mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 14:11:04 +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:
@@ -138,7 +138,7 @@ fn M() {
|
||||
// CHECK:STDOUT: %H.call.loc29 = call i32 @_CH.Main.4d6ceefeb7f772f4(i32 %x), !dbg !94
|
||||
// CHECK:STDOUT: store i32 %H.call.loc29, ptr %.loc29_6.3.temp, align 4, !dbg !94
|
||||
// CHECK:STDOUT: call void @"_COp.f58524831c37807e:core.Destroy.Core"(ptr %.loc29_6.3.temp), !dbg !94
|
||||
// CHECK:STDOUT: %H.call.loc30 = call %type.26 @_CH.Main.71d6c598da8ca542(%type.26 zeroinitializer), !dbg !95
|
||||
// CHECK:STDOUT: %H.call.loc30 = call %type.26 @_CH.Main.c3359c2c217ad593(%type.26 zeroinitializer), !dbg !95
|
||||
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc31_8.3.temp), !dbg !97
|
||||
// CHECK:STDOUT: %G.call = call i32 @_CG.Main.89a3e87df6fdafe1(i32 %x), !dbg !97
|
||||
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc31_9.3.temp), !dbg !98
|
||||
@@ -195,7 +195,7 @@ fn M() {
|
||||
// CHECK:STDOUT: %H.call.loc29 = call double @_CH.Main.c5e4ba542a56b71f(double %x), !dbg !133
|
||||
// CHECK:STDOUT: store double %H.call.loc29, ptr %.loc29_6.3.temp, align 8, !dbg !133
|
||||
// CHECK:STDOUT: call void @"_COp.dc14d4dd21801791:core.Destroy.Core"(ptr %.loc29_6.3.temp), !dbg !133
|
||||
// CHECK:STDOUT: %H.call.loc30 = call %type.26 @_CH.Main.71d6c598da8ca542(%type.26 zeroinitializer), !dbg !134
|
||||
// CHECK:STDOUT: %H.call.loc30 = call %type.26 @_CH.Main.c3359c2c217ad593(%type.26 zeroinitializer), !dbg !134
|
||||
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc31_8.3.temp), !dbg !136
|
||||
// CHECK:STDOUT: %G.call = call double @_CG.Main.38241ddc2cd9d74d(double %x), !dbg !136
|
||||
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc31_9.3.temp), !dbg !137
|
||||
@@ -237,7 +237,7 @@ fn M() {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define linkonce_odr %type.26 @_CH.Main.71d6c598da8ca542(%type.26 %x) #0 !dbg !169 {
|
||||
// CHECK:STDOUT: define linkonce_odr %type.26 @_CH.Main.c3359c2c217ad593(%type.26 %x) #0 !dbg !169 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: ret %type.26 %x, !dbg !175
|
||||
// CHECK:STDOUT: }
|
||||
@@ -264,7 +264,7 @@ fn M() {
|
||||
// CHECK:STDOUT: ; uselistorder directives
|
||||
// CHECK:STDOUT: uselistorder ptr @llvm.lifetime.start.p0, { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 18 }
|
||||
// CHECK:STDOUT: uselistorder ptr @_CH.Main.4d6ceefeb7f772f4, { 1, 0 }
|
||||
// CHECK:STDOUT: uselistorder ptr @_CH.Main.71d6c598da8ca542, { 1, 0 }
|
||||
// CHECK:STDOUT: uselistorder ptr @_CH.Main.c3359c2c217ad593, { 1, 0 }
|
||||
// CHECK:STDOUT: uselistorder ptr @_CH.Main.c5e4ba542a56b71f, { 3, 2, 1, 0 }
|
||||
// CHECK:STDOUT: uselistorder ptr @_CH.Main.a76b78461416b4a8, { 5, 2, 0, 4, 3, 1 }
|
||||
// CHECK:STDOUT: uselistorder ptr @_CH.Main.42513763e01cba2c, { 1, 0 }
|
||||
@@ -375,7 +375,7 @@ fn M() {
|
||||
// CHECK:STDOUT: !162 = !DILocalVariable(arg: 1, scope: !161, type: !34)
|
||||
// CHECK:STDOUT: !167 = !DILocation(line: 23, column: 3, scope: !161)
|
||||
// CHECK:STDOUT: !168 = !{!162}
|
||||
// CHECK:STDOUT: !169 = distinct !DISubprogram(name: "H", linkageName: "_CH.Main.71d6c598da8ca542", scope: null, file: !32, line: 22, type: !37, spFlags: DISPFlagDefinition, unit: !33, retainedNodes: !176)
|
||||
// CHECK:STDOUT: !169 = distinct !DISubprogram(name: "H", linkageName: "_CH.Main.c3359c2c217ad593", scope: null, file: !32, line: 22, type: !37, spFlags: DISPFlagDefinition, unit: !33, retainedNodes: !176)
|
||||
// CHECK:STDOUT: !170 = !DILocalVariable(arg: 1, scope: !169, type: !35)
|
||||
// CHECK:STDOUT: !175 = !DILocation(line: 23, column: 3, scope: !169)
|
||||
// CHECK:STDOUT: !176 = !{!170}
|
||||
|
||||
Reference in New Issue
Block a user