1// RUN: %clang_cc1 -triple i686 %s -emit-llvm -o - | FileCheck %s
2// RUN: %clang_cc1 -triple x86_64 %s -emit-llvm -o - | FileCheck %s
3// RUN: %clang_cc1 -triple arm %s -emit-llvm -o - | FileCheck %s
4// RUN: %clang_cc1 -triple mips %s -emit-llvm -o - | FileCheck %s
5// RUN: %clang_cc1 -triple mipsel %s -emit-llvm -o - | FileCheck %s
6// RUN: %clang_cc1 -triple powerpc %s -emit-llvm -o - | FileCheck %s
7// RUN: %clang_cc1 -triple powerpc64 %s -emit-llvm -o - | FileCheck %s
8// RUN: %clang_cc1 -triple s390x %s -emit-llvm -o - | FileCheck %s
9// RUN: %clang_cc1 -triple sparc %s -emit-llvm -o - | FileCheck %s
10// RUN: %clang_cc1 -triple sparcv9 %s -emit-llvm -o - | FileCheck %s
11// RUN: %clang_cc1 -triple thumb %s -emit-llvm -o - | FileCheck %s
12
13int mout0;
14int min1;
15int marray[2];
16
17// CHECK: @single_m
18void single_m()
19{
20  // CHECK: call void asm "foo $1,$0", "=*m,*m[[CLOBBERS:[a-zA-Z0-9@%{},~_$ ]*\"]](i32* {{[a-zA-Z0-9@%]+}}, i32* {{[a-zA-Z0-9@%]+}})
21  asm("foo %1,%0" : "=m" (mout0) : "m" (min1));
22}
23
24// CHECK: @single_o
25void single_o()
26{
27  register int out0 = 0;
28  register int index = 1;
29  // Doesn't really do an offset...
30  //asm("foo %1, %2,%0" : "=r" (out0) : "o" (min1));
31}
32
33// CHECK: @single_V
34void single_V()
35{
36//  asm("foo %1,%0" : "=m" (mout0) : "V" (min1));
37}
38
39// CHECK: @single_lt
40void single_lt()
41{
42  register int out0 = 0;
43  register int in1 = 1;
44  // CHECK: call i32 asm "foo $1,$0", "=r,<r[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
45  asm("foo %1,%0" : "=r" (out0) : "<r" (in1));
46  // CHECK: call i32 asm "foo $1,$0", "=r,r<[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
47  asm("foo %1,%0" : "=r" (out0) : "r<" (in1));
48}
49
50// CHECK: @single_gt
51void single_gt()
52{
53  register int out0 = 0;
54  register int in1 = 1;
55  // CHECK: call i32 asm "foo $1,$0", "=r,>r[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
56  asm("foo %1,%0" : "=r" (out0) : ">r" (in1));
57  // CHECK: call i32 asm "foo $1,$0", "=r,r>[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
58  asm("foo %1,%0" : "=r" (out0) : "r>" (in1));
59}
60
61// CHECK: @single_r
62void single_r()
63{
64  register int out0 = 0;
65  register int in1 = 1;
66  // CHECK: call i32 asm "foo $1,$0", "=r,r[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
67  asm("foo %1,%0" : "=r" (out0) : "r" (in1));
68}
69
70// CHECK: @single_i
71void single_i()
72{
73  register int out0 = 0;
74  // CHECK: call i32 asm "foo $1,$0", "=r,i[[CLOBBERS]](i32 1)
75  asm("foo %1,%0" : "=r" (out0) : "i" (1));
76}
77
78// CHECK: @single_n
79void single_n()
80{
81  register int out0 = 0;
82  // CHECK: call i32 asm "foo $1,$0", "=r,n[[CLOBBERS]](i32 1)
83  asm("foo %1,%0" : "=r" (out0) : "n" (1));
84}
85
86// CHECK: @single_E
87void single_E()
88{
89  register double out0 = 0.0;
90  // CHECK: call double asm "foo $1,$0", "=r,E[[CLOBBERS]](double {{[0-9.eE+-]+}})
91  asm("foo %1,%0" : "=r" (out0) : "E" (1.0e+01));
92}
93
94// CHECK: @single_F
95void single_F()
96{
97  register double out0 = 0.0;
98  // CHECK: call double asm "foo $1,$0", "=r,F[[CLOBBERS]](double {{[0-9.eE+-]+}})
99  asm("foo %1,%0" : "=r" (out0) : "F" (1.0));
100}
101
102// CHECK: @single_s
103void single_s()
104{
105  register int out0 = 0;
106  //asm("foo %1,%0" : "=r" (out0) : "s" (single_s));
107}
108
109// CHECK: @single_g
110void single_g()
111{
112  register int out0 = 0;
113  register int in1 = 1;
114  // CHECK: call i32 asm "foo $1,$0", "=r,imr[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
115  asm("foo %1,%0" : "=r" (out0) : "g" (in1));
116  // CHECK: call i32 asm "foo $1,$0", "=r,imr[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
117  asm("foo %1,%0" : "=r" (out0) : "g" (min1));
118  // CHECK: call i32 asm "foo $1,$0", "=r,imr[[CLOBBERS]](i32 1)
119  asm("foo %1,%0" : "=r" (out0) : "g" (1));
120}
121
122// CHECK: @single_X
123void single_X()
124{
125  register int out0 = 0;
126  register int in1 = 1;
127  // CHECK: call i32 asm "foo $1,$0", "=r,X[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
128  asm("foo %1,%0" : "=r" (out0) : "X" (in1));
129  // CHECK: call i32 asm "foo $1,$0", "=r,X[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
130  asm("foo %1,%0" : "=r" (out0) : "X" (min1));
131  // CHECK: call i32 asm "foo $1,$0", "=r,X[[CLOBBERS]](i32 1)
132  asm("foo %1,%0" : "=r" (out0) : "X" (1));
133  // CHECK: call i32 asm "foo $1,$0", "=r,X[[CLOBBERS]](i32* getelementptr inbounds ([2 x i32], [2 x i32]* {{[a-zA-Z0-9@%]+}}, i32 0, i32 0))
134  asm("foo %1,%0" : "=r" (out0) : "X" (marray));
135  // CHECK: call i32 asm "foo $1,$0", "=r,X[[CLOBBERS]](double {{[0-9.eE+-]+}})
136  asm("foo %1,%0" : "=r" (out0) : "X" (1.0e+01));
137  // CHECK: call i32 asm "foo $1,$0", "=r,X[[CLOBBERS]](double {{[0-9.eE+-]+}})
138  asm("foo %1,%0" : "=r" (out0) : "X" (1.0));
139}
140
141// CHECK: @single_p
142void single_p()
143{
144  register int out0 = 0;
145  // Constraint converted differently on different platforms moved to platform-specific.
146  // : call i32 asm "foo $1,$0", "=r,im[[CLOBBERS]](i32* getelementptr inbounds ([2 x i32], [2 x i32]* {{[a-zA-Z0-9@%]+}}, i32 0, i32 0))
147  asm("foo %1,%0" : "=r" (out0) : "p" (marray));
148}
149
150// CHECK: @multi_m
151void multi_m()
152{
153  // CHECK: call void asm "foo $1,$0", "=*m|r,m|r[[CLOBBERS]](i32* {{[a-zA-Z0-9@%]+}}, i32 {{[a-zA-Z0-9@%]+}})
154  asm("foo %1,%0" : "=m,r" (mout0) : "m,r" (min1));
155}
156
157// CHECK: @multi_o
158void multi_o()
159{
160  register int out0 = 0;
161  register int index = 1;
162  // Doesn't really do an offset...
163  //asm("foo %1, %2,%0" : "=r,r" (out0) : "r,o" (min1));
164}
165
166// CHECK: @multi_V
167void multi_V()
168{
169//  asm("foo %1,%0" : "=m,r" (mout0) : "r,V" (min1));
170}
171
172// CHECK: @multi_lt
173void multi_lt()
174{
175  register int out0 = 0;
176  register int in1 = 1;
177  // CHECK: call i32 asm "foo $1,$0", "=r|r,r|<r[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
178  asm("foo %1,%0" : "=r,r" (out0) : "r,<r" (in1));
179  // CHECK: call i32 asm "foo $1,$0", "=r|r,r|r<[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
180  asm("foo %1,%0" : "=r,r" (out0) : "r,r<" (in1));
181}
182
183// CHECK: @multi_gt
184void multi_gt()
185{
186  register int out0 = 0;
187  register int in1 = 1;
188  // CHECK: call i32 asm "foo $1,$0", "=r|r,r|>r[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
189  asm("foo %1,%0" : "=r,r" (out0) : "r,>r" (in1));
190  // CHECK: call i32 asm "foo $1,$0", "=r|r,r|r>[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
191  asm("foo %1,%0" : "=r,r" (out0) : "r,r>" (in1));
192}
193
194// CHECK: @multi_r
195void multi_r()
196{
197  register int out0 = 0;
198  register int in1 = 1;
199  // CHECK: call i32 asm "foo $1,$0", "=r|r,r|m[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
200  asm("foo %1,%0" : "=r,r" (out0) : "r,m" (in1));
201}
202
203// CHECK: @multi_i
204void multi_i()
205{
206  register int out0 = 0;
207  // CHECK: call i32 asm "foo $1,$0", "=r|r,r|i[[CLOBBERS]](i32 1)
208  asm("foo %1,%0" : "=r,r" (out0) : "r,i" (1));
209}
210
211// CHECK: @multi_n
212void multi_n()
213{
214  register int out0 = 0;
215  // CHECK: call i32 asm "foo $1,$0", "=r|r,r|n[[CLOBBERS]](i32 1)
216  asm("foo %1,%0" : "=r,r" (out0) : "r,n" (1));
217}
218
219// CHECK: @multi_E
220void multi_E()
221{
222  register double out0 = 0.0;
223  // CHECK: call double asm "foo $1,$0", "=r|r,r|E[[CLOBBERS]](double {{[0-9.eE+-]+}})
224  asm("foo %1,%0" : "=r,r" (out0) : "r,E" (1.0e+01));
225}
226
227// CHECK: @multi_F
228void multi_F()
229{
230  register double out0 = 0.0;
231  // CHECK: call double asm "foo $1,$0", "=r|r,r|F[[CLOBBERS]](double {{[0-9.eE+-]+}})
232  asm("foo %1,%0" : "=r,r" (out0) : "r,F" (1.0));
233}
234
235// CHECK: @multi_s
236void multi_s()
237{
238  register int out0 = 0;
239  //asm("foo %1,%0" : "=r,r" (out0) : "r,s" (multi_s));
240}
241
242// CHECK: @multi_g
243void multi_g()
244{
245  register int out0 = 0;
246  register int in1 = 1;
247  // CHECK: call i32 asm "foo $1,$0", "=r|r,r|imr[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
248  asm("foo %1,%0" : "=r,r" (out0) : "r,g" (in1));
249  // CHECK: call i32 asm "foo $1,$0", "=r|r,r|imr[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
250  asm("foo %1,%0" : "=r,r" (out0) : "r,g" (min1));
251  // CHECK: call i32 asm "foo $1,$0", "=r|r,r|imr[[CLOBBERS]](i32 1)
252  asm("foo %1,%0" : "=r,r" (out0) : "r,g" (1));
253}
254
255// CHECK: @multi_X
256void multi_X()
257{
258  register int out0 = 0;
259  register int in1 = 1;
260  // CHECK: call i32 asm "foo $1,$0", "=r|r,r|X[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
261  asm("foo %1,%0" : "=r,r" (out0) : "r,X" (in1));
262  // CHECK: call i32 asm "foo $1,$0", "=r|r,r|X[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
263  asm("foo %1,%0" : "=r,r" (out0) : "r,X" (min1));
264  // CHECK: call i32 asm "foo $1,$0", "=r|r,r|X[[CLOBBERS]](i32 1)
265  asm("foo %1,%0" : "=r,r" (out0) : "r,X" (1));
266  // CHECK: call i32 asm "foo $1,$0", "=r|r,r|X[[CLOBBERS]](i32* getelementptr inbounds ([2 x i32], [2 x i32]* {{[a-zA-Z0-9@%]+}}, i32 0, i32 0))
267  asm("foo %1,%0" : "=r,r" (out0) : "r,X" (marray));
268  // CHECK: call i32 asm "foo $1,$0", "=r|r,r|X[[CLOBBERS]](double {{[0-9.eE+-]+}})
269  asm("foo %1,%0" : "=r,r" (out0) : "r,X" (1.0e+01));
270  // CHECK: call i32 asm "foo $1,$0", "=r|r,r|X[[CLOBBERS]](double {{[0-9.eE+-]+}})
271  asm("foo %1,%0" : "=r,r" (out0) : "r,X" (1.0));
272}
273
274// CHECK: @multi_p
275void multi_p()
276{
277  register int out0 = 0;
278  // Constraint converted differently on different platforms moved to platform-specific.
279  // : call i32 asm "foo $1,$0", "=r|r,r|im[[CLOBBERS]](i32* getelementptr inbounds ([2 x i32], [2 x i32]* {{[a-zA-Z0-9@%]+}}, i32 0, i32 0))
280  asm("foo %1,%0" : "=r,r" (out0) : "r,p" (marray));
281}
282