aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm/lib/Target/Sparc/DelaySlotFiller.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/lib/Target/Sparc/DelaySlotFiller.cpp')
-rw-r--r--contrib/llvm/lib/Target/Sparc/DelaySlotFiller.cpp39
1 files changed, 28 insertions, 11 deletions
diff --git a/contrib/llvm/lib/Target/Sparc/DelaySlotFiller.cpp b/contrib/llvm/lib/Target/Sparc/DelaySlotFiller.cpp
index c689b7f7201e..944f3551279e 100644
--- a/contrib/llvm/lib/Target/Sparc/DelaySlotFiller.cpp
+++ b/contrib/llvm/lib/Target/Sparc/DelaySlotFiller.cpp
@@ -38,14 +38,10 @@ static cl::opt<bool> DisableDelaySlotFiller(
namespace {
struct Filler : public MachineFunctionPass {
- /// Target machine description which we query for reg. names, data
- /// layout, etc.
- ///
- TargetMachine &TM;
const SparcSubtarget *Subtarget;
static char ID;
- Filler(TargetMachine &tm) : MachineFunctionPass(ID), TM(tm) {}
+ Filler() : MachineFunctionPass(ID) {}
const char *getPassName() const override {
return "SPARC Delay Slot Filler";
@@ -66,6 +62,11 @@ namespace {
return Changed;
}
+ MachineFunctionProperties getRequiredProperties() const override {
+ return MachineFunctionProperties().set(
+ MachineFunctionProperties::Property::AllVRegsAllocated);
+ }
+
void insertCallDefsUses(MachineBasicBlock::iterator MI,
SmallSet<unsigned, 32>& RegDefs,
SmallSet<unsigned, 32>& RegUses);
@@ -98,7 +99,7 @@ namespace {
/// slots in Sparc MachineFunctions
///
FunctionPass *llvm::createSparcDelaySlotFillerPass(TargetMachine &tm) {
- return new Filler(tm);
+ return new Filler;
}
@@ -268,6 +269,22 @@ bool Filler::delayHasHazard(MachineBasicBlock::iterator candidate,
return true;
}
}
+
+ unsigned Opcode = candidate->getOpcode();
+ // LD and LDD may have NOPs inserted afterwards in the case of some LEON
+ // processors, so we can't use the delay slot if this feature is switched-on.
+ if (Subtarget->insertNOPLoad()
+ &&
+ Opcode >= SP::LDDArr && Opcode <= SP::LDrr)
+ return true;
+
+ // Same as above for FDIV and FSQRT on some LEON processors.
+ if (Subtarget->fixAllFDIVSQRT()
+ &&
+ Opcode >= SP::FDIVD && Opcode <= SP::FSQRTD)
+ return true;
+
+
return false;
}
@@ -290,12 +307,12 @@ void Filler::insertCallDefsUses(MachineBasicBlock::iterator MI,
assert(Reg.isUse() && "CALL first operand is not a use.");
RegUses.insert(Reg.getReg());
- const MachineOperand &RegOrImm = MI->getOperand(1);
- if (RegOrImm.isImm())
+ const MachineOperand &Operand1 = MI->getOperand(1);
+ if (Operand1.isImm() || Operand1.isGlobal())
break;
- assert(RegOrImm.isReg() && "CALLrr second operand is not a register.");
- assert(RegOrImm.isUse() && "CALLrr second operand is not a use.");
- RegUses.insert(RegOrImm.getReg());
+ assert(Operand1.isReg() && "CALLrr second operand is not a register.");
+ assert(Operand1.isUse() && "CALLrr second operand is not a use.");
+ RegUses.insert(Operand1.getReg());
break;
}
}