| 1 |
// RUN: cir-opt %s -cir-to-llvm -o %t.mlir |
| 2 |
// RUN: FileCheck --input-file=%t.mlir %s |
| 3 |
|
| 4 |
!s32i = !cir.int<s, 32> |
| 5 |
!u8i = !cir.int<u, 8> |
| 6 |
!ty_S = !cir.record<struct "S" {!u8i, !s32i}> |
| 7 |
|
| 8 |
module { |
| 9 |
// CHECK-LABEL: @test_value |
| 10 |
cir.func @test_value() { |
| 11 |
%0 = cir.const #cir.const_record<{#cir.int<1> : !u8i, #cir.int<2> : !s32i}> : !ty_S |
| 12 |
// CHECK: %[[#v0:]] = llvm.mlir.undef : !llvm.struct<"struct.S", (i8, i32)> |
| 13 |
// CHECK-NEXT: %[[#v1:]] = llvm.mlir.constant(1 : i8) : i8 |
| 14 |
// CHECK-NEXT: %[[#v2:]] = llvm.insertvalue %[[#v1]], %[[#v0]][0] : !llvm.struct<"struct.S", (i8, i32)> |
| 15 |
// CHECK-NEXT: %[[#v3:]] = llvm.mlir.constant(2 : i32) : i32 |
| 16 |
// CHECK-NEXT: %[[#v4:]] = llvm.insertvalue %[[#v3]], %[[#v2]][1] : !llvm.struct<"struct.S", (i8, i32)> |
| 17 |
%1 = cir.extract_member %0[0] : !ty_S -> !u8i |
| 18 |
// CHECK-NEXT: %{{.+}} = llvm.extractvalue %[[#v4]][0] : !llvm.struct<"struct.S", (i8, i32)> |
| 19 |
%2 = cir.extract_member %0[1] : !ty_S -> !s32i |
| 20 |
// CHECK-NEXT: %{{.+}} = llvm.extractvalue %[[#v4]][1] : !llvm.struct<"struct.S", (i8, i32)> |
| 21 |
cir.return |
| 22 |
} |
| 23 |
} |