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
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)
46 #elif defined (__x86_64__)
51 /* For readability of the tests. */
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. */
73 register void *q
asm (REG1
) = p
;
74 asm ("foo1 %0" : "=r" (q
) : "0" (q
) : REG1
); /* { dg-error "conflict" } */
81 register void *q
asm (REG1
) = p
;
82 asm ("foo1 %0" : "=r" (q
) : "0" (q
) : REG2
);
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" } */
95 nfoolla (long long llp
)
97 register long long ll
asm (REG1a
) = llp
;
98 asm ("foo1a %0" : "=r" (ll
) : "0" (ll
) : REG2a
);
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" } */
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" } */
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" } */
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" } */
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" } */
149 register void *q
asm (REG1
);
150 register void *w
= p
;
151 asm ("foobar1 %1,%0" : "=r" (q
) : "r" (w
) : REG2
);
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" } */
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
);
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" } */
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
);
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" } */
204 register void *w
= p
;
205 asm ("baz1 %1,%0" : "=r" (q
) : "r" (w
) : REG1
, REG2
);
212 register void *q
asm (REG1
);
213 register void *w
asm (REG2
) = p
;
214 asm ("baz1 %1,%0" : "=r" (q
) : "r" (w
));
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" } */
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" } */
236 /* Real-world example of bug. */
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" } */