local.carbon 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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/let/local.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/let/local.carbon
  10. fn F(a: i32) -> i32 {
  11. let b: i32 = a;
  12. return b;
  13. }
  14. // CHECK:STDOUT: --- local.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: %F.type: type = fn_type @F [template]
  21. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  22. // CHECK:STDOUT: }
  23. // CHECK:STDOUT:
  24. // CHECK:STDOUT: imports {
  25. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  26. // CHECK:STDOUT: .Int32 = %import_ref
  27. // CHECK:STDOUT: import Core//prelude
  28. // CHECK:STDOUT: import Core//prelude/operators
  29. // CHECK:STDOUT: import Core//prelude/types
  30. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  31. // CHECK:STDOUT: import Core//prelude/operators/as
  32. // CHECK:STDOUT: import Core//prelude/operators/index
  33. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  34. // CHECK:STDOUT: import Core//prelude/operators/comparison
  35. // CHECK:STDOUT: import Core//prelude/types/bool
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+15, loaded [template = constants.%Int32]
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT:
  40. // CHECK:STDOUT: file {
  41. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  42. // CHECK:STDOUT: .Core = imports.%Core
  43. // CHECK:STDOUT: .F = %F.decl
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT: %Core.import = import Core
  46. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  47. // CHECK:STDOUT: %a.patt: i32 = binding_pattern a
  48. // CHECK:STDOUT: %a.param_patt: i32 = value_param_pattern %a.patt, runtime_param0
  49. // CHECK:STDOUT: %return.patt: i32 = return_slot_pattern
  50. // CHECK:STDOUT: %return.param_patt: i32 = out_param_pattern %return.patt, runtime_param1
  51. // CHECK:STDOUT: } {
  52. // CHECK:STDOUT: %int.make_type_32.loc11_9: init type = call constants.%Int32() [template = i32]
  53. // CHECK:STDOUT: %.loc11_9.1: type = value_of_initializer %int.make_type_32.loc11_9 [template = i32]
  54. // CHECK:STDOUT: %.loc11_9.2: type = converted %int.make_type_32.loc11_9, %.loc11_9.1 [template = i32]
  55. // CHECK:STDOUT: %int.make_type_32.loc11_17: init type = call constants.%Int32() [template = i32]
  56. // CHECK:STDOUT: %.loc11_17.1: type = value_of_initializer %int.make_type_32.loc11_17 [template = i32]
  57. // CHECK:STDOUT: %.loc11_17.2: type = converted %int.make_type_32.loc11_17, %.loc11_17.1 [template = i32]
  58. // CHECK:STDOUT: %a.param: i32 = value_param runtime_param0
  59. // CHECK:STDOUT: %a: i32 = bind_name a, %a.param
  60. // CHECK:STDOUT: %return.param: ref i32 = out_param runtime_param1
  61. // CHECK:STDOUT: %return: ref i32 = return_slot %return.param
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  66. // CHECK:STDOUT:
  67. // CHECK:STDOUT: fn @F(%a.param_patt: i32) -> i32 {
  68. // CHECK:STDOUT: !entry:
  69. // CHECK:STDOUT: %int.make_type_32.loc12: init type = call constants.%Int32() [template = i32]
  70. // CHECK:STDOUT: %.loc12_10.1: type = value_of_initializer %int.make_type_32.loc12 [template = i32]
  71. // CHECK:STDOUT: %.loc12_10.2: type = converted %int.make_type_32.loc12, %.loc12_10.1 [template = i32]
  72. // CHECK:STDOUT: %a.ref: i32 = name_ref a, %a
  73. // CHECK:STDOUT: %b: i32 = bind_name b, %a.ref
  74. // CHECK:STDOUT: %b.ref: i32 = name_ref b, %b
  75. // CHECK:STDOUT: return %b.ref
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT: