1 // RUN: %clang_cc1 -triple thumbv8m.main -O0 -mcmse -S -emit-llvm %s -o - | \
2 // RUN: FileCheck %s --check-prefixes=CHECK,CHECK-LE,CHECK-SOFTFP
3 // RUN: %clang_cc1 -triple thumbebv8m.main -O0 -mcmse -S -emit-llvm %s -o - | \
4 // RUN: FileCheck %s --check-prefixes=CHECK,CHECK-BE,CHECK-SOFTFP
5 // RUN: %clang_cc1 -triple thumbv8m.main -O2 -mcmse -S -emit-llvm %s -o - | \
6 // RUN: FileCheck %s --check-prefixes=CHECK,CHECK-LE,CHECK-SOFTFP
7 // RUN: %clang_cc1 -triple thumbebv8m.main -O2 -mcmse -S -emit-llvm %s -o - | \
8 // RUN: FileCheck %s --check-prefixes=CHECK,CHECK-BE,CHECK-SOFTFP
9 // RUN: %clang_cc1 -triple thumbv8m.main -O0 -mcmse -mfloat-abi hard \
10 // RUN: -S -emit-llvm %s -o - | \
11 // RUN: FileCheck %s --check-prefixes=CHECK,CHECK-LE,CHECK-HARDFP
13 // We don't really need to repeat *all* the test cases from cmse-clear-return.c
14 // as it won't increase test coverage.
16 // : Memory layout | Mask
17 // LE: .......1 ........ ........ ........ | 0x00000001/1
18 // BE: 1....... ........ ........ ........ | 0x80000000/-2147483648
23 void __attribute__((cmse_nonsecure_call
)) (*g0
)(T0
);
26 void f0(void) { g0(t0
); }
27 // CHECK: define {{.*}} @f0()
28 // CHECK-LE: %[[V0:.*]] = and i32 {{.*}}, 1
29 // CHECK-BE: %[[V0:.*]] = and i32 {{.*}}, -2147483648
30 // CHECK: %[[V1:.*]] = insertvalue [1 x i32] poison, i32 %[[V0]], 0
31 // CHECK: call {{.*}} void %0([1 x i32] %[[V1]])
33 // LE: 11111111 111111.. 11111111 11111111 0xfffffcff/-769
34 // BE: 11111111 ..111111 11111111 11111111 0xff3fffff/-12582913
44 void __attribute__((cmse_nonsecure_call
)) (*g8
)(T8
);
45 void f8(void) { g8(t8
); }
46 // CHECK: define {{.*}} @f8()
47 // CHECK-LE: %[[V0:.*]] = and i32 {{.*}}, -769
48 // CHECK-BE: %[[V0:.*]] = and i32 {{.*}}, -12582913
49 // CHECK: %[[V1:.*]] = insertvalue [1 x i32] poison, i32 %[[V0]], 0
50 // CHECK: call {{.*}} void %0([1 x i32] %[[V1]])
52 // LE(0): 11111111 ........ 11111111 11111111 0xffff00ff/-65281
53 // LE(4): ...111.. 11111... 11111111 .....111 0x7fff81c/134215708
54 // BE(0): 11111111 ........ 11111111 11111111 0xff00ffff/-16711681
55 // BE(4): ..111... ...11111 11111111 111..... 0x381fffe0/941621216
59 int : 2, c
: 3, : 6, d
: 16;
64 void __attribute__((cmse_nonsecure_call
)) (*g15_0
)(T15
);
68 // CHECK: define {{.*}}@f15_0()
69 // CHECK: %[[FN:.*]] = load {{.*}} @g15_0
70 // CHECK-LE: %cmse.clear = and i32 {{.*}}, -65281
71 // CHECK-BE: %cmse.clear = and i32 {{.*}}, -16711681
72 // CHECK: %[[R0:.*]] = insertvalue [2 x i32] poison, i32 %cmse.clear, 0
73 // CHECK-LE: %cmse.clear1 = and i32 {{.*}}, 134215708
74 // CHECK-BE: %cmse.clear1 = and i32 {{.*}}, 941621216
75 // CHECK: %[[R1:.*]] = insertvalue [2 x i32] %[[R0]], i32 %cmse.clear1, 1
76 // CHECK: call {{.*}} void %[[FN]]([2 x i32] %[[R1]])
78 void __attribute__((cmse_nonsecure_call
)) (*g15_1
)(int, int, int, T15
);
82 // CHECK: define {{.*}}@f15_1()
83 // CHECK: %[[FN:.*]] = load {{.*}} @g15_1
84 // CHECK-LE: %cmse.clear = and i32 {{.*}}, -65281
85 // CHECK-BE: %cmse.clear = and i32 {{.*}}, -16711681
86 // CHECK: %[[R0:.*]] = insertvalue [2 x i32] poison, i32 %cmse.clear, 0
87 // CHECK-LE: %cmse.clear1 = and i32 {{.*}}, 134215708
88 // CHECK-BE: %cmse.clear1 = and i32 {{.*}}, 941621216
89 // CHECK: %[[R1:.*]] = insertvalue [2 x i32] %[[R0]], i32 %cmse.clear1, 1
90 // CHECK: call {{.*}} void %[[FN]](i32 noundef 0, i32 noundef 1, i32 noundef 2, [2 x i32] %[[R1]])
92 // LE: 11111111 ........ 11111111 11111111 1111.... ...11111 ........ .111111.
93 // LE: 0xff00fffff01f007e/9079291968726434047
94 // BE: 11111111 ........ 11111111 11111111 ....1111 11111... ........ .111111.
95 // BE: 0xff00ffff0ff8007e/-71776123088273282
100 long long : 4, c
: 9, : 12, d
: 6;
105 void __attribute__((cmse_nonsecure_call
)) (*g16_0
)(T16
);
109 // CHECK: define {{.*}} @f16_0()
110 // CHECK: %[[FN:.*]] = load {{.*}} @g16_0
111 // CHECK-LE: %cmse.clear = and i64 {{.*}}, 9079291968726434047
112 // CHECK-BE: %cmse.clear = and i64 {{.*}}, -71776123088273282
113 // CHECK: %[[R:.*]] = insertvalue [1 x i64] poison, i64 %cmse.clear, 0
114 // CHECK: call {{.*}} void %0([1 x i64] %[[R]])
117 // LE0: 1111..11 .......1 1111..11 .......1 1111..11 .......1 1111..11 .......1
118 // LE4: 1111..11 .......1 1111..11 .......1 11111111 11111111 11111111 ........
119 // LE : 0x01f301f3/32702963 * 3 + 0x00ffffff/16777215
120 // BE0: 11..1111 1....... 11..1111 1....... 11..1111 1....... 11..1111 1.......
121 // BE4: 11..1111 1....... 11..1111 1....... 11111111 11111111 11111111 ........
122 // BE : 0xcf80cf80/-813641856 * 3 + 0xffffff00/-256
135 void __attribute__((cmse_nonsecure_call
)) (*g18
)(T18
);
139 // CHECK: define {{.*}} @f18()
140 // CHECK: %[[FN:.*]] = load {{.*}} @g18
141 // CHECK-LE: %cmse.clear = and i32 {{.*}}, 32702963
142 // CHECK-BE: %cmse.clear = and i32 {{.*}}, -813641856
143 // CHECK: %[[R0:.*]] = insertvalue [4 x i32] poison, i32 %cmse.clear, 0
144 // CHECK-LE: %cmse.clear1 = and i32 {{.*}}, 32702963
145 // CHECK-BE: %cmse.clear1 = and i32 {{.*}}, -813641856
146 // CHECK: %[[R1:.*]] = insertvalue [4 x i32] %[[R0]], i32 %cmse.clear1, 1
147 // CHECK-LE: %cmse.clear2 = and i32 {{.*}}, 32702963
148 // CHECK-BE: %cmse.clear2 = and i32 {{.*}}, -813641856
149 // CHECK: %[[R2:.*]] = insertvalue [4 x i32] %[[R1]], i32 %cmse.clear2, 2
150 // CHECK-LE: %cmse.clear3 = and i32 {{.*}}, 16777215
151 // CHECK-BE: %cmse.clear3 = and i32 {{.*}}, -256
152 // CHECK: %[[R3:.*]] = insertvalue [4 x i32] %[[R2]], i32 %cmse.clear3, 3
153 // CHECK: call {{.*}} void %[[FN]]([4 x i32] %[[R3]])
155 // LE: 11111111 11111111 ..111... ..111... 0x3838ffff/943259647
156 // BE: 11111111 11111111 ...111.. ...111.. 0xffff1c1c/-58340
165 void __attribute__((cmse_nonsecure_call
)) (*g19
)(T19
);
169 // CHECK: define {{.*}} @f19()
170 // CHECK: %[[FN:.*]] = load {{.*}} @g19
171 // CHECK-LE: %cmse.clear = and i32 {{.*}}, 943259647
172 // CHECK-BE: %cmse.clear = and i32 {{.*}}, -58340
173 // CHECK: %[[R:.*]] = insertvalue [1 x i32] poison, i32 %cmse.clear, 0
174 // CHECK: call {{.*}} void %[[FN]]([1 x i32] %[[R]])
182 void __attribute__((cmse_nonsecure_call
)) (*g20
)(T20
);
186 // CHECK: define {{.*}} @f20()
187 // CHECK: %[[FN:.*]] = load {{.*}} @g20
188 // CHECK-SOFTFP: call arm_aapcscc void %[[FN]]([2 x i32]
189 // CHECK-HARDFP: call arm_aapcs_vfpcc void %[[FN]](%struct.T20