76 #include "llvm/IR/IntrinsicsWebAssembly.h" 110 using namespace llvm;
112 #define DEBUG_TYPE "isel" 114 STATISTIC(NumFastIselFailures,
"Number of instructions fast isel failed on");
115 STATISTIC(NumFastIselSuccess,
"Number of instructions fast isel selected");
116 STATISTIC(NumFastIselBlocks,
"Number of blocks selected entirely by fast isel");
117 STATISTIC(NumDAGBlocks,
"Number of blocks selected using DAG");
118 STATISTIC(NumDAGIselRetries,
"Number of times dag isel has to try another path");
119 STATISTIC(NumEntryBlocks,
"Number of entry blocks encountered");
121 "Number of entry blocks where fast isel failed to lower arguments");
125 cl::desc(
"Enable abort calls when \"fast\" instruction selection " 126 "fails to lower an instruction: 0 disable the abort, 1 will " 127 "abort but for args, calls and terminators, 2 will also " 128 "abort for argument lowering, and 3 will never fallback " 129 "to SelectionDAG."));
133 cl::desc(
"Emit a diagnostic when \"fast\" instruction selection " 134 "falls back to SelectionDAG."));
138 cl::desc(
"use Machine Branch Probability Info"),
144 cl::desc(
"Only display the basic block whose name " 145 "matches this for all view-*-dags options"));
148 cl::desc(
"Pop up a window to show dags before the first " 149 "dag combine pass"));
152 cl::desc(
"Pop up a window to show dags before legalize types"));
155 cl::desc(
"Pop up a window to show dags before the post " 156 "legalize types dag combine pass"));
159 cl::desc(
"Pop up a window to show dags before legalize"));
162 cl::desc(
"Pop up a window to show dags before the second " 163 "dag combine pass"));
166 cl::desc(
"Pop up a window to show isel dags as they are selected"));
169 cl::desc(
"Pop up a window to show sched dags as they are processed"));
172 cl::desc(
"Pop up a window to show SUnit dags after they are processed"));
197 cl::desc(
"Instruction schedulers available (before register" 218 if (NewOptLevel == SavedOptLevel)
222 LLVM_DEBUG(
dbgs() <<
"\nChanging optimization level for Function " 224 LLVM_DEBUG(
dbgs() <<
"\tBefore: -O" << SavedOptLevel <<
" ; After: -O" 225 << NewOptLevel <<
"\n");
230 dbgs() <<
"\tFastISel is " 239 LLVM_DEBUG(
dbgs() <<
"\nRestoring optimization level for Function " 242 << SavedOptLevel <<
"\n");
259 return SchedulerCtor(IS, OptLevel);
273 "Unknown sched type!");
292 dbgs() <<
"If a target marks an instruction with " 293 "'usesCustomInserter', it must implement " 294 "TargetLowering::EmitInstrWithCustomInserter!";
302 "If a target marks an instruction with 'hasPostISelHook', " 303 "it must implement TargetLowering::AdjustInstrPostInstrSelection!");
316 AA(), GFI(), OptLevel(OL), DAGSize(0) {
367 if (!CE || !CE->
canTrap())
continue;
396 if (
I.getType()->isFPOrFPVectorTy()) {
400 for (
const auto &
Op :
I.operands()) {
401 if (
Op->getType()->isFPOrFPVectorTy()) {
416 "-fast-isel-abort > 0 requires -fast-isel");
436 LibInfo = &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(Fn);
437 GFI = Fn.
hasGC() ? &getAnalysis<GCModuleInfo>().getFunctionInfo(Fn) :
nullptr;
438 ORE = std::make_unique<OptimizationRemarkEmitter>(&Fn);
439 auto *DTWP = getAnalysisIfAvailable<DominatorTreeWrapperPass>();
441 auto *LIWP = getAnalysisIfAvailable<LoopInfoWrapperPass>();
442 LoopInfo *LI = LIWP ? &LIWP->getLoopInfo() :
nullptr;
443 auto *PSI = &getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
444 auto *
BFI = (PSI && PSI->hasProfileSummary()) ?
445 &getAnalysis<LazyBlockFrequencyInfoPass>().getBFI() :
453 getAnalysisIfAvailable<LegacyDivergenceAnalysis>(), PSI,
BFI);
463 FuncInfo->BPI = &getAnalysis<BranchProbabilityInfoWrapperPass>().getBPI();
468 AA = &getAnalysis<AAResultsWrapperPass>().getAAResults();
489 if (isa<UnreachableInst>(Term) || isa<ReturnInst>(Term))
503 SelectAllBasicBlocks(Fn);
519 unsigned From =
I->first;
520 unsigned To =
I->second;
553 if (!MBB.succ_empty())
557 if (Term != MBB.end() && Term->isReturn()) {
566 if (!
FuncInfo->ArgDbgValues.empty())
572 for (
unsigned i = 0,
e =
FuncInfo->ArgDbgValues.size(); i !=
e; ++i) {
592 if (LDI != LiveInMap.
end()) {
593 assert(!hasFI &&
"There's no handling of frame pointer updating here yet " 603 "DBG_VALUE with nonzero offset");
604 assert(cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(DL) &&
605 "Expected inlined-at fields to agree");
607 BuildMI(*EntryMBB, ++InsertPos, DL,
TII->
get(TargetOpcode::DBG_VALUE),
608 IsIndirect, LDI->second, Variable, Expr);
620 CopyUseMI =
UseMI;
continue;
623 CopyUseMI =
nullptr;
break;
630 CopyUseMI->getOperand(0).getReg(), Variable, Expr);
639 for (
const auto &MBB : *
MF) {
640 if (MFI.
hasCalls() && MF->hasInlineAsm())
643 for (
const auto &
MI : MBB) {
646 MI.isStackAligningInlineAsm()) {
649 if (
MI.isInlineAsm()) {
650 MF->setHasInlineAsm(
true);
666 unsigned From =
I->first;
667 unsigned To =
I->second;
708 R << (
" (in function: " + MF.
getName() +
")").str();
731 HadTailCall =
SDB->HasTailCall;
732 SDB->resolveOrClearDbgInfo();
739 void SelectionDAGISel::ComputeLiveOutVRegInfo() {
772 FuncInfo->AddLiveOutRegInfo(DestReg, NumSignBits, Known);
773 }
while (!Worklist.
empty());
776 void SelectionDAGISel::CodeGenAndEmitDAG() {
778 StringRef GroupDescription =
"Instruction Selection and Scheduling";
779 std::string BlockName;
780 bool MatchFilterBB =
false; (void)MatchFilterBB;
783 getAnalysis<TargetTransformInfoWrapperPass>().getTTI(*
FuncInfo->Fn);
792 FuncInfo->MBB->getBasicBlock()->getName());
808 if (ViewDAGCombine1 && MatchFilterBB)
959 ComputeLiveOutVRegInfo();
969 DoInstructionSelection();
1005 if (FirstMBB != LastMBB)
1006 SDB->UpdateSplitBlock(FirstMBB, LastMBB);
1065 while (!Nodes.
empty()) {
1067 for (
auto *U : N->
uses()) {
1093 void SelectionDAGISel::DoInstructionSelection() {
1096 <<
FuncInfo->MBB->getName() <<
"'\n");
1114 ISelUpdater ISU(*
CurDAG, ISelPosition);
1121 SDNode *Node = &*--ISelPosition;
1132 while (!Nodes.
empty()) {
1149 "Node has already selected predecessor node");
1186 LLVM_DEBUG(
dbgs() <<
"\nISEL: Starting selection on root node: ";
1202 if (
const IntrinsicInst *EHPtrCall = dyn_cast<IntrinsicInst>(U)) {
1204 if (IID == Intrinsic::eh_exceptionpointer ||
1205 IID == Intrinsic::eh_exceptioncode)
1220 bool IsSingleCatchAllClause =
1223 if (!IsSingleCatchAllClause) {
1225 bool IntrFound =
false;
1227 if (
const auto *Call = dyn_cast<IntrinsicInst>(U)) {
1229 if (IID == Intrinsic::wasm_landingpad_index) {
1230 Value *IndexArg = Call->getArgOperand(1);
1231 int Index = cast<ConstantInt>(IndexArg)->getZExtValue();
1238 assert(IntrFound &&
"wasm.landingpad.index intrinsic not found!");
1245 bool SelectionDAGISel::PrepareEHLandingPad() {
1257 if (
const auto *CPI = dyn_cast<CatchPadInst>(LLVMBB->
getFirstNonPHI())) {
1262 assert(EHPhysReg &&
"target lacks exception pointer register");
1264 unsigned VReg =
FuncInfo->getCatchPadExceptionPointerVReg(CPI, PtrRC);
1266 TII->
get(TargetOpcode::COPY), VReg)
1282 if (
const auto *CPI = dyn_cast<CatchPadInst>(LLVMBB->
getFirstNonPHI()))
1305 !isa<DbgInfoIntrinsic>(
I) &&
1330 Address = Address->stripAndAccumulateInBoundsConstantOffsets(DL, Offset);
1336 if (
const auto *AI = dyn_cast<AllocaInst>(Address)) {
1340 }
else if (
const auto *
Arg = dyn_cast<Argument>(Address))
1355 void SelectionDAGISel::SelectAllBasicBlocks(
const Function &Fn) {
1385 ++NumFastIselFailLowerArguments;
1390 R <<
"FastISel didn't lower all arguments: " 1398 CodeGenAndEmitDAG();
1412 if (FastIS && Inserted)
1421 bool AllPredsVisited =
true;
1424 if (!
FuncInfo->VisitedBBs.count(*PI)) {
1425 AllPredsVisited =
false;
1430 if (AllPredsVisited) {
1431 for (
const PHINode &PN : LLVMBB->phis())
1432 FuncInfo->ComputePHILiveOutRegInfo(&PN);
1434 for (
const PHINode &PN : LLVMBB->phis())
1435 FuncInfo->InvalidatePHILiveOutRegInfo(&PN);
1438 FuncInfo->VisitedBBs.insert(LLVMBB);
1442 LLVMBB->getFirstNonPHI()->getIterator();
1454 FuncInfo->ExceptionPointerVirtReg = 0;
1455 FuncInfo->ExceptionSelectorVirtReg = 0;
1456 if (LLVMBB->isEHPad())
1457 if (!PrepareEHLandingPad())
1465 unsigned NumFastIselRemaining = std::distance(Begin, End);
1471 for (; BI != Begin; --BI) {
1477 --NumFastIselRemaining;
1487 --NumFastIselRemaining;
1488 ++NumFastIselSuccess;
1493 while (BeforeInst != &*Begin) {
1498 if (BeforeInst != Inst && isa<LoadInst>(BeforeInst) &&
1503 --NumFastIselRemaining;
1504 ++NumFastIselSuccess;
1521 R <<
"FastISel missed call";
1524 std::string InstStrStorage;
1528 R <<
": " << InstStr.
str();
1535 unsigned &R =
FuncInfo->ValueMap[Inst];
1540 bool HadTailCall =
false;
1542 SelectBasicBlock(Inst->
getIterator(), BI, HadTailCall);
1554 unsigned RemainingNow = std::distance(Begin, BI);
1555 NumFastIselFailures += NumFastIselRemaining - RemainingNow;
1556 NumFastIselRemaining = RemainingNow;
1566 R <<
"FastISel missed terminator";
1570 R <<
"FastISel missed";
1574 std::string InstStrStorage;
1577 R <<
": " << InstStr.
str();
1582 NumFastIselFailures += NumFastIselRemaining;
1590 bool FunctionBasedInstrumentation =
1592 SDB->SPDescriptor.initialize(LLVMBB,
FuncInfo->MBBMap[LLVMBB],
1593 FunctionBasedInstrumentation);
1599 ++NumFastIselBlocks;
1606 SelectBasicBlock(Begin, BI, HadTailCall);
1618 FuncInfo->PHINodesToUpdate.clear();
1627 SDB->clearDanglingDebugInfo();
1628 SDB->SPDescriptor.resetPerFunctionState();
1669 &&
"Should have a copy implying we should have 2 arguments.");
1697 if (SplitPoint == BB->
begin())
1705 SplitPoint = Previous;
1706 if (Previous == Start)
1715 SelectionDAGISel::FinishBasicBlock() {
1717 <<
FuncInfo->PHINodesToUpdate.size() <<
"\n";
1718 for (
unsigned i = 0,
e =
FuncInfo->PHINodesToUpdate.size(); i !=
e;
1720 <<
"Node " << i <<
" : (" <<
FuncInfo->PHINodesToUpdate[i].first
1721 <<
", " <<
FuncInfo->PHINodesToUpdate[i].second <<
")\n");
1725 for (
unsigned i = 0,
e =
FuncInfo->PHINodesToUpdate.size(); i !=
e; ++i) {
1728 "This is not a machine PHI node that we are updating!");
1735 if (
SDB->SPDescriptor.shouldEmitFunctionBasedCheckStackProtector()) {
1744 SDB->visitSPDescriptorParent(
SDB->SPDescriptor, ParentMBB);
1747 CodeGenAndEmitDAG();
1750 SDB->SPDescriptor.resetPerBBState();
1751 }
else if (
SDB->SPDescriptor.shouldEmitStackProtector()) {
1765 SuccessMBB->
splice(SuccessMBB->
end(), ParentMBB,
1772 SDB->visitSPDescriptorParent(
SDB->SPDescriptor, ParentMBB);
1775 CodeGenAndEmitDAG();
1779 if (FailureMBB->
empty()) {
1782 SDB->visitSPDescriptorFailure(
SDB->SPDescriptor);
1785 CodeGenAndEmitDAG();
1789 SDB->SPDescriptor.resetPerBBState();
1793 for (
auto &BTB :
SDB->SL->BitTestCases) {
1803 CodeGenAndEmitDAG();
1807 for (
unsigned j = 0, ej = BTB.Cases.size(); j != ej; ++j) {
1808 UnhandledProb -= BTB.Cases[j].ExtraProb;
1810 FuncInfo->MBB = BTB.Cases[j].ThisBB;
1823 if (BTB.ContiguousRange && j + 2 == ej) {
1826 NextMBB = BTB.Cases[j + 1].TargetBB;
1827 }
else if (j + 1 == ej) {
1829 NextMBB = BTB.Default;
1832 NextMBB = BTB.Cases[j + 1].ThisBB;
1835 SDB->visitBitTestCase(BTB, NextMBB, UnhandledProb, BTB.Reg, BTB.Cases[j],
1840 CodeGenAndEmitDAG();
1842 if (BTB.ContiguousRange && j + 2 == ej) {
1844 BTB.Cases.pop_back();
1850 for (
unsigned pi = 0, pe =
FuncInfo->PHINodesToUpdate.size();
1855 "This is not a machine PHI node that we are updating!");
1858 if (PHIBB == BTB.Default) {
1860 if (!BTB.ContiguousRange) {
1862 .
addMBB(BTB.Cases.back().ThisBB);
1866 for (
unsigned j = 0, ej = BTB.Cases.size();
1874 SDB->SL->BitTestCases.clear();
1879 for (
unsigned i = 0,
e =
SDB->SL->JTCases.size(); i !=
e; ++i) {
1881 if (!
SDB->SL->JTCases[i].first.Emitted) {
1883 FuncInfo->MBB =
SDB->SL->JTCases[i].first.HeaderBB;
1886 SDB->visitJumpTableHeader(
SDB->SL->JTCases[i].second,
1890 CodeGenAndEmitDAG();
1897 SDB->visitJumpTable(
SDB->SL->JTCases[i].second);
1900 CodeGenAndEmitDAG();
1903 for (
unsigned pi = 0, pe =
FuncInfo->PHINodesToUpdate.size();
1908 "This is not a machine PHI node that we are updating!");
1910 if (PHIBB ==
SDB->SL->JTCases[i].second.Default)
1912 .
addMBB(
SDB->SL->JTCases[i].first.HeaderBB);
1914 if (
FuncInfo->MBB->isSuccessor(PHIBB))
1918 SDB->SL->JTCases.clear();
1922 for (
unsigned i = 0,
e =
SDB->SL->SwitchCases.size(); i !=
e; ++i) {
1930 if (
SDB->SL->SwitchCases[i].TrueBB !=
SDB->SL->SwitchCases[i].FalseBB)
1937 CodeGenAndEmitDAG();
1947 for (
unsigned i = 0,
e = Succs.
size(); i !=
e; ++i) {
1955 MBBI != MBBE && MBBI->isPHI(); ++MBBI) {
1958 for (
unsigned pn = 0; ; ++pn) {
1960 "Didn't find PHI entry!");
1961 if (
FuncInfo->PHINodesToUpdate[pn].first == PHI) {
1970 SDB->SL->SwitchCases.clear();
1991 int64_t DesiredMaskS)
const {
1996 if (ActualMask == DesiredMask)
2005 APInt NeededMask = DesiredMask & ~ActualMask;
2020 int64_t DesiredMaskS)
const {
2025 if (ActualMask == DesiredMask)
2034 APInt NeededMask = DesiredMask & ~ActualMask;
2051 std::vector<SDValue> InOps;
2060 if (InOps[e-1].getValueType() ==
MVT::Glue)
2064 unsigned Flags = cast<ConstantSDNode>(InOps[i])->getZExtValue();
2067 Ops.insert(Ops.end(), InOps.begin()+i,
2072 "Memory operand with multiple values?");
2074 unsigned TiedToOperand;
2078 Flags = cast<ConstantSDNode>(InOps[CurOp])->getZExtValue();
2079 for (; TiedToOperand; --TiedToOperand) {
2081 Flags = cast<ConstantSDNode>(InOps[CurOp])->getZExtValue();
2086 std::vector<SDValue> SelOps;
2097 Ops.insert(Ops.end(), SelOps.begin(), SelOps.end());
2103 if (e != InOps.size())
2104 Ops.push_back(InOps.back());
2123 bool IgnoreChains) {
2132 Visited.
insert(ImmedUse);
2137 if ((
Op.getValueType() ==
MVT::Other && IgnoreChains) || N == Def)
2139 if (!Visited.
insert(N).second)
2145 if (Root != ImmedUse) {
2149 if ((
Op.getValueType() ==
MVT::Other && IgnoreChains) || N == Def)
2151 if (!Visited.
insert(N).second)
2172 bool IgnoreChains) {
2231 IgnoreChains =
false;
2237 void SelectionDAGISel::Select_INLINEASM(
SDNode *
N,
bool Branch) {
2250 void SelectionDAGISel::Select_READ_REGISTER(
SDNode *
Op) {
2267 void SelectionDAGISel::Select_WRITE_REGISTER(
SDNode *Op) {
2284 void SelectionDAGISel::Select_UNDEF(
SDNode *N) {
2290 GetVBR(uint64_t Val,
const unsigned char *MatcherTable,
unsigned &Idx) {
2291 assert(Val >= 128 &&
"Not a VBR");
2297 NextBits = MatcherTable[Idx++];
2298 Val |= (NextBits&127) << Shift;
2300 }
while (NextBits & 128);
2307 void SelectionDAGISel::UpdateChains(
2314 if (!ChainNodesMatched.
empty()) {
2316 "Matched input chains but didn't produce a chain");
2319 for (
unsigned i = 0,
e = ChainNodesMatched.
size(); i !=
e; ++i) {
2320 SDNode *ChainNode = ChainNodesMatched[i];
2327 "Deleted node left in chain");
2331 if (ChainNode == NodeToMatch && isMorphNodeTo)
2341 static_cast<SDNode *
>(
nullptr));
2347 if (ChainNode != NodeToMatch && ChainNode->
use_empty() &&
2353 if (!NowDeadNodes.
empty())
2372 unsigned int Max = 8192;
2375 if (ChainNodesMatched.
size() == 1)
2376 return ChainNodesMatched[0]->getOperand(0);
2380 std::function<void(const SDValue)> AddChains = [&](
const SDValue V) {
2394 for (
auto *N : ChainNodesMatched) {
2399 while (!Worklist.
empty())
2403 if (InputChains.
size() == 0)
2413 for (
auto *N : ChainNodesMatched)
2418 if (InputChains.size() == 1)
2419 return InputChains[0];
2425 SDNode *SelectionDAGISel::
2434 int OldGlueResultNo = -1, OldChainResultNo = -1;
2438 OldGlueResultNo = NTMNumResults-1;
2439 if (NTMNumResults != 1 &&
2441 OldChainResultNo = NTMNumResults-2;
2443 OldChainResultNo = NTMNumResults-1;
2461 (
unsigned)OldGlueResultNo != ResNumResults-1)
2463 SDValue(Res, ResNumResults - 1));
2465 if ((EmitNodeInfo & OPFL_GlueOutput) != 0)
2469 if ((EmitNodeInfo &
OPFL_Chain) && OldChainResultNo != -1 &&
2470 (
unsigned)OldChainResultNo != ResNumResults-1)
2472 SDValue(Res, ResNumResults - 1));
2487 CheckSame(
const unsigned char *MatcherTable,
unsigned &MatcherIndex,
2491 unsigned RecNo = MatcherTable[MatcherIndex++];
2492 assert(RecNo < RecordedNodes.size() &&
"Invalid CheckSame");
2493 return N == RecordedNodes[RecNo].first;
2523 CheckOpcode(
const unsigned char *MatcherTable,
unsigned &MatcherIndex,
2525 uint16_t Opc = MatcherTable[MatcherIndex++];
2526 Opc |= (
unsigned short)MatcherTable[MatcherIndex++] << 8;
2553 return cast<CondCodeSDNode>(
N)->
get() ==
2569 if (cast<VTSDNode>(N)->getVT() == VT)
2579 int64_t Val = MatcherTable[MatcherIndex++];
2581 Val =
GetVBR(Val, MatcherTable, MatcherIndex);
2589 SDValue N,
unsigned ChildNo) {
2596 CheckAndImm(
const unsigned char *MatcherTable,
unsigned &MatcherIndex,
2598 int64_t Val = MatcherTable[MatcherIndex++];
2600 Val =
GetVBR(Val, MatcherTable, MatcherIndex);
2609 CheckOrImm(
const unsigned char *MatcherTable,
unsigned &MatcherIndex,
2611 int64_t Val = MatcherTable[MatcherIndex++];
2613 Val =
GetVBR(Val, MatcherTable, MatcherIndex);
2632 switch (Table[Index++]) {
2637 Result = !
::CheckSame(Table, Index, N, RecordedNodes);
2660 unsigned Res = Table[Index++];
2717 unsigned NumRecordedNodes;
2720 unsigned NumMatchedMemRefs;
2723 SDValue InputChain, InputGlue;
2726 bool HasChainNodesMatched;
2744 RecordedNodes(
RN), MatchScopes(MS) {}
2755 if (N == *NodeToMatch)
2760 for (
auto &
I : RecordedNodes)
2761 if (
I.first.getNode() ==
N)
2764 for (
auto &
I : MatchScopes)
2765 for (
auto &J :
I.NodeStack)
2766 if (J.getNode() ==
N)
2774 const unsigned char *MatcherTable,
2775 unsigned TableSize) {
2812 Select_INLINEASM(NodeToMatch,
2816 Select_READ_REGISTER(NodeToMatch);
2819 Select_WRITE_REGISTER(NodeToMatch);
2822 Select_UNDEF(NodeToMatch);
2831 NodeStack.push_back(N);
2849 SDValue InputChain, InputGlue;
2863 unsigned MatcherIndex = 0;
2865 if (!OpcodeOffset.empty()) {
2867 if (N.
getOpcode() < OpcodeOffset.size())
2868 MatcherIndex = OpcodeOffset[N.
getOpcode()];
2869 LLVM_DEBUG(
dbgs() <<
" Initial Opcode index to " << MatcherIndex <<
"\n");
2878 unsigned CaseSize = MatcherTable[Idx++];
2880 CaseSize =
GetVBR(CaseSize, MatcherTable, Idx);
2881 if (CaseSize == 0)
break;
2884 uint16_t Opc = MatcherTable[Idx++];
2885 Opc |= (
unsigned short)MatcherTable[Idx++] << 8;
2886 if (Opc >= OpcodeOffset.size())
2887 OpcodeOffset.resize((Opc+1)*2);
2888 OpcodeOffset[Opc] = Idx;
2893 if (N.
getOpcode() < OpcodeOffset.size())
2894 MatcherIndex = OpcodeOffset[N.
getOpcode()];
2898 assert(MatcherIndex < TableSize &&
"Invalid index");
2900 unsigned CurrentOpcodeIndex = MatcherIndex;
2913 unsigned NumToSkip = MatcherTable[MatcherIndex++];
2914 if (NumToSkip & 128)
2915 NumToSkip =
GetVBR(NumToSkip, MatcherTable, MatcherIndex);
2917 if (NumToSkip == 0) {
2922 FailIndex = MatcherIndex+NumToSkip;
2924 unsigned MatcherIndexOfPredicate = MatcherIndex;
2925 (void)MatcherIndexOfPredicate;
2932 Result, *
this, RecordedNodes);
2937 dbgs() <<
" Skipped scope entry (due to false predicate) at " 2938 <<
"index " << MatcherIndexOfPredicate <<
", continuing at " 2939 << FailIndex <<
"\n");
2940 ++NumDAGIselRetries;
2944 MatcherIndex = FailIndex;
2948 if (FailIndex == 0)
break;
2952 MatchScope NewEntry;
2953 NewEntry.FailIndex = FailIndex;
2954 NewEntry.NodeStack.append(NodeStack.begin(), NodeStack.end());
2955 NewEntry.NumRecordedNodes = RecordedNodes.
size();
2956 NewEntry.NumMatchedMemRefs = MatchedMemRefs.
size();
2957 NewEntry.InputChain = InputChain;
2958 NewEntry.InputGlue = InputGlue;
2959 NewEntry.HasChainNodesMatched = !ChainNodesMatched.
empty();
2965 SDNode *Parent =
nullptr;
2966 if (NodeStack.size() > 1)
2967 Parent = NodeStack[NodeStack.size()-2].getNode();
2968 RecordedNodes.
push_back(std::make_pair(N, Parent));
2985 if (
auto *MN = dyn_cast<MemSDNode>(N))
2986 MatchedMemRefs.
push_back(MN->getMemOperand());
3002 unsigned ChildNo = MatcherTable[MatcherIndex++];
3006 NodeStack.push_back(N);
3018 NodeStack.push_back(N);
3024 NodeStack.pop_back();
3025 assert(!NodeStack.empty() &&
"Node stack imbalance!");
3026 N = NodeStack.back();
3030 if (!::
CheckSame(MatcherTable, MatcherIndex, N, RecordedNodes))
break;
3035 if (!::
CheckChildSame(MatcherTable, MatcherIndex, N, RecordedNodes,
3049 unsigned OpNum = MatcherTable[MatcherIndex++];
3052 for (
unsigned i = 0; i < OpNum; ++i)
3053 Operands.
push_back(RecordedNodes[MatcherTable[MatcherIndex++]].first);
3055 unsigned PredNo = MatcherTable[MatcherIndex++];
3061 unsigned CPNum = MatcherTable[MatcherIndex++];
3062 unsigned RecNo = MatcherTable[MatcherIndex++];
3063 assert(RecNo < RecordedNodes.
size() &&
"Invalid CheckComplexPat");
3067 std::unique_ptr<MatchStateUpdater> MSU;
3069 MSU.reset(
new MatchStateUpdater(*
CurDAG, &NodeToMatch, RecordedNodes,
3073 RecordedNodes[RecNo].
first, CPNum,
3079 if (!::
CheckOpcode(MatcherTable, MatcherIndex, N.getNode()))
break;
3089 unsigned Res = MatcherTable[MatcherIndex++];
3090 if (!::
CheckType(MatcherTable, MatcherIndex, N.getValue(Res),
TLI,
3097 unsigned CurNodeOpcode = N.getOpcode();
3098 unsigned SwitchStart = MatcherIndex-1; (void)SwitchStart;
3102 CaseSize = MatcherTable[MatcherIndex++];
3104 CaseSize =
GetVBR(CaseSize, MatcherTable, MatcherIndex);
3105 if (CaseSize == 0)
break;
3107 uint16_t Opc = MatcherTable[MatcherIndex++];
3108 Opc |= (
unsigned short)MatcherTable[MatcherIndex++] << 8;
3111 if (CurNodeOpcode == Opc)
3115 MatcherIndex += CaseSize;
3119 if (CaseSize == 0)
break;
3122 LLVM_DEBUG(
dbgs() <<
" OpcodeSwitch from " << SwitchStart <<
" to " 3123 << MatcherIndex <<
"\n");
3128 MVT CurNodeVT = N.getSimpleValueType();
3129 unsigned SwitchStart = MatcherIndex-1; (void)SwitchStart;
3133 CaseSize = MatcherTable[MatcherIndex++];
3135 CaseSize =
GetVBR(CaseSize, MatcherTable, MatcherIndex);
3136 if (CaseSize == 0)
break;
3143 if (CurNodeVT == CaseVT)
3147 MatcherIndex += CaseSize;
3151 if (CaseSize == 0)
break;
3155 <<
"] from " << SwitchStart <<
" to " << MatcherIndex
3180 if (!::
CheckInteger(MatcherTable, MatcherIndex, N))
break;
3189 if (!::
CheckAndImm(MatcherTable, MatcherIndex, N, *
this))
break;
3192 if (!::
CheckOrImm(MatcherTable, MatcherIndex, N, *
this))
break;
3202 assert(NodeStack.size() != 1 &&
"No parent node");
3205 bool HasMultipleUses =
false;
3206 for (
unsigned i = 1,
e = NodeStack.size()-1; i !=
e; ++i) {
3207 unsigned NNonChainUses = 0;
3208 SDNode *NS = NodeStack[i].getNode();
3210 if (UI.getUse().getValueType() !=
MVT::Other)
3211 if (++NNonChainUses > 1) {
3212 HasMultipleUses =
true;
3215 if (HasMultipleUses)
break;
3217 if (HasMultipleUses)
break;
3233 int64_t Val = MatcherTable[MatcherIndex++];
3235 Val =
GetVBR(Val, MatcherTable, MatcherIndex);
3236 RecordedNodes.
push_back(std::pair<SDValue, SDNode*>(
3244 unsigned RegNo = MatcherTable[MatcherIndex++];
3245 RecordedNodes.
push_back(std::pair<SDValue, SDNode*>(
3255 unsigned RegNo = MatcherTable[MatcherIndex++];
3256 RegNo |= MatcherTable[MatcherIndex++] << 8;
3257 RecordedNodes.
push_back(std::pair<SDValue, SDNode*>(
3264 unsigned RecNo = MatcherTable[MatcherIndex++];
3265 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitConvertToTarget");
3266 SDValue Imm = RecordedNodes[RecNo].first;
3269 const ConstantInt *Val=cast<ConstantSDNode>(Imm)->getConstantIntValue();
3271 Imm.getValueType());
3273 const ConstantFP *Val=cast<ConstantFPSDNode>(Imm)->getConstantFPValue();
3275 Imm.getValueType());
3278 RecordedNodes.
push_back(std::make_pair(Imm, RecordedNodes[RecNo].
second));
3287 "EmitMergeInputChains should be the first chain producing node");
3289 "Should only have one EmitMergeInputChains per match");
3293 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitMergeInputChains");
3294 ChainNodesMatched.
push_back(RecordedNodes[RecNo].
first.getNode());
3298 if (ChainNodesMatched.
back() != NodeToMatch &&
3299 !RecordedNodes[RecNo].first.hasOneUse()) {
3300 ChainNodesMatched.
clear();
3314 "EmitMergeInputChains should be the first chain producing node");
3321 unsigned NumChains = MatcherTable[MatcherIndex++];
3322 assert(NumChains != 0 &&
"Can't TF zero chains");
3325 "Should only have one EmitMergeInputChains per match");
3328 for (
unsigned i = 0; i != NumChains; ++i) {
3329 unsigned RecNo = MatcherTable[MatcherIndex++];
3330 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitMergeInputChains");
3331 ChainNodesMatched.
push_back(RecordedNodes[RecNo].
first.getNode());
3335 if (ChainNodesMatched.
back() != NodeToMatch &&
3336 !RecordedNodes[RecNo].first.hasOneUse()) {
3337 ChainNodesMatched.
clear();
3343 if (ChainNodesMatched.
empty())
3357 unsigned RecNo = MatcherTable[MatcherIndex++];
3358 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitCopyToReg");
3359 unsigned DestPhysReg = MatcherTable[MatcherIndex++];
3361 DestPhysReg |= MatcherTable[MatcherIndex++] << 8;
3367 DestPhysReg, RecordedNodes[RecNo].
first,
3370 InputGlue = InputChain.
getValue(1);
3375 unsigned XFormNo = MatcherTable[MatcherIndex++];
3376 unsigned RecNo = MatcherTable[MatcherIndex++];
3377 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitNodeXForm");
3379 RecordedNodes.
push_back(std::pair<SDValue,SDNode*>(Res,
nullptr));
3385 unsigned index = MatcherTable[MatcherIndex++];
3386 index |= (MatcherTable[MatcherIndex++] << 8);
3395 uint16_t TargetOpc = MatcherTable[MatcherIndex++];
3396 TargetOpc |= (
unsigned short)MatcherTable[MatcherIndex++] << 8;
3397 unsigned EmitNodeInfo = MatcherTable[MatcherIndex++];
3407 NumVTs = MatcherTable[MatcherIndex++];
3409 for (
unsigned i = 0; i != NumVTs; ++i) {
3425 if (VTs.
size() == 1)
3427 else if (VTs.
size() == 2)
3433 unsigned NumOps = MatcherTable[MatcherIndex++];
3435 for (
unsigned i = 0; i != NumOps; ++i) {
3436 unsigned RecNo = MatcherTable[MatcherIndex++];
3438 RecNo =
GetVBR(RecNo, MatcherTable, MatcherIndex);
3440 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitNode");
3448 FirstOpToCopy += (EmitNodeInfo &
OPFL_Chain) ? 1 : 0;
3450 "Invalid variadic node");
3462 if (EmitNodeInfo & OPFL_Chain)
3472 for (
auto *N : ChainNodesMatched)
3474 MayRaiseFPException =
true;
3482 if (!IsMorphNodeTo) {
3489 for (
unsigned i = 0,
e = VTs.
size(); i !=
e; ++i) {
3496 "NodeToMatch was removed partway through selection");
3500 auto &Chain = ChainNodesMatched;
3502 "Chain node replaced during MorphNode");
3503 Chain.erase(
std::remove(Chain.begin(), Chain.end(),
N), Chain.end());
3505 Res = cast<MachineSDNode>(MorphNode(NodeToMatch, TargetOpc, VTList,
3506 Ops, EmitNodeInfo));
3519 if (EmitNodeInfo & OPFL_GlueOutput) {
3521 if (EmitNodeInfo & OPFL_Chain)
3523 }
else if (EmitNodeInfo & OPFL_Chain)
3536 bool mayLoad = MCID.
mayLoad();
3543 if (MMO->isLoad()) {
3546 }
else if (MMO->isStore()) {
3558 <<
" Dropping mem operands\n";
3559 dbgs() <<
" " << (IsMorphNodeTo ?
"Morphed" :
"Created")
3564 if (IsMorphNodeTo) {
3566 UpdateChains(Res, InputChain, ChainNodesMatched,
true);
3576 unsigned NumResults = MatcherTable[MatcherIndex++];
3578 for (
unsigned i = 0; i != NumResults; ++i) {
3579 unsigned ResSlot = MatcherTable[MatcherIndex++];
3581 ResSlot =
GetVBR(ResSlot, MatcherTable, MatcherIndex);
3583 assert(ResSlot < RecordedNodes.
size() &&
"Invalid CompleteMatch");
3584 SDValue Res = RecordedNodes[ResSlot].first;
3586 assert(i < NodeToMatch->getNumValues() &&
3589 "Invalid number of results to complete!");
3594 Res.getValueSizeInBits()) &&
3595 "invalid replacement");
3600 UpdateChains(NodeToMatch, InputChain, ChainNodesMatched,
false);
3613 "Didn't replace all uses of the node?");
3623 LLVM_DEBUG(
dbgs() <<
" Match failed at index " << CurrentOpcodeIndex
3625 ++NumDAGIselRetries;
3627 if (MatchScopes.
empty()) {
3628 CannotYetSelect(NodeToMatch);
3634 MatchScope &LastScope = MatchScopes.
back();
3635 RecordedNodes.
resize(LastScope.NumRecordedNodes);
3637 NodeStack.append(LastScope.NodeStack.begin(), LastScope.NodeStack.end());
3638 N = NodeStack.back();
3640 if (LastScope.NumMatchedMemRefs != MatchedMemRefs.
size())
3641 MatchedMemRefs.
resize(LastScope.NumMatchedMemRefs);
3642 MatcherIndex = LastScope.FailIndex;
3646 InputChain = LastScope.InputChain;
3647 InputGlue = LastScope.InputGlue;
3648 if (!LastScope.HasChainNodesMatched)
3649 ChainNodesMatched.
clear();
3654 unsigned NumToSkip = MatcherTable[MatcherIndex++];
3655 if (NumToSkip & 128)
3656 NumToSkip =
GetVBR(NumToSkip, MatcherTable, MatcherIndex);
3660 if (NumToSkip != 0) {
3661 LastScope.FailIndex = MatcherIndex+NumToSkip;
3694 if (
auto *FN = dyn_cast<FrameIndexSDNode>(N->
getOperand(0))) {
3698 int32_t Off = C->getSExtValue();
3701 return (Off >= 0) && (((A - 1) & Off) ==
unsigned(Off));
3706 void SelectionDAGISel::CannotYetSelect(
SDNode *N) {
3709 Msg <<
"Cannot select: ";
3715 Msg <<
"\nIn function: " <<
MF->
getName();
3719 cast<ConstantSDNode>(N->
getOperand(HasInputChain))->getZExtValue();
3720 if (iid < Intrinsic::num_intrinsics)
3723 Msg <<
"target intrinsic %" <<
TII->
getName(iid);
3725 Msg <<
"unknown intrinsic #" << iid;
ANNOTATION_LABEL - Represents a mid basic block label used by annotations.
SDNode * MorphNodeTo(SDNode *N, unsigned Opc, SDVTList VTs, ArrayRef< SDValue > Ops)
This mutates the specified node to have the specified return type, opcode, and operands.
std::unique_ptr< SelectionDAGBuilder > SDB
Diagnostic information for ISel fallback path.
SDNode * SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT)
These are used for target selectors to mutate the specified node to have the specified return type...
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckAndImm(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N, const SelectionDAGISel &SDISel)
A parsed version of the target data layout string in and methods for querying it. ...
mop_iterator operands_end()
EVT getValueType() const
Return the ValueType of the referenced return value.
static SDNode * findGlueUse(SDNode *N)
findGlueUse - Return use of MVT::Glue value produced by the specified SDNode.
void EmitLiveInCopies(MachineBasicBlock *EntryMBB, const TargetRegisterInfo &TRI, const TargetInstrInfo &TII)
EmitLiveInCopies - Emit copies to initialize livein virtual registers into the given entry block...
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckCondCode(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N)
void setFlags(SDNodeFlags NewFlags)
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
bool hasPostISelHook(QueryType Type=IgnoreBundle) const
Return true if this instruction requires adjustment after instruction selection by calling a target h...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
uint64_t getZExtValue() const
Get zero extended value.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
static int getNumFixedFromVariadicInfo(unsigned Flags)
getNumFixedFromVariadicInfo - Transform an EmitNode flags word into the number of fixed arity values ...
bool LegalizeTypes()
This transforms the SelectionDAG into a SelectionDAG that only uses types natively supported by the t...
DiagnosticInfoOptimizationBase::Argument NV
static unsigned virtReg2Index(unsigned Reg)
Convert a virtual register number to a 0-based index.
virtual bool IsProfitableToFold(SDValue N, SDNode *U, SDNode *Root) const
IsProfitableToFold - Returns true if it's profitable to fold the specific operand node N of U during ...
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckValueType(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N, const TargetLowering *TLI, const DataLayout &DL)
DELETED_NODE - This is an illegal value that is used to catch errors.
MDNODE_SDNODE - This is a node that holdes an MDNode*, which is used to reference metadata in the IR...
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
MCSymbol * addLandingPad(MachineBasicBlock *LandingPad)
Add a new panding pad, and extract the exception handling information from the landingpad instruction...
void VerifyDAGDiverence()
static cl::opt< bool > ViewISelDAGs("view-isel-dags", cl::Hidden, cl::desc("Pop up a window to show isel dags as they are selected"))
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
unsigned EnableFastISel
EnableFastISel - This flag enables fast-path instruction selection which trades away generated code q...
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
void ReplaceUses(SDValue F, SDValue T)
ReplaceUses - replace all uses of the old node F with the use of the new node T.
std::error_code remove(const Twine &path, bool IgnoreNonExisting=true)
Remove path.
Sched::Preference getSchedulingPreference() const
Return target scheduling preference.
bool CheckAndMask(SDValue LHS, ConstantSDNode *RHS, int64_t DesiredMaskS) const
CheckAndMask - The isel is trying to match something like (and X, 255).
const MachineFunctionProperties & getProperties() const
Get the function properties.
SelectionDAGBuilder - This is the common target-independent lowering implementation that is parameter...
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
void push_back(const T &Elt)
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
virtual bool CheckNodePredicateWithOperands(SDNode *N, unsigned PredNo, const SmallVectorImpl< SDValue > &Operands) const
CheckNodePredicateWithOperands - This function is generated by tblgen in the target.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
static unsigned getFlagWord(unsigned Kind, unsigned NumOps)
Describe properties that are true of each instruction in the target description file.
void initializeTargetLibraryInfoWrapperPassPass(PassRegistry &)
Clients of various APIs that cause global effects on the DAG can optionally implement this interface...
friend struct DAGUpdateListener
DAGUpdateListener is a friend so it can manipulate the listener stack.
bool LegalizeVectors()
This transforms the SelectionDAG into a SelectionDAG that only uses vector math operations supported ...
virtual const TargetLowering * getTargetLowering() const
bool mayWriteToMemory() const
Return true if this instruction may modify memory.
bool isSubsetOf(const APInt &RHS) const
This operation checks that all bits set in this APInt are also set in RHS.
void copyToMachineFrameInfo(MachineFrameInfo &MFI) const
iterator insertAfter(iterator I, MachineInstr *MI)
Insert MI into the instruction list after I.
unsigned getResNo() const
Convenience function for get().getResNo().
bool NewNodesMustHaveLegalTypes
When true, additional steps are taken to ensure that getConstant() and similar functions return DAG n...
TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or anything else with this node...
bool isTerminator() const
bool isStrictFPEnabled() const
Return true if the target support strict float operation.
STATISTIC(NumFunctions, "Total number of functions")
static bool findNonImmUse(SDNode *Root, SDNode *Def, SDNode *ImmedUse, bool IgnoreChains)
findNonImmUse - Return true if "Def" is a predecessor of "Root" via a path beyond "ImmedUse"...
unsigned const TargetRegisterInfo * TRI
bool isInteger() const
Return true if this is an integer or a vector integer type.
void preassignVRegs(MachineBasicBlock *MBB, BasicBlock::const_iterator Begin, BasicBlock::const_iterator End)
const MDOperand & getOperand(unsigned I) const
std::unique_ptr< FunctionLoweringInfo > FuncInfo
virtual Register getRegisterByName(const char *RegName, LLT Ty, const MachineFunction &MF) const
Return the register ID of the name passed in.
RegisterPassParser class - Handle the addition of new machine passes.
const SDNodeFlags getFlags() const
void setNodeId(int Id)
Set unique node id.
bool isTargetOpcode() const
Test if this node has a target-specific opcode (in the <target>ISD namespace).
SDNode * getNode() const
get the SDNode which holds the desired result
TypeSize getTypeSizeInBits(Type *Ty) const
Size examples:
static MachineBasicBlock::iterator FindSplitPointForStackProtector(MachineBasicBlock *BB)
Find the split point at which to splice the end of BB into its success stack protector check machine ...
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
const SDValue & setRoot(SDValue N)
Set the current root tag of the SelectionDAG.
bool mayLoad() const
Return true if this instruction could possibly read memory.
void viewGraph(const std::string &Title)
Pop up a GraphViz/gv window with the DAG rendered using 'dot'.
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckChildType(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N, const TargetLowering *TLI, const DataLayout &DL, unsigned ChildNo)
EntryToken - This is the marker used to indicate the start of a region.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
static bool isUseOperandTiedToDef(unsigned Flag, unsigned &Idx)
isUseOperandTiedToDef - Return true if the flag of the inline asm operand indicates it is an use oper...
bool isReturn() const
Return true if the instruction is a return.
bool hasOneUse() const
Return true if there is exactly one node using value ResNo of Node.
ScheduleDAGSDNodes * createHybridListDAGScheduler(SelectionDAGISel *IS, CodeGenOpt::Level)
createHybridListDAGScheduler - This creates a bottom up register pressure aware list scheduler that m...
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckChildSame(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N, const SmallVectorImpl< std::pair< SDValue, SDNode *>> &RecordedNodes, unsigned ChildNo)
CheckChildSame - Implements OP_CheckChildXSame.
const TargetLibraryInfo * LibInfo
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) This node represents a target in...
static bool hasPredecessorHelper(const SDNode *N, SmallPtrSetImpl< const SDNode *> &Visited, SmallVectorImpl< const SDNode *> &Worklist, unsigned int MaxSteps=0, bool TopologicalPrune=false)
Returns true if N is a predecessor of any node in Worklist.
bool selectInstruction(const Instruction *I)
Do "fast" instruction selection for the given LLVM IR instruction and append the generated machine in...
static DIExpression * prepend(const DIExpression *Expr, uint8_t Flags, int64_t Offset=0)
Prepend DIExpr with a deref and offset operation and optionally turn it into a stack value or/and an ...
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckSame(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N, const SmallVectorImpl< std::pair< SDValue, SDNode *>> &RecordedNodes)
CheckSame - Implements OP_CheckSame.
SwiftErrorValueTracking * SwiftError
void clear()
Clear state and free memory necessary to make this SelectionDAG ready to process a new block...
AnalysisUsage & addRequired()
void setLastLocalValue(MachineInstr *I)
Update the position of the last instruction emitted for materializing constants for use in the curren...
A description of a memory reference used in the backend.
void resetTargetOptions(const Function &F) const
Reset the target options based on the function's attributes.
StringRef getName(ID id)
Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
Option class for critical edge splitting.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
An analysis pass based on legacy pass manager to deliver ProfileSummaryInfo.
Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
virtual bool ComplexPatternFuncMutatesDAG() const
Return true if complex patterns for this target can mutate the DAG.
static bool IsLegalToFold(SDValue N, SDNode *U, SDNode *Root, CodeGenOpt::Level OptLevel, bool IgnoreChains=false)
IsLegalToFold - Returns true if the specific operand node N of U can be folded during instruction sel...
This class is basically a combination of TimeRegion and Timer.
bool isBuildVectorAllZeros(const SDNode *N)
Return true if the specified node is a BUILD_VECTOR where all of the elements are 0 or undef...
A Use represents the edge between a Value definition and its users.
MachineSDNode * getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT)
These are used for target selectors to create a new node with specified return type(s), MachineInstr opcode, and operands.
const TargetLowering * TLI
#define LLVM_ATTRIBUTE_ALWAYS_INLINE
LLVM_ATTRIBUTE_ALWAYS_INLINE - On compilers where we have a directive to do so, mark a method "always...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
CopyToReg - This node has three operands: a chain, a register number to set to this value...
const MDNode * getMD() const
virtual bool enableMachineSchedDefaultSched() const
True if the machine scheduler should disable the TLI preference for preRA scheduling with the source ...
op_iterator op_end() const
virtual void Select(SDNode *N)=0
Main hook for targets to transform nodes into machine nodes.
ScheduleDAGSDNodes *(*)(SelectionDAGISel *, CodeGenOpt::Level) FunctionPassCtor
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
SDValue getEntryNode() const
Return the token chain corresponding to the entry of the function.
static void EnforceNodeIdInvariant(SDNode *N)
TypeSize getValueSizeInBits() const
Returns the size of the value in bits.
const DataLayout & getDataLayout() const
An analysis pass which caches information about the entire Module.
SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckOpcode(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDNode *N)
mir Rename Register Operands
void setFunctionLoweringInfo(FunctionLoweringInfo *FuncInfo)
bool isExportedInst(const Value *V) const
isExportedInst - Return true if the specified value is an instruction exported from its block...
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
void setFunction(MachineFunction &MF)
Initialize data structures for specified new function.
This file implements a class to represent arbitrary precision integral constant values and operations...
INLINEASM - Represents an inline asm block.
This represents a list of ValueType's that has been intern'd by a SelectionDAG.
unsigned DAGSize
DAGSize - Size of DAG being instruction selected.
void initializeAAResultsWrapperPassPass(PassRegistry &)
MachineInstr * getVRegDef(unsigned Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
defusechain_iterator - This class provides iterator support for machine operands in the function that...
unsigned AssignTopologicalOrder()
Topological-sort the AllNodes list and a assign a unique node id for each node in the DAG based on th...
int getArgumentFrameIndex(const Argument *A)
getArgumentFrameIndex - Get frame index for the byval argument.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
int64_t getSExtValue() const
virtual StringRef getPatternForIndex(unsigned index)
getPatternForIndex - Patterns selected by tablegen during ISEL
static bool hasExceptionPointerOrCodeUser(const CatchPadInst *CPI)
static void InvalidateNodeId(SDNode *N)
This is a fast-path instruction selection class that generates poor code and doesn't support illegal ...
A constant value that is initialized with an expression using other constant values.
STRICT_FSETCC/STRICT_FSETCCS - Constrained versions of SETCC, used for floating-point operands only...
Type * getType() const
All values are typed, get the type of this value.
bool getBoolValue() const
Convert APInt to a boolean value.
MachineFunction & getMachineFunction() const
bool canTrap() const
Return true if evaluation of this constant could trap.
virtual const TargetRegisterClass * getRegClassFor(MVT VT, bool isDivergent=false) const
Return the register class that should be used for the specified value type.
void clearKillFlags(unsigned Reg) const
clearKillFlags - Iterate over all the uses of the given register and clear the kill flag from the Mac...
bool isStatepoint(const CallBase *Call)
SDNode * mutateStrictFPToFP(SDNode *Node)
Mutate the specified strict FP node to its non-strict equivalent, unlinking the node from its chain a...
void init(MachineFunction &NewMF, OptimizationRemarkEmitter &NewORE, Pass *PassPtr, const TargetLibraryInfo *LibraryInfo, LegacyDivergenceAnalysis *Divergence, ProfileSummaryInfo *PSIin, BlockFrequencyInfo *BFIin)
Prepare this SelectionDAG to process code in the given MachineFunction.
STRICT_[US]INT_TO_FP - Convert a signed or unsigned integer to a floating point value.
ScheduleDAGSDNodes * createBURRListDAGScheduler(SelectionDAGISel *IS, CodeGenOpt::Level OptLevel)
createBURRListDAGScheduler - This creates a bottom up register usage reduction list scheduler...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
BasicBlock * SplitCriticalEdge(Instruction *TI, unsigned SuccNum, const CriticalEdgeSplittingOptions &Options=CriticalEdgeSplittingOptions())
If this edge is a critical edge, insert a new node to split the critical edge.
static unsigned IsPredicateKnownToFail(const unsigned char *Table, unsigned Index, SDValue N, bool &Result, const SelectionDAGISel &SDISel, SmallVectorImpl< std::pair< SDValue, SDNode *>> &RecordedNodes)
IsPredicateKnownToFail - If we know how and can do so without pushing a scope, evaluate the current n...
bool createEntriesInEntryBlock(DebugLoc DbgLoc)
Create initial definitions of swifterror values in the entry block of the current function...
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out...
op_iterator op_begin() const
MachinePassRegistry - Track the registration of machine passes.
virtual const TargetInstrInfo * getInstrInfo() const
TargetConstant* - Like Constant*, but the DAG does not do any folding, simplification, or lowering of the constant.
~SelectionDAGISel() override
SDValue getTargetConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
static MachinePassRegistry< FunctionPassCtor > Registry
RegisterScheduler class - Track the registration of instruction schedulers.
static LLVM_ATTRIBUTE_ALWAYS_INLINE uint64_t GetVBR(uint64_t Val, const unsigned char *MatcherTable, unsigned &Idx)
GetVBR - decode a vbr encoding whose top bit is set.
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) This node represents a target intrinsic fun...
SDValue getTargetConstantFP(double Val, const SDLoc &DL, EVT VT)
const TargetRegisterClass * constrainRegClass(unsigned Reg, const TargetRegisterClass *RC, unsigned MinNumRegs=0)
constrainRegClass - Constrain the register class of the specified virtual register to be a common sub...
Legacy analysis pass which computes BranchProbabilityInfo.
unsigned getNumSuccessors() const
Return the number of successors that this instruction has.
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
auto count(R &&Range, const E &Element) -> typename std::iterator_traits< decltype(adl_begin(Range))>::difference_type
Wrapper function around std::count to count the number of times an element Element occurs in the give...
void printrFull(raw_ostream &O, const SelectionDAG *G=nullptr) const
Print a SelectionDAG node and all children down to the leaves.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
static cl::opt< bool > EnableFastISelFallbackReport("fast-isel-report-on-fallback", cl::Hidden, cl::desc("Emit a diagnostic when \ast\instruction selection " "falls back to SelectionDAG."))
UNDEF - An undefined node.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
void finishBasicBlock()
Flush the local value map and sink local values if possible.
This corresponds to the llvm.lifetime.
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
MachineRegisterInfo * RegInfo
iterator find(const_arg_type_t< KeyT > Val)
unsigned ComputeNumSignBits(SDValue Op, unsigned Depth=0) const
Return the number of times the sign bit of the register is replicated into the other bits...
bool isVoidTy() const
Return true if this is 'void'.
const BasicBlock & getEntryBlock() const
unsigned getNumValues() const
Return the number of values defined/returned by this operator.
static SDValue HandleMergeInputChains(SmallVectorImpl< SDNode *> &ChainNodesMatched, SelectionDAG *CurDAG)
HandleMergeInputChains - This implements the OPC_EmitMergeInputChains operation for when the pattern ...
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
unsigned getObjectAlignment(int ObjectIdx) const
Return the alignment of the specified stack object.
CriticalEdgeSplittingOptions & setMergeIdenticalEdges()
static void computeUsesMSVCFloatingPoint(const Triple &TT, const Function &F, MachineModuleInfo &MMI)
virtual bool CheckPatternPredicate(unsigned PredNo) const
CheckPatternPredicate - This function is generated by tblgen in the target.
initializer< Ty > init(const Ty &Val)
SmallPtrSet< const Instruction *, 4 > ElidedArgCopyInstrs
void initializeBranchProbabilityInfoWrapperPassPass(PassRegistry &)
OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...) This node represents a target intrin...
CodeGenOpt::Level OptLevel
ScheduleDAGSDNodes - A ScheduleDAG for scheduling SDNode-based DAGs.
const Instruction * getFirstNonPHI() const
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
READ_REGISTER, WRITE_REGISTER - This node represents llvm.register on the DAG, which implements the n...
unsigned const MachineRegisterInfo * MRI
ScheduleDAGSDNodes * createVLIWDAGScheduler(SelectionDAGISel *IS, CodeGenOpt::Level OptLevel)
createVLIWDAGScheduler - Scheduler for VLIW targets.
bool getO0WantsFastISel()
void Legalize()
This transforms the SelectionDAG into a SelectionDAG that is compatible with the target instruction s...
virtual unsigned getExceptionPointerRegister(const Constant *PersonalityFn) const
If a physical register, this returns the register that receives the exception address on entry to an ...
ScheduleDAGSDNodes * createDefaultScheduler(SelectionDAGISel *IS, CodeGenOpt::Level OptLevel)
createDefaultScheduler - This creates an instruction scheduler appropriate for the target...
use_iterator use_begin() const
Provide iteration support to walk over all uses of an SDNode.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
LLVM Basic Block Representation.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
DISubprogram * getSubprogram() const
Get the attached subprogram.
Value * getAddress() const
LLT getLLTForMVT(MVT Ty)
Get a rough equivalent of an LLT for a given MVT.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
MachineInstrBuilder & UseMI
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
void removeDeadCode(MachineBasicBlock::iterator I, MachineBasicBlock::iterator E)
Remove all dead instructions between the I and E.
iterator_range< value_op_iterator > op_values() const
void setUsesMSVCFloatingPoint(bool b)
const SDValue & getOperand(unsigned Num) const
ScheduleDAGSDNodes * createILPListDAGScheduler(SelectionDAGISel *IS, CodeGenOpt::Level)
createILPListDAGScheduler - This creates a bottom up register pressure aware list scheduler that trie...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
ConstantFP - Floating Point Values [float, double].
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Interval::pred_iterator pred_begin(Interval *I)
pred_begin/pred_end - define methods so that Intervals may be used just like BasicBlocks can with the...
DIExpression * getExpression() const
virtual unsigned getExceptionSelectorRegister(const Constant *PersonalityFn) const
If a physical register, this returns the register that receives the exception typeid on entry to a la...
static unsigned getNumOperandRegisters(unsigned Flag)
getNumOperandRegisters - Extract the number of registers field from the inline asm operand flag...
void RemoveDeadNodes()
This method deletes all unreachable nodes in the SelectionDAG.
EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
Represent the analysis usage information of a pass.
This class provides iterator support for SDUse operands that use a specific SDNode.
use_instr_iterator use_instr_begin(unsigned RegNo) const
bool tryToFoldLoad(const LoadInst *LI, const Instruction *FoldInst)
We're checking to see if we can fold LI into FoldInst.
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckChildInteger(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N, unsigned ChildNo)
static unsigned getMemoryConstraintID(unsigned Flag)
bool lowerArguments()
Do "fast" instruction selection for function arguments and append the machine instructions to the cur...
static void replace(Module &M, GlobalVariable *Old, GlobalVariable *New)
static cl::opt< bool > UseMBPI("use-mbpi", cl::desc("use Machine Branch Probability Info"), cl::init(true), cl::Hidden)
const APInt & getAPIntValue() const
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
const Triple & getTargetTriple() const
Interval::pred_iterator pred_end(Interval *I)
AssertSext, AssertZext - These nodes record if a register contains a value that has already been zero...
void setHasInlineAsm(bool B)
Set a flag that indicates that the function contains inline assembly.
virtual void PostprocessISelDAG()
PostprocessISelDAG() - This hook allows the target to hack on the graph right after selection...
void RemoveDeadNode(SDNode *N)
Remove the specified node from the system.
self_iterator getIterator()
virtual MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr &MI, MachineBasicBlock *MBB) const
This method should be implemented by targets that mark instructions with the 'usesCustomInserter' fla...
void getLocation(StringRef &RelativePath, unsigned &Line, unsigned &Column) const
Return location information for this diagnostic in three parts: the relative source file path...
static unsigned getFlagWordForMem(unsigned InputFlag, unsigned Constraint)
Augment an existing flag word returned by getFlagWord with the constraint code for a memory constrain...
static cl::opt< int > EnableFastISelAbort("fast-isel-abort", cl::Hidden, cl::desc("Enable abort calls when \ast\instruction selection " "fails to lower an instruction: 0 disable the abort, 1 will " "abort but for args, calls and terminators, 2 will also " "abort for argument lowering, and 3 will never fallback " "to SelectionDAG."))
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
bool succ_empty(const Instruction *I)
virtual MVT getPointerTy(const DataLayout &DL, uint32_t AS=0) const
Return the pointer type for the given address space, defaults to the pointer type from the data layou...
static void reportFastISelFailure(MachineFunction &MF, OptimizationRemarkEmitter &ORE, OptimizationRemarkMissed &R, bool ShouldAbort)
static bool isMemKind(unsigned Flag)
bool isImplicitDef() const
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckOrImm(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N, const SelectionDAGISel &SDISel)
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
const MachineBasicBlock & front() const
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
StringRef getName(unsigned Opcode) const
Returns the name for the instructions with the given opcode.
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
bool mayRaiseFPException() const
Return true if this instruction may raise a floating-point exception.
bool isMachineOpcode() const
Test if this node has a post-isel opcode, directly corresponding to a MachineInstr opcode...
static void SplitCriticalSideEffectEdges(Function &Fn, DominatorTree *DT, LoopInfo *LI)
SplitCriticalSideEffectEdges - Look for critical edges with a PHI value that may trap on it...
unsigned getNumOperands() const
Return the number of values used by this operation.
std::string & str()
Flushes the stream contents to the target string and returns the string's reference.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
HANDLENODE node - Used as a handle for various purposes.
const DIExpression * getDebugExpression() const
Return the complex address expression referenced by this DBG_VALUE instruction.
virtual bool enableMachineScheduler() const
True if the subtarget should run MachineScheduler after aggressive coalescing.
Triple - Helper class for working with autoconf configuration names.
EH_LABEL - Represents a label in mid basic block used to track locations needed for debug and excepti...
bool isOrEquivalentToAdd(const SDNode *N) const
TargetIntrinsicInfo - Interface to description of machine instruction set.
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckInteger(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N)
void recomputeInsertPt()
Reset InsertPt to prepare for inserting instructions into the current block.
bool isGCRelocate(const CallBase *Call)
bool use_empty() const
Return true if there are no uses of this node.
static void mapWasmLandingPadIndex(MachineBasicBlock *MBB, const CatchPadInst *CPI)
TokenFactor - This node takes multiple tokens as input and produces a single token result...
bool isBuildVectorAllOnes(const SDNode *N)
Return true if the specified node is a BUILD_VECTOR where all of the elements are ~0 or undef...
void dump() const
Dump this node, for debugging.
ScheduleDAGSDNodes * createSourceListDAGScheduler(SelectionDAGISel *IS, CodeGenOpt::Level OptLevel)
createBURRListDAGScheduler - This creates a bottom up list scheduler that schedules nodes in source c...
bool memoperands_empty() const
Iterator for intrusive lists based on ilist_node.
virtual bool supportSplitCSR(MachineFunction *MF) const
Return true if the target supports that a subset of CSRs for the given machine function is handled ex...
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
virtual void initializeSplitCSR(MachineBasicBlock *Entry) const
Perform necessary initialization to handle a subset of CSRs explicitly via copies.
This is the shared class of boolean and integer constants.
BlockVerifier::State From
virtual bool CheckComplexPattern(SDNode *Root, SDNode *Parent, SDValue N, unsigned PatternNo, SmallVectorImpl< std::pair< SDValue, SDNode *> > &Result)
Align max(MaybeAlign Lhs, Align Rhs)
bool isFuncletEHPersonality(EHPersonality Pers)
Returns true if this is a personality function that invokes handler funclets (which must return to it...
std::string getMsg() const
bool isTargetStrictFPOpcode() const
Test if this node has a target-specific opcode that may raise FP exceptions (in the <target>ISD names...
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
bool isDebugValue() const
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
virtual Register getFrameRegister(const MachineFunction &MF) const =0
Debug information queries.
void setNoFPExcept(bool b)
void setFastISel(bool Enable)
An SDNode that represents everything that will be needed to construct a MachineInstr.
SelectionDAGISel(TargetMachine &tm, CodeGenOpt::Level OL=CodeGenOpt::Default)
void Combine(CombineLevel Level, AAResults *AA, CodeGenOpt::Level OptLevel)
This iterates over the nodes in the SelectionDAG, folding certain types of nodes together, or eliminating superfluous nodes.
LegalizeAction getOperationAction(unsigned Op, EVT VT) const
Return how this operation should be treated: either it is legal, needs to be promoted to a larger siz...
LLVM_NODISCARD T pop_back_val()
virtual Function * getSSPStackGuardCheck(const Module &M) const
If the target has a standard stack protection check function that performs validation and error handl...
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
SelectionDAGISel - This is the common base class used for SelectionDAG-based pattern-matching instruc...
unsigned getNumIncomingValues() const
Return the number of incoming edges.
static cl::opt< bool > ViewLegalizeTypesDAGs("view-legalize-types-dags", cl::Hidden, cl::desc("Pop up a window to show dags before legalize types"))
allnodes_const_iterator allnodes_begin() const
virtual void AdjustInstrPostInstrSelection(MachineInstr &MI, SDNode *Node) const
This method should be implemented by targets that mark instructions with the 'hasPostISelHook' flag...
unsigned getNumArgOperands() const
getNumArgOperands - Return the number of funcletpad arguments.
SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, unsigned Reg, SDValue N)
const Function & getFunction() const
Return the LLVM function that this machine code represents.
void startNewBlock()
Set the current block to which generated machine instructions will be appended.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
static cl::opt< bool > ViewLegalizeDAGs("view-legalize-dags", cl::Hidden, cl::desc("Pop up a window to show dags before legalize"))
void setCallSiteLandingPad(MCSymbol *Sym, ArrayRef< unsigned > Sites)
Map the landing pad's EH symbol to the call site indexes.
Class for arbitrary precision integers.
iterator_range< use_iterator > uses()
static unsigned getReg(const void *D, unsigned RC, unsigned RegNo)
This file defines the FastISel class.
ArrayRef< std::pair< unsigned, unsigned > > liveins() const
static use_iterator use_end()
iterator_range< user_iterator > users()
bool mayStore() const
Return true if this instruction could possibly modify memory.
bool use_empty(unsigned RegNo) const
use_empty - Return true if there are no instructions using the specified register.
void replaceRegWith(unsigned FromReg, unsigned ToReg)
replaceRegWith - Replace all instances of FromReg with ToReg in the machine function.
static void getLazyBFIAnalysisUsage(AnalysisUsage &AU)
Helper for client passes to set up the analysis usage on behalf of this pass.
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
TargetSubtargetInfo - Generic base class for all target subtargets.
int getNodeId() const
Return the unique node id.
Representation of each machine instruction.
static bool isFoldedOrDeadInstruction(const Instruction *I, const FunctionLoweringInfo &FuncInfo)
isFoldedOrDeadInstruction - Return true if the specified instruction is side-effect free and is eithe...
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
These are IR-level optimization flags that may be propagated to SDNodes.
Represents a use of a SDNode.
bool hasGC() const
hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm to use during code generatio...
unsigned GetSuccessorNumber(const BasicBlock *BB, const BasicBlock *Succ)
Search for the specified successor of basic block BB and return its position in the terminator instru...
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
Bitwise operators - logical and, logical or, logical xor.
bool isOnlyUserOf(const SDNode *N) const
Return true if this node is the only use of N.
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB 'Other' at the position From, and insert it into this MBB right before '...
SDValue getCopyFromReg(SDValue Chain, const SDLoc &dl, unsigned Reg, EVT VT)
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
LLVM_NODISCARD bool empty() const
bool isTokenTy() const
Return true if this is 'token'.
virtual void viewGraph(const Twine &Name, const Twine &Title)
Pops up a GraphViz/gv window with the ScheduleDAG rendered using 'dot'.
virtual void insertCopiesSplitCSR(MachineBasicBlock *Entry, const SmallVectorImpl< MachineBasicBlock *> &Exits) const
Insert explicit copies in entry and exit blocks.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
StringRef getName() const
Return a constant reference to the value's name.
virtual const TargetIntrinsicInfo * getIntrinsicInfo() const
If intrinsic information is available, return it. If not, return null.
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
static bool MIIsInTerminatorSequence(const MachineInstr &MI)
Given that the input MI is before a partial terminator sequence TSeq, return true if M + TSeq also a ...
void initializeGCModuleInfoPass(PassRegistry &)
static cl::opt< bool > ViewSUnitDAGs("view-sunit-dags", cl::Hidden, cl::desc("Pop up a window to show SUnit dags after they are processed"))
FunctionLoweringInfo - This contains information that is global to a function that is used when lower...
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
bool isCall() const
Return true if the instruction is a call.
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
bool usesMSVCFloatingPoint() const
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
void Run(SelectionDAG *dag, MachineBasicBlock *bb)
Run - perform scheduling.
OptLevelChanger(SelectionDAGISel &ISel, CodeGenOpt::Level NewOptLevel)
DILocalVariable * getVariable() const
bool isSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB is a successor of this block.
unsigned getOpcode() const
SDValue getValue(unsigned R) const
virtual bool CheckNodePredicate(SDNode *N, unsigned PredNo) const
CheckNodePredicate - This function is generated by tblgen in the target.
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
DenseMap< const AllocaInst *, int > StaticAllocaMap
StaticAllocaMap - Keep track of frame indices for fixed sized allocas in the entry block...
void setOptLevel(CodeGenOpt::Level Level)
Overrides the optimization level.
std::unique_ptr< OptimizationRemarkEmitter > ORE
Current optimization remark emitter.
CopyFromReg - This node indicates that the input value is a virtual or physical register that is defi...
const SDValue & getRoot() const
Return the root tag of the SelectionDAG.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
virtual bool SelectInlineAsmMemoryOperand(const SDValue &Op, unsigned ConstraintID, std::vector< SDValue > &OutOps)
SelectInlineAsmMemoryOperand - Select the specified address as a target addressing mode...
bool callsFunctionThatReturnsTwice() const
callsFunctionThatReturnsTwice - Return true if the function has a call to setjmp or other function th...
void setWasmLandingPadIndex(const MachineBasicBlock *LPad, unsigned Index)
Map the landing pad to its index. Used for Wasm exception handling.
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckType(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N, const TargetLowering *TLI, const DataLayout &DL)
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckChild2CondCode(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N)
bool MaskedValueIsZero(SDValue Op, const APInt &Mask, unsigned Depth=0) const
Return true if 'Op & Mask' is known to be zero.
bool CheckOrMask(SDValue LHS, ConstantSDNode *RHS, int64_t DesiredMaskS) const
CheckOrMask - The isel is trying to match something like (or X, 255).
This class is used to form a handle around another node that is persistent and is updated across invo...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool hasProperty(Property P) const
INLINEASM_BR - Terminator version of inline asm. Used by asm-goto.
A raw_ostream that writes to an std::string.
static cl::opt< std::string > FilterDAGBasicBlockName("filter-view-dags", cl::Hidden, cl::desc("Only display the basic block whose name " "matches this for all view-*-dags options"))
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
SDValue getRegister(unsigned Reg, EVT VT)
mop_iterator operands_begin()
virtual FastISel * createFastISel(FunctionLoweringInfo &, const TargetLibraryInfo *) const
This method returns a target specific FastISel object, or null if the target does not support "fast" ...
void SelectInlineAsmMemoryOperands(std::vector< SDValue > &Ops, const SDLoc &DL)
SelectInlineAsmMemoryOperands - Calls to this are automatically generated by tblgen.
unsigned getMachineOpcode() const
This may only be called if isMachineOpcode returns true.
virtual MachineBasicBlock * EmitSchedule(MachineBasicBlock::iterator &InsertPos)
EmitSchedule - Insert MachineInstrs into the MachineBasicBlock according to the order specified in Se...
virtual void finalizeLowering(MachineFunction &MF) const
Execute target specific actions to finalize target lowering.
static use_instr_iterator use_instr_end()
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
const DILocalVariable * getDebugVariable() const
Return the debug variable referenced by this DBG_VALUE instruction.
static cl::opt< bool > ViewSchedDAGs("view-sched-dags", cl::Hidden, cl::desc("Pop up a window to show sched dags as they are processed"))
Primary interface to the complete machine description for the target machine.
bool isEHPad() const
Return true if the instruction is a variety of EH-block.
Machine Instruction Scheduler
bool hasOneUse() const
Return true if there is exactly one user of this value.
void ReplaceNode(SDNode *F, SDNode *T)
Replace all uses of F with T, then remove F from the DAG.
StringRef - Represent a constant reference to a string, i.e.
inst_range instructions(Function *F)
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th funcletpad argument.
bool skipFunction(const Function &F) const
Optional passes call this function to check whether the pass should be skipped.
void salvageDebugInfo(SDNode &N)
To be invoked on an SDNode that is slated to be erased.
virtual void PreprocessISelDAG()
PreprocessISelDAG - This hook allows targets to hack on the graph before instruction selection starts...
KnownBits computeKnownBits(SDValue Op, unsigned Depth=0) const
Determine which bits of Op are known to be either zero or one and return them in Known.
unsigned getNumOperands() const
Register getReg() const
getReg - Returns the register number.
bool isStrictFPOpcode()
Test if this node is a strict floating point pseudo-op.
static cl::opt< bool > ViewDAGCombine1("view-dag-combine1-dags", cl::Hidden, cl::desc("Pop up a window to show dags before the first " "dag combine pass"))
const SDValue & getOperand(unsigned i) const
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object...
bool TimePassesIsEnabled
If the user specifies the -time-passes argument on an LLVM tool command line then the value of this b...
SDNode * getUser()
This returns the SDNode that contains this Use.
static cl::opt< bool > ViewDAGCombineLT("view-dag-combine-lt-dags", cl::Hidden, cl::desc("Pop up a window to show dags before the post " "legalize types dag combine pass"))
virtual RegisterScheduler::FunctionPassCtor getDAGScheduler(CodeGenOpt::Level) const
Target can subclass this hook to select a different DAG scheduler.
void propagateVRegs()
Propagate assigned swifterror vregs through a function, synthesizing PHI nodes when needed to maintai...
bool isWindowsMSVCEnvironment() const
Checks if the environment could be MSVC.
bool shouldEmitSDCheck(const BasicBlock &BB) const
void setNodeMemRefs(MachineSDNode *N, ArrayRef< MachineMemOperand *> NewMemRefs)
Mutate the specified machine node's memory references to the provided list.
const MachineOperand & getOperand(unsigned i) const
virtual StringRef getIncludePathForIndex(unsigned index)
getIncludePathForIndex - get the td source location of pattern instantiation
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
const TargetInstrInfo * TII
void setVariableDbgInfo(const DILocalVariable *Var, const DIExpression *Expr, int Slot, const DILocation *Loc)
Collect information used to emit debugging information of a variable.
This represents the llvm.dbg.declare instruction.
bool isIndirectDebugValue() const
A DBG_VALUE is indirect iff the first operand is a register and the second operand is an immediate...
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
bool isGCResult(const CallBase *Call)
static cl::opt< RegisterScheduler::FunctionPassCtor, false, RegisterPassParser< RegisterScheduler > > ISHeuristic("pre-RA-sched", cl::init(&createDefaultScheduler), cl::Hidden, cl::desc("Instruction schedulers available (before register" " allocation):"))
ISHeuristic command line option for instruction schedulers.
static void processDbgDeclares(FunctionLoweringInfo &FuncInfo)
Collect llvm.dbg.declare information.
PointerType * getType() const
Global values are always pointers.
Wrapper class representing virtual and physical registers.
A wrapper class for inspecting calls to intrinsic functions.
This class contains meta information specific to a module.
This file describes how to lower LLVM code to machine code.
virtual SDValue RunSDNodeXForm(SDValue V, unsigned XFormNo)
bool hasCalls() const
Return true if the current function has any function calls.
This class is used by SelectionDAGISel to temporarily override the optimization level on a per-functi...
bool mayRaiseFPException(SDNode *Node) const
Return whether the node may raise an FP exception.
void SelectCodeCommon(SDNode *NodeToMatch, const unsigned char *MatcherTable, unsigned TableSize)
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.
static cl::opt< bool > ViewDAGCombine2("view-dag-combine2-dags", cl::Hidden, cl::desc("Pop up a window to show dags before the second " "dag combine pass"))
static int getUninvalidatedNodeId(SDNode *N)
static RegisterScheduler defaultListDAGScheduler("default", "Best scheduler for the target", createDefaultScheduler)