aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/CodeGen/SelectionDAGNodes.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-11-08 23:30:11 +0000
committerChris Lattner <sabre@nondot.org>2005-11-08 23:30:11 +0000
commit109654fae9c5b8b96bd3a829824cdbceb27ced06 (patch)
tree8b184965d84d64d8e22e91b116f6f8e0822f15c4 /include/llvm/CodeGen/SelectionDAGNodes.h
parent65113b2f86ac0b714f3f580beb886d42c988c5b6 (diff)
Change the ValueList array for each node to be shared instead of individually
allocated. Further, in the common case where a node has a single value, just reference an element from a small array. This is a small compile-time wi. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24250 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/CodeGen/SelectionDAGNodes.h')
-rw-r--r--include/llvm/CodeGen/SelectionDAGNodes.h28
1 files changed, 9 insertions, 19 deletions
diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h
index de117a898e..2cbca1728e 100644
--- a/include/llvm/CodeGen/SelectionDAGNodes.h
+++ b/include/llvm/CodeGen/SelectionDAGNodes.h
@@ -577,11 +577,14 @@ public:
protected:
friend class SelectionDAG;
+
+ /// getValueTypeList - Return a pointer to the specified value type.
+ ///
+ static MVT::ValueType *getValueTypeList(MVT::ValueType VT);
SDNode(unsigned NT, MVT::ValueType VT) : NodeType(NT), NodeDepth(1) {
OperandList = 0; NumOperands = 0;
- ValueList = new MVT::ValueType[1];
- ValueList[0] = VT;
+ ValueList = getValueTypeList(VT);
NumValues = 1;
}
SDNode(unsigned NT, SDOperand Op)
@@ -668,7 +671,6 @@ protected:
virtual ~SDNode() {
assert(NumOperands == 0 && "Operand list not cleared before deletion");
- delete [] ValueList;
}
/// MorphNodeTo - This clears the return value and operands list, and sets the
@@ -676,7 +678,6 @@ protected:
/// the SelectionDAG class.
void MorphNodeTo(unsigned Opc) {
NodeType = Opc;
- delete [] ValueList;
ValueList = 0;
NumValues = 0;
@@ -691,24 +692,13 @@ protected:
void setValueTypes(MVT::ValueType VT) {
assert(NumValues == 0 && "Should not have values yet!");
- ValueList = new MVT::ValueType[1];
- ValueList[0] = VT;
+ ValueList = getValueTypeList(VT);
NumValues = 1;
}
- void setValueTypes(MVT::ValueType VT1, MVT::ValueType VT2) {
- assert(NumValues == 0 && "Should not have values yet!");
- ValueList = new MVT::ValueType[2];
- ValueList[0] = VT1;
- ValueList[1] = VT2;
- NumValues = 2;
- }
- void setValueTypes(const std::vector<MVT::ValueType> &VTs) {
+ void setValueTypes(MVT::ValueType *List, unsigned NumVal) {
assert(NumValues == 0 && "Should not have values yet!");
- if (VTs.size() == 0) return; // don't alloc memory.
- ValueList = new MVT::ValueType[VTs.size()];
- for (unsigned i = 0, e = VTs.size(); i != e; ++i)
- ValueList[i] = VTs[i];
- NumValues = VTs.size();
+ ValueList = List;
+ NumValues = NumVal;
}
void setOperands(SDOperand Op0) {