Add missing const qualifiers.
authorEvan Cheng <evan.cheng@apple.com>
Tue, 29 May 2007 18:42:18 +0000 (18:42 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Tue, 29 May 2007 18:42:18 +0000 (18:42 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37342 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMInstrInfo.cpp
lib/Target/ARM/ARMInstrInfo.h
lib/Target/ARM/ARMLoadStoreOptimizer.cpp
lib/Target/ARM/ARMRegisterInfo.cpp

index ff717d9deae9aefe97389ddaecb9fe3af80a6c18..7b7b0b46f454ed0c8b569c5bfe98b05494a37258 100644 (file)
@@ -431,13 +431,13 @@ ReverseBranchCondition(std::vector<MachineOperand> &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<MachineOperand> &Pred) const {
+                                const std::vector<MachineOperand> &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<MachineOperand> &Pred1,
-                                     std::vector<MachineOperand> &Pred2) const{
+bool
+ARMInstrInfo::SubsumesPredicate(const std::vector<MachineOperand> &Pred1,
+                                const std::vector<MachineOperand> &Pred2) const{
   if (Pred1.size() > 1 || Pred2.size() > 1)
     return false;
 
index 3f24c8b8294ca8fd3ab88c4429342a04d5760040..5b406cb8168f67626f9bbd53f08dd652ef0d3acb 100644 (file)
@@ -104,13 +104,15 @@ public:
   virtual bool ReverseBranchCondition(std::vector<MachineOperand> &Cond) const;
 
   // Predication support.
-  virtual bool isPredicated(MachineInstr *MI) const;
+  virtual bool isPredicated(const MachineInstr *MI) const;
 
-  virtual bool PredicateInstruction(MachineInstr *MI,
-                                    std::vector<MachineOperand> &Pred) const;
+  virtual
+  bool PredicateInstruction(MachineInstr *MI,
+                            const std::vector<MachineOperand> &Pred) const;
 
-  virtual bool SubsumesPredicate(std::vector<MachineOperand> &Pred1,
-                                 std::vector<MachineOperand> &Pred1) const;
+  virtual
+  bool SubsumesPredicate(const std::vector<MachineOperand> &Pred1,
+                         const std::vector<MachineOperand> &Pred1) const;
 };
 
   // Utility routines
index 7977555b0ed4843610d25ec9a016a6684c62494c..f9d760b874bd3186f3cdc42b3034503c65c888ec 100644 (file)
@@ -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,
index 890542aa1d5b7739479d1ff3a7348e147f3d2802..41bafdcfff5447f490ad83403eadb775fae08425 100644 (file)
@@ -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);