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-*-* crisv32-*-* 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 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
22 #if defined (__alpha__)
25 #elif defined (__CRIS__)
31 #elif defined (__i386__)
34 /* On Darwin -fpic is on by default, so don't use %ebx. */
37 #elif defined (__MMIX__)
40 #elif defined (__powerpc__) || defined (__PPC__) || defined (__ppc__) \
41 || defined (__POWERPC__) || defined (PPC) || defined (_IBMR2) \
45 # if !defined(_ARCH_PPC64)
49 #elif defined (__x86_64__)
54 /* For readability of the tests. */
67 /* REG5 is just another reg if there is one; the difference to REG4 is to
68 keep the original set of registers for CRIS. */
76 register void *q
asm (REG1
) = p
;
77 asm ("foo1 %0" : "=r" (q
) : "0" (q
) : REG1
); /* { dg-error "conflict" } */
84 register void *q
asm (REG1
) = p
;
85 asm ("foo1 %0" : "=r" (q
) : "0" (q
) : REG2
);
90 foolla (long long llp
)
92 register long long ll
asm (REG1a
) = llp
;
93 asm ("foo1a %0" : "=r" (ll
) : "0" (ll
) : REG1a
); /* { dg-error "conflict" } */
98 nfoolla (long long llp
)
100 register long long ll
asm (REG1a
) = llp
;
101 asm ("foo1a %0" : "=r" (ll
) : "0" (ll
) : REG2a
);
106 foollb (long long llp
)
108 register long long ll
asm (REG1a
) = llp
;
109 asm ("foo1b %0" : "=r" (ll
) : "0" (ll
) : REG1b
); /* { dg-error "conflict" } */
116 register void *q
asm (REG1
);
117 register void *w
asm (REG2
) = p
;
118 asm ("bar1 %1,%0" : "=r" (q
) : "r" (w
) : REG1
); /* { dg-error "conflict" } */
123 barlla (long long llp
)
125 register long long ll
asm (REG1a
);
126 register long long mm
asm (REG2a
) = llp
;
127 asm ("bar1a %1,%0" : "=r" (ll
) : "r" (mm
) : REG1b
); /* { dg-error "conflict" } */
132 barllb (long long llp
)
134 register long long ll
asm (REG1a
);
135 register long long mm
asm (REG2a
) = llp
;
136 asm ("bar1b %1,%0" : "=r" (ll
) : "r" (mm
) : REG2b
); /* { dg-error "conflict" } */
143 register void *q
asm (REG1
);
144 register void *w
asm (REG2
) = p
;
145 asm ("foobar1 %1,%0" : "=r" (q
) : "r" (w
) : REG2
); /* { dg-error "conflict" } */
152 register void *q
asm (REG1
);
153 register void *w
= p
;
154 asm ("foobar1 %1,%0" : "=r" (q
) : "r" (w
) : REG2
);
159 foobarlla (long long llp
)
161 register long long ll
asm (REG1a
);
162 register long long mm
asm (REG2a
) = llp
;
163 asm ("foobar1a %1,%0" : "=r" (ll
) : "r" (mm
) : REG1b
); /* { dg-error "conflict" } */
168 nfoobarlla (long long llp
)
170 register long long ll
asm (REG1a
);
171 register long long mm
= llp
;
172 asm ("foobar1a %1,%0" : "=r" (ll
) : "r" (mm
) : REG2a
);
177 foobarllb (long long llp
)
179 register long long ll
asm (REG1a
);
180 register long long mm
asm (REG2a
) = llp
;
181 asm ("foobar1b %1,%0" : "=r" (ll
) : "r" (mm
) : REG2b
); /* { dg-error "conflict" } */
186 nfoobarllb (long long llp
)
188 register long long ll
asm (REG1a
);
189 register long long mm
= llp
;
190 asm ("foobar1b %1,%0" : "=r" (ll
) : "r" (mm
) : REG2b
);
197 register void *q
asm (REG1
);
198 register void *w
asm (REG2
) = p
;
199 asm ("baz1 %1,%0" : "=r" (q
) : "r" (w
) : REG1
, REG2
); /* { dg-error "conflict" } */
207 register void *w
= p
;
208 asm ("baz1 %1,%0" : "=r" (q
) : "r" (w
) : REG1
, REG2
);
215 register void *q
asm (REG1
);
216 register void *w
asm (REG2
) = p
;
217 asm ("baz1 %1,%0" : "=r" (q
) : "r" (w
));
222 bazlla (long long llp
)
224 register long long ll
asm (REG1a
);
225 register long long mm
asm (REG2a
) = llp
;
226 asm ("baz1a %1,%0" : "=r" (ll
) : "r" (mm
) : REG1a
, REG2a
); /* { dg-error "conflict" } */
231 bazllb (long long llp
)
233 register long long ll
asm (REG1a
);
234 register long long mm
asm (REG2a
) = llp
;
235 asm ("baz2a %1,%0" : "=r" (ll
) : "r" (mm
) : REG1b
, REG2b
); /* { dg-error "conflict" } */
239 /* Real-world example of bug. */
242 typedef unsigned int loc_size_t
__attribute__ ((mode (DI
)));
244 typedef __SIZE_TYPE__ loc_size_t
;
249 _dl_stat (const char *file_name
, struct stat
*buf
)
251 register long a
asm (REG1
) = (long) (loc_size_t
) file_name
;
252 register long b
asm (REG2
) = (long) (loc_size_t
) buf
;
254 asm volatile ("movu.w %1,$r9\n\tbreak 13" : "=r" (a
) : "g" (106), "0" (a
), "r" (b
) : REG1
, REG5
); /* { dg-error "conflict" } */