123 using namespace llvm;
125 #define DEBUG_TYPE "isel" 133 cl::desc(
"Generate low-precision inline sequences " 134 "for some float libcalls"),
140 cl::desc(
"Set the case probability threshold for peeling the case from a " 141 "switch statement. A value greater than 100 will void this " 164 if (
auto *R = dyn_cast<ReturnInst>(V))
165 return R->getParent()->getParent()->getCallingConv();
167 if (
auto *CI = dyn_cast<CallInst>(V)) {
168 const bool IsInlineAsm = CI->isInlineAsm();
169 const bool IsIndirectFunctionCall =
170 !IsInlineAsm && !CI->getCalledFunction();
175 const bool IsInstrinsicCall =
176 !IsInlineAsm && !IsIndirectFunctionCall &&
179 if (!IsInlineAsm && !IsInstrinsicCall)
180 return CI->getCallingConv();
187 const SDValue *Parts,
unsigned NumParts,
197 const SDValue *Parts,
unsigned NumParts,
205 assert(NumParts > 0 &&
"No parts to assemble!");
216 unsigned RoundParts = NumParts & (NumParts - 1) ?
217 1 <<
Log2_32(NumParts) : NumParts;
218 unsigned RoundBits = PartBits * RoundParts;
219 EVT RoundVT = RoundBits == ValueBits ?
225 if (RoundParts > 2) {
229 RoundParts / 2, PartVT, HalfVT, V);
240 if (RoundParts < NumParts) {
242 unsigned OddParts = NumParts - RoundParts;
273 !PartVT.
isVector() &&
"Unexpected split");
284 if (PartEVT == ValueVT)
288 ValueVT.
bitsLT(PartEVT)) {
301 if (ValueVT.
bitsLT(PartEVT)) {
305 if (AssertOp.hasValue())
306 Val = DAG.
getNode(*AssertOp, DL, PartEVT, Val,
327 const Twine &ErrMsg) {
328 const Instruction *
I = dyn_cast_or_null<Instruction>(V);
332 const char *AsmError =
", possible invalid constraint for vector type";
333 if (
const CallInst *CI = dyn_cast<CallInst>(I))
334 if (isa<InlineAsm>(CI->getCalledValue()))
335 return Ctx.
emitError(I, ErrMsg + AsmError);
346 const SDValue *Parts,
unsigned NumParts,
350 assert(NumParts > 0 &&
"No parts to assemble!");
351 const bool IsABIRegCopy = CallConv.
hasValue();
360 unsigned NumIntermediates;
366 NumIntermediates, RegisterVT);
370 NumIntermediates, RegisterVT);
373 assert(NumRegs == NumParts &&
"Part count doesn't match vector breakdown!");
375 assert(RegisterVT == PartVT &&
"Part type doesn't match vector breakdown!");
378 "Part type sizes don't match!");
382 if (NumIntermediates == NumParts) {
385 for (
unsigned i = 0; i != NumParts; ++i)
387 PartVT, IntermediateVT, V);
388 }
else if (NumParts > 0) {
391 assert(NumParts % NumIntermediates == 0 &&
392 "Must expand into a divisible number of parts!");
393 unsigned Factor = NumParts / NumIntermediates;
394 for (
unsigned i = 0; i != NumIntermediates; ++i)
396 PartVT, IntermediateVT, V);
405 : NumIntermediates));
408 DL, BuiltVectorTy, Ops);
414 if (PartEVT == ValueVT)
424 "Cannot narrow, it would be a lossy transformation");
435 "Cannot handle this kind of promotion");
465 *DAG.
getContext(), V,
"non-trivial scalar-to-vector conversion");
487 SDValue *Parts,
unsigned NumParts,
MVT PartVT,
499 unsigned OrigNumParts = NumParts;
501 "Copying to an illegal type!");
507 EVT PartEVT = PartVT;
508 if (PartEVT == ValueVT) {
509 assert(NumParts == 1 &&
"No-op copy with multiple parts!");
517 assert(NumParts == 1 &&
"Do not know what to promote to!");
528 "Unknown mismatch!");
530 Val = DAG.
getNode(ExtendKind, DL, ValueVT, Val);
536 assert(NumParts == 1 && PartEVT != ValueVT);
542 "Unknown mismatch!");
552 "Failed to tile the value with PartVT!");
555 if (PartEVT != ValueVT) {
557 "scalar-to-vector conversion failed");
566 if (NumParts & (NumParts - 1)) {
569 "Do not know what to expand to!");
570 unsigned RoundParts = 1 <<
Log2_32(NumParts);
571 unsigned RoundBits = RoundParts * PartBits;
572 unsigned OddParts = NumParts - RoundParts;
575 getCopyToParts(DAG, DL, OddVal, Parts + RoundParts, OddParts, PartVT, V,
582 NumParts = RoundParts;
594 for (
unsigned StepSize = NumParts; StepSize > 1; StepSize /= 2) {
595 for (
unsigned i = 0; i < NumParts; i += StepSize) {
596 unsigned ThisBits = StepSize * PartBits / 2;
599 SDValue &Part1 = Parts[i+StepSize/2];
606 if (ThisBits == PartBits && ThisVT != PartVT) {
626 const bool IsABIRegCopy = CallConv.
hasValue();
629 EVT PartEVT = PartVT;
630 if (PartEVT == ValueVT) {
671 "lossy conversion of vector to scalar type");
672 EVT IntermediateType =
687 unsigned NumIntermediates;
690 NumRegs = TLI.getVectorTypeBreakdownForCallingConv(
692 NumIntermediates, RegisterVT);
695 TLI.getVectorTypeBreakdown(*DAG.
getContext(), ValueVT, IntermediateVT,
696 NumIntermediates, RegisterVT);
700 assert(NumRegs == NumParts &&
"Part count doesn't match vector breakdown!");
702 assert(RegisterVT == PartVT &&
"Part type doesn't match vector breakdown!");
705 unsigned DestVectorNoElts =
715 for (
unsigned i = 0; i != NumIntermediates; ++i) {
719 DAG.
getConstant(i * (NumElements / NumIntermediates), DL,
728 if (NumParts == NumIntermediates) {
731 for (
unsigned i = 0; i != NumParts; ++i)
732 getCopyToParts(DAG, DL, Ops[i], &Parts[i], 1, PartVT, V, CallConv);
733 }
else if (NumParts > 0) {
736 assert(NumIntermediates != 0 &&
"division by zero");
737 assert(NumParts % NumIntermediates == 0 &&
738 "Must expand into a divisible number of parts!");
739 unsigned Factor = NumParts / NumIntermediates;
740 for (
unsigned i = 0; i != NumIntermediates; ++i)
741 getCopyToParts(DAG, DL, Ops[i], &Parts[i * Factor], Factor, PartVT, V,
748 : ValueVTs(1, valuevt), RegVTs(1, regvt),
Regs(regs),
749 RegCount(1, regs.
size()), CallConv(CC) {}
767 for (
unsigned i = 0; i != NumRegs; ++i)
769 RegVTs.push_back(RegisterVT);
798 for (
unsigned i = 0; i != NumRegs; ++i) {
825 if (NumZeroBits == RegSize) {
840 }
else if (NumSignBits > 1) {
884 NumParts, RegisterVT, V, CallConv, ExtendKind);
890 for (
unsigned i = 0; i != NumRegs; ++i) {
902 if (NumRegs == 1 || Flag)
913 Chain = Chains[NumRegs-1];
919 unsigned MatchingIdx,
const SDLoc &dl,
921 std::vector<SDValue> &Ops)
const {
947 "No 1:1 mapping from clobbers to regs?");
955 "If we clobbered the stack pointer, MFI should know about it.");
963 for (
unsigned i = 0; i != NumRegs; ++i) {
976 unsigned RegCount = std::get<0>(CountAndVT);
977 MVT RegisterVT = std::get<1>(CountAndVT);
979 for (
unsigned E = I + RegCount; I !=
E; ++
I)
992 LPadToCallSiteMap.clear();
997 UnusedArgNodeMap.clear();
998 PendingLoads.clear();
999 PendingExports.clear();
1001 HasTailCall =
false;
1002 SDNodeOrder = LowestSDNodeOrder;
1003 StatepointLowering.clear();
1007 DanglingDebugInfoMap.clear();
1011 if (PendingLoads.empty())
1014 if (PendingLoads.size() == 1) {
1015 SDValue Root = PendingLoads[0];
1017 PendingLoads.clear();
1024 PendingLoads.clear();
1032 if (PendingExports.empty())
1037 unsigned i = 0, e = PendingExports.size();
1038 for (; i != e; ++i) {
1039 assert(PendingExports[i].getNode()->getNumOperands() > 1);
1040 if (PendingExports[i].getNode()->getOperand(0) == Root)
1045 PendingExports.push_back(Root);
1050 PendingExports.clear();
1057 if (isa<TerminatorInst>(&I)) {
1058 HandlePHINodesInSuccessorBlocks(I.
getParent());
1062 if (!isa<DbgInfoIntrinsic>(I))
1069 if (
auto *FPMO = dyn_cast<FPMathOperator>(&I)) {
1075 if (
SDNode *Node = getNodeForIRValue(&I)) {
1078 if (!Node->getFlags().isDefined())
1079 Node->setFlags(IncomingFlags);
1081 Node->intersectFlagsWith(IncomingFlags);
1085 if (!isa<TerminatorInst>(&I) && !HasTailCall &&
1087 CopyToExportRegsIfNeeded(&I);
1092 void SelectionDAGBuilder::visitPHI(
const PHINode &) {
1102 #define HANDLE_INST(NUM, OPCODE, CLASS) \ 1103 case Instruction::OPCODE: visit##OPCODE((const CLASS&)I); break; 1104 #include "llvm/IR/Instruction.def" 1110 auto isMatchingDbgValue = [&](DanglingDebugInfo &DDI) {
1114 if (DanglingVariable == Variable && Expr->
fragmentsOverlap(DanglingExpr)) {
1115 LLVM_DEBUG(
dbgs() <<
"Dropping dangling debug info for " << *DI <<
"\n");
1121 for (
auto &DDIMI : DanglingDebugInfoMap) {
1122 DanglingDebugInfoVector &DDIV = DDIMI.second;
1123 DDIV.erase(
remove_if(DDIV, isMatchingDbgValue), DDIV.end());
1131 auto DanglingDbgInfoIt = DanglingDebugInfoMap.find(V);
1132 if (DanglingDbgInfoIt == DanglingDebugInfoMap.end())
1135 DanglingDebugInfoVector &DDIV = DanglingDbgInfoIt->second;
1136 for (
auto &DDI : DDIV) {
1138 assert(DI &&
"Ill-formed DanglingDebugInfo");
1141 unsigned DbgSDNodeOrder = DDI.getSDNodeOrder();
1145 "Expected inlined-at fields to agree");
1148 if (!EmitFuncArgumentDbgValue(V, Variable, Expr, dl,
false, Val)) {
1150 << DbgSDNodeOrder <<
"] for:\n " << *DI <<
"\n");
1157 <<
"changing SDNodeOrder from " << DbgSDNodeOrder <<
" to " 1158 << ValSDNodeOrder <<
"\n");
1159 SDV = getDbgValue(Val, Variable, Expr, dl,
1160 std::max(DbgSDNodeOrder, ValSDNodeOrder));
1164 <<
"in EmitFuncArgumentDbgValue\n");
1177 if (It != FuncInfo.ValueMap.
end()) {
1178 unsigned InReg = It->second;
1183 Result = RFV.getCopyFromRegs(DAG, FuncInfo, getCurSDLoc(), Chain,
nullptr,
1185 resolveDanglingDebugInfo(V, Result);
1205 SDValue Val = getValueImpl(V);
1207 resolveDanglingDebugInfo(V, Val);
1213 return (NodeMap.find(V) != NodeMap.end()) ||
1214 (FuncInfo.ValueMap.find(V) != FuncInfo.ValueMap.end());
1223 if (isa<ConstantSDNode>(N) || isa<ConstantFPSDNode>(
N)) {
1234 SDValue Val = getValueImpl(V);
1236 resolveDanglingDebugInfo(V, Val);
1245 if (
const Constant *
C = dyn_cast<Constant>(V)) {
1254 if (isa<ConstantPointerNull>(
C)) {
1260 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
C))
1267 visit(CE->getOpcode(), *CE);
1269 assert(N1.getNode() &&
"visit didn't populate the NodeMap!");
1273 if (isa<ConstantStruct>(
C) || isa<ConstantArray>(
C)) {
1282 for (
unsigned i = 0, e = Val->
getNumValues(); i != e; ++i)
1290 dyn_cast<ConstantDataSequential>(
C)) {
1292 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
1293 SDNode *Val = getValue(CDS->getElementAsConstant(i)).getNode();
1296 for (
unsigned i = 0, e = Val->
getNumValues(); i != e; ++i)
1300 if (isa<ArrayType>(CDS->getType()))
1306 assert((isa<ConstantAggregateZero>(
C) || isa<UndefValue>(
C)) &&
1307 "Unknown struct or array constant!");
1311 unsigned NumElts = ValueVTs.
size();
1315 for (
unsigned i = 0; i != NumElts; ++i) {
1316 EVT EltVT = ValueVTs[i];
1317 if (isa<UndefValue>(
C))
1318 Constants[i] = DAG.
getUNDEF(EltVT);
1322 Constants[i] = DAG.
getConstant(0, getCurSDLoc(), EltVT);
1338 for (
unsigned i = 0; i != NumElements; ++i)
1339 Ops.
push_back(getValue(CV->getOperand(i)));
1341 assert(isa<ConstantAggregateZero>(
C) &&
"Unknown vector constant!");
1350 Ops.
assign(NumElements, Op);
1359 if (
const AllocaInst *AI = dyn_cast<AllocaInst>(V)) {
1361 FuncInfo.StaticAllocaMap.find(AI);
1362 if (SI != FuncInfo.StaticAllocaMap.end())
1368 if (
const Instruction *Inst = dyn_cast<Instruction>(V)) {
1369 unsigned InReg = FuncInfo.InitializeRegForValue(Inst);
1374 return RFV.getCopyFromRegs(DAG, FuncInfo, getCurSDLoc(), Chain,
nullptr, V);
1380 void SelectionDAGBuilder::visitCatchPad(
const CatchPadInst &
I) {
1390 if (IsMSVCCXX || IsCoreCLR)
1408 if (TargetMBB != NextBlock(FuncInfo.MBB) ||
1421 if (isa<ConstantTokenNone>(ParentPad))
1422 SuccessorColor = &FuncInfo.Fn->getEntryBlock();
1424 SuccessorColor = cast<Instruction>(ParentPad)->
getParent();
1425 assert(SuccessorColor &&
"No parent funclet for catchret!");
1427 assert(SuccessorColorMBB &&
"No MBB for SuccessorColor!");
1436 void SelectionDAGBuilder::visitCleanupPad(
const CleanupPadInst &CPI) {
1439 FuncInfo.MBB->setIsEHScopeEntry();
1440 FuncInfo.MBB->setIsEHFuncletEntry();
1441 FuncInfo.MBB->setIsCleanupFuncletEntry();
1466 if (isa<LandingPadInst>(Pad)) {
1468 UnwindDests.emplace_back(FuncInfo.
MBBMap[EHPadBB], Prob);
1470 }
else if (isa<CleanupPadInst>(Pad)) {
1473 UnwindDests.emplace_back(FuncInfo.
MBBMap[EHPadBB], Prob);
1474 UnwindDests.
back().first->setIsEHScopeEntry();
1475 UnwindDests.back().first->setIsEHFuncletEntry();
1477 }
else if (
auto *CatchSwitch = dyn_cast<CatchSwitchInst>(Pad)) {
1479 for (
const BasicBlock *CatchPadBB : CatchSwitch->handlers()) {
1480 UnwindDests.emplace_back(FuncInfo.
MBBMap[CatchPadBB], Prob);
1482 if (IsMSVCCXX || IsCoreCLR)
1483 UnwindDests.back().first->setIsEHFuncletEntry();
1485 UnwindDests.back().first->setIsEHScopeEntry();
1487 NewEHPadBB = CatchSwitch->getUnwindDest();
1493 if (BPI && NewEHPadBB)
1495 EHPadBB = NewEHPadBB;
1509 for (
auto &UnwindDest : UnwindDests) {
1510 UnwindDest.first->setIsEHPad();
1511 addSuccessorWithProb(FuncInfo.MBB, UnwindDest.first, UnwindDest.second);
1513 FuncInfo.MBB->normalizeSuccProbs();
1521 void SelectionDAGBuilder::visitCatchSwitch(
const CatchSwitchInst &CSI) {
1525 void SelectionDAGBuilder::visitRet(
const ReturnInst &I) {
1528 SDValue Chain = getControlRoot();
1540 LowerDeoptimizingReturn();
1544 if (!FuncInfo.CanLowerReturn) {
1545 unsigned DemoteReg = FuncInfo.DemoteRegister;
1558 DemoteReg, PtrValueVTs[0]);
1564 unsigned NumValues = ValueVTs.size();
1567 for (
unsigned i = 0; i != NumValues; ++i) {
1582 unsigned NumValues = ValueVTs.
size();
1597 bool RetInReg = F->getAttributes().hasAttribute(
1600 for (
unsigned j = 0; j != NumValues; ++j) {
1601 EVT VT = ValueVTs[j];
1613 &Parts[0], NumParts, PartVT, &I, CC, ExtendKind);
1626 for (
unsigned i = 0; i < NumParts; ++i) {
1641 assert(FuncInfo.SwiftErrorArg &&
"Need a swift error argument");
1650 DAG.
getRegister(FuncInfo.getOrCreateSwiftErrorVRegUseAt(
1651 &I, FuncInfo.MBB, FuncInfo.SwiftErrorArg).first,
1659 Chain, CallConv, isVarArg, Outs, OutVals, getCurSDLoc(), DAG);
1663 "LowerReturn didn't return a valid chain!");
1678 if (VMI != FuncInfo.ValueMap.
end()) {
1679 assert(!V->
use_empty() &&
"Unused value assigned virtual registers!");
1680 CopyValueToVirtualRegister(V, VMI->second);
1689 if (!isa<Instruction>(V) && !isa<Argument>(V))
return;
1692 if (FuncInfo.isExportedInst(V))
return;
1694 unsigned Reg = FuncInfo.InitializeRegForValue(V);
1695 CopyValueToVirtualRegister(V, Reg);
1704 if (
VI->getParent() == FromBB)
1708 return FuncInfo.isExportedInst(V);
1713 if (isa<Argument>(V)) {
1718 return FuncInfo.isExportedInst(V);
1735 auto SuccSize = std::max<uint32_t>(
succ_size(SrcBB), 1);
1748 Prob = getEdgeProbability(Src, Dst);
1754 if (
const Instruction *I = dyn_cast<Instruction>(V))
1775 if (
const CmpInst *BOp = dyn_cast<CmpInst>(Cond)) {
1779 if (CurBB == SwitchBB ||
1780 (isExportableFromCurrentBlock(BOp->getOperand(0), BB) &&
1781 isExportableFromCurrentBlock(BOp->getOperand(1), BB))) {
1783 if (
const ICmpInst *IC = dyn_cast<ICmpInst>(Cond)) {
1785 InvertCond ? IC->getInversePredicate() : IC->getPredicate();
1792 if (
TM.Options.NoNaNsFPMath)
1796 CaseBlock CB(Condition, BOp->getOperand(0), BOp->getOperand(1),
nullptr,
1797 TBB, FBB, CurBB, getCurSDLoc(), TProb, FProb);
1798 SwitchCases.push_back(CB);
1806 nullptr, TBB, FBB, CurBB, getCurSDLoc(), TProb, FProb);
1807 SwitchCases.push_back(CB);
1825 FindMergedConditions(CondOp, TBB, FBB, CurBB, SwitchBB, Opc, TProb, FProb,
1841 if (BOpc == Instruction::And)
1842 BOpc = Instruction::Or;
1843 else if (BOpc == Instruction::Or)
1844 BOpc = Instruction::And;
1849 if (!BOp || !(isa<BinaryOperator>(BOp) || isa<CmpInst>(BOp)) ||
1850 BOpc !=
unsigned(Opc) || !BOp->
hasOneUse() ||
1854 EmitBranchForMergedCondition(Cond, TBB, FBB, CurBB, SwitchBB,
1855 TProb, FProb, InvertCond);
1865 if (Opc == Instruction::Or) {
1886 auto NewTrueProb = TProb / 2;
1887 auto NewFalseProb = TProb / 2 + FProb;
1889 FindMergedConditions(BOp->
getOperand(0), TBB, TmpBB, CurBB, SwitchBB, Opc,
1890 NewTrueProb, NewFalseProb, InvertCond);
1896 FindMergedConditions(BOp->
getOperand(1), TBB, FBB, TmpBB, SwitchBB, Opc,
1897 Probs[0], Probs[1], InvertCond);
1899 assert(Opc == Instruction::And &&
"Unknown merge op!");
1919 auto NewTrueProb = TProb + FProb / 2;
1920 auto NewFalseProb = FProb / 2;
1922 FindMergedConditions(BOp->
getOperand(0), TmpBB, FBB, CurBB, SwitchBB, Opc,
1923 NewTrueProb, NewFalseProb, InvertCond);
1929 FindMergedConditions(BOp->
getOperand(1), TBB, FBB, TmpBB, SwitchBB, Opc,
1930 Probs[0], Probs[1], InvertCond);
1939 if (Cases.size() != 2)
return true;
1943 if ((Cases[0].CmpLHS == Cases[1].CmpLHS &&
1944 Cases[0].CmpRHS == Cases[1].CmpRHS) ||
1945 (Cases[0].CmpRHS == Cases[1].CmpLHS &&
1946 Cases[0].CmpLHS == Cases[1].CmpRHS)) {
1952 if (Cases[0].CmpRHS == Cases[1].CmpRHS &&
1953 Cases[0].CC == Cases[1].CC &&
1954 isa<Constant>(Cases[0].CmpRHS) &&
1955 cast<Constant>(Cases[0].CmpRHS)->isNullValue()) {
1956 if (Cases[0].CC ==
ISD::SETEQ && Cases[0].TrueBB == Cases[1].ThisBB)
1958 if (Cases[0].CC ==
ISD::SETNE && Cases[0].FalseBB == Cases[1].ThisBB)
1965 void SelectionDAGBuilder::visitBr(
const BranchInst &I) {
2005 if (
const BinaryOperator *BOp = dyn_cast<BinaryOperator>(CondVal)) {
2009 (Opcode == Instruction::And || Opcode == Instruction::Or)) {
2010 FindMergedConditions(BOp, Succ0MBB, Succ1MBB, BrMBB, BrMBB,
2012 getEdgeProbability(BrMBB, Succ0MBB),
2013 getEdgeProbability(BrMBB, Succ1MBB),
2018 assert(SwitchCases[0].ThisBB == BrMBB &&
"Unexpected lowering!");
2021 if (ShouldEmitAsBranches(SwitchCases)) {
2022 for (
unsigned i = 1, e = SwitchCases.size(); i != e; ++i) {
2023 ExportFromCurrentBlock(SwitchCases[i].CmpLHS);
2024 ExportFromCurrentBlock(SwitchCases[i].CmpRHS);
2028 visitSwitchCase(SwitchCases[0], BrMBB);
2029 SwitchCases.erase(SwitchCases.begin());
2035 for (
unsigned i = 1, e = SwitchCases.size(); i != e; ++i)
2036 FuncInfo.MF->erase(SwitchCases[i].ThisBB);
2038 SwitchCases.clear();
2044 nullptr, Succ0MBB, Succ1MBB, BrMBB, getCurSDLoc());
2048 visitSwitchCase(CB, BrMBB);
2056 SDValue CondLHS = getValue(CB.CmpLHS);
2071 Cond = DAG.
getSetCC(dl,
MVT::i1, CondLHS, getValue(CB.CmpRHS), CB.CC);
2075 const APInt& Low = cast<ConstantInt>(CB.CmpLHS)->getValue();
2076 const APInt&
High = cast<ConstantInt>(CB.CmpRHS)->getValue();
2078 SDValue CmpOp = getValue(CB.CmpMHS);
2081 if (cast<ConstantInt>(CB.CmpLHS)->isMinValue(
true)) {
2093 addSuccessorWithProb(SwitchBB, CB.TrueBB, CB.TrueProb);
2096 if (CB.TrueBB != CB.FalseBB)
2097 addSuccessorWithProb(SwitchBB, CB.FalseBB, CB.FalseProb);
2102 if (CB.TrueBB == NextBlock(SwitchBB)) {
2124 assert(JT.Reg != -1U &&
"Should lower JT Header first!");
2138 JumpTableHeader &JTH,
2140 SDLoc dl = getCurSDLoc();
2145 SDValue SwitchOp = getValue(JTH.SValue);
2158 unsigned JumpTableReg =
2161 JumpTableReg, SwitchOp);
2162 JT.Reg = JumpTableReg;
2177 if (JT.MBB != NextBlock(SwitchBB))
2193 DAG.
getMachineNode(TargetOpcode::LOAD_STACK_GUARD, DL, PtrTy, Chain);
2223 SDLoc dl = getCurSDLoc();
2242 auto *Fn = cast<Function>(GuardCheck);
2244 assert(FnTy->getNumParams() == 1 &&
"Invalid function signature");
2248 Entry.
Node = GuardVal;
2249 Entry.
Ty = FnTy->getParamType(0);
2250 if (Fn->hasAttribute(1, Attribute::AttrKind::InReg))
2252 Args.push_back(Entry);
2257 .setCallee(Fn->getCallingConv(), FnTy->getReturnType(),
2258 getValue(GuardCheck), std::move(Args));
2272 SDValue GuardPtr = getValue(IRGuard);
2314 None,
false, getCurSDLoc(),
false,
false).second;
2322 SDLoc dl = getCurSDLoc();
2325 SDValue SwitchOp = getValue(B.SValue);
2338 bool UsePtrType =
false;
2342 for (
unsigned i = 0, e = B.Cases.size(); i != e; ++i)
2356 B.Reg = FuncInfo.CreateReg(B.RegVT);
2361 addSuccessorWithProb(SwitchBB, B.Default, B.DefaultProb);
2362 addSuccessorWithProb(SwitchBB, MBB, B.Prob);
2370 if (MBB != NextBlock(SwitchBB))
2384 SDLoc dl = getCurSDLoc();
2390 if (PopCount == 1) {
2397 }
else if (PopCount == BB.Range) {
2417 addSuccessorWithProb(SwitchBB, B.TargetBB, B.ExtraProb);
2419 addSuccessorWithProb(SwitchBB, NextMBB, BranchProbToNext);
2430 if (NextMBB != NextBlock(SwitchBB))
2437 void SelectionDAGBuilder::visitInvoke(
const InvokeInst &I) {
2448 {LLVMContext::OB_deopt, LLVMContext::OB_funclet}) &&
2449 "Cannot lower invokes with arbitrary operand bundles yet!");
2453 if (isa<InlineAsm>(
Callee))
2455 else if (Fn && Fn->isIntrinsic()) {
2456 switch (Fn->getIntrinsicID()) {
2459 case Intrinsic::donothing:
2462 case Intrinsic::experimental_patchpoint_void:
2463 case Intrinsic::experimental_patchpoint_i64:
2464 visitPatchpoint(&I, EHPadBB);
2466 case Intrinsic::experimental_gc_statepoint:
2475 LowerCallSiteWithDeoptBundle(&I, getValue(
Callee), EHPadBB);
2477 LowerCallTo(&I, getValue(
Callee),
false, EHPadBB);
2485 CopyToExportRegsIfNeeded(&I);
2496 addSuccessorWithProb(InvokeMBB, Return);
2497 for (
auto &UnwindDest : UnwindDests) {
2498 UnwindDest.first->setIsEHPad();
2499 addSuccessorWithProb(InvokeMBB, UnwindDest.first, UnwindDest.second);
2509 void SelectionDAGBuilder::visitResume(
const ResumeInst &RI) {
2510 llvm_unreachable(
"SelectionDAGBuilder shouldn't visit resume instructions!");
2513 void SelectionDAGBuilder::visitLandingPad(
const LandingPadInst &LP) {
2514 assert(FuncInfo.MBB->isEHPad() &&
2515 "Call to landingpad not in landing pad!");
2523 const Constant *PersonalityFn = FuncInfo.Fn->getPersonalityFn();
2536 SDLoc dl = getCurSDLoc();
2538 assert(ValueVTs.
size() == 2 &&
"Only two-valued landingpads are supported");
2543 if (FuncInfo.ExceptionPointerVirtReg) {
2546 FuncInfo.ExceptionPointerVirtReg,
2554 FuncInfo.ExceptionSelectorVirtReg,
2564 void SelectionDAGBuilder::sortAndRangeify(CaseClusterVector &Clusters) {
2566 for (
const CaseCluster &CC : Clusters)
2567 assert(CC.Low == CC.High &&
"Input clusters must be single-case");
2571 [](
const CaseCluster &a,
const CaseCluster &b) {
2572 return a.Low->getValue().slt(b.Low->getValue());
2576 const unsigned N = Clusters.size();
2577 unsigned DstIndex = 0;
2578 for (
unsigned SrcIndex = 0; SrcIndex <
N; ++SrcIndex) {
2579 CaseCluster &CC = Clusters[SrcIndex];
2583 if (DstIndex != 0 && Clusters[DstIndex - 1].MBB == Succ &&
2584 (CaseVal->
getValue() - Clusters[DstIndex - 1].High->getValue()) == 1) {
2587 Clusters[DstIndex - 1].High = CaseVal;
2588 Clusters[DstIndex - 1].Prob += CC.Prob;
2590 std::memmove(&Clusters[DstIndex++], &Clusters[SrcIndex],
2591 sizeof(Clusters[SrcIndex]));
2594 Clusters.resize(DstIndex);
2600 for (
unsigned i = 0, e = JTCases.size(); i != e; ++i)
2601 if (JTCases[i].
first.HeaderBB == First)
2602 JTCases[i].first.HeaderBB = Last;
2605 for (
unsigned i = 0, e = BitTestCases.size(); i != e; ++i)
2606 if (BitTestCases[i].Parent == First)
2607 BitTestCases[i].Parent = Last;
2610 void SelectionDAGBuilder::visitIndirectBr(
const IndirectBrInst &I) {
2617 bool Inserted = Done.
insert(BB).second;
2622 addSuccessorWithProb(IndirectBrMBB, Succ);
2631 void SelectionDAGBuilder::visitUnreachable(
const UnreachableInst &I) {
2638 if (&I != &BB.
front()) {
2641 if (
const CallInst *Call = dyn_cast<CallInst>(&*PredI)) {
2642 if (Call->doesNotReturn())
2651 void SelectionDAGBuilder::visitFSub(
const User &I) {
2676 case Instruction::Mul:
2677 case Instruction::And:
2678 case Instruction::Or:
2679 case Instruction::Xor:
2681 case Instruction::FAdd:
2682 case Instruction::FMul:
2683 if (
const FPMathOperator *FPOp = dyn_cast<const FPMathOperator>(Inst))
2684 if (FPOp->getFastMathFlags().isFast())
2696 unsigned ElemNumToReduce = ElemNum;
2719 bool ReduxExtracted =
false;
2721 while (!UsersToVisit.empty()) {
2722 auto User = UsersToVisit.back();
2723 UsersToVisit.pop_back();
2732 if (Inst->
getOpcode() == OpCode || isa<PHINode>(U)) {
2733 if (
const FPMathOperator *FPOp = dyn_cast<const FPMathOperator>(Inst))
2734 if (!isa<PHINode>(FPOp) && !FPOp->getFastMathFlags().isFast())
2736 UsersToVisit.push_back(U);
2738 dyn_cast<ShuffleVectorInst>(U)) {
2745 if (ResultElements < ElemNum)
2748 if (ElemNumToReduce == 1)
2750 if (!isa<UndefValue>(U->getOperand(1)))
2752 for (
unsigned i = 0; i < ElemNumToReduce / 2; ++i)
2753 if (ShufInst->getMaskValue(i) != int(i + ElemNumToReduce / 2))
2755 for (
unsigned i = ElemNumToReduce / 2; i < ElemNum; ++i)
2756 if (ShufInst->getMaskValue(i) != -1)
2761 if (!U->hasOneUse())
2765 if (!U2 || U2->getOpcode() != OpCode)
2769 if ((U2->getOperand(0) == U->getOperand(0) && U2->getOperand(1) == U) ||
2770 (U2->getOperand(1) == U->getOperand(0) && U2->getOperand(0) == U)) {
2771 UsersToVisit.push_back(U2);
2772 ElemNumToReduce /= 2;
2775 }
else if (isa<ExtractElementInst>(U)) {
2777 if (ElemNumToReduce != 1)
2781 if (!Val || !Val->
isZero())
2784 ReduxExtracted =
true;
2789 return ReduxExtracted;
2792 void SelectionDAGBuilder::visitBinary(
const User &I,
unsigned Opcode) {
2794 if (
auto *OFBinOp = dyn_cast<OverflowingBinaryOperator>(&I)) {
2798 if (
auto *ExactOp = dyn_cast<PossiblyExactOperator>(&I)) {
2799 Flags.
setExact(ExactOp->isExact());
2803 LLVM_DEBUG(
dbgs() <<
"Detected a reduction operation:" << I <<
"\n");
2810 setValue(&I, BinNodeValue);
2813 void SelectionDAGBuilder::visitShift(
const User &I,
unsigned Opcode) {
2823 unsigned Op2Size = Op2.getValueSizeInBits();
2824 SDLoc DL = getCurSDLoc();
2827 if (ShiftSize > Op2Size)
2834 else if (ShiftSize >=
Log2_32_Ceil(Op2.getValueSizeInBits()))
2849 dyn_cast<const OverflowingBinaryOperator>(&I)) {
2850 nuw = OFBinOp->hasNoUnsignedWrap();
2851 nsw = OFBinOp->hasNoSignedWrap();
2854 dyn_cast<const PossiblyExactOperator>(&I))
2855 exact = ExactOp->isExact();
2866 void SelectionDAGBuilder::visitSDiv(
const User &I) {
2871 Flags.
setExact(isa<PossiblyExactOperator>(&I) &&
2872 cast<PossiblyExactOperator>(&I)->isExact());
2877 void SelectionDAGBuilder::visitICmp(
const User &I) {
2879 if (
const ICmpInst *IC = dyn_cast<ICmpInst>(&I))
2880 predicate = IC->getPredicate();
2881 else if (
const ConstantExpr *IC = dyn_cast<ConstantExpr>(&I))
2889 setValue(&I, DAG.
getSetCC(getCurSDLoc(), DestVT, Op1, Op2, Opcode));
2892 void SelectionDAGBuilder::visitFCmp(
const User &I) {
2894 if (
const FCmpInst *
FC = dyn_cast<FCmpInst>(&I))
2895 predicate =
FC->getPredicate();
2903 if ((FPMO && FPMO->hasNoNaNs()) ||
TM.Options.NoNaNsFPMath)
2908 setValue(&I, DAG.
getSetCC(getCurSDLoc(), DestVT, Op1, Op2, Condition));
2915 return isa<SelectInst>(V);
2919 void SelectionDAGBuilder::visitSelect(
const User &I) {
2923 unsigned NumValues = ValueVTs.
size();
2924 if (NumValues == 0)
return;
2930 auto BaseOps = {Cond};
2936 EVT VT = ValueVTs[0];
2943 VT != TLI.getTypeToTransformTo(Ctx, VT))
2944 VT = TLI.getTypeToTransformTo(Ctx, VT);
2949 bool UseScalarMinMax = VT.
isVector() &&
2955 switch (SPR.Flavor) {
2961 switch (SPR.NaNBehavior) {
2968 else if (TLI.isOperationLegalOrCustom(
ISD::FMINNAN, VT))
2970 else if (UseScalarMinMax)
2978 switch (SPR.NaNBehavior) {
2986 else if (TLI.isOperationLegalOrCustom(
ISD::FMAXNAN, VT))
2988 else if (UseScalarMinMax)
2998 (TLI.isOperationLegalOrCustom(Opc, VT) ||
3006 LHSVal = getValue(LHS);
3007 RHSVal = getValue(RHS);
3012 for (
unsigned i = 0; i != NumValues; ++i) {
3015 Ops.push_back(
SDValue(RHSVal.getNode(), RHSVal.getResNo() + i));
3016 Values[i] = DAG.
getNode(OpCode, getCurSDLoc(),
3017 LHSVal.getNode()->getValueType(LHSVal.getResNo()+i),
3025 void SelectionDAGBuilder::visitTrunc(
const User &I) {
3033 void SelectionDAGBuilder::visitZExt(
const User &I) {
3042 void SelectionDAGBuilder::visitSExt(
const User &I) {
3051 void SelectionDAGBuilder::visitFPTrunc(
const User &I) {
3054 SDLoc dl = getCurSDLoc();
3062 void SelectionDAGBuilder::visitFPExt(
const User &I) {
3070 void SelectionDAGBuilder::visitFPToUI(
const User &I) {
3078 void SelectionDAGBuilder::visitFPToSI(
const User &I) {
3086 void SelectionDAGBuilder::visitUIToFP(
const User &I) {
3094 void SelectionDAGBuilder::visitSIToFP(
const User &I) {
3102 void SelectionDAGBuilder::visitPtrToInt(
const User &I) {
3111 void SelectionDAGBuilder::visitIntToPtr(
const User &I) {
3120 void SelectionDAGBuilder::visitBitCast(
const User &I) {
3122 SDLoc dl = getCurSDLoc();
3136 setValue(&I, DAG.
getConstant(
C->getValue(), dl, DestVT,
false,
3142 void SelectionDAGBuilder::visitAddrSpaceCast(
const User &I) {
3157 void SelectionDAGBuilder::visitInsertElement(
const User &I) {
3165 InVec, InVal, InIdx));
3168 void SelectionDAGBuilder::visitExtractElement(
const User &I) {
3178 void SelectionDAGBuilder::visitShuffleVector(
const User &I) {
3181 SDLoc DL = getCurSDLoc();
3185 unsigned MaskNumElts = Mask.
size();
3192 if (SrcNumElts == MaskNumElts) {
3198 if (SrcNumElts < MaskNumElts) {
3202 if (MaskNumElts % SrcNumElts == 0) {
3206 unsigned NumConcat = MaskNumElts / SrcNumElts;
3207 bool IsConcat =
true;
3209 for (
unsigned i = 0; i != MaskNumElts; ++i) {
3215 if ((Idx % SrcNumElts != (i % SrcNumElts)) ||
3216 (ConcatSrcs[i / SrcNumElts] >= 0 &&
3217 ConcatSrcs[i / SrcNumElts] != (
int)(Idx / SrcNumElts))) {
3222 ConcatSrcs[i / SrcNumElts] = Idx / SrcNumElts;
3229 for (
auto Src : ConcatSrcs) {
3242 unsigned PaddedMaskNumElts =
alignTo(MaskNumElts, SrcNumElts);
3243 unsigned NumConcat = PaddedMaskNumElts / SrcNumElts;
3264 for (
unsigned i = 0; i != MaskNumElts; ++i) {
3266 if (Idx >= (
int)SrcNumElts)
3267 Idx -= SrcNumElts - PaddedMaskNumElts;
3275 if (MaskNumElts != PaddedMaskNumElts)
3280 setValue(&I, Result);
3284 if (SrcNumElts > MaskNumElts) {
3287 int StartIdx[2] = { -1, -1 };
3288 bool CanExtract =
true;
3289 for (
int Idx : Mask) {
3294 if (Idx >= (
int)SrcNumElts) {
3302 int NewStartIdx =
alignDown(Idx, MaskNumElts);
3303 if (NewStartIdx + MaskNumElts > SrcNumElts ||
3304 (StartIdx[Input] >= 0 && StartIdx[Input] != NewStartIdx))
3308 StartIdx[Input] = NewStartIdx;
3311 if (StartIdx[0] < 0 && StartIdx[1] < 0) {
3317 for (
unsigned Input = 0; Input < 2; ++Input) {
3318 SDValue &Src = Input == 0 ? Src1 : Src2;
3319 if (StartIdx[Input] < 0)
3331 for (
int &Idx : MappedOps) {
3332 if (Idx >= (
int)SrcNumElts)
3333 Idx -= SrcNumElts + StartIdx[1] - MaskNumElts;
3349 for (
int Idx : Mask) {
3355 SDValue &Src = Idx < (int)SrcNumElts ? Src1 : Src2;
3356 if (Idx >= (
int)SrcNumElts) Idx -= SrcNumElts;
3368 void SelectionDAGBuilder::visitInsertValue(
const User &I) {
3371 Indices = IV->getIndices();
3373 Indices = cast<ConstantExpr>(&
I)->getIndices();
3379 bool IntoUndef = isa<UndefValue>(Op0);
3380 bool FromUndef = isa<UndefValue>(Op1);
3390 unsigned NumAggValues = AggValueVTs.
size();
3391 unsigned NumValValues = ValValueVTs.size();
3395 if (!NumAggValues) {
3403 for (; i != LinearIndex; ++i)
3404 Values[i] = IntoUndef ? DAG.
getUNDEF(AggValueVTs[i]) :
3409 for (; i != LinearIndex + NumValValues; ++i)
3410 Values[i] = FromUndef ? DAG.
getUNDEF(AggValueVTs[i]) :
3414 for (; i != NumAggValues; ++i)
3415 Values[i] = IntoUndef ? DAG.
getUNDEF(AggValueVTs[i]) :
3422 void SelectionDAGBuilder::visitExtractValue(
const User &I) {
3425 Indices = EV->getIndices();
3427 Indices = cast<ConstantExpr>(&
I)->getIndices();
3432 bool OutOfUndef = isa<UndefValue>(Op0);
3440 unsigned NumValValues = ValValueVTs.
size();
3443 if (!NumValValues) {
3452 for (
unsigned i = LinearIndex; i != LinearIndex + NumValValues; ++i)
3453 Values[i - LinearIndex] =
3462 void SelectionDAGBuilder::visitGetElementPtr(
const User &I) {
3468 SDLoc dl = getCurSDLoc();
3473 cast<VectorType>(I.
getType())->getVectorNumElements() : 0;
3483 const Value *Idx = GTI.getOperand();
3484 if (
StructType *StTy = GTI.getStructTypeOrNull()) {
3485 unsigned Field = cast<Constant>(Idx)->getUniqueInteger().getZExtValue();
3488 uint64_t
Offset = DL->getStructLayout(StTy)->getElementOffset(Field);
3493 if (int64_t(Offset) >= 0 && cast<GEPOperator>(I).isInBounds())
3502 APInt ElementSize(IdxSize, DL->getTypeAllocSize(GTI.getIndexedType()));
3507 if (!CI && isa<ConstantDataVector>(Idx) &&
3509 CI = cast<ConstantInt>(cast<ConstantDataVector>(Idx)->getSplatValue());
3516 SDValue OffsVal = VectorWidth ?
3544 if (ElementSize != 1) {
3546 unsigned Amt = ElementSize.
logBase2();
3565 void SelectionDAGBuilder::visitAlloca(
const AllocaInst &I) {
3568 if (FuncInfo.StaticAllocaMap.count(&I))
3571 SDLoc dl = getCurSDLoc();
3575 uint64_t TySize = DL.getTypeAllocSize(Ty);
3582 if (AllocSize.getValueType() != IntPtr)
3592 unsigned StackAlign =
3594 if (Align <= StackAlign)
3602 AllocSize = DAG.
getNode(
ISD::ADD, dl, AllocSize.getValueType(), AllocSize,
3603 DAG.
getConstant(StackAlign - 1, dl, IntPtr), Flags);
3608 DAG.
getConstant(~(uint64_t)(StackAlign - 1), dl, IntPtr));
3616 assert(FuncInfo.MF->getFrameInfo().hasVarSizedObjects());
3619 void SelectionDAGBuilder::visitLoad(
const LoadInst &I) {
3621 return visitAtomicLoad(I);
3628 if (
const Argument *
Arg = dyn_cast<Argument>(SV)) {
3629 if (
Arg->hasSwiftErrorAttr())
3630 return visitLoadFromSwiftError(I);
3633 if (
const AllocaInst *Alloca = dyn_cast<AllocaInst>(SV)) {
3634 if (Alloca->isSwiftError())
3635 return visitLoadFromSwiftError(I);
3656 unsigned NumValues = ValueVTs.size();
3661 bool ConstantMemory =
false;
3662 if (isVolatile || NumValues > MaxParallelChains)
3669 ConstantMemory =
true;
3675 SDLoc dl = getCurSDLoc();
3688 unsigned ChainI = 0;
3689 for (
unsigned i = 0; i != NumValues; ++i, ++ChainI) {
3696 if (ChainI == MaxParallelChains) {
3697 assert(PendingLoads.empty() &&
"PendingLoads must be serialized first");
3714 if (isDereferenceable)
3720 MMOFlags, AAInfo, Ranges);
3726 if (!ConstantMemory) {
3732 PendingLoads.push_back(Chain);
3739 void SelectionDAGBuilder::visitStoreToSwiftError(
const StoreInst &I) {
3741 "call visitStoreToSwiftError when backend supports swifterror");
3748 assert(ValueVTs.size() == 1 && Offsets[0] == 0 &&
3749 "expect a single EVT for swifterror");
3753 unsigned VReg;
bool CreatedVReg;
3754 std::tie(VReg, CreatedVReg) = FuncInfo.getOrCreateSwiftErrorVRegDefAt(&I);
3758 SDValue(Src.getNode(), Src.getResNo()));
3761 FuncInfo.setCurrentSwiftErrorVReg(FuncInfo.MBB, I.
getOperand(1), VReg);
3764 void SelectionDAGBuilder::visitLoadFromSwiftError(
const LoadInst &I) {
3766 "call visitLoadFromSwiftError when backend supports swifterror");
3771 "Support volatile, non temporal, invariant for load_from_swift_error");
3779 "load_from_swift_error should not be constant memory");
3785 assert(ValueVTs.size() == 1 && Offsets[0] == 0 &&
3786 "expect a single EVT for swifterror");
3790 getRoot(), getCurSDLoc(),
3791 FuncInfo.getOrCreateSwiftErrorVRegUseAt(&I, FuncInfo.MBB, SV).first,
3797 void SelectionDAGBuilder::visitStore(
const StoreInst &I) {
3799 return visitAtomicStore(I);
3808 if (
const Argument *
Arg = dyn_cast<Argument>(PtrV)) {
3809 if (
Arg->hasSwiftErrorAttr())
3810 return visitStoreToSwiftError(I);
3813 if (
const AllocaInst *Alloca = dyn_cast<AllocaInst>(PtrV)) {
3814 if (Alloca->isSwiftError())
3815 return visitStoreToSwiftError(I);
3823 unsigned NumValues = ValueVTs.
size();
3835 SDLoc dl = getCurSDLoc();
3853 unsigned ChainI = 0;
3854 for (
unsigned i = 0; i != NumValues; ++i, ++ChainI) {
3856 if (ChainI == MaxParallelChains) {
3867 Chains[ChainI] = St;
3875 void SelectionDAGBuilder::visitMaskedStore(
const CallInst &I,
3876 bool IsCompressing) {
3877 SDLoc sdl = getCurSDLoc();
3880 unsigned& Alignment) {
3884 Alignment = cast<ConstantInt>(I.
getArgOperand(2))->getZExtValue();
3888 unsigned& Alignment) {
3896 Value *PtrOperand, *MaskOperand, *Src0Operand;
3899 getCompressingStoreOps(PtrOperand, MaskOperand, Src0Operand, Alignment);
3901 getMaskedStoreOps(PtrOperand, MaskOperand, Src0Operand, Alignment);
3903 SDValue Ptr = getValue(PtrOperand);
3904 SDValue Src0 = getValue(Src0Operand);
3905 SDValue Mask = getValue(MaskOperand);
3923 setValue(&I, StoreNode);
3951 const Value *GEPPtr = GEP->getPointerOperand();
3957 unsigned FinalIndex = GEP->getNumOperands() - 1;
3958 Value *IndexVal = GEP->getOperand(FinalIndex);
3961 for (
unsigned i = 1; i < FinalIndex; ++i) {
3963 if (!
C || !
C->isZero())
3980 unsigned GEPWidth = GEP->getType()->getVectorNumElements();
3987 void SelectionDAGBuilder::visitMaskedScatter(
const CallInst &I) {
3988 SDLoc sdl = getCurSDLoc();
3995 unsigned Alignment = (cast<ConstantInt>(I.
getArgOperand(2)))->getZExtValue();
4006 const Value *BasePtr = Ptr;
4007 bool UniformBase =
getUniformBase(BasePtr, Base, Index, Scale,
this);
4009 const Value *MemOpBasePtr = UniformBase ? BasePtr :
nullptr;
4016 Index = getValue(Ptr);
4023 setValue(&I, Scatter);
4026 void SelectionDAGBuilder::visitMaskedLoad(
const CallInst &I,
bool IsExpanding) {
4027 SDLoc sdl = getCurSDLoc();
4030 unsigned& Alignment) {
4033 Alignment = cast<ConstantInt>(I.
getArgOperand(1))->getZExtValue();
4038 unsigned& Alignment) {
4046 Value *PtrOperand, *MaskOperand, *Src0Operand;
4049 getExpandingLoadOps(PtrOperand, MaskOperand, Src0Operand, Alignment);
4051 getMaskedLoadOps(PtrOperand, MaskOperand, Src0Operand, Alignment);
4053 SDValue Ptr = getValue(PtrOperand);
4054 SDValue Src0 = getValue(Src0Operand);
4055 SDValue Mask = getValue(MaskOperand);
4066 bool AddToChain = !AA || !AA->pointsToConstantMemory(
MemoryLocation(
4074 Alignment, AAInfo, Ranges);
4079 PendingLoads.push_back(Load.getValue(1));
4083 void SelectionDAGBuilder::visitMaskedGather(
const CallInst &I) {
4084 SDLoc sdl = getCurSDLoc();
4093 unsigned Alignment = (cast<ConstantInt>(I.
getArgOperand(1)))->getZExtValue();
4105 const Value *BasePtr = Ptr;
4106 bool UniformBase =
getUniformBase(BasePtr, Base, Index, Scale,
this);
4107 bool ConstantMemory =
false;
4114 ConstantMemory =
true;
4121 Alignment, AAInfo, Ranges);
4125 Index = getValue(Ptr);
4133 if (!ConstantMemory)
4134 PendingLoads.push_back(OutChain);
4135 setValue(&I, Gather);
4139 SDLoc dl = getCurSDLoc();
4152 0, SuccessOrder, FailureOrder, SSID);
4160 void SelectionDAGBuilder::visitAtomicRMW(
const AtomicRMWInst &I) {
4161 SDLoc dl = getCurSDLoc();
4197 void SelectionDAGBuilder::visitFence(
const FenceInst &I) {
4198 SDLoc dl = getCurSDLoc();
4209 void SelectionDAGBuilder::visitAtomicLoad(
const LoadInst &I) {
4210 SDLoc dl = getCurSDLoc();
4244 void SelectionDAGBuilder::visitAtomicStore(
const StoreInst &I) {
4245 SDLoc dl = getCurSDLoc();
4272 void SelectionDAGBuilder::visitTargetIntrinsic(
const CallInst &I,
4273 unsigned Intrinsic) {
4293 TargetLowering::IntrinsicInfo Info;
4321 if (IsTgtIntrinsic) {
4326 Info.flags, Info.size);
4327 }
else if (!HasChain) {
4338 PendingLoads.push_back(Chain);
4348 Result = lowerRangeToAssertZExt(DAG, I, Result);
4350 setValue(&I, Result);
4409 SDValue TwoToFractionalPartOfX;
4410 if (LimitFloatPrecision <= 6) {
4425 }
else if (LimitFloatPrecision <= 12) {
4487 LimitFloatPrecision > 0 && LimitFloatPrecision <= 18) {
4512 LimitFloatPrecision > 0 && LimitFloatPrecision <= 18) {
4525 if (LimitFloatPrecision <= 6) {
4540 }
else if (LimitFloatPrecision <= 12) {
4610 LimitFloatPrecision > 0 && LimitFloatPrecision <= 18) {
4623 if (LimitFloatPrecision <= 6) {
4636 }
else if (LimitFloatPrecision <= 12) {
4707 LimitFloatPrecision > 0 && LimitFloatPrecision <= 18) {
4720 if (LimitFloatPrecision <= 6) {
4735 }
else if (LimitFloatPrecision <= 12) {
4795 LimitFloatPrecision > 0 && LimitFloatPrecision <= 18)
4806 bool IsExp10 =
false;
4808 LimitFloatPrecision > 0 && LimitFloatPrecision <= 18) {
4811 IsExp10 = LHSC->isExactlyValue(Ten);
4840 unsigned Val = RHSC->getSExtValue();
4841 if ((
int)Val < 0) Val = -Val;
4869 CurSquare, CurSquare);
4874 if (RHSC->getSExtValue() < 0)
4904 bool SelectionDAGBuilder::EmitFuncArgumentDbgValue(
4914 bool IsIndirect =
false;
4917 int FI = FuncInfo.getArgumentFrameIndex(Arg);
4931 IsIndirect = IsDbgDeclare;
4939 dyn_cast<FrameIndexSDNode>(LNode->getBasePtr().getNode()))
4945 if (VMI != FuncInfo.ValueMap.
end()) {
4949 if (RFV.occupiesMultipleRegs()) {
4951 for (
auto RegAndSize : RFV.getRegsAndSizes()) {
4954 Expr, Offset, RegAndSize.second);
4957 FuncInfo.ArgDbgValues.push_back(
4958 BuildMI(MF, DL, TII->
get(TargetOpcode::DBG_VALUE), IsDbgDeclare,
4959 Op->
getReg(), Variable, *FragmentExpr));
4960 Offset += RegAndSize.second;
4965 IsIndirect = IsDbgDeclare;
4973 "Expected inlined-at fields to agree");
4974 IsIndirect = (Op->
isReg()) ? IsIndirect :
true;
4975 FuncInfo.ArgDbgValues.push_back(
4976 BuildMI(MF, DL, TII->
get(TargetOpcode::DBG_VALUE), IsIndirect,
4977 *
Op, Variable, Expr));
4987 unsigned DbgSDNodeOrder) {
4988 if (
auto *FISDN = dyn_cast<FrameIndexSDNode>(N.
getNode())) {
5000 false, dl, DbgSDNodeOrder);
5003 false, dl, DbgSDNodeOrder);
5007 #if defined(_MSC_VER) && defined(setjmp) && \ 5008 !defined(setjmp_undefined_for_msvc) 5009 # pragma push_macro("setjmp") 5011 # define setjmp_undefined_for_msvc 5018 SelectionDAGBuilder::visitIntrinsicCall(
const CallInst &I,
unsigned Intrinsic) {
5020 SDLoc sdl = getCurSDLoc();
5024 switch (Intrinsic) {
5027 visitTargetIntrinsic(I, Intrinsic);
5029 case Intrinsic::vastart: visitVAStart(I);
return nullptr;
5030 case Intrinsic::vaend: visitVAEnd(I);
return nullptr;
5031 case Intrinsic::vacopy: visitVACopy(I);
return nullptr;
5032 case Intrinsic::returnaddress:
5037 case Intrinsic::addressofreturnaddress:
5041 case Intrinsic::frameaddress:
5046 case Intrinsic::read_register: {
5050 DAG.
getMDNode(cast<MDNode>(cast<MetadataAsValue>(Reg)->getMetadata()));
5058 case Intrinsic::write_register: {
5063 DAG.
getMDNode(cast<MDNode>(cast<MetadataAsValue>(Reg)->getMetadata()));
5065 RegName, getValue(RegValue)));
5068 case Intrinsic::setjmp:
5070 case Intrinsic::longjmp:
5072 case Intrinsic::memcpy: {
5073 const auto &MCI = cast<MemCpyInst>(
I);
5078 unsigned DstAlign = std::max<unsigned>(MCI.getDestAlignment(), 1);
5079 unsigned SrcAlign = std::max<unsigned>(MCI.getSourceAlignment(), 1);
5081 bool isVol = MCI.isVolatile();
5089 updateDAGForMaybeTailCall(MC);
5092 case Intrinsic::memset: {
5093 const auto &MSI = cast<MemSetInst>(
I);
5098 unsigned Align = std::max<unsigned>(MSI.getDestAlignment(), 1);
5099 bool isVol = MSI.isVolatile();
5103 updateDAGForMaybeTailCall(MS);
5106 case Intrinsic::memmove: {
5107 const auto &MMI = cast<MemMoveInst>(
I);
5112 unsigned DstAlign = std::max<unsigned>(MMI.getDestAlignment(), 1);
5113 unsigned SrcAlign = std::max<unsigned>(MMI.getSourceAlignment(), 1);
5115 bool isVol = MMI.isVolatile();
5122 updateDAGForMaybeTailCall(MM);
5125 case Intrinsic::memcpy_element_unordered_atomic: {
5137 SrcAlign, Length, LengthTy, ElemSz, isTC,
5140 updateDAGForMaybeTailCall(MC);
5143 case Intrinsic::memmove_element_unordered_atomic: {
5144 auto &
MI = cast<AtomicMemMoveInst>(
I);
5145 SDValue Dst = getValue(
MI.getRawDest());
5146 SDValue Src = getValue(
MI.getRawSource());
5147 SDValue Length = getValue(
MI.getLength());
5149 unsigned DstAlign =
MI.getDestAlignment();
5150 unsigned SrcAlign =
MI.getSourceAlignment();
5151 Type *LengthTy =
MI.getLength()->getType();
5152 unsigned ElemSz =
MI.getElementSizeInBytes();
5155 SrcAlign, Length, LengthTy, ElemSz, isTC,
5158 updateDAGForMaybeTailCall(MC);
5161 case Intrinsic::memset_element_unordered_atomic: {
5162 auto &
MI = cast<AtomicMemSetInst>(
I);
5163 SDValue Dst = getValue(
MI.getRawDest());
5165 SDValue Length = getValue(
MI.getLength());
5167 unsigned DstAlign =
MI.getDestAlignment();
5168 Type *LengthTy =
MI.getLength()->getType();
5169 unsigned ElemSz =
MI.getElementSizeInBytes();
5172 LengthTy, ElemSz, isTC,
5174 updateDAGForMaybeTailCall(MC);
5177 case Intrinsic::dbg_addr:
5178 case Intrinsic::dbg_declare: {
5182 dropDanglingDebugInfo(Variable, Expression);
5183 assert(Variable &&
"Missing variable");
5187 if (!Address || isa<UndefValue>(Address) ||
5193 bool isParameter = Variable->isParameter() || isa<Argument>(
Address);
5198 if (
const auto *AI =
5200 if (AI->isStaticAlloca()) {
5201 auto I = FuncInfo.StaticAllocaMap.find(AI);
5202 if (I != FuncInfo.StaticAllocaMap.end())
5205 }
else if (
const auto *
Arg = dyn_cast<Argument>(
5207 FI = FuncInfo.getArgumentFrameIndex(
Arg);
5214 if (Intrinsic == Intrinsic::dbg_addr) {
5216 Variable, Expression, FI,
true, dl, SDNodeOrder);
5217 DAG.
AddDbgValue(SDV, getRoot().getNode(), isParameter);
5225 N = UnusedArgNodeMap[
Address];
5228 if (
const BitCastInst *BCI = dyn_cast<BitCastInst>(Address))
5229 Address = BCI->getOperand(0);
5232 if (isParameter && FINode) {
5236 true, dl, SDNodeOrder);
5237 }
else if (isa<Argument>(Address)) {
5240 EmitFuncArgumentDbgValue(Address, Variable, Expression, dl,
true, N);
5244 true, dl, SDNodeOrder);
5250 if (!EmitFuncArgumentDbgValue(Address, Variable, Expression, dl,
true,
5257 case Intrinsic::dbg_label: {
5260 assert(Label &&
"Missing label");
5267 case Intrinsic::dbg_value: {
5273 dropDanglingDebugInfo(Variable, Expression);
5279 if (isa<ConstantInt>(V) || isa<ConstantFP>(V) || isa<UndefValue>(V)) {
5288 if (!N.
getNode() && isa<Argument>(V))
5289 N = UnusedArgNodeMap[V];
5291 if (EmitFuncArgumentDbgValue(V, Variable, Expression, dl,
false, N))
5293 SDV = getDbgValue(N, Variable, Expression, dl, SDNodeOrder);
5300 if (isa<PHINode>(V)) {
5301 auto VMI = FuncInfo.ValueMap.find(V);
5302 if (VMI != FuncInfo.ValueMap.end()) {
5303 unsigned Reg = VMI->second;
5308 if (RFV.occupiesMultipleRegs()) {
5310 unsigned BitsToDescribe = 0;
5311 if (
auto VarSize = Variable->getSizeInBits())
5312 BitsToDescribe = *VarSize;
5314 BitsToDescribe = Fragment->SizeInBits;
5315 for (
auto RegAndSize : RFV.getRegsAndSizes()) {
5316 unsigned RegisterSize = RegAndSize.second;
5318 if (Offset >= BitsToDescribe)
5320 unsigned FragmentSize = (Offset + RegisterSize > BitsToDescribe)
5321 ? BitsToDescribe - Offset
5324 Expression, Offset, FragmentSize);
5328 false, dl, SDNodeOrder);
5330 Offset += RegisterSize;
5350 DanglingDebugInfoMap[V].emplace_back(&DI, dl, SDNodeOrder);
5354 LLVM_DEBUG(
dbgs() <<
"Dropping debug location info for:\n " << DI <<
"\n");
5359 case Intrinsic::eh_typeid_for: {
5368 case Intrinsic::eh_return_i32:
5369 case Intrinsic::eh_return_i64:
5377 case Intrinsic::eh_unwind_init:
5380 case Intrinsic::eh_dwarf_cfa:
5385 case Intrinsic::eh_sjlj_callsite: {
5388 assert(CI &&
"Non-constant call site value in eh.sjlj.callsite!");
5394 case Intrinsic::eh_sjlj_functioncontext: {
5399 int FI = FuncInfo.StaticAllocaMap[FnCtx];
5403 case Intrinsic::eh_sjlj_setjmp: {
5409 setValue(&I, Op.getValue(0));
5413 case Intrinsic::eh_sjlj_longjmp:
5417 case Intrinsic::eh_sjlj_setup_dispatch:
5421 case Intrinsic::masked_gather:
5422 visitMaskedGather(I);
5424 case Intrinsic::masked_load:
5427 case Intrinsic::masked_scatter:
5428 visitMaskedScatter(I);
5430 case Intrinsic::masked_store:
5431 visitMaskedStore(I);
5433 case Intrinsic::masked_expandload:
5434 visitMaskedLoad(I,
true );
5436 case Intrinsic::masked_compressstore:
5437 visitMaskedStore(I,
true );
5439 case Intrinsic::x86_mmx_pslli_w:
5440 case Intrinsic::x86_mmx_pslli_d:
5441 case Intrinsic::x86_mmx_pslli_q:
5442 case Intrinsic::x86_mmx_psrli_w:
5443 case Intrinsic::x86_mmx_psrli_d:
5444 case Intrinsic::x86_mmx_psrli_q:
5445 case Intrinsic::x86_mmx_psrai_w:
5446 case Intrinsic::x86_mmx_psrai_d: {
5448 if (isa<ConstantSDNode>(ShAmt)) {
5449 visitTargetIntrinsic(I, Intrinsic);
5452 unsigned NewIntrinsic = 0;
5454 switch (Intrinsic) {
5455 case Intrinsic::x86_mmx_pslli_w:
5456 NewIntrinsic = Intrinsic::x86_mmx_psll_w;
5458 case Intrinsic::x86_mmx_pslli_d:
5459 NewIntrinsic = Intrinsic::x86_mmx_psll_d;
5461 case Intrinsic::x86_mmx_pslli_q:
5462 NewIntrinsic = Intrinsic::x86_mmx_psll_q;
5464 case Intrinsic::x86_mmx_psrli_w:
5465 NewIntrinsic = Intrinsic::x86_mmx_psrl_w;
5467 case Intrinsic::x86_mmx_psrli_d:
5468 NewIntrinsic = Intrinsic::x86_mmx_psrl_d;
5470 case Intrinsic::x86_mmx_psrli_q:
5471 NewIntrinsic = Intrinsic::x86_mmx_psrl_q;
5473 case Intrinsic::x86_mmx_psrai_w:
5474 NewIntrinsic = Intrinsic::x86_mmx_psra_w;
5476 case Intrinsic::x86_mmx_psrai_d:
5477 NewIntrinsic = Intrinsic::x86_mmx_psra_d;
5498 case Intrinsic::powi:
5502 case Intrinsic::log:
5508 case Intrinsic::log10:
5511 case Intrinsic::exp:
5514 case Intrinsic::exp2:
5517 case Intrinsic::pow:
5521 case Intrinsic::sqrt:
5522 case Intrinsic::fabs:
5523 case Intrinsic::sin:
5524 case Intrinsic::cos:
5525 case Intrinsic::floor:
5526 case Intrinsic::ceil:
5527 case Intrinsic::trunc:
5528 case Intrinsic::rint:
5529 case Intrinsic::nearbyint:
5531 case Intrinsic::canonicalize: {
5533 switch (Intrinsic) {
5535 case Intrinsic::sqrt: Opcode =
ISD::FSQRT;
break;
5536 case Intrinsic::fabs: Opcode =
ISD::FABS;
break;
5537 case Intrinsic::sin: Opcode =
ISD::FSIN;
break;
5538 case Intrinsic::cos: Opcode =
ISD::FCOS;
break;
5539 case Intrinsic::floor: Opcode =
ISD::FFLOOR;
break;
5540 case Intrinsic::ceil: Opcode =
ISD::FCEIL;
break;
5541 case Intrinsic::trunc: Opcode =
ISD::FTRUNC;
break;
5542 case Intrinsic::rint: Opcode =
ISD::FRINT;
break;
5548 setValue(&I, DAG.
getNode(Opcode, sdl,
5559 setValue(&I, DAG.
getNode(Opc, sdl, VT,
5570 setValue(&I, DAG.
getNode(Opc, sdl, VT,
5575 case Intrinsic::copysign:
5581 case Intrinsic::fma:
5588 case Intrinsic::experimental_constrained_fadd:
5589 case Intrinsic::experimental_constrained_fsub:
5590 case Intrinsic::experimental_constrained_fmul:
5591 case Intrinsic::experimental_constrained_fdiv:
5592 case Intrinsic::experimental_constrained_frem:
5593 case Intrinsic::experimental_constrained_fma:
5594 case Intrinsic::experimental_constrained_sqrt:
5595 case Intrinsic::experimental_constrained_pow:
5596 case Intrinsic::experimental_constrained_powi:
5597 case Intrinsic::experimental_constrained_sin:
5598 case Intrinsic::experimental_constrained_cos:
5599 case Intrinsic::experimental_constrained_exp:
5600 case Intrinsic::experimental_constrained_exp2:
5601 case Intrinsic::experimental_constrained_log:
5602 case Intrinsic::experimental_constrained_log10:
5603 case Intrinsic::experimental_constrained_log2:
5604 case Intrinsic::experimental_constrained_rint:
5605 case Intrinsic::experimental_constrained_nearbyint:
5606 visitConstrainedFPIntrinsic(cast<ConstrainedFPIntrinsic>(I));
5608 case Intrinsic::fmuladd: {
5631 case Intrinsic::convert_to_fp16:
5638 case Intrinsic::convert_from_fp16:
5644 case Intrinsic::pcmarker: {
5649 case Intrinsic::readcyclecounter: {
5657 case Intrinsic::bitreverse:
5662 case Intrinsic::bswap:
5667 case Intrinsic::cttz: {
5675 case Intrinsic::ctlz: {
5683 case Intrinsic::ctpop: {
5689 case Intrinsic::fshl:
5690 case Intrinsic::fshr: {
5691 bool IsFSHL = Intrinsic == Intrinsic::fshl;
5704 setValue(&I, DAG.
getNode(RotateOpcode, sdl, VT, X, Z));
5730 Res = DAG.
getSelect(sdl, VT, IsZeroShift, IsFSHL ? X : Y, Res);
5735 case Intrinsic::stacksave: {
5744 case Intrinsic::stackrestore:
5748 case Intrinsic::get_dynamic_area_offset: {
5763 case Intrinsic::stackguard: {
5772 unsigned Align = DL->getPrefTypeAlignment(Global->
getType());
5773 Res = DAG.
getLoad(PtrTy, sdl, Chain, getValue(Global),
5783 case Intrinsic::stackprotector: {
5788 SDValue Src, Chain = getRoot();
5797 int FI = FuncInfo.StaticAllocaMap[Slot];
5810 case Intrinsic::objectsize: {
5814 assert(CI &&
"Non-constant type in __builtin_object_size?");
5827 case Intrinsic::annotation:
5828 case Intrinsic::ptr_annotation:
5829 case Intrinsic::launder_invariant_group:
5830 case Intrinsic::strip_invariant_group:
5834 case Intrinsic::assume:
5835 case Intrinsic::var_annotation:
5836 case Intrinsic::sideeffect:
5840 case Intrinsic::codeview_annotation: {
5852 case Intrinsic::init_trampoline: {
5868 case Intrinsic::adjust_trampoline:
5873 case Intrinsic::gcroot: {
5875 "only valid in functions with gc specified, enforced by Verifier");
5876 assert(GFI &&
"implied by previous");
5881 GFI->addStackRoot(FI->getIndex(), TypeMap);
5884 case Intrinsic::gcread:
5885 case Intrinsic::gcwrite:
5887 case Intrinsic::flt_rounds:
5891 case Intrinsic::expect:
5896 case Intrinsic::debugtrap:
5897 case Intrinsic::trap: {
5902 if (TrapFuncName.
empty()) {
5922 case Intrinsic::uadd_with_overflow:
5923 case Intrinsic::sadd_with_overflow:
5924 case Intrinsic::usub_with_overflow:
5925 case Intrinsic::ssub_with_overflow:
5926 case Intrinsic::umul_with_overflow:
5927 case Intrinsic::smul_with_overflow: {
5929 switch (Intrinsic) {
5931 case Intrinsic::uadd_with_overflow: Op =
ISD::UADDO;
break;
5932 case Intrinsic::sadd_with_overflow: Op =
ISD::SADDO;
break;
5933 case Intrinsic::usub_with_overflow: Op =
ISD::USUBO;
break;
5934 case Intrinsic::ssub_with_overflow: Op =
ISD::SSUBO;
break;
5935 case Intrinsic::umul_with_overflow: Op =
ISD::UMULO;
break;
5936 case Intrinsic::smul_with_overflow: Op =
ISD::SMULO;
break;
5942 setValue(&I, DAG.
getNode(Op, sdl, VTs, Op1, Op2));
5947 unsigned rw = cast<ConstantInt>(I.
getArgOperand(1))->getZExtValue();
5963 PendingLoads.push_back(Result);
5968 case Intrinsic::lifetime_start:
5969 case Intrinsic::lifetime_end: {
5970 bool IsStart = (Intrinsic == Intrinsic::lifetime_start);
5979 E = Allocas.
end(); Object !=
E; ++Object) {
5980 AllocaInst *LifetimeObject = dyn_cast_or_null<AllocaInst>(*Object);
5983 if (!LifetimeObject)
5988 auto SI = FuncInfo.StaticAllocaMap.find(LifetimeObject);
5989 if (
SI == FuncInfo.StaticAllocaMap.end())
5992 int FI =
SI->second;
6005 case Intrinsic::invariant_start:
6009 case Intrinsic::invariant_end:
6012 case Intrinsic::clear_cache:
6014 case Intrinsic::donothing:
6017 case Intrinsic::experimental_stackmap:
6020 case Intrinsic::experimental_patchpoint_void:
6021 case Intrinsic::experimental_patchpoint_i64:
6022 visitPatchpoint(&I);
6024 case Intrinsic::experimental_gc_statepoint:
6027 case Intrinsic::experimental_gc_result:
6028 visitGCResult(cast<GCResultInst>(I));
6030 case Intrinsic::experimental_gc_relocate:
6031 visitGCRelocate(cast<GCRelocateInst>(I));
6033 case Intrinsic::instrprof_increment:
6035 case Intrinsic::instrprof_value_profile:
6037 case Intrinsic::localescape: {
6045 if (isa<ConstantPointerNull>(Arg))
6048 assert(FuncInfo.StaticAllocaMap.count(Slot) &&
6049 "can only escape static allocas");
6050 int FI = FuncInfo.StaticAllocaMap[Slot];
6054 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, dl,
6055 TII->
get(TargetOpcode::LOCAL_ESCAPE))
6056 .addSym(FrameAllocSym)
6063 case Intrinsic::localrecover: {
6092 case Intrinsic::eh_exceptionpointer:
6093 case Intrinsic::eh_exceptioncode: {
6098 unsigned VReg = FuncInfo.getCatchPadExceptionPointerVReg(CPI, PtrRC);
6101 if (Intrinsic == Intrinsic::eh_exceptioncode)
6106 case Intrinsic::xray_customevent: {
6114 SDLoc DL = getCurSDLoc();
6134 setValue(&I, patchableNode);
6137 case Intrinsic::xray_typedevent: {
6145 SDLoc DL = getCurSDLoc();
6166 TargetOpcode::PATCHABLE_TYPED_EVENT_CALL, DL, NodeTys, Ops);
6169 setValue(&I, patchableNode);
6172 case Intrinsic::experimental_deoptimize:
6173 LowerDeoptimizeCall(&I);
6176 case Intrinsic::experimental_vector_reduce_fadd:
6177 case Intrinsic::experimental_vector_reduce_fmul:
6178 case Intrinsic::experimental_vector_reduce_add:
6179 case Intrinsic::experimental_vector_reduce_mul:
6180 case Intrinsic::experimental_vector_reduce_and:
6181 case Intrinsic::experimental_vector_reduce_or:
6182 case Intrinsic::experimental_vector_reduce_xor:
6183 case Intrinsic::experimental_vector_reduce_smax:
6184 case Intrinsic::experimental_vector_reduce_smin:
6185 case Intrinsic::experimental_vector_reduce_umax:
6186 case Intrinsic::experimental_vector_reduce_umin:
6187 case Intrinsic::experimental_vector_reduce_fmax:
6188 case Intrinsic::experimental_vector_reduce_fmin:
6189 visitVectorReduce(I, Intrinsic);
6192 case Intrinsic::icall_branch_funnel: {
6202 "llvm.icall.branch.funnel operand must be a GlobalValue");
6205 struct BranchFunnelTarget {
6214 if (ElemBase !=
Base)
6216 "to the same GlobalValue");
6222 "llvm.icall.branch.funnel operand must be a GlobalValue");
6224 GA->getGlobal(), getCurSDLoc(),
6228 [](
const BranchFunnelTarget &
T1,
const BranchFunnelTarget &T2) {
6229 return T1.Offset < T2.Offset;
6232 for (
auto &
T : Targets) {
6246 case Intrinsic::wasm_landingpad_index: {
6254 void SelectionDAGBuilder::visitConstrainedFPIntrinsic(
6256 SDLoc sdl = getCurSDLoc();
6260 case Intrinsic::experimental_constrained_fadd:
6263 case Intrinsic::experimental_constrained_fsub:
6266 case Intrinsic::experimental_constrained_fmul:
6269 case Intrinsic::experimental_constrained_fdiv:
6272 case Intrinsic::experimental_constrained_frem:
6275 case Intrinsic::experimental_constrained_fma:
6278 case Intrinsic::experimental_constrained_sqrt:
6281 case Intrinsic::experimental_constrained_pow:
6284 case Intrinsic::experimental_constrained_powi:
6287 case Intrinsic::experimental_constrained_sin:
6290 case Intrinsic::experimental_constrained_cos:
6293 case Intrinsic::experimental_constrained_exp:
6296 case Intrinsic::experimental_constrained_exp2:
6299 case Intrinsic::experimental_constrained_log:
6302 case Intrinsic::experimental_constrained_log10:
6305 case Intrinsic::experimental_constrained_log2:
6308 case Intrinsic::experimental_constrained_rint:
6311 case Intrinsic::experimental_constrained_nearbyint:
6324 Result = DAG.
getNode(Opcode, sdl, VTs,
6325 { Chain, getValue(FPI.getArgOperand(0)) });
6327 Result = DAG.
getNode(Opcode, sdl, VTs,
6328 { Chain, getValue(FPI.getArgOperand(0)),
6329 getValue(FPI.getArgOperand(1)),
6330 getValue(FPI.getArgOperand(2)) });
6332 Result = DAG.
getNode(Opcode, sdl, VTs,
6340 setValue(&FPI, FPResult);
6343 std::pair<SDValue, SDValue>
6358 if (CallSiteIndex) {
6360 LPadToCallSiteMap[FuncInfo.MBBMap[EHPadBB]].push_back(CallSiteIndex);
6377 "Non-null chain expected with non-tail call!");
6378 assert((Result.second.getNode() || !Result.first.getNode()) &&
6379 "Null value expected with tail call!");
6381 if (!Result.second.getNode()) {
6388 PendingExports.clear();
6407 BeginLabel, EndLabel);
6409 MF.
addInvoke(FuncInfo.MBBMap[EHPadBB], BeginLabel, EndLabel);
6426 const Value *SwiftErrorVal =
nullptr;
6434 Caller->getAttributes().hasAttrSomewhere(Attribute::SwiftError))
6440 const Value *V = *i;
6446 SDValue ArgNode = getValue(V);
6457 .getOrCreateSwiftErrorVRegUseAt(
6463 Args.push_back(Entry);
6467 if (Entry.
IsSRet && isa<Instruction>(V))
6484 .
setCallee(RetTy, FTy, Callee, std::move(Args), CS)
6487 std::pair<SDValue, SDValue>
Result = lowerInvokable(CLI, EHPadBB);
6489 if (Result.first.getNode()) {
6491 Result.first = lowerRangeToAssertZExt(DAG, *Inst, Result.first);
6492 setValue(Inst, Result.first);
6501 unsigned VReg;
bool CreatedVReg;
6502 std::tie(VReg, CreatedVReg) =
6507 FuncInfo.setCurrentSwiftErrorVReg(FuncInfo.MBB, SwiftErrorVal, VReg);
6516 if (
const Constant *LoadInput = dyn_cast<Constant>(PtrVal)) {
6527 const_cast<Constant *>(LoadInput), LoadTy, *Builder.
DL))
6534 bool ConstantMemory =
false;
6539 ConstantMemory =
true;
6550 if (!ConstantMemory)
6557 void SelectionDAGBuilder::processIntegerCallValue(
const Instruction &I,
6566 setValue(&I, Value);
6574 bool SelectionDAGBuilder::visitMemCmpCall(
const CallInst &I) {
6581 setValue(&I, DAG.
getConstant(0, getCurSDLoc(), CallVT));
6587 DAG, getCurSDLoc(), DAG.
getRoot(), getValue(LHS), getValue(RHS),
6589 if (Res.first.getNode()) {
6590 processIntegerCallValue(I, Res.first,
true);
6591 PendingLoads.push_back(Res.second);
6604 auto hasFastLoadsAndCompare = [&](
unsigned NumBits) {
6612 unsigned SrcAS = RHS->getType()->getPointerAddressSpace();
6627 switch (NumBitsToCompare) {
6639 LoadVT = hasFastLoadsAndCompare(NumBitsToCompare);
6657 processIntegerCallValue(I, Cmp,
false);
6666 bool SelectionDAGBuilder::visitMemChrCall(
const CallInst &I) {
6672 std::pair<SDValue, SDValue> Res =
6674 getValue(Src), getValue(Char), getValue(Length),
6676 if (Res.first.getNode()) {
6677 setValue(&I, Res.first);
6678 PendingLoads.push_back(Res.second);
6690 bool SelectionDAGBuilder::visitMemPCpyCall(
const CallInst &I) {
6697 unsigned Align = std::min(DstAlign, SrcAlign);
6702 SDLoc sdl = getCurSDLoc();
6712 "** memcpy should not be lowered as TailCall in mempcpy context **");
6721 setValue(&I, DstPlusSize);
6730 bool SelectionDAGBuilder::visitStrCpyCall(
const CallInst &I,
bool isStpcpy) {
6734 std::pair<SDValue, SDValue> Res =
6736 getValue(Arg0), getValue(Arg1),
6739 if (Res.first.getNode()) {
6740 setValue(&I, Res.first);
6753 bool SelectionDAGBuilder::visitStrCmpCall(
const CallInst &I) {
6757 std::pair<SDValue, SDValue> Res =
6759 getValue(Arg0), getValue(Arg1),
6762 if (Res.first.getNode()) {
6763 processIntegerCallValue(I, Res.first,
true);
6764 PendingLoads.push_back(Res.second);
6776 bool SelectionDAGBuilder::visitStrLenCall(
const CallInst &I) {
6780 std::pair<SDValue, SDValue> Res =
6783 if (Res.first.getNode()) {
6784 processIntegerCallValue(I, Res.first,
false);
6785 PendingLoads.push_back(Res.second);
6797 bool SelectionDAGBuilder::visitStrNLenCall(
const CallInst &I) {
6801 std::pair<SDValue, SDValue> Res =
6803 getValue(Arg0), getValue(Arg1),
6805 if (Res.first.getNode()) {
6806 processIntegerCallValue(I, Res.first,
false);
6807 PendingLoads.push_back(Res.second);
6819 bool SelectionDAGBuilder::visitUnaryFloatCall(
const CallInst &I,
6835 bool SelectionDAGBuilder::visitBinaryFloatCall(
const CallInst &I,
6844 setValue(&I, DAG.
getNode(Opcode, getCurSDLoc(), VT, Tmp0, Tmp1));
6848 void SelectionDAGBuilder::visitCall(
const CallInst &I) {
6858 const char *RenameFn =
nullptr;
6860 if (
F->isDeclaration()) {
6862 unsigned IID =
F->getIntrinsicID();
6865 IID = II->getIntrinsicID(
F);
6868 RenameFn = visitIntrinsicCall(I, IID);
6879 F->hasName() && LibInfo->getLibFunc(*
F, Func) &&
6880 LibInfo->hasOptimizedCodeGen(Func)) {
6883 case LibFunc_copysign:
6884 case LibFunc_copysignf:
6885 case LibFunc_copysignl:
6929 case LibFunc_sqrt_finite:
6930 case LibFunc_sqrtf_finite:
6931 case LibFunc_sqrtl_finite:
6936 case LibFunc_floorf:
6937 case LibFunc_floorl:
6941 case LibFunc_nearbyint:
6942 case LibFunc_nearbyintf:
6943 case LibFunc_nearbyintl:
6960 case LibFunc_roundf:
6961 case LibFunc_roundl:
6966 case LibFunc_truncf:
6967 case LibFunc_truncl:
6983 case LibFunc_memcmp:
6984 if (visitMemCmpCall(I))
6987 case LibFunc_mempcpy:
6988 if (visitMemPCpyCall(I))
6991 case LibFunc_memchr:
6992 if (visitMemChrCall(I))
6995 case LibFunc_strcpy:
6996 if (visitStrCpyCall(I,
false))
6999 case LibFunc_stpcpy:
7000 if (visitStrCpyCall(I,
true))
7003 case LibFunc_strcmp:
7004 if (visitStrCmpCall(I))
7007 case LibFunc_strlen:
7008 if (visitStrLenCall(I))
7011 case LibFunc_strnlen:
7012 if (visitStrNLenCall(I))
7030 {LLVMContext::OB_deopt, LLVMContext::OB_funclet}) &&
7031 "Cannot lower calls with arbitrary operand bundles!");
7034 LowerCallSiteWithDeoptBundle(&I, Callee,
nullptr);
7067 for (
const auto &Code : Codes)
7081 if (isa<BasicBlock>(CallOperandVal))
7084 llvm::Type *OpTy = CallOperandVal->getType();
7097 if (
StructType *STy = dyn_cast<StructType>(OpTy))
7098 if (STy->getNumElements() == 1)
7099 OpTy = STy->getElementType(0);
7130 SDISelAsmOperandInfo &MatchingOpInfo,
7132 if (OpInfo.ConstraintVT == MatchingOpInfo.ConstraintVT)
7138 std::pair<unsigned, const TargetRegisterClass *> MatchRC =
7140 OpInfo.ConstraintVT);
7141 std::pair<unsigned, const TargetRegisterClass *> InputRC =
7142 TLI.getRegForInlineAsmConstraint(TRI, MatchingOpInfo.ConstraintCode,
7143 MatchingOpInfo.ConstraintVT);
7144 if ((OpInfo.ConstraintVT.isInteger() !=
7145 MatchingOpInfo.ConstraintVT.isInteger()) ||
7146 (MatchRC.second != InputRC.second)) {
7149 " with a matching output constraint of" 7150 " incompatible type!");
7152 MatchingOpInfo.ConstraintVT = OpInfo.ConstraintVT;
7159 SDISelAsmOperandInfo &OpInfo,
7172 const Value *OpVal = OpInfo.CallOperandVal;
7173 if (isa<ConstantFP>(OpVal) || isa<ConstantInt>(OpVal) ||
7174 isa<ConstantVector>(OpVal) || isa<ConstantDataVector>(OpVal)) {
7183 uint64_t TySize = DL.getTypeAllocSize(Ty);
7184 unsigned Align = DL.getPrefTypeAlignment(Ty);
7188 Chain = DAG.
getStore(Chain, Location, OpInfo.CallOperand, StackSlot,
7190 OpInfo.CallOperand = StackSlot;
7204 const SDLoc &DL, SDISelAsmOperandInfo &OpInfo,
7205 SDISelAsmOperandInfo &RefOpInfo) {
7214 std::pair<unsigned, const TargetRegisterClass *> PhysReg =
7216 RefOpInfo.ConstraintVT);
7218 unsigned NumRegs = 1;
7235 if (RegVT.
getSizeInBits() == OpInfo.ConstraintVT.getSizeInBits()) {
7240 OpInfo.CallOperand =
7242 OpInfo.ConstraintVT = RegVT;
7246 }
else if (RegVT.
isInteger() && OpInfo.ConstraintVT.isFloatingPoint()) {
7249 OpInfo.CallOperand =
7251 OpInfo.ConstraintVT = RegVT;
7260 if (OpInfo.isMatchingInputConstraint())
7264 EVT ValueVT = OpInfo.ConstraintVT;
7268 if (
unsigned AssignedReg = PhysReg.first) {
7284 for (; *I != AssignedReg; ++
I)
7285 assert(I != RC->
end() &&
"Didn't find reg!");
7289 for (; NumRegs; --NumRegs, ++
I) {
7290 assert(I != RC->
end() &&
"Ran out of registers to allocate!");
7295 OpInfo.AssignedRegs =
RegsForValue(Regs, RegVT, ValueVT);
7308 for (; NumRegs; --NumRegs)
7311 OpInfo.AssignedRegs =
RegsForValue(Regs, RegVT, ValueVT);
7320 const std::vector<SDValue> &AsmNodeOperands) {
7323 for (; OperandNo; --OperandNo) {
7326 cast<ConstantSDNode>(AsmNodeOperands[CurOp])->getZExtValue();
7330 "Skipped past definitions?");
7342 for (
unsigned i = 0, e = NumRegs; i != e; ++i) {
7384 unsigned get()
const {
return Flags; }
7394 SDISelAsmOperandInfoVector ConstraintOperands;
7400 bool hasMemory =
false;
7403 ExtraFlags ExtraInfo(CS);
7407 for (
unsigned i = 0, e = TargetConstraints.size(); i != e; ++i) {
7408 ConstraintOperands.push_back(SDISelAsmOperandInfo(TargetConstraints[i]));
7409 SDISelAsmOperandInfo &OpInfo = ConstraintOperands.back();
7416 OpInfo.CallOperandVal =
const_cast<Value *
>(CS.
getArgument(ArgNo++));
7420 if (
const BasicBlock *BB = dyn_cast<BasicBlock>(OpInfo.CallOperandVal)) {
7421 OpInfo.CallOperand = DAG.
getBasicBlock(FuncInfo.MBBMap[BB]);
7423 OpInfo.CallOperand = getValue(OpInfo.CallOperandVal);
7438 STy->getElementType(ResNo));
7440 assert(ResNo == 0 &&
"Asm only has one result!");
7446 OpInfo.ConstraintVT = OpVT;
7449 hasMemory = OpInfo.hasMemory(TLI);
7453 auto TargetConstraint = TargetConstraints[i];
7458 ExtraInfo.update(TargetConstraint);
7472 for (
unsigned i = 0, e = ConstraintOperands.size(); i != e; ++i) {
7473 SDISelAsmOperandInfo &OpInfo = ConstraintOperands[i];
7479 if (OpInfo.hasMatchingInput()) {
7480 SDISelAsmOperandInfo &Input = ConstraintOperands[OpInfo.MatchingInput];
7494 !OpInfo.isIndirect) {
7495 assert((OpInfo.isMultipleAlternative ||
7497 "Can only indirectify direct input operands!");
7503 OpInfo.CallOperandVal =
nullptr;
7506 OpInfo.isIndirect =
true;
7511 SDISelAsmOperandInfo &RefOpInfo =
7512 OpInfo.isMatchingInputConstraint()
7513 ? ConstraintOperands[OpInfo.getMatchedOperand()]
7514 : ConstraintOperands[i];
7521 for (
unsigned i = 0, e = ConstraintOperands.size(); i != e; ++i) {
7522 SDISelAsmOperandInfo &OpInfo = ConstraintOperands[i];
7523 SDISelAsmOperandInfo &RefOpInfo =
7524 OpInfo.isMatchingInputConstraint()
7525 ? ConstraintOperands[OpInfo.getMatchedOperand()]
7526 : ConstraintOperands[i];
7535 std::vector<SDValue> AsmNodeOperands;
7536 AsmNodeOperands.push_back(
SDValue());
7544 AsmNodeOperands.push_back(DAG.
getMDNode(SrcLoc));
7556 std::vector<std::pair<RegsForValue, Value *>> IndirectStoresToEmit;
7558 for (
unsigned i = 0, e = ConstraintOperands.size(); i != e; ++i) {
7559 SDISelAsmOperandInfo &OpInfo = ConstraintOperands[i];
7561 switch (OpInfo.Type) {
7566 assert(OpInfo.isIndirect &&
"Memory output must be indirect operand");
7568 unsigned ConstraintID =
7571 "Failed to convert memory constraint code to constraint id.");
7578 AsmNodeOperands.push_back(OpInfo.CallOperand);
7586 if (OpInfo.AssignedRegs.Regs.empty()) {
7588 CS,
"couldn't allocate output register for constraint '" +
7589 Twine(OpInfo.ConstraintCode) +
"'");
7595 if (OpInfo.isIndirect) {
7596 IndirectStoresToEmit.push_back(std::make_pair(OpInfo.AssignedRegs,
7597 OpInfo.CallOperandVal));
7602 RetValRegs.
append(OpInfo.AssignedRegs);
7608 .AddInlineAsmOperands(OpInfo.isEarlyClobber
7611 false, 0, getCurSDLoc(), DAG, AsmNodeOperands);
7615 SDValue InOperandVal = OpInfo.CallOperand;
7617 if (OpInfo.isMatchingInputConstraint()) {
7623 cast<ConstantSDNode>(AsmNodeOperands[CurOp])->getZExtValue();
7627 if (OpInfo.isIndirect) {
7629 emitInlineAsmError(CS,
"inline asm not supported yet:" 7630 " don't know how to handle tied " 7631 "indirect register inputs");
7635 MVT RegVT = AsmNodeOperands[CurOp+1].getSimpleValueType();
7641 emitInlineAsmError(CS,
"inline asm error: This value type register " 7642 "class is not natively supported!");
7648 SDLoc dl = getCurSDLoc();
7650 MatchedRegs.getCopyToRegs(InOperandVal, DAG, dl, Chain, &Flag,
7653 true, OpInfo.getMatchedOperand(), dl,
7654 DAG, AsmNodeOperands);
7660 "Unexpected number of operands");
7665 OpInfo.getMatchedOperand());
7668 AsmNodeOperands.push_back(AsmNodeOperands[CurOp+1]);
7678 std::vector<SDValue> Ops;
7682 emitInlineAsmError(CS,
"invalid operand for inline asm constraint '" +
7683 Twine(OpInfo.ConstraintCode) +
"'");
7688 unsigned ResOpType =
7692 AsmNodeOperands.insert(AsmNodeOperands.end(), Ops.begin(), Ops.end());
7697 assert(OpInfo.isIndirect &&
"Operand must be indirect to be a mem!");
7700 "Memory operands expect pointer values");
7702 unsigned ConstraintID =
7705 "Failed to convert memory constraint code to constraint id.");
7713 AsmNodeOperands.push_back(InOperandVal);
7719 "Unknown constraint type!");
7722 if (OpInfo.isIndirect) {
7724 CS,
"Don't know how to handle indirect register inputs yet " 7725 "for constraint '" +
7726 Twine(OpInfo.ConstraintCode) +
"'");
7731 if (OpInfo.AssignedRegs.Regs.empty()) {
7732 emitInlineAsmError(CS,
"couldn't allocate input reg for constraint '" +
7733 Twine(OpInfo.ConstraintCode) +
"'");
7737 SDLoc dl = getCurSDLoc();
7739 OpInfo.AssignedRegs.getCopyToRegs(InOperandVal, DAG, dl,
7743 dl, DAG, AsmNodeOperands);
7749 if (!OpInfo.AssignedRegs.Regs.empty())
7751 false, 0, getCurSDLoc(), DAG,
7759 if (Flag.
getNode()) AsmNodeOperands.push_back(Flag);
7777 ResultValues[0] = Val;
7782 "Mismatch in number of output operands in asm result");
7783 ResultTypes = CSResultType->
subtypes();
7785 ResultValues.
resize(numRet);
7790 for (
unsigned i = 0; i < numRet; i++) {
7792 SDValue Val = ResultValues[i];
7793 assert(ResultTypes[i]->isSized() &&
"Unexpected unsized type");
7816 ResultVTs[i] = ResultVT;
7817 ResultValues[i] = Val;
7821 DAG.
getVTList(ResultVTs), ResultValues);
7824 if (!IA->
hasSideEffects() && !hasMemory && IndirectStoresToEmit.empty())
7828 std::vector<std::pair<SDValue, const Value *>> StoresToEmit;
7832 for (
unsigned i = 0, e = IndirectStoresToEmit.size(); i != e; ++i) {
7834 const Value *
Ptr = IndirectStoresToEmit[i].second;
7837 StoresToEmit.push_back(std::make_pair(OutVal, Ptr));
7842 for (
unsigned i = 0, e = StoresToEmit.size(); i != e; ++i) {
7844 getValue(StoresToEmit[i].
second),
7849 if (!OutChains.
empty())
7856 const Twine &Message) {
7865 if (ValueVTs.
empty())
7869 for (
unsigned i = 0, e = ValueVTs.
size(); i != e; ++i)
7875 void SelectionDAGBuilder::visitVAStart(
const CallInst &I) {
7882 void SelectionDAGBuilder::visitVAArg(
const VAArgInst &I) {
7886 getCurSDLoc(), getRoot(), getValue(I.
getOperand(0)),
7893 void SelectionDAGBuilder::visitVAEnd(
const CallInst &I) {
7900 void SelectionDAGBuilder::visitVACopy(
const CallInst &I) {
7929 SDLoc SL = getCurSDLoc();
7940 for (
unsigned I = 1; I != NumVals; ++
I)
7955 bool IsPatchPoint) {
7957 Args.reserve(NumArgs);
7961 for (
unsigned ArgI = ArgIdx, ArgE = ArgIdx + NumArgs;
7962 ArgI != ArgE; ++ArgI) {
7963 const Value *V = CS->getOperand(ArgI);
7968 Entry.
Node = getValue(V);
7970 Entry.setAttributes(&CS, ArgI);
7971 Args.push_back(Entry);
7977 .setDiscardResult(CS->use_empty())
7978 .setIsPatchPoint(IsPatchPoint);
8001 for (
unsigned i = StartIdx, e = CS.
arg_size(); i != e; ++i) {
8018 void SelectionDAGBuilder::visitStackmap(
const CallInst &CI) {
8027 SDLoc DL = getCurSDLoc();
8047 cast<ConstantSDNode>(IDVal)->getZExtValue(), DL,
MVT::i64));
8050 cast<ConstantSDNode>(NBytesVal)->getZExtValue(), DL,
8067 InFlag = Chain.getValue(1);
8077 FuncInfo.MF->getFrameInfo().setHasStackMap();
8093 SDLoc dl = getCurSDLoc();
8097 if (
auto* ConstCallee = dyn_cast<ConstantSDNode>(Callee))
8100 else if (
auto* SymbolicCallee = dyn_cast<GlobalAddressSDNode>(Callee))
8102 SDLoc(SymbolicCallee),
8103 SymbolicCallee->getValueType(0));
8107 unsigned NumArgs = cast<ConstantSDNode>(NArgVal)->getZExtValue();
8113 "Not enough arguments provided to the patchpoint intrinsic");
8116 unsigned NumCallArgs = IsAnyRegCC ? 0 : NumArgs;
8121 populateCallLoweringInfo(CLI, CS, NumMetaOpers, NumCallArgs, Callee, ReturnTy,
8123 std::pair<SDValue, SDValue>
Result = lowerInvokable(CLI, EHPadBB);
8125 SDNode *CallEnd = Result.second.getNode();
8132 "Expected a callseq node.");
8142 cast<ConstantSDNode>(IDVal)->getZExtValue(), dl,
MVT::i64));
8145 cast<ConstantSDNode>(NBytesVal)->getZExtValue(), dl,
8154 unsigned NumCallRegArgs = Call->getNumOperands() - (HasGlue ? 4 : 3);
8155 NumCallRegArgs = IsAnyRegCC ? NumArgs : NumCallRegArgs;
8164 for (
unsigned i = NumMetaOpers, e = NumMetaOpers + NumArgs; i != e; ++i)
8169 Ops.
append(Call->op_begin() + 2, e);
8189 if (IsAnyRegCC && HasDef) {
8194 assert(ValueVTs.
size() == 1 &&
"Expected only one return value type.");
8219 if (IsAnyRegCC && HasDef) {
8228 FuncInfo.MF->getFrameInfo().setHasPatchPoint();
8231 void SelectionDAGBuilder::visitVectorReduce(
const CallInst &I,
8232 unsigned Intrinsic) {
8238 SDLoc dl = getCurSDLoc();
8242 if (isa<FPMathOperator>(I))
8245 switch (Intrinsic) {
8246 case Intrinsic::experimental_vector_reduce_fadd:
8252 case Intrinsic::experimental_vector_reduce_fmul:
8258 case Intrinsic::experimental_vector_reduce_add:
8261 case Intrinsic::experimental_vector_reduce_mul:
8264 case Intrinsic::experimental_vector_reduce_and:
8267 case Intrinsic::experimental_vector_reduce_or:
8270 case Intrinsic::experimental_vector_reduce_xor:
8273 case Intrinsic::experimental_vector_reduce_smax:
8276 case Intrinsic::experimental_vector_reduce_smin:
8279 case Intrinsic::experimental_vector_reduce_umax:
8282 case Intrinsic::experimental_vector_reduce_umin:
8285 case Intrinsic::experimental_vector_reduce_fmax:
8288 case Intrinsic::experimental_vector_reduce_fmin:
8316 std::pair<SDValue, SDValue>
8330 for (
size_t i = 0, e = OldRetTys.
size(); i != e; ++i) {
8331 EVT RetVT = OldRetTys[i];
8332 uint64_t
Offset = OldOffsets[i];
8336 RetTys.
append(NumRegs, RegisterVT);
8337 for (
unsigned j = 0; j != NumRegs; ++j)
8338 Offsets.
push_back(Offset + j * RegisterVTByteSZ);
8345 bool CanLowerReturn =
8350 int DemoteStackIdx = -100;
8351 if (!CanLowerReturn) {
8355 uint64_t TySize = DL.getTypeAllocSize(CLI.
RetTy);
8356 unsigned Align = DL.getPrefTypeAlignment(CLI.
RetTy);
8360 DL.getAllocaAddrSpace());
8362 DemoteStackSlot = CLI.
DAG.
getFrameIndex(DemoteStackIdx, getFrameIndexTy(DL));
8364 Entry.
Node = DemoteStackSlot;
8365 Entry.
Ty = StackSlotPtrType;
8384 for (
unsigned I = 0,
E = RetTys.
size(); I !=
E; ++
I) {
8388 unsigned NumRegs = getNumRegistersForCallingConv(CLI.
RetTy->
getContext(),
8390 for (
unsigned i = 0; i != NumRegs; ++i) {
8392 MyFlags.
VT = RegisterVT;
8401 CLI.
Ins.push_back(MyFlags);
8408 if (supportSwiftError()) {
8409 for (
unsigned i = 0, e = Args.size(); i != e; ++i) {
8410 if (Args[i].IsSwiftError) {
8412 MyFlags.
VT = getPointerTy(DL);
8413 MyFlags.
ArgVT =
EVT(getPointerTy(DL));
8415 CLI.
Ins.push_back(MyFlags);
8423 for (
unsigned i = 0, e = Args.size(); i != e; ++i) {
8427 Type *FinalType = Args[i].Ty;
8428 if (Args[i].IsByVal)
8429 FinalType = cast<PointerType>(Args[i].Ty)->getElementType();
8430 bool NeedsRegBlock = functionArgumentNeedsConsecutiveRegisters(
8432 for (
unsigned Value = 0, NumValues = ValueVTs.
size(); Value != NumValues;
8434 EVT VT = ValueVTs[Value];
8437 Args[i].Node.getResNo() + Value);
8443 unsigned OriginalAlignment = getABIAlignmentForCallingConv(ArgTy, DL);
8449 if (Args[i].IsInReg) {
8453 isa<StructType>(FinalType)) {
8456 Flags.setHvaStart();
8464 if (Args[i].IsSwiftSelf)
8465 Flags.setSwiftSelf();
8466 if (Args[i].IsSwiftError)
8467 Flags.setSwiftError();
8468 if (Args[i].IsByVal)
8470 if (Args[i].IsInAlloca) {
8471 Flags.setInAlloca();
8479 if (Args[i].IsByVal || Args[i].IsInAlloca) {
8482 Flags.setByValSize(DL.getTypeAllocSize(ElementTy));
8485 unsigned FrameAlign;
8486 if (Args[i].Alignment)
8487 FrameAlign = Args[i].Alignment;
8489 FrameAlign = getByValTypeAlignment(ElementTy, DL);
8490 Flags.setByValAlign(FrameAlign);
8495 Flags.setInConsecutiveRegs();
8496 Flags.setOrigAlign(OriginalAlignment);
8500 unsigned NumParts = getNumRegistersForCallingConv(CLI.
RetTy->
getContext(),
8507 else if (Args[i].IsZExt)
8515 "unexpected use of 'returned'");
8528 CLI.
RetZExt == Args[i].IsZExt))
8529 Flags.setReturned();
8535 for (
unsigned j = 0; j != NumParts; ++j) {
8539 i, j*Parts[j].getValueType().getStoreSize());
8540 if (NumParts > 1 && j == 0)
8543 MyFlags.Flags.setOrigAlign(1);
8544 if (j == NumParts - 1)
8545 MyFlags.Flags.setSplitEnd();
8548 CLI.
Outs.push_back(MyFlags);
8549 CLI.
OutVals.push_back(Parts[j]);
8552 if (NeedsRegBlock && Value == NumValues - 1)
8553 CLI.
Outs[CLI.
Outs.size() - 1].Flags.setInConsecutiveRegsLast();
8558 CLI.
Chain = LowerCall(CLI, InVals);
8565 "LowerCall didn't return a valid chain!");
8567 "LowerCall emitted a return value for a tail call!");
8569 "LowerCall didn't emit the correct number of values!");
8581 for (
unsigned i = 0, e = CLI.
Ins.size(); i != e; ++i) {
8582 assert(InVals[i].getNode() &&
"LowerCall emitted a null value!");
8583 assert(
EVT(CLI.
Ins[i].VT) == InVals[i].getValueType() &&
8584 "LowerCall emitted a value with the wrong type!");
8589 if (!CanLowerReturn) {
8596 assert(PVTs.
size() == 1 &&
"Pointers should fit in one register");
8597 EVT PtrVT = PVTs[0];
8599 unsigned NumValues = RetTys.
size();
8600 ReturnValues.resize(NumValues);
8608 for (
unsigned i = 0; i < NumValues; ++i) {
8613 RetTys[i], CLI.
DL, CLI.
Chain, Add,
8615 DemoteStackIdx, Offsets[i]),
8617 ReturnValues[i] = L;
8630 unsigned CurReg = 0;
8631 for (
unsigned I = 0,
E = RetTys.
size(); I !=
E; ++
I) {
8635 unsigned NumRegs = getNumRegistersForCallingConv(CLI.
RetTy->
getContext(),
8639 NumRegs, RegisterVT, VT,
nullptr,
8647 if (ReturnValues.empty())
8653 return std::make_pair(Res, CLI.
Chain);
8672 "Copy from a reg to the same reg!");
8683 ISD::NodeType ExtendType = (FuncInfo.PreferredExtendType.find(V) ==
8684 FuncInfo.PreferredExtendType.end())
8686 : FuncInfo.PreferredExtendType[V];
8687 RFV.getCopyToRegs(Op, DAG, getCurSDLoc(), Chain,
nullptr, V, ExtendType);
8688 PendingExports.push_back(Chain);
8704 if (cast<Instruction>(U)->getParent() != &Entry || isa<SwitchInst>(U))
8712 std::pair<const AllocaInst *, const StoreInst *>>;
8724 enum StaticAllocaInfo {
Unknown, Clobbered, Elidable };
8727 StaticAllocas.
reserve(NumArgs * 2);
8729 auto GetInfoIfStaticAlloca = [&](
const Value *V) -> StaticAllocaInfo * {
8734 if (!AI || !AI->isStaticAlloca() || !FuncInfo->
StaticAllocaMap.count(AI))
8737 return &Iter.first->second;
8753 if (isa<DbgInfoIntrinsic>(I))
8758 if (StaticAllocaInfo *Info = GetInfoIfStaticAlloca(U))
8759 *Info = StaticAllocaInfo::Clobbered;
8765 if (StaticAllocaInfo *Info = GetInfoIfStaticAlloca(
SI->getValueOperand()))
8766 *Info = StaticAllocaInfo::Clobbered;
8769 const Value *Dst =
SI->getPointerOperand()->stripPointerCasts();
8770 StaticAllocaInfo *Info = GetInfoIfStaticAlloca(Dst);
8773 const AllocaInst *AI = cast<AllocaInst>(Dst);
8781 const Value *Val =
SI->getValueOperand()->stripPointerCasts();
8783 if (!
Arg ||
Arg->hasInAllocaAttr() ||
Arg->hasByValAttr() ||
8787 ArgCopyElisionCandidates.
count(
Arg)) {
8788 *Info = StaticAllocaInfo::Clobbered;
8792 LLVM_DEBUG(
dbgs() <<
"Found argument copy elision candidate: " << *AI
8796 *Info = StaticAllocaInfo::Elidable;
8802 if (ArgCopyElisionCandidates.
size() == NumArgs)
8814 SDValue ArgVal,
bool &ArgHasUses) {
8826 auto ArgCopyIter = ArgCopyElisionCandidates.
find(&Arg);
8827 assert(ArgCopyIter != ArgCopyElisionCandidates.
end());
8828 const AllocaInst *AI = ArgCopyIter->second.first;
8829 int FixedIndex = FINode->getIndex();
8831 int OldIndex = AllocaIndex;
8835 dbgs() <<
" argument copy elision failed due to bad fixed stack " 8839 unsigned RequiredAlignment = AI->getAlignment();
8840 if (!RequiredAlignment) {
8842 AI->getAllocatedType());
8845 LLVM_DEBUG(
dbgs() <<
" argument copy elision failed: alignment of alloca " 8846 "greater than stack argument alignment (" 8847 << RequiredAlignment <<
" vs " 8855 dbgs() <<
"Eliding argument copy from " << Arg <<
" to " << *AI <<
'\n' 8856 <<
" Replacing frame index " << OldIndex <<
" with " << FixedIndex
8861 AllocaIndex = FixedIndex;
8862 ArgCopyElisionFrameIndexMap.
insert({OldIndex, FixedIndex});
8867 ElidedArgCopyInstrs.
insert(SI);
8871 for (
const Value *U : Arg.
users()) {
8879 void SelectionDAGISel::LowerArguments(
const Function &
F) {
8881 SDLoc dl = SDB->getCurSDLoc();
8885 if (!FuncInfo->CanLowerReturn) {
8897 MVT RegisterVT = TLI->getRegisterType(*DAG.
getContext(), ValueVTs[0]);
8910 for (
const Argument &
Arg : F.
args()) {
8911 unsigned ArgNo =
Arg.getArgNo();
8915 unsigned PartBase = 0;
8917 if (
Arg.hasAttribute(Attribute::ByVal))
8918 FinalType = cast<PointerType>(FinalType)->getElementType();
8919 bool NeedsRegBlock = TLI->functionArgumentNeedsConsecutiveRegisters(
8921 for (
unsigned Value = 0, NumValues = ValueVTs.
size();
8922 Value != NumValues; ++Value) {
8923 EVT VT = ValueVTs[Value];
8930 unsigned OriginalAlignment =
8931 TLI->getABIAlignmentForCallingConv(ArgTy, DL);
8933 if (
Arg.hasAttribute(Attribute::ZExt))
8935 if (
Arg.hasAttribute(Attribute::SExt))
8937 if (
Arg.hasAttribute(Attribute::InReg)) {
8950 if (
Arg.hasAttribute(Attribute::StructRet))
8952 if (
Arg.hasAttribute(Attribute::SwiftSelf))
8954 if (
Arg.hasAttribute(Attribute::SwiftError))
8956 if (
Arg.hasAttribute(Attribute::ByVal))
8958 if (
Arg.hasAttribute(Attribute::InAlloca)) {
8978 unsigned FrameAlign;
8979 if (
Arg.getParamAlignment())
8980 FrameAlign =
Arg.getParamAlignment();
8982 FrameAlign = TLI->getByValTypeAlignment(ElementTy, DL);
8985 if (
Arg.hasAttribute(Attribute::Nest))
8990 if (ArgCopyElisionCandidates.
count(&
Arg))
8993 MVT RegisterVT = TLI->getRegisterTypeForCallingConv(
8995 unsigned NumRegs = TLI->getNumRegistersForCallingConv(
8997 for (
unsigned i = 0; i != NumRegs; ++i) {
8998 ISD::InputArg MyFlags(Flags, RegisterVT, VT, isArgValueUsed,
9000 if (NumRegs > 1 && i == 0)
9004 MyFlags.Flags.setOrigAlign(1);
9005 if (i == NumRegs - 1)
9006 MyFlags.Flags.setSplitEnd();
9010 if (NeedsRegBlock && Value == NumValues - 1)
9011 Ins[Ins.
size() - 1].Flags.setInConsecutiveRegsLast();
9018 SDValue NewRoot = TLI->LowerFormalArguments(
9023 "LowerFormalArguments didn't return a valid chain!");
9025 "LowerFormalArguments didn't emit the correct number of values!");
9027 for (
unsigned i = 0, e = Ins.
size(); i != e; ++i) {
9028 assert(InVals[i].getNode() &&
9029 "LowerFormalArguments emitted a null value!");
9030 assert(
EVT(Ins[i].VT) == InVals[i].getValueType() &&
9031 "LowerFormalArguments emitted a value with the wrong type!");
9036 DAG.setRoot(NewRoot);
9040 if (!FuncInfo->CanLowerReturn) {
9046 DAG.getDataLayout().getAllocaAddrSpace()),
9048 MVT VT = ValueVTs[0].getSimpleVT();
9049 MVT RegVT = TLI->getRegisterType(*CurDAG->getContext(), VT);
9057 FuncInfo->DemoteRegister = SRetReg;
9059 SDB->DAG.getCopyToReg(NewRoot, SDB->getCurSDLoc(), SRetReg, ArgValue);
9060 DAG.setRoot(NewRoot);
9068 for (
const Argument &
Arg : F.
args()) {
9072 unsigned NumValues = ValueVTs.
size();
9080 if (Ins[i].Flags.isCopyElisionCandidate()) {
9082 ElidedArgCopyInstrs, ArgCopyElisionCandidates,
Arg,
9083 InVals[i], ArgHasUses);
9088 bool isSwiftErrorArg =
9089 TLI->supportSwiftError() &&
9090 Arg.hasAttribute(Attribute::SwiftError);
9091 if (!ArgHasUses && !isSwiftErrorArg) {
9092 SDB->setUnusedArgValue(&
Arg, InVals[i]);
9096 dyn_cast<FrameIndexSDNode>(InVals[i].getNode()))
9097 FuncInfo->setArgumentFrameIndex(&
Arg, FI->getIndex());
9100 for (
unsigned Val = 0; Val != NumValues; ++Val) {
9101 EVT VT = ValueVTs[Val];
9102 MVT PartVT = TLI->getRegisterTypeForCallingConv(*CurDAG->getContext(),
9104 unsigned NumParts = TLI->getNumRegistersForCallingConv(
9110 if (ArgHasUses || isSwiftErrorArg) {
9112 if (
Arg.hasAttribute(Attribute::SExt))
9114 else if (
Arg.hasAttribute(Attribute::ZExt))
9118 PartVT, VT,
nullptr,
9126 if (ArgValues.
empty())
9131 dyn_cast<FrameIndexSDNode>(ArgValues[0].getNode()))
9132 FuncInfo->setArgumentFrameIndex(&
Arg, FI->getIndex());
9135 SDB->getCurSDLoc());
9137 SDB->setValue(&
Arg, Res);
9146 unsigned LowAddressOp = DAG.getDataLayout().isBigEndian() ? 1 : 0;
9150 dyn_cast<FrameIndexSDNode>(LNode->getBasePtr().getNode()))
9151 FuncInfo->setArgumentFrameIndex(&
Arg, FI->getIndex());
9158 FuncInfo->setCurrentSwiftErrorVReg(FuncInfo->MBB,
9159 FuncInfo->SwiftErrorArg, Reg);
9171 FuncInfo->ValueMap[&
Arg] =
Reg;
9176 FuncInfo->InitializeRegForValue(&
Arg);
9177 SDB->CopyToExportRegsIfNeeded(&
Arg);
9181 if (!Chains.
empty()) {
9186 DAG.setRoot(NewRoot);
9188 assert(i == InVals.
size() &&
"Argument register count mismatch!");
9193 if (!DbgDeclareInfo.empty() && !ArgCopyElisionFrameIndexMap.
empty()) {
9195 auto I = ArgCopyElisionFrameIndexMap.
find(
VI.Slot);
9196 if (I != ArgCopyElisionFrameIndexMap.
end())
9197 VI.Slot = I->second;
9202 EmitFunctionEntryCode();
9212 SelectionDAGBuilder::HandlePHINodesInSuccessorBlocks(
const BasicBlock *LLVMBB) {
9221 if (!isa<PHINode>(SuccBB->
begin()))
continue;
9226 if (!SuccsHandled.
insert(SuccMBB).second)
9240 if (PN.getType()->isEmptyTy())
9244 const Value *PHIOp = PN.getIncomingValueForBlock(LLVMBB);
9246 if (
const Constant *
C = dyn_cast<Constant>(PHIOp)) {
9247 unsigned &RegOut = ConstantsOut[
C];
9249 RegOut = FuncInfo.CreateRegs(
C->
getType());
9250 CopyValueToVirtualRegister(
C, RegOut);
9255 FuncInfo.ValueMap.find(PHIOp);
9256 if (I != FuncInfo.ValueMap.
end())
9259 assert(isa<AllocaInst>(PHIOp) &&
9260 FuncInfo.StaticAllocaMap.count(cast<AllocaInst>(PHIOp)) &&
9261 "Didn't codegen value into a register!??");
9262 Reg = FuncInfo.CreateRegs(PHIOp->
getType());
9263 CopyValueToVirtualRegister(PHIOp, Reg);
9272 for (
unsigned vti = 0, vte = ValueVTs.
size(); vti != vte; ++vti) {
9273 EVT VT = ValueVTs[vti];
9275 for (
unsigned i = 0, e = NumRegisters; i != e; ++i)
9276 FuncInfo.PHINodesToUpdate.push_back(
9277 std::make_pair(&*MBBI++,
Reg + i));
9278 Reg += NumRegisters;
9283 ConstantsOut.clear();
9289 SelectionDAGBuilder::StackProtectorDescriptor::
9299 MF->
insert(++BBI, SuccMBB);
9309 if (++I == FuncInfo.MF->end())
9319 void SelectionDAGBuilder::updateDAGForMaybeTailCall(
SDValue MaybeTC) {
9321 if (MaybeTC.
getNode() !=
nullptr)
9322 DAG.setRoot(MaybeTC);
9328 SelectionDAGBuilder::getJumpTableRange(
const CaseClusterVector &Clusters,
9329 unsigned First,
unsigned Last)
const {
9331 const APInt &LowCase = Clusters[First].Low->getValue();
9332 const APInt &HighCase = Clusters[Last].High->getValue();
9339 return (HighCase - LowCase).getLimitedValue((
UINT64_MAX - 1) / 100) + 1;
9342 uint64_t SelectionDAGBuilder::getJumpTableNumCases(
9344 unsigned Last)
const {
9346 assert(TotalCases[Last] >= TotalCases[First]);
9348 TotalCases[Last] - (First == 0 ? 0 : TotalCases[First - 1]);
9352 bool SelectionDAGBuilder::buildJumpTable(
const CaseClusterVector &Clusters,
9353 unsigned First,
unsigned Last,
9356 CaseCluster &JTCluster) {
9360 unsigned NumCmps = 0;
9361 std::vector<MachineBasicBlock*> Table;
9365 for (
unsigned I = First;
I <= Last; ++
I)
9368 for (
unsigned I = First;
I <= Last; ++
I) {
9370 Prob += Clusters[
I].Prob;
9371 const APInt &Low = Clusters[
I].Low->getValue();
9372 const APInt &
High = Clusters[
I].High->getValue();
9373 NumCmps += (Low ==
High) ? 1 : 2;
9376 const APInt &PreviousHigh = Clusters[
I - 1].High->getValue();
9378 uint64_t Gap = (Low - PreviousHigh).getLimitedValue() - 1;
9379 for (uint64_t J = 0; J < Gap; J++)
9380 Table.push_back(DefaultMBB);
9382 uint64_t ClusterSize = (High - Low).getLimitedValue() + 1;
9383 for (uint64_t J = 0; J < ClusterSize; ++J)
9384 Table.push_back(Clusters[
I].MBB);
9385 JTProbs[Clusters[
I].MBB] += Clusters[
I].Prob;
9389 unsigned NumDests = JTProbs.
size();
9391 NumDests, NumCmps, Clusters[First].Low->getValue(),
9392 Clusters[Last].High->getValue(), DAG.getDataLayout())) {
9406 if (Done.
count(Succ))
9408 addSuccessorWithProb(JumpTableMBB, Succ, JTProbs[Succ]);
9414 ->createJumpTableIndex(Table);
9418 JumpTableHeader JTH(Clusters[First].Low->getValue(),
9421 JTCases.emplace_back(std::move(JTH), std::move(JT));
9423 JTCluster = CaseCluster::jumpTable(Clusters[First].Low, Clusters[Last].
High,
9424 JTCases.size() - 1, Prob);
9428 void SelectionDAGBuilder::findJumpTables(CaseClusterVector &Clusters,
9433 assert(!Clusters.empty());
9434 for (CaseCluster &
C : Clusters)
9436 for (
unsigned i = 1, e = Clusters.size(); i < e; ++i)
9437 assert(Clusters[i - 1].
High->getValue().slt(Clusters[i].Low->getValue()));
9444 const int64_t
N = Clusters.size();
9446 const unsigned SmallNumberOfEntries = MinJumpTableEntries / 2;
9448 if (N < 2 || N < MinJumpTableEntries)
9453 for (
unsigned i = 0; i <
N; ++i) {
9454 const APInt &
Hi = Clusters[i].High->getValue();
9455 const APInt &
Lo = Clusters[i].Low->getValue();
9456 TotalCases[i] = (Hi -
Lo).getLimitedValue() + 1;
9458 TotalCases[i] += TotalCases[i - 1];
9462 uint64_t Range = getJumpTableRange(Clusters,0, N - 1);
9463 uint64_t NumCases = getJumpTableNumCases(TotalCases, 0, N - 1);
9465 assert(Range >= NumCases);
9467 CaseCluster JTCluster;
9468 if (buildJumpTable(Clusters, 0, N - 1, SI, DefaultMBB, JTCluster)) {
9469 Clusters[0] = JTCluster;
9496 enum PartitionScores :
unsigned {
9504 MinPartitions[N - 1] = 1;
9505 LastElement[N - 1] = N - 1;
9506 PartitionsScore[N - 1] = PartitionScores::SingleCase;
9509 for (int64_t i = N - 2; i >= 0; i--) {
9512 MinPartitions[i] = MinPartitions[i + 1] + 1;
9514 PartitionsScore[i] = PartitionsScore[i + 1] + PartitionScores::SingleCase;
9517 for (int64_t j = N - 1; j > i; j--) {
9519 uint64_t Range = getJumpTableRange(Clusters, i, j);
9520 uint64_t NumCases = getJumpTableNumCases(TotalCases, i, j);
9522 assert(Range >= NumCases);
9524 unsigned NumPartitions = 1 + (j == N - 1 ? 0 : MinPartitions[j + 1]);
9525 unsigned Score = j == N - 1 ? 0 : PartitionsScore[j + 1];
9526 int64_t NumEntries = j - i + 1;
9528 if (NumEntries == 1)
9529 Score += PartitionScores::SingleCase;
9530 else if (NumEntries <= SmallNumberOfEntries)
9531 Score += PartitionScores::FewCases;
9532 else if (NumEntries >= MinJumpTableEntries)
9533 Score += PartitionScores::Table;
9537 if (NumPartitions < MinPartitions[i] ||
9538 (NumPartitions == MinPartitions[i] && Score > PartitionsScore[i])) {
9539 MinPartitions[i] = NumPartitions;
9541 PartitionsScore[i] = Score;
9548 unsigned DstIndex = 0;
9549 for (
unsigned First = 0, Last; First <
N; First = Last + 1) {
9550 Last = LastElement[First];
9552 assert(DstIndex <= First);
9553 unsigned NumClusters = Last - First + 1;
9555 CaseCluster JTCluster;
9556 if (NumClusters >= MinJumpTableEntries &&
9557 buildJumpTable(Clusters, First, Last, SI, DefaultMBB, JTCluster)) {
9558 Clusters[DstIndex++] = JTCluster;
9560 for (
unsigned I = First;
I <= Last; ++
I)
9561 std::memmove(&Clusters[DstIndex++], &Clusters[
I],
sizeof(Clusters[I]));
9564 Clusters.resize(DstIndex);
9567 bool SelectionDAGBuilder::buildBitTests(CaseClusterVector &Clusters,
9568 unsigned First,
unsigned Last,
9570 CaseCluster &BTCluster) {
9575 BitVector Dests(FuncInfo.MF->getNumBlockIDs());
9576 unsigned NumCmps = 0;
9577 for (int64_t
I = First;
I <= Last; ++
I) {
9580 NumCmps += (Clusters[
I].Low == Clusters[
I].High) ? 1 : 2;
9582 unsigned NumDests = Dests.count();
9584 APInt Low = Clusters[First].Low->getValue();
9585 APInt High = Clusters[Last].High->getValue();
9590 if (!TLI.isSuitableForBitTests(NumDests, NumCmps, Low, High, DL))
9596 const int BitWidth = TLI.getPointerTy(DL).getSizeInBits();
9597 assert(TLI.rangeFitsInWord(Low, High, DL) &&
9598 "Case range must fit in bit mask!");
9602 bool ContiguousRange =
true;
9603 for (int64_t
I = First + 1;
I <= Last; ++
I) {
9604 if (Clusters[
I].Low->getValue() != Clusters[
I - 1].High->getValue() + 1) {
9605 ContiguousRange =
false;
9615 ContiguousRange =
false;
9618 CmpRange = High - Low;
9623 for (
unsigned i = First; i <= Last; ++i) {
9626 for (j = 0; j < CBV.size(); ++j)
9627 if (CBV[j].BB == Clusters[i].MBB)
9629 if (j == CBV.size())
9632 CaseBits *CB = &CBV[j];
9635 uint64_t
Lo = (Clusters[i].Low->getValue() - LowBound).getZExtValue();
9636 uint64_t
Hi = (Clusters[i].High->getValue() - LowBound).getZExtValue();
9637 assert(Hi >= Lo && Hi < 64 &&
"Invalid bit case!");
9638 CB->Mask |= (-1ULL >> (63 - (Hi -
Lo))) << Lo;
9639 CB->Bits += Hi - Lo + 1;
9640 CB->ExtraProb += Clusters[i].Prob;
9641 TotalProb += Clusters[i].Prob;
9645 llvm::sort(CBV.begin(), CBV.end(), [](
const CaseBits &a,
const CaseBits &b) {
9647 if (a.ExtraProb != b.ExtraProb)
9648 return a.ExtraProb > b.ExtraProb;
9649 if (a.Bits != b.Bits)
9650 return a.Bits > b.Bits;
9651 return a.Mask < b.Mask;
9654 for (
auto &CB : CBV) {
9656 FuncInfo.MF->CreateMachineBasicBlock(SI->
getParent());
9657 BTI.
push_back(BitTestCase(CB.Mask, BitTestBB, CB.BB, CB.ExtraProb));
9659 BitTestCases.emplace_back(std::move(LowBound), std::move(CmpRange),
9661 ContiguousRange,
nullptr,
nullptr, std::move(BTI),
9664 BTCluster = CaseCluster::bitTests(Clusters[First].Low, Clusters[Last].High,
9665 BitTestCases.size() - 1, TotalProb);
9669 void SelectionDAGBuilder::findBitTestClusters(CaseClusterVector &Clusters,
9676 assert(!Clusters.empty());
9677 assert(Clusters[0].
Kind == CC_Range || Clusters[0].
Kind == CC_JumpTable);
9678 for (
const CaseCluster &
C : Clusters)
9679 assert(
C.Kind == CC_Range ||
C.Kind == CC_JumpTable);
9680 for (
unsigned i = 1; i < Clusters.size(); ++i)
9681 assert(Clusters[i-1].
High->getValue().slt(Clusters[i].Low->getValue()));
9697 const int64_t
N = Clusters.size();
9707 MinPartitions[N - 1] = 1;
9708 LastElement[N - 1] = N - 1;
9711 for (int64_t i = N - 2; i >= 0; --i) {
9714 MinPartitions[i] = MinPartitions[i + 1] + 1;
9719 for (int64_t j = std::min(N - 1, i + BitWidth - 1); j > i; --j) {
9724 Clusters[j].High->getValue(), DL))
9729 bool RangesOnly =
true;
9730 BitVector Dests(FuncInfo.MF->getNumBlockIDs());
9731 for (int64_t k = i; k <= j; k++) {
9732 if (Clusters[k].
Kind != CC_Range) {
9736 Dests.set(Clusters[k].MBB->
getNumber());
9738 if (!RangesOnly || Dests.count() > 3)
9742 unsigned NumPartitions = 1 + (j == N - 1 ? 0 : MinPartitions[j + 1]);
9743 if (NumPartitions < MinPartitions[i]) {
9745 MinPartitions[i] = NumPartitions;
9752 unsigned DstIndex = 0;
9753 for (
unsigned First = 0, Last; First <
N; First = Last + 1) {
9754 Last = LastElement[First];
9756 assert(DstIndex <= First);
9758 CaseCluster BitTestCluster;
9759 if (buildBitTests(Clusters, First, Last, SI, BitTestCluster)) {
9760 Clusters[DstIndex++] = BitTestCluster;
9762 size_t NumClusters = Last - First + 1;
9763 std::memmove(&Clusters[DstIndex], &Clusters[First],
9764 sizeof(Clusters[0]) * NumClusters);
9765 DstIndex += NumClusters;
9768 Clusters.resize(DstIndex);
9771 void SelectionDAGBuilder::lowerWorkItem(SwitchWorkListItem
W,
Value *Cond,
9777 if (++BBI != FuncInfo.MF->end())
9780 unsigned Size = W.LastCluster - W.FirstCluster + 1;
9784 if (Size == 2 && W.MBB == SwitchMBB) {
9792 CaseCluster &
Small = *W.FirstCluster;
9793 CaseCluster &Big = *W.LastCluster;
9795 if (Small.Low == Small.High && Big.Low == Big.High &&
9796 Small.MBB == Big.MBB) {
9797 const APInt &SmallValue = Small.Low->getValue();
9798 const APInt &BigValue = Big.Low->getValue();
9801 APInt CommonBit = BigValue ^ SmallValue;
9803 SDValue CondLHS = getValue(Cond);
9805 SDLoc DL = getCurSDLoc();
9808 DAG.getConstant(CommonBit, DL, VT));
9810 DL,
MVT::i1, Or, DAG.getConstant(BigValue | SmallValue, DL, VT),
9816 addSuccessorWithProb(SwitchMBB, Small.MBB, Small.Prob + Big.Prob);
9818 addSuccessorWithProb(
9819 SwitchMBB, DefaultMBB,
9823 addSuccessorWithProb(SwitchMBB, DefaultMBB);
9828 DAG.getBasicBlock(Small.MBB));
9831 DAG.getBasicBlock(DefaultMBB));
9833 DAG.setRoot(BrCond);
9844 llvm::sort(W.FirstCluster, W.LastCluster + 1,
9845 [](
const CaseCluster &a,
const CaseCluster &b) {
9846 return a.Prob != b.Prob ?
9848 a.Low->getValue().slt(b.Low->getValue());
9853 for (CaseClusterIt
I = W.LastCluster;
I > W.FirstCluster; ) {
9855 if (
I->Prob > W.LastCluster->Prob)
9857 if (
I->Kind == CC_Range &&
I->MBB == NextMBB) {
9867 for (CaseClusterIt
I = W.FirstCluster;
I <= W.LastCluster; ++
I)
9868 UnhandledProbs +=
I->Prob;
9871 for (CaseClusterIt
I = W.FirstCluster,
E = W.LastCluster;
I <=
E; ++
I) {
9873 if (
I == W.LastCluster) {
9875 Fallthrough = DefaultMBB;
9878 CurMF->
insert(BBI, Fallthrough);
9880 ExportFromCurrentBlock(Cond);
9882 UnhandledProbs -=
I->Prob;
9885 case CC_JumpTable: {
9887 JumpTableHeader *JTH = &JTCases[
I->JTCasesIndex].first;
9892 CurMF->
insert(BBI, JumpMBB);
9894 auto JumpProb =
I->Prob;
9895 auto FallthroughProb = UnhandledProbs;
9903 if (*SI == DefaultMBB) {
9904 JumpProb += DefaultProb / 2;
9905 FallthroughProb -= DefaultProb / 2;
9912 addSuccessorWithProb(CurMBB, Fallthrough, FallthroughProb);
9913 addSuccessorWithProb(CurMBB, JumpMBB, JumpProb);
9918 JTH->HeaderBB = CurMBB;
9919 JT->Default = Fallthrough;
9922 if (CurMBB == SwitchMBB) {
9923 visitJumpTableHeader(*JT, *JTH, SwitchMBB);
9924 JTH->Emitted =
true;
9930 BitTestBlock *BTB = &BitTestCases[
I->BTCasesIndex];
9933 for (BitTestCase &BTC : BTB->Cases)
9934 CurMF->
insert(BBI, BTC.ThisBB);
9937 BTB->Parent = CurMBB;
9938 BTB->Default = Fallthrough;
9940 BTB->DefaultProb = UnhandledProbs;
9944 if (!BTB->ContiguousRange) {
9945 BTB->Prob += DefaultProb / 2;
9946 BTB->DefaultProb -= DefaultProb / 2;
9950 if (CurMBB == SwitchMBB) {
9951 visitBitTestHeader(*BTB, SwitchMBB);
9952 BTB->Emitted =
true;
9957 const Value *RHS, *LHS, *MHS;
9959 if (
I->Low ==
I->High) {
9974 CaseBlock CB(CC, LHS, RHS, MHS,
I->MBB, Fallthrough, CurMBB,
9975 getCurSDLoc(),
I->Prob, UnhandledProbs);
9977 if (CurMBB == SwitchMBB)
9978 visitSwitchCase(CB, SwitchMBB);
9980 SwitchCases.push_back(CB);
9985 CurMBB = Fallthrough;
9989 unsigned SelectionDAGBuilder::caseClusterRank(
const CaseCluster &CC,
9990 CaseClusterIt First,
9991 CaseClusterIt Last) {
9992 return std::count_if(First, Last + 1, [&](
const CaseCluster &
X) {
9993 if (X.Prob != CC.Prob)
9994 return X.Prob > CC.Prob;
9997 return X.Low->getValue().slt(CC.Low->getValue());
10001 void SelectionDAGBuilder::splitWorkItem(SwitchWorkList &WorkList,
10002 const SwitchWorkListItem &W,
10005 assert(W.FirstCluster->Low->getValue().slt(W.LastCluster->Low->getValue()) &&
10006 "Clusters not sorted?");
10008 assert(W.LastCluster - W.FirstCluster + 1 >= 2 &&
"Too small to split!");
10013 CaseClusterIt LastLeft = W.FirstCluster;
10014 CaseClusterIt FirstRight = W.LastCluster;
10015 auto LeftProb = LastLeft->Prob + W.DefaultProb / 2;
10016 auto RightProb = FirstRight->Prob + W.DefaultProb / 2;
10023 while (LastLeft + 1 < FirstRight) {
10024 if (LeftProb < RightProb || (LeftProb == RightProb && (I & 1)))
10025 LeftProb += (++LastLeft)->Prob;
10027 RightProb += (--FirstRight)->Prob;
10037 unsigned NumLeft = LastLeft - W.FirstCluster + 1;
10038 unsigned NumRight = W.LastCluster - FirstRight + 1;
10040 if (std::min(NumLeft, NumRight) < 3 &&
std::max(NumLeft, NumRight) > 3) {
10044 if (NumLeft < NumRight) {
10046 CaseCluster &CC = *FirstRight;
10047 unsigned RightSideRank = caseClusterRank(CC, FirstRight, W.LastCluster);
10048 unsigned LeftSideRank = caseClusterRank(CC, W.FirstCluster, LastLeft);
10049 if (LeftSideRank <= RightSideRank) {
10056 assert(NumRight < NumLeft);
10058 CaseCluster &CC = *LastLeft;
10059 unsigned LeftSideRank = caseClusterRank(CC, W.FirstCluster, LastLeft);
10060 unsigned RightSideRank = caseClusterRank(CC, FirstRight, W.LastCluster);
10061 if (RightSideRank <= LeftSideRank) {
10072 assert(LastLeft + 1 == FirstRight);
10073 assert(LastLeft >= W.FirstCluster);
10074 assert(FirstRight <= W.LastCluster);
10078 CaseClusterIt PivotCluster = FirstRight;
10079 assert(PivotCluster > W.FirstCluster);
10080 assert(PivotCluster <= W.LastCluster);
10082 CaseClusterIt FirstLeft = W.FirstCluster;
10083 CaseClusterIt LastRight = W.LastCluster;
10095 if (FirstLeft == LastLeft && FirstLeft->Kind == CC_Range &&
10096 FirstLeft->Low == W.GE &&
10097 (FirstLeft->High->getValue() + 1LL) == Pivot->
getValue()) {
10098 LeftMBB = FirstLeft->MBB;
10100 LeftMBB = FuncInfo.MF->CreateMachineBasicBlock(W.MBB->getBasicBlock());
10101 FuncInfo.MF->
insert(BBI, LeftMBB);
10102 WorkList.push_back(
10103 {LeftMBB, FirstLeft, LastLeft, W.GE, Pivot, W.DefaultProb / 2});
10105 ExportFromCurrentBlock(Cond);
10112 if (FirstRight == LastRight && FirstRight->Kind == CC_Range &&
10113 W.LT && (FirstRight->High->getValue() + 1ULL) == W.LT->getValue()) {
10114 RightMBB = FirstRight->MBB;
10116 RightMBB = FuncInfo.MF->CreateMachineBasicBlock(W.MBB->getBasicBlock());
10117 FuncInfo.MF->
insert(BBI, RightMBB);
10118 WorkList.push_back(
10119 {RightMBB, FirstRight, LastRight, Pivot, W.LT, W.DefaultProb / 2});
10121 ExportFromCurrentBlock(Cond);
10125 CaseBlock CB(
ISD::SETLT, Cond, Pivot,
nullptr, LeftMBB, RightMBB, W.MBB,
10126 getCurSDLoc(), LeftProb, RightProb);
10128 if (W.MBB == SwitchMBB)
10129 visitSwitchCase(CB, SwitchMBB);
10131 SwitchCases.push_back(CB);
10154 const SwitchInst &SI, CaseClusterVector &Clusters,
10164 unsigned PeeledCaseIndex = 0;
10165 bool SwitchPeeled =
false;
10167 CaseCluster &CC = Clusters[
Index];
10168 if (CC.Prob < TopCaseProb)
10170 TopCaseProb = CC.Prob;
10171 PeeledCaseIndex =
Index;
10172 SwitchPeeled =
true;
10177 LLVM_DEBUG(
dbgs() <<
"Peeled one top case in switch stmt, prob: " 10178 << TopCaseProb <<
"\n");
10184 FuncInfo.MF->CreateMachineBasicBlock(SwitchMBB->
getBasicBlock());
10185 FuncInfo.MF->
insert(BBI, PeeledSwitchMBB);
10188 auto PeeledCaseIt = Clusters.begin() + PeeledCaseIndex;
10189 SwitchWorkListItem W = {SwitchMBB, PeeledCaseIt, PeeledCaseIt,
10190 nullptr,
nullptr, TopCaseProb.
getCompl()};
10191 lowerWorkItem(W, SI.
getCondition(), SwitchMBB, PeeledSwitchMBB);
10193 Clusters.erase(PeeledCaseIt);
10194 for (CaseCluster &CC : Clusters) {
10196 dbgs() <<
"Scale the probablity for one cluster, before scaling: " 10197 << CC.Prob <<
"\n");
10201 PeeledCaseProb = TopCaseProb;
10202 return PeeledSwitchMBB;
10205 void SelectionDAGBuilder::visitSwitch(
const SwitchInst &SI) {
10208 CaseClusterVector Clusters;
10210 for (
auto I : SI.
cases()) {
10216 Clusters.push_back(CaseCluster::range(CaseVal, CaseVal, Succ, Prob));
10224 sortAndRangeify(Clusters);
10229 bool UnreachableDefault =
10231 if (UnreachableDefault && !Clusters.empty()) {
10233 unsigned MaxPop = 0;
10235 for (
auto I : SI.
cases()) {
10237 if (++Popularity[BB] > MaxPop) {
10238 MaxPop = Popularity[BB];
10243 assert(MaxPop > 0 && MaxBB);
10244 DefaultMBB = FuncInfo.MBBMap[MaxBB];
10248 CaseClusterVector New;
10249 New.reserve(Clusters.size());
10250 for (CaseCluster &CC : Clusters) {
10251 if (CC.MBB != DefaultMBB)
10254 Clusters = std::move(New);
10261 peelDominantCaseCluster(SI, Clusters, PeeledCaseProb);
10265 if (Clusters.empty()) {
10266 assert(PeeledSwitchMBB == SwitchMBB);
10268 if (DefaultMBB != NextBlock(SwitchMBB)) {
10270 getControlRoot(), DAG.getBasicBlock(DefaultMBB)));
10275 findJumpTables(Clusters, &SI, DefaultMBB);
10276 findBitTestClusters(Clusters, &SI);
10279 dbgs() <<
"Case clusters: ";
10280 for (
const CaseCluster &
C : Clusters) {
10281 if (
C.Kind == CC_JumpTable)
10283 if (
C.Kind == CC_BitTests)
10287 if (
C.Low !=
C.High) {
10296 assert(!Clusters.empty());
10297 SwitchWorkList WorkList;
10298 CaseClusterIt First = Clusters.begin();
10299 CaseClusterIt Last = Clusters.end() - 1;
10300 auto DefaultProb = getEdgeProbability(PeeledSwitchMBB, DefaultMBB);
10306 WorkList.push_back(
10307 {PeeledSwitchMBB, First, Last,
nullptr,
nullptr, DefaultProb});
10309 while (!WorkList.empty()) {
10310 SwitchWorkListItem W = WorkList.back();
10311 WorkList.pop_back();
10312 unsigned NumClusters = W.LastCluster - W.FirstCluster + 1;
10317 splitWorkItem(WorkList, W, SI.
getCondition(), SwitchMBB);
10321 lowerWorkItem(W, SI.
getCondition(), SwitchMBB, DefaultMBB);
ANNOTATION_LABEL - Represents a mid basic block label used by annotations.
SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
Helper function to build ISD::STORE nodes.
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
ADJUST_TRAMPOLINE - This corresponds to the adjust_trampoline intrinsic.
bool onlyReadsMemory() const
Determine if the function does not access or only reads memory.
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type down to the precision of the ...
Return a value (possibly void), from a function.
SDValue getGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT, int64_t offset=0, bool isTargetGA=false, unsigned char TargetFlags=0)
Value * getValueOperand()
unsigned getNumCases() const
Return the number of 'cases' in this switch instruction, excluding the default case.
static MVT getIntegerVT(unsigned BitWidth)
void setByValAlign(unsigned A)
void push_back(const T &Elt)
unsigned Log2_32_Ceil(uint32_t Value)
Return the ceil log base 2 of the specified value, 32 if the value is zero.
A parsed version of the target data layout string in and methods for querying it. ...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
static ConstantInt * getFalse(LLVMContext &Context)
ISD::CondCode getICmpCondCode(ICmpInst::Predicate Pred)
getICmpCondCode - Return the ISD condition code corresponding to the given LLVM IR integer condition ...
FMINNUM/FMAXNUM - Perform floating-point minimum or maximum on two values.
static void findArgumentCopyElisionCandidates(const DataLayout &DL, FunctionLoweringInfo *FuncInfo, ArgCopyElisionMapTy &ArgCopyElisionCandidates)
Scan the entry block of the function in FuncInfo for arguments that look like copies into a local all...
virtual MVT getVectorIdxTy(const DataLayout &DL) const
Returns the type to be used for the index operand of: ISD::INSERT_VECTOR_ELT, ISD::EXTRACT_VECTOR_ELT...
EVT getValueType() const
Return the ValueType of the referenced return value.
Function * getCalledFunction() const
Return the function called, or null if this is an indirect function invocation.
bool isInteger() const
Return true if this is an integer or a vector integer type.
ArrayRef< Type * > subtypes() const
This class is the base class for the comparison instructions.
virtual std::pair< SDValue, SDValue > EmitTargetCodeForStrnlen(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Src, SDValue MaxLength, MachinePointerInfo SrcPtrInfo) const
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
unsigned getIndexSizeInBits(unsigned AS) const
Size in bits of index used for address calculation in getelementptr.
Constrained versions of libm-equivalent floating point intrinsics.
EXTRACT_ELEMENT - This is used to get the lower or upper (determined by a Constant, which is required to be operand #1) half of the integer or float value specified as operand #0.
*p = old <signed v ? old : v
bool usesUnderscoreLongJmp() const
Determine if we should use _longjmp or longjmp to implement llvm.longjmp.
bool isOnlyUsedInZeroEqualityComparison(const Instruction *CxtI)
iterator_range< CaseIt > cases()
Iteration adapter for range-for loops.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
This class represents an incoming formal argument to a Function.
BranchProbability getCompl() const
SDValue getSetCC(const SDLoc &DL, EVT VT, SDValue LHS, SDValue RHS, ISD::CondCode Cond)
Helper function to make it easier to build SetCC's if you just have an ISD::CondCode instead of an SD...
static SDValue getAddressForMemoryInput(SDValue Chain, const SDLoc &Location, SDISelAsmOperandInfo &OpInfo, SelectionDAG &DAG)
Get a direct memory input to behave well as an indirect operand.
unsigned arg_size() const
SDValue getCALLSEQ_END(SDValue Chain, SDValue Op1, SDValue Op2, SDValue InGlue, const SDLoc &DL)
Return a new CALLSEQ_END node, which always must have a glue result (to ensure it's not CSE'd)...
CallingConv::ID getCallingConv() const
Get the calling convention of the call.
const TargetRegisterClass * getRegClass(unsigned Reg) const
Return the register class of the specified virtual register.
This represents the llvm.dbg.label instruction.
Atomic ordering constants.
C - The default llvm calling convention, compatible with C.
DELETED_NODE - This is an illegal value that is used to catch errors.
virtual std::pair< SDValue, SDValue > EmitTargetCodeForStrcmp(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Op1, SDValue Op2, MachinePointerInfo Op1PtrInfo, MachinePointerInfo Op2PtrInfo) const
Emit target-specific code that performs a strcmp, in cases where that is faster than a libcall...
EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR (an vector value) starting with the ...
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.
void setCopyElisionCandidate()
void ExportFromCurrentBlock(const Value *V)
ExportFromCurrentBlock - If this condition isn't known to be exported from the current basic block...
bool isAtomic() const
Return true if this instruction has an AtomicOrdering of unordered or higher.
static SDValue expandExp2(const SDLoc &dl, SDValue Op, SelectionDAG &DAG, const TargetLowering &TLI)
expandExp2 - Lower an exp2 intrinsic.
unsigned countOperandBundlesOfType(StringRef Name) const
Return the number of operand bundles with the tag Name attached to this instruction.
void setMemRefs(mmo_iterator NewMemRefs, mmo_iterator NewMemRefsEnd)
Assign this MachineSDNodes's memory reference descriptor list.
void setCallsUnwindInit(bool b)
iterator begin() const
begin/end - Return all of the registers in this class.
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
A Module instance is used to store all the information related to an LLVM module. ...
bool isSized(SmallPtrSetImpl< Type *> *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
BasicBlock * getSuccessor(unsigned idx) const
Return the specified successor.
An instruction for ordering other memory operations.
SDValue getAtomicMemcpy(SDValue Chain, const SDLoc &dl, SDValue Dst, unsigned DstAlign, SDValue Src, unsigned SrcAlign, SDValue Size, Type *SizeTy, unsigned ElemSz, bool isTailCall, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo)
void CopyValueToVirtualRegister(const Value *V, unsigned Reg)
an instruction that atomically checks whether a specified value is in a memory location, and, if it is, stores a new value there.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
const Value * getSplatValue(const Value *V)
Get splat value if the input is a splat vector or return nullptr.
bool isVector() const
Return true if this is a vector value type.
unsigned getIROrder() const
Return the node ordering.
static unsigned LimitFloatPrecision
LimitFloatPrecision - Generate low-precision inline sequences for some float libcalls (6...
void addLandingPadInfo(const LandingPadInst &I, MachineBasicBlock &MBB)
Extract the exception handling information from the landingpad instruction and add them to the specif...
bool usesUnderscoreSetJmp() const
Determine if we should use _setjmp or setjmp to implement llvm.setjmp.
virtual unsigned getJumpTableEncoding() const
Return the entry encoding for a jump table in the current function.
SelectionDAGBuilder - This is the common target-independent lowering implementation that is parameter...
A specialization of it's base class for read only access to a gc.statepoint.
bool isABIMangled() const
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
virtual void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint, std::vector< SDValue > &Ops, SelectionDAG &DAG) const
Lower the specified operand into the Ops vector.
virtual unsigned getVectorTypeBreakdownForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT, EVT &IntermediateVT, unsigned &NumIntermediates, MVT &RegisterVT) const
Certain targets such as MIPS require that some types such as vectors are always broken down into scal...
bool hasOpaqueSPAdjustment() const
Returns true if the function contains opaque dynamic stack adjustments.
MCSymbol * getOrCreateFrameAllocSymbol(StringRef FuncName, unsigned Idx)
Gets a symbol that will be defined to the final stack offset of a local variable after codegen...
static unsigned getFlagWord(unsigned Kind, unsigned NumOps)
unsigned succ_size(const BasicBlock *BB)
unsigned getReg() const
getReg - Returns the register number.
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
bool slt(const APInt &RHS) const
Signed less than comparison.
STACKRESTORE has two operands, an input chain and a pointer to restore to it returns an output chain...
This class represents a function call, abstracting a target machine's calling convention.
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
static bool getUniformBase(const Value *&Ptr, SDValue &Base, SDValue &Index, SDValue &Scale, SelectionDAGBuilder *SDB)
Value * getCondition() const
unsigned getSourceAlignment() const
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space...
static uint64_t round(uint64_t Acc, uint64_t Input)
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this store instruction.
gep_type_iterator gep_type_end(const User *GEP)
SDValue getBasicBlock(MachineBasicBlock *MBB)
RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
const std::string & getAsmString() const
*p = old <unsigned v ? old : v
unsigned getVectorNumElements() const
This class represents the atomic memcpy intrinsic i.e.
void copyFMF(const FPMathOperator &FPMO)
Propagate the fast-math-flags from an IR FPMathOperator.
AtomicOrdering getOrdering() const
Returns the ordering constraint of this load instruction.
void visitJumpTableHeader(JumpTable &JT, JumpTableHeader &JTH, MachineBasicBlock *SwitchBB)
visitJumpTableHeader - This function emits necessary code to produce index in the JumpTable from swit...
Function Alias Analysis Results
bool isSuitableForBitTests(unsigned NumDests, unsigned NumCmps, const APInt &Low, const APInt &High, const DataLayout &DL) const
Return true if lowering to a bit test is suitable for a set of case clusters which contains NumDests ...
*p = old >unsigned v ? old : v
This instruction constructs a fixed permutation of two input vectors.
Optional< CallingConv::ID > CallConv
Records if this value needs to be treated in an ABI dependant manner, different to normal type legali...
LLVMContext & getContext() const
All values hold a context through their type.
virtual std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const
Given a physical register constraint (e.g.
void addSuccessorWithoutProb(MachineBasicBlock *Succ)
Add Succ as a successor of this MachineBasicBlock.
auto count_if(R &&Range, UnaryPredicate P) -> typename std::iterator_traits< decltype(adl_begin(Range))>::difference_type
Wrapper function around std::count_if to count the number of times an element satisfying a given pred...
Val, Success, OUTCHAIN = ATOMIC_CMP_SWAP_WITH_SUCCESS(INCHAIN, ptr, cmp, swap) N.b.
static SDValue expandLog2(const SDLoc &dl, SDValue Op, SelectionDAG &DAG, const TargetLowering &TLI)
expandLog2 - Lower a log2 intrinsic.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly...
void setInConsecutiveRegs()
BasicBlock * getSuccessor(unsigned i) const
Value * getNewValOperand()
Constrained versions of the binary floating point operators.
virtual const TargetRegisterClass * getRegClassFor(MVT VT) const
Return the register class that should be used for the specified value type.
unsigned const TargetRegisterInfo * TRI
virtual AsmOperandInfoVector ParseConstraints(const DataLayout &DL, const TargetRegisterInfo *TRI, ImmutableCallSite CS) const
Split up the constraint string from the inline assembly value into the specific constraints and their...
bool isInteger() const
Return true if this is an integer or a vector integer type.
static SDValue getCopyFromParts(SelectionDAG &DAG, const SDLoc &DL, const SDValue *Parts, unsigned NumParts, MVT PartVT, EVT ValueVT, const Value *V, Optional< CallingConv::ID > CC=None, Optional< ISD::NodeType > AssertOp=None)
getCopyFromParts - Create a value that contains the specified legal parts combined into the value the...
MachineModuleInfo & getMMI() const
CallLoweringInfo & setDebugLoc(const SDLoc &dl)
SDValue getSelect(const SDLoc &DL, EVT VT, SDValue Cond, SDValue LHS, SDValue RHS)
Helper function to make it easier to build Select's if you just have operands and don't want to check...
uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
An instruction for reading from memory.
[US]{MIN/MAX} - Binary minimum or maximum or signed or unsigned integers.
an instruction that atomically reads a memory location, combines it with another value, and then stores the result back.
SDNode * getNode() const
get the SDNode which holds the desired result
Value * getCondition() const
SDValue getTargetExternalSymbol(const char *Sym, EVT VT, unsigned char TargetFlags=0)
BasicBlock * getUnwindDest() const
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
bool isVectorTy() const
True if this is an instance of VectorType.
static BranchProbability getOne()
This is the common base class for constrained floating point intrinsics.
virtual bool isZExtFree(Type *FromTy, Type *ToTy) const
Return true if any actual instruction that defines a value of type FromTy implicitly zero-extends the...
BasicBlock * getSuccessor() const
unsigned getTypeIDFor(const GlobalValue *TI)
Return the type id for the specified typeinfo. This is function wide.
const SDValue & setRoot(SDValue N)
Set the current root tag of the SelectionDAG.
bool isOperationLegalOrCustom(unsigned Op, EVT VT) const
Return true if the specified operation is legal on this target or can be made legal with custom lower...
Value * getLength() const
GlobalValue * ExtractTypeInfo(Value *V)
ExtractTypeInfo - Returns the type info, possibly bitcast, encoded in V.
bool hasOperandBundlesOtherThan(ArrayRef< uint32_t > IDs) const
Return true if this operand bundle user contains operand bundles with tags other than those specified...
static void diagnosePossiblyInvalidConstraint(LLVMContext &Ctx, const Value *V, const Twine &ErrMsg)
void DeleteNode(SDNode *N)
Remove the specified node from the system.
SDValue getValueImpl(const Value *V)
getValueImpl - Helper function for getValue and getNonRegisterValue.
SDValue getConstantPool(const Constant *C, EVT VT, unsigned Align=0, int Offs=0, bool isT=false, unsigned char TargetFlags=0)
*p = old >signed v ? old : v
unsigned NoTrapAfterNoreturn
Do not emit a trap instruction for 'unreachable' IR instructions behind noreturn calls, even if TrapUnreachable is true.
static unsigned getUnderlyingArgReg(const SDValue &N)
unsigned getValueSizeInBits() const
Returns the size of the value in bits.
EntryToken - This is the marker used to indicate the start of a region.
virtual bool getTgtMemIntrinsic(IntrinsicInfo &, const CallInst &, MachineFunction &, unsigned) const
Given an intrinsic, checks if on the target the intrinsic will need to map to a MemIntrinsicNode (tou...
OUTCHAIN = ATOMIC_FENCE(INCHAIN, ordering, scope) This corresponds to the fence instruction.
void AddDbgValue(SDDbgValue *DB, SDNode *SD, bool isParameter)
Add a dbg_value SDNode.
int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSpillSlot, const AllocaInst *Alloca=nullptr, uint8_t ID=0)
Create a new statically sized stack object, returning a nonnegative identifier to represent it...
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
SDValue getMCSymbol(MCSymbol *Sym, EVT VT)
void FindMergedConditions(const Value *Cond, MachineBasicBlock *TBB, MachineBasicBlock *FBB, MachineBasicBlock *CurBB, MachineBasicBlock *SwitchBB, Instruction::BinaryOps Opc, BranchProbability TProb, BranchProbability FProb, bool InvertCond)
FindMergedConditions - If Cond is an expression like.
void ReplaceAllUsesOfValuesWith(const SDValue *From, const SDValue *To, unsigned Num)
Like ReplaceAllUsesOfValueWith, but for multiple values at once.
void EmitBranchForMergedCondition(const Value *Cond, MachineBasicBlock *TBB, MachineBasicBlock *FBB, MachineBasicBlock *CurBB, MachineBasicBlock *SwitchBB, BranchProbability TProb, BranchProbability FProb, bool InvertCond)
EmitBranchForMergedCondition - Helper method for FindMergedConditions.
unsigned getBitWidth() const
Return the number of bits in the APInt.
bool isWrappedSet() const
Return true if this set wraps around the top of the range.
BasicBlock * getSuccessor(unsigned i) const
SDValue getExternalSymbol(const char *Sym, EVT VT)
bool onlyReadsMemory() const
Determine if the call does not access or only reads memory.
static MachineOperand CreateReg(unsigned Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false, bool isRenamable=false)
void computeUsesVAFloatArgument(const CallInst &I, MachineModuleInfo &MMI)
Determine if any floating-point values are being passed to this variadic function, and set the MachineModuleInfo's usesVAFloatArgument flag if so.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
virtual std::pair< SDValue, SDValue > EmitTargetCodeForMemchr(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Src, SDValue Char, SDValue Length, MachinePointerInfo SrcPtrInfo) const
Emit target-specific code that performs a memchr, in cases where that is faster than a libcall...
RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) This node represents a target in...
SDValue getAtomicMemset(SDValue Chain, const SDLoc &dl, SDValue Dst, unsigned DstAlign, SDValue Value, SDValue Size, Type *SizeTy, unsigned ElemSz, bool isTailCall, MachinePointerInfo DstPtrInfo)
void setCurrentCallSite(unsigned Site)
Set the call site currently being processed.
MachineJumpTableInfo * getOrCreateJumpTableInfo(unsigned JTEntryKind)
getOrCreateJumpTableInfo - Get the JumpTableInfo for this function, if it does already exist...
SDValue getValue(const Value *V)
getValue - Return an SDValue for the given Value.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
AtomicOrdering getFailureOrdering() const
Returns the failure ordering constraint of this cmpxchg instruction.
iterator begin()
Instruction iterator methods.
bool hasSideEffects() const
MVT getRegisterType(MVT VT) const
Return the type of registers that this ValueType will eventually require.
OUTCHAIN = EH_SJLJ_LONGJMP(INCHAIN, buffer) This corresponds to the eh.sjlj.longjmp intrinsic...
X86_INTR - x86 hardware interrupt context.
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
SDValue getIntPtrConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
void setNoSignedWrap(bool b)
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.
The address of a basic block.
unsigned getAllocaAddrSpace() const
uint64_t alignDown(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the largest uint64_t less than or equal to Value and is Skew mod Align.
CLEANUPRET - Represents a return from a cleanup block funclet.
bool isVolatile() const
Return true if this is a load from a volatile memory location.
A description of a memory reference used in the backend.
const CallInst * getTerminatingDeoptimizeCall() const
Returns the call instruction calling @llvm.experimental.deoptimize prior to the terminating return in...
static unsigned getFlagWordForRegClass(unsigned InputFlag, unsigned RC)
getFlagWordForRegClass - Augment an existing flag word returned by getFlagWord with the required regi...
PCMARKER - This corresponds to the pcmarker intrinsic.
Predicate getInversePredicate() const
For example, EQ -> NE, UGT -> ULE, SLT -> SGE, OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc.
void visitSwitchCase(CaseBlock &CB, MachineBasicBlock *SwitchBB)
visitSwitchCase - Emits the necessary code to represent a single node in the binary search tree resul...
void setVectorReduction(bool b)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
const HexagonInstrInfo * TII
unsigned getAlignment() const
Return the alignment of the memory that is being allocated by the instruction.
bool isNonNegative() const
Determine if this APInt Value is non-negative (>= 0)
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
unsigned getNumSuccessors() const
static bool hasOnlySelectUsers(const Value *Cond)
Shift and rotation operations.
Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
std::size_t countTrailingOnes(T Value, ZeroBehavior ZB=ZB_Width)
Count the number of ones from the least significant bit to the first zero bit.
virtual MVT getRegisterTypeForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const
Certain combinations of ABIs, Targets and features require that types are legal for some operations a...
Class to represent struct types.
LLVMContext & getContext() const
Get the global data context.
A Use represents the edge between a Value definition and its users.
DILabel * getLabel() const
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
PointerType * getPointerTo(unsigned AddrSpace=0) const
Return a pointer to the current type.
BinOp getOperation() const
TargetLowering::ConstraintType ConstraintType
Information about the constraint code, e.g.
SDValue getMaskedScatter(SDVTList VTs, EVT VT, const SDLoc &dl, ArrayRef< SDValue > Ops, MachineMemOperand *MMO)
CallLoweringInfo & setChain(SDValue InChain)
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
static unsigned findMatchingInlineAsmOperand(unsigned OperandNo, const std::vector< SDValue > &AsmNodeOperands)
FLT_ROUNDS_ - Returns current rounding mode: -1 Undefined 0 Round to 0 1 Round to nearest 2 Round to ...
virtual bool useLoadStackGuardNode() const
If this function returns true, SelectionDAGBuilder emits a LOAD_STACK_GUARD node when it is lowering ...
SmallVector< EVT, 4 > ValueVTs
The value types of the values, which may not be legal, and may need be promoted or synthesized from o...
bool IsPostTypeLegalization
This file contains the simple types necessary to represent the attributes associated with functions a...
NaN behavior not applicable.
unsigned getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
InstrTy * getInstruction() const
EH_DWARF_CFA - This node represents the pointer to the DWARF Canonical Frame Address (CFA)...
The memory access is dereferenceable (i.e., doesn't trap).
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt) Val, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN, ptr, amt) For double-word atomic operations: ValLo, ValHi, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amtLo, amtHi) ValLo, ValHi, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN, ptr, amtLo, amtHi) These correspond to the atomicrmw instruction.
bool hasBigEndianPartOrdering(EVT VT, const DataLayout &DL) const
When splitting a value of the specified type into parts, does the Lo or Hi part come first...
static bool isRegDefEarlyClobberKind(unsigned Flag)
static unsigned convertMemFlagWordToMatchingFlagWord(unsigned InputFlag)
SDValue getEntryNode() const
Return the token chain corresponding to the entry of the function.
const DataLayout & getDataLayout() const
unsigned getDestAlignment() const
void setByValSize(unsigned S)
SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and llvm.returnaddress on the DAG...
void setFunctionContextIndex(int I)
unsigned getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
uint64_t getNumElements() const
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s, unsigned base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
unsigned getID() const
Return the register class ID number.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
zlib-gnu style compression
This file implements a class to represent arbitrary precision integral constant values and operations...
INLINEASM - Represents an inline asm block.
OutputArg - This struct carries flags and a value for a single outgoing (actual) argument or outgoing...
This represents a list of ValueType's that has been intern'd by a SelectionDAG.
unsigned getLiveInPhysReg(unsigned VReg) const
getLiveInPhysReg - If VReg is a live-in virtual register, return the corresponding live-in physical r...
SmallVector< ISD::InputArg, 32 > Ins
AtomicOrdering
Atomic ordering for LLVM's memory model.
static SDValue getCopyFromPartsVector(SelectionDAG &DAG, const SDLoc &DL, const SDValue *Parts, unsigned NumParts, MVT PartVT, EVT ValueVT, const Value *V, Optional< CallingConv::ID > CC)
getCopyFromPartsVector - Create a value that contains the specified legal parts combined into the val...
STACKSAVE - STACKSAVE has one operand, an input chain.
SDValue getMergeValues(ArrayRef< SDValue > Ops, const SDLoc &dl)
Create a MERGE_VALUES node from the given operands.
unsigned getSizeInBits() const
void assign(size_type NumElts, const T &Elt)
virtual SDValue prepareVolatileOrAtomicLoad(SDValue Chain, const SDLoc &DL, SelectionDAG &DAG) const
This callback is used to prepare for a volatile or atomic load.
auto reverse(ContainerTy &&C, typename std::enable_if< has_rbegin< ContainerTy >::value >::type *=nullptr) -> decltype(make_range(C.rbegin(), C.rend()))
ValTy * getCalledValue() const
Return the pointer to function that is being called.
void emitError(unsigned LocCookie, const Twine &ErrorStr)
emitError - Emit an error message to the currently installed error handler with optional location inf...
Value * getPointerOperand()
unsigned getActiveBits() const
Compute the number of active bits in the value.
SDValue getSExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either sign-extending or trunca...
SDValue getCopyFromRegs(SelectionDAG &DAG, FunctionLoweringInfo &FuncInfo, const SDLoc &dl, SDValue &Chain, SDValue *Flag, const Value *V=nullptr) const
Emit a series of CopyFromReg nodes that copies from this value and returns the result as a ValueVTs v...
unsigned getScalarSizeInBits() const
static BranchProbability scaleCaseProbality(BranchProbability CaseProb, BranchProbability PeeledCaseProb)
This is a fast-path instruction selection class that generates poor code and doesn't support illegal ...
Class to represent function types.
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.
static SDValue getLoadStackGuard(SelectionDAG &DAG, const SDLoc &DL, SDValue &Chain)
Create a LOAD_STACK_GUARD node, and let it carry the target specific global variable if there exists ...
FastMathFlags getFastMathFlags() const
Convenience function for getting all the fast-math flags, which must be an operator which supports th...
Type * getType() const
All values are typed, get the type of this value.
CATCHPAD - Represents a catchpad instruction.
void getCopyToRegs(SDValue Val, SelectionDAG &DAG, const SDLoc &dl, SDValue &Chain, SDValue *Flag, const Value *V=nullptr, ISD::NodeType PreferredExtendType=ISD::ANY_EXTEND) const
Emit a series of CopyToReg nodes that copies the specified value into the registers specified by this...
MachineFunction & getMachineFunction() const
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
SDValue getMaskedGather(SDVTList VTs, EVT VT, const SDLoc &dl, ArrayRef< SDValue > Ops, MachineMemOperand *MMO)
OUTCHAIN = EH_SJLJ_SETUP_DISPATCH(INCHAIN) The target initializes the dispatch table here...
const LiveOutInfo * GetLiveOutRegInfo(unsigned Reg)
GetLiveOutRegInfo - Gets LiveOutInfo for a register, returning NULL if the register is a PHI destinat...
static void normalizeProbabilities(ProbabilityIter Begin, ProbabilityIter End)
ConstantDataSequential - A vector or array constant whose element type is a simple 1/2/4/8-byte integ...
virtual bool supportSwiftError() const
Return true if the target supports swifterror attribute.
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
SDValue getTargetFrameIndex(int FI, EVT VT)
AtomicOrdering getSuccessOrdering() const
Returns the success ordering constraint of this cmpxchg instruction.
const TargetMachine & getTarget() const
const T & getValue() const LLVM_LVALUE_FUNCTION
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
const MCContext & getContext() const
Value * GetPointerBaseWithConstantOffset(Value *Ptr, int64_t &Offset, const DataLayout &DL)
Analyze the specified pointer to see if it can be expressed as a base pointer plus a constant offset...
This contains information for each constraint that we are lowering.
APInt sextOrTrunc(unsigned width) const
Sign extend or truncate to width.
Simple integer binary arithmetic operators.
bool isNoBuiltin() const
Return true if the call should not be treated as a call to a builtin.
SDValue getNonRegisterValue(const Value *V)
getNonRegisterValue - Return an SDValue for the given Value, but don't look in FuncInfo.ValueMap for a virtual register.
This instruction compares its operands according to the predicate given to the constructor.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
SmallVector< ISD::OutputArg, 32 > Outs
void setCallSiteBeginLabel(MCSymbol *BeginLabel, unsigned Site)
Map the begin label for a call site.
static void patchMatchingInput(const SDISelAsmOperandInfo &OpInfo, SDISelAsmOperandInfo &MatchingOpInfo, SelectionDAG &DAG)
Make sure that the output operand OpInfo and its corresponding input operand MatchingOpInfo have comp...
This class represents a no-op cast from one type to another.
unsigned getCurrentCallSite()
Get the call site currently being processed, if any.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
const APInt & getValue() const
Return the constant as an APInt value reference.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
bool ShouldEmitAsBranches(const std::vector< CaseBlock > &Cases)
If the set of cases should be emitted as a series of branches, return true.
static Optional< FragmentInfo > getFragmentInfo(expr_op_iterator Start, expr_op_iterator End)
Retrieve the details of this fragment expression.
SDValue lowerRangeToAssertZExt(SelectionDAG &DAG, const Instruction &I, SDValue Op)
static SDValue expandPow(const SDLoc &dl, SDValue LHS, SDValue RHS, SelectionDAG &DAG, const TargetLowering &TLI)
visitPow - Lower a pow intrinsic.
SDValue getUNDEF(EVT VT)
Return an UNDEF node. UNDEF does not have a useful SDLoc.
AttributeList getAttributes() const
Return the attribute list for this Function.
An instruction for storing to memory.
SDDbgValue * getVRegDbgValue(DIVariable *Var, DIExpression *Expr, unsigned VReg, bool IsIndirect, const DebugLoc &DL, unsigned O)
Creates a VReg SDDbgValue node.
SDValue getMaskedStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, SDValue Mask, EVT MemVT, MachineMemOperand *MMO, bool IsTruncating=false, bool IsCompressing=false)
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...
void init(GCFunctionInfo *gfi, AliasAnalysis *AA, const TargetLibraryInfo *li)
virtual const TargetInstrInfo * getInstrInfo() const
ISD::CondCode getFCmpCondCode(FCmpInst::Predicate Pred)
getFCmpCondCode - Return the ISD condition code corresponding to the given LLVM IR floating-point con...
void populateCallLoweringInfo(TargetLowering::CallLoweringInfo &CLI, ImmutableCallSite CS, unsigned ArgIdx, unsigned NumArgs, SDValue Callee, Type *ReturnTy, bool IsPatchPoint)
Populate a CallLowerinInfo (into CLI) based on the properties of the call being lowered.
READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
SDValue getTargetConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
ConstraintPrefix Type
Type - The basic type of the constraint: input/output/clobber.
virtual unsigned getInlineAsmMemConstraint(StringRef ConstraintCode) const
static bool isRegDefKind(unsigned Flag)
ArrayRef< SDUse > ops() const
SDValue getSplatBuildVector(EVT VT, const SDLoc &DL, SDValue Op)
Return a splat ISD::BUILD_VECTOR node, consisting of Op splatted to all elements. ...
SDValue getLabelNode(unsigned Opcode, const SDLoc &dl, SDValue Root, MCSymbol *Label)
void setSuccProbability(succ_iterator I, BranchProbability Prob)
Set successor probability of a given iterator.
bool findValue(const Value *V) const
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
void setStackProtectorIndex(int I)
AttributeList getAttributes() const
Return the parameter attributes for this call.
void setOrigAlign(unsigned A)
static cl::opt< unsigned > SwitchPeelThreshold("switch-peel-threshold", cl::Hidden, cl::init(66), cl::desc("Set the case probability threshold for peeling the case from a " "switch statement. A value greater than 100 will void this " "optimization"))
bool isTypeLegalForClass(const TargetRegisterClass &RC, MVT T) const
Return true if the given TargetRegisterClass has the ValueType T.
static SDValue getLimitedPrecisionExp2(SDValue t0, const SDLoc &dl, SelectionDAG &DAG)
RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) This node represents a target intrinsic fun...
amdgpu Simplify well known AMD library false Value * Callee
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
APInt getUnsignedMin() const
Return the smallest unsigned value contained in the ConstantRange.
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
void ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL, Type *Ty, SmallVectorImpl< EVT > &ValueVTs, SmallVectorImpl< uint64_t > *Offsets=nullptr, uint64_t StartingOffset=0)
ComputeValueVTs - Given an LLVM IR type, compute a sequence of EVTs that represent all the individual...
static const Value * getNotArgument(const Value *BinOp)
MVT getVectorElementType() const
Value * getOperand(unsigned i) const
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
Class to represent pointers.
void normalizeSuccProbs()
Normalize probabilities of all successors so that the sum of them becomes one.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
void append(const RegsForValue &RHS)
Add the specified values to this one.
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
bool isJumpExpensive() const
Return true if Flow Control is an expensive operation that should be avoided.
Flag
These should be considered private to the implementation of the MCInstrDesc class.
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector with the specified, possibly variable...
TargetInstrInfo - Interface to description of machine instruction set.
This corresponds to the llvm.lifetime.
MVT getSimpleValueType() const
Return the simple ValueType of the referenced return value.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
iterator find(const_arg_type_t< KeyT > Val)
Value * getOperand(unsigned i_nocapture) const
bool doesNotAccessMemory() const
Determine if the function does not access memory.
User::op_iterator op_end()
static Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
void setAttributes(ImmutableCallSite *CS, unsigned ArgIdx)
Set CallLoweringInfo attribute flags based on a call instruction and called function attributes...
bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal=false)
Checks whether the given location points to constant memory, or if OrLocal is true whether it points ...
bool isVoidTy() const
Return true if this is 'void'.
The memory access is volatile.
const BasicBlock & getEntryBlock() const
constexpr uint64_t MinAlign(uint64_t A, uint64_t B)
A and B are either alignments or offsets.
unsigned getNumValues() const
Return the number of values defined/returned by this operator.
an instruction for type-safe pointer arithmetic to access elements of arrays and structs ...
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...
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
void getAAMetadata(AAMDNodes &N, bool Merge=false) const
Fills the AAMDNodes structure with AA metadata from this instruction.
void setIsEHScopeEntry(bool V=true)
Indicates if this is the entry block of an EH scope, i.e., the block that that used to have a catchpa...
SDDbgValue * getConstantDbgValue(DIVariable *Var, DIExpression *Expr, const Value *C, const DebugLoc &DL, unsigned O)
Creates a constant SDDbgValue node.
unsigned getObjectAlignment(int ObjectIdx) const
Return the alignment of the specified stack object.
SDValue getMDNode(const MDNode *MD)
Return an MDNodeSDNode which holds an MDNode.
initializer< Ty > init(const Ty &Val)
bool bitsGE(EVT VT) const
Return true if this has no less bits than VT.
SDValue getVectorShuffle(EVT VT, const SDLoc &dl, SDValue N1, SDValue N2, ArrayRef< int > Mask)
Return an ISD::VECTOR_SHUFFLE node.
Type * getReturnType() const
Returns the type of the ret val.
std::pair< SDValue, SDValue > lowerInvokable(TargetLowering::CallLoweringInfo &CLI, const BasicBlock *EHPadBB=nullptr)
static MachinePointerInfo getUnknownStack(MachineFunction &MF)
Stack memory without other information.
SmallVector< SDValue, 4 > InVals
std::vector< AsmOperandInfo > AsmOperandInfoVector
OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...) This node represents a target intrin...
These reductions are non-strict, and have a single vector operand.
MVT getSimpleValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
Return the MVT corresponding to this LLVM type. See getValueType.
virtual bool isSuitableForJumpTable(const SwitchInst *SI, uint64_t NumCases, uint64_t Range) const
Return true if lowering to a jump table is suitable for a set of case clusters which may contain NumC...
The landingpad instruction holds all of the information necessary to generate correct exception handl...
const Instruction * getFirstNonPHI() const
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
Control flow instructions. These all have token chains.
MCSymbol * createTempSymbol(bool CanBeUnnamed=true)
Create and return a new assembler temporary symbol with a unique but unspecified name.
READ_REGISTER, WRITE_REGISTER - This node represents llvm.register on the DAG, which implements the n...
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Subclasses of this class are all able to terminate a basic block.
Value * getVariableLocation(bool AllowNullOp=true) const
Get the location corresponding to the variable referenced by the debug info intrinsic.
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this rmw instruction.
bool isStrictlyPositive() const
Determine if this APInt Value is positive.
unsigned const MachineRegisterInfo * MRI
std::size_t countTrailingZeros(T Val, ZeroBehavior ZB=ZB_Width)
Count number of 0's from the least significant bit to the most stopping at the first 1...
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...
virtual unsigned getExceptionPointerRegister(const Constant *PersonalityFn) const
If a physical register, this returns the register that receives the exception address on entry to an ...
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
LOCAL_RECOVER - Represents the llvm.localrecover intrinsic.
ConstantRange getConstantRangeFromMetadata(const MDNode &RangeMD)
Parse out a conservative ConstantRange from !range metadata.
LLVM Basic Block Representation.
void addInvoke(MachineBasicBlock *LandingPad, MCSymbol *BeginLabel, MCSymbol *EndLabel)
Provide the begin and end labels of an invoke style call and associate it with a try landing pad bloc...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
The instances of the Type class are immutable: once they are created, they are never changed...
const SelectionDAGTargetInfo & getSelectionDAGInfo() const
This is an important class for using LLVM in a threaded context.
void RemoveStackObject(int ObjectIdx)
Remove or mark dead a statically sized stack object.
virtual ConstraintType getConstraintType(StringRef Constraint) const
Given a constraint, return the type of constraint it is for this target.
Simple binary floating point operators.
Conditional or Unconditional Branch instruction.
static AttributeList getReturnAttrs(TargetLowering::CallLoweringInfo &CLI)
Returns an AttributeList representing the attributes applied to the return value of the given call...
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
unsigned getScalarSizeInBits() const
This function has undefined behavior.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
bool hasEHFunclets() const
VAEND, VASTART - VAEND and VASTART have three operands: an input chain, pointer, and a SRCVALUE...
Resume the propagation of an exception.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
const SDValue & getOperand(unsigned Num) const
Value * getCompareOperand()
unsigned getNumContainedTypes() const
Return the number of types in the derived type.
INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element at IDX replaced with VAL...
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...
const Instruction & front() const
Indirect Branch Instruction.
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.
SDValue getCALLSEQ_START(SDValue Chain, uint64_t InSize, uint64_t OutSize, const SDLoc &DL)
Return a new CALLSEQ_START node, that starts new call frame, in which InSize bytes are set up inside ...
SDValue getAddrSpaceCast(const SDLoc &dl, EVT VT, SDValue Ptr, unsigned SrcAS, unsigned DestAS)
Return an AddrSpaceCastSDNode.
void dropDanglingDebugInfo(const DILocalVariable *Variable, const DIExpression *Expr)
If we have dangling debug info that describes Variable, or an overlapping part of variable considerin...
int getStackProtectorIndex() const
Return the index for the stack protector object.
virtual SDValue emitStackGuardXorFP(SelectionDAG &DAG, SDValue Val, const SDLoc &DL) const
BasicBlock * getDefaultDest() const
User::op_iterator op_begin()
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...
APInt getUnsignedMax() const
Return the largest unsigned value contained in the ConstantRange.
static unsigned getNumOperandRegisters(unsigned Flag)
getNumOperandRegisters - Extract the number of registers field from the inline asm operand flag...
A udiv or sdiv instruction, which can be marked as "exact", indicating that no bits are destroyed...
bool isValidLocationForIntrinsic(const DILocation *DL) const
Check that a location is valid for this variable.
EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
bool isFast() const
'Fast' means all bits are set.
This file declares a class to represent arbitrary precision floating point values and provide a varie...
static Type * getVoidTy(LLVMContext &C)
DILocalVariable * getVariable() const
INIT_TRAMPOLINE - This corresponds to the init_trampoline intrinsic.
virtual bool areJTsAllowed(const Function *Fn) const
Return true if lowering to a jump table is allowed.
const Instruction & back() const
bool optForSize() const
Optimize this function for size (-Os) or minimum size (-Oz).
This instruction compares its operands according to the predicate given to the constructor.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Utility class for integer operators which may exhibit overflow - Add, Sub, Mul, and Shl...
void print(raw_ostream &O, bool IsForDebug=false) const
Implement operator<< on Value.
void ReplaceAllUsesWith(SDValue From, SDValue To)
Modify anything using 'From' to use 'To' instead.
TRAP - Trapping instruction.
const Triple & getTargetTriple() const
DIExpression * getExpression() const
Value * getPointerOperand()
AssertSext, AssertZext - These nodes record if a register contains a value that has already been zero...
Base class for variables.
DEBUGTRAP - Trap intended to get the attention of a debugger.
static bool isNot(const Value *V)
virtual MVT getFenceOperandTy(const DataLayout &DL) const
Return the type for operands of fence.
SDNode * getGluedNode() const
If this node has a glue operand, return the node to which the glue operand points.
void reserve(size_type NumEntries)
Grow the densemap so that it can contain at least NumEntries items before resizing again...
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
SDValue getMemIntrinsicNode(unsigned Opcode, const SDLoc &dl, SDVTList VTList, ArrayRef< SDValue > Ops, EVT MemVT, MachinePointerInfo PtrInfo, unsigned Align=0, MachineMemOperand::Flags Flags=MachineMemOperand::MOLoad|MachineMemOperand::MOStore, unsigned Size=0)
Creates a MemIntrinsicNode that may produce a result and takes a list of operands.
The memory access is non-temporal.
bool isFullSet() const
Return true if this set contains all of the elements possible for this data-type. ...
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
Constant Vector Declarations.
virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const
This callback is invoked for operations that are unsupported by the target, which are registered to u...
bool isOperationLegal(unsigned Op, EVT VT) const
Return true if the specified operation is legal on this target.
static unsigned getFlagWordForMem(unsigned InputFlag, unsigned Constraint)
Augment an existing flag word returned by getFlagWord with the constraint code for a memory constrain...
SDValue getMaskedLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, SDValue Mask, SDValue Src0, EVT MemVT, MachineMemOperand *MMO, ISD::LoadExtType, bool IsExpanding=false)
Constant * ConstantFoldLoadFromConstPtr(Constant *C, Type *Ty, const DataLayout &DL)
ConstantFoldLoadFromConstPtr - Return the value that a load from C would produce if it is constant an...
auto remove_if(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
Provide wrappers to std::remove_if which take ranges instead of having to pass begin/end explicitly...
const MachineInstrBuilder & addFrameIndex(int Idx) const
static double log2(double V)
Bit counting operators with an undefined result for zero inputs.
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
bool supportsUnalignedAtomics() const
Whether the target supports unaligned atomic operations.
Targets can subclass this to parameterize the SelectionDAG lowering and instruction selection process...
virtual EVT getTypeForExtReturn(LLVMContext &Context, EVT VT, ISD::NodeType) const
Return the type that should be used to zero or sign extend a zeroext/signext integer return value...
succ_iterator succ_begin()
static SDValue ExpandPowI(const SDLoc &DL, SDValue LHS, SDValue RHS, SelectionDAG &DAG)
ExpandPowI - Expand a llvm.powi intrinsic.
std::vector< ArgListEntry > ArgListTy
static bool isMemKind(unsigned Flag)
detail::zippy< detail::zip_first, T, U, Args... > zip_first(T &&t, U &&u, Args &&... args)
zip iterator that, for the sake of efficiency, assumes the first iteratee to be the shortest...
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs, and aliases.
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this cmpxchg instruction.
Attribute getAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return the attribute object that exists at the given index.
bool isAlignStack() const
BasicBlock * getSuccessor(unsigned i) const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
uint32_t getElementSizeInBytes() const
const Value * getArraySize() const
Get the number of elements allocated.
This structure contains all information that is necessary for lowering calls.
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
AtomicOrdering getOrdering() const
Returns the ordering constraint of this rmw instruction.
This class contains a discriminated union of information about pointers in memory operands...
virtual bool useStackGuardXorFP() const
If this function returns true, stack protection checks should XOR the frame pointer (or whichever poi...
unsigned getNumOperands() const
Return the number of values used by this operation.
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
static void GetRegistersForValue(SelectionDAG &DAG, const TargetLowering &TLI, const SDLoc &DL, SDISelAsmOperandInfo &OpInfo, SDISelAsmOperandInfo &RefOpInfo)
GetRegistersForValue - Assign registers (virtual or physical) for the specified operand.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
LLVM_READONLY APFloat maxnum(const APFloat &A, const APFloat &B)
Implements IEEE maxNum semantics.
EVT getValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
Return the EVT corresponding to this LLVM type.
SDLoc getCurSDLoc() const
SDValue getAtomicCmpSwap(unsigned Opcode, const SDLoc &dl, EVT MemVT, SDVTList VTs, SDValue Chain, SDValue Ptr, SDValue Cmp, SDValue Swp, MachinePointerInfo PtrInfo, unsigned Alignment, AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering, SyncScope::ID SSID)
Gets a node for an atomic cmpxchg op.
static SDValue expandExp(const SDLoc &dl, SDValue Op, SelectionDAG &DAG, const TargetLowering &TLI)
expandExp - Lower an exp intrinsic.
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
bool isInTailCallPosition(ImmutableCallSite CS, const TargetMachine &TM)
Test if the given instruction is in a position to be optimized with a tail-call.
SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr)
Loads are not normal binary operators: their result type is not determined by their operands...
Triple - Helper class for working with autoconf configuration names.
BranchProbability getEdgeProbability(const BasicBlock *Src, unsigned IndexInSuccessors) const
Get an edge's probability, relative to other out-edges of the Src.
void sort(IteratorTy Start, IteratorTy End)
TargetIntrinsicInfo - Interface to description of machine instruction set.
The memory access writes data.
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
static bool isVectorReductionOp(const User *I)
Checks if the given instruction performs a vector reduction, in which case we have the freedom to alt...
unsigned getVectorTypeBreakdown(LLVMContext &Context, EVT VT, EVT &IntermediateVT, unsigned &NumIntermediates, MVT &RegisterVT) const
Vector types are broken down into some number of legal first class types.
SDDbgValue * getDbgValue(DIVariable *Var, DIExpression *Expr, SDNode *N, unsigned R, bool IsIndirect, const DebugLoc &DL, unsigned O)
Creates a SDDbgValue node.
virtual void LowerOperationWrapper(SDNode *N, SmallVectorImpl< SDValue > &Results, SelectionDAG &DAG) const
This callback is invoked by the type legalizer to legalize nodes with an illegal operand type but leg...
bool isEmptySet() const
Return true if this set contains no members.
void CopyToExportRegsIfNeeded(const Value *V)
CopyToExportRegsIfNeeded - If the given value has virtual registers created for it, emit nodes to copy the value into the virtual registers.
void GetReturnInfo(CallingConv::ID CC, Type *ReturnType, AttributeList attr, SmallVectorImpl< ISD::OutputArg > &Outs, const TargetLowering &TLI, const DataLayout &DL)
Given an LLVM IR type and return type attributes, compute the return value EVTs and flags...
Given one NaN input, returns the non-NaN.
SDValue getBitcast(EVT VT, SDValue V)
Return a bitcast using the SDLoc of the value operand, and casting to the provided type...
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
Representation for a specific memory location.
virtual MVT hasFastEqualityCompare(unsigned NumBits) const
Return the preferred operand type if the target has a quick way to compare integer values of the give...
TokenFactor - This node takes multiple tokens as input and produces a single token result...
void visitSPDescriptorFailure(StackProtectorDescriptor &SPD)
Codegen the failure basic block for a stack protector check.
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
static const fltSemantics & IEEEsingle() LLVM_READNONE
const TargetLowering & getTargetLoweringInfo() const
Iterator for intrusive lists based on ilist_node.
unsigned getNumOperands() const
virtual unsigned getNumRegistersForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const
Certain targets require unusual breakdowns of certain types.
void setNoUnsignedWrap(bool b)
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
static SDValue GetSignificand(SelectionDAG &DAG, SDValue Op, const SDLoc &dl)
GetSignificand - Get the significand and build it into a floating-point number with exponent of 1: ...
unsigned countPopulation(T Value)
Count the number of set bits in a value.
void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the generic address space (address sp...
This is the shared class of boolean and integer constants.
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
virtual std::pair< SDValue, SDValue > EmitTargetCodeForStrcpy(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Dest, SDValue Src, MachinePointerInfo DestPtrInfo, MachinePointerInfo SrcPtrInfo, bool isStpcpy) const
Emit target-specific code that performs a strcpy or stpcpy, in cases where that is faster than a libc...
static uint32_t getDenominator()
SmallVector< unsigned, 4 > RegCount
This list holds the number of registers for each value.
Returns platform specific canonical encoding of a floating point number.
ValTy * getArgument(unsigned ArgNo) const
virtual bool allowsMisalignedMemoryAccesses(EVT, unsigned AddrSpace=0, unsigned Align=1, bool *=nullptr) const
Determine if the target supports unaligned memory accesses.
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
bool isFuncletEHPersonality(EHPersonality Pers)
Returns true if this is a personality function that invokes handler funclets (which must return to it...
EVT getVectorElementType() const
Given a vector type, return the type of each element.
virtual const char * getClearCacheBuiltinName() const
Return the builtin name for the __builtin___clear_cache intrinsic Default is to invoke the clear cach...
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
SDDbgValue * getFrameIndexDbgValue(DIVariable *Var, DIExpression *Expr, unsigned FI, bool IsIndirect, const DebugLoc &DL, unsigned O)
Creates a FrameIndex SDDbgValue node.
MSVC calling convention that passes vectors and vector aggregates in SSE registers.
SDValue getZExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either zero-extending or trunca...
RegsForValue - This struct represents the registers (physical or virtual) that a particular set of va...
CallLoweringInfo & setCallee(CallingConv::ID CC, Type *ResultType, SDValue Target, ArgListTy &&ArgsList)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Utility class for floating point operations which can have information about relaxed accuracy require...
Module.h This file contains the declarations for the Module class.
SDValue getBuildVector(EVT VT, const SDLoc &DL, ArrayRef< SDValue > Ops)
Return an ISD::BUILD_VECTOR node.
Provides information about what library functions are available for the current target.
void clear()
Clear out the current SelectionDAG and the associated state and prepare this SelectionDAGBuilder obje...
SDValue getMemcpy(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, bool isVol, bool AlwaysInline, bool isTailCall, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo)
This class represents a range of values.
static SDValue getF32Constant(SelectionDAG &DAG, unsigned Flt, const SDLoc &dl)
getF32Constant - Get 32-bit floating point constant.
This is the common base class for debug info intrinsics.
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
BRCOND - Conditional branch.
bool isAggregateType() const
Return true if the type is an aggregate type.
bool isOSLinux() const
Tests whether the OS is Linux.
An SDNode that represents everything that will be needed to construct a MachineInstr.
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
Byte Swap and Counting operators.
void setCallsEHReturn(bool b)
void visit(const Instruction &I)
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
bool rangeFitsInWord(const APInt &Low, const APInt &High, const DataLayout &DL) const
Check whether the range [Low,High] fits in a machine word.
SDValue getMemmove(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, bool isVol, bool isTailCall, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo)
const WinEHFuncInfo * getWinEHFuncInfo() const
getWinEHFuncInfo - Return information about how the current function uses Windows exception handling...
static bool isOnlyUsedInEntryBlock(const Argument *A, bool FastISel)
isOnlyUsedInEntryBlock - If the specified argument is only used in the entry block, return true.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
uint64_t scale(uint64_t Num) const
Scale a large integer.
void addIPToStateRange(const InvokeInst *II, MCSymbol *InvokeBegin, MCSymbol *InvokeEnd)
static Optional< CallingConv::ID > getABIRegCopyCC(const Value *V)
Represents one node in the SelectionDAG.
Value * getRawSource() const
Return the arguments to the instruction.
static SDValue expandLog(const SDLoc &dl, SDValue Op, SelectionDAG &DAG, const TargetLowering &TLI)
expandLog - Lower a log intrinsic.
void UpdateSplitBlock(MachineBasicBlock *First, MachineBasicBlock *Last)
UpdateSplitBlock - When an MBB was split during scheduling, update the references that need to refer ...
unsigned getEVTAlignment(EVT MemoryVT) const
Compute the default alignment value for the given type.
static ConstantInt * getTrue(LLVMContext &Context)
ISD::CondCode getFCmpCodeWithoutNaN(ISD::CondCode CC)
getFCmpCodeWithoutNaN - Given an ISD condition code comparing floats, return the equivalent code if w...
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 logBase2() const
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
unsigned getVectorNumElements() const
Class to represent vector types.
SmallVector< std::pair< unsigned, unsigned >, 4 > getRegsAndSizes() const
Return a list of registers and their sizes.
static const unsigned MaxParallelChains
static EVT getVectorVT(LLVMContext &Context, EVT VT, unsigned NumElements, bool IsScalable=false)
Returns the EVT that represents a vector NumElements in length, where each element is of type VT...
Target - Wrapper for Target specific information.
bool isTypeLegal(EVT VT) const
Return true if the target has native support for the specified value type.
Class for arbitrary precision integers.
virtual void ComputeConstraintToUse(AsmOperandInfo &OpInfo, SDValue Op, SelectionDAG *DAG=nullptr) const
Determines the constraint code and constraint type to use for the specific AsmOperandInfo, setting OpInfo.ConstraintCode and OpInfo.ConstraintType.
static StringRef dropLLVMManglingEscape(StringRef Name)
If the given string begins with the GlobalValue name mangling escape character '\1', drop it.
SDValue getConstantFP(double Val, const SDLoc &DL, EVT VT, bool isTarget=false)
Create a ConstantFPSDNode wrapping a constant value.
bool fragmentsOverlap(const DIExpression *Other) const
Check if fragments overlap between this DIExpression and Other.
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
Select(COND, TRUEVAL, FALSEVAL).
bool bitsLT(EVT VT) const
Return true if this has less bits than VT.
bool isPowerOf2() const
Check if this APInt's value is a power of two greater than zero.
iterator_range< user_iterator > users()
ZERO_EXTEND - Used for integer types, zeroing the new bits.
void AddDbgLabel(SDDbgLabel *DB)
Add a dbg_label SDNode.
ANY_EXTEND - Used for integer types. The high bits are undefined.
virtual std::pair< SDValue, SDValue > EmitTargetCodeForStrlen(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Src, MachinePointerInfo SrcPtrInfo) const
virtual bool isFMAFasterThanFMulAndFAdd(EVT) const
Return true if an FMA operation is faster than a pair of fmul and fadd instructions.
FCOPYSIGN(X, Y) - Return the value of X with the sign of Y.
FMINNAN/FMAXNAN - Behave identically to FMINNUM/FMAXNUM, except that when a single input is NaN...
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
const MCPhysReg * iterator
SDValue getBlockAddress(const BlockAddress *BA, EVT VT, int64_t Offset=0, bool isTarget=false, unsigned char TargetFlags=0)
void setIsEHFuncletEntry(bool V=true)
Indicates if this is the entry block of an EH funclet.
virtual Value * getSSPStackGuardCheck(const Module &M) const
If the target has a standard stack protection check function that performs validation and error handl...
virtual std::pair< SDValue, SDValue > EmitTargetCodeForMemcmp(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Op1, SDValue Op2, SDValue Op3, MachinePointerInfo Op1PtrInfo, MachinePointerInfo Op2PtrInfo) const
Emit target-specific code that performs a memcmp, in cases where that is faster than a libcall...
CATCHRET - Represents a return from a catch block funclet.
static void getCopyToParts(SelectionDAG &DAG, const SDLoc &DL, SDValue Val, SDValue *Parts, unsigned NumParts, MVT PartVT, const Value *V, Optional< CallingConv::ID > CallConv=None, ISD::NodeType ExtendKind=ISD::ANY_EXTEND)
getCopyToParts - Create a series of nodes that contain the specified value split into legal parts...
amdgpu Simplify well known AMD library false Value Value * Arg
SmallVector< SDValue, 8 > PendingLoads
PendingLoads - Loads are not emitted to the program immediately.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
The memory access reads data.
static void tryToElideArgumentCopy(FunctionLoweringInfo *FuncInfo, SmallVectorImpl< SDValue > &Chains, DenseMap< int, int > &ArgCopyElisionFrameIndexMap, SmallPtrSetImpl< const Instruction *> &ElidedArgCopyInstrs, ArgCopyElisionMapTy &ArgCopyElisionCandidates, const Argument &Arg, SDValue ArgVal, bool &ArgHasUses)
Try to elide argument copies from memory into a local alloca.
bool isStrictFP() const
Determine if the call requires strict floating point semantics.
SDDbgLabel * getDbgLabel(DILabel *Label, const DebugLoc &DL, unsigned O)
Creates a SDDbgLabel node.
uint64_t getTypeSizeInBits(Type *Ty) const
Size examples:
GET_DYNAMIC_AREA_OFFSET - get offset from native SP to the address of the most recent dynamic alloca...
std::pair< SDValue, SDValue > LowerCallTo(CallLoweringInfo &CLI) const
This function lowers an abstract call to a function into an actual call.
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
CallLoweringInfo & setTailCall(bool Value=true)
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
bool isDereferenceablePointer(const Value *V, const DataLayout &DL, const Instruction *CtxI=nullptr, const DominatorTree *DT=nullptr)
Return true if this is always a dereferenceable pointer.
BR_JT - Jumptable branch.
VACOPY - VACOPY has 5 operands: an input chain, a destination pointer, a source pointer, a SRCVALUE for the destination, and a SRCVALUE for the source.
Predicate getPredicate() const
Return the predicate for this instruction.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
These are IR-level optimization flags that may be propagated to SDNodes.
Represents a use of a SDNode.
CallLoweringInfo & setConvergent(bool Value=true)
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
SmallVector< SDValue, 32 > OutVals
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this fence instruction.
bool hasGC() const
hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm to use during code generatio...
bool isVolatile() const
Return true if this is a store to a volatile memory location.
Analysis providing branch probability information.
bool isVector() const
Return true if this is a vector value type.
Bitwise operators - logical and, logical or, logical xor.
Holds the information from a dbg_label node through SDISel.
static SDValue GetExponent(SelectionDAG &DAG, SDValue Op, const TargetLowering &TLI, const SDLoc &dl)
GetExponent - Get the exponent:
pointer data()
Return a pointer to the vector's buffer, even if empty().
const Function * getParent() const
SDValue getCopyFromReg(SDValue Chain, const SDLoc &dl, unsigned Reg, EVT VT)
unsigned getAlignment() const
Return the alignment of the access that is being performed.
std::pair< SDValue, SDValue > makeLibCall(SelectionDAG &DAG, RTLIB::Libcall LC, EVT RetVT, ArrayRef< SDValue > Ops, bool isSigned, const SDLoc &dl, bool doesNotReturn=false, bool isReturnValueUsed=true) const
Returns a pair of (return value, chain).
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
LLVM_NODISCARD bool empty() const
unsigned getNumArgOperands() const
Return the number of call arguments.
StringRef getValueAsString() const
Return the attribute's value as a string.
AtomicOrdering getOrdering() const
Returns the ordering constraint of this store instruction.
This represents the llvm.dbg.value instruction.
bool isTokenTy() const
Return true if this is 'token'.
This file provides utility analysis objects describing memory locations.
Value * getPointerOperand()
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
virtual EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context, EVT VT) const
Return the ValueType of the result of SETCC operations.
Establish a view to a call site for examination.
const Function * getParent() const
Return the enclosing method, or null if none.
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this load instruction.
void push_back(MachineInstr *MI)
const TargetSubtargetInfo & getSubtarget() const
FunctionLoweringInfo - This contains information that is global to a function that is used when lower...
static void addStackMapLiveVars(ImmutableCallSite CS, unsigned StartIdx, const SDLoc &DL, SmallVectorImpl< SDValue > &Ops, SelectionDAGBuilder &Builder)
Add a stack map intrinsic call's live variable operands to a stackmap or patchpoint target node's ope...
bool optForMinSize() const
Optimize this function for minimum size (-Oz).
static Constant * getZeroValueForNegation(Type *Ty)
Floating point negation must be implemented with f(x) = -0.0 - x.
virtual const TargetFrameLowering * getFrameLowering() const
The memory access always returns the same value (or traps).
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
unsigned InferPtrAlignment(SDValue Ptr) const
Infer alignment of a load / store address.
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Value * getCatchSwitchParentPad() const
Get the parentPad of this catchret's catchpad's catchswitch.
iterator_range< const_phi_iterator > phis() const
Returns a range that iterates over the phis in the basic block.
unsigned getOpcode() const
SDValue getValue(unsigned R) const
virtual Value * getSDagStackGuard(const Module &M) const
Return the variable that's previously inserted by insertSSPDeclarations, if any, otherwise return nul...
virtual MachineMemOperand::Flags getMMOFlags(const Instruction &I) const
This callback is used to inspect load/store instructions and add target-specific MachineMemOperand fl...
bool isUnconditional() const
DenseMap< const AllocaInst *, int > StaticAllocaMap
StaticAllocaMap - Keep track of frame indices for fixed sized allocas in the entry block...
unsigned getNumRegisters(LLVMContext &Context, EVT VT) const
Return the number of registers that this ValueType will eventually require.
RESULT, OUTCHAIN = EH_SJLJ_SETJMP(INCHAIN, buffer) This corresponds to the eh.sjlj.setjmp intrinsic.
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
unsigned getAlignment() const
Return the alignment of the access that is being performed.
SDValue getAtomicMemmove(SDValue Chain, const SDLoc &dl, SDValue Dst, unsigned DstAlign, SDValue Src, unsigned SrcAlign, SDValue Size, Type *SizeTy, unsigned ElemSz, bool isTailCall, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo)
LLVM_NODISCARD bool empty() const
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.
Type * getType() const
Return the type of the instruction that generated this call site.
SDValue getCopyFromRegs(const Value *V, Type *Ty)
getCopyFromRegs - If there was virtual register allocated for the value V emit CopyFromReg of the spe...
bool isReg() const
isReg - Tests if this is a MO_Register operand.
OutputIt transform(R &&Range, OutputIt d_first, UnaryPredicate P)
Wrapper function around std::transform to apply a function to a range and store the result elsewhere...
SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
bool isMinValue() const
Determine if this is the smallest unsigned value.
OUTCHAIN = EH_RETURN(INCHAIN, OFFSET, HANDLER) - This node represents 'eh_return' gcc dwarf builtin...
AsmDialect getDialect() const
void setIsImmutableObjectIndex(int ObjectIdx, bool IsImmutable)
Marks the immutability of an object.
SDValue getAtomic(unsigned Opcode, const SDLoc &dl, EVT MemVT, SDValue Chain, SDValue Ptr, SDValue Val, const Value *PtrVal, unsigned Alignment, AtomicOrdering Ordering, SyncScope::ID SSID)
Gets a node for an atomic op, produces result (if relevant) and chain and takes 2 operands...
bool isStatepoint(ImmutableCallSite CS)
SDValue getVAArg(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, SDValue SV, unsigned Align)
VAArg produces a result and token chain, and takes a pointer and a source value as input...
void GetUnderlyingObjects(Value *V, SmallVectorImpl< Value *> &Objects, const DataLayout &DL, LoopInfo *LI=nullptr, unsigned MaxLookup=6)
This method is similar to GetUnderlyingObject except that it can look through phi and select instruct...
virtual unsigned getMinimumJumpTableEntries() const
Return lower limit for number of blocks in a jump table.
void LowerCallTo(ImmutableCallSite CS, SDValue Callee, bool IsTailCall, const BasicBlock *EHPadBB=nullptr)
CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of vector type with the same length ...
const Value * getCalledValue() const
Get a pointer to the function that is invoked by this instruction.
SmallVector< MVT, 4 > RegVTs
The value types of the registers.
SDValue getJumpTable(int JTI, EVT VT, bool isTarget=false, unsigned char TargetFlags=0)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const BasicBlock & front() const
unsigned getNumSuccessors() const
Return the number of successors that this terminator has.
void insert(iterator MBBI, MachineBasicBlock *MBB)
SDValue getFrameIndex(int FI, EVT VT, bool isTarget=false)
bool isAsynchronousEHPersonality(EHPersonality Pers)
Returns true if this personality function catches asynchronous exceptions.
static bool createVirtualRegs(SmallVector< unsigned, 4 > &Regs, unsigned NumRegs, MVT RegVT, SelectionDAG &DAG)
Fill Regs with NumRegs new virtual registers of type RegVT.
Given one NaN input, returns the NaN.
SmallVector< int, 16 > getShuffleMask() const
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th call argument.
static SDValue getMemCmpLoad(const Value *PtrVal, MVT LoadVT, SelectionDAGBuilder &Builder)
bool isSingleValueType() const
Return true if the type is a valid type for a register in codegen.
static void findUnwindDestinations(FunctionLoweringInfo &FuncInfo, const BasicBlock *EHPadBB, BranchProbability Prob, SmallVectorImpl< std::pair< MachineBasicBlock *, BranchProbability >> &UnwindDests)
When an invoke or a cleanupret unwinds to the next EH pad, there are many places it could ultimately ...
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.
FMA - Perform a * b + c with no intermediate rounding step.
SDValue getRegister(unsigned Reg, EVT VT)
unsigned getResNo() const
get the index which selects a specific result in the SDNode
SDValue getAnyExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either any-extending or truncat...
FMIN/FMAX nodes can have flags, for NaN/NoNaN variants.
uint64_t getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
SelectPatternResult matchSelectPattern(Value *V, Value *&LHS, Value *&RHS, Instruction::CastOps *CastOp=nullptr, unsigned Depth=0)
Pattern match integer [SU]MIN, [SU]MAX and ABS idioms, returning the kind and providing the out param...
FunctionType * getFunctionType() const
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
static VectorType * get(Type *ElementType, unsigned NumElements)
This static method is the primary way to construct an VectorType.
void setDebugLoc(DebugLoc dl)
Set source location info.
unsigned getStackPointerRegisterToSaveRestore() const
If a physical register, this specifies the register that llvm.savestack/llvm.restorestack should save...
SDValue getValueType(EVT)
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
SDValue getFPExtendOrRound(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of float type, to the float type VT, by either extending or rounding (by tr...
PREFETCH - This corresponds to a prefetch intrinsic.
static const Function * getParent(const Value *V)
void AddInlineAsmOperands(unsigned Code, bool HasMatching, unsigned MatchingIdx, const SDLoc &dl, SelectionDAG &DAG, std::vector< SDValue > &Ops) const
Add this value to the specified inlineasm node operand list.
const Value * getCalledValue() const
Get a pointer to the function that is invoked by this instruction.
MVT getFrameIndexTy(const DataLayout &DL) const
Return the type for frame index, which is determined by the alloca address space specified through th...
SDValue getEHLabel(const SDLoc &dl, SDValue Root, MCSymbol *Label)
unsigned countMinLeadingZeros() const
Returns the minimum number of leading zero bits.
Type * getElementType() const
SDValue getSrcValue(const Value *v)
Construct a node to track a Value* through the backend.
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 hasNoNaNs() const
Determine whether the no-NaNs flag is set.
bool hasOneUse() const
Return true if there is exactly one user of this value.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
Convenience struct for specifying and reasoning about fast-math flags.
StringRef - Represent a constant reference to a string, i.e.
Garbage collection metadata for a single function.
void clearDanglingDebugInfo()
Clear the dangling debug information map.
unsigned TrapUnreachable
Emit target-specific trap instruction for 'unreachable' IR instructions.
static cl::opt< unsigned, true > LimitFPPrecision("limit-float-precision", cl::desc("Generate low-precision inline sequences " "for some float libcalls"), cl::location(LimitFloatPrecision), cl::Hidden, cl::init(0))
const Instruction * getFirstNonPHIOrDbg() const
Returns a pointer to the first instruction in this block that is not a PHINode or a debug intrinsic...
AtomicOrdering getOrdering() const
Returns the ordering constraint of this fence instruction.
static BranchProbability getZero()
bool isConvergent() const
Determine if the call is convergent.
bool isEmptyTy() const
Return true if this type is empty, that is, it has no elements or all of its elements are empty...
static SDValue expandLog10(const SDLoc &dl, SDValue Op, SelectionDAG &DAG, const TargetLowering &TLI)
expandLog10 - Lower a log10 intrinsic.
MERGE_VALUES - This node takes multiple discrete operands and returns them all as its individual resu...
static bool isVolatile(Instruction *Inst)
static APInt getNullValue(unsigned numBits)
Get the '0' value.
void addCodeViewAnnotation(MCSymbol *Label, MDNode *MD)
Record annotations associated with a particular label.
const SDValue & getOperand(unsigned i) const
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...
OUTCHAIN = ATOMIC_STORE(INCHAIN, ptr, val) This corresponds to "store atomic" instruction.
const Value * stripInBoundsConstantOffsets() const
Strip off pointer casts and all-constant inbounds GEPs.
TRUNCATE - Completely drop the high bits.
SDValue getObjectPtrOffset(const SDLoc &SL, SDValue Op, int64_t Offset)
Create an add instruction with appropriate flags when used for addressing some offset of an object...
bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
for(unsigned i=Desc.getNumOperands(), e=OldMI.getNumOperands();i !=e;++i)
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
unsigned ComputeLinearIndex(Type *Ty, const unsigned *Indices, const unsigned *IndicesEnd, unsigned CurIndex=0)
Compute the linearized index of a member in a nested aggregate/struct/array.
bool isExportableFromCurrentBlock(const Value *V, const BasicBlock *FromBB)
Holds the information from a dbg_value node through SDISel.
virtual SDValue LowerReturn(SDValue, CallingConv::ID, bool, const SmallVectorImpl< ISD::OutputArg > &, const SmallVectorImpl< SDValue > &, const SDLoc &, SelectionDAG &) const
This hook must be implemented to lower outgoing return values, described by the Outs array...
FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW, FLOG, FLOG2, FLOG10, FEXP, FEXP2, FCEIL, FTRUNC, FRINT, FNEARBYINT, FROUND, FFLOOR - Perform various unary floating point operations.
static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)
Returns the EVT that represents an integer with the given number of bits.
SmallVector< unsigned, 4 > Regs
This list holds the registers assigned to the values.
Value * getPointerOperand()
MachineInstr::mmo_iterator allocateMemRefsArray(unsigned long Num)
allocateMemRefsArray - Allocate an array to hold MachineMemOperand pointers.
virtual bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const
Returns true if a cast between SrcAS and DestAS is a noop.
SDValue getMemset(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, bool isVol, bool isTailCall, MachinePointerInfo DstPtrInfo)
Val, OUTCHAIN = ATOMIC_LOAD(INCHAIN, ptr) This corresponds to "load atomic" instruction.
Value * getRawDest() const
static MachineOperand CreateFI(int Idx)
uint32_t getNumerator() const
void visitBitTestHeader(BitTestBlock &B, MachineBasicBlock *SwitchBB)
visitBitTestHeader - This function emits necessary code to produce value suitable for "bit tests" ...
LocationClass< Ty > location(Ty &L)
LLVMContext * getContext() const
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Type * getElementType() const
LLVM_READONLY APFloat minnum(const APFloat &A, const APFloat &B)
Implements IEEE minNum semantics.
CallLoweringInfo & setLibCallee(CallingConv::ID CC, Type *ResultType, SDValue Target, ArgListTy &&ArgsList)
std::vector< MachineBasicBlock * >::iterator succ_iterator
EVT getShiftAmountTy(EVT LHSTy, const DataLayout &DL, bool LegalTypes=true) const
static BranchProbability getBranchProbStackProtector(bool IsLikely)
unsigned createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
void resolveDanglingDebugInfo(const Value *V, SDValue Val)
static AttributeList get(LLVMContext &C, ArrayRef< std::pair< unsigned, Attribute >> Attrs)
Create an AttributeList with the specified parameters in it.
iterator_range< arg_iterator > args()
bool isStructTy() const
True if this is an instance of StructType.
static unsigned getFlagWordForMatchingOp(unsigned InputFlag, unsigned MatchedOperandNo)
getFlagWordForMatchingOp - Augment an existing flag word returned by getFlagWord with information ind...
bool isArrayTy() const
True if this is an instance of ArrayType.
static Optional< DIExpression * > createFragmentExpression(const DIExpression *Expr, unsigned OffsetInBits, unsigned SizeInBits)
Create a DIExpression to describe one part of an aggregate variable that is fragmented across multipl...
This class contains meta information specific to a module.
This file describes how to lower LLVM code to machine code.
const BasicBlock * getParent() const
an instruction to allocate memory on the stack
vt_iterator legalclasstypes_begin(const TargetRegisterClass &RC) const
Loop over all of the value types that can be represented by values in the given register class...
This instruction inserts a struct field of array element value into an aggregate value.
SDValue getTargetGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT, int64_t offset=0, unsigned char TargetFlags=0)
gep_type_iterator gep_type_begin(const User *GEP)
static bool InBlock(const Value *V, const BasicBlock *BB)
This class is used to represent ISD::LOAD nodes.
DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned to a specified boundary...
static void getCopyToPartsVector(SelectionDAG &DAG, const SDLoc &dl, SDValue Val, SDValue *Parts, unsigned NumParts, MVT PartVT, const Value *V, Optional< CallingConv::ID > CallConv)
getCopyToPartsVector - Create a series of nodes that contain the specified value split into legal par...