basic.carbon 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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_literal 1 [template]
  22. // CHECK:STDOUT: }
  23. // CHECK:STDOUT:
  24. // CHECK:STDOUT: file {
  25. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  26. // CHECK:STDOUT: .Core = %Core
  27. // CHECK:STDOUT: .Main = %Main.decl
  28. // CHECK:STDOUT: }
  29. // CHECK:STDOUT: %Core.import = import Core
  30. // CHECK:STDOUT: %Core: <namespace> = namespace %Core.import, [template] {}
  31. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
  32. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {
  33. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  34. // CHECK:STDOUT: %.loc11_14.1: type = value_of_initializer %int.make_type_32 [template = i32]
  35. // CHECK:STDOUT: %.loc11_14.2: type = converted %int.make_type_32, %.loc11_14.1 [template = i32]
  36. // CHECK:STDOUT: @Main.%return: ref i32 = var <return slot>
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32]
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: fn @Main() -> i32 {
  44. // CHECK:STDOUT: !entry:
  45. // CHECK:STDOUT: %.loc12_10: i32 = int_literal 1 [template = constants.%.2]
  46. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  47. // CHECK:STDOUT: %.loc12_15.1: type = value_of_initializer %int.make_type_32 [template = i32]
  48. // CHECK:STDOUT: %.loc12_15.2: type = converted %int.make_type_32, %.loc12_15.1 [template = i32]
  49. // CHECK:STDOUT: return %.loc12_10
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT: