diff options
author | Chris Lattner <sabre@nondot.org> | 2006-08-14 23:31:51 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-08-14 23:31:51 +0000 |
commit | 2fa6d3b1fcadbde90eaee0e8e89aebd81630b662 (patch) | |
tree | b1cc5444e7815fca810ed9bf7d94b477a7266da0 /include | |
parent | 64d128de9c1fa813d79239ea2405bd8f8ef5295c (diff) | |
download | external_llvm-2fa6d3b1fcadbde90eaee0e8e89aebd81630b662.zip external_llvm-2fa6d3b1fcadbde90eaee0e8e89aebd81630b662.tar.gz external_llvm-2fa6d3b1fcadbde90eaee0e8e89aebd81630b662.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29685 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/CodeGen/SelectionDAG.h | 39 | ||||
-rw-r--r-- | include/llvm/CodeGen/SelectionDAGNodes.h | 4 |
2 files changed, 18 insertions, 25 deletions
diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h index 3a3911b..8208af6 100644 --- a/include/llvm/CodeGen/SelectionDAG.h +++ b/include/llvm/CodeGen/SelectionDAG.h @@ -155,29 +155,23 @@ public: // 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 @@ public: // 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 @@ public: /// 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 @@ public: 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 @@ public: /// 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 @@ private: 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); diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h index dc58bd9..86c8d2e 100644 --- a/include/llvm/CodeGen/SelectionDAGNodes.h +++ b/include/llvm/CodeGen/SelectionDAGNodes.h @@ -697,7 +697,7 @@ class SDNode { /// 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 @@ protected: 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; |