From 7cf11b4ab248d6ab7fb0d9df0b72baf158201abe Mon Sep 17 00:00:00 2001 From: Andrew Lenharth Date: Mon, 23 Jan 2006 21:51:14 +0000 Subject: [PATCH] another couple selects git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25551 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/SelectionDAG.h | 20 ++++++++++++++++++++ include/llvm/CodeGen/SelectionDAGNodes.h | 18 ++++++++++++++++++ lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 22 ++++++++++++++++++++++ 3 files changed, 60 insertions(+) diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h index 1991cd3efed..f9d7172672e 100644 --- a/include/llvm/CodeGen/SelectionDAG.h +++ b/include/llvm/CodeGen/SelectionDAG.h @@ -318,6 +318,10 @@ public: SDOperand Op1, SDOperand Op2, SDOperand Op3, SDOperand Op4, SDOperand Op5, SDOperand Op6, SDOperand Op7); + SDOperand SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT, + SDOperand Op1, SDOperand Op2, SDOperand Op3, + SDOperand Op4, SDOperand Op5, SDOperand Op6, + SDOperand Op7, SDOperand Op8); SDOperand SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT1, MVT::ValueType VT2, SDOperand Op1, SDOperand Op2); SDOperand SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT1, @@ -383,6 +387,22 @@ public: Ops.push_back(Op7); return getNode(ISD::BUILTIN_OP_END+Opcode, VT, Ops); } + SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT, + SDOperand Op1, SDOperand Op2, SDOperand Op3, + SDOperand Op4, SDOperand Op5, SDOperand Op6, + SDOperand Op7, SDOperand Op8) { + std::vector Ops; + Ops.reserve(8); + Ops.push_back(Op1); + Ops.push_back(Op2); + Ops.push_back(Op3); + Ops.push_back(Op4); + Ops.push_back(Op5); + Ops.push_back(Op6); + Ops.push_back(Op7); + Ops.push_back(Op8); + return getNode(ISD::BUILTIN_OP_END+Opcode, VT, Ops); + } SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT, std::vector &Ops) { return getNode(ISD::BUILTIN_OP_END+Opcode, VT, Ops); diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h index 7b424290314..5cb2d1c9dcc 100644 --- a/include/llvm/CodeGen/SelectionDAGNodes.h +++ b/include/llvm/CodeGen/SelectionDAGNodes.h @@ -856,6 +856,24 @@ protected: Op4.Val->Uses.push_back(this); Op5.Val->Uses.push_back(this); Op6.Val->Uses.push_back(this); } + void setOperands(SDOperand Op0, SDOperand Op1, SDOperand Op2, SDOperand Op3, + SDOperand Op4, SDOperand Op5, SDOperand Op6, SDOperand Op7) { + assert(NumOperands == 0 && "Should not have operands yet!"); + OperandList = new SDOperand[8]; + OperandList[0] = Op0; + OperandList[1] = Op1; + OperandList[2] = Op2; + OperandList[3] = Op3; + OperandList[4] = Op4; + OperandList[5] = Op5; + OperandList[6] = Op6; + OperandList[7] = Op7; + NumOperands = 8; + Op0.Val->Uses.push_back(this); Op1.Val->Uses.push_back(this); + Op2.Val->Uses.push_back(this); Op3.Val->Uses.push_back(this); + Op4.Val->Uses.push_back(this); Op5.Val->Uses.push_back(this); + Op6.Val->Uses.push_back(this); Op7.Val->Uses.push_back(this); + } void addUser(SDNode *User) { Uses.push_back(User); diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 3165fc1d651..c1ba5ebc4ab 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -1671,6 +1671,28 @@ SDOperand SelectionDAG::SelectNodeTo(SDNode *N, unsigned TargetOpc, ON = N; // Memoize the new node. return SDOperand(N, 0); } +SDOperand SelectionDAG::SelectNodeTo(SDNode *N, unsigned TargetOpc, + MVT::ValueType VT, SDOperand Op1, + SDOperand Op2, SDOperand Op3,SDOperand Op4, + SDOperand Op5, SDOperand Op6, + SDOperand Op7, SDOperand Op8) { + // If an identical node already exists, use it. + std::vector OpList; + OpList.push_back(Op1); OpList.push_back(Op2); OpList.push_back(Op3); + OpList.push_back(Op4); OpList.push_back(Op5); OpList.push_back(Op6); + OpList.push_back(Op7); OpList.push_back(Op8); + SDNode *&ON = OneResultNodes[std::make_pair(ISD::BUILTIN_OP_END+TargetOpc, + std::make_pair(VT, OpList))]; + if (ON) return SDOperand(ON, 0); + + RemoveNodeFromCSEMaps(N); + N->MorphNodeTo(ISD::BUILTIN_OP_END+TargetOpc); + N->setValueTypes(VT); + N->setOperands(Op1, Op2, Op3, Op4, Op5, Op6, Op7, Op8); + + ON = N; // Memoize the new node. + return SDOperand(N, 0); +} SDOperand SelectionDAG::SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT1, MVT::ValueType VT2,