mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Make SemIR::TypeType be an empty FacetType instruction (#7813)
The type `type` is now a `FacetType` inst with no constraints. This brings the model implemented in the toolchain into better alignment with the language design. The `SemIR::TypeType` struct remains as a scope for holding the `TypeInstId`, `ConstantId`, and `TypeId` constants, but is not an `InstKind` anymore. The `TypeType` inst looks a lot like singletons, but there are many `FacetType` insts so it doesn't quite fit that model. So we put it alongside singletons with a fixed inst id but refer to it as a more general "builtin" inst that is not a singleton. `Namespace::PackageInstId` is similar, and we group it with `TypeType` conceptually as another builtin instruction with a fixed id. No conversion is needed anymore to use a `type` as a facet, since types also have a `FacetType` type. This simplifies and removes a number of helpers and branches throughout the code. The `TypeType` inst is now part of the constant store, so we end up printing it in the constants block in every test. But it's also named `type` rather than `%type` to preserve the majority of existing formatting behaviour, though this does look different from other constants. Assisted-by: Opus 5 was used to generate a first draft and validate the refactoring. Though nearly everything non-trivial the tool wrote has been modified or rewritten.
This commit is contained in:
@@ -32,6 +32,7 @@ fn F(c: C) -> i32 {
|
||||
// CHECK:STDOUT: --- instance_method.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %C: type = class_type @C [concrete]
|
||||
// CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
|
||||
// CHECK:STDOUT: %Self: %I.type = symbolic_binding Self, 0 [symbolic]
|
||||
@@ -67,10 +68,8 @@ fn F(c: C) -> i32 {
|
||||
// CHECK:STDOUT: %c.patt: %pattern_type.98b = wrapper_binding_pattern c, %c.param_patt [concrete]
|
||||
// CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
|
||||
// CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %C.type.facet: %type = facet_value %C, () [concrete]
|
||||
// CHECK:STDOUT: %I.WithSelf.F.type.b04: type = fn_type @I.WithSelf.F, @I.WithSelf(%C.type.facet) [concrete]
|
||||
// CHECK:STDOUT: %I.WithSelf.F.cef: %I.WithSelf.F.type.b04 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %I.WithSelf.F.type.a90: type = fn_type @I.WithSelf.F, @I.WithSelf(%C) [concrete]
|
||||
// CHECK:STDOUT: %I.WithSelf.F.040: %I.WithSelf.F.type.a90 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %.a89: type = fn_type_with_self_type %I.WithSelf.F.type.372, %I.facet [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
@@ -235,10 +234,10 @@ fn F(c: C) -> i32 {
|
||||
// CHECK:STDOUT: %self.patt.loc18_8.2 => constants.%self.patt.36a
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: specific @I.WithSelf(constants.%C.type.facet) {
|
||||
// CHECK:STDOUT: specific @I.WithSelf(constants.%C) {
|
||||
// CHECK:STDOUT: !definition:
|
||||
// CHECK:STDOUT: %Self => constants.%C.type.facet
|
||||
// CHECK:STDOUT: %I.WithSelf.F.type => constants.%I.WithSelf.F.type.b04
|
||||
// CHECK:STDOUT: %I.WithSelf.F => constants.%I.WithSelf.F.cef
|
||||
// CHECK:STDOUT: %Self => constants.%C
|
||||
// CHECK:STDOUT: %I.WithSelf.F.type => constants.%I.WithSelf.F.type.a90
|
||||
// CHECK:STDOUT: %I.WithSelf.F => constants.%I.WithSelf.F.040
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
|
||||
Reference in New Issue
Block a user