brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.4 KiB · c4cb967 Raw
100 lines · c
1// RUN: %clang_cc1 -triple i386-pc-linux-gnu -fsyntax-only -verify %s2// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -verify %s3 4#if !__has_extension(gnu_asm)5#error Extension 'gnu_asm' should be available by default6#endif7#if !__has_extension(gnu_asm_goto_with_outputs)8#error Extension 'gnu_asm_goto_with_outputs' should be available by default9#endif10#if !__has_extension(gnu_asm_goto_with_outputs_full)11#error Extension 'gnu_asm_goto_with_outputs_full' should be available by default12#endif13 14int a, b, c, d, e, f, g, h, i, j, k, l;15 16void test(void) {17  __asm__ volatile goto (""18            :: [a] "r" (a), [b] "r" (b), [c] "r" (c), [d] "r" (d),19               [e] "r" (e), [f] "r" (f), [g] "r" (g), [h] "r" (h),20               [i] "r" (i), [j] "r" (j), [k] "r" (k), [l] "r" (l)21            ::lab1,lab2);22lab1: return;23lab2: return;24}25 26void test2(void) {27  __asm__ volatile goto (""28            :: [a] "r,m" (a), [b] "r,m" (b), [c] "r,m" (c), [d] "r,m" (d),29               [e] "r,m" (e), [f] "r,m" (f), [g] "r,m" (g), [h] "r,m" (h),30               [i] "r,m" (i), [j] "r,m" (j), [k] "r,m" (k), [l] "r,m" (l)31            :: lab);32  lab: return;33}34 35int test3(int x) {36  __asm__ volatile goto ("decl %0; jnz %l[a]"37                         : "=r" (x) : "m" (x) : "memory" : a);38a:39  return -x;40}41 42int test4(int x) {43  int y;44  if (x > 42)45    __asm__ volatile goto ("decl %0; jnz %l[a]"46                           : "=r" (x), "=r" (y) : "m" (x) : "memory" : a);47  else48    __asm__ volatile goto ("decl %0; jnz %l[b]"49                           : "=r" (x), "=r" (y) : "m" (x) : "memory" : b);50  x = y + 42;51a:52  return -x;53b:54  return +x;55}56 57int test5(void) {58  int x,cond,*e;59  // expected-error@+1 {{expected ')'}}60  asm ("mov %[e], %[e]" : : [e] "rm" (*e)::a)61  // expected-error@+1 {{expected identifier}}62  asm goto ("decl %0;" :: "m"(x) : "memory" : );63  // expected-error@+1 {{expected ':'}}64  asm goto ("decl %0;" :: "m"(x) : "memory" );65  // expected-error@+1 {{use of undeclared label 'x'}}66  asm goto ("decl %0;" :: "m"(x) : "memory" :x);67  // expected-error@+1 {{use of undeclared label 'b'}}68  asm goto ("decl %0;" :: "m"(x) : "memory" :b);69  // expected-error@+1 {{invalid operand number in inline asm string}}70  asm goto ("testl %0, %0; jne %l3;" :: "r"(cond)::label_true, loop);71  // expected-error@+1 {{unknown symbolic operand name in inline assembly string}}72  asm goto ("decl %0; jnz %l[b]" :: "m"(x) : "memory" : a);73a:74label_true:75loop:76  return 0;77}78 79int test6(int y) {80  int x,cond,*e;81  // expected-error@+1 {{expected ')'}}82  asm ("mov %[e], %[e]" : "=r" (y) : [e] "rm" (*e), "r" (y) :: a)83  // expected-error@+1 {{expected identifier}}84  asm goto ("decl %0;" : "=r" (y) : "m" (x), "r" (y) : "memory" :);85  // expected-error@+1  {{expected ':'}}86  asm goto ("decl %0;" : "=r" (y) : "m" (x), "r" (y) : "memory");87  // expected-error@+1 {{use of undeclared label 'x'}}88  asm goto ("decl %0;" : "=r" (y) : "m" (x), "r" (y) : "memory" : x);89  // expected-error@+1 {{use of undeclared label 'b'}}90  asm goto ("decl %0;" : "=r" (y) : "m" (x), "r" (y) : "memory" : b);91  // expected-error@+1 {{invalid operand number in inline asm string}}92  asm goto ("testl %0, %0; jne %l5;" : "=r" (y) : "r" (cond), "r" (y) :: label_true, loop);93  // expected-error@+1 {{unknown symbolic operand name in inline assembly string}}94  asm goto ("decl %0; jnz %l[b]" : "=r" (y) : "m" (x), "r" (y) : "memory" : a);95label_true:96loop:97a:98  return 0;99}100