eliminate the SDNode::setValueTypes method.
authorChris Lattner <sabre@nondot.org>
Sun, 4 Feb 2007 07:37:24 +0000 (07:37 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 4 Feb 2007 07:37:24 +0000 (07:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33876 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/SelectionDAGNodes.h
lib/CodeGen/SelectionDAG/SelectionDAG.cpp

index 01baab519210a8994b2b2c406f3696d881ec9339..a04290becab2abd4fa6ad571e11d515ef28a919c 100644 (file)
@@ -904,7 +904,7 @@ protected:
     return Ret;
   }
 
-  SDNode(unsigned Opc, const SDOperand *Ops, unsigned NumOps)
+  SDNode(unsigned Opc, SDVTList VTs, const SDOperand *Ops, unsigned NumOps)
     : NodeType(Opc), NodeId(-1) {
     OperandsNeedDelete = true;
     NumOperands = NumOps;
@@ -915,8 +915,8 @@ protected:
       SDNode *N = OperandList[i].Val;
       N->Uses.push_back(this);
     }
-    ValueList = 0;
-    NumValues = 0;
+    ValueList = VTs.VTs;
+    NumValues = VTs.NumVTs;
     Prev = 0; Next = 0;
   }
 
@@ -926,12 +926,6 @@ protected:
   void MorphNodeTo(unsigned Opc, SDVTList L,
                    const SDOperand *Ops, unsigned NumOps);
   
-  void setValueTypes(SDVTList L) {
-    assert(NumValues == 0 && "Should not have values yet!");
-    ValueList = L.VTs;
-    NumValues = L.NumVTs;
-  }
-  
   void addUser(SDNode *User) {
     Uses.push_back(User);
   }
@@ -987,7 +981,8 @@ inline bool SDOperand::hasOneUse() const {
 class HandleSDNode : public SDNode {
   virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
 public:
-  HandleSDNode(SDOperand X) : SDNode(ISD::HANDLENODE, &X, 1) {}
+  HandleSDNode(SDOperand X) : SDNode(ISD::HANDLENODE, getSDVTList(MVT::Other),
+                                     &X, 1) {}
   ~HandleSDNode();  
   SDOperand getValue() const { return getOperand(0); }
 };
@@ -998,8 +993,7 @@ class StringSDNode : public SDNode {
 protected:
   friend class SelectionDAG;
   StringSDNode(const std::string &val)
-    : SDNode(ISD::STRING, 0, 0), Value(val) {
-    setValueTypes(getSDVTList(MVT::Other));
+    : SDNode(ISD::STRING, getSDVTList(MVT::Other), 0, 0), Value(val) {
   }
 public:
   const std::string &getValue() const { return Value; }
@@ -1015,8 +1009,8 @@ class ConstantSDNode : public SDNode {
 protected:
   friend class SelectionDAG;
   ConstantSDNode(bool isTarget, uint64_t val, MVT::ValueType VT)
-    : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, 0, 0), Value(val) {
-    setValueTypes(getSDVTList(VT));
+    : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, getSDVTList(VT),
+             0, 0), Value(val) {
   }
 public:
 
@@ -1045,9 +1039,9 @@ class ConstantFPSDNode : public SDNode {
 protected:
   friend class SelectionDAG;
   ConstantFPSDNode(bool isTarget, double val, MVT::ValueType VT)
-    : SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP, 0, 0), 
+    : SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP,
+             getSDVTList(VT), 0, 0), 
       Value(val) {
-    setValueTypes(getSDVTList(VT));
   }
 public:
 
@@ -1074,9 +1068,9 @@ protected:
   friend class SelectionDAG;
   GlobalAddressSDNode(bool isTarget, const GlobalValue *GA, MVT::ValueType VT,
                       int o=0)
-    : SDNode(isTarget ? ISD::TargetGlobalAddress : ISD::GlobalAddress, 0, 0),
+    : SDNode(isTarget ? ISD::TargetGlobalAddress : ISD::GlobalAddress,
+             getSDVTList(VT), 0, 0),
       Offset(o) {
-    setValueTypes(getSDVTList(VT));
     TheGlobal = const_cast<GlobalValue*>(GA);
   }
 public:
@@ -1098,8 +1092,8 @@ class FrameIndexSDNode : public SDNode {
 protected:
   friend class SelectionDAG;
   FrameIndexSDNode(int fi, MVT::ValueType VT, bool isTarg)
-    : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, 0, 0), FI(fi) {
-    setValueTypes(getSDVTList(VT));
+    : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, getSDVTList(VT),
+             0, 0), FI(fi) {
   }
 public:
 
@@ -1118,8 +1112,8 @@ class JumpTableSDNode : public SDNode {
 protected:
   friend class SelectionDAG;
   JumpTableSDNode(int jti, MVT::ValueType VT, bool isTarg)
-    : SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable, 0, 0), JTI(jti) {
-    setValueTypes(getSDVTList(VT));
+    : SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable, getSDVTList(VT),
+             0, 0), JTI(jti) {
   }
 public:
     
@@ -1144,35 +1138,32 @@ protected:
   friend class SelectionDAG;
   ConstantPoolSDNode(bool isTarget, Constant *c, MVT::ValueType VT,
                      int o=0)
-    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 0, 0),
-      Offset(o), Alignment(0) {
+    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
+             getSDVTList(VT), 0, 0), Offset(o), Alignment(0) {
     assert((int)Offset >= 0 && "Offset is too large");
-    setValueTypes(getSDVTList(VT));
     Val.ConstVal = c;
   }
   ConstantPoolSDNode(bool isTarget, Constant *c, MVT::ValueType VT, int o,
                      unsigned Align)
-    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 0, 0),
+    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 
+             getSDVTList(VT), 0, 0),
       Offset(o), Alignment(Align) {
     assert((int)Offset >= 0 && "Offset is too large");
-    setValueTypes(getSDVTList(VT));
     Val.ConstVal = c;
   }
   ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
                      MVT::ValueType VT, int o=0)
-    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 0, 0),
-      Offset(o), Alignment(0) {
+    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 
+             getSDVTList(VT), 0, 0), Offset(o), Alignment(0) {
     assert((int)Offset >= 0 && "Offset is too large");
-    setValueTypes(getSDVTList(VT));
     Val.MachineCPVal = v;
     Offset |= 1 << (sizeof(unsigned)*8-1);
   }
   ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
                      MVT::ValueType VT, int o, unsigned Align)
-    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 0, 0),
-      Offset(o), Alignment(Align) {
+    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
+             getSDVTList(VT), 0, 0), Offset(o), Alignment(Align) {
     assert((int)Offset >= 0 && "Offset is too large");
-    setValueTypes(getSDVTList(VT));
     Val.MachineCPVal = v;
     Offset |= 1 << (sizeof(unsigned)*8-1);
   }
@@ -1215,8 +1206,7 @@ class BasicBlockSDNode : public SDNode {
 protected:
   friend class SelectionDAG;
   BasicBlockSDNode(MachineBasicBlock *mbb)
-    : SDNode(ISD::BasicBlock, 0, 0), MBB(mbb) {
-    setValueTypes(getSDVTList(MVT::Other));
+    : SDNode(ISD::BasicBlock, getSDVTList(MVT::Other), 0, 0), MBB(mbb) {
   }
 public:
 
@@ -1235,8 +1225,7 @@ class SrcValueSDNode : public SDNode {
 protected:
   friend class SelectionDAG;
   SrcValueSDNode(const Value* v, int o)
-    : SDNode(ISD::SRCVALUE, 0, 0), V(v), offset(o) {
-    setValueTypes(getSDVTList(MVT::Other));
+    : SDNode(ISD::SRCVALUE, getSDVTList(MVT::Other), 0, 0), V(v), offset(o) {
   }
 
 public:
@@ -1256,8 +1245,7 @@ class RegisterSDNode : public SDNode {
 protected:
   friend class SelectionDAG;
   RegisterSDNode(unsigned reg, MVT::ValueType VT)
-    : SDNode(ISD::Register, 0, 0), Reg(reg) {
-    setValueTypes(getSDVTList(VT));
+    : SDNode(ISD::Register, getSDVTList(VT), 0, 0), Reg(reg) {
   }
 public:
 
@@ -1275,9 +1263,8 @@ class ExternalSymbolSDNode : public SDNode {
 protected:
   friend class SelectionDAG;
   ExternalSymbolSDNode(bool isTarget, const char *Sym, MVT::ValueType VT)
-    : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol, 0, 0),
-      Symbol(Sym) {
-    setValueTypes(getSDVTList(VT));
+    : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol,
+             getSDVTList(VT), 0, 0), Symbol(Sym) {
   }
 public:
 
@@ -1296,8 +1283,7 @@ class CondCodeSDNode : public SDNode {
 protected:
   friend class SelectionDAG;
   CondCodeSDNode(ISD::CondCode Cond)
-    : SDNode(ISD::CONDCODE, 0, 0), Condition(Cond) {
-    setValueTypes(getSDVTList(MVT::Other));
+    : SDNode(ISD::CONDCODE, getSDVTList(MVT::Other), 0, 0), Condition(Cond) {
   }
 public:
 
@@ -1316,8 +1302,8 @@ class VTSDNode : public SDNode {
   virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
 protected:
   friend class SelectionDAG;
-  VTSDNode(MVT::ValueType VT) : SDNode(ISD::VALUETYPE, 0, 0), ValueType(VT) {
-    setValueTypes(getSDVTList(MVT::Other));
+  VTSDNode(MVT::ValueType VT) : SDNode(ISD::VALUETYPE, getSDVTList(MVT::Other),
+                                       0, 0), ValueType(VT) {
   }
 public:
 
@@ -1356,10 +1342,10 @@ class LoadSDNode : public SDNode {
   bool IsVolatile;
 protected:
   friend class SelectionDAG;
-  LoadSDNode(SDOperand *ChainPtrOff,
+  LoadSDNode(SDOperand *ChainPtrOff, SDVTList VTs,
              ISD::MemIndexedMode AM, ISD::LoadExtType ETy, MVT::ValueType LVT,
              const Value *SV, int O=0, unsigned Align=1, bool Vol=false)
-    : SDNode(ISD::LOAD, ChainPtrOff, 3),
+    : SDNode(ISD::LOAD, VTs, ChainPtrOff, 3),
       AddrMode(AM), ExtType(ETy), LoadedVT(LVT), SrcValue(SV), SVOffset(O),
       Alignment(Align), IsVolatile(Vol) {
     assert((getOffset().getOpcode() == ISD::UNDEF ||
@@ -1412,10 +1398,10 @@ class StoreSDNode : public SDNode {
   bool IsVolatile;
 protected:
   friend class SelectionDAG;
-  StoreSDNode(SDOperand *ChainValuePtrOff,
+  StoreSDNode(SDOperand *ChainValuePtrOff, SDVTList VTs,
               ISD::MemIndexedMode AM, bool isTrunc, MVT::ValueType SVT,
               const Value *SV, int O=0, unsigned Align=0, bool Vol=false)
-    : SDNode(ISD::STORE, ChainValuePtrOff, 4),
+    : SDNode(ISD::STORE, VTs, ChainValuePtrOff, 4),
       AddrMode(AM), IsTruncStore(isTrunc), StoredVT(SVT), SrcValue(SV),
       SVOffset(O), Alignment(Align), IsVolatile(Vol) {
     assert((getOffset().getOpcode() == ISD::UNDEF || 
@@ -1503,9 +1489,7 @@ struct ilist_traits<SDNode> {
   static void setNext(SDNode *N, SDNode *Next) { N->Next = Next; }
   
   static SDNode *createSentinel() {
-    SDNode *N = new SDNode(ISD::EntryToken, 0, 0);
-    N->setValueTypes(SDNode::getSDVTList(MVT::Other));
-    return N;
+    return new SDNode(ISD::EntryToken, SDNode::getSDVTList(MVT::Other), 0, 0);
   }
   static void destroySentinel(SDNode *N) { delete N; }
   //static SDNode *createNode(const SDNode &V) { return new SDNode(V); }
index 5ed5822434652b83f2221b04cd4f39afdf65a352..c154d7941150af175534f7bd707d0ebf30134e77 100644 (file)
@@ -939,8 +939,7 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT) {
   void *IP = 0;
   if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
     return SDOperand(E, 0);
-  SDNode *N = new SDNode(Opcode, 0, 0);
-  N->setValueTypes(SDNode::getSDVTList(VT));
+  SDNode *N = new SDNode(Opcode, SDNode::getSDVTList(VT), 0, 0);
   CSEMap.InsertNode(N, IP);
   
   AllNodes.push_back(N);
@@ -1121,12 +1120,10 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
     void *IP = 0;
     if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
       return SDOperand(E, 0);
-    N = new SDNode(Opcode, Ops, 1);
-    N->setValueTypes(VTs);
+    N = new SDNode(Opcode, VTs, Ops, 1);
     CSEMap.InsertNode(N, IP);
   } else {
-    N = new SDNode(Opcode, Ops, 1);
-    N->setValueTypes(VTs);
+    N = new SDNode(Opcode, VTs, Ops, 1);
   }
   AllNodes.push_back(N);
   return SDOperand(N, 0);
@@ -1423,12 +1420,10 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
     void *IP = 0;
     if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
       return SDOperand(E, 0);
-    N = new SDNode(Opcode, Ops, 2);
-    N->setValueTypes(VTs);
+    N = new SDNode(Opcode, VTs, Ops, 2);
     CSEMap.InsertNode(N, IP);
   } else {
-    N = new SDNode(Opcode, Ops, 2);
-    N->setValueTypes(VTs);
+    N = new SDNode(Opcode, VTs, Ops, 2);
   }
 
   AllNodes.push_back(N);
@@ -1482,12 +1477,10 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
     void *IP = 0;
     if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
       return SDOperand(E, 0);
-    N = new SDNode(Opcode, Ops, 3);
-    N->setValueTypes(VTs);
+    N = new SDNode(Opcode, VTs, Ops, 3);
     CSEMap.InsertNode(N, IP);
   } else {
-    N = new SDNode(Opcode, Ops, 3);
-    N->setValueTypes(VTs);
+    N = new SDNode(Opcode, VTs, Ops, 3);
   }
   AllNodes.push_back(N);
   return SDOperand(N, 0);
@@ -1528,10 +1521,9 @@ SDOperand SelectionDAG::getLoad(MVT::ValueType VT,
   void *IP = 0;
   if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
     return SDOperand(E, 0);
-  SDNode *N = new LoadSDNode(Ops, ISD::UNINDEXED,
+  SDNode *N = new LoadSDNode(Ops, VTs, ISD::UNINDEXED,
                              ISD::NON_EXTLOAD, VT, SV, SVOffset, Alignment,
                              isVolatile);
-  N->setValueTypes(VTs);
   CSEMap.InsertNode(N, IP);
   AllNodes.push_back(N);
   return SDOperand(N, 0);
@@ -1573,9 +1565,8 @@ SDOperand SelectionDAG::getExtLoad(ISD::LoadExtType ExtType, MVT::ValueType VT,
   void *IP = 0;
   if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
     return SDOperand(E, 0);
-  SDNode *N = new LoadSDNode(Ops, ISD::UNINDEXED, ExtType, EVT,
+  SDNode *N = new LoadSDNode(Ops, VTs, ISD::UNINDEXED, ExtType, EVT,
                              SV, SVOffset, Alignment, isVolatile);
-  N->setValueTypes(VTs);
   CSEMap.InsertNode(N, IP);
   AllNodes.push_back(N);
   return SDOperand(N, 0);
@@ -1602,11 +1593,10 @@ SelectionDAG::getIndexedLoad(SDOperand OrigLoad, SDOperand Base,
   void *IP = 0;
   if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
     return SDOperand(E, 0);
-  SDNode *N = new LoadSDNode(Ops, AM,
+  SDNode *N = new LoadSDNode(Ops, VTs, AM,
                              LD->getExtensionType(), LD->getLoadedVT(),
                              LD->getSrcValue(), LD->getSrcValueOffset(),
                              LD->getAlignment(), LD->isVolatile());
-  N->setValueTypes(VTs);
   CSEMap.InsertNode(N, IP);
   AllNodes.push_back(N);
   return SDOperand(N, 0);
@@ -1642,9 +1632,8 @@ SDOperand SelectionDAG::getStore(SDOperand Chain, SDOperand Val,
   void *IP = 0;
   if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
     return SDOperand(E, 0);
-  SDNode *N = new StoreSDNode(Ops, ISD::UNINDEXED, false,
+  SDNode *N = new StoreSDNode(Ops, VTs, ISD::UNINDEXED, false,
                               VT, SV, SVOffset, Alignment, isVolatile);
-  N->setValueTypes(VTs);
   CSEMap.InsertNode(N, IP);
   AllNodes.push_back(N);
   return SDOperand(N, 0);
@@ -1678,9 +1667,8 @@ SDOperand SelectionDAG::getTruncStore(SDOperand Chain, SDOperand Val,
   void *IP = 0;
   if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
     return SDOperand(E, 0);
-  SDNode *N = new StoreSDNode(Ops, ISD::UNINDEXED, isTrunc,
+  SDNode *N = new StoreSDNode(Ops, VTs, ISD::UNINDEXED, isTrunc,
                               SVT, SV, SVOffset, Alignment, isVolatile);
-  N->setValueTypes(VTs);
   CSEMap.InsertNode(N, IP);
   AllNodes.push_back(N);
   return SDOperand(N, 0);
@@ -1706,11 +1694,10 @@ SelectionDAG::getIndexedStore(SDOperand OrigStore, SDOperand Base,
   void *IP = 0;
   if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
     return SDOperand(E, 0);
-  SDNode *N = new StoreSDNode(Ops, AM,
+  SDNode *N = new StoreSDNode(Ops, VTs, AM,
                               ST->isTruncatingStore(), ST->getStoredVT(),
                               ST->getSrcValue(), ST->getSrcValueOffset(),
                               ST->getAlignment(), ST->isVolatile());
-  N->setValueTypes(VTs);
   CSEMap.InsertNode(N, IP);
   AllNodes.push_back(N);
   return SDOperand(N, 0);
@@ -1762,12 +1749,10 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
     void *IP = 0;
     if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
       return SDOperand(E, 0);
-    N = new SDNode(Opcode, Ops, NumOps);
-    N->setValueTypes(VTs);
+    N = new SDNode(Opcode, VTs, Ops, NumOps);
     CSEMap.InsertNode(N, IP);
   } else {
-    N = new SDNode(Opcode, Ops, NumOps);
-    N->setValueTypes(VTs);
+    N = new SDNode(Opcode, VTs, Ops, NumOps);
   }
   AllNodes.push_back(N);
   return SDOperand(N, 0);
@@ -1824,12 +1809,10 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, SDVTList VTList,
     void *IP = 0;
     if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
       return SDOperand(E, 0);
-    N = new SDNode(Opcode, Ops, NumOps);
-    N->setValueTypes(VTList);
+    N = new SDNode(Opcode, VTList, Ops, NumOps);
     CSEMap.InsertNode(N, IP);
   } else {
-    N = new SDNode(Opcode, Ops, NumOps);
-    N->setValueTypes(VTList);
+    N = new SDNode(Opcode, VTList, Ops, NumOps);
   }
   AllNodes.push_back(N);
   return SDOperand(N, 0);