102 using namespace llvm;
104 #define DEBUG_TYPE "isel" 106 STATISTIC(NumFastIselFailures,
"Number of instructions fast isel failed on");
107 STATISTIC(NumFastIselSuccess,
"Number of instructions fast isel selected");
108 STATISTIC(NumFastIselBlocks,
"Number of blocks selected entirely by fast isel");
109 STATISTIC(NumDAGBlocks,
"Number of blocks selected using DAG");
110 STATISTIC(NumDAGIselRetries,
"Number of times dag isel has to try another path");
111 STATISTIC(NumEntryBlocks,
"Number of entry blocks encountered");
113 "Number of entry blocks where fast isel failed to lower arguments");
117 cl::desc(
"Enable abort calls when \"fast\" instruction selection " 118 "fails to lower an instruction: 0 disable the abort, 1 will " 119 "abort but for args, calls and terminators, 2 will also " 120 "abort for argument lowering, and 3 will never fallback " 121 "to SelectionDAG."));
125 cl::desc(
"Emit a diagnostic when \"fast\" instruction selection " 126 "falls back to SelectionDAG."));
130 cl::desc(
"use Machine Branch Probability Info"),
136 cl::desc(
"Only display the basic block whose name " 137 "matches this for all view-*-dags options"));
140 cl::desc(
"Pop up a window to show dags before the first " 141 "dag combine pass"));
144 cl::desc(
"Pop up a window to show dags before legalize types"));
147 cl::desc(
"Pop up a window to show dags before legalize"));
150 cl::desc(
"Pop up a window to show dags before the second " 151 "dag combine pass"));
154 cl::desc(
"Pop up a window to show dags before the post legalize types" 155 " dag combine pass"));
158 cl::desc(
"Pop up a window to show isel dags as they are selected"));
161 cl::desc(
"Pop up a window to show sched dags as they are processed"));
164 cl::desc(
"Pop up a window to show SUnit dags after they are processed"));
190 cl::desc(
"Instruction schedulers available (before register" 211 if (NewOptLevel == SavedOptLevel)
215 LLVM_DEBUG(
dbgs() <<
"\nChanging optimization level for Function " 217 LLVM_DEBUG(
dbgs() <<
"\tBefore: -O" << SavedOptLevel <<
" ; After: -O" 218 << NewOptLevel <<
"\n");
223 dbgs() <<
"\tFastISel is " 232 LLVM_DEBUG(
dbgs() <<
"\nRestoring optimization level for Function " 235 << SavedOptLevel <<
"\n");
252 return SchedulerCtor(IS, OptLevel);
266 "Unknown sched type!");
285 dbgs() <<
"If a target marks an instruction with " 286 "'usesCustomInserter', it must implement " 287 "TargetLowering::EmitInstrWithCustomInserter!";
295 "If a target marks an instruction with 'hasPostISelHook', " 296 "it must implement TargetLowering::AdjustInstrPostInstrSelection!");
362 if (!CE || !CE->
canTrap())
continue;
387 "-fast-isel-abort > 0 requires -fast-isel");
407 LibInfo = &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
408 GFI = Fn.
hasGC() ? &getAnalysis<GCModuleInfo>().getFunctionInfo(Fn) :
nullptr;
409 ORE = make_unique<OptimizationRemarkEmitter>(&Fn);
410 auto *DTWP = getAnalysisIfAvailable<DominatorTreeWrapperPass>();
412 auto *LIWP = getAnalysisIfAvailable<LoopInfoWrapperPass>();
413 LoopInfo *LI = LIWP ? &LIWP->getLoopInfo() :
nullptr;
420 getAnalysisIfAvailable<DivergenceAnalysis>());
429 FuncInfo->
BPI = &getAnalysis<BranchProbabilityInfoWrapperPass>().getBPI();
434 AA = &getAnalysis<AAResultsWrapperPass>().getAAResults();
455 if (isa<UnreachableInst>(Term) || isa<ReturnInst>(Term))
469 SelectAllBasicBlocks(Fn);
486 if (!MBB.succ_empty())
490 if (Term != MBB.end() && Term->isReturn()) {
525 if (LDI != LiveInMap.
end()) {
526 assert(!hasFI &&
"There's no handling of frame pointer updating here yet " 536 "DBG_VALUE with nonzero offset");
537 assert(cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(DL) &&
538 "Expected inlined-at fields to agree");
540 BuildMI(*EntryMBB, ++InsertPos, DL,
TII->
get(TargetOpcode::DBG_VALUE),
541 IsIndirect, LDI->second, Variable, Expr);
553 CopyUseMI =
UseMI;
continue;
556 CopyUseMI =
nullptr;
break;
563 CopyUseMI->getOperand(0).getReg(), Variable, Expr);
572 for (
const auto &MBB : *
MF) {
573 if (MFI.
hasCalls() && MF->hasInlineAsm())
576 for (
const auto &
MI : MBB) {
579 MI.isStackAligningInlineAsm()) {
582 if (
MI.isInlineAsm()) {
583 MF->setHasInlineAsm(
true);
597 unsigned From =
I->first;
598 unsigned To =
I->second;
640 R << (
" (in function: " + MF.
getName() +
")").str();
670 void SelectionDAGISel::ComputeLiveOutVRegInfo() {
682 if (!VisitedNodes.
insert(N).second)
707 }
while (!Worklist.
empty());
710 void SelectionDAGISel::CodeGenAndEmitDAG() {
712 StringRef GroupDescription =
"Instruction Selection and Scheduling";
713 std::string BlockName;
714 int BlockNumber = -1;
716 bool MatchFilterBB =
false; (void)MatchFilterBB;
718 getAnalysis<TargetTransformInfoWrapperPass>().getTTI(*
FuncInfo->
Fn);
743 if (ViewDAGCombine1 && MatchFilterBB)
882 ComputeLiveOutVRegInfo();
892 DoInstructionSelection();
928 if (FirstMBB != LastMBB)
988 while (!Nodes.
empty()) {
990 for (
auto *U : N->
uses()) {
1016 void SelectionDAGISel::DoInstructionSelection() {
1037 ISelUpdater ISU(*
CurDAG, ISelPosition);
1044 SDNode *Node = &*--ISelPosition;
1055 while (!Nodes.
empty()) {
1072 "Node has already selected predecessor node");
1091 LLVM_DEBUG(
dbgs() <<
"\nISEL: Starting selection on root node: ";
1107 if (
const IntrinsicInst *EHPtrCall = dyn_cast<IntrinsicInst>(U)) {
1109 if (IID == Intrinsic::eh_exceptionpointer ||
1110 IID == Intrinsic::eh_exceptioncode)
1119 bool SelectionDAGISel::PrepareEHLandingPad() {
1128 if (
const auto *CPI = dyn_cast<CatchPadInst>(LLVMBB->
getFirstNonPHI())) {
1133 assert(EHPhysReg &&
"target lacks exception pointer register");
1137 TII->
get(TargetOpcode::COPY), VReg)
1174 !isa<TerminatorInst>(
I) &&
1175 !isa<DbgInfoIntrinsic>(I) &&
1194 bool HaveSeenSwiftErrorArg =
false;
1197 if (AI->hasSwiftErrorAttr()) {
1198 assert(!HaveSeenSwiftErrorArg &&
1199 "Must have only one swifterror parameter");
1200 (void)HaveSeenSwiftErrorArg;
1201 HaveSeenSwiftErrorArg =
true;
1206 for (
const auto &LLVMBB : Fn)
1207 for (
const auto &Inst : LLVMBB) {
1208 if (
const AllocaInst *Alloca = dyn_cast<AllocaInst>(&Inst))
1209 if (Alloca->isSwiftError())
1228 "expected to insert into entry block");
1271 Address = Address->stripAndAccumulateInBoundsConstantOffsets(DL, Offset);
1277 if (
const auto *AI = dyn_cast<AllocaInst>(Address)) {
1281 }
else if (
const auto *
Arg = dyn_cast<Argument>(Address))
1298 auto *
TLI = FuncInfo->
TLI;
1312 auto Key = std::make_pair(MBB, SwiftErrorVal);
1316 unsigned UUseVReg = UpwardsUse ? UUseIt->second : 0;
1318 assert(!(UpwardsUse && !DownwardDef) &&
1319 "We can't have an upwards use but no downwards def");
1324 if (!UpwardsUse && DownwardDef)
1334 for (
auto *Pred : MBB->predecessors()) {
1335 if (!Visited.
insert(Pred).second)
1348 UUseVReg = UUseIt->second;
1355 VRegs.
size() >= 1 &&
1358 [&](
const std::pair<const MachineBasicBlock *, unsigned> &V)
1359 ->
bool {
return V.second != VRegs[0].second; }) !=
1364 if (!UpwardsUse && !needPHI) {
1366 "No predecessors? The entry block should bail out earlier");
1372 auto DLoc = isa<Instruction>(SwiftErrorVal)
1373 ? cast<Instruction>(SwiftErrorVal)->getDebugLoc()
1381 "No predecessors? Is the Calling Convention correct?");
1382 unsigned DestReg = UUseVReg;
1383 BuildMI(*MBB, MBB->getFirstNonPHI(), DLoc,
TII->
get(TargetOpcode::COPY),
1385 .addReg(VRegs[0].
second);
1394 UpwardsUse ? UUseVReg
1397 BuildMI(*MBB, MBB->getFirstNonPHI(), DLoc,
1398 TII->
get(TargetOpcode::PHI), PHIVReg);
1399 for (
auto BBRegPair : VRegs) {
1400 SwiftErrorPHI.
addReg(BBRegPair.second).
addMBB(BBRegPair.first);
1419 for (
auto It = Begin; It != End; ++It) {
1423 const Value *SwiftErrorAddr =
nullptr;
1428 assert(!SwiftErrorAddr &&
"Cannot have multiple swifterror arguments");
1429 SwiftErrorAddr = &*
Arg;
1431 "Must have a swifterror value argument");
1432 unsigned VReg;
bool CreatedReg;
1434 &*It, FuncInfo->
MBB, SwiftErrorAddr);
1437 if (!SwiftErrorAddr)
1441 unsigned VReg;
bool CreatedReg;
1442 std::tie(VReg, CreatedReg) =
1448 }
else if (
const LoadInst *LI = dyn_cast<const LoadInst>(&*It)) {
1449 const Value *V = LI->getOperand(0);
1453 unsigned VReg;
bool CreatedReg;
1454 std::tie(VReg, CreatedReg) =
1459 }
else if (
const StoreInst *
SI = dyn_cast<const StoreInst>(&*It)) {
1460 const Value *SwiftErrorAddr =
SI->getOperand(1);
1465 unsigned VReg;
bool CreatedReg;
1466 std::tie(VReg, CreatedReg) =
1472 }
else if (
const ReturnInst *R = dyn_cast<const ReturnInst>(&*It)) {
1473 const Function *
F = R->getParent()->getParent();
1477 unsigned VReg;
bool CreatedReg;
1485 void SelectionDAGISel::SelectAllBasicBlocks(
const Function &Fn) {
1517 ++NumFastIselFailLowerArguments;
1522 R <<
"FastISel didn't lower all arguments: " 1530 CodeGenAndEmitDAG();
1549 bool AllPredsVisited =
true;
1553 AllPredsVisited =
false;
1558 if (AllPredsVisited) {
1559 for (
const PHINode &PN : LLVMBB->phis())
1562 for (
const PHINode &PN : LLVMBB->phis())
1570 LLVMBB->getFirstNonPHI()->getIterator();
1584 if (LLVMBB->isEHPad())
1585 if (!PrepareEHLandingPad())
1593 unsigned NumFastIselRemaining = std::distance(Begin, End);
1599 for (; BI != Begin; --BI) {
1605 --NumFastIselRemaining;
1615 --NumFastIselRemaining;
1616 ++NumFastIselSuccess;
1621 while (BeforeInst != &*Begin) {
1626 if (BeforeInst != Inst && isa<LoadInst>(BeforeInst) &&
1631 --NumFastIselRemaining;
1632 ++NumFastIselSuccess;
1648 R <<
"FastISel missed call";
1651 std::string InstStrStorage;
1655 R <<
": " << InstStr.
str();
1667 bool HadTailCall =
false;
1669 SelectBasicBlock(Inst->
getIterator(), BI, HadTailCall);
1681 unsigned RemainingNow = std::distance(Begin, BI);
1682 NumFastIselFailures += NumFastIselRemaining - RemainingNow;
1683 NumFastIselRemaining = RemainingNow;
1691 if (isa<TerminatorInst>(Inst)) {
1693 R <<
"FastISel missed terminator";
1697 R <<
"FastISel missed";
1701 std::string InstStrStorage;
1704 R <<
": " << InstStr.
str();
1709 NumFastIselFailures += NumFastIselRemaining;
1717 bool FunctionBasedInstrumentation =
1720 FunctionBasedInstrumentation);
1726 ++NumFastIselBlocks;
1733 SelectBasicBlock(Begin, BI, HadTailCall);
1796 &&
"Should have a copy implying we should have 2 arguments.");
1800 if (!OPI2->
isReg() ||
1825 if (SplitPoint == BB->
begin())
1833 SplitPoint = Previous;
1834 if (Previous == Start)
1843 SelectionDAGISel::FinishBasicBlock() {
1856 "This is not a machine PHI node that we are updating!");
1875 CodeGenAndEmitDAG();
1893 SuccessMBB->
splice(SuccessMBB->
end(), ParentMBB,
1903 CodeGenAndEmitDAG();
1907 if (FailureMBB->
empty()) {
1913 CodeGenAndEmitDAG();
1931 CodeGenAndEmitDAG();
1935 for (
unsigned j = 0, ej = BTB.Cases.size(); j != ej; ++j) {
1936 UnhandledProb -= BTB.Cases[j].ExtraProb;
1951 if (BTB.ContiguousRange && j + 2 == ej) {
1954 NextMBB = BTB.Cases[j + 1].TargetBB;
1955 }
else if (j + 1 == ej) {
1957 NextMBB = BTB.Default;
1960 NextMBB = BTB.Cases[j + 1].ThisBB;
1968 CodeGenAndEmitDAG();
1970 if (BTB.ContiguousRange && j + 2 == ej) {
1972 BTB.Cases.pop_back();
1983 "This is not a machine PHI node that we are updating!");
1986 if (PHIBB == BTB.Default) {
1988 if (!BTB.ContiguousRange) {
1990 .
addMBB(BTB.Cases.back().ThisBB);
1994 for (
unsigned j = 0, ej = BTB.Cases.size();
2007 for (
unsigned i = 0, e =
SDB->
JTCases.size(); i != e; ++i) {
2018 CodeGenAndEmitDAG();
2028 CodeGenAndEmitDAG();
2036 "This is not a machine PHI node that we are updating!");
2065 CodeGenAndEmitDAG();
2075 for (
unsigned i = 0, e = Succs.
size(); i != e; ++i) {
2083 MBBI != MBBE && MBBI->isPHI(); ++MBBI) {
2086 for (
unsigned pn = 0; ; ++pn) {
2088 "Didn't find PHI entry!");
2119 int64_t DesiredMaskS)
const {
2124 if (ActualMask == DesiredMask)
2133 APInt NeededMask = DesiredMask & ~ActualMask;
2148 int64_t DesiredMaskS)
const {
2153 if (ActualMask == DesiredMask)
2162 APInt NeededMask = DesiredMask & ~ActualMask;
2181 std::vector<SDValue> InOps;
2190 if (InOps[e-1].getValueType() ==
MVT::Glue)
2194 unsigned Flags = cast<ConstantSDNode>(InOps[i])->getZExtValue();
2197 Ops.insert(Ops.end(), InOps.begin()+i,
2202 "Memory operand with multiple values?");
2204 unsigned TiedToOperand;
2208 Flags = cast<ConstantSDNode>(InOps[CurOp])->getZExtValue();
2209 for (; TiedToOperand; --TiedToOperand) {
2211 Flags = cast<ConstantSDNode>(InOps[CurOp])->getZExtValue();
2216 std::vector<SDValue> SelOps;
2227 Ops.insert(Ops.end(), SelOps.begin(), SelOps.end());
2233 if (e != InOps.size())
2234 Ops.push_back(InOps.back());
2253 bool IgnoreChains) {
2262 Visited.
insert(ImmedUse);
2267 if ((
Op.getValueType() ==
MVT::Other && IgnoreChains) || N == Def)
2269 if (!Visited.
insert(N).second)
2275 if (Root != ImmedUse) {
2279 if ((
Op.getValueType() ==
MVT::Other && IgnoreChains) || N == Def)
2281 if (!Visited.
insert(N).second)
2302 bool IgnoreChains) {
2361 IgnoreChains =
false;
2367 void SelectionDAGISel::Select_INLINEASM(
SDNode *
N) {
2380 void SelectionDAGISel::Select_READ_REGISTER(
SDNode *
Op) {
2394 void SelectionDAGISel::Select_WRITE_REGISTER(
SDNode *Op) {
2408 void SelectionDAGISel::Select_UNDEF(
SDNode *N) {
2414 GetVBR(uint64_t Val,
const unsigned char *MatcherTable,
unsigned &Idx) {
2415 assert(Val >= 128 &&
"Not a VBR");
2421 NextBits = MatcherTable[Idx++];
2422 Val |= (NextBits&127) << Shift;
2424 }
while (NextBits & 128);
2431 void SelectionDAGISel::UpdateChains(
2438 if (!ChainNodesMatched.
empty()) {
2440 "Matched input chains but didn't produce a chain");
2443 for (
unsigned i = 0, e = ChainNodesMatched.
size(); i != e; ++i) {
2444 SDNode *ChainNode = ChainNodesMatched[i];
2451 "Deleted node left in chain");
2455 if (ChainNode == NodeToMatch && isMorphNodeTo)
2465 static_cast<SDNode *
>(
nullptr));
2471 if (ChainNode != NodeToMatch && ChainNode->
use_empty() &&
2477 if (!NowDeadNodes.
empty())
2496 unsigned int Max = 8192;
2499 if (ChainNodesMatched.
size() == 1)
2500 return ChainNodesMatched[0]->getOperand(0);
2504 std::function<void(const SDValue)> AddChains = [&](
const SDValue V) {
2518 for (
auto *N : ChainNodesMatched) {
2523 while (!Worklist.
empty())
2527 if (InputChains.
size() == 0)
2537 for (
auto *N : ChainNodesMatched)
2542 if (InputChains.size() == 1)
2543 return InputChains[0];
2549 SDNode *SelectionDAGISel::
2558 int OldGlueResultNo = -1, OldChainResultNo = -1;
2562 OldGlueResultNo = NTMNumResults-1;
2563 if (NTMNumResults != 1 &&
2565 OldChainResultNo = NTMNumResults-2;
2567 OldChainResultNo = NTMNumResults-1;
2585 (
unsigned)OldGlueResultNo != ResNumResults-1)
2587 SDValue(Res, ResNumResults - 1));
2589 if ((EmitNodeInfo & OPFL_GlueOutput) != 0)
2593 if ((EmitNodeInfo &
OPFL_Chain) && OldChainResultNo != -1 &&
2594 (
unsigned)OldChainResultNo != ResNumResults-1)
2596 SDValue(Res, ResNumResults - 1));
2611 CheckSame(
const unsigned char *MatcherTable,
unsigned &MatcherIndex,
2615 unsigned RecNo = MatcherTable[MatcherIndex++];
2616 assert(RecNo < RecordedNodes.size() &&
"Invalid CheckSame");
2617 return N == RecordedNodes[RecNo].first;
2647 CheckOpcode(
const unsigned char *MatcherTable,
unsigned &MatcherIndex,
2649 uint16_t Opc = MatcherTable[MatcherIndex++];
2650 Opc |= (
unsigned short)MatcherTable[MatcherIndex++] << 8;
2677 return cast<CondCodeSDNode>(
N)->
get() ==
2685 if (cast<VTSDNode>(N)->getVT() == VT)
2695 int64_t Val = MatcherTable[MatcherIndex++];
2697 Val =
GetVBR(Val, MatcherTable, MatcherIndex);
2705 SDValue N,
unsigned ChildNo) {
2712 CheckAndImm(
const unsigned char *MatcherTable,
unsigned &MatcherIndex,
2714 int64_t Val = MatcherTable[MatcherIndex++];
2716 Val =
GetVBR(Val, MatcherTable, MatcherIndex);
2725 CheckOrImm(
const unsigned char *MatcherTable,
unsigned &MatcherIndex,
2727 int64_t Val = MatcherTable[MatcherIndex++];
2729 Val =
GetVBR(Val, MatcherTable, MatcherIndex);
2748 switch (Table[Index++]) {
2753 Result = !
::CheckSame(Table, Index, N, RecordedNodes);
2776 unsigned Res = Table[Index++];
2830 unsigned NumRecordedNodes;
2833 unsigned NumMatchedMemRefs;
2836 SDValue InputChain, InputGlue;
2839 bool HasChainNodesMatched;
2857 RecordedNodes(
RN), MatchScopes(MS) {}
2868 if (N == *NodeToMatch)
2873 for (
auto &
I : RecordedNodes)
2874 if (
I.first.getNode() ==
N)
2877 for (
auto &
I : MatchScopes)
2878 for (
auto &J :
I.NodeStack)
2879 if (J.getNode() ==
N)
2887 const unsigned char *MatcherTable,
2888 unsigned TableSize) {
2924 Select_INLINEASM(NodeToMatch);
2927 Select_READ_REGISTER(NodeToMatch);
2930 Select_WRITE_REGISTER(NodeToMatch);
2933 Select_UNDEF(NodeToMatch);
2942 NodeStack.push_back(N);
2960 SDValue InputChain, InputGlue;
2974 unsigned MatcherIndex = 0;
2976 if (!OpcodeOffset.empty()) {
2978 if (N.
getOpcode() < OpcodeOffset.size())
2979 MatcherIndex = OpcodeOffset[N.
getOpcode()];
2980 LLVM_DEBUG(
dbgs() <<
" Initial Opcode index to " << MatcherIndex <<
"\n");
2989 unsigned CaseSize = MatcherTable[Idx++];
2991 CaseSize =
GetVBR(CaseSize, MatcherTable, Idx);
2992 if (CaseSize == 0)
break;
2995 uint16_t Opc = MatcherTable[Idx++];
2996 Opc |= (
unsigned short)MatcherTable[Idx++] << 8;
2997 if (Opc >= OpcodeOffset.size())
2998 OpcodeOffset.resize((Opc+1)*2);
2999 OpcodeOffset[Opc] = Idx;
3004 if (N.
getOpcode() < OpcodeOffset.size())
3005 MatcherIndex = OpcodeOffset[N.
getOpcode()];
3009 assert(MatcherIndex < TableSize &&
"Invalid index");
3011 unsigned CurrentOpcodeIndex = MatcherIndex;
3024 unsigned NumToSkip = MatcherTable[MatcherIndex++];
3025 if (NumToSkip & 128)
3026 NumToSkip =
GetVBR(NumToSkip, MatcherTable, MatcherIndex);
3028 if (NumToSkip == 0) {
3033 FailIndex = MatcherIndex+NumToSkip;
3035 unsigned MatcherIndexOfPredicate = MatcherIndex;
3036 (void)MatcherIndexOfPredicate;
3043 Result, *
this, RecordedNodes);
3048 dbgs() <<
" Skipped scope entry (due to false predicate) at " 3049 <<
"index " << MatcherIndexOfPredicate <<
", continuing at " 3050 << FailIndex <<
"\n");
3051 ++NumDAGIselRetries;
3055 MatcherIndex = FailIndex;
3059 if (FailIndex == 0)
break;
3063 MatchScope NewEntry;
3064 NewEntry.FailIndex = FailIndex;
3065 NewEntry.NodeStack.append(NodeStack.begin(), NodeStack.end());
3066 NewEntry.NumRecordedNodes = RecordedNodes.
size();
3067 NewEntry.NumMatchedMemRefs = MatchedMemRefs.
size();
3068 NewEntry.InputChain = InputChain;
3069 NewEntry.InputGlue = InputGlue;
3070 NewEntry.HasChainNodesMatched = !ChainNodesMatched.
empty();
3076 SDNode *Parent =
nullptr;
3077 if (NodeStack.size() > 1)
3078 Parent = NodeStack[NodeStack.size()-2].getNode();
3079 RecordedNodes.
push_back(std::make_pair(N, Parent));
3096 if (
auto *MN = dyn_cast<MemSDNode>(N))
3097 MatchedMemRefs.
push_back(MN->getMemOperand());
3113 unsigned ChildNo = MatcherTable[MatcherIndex++];
3117 NodeStack.push_back(N);
3129 NodeStack.push_back(N);
3135 NodeStack.pop_back();
3136 assert(!NodeStack.empty() &&
"Node stack imbalance!");
3137 N = NodeStack.back();
3141 if (!::
CheckSame(MatcherTable, MatcherIndex, N, RecordedNodes))
break;
3146 if (!::
CheckChildSame(MatcherTable, MatcherIndex, N, RecordedNodes,
3160 unsigned CPNum = MatcherTable[MatcherIndex++];
3161 unsigned RecNo = MatcherTable[MatcherIndex++];
3162 assert(RecNo < RecordedNodes.
size() &&
"Invalid CheckComplexPat");
3166 std::unique_ptr<MatchStateUpdater> MSU;
3168 MSU.reset(
new MatchStateUpdater(*
CurDAG, &NodeToMatch, RecordedNodes,
3172 RecordedNodes[RecNo].
first, CPNum,
3178 if (!::
CheckOpcode(MatcherTable, MatcherIndex, N.getNode()))
break;
3188 unsigned Res = MatcherTable[MatcherIndex++];
3189 if (!::
CheckType(MatcherTable, MatcherIndex, N.getValue(Res),
TLI,
3196 unsigned CurNodeOpcode = N.getOpcode();
3197 unsigned SwitchStart = MatcherIndex-1; (void)SwitchStart;
3201 CaseSize = MatcherTable[MatcherIndex++];
3203 CaseSize =
GetVBR(CaseSize, MatcherTable, MatcherIndex);
3204 if (CaseSize == 0)
break;
3206 uint16_t Opc = MatcherTable[MatcherIndex++];
3207 Opc |= (
unsigned short)MatcherTable[MatcherIndex++] << 8;
3210 if (CurNodeOpcode == Opc)
3214 MatcherIndex += CaseSize;
3218 if (CaseSize == 0)
break;
3221 LLVM_DEBUG(
dbgs() <<
" OpcodeSwitch from " << SwitchStart <<
" to " 3222 << MatcherIndex <<
"\n");
3227 MVT CurNodeVT = N.getSimpleValueType();
3228 unsigned SwitchStart = MatcherIndex-1; (void)SwitchStart;
3232 CaseSize = MatcherTable[MatcherIndex++];
3234 CaseSize =
GetVBR(CaseSize, MatcherTable, MatcherIndex);
3235 if (CaseSize == 0)
break;
3242 if (CurNodeVT == CaseVT)
3246 MatcherIndex += CaseSize;
3250 if (CaseSize == 0)
break;
3254 <<
"] from " << SwitchStart <<
" to " << MatcherIndex
3276 if (!::
CheckInteger(MatcherTable, MatcherIndex, N))
break;
3285 if (!::
CheckAndImm(MatcherTable, MatcherIndex, N, *
this))
break;
3288 if (!::
CheckOrImm(MatcherTable, MatcherIndex, N, *
this))
break;
3292 assert(NodeStack.size() != 1 &&
"No parent node");
3295 bool HasMultipleUses =
false;
3296 for (
unsigned i = 1, e = NodeStack.size()-1; i != e; ++i)
3297 if (!NodeStack[i].getNode()->hasOneUse()) {
3298 HasMultipleUses =
true;
3301 if (HasMultipleUses)
break;
3317 int64_t Val = MatcherTable[MatcherIndex++];
3319 Val =
GetVBR(Val, MatcherTable, MatcherIndex);
3320 RecordedNodes.
push_back(std::pair<SDValue, SDNode*>(
3328 unsigned RegNo = MatcherTable[MatcherIndex++];
3329 RecordedNodes.
push_back(std::pair<SDValue, SDNode*>(
3339 unsigned RegNo = MatcherTable[MatcherIndex++];
3340 RegNo |= MatcherTable[MatcherIndex++] << 8;
3341 RecordedNodes.
push_back(std::pair<SDValue, SDNode*>(
3348 unsigned RecNo = MatcherTable[MatcherIndex++];
3349 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitConvertToTarget");
3350 SDValue Imm = RecordedNodes[RecNo].first;
3353 const ConstantInt *Val=cast<ConstantSDNode>(Imm)->getConstantIntValue();
3355 Imm.getValueType());
3357 const ConstantFP *Val=cast<ConstantFPSDNode>(Imm)->getConstantFPValue();
3359 Imm.getValueType());
3362 RecordedNodes.
push_back(std::make_pair(Imm, RecordedNodes[RecNo].
second));
3371 "EmitMergeInputChains should be the first chain producing node");
3373 "Should only have one EmitMergeInputChains per match");
3377 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitMergeInputChains");
3378 ChainNodesMatched.
push_back(RecordedNodes[RecNo].
first.getNode());
3382 if (ChainNodesMatched.
back() != NodeToMatch &&
3383 !RecordedNodes[RecNo].first.hasOneUse()) {
3384 ChainNodesMatched.
clear();
3398 "EmitMergeInputChains should be the first chain producing node");
3405 unsigned NumChains = MatcherTable[MatcherIndex++];
3406 assert(NumChains != 0 &&
"Can't TF zero chains");
3409 "Should only have one EmitMergeInputChains per match");
3412 for (
unsigned i = 0; i != NumChains; ++i) {
3413 unsigned RecNo = MatcherTable[MatcherIndex++];
3414 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitMergeInputChains");
3415 ChainNodesMatched.
push_back(RecordedNodes[RecNo].
first.getNode());
3419 if (ChainNodesMatched.
back() != NodeToMatch &&
3420 !RecordedNodes[RecNo].first.hasOneUse()) {
3421 ChainNodesMatched.
clear();
3427 if (ChainNodesMatched.
empty())
3440 unsigned RecNo = MatcherTable[MatcherIndex++];
3441 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitCopyToReg");
3442 unsigned DestPhysReg = MatcherTable[MatcherIndex++];
3448 DestPhysReg, RecordedNodes[RecNo].
first,
3451 InputGlue = InputChain.
getValue(1);
3456 unsigned XFormNo = MatcherTable[MatcherIndex++];
3457 unsigned RecNo = MatcherTable[MatcherIndex++];
3458 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitNodeXForm");
3460 RecordedNodes.
push_back(std::pair<SDValue,SDNode*>(Res,
nullptr));
3466 unsigned index = MatcherTable[MatcherIndex++];
3467 index |= (MatcherTable[MatcherIndex++] << 8);
3476 uint16_t TargetOpc = MatcherTable[MatcherIndex++];
3477 TargetOpc |= (
unsigned short)MatcherTable[MatcherIndex++] << 8;
3478 unsigned EmitNodeInfo = MatcherTable[MatcherIndex++];
3488 NumVTs = MatcherTable[MatcherIndex++];
3490 for (
unsigned i = 0; i != NumVTs; ++i) {
3506 if (VTs.
size() == 1)
3508 else if (VTs.
size() == 2)
3514 unsigned NumOps = MatcherTable[MatcherIndex++];
3516 for (
unsigned i = 0; i != NumOps; ++i) {
3517 unsigned RecNo = MatcherTable[MatcherIndex++];
3519 RecNo =
GetVBR(RecNo, MatcherTable, MatcherIndex);
3521 assert(RecNo < RecordedNodes.
size() &&
"Invalid EmitNode");
3529 FirstOpToCopy += (EmitNodeInfo &
OPFL_Chain) ? 1 : 0;
3531 "Invalid variadic node");
3534 for (
unsigned i = FirstOpToCopy, e = NodeToMatch->
getNumOperands();
3543 if (EmitNodeInfo & OPFL_Chain)
3552 if (!IsMorphNodeTo) {
3559 for (
unsigned i = 0, e = VTs.
size(); i != e; ++i) {
3566 "NodeToMatch was removed partway through selection");
3570 auto &Chain = ChainNodesMatched;
3572 "Chain node replaced during MorphNode");
3573 Chain.erase(
std::remove(Chain.begin(), Chain.end(),
N), Chain.end());
3575 Res = cast<MachineSDNode>(MorphNode(NodeToMatch, TargetOpc, VTList,
3576 Ops, EmitNodeInfo));
3581 if (EmitNodeInfo & OPFL_GlueOutput) {
3583 if (EmitNodeInfo & OPFL_Chain)
3585 }
else if (EmitNodeInfo & OPFL_Chain)
3598 bool mayLoad = MCID.
mayLoad();
3601 unsigned NumMemRefs = 0;
3603 MatchedMemRefs.
begin(),
E = MatchedMemRefs.
end();
I !=
E; ++
I) {
3604 if ((*I)->isLoad()) {
3607 }
else if ((*I)->isStore()) {
3620 MatchedMemRefs.
begin(),
E = MatchedMemRefs.
end();
I !=
E; ++
I) {
3621 if ((*I)->isLoad()) {
3624 }
else if ((*I)->isStore()) {
3632 Res->
setMemRefs(MemRefs, MemRefs + NumMemRefs);
3636 <<
" Dropping mem operands\n";
3637 dbgs() <<
" " << (IsMorphNodeTo ?
"Morphed" :
"Created")
3642 if (IsMorphNodeTo) {
3644 UpdateChains(Res, InputChain, ChainNodesMatched,
true);
3654 unsigned NumResults = MatcherTable[MatcherIndex++];
3656 for (
unsigned i = 0; i != NumResults; ++i) {
3657 unsigned ResSlot = MatcherTable[MatcherIndex++];
3659 ResSlot =
GetVBR(ResSlot, MatcherTable, MatcherIndex);
3661 assert(ResSlot < RecordedNodes.
size() &&
"Invalid CompleteMatch");
3662 SDValue Res = RecordedNodes[ResSlot].first;
3664 assert(i < NodeToMatch->getNumValues() &&
3667 "Invalid number of results to complete!");
3672 Res.getValueSizeInBits()) &&
3673 "invalid replacement");
3678 UpdateChains(NodeToMatch, InputChain, ChainNodesMatched,
false);
3691 "Didn't replace all uses of the node?");
3701 LLVM_DEBUG(
dbgs() <<
" Match failed at index " << CurrentOpcodeIndex
3703 ++NumDAGIselRetries;
3705 if (MatchScopes.
empty()) {
3706 CannotYetSelect(NodeToMatch);
3712 MatchScope &LastScope = MatchScopes.
back();
3713 RecordedNodes.
resize(LastScope.NumRecordedNodes);
3715 NodeStack.append(LastScope.NodeStack.begin(), LastScope.NodeStack.end());
3716 N = NodeStack.back();
3718 if (LastScope.NumMatchedMemRefs != MatchedMemRefs.
size())
3719 MatchedMemRefs.
resize(LastScope.NumMatchedMemRefs);
3720 MatcherIndex = LastScope.FailIndex;
3724 InputChain = LastScope.InputChain;
3725 InputGlue = LastScope.InputGlue;
3726 if (!LastScope.HasChainNodesMatched)
3727 ChainNodesMatched.
clear();
3732 unsigned NumToSkip = MatcherTable[MatcherIndex++];
3733 if (NumToSkip & 128)
3734 NumToSkip =
GetVBR(NumToSkip, MatcherTable, MatcherIndex);
3738 if (NumToSkip != 0) {
3739 LastScope.FailIndex = MatcherIndex+NumToSkip;
3757 if (
auto *FN = dyn_cast<FrameIndexSDNode>(N->
getOperand(0))) {
3761 int32_t Off = C->getSExtValue();
3764 return (Off >= 0) && (((A - 1) & Off) ==
unsigned(Off));
3769 void SelectionDAGISel::CannotYetSelect(
SDNode *N) {
3772 Msg <<
"Cannot select: ";
3778 Msg <<
"\nIn function: " <<
MF->
getName();
3782 cast<ConstantSDNode>(N->
getOperand(HasInputChain))->getZExtValue();
3786 Msg <<
"target intrinsic %" <<
TII->
getName(iid);
3788 Msg <<
"unknown intrinsic #" << iid;
ANNOTATION_LABEL - Represents a mid basic block label used by annotations.
SDNode * MorphNodeTo(SDNode *N, unsigned Opc, SDVTList VTs, ArrayRef< SDValue > Ops)
This mutates the specified node to have the specified return type, opcode, and operands.
Return a value (possibly void), from a function.
std::vector< BitTestBlock > BitTestCases
BitTestCases - Vector of BitTestBlock structures used to communicate SwitchInst code generation infor...
Diagnostic information for ISel fallback path.
void push_back(const T &Elt)
SDNode * SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT)
These are used for target selectors to mutate the specified node to have the specified return type...
SelectionDAGBuilder * SDB
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckAndImm(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N, const SelectionDAGISel &SDISel)
A parsed version of the target data layout string in and methods for querying it. ...
mop_iterator operands_end()
EVT getValueType() const
Return the ValueType of the referenced return value.
static SDNode * findGlueUse(SDNode *N)
findGlueUse - Return use of MVT::Glue value produced by the specified SDNode.
void EmitLiveInCopies(MachineBasicBlock *EntryMBB, const TargetRegisterInfo &TRI, const TargetInstrInfo &TII)
EmitLiveInCopies - Emit copies to initialize livein virtual registers into the given entry block...
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckCondCode(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N)
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
bool hasPostISelHook(QueryType Type=IgnoreBundle) const
Return true if this instruction requires adjustment after instruction selection by calling a target h...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
uint64_t getZExtValue() const
Get zero extended value.
DebugLoc getCurDebugLoc() const
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
static int getNumFixedFromVariadicInfo(unsigned Flags)
getNumFixedFromVariadicInfo - Transform an EmitNode flags word into the number of fixed arity values ...
This class represents an incoming formal argument to a Function.
bool LegalizeTypes()
This transforms the SelectionDAG into a SelectionDAG that only uses types natively supported by the t...
DiagnosticInfoOptimizationBase::Argument NV
typename SuperClass::const_iterator const_iterator
const TargetRegisterClass * getRegClass(unsigned Reg) const
Return the register class of the specified virtual register.
virtual bool IsProfitableToFold(SDValue N, SDNode *U, SDNode *Root) const
IsProfitableToFold - Returns true if it's profitable to fold the specific operand node N of U during ...
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckValueType(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N, const TargetLowering *TLI, const DataLayout &DL)
DELETED_NODE - This is an illegal value that is used to catch errors.
MDNODE_SDNODE - This is a node that holdes an MDNode*, which is used to reference metadata in the IR...
static unsigned virtReg2Index(unsigned Reg)
Convert a virtual register number to a 0-based index.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Compute iterated dominance frontiers using a linear time algorithm.
MCSymbol * addLandingPad(MachineBasicBlock *LandingPad)
Add a new panding pad. Returns the label ID for the landing pad entry.
void setMemRefs(mmo_iterator NewMemRefs, mmo_iterator NewMemRefsEnd)
Assign this MachineSDNodes's memory reference descriptor list.
void VerifyDAGDiverence()
static cl::opt< bool > ViewISelDAGs("view-isel-dags", cl::Hidden, cl::desc("Pop up a window to show isel dags as they are selected"))
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
unsigned getCatchPadExceptionPointerVReg(const Value *CPI, const TargetRegisterClass *RC)
DenseMap< MachineBasicBlock *, SmallVector< unsigned, 4 > > LPadToCallSiteMap
LPadToCallSiteMap - Map a landing pad to the call site indexes.
unsigned EnableFastISel
EnableFastISel - This flag enables fast-path instruction selection which trades away generated code q...
static void propagateSwiftErrorVRegs(FunctionLoweringInfo *FuncInfo)
Propagate swifterror values through the machine function CFG.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
void ReplaceUses(SDValue F, SDValue T)
ReplaceUses - replace all uses of the old node F with the use of the new node T.
std::error_code remove(const Twine &path, bool IgnoreNonExisting=true)
Remove path.
Sched::Preference getSchedulingPreference() const
Return target scheduling preference.
bool CheckAndMask(SDValue LHS, ConstantSDNode *RHS, int64_t DesiredMaskS) const
CheckAndMask - The isel is trying to match something like (and X, 255).
const MachineFunctionProperties & getProperties() const
Get the function properties.
virtual unsigned getRegisterByName(const char *RegName, EVT VT, SelectionDAG &DAG) const
Return the register ID of the name passed in.
SelectionDAGBuilder - This is the common target-independent lowering implementation that is parameter...
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
static unsigned getFlagWord(unsigned Kind, unsigned NumOps)
Describe properties that are true of each instruction in the target description file.
void initializeTargetLibraryInfoWrapperPassPass(PassRegistry &)
Clients of various APIs that cause global effects on the DAG can optionally implement this interface...
unsigned getReg() const
getReg - Returns the register number.
friend struct DAGUpdateListener
DAGUpdateListener is a friend so it can manipulate the listener stack.
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
bool LegalizeVectors()
This transforms the SelectionDAG into a SelectionDAG that only uses vector math operations supported ...
virtual const TargetLowering * getTargetLowering() const
iterator_range< IterTy > args() const
bool mayWriteToMemory() const
Return true if this instruction may modify memory.
bool isSubsetOf(const APInt &RHS) const
This operation checks that all bits set in this APInt are also set in RHS.
void copyToMachineFrameInfo(MachineFrameInfo &MFI) const
iterator insertAfter(iterator I, MachineInstr *MI)
Insert MI into the instruction list after I.
unsigned getResNo() const
Convenience function for get().getResNo().
void visitJumpTableHeader(JumpTable &JT, JumpTableHeader &JTH, MachineBasicBlock *SwitchBB)
visitJumpTableHeader - This function emits necessary code to produce index in the JumpTable from swit...
bool NewNodesMustHaveLegalTypes
When true, additional steps are taken to ensure that getConstant() and similar functions return DAG n...
TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or anything else with this node...
static const MCPhysReg VRegs[32]
void getLocation(StringRef *Filename, unsigned *Line, unsigned *Column) const
Return location information for this diagnostic in three parts: the source file name, line number and column.
virtual const TargetRegisterClass * getRegClassFor(MVT VT) const
Return the register class that should be used for the specified value type.
STATISTIC(NumFunctions, "Total number of functions")
static bool findNonImmUse(SDNode *Root, SDNode *Def, SDNode *ImmedUse, bool IgnoreChains)
findNonImmUse - Return true if "Def" is a predecessor of "Root" via a path beyond "ImmedUse"...
unsigned const TargetRegisterInfo * TRI
bool isInteger() const
Return true if this is an integer or a vector integer type.
const MDOperand & getOperand(unsigned I) const
An instruction for reading from memory.
RegisterPassParser class - Handle the addition of new machine passes.
void setNodeId(int Id)
Set unique node id.
SDNode * getNode() const
get the SDNode which holds the desired result
static MachineBasicBlock::iterator FindSplitPointForStackProtector(MachineBasicBlock *BB)
Find the split point at which to splice the end of BB into its success stack protector check machine ...
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
const SDValue & setRoot(SDValue N)
Set the current root tag of the SelectionDAG.
bool mayLoad() const
Return true if this instruction could possibly read memory.
void viewGraph(const std::string &Title)
Pop up a GraphViz/gv window with the DAG rendered using 'dot'.
#define LLVM_ATTRIBUTE_ALWAYS_INLINE
LLVM_ATTRIBUTE_ALWAYS_INLINE - On compilers where we have a directive to do so, mark a method "always...
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckChildType(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N, const TargetLowering *TLI, const DataLayout &DL, unsigned ChildNo)
unsigned getValueSizeInBits() const
Returns the size of the value in bits.
EntryToken - This is the marker used to indicate the start of a region.
void setCurrentSwiftErrorVReg(const MachineBasicBlock *MBB, const Value *, unsigned)
Set the swifterror virtual register in the SwiftErrorVRegDefMap for this basic block.
static bool isUseOperandTiedToDef(unsigned Flag, unsigned &Idx)
isUseOperandTiedToDef - Return true if the flag of the inline asm operand indicates it is an use oper...
bool isReturn() const
Return true if the instruction is a return.
bool hasOneUse() const
Return true if there is exactly one node using value ResNo of Node.
ScheduleDAGSDNodes * createHybridListDAGScheduler(SelectionDAGISel *IS, CodeGenOpt::Level)
createHybridListDAGScheduler - This creates a bottom up register pressure aware list scheduler that m...
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckChildSame(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N, const SmallVectorImpl< std::pair< SDValue, SDNode *>> &RecordedNodes, unsigned ChildNo)
CheckChildSame - Implements OP_CheckChildXSame.
const TargetLibraryInfo * LibInfo
void set(const Function &Fn, MachineFunction &MF, SelectionDAG *DAG)
set - Initialize this FunctionLoweringInfo with the given Function and its associated MachineFunction...
bool isGCRelocate(ImmutableCallSite CS)
static void setupSwiftErrorVals(const Function &Fn, const TargetLowering *TLI, FunctionLoweringInfo *FuncInfo)
Set up SwiftErrorVals by going through the function.
static DIExpression * prepend(const DIExpression *Expr, bool DerefBefore, int64_t Offset=0, bool DerefAfter=false, bool StackValue=false)
Prepend DIExpr with a deref and offset operation and optionally turn it into a stack value...
RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) This node represents a target in...
static bool hasPredecessorHelper(const SDNode *N, SmallPtrSetImpl< const SDNode *> &Visited, SmallVectorImpl< const SDNode *> &Worklist, unsigned int MaxSteps=0, bool TopologicalPrune=false)
Returns true if N is a predecessor of any node in Worklist.
bool selectInstruction(const Instruction *I)
Do "fast" instruction selection for the given LLVM IR instruction and append the generated machine in...
static bool isFoldedOrDeadInstruction(const Instruction *I, FunctionLoweringInfo *FuncInfo)
isFoldedOrDeadInstruction - Return true if the specified instruction is side-effect free and is eithe...
StackProtectorDescriptor SPDescriptor
A StackProtectorDescriptor structure used to communicate stack protector information in between Selec...
std::pair< unsigned, bool > getOrCreateSwiftErrorVRegDefAt(const Instruction *)
Get or create the swifterror value virtual register for a def of a swifterror by an instruction...
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckSame(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N, const SmallVectorImpl< std::pair< SDValue, SDNode *>> &RecordedNodes)
CheckSame - Implements OP_CheckSame.
void visitSPDescriptorParent(StackProtectorDescriptor &SPD, MachineBasicBlock *ParentBB)
Codegen a new tail for a stack protector check ParentMBB which has had its tail spliced into a stack ...
SDValue getRoot()
Return the current virtual root of the Selection DAG, flushing any PendingLoad items.
void clear()
Clear state and free memory necessary to make this SelectionDAG ready to process a new block...
AnalysisUsage & addRequired()
void setLastLocalValue(MachineInstr *I)
Update the position of the last instruction emitted for materializing constants for use in the curren...
A description of a memory reference used in the backend.
void resetTargetOptions(const Function &F) const
Reset the target options based on the function's attributes.
StringRef getName(ID id)
Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
void visitSwitchCase(CaseBlock &CB, MachineBasicBlock *SwitchBB)
visitSwitchCase - Emits the necessary code to represent a single node in the binary search tree resul...
Option class for critical edge splitting.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
virtual bool ComplexPatternFuncMutatesDAG() const
Return true if complex patterns for this target can mutate the DAG.
static bool IsLegalToFold(SDValue N, SDNode *U, SDNode *Root, CodeGenOpt::Level OptLevel, bool IgnoreChains=false)
IsLegalToFold - Returns true if the specific operand node N of U can be folded during instruction sel...
This class is basically a combination of TimeRegion and Timer.
A Use represents the edge between a Value definition and its users.
const Value * SwiftErrorArg
The swifterror argument of the current function.
MachineSDNode * getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT)
These are used for target selectors to create a new node with specified return type(s), MachineInstr opcode, and operands.
void visitJumpTable(JumpTable &JT)
visitJumpTable - Emit JumpTable node in the current MBB
DenseMap< const Value *, unsigned > ValueMap
ValueMap - Since we emit code for the function a basic block at a time, we must remember which virtua...
const TargetLowering * TLI
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
CopyToReg - This node has three operands: a chain, a register number to set to this value...
const MDNode * getMD() const
virtual bool enableMachineSchedDefaultSched() const
True if the machine scheduler should disable the TLI preference for preRA scheduling with the source ...
op_iterator op_end() const
static MachinePassRegistry Registry
RegisterScheduler class - Track the registration of instruction schedulers.
virtual void Select(SDNode *N)=0
Main hook for targets to transform nodes into machine nodes.
ScheduleDAGSDNodes *(*)(SelectionDAGISel *, CodeGenOpt::Level) FunctionPassCtor
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
SDValue getEntryNode() const
Return the token chain corresponding to the entry of the function.
static void EnforceNodeIdInvariant(SDNode *N)
const DataLayout & getDataLayout() const
An analysis pass which caches information about the entire Module.
SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckOpcode(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDNode *N)
void setFunctionLoweringInfo(FunctionLoweringInfo *FuncInfo)
virtual unsigned getFrameRegister(const MachineFunction &MF) const =0
Debug information queries.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
This file implements a class to represent arbitrary precision integral constant values and operations...
INLINEASM - Represents an inline asm block.
This represents a list of ValueType's that has been intern'd by a SelectionDAG.
unsigned DAGSize
DAGSize - Size of DAG being instruction selected.
void initializeAAResultsWrapperPassPass(PassRegistry &)
MachineInstr * getVRegDef(unsigned Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
defusechain_iterator - This class provides iterator support for machine operands in the function that...
unsigned AssignTopologicalOrder()
Topological-sort the AllNodes list and a assign a unique node id for each node in the DAG based on th...
int getArgumentFrameIndex(const Argument *A)
getArgumentFrameIndex - Get frame index for the byval argument.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
int64_t getSExtValue() const
virtual StringRef getPatternForIndex(unsigned index)
getPatternForIndex - Patterns selected by tablegen during ISEL
static bool hasExceptionPointerOrCodeUser(const CatchPadInst *CPI)
static void InvalidateNodeId(SDNode *N)
This is a fast-path instruction selection class that generates poor code and doesn't support illegal ...
A constant value that is initialized with an expression using other constant values.
unsigned getSizeInBits() const
Return the size of the specified value type in bits.
Type * getType() const
All values are typed, get the type of this value.
bool getBoolValue() const
Convert APInt to a boolean value.
bool canTrap() const
Return true if evaluation of this constant could trap.
void clearKillFlags(unsigned Reg) const
clearKillFlags - Iterate over all the uses of the given register and clear the kill flag from the Mac...
virtual bool supportSwiftError() const
Return true if the target supports swifterror attribute.
bool isSwiftError() const
Return true if this value is a swifterror value.
SDNode * mutateStrictFPToFP(SDNode *Node)
Mutate the specified strict FP node to its non-strict equivalent, unlinking the node from its chain a...
ScheduleDAGSDNodes * createBURRListDAGScheduler(SelectionDAGISel *IS, CodeGenOpt::Level OptLevel)
createBURRListDAGScheduler - This creates a bottom up register usage reduction list scheduler...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
static unsigned IsPredicateKnownToFail(const unsigned char *Table, unsigned Index, SDValue N, bool &Result, const SelectionDAGISel &SDISel, SmallVectorImpl< std::pair< SDValue, SDNode *>> &RecordedNodes)
IsPredicateKnownToFail - If we know how and can do so without pushing a scope, evaluate the current n...
AttributeList getAttributes() const
Return the attribute list for this Function.
An instruction for storing to memory.
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out...
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
op_iterator op_begin() const
MachinePassRegistry - Track the registration of machine passes.
void init(GCFunctionInfo *gfi, AliasAnalysis *AA, const TargetLibraryInfo *li)
virtual const TargetInstrInfo * getInstrInfo() const
TargetConstant* - Like Constant*, but the DAG does not do any folding, simplification, or lowering of the constant.
~SelectionDAGISel() override
SDValue getTargetConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
static LLVM_ATTRIBUTE_ALWAYS_INLINE uint64_t GetVBR(uint64_t Val, const unsigned char *MatcherTable, unsigned &Idx)
GetVBR - decode a vbr encoding whose top bit is set.
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) This node represents a target intrinsic fun...
SDValue getTargetConstantFP(double Val, const SDLoc &DL, EVT VT)
const TargetRegisterClass * constrainRegClass(unsigned Reg, const TargetRegisterClass *RC, unsigned MinNumRegs=0)
constrainRegClass - Constrain the register class of the specified virtual register to be a common sub...
Legacy analysis pass which computes BranchProbabilityInfo.
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
auto count(R &&Range, const E &Element) -> typename std::iterator_traits< decltype(adl_begin(Range))>::difference_type
Wrapper function around std::count to count the number of times an element Element occurs in the give...
void printrFull(raw_ostream &O, const SelectionDAG *G=nullptr) const
Print a SelectionDAG node and all children down to the leaves.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
static cl::opt< bool > EnableFastISelFallbackReport("fast-isel-report-on-fallback", cl::Hidden, cl::desc("Emit a diagnostic when \ast\instruction selection " "falls back to SelectionDAG."))
UNDEF - An undefined node.
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"))
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
void finishBasicBlock()
Flush the local value map and sink local values if possible.
TargetInstrInfo - Interface to description of machine instruction set.
This corresponds to the llvm.lifetime.
MachineRegisterInfo * RegInfo
void clear()
clear - Clear out all the function-specific state.
iterator find(const_arg_type_t< KeyT > Val)
unsigned ComputeNumSignBits(SDValue Op, unsigned Depth=0) const
Return the number of times the sign bit of the register is replicated into the other bits...
bool isVoidTy() const
Return true if this is 'void'.
const BasicBlock & getEntryBlock() const
unsigned getNumValues() const
Return the number of values defined/returned by this operator.
bool hasAttrSomewhere(Attribute::AttrKind Kind, unsigned *Index=nullptr) const
Return true if the specified attribute is set for at least one parameter or for the return value...
static SDValue HandleMergeInputChains(SmallVectorImpl< SDNode *> &ChainNodesMatched, SelectionDAG *CurDAG)
HandleMergeInputChains - This implements the OPC_EmitMergeInputChains operation for when the pattern ...
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
BasicBlock * SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, const CriticalEdgeSplittingOptions &Options=CriticalEdgeSplittingOptions())
If this edge is a critical edge, insert a new node to split the critical edge.
unsigned getObjectAlignment(int ObjectIdx) const
Return the alignment of the specified stack object.
CriticalEdgeSplittingOptions & setMergeIdenticalEdges()
virtual bool CheckPatternPredicate(unsigned PredNo) const
CheckPatternPredicate - This function is generated by tblgen in the target.
initializer< Ty > init(const Ty &Val)
SmallPtrSet< const Instruction *, 4 > ElidedArgCopyInstrs
void initializeBranchProbabilityInfoWrapperPassPass(PassRegistry &)
OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...) This node represents a target intrin...
CodeGenOpt::Level OptLevel
void addLiveIn(MCPhysReg PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
ScheduleDAGSDNodes - A ScheduleDAG for scheduling SDNode-based DAGs.
const Instruction * getFirstNonPHI() const
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
READ_REGISTER, WRITE_REGISTER - This node represents llvm.register on the DAG, which implements the n...
Subclasses of this class are all able to terminate a basic block.
std::vector< std::pair< MachineInstr *, unsigned > > PHINodesToUpdate
PHINodesToUpdate - A list of phi instructions whose operand list will be updated after processing the...
unsigned const MachineRegisterInfo * MRI
ScheduleDAGSDNodes * createVLIWDAGScheduler(SelectionDAGISel *IS, CodeGenOpt::Level OptLevel)
createVLIWDAGScheduler - Scheduler for VLIW targets.
StringRef getName() const
Return the name of the corresponding LLVM basic block, or an empty string.
bool HasTailCall
HasTailCall - This is set to true if a call in the current block has been translated as a tail call...
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...
bool getO0WantsFastISel()
static void preassignSwiftErrorRegs(const TargetLowering *TLI, FunctionLoweringInfo *FuncInfo, BasicBlock::const_iterator Begin, BasicBlock::const_iterator End)
void Legalize()
This transforms the SelectionDAG into a SelectionDAG that is compatible with the target instruction s...
virtual unsigned getExceptionPointerRegister(const Constant *PersonalityFn) const
If a physical register, this returns the register that receives the exception address on entry to an ...
ScheduleDAGSDNodes * createDefaultScheduler(SelectionDAGISel *IS, CodeGenOpt::Level OptLevel)
createDefaultScheduler - This creates an instruction scheduler appropriate for the target...
use_iterator use_begin() const
Provide iteration support to walk over all uses of an SDNode.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
LLVM Basic Block Representation.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
DISubprogram * getSubprogram() const
Get the attached subprogram.
Value * getAddress() const
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
std::pair< unsigned, bool > getOrCreateSwiftErrorVRegUseAt(const Instruction *, const MachineBasicBlock *, const Value *)
MachineInstrBuilder & UseMI
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
void removeDeadCode(MachineBasicBlock::iterator I, MachineBasicBlock::iterator E)
Remove all dead instructions between the I and E.
iterator_range< value_op_iterator > op_values() const
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
const SDValue & getOperand(unsigned Num) const
ScheduleDAGSDNodes * createILPListDAGScheduler(SelectionDAGISel *IS, CodeGenOpt::Level)
createILPListDAGScheduler - This creates a bottom up register pressure aware list scheduler that trie...
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
bool succ_empty(const BasicBlock *BB)
ConstantFP - Floating Point Values [float, double].
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Interval::pred_iterator pred_begin(Interval *I)
pred_begin/pred_end - define methods so that Intervals may be used just like BasicBlocks can with the...
virtual unsigned getExceptionSelectorRegister(const Constant *PersonalityFn) const
If a physical register, this returns the register that receives the exception typeid on entry to a la...
static unsigned getNumOperandRegisters(unsigned Flag)
getNumOperandRegisters - Extract the number of registers field from the inline asm operand flag...
void RemoveDeadNodes()
This method deletes all unreachable nodes in the SelectionDAG.
Represent the analysis usage information of a pass.
void Combine(CombineLevel Level, AliasAnalysis *AA, CodeGenOpt::Level OptLevel)
This iterates over the nodes in the SelectionDAG, folding certain types of nodes together, or eliminating superfluous nodes.
This class provides iterator support for SDUse operands that use a specific SDNode.
DILocalVariable * getVariable() const
use_instr_iterator use_instr_begin(unsigned RegNo) const
bool tryToFoldLoad(const LoadInst *LI, const Instruction *FoldInst)
We're checking to see if we can fold LI into FoldInst.
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckChildInteger(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N, unsigned ChildNo)
static unsigned getMemoryConstraintID(unsigned Flag)
bool lowerArguments()
Do "fast" instruction selection for function arguments and append the machine instructions to the cur...
static cl::opt< bool > UseMBPI("use-mbpi", cl::desc("use Machine Branch Probability Info"), cl::init(true), cl::Hidden)
const APInt & getAPIntValue() const
DIExpression * getExpression() const
Interval::pred_iterator pred_end(Interval *I)
AssertSext, AssertZext - These nodes record if a register contains a value that has already been zero...
void setHasInlineAsm(bool B)
Set a flag that indicates that the function contains inline assembly.
virtual void PostprocessISelDAG()
PostprocessISelDAG() - This hook allows the target to hack on the graph right after selection...
void RemoveDeadNode(SDNode *N)
Remove the specified node from the system.
self_iterator getIterator()
void AddLiveOutRegInfo(unsigned Reg, unsigned NumSignBits, const KnownBits &Known)
AddLiveOutRegInfo - Adds LiveOutInfo for a register.
virtual MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr &MI, MachineBasicBlock *MBB) const
This method should be implemented by targets that mark instructions with the 'usesCustomInserter' fla...
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
auto find_if(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly...
static unsigned getFlagWordForMem(unsigned InputFlag, unsigned Constraint)
Augment an existing flag word returned by getFlagWord with the constraint code for a memory constrain...
static cl::opt< int > EnableFastISelAbort("fast-isel-abort", cl::Hidden, cl::desc("Enable abort calls when \ast\instruction selection " "fails to lower an instruction: 0 disable the abort, 1 will " "abort but for args, calls and terminators, 2 will also " "abort for argument lowering, and 3 will never fallback " "to SelectionDAG."))
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
unsigned ExceptionPointerVirtReg
If the current MBB is a landing pad, the exception pointer and exception selector registers are copie...
SmallPtrSet< const BasicBlock *, 4 > VisitedBBs
VisitedBBs - The set of basic blocks visited thus far by instruction selection.
static void reportFastISelFailure(MachineFunction &MF, OptimizationRemarkEmitter &ORE, OptimizationRemarkMissed &R, bool ShouldAbort)
static bool isMemKind(unsigned Flag)
bool isImplicitDef() const
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckOrImm(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N, const SelectionDAGISel &SDISel)
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
const MachineBasicBlock & front() const
StringRef getName(unsigned Opcode) const
Returns the name for the instructions with the given opcode.
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
void ComputePHILiveOutRegInfo(const PHINode *)
ComputePHILiveOutRegInfo - Compute LiveOutInfo for a PHI's destination register based on the LiveOutI...
bool isMachineOpcode() const
Test if this node has a post-isel opcode, directly corresponding to a MachineInstr opcode...
static void SplitCriticalSideEffectEdges(Function &Fn, DominatorTree *DT, LoopInfo *LI)
SplitCriticalSideEffectEdges - Look for critical edges with a PHI value that may trap on it...
unsigned getNumOperands() const
Return the number of values used by this operation.
std::string & str()
Flushes the stream contents to the target string and returns the string's reference.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
HANDLENODE node - Used as a handle for various purposes.
const DIExpression * getDebugExpression() const
Return the complex address expression referenced by this DBG_VALUE instruction.
MachineBasicBlock * MBB
MBB - The current block.
virtual bool enableMachineScheduler() const
True if the subtarget should run MachineScheduler after aggressive coalescing.
EH_LABEL - Represents a label in mid basic block used to track locations needed for debug and excepti...
bool isOrEquivalentToAdd(const SDNode *N) const
TargetIntrinsicInfo - Interface to description of machine instruction set.
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckInteger(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N)
void recomputeInsertPt()
Reset InsertPt to prepare for inserting instructions into the current block.
bool use_empty() const
Return true if there are no uses of this node.
bool SplitCSR
True if part of the CSRs will be handled via explicit copies.
bool isLandingPad() const
Return true if this basic block is a landing pad.
TokenFactor - This node takes multiple tokens as input and produces a single token result...
void dump() const
Dump this node, for debugging.
void visitSPDescriptorFailure(StackProtectorDescriptor &SPD)
Codegen the failure basic block for a stack protector check.
ScheduleDAGSDNodes * createSourceListDAGScheduler(SelectionDAGISel *IS, CodeGenOpt::Level OptLevel)
createBURRListDAGScheduler - This creates a bottom up list scheduler that schedules nodes in source c...
bool memoperands_empty() const
Iterator for intrusive lists based on ilist_node.
virtual bool supportSplitCSR(MachineFunction *MF) const
Return true if the target supports that a subset of CSRs for the given machine function is handled ex...
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
virtual void initializeSplitCSR(MachineBasicBlock *Entry) const
Perform necessary initialization to handle a subset of CSRs explicitly via copies.
This is the shared class of boolean and integer constants.
virtual bool CheckComplexPattern(SDNode *Root, SDNode *Parent, SDValue N, unsigned PatternNo, SmallVectorImpl< std::pair< SDValue, SDNode *> > &Result)
DenseMap< std::pair< const MachineBasicBlock *, const Value * >, unsigned > SwiftErrorVRegDefMap
A map from swifterror value in a basic block to the virtual register it is currently represented by...
std::string getMsg() const
DenseMap< unsigned, unsigned > RegFixups
RegFixups - Registers which need to be replaced after isel is done.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
bool isDebugValue() const
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
SmallVector< MachineInstr *, 8 > ArgDbgValues
ArgDbgValues - A list of DBG_VALUE instructions created during isel for function arguments that are i...
void clear()
Clear out the current SelectionDAG and the associated state and prepare this SelectionDAGBuilder obje...
void setFastISel(bool Enable)
static void createSwiftErrorEntriesInEntryBlock(FunctionLoweringInfo *FuncInfo, FastISel *FastIS, const TargetLowering *TLI, const TargetInstrInfo *TII, SelectionDAGBuilder *SDB)
An SDNode that represents everything that will be needed to construct a MachineInstr.
SelectionDAGISel(TargetMachine &tm, CodeGenOpt::Level OL=CodeGenOpt::Default)
void visit(const Instruction &I)
LLVM_NODISCARD T pop_back_val()
static void processDbgDeclares(FunctionLoweringInfo *FuncInfo)
Collect llvm.dbg.declare information.
DenseMap< std::pair< const MachineBasicBlock *, const Value * >, unsigned > SwiftErrorVRegUpwardsUse
A list of upward exposed vreg uses that need to be satisfied by either a copy def or a phi node at th...
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
SelectionDAGISel - This is the common base class used for SelectionDAG-based pattern-matching instruc...
void UpdateSplitBlock(MachineBasicBlock *First, MachineBasicBlock *Last)
UpdateSplitBlock - When an MBB was split during scheduling, update the references that need to refer ...
unsigned getNumIncomingValues() const
Return the number of incoming edges.
static cl::opt< bool > ViewLegalizeTypesDAGs("view-legalize-types-dags", cl::Hidden, cl::desc("Pop up a window to show dags before legalize types"))
allnodes_const_iterator allnodes_begin() const
virtual void AdjustInstrPostInstrSelection(MachineInstr &MI, SDNode *Node) const
This method should be implemented by targets that mark instructions with the 'hasPostISelHook' flag...
SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, unsigned Reg, SDValue N)
const Function & getFunction() const
Return the LLVM function that this machine code represents.
unsigned CreateRegs(Type *Ty)
CreateRegs - Allocate the appropriate number of virtual registers of the correctly promoted or expand...
void startNewBlock()
Set the current block to which generated machine instructions will be appended.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
static cl::opt< bool > ViewLegalizeDAGs("view-legalize-dags", cl::Hidden, cl::desc("Pop up a window to show dags before legalize"))
void setCallSiteLandingPad(MCSymbol *Sym, ArrayRef< unsigned > Sites)
Map the landing pad's EH symbol to the call site indexes.
Class for arbitrary precision integers.
iterator_range< use_iterator > uses()
static unsigned getReg(const void *D, unsigned RC, unsigned RegNo)
void visitBitTestCase(BitTestBlock &BB, MachineBasicBlock *NextMBB, BranchProbability BranchProbToNext, unsigned Reg, BitTestCase &B, MachineBasicBlock *SwitchBB)
visitBitTestCase - this function produces one "bit test"
BranchProbabilityInfo * BPI
This file defines the FastISel class.
ArrayRef< std::pair< unsigned, unsigned > > liveins() const
static use_iterator use_end()
iterator_range< user_iterator > users()
std::vector< JumpTableBlock > JTCases
JTCases - Vector of JumpTable structures used to communicate SwitchInst code generation information...
bool mayStore() const
Return true if this instruction could possibly modify memory.
bool use_empty(unsigned RegNo) const
use_empty - Return true if there are no instructions using the specified register.
void replaceRegWith(unsigned FromReg, unsigned ToReg)
replaceRegWith - Replace all instances of FromReg with ToReg in the machine function.
virtual Value * getSSPStackGuardCheck(const Module &M) const
If the target has a standard stack protection check function that performs validation and error handl...
amdgpu Simplify well known AMD library false Value Value * Arg
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
TargetSubtargetInfo - Generic base class for all target subtargets.
int getNodeId() const
Return the unique node id.
uint64_t getTypeSizeInBits(Type *Ty) const
Size examples:
Representation of each machine instruction.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
Represents a use of a SDNode.
unsigned ExceptionSelectorVirtReg
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
bool hasGC() const
hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm to use during code generatio...
unsigned GetSuccessorNumber(const BasicBlock *BB, const BasicBlock *Succ)
Search for the specified successor of basic block BB and return its position in the terminator instru...
bool isVector() const
Return true if this is a vector value type.
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
Bitwise operators - logical and, logical or, logical xor.
bool isOnlyUserOf(const SDNode *N) const
Return true if this node is the only use of N.
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB 'Other' at the position From, and insert it into this MBB right before '...
SDValue getCopyFromReg(SDValue Chain, const SDLoc &dl, unsigned Reg, EVT VT)
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
LLVM_NODISCARD bool empty() const
bool isTokenTy() const
Return true if this is 'token'.
virtual void viewGraph(const Twine &Name, const Twine &Title)
Pops up a GraphViz/gv window with the ScheduleDAG rendered using 'dot'.
virtual void insertCopiesSplitCSR(MachineBasicBlock *Entry, const SmallVectorImpl< MachineBasicBlock *> &Exits) const
Insert explicit copies in entry and exit blocks.
void computeKnownBits(SDValue Op, KnownBits &Known, unsigned Depth=0) const
Determine which bits of Op are known to be either zero or one and return them in Known.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
void init(MachineFunction &NewMF, OptimizationRemarkEmitter &NewORE, Pass *PassPtr, const TargetLibraryInfo *LibraryInfo, DivergenceAnalysis *Divergence)
Prepare this SelectionDAG to process code in the given MachineFunction.
StringRef getName() const
Return a constant reference to the value's name.
virtual const TargetIntrinsicInfo * getIntrinsicInfo() const
If intrinsic information is available, return it. If not, return null.
Establish a view to a call site for examination.
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
static bool MIIsInTerminatorSequence(const MachineInstr &MI)
Given that the input MI is before a partial terminator sequence TSeq, return true if M + TSeq also a ...
void initializeGCModuleInfoPass(PassRegistry &)
static cl::opt< bool > ViewSUnitDAGs("view-sunit-dags", cl::Hidden, cl::desc("Pop up a window to show SUnit dags after they are processed"))
FunctionLoweringInfo - This contains information that is global to a function that is used when lower...
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
bool isCall() const
Return true if the instruction is a call.
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
MachineBasicBlock::iterator InsertPt
MBB - The current insert position inside the current block.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
void Run(SelectionDAG *dag, MachineBasicBlock *bb)
Run - perform scheduling.
OptLevelChanger(SelectionDAGISel &ISel, CodeGenOpt::Level NewOptLevel)
iterator getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
bool isSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB is a successor of this block.
unsigned getOpcode() const
SDValue getValue(unsigned R) const
virtual bool CheckNodePredicate(SDNode *N, unsigned PredNo) const
CheckNodePredicate - This function is generated by tblgen in the target.
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
DenseMap< const AllocaInst *, int > StaticAllocaMap
StaticAllocaMap - Keep track of frame indices for fixed sized allocas in the entry block...
void setOptLevel(CodeGenOpt::Level Level)
Overrides the optimization level.
std::unique_ptr< OptimizationRemarkEmitter > ORE
Current optimization remark emitter.
CopyFromReg - This node indicates that the input value is a virtual or physical register that is defi...
const SDValue & getRoot() const
Return the root tag of the SelectionDAG.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
virtual bool SelectInlineAsmMemoryOperand(const SDValue &Op, unsigned ConstraintID, std::vector< SDValue > &OutOps)
SelectInlineAsmMemoryOperand - Select the specified address as a target addressing mode...
bool isStatepoint(ImmutableCallSite CS)
bool callsFunctionThatReturnsTwice() const
callsFunctionThatReturnsTwice - Return true if the function has a call to setjmp or other function th...
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckType(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N, const TargetLowering *TLI, const DataLayout &DL)
bool MaskedValueIsZero(SDValue Op, const APInt &Mask, unsigned Depth=0) const
Return true if 'Op & Mask' is known to be zero.
bool CheckOrMask(SDValue LHS, ConstantSDNode *RHS, int64_t DesiredMaskS) const
CheckOrMask - The isel is trying to match something like (or X, 255).
This class is used to form a handle around another node that is persistent and is updated across invo...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool hasProperty(Property P) const
unsigned getNumSuccessors() const
Return the number of successors that this terminator has.
A raw_ostream that writes to an std::string.
void InvalidatePHILiveOutRegInfo(const PHINode *PN)
InvalidatePHILiveOutRegInfo - Invalidates a PHI's LiveOutInfo, to be called when a block is visited b...
static cl::opt< std::string > FilterDAGBasicBlockName("filter-view-dags", cl::Hidden, cl::desc("Only display the basic block whose name " "matches this for all view-*-dags options"))
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
Constant * getPersonalityFn() const
Get the personality function associated with this function.
SDValue getRegister(unsigned Reg, EVT VT)
mop_iterator operands_begin()
virtual FastISel * createFastISel(FunctionLoweringInfo &, const TargetLibraryInfo *) const
This method returns a target specific FastISel object, or null if the target does not support "fast" ...
void SelectInlineAsmMemoryOperands(std::vector< SDValue > &Ops, const SDLoc &DL)
SelectInlineAsmMemoryOperands - Calls to this are automatically generated by tblgen.
virtual MachineBasicBlock * EmitSchedule(MachineBasicBlock::iterator &InsertPos)
EmitSchedule - Insert MachineInstrs into the MachineBasicBlock according to the order specified in Se...
virtual void finalizeLowering(MachineFunction &MF) const
Execute target specific actions to finalize target lowering.
static use_instr_iterator use_instr_end()
llvm::DenseMap< PointerIntPair< const Instruction *, 1, bool >, unsigned > SwiftErrorVRegDefUses
A map from instructions that define/use a swifterror value to the virtual register that represents th...
const DILocalVariable * getDebugVariable() const
Return the debug variable referenced by this DBG_VALUE instruction.
static cl::opt< bool > ViewSchedDAGs("view-sched-dags", cl::Hidden, cl::desc("Pop up a window to show sched dags as they are processed"))
std::vector< CaseBlock > SwitchCases
SwitchCases - Vector of CaseBlock structures used to communicate SwitchInst code generation informati...
Primary interface to the complete machine description for the target machine.
bool isEHPad() const
Return true if the instruction is a variety of EH-block.
Machine Instruction Scheduler
DenseMap< const BasicBlock *, MachineBasicBlock * > MBBMap
MBBMap - A mapping from LLVM basic blocks to their machine code entry.
SDValue getControlRoot()
Similar to getRoot, but instead of flushing all the PendingLoad items, flush all the PendingExports i...
bool hasOneUse() const
Return true if there is exactly one user of this value.
void ReplaceNode(SDNode *F, SDNode *T)
Replace all uses of F with T, then remove F from the DAG.
StringRef - Represent a constant reference to a string, i.e.
static Expected< std::string > replace(StringRef S, StringRef From, StringRef To)
void clearDanglingDebugInfo()
Clear the dangling debug information map.
SwiftErrorValues SwiftErrorVals
A function can only have a single swifterror argument.
bool skipFunction(const Function &F) const
Optional passes call this function to check whether the pass should be skipped.
const TargetLowering * TLI
void salvageDebugInfo(SDNode &N)
To be invoked on an SDNode that is slated to be erased.
virtual void PreprocessISelDAG()
PreprocessISelDAG - This hook allows targets to hack on the graph before instruction selection starts...
unsigned getNumOperands() const
bool isStrictFPOpcode()
Test if this node is a strict floating point pseudo-op.
static cl::opt< bool > ViewDAGCombine1("view-dag-combine1-dags", cl::Hidden, cl::desc("Pop up a window to show dags before the first " "dag combine pass"))
const SDValue & getOperand(unsigned i) const
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object...
bool TimePassesIsEnabled
If the user specifies the -time-passes argument on an LLVM tool command line then the value of this b...
const TerminatorInst * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
SDNode * getUser()
This returns the SDNode that contains this Use.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned char TargetFlags=0) const
virtual RegisterScheduler::FunctionPassCtor getDAGScheduler(CodeGenOpt::Level) const
Target can subclass this hook to select a different DAG scheduler.
bool shouldEmitSDCheck(const BasicBlock &BB) const
const MachineOperand & getOperand(unsigned i) const
virtual StringRef getIncludePathForIndex(unsigned index)
getIncludePathForIndex - get the td source location of pattern instantiation
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
const TargetInstrInfo * TII
void setVariableDbgInfo(const DILocalVariable *Var, const DIExpression *Expr, int Slot, const DILocation *Loc)
Collect information used to emit debugging information of a variable.
This represents the llvm.dbg.declare instruction.
bool isIndirectDebugValue() const
A DBG_VALUE is indirect iff the first operand is a register and the second operand is an immediate...
MachineInstr::mmo_iterator allocateMemRefsArray(unsigned long Num)
allocateMemRefsArray - Allocate an array to hold MachineMemOperand pointers.
void visitBitTestHeader(BitTestBlock &B, MachineBasicBlock *SwitchBB)
visitBitTestHeader - This function emits necessary code to produce value suitable for "bit tests" ...
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.
bool isExportedInst(const Value *V)
isExportedInst - Return true if the specified value is an instruction exported from its block...
PointerType * getType() const
Global values are always pointers.
FunctionLoweringInfo * FuncInfo
unsigned createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
A wrapper class for inspecting calls to intrinsic functions.
This file describes how to lower LLVM code to machine code.
virtual SDValue RunSDNodeXForm(SDValue V, unsigned XFormNo)
bool hasCalls() const
Return true if the current function has any function calls.
an instruction to allocate memory on the stack
This class is used by SelectionDAGISel to temporarily override the optimization level on a per-functi...
void SelectCodeCommon(SDNode *NodeToMatch, const unsigned char *MatcherTable, unsigned TableSize)
unsigned getOrCreateSwiftErrorVReg(const MachineBasicBlock *, const Value *)
Get or create the swifterror value virtual register in SwiftErrorVRegDefMap for this basic block...
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.
static cl::opt< bool > ViewDAGCombine2("view-dag-combine2-dags", cl::Hidden, cl::desc("Pop up a window to show dags before the second " "dag combine pass"))
static int getUninvalidatedNodeId(SDNode *N)
static RegisterScheduler defaultListDAGScheduler("default", "Best scheduler for the target", createDefaultScheduler)