GCC with __asm__ generic temporary register query

Segher Boessenkool segher@kernel.crashing.org
Sun Jun 24 18:29:00 GMT 2007


> Is it possible to ask GCC to allocate a register but not have to 
> assign it a local variable (because its a temporary register used in 
> the __asm__ block) ?
>
> This way GCC knows that register is clobbered and allocated but does 
> not need to generate any load or store to the local variable 
> before/after the insertion of the __asm__ block.

GCC will optimise those dummy assignments away already.

> The usual syntax would be like:
> __asm__ __volatile__ (
> "nop"
> : "=r" ((local_output_var))
> : "r" ((local_input_var))
> : /* clobber list */
> );
>
> I'd essentially asking to do away with the "((local_foobar_var))" 
> part, since I just want a register substituted for "%0" and/or "%1" 
> that is not reciprocated with a C variable.

For the output var, you can use the clobber list instead,
but you have to use a hard register then -- not the
smartest move in most cases.

For the input var -- well it just shouldn't be listed as
input if it isn't one!

Showing us a real piece of code would likely get you a
better answer, btw.


Segher



More information about the Gcc-help mailing list