Files
carbon-lang/toolchain/check/testdata/basics/textual_ir.carbon
T
Richard Smith 6d5e62974c Add SemIR instruction to track that a conversion was performed. (#3363)
Instead of ad-hoc conversion tracking on some kinds of nodes that
conversion creates, consolidate tracking into a single node kind. This
frees up an operand on `Init` instructions that can be used to store the
destination.
2023-11-09 23:58:54 +00:00

40 lines
1.7 KiB
Plaintext

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// ARGS: compile --phase=check --dump-sem-ir %s
//
// Check that the command-line flag to dump textual IR works.
//
// AUTOUPDATE
fn Foo(n: i32) -> (i32, f64) {
return (n + 2, 3.4);
}
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %.loc11_28.1: type = tuple_type (type, type)
// CHECK:STDOUT: %.loc11_28.2: type = tuple_type (i32, f64)
// CHECK:STDOUT: %.loc11_28.3: type = ptr_type (i32, f64)
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file "textual_ir.carbon" {
// CHECK:STDOUT: %Foo: <function> = fn_decl @Foo
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%n: i32) -> %return: (i32, f64) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %n.ref: i32 = name_reference n, %n
// CHECK:STDOUT: %.loc12_15: i32 = int_literal 2
// CHECK:STDOUT: %.loc12_13: i32 = add %n.ref, %.loc12_15
// CHECK:STDOUT: %.loc12_18: f64 = real_literal 34e-1
// CHECK:STDOUT: %.loc12_21.1: (i32, f64) = tuple_literal (%.loc12_13, %.loc12_18)
// CHECK:STDOUT: %.loc12_21.2: ref i32 = tuple_access %return, member0
// CHECK:STDOUT: %.loc12_21.3: init i32 = initialize_from %.loc12_13 to %.loc12_21.2
// CHECK:STDOUT: %.loc12_21.4: ref f64 = tuple_access %return, member1
// CHECK:STDOUT: %.loc12_21.5: init f64 = initialize_from %.loc12_18 to %.loc12_21.4
// CHECK:STDOUT: %.loc12_21.6: init (i32, f64) = tuple_init (%.loc12_21.3, %.loc12_21.5) to %return
// CHECK:STDOUT: %.loc12_21.7: init (i32, f64) = converted %.loc12_21.1, %.loc12_21.6
// CHECK:STDOUT: return %.loc12_21.7
// CHECK:STDOUT: }