This patch implements functionality in MIPS delay slot filler such as if delay slot filler have to put NOP instruction into the delay slot of microMIPS BEQ or BNE instruction which uses the register $0, then instead of emitting NOP this instruction is replaced by the corresponding microMIPS compact branch instruction, i.e. BEQZC or BNEZC.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
LGTM with micromips-long-branch.ll change explained, and with the Br->hasDelaySlot() change.
lib/Target/Mips/MipsDelaySlotFiller.cpp | ||
---|---|---|
535–546 ↗ | (On Diff #8966) | You don't have to do it in this patch, but the same trick will be useful for MIPS32r6/MIPS64r6. It would be good to use a try/fallback approach so we don't have to add several if-statements. E.g something like: if (!replaceWithCompactBranch(...)) bundle a NOP with the branch where replaceWithCompactBranch() returns true if it sucessfully used a compact branch. |
lib/Target/Mips/MipsLongBranch.cpp | ||
240–241 ↗ | (On Diff #8966) | I believe this should be: if (!Br->hasDelaySlot()) ... |
test/CodeGen/Mips/micromips-long-branch.ll | ||
16423 ↗ | (On Diff #8966) | Why did this change when nothing else in the file did? I can't think of a reason the patch would change it. |
Rebased patch:
In the function MipsLongBranch::replaceBranch() the condition:
((unsigned) Br->getOpcode()) != Mips::BEQZC_MM && ((unsigned) Br->getOpcode()) != Mips::BNEZC_MM
is replaced with:
Br->hasDelaySlot()
The file 'test/CodeGen/Mips/micromips-long-branch.ll' has been removed since by commit 207656. MicroMIPS long branch is now tested in the file 'test/CodeGen/Mips/longbranch.ll'. Back then the change of value of ADDIU instruction was due to its role in calculation of long branches. The immediate part of ADDIU was something like %lo(($lab1)-($lab2)), and because BEQZ was between $lab1 and $lab2 after it was replaced by BEQZC (no NOP anymore) the immediate value of ADDIU was changed.