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

include/llvm/CodeGen/MachineInstr.h
include/llvm/Target/TargetInstrInfo.h
lib/CodeGen/MachineInstr.cpp
lib/Target/TargetInstrInfo.cpp

index 52ae842da34b2d83cd1b5b2127f0c2db21cee96f..c20d231a5cdf5ead3fc90a87e036fec50142d97f 100644 (file)
@@ -415,15 +415,16 @@ public:
   /// findRegisterUseOperandIdx() - Returns the operand index that is a use of
   /// the specific register or -1 if it is not found. It further tightening
   /// the search criteria to a use that kills the register if isKill is true.
-  int findRegisterUseOperandIdx(unsigned Reg, bool isKill = false);
+  int findRegisterUseOperandIdx(unsigned Reg, bool isKill = false) const;
   
   /// findRegisterDefOperand() - Returns the MachineOperand that is a def of
   /// the specific register or NULL if it is not found.
   MachineOperand *findRegisterDefOperand(unsigned Reg);
 
-  /// findFirstPredOperand() - Find the first operand in the operand list that
-  // is used to represent the predicate.
-  MachineOperand *findFirstPredOperand();
+  /// findFirstPredOperandIdx() - Find the index of the first operand in the
+  /// operand list that is used to represent the predicate. It returns -1 if
+  /// none is found.
+  int findFirstPredOperandIdx() const;
   
   /// copyKillDeadInfo - Copies kill / dead operand properties from MI.
   ///
index bb1dfd2b36bce1d352269ef561d3abecd8b75b63..5fe9130634b8cceff0b4fe70c070c998a7a997fc 100644 (file)
@@ -395,19 +395,21 @@ public:
 
   /// isPredicable - Returns true if the instruction is already predicated.
   ///
-  virtual bool isPredicated(MachineInstr *MI) const {
+  virtual bool isPredicated(const MachineInstr *MI) const {
     return false;
   }
 
   /// PredicateInstruction - Convert the instruction into a predicated
   /// instruction. It returns true if the operation was successful.
-  virtual bool PredicateInstruction(MachineInstr *MI,
-                                    std::vector<MachineOperand> &Pred) const;
+  virtual
+  bool PredicateInstruction(MachineInstr *MI,
+                            const std::vector<MachineOperand> &Pred) const;
 
   /// SubsumesPredicate - Returns true if the first specified predicated
   /// subsumes the second, e.g. GE subsumes GT.
-  virtual bool SubsumesPredicate(std::vector<MachineOperand> &Pred1,
-                                 std::vector<MachineOperand> &Pred2) const {
+  virtual
+  bool SubsumesPredicate(const std::vector<MachineOperand> &Pred1,
+                         const std::vector<MachineOperand> &Pred2) const {
     return false;
   }
 
index d27cf6a77b08d5e3cee3dc7f6f2632074b7645d7..723296eda4773d2c35a0659f2e047a23e05fe229 100644 (file)
@@ -191,9 +191,9 @@ bool MachineInstr::isPredicable() const {
 /// findRegisterUseOperandIdx() - Returns the MachineOperand that is a use of
 /// the specific register or -1 if it is not found. It further tightening
 /// the search criteria to a use that kills the register if isKill is true.
-int MachineInstr::findRegisterUseOperandIdx(unsigned Reg, bool isKill) {
+int MachineInstr::findRegisterUseOperandIdx(unsigned Reg, bool isKill) const {
   for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
-    MachineOperand &MO = getOperand(i);
+    const MachineOperand &MO = getOperand(i);
     if (MO.isReg() && MO.isUse() && MO.getReg() == Reg)
       if (!isKill || MO.isKill())
         return i;
@@ -212,17 +212,18 @@ MachineOperand *MachineInstr::findRegisterDefOperand(unsigned Reg) {
   return NULL;
 }
 
-/// findFirstPredOperand() - Find the first operand in the operand list that
-// is used to represent the predicate.
-MachineOperand *MachineInstr::findFirstPredOperand() {
+/// findFirstPredOperandIdx() - Find the index of the first operand in the
+/// operand list that is used to represent the predicate. It returns -1 if
+/// none is found.
+int MachineInstr::findFirstPredOperandIdx() const {
   const TargetInstrDescriptor *TID = getInstrDescriptor();
   if (TID->Flags & M_PREDICABLE) {
     for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
       if ((TID->OpInfo[i].Flags & M_PREDICATE_OPERAND))
-        return &getOperand(i);
+        return i;
   }
 
-  return NULL;
+  return -1;
 }
   
 /// copyKillDeadInfo - Copies kill / dead operand properties from MI.
index 54158f756a66713a605adad8027159259768f390..56ec835a119784b3a1c77021133bdb4e0ed666e0 100644 (file)
@@ -61,7 +61,7 @@ MachineInstr *TargetInstrInfo::commuteInstruction(MachineInstr *MI) const {
 }
 
 bool TargetInstrInfo::PredicateInstruction(MachineInstr *MI,
-                                      std::vector<MachineOperand> &Pred) const {
+                                const std::vector<MachineOperand> &Pred) const {
   bool MadeChange = false;
   const TargetInstrDescriptor *TID = MI->getInstrDescriptor();
   if (TID->Flags & M_PREDICABLE) {