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

Chris Lattner lattner at cs.uiuc.edu
Mon Aug 7 19:24:05 PDT 2006



Changes in directory llvm/include/llvm/CodeGen:

SelectionDAG.h updated: 1.110 -> 1.111
---
Log message:

Start eliminating temporary vectors used to create DAG nodes.  Instead, pass
in the start of an array and a count of operands where applicable.  In many
cases, the number of operands is known, so this static array can be allocated
on the stack, avoiding the heap.  In many other cases, a SmallVector can be
used, which has the same benefit in the common cases.

I updated a lot of code calling getNode that takes a vector, but ran out of
time.  The rest of the code should be updated, and these methods should be
removed.

We should also do the same thing to eliminate the methods that take a
vector of MVT::ValueTypes.

It would be extra nice to convert the dagiselemitter to avoid creating vectors
for operands when calling getTargetNode.



---
Diffs of the changes:  (+15 -19)

 SelectionDAG.h |   34 +++++++++++++++-------------------
 1 files changed, 15 insertions(+), 19 deletions(-)


Index: llvm/include/llvm/CodeGen/SelectionDAG.h
diff -u llvm/include/llvm/CodeGen/SelectionDAG.h:1.110 llvm/include/llvm/CodeGen/SelectionDAG.h:1.111
--- llvm/include/llvm/CodeGen/SelectionDAG.h:1.110	Mon Aug  7 20:09:31 2006
+++ llvm/include/llvm/CodeGen/SelectionDAG.h	Mon Aug  7 21:23:41 2006
@@ -145,12 +145,8 @@
     std::vector<MVT::ValueType> VTs;
     VTs.push_back(MVT::Other);
     VTs.push_back(MVT::Flag);
-    std::vector<SDOperand> Ops;
-    Ops.push_back(Chain);
-    Ops.push_back(getRegister(Reg, N.getValueType()));
-    Ops.push_back(N);
-    if (Flag.Val) Ops.push_back(Flag);
-    return getNode(ISD::CopyToReg, VTs, Ops);
+    SDOperand Ops[] = { Chain, getRegister(Reg, N.getValueType()), N, Flag };
+    return getNode(ISD::CopyToReg, VTs, Ops, Flag.Val ? 4 : 3);
   }
 
   // Similar to last getCopyToReg() except parameter Reg is a SDOperand
@@ -159,12 +155,8 @@
     std::vector<MVT::ValueType> VTs;
     VTs.push_back(MVT::Other);
     VTs.push_back(MVT::Flag);
-    std::vector<SDOperand> Ops;
-    Ops.push_back(Chain);
-    Ops.push_back(Reg);
-    Ops.push_back(N);
-    if (Flag.Val) Ops.push_back(Flag);
-    return getNode(ISD::CopyToReg, VTs, Ops);
+    SDOperand Ops[] = { Chain, Reg, N, Flag };
+    return getNode(ISD::CopyToReg, VTs, Ops, Flag.Val ? 4 : 3);
   }
   
   SDOperand getCopyFromReg(SDOperand Chain, unsigned Reg, MVT::ValueType VT) {
@@ -218,14 +210,17 @@
                     SDOperand N1, SDOperand N2, SDOperand N3, SDOperand N4,
                     SDOperand N5);
   SDOperand getNode(unsigned Opcode, MVT::ValueType VT,
-                    std::vector<SDOperand> &Children);
-  SDOperand getNode(unsigned Opcode, std::vector<MVT::ValueType> &ResultTys,
-                    std::vector<SDOperand> &Ops);
-
-  SDOperand getNode(unsigned Opcode, MVT::ValueType VT,
                     const SDOperand *Ops, unsigned NumOps);
+  SDOperand getNode(unsigned Opcode, MVT::ValueType VT,
+                    const std::vector<SDOperand> &Ops) {
+    return getNode(Opcode, VT, &Ops[0], Ops.size());
+  }
   SDOperand getNode(unsigned Opcode, std::vector<MVT::ValueType> &ResultTys,
                     const SDOperand *Ops, unsigned NumOps);
+  SDOperand getNode(unsigned Opcode, std::vector<MVT::ValueType> &ResultTys,
+                    const std::vector<SDOperand> &Ops) {
+    return getNode(Opcode, ResultTys, &Ops[0], Ops.size());
+  }
   
   
   /// getSetCC - Helper function to make it easier to build SetCC's if you just
@@ -351,7 +346,7 @@
                         SDOperand Op4, SDOperand Op5, SDOperand Op6,
                         SDOperand Op7, SDOperand Op8);
   SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT,
-                        std::vector<SDOperand> &Ops);
+                        const SDOperand *Ops, unsigned NumOps);
   SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
                         MVT::ValueType VT2, SDOperand Op1);
   SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
@@ -391,7 +386,8 @@
                         SDOperand Op3, SDOperand Op4, SDOperand Op5,
                         SDOperand Op6, SDOperand Op7);
   SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1, 
-                        MVT::ValueType VT2, std::vector<SDOperand> &Ops);
+                        MVT::ValueType VT2,
+                        const SDOperand *Ops, unsigned NumOps);
   
   /// ReplaceAllUsesWith - Modify anything using 'From' to use 'To' instead.
   /// This can cause recursive merging of nodes in the DAG.  Use the first






More information about the llvm-commits mailing list