simple_with_fun.carbon 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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/global/simple_with_fun.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/global/simple_with_fun.carbon
  10. fn test_a() -> i32 {
  11. return 0;
  12. }
  13. var a: i32 = test_a();
  14. // CHECK:STDOUT: --- simple_with_fun.carbon
  15. // CHECK:STDOUT:
  16. // CHECK:STDOUT: constants {
  17. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  18. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  19. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  20. // CHECK:STDOUT: %test_a.type: type = fn_type @test_a [template]
  21. // CHECK:STDOUT: %test_a: %test_a.type = struct_value () [template]
  22. // CHECK:STDOUT: %.2: i32 = int_literal 0 [template]
  23. // CHECK:STDOUT: }
  24. // CHECK:STDOUT:
  25. // CHECK:STDOUT: file {
  26. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  27. // CHECK:STDOUT: .Core = %Core
  28. // CHECK:STDOUT: .test_a = %test_a.decl
  29. // CHECK:STDOUT: .a = %a
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  32. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  33. // CHECK:STDOUT: %test_a.decl: %test_a.type = fn_decl @test_a [template = constants.%test_a] {
  34. // CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32]
  35. // CHECK:STDOUT: %.loc11_16.1: type = value_of_initializer %int.make_type_32.loc11 [template = i32]
  36. // CHECK:STDOUT: %.loc11_16.2: type = converted %int.make_type_32.loc11, %.loc11_16.1 [template = i32]
  37. // CHECK:STDOUT: @test_a.%return: ref i32 = var <return slot>
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  40. // CHECK:STDOUT: %int.make_type_32.loc15: init type = call constants.%Int32() [template = i32]
  41. // CHECK:STDOUT: %.loc15_8.1: type = value_of_initializer %int.make_type_32.loc15 [template = i32]
  42. // CHECK:STDOUT: %.loc15_8.2: type = converted %int.make_type_32.loc15, %.loc15_8.1 [template = i32]
  43. // CHECK:STDOUT: %a.var: ref i32 = var a
  44. // CHECK:STDOUT: %a: ref i32 = bind_name a, %a.var
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: fn @test_a() -> i32 {
  50. // CHECK:STDOUT: !entry:
  51. // CHECK:STDOUT: %.loc12: i32 = int_literal 0 [template = constants.%.2]
  52. // CHECK:STDOUT: return %.loc12
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT:
  55. // CHECK:STDOUT: fn @__global_init() {
  56. // CHECK:STDOUT: !entry:
  57. // CHECK:STDOUT: %test_a.ref: %test_a.type = name_ref test_a, file.%test_a.decl [template = constants.%test_a]
  58. // CHECK:STDOUT: %test_a.call: init i32 = call %test_a.ref()
  59. // CHECK:STDOUT: assign file.%a.var, %test_a.call
  60. // CHECK:STDOUT: return
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT: