diff --git a/lib/Target/ARM/ARMInstrInfo.cpp b/lib/Target/ARM/ARMInstrInfo.cpp index ff717d9deae..7b7b0b46f45 100644 --- a/lib/Target/ARM/ARMInstrInfo.cpp +++ b/lib/Target/ARM/ARMInstrInfo.cpp @@ -431,13 +431,13 @@ ReverseBranchCondition(std::vector &Cond) const { return false; } -bool ARMInstrInfo::isPredicated(MachineInstr *MI) const { - MachineOperand *PMO = MI->findFirstPredOperand(); - return PMO && PMO->getImmedValue() != ARMCC::AL; +bool ARMInstrInfo::isPredicated(const MachineInstr *MI) const { + int PIdx = MI->findFirstPredOperandIdx(); + return PIdx != -1 && MI->getOperand(PIdx).getImmedValue() != ARMCC::AL; } bool ARMInstrInfo::PredicateInstruction(MachineInstr *MI, - std::vector &Pred) const { + const std::vector &Pred) const { unsigned Opc = MI->getOpcode(); if (Opc == ARM::B || Opc == ARM::tB) { MI->setInstrDescriptor(get(Opc == ARM::B ? ARM::Bcc : ARM::tBcc)); @@ -445,16 +445,18 @@ bool ARMInstrInfo::PredicateInstruction(MachineInstr *MI, return true; } - MachineOperand *PMO = MI->findFirstPredOperand(); - if (PMO) { - PMO->setImm(Pred[0].getImmedValue()); + int PIdx = MI->findFirstPredOperandIdx(); + if (PIdx != -1) { + MachineOperand &PMO = MI->getOperand(PIdx); + PMO.setImm(Pred[0].getImmedValue()); return true; } return false; } -bool ARMInstrInfo::SubsumesPredicate(std::vector &Pred1, - std::vector &Pred2) const{ +bool +ARMInstrInfo::SubsumesPredicate(const std::vector &Pred1, + const std::vector &Pred2) const{ if (Pred1.size() > 1 || Pred2.size() > 1) return false; diff --git a/lib/Target/ARM/ARMInstrInfo.h b/lib/Target/ARM/ARMInstrInfo.h index 3f24c8b8294..5b406cb8168 100644 --- a/lib/Target/ARM/ARMInstrInfo.h +++ b/lib/Target/ARM/ARMInstrInfo.h @@ -104,13 +104,15 @@ public: virtual bool ReverseBranchCondition(std::vector &Cond) const; // Predication support. - virtual bool isPredicated(MachineInstr *MI) const; + virtual bool isPredicated(const MachineInstr *MI) const; - virtual bool PredicateInstruction(MachineInstr *MI, - std::vector &Pred) const; + virtual + bool PredicateInstruction(MachineInstr *MI, + const std::vector &Pred) const; - virtual bool SubsumesPredicate(std::vector &Pred1, - std::vector &Pred1) const; + virtual + bool SubsumesPredicate(const std::vector &Pred1, + const std::vector &Pred1) const; }; // Utility routines diff --git a/lib/Target/ARM/ARMLoadStoreOptimizer.cpp b/lib/Target/ARM/ARMLoadStoreOptimizer.cpp index 7977555b0ed..f9d760b874b 100644 --- a/lib/Target/ARM/ARMLoadStoreOptimizer.cpp +++ b/lib/Target/ARM/ARMLoadStoreOptimizer.cpp @@ -245,8 +245,9 @@ ARMLoadStoreOpt::MergeLDR_STR(MachineBasicBlock &MBB, unsigned SIndex, /// getInstrPredicate - If instruction is predicated, returns its predicate /// condition, otherwise returns AL. static ARMCC::CondCodes getInstrPredicate(MachineInstr *MI) { - MachineOperand *PredMO = MI->findFirstPredOperand(); - return PredMO ? (ARMCC::CondCodes)PredMO->getImmedValue() : ARMCC::AL; + int PIdx = MI->findFirstPredOperandIdx(); + return PIdx == -1 ? ARMCC::AL + : (ARMCC::CondCodes)MI->getOperand(PIdx).getImmedValue(); } static inline bool isMatchingDecrement(MachineInstr *MI, unsigned Base, diff --git a/lib/Target/ARM/ARMRegisterInfo.cpp b/lib/Target/ARM/ARMRegisterInfo.cpp index 890542aa1d5..41bafdcfff5 100644 --- a/lib/Target/ARM/ARMRegisterInfo.cpp +++ b/lib/Target/ARM/ARMRegisterInfo.cpp @@ -1009,9 +1009,9 @@ void ARMRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II, if (ScratchReg == 0) // No register is "free". Scavenge a register. ScratchReg = RS->scavengeRegister(&ARM::GPRRegClass, II, SPAdj); - MachineOperand *MO = MI.findFirstPredOperand(); - ARMCC::CondCodes Pred = MO ? - (ARMCC::CondCodes)MO->getImmedValue() : ARMCC::AL; + int PIdx = MI.findFirstPredOperandIdx(); + ARMCC::CondCodes Pred = (PIdx == -1) + ? ARMCC::AL : (ARMCC::CondCodes)MI.getOperand(PIdx).getImmedValue(); emitARMRegPlusImmediate(MBB, II, ScratchReg, FrameReg, Pred, isSub ? -Offset : Offset, TII); MI.getOperand(i).ChangeToRegister(ScratchReg, false, false, true);