Use the package/library name in ImportIRId formatting. (#4154)

Also adds import_ir_scope to namespace formatting. I'd done this as an
aid for #4153, and am splitting it out.

---------

Co-authored-by: Geoff Romer <gromer@google.com>
This commit is contained in:
Jon Ross-Perkins
2024-07-22 22:43:36 +00:00
committed by GitHub
co-authored by Geoff Romer
parent 000d6d63ef
commit 07c286e3cb
475 changed files with 8796 additions and 3278 deletions
+13 -5
View File
@@ -28,10 +28,10 @@ var arr: [i32; Add(1, 2)];
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
@@ -41,7 +41,15 @@ var arr: [i32; Add(1, 2)];
// CHECK:STDOUT: .arr = %arr
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: %Core: <namespace> = namespace %Core.import, [template] {}
// CHECK:STDOUT: %Core: <namespace> = namespace %Core.import, [template] {
// CHECK:STDOUT: import Core//prelude
// CHECK:STDOUT: import Core//prelude/operators
// CHECK:STDOUT: import Core//prelude/types
// CHECK:STDOUT: import Core//prelude/operators/arithmetic
// CHECK:STDOUT: import Core//prelude/operators/bitwise
// CHECK:STDOUT: import Core//prelude/operators/comparison
// CHECK:STDOUT: import Core//prelude/types/bool
// CHECK:STDOUT: }
// CHECK:STDOUT: %Add.decl: %Add.type = fn_decl @Add [template = constants.%Add] {
// CHECK:STDOUT: %int.make_type_32.loc11_11: init type = call constants.%Int32() [template = i32]
// CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %int.make_type_32.loc11_11 [template = i32]
+12 -4
View File
@@ -21,9 +21,9 @@ fn Add(a: i32, b: i32) -> i32 = "int.sadd";
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
@@ -32,7 +32,15 @@ fn Add(a: i32, b: i32) -> i32 = "int.sadd";
// CHECK:STDOUT: .Add = %Add.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: %Core: <namespace> = namespace %Core.import, [template] {}
// CHECK:STDOUT: %Core: <namespace> = namespace %Core.import, [template] {
// CHECK:STDOUT: import Core//prelude
// CHECK:STDOUT: import Core//prelude/operators
// CHECK:STDOUT: import Core//prelude/types
// CHECK:STDOUT: import Core//prelude/operators/arithmetic
// CHECK:STDOUT: import Core//prelude/operators/bitwise
// CHECK:STDOUT: import Core//prelude/operators/comparison
// CHECK:STDOUT: import Core//prelude/types/bool
// CHECK:STDOUT: }
// CHECK:STDOUT: %Add.decl: %Add.type = fn_decl @Add [template = constants.%Add] {
// CHECK:STDOUT: %int.make_type_32.loc11_11: init type = call constants.%Int32() [template = i32]
// CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %int.make_type_32.loc11_11 [template = i32]
@@ -52,24 +52,24 @@ fn C(n: i32, m: i32) -> i32 = "int.sadd";
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.9: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.10: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.11: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.12: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.13: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.14: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.15: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.16: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.17: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.18: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.9: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.10: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.11: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.12: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.13: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.14: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.15: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.16: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.17: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.18: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
@@ -80,7 +80,15 @@ fn C(n: i32, m: i32) -> i32 = "int.sadd";
// CHECK:STDOUT: .C = %C.decl.loc31
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: %Core: <namespace> = namespace %Core.import, [template] {}
// CHECK:STDOUT: %Core: <namespace> = namespace %Core.import, [template] {
// CHECK:STDOUT: import Core//prelude
// CHECK:STDOUT: import Core//prelude/operators
// CHECK:STDOUT: import Core//prelude/types
// CHECK:STDOUT: import Core//prelude/operators/arithmetic
// CHECK:STDOUT: import Core//prelude/operators/bitwise
// CHECK:STDOUT: import Core//prelude/operators/comparison
// CHECK:STDOUT: import Core//prelude/types/bool
// CHECK:STDOUT: }
// CHECK:STDOUT: %A.decl.loc11: %A.type = fn_decl @A [template = constants.%A] {
// CHECK:STDOUT: %int.make_type_32.loc11_9: init type = call constants.%Int32() [template = i32]
// CHECK:STDOUT: %.loc11_9.1: type = value_of_initializer %int.make_type_32.loc11_9 [template = i32]
@@ -27,7 +27,15 @@ fn UnknownBuiltin() = "unknown.builtin.name";
// CHECK:STDOUT: .UnknownBuiltin = %UnknownBuiltin.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: %Core: <namespace> = namespace %Core.import, [template] {}
// CHECK:STDOUT: %Core: <namespace> = namespace %Core.import, [template] {
// CHECK:STDOUT: import Core//prelude
// CHECK:STDOUT: import Core//prelude/operators
// CHECK:STDOUT: import Core//prelude/types
// CHECK:STDOUT: import Core//prelude/operators/arithmetic
// CHECK:STDOUT: import Core//prelude/operators/bitwise
// CHECK:STDOUT: import Core//prelude/operators/comparison
// CHECK:STDOUT: import Core//prelude/types/bool
// CHECK:STDOUT: }
// CHECK:STDOUT: %UnknownBuiltin.decl: %UnknownBuiltin.type = fn_decl @UnknownBuiltin [template = constants.%UnknownBuiltin] {}
// CHECK:STDOUT: }
// CHECK:STDOUT:
+14 -6
View File
@@ -42,11 +42,11 @@ var arr: [i32; 1.(I.F)(2)];
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
@@ -56,7 +56,15 @@ var arr: [i32; 1.(I.F)(2)];
// CHECK:STDOUT: .arr = %arr
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: %Core: <namespace> = namespace %Core.import, [template] {}
// CHECK:STDOUT: %Core: <namespace> = namespace %Core.import, [template] {
// CHECK:STDOUT: import Core//prelude
// CHECK:STDOUT: import Core//prelude/operators
// CHECK:STDOUT: import Core//prelude/types
// CHECK:STDOUT: import Core//prelude/operators/arithmetic
// CHECK:STDOUT: import Core//prelude/operators/bitwise
// CHECK:STDOUT: import Core//prelude/operators/comparison
// CHECK:STDOUT: import Core//prelude/types/bool
// CHECK:STDOUT: }
// CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {}
// CHECK:STDOUT: impl_decl @impl {
// CHECK:STDOUT: %int.make_type_32.loc15: init type = call constants.%Int32() [template = i32]
@@ -121,15 +121,15 @@ var arr: [i32; 1 + 2] = (3, 4, 3 + 4);
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir1, inst+2, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.2: type = import_ref ir1, inst+6, loaded [template = constants.%.2]
// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+8, unloaded
// CHECK:STDOUT: %import_ref.4: %.6 = import_ref ir1, inst+28, loaded [template = constants.%.7]
// CHECK:STDOUT: %import_ref.5: %Op.type.2 = import_ref ir1, inst+24, loaded [template = constants.%Op.2]
// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir1, inst+2, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.7: type = import_ref ir1, inst+6, loaded [template = constants.%.2]
// CHECK:STDOUT: %import_ref.8 = import_ref ir1, inst+24, unloaded
// CHECK:STDOUT: %import_ref.9: type = import_ref ir1, inst+6, loaded [template = constants.%.2]
// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//default, inst+2, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.2: type = import_ref Core//default, inst+6, loaded [template = constants.%.2]
// CHECK:STDOUT: %import_ref.3 = import_ref Core//default, inst+8, unloaded
// CHECK:STDOUT: %import_ref.4: %.6 = import_ref Core//default, inst+28, loaded [template = constants.%.7]
// CHECK:STDOUT: %import_ref.5: %Op.type.2 = import_ref Core//default, inst+24, loaded [template = constants.%Op.2]
// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref Core//default, inst+2, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.7: type = import_ref Core//default, inst+6, loaded [template = constants.%.2]
// CHECK:STDOUT: %import_ref.8 = import_ref Core//default, inst+24, unloaded
// CHECK:STDOUT: %import_ref.9: type = import_ref Core//default, inst+6, loaded [template = constants.%.2]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
@@ -138,7 +138,9 @@ var arr: [i32; 1 + 2] = (3, 4, 3 + 4);
// CHECK:STDOUT: .arr = %arr
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: %Core: <namespace> = namespace %Core.import, [template] {}
// CHECK:STDOUT: %Core: <namespace> = namespace %Core.import, [template] {
// CHECK:STDOUT: import Core//default
// CHECK:STDOUT: }
// CHECK:STDOUT: impl_decl @impl {
// CHECK:STDOUT: %int.make_type_32.loc6: init type = call constants.%Int32() [template = i32]
// CHECK:STDOUT: %.loc6_6.1: type = value_of_initializer %int.make_type_32.loc6 [template = i32]
@@ -80,8 +80,8 @@ var arr: [i32; Core.TestAdd(1, 2)] = (1, 2, 3);
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir1, inst+2, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.2: %TestAdd.type = import_ref ir1, inst+20, loaded [template = constants.%TestAdd]
// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//test, inst+2, loaded [template = constants.%Int32]
// CHECK:STDOUT: %import_ref.2: %TestAdd.type = import_ref Core//test, inst+20, loaded [template = constants.%TestAdd]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
@@ -90,7 +90,9 @@ var arr: [i32; Core.TestAdd(1, 2)] = (1, 2, 3);
// CHECK:STDOUT: .arr = %arr
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: %Core: <namespace> = namespace %Core.import, [template] {}
// CHECK:STDOUT: %Core: <namespace> = namespace %Core.import, [template] {
// CHECK:STDOUT: import Core//test
// CHECK:STDOUT: }
// CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
// CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, %Core [template = %Core]
// CHECK:STDOUT: %TestAdd.ref: %TestAdd.type = name_ref TestAdd, imports.%import_ref.2 [template = constants.%TestAdd]