| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- // 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
- //
- // AUTOUPDATE
- // --- core.carbon
- package Core library "test";
- fn TestAdd(a: i32, b: i32) -> i32 = "int.sadd";
- // --- use.carbon
- import Core library "test";
- var arr: [i32; Core.TestAdd(1, 2)] = (1, 2, 3);
- // CHECK:STDOUT: --- core.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %TestAdd: type = fn_type @TestAdd [template]
- // CHECK:STDOUT: %.1: type = tuple_type () [template]
- // CHECK:STDOUT: %struct: TestAdd = struct_value () [template]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = namespace [template] {
- // CHECK:STDOUT: .TestAdd = %TestAdd.decl
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %TestAdd.decl: TestAdd = fn_decl @TestAdd [template = constants.%struct] {
- // CHECK:STDOUT: %a.loc4_12.1: i32 = param a
- // CHECK:STDOUT: @TestAdd.%a: i32 = bind_name a, %a.loc4_12.1
- // CHECK:STDOUT: %b.loc4_20.1: i32 = param b
- // CHECK:STDOUT: @TestAdd.%b: i32 = bind_name b, %b.loc4_20.1
- // CHECK:STDOUT: @TestAdd.%return: ref i32 = var <return slot>
- // CHECK:STDOUT: }
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @TestAdd(%a: i32, %b: i32) -> i32 = "int.sadd";
- // CHECK:STDOUT:
- // CHECK:STDOUT: --- use.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %TestAdd: type = fn_type @TestAdd [template]
- // CHECK:STDOUT: %.1: type = tuple_type () [template]
- // CHECK:STDOUT: %struct: TestAdd = struct_value () [template]
- // CHECK:STDOUT: %.2: i32 = int_literal 1 [template]
- // CHECK:STDOUT: %.3: i32 = int_literal 2 [template]
- // CHECK:STDOUT: %.4: i32 = int_literal 3 [template]
- // CHECK:STDOUT: %.5: type = array_type %.4, i32 [template]
- // CHECK:STDOUT: %.6: type = ptr_type [i32; 3] [template]
- // CHECK:STDOUT: %.7: type = tuple_type (i32, i32, i32) [template]
- // CHECK:STDOUT: %.8: i32 = int_literal 0 [template]
- // CHECK:STDOUT: %array: [i32; 3] = tuple_value (%.2, %.3, %.4) [template]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = namespace [template] {
- // CHECK:STDOUT: .Core = %Core
- // CHECK:STDOUT: .arr = %arr
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
- // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, %Core [template = %Core]
- // CHECK:STDOUT: %import_ref: TestAdd = import_ref ir2, inst+6, loaded [template = constants.%struct]
- // CHECK:STDOUT: %TestAdd.ref: TestAdd = name_ref TestAdd, %import_ref [template = constants.%struct]
- // CHECK:STDOUT: %.loc4_29: i32 = int_literal 1 [template = constants.%.2]
- // CHECK:STDOUT: %.loc4_32: i32 = int_literal 2 [template = constants.%.3]
- // CHECK:STDOUT: %int.sadd: init i32 = call %TestAdd.ref(%.loc4_29, %.loc4_32) [template = constants.%.4]
- // CHECK:STDOUT: %.loc4_34: type = array_type %int.sadd, i32 [template = constants.%.5]
- // CHECK:STDOUT: %arr.var: ref [i32; 3] = var arr
- // CHECK:STDOUT: %arr: ref [i32; 3] = bind_name arr, %arr.var
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @TestAdd(%a: i32, %b: i32) -> i32 = "int.sadd";
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @__global_init() {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: %.loc4_39: i32 = int_literal 1 [template = constants.%.2]
- // CHECK:STDOUT: %.loc4_42: i32 = int_literal 2 [template = constants.%.3]
- // CHECK:STDOUT: %.loc4_45: i32 = int_literal 3 [template = constants.%.4]
- // CHECK:STDOUT: %.loc4_46.1: (i32, i32, i32) = tuple_literal (%.loc4_39, %.loc4_42, %.loc4_45)
- // CHECK:STDOUT: %.loc4_46.2: i32 = int_literal 0 [template = constants.%.8]
- // CHECK:STDOUT: %.loc4_46.3: ref i32 = array_index file.%arr.var, %.loc4_46.2
- // CHECK:STDOUT: %.loc4_46.4: init i32 = initialize_from %.loc4_39 to %.loc4_46.3 [template = constants.%.2]
- // CHECK:STDOUT: %.loc4_46.5: i32 = int_literal 1 [template = constants.%.2]
- // CHECK:STDOUT: %.loc4_46.6: ref i32 = array_index file.%arr.var, %.loc4_46.5
- // CHECK:STDOUT: %.loc4_46.7: init i32 = initialize_from %.loc4_42 to %.loc4_46.6 [template = constants.%.3]
- // CHECK:STDOUT: %.loc4_46.8: i32 = int_literal 2 [template = constants.%.3]
- // CHECK:STDOUT: %.loc4_46.9: ref i32 = array_index file.%arr.var, %.loc4_46.8
- // CHECK:STDOUT: %.loc4_46.10: init i32 = initialize_from %.loc4_45 to %.loc4_46.9 [template = constants.%.4]
- // CHECK:STDOUT: %.loc4_46.11: init [i32; 3] = array_init (%.loc4_46.4, %.loc4_46.7, %.loc4_46.10) to file.%arr.var [template = constants.%array]
- // CHECK:STDOUT: %.loc4_47: init [i32; 3] = converted %.loc4_46.1, %.loc4_46.11 [template = constants.%array]
- // CHECK:STDOUT: assign file.%arr.var, %.loc4_47
- // CHECK:STDOUT: return
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
|