mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-21 23:26:39 +00: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:
1 parent
83ca5b71e3
commit
fcae9610bd
795 files changed
+9505
-8048
No files matched your search
+20
-19
@@ -88,6 +88,7 @@ var g: E({.a = 1, .b = 2}) = {} as E({.a = 3, .b = 4} as D);
|
||||
// CHECK:STDOUT: --- fail_empty_params.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %NoParams: type = class_type @NoParams [concrete]
|
||||
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
|
||||
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
|
||||
@@ -191,15 +192,15 @@ var g: E({.a = 1, .b = 2}) = {} as E({.a = 3, .b = 4} as D);
|
||||
// CHECK:STDOUT: --- fail_nested.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %.Self.frozen: %type = symbolic_binding .Self [symbolic_self]
|
||||
// CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete]
|
||||
// CHECK:STDOUT: %T.patt.d47: %pattern_type.98f = symbolic_binding_pattern T, 0 [symbolic]
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %.Self.frozen: type = symbolic_binding .Self [symbolic_self]
|
||||
// CHECK:STDOUT: %pattern_type.9a5: type = pattern_type type [concrete]
|
||||
// CHECK:STDOUT: %T.patt.3a0: %pattern_type.9a5 = symbolic_binding_pattern T, 0 [symbolic]
|
||||
// CHECK:STDOUT: %T.67d: type = symbolic_binding T, 0 [symbolic]
|
||||
// CHECK:STDOUT: %Outer.type: type = generic_class_type @Outer [concrete]
|
||||
// CHECK:STDOUT: %Outer.generic: %Outer.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %Outer.dee: type = class_type @Outer, @Outer(%T.67d) [symbolic]
|
||||
// CHECK:STDOUT: %U.patt: %pattern_type.98f = symbolic_binding_pattern U, 1 [symbolic]
|
||||
// CHECK:STDOUT: %U.patt: %pattern_type.9a5 = symbolic_binding_pattern U, 1 [symbolic]
|
||||
// CHECK:STDOUT: %U: type = symbolic_binding U, 1 [symbolic]
|
||||
// CHECK:STDOUT: %Inner.type.8f7: type = generic_class_type @Inner, @Outer(%T.67d) [symbolic]
|
||||
// CHECK:STDOUT: %Inner.generic.b3a: %Inner.type.8f7 = struct_value () [symbolic]
|
||||
@@ -260,10 +261,10 @@ var g: E({.a = 1, .b = 2}) = {} as E({.a = 3, .b = 4} as D);
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core.import = import Core
|
||||
// CHECK:STDOUT: %Outer.decl: %Outer.type = class_decl @Outer [concrete = constants.%Outer.generic] {
|
||||
// CHECK:STDOUT: %T.patt.loc4_14.1: %pattern_type.98f = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_14.2 (constants.%T.patt.d47)]
|
||||
// CHECK:STDOUT: %T.patt.loc4_14.1: %pattern_type.9a5 = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_14.2 (constants.%T.patt.3a0)]
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %.loc4_16.1: type = splice_block %.loc4_16.2 [concrete = type] {
|
||||
// CHECK:STDOUT: %.Self.frozen: %type = symbolic_binding .Self [symbolic_self = constants.%.Self.frozen]
|
||||
// CHECK:STDOUT: %.Self.frozen: type = symbolic_binding .Self [symbolic_self = constants.%.Self.frozen]
|
||||
// CHECK:STDOUT: %.loc4_16.2: type = type_literal type [concrete = type]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %T.loc4_14.2: type = symbolic_binding T, 0 [symbolic = %T.loc4_14.1 (constants.%T.67d)]
|
||||
@@ -303,7 +304,7 @@ var g: E({.a = 1, .b = 2}) = {} as E({.a = 3, .b = 4} as D);
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: generic class @Outer(%T.loc4_14.2: type) {
|
||||
// CHECK:STDOUT: %T.patt.loc4_14.2: %pattern_type.98f = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_14.2 (constants.%T.patt.d47)]
|
||||
// CHECK:STDOUT: %T.patt.loc4_14.2: %pattern_type.9a5 = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_14.2 (constants.%T.patt.3a0)]
|
||||
// CHECK:STDOUT: %T.loc4_14.1: type = symbolic_binding T, 0 [symbolic = %T.loc4_14.1 (constants.%T.67d)]
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !definition:
|
||||
@@ -312,10 +313,10 @@ var g: E({.a = 1, .b = 2}) = {} as E({.a = 3, .b = 4} as D);
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: class {
|
||||
// CHECK:STDOUT: %Inner.decl: @Outer.%Inner.type (%Inner.type.8f7) = class_decl @Inner [symbolic = @Outer.%Inner.generic (constants.%Inner.generic.b3a)] {
|
||||
// CHECK:STDOUT: %U.patt.loc5_16.1: %pattern_type.98f = symbolic_binding_pattern U, 1 [symbolic = %U.patt.loc5_16.2 (constants.%U.patt)]
|
||||
// CHECK:STDOUT: %U.patt.loc5_16.1: %pattern_type.9a5 = symbolic_binding_pattern U, 1 [symbolic = %U.patt.loc5_16.2 (constants.%U.patt)]
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %.loc5_18.1: type = splice_block %.loc5_18.2 [concrete = type] {
|
||||
// CHECK:STDOUT: %.Self.frozen: %type = symbolic_binding .Self [symbolic_self = constants.%.Self.frozen]
|
||||
// CHECK:STDOUT: %.Self.frozen: type = symbolic_binding .Self [symbolic_self = constants.%.Self.frozen]
|
||||
// CHECK:STDOUT: %.loc5_18.2: type = type_literal type [concrete = type]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %U.loc5_16.2: type = symbolic_binding U, 1 [symbolic = %U.loc5_16.1 (constants.%U)]
|
||||
@@ -330,7 +331,7 @@ var g: E({.a = 1, .b = 2}) = {} as E({.a = 3, .b = 4} as D);
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: generic class @Inner(@Outer.%T.loc4_14.2: type, %U.loc5_16.2: type) {
|
||||
// CHECK:STDOUT: %U.patt.loc5_16.2: %pattern_type.98f = symbolic_binding_pattern U, 1 [symbolic = %U.patt.loc5_16.2 (constants.%U.patt)]
|
||||
// CHECK:STDOUT: %U.patt.loc5_16.2: %pattern_type.9a5 = symbolic_binding_pattern U, 1 [symbolic = %U.patt.loc5_16.2 (constants.%U.patt)]
|
||||
// CHECK:STDOUT: %U.loc5_16.1: type = symbolic_binding U, 1 [symbolic = %U.loc5_16.1 (constants.%U)]
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !definition:
|
||||
@@ -361,7 +362,7 @@ var g: E({.a = 1, .b = 2}) = {} as E({.a = 3, .b = 4} as D);
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: specific @Outer(constants.%T.67d) {
|
||||
// CHECK:STDOUT: %T.patt.loc4_14.2 => constants.%T.patt.d47
|
||||
// CHECK:STDOUT: %T.patt.loc4_14.2 => constants.%T.patt.3a0
|
||||
// CHECK:STDOUT: %T.loc4_14.1 => constants.%T.67d
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
@@ -371,7 +372,7 @@ var g: E({.a = 1, .b = 2}) = {} as E({.a = 3, .b = 4} as D);
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: specific @Outer(constants.%ptr.c28) {
|
||||
// CHECK:STDOUT: %T.patt.loc4_14.2 => constants.%T.patt.d47
|
||||
// CHECK:STDOUT: %T.patt.loc4_14.2 => constants.%T.patt.3a0
|
||||
// CHECK:STDOUT: %T.loc4_14.1 => constants.%ptr.c28
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !definition:
|
||||
@@ -389,8 +390,8 @@ var g: E({.a = 1, .b = 2}) = {} as E({.a = 3, .b = 4} as D);
|
||||
// CHECK:STDOUT: --- fail_int_value.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %.Self.frozen: %type = symbolic_binding .Self [symbolic_self]
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %.Self.frozen: type = symbolic_binding .Self [symbolic_self]
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
||||
// CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
|
||||
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
|
||||
@@ -452,7 +453,7 @@ var g: E({.a = 1, .b = 2}) = {} as E({.a = 3, .b = 4} as D);
|
||||
// CHECK:STDOUT: %N.patt.loc4_10.1: %pattern_type.6b6 = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc4_10.2 (constants.%N.patt.38a)]
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %.loc4: type = splice_block %i32 [concrete = constants.%i32] {
|
||||
// CHECK:STDOUT: %.Self.frozen: %type = symbolic_binding .Self [symbolic_self = constants.%.Self.frozen]
|
||||
// CHECK:STDOUT: %.Self.frozen: type = symbolic_binding .Self [symbolic_self = constants.%.Self.frozen]
|
||||
// CHECK:STDOUT: %i32: type = type_literal constants.%i32 [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %N.loc4_10.2: %i32 = symbolic_binding N, 0 [symbolic = %N.loc4_10.1 (constants.%N.37f)]
|
||||
@@ -515,6 +516,7 @@ var g: E({.a = 1, .b = 2}) = {} as E({.a = 3, .b = 4} as D);
|
||||
// CHECK:STDOUT: --- fail_class_param.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %D: type = class_type @D [concrete]
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
||||
// CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
|
||||
@@ -523,8 +525,7 @@ var g: E({.a = 1, .b = 2}) = {} as E({.a = 3, .b = 4} as D);
|
||||
// CHECK:STDOUT: %D.elem: type = unbound_element_type %D, %i32 [concrete]
|
||||
// CHECK:STDOUT: %struct_type.a.b.b4c: type = struct_type {.a: %i32, .b: %i32} [concrete]
|
||||
// CHECK:STDOUT: %complete_type.7b9: <witness> = complete_type_witness %struct_type.a.b.b4c [concrete]
|
||||
// CHECK:STDOUT: %type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %.Self.frozen: %type = symbolic_binding .Self [symbolic_self]
|
||||
// CHECK:STDOUT: %.Self.frozen: type = symbolic_binding .Self [symbolic_self]
|
||||
// CHECK:STDOUT: %pattern_type.d8d: type = pattern_type %D [concrete]
|
||||
// CHECK:STDOUT: %F.patt: %pattern_type.d8d = symbolic_binding_pattern F, 0 [symbolic]
|
||||
// CHECK:STDOUT: %F: %D = symbolic_binding F, 0 [symbolic]
|
||||
@@ -604,7 +605,7 @@ var g: E({.a = 1, .b = 2}) = {} as E({.a = 3, .b = 4} as D);
|
||||
// CHECK:STDOUT: %F.patt.loc9_10.1: %pattern_type.d8d = symbolic_binding_pattern F, 0 [symbolic = %F.patt.loc9_10.2 (constants.%F.patt)]
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %.loc9: type = splice_block %D.ref [concrete = constants.%D] {
|
||||
// CHECK:STDOUT: %.Self.frozen: %type = symbolic_binding .Self [symbolic_self = constants.%.Self.frozen]
|
||||
// CHECK:STDOUT: %.Self.frozen: type = symbolic_binding .Self [symbolic_self = constants.%.Self.frozen]
|
||||
// CHECK:STDOUT: %D.ref: type = name_ref D, file.%D.decl [concrete = constants.%D]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %F.loc9_10.2: %D = symbolic_binding F, 0 [symbolic = %F.loc9_10.1 (constants.%F)]
|
||||
|
||||
Reference in new issue
Block a user