2010-03-04 05:52:23 +08:00
|
|
|
// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
|
2009-03-10 14:33:24 +08:00
|
|
|
void t1(int len) {
|
2009-01-12 05:23:27 +08:00
|
|
|
__asm__ volatile("" : "=&r"(len), "+&r"(len));
|
2009-01-12 03:46:50 +08:00
|
|
|
}
|
2009-01-12 05:23:27 +08:00
|
|
|
|
2009-03-10 14:33:24 +08:00
|
|
|
void t2(unsigned long long t) {
|
2009-01-12 05:23:27 +08:00
|
|
|
__asm__ volatile("" : "+m"(t));
|
|
|
|
}
|
|
|
|
|
2009-03-10 14:33:24 +08:00
|
|
|
void t3(unsigned char *src, unsigned long long temp) {
|
2009-01-12 05:23:27 +08:00
|
|
|
__asm__ volatile("" : "+m"(temp), "+r"(src));
|
|
|
|
}
|
|
|
|
|
2009-03-10 14:33:24 +08:00
|
|
|
void t4() {
|
2009-01-12 10:22:13 +08:00
|
|
|
unsigned long long a;
|
|
|
|
struct reg { unsigned long long a, b; } b;
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
__asm__ volatile ("":: "m"(a), "m"(b));
|
2009-01-12 10:22:13 +08:00
|
|
|
}
|
2009-01-12 05:23:27 +08:00
|
|
|
|
2009-01-28 04:38:24 +08:00
|
|
|
// PR3417
|
2009-03-10 14:33:24 +08:00
|
|
|
void t5(int i) {
|
2009-01-28 04:38:24 +08:00
|
|
|
asm("nop" : "=r"(i) : "0"(t5));
|
|
|
|
}
|
2009-02-22 10:11:23 +08:00
|
|
|
|
|
|
|
// PR3641
|
2009-03-10 14:33:24 +08:00
|
|
|
void t6(void) {
|
2009-02-22 10:11:23 +08:00
|
|
|
__asm__ volatile("" : : "i" (t6));
|
|
|
|
}
|
2009-03-10 14:33:24 +08:00
|
|
|
|
|
|
|
void t7(int a) {
|
|
|
|
__asm__ volatile("T7 NAMED: %[input]" : "+r"(a): [input] "i" (4));
|
2010-03-04 08:38:16 +08:00
|
|
|
// CHECK: @t7(i32
|
|
|
|
// CHECK: T7 NAMED: $1
|
2009-03-10 14:38:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void t8() {
|
|
|
|
__asm__ volatile("T8 NAMED MODIFIER: %c[input]" :: [input] "i" (4));
|
2010-03-04 08:38:16 +08:00
|
|
|
// CHECK: @t8()
|
|
|
|
// CHECK: T8 NAMED MODIFIER: ${0:c}
|
2009-03-10 14:38:02 +08:00
|
|
|
}
|
2009-03-10 14:42:37 +08:00
|
|
|
|
|
|
|
// PR3682
|
|
|
|
unsigned t9(unsigned int a) {
|
|
|
|
asm("bswap %0 %1" : "+r" (a));
|
|
|
|
return a;
|
|
|
|
}
|
2009-04-03 13:57:08 +08:00
|
|
|
|
|
|
|
// PR3908
|
|
|
|
void t10(int r) {
|
|
|
|
__asm__("PR3908 %[lf] %[xx] %[li] %[r]" : [r] "+r" (r) : [lf] "mx" (0), [li] "mr" (0), [xx] "x" ((double)(0)));
|
2010-03-04 08:38:16 +08:00
|
|
|
|
|
|
|
// CHECK: @t10(
|
|
|
|
// CHECK:PR3908 $1 $3 $2 $0
|
2009-04-03 13:57:08 +08:00
|
|
|
}
|
2009-05-03 15:27:51 +08:00
|
|
|
|
|
|
|
|
|
|
|
// PR3373
|
|
|
|
unsigned t11(signed char input) {
|
|
|
|
unsigned output;
|
|
|
|
__asm__("xyz"
|
|
|
|
: "=a" (output)
|
|
|
|
: "0" (input));
|
|
|
|
return output;
|
|
|
|
}
|
2009-05-03 15:53:25 +08:00
|
|
|
|
2009-05-03 16:21:20 +08:00
|
|
|
// PR3373
|
|
|
|
unsigned char t12(unsigned input) {
|
|
|
|
unsigned char output;
|
|
|
|
__asm__("xyz"
|
|
|
|
: "=a" (output)
|
|
|
|
: "0" (input));
|
|
|
|
return output;
|
|
|
|
}
|
2009-05-03 15:53:25 +08:00
|
|
|
|
2009-05-03 16:32:32 +08:00
|
|
|
unsigned char t13(unsigned input) {
|
|
|
|
unsigned char output;
|
|
|
|
__asm__("xyz %1"
|
|
|
|
: "=a" (output)
|
|
|
|
: "0" (input));
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
2009-05-03 17:05:53 +08:00
|
|
|
struct large {
|
|
|
|
int x[1000];
|
|
|
|
};
|
|
|
|
|
|
|
|
unsigned long t15(int x, struct large *P) {
|
|
|
|
__asm__("xyz "
|
|
|
|
: "=r" (x)
|
|
|
|
: "m" (*P), "0" (x));
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-05-03 15:53:25 +08:00
|
|
|
|
2009-05-03 16:32:32 +08:00
|
|
|
// bitfield destination of an asm.
|
2009-05-03 15:53:25 +08:00
|
|
|
struct S {
|
|
|
|
int a : 4;
|
|
|
|
};
|
|
|
|
|
2009-05-03 16:32:32 +08:00
|
|
|
void t14(struct S *P) {
|
2009-05-03 15:53:25 +08:00
|
|
|
__asm__("abc %0" : "=r"(P->a) );
|
|
|
|
}
|
2009-05-03 16:32:32 +08:00
|
|
|
|
|
|
|
|
2009-10-13 12:32:07 +08:00
|
|
|
// PR4938
|
|
|
|
int t16() {
|
|
|
|
int a,b;
|
|
|
|
asm ( "nop;"
|
|
|
|
:"=%c" (a)
|
|
|
|
: "r" (b)
|
|
|
|
);
|
|
|
|
return 0;
|
|
|
|
}
|
2010-03-04 05:52:23 +08:00
|
|
|
|
|
|
|
// PR6475
|
|
|
|
void t17() {
|
|
|
|
int i;
|
|
|
|
__asm__ ( "nop": "=m"(i));
|
|
|
|
|
|
|
|
// CHECK: @t17()
|
|
|
|
// CHECK: call void asm "nop", "=*m,
|
|
|
|
}
|
|
|
|
|
2010-03-04 05:56:57 +08:00
|
|
|
// <rdar://problem/6841383>
|
|
|
|
int t18(unsigned data) {
|
|
|
|
int a, b;
|
|
|
|
|
|
|
|
asm("xyz" :"=a"(a), "=d"(b) : "a"(data));
|
|
|
|
return a + b;
|
|
|
|
// CHECK: t18(i32
|
|
|
|
// CHECK: = call {{.*}}asm "xyz"
|
|
|
|
// CHECK-NEXT: extractvalue
|
|
|
|
// CHECK-NEXT: extractvalue
|
|
|
|
}
|
2010-04-06 02:44:00 +08:00
|
|
|
|
|
|
|
|
|
|
|
// PR6780
|
|
|
|
int t19(unsigned data) {
|
|
|
|
int a, b;
|
|
|
|
|
|
|
|
asm("x{abc|def|ghi}z" :"=r"(a): "r"(data));
|
|
|
|
return a + b;
|
|
|
|
// CHECK: t19(i32
|
|
|
|
// CHECK: = call {{.*}}asm "x$(abc$|def$|ghi$)z"
|
|
|
|
}
|
|
|
|
|
2010-04-24 01:27:29 +08:00
|
|
|
|
|
|
|
// PR6845 - Mismatching source/dest fp types.
|
|
|
|
double t20(double x) {
|
|
|
|
register long double result;
|
|
|
|
__asm __volatile ("frndint" : "=t" (result) : "0" (x));
|
|
|
|
return result;
|
|
|
|
|
|
|
|
// CHECK: @t20
|
|
|
|
// CHECK: fpext double {{.*}} to x86_fp80
|
|
|
|
// CHECK-NEXT: call x86_fp80 asm sideeffect "frndint"
|
|
|
|
// CHECK: fptrunc x86_fp80 {{.*}} to double
|
|
|
|
}
|
|
|
|
|
|
|
|
float t21(long double x) {
|
|
|
|
register float result;
|
|
|
|
__asm __volatile ("frndint" : "=t" (result) : "0" (x));
|
|
|
|
return result;
|
|
|
|
// CHECK: @t21
|
|
|
|
// CHECK: call x86_fp80 asm sideeffect "frndint"
|
|
|
|
// CHECK-NEXT: fptrunc x86_fp80 {{.*}} to float
|
|
|
|
}
|
2010-08-25 06:33:12 +08:00
|
|
|
|
|
|
|
// <rdar://problem/8348447> - accept 'l' constraint
|
|
|
|
unsigned char t22(unsigned char a, unsigned char b) {
|
|
|
|
unsigned int la = a;
|
|
|
|
unsigned int lb = b;
|
|
|
|
unsigned int bigres;
|
|
|
|
unsigned char res;
|
|
|
|
__asm__ ("0:\n1:\n" : [bigres] "=la"(bigres) : [la] "0"(la), [lb] "c"(lb) :
|
|
|
|
"edx", "cc");
|
|
|
|
res = bigres;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
// <rdar://problem/8348447> - accept 'l' constraint
|
|
|
|
unsigned char t23(unsigned char a, unsigned char b) {
|
|
|
|
unsigned int la = a;
|
|
|
|
unsigned int lb = b;
|
|
|
|
unsigned char res;
|
|
|
|
__asm__ ("0:\n1:\n" : [res] "=la"(res) : [la] "0"(la), [lb] "c"(lb) :
|
|
|
|
"edx", "cc");
|
|
|
|
return res;
|
|
|
|
}
|