- 论坛徽章:
- 0
|
gcc针对MIPS自动将分支指令扩展为分支+NOP指令
这是google的:
http://gcc.gnu.org/ml/gcc/2008-01/msg00577.html
Boris Boesler <baembel@gmx.de> writes:
> I have to insert NOP-instructions into the insn-stream in my back-
> end. I do this with something ala emit_insn_after(gen_nop, xyz). This
> works so far.
>
> GCC leaves control-flow operations as they are, if it there are no
> instructions which can be used to fill the branch delay slots. My
> first idea was to convert these control-flow cf to SEQUENCE(cf) and
> hope the GCC will invoke DBR_OUTPUT_SEQEND(), but it does not? My
> second idea was to add these NOP-instructions: SEQUENCE(cf,
> NOP,...,NOP). I "reused" the code in function emit_delay_sequence()
> in reorg.c and added NOPs with:
> XVECEXP (seq, 0, i) = emit_insn_after(tem, XVECEXP (seq, 0, i - 1));
> or
> XVECEXP (seq, 0, i) = tem;
> But GCC will fail in both cases in final_scan_insn() or asm_noperands
> (). In both cases the CONST_INT (pattern for nop) is passed as a rtx
> pointer.
>
> so, how do I add NOP-instructions properly?
I'm not quite sure what you're trying to do here. Do you need to insert
nops in delay slots only, or do you need to insert nops at other places
too (such as to work around processor errata)?
If the former: you don't need to make delay-slot nops explicit in
the rtl. Just make your branch output patterns add whatever nops
are needed. See the MIPS port for an example. E.g. on MIPS,
a plain "jr foo" JUMP_INSN is written as:
jr foo
nop
(Specifically, MIPS uses a special '%/' asm punctuation character,
so that:
"jr\t%0%/"
will print a nop if the rtl has no explicit delay slot.)
If you need to insert nops outside delay slots, than you should
do it after delayed-branch scheduling. Again, MIPS has examples
of this; it calls dbr_schedule from within md_reorg.
Not sure if that's any help though, sorry... |
|