#include <algorithm>
using namespace llvm;
+/// makeVTList - Return an instance of the SDVTList struct initialized with the
+/// specified members.
+static SDVTList makeVTList(const MVT::ValueType *VTs, unsigned NumVTs) {
+ SDVTList Res = {VTs, NumVTs};
+ return Res;
+}
+
static bool isCommutativeBinOp(unsigned Opcode) {
switch (Opcode) {
case ISD::ADD:
SelectionDAGCSEMap::NodeID ID;
ID.SetOpcode(N->getOpcode());
- ID.SetValueTypes(N->value_begin());
+ ID.SetValueTypes(N->getVTList());
ID.SetOperands(Op);
return CSEMap.FindNodeOrInsertPos(ID, InsertPos);
}
SelectionDAGCSEMap::NodeID ID;
ID.SetOpcode(N->getOpcode());
- ID.SetValueTypes(N->value_begin());
+ ID.SetValueTypes(N->getVTList());
ID.SetOperands(Op1, Op2);
return CSEMap.FindNodeOrInsertPos(ID, InsertPos);
}
SelectionDAGCSEMap::NodeID ID;
ID.SetOpcode(N->getOpcode());
- ID.SetValueTypes(N->value_begin());
+ ID.SetValueTypes(N->getVTList());
ID.SetOperands(Ops, NumOps);
return CSEMap.FindNodeOrInsertPos(ID, InsertPos);
}
Val &= MVT::getIntVTBitMask(VT);
unsigned Opc = isT ? ISD::TargetConstant : ISD::Constant;
- SelectionDAGCSEMap::NodeID ID(Opc, getNodeValueTypes(VT));
+ SelectionDAGCSEMap::NodeID ID(Opc, getVTList(VT));
ID.AddInteger(Val);
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
// value, so that we don't have problems with 0.0 comparing equal to -0.0, and
// we don't have issues with SNANs.
unsigned Opc = isTarget ? ISD::TargetConstantFP : ISD::ConstantFP;
- SelectionDAGCSEMap::NodeID ID(Opc, getNodeValueTypes(VT));
+ SelectionDAGCSEMap::NodeID ID(Opc, getVTList(VT));
ID.AddInteger(DoubleToBits(Val));
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
MVT::ValueType VT, int Offset,
bool isTargetGA) {
unsigned Opc = isTargetGA ? ISD::TargetGlobalAddress : ISD::GlobalAddress;
- SelectionDAGCSEMap::NodeID ID(Opc, getNodeValueTypes(VT));
+ SelectionDAGCSEMap::NodeID ID(Opc, getVTList(VT));
ID.AddPointer(GV);
ID.AddInteger(Offset);
void *IP = 0;
SDOperand SelectionDAG::getFrameIndex(int FI, MVT::ValueType VT,
bool isTarget) {
unsigned Opc = isTarget ? ISD::TargetFrameIndex : ISD::FrameIndex;
- SelectionDAGCSEMap::NodeID ID(Opc, getNodeValueTypes(VT));
+ SelectionDAGCSEMap::NodeID ID(Opc, getVTList(VT));
ID.AddInteger(FI);
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
SDOperand SelectionDAG::getJumpTable(int JTI, MVT::ValueType VT, bool isTarget){
unsigned Opc = isTarget ? ISD::TargetJumpTable : ISD::JumpTable;
- SelectionDAGCSEMap::NodeID ID(Opc, getNodeValueTypes(VT));
+ SelectionDAGCSEMap::NodeID ID(Opc, getVTList(VT));
ID.AddInteger(JTI);
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
unsigned Alignment, int Offset,
bool isTarget) {
unsigned Opc = isTarget ? ISD::TargetConstantPool : ISD::ConstantPool;
- SelectionDAGCSEMap::NodeID ID(Opc, getNodeValueTypes(VT));
+ SelectionDAGCSEMap::NodeID ID(Opc, getVTList(VT));
ID.AddInteger(Alignment);
ID.AddInteger(Offset);
ID.AddPointer(C);
SDOperand SelectionDAG::getBasicBlock(MachineBasicBlock *MBB) {
- SelectionDAGCSEMap::NodeID ID(ISD::BasicBlock, getNodeValueTypes(MVT::Other));
+ SelectionDAGCSEMap::NodeID ID(ISD::BasicBlock, getVTList(MVT::Other));
ID.AddPointer(MBB);
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
}
SDOperand SelectionDAG::getRegister(unsigned RegNo, MVT::ValueType VT) {
- SelectionDAGCSEMap::NodeID ID(ISD::Register, getNodeValueTypes(VT));
+ SelectionDAGCSEMap::NodeID ID(ISD::Register, getVTList(VT));
ID.AddInteger(RegNo);
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
assert((!V || isa<PointerType>(V->getType())) &&
"SrcValue is not a pointer?");
- SelectionDAGCSEMap::NodeID ID(ISD::SRCVALUE, getNodeValueTypes(MVT::Other));
+ SelectionDAGCSEMap::NodeID ID(ISD::SRCVALUE, getVTList(MVT::Other));
ID.AddPointer(V);
ID.AddInteger(Offset);
void *IP = 0;
/// getNode - Gets or creates the specified node.
///
SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT) {
- const MVT::ValueType *VTs = getNodeValueTypes(VT);
- SelectionDAGCSEMap::NodeID ID(Opcode, VTs);
+ SelectionDAGCSEMap::NodeID ID(Opcode, getVTList(VT));
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDOperand(E, 0);
}
SDNode *N;
- const MVT::ValueType *VTs = getNodeValueTypes(VT);
+ SDVTList VTs = getVTList(VT);
if (VT != MVT::Flag) { // Don't CSE flag producing nodes
SelectionDAGCSEMap::NodeID ID(Opcode, VTs, Operand);
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDOperand(E, 0);
N = new SDNode(Opcode, Operand);
- N->setValueTypes(VTs, 1);
+ N->setValueTypes(VTs);
CSEMap.InsertNode(N, IP);
} else {
N = new SDNode(Opcode, Operand);
- N->setValueTypes(VTs, 1);
+ N->setValueTypes(VTs);
}
AllNodes.push_back(N);
return SDOperand(N, 0);
// Memoize this node if possible.
SDNode *N;
- const MVT::ValueType *VTs = getNodeValueTypes(VT);
+ SDVTList VTs = getVTList(VT);
if (VT != MVT::Flag) {
SelectionDAGCSEMap::NodeID ID(Opcode, VTs, N1, N2);
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDOperand(E, 0);
N = new SDNode(Opcode, N1, N2);
- N->setValueTypes(VTs, 1);
+ N->setValueTypes(VTs);
CSEMap.InsertNode(N, IP);
} else {
N = new SDNode(Opcode, N1, N2);
- N->setValueTypes(VTs, 1);
+ N->setValueTypes(VTs);
}
AllNodes.push_back(N);
// Memoize node if it doesn't produce a flag.
SDNode *N;
- const MVT::ValueType *VTs = getNodeValueTypes(VT);
-
+ SDVTList VTs = getVTList(VT);
if (VT != MVT::Flag) {
SelectionDAGCSEMap::NodeID ID(Opcode, VTs, N1, N2, N3);
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDOperand(E, 0);
N = new SDNode(Opcode, N1, N2, N3);
- N->setValueTypes(VTs, 1);
+ N->setValueTypes(VTs);
CSEMap.InsertNode(N, IP);
} else {
N = new SDNode(Opcode, N1, N2, N3);
- N->setValueTypes(VTs, 1);
+ N->setValueTypes(VTs);
}
AllNodes.push_back(N);
return SDOperand(N, 0);
SDOperand SelectionDAG::getLoad(MVT::ValueType VT,
SDOperand Chain, SDOperand Ptr,
SDOperand SV) {
- const MVT::ValueType *VTs = getNodeValueTypes(VT, MVT::Other);
+ SDVTList VTs = getVTList(VT, MVT::Other);
SelectionDAGCSEMap::NodeID ID(ISD::LOAD, VTs, Chain, Ptr, SV);
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDOperand(E, 0);
SDNode *N = new SDNode(ISD::LOAD, Chain, Ptr, SV);
- N->setValueTypes(VTs, 2);
+ N->setValueTypes(VTs);
CSEMap.InsertNode(N, IP);
AllNodes.push_back(N);
return SDOperand(N, 0);
// Memoize nodes.
SDNode *N;
- const MVT::ValueType *VTs = getNodeValueTypes(VT);
+ SDVTList VTs = getVTList(VT);
if (VT != MVT::Flag) {
SelectionDAGCSEMap::NodeID ID(Opcode, VTs, Ops, NumOps);
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDOperand(E, 0);
N = new SDNode(Opcode, Ops, NumOps);
- N->setValueTypes(VTs, 1);
+ N->setValueTypes(VTs);
CSEMap.InsertNode(N, IP);
} else {
N = new SDNode(Opcode, Ops, NumOps);
- N->setValueTypes(VTs, 1);
+ N->setValueTypes(VTs);
}
AllNodes.push_back(N);
return SDOperand(N, 0);
// Memoize the node unless it returns a flag.
SDNode *N;
+ SDVTList VTList = makeVTList(VTs, NumVTs);
if (VTs[NumVTs-1] != MVT::Flag) {
SelectionDAGCSEMap::NodeID ID;
ID.SetOpcode(Opcode);
- ID.SetValueTypes(VTs);
+ ID.SetValueTypes(VTList);
ID.SetOperands(&Ops[0], NumOps);
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDOperand(E, 0);
N = new SDNode(Opcode, Ops, NumOps);
- N->setValueTypes(VTs, NumVTs);
+ N->setValueTypes(VTList);
CSEMap.InsertNode(N, IP);
} else {
N = new SDNode(Opcode, Ops, NumOps);
- N->setValueTypes(VTs, NumVTs);
+ N->setValueTypes(VTList);
}
AllNodes.push_back(N);
return SDOperand(N, 0);
}
-/// makeVTList - Return an instance of the SDVTList struct initialized with the
-/// specified members.
-static SDVTList makeVTList(const MVT::ValueType *VTs, unsigned NumVTs) {
- SDVTList Res = {VTs, NumVTs};
- return Res;
-}
-
SDVTList SelectionDAG::getVTList(MVT::ValueType VT) {
return makeVTList(SDNode::getValueTypeList(VT), 1);
}
/// the current one.
SDOperand SelectionDAG::SelectNodeTo(SDNode *N, unsigned TargetOpc,
MVT::ValueType VT) {
- const MVT::ValueType *VTs = getNodeValueTypes(VT);
+ SDVTList VTs = getVTList(VT);
SelectionDAGCSEMap::NodeID ID(ISD::BUILTIN_OP_END+TargetOpc, VTs);
void *IP = 0;
if (SDNode *ON = CSEMap.FindNodeOrInsertPos(ID, IP))
RemoveNodeFromCSEMaps(N);
N->MorphNodeTo(ISD::BUILTIN_OP_END+TargetOpc);
- N->setValueTypes(getNodeValueTypes(VT), 1);
+ N->setValueTypes(VTs);
CSEMap.InsertNode(N, IP);
return SDOperand(N, 0);
SDOperand SelectionDAG::SelectNodeTo(SDNode *N, unsigned TargetOpc,
MVT::ValueType VT, SDOperand Op1) {
// If an identical node already exists, use it.
- const MVT::ValueType *VTs = getNodeValueTypes(VT);
+ SDVTList VTs = getVTList(VT);
SelectionDAGCSEMap::NodeID ID(ISD::BUILTIN_OP_END+TargetOpc, VTs, Op1);
void *IP = 0;
if (SDNode *ON = CSEMap.FindNodeOrInsertPos(ID, IP))
RemoveNodeFromCSEMaps(N);
N->MorphNodeTo(ISD::BUILTIN_OP_END+TargetOpc);
- N->setValueTypes(getNodeValueTypes(VT), 1);
+ N->setValueTypes(VTs);
N->setOperands(Op1);
CSEMap.InsertNode(N, IP);
return SDOperand(N, 0);
MVT::ValueType VT, SDOperand Op1,
SDOperand Op2) {
// If an identical node already exists, use it.
- const MVT::ValueType *VTs = getNodeValueTypes(VT);
+ SDVTList VTs = getVTList(VT);
SelectionDAGCSEMap::NodeID ID(ISD::BUILTIN_OP_END+TargetOpc, VTs, Op1, Op2);
void *IP = 0;
if (SDNode *ON = CSEMap.FindNodeOrInsertPos(ID, IP))
RemoveNodeFromCSEMaps(N);
N->MorphNodeTo(ISD::BUILTIN_OP_END+TargetOpc);
- N->setValueTypes(VTs, 1);
+ N->setValueTypes(VTs);
N->setOperands(Op1, Op2);
CSEMap.InsertNode(N, IP); // Memoize the new node.
MVT::ValueType VT, SDOperand Op1,
SDOperand Op2, SDOperand Op3) {
// If an identical node already exists, use it.
- const MVT::ValueType *VTs = getNodeValueTypes(VT);
- SelectionDAGCSEMap::NodeID ID(ISD::BUILTIN_OP_END+TargetOpc, VTs, Op1, Op2, Op3);
+ SDVTList VTs = getVTList(VT);
+ SelectionDAGCSEMap::NodeID ID(ISD::BUILTIN_OP_END+TargetOpc, VTs,
+ Op1, Op2, Op3);
void *IP = 0;
if (SDNode *ON = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDOperand(ON, 0);
RemoveNodeFromCSEMaps(N);
N->MorphNodeTo(ISD::BUILTIN_OP_END+TargetOpc);
- N->setValueTypes(VTs, 1);
+ N->setValueTypes(VTs);
N->setOperands(Op1, Op2, Op3);
CSEMap.InsertNode(N, IP); // Memoize the new node.
SDOperand Op2, SDOperand Op3,
SDOperand Op4) {
// If an identical node already exists, use it.
- const MVT::ValueType *VTs = getNodeValueTypes(VT);
+ SDVTList VTs = getVTList(VT);
SelectionDAGCSEMap::NodeID ID(ISD::BUILTIN_OP_END+TargetOpc, VTs);
ID.AddOperand(Op1);
ID.AddOperand(Op2);
RemoveNodeFromCSEMaps(N);
N->MorphNodeTo(ISD::BUILTIN_OP_END+TargetOpc);
- N->setValueTypes(VTs, 1);
+ N->setValueTypes(VTs);
N->setOperands(Op1, Op2, Op3, Op4);
CSEMap.InsertNode(N, IP); // Memoize the new node.
MVT::ValueType VT, SDOperand Op1,
SDOperand Op2, SDOperand Op3,
SDOperand Op4, SDOperand Op5) {
- const MVT::ValueType *VTs = getNodeValueTypes(VT);
+ SDVTList VTs = getVTList(VT);
SelectionDAGCSEMap::NodeID ID(ISD::BUILTIN_OP_END+TargetOpc, VTs);
ID.AddOperand(Op1);
ID.AddOperand(Op2);
RemoveNodeFromCSEMaps(N);
N->MorphNodeTo(ISD::BUILTIN_OP_END+TargetOpc);
- N->setValueTypes(VTs, 1);
+ N->setValueTypes(VTs);
N->setOperands(Op1, Op2, Op3, Op4, Op5);
CSEMap.InsertNode(N, IP); // Memoize the new node.
MVT::ValueType VT, SDOperand Op1,
SDOperand Op2, SDOperand Op3,SDOperand Op4,
SDOperand Op5, SDOperand Op6) {
- const MVT::ValueType *VTs = getNodeValueTypes(VT);
+ SDVTList VTs = getVTList(VT);
SelectionDAGCSEMap::NodeID ID(ISD::BUILTIN_OP_END+TargetOpc, VTs);
ID.AddOperand(Op1);
ID.AddOperand(Op2);
RemoveNodeFromCSEMaps(N);
N->MorphNodeTo(ISD::BUILTIN_OP_END+TargetOpc);
- N->setValueTypes(VTs, 1);
+ N->setValueTypes(VTs);
N->setOperands(Op1, Op2, Op3, Op4, Op5, Op6);
CSEMap.InsertNode(N, IP); // Memoize the new node.
SDOperand Op2, SDOperand Op3,SDOperand Op4,
SDOperand Op5, SDOperand Op6,
SDOperand Op7) {
- const MVT::ValueType *VTs = getNodeValueTypes(VT);
+ SDVTList VTs = getVTList(VT);
// If an identical node already exists, use it.
SelectionDAGCSEMap::NodeID ID(ISD::BUILTIN_OP_END+TargetOpc, VTs);
ID.AddOperand(Op1);
RemoveNodeFromCSEMaps(N);
N->MorphNodeTo(ISD::BUILTIN_OP_END+TargetOpc);
- N->setValueTypes(VTs, 1);
+ N->setValueTypes(VTs);
N->setOperands(Op1, Op2, Op3, Op4, Op5, Op6, Op7);
CSEMap.InsertNode(N, IP); // Memoize the new node.
SDOperand Op5, SDOperand Op6,
SDOperand Op7, SDOperand Op8) {
// If an identical node already exists, use it.
- const MVT::ValueType *VTs = getNodeValueTypes(VT);
+ SDVTList VTs = getVTList(VT);
SelectionDAGCSEMap::NodeID ID(ISD::BUILTIN_OP_END+TargetOpc, VTs);
ID.AddOperand(Op1);
ID.AddOperand(Op2);
RemoveNodeFromCSEMaps(N);
N->MorphNodeTo(ISD::BUILTIN_OP_END+TargetOpc);
- N->setValueTypes(VTs, 1);
+ N->setValueTypes(VTs);
N->setOperands(Op1, Op2, Op3, Op4, Op5, Op6, Op7, Op8);
CSEMap.InsertNode(N, IP); // Memoize the new node.
SDOperand SelectionDAG::SelectNodeTo(SDNode *N, unsigned TargetOpc,
MVT::ValueType VT1, MVT::ValueType VT2,
SDOperand Op1, SDOperand Op2) {
- const MVT::ValueType *VTs = getNodeValueTypes(VT1, VT2);
+ SDVTList VTs = getVTList(VT1, VT2);
SelectionDAGCSEMap::NodeID ID(ISD::BUILTIN_OP_END+TargetOpc, VTs, Op1, Op2);
void *IP = 0;
if (SDNode *ON = CSEMap.FindNodeOrInsertPos(ID, IP))
RemoveNodeFromCSEMaps(N);
N->MorphNodeTo(ISD::BUILTIN_OP_END+TargetOpc);
- N->setValueTypes(VTs, 2);
+ N->setValueTypes(VTs);
N->setOperands(Op1, Op2);
CSEMap.InsertNode(N, IP); // Memoize the new node.
SDOperand Op1, SDOperand Op2,
SDOperand Op3) {
// If an identical node already exists, use it.
- const MVT::ValueType *VTs = getNodeValueTypes(VT1, VT2);
+ SDVTList VTs = getVTList(VT1, VT2);
SelectionDAGCSEMap::NodeID ID(ISD::BUILTIN_OP_END+TargetOpc, VTs,
Op1, Op2, Op3);
void *IP = 0;
RemoveNodeFromCSEMaps(N);
N->MorphNodeTo(ISD::BUILTIN_OP_END+TargetOpc);
- N->setValueTypes(VTs, 2);
+ N->setValueTypes(VTs);
N->setOperands(Op1, Op2, Op3);
CSEMap.InsertNode(N, IP); // Memoize the new node.
SDOperand Op1, SDOperand Op2,
SDOperand Op3, SDOperand Op4) {
// If an identical node already exists, use it.
- const MVT::ValueType *VTs = getNodeValueTypes(VT1, VT2);
+ SDVTList VTs = getVTList(VT1, VT2);
SelectionDAGCSEMap::NodeID ID(ISD::BUILTIN_OP_END+TargetOpc, VTs);
ID.AddOperand(Op1);
ID.AddOperand(Op2);
RemoveNodeFromCSEMaps(N);
N->MorphNodeTo(ISD::BUILTIN_OP_END+TargetOpc);
- N->setValueTypes(VTs, 2);
+ N->setValueTypes(VTs);
N->setOperands(Op1, Op2, Op3, Op4);
CSEMap.InsertNode(N, IP); // Memoize the new node.
SDOperand Op3, SDOperand Op4,
SDOperand Op5) {
// If an identical node already exists, use it.
- const MVT::ValueType *VTs = getNodeValueTypes(VT1, VT2);
+ SDVTList VTs = getVTList(VT1, VT2);
SelectionDAGCSEMap::NodeID ID(ISD::BUILTIN_OP_END+TargetOpc, VTs);
ID.AddOperand(Op1);
ID.AddOperand(Op2);
RemoveNodeFromCSEMaps(N);
N->MorphNodeTo(ISD::BUILTIN_OP_END+TargetOpc);
- N->setValueTypes(VTs, 2);
+ N->setValueTypes(VTs);
N->setOperands(Op1, Op2, Op3, Op4, Op5);
CSEMap.InsertNode(N, IP); // Memoize the new node.