textual_ir.carbon 3.0 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. // ARGS: compile --no-prelude-import --phase=check --dump-sem-ir %s
  6. //
  7. // Check that the command-line flag to dump textual IR works.
  8. //
  9. // AUTOUPDATE
  10. fn Foo(n: ()) -> ((), ()) {
  11. return (n, ());
  12. }
  13. // CHECK:STDOUT: --- textual_ir.carbon
  14. // CHECK:STDOUT:
  15. // CHECK:STDOUT: constants {
  16. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  17. // CHECK:STDOUT: %.2: type = tuple_type ((), ()) [template]
  18. // CHECK:STDOUT: %.3: type = ptr_type ((), ()) [template]
  19. // CHECK:STDOUT: %.4: () = tuple_value () [template]
  20. // CHECK:STDOUT: %.5: ((), ()) = tuple_value (%.4, %.4) [template]
  21. // CHECK:STDOUT: }
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: file {
  24. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  25. // CHECK:STDOUT: .Foo = %Foo
  26. // CHECK:STDOUT: }
  27. // CHECK:STDOUT: %Foo: <function> = fn_decl @Foo [template] {
  28. // CHECK:STDOUT: %.loc11_12.1: () = tuple_literal ()
  29. // CHECK:STDOUT: %.loc11_12.2: type = converted %.loc11_12.1, constants.%.1 [template = constants.%.1]
  30. // CHECK:STDOUT: %n.loc11_8.1: () = param n
  31. // CHECK:STDOUT: @Foo.%n: () = bind_name n, %n.loc11_8.1
  32. // CHECK:STDOUT: %.loc11_20.1: () = tuple_literal ()
  33. // CHECK:STDOUT: %.loc11_24.1: () = tuple_literal ()
  34. // CHECK:STDOUT: %.loc11_25.1: ((), ()) = tuple_literal (%.loc11_20.1, %.loc11_24.1)
  35. // CHECK:STDOUT: %.loc11_20.2: type = converted %.loc11_20.1, constants.%.1 [template = constants.%.1]
  36. // CHECK:STDOUT: %.loc11_24.2: type = converted %.loc11_24.1, constants.%.1 [template = constants.%.1]
  37. // CHECK:STDOUT: %.loc11_25.2: type = converted %.loc11_25.1, constants.%.2 [template = constants.%.2]
  38. // CHECK:STDOUT: @Foo.%return: ref ((), ()) = var <return slot>
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: fn @Foo(%n: ()) -> %return: ((), ()) {
  43. // CHECK:STDOUT: !entry:
  44. // CHECK:STDOUT: %n.ref: () = name_ref n, %n
  45. // CHECK:STDOUT: %.loc12_15.1: () = tuple_literal ()
  46. // CHECK:STDOUT: %.loc12_16.1: ((), ()) = tuple_literal (%n.ref, %.loc12_15.1)
  47. // CHECK:STDOUT: %.loc12_16.2: ref () = tuple_access %return, element0
  48. // CHECK:STDOUT: %.loc12_11.1: init () = tuple_init () to %.loc12_16.2 [template = constants.%.4]
  49. // CHECK:STDOUT: %.loc12_11.2: init () = converted %n.ref, %.loc12_11.1 [template = constants.%.4]
  50. // CHECK:STDOUT: %.loc12_16.3: ref () = tuple_access %return, element1
  51. // CHECK:STDOUT: %.loc12_15.2: init () = tuple_init () to %.loc12_16.3 [template = constants.%.4]
  52. // CHECK:STDOUT: %.loc12_15.3: init () = converted %.loc12_15.1, %.loc12_15.2 [template = constants.%.4]
  53. // CHECK:STDOUT: %.loc12_16.4: init ((), ()) = tuple_init (%.loc12_11.2, %.loc12_15.3) to %return [template = constants.%.5]
  54. // CHECK:STDOUT: %.loc12_16.5: init ((), ()) = converted %.loc12_16.1, %.loc12_16.4 [template = constants.%.5]
  55. // CHECK:STDOUT: return %.loc12_16.5
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT: