No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gcc4 / gcc / testsuite / gcc.dg / 20020919-1.c
blob9c16d3d07e82ce3a639387f40cf07aa30f915d24
1 /* Copyright (C) 2002 Free Software Foundation.
2 by Hans-Peter Nilsson <hp@axis.com>
4 Making sure that asm clobbers conflicting with asm-declared input
5 operands are detected: ``You may not write a clobber description in a
6 way that overlaps with an input or output operand''.
8 You must be this tall ---> fit two long longs in asm-declared registers
9 to enter this amusement. */
11 /* { dg-do compile { target alpha-*-* cris-*-* i?86-*-* mmix-*-* powerpc-*-* rs6000-*-* x86_64-*-* } } */
12 /* { dg-options "-O2" } */
14 /* Constructed examples; input/output (same register), output, input, and
15 input and output (different registers). */
17 /* The long longs are used to test overlap overlap for multi-register
18 registers. REG2 and REG4 must be the second halves (defined as
19 higher-numbered parts) of REG1 and REG3 respectively when two registers
20 are needed. */
22 #if defined (__alpha__)
23 # define REG1 "$1"
24 # define REG2 "$2"
25 #elif defined (__CRIS__)
26 # define REG1 "r10"
27 # define REG2 "r11"
28 # define REG3 "r12"
29 # define REG4 "r13"
30 # define REG5 "r9"
31 #elif defined (__i386__)
32 # define REG1 "%eax"
33 # define REG2 "%edx"
34 /* On Darwin -fpic is on by default, so don't use %ebx. */
35 # define REG3 "%esi"
36 # define REG4 "%edi"
37 #elif defined (__MMIX__)
38 # define REG1 "$8"
39 # define REG2 "$9"
40 #elif defined (__powerpc__) || defined (__PPC__) || defined (__ppc__) \
41 || defined (__POWERPC__) || defined (PPC) || defined (_IBMR2)
42 # define REG1 "6"
43 # define REG2 "7"
44 # define REG3 "8"
45 # define REG4 "9"
46 #elif defined (__x86_64__)
47 # define REG1 "rax"
48 # define REG2 "rdx"
49 #endif
51 /* For readability of the tests. */
52 #ifdef REG3
53 # define REG1a REG1
54 # define REG1b REG2
55 # define REG2a REG3
56 # define REG2b REG4
57 #else
58 # define REG1a REG1
59 # define REG1b REG1
60 # define REG2a REG2
61 # define REG2b REG2
62 #endif
64 /* REG5 is just another reg if there is one; the difference to REG4 is to
65 keep the original set of registers for CRIS. */
66 #ifndef REG5
67 #define REG5 REG2b
68 #endif
70 void *
71 foo (void *p)
73 register void *q asm (REG1) = p;
74 asm ("foo1 %0" : "=r" (q) : "0" (q) : REG1); /* { dg-error "conflict" } */
75 return q;
78 void *
79 nfoo (void *p)
81 register void *q asm (REG1) = p;
82 asm ("foo1 %0" : "=r" (q) : "0" (q) : REG2);
83 return q;
86 long long
87 foolla (long long llp)
89 register long long ll asm (REG1a) = llp;
90 asm ("foo1a %0" : "=r" (ll) : "0" (ll) : REG1a); /* { dg-error "conflict" } */
91 return ll;
94 long long
95 nfoolla (long long llp)
97 register long long ll asm (REG1a) = llp;
98 asm ("foo1a %0" : "=r" (ll) : "0" (ll) : REG2a);
99 return ll;
102 long long
103 foollb (long long llp)
105 register long long ll asm (REG1a) = llp;
106 asm ("foo1b %0" : "=r" (ll) : "0" (ll) : REG1b); /* { dg-error "conflict" } */
107 return ll;
110 void *
111 bar (void *p)
113 register void *q asm (REG1);
114 register void *w asm (REG2) = p;
115 asm ("bar1 %1,%0" : "=r" (q) : "r" (w) : REG1); /* { dg-error "conflict" } */
116 return q;
119 long long
120 barlla (long long llp)
122 register long long ll asm (REG1a);
123 register long long mm asm (REG2a) = llp;
124 asm ("bar1a %1,%0" : "=r" (ll) : "r" (mm) : REG1b); /* { dg-error "conflict" } */
125 return ll;
128 long long
129 barllb (long long llp)
131 register long long ll asm (REG1a);
132 register long long mm asm (REG2a) = llp;
133 asm ("bar1b %1,%0" : "=r" (ll) : "r" (mm) : REG2b); /* { dg-error "conflict" } */
134 return ll;
137 void *
138 foobar (void *p)
140 register void *q asm (REG1);
141 register void *w asm (REG2) = p;
142 asm ("foobar1 %1,%0" : "=r" (q) : "r" (w) : REG2); /* { dg-error "conflict" } */
143 return q;
146 void *
147 nfoobar (void *p)
149 register void *q asm (REG1);
150 register void *w = p;
151 asm ("foobar1 %1,%0" : "=r" (q) : "r" (w) : REG2);
152 return q;
155 long long
156 foobarlla (long long llp)
158 register long long ll asm (REG1a);
159 register long long mm asm (REG2a) = llp;
160 asm ("foobar1a %1,%0" : "=r" (ll) : "r" (mm) : REG1b); /* { dg-error "conflict" } */
161 return ll;
164 long long
165 nfoobarlla (long long llp)
167 register long long ll asm (REG1a);
168 register long long mm = llp;
169 asm ("foobar1a %1,%0" : "=r" (ll) : "r" (mm) : REG2a);
170 return ll;
173 long long
174 foobarllb (long long llp)
176 register long long ll asm (REG1a);
177 register long long mm asm (REG2a) = llp;
178 asm ("foobar1b %1,%0" : "=r" (ll) : "r" (mm) : REG2b); /* { dg-error "conflict" } */
179 return ll;
182 long long
183 nfoobarllb (long long llp)
185 register long long ll asm (REG1a);
186 register long long mm = llp;
187 asm ("foobar1b %1,%0" : "=r" (ll) : "r" (mm) : REG2b);
188 return ll;
191 void *
192 baz (void *p)
194 register void *q asm (REG1);
195 register void *w asm (REG2) = p;
196 asm ("baz1 %1,%0" : "=r" (q) : "r" (w) : REG1, REG2); /* { dg-error "conflict" } */
197 return q;
200 void *
201 nbaz (void *p)
203 register void *q;
204 register void *w = p;
205 asm ("baz1 %1,%0" : "=r" (q) : "r" (w) : REG1, REG2);
206 return q;
209 void *
210 nbaz2 (void *p)
212 register void *q asm (REG1);
213 register void *w asm (REG2) = p;
214 asm ("baz1 %1,%0" : "=r" (q) : "r" (w));
215 return q;
218 long long
219 bazlla (long long llp)
221 register long long ll asm (REG1a);
222 register long long mm asm (REG2a) = llp;
223 asm ("baz1a %1,%0" : "=r" (ll) : "r" (mm) : REG1a, REG2a); /* { dg-error "conflict" } */
224 return ll;
227 long long
228 bazllb (long long llp)
230 register long long ll asm (REG1a);
231 register long long mm asm (REG2a) = llp;
232 asm ("baz2a %1,%0" : "=r" (ll) : "r" (mm) : REG1b, REG2b); /* { dg-error "conflict" } */
233 return ll;
236 /* Real-world example of bug. */
238 struct stat;
240 _dl_stat (const char *file_name, struct stat *buf)
242 register long a asm (REG1) = (long) file_name;
243 register long b asm (REG2) = (long) buf;
245 asm volatile ("movu.w %1,$r9\n\tbreak 13" : "=r" (a) : "g" (106), "0" (a), "r" (b) : REG1, REG5); /* { dg-error "conflict" } */
246 if (a >= 0)
247 return (int) a;
248 return (int) -1;