80#include "llvm/IR/IntrinsicsWebAssembly.h"
118#define DEBUG_TYPE "isel"
119#define ISEL_DUMP_DEBUG_TYPE DEBUG_TYPE "-dump"
121STATISTIC(NumFastIselFailures,
"Number of instructions fast isel failed on");
122STATISTIC(NumFastIselSuccess,
"Number of instructions fast isel selected");
123STATISTIC(NumFastIselBlocks,
"Number of blocks selected entirely by fast isel");
124STATISTIC(NumDAGBlocks,
"Number of blocks selected using DAG");
125STATISTIC(NumDAGIselRetries,
"Number of times dag isel has to try another path");
126STATISTIC(NumEntryBlocks,
"Number of entry blocks encountered");
128 "Number of entry blocks where fast isel failed to lower arguments");
132 cl::desc(
"Enable abort calls when \"fast\" instruction selection "
133 "fails to lower an instruction: 0 disable the abort, 1 will "
134 "abort but for args, calls and terminators, 2 will also "
135 "abort for argument lowering, and 3 will never fallback "
136 "to SelectionDAG."));
140 cl::desc(
"Emit a diagnostic when \"fast\" instruction selection "
141 "falls back to SelectionDAG."));
145 cl::desc(
"use Machine Branch Probability Info"),
151 cl::desc(
"Print DAGs with sorted nodes in debug dump"),
156 cl::desc(
"Only display the basic block whose name "
157 "matches this for all view-*-dags options"));
160 cl::desc(
"Pop up a window to show dags before the first "
161 "dag combine pass"));
164 cl::desc(
"Pop up a window to show dags before legalize types"));
167 cl::desc(
"Pop up a window to show dags before the post "
168 "legalize types dag combine pass"));
171 cl::desc(
"Pop up a window to show dags before legalize"));
174 cl::desc(
"Pop up a window to show dags before the second "
175 "dag combine pass"));
178 cl::desc(
"Pop up a window to show isel dags as they are selected"));
181 cl::desc(
"Pop up a window to show sched dags as they are processed"));
184 cl::desc(
"Pop up a window to show SUnit dags after they are processed"));
193#define ISEL_DUMP(X) \
195 if (llvm::DebugFlag && \
196 (isCurrentDebugType(DEBUG_TYPE) || \
197 (isCurrentDebugType(ISEL_DUMP_DEBUG_TYPE) && MatchFilterFuncName))) { \
202#define ISEL_DUMP(X) do { } while (false)
222 cl::desc(
"Instruction schedulers available (before register"
235 return Arg.hasAttribute(Attribute::AttrKind::SwiftAsync);
265 SavedOptLevel = IS.OptLevel;
266 SavedFastISel = IS.TM.Options.EnableFastISel;
267 if (NewOptLevel != SavedOptLevel) {
268 IS.OptLevel = NewOptLevel;
269 IS.TM.setOptLevel(NewOptLevel);
270 LLVM_DEBUG(
dbgs() <<
"\nChanging optimization level for Function "
271 << IS.MF->getFunction().getName() <<
"\n");
272 LLVM_DEBUG(
dbgs() <<
"\tBefore: -O" <<
static_cast<int>(SavedOptLevel)
273 <<
" ; After: -O" <<
static_cast<int>(NewOptLevel)
276 IS.TM.setFastISel(IS.TM.getO0WantsFastISel());
279 IS.TM.setFastISel(
false);
281 dbgs() <<
"\tFastISel is "
282 << (IS.TM.Options.EnableFastISel ?
"enabled" :
"disabled")
287 if (IS.OptLevel == SavedOptLevel)
289 LLVM_DEBUG(
dbgs() <<
"\nRestoring optimization level for Function "
290 << IS.MF->getFunction().getName() <<
"\n");
291 LLVM_DEBUG(
dbgs() <<
"\tBefore: -O" <<
static_cast<int>(IS.OptLevel)
292 <<
" ; After: -O" <<
static_cast<int>(SavedOptLevel) <<
"\n");
293 IS.OptLevel = SavedOptLevel;
294 IS.TM.setOptLevel(SavedOptLevel);
295 IS.TM.setFastISel(SavedFastISel);
308 if (
auto *SchedulerCtor = ST.getDAGScheduler(OptLevel)) {
309 return SchedulerCtor(IS, OptLevel);
313 (ST.enableMachineScheduler() && ST.enableMachineSchedDefaultSched()) ||
327 "Unknown sched type!");
336 switch (
MI.getOpcode()) {
337 case TargetOpcode::STATEPOINT:
340 case TargetOpcode::STACKMAP:
341 case TargetOpcode::PATCHPOINT:
348 dbgs() <<
"If a target marks an instruction with "
349 "'usesCustomInserter', it must implement "
350 "TargetLowering::EmitInstrWithCustomInserter!\n";
358 "If a target marks an instruction with 'hasPostISelHook', "
359 "it must implement TargetLowering::AdjustInstrPostInstrSelection!");
367 char &ID, std::unique_ptr<SelectionDAGISel> S)
391 : Selector->OptLevel;
395 Selector->initializeAnalysisResults(*
this);
396 return Selector->runOnMachineFunction(MF);
425 if (
UseMBPI && RegisterPGOPasses)
432 if (RegisterPGOPasses)
462 : Selector->OptLevel;
465 Selector->initializeAnalysisResults(MFAM);
466 Selector->runOnMachineFunction(MF);
492 ORE = std::make_unique<OptimizationRemarkEmitter>(&Fn);
496 if (PSI && PSI->hasProfileSummary() && RegisterPGOPasses)
507 if (!LibcallResult) {
509 "' analysis required");
520 if (
UseMBPI && RegisterPGOPasses)
556 ORE = std::make_unique<OptimizationRemarkEmitter>(&Fn);
560 if (PSI && PSI->hasProfileSummary() && RegisterPGOPasses)
569 UA = &UAPass->getUniformityInfo();
582 if (
UseMBPI && RegisterPGOPasses)
612 MF->setHasInlineAsm(
false);
639 TLI->initializeSplitCSR(EntryMBB);
641 SelectAllBasicBlocks(Fn);
661 auto J =
FuncInfo->RegFixups.find(To);
668 MRI.constrainRegClass(To,
MRI.getRegClass(From));
670 MRI.replaceRegWith(From, To);
684 if (!
MBB.succ_empty())
688 if (Term !=
MBB.end() && Term->isReturn()) {
693 TLI->insertCopiesSplitCSR(EntryMBB, Returns);
697 if (!
FuncInfo->ArgDbgValues.empty())
698 for (std::pair<MCRegister, Register> LI :
RegInfo->liveins())
703 for (
unsigned i = 0, e =
FuncInfo->ArgDbgValues.size(); i != e; ++i) {
705 assert(
MI->getOpcode() != TargetOpcode::DBG_VALUE_LIST &&
706 "Function parameters should not be described by DBG_VALUE_LIST.");
707 bool hasFI =
MI->getDebugOperand(0).isFI();
709 hasFI ?
TRI.getFrameRegister(*
MF) :
MI->getDebugOperand(0).getReg();
710 if (Reg.isPhysical())
717 Def->getParent()->insert(std::next(InsertPos),
MI);
728 if (!Reg.isPhysical())
730 auto LDI = LiveInMap.
find(Reg);
731 if (LDI != LiveInMap.
end()) {
732 assert(!hasFI &&
"There's no handling of frame pointer updating here yet "
736 const MDNode *Variable =
MI->getDebugVariable();
737 const MDNode *Expr =
MI->getDebugExpression();
739 bool IsIndirect =
MI->isIndirectDebugValue();
741 assert(
MI->getDebugOffset().getImm() == 0 &&
742 "DBG_VALUE with nonzero offset");
744 "Expected inlined-at fields to agree");
745 assert(
MI->getOpcode() != TargetOpcode::DBG_VALUE_LIST &&
746 "Didn't expect to see a DBG_VALUE_LIST here");
748 BuildMI(*EntryMBB, ++InsertPos,
DL,
TII->get(TargetOpcode::DBG_VALUE),
749 IsIndirect, LDI->second, Variable, Expr);
756 if (
UseMI.isDebugValue())
758 if (
UseMI.isCopy() && !CopyUseMI &&
UseMI.getParent() == EntryMBB) {
767 TRI.getRegSizeInBits(LDI->second,
MRI) ==
782 if (
MF->useDebugInstrRef())
783 MF->finalizeDebugInstrRefs();
787 for (
const auto &
MBB : *
MF) {
791 for (
const auto &
MI :
MBB) {
793 if ((
MCID.isCall() && !
MCID.isReturn()) ||
794 MI.isStackAligningInlineAsm()) {
797 if (
MI.isInlineAsm()) {
798 MF->setHasInlineAsm(
true);
807 ISEL_DUMP(
dbgs() <<
"*** MachineFunction at end of ISel ***\n");
819 if (!R.getLocation().isValid() || ShouldAbort)
820 R << (
" (in function: " + MF.
getName() +
")").str();
838 bool HaveFakeUse =
false;
839 bool HaveTailCall =
false;
842 if (CI->isTailCall()) {
847 if (
II->getIntrinsicID() == Intrinsic::fake_use)
849 }
while (
I != Begin);
852 if (!HaveTailCall || !HaveFakeUse)
861 FakeUse && FakeUse->getIntrinsicID() == Intrinsic::fake_use) {
863 !UsedDef || UsedDef->getParent() !=
I->getParent() ||
864 UsedDef->comesBefore(&*
I))
869 for (
auto *Inst : FakeUses)
870 Inst->moveBefore(*Inst->getParent(),
I);
877 CurDAG->NewNodesMustHaveLegalTypes =
false;
886 SDB->visitDbgInfo(*
I);
891 HadTailCall =
SDB->HasTailCall;
892 SDB->resolveOrClearDbgInfo();
899void SelectionDAGISel::ComputeLiveOutVRegInfo() {
900 SmallPtrSet<SDNode *, 16>
Added;
913 if (
Op.getValueType() == MVT::Other &&
Added.insert(
Op.getNode()).second)
926 EVT SrcVT = Src.getValueType();
930 unsigned NumSignBits =
CurDAG->ComputeNumSignBits(Src);
933 }
while (!Worklist.
empty());
936void SelectionDAGISel::CodeGenAndEmitDAG() {
937 StringRef GroupName =
"sdag";
938 StringRef GroupDescription =
"Instruction Selection and Scheduling";
939 std::string BlockName;
940 bool MatchFilterBB =
false;
944 CurDAG->NewNodesMustHaveLegalTypes =
false;
949 FuncInfo->MBB->getBasicBlock()->getName());
958 (
MF->getName() +
":" +
FuncInfo->MBB->getBasicBlock()->getName()).str();
965#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
966 if (
TTI->hasBranchDivergence())
967 CurDAG->VerifyDAGDivergence();
971 CurDAG->viewGraph(
"dag-combine1 input for " + BlockName);
975 NamedRegionTimer
T(
"combine1",
"DAG Combining 1", GroupName,
985#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
986 if (
TTI->hasBranchDivergence())
987 CurDAG->VerifyDAGDivergence();
993 CurDAG->viewGraph(
"legalize-types input for " + BlockName);
997 NamedRegionTimer
T(
"legalize_types",
"Type Legalization", GroupName,
1007#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
1008 if (
TTI->hasBranchDivergence())
1009 CurDAG->VerifyDAGDivergence();
1013 CurDAG->NewNodesMustHaveLegalTypes =
true;
1017 CurDAG->viewGraph(
"dag-combine-lt input for " + BlockName);
1021 NamedRegionTimer
T(
"combine_lt",
"DAG Combining after legalize types",
1026 ISEL_DUMP(
dbgs() <<
"\nOptimized type-legalized selection DAG: "
1031#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
1032 if (
TTI->hasBranchDivergence())
1033 CurDAG->VerifyDAGDivergence();
1038 NamedRegionTimer
T(
"legalize_vec",
"Vector Legalization", GroupName,
1049#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
1050 if (
TTI->hasBranchDivergence())
1051 CurDAG->VerifyDAGDivergence();
1055 NamedRegionTimer
T(
"legalize_types2",
"Type Legalization 2", GroupName,
1060 ISEL_DUMP(
dbgs() <<
"\nVector/type-legalized selection DAG: "
1065#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
1066 if (
TTI->hasBranchDivergence())
1067 CurDAG->VerifyDAGDivergence();
1071 CurDAG->viewGraph(
"dag-combine-lv input for " + BlockName);
1075 NamedRegionTimer
T(
"combine_lv",
"DAG Combining after legalize vectors",
1080 ISEL_DUMP(
dbgs() <<
"\nOptimized vector-legalized selection DAG: "
1085#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
1086 if (
TTI->hasBranchDivergence())
1087 CurDAG->VerifyDAGDivergence();
1092 CurDAG->viewGraph(
"legalize input for " + BlockName);
1095 NamedRegionTimer
T(
"legalize",
"DAG Legalization", GroupName,
1105#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
1106 if (
TTI->hasBranchDivergence())
1107 CurDAG->VerifyDAGDivergence();
1111 CurDAG->viewGraph(
"dag-combine2 input for " + BlockName);
1115 NamedRegionTimer
T(
"combine2",
"DAG Combining 2", GroupName,
1125#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
1126 if (
TTI->hasBranchDivergence())
1127 CurDAG->VerifyDAGDivergence();
1131 ComputeLiveOutVRegInfo();
1134 CurDAG->viewGraph(
"isel input for " + BlockName);
1139 NamedRegionTimer
T(
"isel",
"Instruction Selection", GroupName,
1141 DoInstructionSelection();
1150 CurDAG->viewGraph(
"scheduler input for " + BlockName);
1154 Scheduler.reset(CreateScheduler());
1156 NamedRegionTimer
T(
"sched",
"Instruction Scheduling", GroupName,
1162 Scheduler->viewGraph();
1166 MachineBasicBlock *FirstMBB =
FuncInfo->MBB, *LastMBB;
1168 NamedRegionTimer
T(
"emit",
"Instruction Creation", GroupName,
1178 if (FirstMBB != LastMBB)
1179 SDB->UpdateSplitBlock(FirstMBB, LastMBB);
1194 : SelectionDAG::DAGUpdateListener(DAG), ISelPosition(isp) {}
1199 void NodeDeleted(SDNode *
N, SDNode *
E)
override {
1207 void NodeInserted(SDNode *
N)
override {
1208 SDNode *CurNode = &*ISelPosition;
1209 if (MDNode *MD = DAG.getPCSections(CurNode))
1210 DAG.addPCSections(
N, MD);
1211 if (MDNode *MMRA = DAG.getMMRAMetadata(CurNode))
1212 DAG.addMMRAMetadata(
N, MMRA);
1242 while (!Nodes.
empty()) {
1244 for (
auto *U :
N->users()) {
1245 auto UId = U->getNodeId();
1258 int InvalidId = -(
N->getNodeId() + 1);
1259 N->setNodeId(InvalidId);
1264 int Id =
N->getNodeId();
1270void SelectionDAGISel::DoInstructionSelection() {
1273 <<
FuncInfo->MBB->getName() <<
"'\n");
1291 ISelUpdater ISU(*
CurDAG, ISelPosition);
1302 if (
Node->use_empty())
1309 while (!Nodes.
empty()) {
1326 "Node has already selected predecessor node");
1338 if (!
TLI->isStrictFPEnabled() &&
Node->isStrictFPOpcode()) {
1343 switch (
Node->getOpcode()) {
1352 ActionVT =
Node->getOperand(1).getValueType();
1355 ActionVT =
Node->getValueType(0);
1358 if (
TLI->getOperationAction(
Node->getOpcode(), ActionVT)
1363 LLVM_DEBUG(
dbgs() <<
"\nISEL: Starting selection on root node: ";
1369 CurDAG->setRoot(Dummy.getValue());
1381 if (IID == Intrinsic::eh_exceptionpointer ||
1382 IID == Intrinsic::eh_exceptioncode)
1397 bool IsSingleCatchAllClause =
1402 bool IsCatchLongjmp = CPI->
arg_size() == 0;
1403 if (!IsSingleCatchAllClause && !IsCatchLongjmp) {
1405 bool IntrFound =
false;
1409 if (IID == Intrinsic::wasm_landingpad_index) {
1410 Value *IndexArg =
Call->getArgOperand(1);
1418 assert(IntrFound &&
"wasm.landingpad.index intrinsic not found!");
1425bool SelectionDAGISel::PrepareEHLandingPad() {
1430 TLI->getRegClassFor(
TLI->getPointerTy(
CurDAG->getDataLayout()));
1441 MCRegister EHPhysReg =
TLI->getExceptionPointerRegister(
1442 FuncInfo->ExceptionModel, PersonalityFn);
1443 assert(EHPhysReg &&
"target lacks exception pointer register");
1447 TII->get(TargetOpcode::COPY), VReg)
1458 const MCInstrDesc &
II =
TII->get(TargetOpcode::EH_LABEL);
1464 const TargetRegisterInfo &
TRI = *
MF->getSubtarget().getRegisterInfo();
1465 if (
auto *RegMask =
TRI.getCustomEHPadPreservedMask(*
MF))
1466 MF->getRegInfo().addPhysRegsUsedFromRegMask(RegMask);
1473 MF->setCallSiteLandingPad(Label,
SDB->LPadToCallSiteMap[
MBB]);
1475 if (MCRegister
Reg =
TLI->getExceptionPointerRegister(
1476 FuncInfo->ExceptionModel, PersonalityFn))
1479 if (MCRegister
Reg =
TLI->getExceptionSelectorRegister(
1480 FuncInfo->ExceptionModel, PersonalityFn))
1489 llvm::WinEHFuncInfo *EHInfo =
MF->getWinEHFuncInfo();
1492 for (MachineBasicBlock &
MBB : *
MF) {
1502 MachineInstr *MIb = &*MBBb;
1507 MCSymbol *BeginLabel =
MF->getContext().createTempSymbol();
1508 MCSymbol *EndLabel =
MF->getContext().createTempSymbol();
1511 TII->get(TargetOpcode::EH_LABEL))
1514 MachineInstr *MIe = &*(--MBBe);
1520 TII->get(TargetOpcode::EH_LABEL))
1531 return !
I->mayHaveSideEffects() &&
1532 !
I->isTerminator() &&
1544 auto ArgIt = FuncInfo.
ValueMap.find(Arg);
1545 if (ArgIt == FuncInfo.
ValueMap.end())
1547 Register ArgVReg = ArgIt->getSecond();
1551 if (VirtReg == ArgVReg) {
1555 LLVM_DEBUG(
dbgs() <<
"processDbgDeclare: setVariableDbgInfo Var=" << *Var
1556 <<
", Expr=" << *Expr <<
", MCRegister=" << PhysReg
1557 <<
", DbgLoc=" << DbgLoc <<
"\n");
1568 <<
" (bad address)\n");
1575 if (!Address->getType()->isPointerTy())
1581 assert(Var &&
"Missing variable");
1582 assert(DbgLoc &&
"Missing location");
1586 APInt Offset(
DL.getIndexTypeSizeInBits(Address->getType()), 0);
1587 Address = Address->stripAndAccumulateInBoundsConstantOffsets(
DL,
Offset);
1592 int FI = std::numeric_limits<int>::max();
1600 if (FI == std::numeric_limits<int>::max())
1603 if (
Offset.getBoolValue())
1607 LLVM_DEBUG(
dbgs() <<
"processDbgDeclare: setVariableDbgInfo Var=" << *Var
1608 <<
", Expr=" << *Expr <<
", FI=" << FI
1609 <<
", DbgLoc=" << DbgLoc <<
"\n");
1621 DVR.getExpression(), DVR.getVariable(),
1636 assert(!It->Values.hasArgList() &&
"Single loc variadic ops not supported");
1642void SelectionDAGISel::SelectAllBasicBlocks(
const Function &Fn) {
1643 assert(!Scheduler &&
"scheduler leaked from previous function");
1646 FastISel *FastIS =
nullptr;
1647 if (
TM.Options.EnableFastISel) {
1652 ReversePostOrderTraversal<const Function*> RPOT(&Fn);
1666 LowerArguments(Fn,
false);
1673 ++NumFastIselFailLowerArguments;
1675 OptimizationRemarkMissed
R(
"sdagisel",
"FastISelFailure",
1678 R <<
"FastISel didn't lower all arguments: "
1683 LowerArguments(Fn,
true);
1686 CodeGenAndEmitDAG();
1700 if (FastIS && Inserted)
1705 "expected AssignmentTrackingAnalysis pass results");
1713 for (
const BasicBlock *LLVMBB : RPOT) {
1715 bool AllPredsVisited =
true;
1718 AllPredsVisited =
false;
1723 if (AllPredsVisited) {
1724 for (
const PHINode &PN : LLVMBB->
phis())
1725 FuncInfo->ComputePHILiveOutRegInfo(&PN);
1727 for (
const PHINode &PN : LLVMBB->
phis())
1728 FuncInfo->InvalidatePHILiveOutRegInfo(&PN);
1739 const_cast<BasicBlock *
>(LLVMBB)->getFirstNonPHIIt();
1759 if (!PrepareEHLandingPad())
1765 if (NewRoot && NewRoot !=
CurDAG->getRoot())
1766 CurDAG->setRoot(NewRoot);
1775 unsigned NumFastIselRemaining = std::distance(Begin,
End);
1781 for (; BI != Begin; --BI) {
1787 --NumFastIselRemaining;
1798 --NumFastIselRemaining;
1799 ++NumFastIselSuccess;
1806 while (BeforeInst != &*Begin) {
1816 <<
"FastISel folded load: " << *BeforeInst <<
"\n");
1819 --NumFastIselRemaining;
1820 ++NumFastIselSuccess;
1834 OptimizationRemarkMissed
R(
"sdagisel",
"FastISelFailure",
1837 R <<
"FastISel missed call";
1840 std::string InstStrStorage;
1841 raw_string_ostream InstStr(InstStrStorage);
1844 R <<
": " << InstStrStorage;
1853 NumFastIselFailures += NumFastIselRemaining;
1864 bool HadTailCall =
false;
1866 SelectBasicBlock(Inst->
getIterator(), BI, HadTailCall);
1878 unsigned RemainingNow = std::distance(Begin, BI);
1879 NumFastIselFailures += NumFastIselRemaining - RemainingNow;
1880 NumFastIselRemaining = RemainingNow;
1884 OptimizationRemarkMissed
R(
"sdagisel",
"FastISelFailure",
1890 R <<
"FastISel missed terminator";
1894 R <<
"FastISel missed";
1898 std::string InstStrStorage;
1899 raw_string_ostream InstStr(InstStrStorage);
1901 R <<
": " << InstStrStorage;
1906 NumFastIselFailures += NumFastIselRemaining;
1913 if (
SP->shouldEmitSDCheck(*LLVMBB)) {
1914 bool FunctionBasedInstrumentation =
1917 SDB->SPDescriptor.initialize(LLVMBB,
FuncInfo->getMBB(LLVMBB),
1918 FunctionBasedInstrumentation);
1924 ++NumFastIselBlocks;
1931 SelectBasicBlock(Begin, BI, HadTailCall);
1943 FuncInfo->PHINodesToUpdate.clear();
1949 reportIPToStateForBlocks(
MF);
1951 SP->copyToMachineFrameInfo(
MF->getFrameInfo());
1957 SDB->clearDanglingDebugInfo();
1958 SDB->SPDescriptor.resetPerFunctionState();
1962SelectionDAGISel::FinishBasicBlock() {
1964 <<
FuncInfo->PHINodesToUpdate.size() <<
"\n";
1965 for (
unsigned i = 0, e =
FuncInfo->PHINodesToUpdate.size(); i != e;
1967 <<
"Node " << i <<
" : (" <<
FuncInfo->PHINodesToUpdate[i].first
1973 for (
unsigned i = 0, e =
FuncInfo->PHINodesToUpdate.size(); i != e; ++i) {
1974 MachineInstrBuilder
PHI(*
MF,
FuncInfo->PHINodesToUpdate[i].first);
1976 "This is not a machine PHI node that we are updating!");
1977 if (!
FuncInfo->MBB->isSuccessor(
PHI->getParent()))
1983 if (
SDB->SPDescriptor.shouldEmitFunctionBasedCheckStackProtector()) {
1986 MachineBasicBlock *ParentMBB =
SDB->SPDescriptor.getParentMBB();
1991 SDB->visitSPDescriptorParent(
SDB->SPDescriptor, ParentMBB);
1994 CodeGenAndEmitDAG();
1997 SDB->SPDescriptor.resetPerBBState();
1998 }
else if (
SDB->SPDescriptor.shouldEmitStackProtector()) {
1999 MachineBasicBlock *ParentMBB =
SDB->SPDescriptor.getParentMBB();
2000 MachineBasicBlock *SuccessMBB =
SDB->SPDescriptor.getSuccessMBB();
2012 SuccessMBB->
splice(SuccessMBB->
end(), ParentMBB, SplitPoint,
2018 SDB->visitSPDescriptorParent(
SDB->SPDescriptor, ParentMBB);
2021 CodeGenAndEmitDAG();
2024 MachineBasicBlock *FailureMBB =
SDB->SPDescriptor.getFailureMBB();
2025 if (FailureMBB->
empty()) {
2028 SDB->visitSPDescriptorFailure(
SDB->SPDescriptor);
2031 CodeGenAndEmitDAG();
2035 SDB->SPDescriptor.resetPerBBState();
2039 for (
auto &BTB :
SDB->SL->BitTestCases) {
2049 CodeGenAndEmitDAG();
2052 BranchProbability UnhandledProb = BTB.Prob;
2053 for (
unsigned j = 0, ej = BTB.Cases.size(); j != ej; ++j) {
2054 UnhandledProb -= BTB.Cases[
j].ExtraProb;
2068 MachineBasicBlock *NextMBB;
2069 if ((BTB.ContiguousRange || BTB.FallthroughUnreachable) && j + 2 == ej) {
2072 NextMBB = BTB.Cases[
j + 1].TargetBB;
2073 }
else if (j + 1 == ej) {
2075 NextMBB = BTB.Default;
2078 NextMBB = BTB.Cases[
j + 1].ThisBB;
2081 SDB->visitBitTestCase(BTB, NextMBB, UnhandledProb, BTB.Reg, BTB.Cases[j],
2086 CodeGenAndEmitDAG();
2088 if ((BTB.ContiguousRange || BTB.FallthroughUnreachable) && j + 2 == ej) {
2090 BTB.Cases.pop_back();
2096 for (
const std::pair<MachineInstr *, Register> &
P :
2098 MachineInstrBuilder
PHI(*
MF,
P.first);
2099 MachineBasicBlock *PHIBB =
PHI->getParent();
2101 "This is not a machine PHI node that we are updating!");
2104 if (PHIBB == BTB.Default) {
2105 PHI.addReg(
P.second).addMBB(BTB.Parent);
2106 if (!BTB.ContiguousRange) {
2107 PHI.addReg(
P.second).addMBB(BTB.Cases.back().ThisBB);
2111 for (
const SwitchCG::BitTestCase &
BT : BTB.Cases) {
2112 MachineBasicBlock* cBB =
BT.ThisBB;
2114 PHI.addReg(
P.second).addMBB(cBB);
2118 SDB->SL->BitTestCases.clear();
2123 for (
unsigned i = 0, e =
SDB->SL->JTCases.size(); i != e; ++i) {
2125 if (!
SDB->SL->JTCases[i].first.Emitted) {
2127 FuncInfo->MBB =
SDB->SL->JTCases[i].first.HeaderBB;
2130 SDB->visitJumpTableHeader(
SDB->SL->JTCases[i].second,
2134 CodeGenAndEmitDAG();
2141 SDB->visitJumpTable(
SDB->SL->JTCases[i].second);
2144 CodeGenAndEmitDAG();
2147 for (
unsigned pi = 0, pe =
FuncInfo->PHINodesToUpdate.size();
2149 MachineInstrBuilder
PHI(*
MF,
FuncInfo->PHINodesToUpdate[pi].first);
2152 "This is not a machine PHI node that we are updating!");
2154 if (PHIBB ==
SDB->SL->JTCases[i].second.Default)
2156 .addMBB(
SDB->SL->JTCases[i].first.HeaderBB);
2158 if (
FuncInfo->MBB->isSuccessor(PHIBB))
2162 SDB->SL->JTCases.clear();
2166 for (
unsigned i = 0, e =
SDB->SL->SwitchCases.size(); i != e; ++i) {
2172 SmallVector<MachineBasicBlock *, 2> Succs;
2174 if (
SDB->SL->SwitchCases[i].TrueBB !=
SDB->SL->SwitchCases[i].FalseBB)
2181 CodeGenAndEmitDAG();
2185 MachineBasicBlock *ThisBB =
FuncInfo->MBB;
2191 for (MachineBasicBlock *Succ : Succs) {
2202 for (
unsigned pn = 0; ; ++pn) {
2204 "Didn't find PHI entry!");
2205 if (
FuncInfo->PHINodesToUpdate[pn].first ==
PHI) {
2206 PHI.addReg(
FuncInfo->PHINodesToUpdate[pn].second).addMBB(ThisBB);
2214 SDB->SL->SwitchCases.clear();
2235 int64_t DesiredMaskS)
const {
2236 const APInt &ActualMask = RHS->getAPIntValue();
2239 const APInt &DesiredMask =
APInt(LHS.getValueSizeInBits(), DesiredMaskS,
2243 if (ActualMask == DesiredMask)
2252 APInt NeededMask = DesiredMask & ~ActualMask;
2253 if (
CurDAG->MaskedValueIsZero(LHS, NeededMask))
2267 int64_t DesiredMaskS)
const {
2268 const APInt &ActualMask = RHS->getAPIntValue();
2271 const APInt &DesiredMask =
APInt(LHS.getValueSizeInBits(), DesiredMaskS,
2275 if (ActualMask == DesiredMask)
2284 APInt NeededMask = DesiredMask & ~ActualMask;
2304 std::list<HandleSDNode> Handles;
2309 Handles.emplace_back(
2313 if (
Ops[e - 1].getValueType() == MVT::Glue)
2318 if (!Flags.isMemKind() && !Flags.isFuncKind()) {
2320 Handles.insert(Handles.end(),
Ops.begin() + i,
2321 Ops.begin() + i + Flags.getNumOperandRegisters() + 1);
2322 i += Flags.getNumOperandRegisters() + 1;
2324 assert(Flags.getNumOperandRegisters() == 1 &&
2325 "Memory operand with multiple values?");
2327 unsigned TiedToOperand;
2328 if (Flags.isUseOperandTiedToDef(TiedToOperand)) {
2332 for (; TiedToOperand; --TiedToOperand) {
2333 CurOp += Flags.getNumOperandRegisters() + 1;
2339 std::vector<SDValue> SelOps;
2341 Flags.getMemoryConstraintID();
2350 Flags.setMemConstraint(ConstraintID);
2351 Handles.emplace_back(
CurDAG->getTargetConstant(Flags,
DL, MVT::i32));
2358 if (e !=
Ops.size())
2359 Handles.emplace_back(
Ops.back());
2362 for (
auto &handle : Handles)
2363 Ops.push_back(handle.getValue());
2369 bool IgnoreChains) {
2378 Visited.
insert(ImmedUse);
2383 if ((
Op.getValueType() == MVT::Other && IgnoreChains) ||
N == Def)
2385 if (!Visited.
insert(
N).second)
2391 if (Root != ImmedUse) {
2395 if ((
Op.getValueType() == MVT::Other && IgnoreChains) ||
N == Def)
2397 if (!Visited.
insert(
N).second)
2412 return N.hasOneUse();
2419 bool IgnoreChains) {
2468 while (VT == MVT::Glue) {
2479 IgnoreChains =
false;
2485void SelectionDAGISel::Select_INLINEASM(
SDNode *
N) {
2488 std::vector<SDValue>
Ops(
N->op_begin(),
N->op_end());
2491 const EVT VTs[] = {MVT::Other, MVT::Glue};
2498void SelectionDAGISel::Select_READ_REGISTER(
SDNode *
Op) {
2503 EVT VT =
Op->getValueType(0);
2514 "\" for llvm.read_register",
2515 Fn,
Op->getDebugLoc()));
2517 SDValue(
CurDAG->getMachineNode(TargetOpcode::IMPLICIT_DEF, dl, VT), 0);
2521 CurDAG->getCopyFromReg(
Op->getOperand(0), dl,
Reg,
Op->getValueType(0));
2529void SelectionDAGISel::Select_WRITE_REGISTER(
SDNode *
Op) {
2534 EVT VT =
Op->getOperand(2).getValueType();
2544 "\" for llvm.write_register",
2545 Fn,
Op->getDebugLoc()));
2549 CurDAG->getCopyToReg(
Op->getOperand(0), dl,
Reg,
Op->getOperand(2));
2557void SelectionDAGISel::Select_UNDEF(
SDNode *
N) {
2558 CurDAG->SelectNodeTo(
N, TargetOpcode::IMPLICIT_DEF,
N->getValueType(0));
2563void SelectionDAGISel::Select_FAKE_USE(
SDNode *
N) {
2564 CurDAG->SelectNodeTo(
N, TargetOpcode::FAKE_USE,
N->getValueType(0),
2565 N->getOperand(1),
N->getOperand(0));
2568void SelectionDAGISel::Select_RELOC_NONE(
SDNode *
N) {
2569 CurDAG->SelectNodeTo(
N, TargetOpcode::RELOC_NONE,
N->getValueType(0),
2570 N->getOperand(1),
N->getOperand(0));
2573void SelectionDAGISel::Select_FREEZE(
SDNode *
N) {
2577 CurDAG->SelectNodeTo(
N, TargetOpcode::COPY,
N->getValueType(0),
2581void SelectionDAGISel::Select_ARITH_FENCE(
SDNode *
N) {
2582 CurDAG->SelectNodeTo(
N, TargetOpcode::ARITH_FENCE,
N->getValueType(0),
2586void SelectionDAGISel::Select_MEMBARRIER(
SDNode *
N) {
2587 CurDAG->SelectNodeTo(
N, TargetOpcode::MEMBARRIER,
N->getValueType(0),
2591void SelectionDAGISel::Select_CONVERGENCECTRL_ANCHOR(
SDNode *
N) {
2592 CurDAG->SelectNodeTo(
N, TargetOpcode::CONVERGENCECTRL_ANCHOR,
2593 N->getValueType(0));
2596void SelectionDAGISel::Select_CONVERGENCECTRL_ENTRY(
SDNode *
N) {
2597 CurDAG->SelectNodeTo(
N, TargetOpcode::CONVERGENCECTRL_ENTRY,
2598 N->getValueType(0));
2601void SelectionDAGISel::Select_CONVERGENCECTRL_LOOP(
SDNode *
N) {
2602 CurDAG->SelectNodeTo(
N, TargetOpcode::CONVERGENCECTRL_LOOP,
2603 N->getValueType(0),
N->getOperand(0));
2608 SDNode *OpNode = OpVal.
getNode();
2616 CurDAG->getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
2620 Ops.push_back(OpVal);
2624void SelectionDAGISel::Select_STACKMAP(
SDNode *
N) {
2626 auto *It =
N->op_begin();
2635 assert(
ID.getValueType() == MVT::i64);
2641 Ops.push_back(Shad);
2644 for (; It !=
N->op_end(); It++)
2645 pushStackMapLiveVariable(
Ops, *It,
DL);
2647 Ops.push_back(Chain);
2648 Ops.push_back(InGlue);
2650 SDVTList NodeTys =
CurDAG->getVTList(MVT::Other, MVT::Glue);
2651 CurDAG->SelectNodeTo(
N, TargetOpcode::STACKMAP, NodeTys,
Ops);
2654void SelectionDAGISel::Select_PATCHPOINT(
SDNode *
N) {
2656 auto *It =
N->op_begin();
2661 std::optional<SDValue> Glue;
2662 if (It->getValueType() == MVT::Glue)
2668 assert(
ID.getValueType() == MVT::i64);
2674 Ops.push_back(Shad);
2677 Ops.push_back(*It++);
2682 Ops.push_back(NumArgs);
2685 Ops.push_back(*It++);
2689 Ops.push_back(*It++);
2692 for (; It !=
N->op_end(); It++)
2693 pushStackMapLiveVariable(
Ops, *It,
DL);
2696 Ops.push_back(RegMask);
2697 Ops.push_back(Chain);
2698 if (Glue.has_value())
2699 Ops.push_back(*Glue);
2701 SDVTList NodeTys =
N->getVTList();
2702 CurDAG->SelectNodeTo(
N, TargetOpcode::PATCHPOINT, NodeTys,
Ops);
2708 assert(Val >= 128 &&
"Not a VBR");
2714 NextBits = MatcherTable[Idx++];
2715 Val |= (NextBits&127) << Shift;
2717 }
while (NextBits & 128);
2728 NextBits = MatcherTable[Idx++];
2729 Val |= (NextBits & 127) << Shift;
2731 }
while (NextBits & 128);
2733 if (Shift < 64 && (NextBits & 0x40))
2743 unsigned SimpleVT = MatcherTable[MatcherIndex++];
2745 SimpleVT =
GetVBR(SimpleVT, MatcherTable, MatcherIndex);
2754 unsigned Index = MatcherTable[MatcherIndex++];
2758void SelectionDAGISel::Select_JUMP_TABLE_DEBUG_INFO(
SDNode *
N) {
2760 CurDAG->SelectNodeTo(
N, TargetOpcode::JUMP_TABLE_DEBUG_INFO, MVT::Glue,
2761 CurDAG->getTargetConstant(
N->getConstantOperandVal(1),
2762 dl, MVT::i64,
true));
2767void SelectionDAGISel::UpdateChains(
2774 if (!ChainNodesMatched.
empty()) {
2776 "Matched input chains but didn't produce a chain");
2779 for (
unsigned i = 0, e = ChainNodesMatched.
size(); i != e; ++i) {
2780 SDNode *ChainNode = ChainNodesMatched[i];
2787 "Deleted node left in chain");
2791 if (ChainNode == NodeToMatch && isMorphNodeTo)
2798 SelectionDAG::DAGNodeDeletedListener NDL(
2799 *
CurDAG, [&](SDNode *
N, SDNode *
E) {
2800 llvm::replace(ChainNodesMatched,
N,
static_cast<SDNode *
>(
nullptr));
2806 if (ChainNode != NodeToMatch && ChainNode->
use_empty() &&
2812 if (!NowDeadNodes.
empty())
2813 CurDAG->RemoveDeadNodes(NowDeadNodes);
2831 unsigned int Max = 8192;
2834 if (ChainNodesMatched.
size() == 1)
2835 return ChainNodesMatched[0]->getOperand(0);
2840 if (
V.getValueType() != MVT::Other)
2844 if (!Visited.
insert(
V.getNode()).second)
2853 for (
auto *
N : ChainNodesMatched) {
2858 while (!Worklist.
empty())
2862 if (InputChains.
size() == 0)
2873 if (InputChains.
size() != 1 &&
2874 V->getValueType(
V->getNumValues() - 1) == MVT::Glue &&
2875 InputGlue.
getNode() ==
V.getNode())
2880 for (
auto *
N : ChainNodesMatched)
2885 if (InputChains.
size() == 1)
2886 return InputChains[0];
2888 MVT::Other, InputChains);
2892SDNode *SelectionDAGISel::
2901 int OldGlueResultNo = -1, OldChainResultNo = -1;
2903 unsigned NTMNumResults =
Node->getNumValues();
2904 if (
Node->getValueType(NTMNumResults-1) == MVT::Glue) {
2905 OldGlueResultNo = NTMNumResults-1;
2906 if (NTMNumResults != 1 &&
2907 Node->getValueType(NTMNumResults-2) == MVT::Other)
2908 OldChainResultNo = NTMNumResults-2;
2909 }
else if (
Node->getValueType(NTMNumResults-1) == MVT::Other)
2910 OldChainResultNo = NTMNumResults-1;
2914 SDNode *Res =
CurDAG->MorphNodeTo(Node, ~TargetOpc, VTList,
Ops);
2928 static_cast<unsigned>(OldGlueResultNo) != ResNumResults - 1)
2930 SDValue(Res, ResNumResults - 1));
2936 if ((EmitNodeInfo &
OPFL_Chain) && OldChainResultNo != -1 &&
2937 static_cast<unsigned>(OldChainResultNo) != ResNumResults - 1)
2939 SDValue(Res, ResNumResults - 1));
2957 unsigned RecNo = MatcherTable[MatcherIndex++];
2958 assert(RecNo < RecordedNodes.size() &&
"Invalid CheckSame");
2959 return N == RecordedNodes[RecNo].first;
2967 if (ChildNo >=
N.getNumOperands())
2969 return ::CheckSame(MatcherTable, MatcherIndex,
N.getOperand(ChildNo),
2977 bool TwoBytePredNo =
2981 ? MatcherTable[MatcherIndex++]
2984 PredNo |= MatcherTable[MatcherIndex++] << 8;
2994 ? MatcherTable[MatcherIndex++]
3002 Opc |=
static_cast<uint16_t>(MatcherTable[MatcherIndex++]) << 8;
3003 return N->getOpcode() ==
Opc;
3010 if (
N.getValueType() == VT)
3014 return VT == MVT::iPTR &&
N.getValueType() ==
TLI->getPointerTy(
DL);
3020 if (ChildNo >=
N.getNumOperands())
3022 return ::CheckType(VT,
N.getOperand(ChildNo),
TLI,
DL);
3034 if (2 >=
N.getNumOperands())
3036 return ::CheckCondCode(MatcherTable, MatcherIndex,
N.getOperand(2));
3052 int64_t Val =
GetSignedVBR(MatcherTable, MatcherIndex);
3055 return C &&
C->getAPIntValue().trySExtValue() == Val;
3061 if (ChildNo >=
N.getNumOperands())
3063 return ::CheckInteger(MatcherTable, MatcherIndex,
N.getOperand(ChildNo));
3069 int64_t Val = MatcherTable[MatcherIndex++];
3071 Val =
GetVBR(Val, MatcherTable, MatcherIndex);
3073 if (
N->getOpcode() !=
ISD::AND)
return false;
3082 int64_t Val = MatcherTable[MatcherIndex++];
3084 Val =
GetVBR(Val, MatcherTable, MatcherIndex);
3086 if (
N->getOpcode() !=
ISD::OR)
return false;
3101 size_t StartIndex = Index;
3102 unsigned Opcode =
Table[Index++];
3166 unsigned Res =
Table[Index++];
3271 unsigned NumRecordedNodes;
3274 unsigned NumMatchedMemRefs;
3277 SDValue InputChain, InputGlue;
3280 bool HasChainNodesMatched;
3289 SDNode **NodeToMatch;
3290 SmallVectorImpl<std::pair<SDValue, SDNode *>> &RecordedNodes;
3291 SmallVectorImpl<MatchScope> &MatchScopes;
3294 MatchStateUpdater(SelectionDAG &DAG, SDNode **NodeToMatch,
3295 SmallVectorImpl<std::pair<SDValue, SDNode *>> &RN,
3296 SmallVectorImpl<MatchScope> &MS)
3297 : SelectionDAG::DAGUpdateListener(DAG), NodeToMatch(NodeToMatch),
3298 RecordedNodes(
RN), MatchScopes(MS) {}
3300 void NodeDeleted(SDNode *
N, SDNode *
E)
override {
3306 if (!
E ||
E->isMachineOpcode())
3309 if (
N == *NodeToMatch)
3314 for (
auto &
I : RecordedNodes)
3315 if (
I.first.getNode() ==
N)
3318 for (
auto &
I : MatchScopes)
3319 for (
auto &J :
I.NodeStack)
3320 if (J.getNode() ==
N)
3330 const uint8_t *OperandLists) {
3367 CurDAG->RemoveDeadNode(NodeToMatch);
3371 Select_INLINEASM(NodeToMatch);
3374 Select_READ_REGISTER(NodeToMatch);
3377 Select_WRITE_REGISTER(NodeToMatch);
3381 Select_UNDEF(NodeToMatch);
3384 Select_FAKE_USE(NodeToMatch);
3387 Select_RELOC_NONE(NodeToMatch);
3390 Select_FREEZE(NodeToMatch);
3393 Select_ARITH_FENCE(NodeToMatch);
3396 Select_MEMBARRIER(NodeToMatch);
3399 Select_STACKMAP(NodeToMatch);
3402 Select_PATCHPOINT(NodeToMatch);
3405 Select_JUMP_TABLE_DEBUG_INFO(NodeToMatch);
3408 Select_CONVERGENCECTRL_ANCHOR(NodeToMatch);
3411 Select_CONVERGENCECTRL_ENTRY(NodeToMatch);
3414 Select_CONVERGENCECTRL_LOOP(NodeToMatch);
3441 SDValue InputChain, InputGlue, DeactivationSymbol;
3455 size_t MatcherIndex = 0;
3457 if (!OpcodeOffset.empty()) {
3459 if (
N.getOpcode() < OpcodeOffset.size())
3460 MatcherIndex = OpcodeOffset[
N.getOpcode()];
3461 LLVM_DEBUG(
dbgs() <<
" Initial Opcode index to " << MatcherIndex <<
"\n");
3470 unsigned CaseSize = MatcherTable[Idx++];
3472 CaseSize =
GetVBR(CaseSize, MatcherTable, Idx);
3473 if (CaseSize == 0)
break;
3476 uint16_t
Opc = MatcherTable[Idx++];
3477 Opc |=
static_cast<uint16_t
>(MatcherTable[Idx++]) << 8;
3478 if (
Opc >= OpcodeOffset.size())
3479 OpcodeOffset.resize((
Opc+1)*2);
3480 OpcodeOffset[
Opc] = Idx;
3485 if (
N.getOpcode() < OpcodeOffset.size())
3486 MatcherIndex = OpcodeOffset[
N.getOpcode()];
3490 assert(MatcherIndex < TableSize &&
"Invalid index");
3492 size_t CurrentOpcodeIndex = MatcherIndex;
3506 unsigned NumToSkip = MatcherTable[MatcherIndex++];
3507 if (NumToSkip & 128)
3508 NumToSkip =
GetVBR(NumToSkip, MatcherTable, MatcherIndex);
3510 if (NumToSkip == 0) {
3515 FailIndex = MatcherIndex+NumToSkip;
3517 size_t MatcherIndexOfPredicate = MatcherIndex;
3518 (void)MatcherIndexOfPredicate;
3528 dbgs() <<
" Skipped scope entry (due to false predicate) at "
3529 <<
"index " << MatcherIndexOfPredicate <<
", continuing at "
3530 << FailIndex <<
"\n");
3531 ++NumDAGIselRetries;
3535 MatcherIndex = FailIndex;
3539 if (FailIndex == 0)
break;
3544 NewEntry.FailIndex = FailIndex;
3545 NewEntry.NodeStack.append(NodeStack.
begin(), NodeStack.
end());
3546 NewEntry.NumRecordedNodes = RecordedNodes.
size();
3547 NewEntry.NumMatchedMemRefs = MatchedMemRefs.
size();
3548 NewEntry.InputChain = InputChain;
3549 NewEntry.InputGlue = InputGlue;
3550 NewEntry.HasChainNodesMatched = !ChainNodesMatched.
empty();
3555 SDNode *Parent =
nullptr;
3556 if (NodeStack.
size() > 1)
3557 Parent = NodeStack[NodeStack.
size()-2].getNode();
3567 if (ChildNo >=
N.getNumOperands())
3585 if (
N->getNumOperands() != 0 &&
3586 N->getOperand(
N->getNumOperands()-1).getValueType() == MVT::Glue)
3587 InputGlue =
N->getOperand(
N->getNumOperands()-1);
3593 if (
N->getNumOperands() != 0 &&
3594 N->getOperand(
N->getNumOperands() - 1).getOpcode() ==
3596 DeactivationSymbol =
N->getOperand(
N->getNumOperands() - 1);
3600 unsigned ChildNo = MatcherTable[MatcherIndex++];
3601 if (ChildNo >=
N.getNumOperands())
3603 N =
N.getOperand(ChildNo);
3613 if (ChildNo >=
N.getNumOperands())
3615 N =
N.getOperand(ChildNo);
3631 assert(!NodeStack.
empty() &&
"Node stack imbalance!");
3632 N = NodeStack.
back();
3635 ? MatcherTable[MatcherIndex++]
3637 if (SiblingNo >=
N.getNumOperands())
3639 N =
N.getOperand(SiblingNo);
3646 assert(!NodeStack.
empty() &&
"Node stack imbalance!");
3647 N = NodeStack.
back();
3651 if (!
::CheckSame(MatcherTable, MatcherIndex,
N, RecordedNodes))
break;
3687 unsigned OpNum = MatcherTable[MatcherIndex++];
3690 for (
unsigned i = 0; i < OpNum; ++i)
3691 Operands.push_back(RecordedNodes[MatcherTable[MatcherIndex++]].first);
3693 unsigned PredNo = MatcherTable[MatcherIndex++];
3708 ? MatcherTable[MatcherIndex++]
3710 unsigned RecNo = MatcherTable[MatcherIndex++];
3711 assert(RecNo < RecordedNodes.
size() &&
"Invalid CheckComplexPat");
3715 std::unique_ptr<MatchStateUpdater> MSU;
3717 MSU.reset(
new MatchStateUpdater(*
CurDAG, &NodeToMatch, RecordedNodes,
3721 RecordedNodes[RecNo].first, CPNum,
3727 if (!
::CheckOpcode(MatcherTable, MatcherIndex,
N.getNode()))
break;
3744 VT =
getHwModeVT(MatcherTable, MatcherIndex, *
this);
3760 unsigned Res = MatcherTable[MatcherIndex++];
3765 CurDAG->getDataLayout()))
3771 unsigned CurNodeOpcode =
N.getOpcode();
3772 unsigned SwitchStart = MatcherIndex-1; (void)SwitchStart;
3776 CaseSize = MatcherTable[MatcherIndex++];
3778 CaseSize =
GetVBR(CaseSize, MatcherTable, MatcherIndex);
3779 if (CaseSize == 0)
break;
3781 uint16_t
Opc = MatcherTable[MatcherIndex++];
3782 Opc |=
static_cast<uint16_t
>(MatcherTable[MatcherIndex++]) << 8;
3785 if (CurNodeOpcode ==
Opc)
3789 MatcherIndex += CaseSize;
3793 if (CaseSize == 0)
break;
3796 LLVM_DEBUG(
dbgs() <<
" OpcodeSwitch from " << SwitchStart <<
" to "
3797 << MatcherIndex <<
"\n");
3802 MVT CurNodeVT =
N.getSimpleValueType();
3803 unsigned SwitchStart = MatcherIndex-1; (void)SwitchStart;
3807 CaseSize = MatcherTable[MatcherIndex++];
3809 CaseSize =
GetVBR(CaseSize, MatcherTable, MatcherIndex);
3810 if (CaseSize == 0)
break;
3813 if (CaseVT == MVT::iPTR)
3814 CaseVT =
TLI->getPointerTy(
CurDAG->getDataLayout());
3817 if (CurNodeVT == CaseVT)
3821 MatcherIndex += CaseSize;
3825 if (CaseSize == 0)
break;
3829 <<
"] from " << SwitchStart <<
" to " << MatcherIndex
3834 unsigned ChildNo = MatcherTable[MatcherIndex++];
3835 [[maybe_unused]]
unsigned SwitchStart = MatcherIndex - 2;
3837 std::optional<int64_t> ChildVal;
3838 if (ChildNo <
N.getNumOperands()) {
3840 ChildVal =
C->getAPIntValue().trySExtValue();
3846 CaseSize = MatcherTable[MatcherIndex++];
3848 CaseSize =
GetVBR(CaseSize, MatcherTable, MatcherIndex);
3852 int64_t CaseVal =
GetSignedVBR(MatcherTable, MatcherIndex);
3855 if (ChildVal == CaseVal)
3859 MatcherIndex += CaseSize;
3866 LLVM_DEBUG(
dbgs() <<
" ChildIntegerSwitch[" << ChildNo <<
"] from "
3867 << SwitchStart <<
" to " << MatcherIndex <<
'\n');
3935 VT =
getHwModeVT(MatcherTable, MatcherIndex, *
this);
3951 CurDAG->getDataLayout()))
3967 if (!
::CheckOrImm(MatcherTable, MatcherIndex,
N, *
this))
break;
3983 assert(NodeStack.
size() != 1 &&
"No parent node");
3986 bool HasMultipleUses =
false;
3987 for (
unsigned i = 1, e = NodeStack.
size()-1; i != e; ++i) {
3988 unsigned NNonChainUses = 0;
3989 SDNode *NS = NodeStack[i].getNode();
3991 if (U.getValueType() != MVT::Other)
3992 if (++NNonChainUses > 1) {
3993 HasMultipleUses =
true;
3996 if (HasMultipleUses)
break;
3998 if (HasMultipleUses)
break;
4033 VT =
getHwModeVT(MatcherTable, MatcherIndex, *
this);
4042 int64_t Val =
GetSignedVBR(MatcherTable, MatcherIndex);
4064 VT =
getHwModeVT(MatcherTable, MatcherIndex, *
this);
4070 unsigned RegNo = MatcherTable[MatcherIndex++];
4082 unsigned RegNo = MatcherTable[MatcherIndex++];
4083 RegNo |= MatcherTable[MatcherIndex++] << 8;
4099 ? MatcherTable[MatcherIndex++]
4101 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitConvertToTarget");
4107 Imm.getValueType());
4111 Imm.getValueType());
4123 "EmitMergeInputChains should be the first chain producing node");
4125 "Should only have one EmitMergeInputChains per match");
4129 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitMergeInputChains");
4130 ChainNodesMatched.
push_back(RecordedNodes[RecNo].first.getNode());
4136 if (ChainNodesMatched.
back() != NodeToMatch &&
4137 !RecordedNodes[RecNo].first.hasOneUse()) {
4138 ChainNodesMatched.
clear();
4152 "EmitMergeInputChains should be the first chain producing node");
4159 unsigned NumChains = MatcherTable[MatcherIndex++];
4160 assert(NumChains != 0 &&
"Can't TF zero chains");
4163 "Should only have one EmitMergeInputChains per match");
4166 for (
unsigned i = 0; i != NumChains; ++i) {
4167 unsigned RecNo = MatcherTable[MatcherIndex++];
4168 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitMergeInputChains");
4169 ChainNodesMatched.
push_back(RecordedNodes[RecNo].first.getNode());
4175 if (ChainNodesMatched.
back() != NodeToMatch &&
4176 !RecordedNodes[RecNo].first.hasOneUse()) {
4177 ChainNodesMatched.
clear();
4183 if (ChainNodesMatched.
empty())
4208 : MatcherTable[MatcherIndex++];
4209 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitCopyToReg");
4210 unsigned DestPhysReg = MatcherTable[MatcherIndex++];
4212 DestPhysReg |= MatcherTable[MatcherIndex++] << 8;
4215 InputChain =
CurDAG->getEntryNode();
4217 InputChain =
CurDAG->getCopyToReg(InputChain,
SDLoc(NodeToMatch),
4218 DestPhysReg, RecordedNodes[RecNo].first,
4221 InputGlue = InputChain.
getValue(1);
4226 unsigned XFormNo = MatcherTable[MatcherIndex++];
4227 unsigned RecNo = MatcherTable[MatcherIndex++];
4228 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitNodeXForm");
4236 unsigned index = MatcherTable[MatcherIndex++];
4237 index |= (MatcherTable[MatcherIndex++] << 8);
4238 index |= (MatcherTable[MatcherIndex++] << 16);
4239 index |= (MatcherTable[MatcherIndex++] << 24);
4269 uint32_t TargetOpc = MatcherTable[MatcherIndex++];
4270 TargetOpc |= (MatcherTable[MatcherIndex++] << 8);
4271 unsigned EmitNodeInfo;
4290 EmitNodeInfo = MatcherTable[MatcherIndex++];
4315 NumVTs = MatcherTable[MatcherIndex++];
4318 for (
unsigned i = 0; i != NumVTs; ++i) {
4320 if (VT == MVT::iPTR)
4321 VT =
TLI->getPointerTy(
CurDAG->getDataLayout());
4325 for (
unsigned i = 0; i != NumVTs; ++i) {
4327 if (VT == MVT::iPTR)
4328 VT =
TLI->getPointerTy(
CurDAG->getDataLayout()).SimpleTy;
4341 if (VTs.
size() == 1)
4342 VTList =
CurDAG->getVTList(VTs[0]);
4343 else if (VTs.
size() == 2)
4344 VTList =
CurDAG->getVTList(VTs[0], VTs[1]);
4346 VTList =
CurDAG->getVTList(VTs);
4349 unsigned NumOps = MatcherTable[MatcherIndex++];
4354 size_t OperandIndex = MatcherTable[MatcherIndex++];
4355 if (OperandIndex & 128)
4356 OperandIndex =
GetVBR(OperandIndex, MatcherTable, MatcherIndex);
4358 for (
unsigned i = 0; i !=
NumOps; ++i) {
4359 unsigned RecNo = OperandLists[OperandIndex++];
4361 RecNo =
GetVBR(RecNo, OperandLists, OperandIndex);
4363 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitNode");
4364 Ops.push_back(RecordedNodes[RecNo].first);
4372 FirstOpToCopy += (EmitNodeInfo &
OPFL_Chain) ? 1 : 0;
4374 "Invalid variadic node");
4377 for (
unsigned i = FirstOpToCopy, e = NodeToMatch->
getNumOperands();
4380 if (V.getValueType() == MVT::Glue)
break;
4387 Ops.push_back(InputChain);
4388 if (DeactivationSymbol.
getNode() !=
nullptr)
4389 Ops.push_back(DeactivationSymbol);
4391 Ops.push_back(InputGlue);
4397 bool MayRaiseFPException =
4404 bool IsMorphNodeTo =
4407 if (!IsMorphNodeTo) {
4410 Res =
CurDAG->getMachineNode(TargetOpc,
SDLoc(NodeToMatch),
4414 for (
unsigned i = 0, e = VTs.
size(); i != e; ++i) {
4415 if (VTs[i] == MVT::Other || VTs[i] == MVT::Glue)
break;
4420 "NodeToMatch was removed partway through selection");
4424 auto &Chain = ChainNodesMatched;
4426 "Chain node replaced during MorphNode");
4430 Ops, EmitNodeInfo));
4457 bool mayLoad =
MCID.mayLoad();
4458 bool mayStore =
MCID.mayStore();
4464 if (MMO->isLoad()) {
4467 }
else if (MMO->isStore()) {
4475 CurDAG->setNodeMemRefs(Res, FilteredMemRefs);
4479 if (!MatchedMemRefs.
empty() && Res->memoperands_empty())
4480 dbgs() <<
" Dropping mem operands\n";
4481 dbgs() <<
" " << (IsMorphNodeTo ?
"Morphed" :
"Created") <<
" node: ";
4486 if (IsMorphNodeTo) {
4488 UpdateChains(Res, InputChain, ChainNodesMatched,
true);
4498 unsigned NumResults = MatcherTable[MatcherIndex++];
4500 for (
unsigned i = 0; i != NumResults; ++i) {
4501 unsigned ResSlot = MatcherTable[MatcherIndex++];
4503 ResSlot =
GetVBR(ResSlot, MatcherTable, MatcherIndex);
4505 assert(ResSlot < RecordedNodes.
size() &&
"Invalid CompleteMatch");
4506 SDValue Res = RecordedNodes[ResSlot].first;
4508 assert(i < NodeToMatch->getNumValues() &&
4511 "Invalid number of results to complete!");
4517 "invalid replacement");
4522 UpdateChains(NodeToMatch, InputChain, ChainNodesMatched,
false);
4535 "Didn't replace all uses of the node?");
4536 CurDAG->RemoveDeadNode(NodeToMatch);
4545 LLVM_DEBUG(
dbgs() <<
" Match failed at index " << CurrentOpcodeIndex
4547 ++NumDAGIselRetries;
4549 if (MatchScopes.
empty()) {
4550 CannotYetSelect(NodeToMatch);
4556 MatchScope &LastScope = MatchScopes.
back();
4557 RecordedNodes.
resize(LastScope.NumRecordedNodes);
4558 NodeStack.
assign(LastScope.NodeStack.begin(), LastScope.NodeStack.end());
4559 N = NodeStack.
back();
4561 if (LastScope.NumMatchedMemRefs != MatchedMemRefs.
size())
4562 MatchedMemRefs.
resize(LastScope.NumMatchedMemRefs);
4563 MatcherIndex = LastScope.FailIndex;
4567 InputChain = LastScope.InputChain;
4568 InputGlue = LastScope.InputGlue;
4569 if (!LastScope.HasChainNodesMatched)
4570 ChainNodesMatched.
clear();
4575 unsigned NumToSkip = MatcherTable[MatcherIndex++];
4576 if (NumToSkip & 128)
4577 NumToSkip =
GetVBR(NumToSkip, MatcherTable, MatcherIndex);
4581 if (NumToSkip != 0) {
4582 LastScope.FailIndex = MatcherIndex+NumToSkip;
4596 if (
N->isMachineOpcode()) {
4598 return MCID.mayRaiseFPException();
4603 if (
N->isTargetOpcode()) {
4607 return N->isStrictFPOpcode();
4620 int32_t
Off =
C->getSExtValue();
4623 return (
Off >= 0) && (((
A.value() - 1) &
Off) ==
unsigned(
Off));
4631 unsigned ShiftBits =
Log2_32(ShiftWidth);
4636 N.getScalarValueSizeInBits() >= ShiftBits)
4637 N =
N.getOperand(0);
4642 const APInt &AndMask =
N.getConstantOperandAPInt(1);
4657 ShAmt =
N.getOperand(0);
4661void SelectionDAGISel::CannotYetSelect(
SDNode *
N) {
4664 Msg <<
"Cannot select: ";
4666 Msg.enable_colors(
errs().has_colors());
4674 bool HasInputChain =
N->getOperand(0).getValueType() == MVT::Other;
4675 unsigned iid =
N->getConstantOperandVal(HasInputChain);
4676 if (iid < Intrinsic::num_intrinsics)
4679 Msg <<
"unknown intrinsic #" << iid;
for(const MachineOperand &MO :llvm::drop_begin(OldMI.operands(), Desc.getNumOperands()))
MachineInstrBuilder & UseMI
const AArch64Subtarget & Subtarget
const TargetLowering & TLI
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< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
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[]
if(!TBB||Cond.size()< 1) return false
Register const TargetRegisterInfo * TRI
Promote Memory to Register
uint64_t IntrinsicInst * II
FunctionAnalysisManager FAM
This header defines classes/functions to handle pass execution timing information with interfaces for...
This file builds on the ADT/GraphTraits.h file to build a generic graph post order iterator.
MachineRegisterInfo & MRI
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckNodePredicate(unsigned Opcode, const uint8_t *MatcherTable, size_t &MatcherIndex, const SelectionDAGISel &SDISel, SDValue Op)
CheckNodePredicate - Implements OP_CheckNodePredicate.
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckSame(const uint8_t *MatcherTable, size_t &MatcherIndex, SDValue N, const SmallVectorImpl< std::pair< SDValue, SDNode * > > &RecordedNodes)
CheckSame - Implements OP_CheckSame.
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 CheckOrImm(const uint8_t *MatcherTable, size_t &MatcherIndex, SDValue N, const SelectionDAGISel &SDISel)
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckCondCode(const uint8_t *MatcherTable, size_t &MatcherIndex, SDValue N)
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckChildInteger(const uint8_t *MatcherTable, size_t &MatcherIndex, SDValue N, unsigned ChildNo)
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 uint8_t *MatcherTable, size_t &Idx)
GetVBR - decode a vbr encoding whose top bit is set.
static cl::opt< bool > DumpSortedDAG("dump-sorted-dags", cl::Hidden, cl::desc("Print DAGs with sorted nodes in debug dump"), cl::init(false))
static void reportFastISelFailure(MachineFunction &MF, OptimizationRemarkEmitter &ORE, OptimizationRemarkMissed &R, bool ShouldAbort)
static bool IsPredicateKnownToFail(const uint8_t *Table, size_t &Index, SDValue N, const SelectionDAGISel &SDISel, const 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< 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 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 CheckChildSame(const uint8_t *MatcherTable, size_t &MatcherIndex, SDValue N, const SmallVectorImpl< std::pair< SDValue, SDNode * > > &RecordedNodes, unsigned ChildNo)
CheckChildSame - Implements OP_CheckChildXSame.
static void processSingleLocVars(FunctionLoweringInfo &FuncInfo, FunctionVarLocs const *FnVarLocs)
Collect single location variable information generated with assignment tracking.
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 LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckInteger(const uint8_t *MatcherTable, size_t &MatcherIndex, SDValue N)
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckPatternPredicate(unsigned Opcode, const uint8_t *MatcherTable, size_t &MatcherIndex, const SelectionDAGISel &SDISel)
CheckPatternPredicate - Implements OP_CheckPatternPredicate.
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 void preserveFakeUses(BasicBlock::iterator Begin, BasicBlock::iterator End)
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckOpcode(const uint8_t *MatcherTable, size_t &MatcherIndex, SDNode *N)
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 bool CheckType(MVT::SimpleValueType VT, SDValue N, const TargetLowering *TLI, const DataLayout &DL)
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckAndImm(const uint8_t *MatcherTable, size_t &MatcherIndex, SDValue N, const SelectionDAGISel &SDISel)
static bool hasExceptionPointerOrCodeUser(const CatchPadInst *CPI)
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckValueType(const uint8_t *MatcherTable, size_t &MatcherIndex, SDValue N, const TargetLowering *TLI, const DataLayout &DL)
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 int64_t GetSignedVBR(const unsigned char *MatcherTable, size_t &Idx)
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 LLVM_ATTRIBUTE_ALWAYS_INLINE MVT::SimpleValueType getSimpleVT(const uint8_t *MatcherTable, size_t &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 CheckChild2CondCode(const uint8_t *MatcherTable, size_t &MatcherIndex, SDValue N)
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 MVT getHwModeVT(const uint8_t *MatcherTable, size_t &MatcherIndex, const SelectionDAGISel &SDISel)
Decode a HwMode VT in MatcherTable by calling getValueTypeForHwMode.
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.
unsigned getBitWidth() const
Return the number of bits in the APInt.
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.
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)
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.
LLVM_ABI 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...
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
iterator_range< user_iterator > users()
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.
Describe properties that are true of each instruction in the target description file.
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.
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 & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addSym(MCSymbol *Sym, unsigned char TargetFlags=0) const
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.
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.
Records a mapping from an opaque lowering context to its LibcallLoweringInfo.
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)
LLVM_ABI 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_CheckChild4TypeByHwMode0
@ 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_CheckChild1TypeByHwMode0
@ OPC_CheckPatternPredicate6
@ OPC_CheckPatternPredicate7
@ OPC_CheckChild5TypeByHwMode
@ OPC_EmitMergeInputChains
@ OPC_CheckChild0TypeByHwMode0
@ OPC_EmitMergeInputChains1_0
@ OPC_CheckFoldableChainNode
@ OPC_CheckChild6TypeByHwMode
@ OPC_EmitConvertToTarget3
@ OPC_CheckChild7TypeByHwMode0
@ OPC_CheckChild7TypeByHwMode
@ OPC_EmitRegisterByHwMode
@ OPC_CheckPredicateWithOperands
@ OPC_EmitIntegerByHwMode0
@ OPC_CheckChild3TypeByHwMode0
@ OPC_EmitConvertToTarget4
@ OPC_CheckChild2TypeByHwMode0
@ OPC_EmitIntegerByHwMode
@ OPC_CheckChild3TypeByHwMode
@ OPC_CheckTypeResByHwMode
@ OPC_CheckChild5TypeByHwMode0
@ OPC_EmitConvertToTarget7
@ OPC_EmitMergeInputChains1_2
@ OPC_CheckChild6TypeByHwMode0
@ 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 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
bool selectShiftAmountMask(SDValue N, unsigned ShiftWidth, SDValue &ShAmt) const
Look through a mask on the amount N of a shift that reads only the low Log2(ShiftWidth) bits of its a...
void ReplaceNode(SDNode *F, SDNode *T)
Replace all uses of F with T, then remove F from the DAG.
void SelectCodeCommon(SDNode *NodeToMatch, const uint8_t *MatcherTable, unsigned TableSize, const uint8_t *OperandLists)
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)
LLVM_NO_SANITIZE_CFI_UNRELATED_CAST iterator begin()
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
constexpr const char * data() const
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...
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.
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.
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.
LLVM_ABI bool isConstantSplatVectorAllZeros(SDValue V, bool BuildVectorOnly=false)
Return true if the specified value 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.
@ TRUNCATE
TRUNCATE - Completely drop the high bits.
@ 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 isConstantSplatVectorAllOnes(SDValue V, bool BuildVectorOnly=false)
Return true if the specified value is a BUILD_VECTOR or SPLAT_VECTOR where all of the elements are ~0...
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....
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.
@ Known
Known to have no common set bits.
@ Kill
The last use of a register.
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.
LLVM_ABI 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 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...
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
LLVM_ABI const LibcallLoweringInfo & getLibcallLowering(const ModuleLibcallLoweringInfo &ModuleInfo, const TargetSubtargetInfo &Subtarget)
Resolve the LibcallLoweringInfo for Subtarget from the module-level ModuleInfo, applying the subtarge...
@ Off
Use window algorithm after SMS algorithm fails.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI 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.
@ End
Run the machine verifier once, at the end of the pipeline.
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.
MCRegisterClass TargetRegisterClass
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.
bool shouldSkipOptimizationForOptBisect(IRUnitRef IR)
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.
LLVM_ABI void addIPToStateRange(const InvokeInst *II, MCSymbol *InvokeBegin, MCSymbol *InvokeEnd)
DenseMap< const BasicBlock *, int > BlockToStateMap