This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: asm and "cc" "memory" volatile etc.. (slightly offtopic)


>>>>> "Richard" == Richard Henderson <rth@cygnus.com> writes:

 Richard> On Tue, Nov 11, 1997 at 10:59:21AM -0700, Jeffrey A Law
 Richard> wrote:
 >> > Is there some way to say gcc, that is just updates given block
 >> of memory > (rtl expression for memcpy dont say clobbers:memory
 >> but says set BLK...  > is there any way to write this in asm?)
 >> I'm not aware of any way to selectively tell gcc that only a
 >> certain block of memory is read/clobbered by an asm (or any
 >> BLKmode instruction).

 Richard> The following has been found to be effective.

 Richard> struct large_struct { unsigned long buf[1234]; }; #define
 Richard> m(x) (*(struct large_struct *)(x))
	
 Richard> extern inline int test_bit(int nr, void *addr) { int ret;
 Richard> __asm__("btl %2,%1\n\tsbbl %0,%0" : "=r"(ret) :
 Richard> "m"(m(addr)), "ir"(nr)); return ret; }

I've found that some backends are perfectly happy to rearrange asm
statements (gnu extended asm, that is) even if wrapped inside an
inline function.  As far as I understand it, the only reliable way to
force that not to happen is to say "asm volatile".  (Note that
declaring the inline function "volatile" doesn't help.)

Then again, for other back ends you may not see this, and for those
that will do this, they won't do it for all the test cases you feed
it.

	paul



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]