basic.carbon 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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/as/basic.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/as/basic.carbon
  10. fn Main() -> i32 {
  11. return 1 as i32;
  12. }
  13. // CHECK:STDOUT: --- basic.carbon
  14. // CHECK:STDOUT:
  15. // CHECK:STDOUT: constants {
  16. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  17. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  18. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  19. // CHECK:STDOUT: %Main.type: type = fn_type @Main [concrete]
  20. // CHECK:STDOUT: %Main: %Main.type = struct_value () [concrete]
  21. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  22. // CHECK:STDOUT: %As.type.fd4: type = facet_type <@As, @As(%i32)> [concrete]
  23. // CHECK:STDOUT: %Convert.type.99b: type = fn_type @Convert.1, @As(%i32) [concrete]
  24. // CHECK:STDOUT: %As.impl_witness_table.eb4 = impl_witness_table (imports.%Core.import_ref.78a), @impl.686 [concrete]
  25. // CHECK:STDOUT: %As.impl_witness.6b4: <witness> = impl_witness %As.impl_witness_table.eb4, @impl.686(%int_32) [concrete]
  26. // CHECK:STDOUT: %Convert.type.4fd: type = fn_type @Convert.5, @impl.686(%int_32) [concrete]
  27. // CHECK:STDOUT: %Convert.197: %Convert.type.4fd = struct_value () [concrete]
  28. // CHECK:STDOUT: %As.facet: %As.type.fd4 = facet_value Core.IntLiteral, (%As.impl_witness.6b4) [concrete]
  29. // CHECK:STDOUT: %.982: type = fn_type_with_self_type %Convert.type.99b, %As.facet [concrete]
  30. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.197 [concrete]
  31. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.197, @Convert.5(%int_32) [concrete]
  32. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  33. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT:
  36. // CHECK:STDOUT: imports {
  37. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  38. // CHECK:STDOUT: .Int = %Core.Int
  39. // CHECK:STDOUT: .As = %Core.As
  40. // CHECK:STDOUT: import Core//prelude
  41. // CHECK:STDOUT: import Core//prelude/...
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT:
  45. // CHECK:STDOUT: file {
  46. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  47. // CHECK:STDOUT: .Core = imports.%Core
  48. // CHECK:STDOUT: .Main = %Main.decl
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT: %Core.import = import Core
  51. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [concrete = constants.%Main] {
  52. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern
  53. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param0
  54. // CHECK:STDOUT: } {
  55. // CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  56. // CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  57. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param0
  58. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: fn @Main() -> %i32 {
  63. // CHECK:STDOUT: !entry:
  64. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  65. // CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  66. // CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  67. // CHECK:STDOUT: %impl.elem0: %.982 = impl_witness_access constants.%As.impl_witness.6b4, element0 [concrete = constants.%Convert.197]
  68. // CHECK:STDOUT: %bound_method.loc12_12.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Convert.bound]
  69. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.5(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  70. // CHECK:STDOUT: %bound_method.loc12_12.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method]
  71. // CHECK:STDOUT: %int.convert_checked: init %i32 = call %bound_method.loc12_12.2(%int_1) [concrete = constants.%int_1.5d2]
  72. // CHECK:STDOUT: %.loc12_12.1: %i32 = value_of_initializer %int.convert_checked [concrete = constants.%int_1.5d2]
  73. // CHECK:STDOUT: %.loc12_12.2: %i32 = converted %int_1, %.loc12_12.1 [concrete = constants.%int_1.5d2]
  74. // CHECK:STDOUT: return %.loc12_12.2
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT: