basic.carbon 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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: %Int32.type: type = fn_type @Int32 [template]
  17. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  18. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  19. // CHECK:STDOUT: %Main.type: type = fn_type @Main [template]
  20. // CHECK:STDOUT: %Main: %Main.type = struct_value () [template]
  21. // CHECK:STDOUT: %.2: i32 = int_value 1 [template]
  22. // CHECK:STDOUT: }
  23. // CHECK:STDOUT:
  24. // CHECK:STDOUT: imports {
  25. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  26. // CHECK:STDOUT: .Int32 = %import_ref
  27. // CHECK:STDOUT: import Core//prelude
  28. // CHECK:STDOUT: import Core//prelude/...
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+15, loaded [template = constants.%Int32]
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: file {
  34. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  35. // CHECK:STDOUT: .Core = imports.%Core
  36. // CHECK:STDOUT: .Main = %Main.decl
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: %Core.import = import Core
  39. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {
  40. // CHECK:STDOUT: %return.patt: i32 = return_slot_pattern
  41. // CHECK:STDOUT: %return.param_patt: i32 = out_param_pattern %return.patt, runtime_param0
  42. // CHECK:STDOUT: } {
  43. // CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32]
  44. // CHECK:STDOUT: %.loc11_14.1: type = value_of_initializer %int.make_type_32.loc11 [template = i32]
  45. // CHECK:STDOUT: %.loc11_14.2: type = converted %int.make_type_32.loc11, %.loc11_14.1 [template = i32]
  46. // CHECK:STDOUT: %return.param: ref i32 = out_param runtime_param0
  47. // CHECK:STDOUT: %return: ref i32 = return_slot %return.param
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT:
  51. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: fn @Main() -> i32 {
  54. // CHECK:STDOUT: !entry:
  55. // CHECK:STDOUT: %.loc12_10: i32 = int_value 1 [template = constants.%.2]
  56. // CHECK:STDOUT: %int.make_type_32.loc12: init type = call constants.%Int32() [template = i32]
  57. // CHECK:STDOUT: %.loc12_15.1: type = value_of_initializer %int.make_type_32.loc12 [template = i32]
  58. // CHECK:STDOUT: %.loc12_15.2: type = converted %int.make_type_32.loc12, %.loc12_15.1 [template = i32]
  59. // CHECK:STDOUT: return %.loc12_10
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT: