Files
carbon-lang/toolchain/semantics/testdata/pointer/basic.carbon
T
Richard SmithandChandler Carruth 6cbf280a68 Add formatted textual IR output (#3056)
Add a textual IR format to the toolchain.

The exact details of the format are somewhat arbitrary right now, and I
expect them to change as we refine the semantics IR model, but at the
moment they're somewhat directly following the current structure of the
IR.

Semantics tests currently test both the "raw" format, which shows the
details of the representation, and the textual format, which is somewhat
higher level. We may want to revisit that decision once the textual
format is a bit more stable, and test only the textual format in most of
these tests, but for now it seems prudent to keep both sets of tests.

---------

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2023-08-10 19:41:39 +00:00

85 lines
2.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
//
// AUTOUPDATE
fn F() -> i32 {
var n: i32 = 0;
var p: i32* = &n;
return *p;
}
// CHECK:STDOUT: cross_reference_irs_size: 1
// CHECK:STDOUT: functions: [
// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: {block2}}},
// CHECK:STDOUT: ]
// CHECK:STDOUT: integer_literals: [
// CHECK:STDOUT: 0,
// CHECK:STDOUT: ]
// CHECK:STDOUT: real_literals: [
// CHECK:STDOUT: ]
// CHECK:STDOUT: strings: [
// CHECK:STDOUT: F,
// CHECK:STDOUT: n,
// CHECK:STDOUT: p,
// CHECK:STDOUT: ]
// CHECK:STDOUT: types: [
// CHECK:STDOUT: nodeIntegerType,
// CHECK:STDOUT: node+5,
// CHECK:STDOUT: ]
// CHECK:STDOUT: type_blocks: [
// CHECK:STDOUT: ]
// CHECK:STDOUT: nodes: [
// CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0},
// CHECK:STDOUT: {kind: VarStorage, type: type0},
// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0},
// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0},
// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+3},
// CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType},
// CHECK:STDOUT: {kind: VarStorage, type: type1},
// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+6, type: type1},
// CHECK:STDOUT: {kind: AddressOf, arg0: node+1, type: type1},
// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+8},
// CHECK:STDOUT: {kind: Dereference, arg0: node+6, type: type0},
// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+10},
// CHECK:STDOUT: ]
// CHECK:STDOUT: node_blocks: [
// CHECK:STDOUT: [
// CHECK:STDOUT: ],
// CHECK:STDOUT: [
// CHECK:STDOUT: node+0,
// CHECK:STDOUT: ],
// CHECK:STDOUT: [
// CHECK:STDOUT: node+1,
// CHECK:STDOUT: node+2,
// CHECK:STDOUT: node+3,
// CHECK:STDOUT: node+4,
// CHECK:STDOUT: node+5,
// CHECK:STDOUT: node+6,
// CHECK:STDOUT: node+7,
// CHECK:STDOUT: node+8,
// CHECK:STDOUT: node+9,
// CHECK:STDOUT: node+10,
// CHECK:STDOUT: node+11,
// CHECK:STDOUT: ],
// CHECK:STDOUT: ]
// CHECK:STDOUT:
// CHECK:STDOUT: package {
// CHECK:STDOUT: %.loc7 = fn_decl @F
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F() -> i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %n: i32 = var
// CHECK:STDOUT: %.loc8: i32 = int_value 0
// CHECK:STDOUT: assign %n, %.loc8
// CHECK:STDOUT: %.loc9_13: type = ptr_type i32
// CHECK:STDOUT: %p: i32* = var
// CHECK:STDOUT: %.loc9_17: i32* = address_of %n
// CHECK:STDOUT: assign %p, %.loc9_17
// CHECK:STDOUT: %.loc11: i32 = dereference %p
// CHECK:STDOUT: return %.loc11
// CHECK:STDOUT: }