80#include "llvm/IR/IntrinsicsWebAssembly.h"
116#define DEBUG_TYPE "isel"
117#define ISEL_DUMP_DEBUG_TYPE DEBUG_TYPE "-dump"
119STATISTIC(NumFastIselFailures,
"Number of instructions fast isel failed on");
120STATISTIC(NumFastIselSuccess,
"Number of instructions fast isel selected");
121STATISTIC(NumFastIselBlocks,
"Number of blocks selected entirely by fast isel");
122STATISTIC(NumDAGBlocks,
"Number of blocks selected using DAG");
123STATISTIC(NumDAGIselRetries,
"Number of times dag isel has to try another path");
124STATISTIC(NumEntryBlocks,
"Number of entry blocks encountered");
126 "Number of entry blocks where fast isel failed to lower arguments");
130 cl::desc(
"Enable abort calls when \"fast\" instruction selection "
131 "fails to lower an instruction: 0 disable the abort, 1 will "
132 "abort but for args, calls and terminators, 2 will also "
133 "abort for argument lowering, and 3 will never fallback "
134 "to SelectionDAG."));
138 cl::desc(
"Emit a diagnostic when \"fast\" instruction selection "
139 "falls back to SelectionDAG."));
143 cl::desc(
"use Machine Branch Probability Info"),
149 cl::desc(
"Print DAGs with sorted nodes in debug dump"),
154 cl::desc(
"Only display the basic block whose name "
155 "matches this for all view-*-dags options"));
158 cl::desc(
"Pop up a window to show dags before the first "
159 "dag combine pass"));
162 cl::desc(
"Pop up a window to show dags before legalize types"));
165 cl::desc(
"Pop up a window to show dags before the post "
166 "legalize types dag combine pass"));
169 cl::desc(
"Pop up a window to show dags before legalize"));
172 cl::desc(
"Pop up a window to show dags before the second "
173 "dag combine pass"));
176 cl::desc(
"Pop up a window to show isel dags as they are selected"));
179 cl::desc(
"Pop up a window to show sched dags as they are processed"));
182 cl::desc(
"Pop up a window to show SUnit dags after they are processed"));
191#define ISEL_DUMP(X) \
193 if (llvm::DebugFlag && \
194 (isCurrentDebugType(DEBUG_TYPE) || \
195 (isCurrentDebugType(ISEL_DUMP_DEBUG_TYPE) && MatchFilterFuncName))) { \
200#define ISEL_DUMP(X) do { } while (false)
220 cl::desc(
"Instruction schedulers available (before register"
233 return Arg.hasAttribute(Attribute::AttrKind::SwiftAsync);
263 SavedOptLevel = IS.OptLevel;
264 SavedFastISel = IS.TM.Options.EnableFastISel;
265 if (NewOptLevel != SavedOptLevel) {
266 IS.OptLevel = NewOptLevel;
267 IS.TM.setOptLevel(NewOptLevel);
268 LLVM_DEBUG(
dbgs() <<
"\nChanging optimization level for Function "
269 << IS.MF->getFunction().getName() <<
"\n");
270 LLVM_DEBUG(
dbgs() <<
"\tBefore: -O" <<
static_cast<int>(SavedOptLevel)
271 <<
" ; After: -O" <<
static_cast<int>(NewOptLevel)
274 IS.TM.setFastISel(IS.TM.getO0WantsFastISel());
277 IS.TM.setFastISel(
false);
279 dbgs() <<
"\tFastISel is "
280 << (IS.TM.Options.EnableFastISel ?
"enabled" :
"disabled")
285 if (IS.OptLevel == SavedOptLevel)
287 LLVM_DEBUG(
dbgs() <<
"\nRestoring optimization level for Function "
288 << IS.MF->getFunction().getName() <<
"\n");
289 LLVM_DEBUG(
dbgs() <<
"\tBefore: -O" <<
static_cast<int>(IS.OptLevel)
290 <<
" ; After: -O" <<
static_cast<int>(SavedOptLevel) <<
"\n");
291 IS.OptLevel = SavedOptLevel;
292 IS.TM.setOptLevel(SavedOptLevel);
293 IS.TM.setFastISel(SavedFastISel);
306 if (
auto *SchedulerCtor = ST.getDAGScheduler(OptLevel)) {
307 return SchedulerCtor(IS, OptLevel);
311 (ST.enableMachineScheduler() && ST.enableMachineSchedDefaultSched()) ||
325 "Unknown sched type!");
334 switch (
MI.getOpcode()) {
335 case TargetOpcode::STATEPOINT:
338 case TargetOpcode::STACKMAP:
339 case TargetOpcode::PATCHPOINT:
346 dbgs() <<
"If a target marks an instruction with "
347 "'usesCustomInserter', it must implement "
348 "TargetLowering::EmitInstrWithCustomInserter!\n";
356 "If a target marks an instruction with 'hasPostISelHook', "
357 "it must implement TargetLowering::AdjustInstrPostInstrSelection!");
365 char &
ID, std::unique_ptr<SelectionDAGISel> S)
396 : Selector->OptLevel;
400 Selector->initializeAnalysisResults(*
this);
401 return Selector->runOnMachineFunction(MF);
431 if (
UseMBPI && RegisterPGOPasses)
438 if (RegisterPGOPasses)
473 : Selector->OptLevel;
476 Selector->initializeAnalysisResults(MFAM);
477 Selector->runOnMachineFunction(MF);
503 ORE = std::make_unique<OptimizationRemarkEmitter>(&Fn);
508 if (PSI && PSI->hasProfileSummary() && RegisterPGOPasses)
521 if (!LibcallResult) {
523 "' analysis required");
535 if (
UseMBPI && RegisterPGOPasses)
571 ORE = std::make_unique<OptimizationRemarkEmitter>(&Fn);
575 if (PSI && PSI->hasProfileSummary() && RegisterPGOPasses)
584 UA = &UAPass->getUniformityInfo();
601 if (
UseMBPI && RegisterPGOPasses)
631 MF->setHasInlineAsm(
false);
658 TLI->initializeSplitCSR(EntryMBB);
660 SelectAllBasicBlocks(Fn);
688 MRI.constrainRegClass(To,
MRI.getRegClass(From));
694 if (!
MRI.use_empty(To))
695 MRI.clearKillFlags(From);
696 MRI.replaceRegWith(From, To);
710 if (!
MBB.succ_empty())
714 if (Term !=
MBB.end() && Term->isReturn()) {
719 TLI->insertCopiesSplitCSR(EntryMBB, Returns);
723 if (!
FuncInfo->ArgDbgValues.empty())
724 for (std::pair<MCRegister, Register> LI :
RegInfo->liveins())
729 for (
unsigned i = 0, e =
FuncInfo->ArgDbgValues.size(); i != e; ++i) {
731 assert(
MI->getOpcode() != TargetOpcode::DBG_VALUE_LIST &&
732 "Function parameters should not be described by DBG_VALUE_LIST.");
733 bool hasFI =
MI->getDebugOperand(0).isFI();
735 hasFI ?
TRI.getFrameRegister(*
MF) :
MI->getDebugOperand(0).getReg();
736 if (Reg.isPhysical())
743 Def->getParent()->insert(std::next(InsertPos),
MI);
754 if (!Reg.isPhysical())
757 if (LDI != LiveInMap.
end()) {
758 assert(!hasFI &&
"There's no handling of frame pointer updating here yet "
762 const MDNode *Variable =
MI->getDebugVariable();
763 const MDNode *Expr =
MI->getDebugExpression();
765 bool IsIndirect =
MI->isIndirectDebugValue();
767 assert(
MI->getDebugOffset().getImm() == 0 &&
768 "DBG_VALUE with nonzero offset");
770 "Expected inlined-at fields to agree");
771 assert(
MI->getOpcode() != TargetOpcode::DBG_VALUE_LIST &&
772 "Didn't expect to see a DBG_VALUE_LIST here");
774 BuildMI(*EntryMBB, ++InsertPos,
DL,
TII->get(TargetOpcode::DBG_VALUE),
775 IsIndirect, LDI->second, Variable, Expr);
782 if (
UseMI.isDebugValue())
784 if (
UseMI.isCopy() && !CopyUseMI &&
UseMI.getParent() == EntryMBB) {
793 TRI.getRegSizeInBits(LDI->second,
MRI) ==
808 if (
MF->useDebugInstrRef())
809 MF->finalizeDebugInstrRefs();
813 for (
const auto &
MBB : *
MF) {
817 for (
const auto &
MI :
MBB) {
819 if ((
MCID.isCall() && !
MCID.isReturn()) ||
820 MI.isStackAligningInlineAsm()) {
823 if (
MI.isInlineAsm()) {
824 MF->setHasInlineAsm(
true);
833 ISEL_DUMP(
dbgs() <<
"*** MachineFunction at end of ISel ***\n");
845 if (!R.getLocation().isValid() || ShouldAbort)
846 R << (
" (in function: " + MF.
getName() +
")").str();
864 bool HaveFakeUse =
false;
865 bool HaveTailCall =
false;
868 if (CI->isTailCall()) {
873 if (
II->getIntrinsicID() == Intrinsic::fake_use)
875 }
while (
I != Begin);
878 if (!HaveTailCall || !HaveFakeUse)
887 FakeUse && FakeUse->getIntrinsicID() == Intrinsic::fake_use) {
889 !UsedDef || UsedDef->getParent() !=
I->getParent() ||
890 UsedDef->comesBefore(&*
I))
895 for (
auto *Inst : FakeUses)
896 Inst->moveBefore(*Inst->getParent(),
I);
903 CurDAG->NewNodesMustHaveLegalTypes =
false;
912 SDB->visitDbgInfo(*
I);
917 HadTailCall =
SDB->HasTailCall;
918 SDB->resolveOrClearDbgInfo();
925void SelectionDAGISel::ComputeLiveOutVRegInfo() {
926 SmallPtrSet<SDNode *, 16>
Added;
939 if (
Op.getValueType() == MVT::Other &&
Added.insert(
Op.getNode()).second)
952 EVT SrcVT = Src.getValueType();
956 unsigned NumSignBits =
CurDAG->ComputeNumSignBits(Src);
957 Known =
CurDAG->computeKnownBits(Src);
958 FuncInfo->AddLiveOutRegInfo(DestReg, NumSignBits, Known);
959 }
while (!Worklist.
empty());
962void SelectionDAGISel::CodeGenAndEmitDAG() {
963 StringRef GroupName =
"sdag";
964 StringRef GroupDescription =
"Instruction Selection and Scheduling";
965 std::string BlockName;
966 bool MatchFilterBB =
false;
970 CurDAG->NewNodesMustHaveLegalTypes =
false;
975 FuncInfo->MBB->getBasicBlock()->getName());
984 (
MF->getName() +
":" +
FuncInfo->MBB->getBasicBlock()->getName()).str();
991#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
992 if (
TTI->hasBranchDivergence())
993 CurDAG->VerifyDAGDivergence();
997 CurDAG->viewGraph(
"dag-combine1 input for " + BlockName);
1001 NamedRegionTimer
T(
"combine1",
"DAG Combining 1", GroupName,
1011#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
1012 if (
TTI->hasBranchDivergence())
1013 CurDAG->VerifyDAGDivergence();
1019 CurDAG->viewGraph(
"legalize-types input for " + BlockName);
1023 NamedRegionTimer
T(
"legalize_types",
"Type Legalization", GroupName,
1033#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
1034 if (
TTI->hasBranchDivergence())
1035 CurDAG->VerifyDAGDivergence();
1039 CurDAG->NewNodesMustHaveLegalTypes =
true;
1043 CurDAG->viewGraph(
"dag-combine-lt input for " + BlockName);
1047 NamedRegionTimer
T(
"combine_lt",
"DAG Combining after legalize types",
1052 ISEL_DUMP(
dbgs() <<
"\nOptimized type-legalized selection DAG: "
1057#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
1058 if (
TTI->hasBranchDivergence())
1059 CurDAG->VerifyDAGDivergence();
1064 NamedRegionTimer
T(
"legalize_vec",
"Vector Legalization", GroupName,
1075#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
1076 if (
TTI->hasBranchDivergence())
1077 CurDAG->VerifyDAGDivergence();
1081 NamedRegionTimer
T(
"legalize_types2",
"Type Legalization 2", GroupName,
1086 ISEL_DUMP(
dbgs() <<
"\nVector/type-legalized selection DAG: "
1091#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
1092 if (
TTI->hasBranchDivergence())
1093 CurDAG->VerifyDAGDivergence();
1097 CurDAG->viewGraph(
"dag-combine-lv input for " + BlockName);
1101 NamedRegionTimer
T(
"combine_lv",
"DAG Combining after legalize vectors",
1106 ISEL_DUMP(
dbgs() <<
"\nOptimized vector-legalized selection DAG: "
1111#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
1112 if (
TTI->hasBranchDivergence())
1113 CurDAG->VerifyDAGDivergence();
1118 CurDAG->viewGraph(
"legalize input for " + BlockName);
1121 NamedRegionTimer
T(
"legalize",
"DAG Legalization", GroupName,
1131#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
1132 if (
TTI->hasBranchDivergence())
1133 CurDAG->VerifyDAGDivergence();
1137 CurDAG->viewGraph(
"dag-combine2 input for " + BlockName);
1141 NamedRegionTimer
T(
"combine2",
"DAG Combining 2", GroupName,
1151#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
1152 if (
TTI->hasBranchDivergence())
1153 CurDAG->VerifyDAGDivergence();
1157 ComputeLiveOutVRegInfo();
1160 CurDAG->viewGraph(
"isel input for " + BlockName);
1165 NamedRegionTimer
T(
"isel",
"Instruction Selection", GroupName,
1167 DoInstructionSelection();
1176 CurDAG->viewGraph(
"scheduler input for " + BlockName);
1179 ScheduleDAGSDNodes *
Scheduler = CreateScheduler();
1181 NamedRegionTimer
T(
"sched",
"Instruction Scheduling", GroupName,
1191 MachineBasicBlock *FirstMBB =
FuncInfo->MBB, *LastMBB;
1193 NamedRegionTimer
T(
"emit",
"Instruction Creation", GroupName,
1203 if (FirstMBB != LastMBB)
1204 SDB->UpdateSplitBlock(FirstMBB, LastMBB);
1208 NamedRegionTimer
T(
"cleanup",
"Instruction Scheduling Cleanup", GroupName,
1226 : SelectionDAG::DAGUpdateListener(DAG), ISelPosition(isp) {}
1231 void NodeDeleted(SDNode *
N, SDNode *
E)
override {
1239 void NodeInserted(SDNode *
N)
override {
1240 SDNode *CurNode = &*ISelPosition;
1241 if (MDNode *MD = DAG.getPCSections(CurNode))
1242 DAG.addPCSections(
N, MD);
1243 if (MDNode *MMRA = DAG.getMMRAMetadata(CurNode))
1244 DAG.addMMRAMetadata(
N, MMRA);
1274 while (!Nodes.
empty()) {
1276 for (
auto *U :
N->users()) {
1277 auto UId = U->getNodeId();
1290 int InvalidId = -(
N->getNodeId() + 1);
1291 N->setNodeId(InvalidId);
1296 int Id =
N->getNodeId();
1302void SelectionDAGISel::DoInstructionSelection() {
1305 <<
FuncInfo->MBB->getName() <<
"'\n");
1323 ISelUpdater ISU(*
CurDAG, ISelPosition);
1334 if (
Node->use_empty())
1341 while (!Nodes.
empty()) {
1358 "Node has already selected predecessor node");
1370 if (!
TLI->isStrictFPEnabled() &&
Node->isStrictFPOpcode()) {
1375 switch (
Node->getOpcode()) {
1384 ActionVT =
Node->getOperand(1).getValueType();
1387 ActionVT =
Node->getValueType(0);
1390 if (
TLI->getOperationAction(
Node->getOpcode(), ActionVT)
1395 LLVM_DEBUG(
dbgs() <<
"\nISEL: Starting selection on root node: ";
1401 CurDAG->setRoot(Dummy.getValue());
1413 if (IID == Intrinsic::eh_exceptionpointer ||
1414 IID == Intrinsic::eh_exceptioncode)
1429 bool IsSingleCatchAllClause =
1434 bool IsCatchLongjmp = CPI->
arg_size() == 0;
1435 if (!IsSingleCatchAllClause && !IsCatchLongjmp) {
1437 bool IntrFound =
false;
1441 if (IID == Intrinsic::wasm_landingpad_index) {
1442 Value *IndexArg =
Call->getArgOperand(1);
1450 assert(IntrFound &&
"wasm.landingpad.index intrinsic not found!");
1457bool SelectionDAGISel::PrepareEHLandingPad() {
1461 const TargetRegisterClass *PtrRC =
1462 TLI->getRegClassFor(
TLI->getPointerTy(
CurDAG->getDataLayout()));
1473 MCRegister EHPhysReg =
TLI->getExceptionPointerRegister(PersonalityFn);
1474 assert(EHPhysReg &&
"target lacks exception pointer register");
1478 TII->get(TargetOpcode::COPY), VReg)
1489 const MCInstrDesc &
II =
TII->get(TargetOpcode::EH_LABEL);
1495 const TargetRegisterInfo &
TRI = *
MF->getSubtarget().getRegisterInfo();
1496 if (
auto *RegMask =
TRI.getCustomEHPadPreservedMask(*
MF))
1497 MF->getRegInfo().addPhysRegsUsedFromRegMask(RegMask);
1504 MF->setCallSiteLandingPad(Label,
SDB->LPadToCallSiteMap[
MBB]);
1506 if (MCRegister
Reg =
TLI->getExceptionPointerRegister(PersonalityFn))
1509 if (MCRegister
Reg =
TLI->getExceptionSelectorRegister(PersonalityFn))
1518 llvm::WinEHFuncInfo *EHInfo =
MF->getWinEHFuncInfo();
1521 for (MachineBasicBlock &
MBB : *
MF) {
1531 MachineInstr *MIb = &*MBBb;
1536 MCSymbol *BeginLabel =
MF->getContext().createTempSymbol();
1537 MCSymbol *EndLabel =
MF->getContext().createTempSymbol();
1540 TII->get(TargetOpcode::EH_LABEL))
1543 MachineInstr *MIe = &*(--MBBe);
1549 TII->get(TargetOpcode::EH_LABEL))
1560 return !
I->mayWriteToMemory() &&
1561 !
I->isTerminator() &&
1573 auto ArgIt = FuncInfo.
ValueMap.find(Arg);
1574 if (ArgIt == FuncInfo.
ValueMap.end())
1576 Register ArgVReg = ArgIt->getSecond();
1580 if (VirtReg == ArgVReg) {
1584 LLVM_DEBUG(
dbgs() <<
"processDbgDeclare: setVariableDbgInfo Var=" << *Var
1585 <<
", Expr=" << *Expr <<
", MCRegister=" << PhysReg
1586 <<
", DbgLoc=" << DbgLoc <<
"\n");
1597 <<
" (bad address)\n");
1604 if (!Address->getType()->isPointerTy())
1610 assert(Var &&
"Missing variable");
1611 assert(DbgLoc &&
"Missing location");
1615 APInt Offset(
DL.getIndexTypeSizeInBits(Address->getType()), 0);
1616 Address = Address->stripAndAccumulateInBoundsConstantOffsets(
DL,
Offset);
1621 int FI = std::numeric_limits<int>::max();
1629 if (FI == std::numeric_limits<int>::max())
1632 if (
Offset.getBoolValue())
1636 LLVM_DEBUG(
dbgs() <<
"processDbgDeclare: setVariableDbgInfo Var=" << *Var
1637 <<
", Expr=" << *Expr <<
", FI=" << FI
1638 <<
", DbgLoc=" << DbgLoc <<
"\n");
1650 DVR.getExpression(), DVR.getVariable(),
1665 assert(!It->Values.hasArgList() &&
"Single loc variadic ops not supported");
1671void SelectionDAGISel::SelectAllBasicBlocks(
const Function &Fn) {
1674 FastISel *FastIS =
nullptr;
1675 if (
TM.Options.EnableFastISel) {
1680 ReversePostOrderTraversal<const Function*> RPOT(&Fn);
1701 ++NumFastIselFailLowerArguments;
1703 OptimizationRemarkMissed
R(
"sdagisel",
"FastISelFailure",
1706 R <<
"FastISel didn't lower all arguments: "
1714 CodeGenAndEmitDAG();
1728 if (FastIS && Inserted)
1733 "expected AssignmentTrackingAnalysis pass results");
1741 for (
const BasicBlock *LLVMBB : RPOT) {
1743 bool AllPredsVisited =
true;
1745 if (!
FuncInfo->VisitedBBs[Pred->getNumber()]) {
1746 AllPredsVisited =
false;
1751 if (AllPredsVisited) {
1752 for (
const PHINode &PN : LLVMBB->
phis())
1753 FuncInfo->ComputePHILiveOutRegInfo(&PN);
1755 for (
const PHINode &PN : LLVMBB->
phis())
1756 FuncInfo->InvalidatePHILiveOutRegInfo(&PN);
1767 const_cast<BasicBlock *
>(LLVMBB)->getFirstNonPHIIt();
1787 if (!PrepareEHLandingPad())
1793 if (NewRoot && NewRoot !=
CurDAG->getRoot())
1794 CurDAG->setRoot(NewRoot);
1803 unsigned NumFastIselRemaining = std::distance(Begin, End);
1809 for (; BI != Begin; --BI) {
1815 --NumFastIselRemaining;
1826 --NumFastIselRemaining;
1827 ++NumFastIselSuccess;
1834 while (BeforeInst != &*Begin) {
1844 <<
"FastISel folded load: " << *BeforeInst <<
"\n");
1847 --NumFastIselRemaining;
1848 ++NumFastIselSuccess;
1862 OptimizationRemarkMissed
R(
"sdagisel",
"FastISelFailure",
1865 R <<
"FastISel missed call";
1868 std::string InstStrStorage;
1869 raw_string_ostream InstStr(InstStrStorage);
1872 R <<
": " << InstStrStorage;
1881 NumFastIselFailures += NumFastIselRemaining;
1892 bool HadTailCall =
false;
1894 SelectBasicBlock(Inst->
getIterator(), BI, HadTailCall);
1906 unsigned RemainingNow = std::distance(Begin, BI);
1907 NumFastIselFailures += NumFastIselRemaining - RemainingNow;
1908 NumFastIselRemaining = RemainingNow;
1912 OptimizationRemarkMissed
R(
"sdagisel",
"FastISelFailure",
1918 R <<
"FastISel missed terminator";
1922 R <<
"FastISel missed";
1926 std::string InstStrStorage;
1927 raw_string_ostream InstStr(InstStrStorage);
1929 R <<
": " << InstStrStorage;
1934 NumFastIselFailures += NumFastIselRemaining;
1941 if (
SP->shouldEmitSDCheck(*LLVMBB)) {
1942 bool FunctionBasedInstrumentation =
1945 SDB->SPDescriptor.initialize(LLVMBB,
FuncInfo->getMBB(LLVMBB),
1946 FunctionBasedInstrumentation);
1952 ++NumFastIselBlocks;
1959 SelectBasicBlock(Begin, BI, HadTailCall);
1971 FuncInfo->PHINodesToUpdate.clear();
1977 reportIPToStateForBlocks(
MF);
1979 SP->copyToMachineFrameInfo(
MF->getFrameInfo());
1984 SDB->clearDanglingDebugInfo();
1985 SDB->SPDescriptor.resetPerFunctionState();
1989SelectionDAGISel::FinishBasicBlock() {
1991 <<
FuncInfo->PHINodesToUpdate.size() <<
"\n";
1992 for (
unsigned i = 0, e =
FuncInfo->PHINodesToUpdate.size(); i != e;
1994 <<
"Node " << i <<
" : (" <<
FuncInfo->PHINodesToUpdate[i].first
2000 for (
unsigned i = 0, e =
FuncInfo->PHINodesToUpdate.size(); i != e; ++i) {
2001 MachineInstrBuilder
PHI(*
MF,
FuncInfo->PHINodesToUpdate[i].first);
2003 "This is not a machine PHI node that we are updating!");
2004 if (!
FuncInfo->MBB->isSuccessor(
PHI->getParent()))
2010 if (
SDB->SPDescriptor.shouldEmitFunctionBasedCheckStackProtector()) {
2013 MachineBasicBlock *ParentMBB =
SDB->SPDescriptor.getParentMBB();
2018 SDB->visitSPDescriptorParent(
SDB->SPDescriptor, ParentMBB);
2021 CodeGenAndEmitDAG();
2024 SDB->SPDescriptor.resetPerBBState();
2025 }
else if (
SDB->SPDescriptor.shouldEmitStackProtector()) {
2026 MachineBasicBlock *ParentMBB =
SDB->SPDescriptor.getParentMBB();
2027 MachineBasicBlock *SuccessMBB =
SDB->SPDescriptor.getSuccessMBB();
2039 SuccessMBB->
splice(SuccessMBB->
end(), ParentMBB, SplitPoint,
2045 SDB->visitSPDescriptorParent(
SDB->SPDescriptor, ParentMBB);
2048 CodeGenAndEmitDAG();
2051 MachineBasicBlock *FailureMBB =
SDB->SPDescriptor.getFailureMBB();
2052 if (FailureMBB->
empty()) {
2055 SDB->visitSPDescriptorFailure(
SDB->SPDescriptor);
2058 CodeGenAndEmitDAG();
2062 SDB->SPDescriptor.resetPerBBState();
2066 for (
auto &BTB :
SDB->SL->BitTestCases) {
2076 CodeGenAndEmitDAG();
2079 BranchProbability UnhandledProb = BTB.Prob;
2080 for (
unsigned j = 0, ej = BTB.Cases.size(); j != ej; ++j) {
2081 UnhandledProb -= BTB.Cases[
j].ExtraProb;
2095 MachineBasicBlock *NextMBB;
2096 if ((BTB.ContiguousRange || BTB.FallthroughUnreachable) && j + 2 == ej) {
2099 NextMBB = BTB.Cases[
j + 1].TargetBB;
2100 }
else if (j + 1 == ej) {
2102 NextMBB = BTB.Default;
2105 NextMBB = BTB.Cases[
j + 1].ThisBB;
2108 SDB->visitBitTestCase(BTB, NextMBB, UnhandledProb, BTB.Reg, BTB.Cases[j],
2113 CodeGenAndEmitDAG();
2115 if ((BTB.ContiguousRange || BTB.FallthroughUnreachable) && j + 2 == ej) {
2117 BTB.Cases.pop_back();
2123 for (
const std::pair<MachineInstr *, Register> &
P :
2125 MachineInstrBuilder
PHI(*
MF,
P.first);
2126 MachineBasicBlock *PHIBB =
PHI->getParent();
2128 "This is not a machine PHI node that we are updating!");
2131 if (PHIBB == BTB.Default) {
2132 PHI.addReg(
P.second).addMBB(BTB.Parent);
2133 if (!BTB.ContiguousRange) {
2134 PHI.addReg(
P.second).addMBB(BTB.Cases.back().ThisBB);
2138 for (
const SwitchCG::BitTestCase &
BT : BTB.Cases) {
2139 MachineBasicBlock* cBB =
BT.ThisBB;
2141 PHI.addReg(
P.second).addMBB(cBB);
2145 SDB->SL->BitTestCases.clear();
2150 for (
unsigned i = 0, e =
SDB->SL->JTCases.size(); i != e; ++i) {
2152 if (!
SDB->SL->JTCases[i].first.Emitted) {
2154 FuncInfo->MBB =
SDB->SL->JTCases[i].first.HeaderBB;
2157 SDB->visitJumpTableHeader(
SDB->SL->JTCases[i].second,
2161 CodeGenAndEmitDAG();
2168 SDB->visitJumpTable(
SDB->SL->JTCases[i].second);
2171 CodeGenAndEmitDAG();
2174 for (
unsigned pi = 0, pe =
FuncInfo->PHINodesToUpdate.size();
2176 MachineInstrBuilder
PHI(*
MF,
FuncInfo->PHINodesToUpdate[pi].first);
2179 "This is not a machine PHI node that we are updating!");
2181 if (PHIBB ==
SDB->SL->JTCases[i].second.Default)
2183 .addMBB(
SDB->SL->JTCases[i].first.HeaderBB);
2185 if (
FuncInfo->MBB->isSuccessor(PHIBB))
2189 SDB->SL->JTCases.clear();
2193 for (
unsigned i = 0, e =
SDB->SL->SwitchCases.size(); i != e; ++i) {
2201 if (
SDB->SL->SwitchCases[i].TrueBB !=
SDB->SL->SwitchCases[i].FalseBB)
2208 CodeGenAndEmitDAG();
2212 MachineBasicBlock *ThisBB =
FuncInfo->MBB;
2218 for (MachineBasicBlock *Succ : Succs) {
2229 for (
unsigned pn = 0; ; ++pn) {
2231 "Didn't find PHI entry!");
2232 if (
FuncInfo->PHINodesToUpdate[pn].first ==
PHI) {
2233 PHI.addReg(
FuncInfo->PHINodesToUpdate[pn].second).addMBB(ThisBB);
2241 SDB->SL->SwitchCases.clear();
2262 int64_t DesiredMaskS)
const {
2263 const APInt &ActualMask = RHS->getAPIntValue();
2266 const APInt &DesiredMask =
APInt(LHS.getValueSizeInBits(), DesiredMaskS,
2270 if (ActualMask == DesiredMask)
2279 APInt NeededMask = DesiredMask & ~ActualMask;
2280 if (
CurDAG->MaskedValueIsZero(LHS, NeededMask))
2294 int64_t DesiredMaskS)
const {
2295 const APInt &ActualMask = RHS->getAPIntValue();
2298 const APInt &DesiredMask =
APInt(LHS.getValueSizeInBits(), DesiredMaskS,
2302 if (ActualMask == DesiredMask)
2311 APInt NeededMask = DesiredMask & ~ActualMask;
2331 std::list<HandleSDNode> Handles;
2336 Handles.emplace_back(
2345 if (!Flags.isMemKind() && !Flags.isFuncKind()) {
2347 Handles.insert(Handles.end(),
Ops.begin() + i,
2348 Ops.begin() + i + Flags.getNumOperandRegisters() + 1);
2349 i += Flags.getNumOperandRegisters() + 1;
2351 assert(Flags.getNumOperandRegisters() == 1 &&
2352 "Memory operand with multiple values?");
2354 unsigned TiedToOperand;
2355 if (Flags.isUseOperandTiedToDef(TiedToOperand)) {
2359 for (; TiedToOperand; --TiedToOperand) {
2360 CurOp += Flags.getNumOperandRegisters() + 1;
2366 std::vector<SDValue> SelOps;
2368 Flags.getMemoryConstraintID();
2377 Flags.setMemConstraint(ConstraintID);
2378 Handles.emplace_back(
CurDAG->getTargetConstant(Flags,
DL, MVT::i32));
2385 if (e !=
Ops.size())
2386 Handles.emplace_back(
Ops.back());
2389 for (
auto &handle : Handles)
2390 Ops.push_back(handle.getValue());
2396 bool IgnoreChains) {
2405 Visited.
insert(ImmedUse);
2410 if ((
Op.getValueType() == MVT::Other && IgnoreChains) ||
N == Def)
2412 if (!Visited.
insert(
N).second)
2418 if (Root != ImmedUse) {
2422 if ((
Op.getValueType() == MVT::Other && IgnoreChains) ||
N == Def)
2424 if (!Visited.
insert(
N).second)
2439 return N.hasOneUse();
2446 bool IgnoreChains) {
2495 while (VT == MVT::Glue) {
2506 IgnoreChains =
false;
2512void SelectionDAGISel::Select_INLINEASM(
SDNode *
N) {
2515 std::vector<SDValue>
Ops(
N->op_begin(),
N->op_end());
2518 const EVT VTs[] = {MVT::Other, MVT::Glue};
2525void SelectionDAGISel::Select_READ_REGISTER(
SDNode *
Op) {
2530 EVT VT =
Op->getValueType(0);
2533 const MachineFunction &
MF =
CurDAG->getMachineFunction();
2541 "\" for llvm.read_register",
2542 Fn,
Op->getDebugLoc()));
2544 SDValue(
CurDAG->getMachineNode(TargetOpcode::IMPLICIT_DEF, dl, VT), 0);
2548 CurDAG->getCopyFromReg(
Op->getOperand(0), dl,
Reg,
Op->getValueType(0));
2556void SelectionDAGISel::Select_WRITE_REGISTER(
SDNode *
Op) {
2561 EVT VT =
Op->getOperand(2).getValueType();
2564 const MachineFunction &
MF =
CurDAG->getMachineFunction();
2571 "\" for llvm.write_register",
2572 Fn,
Op->getDebugLoc()));
2576 CurDAG->getCopyToReg(
Op->getOperand(0), dl,
Reg,
Op->getOperand(2));
2584void SelectionDAGISel::Select_UNDEF(
SDNode *
N) {
2585 CurDAG->SelectNodeTo(
N, TargetOpcode::IMPLICIT_DEF,
N->getValueType(0));
2590void SelectionDAGISel::Select_FAKE_USE(
SDNode *
N) {
2591 CurDAG->SelectNodeTo(
N, TargetOpcode::FAKE_USE,
N->getValueType(0),
2592 N->getOperand(1),
N->getOperand(0));
2595void SelectionDAGISel::Select_RELOC_NONE(
SDNode *
N) {
2596 CurDAG->SelectNodeTo(
N, TargetOpcode::RELOC_NONE,
N->getValueType(0),
2597 N->getOperand(1),
N->getOperand(0));
2600void SelectionDAGISel::Select_FREEZE(
SDNode *
N) {
2604 CurDAG->SelectNodeTo(
N, TargetOpcode::COPY,
N->getValueType(0),
2608void SelectionDAGISel::Select_ARITH_FENCE(
SDNode *
N) {
2609 CurDAG->SelectNodeTo(
N, TargetOpcode::ARITH_FENCE,
N->getValueType(0),
2613void SelectionDAGISel::Select_MEMBARRIER(
SDNode *
N) {
2614 CurDAG->SelectNodeTo(
N, TargetOpcode::MEMBARRIER,
N->getValueType(0),
2618void SelectionDAGISel::Select_CONVERGENCECTRL_ANCHOR(
SDNode *
N) {
2619 CurDAG->SelectNodeTo(
N, TargetOpcode::CONVERGENCECTRL_ANCHOR,
2620 N->getValueType(0));
2623void SelectionDAGISel::Select_CONVERGENCECTRL_ENTRY(
SDNode *
N) {
2624 CurDAG->SelectNodeTo(
N, TargetOpcode::CONVERGENCECTRL_ENTRY,
2625 N->getValueType(0));
2628void SelectionDAGISel::Select_CONVERGENCECTRL_LOOP(
SDNode *
N) {
2629 CurDAG->SelectNodeTo(
N, TargetOpcode::CONVERGENCECTRL_LOOP,
2630 N->getValueType(0),
N->getOperand(0));
2635 SDNode *OpNode = OpVal.
getNode();
2643 CurDAG->getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
2647 Ops.push_back(OpVal);
2651void SelectionDAGISel::Select_STACKMAP(
SDNode *
N) {
2653 auto *It =
N->op_begin();
2662 assert(
ID.getValueType() == MVT::i64);
2668 Ops.push_back(Shad);
2671 for (; It !=
N->op_end(); It++)
2672 pushStackMapLiveVariable(
Ops, *It,
DL);
2674 Ops.push_back(Chain);
2675 Ops.push_back(InGlue);
2677 SDVTList NodeTys =
CurDAG->getVTList(MVT::Other, MVT::Glue);
2678 CurDAG->SelectNodeTo(
N, TargetOpcode::STACKMAP, NodeTys,
Ops);
2681void SelectionDAGISel::Select_PATCHPOINT(
SDNode *
N) {
2683 auto *It =
N->op_begin();
2688 std::optional<SDValue> Glue;
2689 if (It->getValueType() == MVT::Glue)
2695 assert(
ID.getValueType() == MVT::i64);
2701 Ops.push_back(Shad);
2704 Ops.push_back(*It++);
2709 Ops.push_back(NumArgs);
2712 Ops.push_back(*It++);
2716 Ops.push_back(*It++);
2719 for (; It !=
N->op_end(); It++)
2720 pushStackMapLiveVariable(
Ops, *It,
DL);
2723 Ops.push_back(RegMask);
2724 Ops.push_back(Chain);
2725 if (Glue.has_value())
2726 Ops.push_back(*Glue);
2728 SDVTList NodeTys =
N->getVTList();
2729 CurDAG->SelectNodeTo(
N, TargetOpcode::PATCHPOINT, NodeTys,
Ops);
2735 assert(Val >= 128 &&
"Not a VBR");
2741 NextBits = MatcherTable[Idx++];
2742 Val |= (NextBits&127) << Shift;
2744 }
while (NextBits & 128);
2755 NextBits = MatcherTable[Idx++];
2756 Val |= (NextBits & 127) << Shift;
2758 }
while (NextBits & 128);
2760 if (Shift < 64 && (NextBits & 0x40))
2770 unsigned SimpleVT = MatcherTable[MatcherIndex++];
2772 SimpleVT =
GetVBR(SimpleVT, MatcherTable, MatcherIndex);
2781 unsigned Index = MatcherTable[MatcherIndex++];
2785void SelectionDAGISel::Select_JUMP_TABLE_DEBUG_INFO(
SDNode *
N) {
2787 CurDAG->SelectNodeTo(
N, TargetOpcode::JUMP_TABLE_DEBUG_INFO, MVT::Glue,
2788 CurDAG->getTargetConstant(
N->getConstantOperandVal(1),
2789 dl, MVT::i64,
true));
2794void SelectionDAGISel::UpdateChains(
2801 if (!ChainNodesMatched.
empty()) {
2803 "Matched input chains but didn't produce a chain");
2806 for (
unsigned i = 0, e = ChainNodesMatched.
size(); i != e; ++i) {
2807 SDNode *ChainNode = ChainNodesMatched[i];
2814 "Deleted node left in chain");
2818 if (ChainNode == NodeToMatch && isMorphNodeTo)
2825 SelectionDAG::DAGNodeDeletedListener NDL(
2826 *
CurDAG, [&](SDNode *
N, SDNode *
E) {
2827 llvm::replace(ChainNodesMatched,
N,
static_cast<SDNode *
>(
nullptr));
2833 if (ChainNode != NodeToMatch && ChainNode->
use_empty() &&
2839 if (!NowDeadNodes.
empty())
2840 CurDAG->RemoveDeadNodes(NowDeadNodes);
2858 unsigned int Max = 8192;
2861 if (ChainNodesMatched.
size() == 1)
2862 return ChainNodesMatched[0]->getOperand(0);
2866 std::function<void(
const SDValue)> AddChains = [&](
const SDValue V) {
2867 if (V.getValueType() != MVT::Other)
2871 if (!Visited.
insert(V.getNode()).second)
2874 for (
const SDValue &
Op : V->op_values())
2880 for (
auto *
N : ChainNodesMatched) {
2885 while (!Worklist.
empty())
2889 if (InputChains.
size() == 0)
2896 for (
SDValue V : InputChains) {
2900 if (InputChains.
size() != 1 &&
2901 V->getValueType(V->getNumValues() - 1) == MVT::Glue &&
2902 InputGlue.
getNode() == V.getNode())
2907 for (
auto *
N : ChainNodesMatched)
2912 if (InputChains.
size() == 1)
2913 return InputChains[0];
2915 MVT::Other, InputChains);
2919SDNode *SelectionDAGISel::
2928 int OldGlueResultNo = -1, OldChainResultNo = -1;
2930 unsigned NTMNumResults =
Node->getNumValues();
2931 if (
Node->getValueType(NTMNumResults-1) == MVT::Glue) {
2932 OldGlueResultNo = NTMNumResults-1;
2933 if (NTMNumResults != 1 &&
2934 Node->getValueType(NTMNumResults-2) == MVT::Other)
2935 OldChainResultNo = NTMNumResults-2;
2936 }
else if (
Node->getValueType(NTMNumResults-1) == MVT::Other)
2937 OldChainResultNo = NTMNumResults-1;
2941 SDNode *Res =
CurDAG->MorphNodeTo(Node, ~TargetOpc, VTList,
Ops);
2955 static_cast<unsigned>(OldGlueResultNo) != ResNumResults - 1)
2957 SDValue(Res, ResNumResults - 1));
2963 if ((EmitNodeInfo &
OPFL_Chain) && OldChainResultNo != -1 &&
2964 static_cast<unsigned>(OldChainResultNo) != ResNumResults - 1)
2966 SDValue(Res, ResNumResults - 1));
2984 unsigned RecNo = MatcherTable[MatcherIndex++];
2985 assert(RecNo < RecordedNodes.size() &&
"Invalid CheckSame");
2986 return N == RecordedNodes[RecNo].first;
2994 if (ChildNo >=
N.getNumOperands())
2996 return ::CheckSame(MatcherTable, MatcherIndex,
N.getOperand(ChildNo),
3004 bool TwoBytePredNo =
3008 ? MatcherTable[MatcherIndex++]
3011 PredNo |= MatcherTable[MatcherIndex++] << 8;
3021 ? MatcherTable[MatcherIndex++]
3029 Opc |=
static_cast<uint16_t>(MatcherTable[MatcherIndex++]) << 8;
3030 return N->getOpcode() ==
Opc;
3037 if (
N.getValueType() == VT)
3047 if (ChildNo >=
N.getNumOperands())
3049 return ::CheckType(VT,
N.getOperand(ChildNo), TLI,
DL);
3061 if (2 >=
N.getNumOperands())
3063 return ::CheckCondCode(MatcherTable, MatcherIndex,
N.getOperand(2));
3079 int64_t Val =
GetSignedVBR(MatcherTable, MatcherIndex);
3082 return C &&
C->getAPIntValue().trySExtValue() == Val;
3088 if (ChildNo >=
N.getNumOperands())
3090 return ::CheckInteger(MatcherTable, MatcherIndex,
N.getOperand(ChildNo));
3096 int64_t Val = MatcherTable[MatcherIndex++];
3098 Val =
GetVBR(Val, MatcherTable, MatcherIndex);
3100 if (
N->getOpcode() !=
ISD::AND)
return false;
3109 int64_t Val = MatcherTable[MatcherIndex++];
3111 Val =
GetVBR(Val, MatcherTable, MatcherIndex);
3113 if (
N->getOpcode() !=
ISD::OR)
return false;
3129 unsigned Opcode = Table[Index++];
3195 unsigned Res = Table[Index++];
3297 unsigned NumRecordedNodes;
3300 unsigned NumMatchedMemRefs;
3303 SDValue InputChain, InputGlue;
3306 bool HasChainNodesMatched;
3315 SDNode **NodeToMatch;
3316 SmallVectorImpl<std::pair<SDValue, SDNode *>> &RecordedNodes;
3317 SmallVectorImpl<MatchScope> &MatchScopes;
3320 MatchStateUpdater(SelectionDAG &DAG, SDNode **NodeToMatch,
3321 SmallVectorImpl<std::pair<SDValue, SDNode *>> &RN,
3322 SmallVectorImpl<MatchScope> &MS)
3323 : SelectionDAG::DAGUpdateListener(DAG), NodeToMatch(NodeToMatch),
3324 RecordedNodes(
RN), MatchScopes(MS) {}
3326 void NodeDeleted(SDNode *
N, SDNode *
E)
override {
3332 if (!
E ||
E->isMachineOpcode())
3335 if (
N == *NodeToMatch)
3340 for (
auto &
I : RecordedNodes)
3341 if (
I.first.getNode() ==
N)
3344 for (
auto &
I : MatchScopes)
3345 for (
auto &J :
I.NodeStack)
3346 if (J.getNode() ==
N)
3355 unsigned TableSize) {
3392 CurDAG->RemoveDeadNode(NodeToMatch);
3396 Select_INLINEASM(NodeToMatch);
3399 Select_READ_REGISTER(NodeToMatch);
3402 Select_WRITE_REGISTER(NodeToMatch);
3406 Select_UNDEF(NodeToMatch);
3409 Select_FAKE_USE(NodeToMatch);
3412 Select_RELOC_NONE(NodeToMatch);
3415 Select_FREEZE(NodeToMatch);
3418 Select_ARITH_FENCE(NodeToMatch);
3421 Select_MEMBARRIER(NodeToMatch);
3424 Select_STACKMAP(NodeToMatch);
3427 Select_PATCHPOINT(NodeToMatch);
3430 Select_JUMP_TABLE_DEBUG_INFO(NodeToMatch);
3433 Select_CONVERGENCECTRL_ANCHOR(NodeToMatch);
3436 Select_CONVERGENCECTRL_ENTRY(NodeToMatch);
3439 Select_CONVERGENCECTRL_LOOP(NodeToMatch);
3466 SDValue InputChain, InputGlue, DeactivationSymbol;
3480 unsigned MatcherIndex = 0;
3482 if (!OpcodeOffset.empty()) {
3484 if (
N.getOpcode() < OpcodeOffset.size())
3485 MatcherIndex = OpcodeOffset[
N.getOpcode()];
3486 LLVM_DEBUG(
dbgs() <<
" Initial Opcode index to " << MatcherIndex <<
"\n");
3495 unsigned CaseSize = MatcherTable[Idx++];
3497 CaseSize =
GetVBR(CaseSize, MatcherTable, Idx);
3498 if (CaseSize == 0)
break;
3502 Opc |=
static_cast<uint16_t>(MatcherTable[Idx++]) << 8;
3503 if (
Opc >= OpcodeOffset.size())
3504 OpcodeOffset.resize((
Opc+1)*2);
3505 OpcodeOffset[
Opc] = Idx;
3510 if (
N.getOpcode() < OpcodeOffset.size())
3511 MatcherIndex = OpcodeOffset[
N.getOpcode()];
3515 assert(MatcherIndex < TableSize &&
"Invalid index");
3517 unsigned CurrentOpcodeIndex = MatcherIndex;
3531 unsigned NumToSkip = MatcherTable[MatcherIndex++];
3532 if (NumToSkip & 128)
3533 NumToSkip =
GetVBR(NumToSkip, MatcherTable, MatcherIndex);
3535 if (NumToSkip == 0) {
3540 FailIndex = MatcherIndex+NumToSkip;
3542 unsigned MatcherIndexOfPredicate = MatcherIndex;
3543 (void)MatcherIndexOfPredicate;
3550 Result, *
this, RecordedNodes);
3555 dbgs() <<
" Skipped scope entry (due to false predicate) at "
3556 <<
"index " << MatcherIndexOfPredicate <<
", continuing at "
3557 << FailIndex <<
"\n");
3558 ++NumDAGIselRetries;
3562 MatcherIndex = FailIndex;
3566 if (FailIndex == 0)
break;
3570 MatchScope NewEntry;
3571 NewEntry.FailIndex = FailIndex;
3572 NewEntry.NodeStack.append(NodeStack.
begin(), NodeStack.
end());
3573 NewEntry.NumRecordedNodes = RecordedNodes.
size();
3574 NewEntry.NumMatchedMemRefs = MatchedMemRefs.
size();
3575 NewEntry.InputChain = InputChain;
3576 NewEntry.InputGlue = InputGlue;
3577 NewEntry.HasChainNodesMatched = !ChainNodesMatched.
empty();
3583 SDNode *Parent =
nullptr;
3584 if (NodeStack.
size() > 1)
3585 Parent = NodeStack[NodeStack.
size()-2].getNode();
3595 if (ChildNo >=
N.getNumOperands())
3603 MatchedMemRefs.
push_back(MN->getMemOperand());
3613 if (
N->getNumOperands() != 0 &&
3614 N->getOperand(
N->getNumOperands()-1).getValueType() == MVT::Glue)
3615 InputGlue =
N->getOperand(
N->getNumOperands()-1);
3621 if (
N->getNumOperands() != 0 &&
3622 N->getOperand(
N->getNumOperands() - 1).getOpcode() ==
3624 DeactivationSymbol =
N->getOperand(
N->getNumOperands() - 1);
3628 unsigned ChildNo = MatcherTable[MatcherIndex++];
3629 if (ChildNo >=
N.getNumOperands())
3631 N =
N.getOperand(ChildNo);
3641 if (ChildNo >=
N.getNumOperands())
3643 N =
N.getOperand(ChildNo);
3659 assert(!NodeStack.
empty() &&
"Node stack imbalance!");
3660 N = NodeStack.
back();
3663 ? MatcherTable[MatcherIndex++]
3665 if (SiblingNo >=
N.getNumOperands())
3667 N =
N.getOperand(SiblingNo);
3674 assert(!NodeStack.
empty() &&
"Node stack imbalance!");
3675 N = NodeStack.
back();
3679 if (!
::CheckSame(MatcherTable, MatcherIndex,
N, RecordedNodes))
break;
3715 unsigned OpNum = MatcherTable[MatcherIndex++];
3718 for (
unsigned i = 0; i < OpNum; ++i)
3719 Operands.
push_back(RecordedNodes[MatcherTable[MatcherIndex++]].first);
3721 unsigned PredNo = MatcherTable[MatcherIndex++];
3736 ? MatcherTable[MatcherIndex++]
3738 unsigned RecNo = MatcherTable[MatcherIndex++];
3739 assert(RecNo < RecordedNodes.
size() &&
"Invalid CheckComplexPat");
3743 std::unique_ptr<MatchStateUpdater> MSU;
3745 MSU.reset(
new MatchStateUpdater(*
CurDAG, &NodeToMatch, RecordedNodes,
3749 RecordedNodes[RecNo].first, CPNum,
3755 if (!
::CheckOpcode(MatcherTable, MatcherIndex,
N.getNode()))
break;
3771 VT =
getHwModeVT(MatcherTable, MatcherIndex, *
this);
3784 unsigned Res = MatcherTable[MatcherIndex++];
3789 CurDAG->getDataLayout()))
3795 unsigned CurNodeOpcode =
N.getOpcode();
3796 unsigned SwitchStart = MatcherIndex-1; (void)SwitchStart;
3800 CaseSize = MatcherTable[MatcherIndex++];
3802 CaseSize =
GetVBR(CaseSize, MatcherTable, MatcherIndex);
3803 if (CaseSize == 0)
break;
3806 Opc |=
static_cast<uint16_t>(MatcherTable[MatcherIndex++]) << 8;
3809 if (CurNodeOpcode ==
Opc)
3813 MatcherIndex += CaseSize;
3817 if (CaseSize == 0)
break;
3820 LLVM_DEBUG(
dbgs() <<
" OpcodeSwitch from " << SwitchStart <<
" to "
3821 << MatcherIndex <<
"\n");
3826 MVT CurNodeVT =
N.getSimpleValueType();
3827 unsigned SwitchStart = MatcherIndex-1; (void)SwitchStart;
3831 CaseSize = MatcherTable[MatcherIndex++];
3833 CaseSize =
GetVBR(CaseSize, MatcherTable, MatcherIndex);
3834 if (CaseSize == 0)
break;
3837 if (CaseVT == MVT::iPTR)
3838 CaseVT =
TLI->getPointerTy(
CurDAG->getDataLayout());
3841 if (CurNodeVT == CaseVT)
3845 MatcherIndex += CaseSize;
3849 if (CaseSize == 0)
break;
3853 <<
"] from " << SwitchStart <<
" to " << MatcherIndex
3922 CurDAG->getDataLayout()))
3938 if (!
::CheckOrImm(MatcherTable, MatcherIndex,
N, *
this))
break;
3950 assert(NodeStack.
size() != 1 &&
"No parent node");
3953 bool HasMultipleUses =
false;
3954 for (
unsigned i = 1, e = NodeStack.
size()-1; i != e; ++i) {
3955 unsigned NNonChainUses = 0;
3956 SDNode *NS = NodeStack[i].getNode();
3958 if (U.getValueType() != MVT::Other)
3959 if (++NNonChainUses > 1) {
3960 HasMultipleUses =
true;
3963 if (HasMultipleUses)
break;
3965 if (HasMultipleUses)
break;
3999 VT =
getHwModeVT(MatcherTable, MatcherIndex, *
this);
4005 int64_t Val =
GetSignedVBR(MatcherTable, MatcherIndex);
4027 VT =
getHwModeVT(MatcherTable, MatcherIndex, *
this);
4033 unsigned RegNo = MatcherTable[MatcherIndex++];
4045 unsigned RegNo = MatcherTable[MatcherIndex++];
4046 RegNo |= MatcherTable[MatcherIndex++] << 8;
4062 ? MatcherTable[MatcherIndex++]
4064 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitConvertToTarget");
4065 SDValue Imm = RecordedNodes[RecNo].first;
4069 Imm =
CurDAG->getTargetConstant(*Val,
SDLoc(NodeToMatch),
4070 Imm.getValueType());
4073 Imm =
CurDAG->getTargetConstantFP(*Val,
SDLoc(NodeToMatch),
4074 Imm.getValueType());
4077 RecordedNodes.
emplace_back(Imm, RecordedNodes[RecNo].second);
4086 "EmitMergeInputChains should be the first chain producing node");
4088 "Should only have one EmitMergeInputChains per match");
4092 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitMergeInputChains");
4093 ChainNodesMatched.
push_back(RecordedNodes[RecNo].first.getNode());
4099 if (ChainNodesMatched.
back() != NodeToMatch &&
4100 !RecordedNodes[RecNo].first.hasOneUse()) {
4101 ChainNodesMatched.
clear();
4115 "EmitMergeInputChains should be the first chain producing node");
4122 unsigned NumChains = MatcherTable[MatcherIndex++];
4123 assert(NumChains != 0 &&
"Can't TF zero chains");
4126 "Should only have one EmitMergeInputChains per match");
4129 for (
unsigned i = 0; i != NumChains; ++i) {
4130 unsigned RecNo = MatcherTable[MatcherIndex++];
4131 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitMergeInputChains");
4132 ChainNodesMatched.
push_back(RecordedNodes[RecNo].first.getNode());
4138 if (ChainNodesMatched.
back() != NodeToMatch &&
4139 !RecordedNodes[RecNo].first.hasOneUse()) {
4140 ChainNodesMatched.
clear();
4146 if (ChainNodesMatched.
empty())
4171 : MatcherTable[MatcherIndex++];
4172 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitCopyToReg");
4173 unsigned DestPhysReg = MatcherTable[MatcherIndex++];
4175 DestPhysReg |= MatcherTable[MatcherIndex++] << 8;
4178 InputChain =
CurDAG->getEntryNode();
4180 InputChain =
CurDAG->getCopyToReg(InputChain,
SDLoc(NodeToMatch),
4181 DestPhysReg, RecordedNodes[RecNo].first,
4184 InputGlue = InputChain.
getValue(1);
4189 unsigned XFormNo = MatcherTable[MatcherIndex++];
4190 unsigned RecNo = MatcherTable[MatcherIndex++];
4191 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitNodeXForm");
4199 unsigned index = MatcherTable[MatcherIndex++];
4200 index |= (MatcherTable[MatcherIndex++] << 8);
4201 index |= (MatcherTable[MatcherIndex++] << 16);
4202 index |= (MatcherTable[MatcherIndex++] << 24);
4232 uint16_t TargetOpc = MatcherTable[MatcherIndex++];
4233 TargetOpc |=
static_cast<uint16_t>(MatcherTable[MatcherIndex++]) << 8;
4234 unsigned EmitNodeInfo;
4253 EmitNodeInfo = MatcherTable[MatcherIndex++];
4278 NumVTs = MatcherTable[MatcherIndex++];
4281 for (
unsigned i = 0; i != NumVTs; ++i) {
4283 if (VT == MVT::iPTR)
4284 VT =
TLI->getPointerTy(
CurDAG->getDataLayout());
4288 for (
unsigned i = 0; i != NumVTs; ++i) {
4290 if (VT == MVT::iPTR)
4291 VT =
TLI->getPointerTy(
CurDAG->getDataLayout()).SimpleTy;
4304 if (VTs.
size() == 1)
4305 VTList =
CurDAG->getVTList(VTs[0]);
4306 else if (VTs.
size() == 2)
4307 VTList =
CurDAG->getVTList(VTs[0], VTs[1]);
4309 VTList =
CurDAG->getVTList(VTs);
4312 unsigned NumOps = MatcherTable[MatcherIndex++];
4314 for (
unsigned i = 0; i !=
NumOps; ++i) {
4315 unsigned RecNo = MatcherTable[MatcherIndex++];
4317 RecNo =
GetVBR(RecNo, MatcherTable, MatcherIndex);
4319 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitNode");
4320 Ops.push_back(RecordedNodes[RecNo].first);
4327 FirstOpToCopy += (EmitNodeInfo &
OPFL_Chain) ? 1 : 0;
4329 "Invalid variadic node");
4332 for (
unsigned i = FirstOpToCopy, e = NodeToMatch->
getNumOperands();
4335 if (V.getValueType() == MVT::Glue)
break;
4342 Ops.push_back(InputChain);
4343 if (DeactivationSymbol.
getNode() !=
nullptr)
4344 Ops.push_back(DeactivationSymbol);
4346 Ops.push_back(InputGlue);
4352 bool MayRaiseFPException =
4359 bool IsMorphNodeTo =
4362 if (!IsMorphNodeTo) {
4365 Res =
CurDAG->getMachineNode(TargetOpc,
SDLoc(NodeToMatch),
4369 for (
unsigned i = 0, e = VTs.
size(); i != e; ++i) {
4370 if (VTs[i] == MVT::Other || VTs[i] == MVT::Glue)
break;
4375 "NodeToMatch was removed partway through selection");
4379 auto &Chain = ChainNodesMatched;
4381 "Chain node replaced during MorphNode");
4385 Ops, EmitNodeInfo));
4412 bool mayLoad =
MCID.mayLoad();
4413 bool mayStore =
MCID.mayStore();
4419 if (MMO->isLoad()) {
4422 }
else if (MMO->isStore()) {
4430 CurDAG->setNodeMemRefs(Res, FilteredMemRefs);
4434 if (!MatchedMemRefs.
empty() && Res->memoperands_empty())
4435 dbgs() <<
" Dropping mem operands\n";
4436 dbgs() <<
" " << (IsMorphNodeTo ?
"Morphed" :
"Created") <<
" node: ";
4441 if (IsMorphNodeTo) {
4443 UpdateChains(Res, InputChain, ChainNodesMatched,
true);
4453 unsigned NumResults = MatcherTable[MatcherIndex++];
4455 for (
unsigned i = 0; i != NumResults; ++i) {
4456 unsigned ResSlot = MatcherTable[MatcherIndex++];
4458 ResSlot =
GetVBR(ResSlot, MatcherTable, MatcherIndex);
4460 assert(ResSlot < RecordedNodes.
size() &&
"Invalid CompleteMatch");
4461 SDValue Res = RecordedNodes[ResSlot].first;
4463 assert(i < NodeToMatch->getNumValues() &&
4466 "Invalid number of results to complete!");
4472 "invalid replacement");
4477 UpdateChains(NodeToMatch, InputChain, ChainNodesMatched,
false);
4490 "Didn't replace all uses of the node?");
4491 CurDAG->RemoveDeadNode(NodeToMatch);
4500 LLVM_DEBUG(
dbgs() <<
" Match failed at index " << CurrentOpcodeIndex
4502 ++NumDAGIselRetries;
4504 if (MatchScopes.
empty()) {
4505 CannotYetSelect(NodeToMatch);
4511 MatchScope &LastScope = MatchScopes.
back();
4512 RecordedNodes.
resize(LastScope.NumRecordedNodes);
4513 NodeStack.
assign(LastScope.NodeStack.begin(), LastScope.NodeStack.end());
4514 N = NodeStack.
back();
4516 if (LastScope.NumMatchedMemRefs != MatchedMemRefs.
size())
4517 MatchedMemRefs.
resize(LastScope.NumMatchedMemRefs);
4518 MatcherIndex = LastScope.FailIndex;
4522 InputChain = LastScope.InputChain;
4523 InputGlue = LastScope.InputGlue;
4524 if (!LastScope.HasChainNodesMatched)
4525 ChainNodesMatched.
clear();
4530 unsigned NumToSkip = MatcherTable[MatcherIndex++];
4531 if (NumToSkip & 128)
4532 NumToSkip =
GetVBR(NumToSkip, MatcherTable, MatcherIndex);
4536 if (NumToSkip != 0) {
4537 LastScope.FailIndex = MatcherIndex+NumToSkip;
4551 if (
N->isMachineOpcode()) {
4553 return MCID.mayRaiseFPException();
4558 if (
N->isTargetOpcode()) {
4562 return N->isStrictFPOpcode();
4575 int32_t Off =
C->getSExtValue();
4578 return (Off >= 0) && (((
A.value() - 1) & Off) ==
unsigned(Off));
4583void SelectionDAGISel::CannotYetSelect(
SDNode *
N) {
4586 Msg <<
"Cannot select: ";
4588 Msg.enable_colors(
errs().has_colors());
4594 Msg <<
"\nIn function: " <<
MF->
getName();
4596 bool HasInputChain =
N->getOperand(0).getValueType() == MVT::Other;
4597 unsigned iid =
N->getConstantOperandVal(HasInputChain);
4598 if (iid < Intrinsic::num_intrinsics)
4601 Msg <<
"unknown intrinsic #" << iid;
unsigned const MachineRegisterInfo * MRI
for(const MachineOperand &MO :llvm::drop_begin(OldMI.operands(), Desc.getNumOperands()))
MachineInstrBuilder & UseMI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
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
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...
This file defines the DenseMap class.
This file defines the FastISel class.
Module.h This file contains the declarations for the Module class.
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
PostRA Machine Instruction Scheduler
Register const TargetRegisterInfo * TRI
Promote Memory to Register
uint64_t IntrinsicInst * II
FunctionAnalysisManager FAM
This file builds on the ADT/GraphTraits.h file to build a generic graph post order iterator.
static Type * getValueType(Value *V)
Returns the type of the given value/instruction V.
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckInteger(const uint8_t *MatcherTable, unsigned &MatcherIndex, SDValue N)
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 uint8_t *MatcherTable, unsigned &MatcherIndex, const SelectionDAGISel &SDISel)
CheckPatternPredicate - Implements OP_CheckPatternPredicate.
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 cl::opt< bool > DumpSortedDAG("dump-sorted-dags", cl::Hidden, cl::desc("Print DAGs with sorted nodes in debug dump"), cl::init(false))
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckChild2CondCode(const uint8_t *MatcherTable, unsigned &MatcherIndex, SDValue N)
static void reportFastISelFailure(MachineFunction &MF, OptimizationRemarkEmitter &ORE, OptimizationRemarkMissed &R, bool ShouldAbort)
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckCondCode(const uint8_t *MatcherTable, unsigned &MatcherIndex, SDValue N)
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 LLVM_ATTRIBUTE_ALWAYS_INLINE MVT getHwModeVT(const uint8_t *MatcherTable, unsigned &MatcherIndex, const SelectionDAGISel &SDISel)
Decode a HwMode VT in MatcherTable by calling getValueTypeForHwMode.
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 LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckValueType(const uint8_t *MatcherTable, unsigned &MatcherIndex, SDValue N, const TargetLowering *TLI, const DataLayout &DL)
static void processSingleLocVars(FunctionLoweringInfo &FuncInfo, FunctionVarLocs const *FnVarLocs)
Collect single location variable information generated with assignment tracking.
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckChildInteger(const uint8_t *MatcherTable, unsigned &MatcherIndex, SDValue N, unsigned ChildNo)
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckAndImm(const uint8_t *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 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 uint64_t GetVBR(uint64_t Val, const uint8_t *MatcherTable, unsigned &Idx)
GetVBR - decode a vbr encoding whose top bit is set.
static void preserveFakeUses(BasicBlock::iterator Begin, BasicBlock::iterator End)
static SDValue HandleMergeInputChains(const SmallVectorImpl< SDNode * > &ChainNodesMatched, SDValue InputGlue, SelectionDAG *CurDAG)
HandleMergeInputChains - This implements the OPC_EmitMergeInputChains operation for when the pattern ...
static LLVM_ATTRIBUTE_ALWAYS_INLINE int64_t GetSignedVBR(const unsigned char *MatcherTable, unsigned &Idx)
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckSame(const uint8_t *MatcherTable, unsigned &MatcherIndex, SDValue N, const SmallVectorImpl< std::pair< SDValue, SDNode * > > &RecordedNodes)
CheckSame - Implements OP_CheckSame.
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckType(MVT::SimpleValueType VT, SDValue N, const TargetLowering *TLI, const DataLayout &DL)
static bool hasExceptionPointerOrCodeUser(const CatchPadInst *CPI)
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 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 LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckNodePredicate(unsigned Opcode, const uint8_t *MatcherTable, unsigned &MatcherIndex, const SelectionDAGISel &SDISel, SDValue Op)
CheckNodePredicate - Implements OP_CheckNodePredicate.
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckOrImm(const uint8_t *MatcherTable, unsigned &MatcherIndex, SDValue N, const SelectionDAGISel &SDISel)
static bool maintainPGOProfile(const TargetMachine &TM, CodeGenOptLevel OptLevel)
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 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 LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckChildSame(const uint8_t *MatcherTable, unsigned &MatcherIndex, SDValue N, const SmallVectorImpl< std::pair< SDValue, SDNode * > > &RecordedNodes, unsigned ChildNo)
CheckChildSame - Implements OP_CheckChildXSame.
static unsigned IsPredicateKnownToFail(const uint8_t *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 LLVM_ATTRIBUTE_ALWAYS_INLINE MVT::SimpleValueType getSimpleVT(const uint8_t *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 CheckOpcode(const uint8_t *MatcherTable, unsigned &MatcherIndex, SDNode *N)
static bool isFoldedOrDeadInstruction(const Instruction *I, const FunctionLoweringInfo &FuncInfo)
isFoldedOrDeadInstruction - Return true if the specified instruction is side-effect free and is eithe...
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
This file describes how to lower LLVM code to machine code.
A manager for alias analyses.
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object.
AAResults & getAAResults()
Class for arbitrary precision integers.
bool isSubsetOf(const APInt &RHS) const
This operation checks that all bits set in this APInt are also set in RHS.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
This class represents an incoming formal argument to a Function.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
A function analysis which provides an AssumptionCache.
An immutable pass that tracks lazily created AssumptionCache objects.
LLVM Basic Block Representation.
unsigned getNumber() const
iterator_range< const_phi_iterator > phis() const
Returns a range that iterates over the phis in the basic block.
LLVM_ABI InstListType::const_iterator getFirstNonPHIIt() const
Returns an iterator to the first instruction in this block that is not a PHINode instruction.
InstListType::const_iterator const_iterator
InstListType::iterator iterator
Instruction iterators...
bool isEHPad() const
Return true if this basic block is an exception handling block.
LLVM_ABI const Instruction * getFirstMayFaultInst() const
Returns the first potential AsynchEH faulty instruction currently it checks for loads/stores (which m...
Analysis pass which computes BlockFrequencyInfo.
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
Analysis pass which computes BranchProbabilityInfo.
Legacy analysis pass which computes BranchProbabilityInfo.
This class represents a function call, abstracting a target machine's calling convention.
ConstantFP - Floating Point Values [float, double].
This is the shared class of boolean and integer constants.
LLVM_ABI bool isEntryValue() const
Check if the expression consists of exactly one entry value operand.
static LLVM_ABI DIExpression * append(const DIExpression *Expr, ArrayRef< uint64_t > Ops)
Append the opcodes Ops to DIExpr.
static LLVM_ABI 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 ...
A parsed version of the target data layout string in and methods for querying it.
Record of a variable value-assignment, aka a non instruction representation of the dbg....
iterator find(const_arg_type_t< KeyT > Val)
DenseMapIterator< KeyT, ValueT, KeyInfoT, BucketT > iterator
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Diagnostic information for ISel fallback path.
void setLastLocalValue(MachineInstr *I)
Update the position of the last instruction emitted for materializing constants for use in the curren...
void handleDbgInfo(const Instruction *II)
Target-independent lowering of non-instruction debug info associated with this instruction.
bool tryToFoldLoad(const LoadInst *LI, const Instruction *FoldInst)
We're checking to see if we can fold LI into FoldInst.
void removeDeadCode(MachineBasicBlock::iterator I, MachineBasicBlock::iterator E)
Remove all dead instructions between the I and E.
void startNewBlock()
Set the current block to which generated machine instructions will be appended.
bool selectInstruction(const Instruction *I)
Do "fast" instruction selection for the given LLVM IR instruction and append the generated machine in...
void finishBasicBlock()
Flush the local value map.
void recomputeInsertPt()
Reset InsertPt to prepare for inserting instructions into the current block.
bool lowerArguments()
Do "fast" instruction selection for function arguments and append the machine instructions to the cur...
unsigned arg_size() const
arg_size - Return the number of funcletpad arguments.
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th funcletpad argument.
FunctionLoweringInfo - This contains information that is global to a function that is used when lower...
SmallPtrSet< const DbgVariableRecord *, 8 > PreprocessedDVRDeclares
Collection of dbg_declare instructions handled after argument lowering and before ISel proper.
DenseMap< const AllocaInst *, int > StaticAllocaMap
StaticAllocaMap - Keep track of frame indices for fixed sized allocas in the entry block.
int getArgumentFrameIndex(const Argument *A)
getArgumentFrameIndex - Get frame index for the byval argument.
bool isExportedInst(const Value *V) const
isExportedInst - Return true if the specified value is an instruction exported from its block.
DenseMap< const Value *, Register > ValueMap
ValueMap - Since we emit code for the function a basic block at a time, we must remember which virtua...
MachineRegisterInfo * RegInfo
bool skipFunction(const Function &F) const
Optional passes call this function to check whether the pass should be skipped.
Data structure describing the variable locations in a function.
const VarLocInfo * single_locs_begin() const
DILocalVariable * getDILocalVariable(const VarLocInfo *Loc) const
Return the DILocalVariable for the location definition represented by ID.
const VarLocInfo * single_locs_end() const
One past the last single-location variable location definition.
const BasicBlock & getEntryBlock() const
FunctionType * getFunctionType() const
Returns the FunctionType for me.
unsigned getMaxBlockNumber() const
Return a value larger than the largest block number.
iterator_range< arg_iterator > args()
DISubprogram * getSubprogram() const
Get the attached subprogram.
bool hasMinSize() const
Optimize this function for minimum size (-Oz).
bool hasGC() const
hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm to use during code generatio...
bool hasOptNone() const
Do not optimize this function (-O0).
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
An analysis pass which caches information about the Function.
An analysis pass which caches information about the entire Module.
Module * getParent()
Get the module that this global value is contained inside of...
This class is used to form a handle around another node that is persistent and is updated across invo...
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
bool isTerminator() const
A wrapper class for inspecting calls to intrinsic functions.
LLVM_ABI void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
This is an alternative analysis pass to BlockFrequencyInfoWrapperPass.
static void getLazyBFIAnalysisUsage(AnalysisUsage &AU)
Helper for client passes to set up the analysis usage on behalf of this pass.
Record a mapping from subtarget to LibcallLoweringInfo.
const LibcallLoweringInfo & getLibcallLowering(const TargetSubtargetInfo &Subtarget) const
Describe properties that are true of each instruction in the target description file.
virtual unsigned getHwMode(enum HwModeType type=HwMode_Default) const
HwMode ID corresponding to the 'type' parameter is retrieved from the HwMode bit set of the current s...
const MDNode * getMD() const
const MDOperand & getOperand(unsigned I) const
LLVM_ABI StringRef getString() const
LLVM_ABI instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
LLVM_ABI iterator getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
instr_iterator instr_end()
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
iterator insertAfter(iterator I, MachineInstr *MI)
Insert MI into the instruction list after I.
LLVM_ABI bool isSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB is a successor of this block.
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 '...
MachineInstrBundleIterator< MachineInstr > iterator
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
bool hasCalls() const
Return true if the current function has any function calls.
Align getObjectAlign(int ObjectIdx) const
Return the alignment of the specified stack object.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
MachineFunctionPass(char &ID)
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
bool useDebugInstrRef() const
Returns true if the function's variable locations are tracked with instruction referencing.
void setWasmLandingPadIndex(const MachineBasicBlock *LPad, unsigned Index)
Map the landing pad to its index. Used for Wasm exception handling.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
void setUseDebugInstrRef(bool UseInstrRef)
Set whether this function will use instruction referencing or not.
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
Function & getFunction()
Return the LLVM function that this machine code represents.
bool shouldUseDebugInstrRef() const
Determine whether, in the current machine configuration, we should use instruction referencing or not...
const MachineFunctionProperties & getProperties() const
Get the function properties.
void setVariableDbgInfo(const DILocalVariable *Var, const DIExpression *Expr, int Slot, const DILocation *Loc)
Collect information used to emit debugging information of a variable in a stack slot.
const MachineInstrBuilder & addSym(MCSymbol *Sym, unsigned char TargetFlags=0) const
const MachineInstrBuilder & addReg(Register RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
Representation of each machine instruction.
bool isTerminator(QueryType Type=AnyInBundle) const
Returns true if this instruction part of the terminator for a basic block.
const MachineOperand & getOperand(unsigned i) const
A description of a memory reference used in the backend.
An analysis that produces MachineModuleInfo for a module.
This class contains meta information specific to a module.
Register getReg() const
getReg - Returns the register number.
MachinePassRegistry - Track the registration of machine passes.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
ArrayRef< std::pair< MCRegister, Register > > liveins() const
An SDNode that represents everything that will be needed to construct a MachineInstr.
Metadata * getModuleFlag(StringRef Key) const
Return the corresponding value if Key appears in module flags, otherwise return null.
This class is used by SelectionDAGISel to temporarily override the optimization level on a per-functi...
OptLevelChanger(SelectionDAGISel &ISel, CodeGenOptLevel NewOptLevel)
static LLVM_ABI PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
AnalysisType & getAnalysis() const
getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information ...
AnalysisType * getAnalysisIfAvailable() const
getAnalysisIfAvailable<AnalysisType>() - Subclasses use this function to get analysis information tha...
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
An analysis pass based on the new PM to deliver ProfileSummaryInfo.
An analysis pass based on legacy pass manager to deliver ProfileSummaryInfo.
RegisterPassParser class - Handle the addition of new machine passes.
ScheduleDAGSDNodes *(*)(SelectionDAGISel *, CodeGenOptLevel) FunctionPassCtor
static LLVM_ABI MachinePassRegistry< FunctionPassCtor > Registry
RegisterScheduler class - Track the registration of instruction schedulers.
Wrapper class representing virtual and physical registers.
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
bool isMachineOpcode() const
Test if this node has a post-isel opcode, directly corresponding to a MachineInstr opcode.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
SDNode * getGluedUser() const
If this node has a glue value with a user, return the user (there is at most one).
LLVM_ABI bool isOnlyUserOf(const SDNode *N) const
Return true if this node is the only use of N.
iterator_range< value_op_iterator > op_values() const
iterator_range< use_iterator > uses()
void setNodeId(int Id)
Set unique node id.
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.
uint64_t getAsZExtVal() const
Helper method returns the zero-extended integer value of a ConstantSDNode.
bool use_empty() const
Return true if there are no uses of this node.
unsigned getNumValues() const
Return the number of values defined/returned by this operator.
unsigned getNumOperands() const
Return the number of values used by this operation.
const SDValue & getOperand(unsigned Num) const
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
Represents a use of a SDNode.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
SDNode * getNode() const
get the SDNode which holds the desired result
SDValue getValue(unsigned R) const
EVT getValueType() const
Return the ValueType of the referenced return value.
TypeSize getValueSizeInBits() const
Returns the size of the value in bits.
ScheduleDAGSDNodes - A ScheduleDAG for scheduling SDNode-based DAGs.
SelectionDAGBuilder - This is the common target-independent lowering implementation that is parameter...
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
SelectionDAGISelLegacy(char &ID, std::unique_ptr< SelectionDAGISel > S)
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
SelectionDAGISel - This is the common base class used for SelectionDAG-based pattern-matching instruc...
std::optional< BatchAAResults > BatchAA
std::unique_ptr< FunctionLoweringInfo > FuncInfo
SmallPtrSet< const Instruction *, 4 > ElidedArgCopyInstrs
virtual bool SelectInlineAsmMemoryOperand(const SDValue &Op, InlineAsm::ConstraintCode ConstraintID, std::vector< SDValue > &OutOps)
SelectInlineAsmMemoryOperand - Select the specified address as a target addressing mode,...
bool CheckOrMask(SDValue LHS, ConstantSDNode *RHS, int64_t DesiredMaskS) const
CheckOrMask - The isel is trying to match something like (or X, 255).
void initializeAnalysisResults(MachineFunctionAnalysisManager &MFAM)
const TargetTransformInfo * TTI
virtual bool CheckNodePredicate(SDValue Op, unsigned PredNo) const
CheckNodePredicate - This function is generated by tblgen in the target.
virtual bool CheckNodePredicateWithOperands(SDValue Op, unsigned PredNo, ArrayRef< SDValue > Operands) const
CheckNodePredicateWithOperands - This function is generated by tblgen in the target.
const TargetLowering * TLI
virtual void PostprocessISelDAG()
PostprocessISelDAG() - This hook allows the target to hack on the graph right after selection.
std::unique_ptr< OptimizationRemarkEmitter > ORE
Current optimization remark emitter.
MachineRegisterInfo * RegInfo
unsigned DAGSize
DAGSize - Size of DAG being instruction selected.
@ OPC_MorphNodeTo2GlueOutput
@ OPC_CheckPatternPredicate5
@ OPC_EmitCopyToRegTwoByte
@ OPC_MorphNodeTo2GlueInput
@ OPC_CheckChild2CondCode
@ OPC_CheckChild2TypeByHwMode
@ OPC_CheckPatternPredicateTwoByte
@ OPC_CheckPatternPredicate1
@ OPC_CheckChild4TypeByHwMode
@ OPC_MorphNodeTo1GlueOutput
@ OPC_CaptureDeactivationSymbol
@ OPC_EmitMergeInputChains1_1
@ OPC_CheckPatternPredicate2
@ OPC_EmitConvertToTarget2
@ OPC_EmitConvertToTarget0
@ OPC_CheckPatternPredicate4
@ OPC_EmitConvertToTarget1
@ OPC_CheckPatternPredicate
@ OPC_CheckPatternPredicate6
@ OPC_CheckPatternPredicate7
@ OPC_CheckChild5TypeByHwMode
@ OPC_EmitMergeInputChains
@ OPC_EmitMergeInputChains1_0
@ OPC_CheckFoldableChainNode
@ OPC_CheckChild6TypeByHwMode
@ OPC_EmitConvertToTarget3
@ OPC_CheckChild7TypeByHwMode
@ OPC_EmitRegisterByHwMode
@ OPC_CheckPredicateWithOperands
@ OPC_EmitConvertToTarget4
@ OPC_EmitIntegerByHwMode
@ OPC_CheckChild3TypeByHwMode
@ OPC_CheckTypeResByHwMode
@ OPC_EmitConvertToTarget7
@ OPC_EmitMergeInputChains1_2
@ OPC_EmitConvertToTarget5
@ OPC_MorphNodeToByHwMode
@ OPC_CheckPatternPredicate0
@ OPC_EmitRegisterByHwMode2
@ OPC_MorphNodeTo1GlueInput
@ OPC_CheckChild0TypeByHwMode
@ OPC_CheckChild1TypeByHwMode
@ OPC_CheckPatternPredicate3
@ OPC_EmitConvertToTarget
@ OPC_EmitConvertToTarget6
bool isOrEquivalentToAdd(const SDNode *N) const
virtual bool CheckComplexPattern(SDNode *Root, SDNode *Parent, SDValue N, unsigned PatternNo, SmallVectorImpl< std::pair< SDValue, SDNode * > > &Result)
virtual bool CheckPatternPredicate(unsigned PredNo) const
CheckPatternPredicate - This function is generated by tblgen in the target.
static int getNumFixedFromVariadicInfo(unsigned Flags)
getNumFixedFromVariadicInfo - Transform an EmitNode flags word into the number of fixed arity values ...
const TargetLibraryInfo * LibInfo
static int getUninvalidatedNodeId(SDNode *N)
const TargetInstrInfo * TII
std::unique_ptr< SwiftErrorValueTracking > SwiftError
static void EnforceNodeIdInvariant(SDNode *N)
void SelectCodeCommon(SDNode *NodeToMatch, const uint8_t *MatcherTable, unsigned TableSize)
void ReplaceUses(SDValue F, SDValue T)
ReplaceUses - replace all uses of the old node F with the use of the new node T.
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 ...
virtual SDValue RunSDNodeXForm(SDValue V, unsigned XFormNo)
virtual MVT getValueTypeForHwMode(unsigned Index) const
bool MatchFilterFuncName
True if the function currently processing is in the function printing list (i.e.
void SelectInlineAsmMemoryOperands(std::vector< SDValue > &Ops, const SDLoc &DL)
SelectInlineAsmMemoryOperands - Calls to this are automatically generated by tblgen.
static bool IsLegalToFold(SDValue N, SDNode *U, SDNode *Root, CodeGenOptLevel OptLevel, bool IgnoreChains=false)
IsLegalToFold - Returns true if the specific operand node N of U can be folded during instruction sel...
virtual bool ComplexPatternFuncMutatesDAG() const
Return true if complex patterns for this target can mutate the DAG.
virtual void PreprocessISelDAG()
PreprocessISelDAG - This hook allows targets to hack on the graph before instruction selection starts...
BatchAAResults * getBatchAA() const
Returns a (possibly null) pointer to the current BatchAAResults.
bool CheckAndMask(SDValue LHS, ConstantSDNode *RHS, int64_t DesiredMaskS) const
CheckAndMask - The isel is trying to match something like (and X, 255).
virtual ~SelectionDAGISel()
virtual StringRef getPatternForIndex(unsigned index)
getPatternForIndex - Patterns selected by tablegen during ISEL
bool mayRaiseFPException(SDNode *Node) const
Return whether the node may raise an FP exception.
std::unique_ptr< SelectionDAGBuilder > SDB
void ReplaceNode(SDNode *F, SDNode *T)
Replace all uses of F with T, then remove F from the DAG.
const LibcallLoweringInfo * LibcallLowering
SelectionDAGISel(TargetMachine &tm, CodeGenOptLevel OL=CodeGenOptLevel::Default)
virtual bool runOnMachineFunction(MachineFunction &mf)
static void InvalidateNodeId(SDNode *N)
virtual StringRef getIncludePathForIndex(unsigned index)
getIncludePathForIndex - get the td source location of pattern instantiation
Targets can subclass this to parameterize the SelectionDAG lowering and instruction selection process...
virtual bool mayRaiseFPException(unsigned Opcode) const
Returns true if a node with the given target-specific opcode may raise a floating-point exception.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
const SDValue & getRoot() const
Return the root tag of the SelectionDAG.
allnodes_const_iterator allnodes_begin() const
const DataLayout & getDataLayout() const
LLVM_ABI void RemoveDeadNode(SDNode *N)
Remove the specified node from the system.
LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
LLVM_ABI unsigned AssignTopologicalOrder()
Topological-sort the AllNodes list and a assign a unique node id for each node in the DAG based on th...
SDValue getEntryNode() const
Return the token chain corresponding to the entry of the function.
ilist< SDNode >::iterator allnodes_iterator
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void assign(size_type NumElts, ValueParamT Elt)
reference emplace_back(ArgTypes &&... Args)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Analysis pass providing the TargetTransformInfo.
Analysis pass providing the TargetLibraryInfo.
MachineBasicBlock * emitPatchPoint(MachineInstr &MI, MachineBasicBlock *MBB) const
Replace/modify any TargetFrameIndex operands with a targte-dependent sequence of memory operands that...
Sched::Preference getSchedulingPreference() const
Return target scheduling preference.
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...
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
virtual void AdjustInstrPostInstrSelection(MachineInstr &MI, SDNode *Node) const
This method should be implemented by targets that mark instructions with the 'hasPostISelHook' flag.
virtual MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr &MI, MachineBasicBlock *MBB) const
This method should be implemented by targets that mark instructions with the 'usesCustomInserter' fla...
Primary interface to the complete machine description for the target machine.
const std::optional< PGOOptions > & getPGOOption() const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
TargetSubtargetInfo - Generic base class for all target subtargets.
virtual const TargetInstrInfo * getInstrInfo() const
virtual const TargetLowering * getTargetLowering() const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
bool isTokenTy() const
Return true if this is 'token'.
bool isVoidTy() const
Return true if this is 'void'.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
bool hasOneUse() const
Return true if there is exactly one use of this value.
iterator_range< user_iterator > users()
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
self_iterator getIterator()
A raw_ostream that writes to an std::string.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
LLVM_ABI bool isConstantSplatVectorAllOnes(const SDNode *N, bool BuildVectorOnly=false)
Return true if the specified node is a BUILD_VECTOR or SPLAT_VECTOR where all of the elements are ~0 ...
@ CONVERGENCECTRL_ANCHOR
The llvm.experimental.convergence.* intrinsics.
@ MDNODE_SDNODE
MDNODE_SDNODE - This is a node that holdes an MDNode*, which is used to reference metadata in the IR.
@ STRICT_FSETCC
STRICT_FSETCC/STRICT_FSETCCS - Constrained versions of SETCC, used for floating-point operands only.
@ DELETED_NODE
DELETED_NODE - This is an illegal value that is used to catch errors.
@ POISON
POISON - A poison node.
@ JUMP_TABLE_DEBUG_INFO
JUMP_TABLE_DEBUG_INFO - Jumptable debug info.
@ DEACTIVATION_SYMBOL
Untyped node storing deactivation symbol reference (DeactivationSymbolSDNode).
@ INTRINSIC_VOID
OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...) This node represents a target intrin...
@ MEMBARRIER
MEMBARRIER - Compiler barrier only; generate a no-op.
@ FAKE_USE
FAKE_USE represents a use of the operand but does not do anything.
@ EH_LABEL
EH_LABEL - Represents a label in mid basic block used to track locations needed for debug and excepti...
@ ANNOTATION_LABEL
ANNOTATION_LABEL - Represents a mid basic block label used by annotations.
@ UNDEF
UNDEF - An undefined node.
@ AssertAlign
AssertAlign - These nodes record if a register contains a value that has a known alignment and the tr...
@ BasicBlock
Various leaf nodes.
@ CopyFromReg
CopyFromReg - This node indicates that the input value is a virtual or physical register that is defi...
@ TargetGlobalAddress
TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or anything else with this node...
@ ARITH_FENCE
ARITH_FENCE - This corresponds to a arithmetic fence intrinsic.
@ AssertNoFPClass
AssertNoFPClass - These nodes record if a register contains a float value that is known to be not som...
@ EntryToken
EntryToken - This is the marker used to indicate the start of a region.
@ READ_REGISTER
READ_REGISTER, WRITE_REGISTER - This node represents llvm.register on the DAG, which implements the n...
@ CopyToReg
CopyToReg - This node has three operands: a chain, a register number to set to this value,...
@ PATCHPOINT
The llvm.experimental.patchpoint.
@ LIFETIME_START
This corresponds to the llvm.lifetime.
@ STRICT_SINT_TO_FP
STRICT_[US]INT_TO_FP - Convert a signed or unsigned integer to a floating point value.
@ HANDLENODE
HANDLENODE node - Used as a handle for various purposes.
@ INLINEASM_BR
INLINEASM_BR - Branching version of inline asm. Used by asm-goto.
@ TargetConstant
TargetConstant* - Like Constant*, but the DAG does not do any folding, simplification,...
@ RELOC_NONE
Issue a no-op relocation against a given symbol at the current location.
@ AND
Bitwise operators - logical and, logical or, logical xor.
@ INTRINSIC_WO_CHAIN
RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) This node represents a target intrinsic fun...
@ PSEUDO_PROBE
Pseudo probe for AutoFDO, as a place holder in a basic block to improve the sample counts quality.
@ STACKMAP
The llvm.experimental.stackmap intrinsic.
@ FREEZE
FREEZE - FREEZE(VAL) returns an arbitrary value if VAL is UNDEF (or is evaluated to UNDEF),...
@ TokenFactor
TokenFactor - This node takes multiple tokens as input and produces a single token result.
@ INLINEASM
INLINEASM - Represents an inline asm block.
@ AssertSext
AssertSext, AssertZext - These nodes record if a register contains a value that has already been zero...
@ INTRINSIC_W_CHAIN
RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) This node represents a target in...
LLVM_ABI bool isConstantSplatVectorAllZeros(const SDNode *N, bool BuildVectorOnly=false)
Return true if the specified node is a BUILD_VECTOR or SPLAT_VECTOR where all of the elements are 0 o...
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
LLVM_ABI StringRef getBaseName(ID id)
Return the LLVM name for an intrinsic, without encoded types for overloading, such as "llvm....
@ Kill
The last use of a register.
initializer< Ty > init(const Ty &Val)
DiagnosticInfoOptimizationBase::Argument NV
NodeAddr< NodeBase * > Node
friend class Instruction
Iterator for Instructions in a `BasicBlock.
This is an optimization pass for GlobalISel generic memory operations.
GenericUniformityInfo< SSAContext > UniformityInfo
LLVM_ABI ScheduleDAGSDNodes * createDefaultScheduler(SelectionDAGISel *IS, CodeGenOptLevel OptLevel)
createDefaultScheduler - This creates an instruction scheduler appropriate for the target.
OuterAnalysisManagerProxy< ModuleAnalysisManager, MachineFunction > ModuleAnalysisManagerMachineFunctionProxy
Provide the ModuleAnalysisManager to Function proxy.
bool succ_empty(const Instruction *I)
LLVM_ABI ScheduleDAGSDNodes * createBURRListDAGScheduler(SelectionDAGISel *IS, CodeGenOptLevel OptLevel)
createBURRListDAGScheduler - This creates a bottom up register usage reduction list scheduler.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI ScheduleDAGSDNodes * createHybridListDAGScheduler(SelectionDAGISel *IS, CodeGenOptLevel)
createHybridListDAGScheduler - This creates a bottom up register pressure aware list scheduler that m...
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
MachineBasicBlock::iterator findSplitPointForStackProtector(MachineBasicBlock *BB, const TargetInstrInfo &TII)
Find the split point at which to splice the end of BB into its success stack protector check machine ...
LLVM_ABI bool TimePassesIsEnabled
If the user specifies the -time-passes argument on an LLVM tool command line then the value of this b...
LLVM_ABI LLT getLLTForMVT(MVT Ty)
Get a rough equivalent of an LLT for a given MVT.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI void initializeGCModuleInfoPass(PassRegistry &)
LLVM_ABI ScheduleDAGSDNodes * createFastDAGScheduler(SelectionDAGISel *IS, CodeGenOptLevel OptLevel)
createFastDAGScheduler - This creates a "fast" scheduler.
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
void erase(Container &C, ValueType V)
Wrapper function to remove a value from a container:
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI ScheduleDAGSDNodes * createDAGLinearizer(SelectionDAGISel *IS, CodeGenOptLevel OptLevel)
createDAGLinearizer - This creates a "no-scheduling" scheduler which linearize the DAG using topologi...
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool isFunctionInPrintList(StringRef FunctionName)
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
LLVM_ABI EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
CodeGenOptLevel
Code generation optimization level.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
bool isFuncletEHPersonality(EHPersonality Pers)
Returns true if this is a personality function that invokes handler funclets (which must return to it...
LLVM_ABI ScheduleDAGSDNodes * createSourceListDAGScheduler(SelectionDAGISel *IS, CodeGenOptLevel OptLevel)
createSourceListDAGScheduler - This creates a bottom up list scheduler that schedules nodes in source...
LLVM_ABI bool isAssignmentTrackingEnabled(const Module &M)
Return true if assignment tracking is enabled for module M.
void replace(R &&Range, const T &OldValue, const T &NewValue)
Provide wrappers to std::replace which take ranges instead of having to pass begin/end explicitly.
DWARFExpression::Operation Op
LLVM_ABI void initializeAAResultsWrapperPassPass(PassRegistry &)
LLVM_ABI void initializeTargetLibraryInfoWrapperPassPass(PassRegistry &)
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI ScheduleDAGSDNodes * createILPListDAGScheduler(SelectionDAGISel *IS, CodeGenOptLevel)
createILPListDAGScheduler - This creates a bottom up register pressure aware list scheduler that trie...
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
auto predecessors(const MachineBasicBlock *BB)
LLVM_ABI void initializeBranchProbabilityInfoWrapperPassPass(PassRegistry &)
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
constexpr int64_t SignExtend64(uint64_t x)
Sign-extend the number in the bottom B bits of X to a 64-bit integer.
LLVM_ABI ScheduleDAGSDNodes * createVLIWDAGScheduler(SelectionDAGISel *IS, CodeGenOptLevel OptLevel)
createVLIWDAGScheduler - Scheduler for VLIW targets.
static auto filterDbgVars(iterator_range< simple_ilist< DbgRecord >::iterator > R)
Filter the DbgRecord range to DbgVariableRecord types only and downcast.
LLVM_ABI Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
LLVM_ABI Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.
Implement std::hash so that hash_code can be used in STL containers.
This struct is a compact representation of a valid (non-zero power of two) alignment.
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
bool isInteger() const
Return true if this is an integer or a vector integer type.
A struct capturing PGO tunables.
This represents a list of ValueType's that has been intern'd by a SelectionDAG.
Clients of various APIs that cause global effects on the DAG can optionally implement this interface.
void addIPToStateRange(const InvokeInst *II, MCSymbol *InvokeBegin, MCSymbol *InvokeEnd)
DenseMap< const BasicBlock *, int > BlockToStateMap