Chris Lattner | 10ca96a | 2009-03-10 06:33:24 +0000 | [diff] [blame] | 1 | // RUN: clang -emit-llvm %s -o %t -arch=i386 && |
| 2 | void t1(int len) { |
Anders Carlsson | 9f2505b | 2009-01-11 21:23:27 +0000 | [diff] [blame] | 3 | __asm__ volatile("" : "=&r"(len), "+&r"(len)); |
Anders Carlsson | 2763b3a | 2009-01-11 19:46:50 +0000 | [diff] [blame] | 4 | } |
Anders Carlsson | 9f2505b | 2009-01-11 21:23:27 +0000 | [diff] [blame] | 5 | |
Chris Lattner | 10ca96a | 2009-03-10 06:33:24 +0000 | [diff] [blame] | 6 | void t2(unsigned long long t) { |
Anders Carlsson | 9f2505b | 2009-01-11 21:23:27 +0000 | [diff] [blame] | 7 | __asm__ volatile("" : "+m"(t)); |
| 8 | } |
| 9 | |
Chris Lattner | 10ca96a | 2009-03-10 06:33:24 +0000 | [diff] [blame] | 10 | void t3(unsigned char *src, unsigned long long temp) { |
Anders Carlsson | 9f2505b | 2009-01-11 21:23:27 +0000 | [diff] [blame] | 11 | __asm__ volatile("" : "+m"(temp), "+r"(src)); |
| 12 | } |
| 13 | |
Chris Lattner | 10ca96a | 2009-03-10 06:33:24 +0000 | [diff] [blame] | 14 | void t4() { |
Anders Carlsson | ebaae2a | 2009-01-12 02:22:13 +0000 | [diff] [blame] | 15 | unsigned long long a; |
| 16 | struct reg { unsigned long long a, b; } b; |
| 17 | |
| 18 | __asm__ volatile ("":: "m"(a), "m"(b)); |
| 19 | } |
Anders Carlsson | 9f2505b | 2009-01-11 21:23:27 +0000 | [diff] [blame] | 20 | |
Anders Carlsson | 03eb543 | 2009-01-27 20:38:24 +0000 | [diff] [blame] | 21 | // PR3417 |
Chris Lattner | 10ca96a | 2009-03-10 06:33:24 +0000 | [diff] [blame] | 22 | void t5(int i) { |
Anders Carlsson | 03eb543 | 2009-01-27 20:38:24 +0000 | [diff] [blame] | 23 | asm("nop" : "=r"(i) : "0"(t5)); |
| 24 | } |
Anders Carlsson | 6032979 | 2009-02-22 02:11:23 +0000 | [diff] [blame] | 25 | |
| 26 | // PR3641 |
Chris Lattner | 10ca96a | 2009-03-10 06:33:24 +0000 | [diff] [blame] | 27 | void t6(void) { |
Anders Carlsson | 6032979 | 2009-02-22 02:11:23 +0000 | [diff] [blame] | 28 | __asm__ volatile("" : : "i" (t6)); |
| 29 | } |
Chris Lattner | 10ca96a | 2009-03-10 06:33:24 +0000 | [diff] [blame] | 30 | |
Chris Lattner | 88beebe | 2009-03-10 06:42:37 +0000 | [diff] [blame^] | 31 | // RUN: grep "T7 NAMED: \$2" %t && |
Chris Lattner | 10ca96a | 2009-03-10 06:33:24 +0000 | [diff] [blame] | 32 | void t7(int a) { |
| 33 | __asm__ volatile("T7 NAMED: %[input]" : "+r"(a): [input] "i" (4)); |
Chris Lattner | 02af974 | 2009-03-10 06:38:02 +0000 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | // RUN: grep "T8 NAMED MODIFIER: \${0:c}" %t |
| 37 | void t8() { |
| 38 | __asm__ volatile("T8 NAMED MODIFIER: %c[input]" :: [input] "i" (4)); |
| 39 | } |
Chris Lattner | 88beebe | 2009-03-10 06:42:37 +0000 | [diff] [blame^] | 40 | |
| 41 | // PR3682 |
| 42 | unsigned t9(unsigned int a) { |
| 43 | asm("bswap %0 %1" : "+r" (a)); |
| 44 | return a; |
| 45 | } |