| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
- // Exceptions. See /LICENSE for license information.
- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
- //
- // ARGS: --include-diagnostic-kind compile --no-prelude-import --phase=check --dump-sem-ir --dump-raw-sem-ir %s
- //
- // Check that we can combine textual IR and raw IR dumping in one compile.
- //
- // AUTOUPDATE
- // TIP: To test this file alone, run:
- // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/driver/testdata/compile/multifile_raw_and_textual_ir.carbon
- // TIP: To dump output, run:
- // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/driver/testdata/compile/multifile_raw_and_textual_ir.carbon
- // --- a.carbon
- package A;
- fn A() {}
- // --- b.carbon
- package B;
- import A;
- fn B() {
- A.A();
- }
- // CHECK:STDOUT: ---
- // CHECK:STDOUT: filename: a.carbon
- // CHECK:STDOUT: sem_ir:
- // CHECK:STDOUT: import_irs:
- // CHECK:STDOUT: ir0: {decl_id: inst<none>, is_export: false}
- // CHECK:STDOUT: import_ir_insts: {}
- // CHECK:STDOUT: name_scopes:
- // CHECK:STDOUT: name_scope0: {inst: inst12, parent_scope: name_scope<none>, has_error: false, extended_scopes: [], names: {name0: inst13}}
- // CHECK:STDOUT: entity_names: {}
- // CHECK:STDOUT: functions:
- // CHECK:STDOUT: function0: {name: name0, parent_scope: name_scope0, body: [inst_block5]}
- // CHECK:STDOUT: classes: {}
- // CHECK:STDOUT: generics: {}
- // CHECK:STDOUT: specifics: {}
- // CHECK:STDOUT: struct_type_fields:
- // CHECK:STDOUT: struct_type_fields0: {}
- // CHECK:STDOUT: types:
- // CHECK:STDOUT: 'type(TypeType)': {kind: copy, type: type(TypeType)}
- // CHECK:STDOUT: 'type(Error)': {kind: copy, type: type(Error)}
- // CHECK:STDOUT: 'type(inst(NamespaceType))': {kind: copy, type: type(inst(NamespaceType))}
- // CHECK:STDOUT: 'type(inst14)': {kind: none, type: type(inst15)}
- // CHECK:STDOUT: 'type(inst15)': {kind: none, type: type(inst15)}
- // CHECK:STDOUT: type_blocks:
- // CHECK:STDOUT: type_block0: {}
- // CHECK:STDOUT: insts:
- // CHECK:STDOUT: inst12: {kind: Namespace, arg0: name_scope0, arg1: inst<none>, type: type(inst(NamespaceType))}
- // CHECK:STDOUT: inst13: {kind: FunctionDecl, arg0: function0, arg1: inst_block_empty, type: type(inst14)}
- // CHECK:STDOUT: inst14: {kind: FunctionType, arg0: function0, arg1: specific<none>, type: type(TypeType)}
- // CHECK:STDOUT: inst15: {kind: TupleType, arg0: type_block0, type: type(TypeType)}
- // CHECK:STDOUT: inst16: {kind: StructValue, arg0: inst_block_empty, type: type(inst14)}
- // CHECK:STDOUT: inst17: {kind: Return}
- // CHECK:STDOUT: constant_values:
- // CHECK:STDOUT: inst12: template_constant(inst12)
- // CHECK:STDOUT: inst13: template_constant(inst16)
- // CHECK:STDOUT: inst14: template_constant(inst14)
- // CHECK:STDOUT: inst15: template_constant(inst15)
- // CHECK:STDOUT: inst16: template_constant(inst16)
- // CHECK:STDOUT: symbolic_constants: {}
- // CHECK:STDOUT: inst_blocks:
- // CHECK:STDOUT: inst_block_empty: {}
- // CHECK:STDOUT: exports:
- // CHECK:STDOUT: 0: inst13
- // CHECK:STDOUT: import_refs: {}
- // CHECK:STDOUT: global_init: {}
- // CHECK:STDOUT: inst_block4: {}
- // CHECK:STDOUT: inst_block5:
- // CHECK:STDOUT: 0: inst17
- // CHECK:STDOUT: inst_block6:
- // CHECK:STDOUT: 0: inst12
- // CHECK:STDOUT: 1: inst13
- // CHECK:STDOUT: ...
- // CHECK:STDOUT:
- // CHECK:STDOUT: --- a.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %A.type: type = fn_type @A [template]
- // CHECK:STDOUT: %A: %A.type = struct_value () [template]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = namespace [template] {
- // CHECK:STDOUT: .A = %A.decl
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} {}
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @A() {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: return
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: ---
- // CHECK:STDOUT: filename: b.carbon
- // CHECK:STDOUT: sem_ir:
- // CHECK:STDOUT: import_irs:
- // CHECK:STDOUT: ir0: {decl_id: inst<none>, is_export: false}
- // CHECK:STDOUT: ir1: {decl_id: inst13, is_export: false}
- // CHECK:STDOUT: import_ir_insts:
- // CHECK:STDOUT: import_ir_inst0: {ir_id: ir1, inst_id: inst13}
- // CHECK:STDOUT: import_ir_inst1: {ir_id: ir1, inst_id: inst13}
- // CHECK:STDOUT: name_scopes:
- // CHECK:STDOUT: name_scope0: {inst: inst12, parent_scope: name_scope<none>, has_error: false, extended_scopes: [], names: {name1: inst14, name0: inst15}}
- // CHECK:STDOUT: name_scope1: {inst: inst14, parent_scope: name_scope0, has_error: false, extended_scopes: [], names: {name1: inst20}}
- // CHECK:STDOUT: entity_names:
- // CHECK:STDOUT: entity_name0: {name: name1, parent_scope: name_scope1, index: comp_time_bind<none>}
- // CHECK:STDOUT: functions:
- // CHECK:STDOUT: function0: {name: name0, parent_scope: name_scope0, body: [inst_block5]}
- // CHECK:STDOUT: function1: {name: name1, parent_scope: name_scope1}
- // CHECK:STDOUT: classes: {}
- // CHECK:STDOUT: generics: {}
- // CHECK:STDOUT: specifics: {}
- // CHECK:STDOUT: struct_type_fields:
- // CHECK:STDOUT: struct_type_fields0: {}
- // CHECK:STDOUT: types:
- // CHECK:STDOUT: 'type(TypeType)': {kind: copy, type: type(TypeType)}
- // CHECK:STDOUT: 'type(Error)': {kind: copy, type: type(Error)}
- // CHECK:STDOUT: 'type(inst(NamespaceType))': {kind: copy, type: type(inst(NamespaceType))}
- // CHECK:STDOUT: 'type(inst16)': {kind: none, type: type(inst17)}
- // CHECK:STDOUT: 'type(inst17)': {kind: none, type: type(inst17)}
- // CHECK:STDOUT: 'type(inst22)': {kind: none, type: type(inst17)}
- // CHECK:STDOUT: type_blocks:
- // CHECK:STDOUT: type_block0: {}
- // CHECK:STDOUT: insts:
- // CHECK:STDOUT: inst12: {kind: Namespace, arg0: name_scope0, arg1: inst<none>, type: type(inst(NamespaceType))}
- // CHECK:STDOUT: inst13: {kind: ImportDecl, arg0: name1}
- // CHECK:STDOUT: inst14: {kind: Namespace, arg0: name_scope1, arg1: inst13, type: type(inst(NamespaceType))}
- // CHECK:STDOUT: inst15: {kind: FunctionDecl, arg0: function0, arg1: inst_block_empty, type: type(inst16)}
- // CHECK:STDOUT: inst16: {kind: FunctionType, arg0: function0, arg1: specific<none>, type: type(TypeType)}
- // CHECK:STDOUT: inst17: {kind: TupleType, arg0: type_block0, type: type(TypeType)}
- // CHECK:STDOUT: inst18: {kind: StructValue, arg0: inst_block_empty, type: type(inst16)}
- // CHECK:STDOUT: inst19: {kind: NameRef, arg0: name1, arg1: inst14, type: type(inst(NamespaceType))}
- // CHECK:STDOUT: inst20: {kind: ImportRefLoaded, arg0: import_ir_inst0, arg1: entity_name0, type: type(inst22)}
- // CHECK:STDOUT: inst21: {kind: FunctionDecl, arg0: function1, arg1: inst_block_empty, type: type(inst22)}
- // CHECK:STDOUT: inst22: {kind: FunctionType, arg0: function1, arg1: specific<none>, type: type(TypeType)}
- // CHECK:STDOUT: inst23: {kind: StructValue, arg0: inst_block_empty, type: type(inst22)}
- // CHECK:STDOUT: inst24: {kind: NameRef, arg0: name1, arg1: inst20, type: type(inst22)}
- // CHECK:STDOUT: inst25: {kind: Call, arg0: inst24, arg1: inst_block_empty, type: type(inst17)}
- // CHECK:STDOUT: inst26: {kind: Return}
- // CHECK:STDOUT: constant_values:
- // CHECK:STDOUT: inst12: template_constant(inst12)
- // CHECK:STDOUT: inst14: template_constant(inst14)
- // CHECK:STDOUT: inst15: template_constant(inst18)
- // CHECK:STDOUT: inst16: template_constant(inst16)
- // CHECK:STDOUT: inst17: template_constant(inst17)
- // CHECK:STDOUT: inst18: template_constant(inst18)
- // CHECK:STDOUT: inst19: template_constant(inst14)
- // CHECK:STDOUT: inst20: template_constant(inst23)
- // CHECK:STDOUT: inst21: template_constant(inst23)
- // CHECK:STDOUT: inst22: template_constant(inst22)
- // CHECK:STDOUT: inst23: template_constant(inst23)
- // CHECK:STDOUT: inst24: template_constant(inst23)
- // CHECK:STDOUT: symbolic_constants: {}
- // CHECK:STDOUT: inst_blocks:
- // CHECK:STDOUT: inst_block_empty: {}
- // CHECK:STDOUT: exports:
- // CHECK:STDOUT: 0: inst15
- // CHECK:STDOUT: import_refs:
- // CHECK:STDOUT: 0: inst14
- // CHECK:STDOUT: 1: inst20
- // CHECK:STDOUT: global_init: {}
- // CHECK:STDOUT: inst_block4: {}
- // CHECK:STDOUT: inst_block5:
- // CHECK:STDOUT: 0: inst19
- // CHECK:STDOUT: 1: inst24
- // CHECK:STDOUT: 2: inst25
- // CHECK:STDOUT: 3: inst26
- // CHECK:STDOUT: inst_block6:
- // CHECK:STDOUT: 0: inst12
- // CHECK:STDOUT: 1: inst13
- // CHECK:STDOUT: 2: inst15
- // CHECK:STDOUT: ...
- // CHECK:STDOUT:
- // CHECK:STDOUT: --- b.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %B.type: type = fn_type @B [template]
- // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
- // CHECK:STDOUT: %B: %B.type = struct_value () [template]
- // CHECK:STDOUT: %A.type: type = fn_type @A [template]
- // CHECK:STDOUT: %A: %A.type = struct_value () [template]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: imports {
- // CHECK:STDOUT: %A: <namespace> = namespace file.%A.import, [template] {
- // CHECK:STDOUT: .A = %A.A
- // CHECK:STDOUT: import A//default
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %A.A: %A.type = import_ref A//default, A, loaded [template = constants.%A]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = namespace [template] {
- // CHECK:STDOUT: .A = imports.%A
- // CHECK:STDOUT: .B = %B.decl
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %A.import = import A
- // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] {} {}
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @B() {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: %A.ref.loc6_3: <namespace> = name_ref A, imports.%A [template = imports.%A]
- // CHECK:STDOUT: %A.ref.loc6_4: %A.type = name_ref A, imports.%A.A [template = constants.%A]
- // CHECK:STDOUT: %A.call: init %empty_tuple.type = call %A.ref.loc6_4()
- // CHECK:STDOUT: return
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @A() [from "a.carbon"];
- // CHECK:STDOUT:
|