mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-07 14:33:15 +00:00
[mips] [IAS] Outline NOP creation. NFC.
Summary: Make the code more readable by outlining NOP creation. Reviewers: dsanders Reviewed By: dsanders Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D8320 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232371 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
05dd2d9019
commit
9565a29874
@ -193,6 +193,9 @@ class MipsAsmParser : public MCTargetAsmParser {
|
|||||||
bool expandLoadStoreMultiple(MCInst &Inst, SMLoc IDLoc,
|
bool expandLoadStoreMultiple(MCInst &Inst, SMLoc IDLoc,
|
||||||
SmallVectorImpl<MCInst> &Instructions);
|
SmallVectorImpl<MCInst> &Instructions);
|
||||||
|
|
||||||
|
void createNop(bool hasShortDelaySlot, SMLoc IDLoc,
|
||||||
|
SmallVectorImpl<MCInst> &Instructions);
|
||||||
|
|
||||||
bool reportParseError(Twine ErrorMsg);
|
bool reportParseError(Twine ErrorMsg);
|
||||||
bool reportParseError(SMLoc Loc, Twine ErrorMsg);
|
bool reportParseError(SMLoc Loc, Twine ErrorMsg);
|
||||||
|
|
||||||
@ -1367,22 +1370,11 @@ bool MipsAsmParser::processInstruction(MCInst &Inst, SMLoc IDLoc,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MCID.hasDelaySlot() && AssemblerOptions.back()->isReorder()) {
|
|
||||||
// If this instruction has a delay slot and .set reorder is active,
|
// If this instruction has a delay slot and .set reorder is active,
|
||||||
// emit a NOP after it.
|
// emit a NOP after it.
|
||||||
|
if (MCID.hasDelaySlot() && AssemblerOptions.back()->isReorder()) {
|
||||||
Instructions.push_back(Inst);
|
Instructions.push_back(Inst);
|
||||||
MCInst NopInst;
|
createNop(hasShortDelaySlot(Inst.getOpcode()), IDLoc, Instructions);
|
||||||
if (hasShortDelaySlot(Inst.getOpcode())) {
|
|
||||||
NopInst.setOpcode(Mips::MOVE16_MM);
|
|
||||||
NopInst.addOperand(MCOperand::CreateReg(Mips::ZERO));
|
|
||||||
NopInst.addOperand(MCOperand::CreateReg(Mips::ZERO));
|
|
||||||
} else {
|
|
||||||
NopInst.setOpcode(Mips::SLL);
|
|
||||||
NopInst.addOperand(MCOperand::CreateReg(Mips::ZERO));
|
|
||||||
NopInst.addOperand(MCOperand::CreateReg(Mips::ZERO));
|
|
||||||
NopInst.addOperand(MCOperand::CreateImm(0));
|
|
||||||
}
|
|
||||||
Instructions.push_back(NopInst);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1984,14 +1976,10 @@ bool MipsAsmParser::expandUncondBranchMMPseudo(
|
|||||||
}
|
}
|
||||||
Instructions.push_back(Inst);
|
Instructions.push_back(Inst);
|
||||||
|
|
||||||
if (AssemblerOptions.back()->isReorder()) {
|
|
||||||
// If .set reorder is active, emit a NOP after the branch instruction.
|
// If .set reorder is active, emit a NOP after the branch instruction.
|
||||||
MCInst NopInst;
|
if (AssemblerOptions.back()->isReorder())
|
||||||
NopInst.setOpcode(Mips::MOVE16_MM);
|
createNop(true, IDLoc, Instructions);
|
||||||
NopInst.addOperand(MCOperand::CreateReg(Mips::ZERO));
|
|
||||||
NopInst.addOperand(MCOperand::CreateReg(Mips::ZERO));
|
|
||||||
Instructions.push_back(NopInst);
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2134,6 +2122,22 @@ MipsAsmParser::expandLoadStoreMultiple(MCInst &Inst, SMLoc IDLoc,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MipsAsmParser::createNop(bool hasShortDelaySlot, SMLoc IDLoc,
|
||||||
|
SmallVectorImpl<MCInst> &Instructions) {
|
||||||
|
MCInst NopInst;
|
||||||
|
if (hasShortDelaySlot) {
|
||||||
|
NopInst.setOpcode(Mips::MOVE16_MM);
|
||||||
|
NopInst.addOperand(MCOperand::CreateReg(Mips::ZERO));
|
||||||
|
NopInst.addOperand(MCOperand::CreateReg(Mips::ZERO));
|
||||||
|
} else {
|
||||||
|
NopInst.setOpcode(Mips::SLL);
|
||||||
|
NopInst.addOperand(MCOperand::CreateReg(Mips::ZERO));
|
||||||
|
NopInst.addOperand(MCOperand::CreateReg(Mips::ZERO));
|
||||||
|
NopInst.addOperand(MCOperand::CreateImm(0));
|
||||||
|
}
|
||||||
|
Instructions.push_back(NopInst);
|
||||||
|
}
|
||||||
|
|
||||||
unsigned MipsAsmParser::checkTargetMatchPredicate(MCInst &Inst) {
|
unsigned MipsAsmParser::checkTargetMatchPredicate(MCInst &Inst) {
|
||||||
// As described by the Mips32r2 spec, the registers Rd and Rs for
|
// As described by the Mips32r2 spec, the registers Rd and Rs for
|
||||||
// jalr.hb must be different.
|
// jalr.hb must be different.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user