This is the mail archive of the gcc@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]

Re: Unfillable branch delay slots



> My MIPS-like port fails to generate NOP to fill a delay slot when no
> useful insn will fit.  I don't see any mention of this case in the
> GCC manual.  How is this supposed to be done?

Heh, I just fixed this one myself yesterday.  It's not obvious from
the documentation, but it works like this:

Hook DBR_OUTPUT_SEQEND.  If `final_sequence' (a global in output.h) is
not null, then gcc has scheduled one or more insns into the delay
slot.  `final_sequence' itself is a SEQUENCE rtl, the first entry of
which is the insn that has delay slots.  Examine this insn to
determine the number of delay slots needed.  Call
dbr_sequence_length() to determine how many have already been filled.
Use fprintf to emit the remaining nops.

There's a catch.  If *zero* delay slots were filled, there is no
SEQUENCE, and dbr_output_seqend is never called (I consider this a
bug; gcc should create a SEQUENCE anyway to make the API cleaner).
You need to detect this in the emit phase of your insn, i.e. in the md
file, use something like "* return chip_emit_this_insn(operands);".
If `final_sequence' is NULL, return a string for your opcode and the
nops for the delay slots (i.e. return "mov %1,%2\n\tnop\n\tnop").  If
it is not NULL, just return the opcode string.

If you get it working, consider submitting a doc patch.


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