definition.carbon 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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/definition.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/builtin/definition.carbon
  10. fn Add(a: i32, b: i32) -> i32 = "int.sadd";
  11. // CHECK:STDOUT: --- definition.carbon
  12. // CHECK:STDOUT:
  13. // CHECK:STDOUT: constants {
  14. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  15. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  16. // CHECK:STDOUT: %Add.type: type = fn_type @Add [template]
  17. // CHECK:STDOUT: %Add: %Add.type = struct_value () [template]
  18. // CHECK:STDOUT: }
  19. // CHECK:STDOUT:
  20. // CHECK:STDOUT: imports {
  21. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  22. // CHECK:STDOUT: .Int = %Core.Int
  23. // CHECK:STDOUT: import Core//prelude
  24. // CHECK:STDOUT: import Core//prelude/...
  25. // CHECK:STDOUT: }
  26. // CHECK:STDOUT: }
  27. // CHECK:STDOUT:
  28. // CHECK:STDOUT: file {
  29. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  30. // CHECK:STDOUT: .Core = imports.%Core
  31. // CHECK:STDOUT: .Add = %Add.decl
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT: %Core.import = import Core
  34. // CHECK:STDOUT: %Add.decl: %Add.type = fn_decl @Add [template = constants.%Add] {
  35. // CHECK:STDOUT: %a.patt: %i32 = binding_pattern a
  36. // CHECK:STDOUT: %a.param_patt: %i32 = value_param_pattern %a.patt, runtime_param0
  37. // CHECK:STDOUT: %b.patt: %i32 = binding_pattern b
  38. // CHECK:STDOUT: %b.param_patt: %i32 = value_param_pattern %b.patt, runtime_param1
  39. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  40. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param2
  41. // CHECK:STDOUT: } {
  42. // CHECK:STDOUT: %int_32.loc11_27: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  43. // CHECK:STDOUT: %i32.loc11_27: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  44. // CHECK:STDOUT: %a.param: %i32 = value_param runtime_param0
  45. // CHECK:STDOUT: %.loc11_11: type = splice_block %i32.loc11_11 [template = constants.%i32] {
  46. // CHECK:STDOUT: %int_32.loc11_11: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  47. // CHECK:STDOUT: %i32.loc11_11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: %a: %i32 = bind_name a, %a.param
  50. // CHECK:STDOUT: %b.param: %i32 = value_param runtime_param1
  51. // CHECK:STDOUT: %.loc11_19: type = splice_block %i32.loc11_19 [template = constants.%i32] {
  52. // CHECK:STDOUT: %int_32.loc11_19: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  53. // CHECK:STDOUT: %i32.loc11_19: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT: %b: %i32 = bind_name b, %b.param
  56. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param2
  57. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT:
  61. // CHECK:STDOUT: fn @Add(%a.param_patt: %i32, %b.param_patt: %i32) -> %i32 = "int.sadd";
  62. // CHECK:STDOUT: