Andy Kaylor 93afd8f9ac
[CIR] Upstream support for type aliases (#131912)
CIR uses aliases for standard integer types and void. This change adds
upstream support for those aliases and updates existing tests.
2025-03-19 14:13:22 -07:00

61 lines
1.7 KiB
Plaintext

// RUN: cir-opt %s -cir-flatten-cfg -o - | FileCheck %s
!u32i = !cir.int<u, 32>
module {
cir.func @foo() {
cir.scope {
%0 = cir.alloca !u32i, !cir.ptr<!u32i>, ["a", init] {alignment = 4 : i64}
%1 = cir.const #cir.int<4> : !u32i
cir.store %1, %0 : !u32i, !cir.ptr<!u32i>
}
cir.return
}
// CHECK: cir.func @foo() {
// CHECK: cir.br ^bb1
// CHECK: ^bb1: // pred: ^bb0
// CHECK: %0 = cir.alloca !u32i, !cir.ptr<!u32i>, ["a", init] {alignment = 4 : i64}
// CHECK: %1 = cir.const #cir.int<4> : !u32i
// CHECK: cir.store %1, %0 : !u32i, !cir.ptr<!u32i>
// CHECK: cir.br ^bb2
// CHECK: ^bb2: // pred: ^bb1
// CHECK: cir.return
// CHECK: }
// Should drop empty scopes.
cir.func @empty_scope() {
cir.scope {
}
cir.return
}
// CHECK: cir.func @empty_scope() {
// CHECK: cir.return
// CHECK: }
cir.func @scope_with_return() -> !u32i {
%0 = cir.alloca !u32i, !cir.ptr<!u32i>, ["__retval"] {alignment = 4 : i64}
cir.scope {
%2 = cir.const #cir.int<0> : !u32i
cir.store %2, %0 : !u32i, !cir.ptr<!u32i>
%3 = cir.load %0 : !cir.ptr<!u32i>, !u32i
cir.return %3 : !u32i
}
%1 = cir.load %0 : !cir.ptr<!u32i>, !u32i
cir.return %1 : !u32i
}
// CHECK: cir.func @scope_with_return() -> !u32i {
// CHECK: %0 = cir.alloca !u32i, !cir.ptr<!u32i>, ["__retval"] {alignment = 4 : i64}
// CHECK: cir.br ^bb1
// CHECK: ^bb1: // pred: ^bb0
// CHECK: %1 = cir.const #cir.int<0> : !u32i
// CHECK: cir.store %1, %0 : !u32i, !cir.ptr<!u32i>
// CHECK: %2 = cir.load %0 : !cir.ptr<!u32i>, !u32i
// CHECK: cir.return %2 : !u32i
// CHECK: ^bb2: // no predecessors
// CHECK: %3 = cir.load %0 : !cir.ptr<!u32i>, !u32i
// CHECK: cir.return %3 : !u32i
// CHECK: }
}