This is the mail archive of the gcc-help@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]
Other format: [Raw text]

Re: GCC with __asm__ generic temporary register query


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



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