getPreIndexedLoad -> getIndexedLoad.
authorEvan Cheng <evan.cheng@apple.com>
Thu, 26 Oct 2006 21:53:40 +0000 (21:53 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Thu, 26 Oct 2006 21:53:40 +0000 (21:53 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31209 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/SelectionDAG.cpp

index 45fd350496c4bbf2f3f340755b3b558c1a8b9026..3bd6768576c9f8f448fd3211d825721e0402a55b 100644 (file)
@@ -1447,28 +1447,14 @@ SDOperand SelectionDAG::getExtLoad(ISD::LoadExtType ExtType, MVT::ValueType VT,
   return SDOperand(N, 0);
 }
 
-SDOperand SelectionDAG::getPreIndexedLoad(SDOperand OrigLoad, SDOperand Base) {
+SDOperand SelectionDAG::getIndexedLoad(SDOperand OrigLoad, SDOperand Base,
+                                       SDOperand Offset, ISD::MemOpAddrMode AM){
   LoadSDNode *LD = cast<LoadSDNode>(OrigLoad);
-  SDOperand Ptr = LD->getBasePtr();
-  MVT::ValueType PtrVT = Ptr.getValueType();
-  unsigned Opc = Ptr.getOpcode();
-  SDOperand Offset = LD->getOffset();
-  assert(Offset.getOpcode() == ISD::UNDEF);
-  assert((Opc == ISD::ADD || Opc == ISD::SUB) &&
-         "Load address must be <base +/- offset>!");
-  ISD::MemOpAddrMode AM = (Opc == ISD::ADD) ? ISD::PRE_INC : ISD::PRE_DEC;
-  if (Ptr.getOperand(0) == Base) {
-    Offset = Ptr.getOperand(1);
-    Ptr = Ptr.getOperand(0);
-  } else {
-    assert(Ptr.getOperand(1) == Base);
-    Offset = Ptr.getOperand(0);
-    Ptr = Ptr.getOperand(1);
-  }
-
+  assert(LD->getOffset().getOpcode() == ISD::UNDEF &&
+         "Load is already a indexed load!");
   MVT::ValueType VT = OrigLoad.getValueType();
-  SDVTList VTs = getVTList(VT, PtrVT, MVT::Other);
-  SelectionDAGCSEMap::NodeID ID(ISD::LOAD, VTs, LD->getChain(), Ptr, Offset);
+  SDVTList VTs = getVTList(VT, Base.getValueType(), MVT::Other);
+  SelectionDAGCSEMap::NodeID ID(ISD::LOAD, VTs, LD->getChain(), Base, Offset);
   ID.AddInteger(AM);
   ID.AddInteger(LD->getExtensionType());
   ID.AddInteger(LD->getLoadedVT());
@@ -1479,7 +1465,7 @@ SDOperand SelectionDAG::getPreIndexedLoad(SDOperand OrigLoad, SDOperand Base) {
   void *IP = 0;
   if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
     return SDOperand(E, 0);
-  SDNode *N = new LoadSDNode(LD->getChain(), Ptr, Offset, AM,
+  SDNode *N = new LoadSDNode(LD->getChain(), Base, Offset, AM,
                              LD->getExtensionType(), LD->getLoadedVT(),
                              LD->getSrcValue(), LD->getSrcValueOffset(),
                              LD->getAlignment(), LD->isVolatile());