This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Unfillable branch delay slots
- To: greg at mcgary dot org
- Subject: Re: Unfillable branch delay slots
- From: DJ Delorie <dj at redhat dot com>
- Date: Thu, 26 Apr 2001 12:16:57 -0400
- CC: gcc at gcc dot gnu dot org
- References: <200104260015.RAA02782@kayak.mcgary.org>
> 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.