[llvm-commits] [llvm] r85530 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAGISel.h lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp utils/TableGen/DAGISelEmitter.cpp
Dan Gohman
gohman at apple.com
Thu Oct 29 15:30:23 PDT 2009
Author: djg
Date: Thu Oct 29 17:30:23 2009
New Revision: 85530
URL: http://llvm.org/viewvc/llvm-project?rev=85530&view=rev
Log:
Move some code from being emitted as boilerplate duplicated in every
*ISelDAGToDAG.cpp to being regular code in SelectionDAGISel.cpp.
Modified:
llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
llvm/trunk/utils/TableGen/DAGISelEmitter.cpp
Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h?rev=85530&r1=85529&r2=85530&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h Thu Oct 29 17:30:23 2009
@@ -110,6 +110,14 @@
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,
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=85530&r1=85529&r2=85530&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Thu Oct 29 17:30:23 2009
@@ -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 @@
return !isNonImmUse(Root, N, U);
}
+SDNode *SelectionDAGISel::Select_INLINEASM(SDValue N) {
+ std::vector<SDValue> Ops(N.getNode()->op_begin(), N.getNode()->op_end());
+ SelectInlineAsmMemoryOperands(Ops);
+
+ std::vector<EVT> 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<LabelSDNode>(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<LabelSDNode>(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<ConstantSDNode>(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;
Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelEmitter.cpp?rev=85530&r1=85529&r2=85530&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/DAGISelEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Thu Oct 29 17:30:23 2009
@@ -1917,40 +1917,6 @@
}
}
- // Emit boilerplate.
- OS << "SDNode *Select_INLINEASM(SDValue N) {\n"
- << " std::vector<SDValue> Ops(N.getNode()->op_begin(), N.getNode()->op_end());\n"
- << " SelectInlineAsmMemoryOperands(Ops);\n\n"
-
- << " std::vector<EVT> 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<LabelSDNode>(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<LabelSDNode>(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 @@
<< " }\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<ConstantSDNode>(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) {
More information about the llvm-commits
mailing list