| 1 |
// RUN: %clang_cc1 -triple i386-pc-linux-gnu -fsyntax-only -verify -std=c++11 %s |
| 2 |
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -verify -std=c++11 %s |
| 3 |
|
| 4 |
int a, b, c, d, e, f, g, h, i, j, k, l; |
| 5 |
|
| 6 |
void test1(void) { |
| 7 |
__asm__ volatile goto ("" |
| 8 |
:: [a] "r" (a), [b] "r" (b), [c] "r" (c), [d] "r" (d), |
| 9 |
[e] "r" (e), [f] "r" (f), [g] "r" (g), [h] "r" (h), |
| 10 |
[i] "r" (i), [j] "r" (j), [k] "r" (k), [l] "r" (l) |
| 11 |
::lab1,lab2); |
| 12 |
lab1: return; |
| 13 |
lab2: return; |
| 14 |
} |
| 15 |
|
| 16 |
void test2(void) { |
| 17 |
__asm__ volatile goto ("" |
| 18 |
:: [a] "r,m" (a), [b] "r,m" (b), [c] "r,m" (c), [d] "r,m" (d), |
| 19 |
[e] "r,m" (e), [f] "r,m" (f), [g] "r,m" (g), [h] "r,m" (h), |
| 20 |
[i] "r,m" (i), [j] "r,m" (j), [k] "r,m" (k), [l] "r,m" (l) |
| 21 |
:: lab); |
| 22 |
lab: return; |
| 23 |
} |
| 24 |
|
| 25 |
int test3(int x) { |
| 26 |
__asm__ volatile goto ("decl %0; jnz %l[a]" |
| 27 |
: "=r" (x) : "m" (x) : "memory" : a); |
| 28 |
a: |
| 29 |
return -x; |
| 30 |
} |
| 31 |
|
| 32 |
int test4(int x) { |
| 33 |
int y; |
| 34 |
if (x > 42) |
| 35 |
__asm__ volatile goto ("decl %0; jnz %l[a]" |
| 36 |
: "=r" (x), "=r" (y) : "m" (x) : "memory" : a); |
| 37 |
else |
| 38 |
__asm__ volatile goto ("decl %0; jnz %l[b]" |
| 39 |
: "=r" (x), "=r" (y) : "m" (x) : "memory" : b); |
| 40 |
x = y + 42; |
| 41 |
a: |
| 42 |
return -x; |
| 43 |
b: |
| 44 |
return +x; |
| 45 |
} |
| 46 |
|
| 47 |
int test5(void) { |
| 48 |
int x,cond,*e; |
| 49 |
// expected-error@+1 {{expected ')'}} |
| 50 |
asm ("mov %[e], %[e]" : : [e] "rm" (*e)::a) |
| 51 |
// expected-error@+1 {{expected identifier}} |
| 52 |
asm goto ("decl %0;" :: "m"(x) : "memory" : ); |
| 53 |
// expected-error@+1 {{expected ':'}} |
| 54 |
asm goto ("decl %0;" :: "m"(x) : "memory" ); |
| 55 |
// expected-error@+1 {{use of undeclared label 'x'}} |
| 56 |
asm goto ("decl %0;" :: "m"(x) : "memory" :x); |
| 57 |
// expected-error@+1 {{use of undeclared label 'b'}} |
| 58 |
asm goto ("decl %0;" :: "m"(x) : "memory" :b); |
| 59 |
// expected-error@+1 {{invalid operand number in inline asm string}} |
| 60 |
asm goto ("testl %0, %0; jne %l3;" :: "r"(cond)::label_true, loop); |
| 61 |
// expected-error@+1 {{unknown symbolic operand name in inline assembly string}} |
| 62 |
asm goto ("decl %0; jnz %l[b]" :: "m"(x) : "memory" : a); |
| 63 |
label_true: |
| 64 |
loop: |
| 65 |
a: |
| 66 |
return 0; |
| 67 |
} |
| 68 |
|
| 69 |
int test6(int y) { |
| 70 |
int x,cond,*e; |
| 71 |
// expected-error@+1 {{expected ')'}} |
| 72 |
asm ("mov %[e], %[e]" : "=r" (y) : [e] "rm" (*e), "r" (y) :: a) |
| 73 |
// expected-error@+1 {{expected identifier}} |
| 74 |
asm goto ("decl %0;" : "=r" (y) : "m" (x), "r" (y) : "memory" :); |
| 75 |
// expected-error@+1 {{expected ':'}} |
| 76 |
asm goto ("decl %0;" : "=r" (y) : "m" (x), "r" (y) : "memory"); |
| 77 |
// expected-error@+1 {{use of undeclared label 'x'}} |
| 78 |
asm goto ("decl %0;" : "=r" (y) : "m" (x), "r" (y) : "memory" : x); |
| 79 |
// expected-error@+1 {{use of undeclared label 'b'}} |
| 80 |
asm goto ("decl %0;" : "=r" (y) : "m" (x), "r" (y) : "memory" : b); |
| 81 |
// expected-error@+1 {{invalid operand number in inline asm string}} |
| 82 |
asm goto ("testl %0, %0; jne %l5;" : "=r" (y) : "r" (cond), "r" (y) :: label_true, loop); |
| 83 |
// expected-error@+1 {{unknown symbolic operand name in inline assembly string}} |
| 84 |
asm goto ("decl %0; jnz %l[b]" : "=r" (y) : "m" (x), "r" (y) : "memory" : a); |
| 85 |
label_true: |
| 86 |
loop: |
| 87 |
a: |
| 88 |
return 0; |
| 89 |
} |