definition.carbon 4.1 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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/int.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/function/builtin/definition.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/builtin/definition.carbon
  14. fn Add(a: i32, b: i32) -> i32 = "int.sadd";
  15. // CHECK:STDOUT: --- definition.carbon
  16. // CHECK:STDOUT:
  17. // CHECK:STDOUT: constants {
  18. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  19. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  20. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  21. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  22. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  23. // CHECK:STDOUT: %Add.type: type = fn_type @Add [concrete]
  24. // CHECK:STDOUT: %Add: %Add.type = struct_value () [concrete]
  25. // CHECK:STDOUT: }
  26. // CHECK:STDOUT:
  27. // CHECK:STDOUT: imports {
  28. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  29. // CHECK:STDOUT: .Int = %Core.Int
  30. // CHECK:STDOUT: import Core//prelude
  31. // CHECK:STDOUT: import Core//prelude/...
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT:
  36. // CHECK:STDOUT: file {
  37. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  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 [concrete = constants.%Add] {
  43. // CHECK:STDOUT: %a.patt: %pattern_type.7ce = value_binding_pattern a [concrete]
  44. // CHECK:STDOUT: %a.param_patt: %pattern_type.7ce = value_param_pattern %a.patt, call_param0 [concrete]
  45. // CHECK:STDOUT: %b.patt: %pattern_type.7ce = value_binding_pattern b [concrete]
  46. // CHECK:STDOUT: %b.param_patt: %pattern_type.7ce = value_param_pattern %b.patt, call_param1 [concrete]
  47. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
  48. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param2 [concrete]
  49. // CHECK:STDOUT: } {
  50. // CHECK:STDOUT: %int_32.loc15_27: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  51. // CHECK:STDOUT: %i32.loc15_27: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  52. // CHECK:STDOUT: %a.param: %i32 = value_param call_param0
  53. // CHECK:STDOUT: %.loc15_11: type = splice_block %i32.loc15_11 [concrete = constants.%i32] {
  54. // CHECK:STDOUT: %int_32.loc15_11: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  55. // CHECK:STDOUT: %i32.loc15_11: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT: %a: %i32 = value_binding a, %a.param
  58. // CHECK:STDOUT: %b.param: %i32 = value_param call_param1
  59. // CHECK:STDOUT: %.loc15_19: type = splice_block %i32.loc15_19 [concrete = constants.%i32] {
  60. // CHECK:STDOUT: %int_32.loc15_19: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  61. // CHECK:STDOUT: %i32.loc15_19: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT: %b: %i32 = value_binding b, %b.param
  64. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param2
  65. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: fn @Add(%a.param: %i32, %b.param: %i32) -> %i32 = "int.sadd";
  70. // CHECK:STDOUT: