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:
+12
-12
@@ -74,8 +74,8 @@ fn CallSpecific(x: C*) -> C* {
|
||||
// CHECK:STDOUT: --- explicit.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: %Copy.type: type = facet_type <@Copy> [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.e81: type = pattern_type %Copy.type [concrete]
|
||||
// CHECK:STDOUT: %T.patt.fe6: %pattern_type.e81 = symbolic_binding_pattern T, 0 [symbolic]
|
||||
@@ -97,8 +97,8 @@ fn CallSpecific(x: C*) -> C* {
|
||||
// CHECK:STDOUT: %specific_impl_fn.e2a: <specific function> = specific_impl_function %impl.elem0.bd2, @Copy.WithSelf.Op(%T.f84) [symbolic]
|
||||
// CHECK:STDOUT: %T.67d: type = symbolic_binding T, 0 [symbolic]
|
||||
// CHECK:STDOUT: %ptr.e8f: type = ptr_type %T.67d [symbolic]
|
||||
// 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: %pattern_type.9a5: type = pattern_type type [concrete]
|
||||
// CHECK:STDOUT: %T.patt.3a0: %pattern_type.9a5 = symbolic_binding_pattern T, 0 [symbolic]
|
||||
// CHECK:STDOUT: %require_complete.ef1: <witness> = require_complete_type %ptr.e8f [symbolic]
|
||||
// CHECK:STDOUT: %ptr.as.Copy.impl.Op.type.ff5: type = fn_type @ptr.as.Copy.impl.Op, @ptr.as.Copy.impl(%T.67d) [symbolic]
|
||||
// CHECK:STDOUT: %ptr.as.Copy.impl.Op.ce9: %ptr.as.Copy.impl.Op.type.ff5 = struct_value () [symbolic]
|
||||
@@ -160,7 +160,7 @@ fn CallSpecific(x: C*) -> C* {
|
||||
// CHECK:STDOUT: %.loc5_44.3: type = converted %T.ref.loc5_44, %T.as_type.loc5_44 [symbolic = %T.as_type.loc5_38.1 (constants.%T.as_type)]
|
||||
// CHECK:STDOUT: %.loc5_44.4: Core.Form = init_form %.loc5_44.3 [symbolic = %.loc5_44.2 (constants.%.1ce700.2)]
|
||||
// CHECK:STDOUT: %.loc5_28: type = splice_block %Copy.ref [concrete = constants.%Copy.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: %Core.ref: <namespace> = name_ref Core, imports.%Core [concrete = imports.%Core]
|
||||
// CHECK:STDOUT: %Copy.ref: type = name_ref Copy, imports.%Core.Copy [concrete = constants.%Copy.type]
|
||||
// CHECK:STDOUT: }
|
||||
@@ -310,7 +310,7 @@ fn CallSpecific(x: C*) -> C* {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: specific @CallGenericPtr(constants.%T.67d) {
|
||||
// CHECK:STDOUT: %T.patt.loc16_28.2 => constants.%T.patt.d47
|
||||
// CHECK:STDOUT: %T.patt.loc16_28.2 => constants.%T.patt.3a0
|
||||
// CHECK:STDOUT: %T.loc16_28.1 => constants.%T.67d
|
||||
// CHECK:STDOUT: %ptr.loc16_40.1 => constants.%ptr.e8f
|
||||
// CHECK:STDOUT: %pattern_type => constants.%pattern_type.4f4
|
||||
@@ -364,8 +364,8 @@ fn CallSpecific(x: C*) -> C* {
|
||||
// CHECK:STDOUT: --- deduced.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: %Copy.type: type = facet_type <@Copy> [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.e81: type = pattern_type %Copy.type [concrete]
|
||||
// CHECK:STDOUT: %T.patt.fe6: %pattern_type.e81 = symbolic_binding_pattern T, 0 [symbolic]
|
||||
@@ -387,8 +387,8 @@ fn CallSpecific(x: C*) -> C* {
|
||||
// CHECK:STDOUT: %specific_impl_fn.e2a: <specific function> = specific_impl_function %impl.elem0.bd2, @Copy.WithSelf.Op(%T.f84) [symbolic]
|
||||
// CHECK:STDOUT: %T.67d: type = symbolic_binding T, 0 [symbolic]
|
||||
// CHECK:STDOUT: %ptr.e8f: type = ptr_type %T.67d [symbolic]
|
||||
// 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: %pattern_type.9a5: type = pattern_type type [concrete]
|
||||
// CHECK:STDOUT: %T.patt.3a0: %pattern_type.9a5 = symbolic_binding_pattern T, 0 [symbolic]
|
||||
// CHECK:STDOUT: %require_complete.ef1: <witness> = require_complete_type %ptr.e8f [symbolic]
|
||||
// CHECK:STDOUT: %ptr.as.Copy.impl.Op.type.ff5: type = fn_type @ptr.as.Copy.impl.Op, @ptr.as.Copy.impl(%T.67d) [symbolic]
|
||||
// CHECK:STDOUT: %ptr.as.Copy.impl.Op.ce9: %ptr.as.Copy.impl.Op.type.ff5 = struct_value () [symbolic]
|
||||
@@ -450,7 +450,7 @@ fn CallSpecific(x: C*) -> C* {
|
||||
// CHECK:STDOUT: %.loc5_36.3: type = converted %T.ref.loc5_36, %T.as_type.loc5_36 [symbolic = %T.as_type.loc5_30.1 (constants.%T.as_type)]
|
||||
// CHECK:STDOUT: %.loc5_36.4: Core.Form = init_form %.loc5_36.3 [symbolic = %.loc5_36.2 (constants.%.1ce700.2)]
|
||||
// CHECK:STDOUT: %.loc5_20: type = splice_block %Copy.ref [concrete = constants.%Copy.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: %Core.ref: <namespace> = name_ref Core, imports.%Core [concrete = imports.%Core]
|
||||
// CHECK:STDOUT: %Copy.ref: type = name_ref Copy, imports.%Core.Copy [concrete = constants.%Copy.type]
|
||||
// CHECK:STDOUT: }
|
||||
@@ -591,7 +591,7 @@ fn CallSpecific(x: C*) -> C* {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: specific @CallGenericPtr(constants.%T.67d) {
|
||||
// CHECK:STDOUT: %T.patt.loc16_28.2 => constants.%T.patt.d47
|
||||
// CHECK:STDOUT: %T.patt.loc16_28.2 => constants.%T.patt.3a0
|
||||
// CHECK:STDOUT: %T.loc16_28.1 => constants.%T.67d
|
||||
// CHECK:STDOUT: %ptr.loc16_40.1 => constants.%ptr.e8f
|
||||
// CHECK:STDOUT: %pattern_type => constants.%pattern_type.4f4
|
||||
|
||||
Reference in New Issue
Block a user