brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.8 KiB · 14a2aaf Raw
72 lines · c
1// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir2// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CIR3// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t-cir.ll4// RUN: FileCheck --input-file=%t-cir.ll %s --check-prefix=LLVM5// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll6// RUN: FileCheck --input-file=%t.ll %s --check-prefix=OGCG7 8typedef union {9  int x;10  int y : 4;11  int z : 8;12} demo;13 14// CIR:  !rec_demo = !cir.record<union "demo" {!s32i, !u8i, !u8i}>15// LLVM: %union.demo = type { i32 }16// OGCG: %union.demo = type { i32 }17 18typedef union {19  int x;20  int y : 3;21  int   : 0;22  int z : 2;23} zero_bit;24 25// CIR:  !rec_zero_bit = !cir.record<union "zero_bit" {!s32i, !u8i, !u8i}>26// LLVM: %union.zero_bit = type { i32 }27// OGCG: %union.zero_bit = type { i32 }28 29demo d;30zero_bit z;31 32void f() {33    demo d;34    d.x = 1;35    d.y = 2;36    d.z = 0;37}38 39// CIR: #bfi_y = #cir.bitfield_info<name = "y", storage_type = !u8i, size = 4, offset = 0, is_signed = true>40// CIR: #bfi_z = #cir.bitfield_info<name = "z", storage_type = !u8i, size = 8, offset = 0, is_signed = true>41 42// CIR:   cir.func no_proto dso_local @f43// CIR:    [[ALLOC:%.*]] = cir.alloca !rec_demo, !cir.ptr<!rec_demo>, ["d"] {alignment = 4 : i64}44// CIR:    [[ONE:%.*]] = cir.const #cir.int<1> : !s32i45// CIR:    [[X:%.*]] = cir.get_member [[ALLOC]][0] {name = "x"} : !cir.ptr<!rec_demo> -> !cir.ptr<!s32i>46// CIR:    cir.store align(4) [[ONE]], [[X]] : !s32i, !cir.ptr<!s32i>47// CIR:    [[TWO:%.*]] = cir.const #cir.int<2> : !s32i48// CIR:    [[Y:%.*]] = cir.get_member [[ALLOC]][1] {name = "y"} : !cir.ptr<!rec_demo> -> !cir.ptr<!u8i>49// CIR:    [[SET:%.*]] = cir.set_bitfield align(4) (#bfi_y, [[Y]] : !cir.ptr<!u8i>, [[TWO]] : !s32i) -> !s32i50// CIR:    [[ZERO:%.*]] = cir.const #cir.int<0> : !s32i51// CIR:    [[Z:%.*]] = cir.get_member [[ALLOC]][2] {name = "z"} : !cir.ptr<!rec_demo> -> !cir.ptr<!u8i>52// CIR:    [[SET2:%.*]] = cir.set_bitfield align(4) (#bfi_z, [[Z]] : !cir.ptr<!u8i>, [[ZERO]] : !s32i) -> !s32i53// CIR:    cir.return54 55// LLVM: define dso_local void @f56// LLVM:   [[ALLOC:%.*]] = alloca %union.demo, i64 1, align 457// LLVM:   store i32 1, ptr [[ALLOC]], align 458// LLVM:   [[BFLOAD:%.*]] = load i8, ptr [[ALLOC]], align 459// LLVM:   [[CLEAR:%.*]] = and i8 [[BFLOAD]], -1660// LLVM:   [[SET:%.*]] = or i8 [[CLEAR]], 261// LLVM:   store i8 [[SET]], ptr [[ALLOC]], align 462// LLVM:   store i8 0, ptr [[ALLOC]], align 463 64// OGCG: define dso_local void @f65// OGCG:   [[ALLOC:%.*]] = alloca %union.demo, align 466// OGCG:   store i32 1, ptr [[ALLOC]], align 467// OGCG:   [[BFLOAD:%.*]] = load i8, ptr [[ALLOC]], align 468// OGCG:   [[CLEAR:%.*]] = and i8 [[BFLOAD]], -1669// OGCG:   [[SET:%.*]] = or i8 [[CLEAR]], 270// OGCG:   store i8 [[SET]], ptr [[ALLOC]], align 471// OGCG:   store i8 0, ptr [[ALLOC]], align 472