mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-04 21:31:03 +00:00
Move some code from being emitted as boilerplate duplicated in every
*ISelDAGToDAG.cpp to being regular code in SelectionDAGISel.cpp. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85530 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
67a8a7b3bd
commit
e1f188fe27
@ -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,
|
||||
|
@ -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<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;
|
||||
|
@ -1917,40 +1917,6 @@ void DAGISelEmitter::EmitInstructionSelector(raw_ostream &OS) {
|
||||
}
|
||||
}
|
||||
|
||||
// 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 @@ 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<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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user