mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Model Core.Int as a class type (#4644)
Instead of treating `Core.Int` as the toolchain's builtin `IntType`, model it as a class that adapts the builtin type. This aligns us better with the intended language model, gives an associated library for `impl`s involving `Core.Int` to live within, and opens the door adding member functions to `Core.Int` if we decide that is desirable. Remarkably it also seems to make the formatted SemIR a little smaller, because a call to a generic class generates less IR than a call to a function.
This commit is contained in:
+8
-8
@@ -42,20 +42,20 @@ class A {
|
||||
// CHECK:STDOUT: define i32 @_CAccess.A.Main(ptr %self) !dbg !10 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %.loc19_16.1.v = getelementptr inbounds nuw { [2 x i32] }, ptr %self, i32 0, i32 0, !dbg !11
|
||||
// CHECK:STDOUT: %.loc19_20.4.array.index = getelementptr inbounds [2 x i32], ptr %.loc19_16.1.v, i32 0, i32 0, !dbg !11
|
||||
// CHECK:STDOUT: %.loc19_20.5 = load i32, ptr %.loc19_20.4.array.index, align 4, !dbg !11
|
||||
// CHECK:STDOUT: ret i32 %.loc19_20.5, !dbg !12
|
||||
// CHECK:STDOUT: %.loc19_20.2.array.index = getelementptr inbounds [2 x i32], ptr %.loc19_16.1.v, i32 0, i32 0, !dbg !11
|
||||
// CHECK:STDOUT: %.loc19_20.3 = load i32, ptr %.loc19_20.2.array.index, align 4, !dbg !11
|
||||
// CHECK:STDOUT: ret i32 %.loc19_20.3, !dbg !12
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: define i32 @_CUse.A.Main(ptr %self) !dbg !13 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %.loc23_9.2.v = getelementptr inbounds nuw { [2 x i32] }, ptr %self, i32 0, i32 0, !dbg !14
|
||||
// CHECK:STDOUT: %.loc23_14.3.array.index = getelementptr inbounds [2 x i32], ptr %.loc23_9.2.v, i32 0, i32 0, !dbg !14
|
||||
// CHECK:STDOUT: store i32 1, ptr %.loc23_14.3.array.index, align 4, !dbg !14
|
||||
// CHECK:STDOUT: %.loc23_14.array.index = getelementptr inbounds [2 x i32], ptr %.loc23_9.2.v, i32 0, i32 0, !dbg !14
|
||||
// CHECK:STDOUT: store i32 1, ptr %.loc23_14.array.index, align 4, !dbg !14
|
||||
// CHECK:STDOUT: %.loc24_16.2.v = getelementptr inbounds nuw { [2 x i32] }, ptr %self, i32 0, i32 0, !dbg !15
|
||||
// CHECK:STDOUT: %.loc24_21.3.array.index = getelementptr inbounds [2 x i32], ptr %.loc24_16.2.v, i32 0, i32 1, !dbg !15
|
||||
// CHECK:STDOUT: %.loc24_21.4 = load i32, ptr %.loc24_21.3.array.index, align 4, !dbg !15
|
||||
// CHECK:STDOUT: ret i32 %.loc24_21.4, !dbg !16
|
||||
// CHECK:STDOUT: %.loc24_21.1.array.index = getelementptr inbounds [2 x i32], ptr %.loc24_16.2.v, i32 0, i32 1, !dbg !15
|
||||
// CHECK:STDOUT: %.loc24_21.2 = load i32, ptr %.loc24_21.1.array.index, align 4, !dbg !15
|
||||
// CHECK:STDOUT: ret i32 %.loc24_21.2, !dbg !16
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
|
||||
|
||||
+3
-3
@@ -23,9 +23,9 @@ fn G() -> i32 {
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: define i32 @_CF.Main(ptr %arr, i32 %i) !dbg !4 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %.loc12_15.4.array.index = getelementptr inbounds [3 x i32], ptr %arr, i32 0, i32 %i, !dbg !7
|
||||
// CHECK:STDOUT: %.loc12_15.5 = load i32, ptr %.loc12_15.4.array.index, align 4, !dbg !7
|
||||
// CHECK:STDOUT: ret i32 %.loc12_15.5, !dbg !8
|
||||
// CHECK:STDOUT: %.loc12_15.2.array.index = getelementptr inbounds [3 x i32], ptr %arr, i32 0, i32 %i, !dbg !7
|
||||
// CHECK:STDOUT: %.loc12_15.3 = load i32, ptr %.loc12_15.2.array.index, align 4, !dbg !7
|
||||
// CHECK:STDOUT: ret i32 %.loc12_15.3, !dbg !8
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: define i32 @_CG.Main() !dbg !9 {
|
||||
|
||||
Reference in New Issue
Block a user