asm.c revision b77e07a23dda6b74e0f73460ec7ef569345ea13b
1// RUN: clang-cc -triple i386-unknown-unknown -emit-llvm %s -o %t &&
2void t1(int len) {
3  __asm__ volatile("" : "=&r"(len), "+&r"(len));
4}
5
6void t2(unsigned long long t)  {
7  __asm__ volatile("" : "+m"(t));
8}
9
10void t3(unsigned char *src, unsigned long long temp) {
11  __asm__ volatile("" : "+m"(temp), "+r"(src));
12}
13
14void t4() {
15  unsigned long long a;
16  struct reg { unsigned long long a, b; } b;
17
18	__asm__ volatile ("":: "m"(a), "m"(b));
19}
20
21// PR3417
22void t5(int i) {
23  asm("nop" : "=r"(i) : "0"(t5));
24}
25
26// PR3641
27void t6(void) {
28  __asm__ volatile("" : : "i" (t6));
29}
30
31// RUN: grep "T7 NAMED: \$1" %t &&
32void t7(int a) {
33  __asm__ volatile("T7 NAMED: %[input]" : "+r"(a): [input] "i" (4));
34}
35
36// RUN: grep "T8 NAMED MODIFIER: \${0:c}" %t
37void t8() {
38  __asm__ volatile("T8 NAMED MODIFIER: %c[input]" :: [input] "i" (4));
39}
40
41// PR3682
42unsigned t9(unsigned int a) {
43  asm("bswap %0 %1" : "+r" (a));
44  return a;
45}
46
47// PR3908
48// RUN: grep "PR3908 \$1 \$3 \$2 \$0" %t
49void t10(int r) {
50  __asm__("PR3908 %[lf] %[xx] %[li] %[r]" : [r] "+r" (r) : [lf] "mx" (0), [li] "mr" (0), [xx] "x" ((double)(0)));
51}
52
53
54// PR3373
55unsigned t11(signed char input) {
56  unsigned  output;
57  __asm__("xyz"
58          : "=a" (output)
59          : "0" (input));
60  return output;
61}
62
63// PR3373
64unsigned char t12(unsigned input) {
65  unsigned char output;
66  __asm__("xyz"
67          : "=a" (output)
68          : "0" (input));
69  return output;
70}
71
72unsigned char t13(unsigned input) {
73  unsigned char output;
74  __asm__("xyz %1"
75          : "=a" (output)
76          : "0" (input));
77  return output;
78}
79
80struct large {
81  int x[1000];
82};
83
84unsigned long t15(int x, struct large *P) {
85  __asm__("xyz "
86          : "=r" (x)
87          : "m" (*P), "0" (x));
88  return x;
89}
90
91
92
93
94// bitfield destination of an asm.
95struct S {
96  int a : 4;
97};
98
99void t14(struct S *P) {
100  __asm__("abc %0" : "=r"(P->a) );
101}
102
103
104