inline assembly operands
Jim Wilson
wilson@specifixinc.com
Fri Jun 25 00:48:00 GMT 2004
Luchezar Belev wrote:
> why out-of-function asm statements can't have operands?
Old-style asms just emit a string to the assembly file, and can appear
anywhere.
Extended asms are converted into IL. If they appear outside a function,
then that is a serious problem, as we can't process IL outside of a
function context.
We could perhaps handle a limited set of machine independent constraints
outside a function, but quite a bit of new code would have to be
written, and it isn't clear if it is worth the effort. There would also
be a documentation problem explaining what works outside functions and
what doesn't.
> asm (".equ A, %0"::"i"(sizeof(something)));
> /* and compile with -masm=intel to make the
> * compiler not to prefix the "immediate operand" */
There is usually a print code you can use to solve this. %a0 works fine
for x86, and probably also for many other targets.
> but now it seems unreliable since with the new
> unit-at-a-time feature the compiler may reorder
> the functions and top-level asm statements arbitrarily.
Yes. It won't be reliable unless you use -fno-unit-at-a-time.
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com
More information about the Gcc
mailing list