79#include "llvm/IR/IntrinsicsWebAssembly.h"
117#define DEBUG_TYPE "isel"
118#define ISEL_DUMP_DEBUG_TYPE DEBUG_TYPE "-dump"
120STATISTIC(NumFastIselFailures,
"Number of instructions fast isel failed on");
121STATISTIC(NumFastIselSuccess,
"Number of instructions fast isel selected");
122STATISTIC(NumFastIselBlocks,
"Number of blocks selected entirely by fast isel");
123STATISTIC(NumDAGBlocks,
"Number of blocks selected using DAG");
124STATISTIC(NumDAGIselRetries,
"Number of times dag isel has to try another path");
125STATISTIC(NumEntryBlocks,
"Number of entry blocks encountered");
127 "Number of entry blocks where fast isel failed to lower arguments");
131 cl::desc(
"Enable abort calls when \"fast\" instruction selection "
132 "fails to lower an instruction: 0 disable the abort, 1 will "
133 "abort but for args, calls and terminators, 2 will also "
134 "abort for argument lowering, and 3 will never fallback "
135 "to SelectionDAG."));
139 cl::desc(
"Emit a diagnostic when \"fast\" instruction selection "
140 "falls back to SelectionDAG."));
144 cl::desc(
"use Machine Branch Probability Info"),
150 cl::desc(
"Only display the basic block whose name "
151 "matches this for all view-*-dags options"));
154 cl::desc(
"Pop up a window to show dags before the first "
155 "dag combine pass"));
158 cl::desc(
"Pop up a window to show dags before legalize types"));
161 cl::desc(
"Pop up a window to show dags before the post "
162 "legalize types dag combine pass"));
165 cl::desc(
"Pop up a window to show dags before legalize"));
168 cl::desc(
"Pop up a window to show dags before the second "
169 "dag combine pass"));
172 cl::desc(
"Pop up a window to show isel dags as they are selected"));
175 cl::desc(
"Pop up a window to show sched dags as they are processed"));
178 cl::desc(
"Pop up a window to show SUnit dags after they are processed"));
187#define ISEL_DUMP(X) \
189 if (llvm::DebugFlag && \
190 (isCurrentDebugType(DEBUG_TYPE) || \
191 (isCurrentDebugType(ISEL_DUMP_DEBUG_TYPE) && MatchFilterFuncName))) { \
196#define ISEL_DUMP(X) do { } while (false)
216 cl::desc(
"Instruction schedulers available (before register"
229 return Arg.hasAttribute(Attribute::AttrKind::SwiftAsync);
248 if (NewOptLevel != SavedOptLevel) {
251 LLVM_DEBUG(
dbgs() <<
"\nChanging optimization level for Function "
253 LLVM_DEBUG(
dbgs() <<
"\tBefore: -O" <<
static_cast<int>(SavedOptLevel)
254 <<
" ; After: -O" <<
static_cast<int>(NewOptLevel)
262 dbgs() <<
"\tFastISel is "
270 LLVM_DEBUG(
dbgs() <<
"\nRestoring optimization level for Function "
273 <<
" ; After: -O" <<
static_cast<int>(SavedOptLevel) <<
"\n");
289 if (
auto *SchedulerCtor = ST.getDAGScheduler(OptLevel)) {
290 return SchedulerCtor(IS, OptLevel);
294 (ST.enableMachineScheduler() && ST.enableMachineSchedDefaultSched()) ||
308 "Unknown sched type!");
318 dbgs() <<
"If a target marks an instruction with "
319 "'usesCustomInserter', it must implement "
320 "TargetLowering::EmitInstrWithCustomInserter!\n";
328 "If a target marks an instruction with 'hasPostISelHook', "
329 "it must implement TargetLowering::AdjustInstrPostInstrSelection!");
337 char &
ID, std::unique_ptr<SelectionDAGISel> S)
369 : Selector->OptLevel;
373 Selector->initializeAnalysisResults(*
this);
374 return Selector->runOnMachineFunction(MF);
448 : Selector->OptLevel;
451 Selector->initializeAnalysisResults(MFAM);
452 Selector->runOnMachineFunction(MF);
475 ORE = std::make_unique<OptimizationRemarkEmitter>(&Fn);
510#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
530 ORE = std::make_unique<OptimizationRemarkEmitter>(&Fn);
543 UA = &UAPass->getUniformityInfo();
568#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
600 if (isa<UnreachableInst>(Term) || isa<ReturnInst>(Term))
614 SelectAllBasicBlocks(Fn);
642 MRI.constrainRegClass(To,
MRI.getRegClass(
From));
648 if (!
MRI.use_empty(To))
668 if (Term !=
MBB.
end() && Term->isReturn()) {
677 if (!
FuncInfo->ArgDbgValues.empty())
683 for (
unsigned i = 0, e =
FuncInfo->ArgDbgValues.size(); i != e; ++i) {
685 assert(
MI->getOpcode() != TargetOpcode::DBG_VALUE_LIST &&
686 "Function parameters should not be described by DBG_VALUE_LIST.");
687 bool hasFI =
MI->getDebugOperand(0).isFI();
689 hasFI ?
TRI.getFrameRegister(*
MF) :
MI->getDebugOperand(0).getReg();
690 if (Reg.isPhysical())
697 Def->getParent()->insert(std::next(InsertPos),
MI);
709 if (LDI != LiveInMap.
end()) {
710 assert(!hasFI &&
"There's no handling of frame pointer updating here yet "
714 const MDNode *Variable =
MI->getDebugVariable();
715 const MDNode *Expr =
MI->getDebugExpression();
717 bool IsIndirect =
MI->isIndirectDebugValue();
719 assert(
MI->getDebugOffset().getImm() == 0 &&
720 "DBG_VALUE with nonzero offset");
721 assert(cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(
DL) &&
722 "Expected inlined-at fields to agree");
723 assert(
MI->getOpcode() != TargetOpcode::DBG_VALUE_LIST &&
724 "Didn't expect to see a DBG_VALUE_LIST here");
727 IsIndirect, LDI->second, Variable, Expr);
734 if (
UseMI.isDebugValue())
736 if (
UseMI.isCopy() && !CopyUseMI &&
UseMI.getParent() == EntryMBB) {
745 TRI.getRegSizeInBits(LDI->second,
MRI) ==
765 for (
const auto &
MBB : *
MF) {
769 for (
const auto &
MI :
MBB) {
772 MI.isStackAligningInlineAsm()) {
775 if (
MI.isInlineAsm()) {
785 ISEL_DUMP(
dbgs() <<
"*** MachineFunction at end of ISel ***\n");
797 if (!R.getLocation().isValid() || ShouldAbort)
798 R << (
" (in function: " + MF.
getName() +
")").str();
820 SDB->visitDbgInfo(*
I);
825 HadTailCall =
SDB->HasTailCall;
826 SDB->resolveOrClearDbgInfo();
833void SelectionDAGISel::ComputeLiveOutVRegInfo() {
847 if (
Op.getValueType() == MVT::Other &&
Added.insert(
Op.getNode()).second)
854 unsigned DestReg = cast<RegisterSDNode>(
N->getOperand(1))->getReg();
860 EVT SrcVT = Src.getValueType();
866 FuncInfo->AddLiveOutRegInfo(DestReg, NumSignBits, Known);
867 }
while (!Worklist.
empty());
870void SelectionDAGISel::CodeGenAndEmitDAG() {
872 StringRef GroupDescription =
"Instruction Selection and Scheduling";
873 std::string BlockName;
874 bool MatchFilterBB =
false;
883 FuncInfo->MBB->getBasicBlock()->getName());
899#if LLVM_ENABLE_ABI_BREAKING_CHECKS
919#if LLVM_ENABLE_ABI_BREAKING_CHECKS
941#if LLVM_ENABLE_ABI_BREAKING_CHECKS
960 ISEL_DUMP(
dbgs() <<
"\nOptimized type-legalized selection DAG: "
965#if LLVM_ENABLE_ABI_BREAKING_CHECKS
983#if LLVM_ENABLE_ABI_BREAKING_CHECKS
994 ISEL_DUMP(
dbgs() <<
"\nVector/type-legalized selection DAG: "
999#if LLVM_ENABLE_ABI_BREAKING_CHECKS
1014 ISEL_DUMP(
dbgs() <<
"\nOptimized vector-legalized selection DAG: "
1019#if LLVM_ENABLE_ABI_BREAKING_CHECKS
1039#if LLVM_ENABLE_ABI_BREAKING_CHECKS
1059#if LLVM_ENABLE_ABI_BREAKING_CHECKS
1065 ComputeLiveOutVRegInfo();
1075 DoInstructionSelection();
1111 if (FirstMBB != LastMBB)
1112 SDB->UpdateSplitBlock(FirstMBB, LastMBB);
1134 :
SelectionDAG::DAGUpdateListener(DAG), ISelPosition(isp) {}
1147 void NodeInserted(
SDNode *
N)
override {
1148 SDNode *CurNode = &*ISelPosition;
1149 if (
MDNode *MD = DAG.getPCSections(CurNode))
1150 DAG.addPCSections(
N, MD);
1151 if (
MDNode *MMRA = DAG.getMMRAMetadata(CurNode))
1152 DAG.addMMRAMetadata(
N, MMRA);
1182 while (!Nodes.
empty()) {
1184 for (
auto *U :
N->uses()) {
1185 auto UId = U->getNodeId();
1198 int InvalidId = -(
N->getNodeId() + 1);
1199 N->setNodeId(InvalidId);
1204 int Id =
N->getNodeId();
1210void SelectionDAGISel::DoInstructionSelection() {
1213 <<
FuncInfo->MBB->getName() <<
"'\n");
1231 ISelUpdater ISU(*
CurDAG, ISelPosition);
1238 SDNode *Node = &*--ISelPosition;
1242 if (Node->use_empty())
1249 while (!Nodes.
empty()) {
1266 "Node has already selected predecessor node");
1283 switch (
Node->getOpcode()) {
1292 ActionVT =
Node->getOperand(1).getValueType();
1295 ActionVT =
Node->getValueType(0);
1303 LLVM_DEBUG(
dbgs() <<
"\nISEL: Starting selection on root node: ";
1319 if (
const IntrinsicInst *EHPtrCall = dyn_cast<IntrinsicInst>(U)) {
1321 if (IID == Intrinsic::eh_exceptionpointer ||
1322 IID == Intrinsic::eh_exceptioncode)
1337 bool IsSingleCatchAllClause =
1342 bool IsCatchLongjmp = CPI->
arg_size() == 0;
1343 if (!IsSingleCatchAllClause && !IsCatchLongjmp) {
1345 bool IntrFound =
false;
1347 if (
const auto *Call = dyn_cast<IntrinsicInst>(U)) {
1349 if (IID == Intrinsic::wasm_landingpad_index) {
1350 Value *IndexArg = Call->getArgOperand(1);
1351 int Index = cast<ConstantInt>(IndexArg)->getZExtValue();
1358 assert(IntrFound &&
"wasm.landingpad.index intrinsic not found!");
1365bool SelectionDAGISel::PrepareEHLandingPad() {
1377 if (
const auto *CPI = dyn_cast<CatchPadInst>(LLVMBB->
getFirstNonPHI())) {
1382 assert(EHPhysReg &&
"target lacks exception pointer register");
1384 unsigned VReg =
FuncInfo->getCatchPadExceptionPointerVReg(CPI, PtrRC);
1386 TII->
get(TargetOpcode::COPY), VReg)
1404 if (
auto *RegMask =
TRI.getCustomEHPadPreservedMask(*
MF))
1408 if (
const auto *CPI = dyn_cast<CatchPadInst>(LLVMBB->
getFirstNonPHI()))
1444 TII->
get(TargetOpcode::EH_LABEL))
1453 TII->
get(TargetOpcode::EH_LABEL))
1464 return !
I->mayWriteToMemory() &&
1465 !
I->isTerminator() &&
1466 !isa<DbgInfoIntrinsic>(
I) &&
1478 auto ArgIt = FuncInfo.
ValueMap.find(Arg);
1479 if (ArgIt == FuncInfo.
ValueMap.end())
1481 Register ArgVReg = ArgIt->getSecond();
1485 if (VirtReg == ArgVReg) {
1489 LLVM_DEBUG(
dbgs() <<
"processDbgDeclare: setVariableDbgInfo Var=" << *Var
1490 <<
", Expr=" << *Expr <<
", MCRegister=" << PhysReg
1491 <<
", DbgLoc=" << DbgLoc <<
"\n");
1502 <<
" (bad address)\n");
1512 assert(Var &&
"Missing variable");
1513 assert(DbgLoc &&
"Missing location");
1523 int FI = std::numeric_limits<int>::max();
1524 if (
const auto *AI = dyn_cast<AllocaInst>(
Address)) {
1528 }
else if (
const auto *Arg = dyn_cast<Argument>(
Address))
1531 if (FI == std::numeric_limits<int>::max())
1534 if (
Offset.getBoolValue())
1538 LLVM_DEBUG(
dbgs() <<
"processDbgDeclare: setVariableDbgInfo Var=" << *Var
1539 <<
", Expr=" << *Expr <<
", FI=" << FI
1540 <<
", DbgLoc=" << DbgLoc <<
"\n");
1549 const auto *DI = dyn_cast<DbgDeclareInst>(&
I);
1551 DI->getVariable(), DI->getDebugLoc()))
1556 DVR.getExpression(), DVR.getVariable(),
1571 assert(!It->Values.hasArgList() &&
"Single loc variadic ops not supported");
1577void SelectionDAGISel::SelectAllBasicBlocks(
const Function &Fn) {
1607 ++NumFastIselFailLowerArguments;
1612 R <<
"FastISel didn't lower all arguments: "
1620 CodeGenAndEmitDAG();
1634 if (FastIS && Inserted)
1639 "expected AssignmentTrackingAnalysis pass results");
1649 bool AllPredsVisited =
true;
1651 if (!
FuncInfo->VisitedBBs[Pred->getNumber()]) {
1652 AllPredsVisited =
false;
1657 if (AllPredsVisited) {
1659 FuncInfo->ComputePHILiveOutRegInfo(&PN);
1662 FuncInfo->InvalidatePHILiveOutRegInfo(&PN);
1681 FuncInfo->ExceptionPointerVirtReg = 0;
1682 FuncInfo->ExceptionSelectorVirtReg = 0;
1684 if (!PrepareEHLandingPad())
1692 unsigned NumFastIselRemaining = std::distance(Begin,
End);
1698 for (; BI != Begin; --BI) {
1704 --NumFastIselRemaining;
1715 --NumFastIselRemaining;
1716 ++NumFastIselSuccess;
1723 while (BeforeInst != &*Begin) {
1728 if (BeforeInst != Inst && isa<LoadInst>(BeforeInst) &&
1733 <<
"FastISel folded load: " << *BeforeInst <<
"\n");
1736 --NumFastIselRemaining;
1737 ++NumFastIselSuccess;
1749 if (isa<CallInst>(Inst) && !isa<GCStatepointInst>(Inst) &&
1750 !isa<GCRelocateInst>(Inst) && !isa<GCResultInst>(Inst)) {
1754 R <<
"FastISel missed call";
1757 std::string InstStrStorage;
1761 R <<
": " << InstStrStorage;
1773 bool HadTailCall =
false;
1775 SelectBasicBlock(Inst->
getIterator(), BI, HadTailCall);
1787 unsigned RemainingNow = std::distance(Begin, BI);
1788 NumFastIselFailures += NumFastIselRemaining - RemainingNow;
1789 NumFastIselRemaining = RemainingNow;
1799 R <<
"FastISel missed terminator";
1803 R <<
"FastISel missed";
1807 std::string InstStrStorage;
1810 R <<
": " << InstStrStorage;
1815 NumFastIselFailures += NumFastIselRemaining;
1823 bool FunctionBasedInstrumentation =
1825 SDB->SPDescriptor.initialize(LLVMBB,
FuncInfo->getMBB(LLVMBB),
1826 FunctionBasedInstrumentation);
1832 ++NumFastIselBlocks;
1839 SelectBasicBlock(Begin, BI, HadTailCall);
1851 FuncInfo->PHINodesToUpdate.clear();
1857 reportIPToStateForBlocks(
MF);
1864 SDB->clearDanglingDebugInfo();
1865 SDB->SPDescriptor.resetPerFunctionState();
1869SelectionDAGISel::FinishBasicBlock() {
1871 <<
FuncInfo->PHINodesToUpdate.size() <<
"\n";
1872 for (
unsigned i = 0, e =
FuncInfo->PHINodesToUpdate.size(); i != e;
1874 <<
"Node " << i <<
" : (" <<
FuncInfo->PHINodesToUpdate[i].first
1875 <<
", " <<
FuncInfo->PHINodesToUpdate[i].second <<
")\n");
1879 for (
unsigned i = 0, e =
FuncInfo->PHINodesToUpdate.size(); i != e; ++i) {
1882 "This is not a machine PHI node that we are updating!");
1883 if (!
FuncInfo->MBB->isSuccessor(
PHI->getParent()))
1889 if (
SDB->SPDescriptor.shouldEmitFunctionBasedCheckStackProtector()) {
1898 SDB->visitSPDescriptorParent(
SDB->SPDescriptor, ParentMBB);
1901 CodeGenAndEmitDAG();
1904 SDB->SPDescriptor.resetPerBBState();
1905 }
else if (
SDB->SPDescriptor.shouldEmitStackProtector()) {
1919 SuccessMBB->
splice(SuccessMBB->
end(), ParentMBB,
1926 SDB->visitSPDescriptorParent(
SDB->SPDescriptor, ParentMBB);
1929 CodeGenAndEmitDAG();
1933 if (FailureMBB->
empty()) {
1936 SDB->visitSPDescriptorFailure(
SDB->SPDescriptor);
1939 CodeGenAndEmitDAG();
1943 SDB->SPDescriptor.resetPerBBState();
1947 for (
auto &BTB :
SDB->SL->BitTestCases) {
1957 CodeGenAndEmitDAG();
1961 for (
unsigned j = 0, ej = BTB.Cases.size(); j != ej; ++j) {
1962 UnhandledProb -= BTB.Cases[
j].ExtraProb;
1977 if ((BTB.ContiguousRange || BTB.FallthroughUnreachable) && j + 2 == ej) {
1980 NextMBB = BTB.Cases[
j + 1].TargetBB;
1981 }
else if (j + 1 == ej) {
1983 NextMBB = BTB.Default;
1986 NextMBB = BTB.Cases[
j + 1].ThisBB;
1989 SDB->visitBitTestCase(BTB, NextMBB, UnhandledProb, BTB.Reg, BTB.Cases[j],
1994 CodeGenAndEmitDAG();
1996 if ((BTB.ContiguousRange || BTB.FallthroughUnreachable) && j + 2 == ej) {
1998 BTB.Cases.pop_back();
2004 for (
const std::pair<MachineInstr *, unsigned> &
P :
2009 "This is not a machine PHI node that we are updating!");
2012 if (PHIBB == BTB.Default) {
2013 PHI.addReg(
P.second).addMBB(BTB.Parent);
2014 if (!BTB.ContiguousRange) {
2015 PHI.addReg(
P.second).addMBB(BTB.Cases.back().ThisBB);
2022 PHI.addReg(
P.second).addMBB(cBB);
2026 SDB->SL->BitTestCases.clear();
2031 for (
unsigned i = 0, e =
SDB->SL->JTCases.size(); i != e; ++i) {
2033 if (!
SDB->SL->JTCases[i].first.Emitted) {
2035 FuncInfo->MBB =
SDB->SL->JTCases[i].first.HeaderBB;
2038 SDB->visitJumpTableHeader(
SDB->SL->JTCases[i].second,
2042 CodeGenAndEmitDAG();
2049 SDB->visitJumpTable(
SDB->SL->JTCases[i].second);
2052 CodeGenAndEmitDAG();
2055 for (
unsigned pi = 0, pe =
FuncInfo->PHINodesToUpdate.size();
2060 "This is not a machine PHI node that we are updating!");
2062 if (PHIBB ==
SDB->SL->JTCases[i].second.Default)
2064 .addMBB(
SDB->SL->JTCases[i].first.HeaderBB);
2066 if (
FuncInfo->MBB->isSuccessor(PHIBB))
2070 SDB->SL->JTCases.clear();
2074 for (
unsigned i = 0, e =
SDB->SL->SwitchCases.size(); i != e; ++i) {
2082 if (
SDB->SL->SwitchCases[i].TrueBB !=
SDB->SL->SwitchCases[i].FalseBB)
2089 CodeGenAndEmitDAG();
2110 for (
unsigned pn = 0; ; ++pn) {
2112 "Didn't find PHI entry!");
2113 if (
FuncInfo->PHINodesToUpdate[pn].first ==
PHI) {
2114 PHI.addReg(
FuncInfo->PHINodesToUpdate[pn].second).addMBB(ThisBB);
2122 SDB->SL->SwitchCases.clear();
2143 int64_t DesiredMaskS)
const {
2144 const APInt &ActualMask =
RHS->getAPIntValue();
2145 const APInt &DesiredMask =
APInt(
LHS.getValueSizeInBits(), DesiredMaskS);
2148 if (ActualMask == DesiredMask)
2157 APInt NeededMask = DesiredMask & ~ActualMask;
2172 int64_t DesiredMaskS)
const {
2173 const APInt &ActualMask =
RHS->getAPIntValue();
2174 const APInt &DesiredMask =
APInt(
LHS.getValueSizeInBits(), DesiredMaskS);
2177 if (ActualMask == DesiredMask)
2186 APInt NeededMask = DesiredMask & ~ActualMask;
2206 std::list<HandleSDNode> Handles;
2211 Handles.emplace_back(
2215 if (Ops[e - 1].getValueType() == MVT::Glue)
2220 if (!Flags.isMemKind() && !Flags.isFuncKind()) {
2222 Handles.insert(Handles.end(), Ops.begin() + i,
2223 Ops.begin() + i + Flags.getNumOperandRegisters() + 1);
2224 i += Flags.getNumOperandRegisters() + 1;
2226 assert(Flags.getNumOperandRegisters() == 1 &&
2227 "Memory operand with multiple values?");
2229 unsigned TiedToOperand;
2230 if (Flags.isUseOperandTiedToDef(TiedToOperand)) {
2234 for (; TiedToOperand; --TiedToOperand) {
2235 CurOp += Flags.getNumOperandRegisters() + 1;
2241 std::vector<SDValue> SelOps;
2243 Flags.getMemoryConstraintID();
2252 Flags.setMemConstraint(ConstraintID);
2254 Handles.insert(Handles.end(), SelOps.begin(), SelOps.end());
2260 if (e != Ops.size())
2261 Handles.emplace_back(Ops.back());
2264 for (
auto &handle : Handles)
2265 Ops.push_back(handle.getValue());
2272 unsigned FlagResNo =
N->getNumValues()-1;
2275 if (
Use.getResNo() == FlagResNo)
2284 bool IgnoreChains) {
2293 Visited.
insert(ImmedUse);
2298 if ((
Op.getValueType() == MVT::Other && IgnoreChains) ||
N == Def)
2300 if (!Visited.
insert(
N).second)
2306 if (Root != ImmedUse) {
2310 if ((
Op.getValueType() == MVT::Other && IgnoreChains) ||
N == Def)
2312 if (!Visited.
insert(
N).second)
2327 return N.hasOneUse();
2334 bool IgnoreChains) {
2383 while (VT == MVT::Glue) {
2394 IgnoreChains =
false;
2400void SelectionDAGISel::Select_INLINEASM(
SDNode *
N) {
2403 std::vector<SDValue> Ops(
N->op_begin(),
N->op_end());
2406 const EVT VTs[] = {MVT::Other, MVT::Glue};
2413void SelectionDAGISel::Select_READ_REGISTER(
SDNode *
Op) {
2418 EVT VT =
Op->getValueType(0);
2424 Op->getOperand(0), dl, Reg,
Op->getValueType(0));
2430void SelectionDAGISel::Select_WRITE_REGISTER(
SDNode *
Op) {
2435 EVT VT =
Op->getOperand(2).getValueType();
2441 Op->getOperand(0), dl, Reg,
Op->getOperand(2));
2447void SelectionDAGISel::Select_UNDEF(
SDNode *
N) {
2451void SelectionDAGISel::Select_FREEZE(
SDNode *
N) {
2459void SelectionDAGISel::Select_ARITH_FENCE(
SDNode *
N) {
2464void SelectionDAGISel::Select_MEMBARRIER(
SDNode *
N) {
2469void SelectionDAGISel::Select_CONVERGENCECTRL_ANCHOR(
SDNode *
N) {
2471 N->getValueType(0));
2474void SelectionDAGISel::Select_CONVERGENCECTRL_ENTRY(
SDNode *
N) {
2476 N->getValueType(0));
2479void SelectionDAGISel::Select_CONVERGENCECTRL_LOOP(
SDNode *
N) {
2481 N->getValueType(0),
N->getOperand(0));
2502void SelectionDAGISel::Select_STACKMAP(
SDNode *
N) {
2504 auto *It =
N->op_begin();
2513 assert(
ID.getValueType() == MVT::i64);
2522 for (; It !=
N->op_end(); It++)
2523 pushStackMapLiveVariable(Ops, *It,
DL);
2532void SelectionDAGISel::Select_PATCHPOINT(
SDNode *
N) {
2534 auto *It =
N->op_begin();
2539 std::optional<SDValue> Glue;
2540 if (It->getValueType() == MVT::Glue)
2546 assert(
ID.getValueType() == MVT::i64);
2570 for (; It !=
N->op_end(); It++)
2571 pushStackMapLiveVariable(Ops, *It,
DL);
2576 if (Glue.has_value())
2586 assert(Val >= 128 &&
"Not a VBR");
2592 NextBits = MatcherTable[
Idx++];
2593 Val |= (NextBits&127) << Shift;
2595 }
while (NextBits & 128);
2603getSimpleVT(
const unsigned char *MatcherTable,
unsigned &MatcherIndex) {
2604 unsigned SimpleVT = MatcherTable[MatcherIndex++];
2606 SimpleVT =
GetVBR(SimpleVT, MatcherTable, MatcherIndex);
2611void SelectionDAGISel::Select_JUMP_TABLE_DEBUG_INFO(
SDNode *
N) {
2615 dl, MVT::i64,
true));
2620void SelectionDAGISel::UpdateChains(
2627 if (!ChainNodesMatched.
empty()) {
2629 "Matched input chains but didn't produce a chain");
2632 for (
unsigned i = 0, e = ChainNodesMatched.
size(); i != e; ++i) {
2633 SDNode *ChainNode = ChainNodesMatched[i];
2640 "Deleted node left in chain");
2644 if (ChainNode == NodeToMatch && isMorphNodeTo)
2653 std::replace(ChainNodesMatched.
begin(), ChainNodesMatched.
end(),
N,
2654 static_cast<SDNode *
>(
nullptr));
2660 if (ChainNode != NodeToMatch && ChainNode->
use_empty() &&
2666 if (!NowDeadNodes.
empty())
2685 unsigned int Max = 8192;
2688 if (ChainNodesMatched.
size() == 1)
2689 return ChainNodesMatched[0]->getOperand(0);
2693 std::function<void(
const SDValue)> AddChains = [&](
const SDValue V) {
2694 if (V.getValueType() != MVT::Other)
2698 if (!Visited.
insert(V.getNode()).second)
2701 for (
const SDValue &
Op : V->op_values())
2707 for (
auto *
N : ChainNodesMatched) {
2712 while (!Worklist.
empty())
2716 if (InputChains.
size() == 0)
2726 for (
auto *
N : ChainNodesMatched)
2731 if (InputChains.
size() == 1)
2732 return InputChains[0];
2734 MVT::Other, InputChains);
2738SDNode *SelectionDAGISel::
2747 int OldGlueResultNo = -1, OldChainResultNo = -1;
2749 unsigned NTMNumResults =
Node->getNumValues();
2750 if (
Node->getValueType(NTMNumResults-1) == MVT::Glue) {
2751 OldGlueResultNo = NTMNumResults-1;
2752 if (NTMNumResults != 1 &&
2753 Node->getValueType(NTMNumResults-2) == MVT::Other)
2754 OldChainResultNo = NTMNumResults-2;
2755 }
else if (
Node->getValueType(NTMNumResults-1) == MVT::Other)
2756 OldChainResultNo = NTMNumResults-1;
2774 static_cast<unsigned>(OldGlueResultNo) != ResNumResults - 1)
2776 SDValue(Res, ResNumResults - 1));
2782 if ((EmitNodeInfo &
OPFL_Chain) && OldChainResultNo != -1 &&
2783 static_cast<unsigned>(OldChainResultNo) != ResNumResults - 1)
2785 SDValue(Res, ResNumResults - 1));
2803 unsigned RecNo = MatcherTable[MatcherIndex++];
2804 assert(RecNo < RecordedNodes.size() &&
"Invalid CheckSame");
2805 return N == RecordedNodes[RecNo].first;
2810 const unsigned char *MatcherTable,
unsigned &MatcherIndex,
SDValue N,
2813 if (ChildNo >=
N.getNumOperands())
2815 return ::CheckSame(MatcherTable, MatcherIndex,
N.getOperand(ChildNo),
2823 bool TwoBytePredNo =
2827 ? MatcherTable[MatcherIndex++]
2830 PredNo |= MatcherTable[MatcherIndex++] << 8;
2840 ? MatcherTable[MatcherIndex++]
2848 uint16_t Opc = MatcherTable[MatcherIndex++];
2849 Opc |=
static_cast<uint16_t>(MatcherTable[MatcherIndex++]) << 8;
2850 return N->getOpcode() == Opc;
2857 if (
N.getValueType() == VT)
2867 if (ChildNo >=
N.getNumOperands())
2869 return ::CheckType(VT,
N.getOperand(ChildNo), TLI,
DL);
2875 return cast<CondCodeSDNode>(
N)->get() ==
2882 if (2 >=
N.getNumOperands())
2884 return ::CheckCondCode(MatcherTable, MatcherIndex,
N.getOperand(2));
2891 if (cast<VTSDNode>(
N)->getVT() == VT)
2895 return VT == MVT::iPTR && cast<VTSDNode>(
N)->getVT() == TLI->
getPointerTy(
DL);
2912 int64_t Val = MatcherTable[MatcherIndex++];
2914 Val =
GetVBR(Val, MatcherTable, MatcherIndex);
2919 return C &&
C->getAPIntValue().trySExtValue() == Val;
2925 if (ChildNo >=
N.getNumOperands())
2927 return ::CheckInteger(MatcherTable, MatcherIndex,
N.getOperand(ChildNo));
2933 int64_t Val = MatcherTable[MatcherIndex++];
2935 Val =
GetVBR(Val, MatcherTable, MatcherIndex);
2937 if (
N->getOpcode() !=
ISD::AND)
return false;
2946 int64_t Val = MatcherTable[MatcherIndex++];
2948 Val =
GetVBR(Val, MatcherTable, MatcherIndex);
2950 if (
N->getOpcode() !=
ISD::OR)
return false;
2967 unsigned Opcode = Table[
Index++];
3027 unsigned Res = Table[
Index++];
3114 unsigned NumRecordedNodes;
3117 unsigned NumMatchedMemRefs;
3120 SDValue InputChain, InputGlue;
3123 bool HasChainNodesMatched;
3140 :
SelectionDAG::DAGUpdateListener(DAG), NodeToMatch(NodeToMatch),
3141 RecordedNodes(
RN), MatchScopes(MS) {}
3149 if (!
E ||
E->isMachineOpcode())
3152 if (
N == *NodeToMatch)
3157 for (
auto &
I : RecordedNodes)
3158 if (
I.first.getNode() ==
N)
3161 for (
auto &
I : MatchScopes)
3162 for (
auto &J :
I.NodeStack)
3163 if (J.getNode() ==
N)
3171 const unsigned char *MatcherTable,
3172 unsigned TableSize) {
3211 Select_INLINEASM(NodeToMatch);
3214 Select_READ_REGISTER(NodeToMatch);
3217 Select_WRITE_REGISTER(NodeToMatch);
3220 Select_UNDEF(NodeToMatch);
3223 Select_FREEZE(NodeToMatch);
3226 Select_ARITH_FENCE(NodeToMatch);
3229 Select_MEMBARRIER(NodeToMatch);
3232 Select_STACKMAP(NodeToMatch);
3235 Select_PATCHPOINT(NodeToMatch);
3238 Select_JUMP_TABLE_DEBUG_INFO(NodeToMatch);
3241 Select_CONVERGENCECTRL_ANCHOR(NodeToMatch);
3244 Select_CONVERGENCECTRL_ENTRY(NodeToMatch);
3247 Select_CONVERGENCECTRL_LOOP(NodeToMatch);
3274 SDValue InputChain, InputGlue;
3288 unsigned MatcherIndex = 0;
3290 if (!OpcodeOffset.empty()) {
3292 if (
N.getOpcode() < OpcodeOffset.size())
3293 MatcherIndex = OpcodeOffset[
N.getOpcode()];
3294 LLVM_DEBUG(
dbgs() <<
" Initial Opcode index to " << MatcherIndex <<
"\n");
3303 unsigned CaseSize = MatcherTable[
Idx++];
3305 CaseSize =
GetVBR(CaseSize, MatcherTable,
Idx);
3306 if (CaseSize == 0)
break;
3310 Opc |=
static_cast<uint16_t>(MatcherTable[
Idx++]) << 8;
3311 if (Opc >= OpcodeOffset.size())
3312 OpcodeOffset.resize((Opc+1)*2);
3313 OpcodeOffset[Opc] =
Idx;
3318 if (
N.getOpcode() < OpcodeOffset.size())
3319 MatcherIndex = OpcodeOffset[
N.getOpcode()];
3323 assert(MatcherIndex < TableSize &&
"Invalid index");
3325 unsigned CurrentOpcodeIndex = MatcherIndex;
3339 unsigned NumToSkip = MatcherTable[MatcherIndex++];
3340 if (NumToSkip & 128)
3341 NumToSkip =
GetVBR(NumToSkip, MatcherTable, MatcherIndex);
3343 if (NumToSkip == 0) {
3348 FailIndex = MatcherIndex+NumToSkip;
3350 unsigned MatcherIndexOfPredicate = MatcherIndex;
3351 (void)MatcherIndexOfPredicate;
3358 Result, *
this, RecordedNodes);
3363 dbgs() <<
" Skipped scope entry (due to false predicate) at "
3364 <<
"index " << MatcherIndexOfPredicate <<
", continuing at "
3365 << FailIndex <<
"\n");
3366 ++NumDAGIselRetries;
3370 MatcherIndex = FailIndex;
3374 if (FailIndex == 0)
break;
3378 MatchScope NewEntry;
3379 NewEntry.FailIndex = FailIndex;
3380 NewEntry.NodeStack.append(NodeStack.
begin(), NodeStack.
end());
3381 NewEntry.NumRecordedNodes = RecordedNodes.
size();
3382 NewEntry.NumMatchedMemRefs = MatchedMemRefs.
size();
3383 NewEntry.InputChain = InputChain;
3384 NewEntry.InputGlue = InputGlue;
3385 NewEntry.HasChainNodesMatched = !ChainNodesMatched.
empty();
3391 SDNode *Parent =
nullptr;
3392 if (NodeStack.
size() > 1)
3393 Parent = NodeStack[NodeStack.
size()-2].getNode();
3394 RecordedNodes.
push_back(std::make_pair(
N, Parent));
3403 if (ChildNo >=
N.getNumOperands())
3406 RecordedNodes.
push_back(std::make_pair(
N->getOperand(ChildNo),
3411 if (
auto *MN = dyn_cast<MemSDNode>(
N))
3412 MatchedMemRefs.
push_back(MN->getMemOperand());
3422 if (
N->getNumOperands() != 0 &&
3423 N->getOperand(
N->getNumOperands()-1).getValueType() == MVT::Glue)
3424 InputGlue =
N->getOperand(
N->getNumOperands()-1);
3428 unsigned ChildNo = MatcherTable[MatcherIndex++];
3429 if (ChildNo >=
N.getNumOperands())
3431 N =
N.getOperand(ChildNo);
3441 if (ChildNo >=
N.getNumOperands())
3443 N =
N.getOperand(ChildNo);
3459 assert(!NodeStack.
empty() &&
"Node stack imbalance!");
3460 N = NodeStack.
back();
3463 ? MatcherTable[MatcherIndex++]
3465 if (SiblingNo >=
N.getNumOperands())
3467 N =
N.getOperand(SiblingNo);
3474 assert(!NodeStack.
empty() &&
"Node stack imbalance!");
3475 N = NodeStack.
back();
3479 if (!
::CheckSame(MatcherTable, MatcherIndex,
N, RecordedNodes))
break;
3516 unsigned OpNum = MatcherTable[MatcherIndex++];
3519 for (
unsigned i = 0; i < OpNum; ++i)
3520 Operands.push_back(RecordedNodes[MatcherTable[MatcherIndex++]].first);
3522 unsigned PredNo = MatcherTable[MatcherIndex++];
3537 ? MatcherTable[MatcherIndex++]
3539 unsigned RecNo = MatcherTable[MatcherIndex++];
3540 assert(RecNo < RecordedNodes.
size() &&
"Invalid CheckComplexPat");
3544 std::unique_ptr<MatchStateUpdater> MSU;
3546 MSU.reset(
new MatchStateUpdater(*
CurDAG, &NodeToMatch, RecordedNodes,
3550 RecordedNodes[RecNo].first, CPNum,
3556 if (!
::CheckOpcode(MatcherTable, MatcherIndex,
N.getNode()))
break;
3579 unsigned Res = MatcherTable[MatcherIndex++];
3587 unsigned CurNodeOpcode =
N.getOpcode();
3588 unsigned SwitchStart = MatcherIndex-1; (void)SwitchStart;
3592 CaseSize = MatcherTable[MatcherIndex++];
3594 CaseSize =
GetVBR(CaseSize, MatcherTable, MatcherIndex);
3595 if (CaseSize == 0)
break;
3597 uint16_t Opc = MatcherTable[MatcherIndex++];
3598 Opc |=
static_cast<uint16_t>(MatcherTable[MatcherIndex++]) << 8;
3601 if (CurNodeOpcode == Opc)
3605 MatcherIndex += CaseSize;
3609 if (CaseSize == 0)
break;
3612 LLVM_DEBUG(
dbgs() <<
" OpcodeSwitch from " << SwitchStart <<
" to "
3613 << MatcherIndex <<
"\n");
3618 MVT CurNodeVT =
N.getSimpleValueType();
3619 unsigned SwitchStart = MatcherIndex-1; (void)SwitchStart;
3623 CaseSize = MatcherTable[MatcherIndex++];
3625 CaseSize =
GetVBR(CaseSize, MatcherTable, MatcherIndex);
3626 if (CaseSize == 0)
break;
3629 if (CaseVT == MVT::iPTR)
3633 if (CurNodeVT == CaseVT)
3637 MatcherIndex += CaseSize;
3641 if (CaseSize == 0)
break;
3645 <<
"] from " << SwitchStart <<
" to " << MatcherIndex
3715 if (!
::CheckOrImm(MatcherTable, MatcherIndex,
N, *
this))
break;
3727 assert(NodeStack.
size() != 1 &&
"No parent node");
3730 bool HasMultipleUses =
false;
3731 for (
unsigned i = 1, e = NodeStack.
size()-1; i != e; ++i) {
3732 unsigned NNonChainUses = 0;
3733 SDNode *NS = NodeStack[i].getNode();
3735 if (UI.getUse().getValueType() != MVT::Other)
3736 if (++NNonChainUses > 1) {
3737 HasMultipleUses =
true;
3740 if (HasMultipleUses)
break;
3742 if (HasMultipleUses)
break;
3781 int64_t Val = MatcherTable[MatcherIndex++];
3783 Val =
GetVBR(Val, MatcherTable, MatcherIndex);
3786 RecordedNodes.
push_back(std::pair<SDValue, SDNode *>(
3805 unsigned RegNo = MatcherTable[MatcherIndex++];
3806 RecordedNodes.
push_back(std::pair<SDValue, SDNode *>(
3815 unsigned RegNo = MatcherTable[MatcherIndex++];
3816 RegNo |= MatcherTable[MatcherIndex++] << 8;
3817 RecordedNodes.
push_back(std::pair<SDValue, SDNode*>(
3833 ? MatcherTable[MatcherIndex++]
3835 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitConvertToTarget");
3836 SDValue Imm = RecordedNodes[RecNo].first;
3839 const ConstantInt *Val=cast<ConstantSDNode>(Imm)->getConstantIntValue();
3841 Imm.getValueType());
3843 const ConstantFP *Val=cast<ConstantFPSDNode>(Imm)->getConstantFPValue();
3845 Imm.getValueType());
3848 RecordedNodes.
push_back(std::make_pair(Imm, RecordedNodes[RecNo].second));
3857 "EmitMergeInputChains should be the first chain producing node");
3859 "Should only have one EmitMergeInputChains per match");
3863 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitMergeInputChains");
3864 ChainNodesMatched.
push_back(RecordedNodes[RecNo].first.getNode());
3870 if (ChainNodesMatched.
back() != NodeToMatch &&
3871 !RecordedNodes[RecNo].first.hasOneUse()) {
3872 ChainNodesMatched.
clear();
3886 "EmitMergeInputChains should be the first chain producing node");
3893 unsigned NumChains = MatcherTable[MatcherIndex++];
3894 assert(NumChains != 0 &&
"Can't TF zero chains");
3897 "Should only have one EmitMergeInputChains per match");
3900 for (
unsigned i = 0; i != NumChains; ++i) {
3901 unsigned RecNo = MatcherTable[MatcherIndex++];
3902 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitMergeInputChains");
3903 ChainNodesMatched.
push_back(RecordedNodes[RecNo].first.getNode());
3909 if (ChainNodesMatched.
back() != NodeToMatch &&
3910 !RecordedNodes[RecNo].first.hasOneUse()) {
3911 ChainNodesMatched.
clear();
3917 if (ChainNodesMatched.
empty())
3942 : MatcherTable[MatcherIndex++];
3943 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitCopyToReg");
3944 unsigned DestPhysReg = MatcherTable[MatcherIndex++];
3946 DestPhysReg |= MatcherTable[MatcherIndex++] << 8;
3952 DestPhysReg, RecordedNodes[RecNo].first,
3955 InputGlue = InputChain.
getValue(1);
3960 unsigned XFormNo = MatcherTable[MatcherIndex++];
3961 unsigned RecNo = MatcherTable[MatcherIndex++];
3962 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitNodeXForm");
3964 RecordedNodes.
push_back(std::pair<SDValue,SDNode*>(Res,
nullptr));
3970 unsigned index = MatcherTable[MatcherIndex++];
3971 index |= (MatcherTable[MatcherIndex++] << 8);
4003 uint16_t TargetOpc = MatcherTable[MatcherIndex++];
4004 TargetOpc |=
static_cast<uint16_t>(MatcherTable[MatcherIndex++]) << 8;
4005 unsigned EmitNodeInfo;
4024 EmitNodeInfo = MatcherTable[MatcherIndex++];
4049 NumVTs = MatcherTable[MatcherIndex++];
4051 for (
unsigned i = 0; i != NumVTs; ++i) {
4053 if (VT == MVT::iPTR)
4066 if (VTs.
size() == 1)
4068 else if (VTs.
size() == 2)
4074 unsigned NumOps = MatcherTable[MatcherIndex++];
4076 for (
unsigned i = 0; i != NumOps; ++i) {
4077 unsigned RecNo = MatcherTable[MatcherIndex++];
4079 RecNo =
GetVBR(RecNo, MatcherTable, MatcherIndex);
4081 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitNode");
4082 Ops.
push_back(RecordedNodes[RecNo].first);
4089 FirstOpToCopy += (EmitNodeInfo &
OPFL_Chain) ? 1 : 0;
4091 "Invalid variadic node");
4094 for (
unsigned i = FirstOpToCopy, e = NodeToMatch->
getNumOperands();
4097 if (V.getValueType() == MVT::Glue)
break;
4112 bool MayRaiseFPException =
4119 bool IsMorphNodeTo =
4122 if (!IsMorphNodeTo) {
4129 for (
unsigned i = 0, e = VTs.
size(); i != e; ++i) {
4130 if (VTs[i] == MVT::Other || VTs[i] == MVT::Glue)
break;
4136 "NodeToMatch was removed partway through selection");
4140 auto &Chain = ChainNodesMatched;
4142 "Chain node replaced during MorphNode");
4145 Res = cast<MachineSDNode>(MorphNode(NodeToMatch, TargetOpc, VTList,
4146 Ops, EmitNodeInfo));
4153 Flags.setNoFPExcept(
true);
4154 Res->setFlags(Flags);
4176 bool mayLoad = MCID.
mayLoad();
4183 if (MMO->isLoad()) {
4186 }
else if (MMO->isStore()) {
4198 <<
" Dropping mem operands\n";
4199 dbgs() <<
" " << (IsMorphNodeTo ?
"Morphed" :
"Created")
4204 if (IsMorphNodeTo) {
4206 UpdateChains(Res, InputChain, ChainNodesMatched,
true);
4216 unsigned NumResults = MatcherTable[MatcherIndex++];
4218 for (
unsigned i = 0; i != NumResults; ++i) {
4219 unsigned ResSlot = MatcherTable[MatcherIndex++];
4221 ResSlot =
GetVBR(ResSlot, MatcherTable, MatcherIndex);
4223 assert(ResSlot < RecordedNodes.
size() &&
"Invalid CompleteMatch");
4224 SDValue Res = RecordedNodes[ResSlot].first;
4226 assert(i < NodeToMatch->getNumValues() &&
4229 "Invalid number of results to complete!");
4235 "invalid replacement");
4240 UpdateChains(NodeToMatch, InputChain, ChainNodesMatched,
false);
4253 "Didn't replace all uses of the node?");
4263 LLVM_DEBUG(
dbgs() <<
" Match failed at index " << CurrentOpcodeIndex
4265 ++NumDAGIselRetries;
4267 if (MatchScopes.
empty()) {
4268 CannotYetSelect(NodeToMatch);
4274 MatchScope &LastScope = MatchScopes.
back();
4275 RecordedNodes.
resize(LastScope.NumRecordedNodes);
4277 NodeStack.
append(LastScope.NodeStack.begin(), LastScope.NodeStack.end());
4278 N = NodeStack.
back();
4280 if (LastScope.NumMatchedMemRefs != MatchedMemRefs.
size())
4281 MatchedMemRefs.
resize(LastScope.NumMatchedMemRefs);
4282 MatcherIndex = LastScope.FailIndex;
4286 InputChain = LastScope.InputChain;
4287 InputGlue = LastScope.InputGlue;
4288 if (!LastScope.HasChainNodesMatched)
4289 ChainNodesMatched.
clear();
4294 unsigned NumToSkip = MatcherTable[MatcherIndex++];
4295 if (NumToSkip & 128)
4296 NumToSkip =
GetVBR(NumToSkip, MatcherTable, MatcherIndex);
4300 if (NumToSkip != 0) {
4301 LastScope.FailIndex = MatcherIndex+NumToSkip;
4315 if (
N->isMachineOpcode()) {
4322 if (
N->isTargetOpcode())
4323 return N->isTargetStrictFPOpcode();
4324 return N->isStrictFPOpcode();
4329 auto *
C = dyn_cast<ConstantSDNode>(
N->getOperand(1));
4334 if (
auto *FN = dyn_cast<FrameIndexSDNode>(
N->getOperand(0))) {
4337 int32_t Off =
C->getSExtValue();
4340 return (Off >= 0) && (((
A.value() - 1) & Off) ==
unsigned(Off));
4345void SelectionDAGISel::CannotYetSelect(
SDNode *
N) {
4348 Msg <<
"Cannot select: ";
4354 Msg <<
"\nIn function: " <<
MF->
getName();
4356 bool HasInputChain =
N->getOperand(0).getValueType() == MVT::Other;
4357 unsigned iid =
N->getConstantOperandVal(HasInputChain);
4358 if (iid < Intrinsic::num_intrinsics)
4361 Msg <<
"target intrinsic %" <<
TII->
getName(iid);
4363 Msg <<
"unknown intrinsic #" << iid;
unsigned const MachineRegisterInfo * MRI
for(const MachineOperand &MO :llvm::drop_begin(OldMI.operands(), Desc.getNumOperands()))
MachineInstrBuilder & UseMI
amdgpu 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.
mir Rename Register Operands
Machine Instruction Scheduler
unsigned const TargetRegisterInfo * TRI
Module.h This file contains the declarations for the Module class.
uint64_t IntrinsicInst * II
FunctionAnalysisManager FAM
const char LLVMTargetMachineRef TM
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 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"))
static bool processIfEntryValueDbgDeclare(FunctionLoweringInfo &FuncInfo, const Value *Arg, DIExpression *Expr, DILocalVariable *Var, DebugLoc DbgLoc)
static cl::opt< bool > ViewSchedDAGs("view-sched-dags", cl::Hidden, cl::desc("Pop up a window to show sched dags as they are processed"))
static void processDbgDeclares(FunctionLoweringInfo &FuncInfo)
Collect llvm.dbg.declare information.
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckType(MVT::SimpleValueType VT, SDValue N, const TargetLowering *TLI, const DataLayout &DL)
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckCondCode(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N)
static bool hasExceptionPointerOrCodeUser(const CatchPadInst *CPI)
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckChild2CondCode(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N)
static cl::opt< bool > ViewLegalizeDAGs("view-legalize-dags", cl::Hidden, cl::desc("Pop up a window to show dags before legalize"))
static cl::opt< bool > ViewLegalizeTypesDAGs("view-legalize-types-dags", cl::Hidden, cl::desc("Pop up a window to show dags before legalize types"))
static SDNode * findGlueUse(SDNode *N)
findGlueUse - Return use of MVT::Glue value produced by the specified SDNode.
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckNodePredicate(unsigned Opcode, const unsigned char *MatcherTable, unsigned &MatcherIndex, const SelectionDAGISel &SDISel, SDNode *N)
CheckNodePredicate - Implements OP_CheckNodePredicate.
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 cl::opt< bool > EnableFastISelFallbackReport("fast-isel-report-on-fallback", cl::Hidden, cl::desc("Emit a diagnostic when \"fast\" instruction selection " "falls back to SelectionDAG."))
static bool processDbgDeclare(FunctionLoweringInfo &FuncInfo, const Value *Address, DIExpression *Expr, DILocalVariable *Var, DebugLoc DbgLoc)
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckOpcode(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDNode *N)
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckChildInteger(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N, unsigned ChildNo)
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"))
static SDValue HandleMergeInputChains(SmallVectorImpl< SDNode * > &ChainNodesMatched, SelectionDAG *CurDAG)
HandleMergeInputChains - This implements the OPC_EmitMergeInputChains operation for when the pattern ...
static bool isFoldedOrDeadInstruction(const Instruction *I, const FunctionLoweringInfo &FuncInfo)
isFoldedOrDeadInstruction - Return true if the specified instruction is side-effect free and is eithe...