1 // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
7 // CHECK: module asm "foo1"
8 // CHECK-NEXT: module asm "foo2"
9 // CHECK-NEXT: module asm "foo3"
12 __asm__
volatile("" : "=&r"(len
), "+&r"(len
));
15 void t2(unsigned long long t
) {
16 __asm__
volatile("" : "+m"(t
));
19 void t3(unsigned char *src
, unsigned long long temp
) {
20 __asm__
volatile("" : "+m"(temp
), "+r"(src
));
25 struct reg
{ unsigned long long a
, b
; } b
;
27 __asm__
volatile ("":: "m"(a
), "m"(b
));
32 asm("nop" : "=r"(i
) : "0"(t5
));
37 __asm__
volatile("" : : "i" (t6
));
41 __asm__
volatile("T7 NAMED: %[input]" : "+r"(a
): [input
] "i" (4));
43 // CHECK: T7 NAMED: $1
47 __asm__
volatile("T8 NAMED MODIFIER: %c[input]" :: [input
] "i" (4));
49 // CHECK: T8 NAMED MODIFIER: ${0:c}
53 unsigned t9(unsigned int a
) {
54 asm("bswap %0 %1" : "+r" (a
));
60 __asm__("PR3908 %[lf] %[xx] %[li] %[r]" : [r
] "+r" (r
) : [lf
] "mx" (0), [li
] "mr" (0), [xx
] "x" ((double)(0)));
63 // CHECK:PR3908 $1 $3 $2 $0
67 unsigned t11(signed char input
) {
76 unsigned char t12(unsigned input
) {
84 unsigned char t13(unsigned input
) {
96 unsigned long t15(int x
, struct large
*P
) {
103 // bitfield destination of an asm.
108 void t14(struct S
*P
) {
109 __asm__("abc %0" : "=r"(P
->a
) );
125 __asm__ ( "nop": "=m"(i
));
128 // CHECK: call void asm "nop", "=*m,
131 int t18(unsigned data
) {
134 asm("xyz" :"=a"(a
), "=d"(b
) : "a"(data
));
137 // CHECK: = call {{.*}}asm "xyz"
138 // CHECK-NEXT: extractvalue
139 // CHECK-NEXT: extractvalue
143 int t19(unsigned data
) {
146 asm("x{abc|def|ghi}z" :"=r"(a
): "r"(data
));
149 // CHECK: = call {{.*}}asm "x$(abc$|def$|ghi$)z"
152 // PR6845 - Mismatching source/dest fp types.
153 double t20(double x
) {
154 register long double result
;
155 __asm
__volatile ("frndint" : "=t" (result
) : "0" (x
));
159 // CHECK: fpext double {{.*}} to x86_fp80
160 // CHECK-NEXT: call x86_fp80 asm sideeffect "frndint"
161 // CHECK: fptrunc x86_fp80 {{.*}} to double
164 float t21(long double x
) {
165 register float result
;
166 __asm
__volatile ("frndint" : "=t" (result
) : "0" (x
));
169 // CHECK: call x86_fp80 asm sideeffect "frndint"
170 // CHECK-NEXT: fptrunc x86_fp80 {{.*}} to float
173 // accept 'l' constraint
174 unsigned char t22(unsigned char a
, unsigned char b
) {
179 __asm__ ("0:\n1:\n" : [bigres
] "=la"(bigres
) : [la
] "0"(la
), [lb
] "c"(lb
) :
185 // accept 'l' constraint
186 unsigned char t23(unsigned char a
, unsigned char b
) {
190 __asm__ ("0:\n1:\n" : [res
] "=la"(res
) : [la
] "0"(la
), [lb
] "c"(lb
) :
198 // CHECK: zext i8 {{.*}} to i32
199 // CHECK-NEXT: call ptr asm "foobar"
200 __asm__ ("foobar" : "=a" (addr
) : "0" (c
));
204 // PR10299 - fpsr, fpcr
207 __asm__
__volatile__( \
211 :"st","st(1)","st(2)","st(3)", \
212 "st(4)","st(5)","st(6)","st(7)", \
218 typedef long long __m256i
__attribute__((__vector_size__(32)));
219 void t26 (__m256i
*p
) {
220 __asm__
volatile("vmovaps %0, %%ymm0" :: "m" (*(__m256i
*)p
) : "ymm0");
223 // Check to make sure the inline asm non-standard dialect attribute _not_ is
228 // CHECK: call void asm sideeffect "nop"
229 // CHECK-NOT: ia_nsdialect
233 // Check handling of '*' and '#' constraint modifiers.
236 asm volatile ("/* %0 */" : : "i#*X,*r" (1));
238 // CHECK: call void asm sideeffect "/* $0 */", "i|r,~{dirflag},~{fpsr},~{flags}"(i32 1)
241 static unsigned t29_var
[1];
244 asm volatile("movl %%eax, %0"
248 // CHECK: call void asm sideeffect "movl %eax, $0", "*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype([1 x i32]) @t29_var)
255 // CHECK: call void asm sideeffect "", "=*&rm,0,~{dirflag},~{fpsr},~{flags}"
260 : "+%%rm"(len
), "+rm"(len
));
262 // CHECK: call void asm sideeffect "", "=*%rm,=*rm,0,1,~{dirflag},~{fpsr},~{flags}"
268 asm goto("testl %0, %0; jne %l1;" :: "r"(cond
)::label_true
, loop
);
269 // CHECK: callbr void asm sideeffect "testl $0, $0; jne ${1:l};", "r,!i,!i,~{dirflag},~{fpsr},~{flags}"(i32 %0) #1
270 // CHECK-NEXT: to label %asm.fallthrough [label %label_true, label %loop]
281 asm ("lea %1, %0" : "=r" (ret
) : "p" (ptr
));
285 // CHECK: %1 = call ptr asm "lea $1, $0", "=r,p,~{dirflag},~{fpsr},~{flags}"(ptr %0)