textual_ir.carbon 1.3 KB

12345678910111213141516171819202122232425262728293031
  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 --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: i32) -> (i32, f64) {
  11. return (n + 2, 3.4);
  12. }
  13. // CHECK:STDOUT: file "textual_ir.carbon" {
  14. // CHECK:STDOUT: %.loc11 = fn_decl @Foo
  15. // CHECK:STDOUT: }
  16. // CHECK:STDOUT:
  17. // CHECK:STDOUT: fn @Foo(%n: i32) -> %return: (i32, f64) {
  18. // CHECK:STDOUT: !entry:
  19. // CHECK:STDOUT: %.loc12_15: i32 = int_literal 2
  20. // CHECK:STDOUT: %.loc12_13: i32 = add %n, %.loc12_15
  21. // CHECK:STDOUT: %.loc12_18: f64 = real_literal 34e-1
  22. // CHECK:STDOUT: %.loc12_21.1: (i32, f64) = tuple_literal (%.loc12_13, %.loc12_18)
  23. // CHECK:STDOUT: %.loc12_21.2: ref i32 = tuple_access %return, member0
  24. // CHECK:STDOUT: %.loc12_21.3: init i32 = initialize_from %.loc12_13 to %.loc12_21.2
  25. // CHECK:STDOUT: %.loc12_21.4: ref f64 = tuple_access %return, member1
  26. // CHECK:STDOUT: %.loc12_21.5: init f64 = initialize_from %.loc12_18 to %.loc12_21.4
  27. // CHECK:STDOUT: %.loc12_21.6: init (i32, f64) = tuple_init %.loc12_21.1, (%.loc12_21.3, %.loc12_21.5)
  28. // CHECK:STDOUT: return %.loc12_21.6
  29. // CHECK:STDOUT: }