Debian Codegraph @

clang/test/CIR/CodeGen/mms-bitfields.c

raw
1 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fms-layout-compatibility=microsoft -fclangir -emit-cir %s -o %t.cir
2 // RUN: FileCheck --input-file=%t.cir %s --check-prefix=CIR
3 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fms-layout-compatibility=microsoft -fclangir -emit-llvm %s -o %t-cir.ll
4 // RUN: FileCheck --input-file=%t-cir.ll %s --check-prefix=LLVM
5 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fms-layout-compatibility=microsoft -emit-llvm %s -o %t.ll
6 // RUN: FileCheck --input-file=%t.ll %s --check-prefix=OGCG
7
8 struct s1 {
9 int f32 : 2;
10 long long f64 : 30;
11 } s1;
12
13 // CIR-DAG: !rec_s1 = !cir.record<struct "s1" {!s32i, !s64i}>
14 // LLVM-DAG: %struct.s1 = type { i32, i64 }
15 // OGCG-DAG: %struct.s1 = type { i32, i64 }
16
17 struct s2 {
18 int a : 24;
19 char b;
20 int c : 30;
21 } Clip;
22
23 // CIR-DAG: !rec_s2 = !cir.record<struct "s2" {!s32i, !s8i, !s32i}>
24 // LLVM-DAG: %struct.s2 = type { i32, i8, i32 }
25 // OGCG-DAG: %struct.s2 = type { i32, i8, i32 }
26
27 struct s3 {
28 int a : 18;
29 int : 0;
30 int c : 14;
31 } zero_bit;
32
33 // CIR-DAG: !rec_s3 = !cir.record<struct "s3" {!s32i, !s32i}>
34 // LLVM-DAG: %struct.s3 = type { i32, i32 }
35 // OGCG-DAG: %struct.s3 = type { i32, i32 }
36
37 #pragma pack (push,1)
38
39 struct Inner {
40 unsigned int A : 1;
41 unsigned int B : 1;
42 unsigned int C : 1;
43 unsigned int D : 30;
44 } Inner;
45
46 #pragma pack (pop)
47
48 // CIR-DAG: !rec_Inner = !cir.record<struct "Inner" {!u32i, !u32i}>
49 // LLVM-DAG: %struct.Inner = type { i32, i32 }
50 // OGCG-DAG: %struct.Inner = type { i32, i32 }
51
52 #pragma pack(push, 1)
53
54 union HEADER {
55 struct A {
56 int : 3; // Bits 2:0
57 int a : 9; // Bits 11:3
58 int : 12; // Bits 23:12
59 int b : 17; // Bits 40:24
60 int : 7; // Bits 47:41
61 int c : 4; // Bits 51:48
62 int : 4; // Bits 55:52
63 int d : 3; // Bits 58:56
64 int : 5; // Bits 63:59
65 } Bits;
66 } HEADER;
67
68 #pragma pack(pop)
69
70 // CIR-DAG: !rec_A = !cir.record<struct "A" {!s32i, !s32i, !s32i}>
71 // CIR-DAG: !rec_HEADER = !cir.record<union "HEADER" {!rec_A}>
72 // LLVM-DAG: %struct.A = type { i32, i32, i32 }
73 // LLVM-DAG: %union.HEADER = type { %struct.A }
74 // OGCG-DAG: %struct.A = type { i32, i32, i32 }
75 // OGCG-DAG: %union.HEADER = type { %struct.A }