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