MS/CW-style inline assembly for GCC

Robert Dewar dewar@gnat.com
Mon May 10 14:34:00 GMT 2004


Paul Koning wrote:

 Geoff> Why wouldn't you write the code in C in these cases?  It seems
 Geoff> to me that if you're willing to have the compiler schedule the
 Geoff> code, you might as well let it select the instructions and do
 Geoff> register allocation as well.
Good argument.

Assembler belongs in places where you need more performance than a
compiler can give you -- in which case you MUST know scheduling.  And
it belongs in places where you need absolute control over what happens
-- diagnostics, DRAM initialization, bootstraps, stuff like that.
One obvious reason for using ASM inserts is that GCC simply
can't generate good code for some things. A very painful
example from Ada's point of view is integer overflow
checking. On many machines this can be done efficiently
but GCC does not know how (yes, it should be taught, it
is on our list :-)
So if someone wanted to have efficient integer overflow
checking they would have to use ASM inserts, and in such
a case, they do want full optimization (providing that
GCC can do it correctly :-)



More information about the Gcc mailing list