From 6f7b63c7d77610fe77bf1ed514437da34a9f8114 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 14 May 2005 06:34:48 +0000 Subject: [PATCH] legalize target-specific operations llvm-svn: 22010 --- lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 3aa45289b8f..680b2ce9bca 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -197,6 +197,29 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { switch (Node->getOpcode()) { default: + if (Node->getOpcode() >= ISD::BUILTIN_OP_END) { + // If this is a target node, legalize it by legalizing the operands then + // passing it through. + std::vector Ops; + bool Changed = false; + for (unsigned i = 0, e = Node->getNumOperands(); i != e; ++i) { + Ops.push_back(LegalizeOp(Node->getOperand(i))); + Changed = Changed || Node->getOperand(i) != Ops.back(); + } + if (Changed) + if (Node->getNumValues() == 1) + Result = DAG.getNode(Node->getOpcode(), Node->getValueType(0), Ops); + else { + std::vector VTs(Node->value_begin(), + Node->value_end()); + Result = DAG.getNode(Node->getOpcode(), VTs, Ops); + } + + for (unsigned i = 0, e = Node->getNumValues(); i != e; ++i) + AddLegalizedOperand(Op.getValue(i), Result.getValue(i)); + return Result.getValue(Op.ResNo); + } + // Otherwise this is an unhandled builtin node. splat. std::cerr << "NODE: "; Node->dump(); std::cerr << "\n"; assert(0 && "Do not know how to legalize this operator!"); abort();