Remove the builtin IR, and instead define builtin types locally. (#3910)

We don't need it any more, and removing it simplifies a few things:

- One fewer predefined `File` and reserved ID.
- We now have simply `Builtin` instructions for builtins, instead of
having an `ImportRef` that indirectly references a `Builtin`.
- `ConstantId`s now always refer directly to a local constant, instead
of sometimes referring to an `ImportRef` for a constant in the builtins
IR.

---------

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
This commit is contained in:
Richard Smith
2024-04-24 18:32:59 +00:00
committed by GitHub
co-authored by Jon Ross-Perkins
parent 1349cc1e8e
commit 62fe0cd385
79 changed files with 600 additions and 671 deletions
@@ -96,10 +96,10 @@ var arr: [i32; 1 + 2] = (3, 4, 3 + 4);
// CHECK:STDOUT: .arr = %arr
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
// CHECK:STDOUT: %import_ref.1: type = import_ref ir3, inst+1, loc_9 [template = constants.%.1]
// CHECK:STDOUT: %import_ref.2: <associated <function> in Add> = import_ref ir3, inst+21, loc_36 [template = constants.%.6]
// CHECK:STDOUT: %import_ref.3 = import_ref ir3, inst+3, unloaded
// CHECK:STDOUT: %import_ref.4: <function> = import_ref ir3, inst+19, loc_10 [template = imports.%Op]
// CHECK:STDOUT: %import_ref.1: type = import_ref ir2, inst+1, loc_9 [template = constants.%.1]
// CHECK:STDOUT: %import_ref.2: <associated <function> in Add> = import_ref ir2, inst+21, loc_36 [template = constants.%.6]
// CHECK:STDOUT: %import_ref.3 = import_ref ir2, inst+3, unloaded
// CHECK:STDOUT: %import_ref.4: <function> = import_ref ir2, inst+19, loc_10 [template = imports.%Op]
// CHECK:STDOUT: impl_decl @impl {
// CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, %Core [template = %Core]
// CHECK:STDOUT: %Add.decl: type = interface_decl @Add [template = constants.%.1] {}
@@ -107,15 +107,15 @@ var arr: [i32; 1 + 2] = (3, 4, 3 + 4);
// CHECK:STDOUT: }
// CHECK:STDOUT: %.loc10_16: i32 = int_literal 1 [template = constants.%.3]
// CHECK:STDOUT: %.loc10_20: i32 = int_literal 2 [template = constants.%.4]
// CHECK:STDOUT: %import_ref.5: type = import_ref ir3, inst+1, loc_36 [template = constants.%.1]
// CHECK:STDOUT: %import_ref.6 = import_ref ir3, inst+19, unloaded
// CHECK:STDOUT: %import_ref.5: type = import_ref ir2, inst+1, loc_36 [template = constants.%.1]
// CHECK:STDOUT: %import_ref.6 = import_ref ir2, inst+19, unloaded
// CHECK:STDOUT: %.1: <function> = interface_witness_access @impl.%.1, element0 [template = @impl.%Op]
// CHECK:STDOUT: %.loc10_18: <bound method> = bound_method %.loc10_16, %.1 [template = constants.%.7]
// CHECK:STDOUT: %int.sadd: init i32 = call %.loc10_18(%.loc10_16, %.loc10_20) [template = constants.%.8]
// CHECK:STDOUT: %.loc10_21: type = array_type %int.sadd, i32 [template = constants.%.9]
// CHECK:STDOUT: %arr.var: ref [i32; 3] = var arr
// CHECK:STDOUT: %arr: ref [i32; 3] = bind_name arr, %arr.var
// CHECK:STDOUT: %import_ref.7: type = import_ref ir3, inst+1, loc_47 [template = constants.%.1]
// CHECK:STDOUT: %import_ref.7: type = import_ref ir2, inst+1, loc_47 [template = constants.%.1]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: interface @Add {
+1 -1
View File
@@ -55,7 +55,7 @@ var arr: [i32; Core.Add(1, 2)] = (1, 2, 3);
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
// CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, %Core [template = %Core]
// CHECK:STDOUT: %import_ref: <function> = import_ref ir3, inst+6, loc_11 [template = imports.%Add]
// CHECK:STDOUT: %import_ref: <function> = import_ref ir2, inst+6, loc_11 [template = imports.%Add]
// CHECK:STDOUT: %Add.ref: <function> = name_ref Add, %import_ref [template = imports.%Add]
// CHECK:STDOUT: %.loc4_25: i32 = int_literal 1 [template = constants.%.1]
// CHECK:STDOUT: %.loc4_28: i32 = int_literal 2 [template = constants.%.2]