mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 21:21:19 +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:
@@ -1022,6 +1022,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- import_unary_operators.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: %C: type = class_type @C [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.bbc: type = pattern_type %C [concrete]
|
||||
@@ -1166,6 +1167,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- import_binary_operators.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: %BinaryC: type = class_type @BinaryC [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.b2b: type = pattern_type %BinaryC [concrete]
|
||||
@@ -1975,6 +1977,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- multiple_calls.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: %BinaryC: type = class_type @BinaryC [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.b2b: type = pattern_type %BinaryC [concrete]
|
||||
@@ -2143,6 +2146,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- fail_todo_rewrite_spaceship.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: %C: type = class_type @C [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.bbc: type = pattern_type %C [concrete]
|
||||
@@ -2313,6 +2317,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- fail_todo_rewrite_equal.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: %EqualC: type = class_type @EqualC [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.4e7: type = pattern_type %EqualC [concrete]
|
||||
@@ -2446,6 +2451,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- import_single_namespace.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: %C: type = class_type @C [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.7cb: type = pattern_type %C [concrete]
|
||||
@@ -2573,6 +2579,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- import_multiple_namespaces.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: %C1: type = class_type @C1 [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.da8: type = pattern_type %C1 [concrete]
|
||||
@@ -2762,6 +2769,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- fail_todo_import_operands_in_namespace_operator_in_global.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: %C: type = class_type @C [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.73b: type = pattern_type %C [concrete]
|
||||
@@ -2868,6 +2876,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- import_inner_class.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: %O: type = class_type @O [concrete]
|
||||
// CHECK:STDOUT: %C: type = class_type @C [concrete]
|
||||
@@ -2993,6 +3002,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- import_inner_class_in_namespace.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: %O: type = class_type @O [concrete]
|
||||
// CHECK:STDOUT: %C: type = class_type @C [concrete]
|
||||
@@ -3127,6 +3137,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- import_member_add_with.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: %MemberClass: type = class_type @MemberClass [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.809: type = pattern_type %MemberClass [concrete]
|
||||
@@ -3255,6 +3266,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- indirect_template_instantiation.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %TemplateB: type = class_type @TemplateB [concrete]
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
|
||||
@@ -3286,6 +3298,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- import_overloading.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: %C: type = class_type @C [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.bbc: type = pattern_type %C [concrete]
|
||||
|
||||
Reference in New Issue
Block a user