mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 19:11:09 +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:
@@ -992,6 +992,7 @@ let _: C(1) = {} as C(Cpp.COUNT);
|
||||
// CHECK:STDOUT: --- import_integer_literal_replacement_token.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.6b6: type = pattern_type %i32 [concrete]
|
||||
@@ -1082,6 +1083,7 @@ let _: C(1) = {} as C(Cpp.COUNT);
|
||||
// CHECK:STDOUT: --- import_macro_and_non_macro_same_name.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
||||
// CHECK:STDOUT: %N: Core.IntLiteral = symbolic_binding N, 0 [symbolic]
|
||||
@@ -1218,6 +1220,7 @@ let _: C(1) = {} as C(Cpp.COUNT);
|
||||
// CHECK:STDOUT: --- import_unary_operator.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.6b6: type = pattern_type %i32 [concrete]
|
||||
@@ -1248,6 +1251,7 @@ let _: C(1) = {} as C(Cpp.COUNT);
|
||||
// CHECK:STDOUT: --- import_binary_operator.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.6b6: type = pattern_type %i32 [concrete]
|
||||
@@ -1278,6 +1282,7 @@ let _: C(1) = {} as C(Cpp.COUNT);
|
||||
// CHECK:STDOUT: --- import_casting.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
||||
// CHECK:STDOUT: %u32: type = class_type @UInt, @UInt(%int_32) [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.668: type = pattern_type %u32 [concrete]
|
||||
@@ -1343,6 +1348,7 @@ let _: C(1) = {} as C(Cpp.COUNT);
|
||||
// CHECK:STDOUT: --- import_nested_macros.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.6b6: type = pattern_type %i32 [concrete]
|
||||
@@ -1373,6 +1379,7 @@ let _: C(1) = {} as C(Cpp.COUNT);
|
||||
// CHECK:STDOUT: --- import_string_literal_object_like_macro.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %str.3d4: type = class_type @String [concrete]
|
||||
// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete]
|
||||
// CHECK:STDOUT: %i64: type = class_type @Int, @Int(%int_64) [concrete]
|
||||
@@ -1484,6 +1491,7 @@ let _: C(1) = {} as C(Cpp.COUNT);
|
||||
// CHECK:STDOUT: --- import_floating_point_literal_macro.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete]
|
||||
// CHECK:STDOUT: %f64.dc1: type = class_type @Float, @Float(%int_64) [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.fb7: type = pattern_type %f64.dc1 [concrete]
|
||||
@@ -1539,6 +1547,7 @@ let _: C(1) = {} as C(Cpp.COUNT);
|
||||
// CHECK:STDOUT: --- import_character_literals.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %char: type = class_type @Char [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.2ff: type = pattern_type %char [concrete]
|
||||
// CHECK:STDOUT: %a.patt: %pattern_type.2ff = value_binding_pattern a [concrete]
|
||||
@@ -1623,6 +1632,7 @@ let _: C(1) = {} as C(Cpp.COUNT);
|
||||
// CHECK:STDOUT: --- import_character_literals_operators.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %char: type = class_type @Char [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.2ff: type = pattern_type %char [concrete]
|
||||
// CHECK:STDOUT: %a.patt: %pattern_type.2ff = value_binding_pattern a [concrete]
|
||||
@@ -1677,6 +1687,7 @@ let _: C(1) = {} as C(Cpp.COUNT);
|
||||
// CHECK:STDOUT: --- import_boolean_literal_macro.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.831: type = pattern_type bool [concrete]
|
||||
// CHECK:STDOUT: %a.patt: %pattern_type.831 = value_binding_pattern a [concrete]
|
||||
// CHECK:STDOUT: %true: bool = bool_literal true [concrete]
|
||||
@@ -1802,6 +1813,7 @@ let _: C(1) = {} as C(Cpp.COUNT);
|
||||
// CHECK:STDOUT: --- nullptr.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
|
||||
// CHECK:STDOUT: %foo.cpp_overload_set.type: type = cpp_overload_set_type @foo.cpp_overload_set [concrete]
|
||||
// CHECK:STDOUT: %foo.cpp_overload_set.value: %foo.cpp_overload_set.type = cpp_overload_set_value @foo.cpp_overload_set [concrete]
|
||||
@@ -1916,6 +1928,7 @@ let _: C(1) = {} as C(Cpp.COUNT);
|
||||
// CHECK:STDOUT: --- enums.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %A: type = class_type @A [concrete]
|
||||
// CHECK:STDOUT: %pattern_type: type = pattern_type %A [concrete]
|
||||
// CHECK:STDOUT: %a.patt: %pattern_type = value_binding_pattern a [concrete]
|
||||
@@ -1949,6 +1962,7 @@ let _: C(1) = {} as C(Cpp.COUNT);
|
||||
// CHECK:STDOUT: --- constexpr_int.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.6b6: type = pattern_type %i32 [concrete]
|
||||
@@ -1991,6 +2005,7 @@ let _: C(1) = {} as C(Cpp.COUNT);
|
||||
// CHECK:STDOUT: --- constexpr_int_addr.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
|
||||
// CHECK:STDOUT: %const: type = const_type %i32 [concrete]
|
||||
@@ -2037,6 +2052,7 @@ let _: C(1) = {} as C(Cpp.COUNT);
|
||||
// CHECK:STDOUT: --- lambda.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.6b6: type = pattern_type %i32 [concrete]
|
||||
@@ -2067,6 +2083,7 @@ let _: C(1) = {} as C(Cpp.COUNT);
|
||||
// CHECK:STDOUT: --- import_macro_redefined.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.6b6: type = pattern_type %i32 [concrete]
|
||||
@@ -2097,6 +2114,7 @@ let _: C(1) = {} as C(Cpp.COUNT);
|
||||
// CHECK:STDOUT: --- import_macro_defined_twice.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.6b6: type = pattern_type %i32 [concrete]
|
||||
@@ -2127,6 +2145,7 @@ let _: C(1) = {} as C(Cpp.COUNT);
|
||||
// CHECK:STDOUT: --- assign.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.6b6: type = pattern_type %i32 [concrete]
|
||||
@@ -2180,6 +2199,7 @@ let _: C(1) = {} as C(Cpp.COUNT);
|
||||
// CHECK:STDOUT: --- assign_subobject.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
|
||||
// CHECK:STDOUT: %SubA: type = class_type @SubA [concrete]
|
||||
|
||||
Reference in New Issue
Block a user