basic.carbon 2.7 KB

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