Debian Codegraph @

clang/test/CIR/CodeGen/comma.c

raw
1 // RUN: %clang_cc1 -std=c23 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
2 // RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR
3 // RUN: %clang_cc1 -std=c23 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-llvm %s -o %t-cir.ll
4 // RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM
5 // RUN: %clang_cc1 -std=c23 -triple x86_64-unknown-linux-gnu -Wno-unused-value -emit-llvm %s -o %t.ll
6 // RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG
7
8 void comma(void) {
9 bool b;
10 char c;
11 float f;
12 int i;
13
14 b = true, c = 65, f = 3.14f, i = 42;
15
16 i = 100, 200;
17 }
18
19 // CIR-LABEL: cir.func{{.*}} @comma()
20 // CIR: %[[B:.*]] = cir.alloca !cir.bool, !cir.ptr<!cir.bool>, ["b"]
21 // CIR: %[[C:.*]] = cir.alloca !s8i, !cir.ptr<!s8i>, ["c"]
22 // CIR: %[[F:.*]] = cir.alloca !cir.float, !cir.ptr<!cir.float>, ["f"]
23 // CIR: %[[I:.*]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["i"]
24 // CIR: %[[TRUE:.*]] = cir.const #true
25 // CIR: cir.store{{.*}} %[[TRUE]], %[[B]] : !cir.bool, !cir.ptr<!cir.bool>
26 // CIR: %[[CHAR_VAL:.*]] = cir.const #cir.int<65> : !s8i
27 // CIR: cir.store{{.*}} %[[CHAR_VAL]], %[[C]] : !s8i, !cir.ptr<!s8i>
28 // CIR: %[[FLOAT_VAL:.*]] = cir.const #cir.fp<3.140000e+00> : !cir.float
29 // CIR: cir.store{{.*}} %[[FLOAT_VAL]], %[[F]] : !cir.float, !cir.ptr<!cir.float>
30 // CIR: %[[INT_VAL:.*]] = cir.const #cir.int<42> : !s32i
31 // CIR: cir.store{{.*}} %[[INT_VAL]], %[[I]] : !s32i, !cir.ptr<!s32i>
32 // CIR: %[[HUNDRED:.*]] = cir.const #cir.int<100> : !s32i
33 // CIR: cir.store{{.*}} %[[HUNDRED]], %[[I]] : !s32i, !cir.ptr<!s32i>
34 // CIR: cir.return
35
36 // LLVM-LABEL: define {{.*}}void @comma(){{.*}} {
37 // LLVM: %[[B_PTR:.*]] = alloca i8
38 // LLVM: %[[C_PTR:.*]] = alloca i8
39 // LLVM: %[[F_PTR:.*]] = alloca float
40 // LLVM: %[[I_PTR:.*]] = alloca i32
41 // LLVM: store i8 1, ptr %[[B_PTR]]
42 // LLVM: store i8 65, ptr %[[C_PTR]]
43 // LLVM: store float 0x40091EB860000000, ptr %[[F_PTR]]
44 // LLVM: store i32 42, ptr %[[I_PTR]]
45 // LLVM: store i32 100, ptr %[[I_PTR]]
46 // LLVM: ret void
47
48 // OGCG-LABEL: define {{.*}}void @comma()
49 // OGCG: %[[B_PTR:.*]] = alloca i8
50 // OGCG: %[[C_PTR:.*]] = alloca i8
51 // OGCG: %[[F_PTR:.*]] = alloca float
52 // OGCG: %[[I_PTR:.*]] = alloca i32
53 // OGCG: store i8 1, ptr %[[B_PTR]]
54 // OGCG: store i8 65, ptr %[[C_PTR]]
55 // OGCG: store float 0x40091EB860000000, ptr %[[F_PTR]]
56 // OGCG: store i32 42, ptr %[[I_PTR]]
57 // OGCG: store i32 100, ptr %[[I_PTR]]
58 // OGCG: ret void