}
/// PredicateInstruction - Convert the instruction into a predicated
- /// instruction.
- virtual void PredicateInstruction(MachineInstr *MI,
+ /// instruction. It returns true if the operation was successful.
+ virtual bool PredicateInstruction(MachineInstr *MI,
std::vector<MachineOperand> &Cond) const;
/// getPointerRegClass - Returns a TargetRegisterClass used for pointer
return false;
}
-void ARMInstrInfo::PredicateInstruction(MachineInstr *MI,
+bool ARMInstrInfo::PredicateInstruction(MachineInstr *MI,
std::vector<MachineOperand> &Cond) const {
unsigned Opc = MI->getOpcode();
if (Opc == ARM::B || Opc == ARM::tB) {
MI->setInstrDescriptor(get(Opc == ARM::B ? ARM::Bcc : ARM::tBcc));
MI->addImmOperand(Cond[0].getImmedValue());
- return;
+ return true;
}
MachineOperand *PMO = MI->findFirstPredOperand();
- PMO->setImm(Cond[0].getImmedValue());
+ if (PMO) {
+ PMO->setImm(Cond[0].getImmedValue());
+ return true;
+ }
+ return false;
}
virtual bool ReverseBranchCondition(std::vector<MachineOperand> &Cond) const;
// Predication support.
- virtual void PredicateInstruction(MachineInstr *MI,
+ virtual bool PredicateInstruction(MachineInstr *MI,
std::vector<MachineOperand> &Cond) const;
};
return MI;
}
-void TargetInstrInfo::PredicateInstruction(MachineInstr *MI,
+bool TargetInstrInfo::PredicateInstruction(MachineInstr *MI,
std::vector<MachineOperand> &Cond) const {
+ bool MadeChange = false;
const TargetInstrDescriptor *TID = MI->getInstrDescriptor();
- assert((TID->Flags & M_PREDICABLE) &&
- "Predicating an unpredicable instruction!");
-
- for (unsigned j = 0, i = 0, e = MI->getNumOperands(); i != e; ++i) {
- if ((TID->OpInfo[i].Flags & M_PREDICATE_OPERAND)) {
- MachineOperand &MO = MI->getOperand(i);
- if (MO.isReg())
- MO.setReg(Cond[j].getReg());
- else if (MO.isImm())
- MO.setImm(Cond[j].getImmedValue());
- else if (MO.isMBB())
- MO.setMachineBasicBlock(Cond[j].getMachineBasicBlock());
- ++j;
+ if (TID->Flags & M_PREDICABLE) {
+ for (unsigned j = 0, i = 0, e = MI->getNumOperands(); i != e; ++i) {
+ if ((TID->OpInfo[i].Flags & M_PREDICATE_OPERAND)) {
+ MachineOperand &MO = MI->getOperand(i);
+ if (MO.isReg()) {
+ MO.setReg(Cond[j].getReg());
+ MadeChange = true;
+ } else if (MO.isImm()) {
+ MO.setImm(Cond[j].getImmedValue());
+ MadeChange = true;
+ } else if (MO.isMBB()) {
+ MO.setMachineBasicBlock(Cond[j].getMachineBasicBlock());
+ MadeChange = true;
+ }
+ ++j;
+ }
}
}
+ return MadeChange;
}