diff --git a/include/llvm/CodeGen/SelectionDAGISel.h b/include/llvm/CodeGen/SelectionDAGISel.h index 2b713f10df5..5d33224cbe2 100644 --- a/include/llvm/CodeGen/SelectionDAGISel.h +++ b/include/llvm/CodeGen/SelectionDAGISel.h @@ -110,6 +110,14 @@ protected: bool CheckOrMask(SDValue LHS, ConstantSDNode *RHS, int64_t DesiredMaskS) const; + // Calls to these functions are generated by tblgen. + SDNode *Select_INLINEASM(SDValue N); + SDNode *Select_UNDEF(const SDValue &N); + SDNode *Select_DBG_LABEL(const SDValue &N); + SDNode *Select_EH_LABEL(const SDValue &N); + void CannotYetSelect(SDValue N); + void CannotYetSelectIntrinsic(SDValue N); + private: void SelectAllBasicBlocks(Function &Fn, MachineFunction &MF, MachineModuleInfo *MMI, diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 6d4562dfed9..b63d5bb2e6a 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -44,6 +44,7 @@ #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetFrameInfo.h" +#include "llvm/Target/TargetIntrinsicInfo.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetLowering.h" #include "llvm/Target/TargetMachine.h" @@ -1293,5 +1294,56 @@ bool SelectionDAGISel::IsLegalAndProfitableToFold(SDNode *N, SDNode *U, return !isNonImmUse(Root, N, U); } +SDNode *SelectionDAGISel::Select_INLINEASM(SDValue N) { + std::vector Ops(N.getNode()->op_begin(), N.getNode()->op_end()); + SelectInlineAsmMemoryOperands(Ops); + + std::vector VTs; + VTs.push_back(MVT::Other); + VTs.push_back(MVT::Flag); + SDValue New = CurDAG->getNode(ISD::INLINEASM, N.getDebugLoc(), + VTs, &Ops[0], Ops.size()); + return New.getNode(); +} + +SDNode *SelectionDAGISel::Select_UNDEF(const SDValue &N) { + return CurDAG->SelectNodeTo(N.getNode(), TargetInstrInfo::IMPLICIT_DEF, + N.getValueType()); +} + +SDNode *SelectionDAGISel::Select_DBG_LABEL(const SDValue &N) { + SDValue Chain = N.getOperand(0); + unsigned C = cast(N)->getLabelID(); + SDValue Tmp = CurDAG->getTargetConstant(C, MVT::i32); + return CurDAG->SelectNodeTo(N.getNode(), TargetInstrInfo::DBG_LABEL, + MVT::Other, Tmp, Chain); +} + +SDNode *SelectionDAGISel::Select_EH_LABEL(const SDValue &N) { + SDValue Chain = N.getOperand(0); + unsigned C = cast(N)->getLabelID(); + SDValue Tmp = CurDAG->getTargetConstant(C, MVT::i32); + return CurDAG->SelectNodeTo(N.getNode(), TargetInstrInfo::EH_LABEL, + MVT::Other, Tmp, Chain); +} + +void SelectionDAGISel::CannotYetSelect(SDValue N) { + std::string msg; + raw_string_ostream Msg(msg); + Msg << "Cannot yet select: "; + N.getNode()->print(Msg, CurDAG); + llvm_report_error(Msg.str()); +} + +void SelectionDAGISel::CannotYetSelectIntrinsic(SDValue N) { + errs() << "Cannot yet select: "; + unsigned iid = + cast(N.getOperand(N.getOperand(0).getValueType() == MVT::Other))->getZExtValue(); + if (iid < Intrinsic::num_intrinsics) + llvm_report_error("Cannot yet select: intrinsic %" + Intrinsic::getName((Intrinsic::ID)iid)); + else if (const TargetIntrinsicInfo *tii = TM.getIntrinsicInfo()) + llvm_report_error(Twine("Cannot yet select: target intrinsic %") + + tii->getName(iid)); +} char SelectionDAGISel::ID = 0; diff --git a/utils/TableGen/DAGISelEmitter.cpp b/utils/TableGen/DAGISelEmitter.cpp index a979cee5c0f..c12ae87769e 100644 --- a/utils/TableGen/DAGISelEmitter.cpp +++ b/utils/TableGen/DAGISelEmitter.cpp @@ -1917,40 +1917,6 @@ void DAGISelEmitter::EmitInstructionSelector(raw_ostream &OS) { } } - // Emit boilerplate. - OS << "SDNode *Select_INLINEASM(SDValue N) {\n" - << " std::vector Ops(N.getNode()->op_begin(), N.getNode()->op_end());\n" - << " SelectInlineAsmMemoryOperands(Ops);\n\n" - - << " std::vector VTs;\n" - << " VTs.push_back(MVT::Other);\n" - << " VTs.push_back(MVT::Flag);\n" - << " SDValue New = CurDAG->getNode(ISD::INLINEASM, N.getDebugLoc(), " - "VTs, &Ops[0], Ops.size());\n" - << " return New.getNode();\n" - << "}\n\n"; - - OS << "SDNode *Select_UNDEF(const SDValue &N) {\n" - << " return CurDAG->SelectNodeTo(N.getNode(), TargetInstrInfo::IMPLICIT_DEF,\n" - << " N.getValueType());\n" - << "}\n\n"; - - OS << "SDNode *Select_DBG_LABEL(const SDValue &N) {\n" - << " SDValue Chain = N.getOperand(0);\n" - << " unsigned C = cast(N)->getLabelID();\n" - << " SDValue Tmp = CurDAG->getTargetConstant(C, MVT::i32);\n" - << " return CurDAG->SelectNodeTo(N.getNode(), TargetInstrInfo::DBG_LABEL,\n" - << " MVT::Other, Tmp, Chain);\n" - << "}\n\n"; - - OS << "SDNode *Select_EH_LABEL(const SDValue &N) {\n" - << " SDValue Chain = N.getOperand(0);\n" - << " unsigned C = cast(N)->getLabelID();\n" - << " SDValue Tmp = CurDAG->getTargetConstant(C, MVT::i32);\n" - << " return CurDAG->SelectNodeTo(N.getNode(), TargetInstrInfo::EH_LABEL,\n" - << " MVT::Other, Tmp, Chain);\n" - << "}\n\n"; - OS << "// The main instruction selector code.\n" << "SDNode *SelectCode(SDValue N) {\n" << " MVT::SimpleValueType NVT = N.getNode()->getValueType(0).getSimpleVT().SimpleTy;\n" @@ -2054,30 +2020,6 @@ void DAGISelEmitter::EmitInstructionSelector(raw_ostream &OS) { << " }\n" << " return NULL;\n" << "}\n\n"; - - OS << "void CannotYetSelect(SDValue N) DISABLE_INLINE {\n" - << " std::string msg;\n" - << " raw_string_ostream Msg(msg);\n" - << " Msg << \"Cannot yet select: \";\n" - << " N.getNode()->print(Msg, CurDAG);\n" - << " llvm_report_error(Msg.str());\n" - << "}\n\n"; - - OS << "void CannotYetSelectIntrinsic(SDValue N) DISABLE_INLINE {\n" - << " errs() << \"Cannot yet select: \";\n" - << " unsigned iid = cast(N.getOperand(" - << "N.getOperand(0).getValueType() == MVT::Other))->getZExtValue();\n" - << " if (iid < Intrinsic::num_intrinsics)\n" - << " llvm_report_error(\"Cannot yet select: intrinsic %\" + " - << "Intrinsic::getName((Intrinsic::ID)iid));\n"; - if (CGP.hasTargetIntrinsics()) { - OS << " else if (const TargetIntrinsicInfo *tii = TM.getIntrinsicInfo())\n" - << " llvm_report_error(Twine(\"Cannot yet select: target intrinsic " - << "%\") + tii->getName(iid));\n"; - } - OS << " else\n" - << " llvm_report_error(\"Cannot yet select: invalid intrinsic\");\n" - << "}\n\n"; } void DAGISelEmitter::run(raw_ostream &OS) {