Scheduling of asm()

Falk Hueffner falk.hueffner@student.uni-tuebingen.de
Sun Jan 6 14:49:00 GMT 2002


mike stump <mrs@windriver.com> writes:

> > When I experimented with some Alpha instructions, I found out
> > there seems to be no way to communicate the scheduling class of an
> > asm() instruction to gcc, leading to somewhat suboptimal
> > code. Would it be reasonably easy to add such a facility?
> 
> If the semantics of the instruction can be written in C, then
> improve the compiler to notice that it can use the instruction to
> implement the required semantics of plain user code.  If the
> semantics are beyond the reach of normal C, then code it as a
> built-in and expose it that way.

This is about instructions that cannot be generated by the compiler,
like zap with a non-constant second argument, cmpbge, or perr.  If I
were to implement them as builtins, I'd end up with one builtin per
opcode, which seems pretty silly, since unlike for example prefetches,
those don't exist on other platforms.  Rather than doing that I'd
teach gcc to look at the opcode in the asm and find its scheduling
class in a table.  This has the advantage of not exposing any more
internals, and the disadvantage of being more work and being
platform-specific, compared to a user supplied scheduling class.  Does
this sound acceptable?

> Both obviate the need for asm("..."), which is a feature.

Sure, I would really like to avoid using asm, too, but it's inevitable
for the features mentioned above.

        Falk



More information about the Gcc mailing list