mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 10:54:49 +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:
@@ -67,6 +67,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- fail_extend_impl_file_scope.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
|
||||
// CHECK:STDOUT: %Self: %I.type = symbolic_binding Self, 0 [symbolic]
|
||||
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
|
||||
@@ -122,6 +123,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- fail_extend_impl_function_scope.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %J.type: type = facet_type <@J> [concrete]
|
||||
// CHECK:STDOUT: %Self: %J.type = symbolic_binding Self, 0 [symbolic]
|
||||
// CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
|
||||
@@ -186,6 +188,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- fail_extend_impl_self_interface.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %Z.type: type = facet_type <@Z> [concrete]
|
||||
// CHECK:STDOUT: %Self.cb6: %Z.type = symbolic_binding Self, 0 [symbolic]
|
||||
// CHECK:STDOUT: %Z.WithSelf.Zero.type.68b: type = fn_type @Z.WithSelf.Zero, @Z.WithSelf(%Self.cb6) [symbolic]
|
||||
@@ -210,10 +213,8 @@ fn F() {
|
||||
// CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %Point.val: %Point = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %.e6b: ref %Point = temporary invalid, %Point.val [concrete]
|
||||
// CHECK:STDOUT: %type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %Point.type.facet: %type = facet_value %Point, () [concrete]
|
||||
// CHECK:STDOUT: %Z.WithSelf.Zero.type.356: type = fn_type @Z.WithSelf.Zero, @Z.WithSelf(%Point.type.facet) [concrete]
|
||||
// CHECK:STDOUT: %Z.WithSelf.Zero.237: %Z.WithSelf.Zero.type.356 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %Z.WithSelf.Zero.type.7b8: type = fn_type @Z.WithSelf.Zero, @Z.WithSelf(%Point) [concrete]
|
||||
// CHECK:STDOUT: %Z.WithSelf.Zero.3cb: %Z.WithSelf.Zero.type.7b8 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %.dfa: type = fn_type_with_self_type %Z.WithSelf.Zero.type.896, %Z.facet [concrete]
|
||||
// CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
|
||||
// CHECK:STDOUT: %Destroy.WithSelf.Op.type.ef016f.2: type = fn_type @Destroy.WithSelf.Op.loc25_7.2 [concrete]
|
||||
@@ -375,10 +376,10 @@ fn F() {
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: specific @Z.WithSelf.Zero(constants.%Z.facet) {}
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: specific @Z.WithSelf(constants.%Point.type.facet) {
|
||||
// CHECK:STDOUT: specific @Z.WithSelf(constants.%Point) {
|
||||
// CHECK:STDOUT: !definition:
|
||||
// CHECK:STDOUT: %Self => constants.%Point.type.facet
|
||||
// CHECK:STDOUT: %Z.WithSelf.Zero.type => constants.%Z.WithSelf.Zero.type.356
|
||||
// CHECK:STDOUT: %Z.WithSelf.Zero => constants.%Z.WithSelf.Zero.237
|
||||
// CHECK:STDOUT: %Self => constants.%Point
|
||||
// CHECK:STDOUT: %Z.WithSelf.Zero.type => constants.%Z.WithSelf.Zero.type.7b8
|
||||
// CHECK:STDOUT: %Z.WithSelf.Zero => constants.%Z.WithSelf.Zero.3cb
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
|
||||
Reference in New Issue
Block a user