1 // REQUIRES: msp430-registered-target
2 // RUN: %clang -target msp430 -Os -S -o- %s | FileCheck %s
5 volatile int i16_1
, i16_2
;
6 volatile long i32_1
, i32_2
;
7 volatile long long i64_1
, i64_2
;
9 volatile double d1
, d2
;
11 _Static_assert(sizeof(int) == 2, "Assumption failed");
12 _Static_assert(sizeof(long) == 4, "Assumption failed");
13 _Static_assert(sizeof(long long) == 8, "Assumption failed");
15 void complex_i16_arg_first(int _Complex x
, int n
) {
16 // CHECK-LABEL: @complex_i16_arg_first
18 // CHECK-DAG: mov r12, &i16_1
20 // CHECK-DAG: mov r13, &i16_2
22 // CHECK-DAG: mov r14, &N
26 void complex_i16_arg_second(int n
, int _Complex x
) {
27 // CHECK-LABEL: @complex_i16_arg_second
29 // CHECK-DAG: mov r12, &N
31 // CHECK-DAG: mov r13, &i16_1
33 // CHECK-DAG: mov r14, &i16_2
37 void complex_i32_arg_first(long _Complex x
, int n
) {
38 // CHECK-LABEL: @complex_i32_arg_first
40 // CHECK-DAG: mov r12, &i32_1
41 // CHECK-DAG: mov r13, &i32_1+2
43 // CHECK-DAG: mov r14, &i32_2
44 // CHECK-DAG: mov r15, &i32_2+2
46 // CHECK-DAG: mov 2(r1), &N
50 void complex_i32_arg_second(int n
, long _Complex x
) {
51 // CHECK-LABEL: @complex_i32_arg_second
53 // CHECK-DAG: mov r12, &N
55 // CHECK-DAG: mov 2(r1), &i32_1
56 // CHECK-DAG: mov 4(r1), &i32_1+2
58 // CHECK-DAG: mov 6(r1), &i32_2
59 // CHECK-DAG: mov 8(r1), &i32_2+2
63 void complex_i64_arg_first(long long _Complex x
, int n
) {
64 // CHECK-LABEL: @complex_i64_arg_first
66 // CHECK-DAG: mov 2(r1), &i64_1
67 // CHECK-DAG: mov 4(r1), &i64_1+2
68 // CHECK-DAG: mov 6(r1), &i64_1+4
69 // CHECK-DAG: mov 8(r1), &i64_1+6
71 // CHECK-DAG: mov 10(r1), &i64_2
72 // CHECK-DAG: mov 12(r1), &i64_2+2
73 // CHECK-DAG: mov 14(r1), &i64_2+4
74 // CHECK-DAG: mov 16(r1), &i64_2+6
76 // CHECK-DAG: mov r12, &N
80 void complex_i64_arg_second(int n
, long long _Complex x
) {
81 // CHECK-LABEL: @complex_i64_arg_second
83 // CHECK-DAG: mov r12, &N
85 // CHECK-DAG: mov 2(r1), &i64_1
86 // CHECK-DAG: mov 4(r1), &i64_1+2
87 // CHECK-DAG: mov 6(r1), &i64_1+4
88 // CHECK-DAG: mov 8(r1), &i64_1+6
90 // CHECK-DAG: mov 10(r1), &i64_2
91 // CHECK-DAG: mov 12(r1), &i64_2+2
92 // CHECK-DAG: mov 14(r1), &i64_2+4
93 // CHECK-DAG: mov 16(r1), &i64_2+6
97 void complex_float_arg_first(float _Complex x
, int n
) {
98 // CHECK-LABEL: @complex_float_arg_first
100 // CHECK-DAG: mov r12, &f1
101 // CHECK-DAG: mov r13, &f1+2
103 // CHECK-DAG: mov r14, &f2
104 // CHECK-DAG: mov r15, &f2+2
106 // CHECK-DAG: mov 2(r1), &N
110 void complex_float_arg_second(int n
, float _Complex x
) {
111 // CHECK-LABEL: @complex_float_arg_second
113 // CHECK-DAG: mov r12, &N
115 // CHECK-DAG: mov 2(r1), &f1
116 // CHECK-DAG: mov 4(r1), &f1+2
118 // CHECK-DAG: mov 6(r1), &f2
119 // CHECK-DAG: mov 8(r1), &f2+2
123 void complex_double_arg_first(double _Complex x
, int n
) {
124 // CHECK-LABEL: @complex_double_arg_first
126 // CHECK-DAG: mov 2(r1), &d1
127 // CHECK-DAG: mov 4(r1), &d1+2
128 // CHECK-DAG: mov 6(r1), &d1+4
129 // CHECK-DAG: mov 8(r1), &d1+6
131 // CHECK-DAG: mov 10(r1), &d2
132 // CHECK-DAG: mov 12(r1), &d2+2
133 // CHECK-DAG: mov 14(r1), &d2+4
134 // CHECK-DAG: mov 16(r1), &d2+6
136 // CHECK-DAG: mov r12, &N
140 void complex_double_arg_second(int n
, double _Complex x
) {
141 // CHECK-LABEL: @complex_double_arg_second
143 // CHECK-DAG: mov 2(r1), &d1
144 // CHECK-DAG: mov 4(r1), &d1+2
145 // CHECK-DAG: mov 6(r1), &d1+4
146 // CHECK-DAG: mov 8(r1), &d1+6
148 // CHECK-DAG: mov 10(r1), &d2
149 // CHECK-DAG: mov 12(r1), &d2+2
150 // CHECK-DAG: mov 14(r1), &d2+4
151 // CHECK-DAG: mov 16(r1), &d2+6
153 // CHECK-DAG: mov r12, &N
157 int _Complex
complex_i16_res(void) {
158 // CHECK-LABEL: @complex_i16_res
160 __real__ res
= 0x1122;
161 // CHECK-DAG: mov #4386, r12
162 __imag__ res
= 0x3344;
163 // CHECK-DAG: mov #13124, r13
168 long _Complex
complex_i32_res(void) {
169 // CHECK-LABEL: @complex_i32_res
171 __real__ res
= 0x11223344;
172 // CHECK-DAG: mov #13124, r12
173 // CHECK-DAG: mov #4386, r13
174 __imag__ res
= 0x55667788;
175 // CHECK-DAG: mov #30600, r14
176 // CHECK-DAG: mov #21862, r15
181 long long _Complex
complex_i64_res(void) {
182 // CHECK-LABEL: @complex_i64_res
183 long long _Complex res
;
184 __real__ res
= 0x1122334455667788;
185 // CHECK-DAG: mov #30600, 0(r12)
186 // CHECK-DAG: mov #21862, 2(r12)
187 // CHECK-DAG: mov #13124, 4(r12)
188 // CHECK-DAG: mov #4386, 6(r12)
189 __imag__ res
= 0x99aabbccddeeff00;
190 // CHECK-DAG: mov #-256, 8(r12)
191 // CHECK-DAG: mov #-8722, 10(r12)
192 // CHECK-DAG: mov #-17460, 12(r12)
193 // CHECK-DAG: mov #-26198, 14(r12)
198 float _Complex
complex_float_res(void) {
199 // CHECK-LABEL: @complex_float_res
202 // CHECK-DAG: clr r12
203 // CHECK-DAG: mov #16256, r13
205 // CHECK-DAG: clr r14
206 // CHECK-DAG: mov #-16512, r15
211 double _Complex
complex_double_res(void) {
212 // CHECK-LABEL: @complex_double_res
215 // CHECK-DAG: clr 0(r12)
216 // CHECK-DAG: clr 2(r12)
217 // CHECK-DAG: clr 4(r12)
218 // CHECK-DAG: mov #16368, 6(r12)
220 // CHECK-DAG: clr 8(r12)
221 // CHECK-DAG: clr 10(r12)
222 // CHECK-DAG: clr 12(r12)
223 // CHECK-DAG: mov #-16400, 14(r12)