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
+19 -19
View File
@@ -163,34 +163,34 @@ var f: ForwardDeclared* = &f_ref.f;
// CHECK:STDOUT: .UseForwardDeclaredF = %UseForwardDeclaredF
// CHECK:STDOUT: .f = %f.loc16
// CHECK:STDOUT: }
// CHECK:STDOUT: %import_ref.1: type = import_ref ir2, inst+2, loc_13 [template = constants.%.1]
// CHECK:STDOUT: %import_ref.2: type = import_ref ir2, inst+6, loc_22 [template = constants.%.3]
// CHECK:STDOUT: %import_ref.3: type = import_ref ir2, inst+18, loc_31 [template = constants.%.4]
// CHECK:STDOUT: %import_ref.4: ref {.f: ForwardDeclared} = import_ref ir2, inst+40, loc_70
// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+2, loc_13 [template = constants.%.1]
// CHECK:STDOUT: %import_ref.2: type = import_ref ir1, inst+6, loc_22 [template = constants.%.3]
// CHECK:STDOUT: %import_ref.3: type = import_ref ir1, inst+18, loc_31 [template = constants.%.4]
// CHECK:STDOUT: %import_ref.4: ref {.f: ForwardDeclared} = import_ref ir1, inst+40, loc_70
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
// CHECK:STDOUT: %import_ref.5 = import_ref ir2, inst+4, unloaded
// CHECK:STDOUT: %import_ref.5 = import_ref ir1, inst+4, unloaded
// CHECK:STDOUT: %UseEmpty: <function> = fn_decl @UseEmpty [template] {
// CHECK:STDOUT: %Empty.decl: type = interface_decl @Empty [template = constants.%.1] {}
// CHECK:STDOUT: %Empty.ref: type = name_ref Empty, %import_ref.1 [template = constants.%.1]
// CHECK:STDOUT: %e.loc6_13.1: Empty = param e
// CHECK:STDOUT: @UseEmpty.%e: Empty = bind_name e, %e.loc6_13.1
// CHECK:STDOUT: }
// CHECK:STDOUT: %import_ref.6 = import_ref ir2, inst+8, unloaded
// CHECK:STDOUT: %import_ref.7: <associated <function> in Basic> = import_ref ir2, inst+16, loc_48 [template = constants.%.8]
// CHECK:STDOUT: %import_ref.8: <associated type in Basic> = import_ref ir2, inst+12, loc_41 [template = constants.%.6]
// CHECK:STDOUT: %import_ref.9 = import_ref ir2, inst+10, unloaded
// CHECK:STDOUT: %import_ref.10 = import_ref ir2, inst+14, unloaded
// CHECK:STDOUT: %import_ref.6 = import_ref ir1, inst+8, unloaded
// CHECK:STDOUT: %import_ref.7: <associated <function> in Basic> = import_ref ir1, inst+16, loc_48 [template = constants.%.8]
// CHECK:STDOUT: %import_ref.8: <associated type in Basic> = import_ref ir1, inst+12, loc_41 [template = constants.%.6]
// CHECK:STDOUT: %import_ref.9 = import_ref ir1, inst+10, unloaded
// CHECK:STDOUT: %import_ref.10 = import_ref ir1, inst+14, unloaded
// CHECK:STDOUT: %UseBasic: <function> = fn_decl @UseBasic [template] {
// CHECK:STDOUT: %Basic.decl: type = interface_decl @Basic [template = constants.%.3] {}
// CHECK:STDOUT: %Basic.ref.loc7: type = name_ref Basic, %import_ref.2 [template = constants.%.3]
// CHECK:STDOUT: %e.loc7_13.1: Basic = param e
// CHECK:STDOUT: @UseBasic.%e: Basic = bind_name e, %e.loc7_13.1
// CHECK:STDOUT: }
// CHECK:STDOUT: %import_ref.11 = import_ref ir2, inst+21, unloaded
// CHECK:STDOUT: %import_ref.12: <associated <function> in ForwardDeclared> = import_ref ir2, inst+29, loc_62 [template = constants.%.12]
// CHECK:STDOUT: %import_ref.13: <associated type in ForwardDeclared> = import_ref ir2, inst+25, loc_55 [template = constants.%.10]
// CHECK:STDOUT: %import_ref.14 = import_ref ir2, inst+23, unloaded
// CHECK:STDOUT: %import_ref.15 = import_ref ir2, inst+27, unloaded
// CHECK:STDOUT: %import_ref.11 = import_ref ir1, inst+21, unloaded
// CHECK:STDOUT: %import_ref.12: <associated <function> in ForwardDeclared> = import_ref ir1, inst+29, loc_62 [template = constants.%.12]
// CHECK:STDOUT: %import_ref.13: <associated type in ForwardDeclared> = import_ref ir1, inst+25, loc_55 [template = constants.%.10]
// CHECK:STDOUT: %import_ref.14 = import_ref ir1, inst+23, unloaded
// CHECK:STDOUT: %import_ref.15 = import_ref ir1, inst+27, unloaded
// CHECK:STDOUT: %UseForwardDeclared: <function> = fn_decl @UseForwardDeclared [template] {
// CHECK:STDOUT: %ForwardDeclared.decl: type = interface_decl @ForwardDeclared [template = constants.%.4] {}
// CHECK:STDOUT: %ForwardDeclared.ref.loc8: type = name_ref ForwardDeclared, %import_ref.3 [template = constants.%.4]
@@ -198,19 +198,19 @@ var f: ForwardDeclared* = &f_ref.f;
// CHECK:STDOUT: @UseForwardDeclared.%f: ForwardDeclared = bind_name f, %f.loc8_23.1
// CHECK:STDOUT: }
// CHECK:STDOUT: %Basic.ref.loc10: type = name_ref Basic, %import_ref.2 [template = constants.%.3]
// CHECK:STDOUT: %import_ref.16 = import_ref ir2, inst+10, unloaded
// CHECK:STDOUT: %import_ref.16 = import_ref ir1, inst+10, unloaded
// CHECK:STDOUT: %T.ref.loc10: <associated type in Basic> = name_ref T, %import_ref.8 [template = constants.%.6]
// CHECK:STDOUT: %UseBasicT: <associated type in Basic> = bind_alias UseBasicT, %import_ref.8 [template = constants.%.6]
// CHECK:STDOUT: %Basic.ref.loc11: type = name_ref Basic, %import_ref.2 [template = constants.%.3]
// CHECK:STDOUT: %import_ref.17 = import_ref ir2, inst+14, unloaded
// CHECK:STDOUT: %import_ref.17 = import_ref ir1, inst+14, unloaded
// CHECK:STDOUT: %F.ref.loc11: <associated <function> in Basic> = name_ref F, %import_ref.7 [template = constants.%.8]
// CHECK:STDOUT: %UseBasicF: <associated <function> in Basic> = bind_alias UseBasicF, %import_ref.7 [template = constants.%.8]
// CHECK:STDOUT: %ForwardDeclared.ref.loc13: type = name_ref ForwardDeclared, %import_ref.3 [template = constants.%.4]
// CHECK:STDOUT: %import_ref.18 = import_ref ir2, inst+23, unloaded
// CHECK:STDOUT: %import_ref.18 = import_ref ir1, inst+23, unloaded
// CHECK:STDOUT: %T.ref.loc13: <associated type in ForwardDeclared> = name_ref T, %import_ref.13 [template = constants.%.10]
// CHECK:STDOUT: %UseForwardDeclaredT: <associated type in ForwardDeclared> = bind_alias UseForwardDeclaredT, %import_ref.13 [template = constants.%.10]
// CHECK:STDOUT: %ForwardDeclared.ref.loc14: type = name_ref ForwardDeclared, %import_ref.3 [template = constants.%.4]
// CHECK:STDOUT: %import_ref.19 = import_ref ir2, inst+27, unloaded
// CHECK:STDOUT: %import_ref.19 = import_ref ir1, inst+27, unloaded
// CHECK:STDOUT: %F.ref.loc14: <associated <function> in ForwardDeclared> = name_ref F, %import_ref.12 [template = constants.%.12]
// CHECK:STDOUT: %UseForwardDeclaredF: <associated <function> in ForwardDeclared> = bind_alias UseForwardDeclaredF, %import_ref.12 [template = constants.%.12]
// CHECK:STDOUT: %ForwardDeclared.ref.loc16: type = name_ref ForwardDeclared, %import_ref.3 [template = constants.%.4]