local.carbon 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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: %.1: Core.IntLiteral = int_value 32 [template]
  18. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  19. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  20. // CHECK:STDOUT: %i32: type = int_type signed, %.1 [template]
  21. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  22. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  23. // CHECK:STDOUT: }
  24. // CHECK:STDOUT:
  25. // CHECK:STDOUT: imports {
  26. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  27. // CHECK:STDOUT: .Int = %import_ref
  28. // CHECK:STDOUT: import Core//prelude
  29. // CHECK:STDOUT: import Core//prelude/...
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: file {
  34. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  35. // CHECK:STDOUT: .Core = imports.%Core
  36. // CHECK:STDOUT: .F = %F.decl
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: %Core.import = import Core
  39. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  40. // CHECK:STDOUT: %a.patt: %i32 = binding_pattern a
  41. // CHECK:STDOUT: %a.param_patt: %i32 = value_param_pattern %a.patt, runtime_param0
  42. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  43. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1
  44. // CHECK:STDOUT: } {
  45. // CHECK:STDOUT: %.loc11_9.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  46. // CHECK:STDOUT: %int.make_type_signed.loc11_9: init type = call constants.%Int(%.loc11_9.1) [template = constants.%i32]
  47. // CHECK:STDOUT: %.loc11_9.2: type = value_of_initializer %int.make_type_signed.loc11_9 [template = constants.%i32]
  48. // CHECK:STDOUT: %.loc11_9.3: type = converted %int.make_type_signed.loc11_9, %.loc11_9.2 [template = constants.%i32]
  49. // CHECK:STDOUT: %.loc11_17.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  50. // CHECK:STDOUT: %int.make_type_signed.loc11_17: init type = call constants.%Int(%.loc11_17.1) [template = constants.%i32]
  51. // CHECK:STDOUT: %.loc11_17.2: type = value_of_initializer %int.make_type_signed.loc11_17 [template = constants.%i32]
  52. // CHECK:STDOUT: %.loc11_17.3: type = converted %int.make_type_signed.loc11_17, %.loc11_17.2 [template = constants.%i32]
  53. // CHECK:STDOUT: %a.param: %i32 = value_param runtime_param0
  54. // CHECK:STDOUT: %a: %i32 = bind_name a, %a.param
  55. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1
  56. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: fn @F(%a.param_patt: %i32) -> %i32 {
  61. // CHECK:STDOUT: !entry:
  62. // CHECK:STDOUT: %.loc12_10.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  63. // CHECK:STDOUT: %int.make_type_signed.loc12: init type = call constants.%Int(%.loc12_10.1) [template = constants.%i32]
  64. // CHECK:STDOUT: %.loc12_10.2: type = value_of_initializer %int.make_type_signed.loc12 [template = constants.%i32]
  65. // CHECK:STDOUT: %.loc12_10.3: type = converted %int.make_type_signed.loc12, %.loc12_10.2 [template = constants.%i32]
  66. // CHECK:STDOUT: %a.ref: %i32 = name_ref a, %a
  67. // CHECK:STDOUT: %b: %i32 = bind_name b, %a.ref
  68. // CHECK:STDOUT: %b.ref: %i32 = name_ref b, %b
  69. // CHECK:STDOUT: return %b.ref
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT: