This is the mail archive of the crossgcc@cygnus.com mailing list for the crossgcc project.


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

problem w/ GCC asm stmt on sparc



I'm having problems getting the following code to compile properly.
Specifically the last asm statement "st %%l0,%0" works if I compile
w/o optimization, but fails if I optimize.  The reason is that addr
is a stack variable but gets optimized to a register if I use "-O2".

Is there any way to `repair' my asm statement below?

  int
  a_spin_trylock(volatile char *addr)
  {
    int __val;
    asm volatile("\
        ldstub %1,%%l0;\
        tst %%l0;\
        mov -1,%%l0;\
        bne 1f; nop;\
        mov %%g0,%%l0;\
     1: st %%l0,%0":
        "=g" (__val): "m" (*addr): "ccr", "%l0");
    return __val;
  }

Thanks,
Matt