textual_ir.carbon 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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, i32, f64) {
  11. return (n, 2, 3.4);
  12. }
  13. // CHECK:STDOUT: --- textual_ir.carbon
  14. // CHECK:STDOUT:
  15. // CHECK:STDOUT: constants {
  16. // CHECK:STDOUT: %.loc11_33.1: type = tuple_type (type, type, type)
  17. // CHECK:STDOUT: %.loc11_33.2: type = tuple_type (i32, i32, f64)
  18. // CHECK:STDOUT: %.loc11_33.3: type = ptr_type (i32, i32, f64)
  19. // CHECK:STDOUT: }
  20. // CHECK:STDOUT:
  21. // CHECK:STDOUT: file {
  22. // CHECK:STDOUT: package: <namespace> = namespace {.Foo = %Foo}
  23. // CHECK:STDOUT: %Foo: <function> = fn_decl @Foo
  24. // CHECK:STDOUT: }
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: fn @Foo(%n: i32) -> %return: (i32, i32, f64) {
  27. // CHECK:STDOUT: !entry:
  28. // CHECK:STDOUT: %n.ref: i32 = name_ref n, %n
  29. // CHECK:STDOUT: %.loc12_14: i32 = int_literal 2
  30. // CHECK:STDOUT: %.loc12_17: f64 = real_literal 34e-1
  31. // CHECK:STDOUT: %.loc12_20.1: (i32, i32, f64) = tuple_literal (%n.ref, %.loc12_14, %.loc12_17)
  32. // CHECK:STDOUT: %.loc12_20.2: ref i32 = tuple_access %return, element0
  33. // CHECK:STDOUT: %.loc12_20.3: init i32 = initialize_from %n.ref to %.loc12_20.2
  34. // CHECK:STDOUT: %.loc12_20.4: ref i32 = tuple_access %return, element1
  35. // CHECK:STDOUT: %.loc12_20.5: init i32 = initialize_from %.loc12_14 to %.loc12_20.4
  36. // CHECK:STDOUT: %.loc12_20.6: ref f64 = tuple_access %return, element2
  37. // CHECK:STDOUT: %.loc12_20.7: init f64 = initialize_from %.loc12_17 to %.loc12_20.6
  38. // CHECK:STDOUT: %.loc12_20.8: init (i32, i32, f64) = tuple_init (%.loc12_20.3, %.loc12_20.5, %.loc12_20.7) to %return
  39. // CHECK:STDOUT: %.loc12_20.9: init (i32, i32, f64) = converted %.loc12_20.1, %.loc12_20.8
  40. // CHECK:STDOUT: return %.loc12_20.9
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT: