[llvm-commits] CVS: llvm/include/llvm/CodeGen/SelectionDAG.h SelectionDAGNodes.h

Chris Lattner lattner at cs.uiuc.edu
Mon Aug 14 16:32:07 PDT 2006



Changes in directory llvm/include/llvm/CodeGen:

SelectionDAG.h updated: 1.119 -> 1.120
SelectionDAGNodes.h updated: 1.140 -> 1.141
---
Log message:

Add a new getNode() method that takes a pointer to an already-intern'd list
of value-type nodes.  This avoids having to do mallocs for std::vectors of
valuetypes when a node returns more than one type.


---
Diffs of the changes:  (+18 -25)

 SelectionDAG.h      |   39 ++++++++++++++++-----------------------
 SelectionDAGNodes.h |    4 ++--
 2 files changed, 18 insertions(+), 25 deletions(-)


Index: llvm/include/llvm/CodeGen/SelectionDAG.h
diff -u llvm/include/llvm/CodeGen/SelectionDAG.h:1.119 llvm/include/llvm/CodeGen/SelectionDAG.h:1.120
--- llvm/include/llvm/CodeGen/SelectionDAG.h:1.119	Mon Aug 14 17:24:39 2006
+++ llvm/include/llvm/CodeGen/SelectionDAG.h	Mon Aug 14 18:31:51 2006
@@ -155,29 +155,23 @@
   // null) and that there should be a flag result.
   SDOperand getCopyToReg(SDOperand Chain, unsigned Reg, SDOperand N,
                          SDOperand Flag) {
-    std::vector<MVT::ValueType> VTs;
-    VTs.push_back(MVT::Other);
-    VTs.push_back(MVT::Flag);
+    const MVT::ValueType *VTs = getNodeValueTypes(MVT::Other, MVT::Flag);
     SDOperand Ops[] = { Chain, getRegister(Reg, N.getValueType()), N, Flag };
-    return getNode(ISD::CopyToReg, VTs, Ops, Flag.Val ? 4 : 3);
+    return getNode(ISD::CopyToReg, VTs, 2, Ops, Flag.Val ? 4 : 3);
   }
 
   // Similar to last getCopyToReg() except parameter Reg is a SDOperand
   SDOperand getCopyToReg(SDOperand Chain, SDOperand Reg, SDOperand N,
                          SDOperand Flag) {
-    std::vector<MVT::ValueType> VTs;
-    VTs.push_back(MVT::Other);
-    VTs.push_back(MVT::Flag);
+    const MVT::ValueType *VTs = getNodeValueTypes(MVT::Other, MVT::Flag);
     SDOperand Ops[] = { Chain, Reg, N, Flag };
-    return getNode(ISD::CopyToReg, VTs, Ops, Flag.Val ? 4 : 3);
+    return getNode(ISD::CopyToReg, VTs, 2, Ops, Flag.Val ? 4 : 3);
   }
   
   SDOperand getCopyFromReg(SDOperand Chain, unsigned Reg, MVT::ValueType VT) {
-    std::vector<MVT::ValueType> ResultTys;
-    ResultTys.push_back(VT);
-    ResultTys.push_back(MVT::Other);
+    const MVT::ValueType *VTs = getNodeValueTypes(VT, MVT::Other);
     SDOperand Ops[] = { Chain, getRegister(Reg, VT) };
-    return getNode(ISD::CopyFromReg, ResultTys, Ops, 2);
+    return getNode(ISD::CopyFromReg, VTs, 2, Ops, 2);
   }
   
   // This version of the getCopyFromReg method takes an extra operand, which
@@ -185,12 +179,9 @@
   // null) and that there should be a flag result.
   SDOperand getCopyFromReg(SDOperand Chain, unsigned Reg, MVT::ValueType VT,
                            SDOperand Flag) {
-    std::vector<MVT::ValueType> ResultTys;
-    ResultTys.push_back(VT);
-    ResultTys.push_back(MVT::Other);
-    ResultTys.push_back(MVT::Flag);
+    const MVT::ValueType *VTs = getNodeValueTypes(VT, MVT::Other, MVT::Flag);
     SDOperand Ops[] = { Chain, getRegister(Reg, VT), Flag };
-    return getNode(ISD::CopyFromReg, ResultTys, Ops, Flag.Val ? 3 : 2);
+    return getNode(ISD::CopyFromReg, VTs, 3, Ops, Flag.Val ? 3 : 2);
   }
 
   SDOperand getCondCode(ISD::CondCode Cond);
@@ -202,11 +193,9 @@
   /// getCALLSEQ_START - Return a new CALLSEQ_START node, which always must have
   /// a flag result (to ensure it's not CSE'd).
   SDOperand getCALLSEQ_START(SDOperand Chain, SDOperand Op) {
-    std::vector<MVT::ValueType> ResultTys;
-    ResultTys.push_back(MVT::Other);
-    ResultTys.push_back(MVT::Flag);
+    const MVT::ValueType *VTs = getNodeValueTypes(MVT::Other, MVT::Flag);
     SDOperand Ops[] = { Chain,  Op };
-    return getNode(ISD::CALLSEQ_START, ResultTys, Ops, 2);
+    return getNode(ISD::CALLSEQ_START, VTs, 2, Ops, 2);
   }
 
   /// getNode - Gets or creates the specified node.
@@ -226,6 +215,8 @@
                     const SDOperand *Ops, unsigned NumOps);
   SDOperand getNode(unsigned Opcode, std::vector<MVT::ValueType> &ResultTys,
                     const SDOperand *Ops, unsigned NumOps);
+  SDOperand getNode(unsigned Opcode, const MVT::ValueType *VTs, unsigned NumVTs,
+                    const SDOperand *Ops, unsigned NumOps);
   
   /// getSetCC - Helper function to make it easier to build SetCC's if you just
   /// have an ISD::CondCode instead of an SDOperand.
@@ -240,8 +231,8 @@
   ///
   SDOperand getSelectCC(SDOperand LHS, SDOperand RHS,
                         SDOperand True, SDOperand False, ISD::CondCode Cond) {
-    MVT::ValueType VT = True.getValueType();
-    return getNode(ISD::SELECT_CC, VT, LHS, RHS, True, False,getCondCode(Cond));
+    return getNode(ISD::SELECT_CC, True.getValueType(), LHS, RHS, True, False,
+                   getCondCode(Cond));
   }
   
   /// getVAArg - VAArg produces a result and token chain, and takes a pointer
@@ -443,6 +434,8 @@
   void DeleteNodeNotInCSEMaps(SDNode *N);
   MVT::ValueType *getNodeValueTypes(MVT::ValueType VT1);
   MVT::ValueType *getNodeValueTypes(MVT::ValueType VT1, MVT::ValueType VT2);
+  MVT::ValueType *getNodeValueTypes(MVT::ValueType VT1, MVT::ValueType VT2,
+                                    MVT::ValueType VT3);
   MVT::ValueType *getNodeValueTypes(std::vector<MVT::ValueType> &RetVals);
   
   


Index: llvm/include/llvm/CodeGen/SelectionDAGNodes.h
diff -u llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.140 llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.141
--- llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.140	Mon Aug 14 17:19:25 2006
+++ llvm/include/llvm/CodeGen/SelectionDAGNodes.h	Mon Aug 14 18:31:51 2006
@@ -697,7 +697,7 @@
   
   /// ValueList - The types of the values this node defines.  SDNode's may
   /// define multiple values simultaneously.
-  MVT::ValueType *ValueList;
+  const MVT::ValueType *ValueList;
 
   /// NumOperands/NumValues - The number of entries in the Operand/Value list.
   unsigned short NumOperands, NumValues;
@@ -899,7 +899,7 @@
     NumOperands = 0;
   }
   
-  void setValueTypes(MVT::ValueType *List, unsigned NumVal) {
+  void setValueTypes(const MVT::ValueType *List, unsigned NumVal) {
     assert(NumValues == 0 && "Should not have values yet!");
     ValueList = List;
     NumValues = NumVal;






More information about the llvm-commits mailing list