80#include "llvm/IR/IntrinsicsWebAssembly.h"
118#define DEBUG_TYPE "isel"
119#define ISEL_DUMP_DEBUG_TYPE DEBUG_TYPE "-dump"
121STATISTIC(NumFastIselFailures,
"Number of instructions fast isel failed on");
122STATISTIC(NumFastIselSuccess,
"Number of instructions fast isel selected");
123STATISTIC(NumFastIselBlocks,
"Number of blocks selected entirely by fast isel");
124STATISTIC(NumDAGBlocks,
"Number of blocks selected using DAG");
125STATISTIC(NumDAGIselRetries,
"Number of times dag isel has to try another path");
126STATISTIC(NumEntryBlocks,
"Number of entry blocks encountered");
128 "Number of entry blocks where fast isel failed to lower arguments");
132 cl::desc(
"Enable abort calls when \"fast\" instruction selection "
133 "fails to lower an instruction: 0 disable the abort, 1 will "
134 "abort but for args, calls and terminators, 2 will also "
135 "abort for argument lowering, and 3 will never fallback "
136 "to SelectionDAG."));
140 cl::desc(
"Emit a diagnostic when \"fast\" instruction selection "
141 "falls back to SelectionDAG."));
145 cl::desc(
"use Machine Branch Probability Info"),
151 cl::desc(
"Only display the basic block whose name "
152 "matches this for all view-*-dags options"));
155 cl::desc(
"Pop up a window to show dags before the first "
156 "dag combine pass"));
159 cl::desc(
"Pop up a window to show dags before legalize types"));
162 cl::desc(
"Pop up a window to show dags before the post "
163 "legalize types dag combine pass"));
166 cl::desc(
"Pop up a window to show dags before legalize"));
169 cl::desc(
"Pop up a window to show dags before the second "
170 "dag combine pass"));
173 cl::desc(
"Pop up a window to show isel dags as they are selected"));
176 cl::desc(
"Pop up a window to show sched dags as they are processed"));
179 cl::desc(
"Pop up a window to show SUnit dags after they are processed"));
188#define ISEL_DUMP(X) \
190 if (llvm::DebugFlag && \
191 (isCurrentDebugType(DEBUG_TYPE) || \
192 (isCurrentDebugType(ISEL_DUMP_DEBUG_TYPE) && MatchFilterFuncName))) { \
197#define ISEL_DUMP(X) do { } while (false)
217 cl::desc(
"Instruction schedulers available (before register"
230 return Arg.hasAttribute(Attribute::AttrKind::SwiftAsync);
249 if (NewOptLevel != SavedOptLevel) {
252 LLVM_DEBUG(
dbgs() <<
"\nChanging optimization level for Function "
254 LLVM_DEBUG(
dbgs() <<
"\tBefore: -O" <<
static_cast<int>(SavedOptLevel)
255 <<
" ; After: -O" <<
static_cast<int>(NewOptLevel)
263 dbgs() <<
"\tFastISel is "
271 LLVM_DEBUG(
dbgs() <<
"\nRestoring optimization level for Function "
274 <<
" ; After: -O" <<
static_cast<int>(SavedOptLevel) <<
"\n");
290 if (
auto *SchedulerCtor = ST.getDAGScheduler(OptLevel)) {
291 return SchedulerCtor(IS, OptLevel);
295 (ST.enableMachineScheduler() && ST.enableMachineSchedDefaultSched()) ||
309 "Unknown sched type!");
319 dbgs() <<
"If a target marks an instruction with "
320 "'usesCustomInserter', it must implement "
321 "TargetLowering::EmitInstrWithCustomInserter!\n";
329 "If a target marks an instruction with 'hasPostISelHook', "
330 "it must implement TargetLowering::AdjustInstrPostInstrSelection!");
338 char &
ID, std::unique_ptr<SelectionDAGISel> S)
370 : Selector->OptLevel;
374 Selector->initializeAnalysisResults(*
this);
375 return Selector->runOnMachineFunction(MF);
449 : Selector->OptLevel;
452 Selector->initializeAnalysisResults(MFAM);
453 Selector->runOnMachineFunction(MF);
476 ORE = std::make_unique<OptimizationRemarkEmitter>(&Fn);
511#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
531 ORE = std::make_unique<OptimizationRemarkEmitter>(&Fn);
544 UA = &UAPass->getUniformityInfo();
569#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
601 if (isa<UnreachableInst>(Term) || isa<ReturnInst>(Term))
615 SelectAllBasicBlocks(Fn);
643 MRI.constrainRegClass(To,
MRI.getRegClass(
From));
649 if (!
MRI.use_empty(To))
669 if (Term !=
MBB.
end() && Term->isReturn()) {
678 if (!
FuncInfo->ArgDbgValues.empty())
684 for (
unsigned i = 0, e =
FuncInfo->ArgDbgValues.size(); i != e; ++i) {
686 assert(
MI->getOpcode() != TargetOpcode::DBG_VALUE_LIST &&
687 "Function parameters should not be described by DBG_VALUE_LIST.");
688 bool hasFI =
MI->getDebugOperand(0).isFI();
690 hasFI ?
TRI.getFrameRegister(*
MF) :
MI->getDebugOperand(0).getReg();
691 if (Reg.isPhysical())
698 Def->getParent()->insert(std::next(InsertPos),
MI);
710 if (LDI != LiveInMap.
end()) {
711 assert(!hasFI &&
"There's no handling of frame pointer updating here yet "
715 const MDNode *Variable =
MI->getDebugVariable();
716 const MDNode *Expr =
MI->getDebugExpression();
718 bool IsIndirect =
MI->isIndirectDebugValue();
720 assert(
MI->getDebugOffset().getImm() == 0 &&
721 "DBG_VALUE with nonzero offset");
722 assert(cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(
DL) &&
723 "Expected inlined-at fields to agree");
724 assert(
MI->getOpcode() != TargetOpcode::DBG_VALUE_LIST &&
725 "Didn't expect to see a DBG_VALUE_LIST here");
728 IsIndirect, LDI->second, Variable, Expr);
735 if (
UseMI.isDebugValue())
737 if (
UseMI.isCopy() && !CopyUseMI &&
UseMI.getParent() == EntryMBB) {
746 TRI.getRegSizeInBits(LDI->second,
MRI) ==
766 for (
const auto &
MBB : *
MF) {
770 for (
const auto &
MI :
MBB) {
773 MI.isStackAligningInlineAsm()) {
776 if (
MI.isInlineAsm()) {
786 ISEL_DUMP(
dbgs() <<
"*** MachineFunction at end of ISel ***\n");
798 if (!R.getLocation().isValid() || ShouldAbort)
799 R << (
" (in function: " + MF.
getName() +
")").str();
814 if (--
I == Begin || !isa<ReturnInst>(*
I))
817 bool HaveFakeUse =
false;
818 bool HaveTailCall =
false;
820 if (
const CallInst *CI = dyn_cast<CallInst>(--
I))
821 if (CI->isTailCall()) {
826 if (
II->getIntrinsicID() == Intrinsic::fake_use)
828 }
while (
I != Begin);
831 if (!HaveTailCall || !HaveFakeUse)
841 if (
auto UsedDef = dyn_cast<Instruction>(FakeUse->getOperand(0));
842 !UsedDef || UsedDef->getParent() !=
I->getParent() ||
843 UsedDef->comesBefore(&*
I))
848 for (
auto *Inst : FakeUses)
849 Inst->moveBefore(*Inst->getParent(),
I);
865 SDB->visitDbgInfo(*
I);
870 HadTailCall =
SDB->HasTailCall;
871 SDB->resolveOrClearDbgInfo();
878void SelectionDAGISel::ComputeLiveOutVRegInfo() {
892 if (
Op.getValueType() == MVT::Other &&
Added.insert(
Op.getNode()).second)
899 Register DestReg = cast<RegisterSDNode>(
N->getOperand(1))->getReg();
905 EVT SrcVT = Src.getValueType();
911 FuncInfo->AddLiveOutRegInfo(DestReg, NumSignBits, Known);
912 }
while (!Worklist.
empty());
915void SelectionDAGISel::CodeGenAndEmitDAG() {
917 StringRef GroupDescription =
"Instruction Selection and Scheduling";
918 std::string BlockName;
919 bool MatchFilterBB =
false;
928 FuncInfo->MBB->getBasicBlock()->getName());
944#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
946 CurDAG->VerifyDAGDivergence();
964#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
966 CurDAG->VerifyDAGDivergence();
986#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
988 CurDAG->VerifyDAGDivergence();
1005 ISEL_DUMP(
dbgs() <<
"\nOptimized type-legalized selection DAG: "
1010#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
1012 CurDAG->VerifyDAGDivergence();
1028#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
1030 CurDAG->VerifyDAGDivergence();
1039 ISEL_DUMP(
dbgs() <<
"\nVector/type-legalized selection DAG: "
1044#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
1046 CurDAG->VerifyDAGDivergence();
1059 ISEL_DUMP(
dbgs() <<
"\nOptimized vector-legalized selection DAG: "
1064#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
1066 CurDAG->VerifyDAGDivergence();
1084#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
1086 CurDAG->VerifyDAGDivergence();
1104#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
1106 CurDAG->VerifyDAGDivergence();
1110 ComputeLiveOutVRegInfo();
1120 DoInstructionSelection();
1156 if (FirstMBB != LastMBB)
1157 SDB->UpdateSplitBlock(FirstMBB, LastMBB);
1179 :
SelectionDAG::DAGUpdateListener(DAG), ISelPosition(isp) {}
1192 void NodeInserted(
SDNode *
N)
override {
1193 SDNode *CurNode = &*ISelPosition;
1194 if (
MDNode *MD = DAG.getPCSections(CurNode))
1195 DAG.addPCSections(
N, MD);
1196 if (
MDNode *MMRA = DAG.getMMRAMetadata(CurNode))
1197 DAG.addMMRAMetadata(
N, MMRA);
1227 while (!Nodes.
empty()) {
1229 for (
auto *U :
N->users()) {
1230 auto UId = U->getNodeId();
1243 int InvalidId = -(
N->getNodeId() + 1);
1244 N->setNodeId(InvalidId);
1249 int Id =
N->getNodeId();
1255void SelectionDAGISel::DoInstructionSelection() {
1258 <<
FuncInfo->MBB->getName() <<
"'\n");
1276 ISelUpdater ISU(*
CurDAG, ISelPosition);
1283 SDNode *Node = &*--ISelPosition;
1287 if (Node->use_empty())
1294 while (!Nodes.
empty()) {
1311 "Node has already selected predecessor node");
1328 switch (
Node->getOpcode()) {
1337 ActionVT =
Node->getOperand(1).getValueType();
1340 ActionVT =
Node->getValueType(0);
1348 LLVM_DEBUG(
dbgs() <<
"\nISEL: Starting selection on root node: ";
1364 if (
const IntrinsicInst *EHPtrCall = dyn_cast<IntrinsicInst>(U)) {
1366 if (IID == Intrinsic::eh_exceptionpointer ||
1367 IID == Intrinsic::eh_exceptioncode)
1382 bool IsSingleCatchAllClause =
1387 bool IsCatchLongjmp = CPI->
arg_size() == 0;
1388 if (!IsSingleCatchAllClause && !IsCatchLongjmp) {
1390 bool IntrFound =
false;
1392 if (
const auto *Call = dyn_cast<IntrinsicInst>(U)) {
1394 if (IID == Intrinsic::wasm_landingpad_index) {
1395 Value *IndexArg = Call->getArgOperand(1);
1396 int Index = cast<ConstantInt>(IndexArg)->getZExtValue();
1403 assert(IntrFound &&
"wasm.landingpad.index intrinsic not found!");
1410bool SelectionDAGISel::PrepareEHLandingPad() {
1422 if (
const auto *CPI = dyn_cast<CatchPadInst>(LLVMBB->
getFirstNonPHI())) {
1427 assert(EHPhysReg &&
"target lacks exception pointer register");
1429 unsigned VReg =
FuncInfo->getCatchPadExceptionPointerVReg(CPI, PtrRC);
1431 TII->
get(TargetOpcode::COPY), VReg)
1449 if (
auto *RegMask =
TRI.getCustomEHPadPreservedMask(*
MF))
1453 if (
const auto *CPI = dyn_cast<CatchPadInst>(LLVMBB->
getFirstNonPHI()))
1493 TII->
get(TargetOpcode::EH_LABEL))
1502 TII->
get(TargetOpcode::EH_LABEL))
1513 return !
I->mayWriteToMemory() &&
1514 !
I->isTerminator() &&
1515 !isa<DbgInfoIntrinsic>(
I) &&
1527 auto ArgIt = FuncInfo.
ValueMap.find(Arg);
1528 if (ArgIt == FuncInfo.
ValueMap.end())
1530 Register ArgVReg = ArgIt->getSecond();
1534 if (VirtReg == ArgVReg) {
1538 LLVM_DEBUG(
dbgs() <<
"processDbgDeclare: setVariableDbgInfo Var=" << *Var
1539 <<
", Expr=" << *Expr <<
", MCRegister=" << PhysReg
1540 <<
", DbgLoc=" << DbgLoc <<
"\n");
1551 <<
" (bad address)\n");
1561 assert(Var &&
"Missing variable");
1562 assert(DbgLoc &&
"Missing location");
1572 int FI = std::numeric_limits<int>::max();
1573 if (
const auto *AI = dyn_cast<AllocaInst>(
Address)) {
1577 }
else if (
const auto *Arg = dyn_cast<Argument>(
Address))
1580 if (FI == std::numeric_limits<int>::max())
1583 if (
Offset.getBoolValue())
1587 LLVM_DEBUG(
dbgs() <<
"processDbgDeclare: setVariableDbgInfo Var=" << *Var
1588 <<
", Expr=" << *Expr <<
", FI=" << FI
1589 <<
", DbgLoc=" << DbgLoc <<
"\n");
1598 const auto *DI = dyn_cast<DbgDeclareInst>(&
I);
1600 DI->getVariable(), DI->getDebugLoc()))
1605 DVR.getExpression(), DVR.getVariable(),
1620 assert(!It->Values.hasArgList() &&
"Single loc variadic ops not supported");
1626void SelectionDAGISel::SelectAllBasicBlocks(
const Function &Fn) {
1656 ++NumFastIselFailLowerArguments;
1661 R <<
"FastISel didn't lower all arguments: "
1669 CodeGenAndEmitDAG();
1683 if (FastIS && Inserted)
1688 "expected AssignmentTrackingAnalysis pass results");
1698 bool AllPredsVisited =
true;
1700 if (!
FuncInfo->VisitedBBs[Pred->getNumber()]) {
1701 AllPredsVisited =
false;
1706 if (AllPredsVisited) {
1708 FuncInfo->ComputePHILiveOutRegInfo(&PN);
1711 FuncInfo->InvalidatePHILiveOutRegInfo(&PN);
1740 FuncInfo->ExceptionPointerVirtReg = 0;
1741 FuncInfo->ExceptionSelectorVirtReg = 0;
1743 if (!PrepareEHLandingPad())
1751 unsigned NumFastIselRemaining = std::distance(Begin,
End);
1757 for (; BI != Begin; --BI) {
1763 --NumFastIselRemaining;
1774 --NumFastIselRemaining;
1775 ++NumFastIselSuccess;
1782 while (BeforeInst != &*Begin) {
1787 if (BeforeInst != Inst && isa<LoadInst>(BeforeInst) &&
1792 <<
"FastISel folded load: " << *BeforeInst <<
"\n");
1795 --NumFastIselRemaining;
1796 ++NumFastIselSuccess;
1808 if (isa<CallInst>(Inst) && !isa<GCStatepointInst>(Inst) &&
1809 !isa<GCRelocateInst>(Inst) && !isa<GCResultInst>(Inst)) {
1813 R <<
"FastISel missed call";
1816 std::string InstStrStorage;
1820 R <<
": " << InstStrStorage;
1832 bool HadTailCall =
false;
1834 SelectBasicBlock(Inst->
getIterator(), BI, HadTailCall);
1846 unsigned RemainingNow = std::distance(Begin, BI);
1847 NumFastIselFailures += NumFastIselRemaining - RemainingNow;
1848 NumFastIselRemaining = RemainingNow;
1858 R <<
"FastISel missed terminator";
1862 R <<
"FastISel missed";
1866 std::string InstStrStorage;
1869 R <<
": " << InstStrStorage;
1874 NumFastIselFailures += NumFastIselRemaining;
1882 bool FunctionBasedInstrumentation =
1884 SDB->SPDescriptor.initialize(LLVMBB,
FuncInfo->getMBB(LLVMBB),
1885 FunctionBasedInstrumentation);
1891 ++NumFastIselBlocks;
1898 SelectBasicBlock(Begin, BI, HadTailCall);
1910 FuncInfo->PHINodesToUpdate.clear();
1916 reportIPToStateForBlocks(
MF);
1923 SDB->clearDanglingDebugInfo();
1924 SDB->SPDescriptor.resetPerFunctionState();
1928SelectionDAGISel::FinishBasicBlock() {
1930 <<
FuncInfo->PHINodesToUpdate.size() <<
"\n";
1931 for (
unsigned i = 0, e =
FuncInfo->PHINodesToUpdate.size(); i != e;
1933 <<
"Node " << i <<
" : (" <<
FuncInfo->PHINodesToUpdate[i].first
1934 <<
", " <<
FuncInfo->PHINodesToUpdate[i].second <<
")\n");
1938 for (
unsigned i = 0, e =
FuncInfo->PHINodesToUpdate.size(); i != e; ++i) {
1941 "This is not a machine PHI node that we are updating!");
1942 if (!
FuncInfo->MBB->isSuccessor(
PHI->getParent()))
1948 if (
SDB->SPDescriptor.shouldEmitFunctionBasedCheckStackProtector()) {
1957 SDB->visitSPDescriptorParent(
SDB->SPDescriptor, ParentMBB);
1960 CodeGenAndEmitDAG();
1963 SDB->SPDescriptor.resetPerBBState();
1964 }
else if (
SDB->SPDescriptor.shouldEmitStackProtector()) {
1978 SuccessMBB->
splice(SuccessMBB->
end(), ParentMBB,
1985 SDB->visitSPDescriptorParent(
SDB->SPDescriptor, ParentMBB);
1988 CodeGenAndEmitDAG();
1992 if (FailureMBB->
empty()) {
1995 SDB->visitSPDescriptorFailure(
SDB->SPDescriptor);
1998 CodeGenAndEmitDAG();
2002 SDB->SPDescriptor.resetPerBBState();
2006 for (
auto &BTB :
SDB->SL->BitTestCases) {
2016 CodeGenAndEmitDAG();
2020 for (
unsigned j = 0, ej = BTB.Cases.size(); j != ej; ++j) {
2021 UnhandledProb -= BTB.Cases[
j].ExtraProb;
2036 if ((BTB.ContiguousRange || BTB.FallthroughUnreachable) && j + 2 == ej) {
2039 NextMBB = BTB.Cases[
j + 1].TargetBB;
2040 }
else if (j + 1 == ej) {
2042 NextMBB = BTB.Default;
2045 NextMBB = BTB.Cases[
j + 1].ThisBB;
2048 SDB->visitBitTestCase(BTB, NextMBB, UnhandledProb, BTB.Reg, BTB.Cases[j],
2053 CodeGenAndEmitDAG();
2055 if ((BTB.ContiguousRange || BTB.FallthroughUnreachable) && j + 2 == ej) {
2057 BTB.Cases.pop_back();
2063 for (
const std::pair<MachineInstr *, unsigned> &
P :
2068 "This is not a machine PHI node that we are updating!");
2071 if (PHIBB == BTB.Default) {
2072 PHI.addReg(
P.second).addMBB(BTB.Parent);
2073 if (!BTB.ContiguousRange) {
2074 PHI.addReg(
P.second).addMBB(BTB.Cases.back().ThisBB);
2081 PHI.addReg(
P.second).addMBB(cBB);
2085 SDB->SL->BitTestCases.clear();
2090 for (
unsigned i = 0, e =
SDB->SL->JTCases.size(); i != e; ++i) {
2092 if (!
SDB->SL->JTCases[i].first.Emitted) {
2094 FuncInfo->MBB =
SDB->SL->JTCases[i].first.HeaderBB;
2097 SDB->visitJumpTableHeader(
SDB->SL->JTCases[i].second,
2101 CodeGenAndEmitDAG();
2108 SDB->visitJumpTable(
SDB->SL->JTCases[i].second);
2111 CodeGenAndEmitDAG();
2114 for (
unsigned pi = 0, pe =
FuncInfo->PHINodesToUpdate.size();
2119 "This is not a machine PHI node that we are updating!");
2121 if (PHIBB ==
SDB->SL->JTCases[i].second.Default)
2123 .addMBB(
SDB->SL->JTCases[i].first.HeaderBB);
2125 if (
FuncInfo->MBB->isSuccessor(PHIBB))
2129 SDB->SL->JTCases.clear();
2133 for (
unsigned i = 0, e =
SDB->SL->SwitchCases.size(); i != e; ++i) {
2141 if (
SDB->SL->SwitchCases[i].TrueBB !=
SDB->SL->SwitchCases[i].FalseBB)
2148 CodeGenAndEmitDAG();
2169 for (
unsigned pn = 0; ; ++pn) {
2171 "Didn't find PHI entry!");
2172 if (
FuncInfo->PHINodesToUpdate[pn].first ==
PHI) {
2173 PHI.addReg(
FuncInfo->PHINodesToUpdate[pn].second).addMBB(ThisBB);
2181 SDB->SL->SwitchCases.clear();
2202 int64_t DesiredMaskS)
const {
2203 const APInt &ActualMask =
RHS->getAPIntValue();
2206 const APInt &DesiredMask =
APInt(
LHS.getValueSizeInBits(), DesiredMaskS,
2210 if (ActualMask == DesiredMask)
2219 APInt NeededMask = DesiredMask & ~ActualMask;
2234 int64_t DesiredMaskS)
const {
2235 const APInt &ActualMask =
RHS->getAPIntValue();
2238 const APInt &DesiredMask =
APInt(
LHS.getValueSizeInBits(), DesiredMaskS,
2242 if (ActualMask == DesiredMask)
2251 APInt NeededMask = DesiredMask & ~ActualMask;
2271 std::list<HandleSDNode> Handles;
2276 Handles.emplace_back(
2285 if (!Flags.isMemKind() && !Flags.isFuncKind()) {
2287 Handles.insert(Handles.end(), Ops.begin() + i,
2288 Ops.begin() + i + Flags.getNumOperandRegisters() + 1);
2289 i += Flags.getNumOperandRegisters() + 1;
2291 assert(Flags.getNumOperandRegisters() == 1 &&
2292 "Memory operand with multiple values?");
2294 unsigned TiedToOperand;
2295 if (Flags.isUseOperandTiedToDef(TiedToOperand)) {
2299 for (; TiedToOperand; --TiedToOperand) {
2300 CurOp += Flags.getNumOperandRegisters() + 1;
2306 std::vector<SDValue> SelOps;
2308 Flags.getMemoryConstraintID();
2317 Flags.setMemConstraint(ConstraintID);
2319 Handles.insert(Handles.end(), SelOps.begin(), SelOps.end());
2325 if (e != Ops.size())
2326 Handles.emplace_back(Ops.back());
2329 for (
auto &handle : Handles)
2330 Ops.push_back(handle.getValue());
2336 bool IgnoreChains) {
2345 Visited.
insert(ImmedUse);
2350 if ((
Op.getValueType() == MVT::Other && IgnoreChains) ||
N == Def)
2352 if (!Visited.
insert(
N).second)
2358 if (Root != ImmedUse) {
2362 if ((
Op.getValueType() == MVT::Other && IgnoreChains) ||
N == Def)
2364 if (!Visited.
insert(
N).second)
2379 return N.hasOneUse();
2386 bool IgnoreChains) {
2435 while (VT == MVT::Glue) {
2446 IgnoreChains =
false;
2452void SelectionDAGISel::Select_INLINEASM(
SDNode *
N) {
2455 std::vector<SDValue> Ops(
N->op_begin(),
N->op_end());
2458 const EVT VTs[] = {MVT::Other, MVT::Glue};
2465void SelectionDAGISel::Select_READ_REGISTER(
SDNode *
Op) {
2470 EVT VT =
Op->getValueType(0);
2476 Op->getOperand(0), dl, Reg,
Op->getValueType(0));
2482void SelectionDAGISel::Select_WRITE_REGISTER(
SDNode *
Op) {
2487 EVT VT =
Op->getOperand(2).getValueType();
2493 Op->getOperand(0), dl, Reg,
Op->getOperand(2));
2499void SelectionDAGISel::Select_UNDEF(
SDNode *
N) {
2505void SelectionDAGISel::Select_FAKE_USE(
SDNode *
N) {
2507 N->getOperand(1),
N->getOperand(0));
2510void SelectionDAGISel::Select_FREEZE(
SDNode *
N) {
2518void SelectionDAGISel::Select_ARITH_FENCE(
SDNode *
N) {
2523void SelectionDAGISel::Select_MEMBARRIER(
SDNode *
N) {
2528void SelectionDAGISel::Select_CONVERGENCECTRL_ANCHOR(
SDNode *
N) {
2530 N->getValueType(0));
2533void SelectionDAGISel::Select_CONVERGENCECTRL_ENTRY(
SDNode *
N) {
2535 N->getValueType(0));
2538void SelectionDAGISel::Select_CONVERGENCECTRL_LOOP(
SDNode *
N) {
2540 N->getValueType(0),
N->getOperand(0));
2561void SelectionDAGISel::Select_STACKMAP(
SDNode *
N) {
2563 auto *It =
N->op_begin();
2572 assert(
ID.getValueType() == MVT::i64);
2581 for (; It !=
N->op_end(); It++)
2582 pushStackMapLiveVariable(Ops, *It,
DL);
2591void SelectionDAGISel::Select_PATCHPOINT(
SDNode *
N) {
2593 auto *It =
N->op_begin();
2598 std::optional<SDValue> Glue;
2599 if (It->getValueType() == MVT::Glue)
2605 assert(
ID.getValueType() == MVT::i64);
2629 for (; It !=
N->op_end(); It++)
2630 pushStackMapLiveVariable(Ops, *It,
DL);
2635 if (Glue.has_value())
2645 assert(Val >= 128 &&
"Not a VBR");
2651 NextBits = MatcherTable[
Idx++];
2652 Val |= (NextBits&127) << Shift;
2654 }
while (NextBits & 128);
2662getSimpleVT(
const unsigned char *MatcherTable,
unsigned &MatcherIndex) {
2663 unsigned SimpleVT = MatcherTable[MatcherIndex++];
2665 SimpleVT =
GetVBR(SimpleVT, MatcherTable, MatcherIndex);
2670void SelectionDAGISel::Select_JUMP_TABLE_DEBUG_INFO(
SDNode *
N) {
2674 dl, MVT::i64,
true));
2679void SelectionDAGISel::UpdateChains(
2686 if (!ChainNodesMatched.
empty()) {
2688 "Matched input chains but didn't produce a chain");
2691 for (
unsigned i = 0, e = ChainNodesMatched.
size(); i != e; ++i) {
2692 SDNode *ChainNode = ChainNodesMatched[i];
2699 "Deleted node left in chain");
2703 if (ChainNode == NodeToMatch && isMorphNodeTo)
2712 std::replace(ChainNodesMatched.
begin(), ChainNodesMatched.
end(),
N,
2713 static_cast<SDNode *
>(
nullptr));
2719 if (ChainNode != NodeToMatch && ChainNode->
use_empty() &&
2725 if (!NowDeadNodes.
empty())
2744 unsigned int Max = 8192;
2747 if (ChainNodesMatched.
size() == 1)
2748 return ChainNodesMatched[0]->getOperand(0);
2752 std::function<void(
const SDValue)> AddChains = [&](
const SDValue V) {
2753 if (V.getValueType() != MVT::Other)
2757 if (!Visited.
insert(V.getNode()).second)
2760 for (
const SDValue &
Op : V->op_values())
2766 for (
auto *
N : ChainNodesMatched) {
2771 while (!Worklist.
empty())
2775 if (InputChains.
size() == 0)
2785 for (
auto *
N : ChainNodesMatched)
2790 if (InputChains.
size() == 1)
2791 return InputChains[0];
2793 MVT::Other, InputChains);
2797SDNode *SelectionDAGISel::
2806 int OldGlueResultNo = -1, OldChainResultNo = -1;
2808 unsigned NTMNumResults =
Node->getNumValues();
2809 if (
Node->getValueType(NTMNumResults-1) == MVT::Glue) {
2810 OldGlueResultNo = NTMNumResults-1;
2811 if (NTMNumResults != 1 &&
2812 Node->getValueType(NTMNumResults-2) == MVT::Other)
2813 OldChainResultNo = NTMNumResults-2;
2814 }
else if (
Node->getValueType(NTMNumResults-1) == MVT::Other)
2815 OldChainResultNo = NTMNumResults-1;
2833 static_cast<unsigned>(OldGlueResultNo) != ResNumResults - 1)
2835 SDValue(Res, ResNumResults - 1));
2841 if ((EmitNodeInfo &
OPFL_Chain) && OldChainResultNo != -1 &&
2842 static_cast<unsigned>(OldChainResultNo) != ResNumResults - 1)
2844 SDValue(Res, ResNumResults - 1));
2862 unsigned RecNo = MatcherTable[MatcherIndex++];
2863 assert(RecNo < RecordedNodes.size() &&
"Invalid CheckSame");
2864 return N == RecordedNodes[RecNo].first;
2869 const unsigned char *MatcherTable,
unsigned &MatcherIndex,
SDValue N,
2872 if (ChildNo >=
N.getNumOperands())
2874 return ::CheckSame(MatcherTable, MatcherIndex,
N.getOperand(ChildNo),
2882 bool TwoBytePredNo =
2886 ? MatcherTable[MatcherIndex++]
2889 PredNo |= MatcherTable[MatcherIndex++] << 8;
2899 ? MatcherTable[MatcherIndex++]
2907 uint16_t Opc = MatcherTable[MatcherIndex++];
2908 Opc |=
static_cast<uint16_t>(MatcherTable[MatcherIndex++]) << 8;
2909 return N->getOpcode() == Opc;
2916 if (
N.getValueType() == VT)
2926 if (ChildNo >=
N.getNumOperands())
2928 return ::CheckType(VT,
N.getOperand(ChildNo), TLI,
DL);
2934 return cast<CondCodeSDNode>(
N)->get() ==
2941 if (2 >=
N.getNumOperands())
2943 return ::CheckCondCode(MatcherTable, MatcherIndex,
N.getOperand(2));
2950 if (cast<VTSDNode>(
N)->getVT() == VT)
2954 return VT == MVT::iPTR && cast<VTSDNode>(
N)->getVT() == TLI->
getPointerTy(
DL);
2971 int64_t Val = MatcherTable[MatcherIndex++];
2973 Val =
GetVBR(Val, MatcherTable, MatcherIndex);
2978 return C &&
C->getAPIntValue().trySExtValue() == Val;
2984 if (ChildNo >=
N.getNumOperands())
2986 return ::CheckInteger(MatcherTable, MatcherIndex,
N.getOperand(ChildNo));
2992 int64_t Val = MatcherTable[MatcherIndex++];
2994 Val =
GetVBR(Val, MatcherTable, MatcherIndex);
2996 if (
N->getOpcode() !=
ISD::AND)
return false;
3005 int64_t Val = MatcherTable[MatcherIndex++];
3007 Val =
GetVBR(Val, MatcherTable, MatcherIndex);
3009 if (
N->getOpcode() !=
ISD::OR)
return false;
3026 unsigned Opcode = Table[Index++];
3086 unsigned Res = Table[Index++];
3173 unsigned NumRecordedNodes;
3176 unsigned NumMatchedMemRefs;
3179 SDValue InputChain, InputGlue;
3182 bool HasChainNodesMatched;
3199 :
SelectionDAG::DAGUpdateListener(DAG), NodeToMatch(NodeToMatch),
3200 RecordedNodes(
RN), MatchScopes(MS) {}
3208 if (!
E ||
E->isMachineOpcode())
3211 if (
N == *NodeToMatch)
3216 for (
auto &
I : RecordedNodes)
3217 if (
I.first.getNode() ==
N)
3220 for (
auto &
I : MatchScopes)
3221 for (
auto &J :
I.NodeStack)
3222 if (J.getNode() ==
N)
3230 const unsigned char *MatcherTable,
3231 unsigned TableSize) {
3270 Select_INLINEASM(NodeToMatch);
3273 Select_READ_REGISTER(NodeToMatch);
3276 Select_WRITE_REGISTER(NodeToMatch);
3279 Select_UNDEF(NodeToMatch);
3282 Select_FAKE_USE(NodeToMatch);
3285 Select_FREEZE(NodeToMatch);
3288 Select_ARITH_FENCE(NodeToMatch);
3291 Select_MEMBARRIER(NodeToMatch);
3294 Select_STACKMAP(NodeToMatch);
3297 Select_PATCHPOINT(NodeToMatch);
3300 Select_JUMP_TABLE_DEBUG_INFO(NodeToMatch);
3303 Select_CONVERGENCECTRL_ANCHOR(NodeToMatch);
3306 Select_CONVERGENCECTRL_ENTRY(NodeToMatch);
3309 Select_CONVERGENCECTRL_LOOP(NodeToMatch);
3336 SDValue InputChain, InputGlue;
3350 unsigned MatcherIndex = 0;
3352 if (!OpcodeOffset.empty()) {
3354 if (
N.getOpcode() < OpcodeOffset.size())
3355 MatcherIndex = OpcodeOffset[
N.getOpcode()];
3356 LLVM_DEBUG(
dbgs() <<
" Initial Opcode index to " << MatcherIndex <<
"\n");
3365 unsigned CaseSize = MatcherTable[
Idx++];
3367 CaseSize =
GetVBR(CaseSize, MatcherTable,
Idx);
3368 if (CaseSize == 0)
break;
3372 Opc |=
static_cast<uint16_t>(MatcherTable[
Idx++]) << 8;
3373 if (Opc >= OpcodeOffset.size())
3374 OpcodeOffset.resize((Opc+1)*2);
3375 OpcodeOffset[Opc] =
Idx;
3380 if (
N.getOpcode() < OpcodeOffset.size())
3381 MatcherIndex = OpcodeOffset[
N.getOpcode()];
3385 assert(MatcherIndex < TableSize &&
"Invalid index");
3387 unsigned CurrentOpcodeIndex = MatcherIndex;
3401 unsigned NumToSkip = MatcherTable[MatcherIndex++];
3402 if (NumToSkip & 128)
3403 NumToSkip =
GetVBR(NumToSkip, MatcherTable, MatcherIndex);
3405 if (NumToSkip == 0) {
3410 FailIndex = MatcherIndex+NumToSkip;
3412 unsigned MatcherIndexOfPredicate = MatcherIndex;
3413 (void)MatcherIndexOfPredicate;
3420 Result, *
this, RecordedNodes);
3425 dbgs() <<
" Skipped scope entry (due to false predicate) at "
3426 <<
"index " << MatcherIndexOfPredicate <<
", continuing at "
3427 << FailIndex <<
"\n");
3428 ++NumDAGIselRetries;
3432 MatcherIndex = FailIndex;
3436 if (FailIndex == 0)
break;
3440 MatchScope NewEntry;
3441 NewEntry.FailIndex = FailIndex;
3442 NewEntry.NodeStack.append(NodeStack.
begin(), NodeStack.
end());
3443 NewEntry.NumRecordedNodes = RecordedNodes.
size();
3444 NewEntry.NumMatchedMemRefs = MatchedMemRefs.
size();
3445 NewEntry.InputChain = InputChain;
3446 NewEntry.InputGlue = InputGlue;
3447 NewEntry.HasChainNodesMatched = !ChainNodesMatched.
empty();
3453 SDNode *Parent =
nullptr;
3454 if (NodeStack.
size() > 1)
3455 Parent = NodeStack[NodeStack.
size()-2].getNode();
3456 RecordedNodes.
push_back(std::make_pair(
N, Parent));
3465 if (ChildNo >=
N.getNumOperands())
3468 RecordedNodes.
push_back(std::make_pair(
N->getOperand(ChildNo),
3473 if (
auto *MN = dyn_cast<MemSDNode>(
N))
3474 MatchedMemRefs.
push_back(MN->getMemOperand());
3484 if (
N->getNumOperands() != 0 &&
3485 N->getOperand(
N->getNumOperands()-1).getValueType() == MVT::Glue)
3486 InputGlue =
N->getOperand(
N->getNumOperands()-1);
3490 unsigned ChildNo = MatcherTable[MatcherIndex++];
3491 if (ChildNo >=
N.getNumOperands())
3493 N =
N.getOperand(ChildNo);
3503 if (ChildNo >=
N.getNumOperands())
3505 N =
N.getOperand(ChildNo);
3521 assert(!NodeStack.
empty() &&
"Node stack imbalance!");
3522 N = NodeStack.
back();
3525 ? MatcherTable[MatcherIndex++]
3527 if (SiblingNo >=
N.getNumOperands())
3529 N =
N.getOperand(SiblingNo);
3536 assert(!NodeStack.
empty() &&
"Node stack imbalance!");
3537 N = NodeStack.
back();
3541 if (!
::CheckSame(MatcherTable, MatcherIndex,
N, RecordedNodes))
break;
3578 unsigned OpNum = MatcherTable[MatcherIndex++];
3581 for (
unsigned i = 0; i < OpNum; ++i)
3582 Operands.push_back(RecordedNodes[MatcherTable[MatcherIndex++]].first);
3584 unsigned PredNo = MatcherTable[MatcherIndex++];
3599 ? MatcherTable[MatcherIndex++]
3601 unsigned RecNo = MatcherTable[MatcherIndex++];
3602 assert(RecNo < RecordedNodes.
size() &&
"Invalid CheckComplexPat");
3606 std::unique_ptr<MatchStateUpdater> MSU;
3608 MSU.reset(
new MatchStateUpdater(*
CurDAG, &NodeToMatch, RecordedNodes,
3612 RecordedNodes[RecNo].first, CPNum,
3618 if (!
::CheckOpcode(MatcherTable, MatcherIndex,
N.getNode()))
break;
3641 unsigned Res = MatcherTable[MatcherIndex++];
3649 unsigned CurNodeOpcode =
N.getOpcode();
3650 unsigned SwitchStart = MatcherIndex-1; (void)SwitchStart;
3654 CaseSize = MatcherTable[MatcherIndex++];
3656 CaseSize =
GetVBR(CaseSize, MatcherTable, MatcherIndex);
3657 if (CaseSize == 0)
break;
3659 uint16_t Opc = MatcherTable[MatcherIndex++];
3660 Opc |=
static_cast<uint16_t>(MatcherTable[MatcherIndex++]) << 8;
3663 if (CurNodeOpcode == Opc)
3667 MatcherIndex += CaseSize;
3671 if (CaseSize == 0)
break;
3674 LLVM_DEBUG(
dbgs() <<
" OpcodeSwitch from " << SwitchStart <<
" to "
3675 << MatcherIndex <<
"\n");
3680 MVT CurNodeVT =
N.getSimpleValueType();
3681 unsigned SwitchStart = MatcherIndex-1; (void)SwitchStart;
3685 CaseSize = MatcherTable[MatcherIndex++];
3687 CaseSize =
GetVBR(CaseSize, MatcherTable, MatcherIndex);
3688 if (CaseSize == 0)
break;
3691 if (CaseVT == MVT::iPTR)
3695 if (CurNodeVT == CaseVT)
3699 MatcherIndex += CaseSize;
3703 if (CaseSize == 0)
break;
3707 <<
"] from " << SwitchStart <<
" to " << MatcherIndex
3777 if (!
::CheckOrImm(MatcherTable, MatcherIndex,
N, *
this))
break;
3789 assert(NodeStack.
size() != 1 &&
"No parent node");
3792 bool HasMultipleUses =
false;
3793 for (
unsigned i = 1, e = NodeStack.
size()-1; i != e; ++i) {
3794 unsigned NNonChainUses = 0;
3795 SDNode *NS = NodeStack[i].getNode();
3797 if (U.getValueType() != MVT::Other)
3798 if (++NNonChainUses > 1) {
3799 HasMultipleUses =
true;
3802 if (HasMultipleUses)
break;
3804 if (HasMultipleUses)
break;
3843 int64_t Val = MatcherTable[MatcherIndex++];
3845 Val =
GetVBR(Val, MatcherTable, MatcherIndex);
3848 RecordedNodes.
push_back(std::pair<SDValue, SDNode *>(
3869 unsigned RegNo = MatcherTable[MatcherIndex++];
3870 RecordedNodes.
push_back(std::pair<SDValue, SDNode *>(
3879 unsigned RegNo = MatcherTable[MatcherIndex++];
3880 RegNo |= MatcherTable[MatcherIndex++] << 8;
3881 RecordedNodes.
push_back(std::pair<SDValue, SDNode*>(
3897 ? MatcherTable[MatcherIndex++]
3899 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitConvertToTarget");
3900 SDValue Imm = RecordedNodes[RecNo].first;
3903 const ConstantInt *Val=cast<ConstantSDNode>(Imm)->getConstantIntValue();
3905 Imm.getValueType());
3907 const ConstantFP *Val=cast<ConstantFPSDNode>(Imm)->getConstantFPValue();
3909 Imm.getValueType());
3912 RecordedNodes.
push_back(std::make_pair(Imm, RecordedNodes[RecNo].second));
3921 "EmitMergeInputChains should be the first chain producing node");
3923 "Should only have one EmitMergeInputChains per match");
3927 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitMergeInputChains");
3928 ChainNodesMatched.
push_back(RecordedNodes[RecNo].first.getNode());
3934 if (ChainNodesMatched.
back() != NodeToMatch &&
3935 !RecordedNodes[RecNo].first.hasOneUse()) {
3936 ChainNodesMatched.
clear();
3950 "EmitMergeInputChains should be the first chain producing node");
3957 unsigned NumChains = MatcherTable[MatcherIndex++];
3958 assert(NumChains != 0 &&
"Can't TF zero chains");
3961 "Should only have one EmitMergeInputChains per match");
3964 for (
unsigned i = 0; i != NumChains; ++i) {
3965 unsigned RecNo = MatcherTable[MatcherIndex++];
3966 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitMergeInputChains");
3967 ChainNodesMatched.
push_back(RecordedNodes[RecNo].first.getNode());
3973 if (ChainNodesMatched.
back() != NodeToMatch &&
3974 !RecordedNodes[RecNo].first.hasOneUse()) {
3975 ChainNodesMatched.
clear();
3981 if (ChainNodesMatched.
empty())
4006 : MatcherTable[MatcherIndex++];
4007 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitCopyToReg");
4008 unsigned DestPhysReg = MatcherTable[MatcherIndex++];
4010 DestPhysReg |= MatcherTable[MatcherIndex++] << 8;
4016 DestPhysReg, RecordedNodes[RecNo].first,
4019 InputGlue = InputChain.
getValue(1);
4024 unsigned XFormNo = MatcherTable[MatcherIndex++];
4025 unsigned RecNo = MatcherTable[MatcherIndex++];
4026 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitNodeXForm");
4028 RecordedNodes.
push_back(std::pair<SDValue,SDNode*>(Res,
nullptr));
4034 unsigned index = MatcherTable[MatcherIndex++];
4035 index |= (MatcherTable[MatcherIndex++] << 8);
4036 index |= (MatcherTable[MatcherIndex++] << 16);
4037 index |= (MatcherTable[MatcherIndex++] << 24);
4069 uint16_t TargetOpc = MatcherTable[MatcherIndex++];
4070 TargetOpc |=
static_cast<uint16_t>(MatcherTable[MatcherIndex++]) << 8;
4071 unsigned EmitNodeInfo;
4090 EmitNodeInfo = MatcherTable[MatcherIndex++];
4115 NumVTs = MatcherTable[MatcherIndex++];
4117 for (
unsigned i = 0; i != NumVTs; ++i) {
4119 if (VT == MVT::iPTR)
4132 if (VTs.
size() == 1)
4134 else if (VTs.
size() == 2)
4140 unsigned NumOps = MatcherTable[MatcherIndex++];
4142 for (
unsigned i = 0; i != NumOps; ++i) {
4143 unsigned RecNo = MatcherTable[MatcherIndex++];
4145 RecNo =
GetVBR(RecNo, MatcherTable, MatcherIndex);
4147 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitNode");
4148 Ops.
push_back(RecordedNodes[RecNo].first);
4155 FirstOpToCopy += (EmitNodeInfo &
OPFL_Chain) ? 1 : 0;
4157 "Invalid variadic node");
4160 for (
unsigned i = FirstOpToCopy, e = NodeToMatch->
getNumOperands();
4163 if (V.getValueType() == MVT::Glue)
break;
4178 bool MayRaiseFPException =
4185 bool IsMorphNodeTo =
4188 if (!IsMorphNodeTo) {
4195 for (
unsigned i = 0, e = VTs.
size(); i != e; ++i) {
4196 if (VTs[i] == MVT::Other || VTs[i] == MVT::Glue)
break;
4202 "NodeToMatch was removed partway through selection");
4206 auto &Chain = ChainNodesMatched;
4208 "Chain node replaced during MorphNode");
4211 Res = cast<MachineSDNode>(MorphNode(NodeToMatch, TargetOpc, VTList,
4212 Ops, EmitNodeInfo));
4239 bool mayLoad = MCID.
mayLoad();
4246 if (MMO->isLoad()) {
4249 }
else if (MMO->isStore()) {
4261 if (!MatchedMemRefs.
empty() && Res->memoperands_empty())
4262 dbgs() <<
" Dropping mem operands\n";
4263 dbgs() <<
" " << (IsMorphNodeTo ?
"Morphed" :
"Created") <<
" node: ";
4268 if (IsMorphNodeTo) {
4270 UpdateChains(Res, InputChain, ChainNodesMatched,
true);
4280 unsigned NumResults = MatcherTable[MatcherIndex++];
4282 for (
unsigned i = 0; i != NumResults; ++i) {
4283 unsigned ResSlot = MatcherTable[MatcherIndex++];
4285 ResSlot =
GetVBR(ResSlot, MatcherTable, MatcherIndex);
4287 assert(ResSlot < RecordedNodes.
size() &&
"Invalid CompleteMatch");
4288 SDValue Res = RecordedNodes[ResSlot].first;
4290 assert(i < NodeToMatch->getNumValues() &&
4293 "Invalid number of results to complete!");
4299 "invalid replacement");
4304 UpdateChains(NodeToMatch, InputChain, ChainNodesMatched,
false);
4317 "Didn't replace all uses of the node?");
4327 LLVM_DEBUG(
dbgs() <<
" Match failed at index " << CurrentOpcodeIndex
4329 ++NumDAGIselRetries;
4331 if (MatchScopes.
empty()) {
4332 CannotYetSelect(NodeToMatch);
4338 MatchScope &LastScope = MatchScopes.
back();
4339 RecordedNodes.
resize(LastScope.NumRecordedNodes);
4341 NodeStack.
append(LastScope.NodeStack.begin(), LastScope.NodeStack.end());
4342 N = NodeStack.
back();
4344 if (LastScope.NumMatchedMemRefs != MatchedMemRefs.
size())
4345 MatchedMemRefs.
resize(LastScope.NumMatchedMemRefs);
4346 MatcherIndex = LastScope.FailIndex;
4350 InputChain = LastScope.InputChain;
4351 InputGlue = LastScope.InputGlue;
4352 if (!LastScope.HasChainNodesMatched)
4353 ChainNodesMatched.
clear();
4358 unsigned NumToSkip = MatcherTable[MatcherIndex++];
4359 if (NumToSkip & 128)
4360 NumToSkip =
GetVBR(NumToSkip, MatcherTable, MatcherIndex);
4364 if (NumToSkip != 0) {
4365 LastScope.FailIndex = MatcherIndex+NumToSkip;
4379 if (
N->isMachineOpcode()) {
4386 if (
N->isTargetOpcode()) {
4390 return N->isStrictFPOpcode();
4395 auto *
C = dyn_cast<ConstantSDNode>(
N->getOperand(1));
4400 if (
auto *FN = dyn_cast<FrameIndexSDNode>(
N->getOperand(0))) {
4403 int32_t Off =
C->getSExtValue();
4406 return (Off >= 0) && (((
A.value() - 1) & Off) ==
unsigned(Off));
4411void SelectionDAGISel::CannotYetSelect(
SDNode *
N) {
4414 Msg <<
"Cannot select: ";
4420 Msg <<
"\nIn function: " <<
MF->
getName();
4422 bool HasInputChain =
N->getOperand(0).getValueType() == MVT::Other;
4423 unsigned iid =
N->getConstantOperandVal(HasInputChain);
4424 if (iid < Intrinsic::num_intrinsics)
4427 Msg <<
"target intrinsic %" <<
TII->
getName(iid);
4429 Msg <<
"unknown intrinsic #" << iid;
unsigned const MachineRegisterInfo * MRI
for(const MachineOperand &MO :llvm::drop_begin(OldMI.operands(), Desc.getNumOperands()))
MachineInstrBuilder & UseMI
AMDGPU Register Bank Select
This file implements a class to represent arbitrary precision integral constant values and operations...
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
Expand Atomic instructions
BlockVerifier::State From
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_ATTRIBUTE_ALWAYS_INLINE
LLVM_ATTRIBUTE_ALWAYS_INLINE - On compilers where we have a directive to do so, mark a method "always...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
This file defines the DenseMap class.
This file defines the FastISel class.
Module.h This file contains the declarations for the Module class.
mir Rename Register Operands
Machine Instruction Scheduler
unsigned const TargetRegisterInfo * TRI
uint64_t IntrinsicInst * II
FunctionAnalysisManager FAM
This file builds on the ADT/GraphTraits.h file to build a generic graph post order iterator.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static Type * getValueType(Value *V)
Returns the type of the given value/instruction V.
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckValueType(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N, const TargetLowering *TLI, const DataLayout &DL)
static cl::opt< bool > ViewSUnitDAGs("view-sunit-dags", cl::Hidden, cl::desc("Pop up a window to show SUnit dags after they are processed"))
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"))
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckPatternPredicate(unsigned Opcode, const unsigned char *MatcherTable, unsigned &MatcherIndex, const SelectionDAGISel &SDISel)
CheckPatternPredicate - Implements OP_CheckPatternPredicate.
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.
static uint64_t decodeSignRotatedValue(uint64_t V)
Decode a signed value stored with the sign bit in the LSB for dense VBR encoding.
static cl::opt< bool > ViewISelDAGs("view-isel-dags", cl::Hidden, cl::desc("Pop up a window to show isel dags as they are selected"))
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.
static void reportFastISelFailure(MachineFunction &MF, OptimizationRemarkEmitter &ORE, OptimizationRemarkMissed &R, bool ShouldAbort)
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 RegisterScheduler defaultListDAGScheduler("default", "Best scheduler for the target", createDefaultScheduler)
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...
static cl::opt< int > EnableFastISelAbort("fast-isel-abort", cl::Hidden, cl::desc("Enable abort calls when \"fast\" 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."))
static void mapWasmLandingPadIndex(MachineBasicBlock *MBB, const CatchPadInst *CPI)
static void processSingleLocVars(FunctionLoweringInfo &FuncInfo, FunctionVarLocs const *FnVarLocs)
Collect single location variable information generated with assignment tracking.
static LLVM_ATTRIBUTE_ALWAYS_INLINE MVT::SimpleValueType getSimpleVT(const unsigned char *MatcherTable, unsigned &MatcherIndex)
getSimpleVT - Decode a value in MatcherTable, if it's a VBR encoded value, use GetVBR to decode it.
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckInteger(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N)
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckAndImm(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N, const SelectionDAGISel &SDISel)
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckOrImm(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N, const SelectionDAGISel &SDISel)
static cl::opt< bool > UseMBPI("use-mbpi", cl::desc("use Machine Branch Probability Info"), cl::init(true), cl::Hidden)
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckChildType(MVT::SimpleValueType VT, SDValue N, const TargetLowering *TLI, const DataLayout &DL, unsigned ChildNo)
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.
static bool dontUseFastISelFor(const Function &Fn)
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".
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"))