blob: d6030a64ba8f9a2de0afd81894c551512f2d5806 [file] [log] [blame]
Chris Lattner10ca96a2009-03-10 06:33:24 +00001// RUN: clang -emit-llvm %s -o %t -arch=i386 &&
2void t1(int len) {
Anders Carlsson9f2505b2009-01-11 21:23:27 +00003 __asm__ volatile("" : "=&r"(len), "+&r"(len));
Anders Carlsson2763b3a2009-01-11 19:46:50 +00004}
Anders Carlsson9f2505b2009-01-11 21:23:27 +00005
Chris Lattner10ca96a2009-03-10 06:33:24 +00006void t2(unsigned long long t) {
Anders Carlsson9f2505b2009-01-11 21:23:27 +00007 __asm__ volatile("" : "+m"(t));
8}
9
Chris Lattner10ca96a2009-03-10 06:33:24 +000010void t3(unsigned char *src, unsigned long long temp) {
Anders Carlsson9f2505b2009-01-11 21:23:27 +000011 __asm__ volatile("" : "+m"(temp), "+r"(src));
12}
13
Chris Lattner10ca96a2009-03-10 06:33:24 +000014void t4() {
Anders Carlssonebaae2a2009-01-12 02:22:13 +000015 unsigned long long a;
16 struct reg { unsigned long long a, b; } b;
17
18 __asm__ volatile ("":: "m"(a), "m"(b));
19}
Anders Carlsson9f2505b2009-01-11 21:23:27 +000020
Anders Carlsson03eb5432009-01-27 20:38:24 +000021// PR3417
Chris Lattner10ca96a2009-03-10 06:33:24 +000022void t5(int i) {
Anders Carlsson03eb5432009-01-27 20:38:24 +000023 asm("nop" : "=r"(i) : "0"(t5));
24}
Anders Carlsson60329792009-02-22 02:11:23 +000025
26// PR3641
Chris Lattner10ca96a2009-03-10 06:33:24 +000027void t6(void) {
Anders Carlsson60329792009-02-22 02:11:23 +000028 __asm__ volatile("" : : "i" (t6));
29}
Chris Lattner10ca96a2009-03-10 06:33:24 +000030
Chris Lattner88beebe2009-03-10 06:42:37 +000031// RUN: grep "T7 NAMED: \$2" %t &&
Chris Lattner10ca96a2009-03-10 06:33:24 +000032void t7(int a) {
33 __asm__ volatile("T7 NAMED: %[input]" : "+r"(a): [input] "i" (4));
Chris Lattner02af9742009-03-10 06:38:02 +000034}
35
36// RUN: grep "T8 NAMED MODIFIER: \${0:c}" %t
37void t8() {
38 __asm__ volatile("T8 NAMED MODIFIER: %c[input]" :: [input] "i" (4));
39}
Chris Lattner88beebe2009-03-10 06:42:37 +000040
41// PR3682
42unsigned t9(unsigned int a) {
43 asm("bswap %0 %1" : "+r" (a));
44 return a;
45}