definition.carbon 4.0 KB

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