Debian Codegraph @

clang/test/CIR/Lowering/inline-asm.cir

raw
1 // RUN: cir-translate %s -cir-to-llvmir --target x86_64-unknown-linux-gnu --disable-cc-lowering | FileCheck %s
2
3 !s32i = !cir.int<s, 32>
4 !u32i = !cir.int<u, 32>
5
6 module {
7 cir.func @f1() {
8 // CHECK: call void asm "", "~{dirflag},~{fpsr},~{flags}"()
9 cir.asm(x86_att,
10 out = [],
11 in = [],
12 in_out = [],
13 {"" "~{dirflag},~{fpsr},~{flags}"})
14 cir.return
15 }
16
17 cir.func @f2() {
18 // CHECK: call void asm sideeffect "", "~{dirflag},~{fpsr},~{flags}"()
19 cir.asm(x86_att,
20 out = [],
21 in = [],
22 in_out = [],
23 {"" "~{dirflag},~{fpsr},~{flags}"}) side_effects
24 cir.return
25 }
26
27 cir.func @f3() {
28 // CHECK: call void asm sideeffect "abc", "~{dirflag},~{fpsr},~{flags}"()
29 cir.asm(x86_att,
30 out = [],
31 in = [],
32 in_out = [],
33 {"abc" "~{dirflag},~{fpsr},~{flags}"}) side_effects
34 cir.return
35 }
36
37 cir.func @f4(%arg0: !s32i) {
38 %0 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init] {alignment = 4 : i64}
39 cir.store %arg0, %0 : !s32i, !cir.ptr<!s32i>
40 // CHECK: call void asm sideeffect "", "*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i32) %2)
41 cir.asm(x86_att,
42 out = [],
43 in = [%0 : !cir.ptr<!s32i> (maybe_memory)],
44 in_out = [],
45 {"" "*m,~{dirflag},~{fpsr},~{flags}"}) side_effects
46 cir.return
47 }
48
49 cir.func @f5() {
50 // CHECK: call void asm inteldialect "", "~{dirflag},~{fpsr},~{flags}"()
51 cir.asm(x86_intel,
52 out = [],
53 in = [],
54 in_out = [],
55 {"" "~{dirflag},~{fpsr},~{flags}"})
56 cir.return
57 }
58
59 cir.func @f6() -> !s32i {
60 %0 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init] {alignment = 4 : i64}
61 // CHECK: %2 = call i32 asm sideeffect "movl $$42, $0", "=r,~{dirflag},~{fpsr},~{flags}"()
62 %1 = cir.asm(x86_att,
63 out = [],
64 in = [],
65 in_out = [],
66 {"movl $$42, $0" "=r,~{dirflag},~{fpsr},~{flags}"}) side_effects -> !s32i
67 cir.store align(4) %1, %0 : !s32i, !cir.ptr<!s32i>
68 %3 = cir.load align(4) %0 : !cir.ptr<!s32i>, !s32i
69 cir.return %3 : !s32i
70 }
71
72 cir.func @f7(%arg0: !u32i) -> !u32i {
73 %0 = cir.alloca !u32i, !cir.ptr<!u32i>, ["x", init] {alignment = 4 : i64}
74 cir.store %arg0, %0 : !u32i, !cir.ptr<!u32i>
75 %1 = cir.load align(4) %0 : !cir.ptr<!u32i>, !u32i
76 // CHECK: %4 = call i32 asm sideeffect "addl $$42, $0", "=r,0,~{dirflag},~{fpsr},~{flags}"(i32 %3)
77 %2 = cir.asm(x86_att,
78 out = [],
79 in = [],
80 in_out = [%1 : !u32i],
81 {"addl $$42, $0" "=r,0,~{dirflag},~{fpsr},~{flags}"}) side_effects -> !u32i
82 cir.store align(4) %2, %0 : !u32i, !cir.ptr<!u32i>
83 %3 = cir.load align(4) %0 : !cir.ptr<!u32i>, !u32i
84 cir.return %3 : !u32i
85 }
86 }