definition.carbon 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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: %Int32.type: type = fn_type @Int32 [template]
  15. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  16. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  17. // CHECK:STDOUT: %Add.type: type = fn_type @Add [template]
  18. // CHECK:STDOUT: %Add: %Add.type = struct_value () [template]
  19. // CHECK:STDOUT: }
  20. // CHECK:STDOUT:
  21. // CHECK:STDOUT: imports {
  22. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  23. // CHECK:STDOUT: .Int32 = %import_ref
  24. // CHECK:STDOUT: import Core//prelude
  25. // CHECK:STDOUT: import Core//prelude/operators
  26. // CHECK:STDOUT: import Core//prelude/types
  27. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  28. // CHECK:STDOUT: import Core//prelude/operators/as
  29. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  30. // CHECK:STDOUT: import Core//prelude/operators/comparison
  31. // CHECK:STDOUT: import Core//prelude/types/bool
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+9, loaded [template = constants.%Int32]
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT:
  36. // CHECK:STDOUT: file {
  37. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  38. // CHECK:STDOUT: .Core = imports.%Core
  39. // CHECK:STDOUT: .Add = %Add.decl
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT: %Core.import = import Core
  42. // CHECK:STDOUT: %Add.decl: %Add.type = fn_decl @Add [template = constants.%Add] {
  43. // CHECK:STDOUT: %a.patt: i32 = binding_pattern a
  44. // CHECK:STDOUT: %a.param_patt: i32 = param_pattern %a.patt, runtime_param0
  45. // CHECK:STDOUT: %b.patt: i32 = binding_pattern b
  46. // CHECK:STDOUT: %b.param_patt: i32 = param_pattern %b.patt, runtime_param1
  47. // CHECK:STDOUT: } {
  48. // CHECK:STDOUT: %int.make_type_32.loc11_11: init type = call constants.%Int32() [template = i32]
  49. // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %int.make_type_32.loc11_11 [template = i32]
  50. // CHECK:STDOUT: %.loc11_11.2: type = converted %int.make_type_32.loc11_11, %.loc11_11.1 [template = i32]
  51. // CHECK:STDOUT: %int.make_type_32.loc11_19: init type = call constants.%Int32() [template = i32]
  52. // CHECK:STDOUT: %.loc11_19.1: type = value_of_initializer %int.make_type_32.loc11_19 [template = i32]
  53. // CHECK:STDOUT: %.loc11_19.2: type = converted %int.make_type_32.loc11_19, %.loc11_19.1 [template = i32]
  54. // CHECK:STDOUT: %int.make_type_32.loc11_27: init type = call constants.%Int32() [template = i32]
  55. // CHECK:STDOUT: %.loc11_27.1: type = value_of_initializer %int.make_type_32.loc11_27 [template = i32]
  56. // CHECK:STDOUT: %.loc11_27.2: type = converted %int.make_type_32.loc11_27, %.loc11_27.1 [template = i32]
  57. // CHECK:STDOUT: %return: ref i32 = var <return slot>
  58. // CHECK:STDOUT: %param.loc11_8: i32 = param runtime_param0
  59. // CHECK:STDOUT: %a: i32 = bind_name a, %param.loc11_8
  60. // CHECK:STDOUT: %param.loc11_16: i32 = param runtime_param1
  61. // CHECK:STDOUT: %b: i32 = bind_name b, %param.loc11_16
  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 @Add(%a.param_patt: i32, %b.param_patt: i32) -> i32 = "int.sadd";
  68. // CHECK:STDOUT: