Eliminate all uses of memInst->getIndicesBROKEN().
authorVikram S. Adve <vadve@cs.uiuc.edu>
Sat, 15 Dec 2001 00:36:32 +0000 (00:36 +0000)
committerVikram S. Adve <vadve@cs.uiuc.edu>
Sat, 15 Dec 2001 00:36:32 +0000 (00:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1485 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/InstrSelectionSupport.h
lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp
lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp
lib/Target/SparcV9/SparcV9InstrSelection.cpp

index 90b3af713dc6e67e3c3033db9b8ee8cd58cf22ec..2cce1dc75426873a67f5b94510169ac6f574446a 100644 (file)
@@ -54,7 +54,7 @@ int64_t         GetConstantValueAsSignedInt     (const Value *V,
 //---------------------------------------------------------------------------
 
 Value*         FoldGetElemChain    (const InstructionNode* getElemInstrNode,
-                                    vector<Constant*>& chainIdxVec);
+                                    vector<Value*>& chainIdxVec);
 
 
 //------------------------------------------------------------------------ 
index 468bd8f5b6eb770244e063548f852df4e2346415..30d9c7eb78a88058a64930a6b63b5df7aab6a74d 100644 (file)
@@ -111,14 +111,14 @@ GetConstantValueAsSignedInt(const Value *V,
 
 Value*
 FoldGetElemChain(const InstructionNode* getElemInstrNode,
-                vector<Constant*>& chainIdxVec)
+                vector<Value*>& chainIdxVec)
 {
   MemAccessInst* getElemInst = (MemAccessInst*)
     getElemInstrNode->getInstruction();
   
   // Initialize return values from the incoming instruction
   Value* ptrVal = getElemInst->getPointerOperand();
-  chainIdxVec = getElemInst->getIndicesBROKEN(); // copies index vector values
+  chainIdxVec = getElemInst->copyIndices();
   
   // Now chase the chain of getElementInstr instructions, if any
   InstrTreeNode* ptrChild = getElemInstrNode->leftChild();
@@ -128,7 +128,7 @@ FoldGetElemChain(const InstructionNode* getElemInstrNode,
       // Child is a GetElemPtr instruction
       getElemInst = (MemAccessInst*)
        ((InstructionNode*) ptrChild)->getInstruction();
-      const vector<Constant*>& idxVec = getElemInst->getIndicesBROKEN();
+      const vector<Value*>& idxVec = getElemInst->copyIndices();
       
       // Get the pointer value out of ptrChild and *prepend* its index vector
       ptrVal = getElemInst->getPointerOperand();
index 468bd8f5b6eb770244e063548f852df4e2346415..30d9c7eb78a88058a64930a6b63b5df7aab6a74d 100644 (file)
@@ -111,14 +111,14 @@ GetConstantValueAsSignedInt(const Value *V,
 
 Value*
 FoldGetElemChain(const InstructionNode* getElemInstrNode,
-                vector<Constant*>& chainIdxVec)
+                vector<Value*>& chainIdxVec)
 {
   MemAccessInst* getElemInst = (MemAccessInst*)
     getElemInstrNode->getInstruction();
   
   // Initialize return values from the incoming instruction
   Value* ptrVal = getElemInst->getPointerOperand();
-  chainIdxVec = getElemInst->getIndicesBROKEN(); // copies index vector values
+  chainIdxVec = getElemInst->copyIndices();
   
   // Now chase the chain of getElementInstr instructions, if any
   InstrTreeNode* ptrChild = getElemInstrNode->leftChild();
@@ -128,7 +128,7 @@ FoldGetElemChain(const InstructionNode* getElemInstrNode,
       // Child is a GetElemPtr instruction
       getElemInst = (MemAccessInst*)
        ((InstructionNode*) ptrChild)->getInstruction();
-      const vector<Constant*>& idxVec = getElemInst->getIndicesBROKEN();
+      const vector<Value*>& idxVec = getElemInst->copyIndices();
       
       // Get the pointer value out of ptrChild and *prepend* its index vector
       ptrVal = getElemInst->getPointerOperand();
index 21212199a86254d45f4b4f748b51d77131a72c61..c4fe73567277278358a44bf3f2556dac9955ce11 100644 (file)
@@ -34,7 +34,7 @@ static void SetMemOperands_Internal     (MachineInstr* minstr,
                                          const InstructionNode* vmInstrNode,
                                          Value* ptrVal,
                                          Value* arrayOffsetVal,
-                                         const vector<Constant*>& idxVec,
+                                         const vector<Value*>& idxVec,
                                          const TargetMachine& target);
 
 
@@ -742,9 +742,7 @@ SetOperandsForMemInstr(MachineInstr* minstr,
   // The major work here is to extract these for all 3 instruction types
   // and then call the common function SetMemOperands_Internal().
   // 
-  const vector<Constant*> OLDIDXVEC = memInst->getIndicesBROKEN();
-  const vector<Constant*>* idxVec = &OLDIDXVEC;  //FIXME
-  vector<Constant*>* newIdxVec = NULL;
+  vector<Value*> idxVec;
   Value* ptrVal;
   Value* arrayOffsetVal = NULL;
   
@@ -765,12 +763,8 @@ SetOperandsForMemInstr(MachineInstr* minstr,
       // instruction into one single index vector.
       // Finally, we never fold for an array instruction so make that NULL.
       
-      newIdxVec = new vector<Constant*>;
-      ptrVal = FoldGetElemChain((InstructionNode*) ptrChild, *newIdxVec);
-      
-      newIdxVec->insert(newIdxVec->end(), idxVec->begin(), idxVec->end());
-      idxVec = newIdxVec;
-      
+      ptrVal = FoldGetElemChain((InstructionNode*) ptrChild, idxVec);
+      idxVec.insert(idxVec.end(), memInst->idx_begin(), memInst->idx_end());
       assert(!((PointerType*)ptrVal->getType())->getElementType()->isArrayType()
              && "GetElemPtr cannot be folded into array refs in selection");
     }
@@ -778,7 +772,8 @@ SetOperandsForMemInstr(MachineInstr* minstr,
     {
       // There is no GetElemPtr instruction.
       // Use the pointer value and the index vector from the Mem instruction.
-      // If it is an array reference, get the array offset value.
+      // If it is an array reference, check that it has been lowered to
+      // at most a single offset, then get the array offset value.
       // 
       ptrVal = memInst->getPointerOperand();
 
@@ -788,16 +783,12 @@ SetOperandsForMemInstr(MachineInstr* minstr,
           assert((memInst->getNumOperands()
                   == (unsigned) 1 + memInst->getFirstIndexOperandNumber())
                  && "Array refs must be lowered before Instruction Selection");
-          
-          arrayOffsetVal = memInst->getOperand(memInst->getFirstIndexOperandNumber());
+          arrayOffsetVal = * memInst->idx_begin();
         }
     }
   
   SetMemOperands_Internal(minstr, vmInstrNode, ptrVal, arrayOffsetVal,
-                          *idxVec, target);
-  
-  if (newIdxVec != NULL)
-    delete newIdxVec;
+                          idxVec, target);
 }
 
 
@@ -806,7 +797,7 @@ SetMemOperands_Internal(MachineInstr* minstr,
                         const InstructionNode* vmInstrNode,
                         Value* ptrVal,
                         Value* arrayOffsetVal,
-                        const vector<Constant*>& idxVec,
+                        const vector<Value*>& idxVec,
                         const TargetMachine& target)
 {
   MemAccessInst* memInst = (MemAccessInst*) vmInstrNode->getInstruction();