call.carbon 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/function/builtin/call.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/builtin/call.carbon
  10. fn Add(a: i32, b: i32) -> i32 = "int.sadd";
  11. var arr: [i32; Add(1, 2)];
  12. // CHECK:STDOUT: --- call.carbon
  13. // CHECK:STDOUT:
  14. // CHECK:STDOUT: constants {
  15. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  16. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  17. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  18. // CHECK:STDOUT: %Add.type: type = fn_type @Add [template]
  19. // CHECK:STDOUT: %Add: %Add.type = struct_value () [template]
  20. // CHECK:STDOUT: %.2: i32 = int_literal 1 [template]
  21. // CHECK:STDOUT: %.3: i32 = int_literal 2 [template]
  22. // CHECK:STDOUT: %.4: i32 = int_literal 3 [template]
  23. // CHECK:STDOUT: %.5: type = array_type %.4, i32 [template]
  24. // CHECK:STDOUT: %.6: type = ptr_type %.5 [template]
  25. // CHECK:STDOUT: }
  26. // CHECK:STDOUT:
  27. // CHECK:STDOUT: file {
  28. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  29. // CHECK:STDOUT: .Core = %Core
  30. // CHECK:STDOUT: .Add = %Add.decl
  31. // CHECK:STDOUT: .arr = %arr
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  34. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  35. // CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  36. // CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  37. // CHECK:STDOUT: %Add.decl: %Add.type = fn_decl @Add [template = constants.%Add] {
  38. // CHECK:STDOUT: %int.make_type_32.loc11_11: init type = call constants.%Int32() [template = i32]
  39. // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %int.make_type_32.loc11_11 [template = i32]
  40. // CHECK:STDOUT: %.loc11_11.2: type = converted %int.make_type_32.loc11_11, %.loc11_11.1 [template = i32]
  41. // CHECK:STDOUT: %a.loc11_8.1: i32 = param a
  42. // CHECK:STDOUT: @Add.%a: i32 = bind_name a, %a.loc11_8.1
  43. // CHECK:STDOUT: %int.make_type_32.loc11_19: init type = call constants.%Int32() [template = i32]
  44. // CHECK:STDOUT: %.loc11_19.1: type = value_of_initializer %int.make_type_32.loc11_19 [template = i32]
  45. // CHECK:STDOUT: %.loc11_19.2: type = converted %int.make_type_32.loc11_19, %.loc11_19.1 [template = i32]
  46. // CHECK:STDOUT: %b.loc11_16.1: i32 = param b
  47. // CHECK:STDOUT: @Add.%b: i32 = bind_name b, %b.loc11_16.1
  48. // CHECK:STDOUT: %int.make_type_32.loc11_27: init type = call constants.%Int32() [template = i32]
  49. // CHECK:STDOUT: %.loc11_27.1: type = value_of_initializer %int.make_type_32.loc11_27 [template = i32]
  50. // CHECK:STDOUT: %.loc11_27.2: type = converted %int.make_type_32.loc11_27, %.loc11_27.1 [template = i32]
  51. // CHECK:STDOUT: @Add.%return: ref i32 = var <return slot>
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  54. // CHECK:STDOUT: %int.make_type_32.loc13: init type = call constants.%Int32() [template = i32]
  55. // CHECK:STDOUT: %Add.ref: %Add.type = name_ref Add, %Add.decl [template = constants.%Add]
  56. // CHECK:STDOUT: %.loc13_20: i32 = int_literal 1 [template = constants.%.2]
  57. // CHECK:STDOUT: %.loc13_23: i32 = int_literal 2 [template = constants.%.3]
  58. // CHECK:STDOUT: %int.sadd: init i32 = call %Add.ref(%.loc13_20, %.loc13_23) [template = constants.%.4]
  59. // CHECK:STDOUT: %.loc13_11.1: type = value_of_initializer %int.make_type_32.loc13 [template = i32]
  60. // CHECK:STDOUT: %.loc13_11.2: type = converted %int.make_type_32.loc13, %.loc13_11.1 [template = i32]
  61. // CHECK:STDOUT: %.loc13_25: type = array_type %int.sadd, i32 [template = constants.%.5]
  62. // CHECK:STDOUT: %arr.var: ref %.5 = var arr
  63. // CHECK:STDOUT: %arr: ref %.5 = bind_name arr, %arr.var
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: fn @Add(%a: i32, %b: i32) -> i32 = "int.sadd";
  69. // CHECK:STDOUT: