#include "llvm/CodeGen/SelectionDAGNodes.h"
#include <map>
+#include <list>
#include <string> // FIXME remove eventually, turning map into const char* map.
namespace llvm {
SDOperand Callee, bool isTailCall = false) {
SDNode *NN = new SDNode(isTailCall ? ISD::TAILCALL : ISD::CALL, Chain,
Callee);
- NN->setValueTypes(RetVals);
+ setNodeValueTypes(NN, RetVals);
AllNodes.push_back(NN);
return NN;
}
ArgsInRegs.insert(ArgsInRegs.begin(), Callee);
ArgsInRegs.insert(ArgsInRegs.begin(), Chain);
SDNode *NN = new SDNode(isTailCall ? ISD::TAILCALL : ISD::CALL, ArgsInRegs);
- NN->setValueTypes(RetVals);
+ setNodeValueTypes(NN, RetVals);
AllNodes.push_back(NN);
return NN;
}
SDNode *AddNonLeafNodeToCSEMaps(SDNode *N);
void DestroyDeadNode(SDNode *N);
void DeleteNodeNotInCSEMaps(SDNode *N);
+ void setNodeValueTypes(SDNode *N, std::vector<MVT::ValueType> &RetVals);
+ void setNodeValueTypes(SDNode *N, MVT::ValueType VT1, MVT::ValueType VT2);
+
/// SimplifySetCC - Try to simplify a setcc built with the specified operands
/// and cc. If unable to simplify it, return a null SDOperand.
SDOperand SimplifySetCC(MVT::ValueType VT, SDOperand N1,
SDOperand N2, ISD::CondCode Cond);
-
+
+ // List of non-single value types.
+ std::list<std::vector<MVT::ValueType> > VTList;
+
// Maps to auto-CSE operations.
std::map<std::pair<unsigned, MVT::ValueType>, SDNode *> NullaryOps;
std::map<std::pair<unsigned, std::pair<SDOperand, MVT::ValueType> >,
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)
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
/// the SelectionDAG class.
void MorphNodeTo(unsigned Opc) {
NodeType = Opc;
- delete [] ValueList;
ValueList = 0;
NumValues = 0;
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) {