74 #define DEBUG_TYPE "isel"
82 cl::desc(
"Generate low-precision inline sequences "
83 "for some float libcalls"),
105 const bool IsRetInst = V && isa<ReturnInst>(V);
106 const bool IsCallInst = V && isa<CallInst>(V);
107 const bool IsInLineAsm =
108 IsCallInst &&
static_cast<const CallInst *
>(V)->isInlineAsm();
109 const bool IsIndirectFunctionCall =
110 IsCallInst && !IsInLineAsm &&
115 const bool IsInstrinsicCall =
116 IsCallInst && !IsInLineAsm && !IsIndirectFunctionCall &&
120 return IsRetInst || (IsCallInst && (!IsInLineAsm && !IsInstrinsicCall));
124 const SDValue *Parts,
unsigned NumParts,
134 const SDValue *Parts,
unsigned NumParts,
137 bool IsABIRegCopy =
false) {
140 PartVT, ValueVT, V, IsABIRegCopy);
142 assert(NumParts > 0 &&
"No parts to assemble!");
153 unsigned RoundParts = NumParts & (NumParts - 1) ?
154 1 <<
Log2_32(NumParts) : NumParts;
155 unsigned RoundBits = PartBits * RoundParts;
156 EVT RoundVT = RoundBits == ValueBits ?
162 if (RoundParts > 2) {
166 RoundParts / 2, PartVT, HalfVT, V);
177 if (RoundParts < NumParts) {
179 unsigned OddParts = NumParts - RoundParts;
182 Parts + RoundParts, OddParts, PartVT, OddVT, V);
210 !PartVT.
isVector() &&
"Unexpected split");
221 if (PartEVT == ValueVT)
225 ValueVT.
bitsLT(PartEVT)) {
238 if (ValueVT.
bitsLT(PartEVT)) {
242 if (AssertOp.hasValue())
243 Val = DAG.
getNode(*AssertOp, DL, PartEVT, Val,
265 const Instruction *
I = dyn_cast_or_null<Instruction>(V);
269 const char *AsmError =
", possible invalid constraint for vector type";
270 if (
const CallInst *CI = dyn_cast<CallInst>(I))
271 if (isa<InlineAsm>(CI->getCalledValue()))
272 return Ctx.
emitError(I, ErrMsg + AsmError);
283 const SDValue *Parts,
unsigned NumParts,
287 assert(NumParts > 0 &&
"No parts to assemble!");
295 unsigned NumIntermediates;
300 *DAG.
getContext(), ValueVT, IntermediateVT, NumIntermediates,
305 NumIntermediates, RegisterVT);
308 assert(NumRegs == NumParts &&
"Part count doesn't match vector breakdown!");
310 assert(RegisterVT == PartVT &&
"Part type doesn't match vector breakdown!");
313 "Part type sizes don't match!");
317 if (NumIntermediates == NumParts) {
320 for (
unsigned i = 0; i != NumParts; ++i)
322 PartVT, IntermediateVT, V);
323 }
else if (NumParts > 0) {
326 assert(NumParts % NumIntermediates == 0 &&
327 "Must expand into a divisible number of parts!");
328 unsigned Factor = NumParts / NumIntermediates;
329 for (
unsigned i = 0; i != NumIntermediates; ++i)
331 PartVT, IntermediateVT, V);
340 : NumIntermediates));
343 DL, BuiltVectorTy, Ops);
349 if (PartEVT == ValueVT)
359 "Cannot narrow, it would be a lossy transformation");
370 "Cannot handle this kind of promotion");
400 *DAG.
getContext(), V,
"non-trivial scalar-to-vector conversion");
415 MVT PartVT,
const Value *V,
bool IsABIRegCopy);
421 SDValue *Parts,
unsigned NumParts,
MVT PartVT,
424 bool IsABIRegCopy =
false) {
433 unsigned OrigNumParts = NumParts;
435 "Copying to an illegal type!");
441 EVT PartEVT = PartVT;
442 if (PartEVT == ValueVT) {
443 assert(NumParts == 1 &&
"No-op copy with multiple parts!");
451 assert(NumParts == 1 &&
"Do not know what to promote to!");
462 "Unknown mismatch!");
464 Val = DAG.
getNode(ExtendKind, DL, ValueVT, Val);
470 assert(NumParts == 1 && PartEVT != ValueVT);
476 "Unknown mismatch!");
486 "Failed to tile the value with PartVT!");
489 if (PartEVT != ValueVT) {
491 "scalar-to-vector conversion failed");
500 if (NumParts & (NumParts - 1)) {
503 "Do not know what to expand to!");
504 unsigned RoundParts = 1 <<
Log2_32(NumParts);
505 unsigned RoundBits = RoundParts * PartBits;
506 unsigned OddParts = NumParts - RoundParts;
509 getCopyToParts(DAG, DL, OddVal, Parts + RoundParts, OddParts, PartVT, V);
515 NumParts = RoundParts;
527 for (
unsigned StepSize = NumParts; StepSize > 1; StepSize /= 2) {
528 for (
unsigned i = 0; i < NumParts; i += StepSize) {
529 unsigned ThisBits = StepSize * PartBits / 2;
532 SDValue &Part1 = Parts[i+StepSize/2];
539 if (ThisBits == PartBits && ThisVT != PartVT) {
563 EVT PartEVT = PartVT;
564 if (PartEVT == ValueVT) {
606 "lossy conversion of vector to scalar type");
607 EVT IntermediateType =
622 unsigned NumIntermediates;
625 NumRegs = TLI.getVectorTypeBreakdownForCallingConv(
626 *DAG.
getContext(), ValueVT, IntermediateVT, NumIntermediates,
630 TLI.getVectorTypeBreakdown(*DAG.
getContext(), ValueVT, IntermediateVT,
631 NumIntermediates, RegisterVT);
635 assert(NumRegs == NumParts &&
"Part count doesn't match vector breakdown!");
637 assert(RegisterVT == PartVT &&
"Part type doesn't match vector breakdown!");
640 unsigned DestVectorNoElts =
650 for (
unsigned i = 0; i != NumIntermediates; ++i) {
654 DAG.
getConstant(i * (NumElements / NumIntermediates), DL,
663 if (NumParts == NumIntermediates) {
666 for (
unsigned i = 0; i != NumParts; ++i)
668 }
else if (NumParts > 0) {
671 assert(NumIntermediates != 0 &&
"division by zero");
672 assert(NumParts % NumIntermediates == 0 &&
673 "Must expand into a divisible number of parts!");
674 unsigned Factor = NumParts / NumIntermediates;
675 for (
unsigned i = 0; i != NumIntermediates; ++i)
676 getCopyToParts(DAG, DL, Ops[i], &Parts[i*Factor], Factor, PartVT, V);
683 EVT valuevt,
bool IsABIMangledValue)
684 : ValueVTs(1, valuevt), RegVTs(1, regvt),
Regs(regs),
685 RegCount(1, regs.size()), IsABIMangled(IsABIMangledValue) {}
689 bool IsABIMangledValue) {
695 unsigned NumRegs = IsABIMangledValue
698 MVT RegisterVT = IsABIMangledValue
701 for (
unsigned i = 0; i != NumRegs; ++i)
703 RegVTs.push_back(RegisterVT);
731 for (
unsigned i = 0; i != NumRegs; ++i) {
758 if (NumZeroBits == RegSize) {
770 if (NumSignBits == RegSize) {
773 }
else if (NumZeroBits >= RegSize - 1) {
776 }
else if (NumSignBits > RegSize - 8) {
779 }
else if (NumZeroBits >= RegSize - 8) {
782 }
else if (NumSignBits > RegSize - 16) {
785 }
else if (NumZeroBits >= RegSize - 16) {
788 }
else if (NumSignBits > RegSize - 32) {
791 }
else if (NumZeroBits >= RegSize - 32) {
804 NumRegs, RegisterVT, ValueVT, V);
833 &Parts[Part], NumParts, RegisterVT, V, ExtendKind);
839 for (
unsigned i = 0; i != NumRegs; ++i) {
851 if (NumRegs == 1 || Flag)
862 Chain = Chains[NumRegs-1];
868 unsigned MatchingIdx,
const SDLoc &dl,
870 std::vector<SDValue> &Ops)
const {
895 for (
unsigned i = 0; i != NumRegs; ++i) {
920 UnusedArgNodeMap.clear();
922 PendingExports.clear();
930 DanglingDebugInfoMap.clear();
955 if (PendingExports.empty())
960 unsigned i = 0, e = PendingExports.size();
961 for (; i != e; ++i) {
962 assert(PendingExports[i].getNode()->getNumOperands() > 1);
963 if (PendingExports[i].getNode()->getOperand(0) == Root)
968 PendingExports.push_back(Root);
973 PendingExports.clear();
980 if (isa<TerminatorInst>(&I)) {
981 HandlePHINodesInSuccessorBlocks(I.
getParent());
985 if (!isa<DbgInfoIntrinsic>(I))
999 void SelectionDAGBuilder::visitPHI(
const PHINode &) {
1009 #define HANDLE_INST(NUM, OPCODE, CLASS) \
1010 case Instruction::OPCODE: visit##OPCODE((const CLASS&)I); break;
1011 #include "llvm/IR/Instruction.def"
1019 DanglingDebugInfo &DDI = DanglingDebugInfoMap[V];
1023 unsigned DbgSDNodeOrder = DDI.getSDNodeOrder();
1027 "Expected inlined-at fields to agree");
1031 if (!EmitFuncArgumentDbgValue(V, Variable, Expr, dl, Offset,
false,
1033 SDV = getDbgValue(Val, Variable, Expr, Offset, dl, DbgSDNodeOrder);
1037 DEBUG(
dbgs() <<
"Dropping debug info for " << *DI <<
"\n");
1038 DanglingDebugInfoMap[V] = DanglingDebugInfo();
1049 unsigned InReg = It->second;
1084 return (NodeMap.find(V) != NodeMap.end()) ||
1094 if (isa<ConstantSDNode>(N) || isa<ConstantFPSDNode>(
N)) {
1116 if (
const Constant *
C = dyn_cast<Constant>(V)) {
1125 if (isa<ConstantPointerNull>(
C)) {
1131 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
C))
1138 visit(CE->getOpcode(), *CE);
1140 assert(N1.getNode() &&
"visit didn't populate the NodeMap!");
1144 if (isa<ConstantStruct>(
C) || isa<ConstantArray>(
C)) {
1153 for (
unsigned i = 0, e = Val->
getNumValues(); i != e; ++i)
1161 dyn_cast<ConstantDataSequential>(
C)) {
1163 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
1167 for (
unsigned i = 0, e = Val->
getNumValues(); i != e; ++i)
1171 if (isa<ArrayType>(CDS->getType()))
1176 if (
C->getType()->isStructTy() ||
C->getType()->isArrayTy()) {
1177 assert((isa<ConstantAggregateZero>(
C) || isa<UndefValue>(
C)) &&
1178 "Unknown struct or array constant!");
1182 unsigned NumElts = ValueVTs.
size();
1186 for (
unsigned i = 0; i != NumElts; ++i) {
1187 EVT EltVT = ValueVTs[i];
1188 if (isa<UndefValue>(
C))
1209 for (
unsigned i = 0; i != NumElements; ++i)
1212 assert(isa<ConstantAggregateZero>(
C) &&
"Unknown vector constant!");
1221 Ops.
assign(NumElements, Op);
1230 if (
const AllocaInst *AI = dyn_cast<AllocaInst>(V)) {
1239 if (
const Instruction *Inst = dyn_cast<Instruction>(V)) {
1251 void SelectionDAGBuilder::visitCatchPad(
const CatchPadInst &
I) {
1257 if (IsMSVCCXX || IsCoreCLR)
1286 if (isa<ConstantTokenNone>(ParentPad))
1289 SuccessorColor = cast<Instruction>(ParentPad)->
getParent();
1290 assert(SuccessorColor &&
"No parent funclet for catchret!");
1292 assert(SuccessorColorMBB &&
"No MBB for SuccessorColor!");
1301 void SelectionDAGBuilder::visitCleanupPad(
const CleanupPadInst &CPI) {
1329 if (isa<LandingPadInst>(Pad)) {
1331 UnwindDests.emplace_back(FuncInfo.
MBBMap[EHPadBB], Prob);
1333 }
else if (isa<CleanupPadInst>(Pad)) {
1336 UnwindDests.emplace_back(FuncInfo.
MBBMap[EHPadBB], Prob);
1337 UnwindDests.
back().first->setIsEHFuncletEntry();
1339 }
else if (
auto *CatchSwitch = dyn_cast<CatchSwitchInst>(Pad)) {
1341 for (
const BasicBlock *CatchPadBB : CatchSwitch->handlers()) {
1342 UnwindDests.emplace_back(FuncInfo.
MBBMap[CatchPadBB], Prob);
1344 if (IsMSVCCXX || IsCoreCLR)
1345 UnwindDests.back().first->setIsEHFuncletEntry();
1347 NewEHPadBB = CatchSwitch->getUnwindDest();
1353 if (BPI && NewEHPadBB)
1355 EHPadBB = NewEHPadBB;
1369 for (
auto &UnwindDest : UnwindDests) {
1370 UnwindDest.first->setIsEHPad();
1371 addSuccessorWithProb(
FuncInfo.
MBB, UnwindDest.first, UnwindDest.second);
1381 void SelectionDAGBuilder::visitCatchSwitch(
const CatchSwitchInst &CSI) {
1385 void SelectionDAGBuilder::visitRet(
const ReturnInst &I) {
1416 DemoteReg, PtrValueVTs[0]);
1422 unsigned NumValues = ValueVTs.size();
1430 for (
unsigned i = 0; i != NumValues; ++i) {
1447 unsigned NumValues = ValueVTs.
size();
1462 bool RetInReg = F->getAttributes().hasAttribute(
1465 for (
unsigned j = 0; j != NumValues; ++j) {
1466 EVT VT = ValueVTs[j];
1476 &Parts[0], NumParts, PartVT, &I, ExtendKind,
true);
1489 for (
unsigned i = 0; i < NumParts; ++i) {
1526 "LowerReturn didn't return a valid chain!");
1542 assert(!V->
use_empty() &&
"Unused value assigned virtual registers!");
1552 if (!isa<Instruction>(V) && !isa<Argument>(V))
return;
1567 if (
VI->getParent() == FromBB)
1576 if (isa<Argument>(V)) {
1598 auto SuccSize = std::max<uint32_t>(
1612 Prob = getEdgeProbability(Src, Dst);
1618 if (
const Instruction *I = dyn_cast<Instruction>(V))
1640 if (
const CmpInst *BOp = dyn_cast<CmpInst>(Cond)) {
1644 if (CurBB == SwitchBB ||
1648 if (
const ICmpInst *IC = dyn_cast<ICmpInst>(Cond)) {
1650 InvertCond ? IC->getInversePredicate() : IC->getPredicate();
1661 CaseBlock CB(Condition, BOp->getOperand(0), BOp->getOperand(1),
nullptr,
1662 TBB, FBB, CurBB, TProb, FProb);
1671 nullptr, TBB, FBB, CurBB, TProb, FProb);
1706 if (BOpc == Instruction::And)
1707 BOpc = Instruction::Or;
1708 else if (BOpc == Instruction::Or)
1709 BOpc = Instruction::And;
1714 if (!BOp || !(isa<BinaryOperator>(BOp) || isa<CmpInst>(BOp)) ||
1720 TProb, FProb, InvertCond);
1730 if (Opc == Instruction::Or) {
1751 auto NewTrueProb = TProb / 2;
1752 auto NewFalseProb = TProb / 2 + FProb;
1755 NewTrueProb, NewFalseProb, InvertCond);
1762 Probs[0], Probs[1], InvertCond);
1764 assert(Opc == Instruction::And &&
"Unknown merge op!");
1784 auto NewTrueProb = TProb + FProb / 2;
1785 auto NewFalseProb = FProb / 2;
1788 NewTrueProb, NewFalseProb, InvertCond);
1795 Probs[0], Probs[1], InvertCond);
1804 if (Cases.size() != 2)
return true;
1808 if ((Cases[0].CmpLHS == Cases[1].CmpLHS &&
1809 Cases[0].CmpRHS == Cases[1].CmpRHS) ||
1810 (Cases[0].CmpRHS == Cases[1].CmpLHS &&
1811 Cases[0].CmpLHS == Cases[1].CmpRHS)) {
1817 if (Cases[0].CmpRHS == Cases[1].CmpRHS &&
1818 Cases[0].CC == Cases[1].CC &&
1819 isa<Constant>(Cases[0].CmpRHS) &&
1820 cast<Constant>(Cases[0].CmpRHS)->isNullValue()) {
1821 if (Cases[0].CC ==
ISD::SETEQ && Cases[0].TrueBB == Cases[1].ThisBB)
1823 if (Cases[0].CC ==
ISD::SETNE && Cases[0].FalseBB == Cases[1].ThisBB)
1830 void SelectionDAGBuilder::visitBr(
const BranchInst &I) {
1871 if (
const BinaryOperator *BOp = dyn_cast<BinaryOperator>(CondVal)) {
1875 (Opcode == Instruction::And || Opcode == Instruction::Or)) {
1878 getEdgeProbability(BrMBB, Succ0MBB),
1879 getEdgeProbability(BrMBB, Succ1MBB),
1888 for (
unsigned i = 1, e =
SwitchCases.size(); i != e; ++i) {
1901 for (
unsigned i = 1, e =
SwitchCases.size(); i != e; ++i)
1910 nullptr, Succ0MBB, Succ1MBB, BrMBB);
1941 const APInt& Low = cast<ConstantInt>(CB.CmpLHS)->
getValue();
1947 if (cast<ConstantInt>(CB.CmpLHS)->isMinValue(
true)) {
1959 addSuccessorWithProb(SwitchBB, CB.TrueBB, CB.TrueProb);
1962 if (CB.TrueBB != CB.FalseBB)
1963 addSuccessorWithProb(SwitchBB, CB.FalseBB, CB.FalseProb);
1968 if (CB.TrueBB == NextBlock(SwitchBB)) {
1990 assert(JT.Reg != -1U &&
"Should lower JT Header first!");
2004 JumpTableHeader &JTH,
2024 unsigned JumpTableReg =
2027 JumpTableReg, SwitchOp);
2028 JT.Reg = JumpTableReg;
2043 if (JT.MBB != NextBlock(SwitchBB))
2059 DAG.
getMachineNode(TargetOpcode::LOAD_STACK_GUARD, DL, PtrTy, Chain);
2105 auto *Fn = cast<Function>(GuardCheck);
2107 assert(FnTy->getNumParams() == 1 &&
"Invalid function signature");
2111 Entry.
Node = StackSlot;
2112 Entry.
Ty = FnTy->getParamType(0);
2113 if (Fn->hasAttribute(1, Attribute::AttrKind::InReg))
2115 Args.push_back(Entry);
2120 .setCallee(Fn->getCallingConv(), FnTy->getReturnType(),
2121 getValue(GuardCheck), std::move(Args));
2123 std::pair<SDValue, SDValue> Result = TLI.
LowerCallTo(CLI);
2201 bool UsePtrType =
false;
2205 for (
unsigned i = 0, e = B.Cases.size(); i != e; ++i)
2224 addSuccessorWithProb(SwitchBB, B.Default, B.DefaultProb);
2225 addSuccessorWithProb(SwitchBB, MBB, B.Prob);
2233 if (MBB != NextBlock(SwitchBB))
2253 if (PopCount == 1) {
2260 }
else if (PopCount == BB.Range) {
2280 addSuccessorWithProb(SwitchBB, B.TargetBB, B.ExtraProb);
2282 addSuccessorWithProb(SwitchBB, NextMBB, BranchProbToNext);
2293 if (NextMBB != NextBlock(SwitchBB))
2300 void SelectionDAGBuilder::visitInvoke(
const InvokeInst &I) {
2312 "Cannot lower invokes with arbitrary operand bundles yet!");
2316 if (isa<InlineAsm>(Callee))
2318 else if (Fn && Fn->isIntrinsic()) {
2319 switch (Fn->getIntrinsicID()) {
2322 case Intrinsic::donothing:
2325 case Intrinsic::experimental_patchpoint_void:
2326 case Intrinsic::experimental_patchpoint_i64:
2327 visitPatchpoint(&I, EHPadBB);
2329 case Intrinsic::experimental_gc_statepoint:
2338 LowerCallSiteWithDeoptBundle(&I, getValue(Callee), EHPadBB);
2340 LowerCallTo(&I, getValue(Callee),
false, EHPadBB);
2348 CopyToExportRegsIfNeeded(&I);
2359 addSuccessorWithProb(InvokeMBB, Return);
2360 for (
auto &UnwindDest : UnwindDests) {
2361 UnwindDest.first->setIsEHPad();
2362 addSuccessorWithProb(InvokeMBB, UnwindDest.first, UnwindDest.second);
2367 DAG.setRoot(DAG.getNode(
ISD::BR, getCurSDLoc(),
2369 DAG.getBasicBlock(Return)));
2372 void SelectionDAGBuilder::visitResume(
const ResumeInst &RI) {
2373 llvm_unreachable(
"SelectionDAGBuilder shouldn't visit resume instructions!");
2376 void SelectionDAGBuilder::visitLandingPad(
const LandingPadInst &LP) {
2378 "Call to landingpad not in landing pad!");
2401 assert(ValueVTs.
size() == 2 &&
"Only two-valued landingpads are supported");
2427 void SelectionDAGBuilder::sortAndRangeify(CaseClusterVector &Clusters) {
2429 for (
const CaseCluster &CC : Clusters)
2430 assert(CC.Low == CC.High &&
"Input clusters must be single-case");
2433 std::sort(Clusters.begin(), Clusters.end(),
2434 [](
const CaseCluster &a,
const CaseCluster &b) {
2435 return a.Low->getValue().slt(b.Low->getValue());
2439 const unsigned N = Clusters.size();
2440 unsigned DstIndex = 0;
2441 for (
unsigned SrcIndex = 0; SrcIndex <
N; ++SrcIndex) {
2442 CaseCluster &CC = Clusters[SrcIndex];
2446 if (DstIndex != 0 && Clusters[DstIndex - 1].MBB == Succ &&
2447 (CaseVal->
getValue() - Clusters[DstIndex - 1].High->getValue()) == 1) {
2450 Clusters[DstIndex - 1].High = CaseVal;
2451 Clusters[DstIndex - 1].Prob += CC.Prob;
2453 std::memmove(&Clusters[DstIndex++], &Clusters[SrcIndex],
2454 sizeof(Clusters[SrcIndex]));
2457 Clusters.resize(DstIndex);
2463 for (
unsigned i = 0, e =
JTCases.size(); i != e; ++i)
2465 JTCases[i].first.HeaderBB = Last;
2468 for (
unsigned i = 0, e =
BitTestCases.size(); i != e; ++i)
2473 void SelectionDAGBuilder::visitIndirectBr(
const IndirectBrInst &I) {
2480 bool Inserted = Done.
insert(BB).second;
2485 addSuccessorWithProb(IndirectBrMBB, Succ);
2494 void SelectionDAGBuilder::visitUnreachable(
const UnreachableInst &I) {
2500 void SelectionDAGBuilder::visitFSub(
const User &I) {
2525 case Instruction::Mul:
2526 case Instruction::And:
2527 case Instruction::Or:
2528 case Instruction::Xor:
2530 case Instruction::FAdd:
2531 case Instruction::FMul:
2532 if (
const FPMathOperator *FPOp = dyn_cast<const FPMathOperator>(Inst))
2533 if (FPOp->getFastMathFlags().unsafeAlgebra())
2541 unsigned ElemNumToReduce = ElemNum;
2564 bool ReduxExtracted =
false;
2566 while (!UsersToVisit.empty()) {
2567 auto User = UsersToVisit.back();
2568 UsersToVisit.pop_back();
2577 if (Inst->
getOpcode() == OpCode || isa<PHINode>(U)) {
2578 if (
const FPMathOperator *FPOp = dyn_cast<const FPMathOperator>(Inst))
2579 if (!isa<PHINode>(FPOp) && !FPOp->getFastMathFlags().unsafeAlgebra())
2581 UsersToVisit.push_back(U);
2583 dyn_cast<ShuffleVectorInst>(U)) {
2590 if (ResultElements < ElemNum)
2593 if (ElemNumToReduce == 1)
2595 if (!isa<UndefValue>(U->getOperand(1)))
2597 for (
unsigned i = 0; i < ElemNumToReduce / 2; ++i)
2598 if (ShufInst->getMaskValue(i) != int(i + ElemNumToReduce / 2))
2600 for (
unsigned i = ElemNumToReduce / 2; i < ElemNum; ++i)
2601 if (ShufInst->getMaskValue(i) != -1)
2606 if (!U->hasOneUse())
2610 if (!U2 || U2->getOpcode() != OpCode)
2614 if ((U2->getOperand(0) == U->getOperand(0) && U2->getOperand(1) == U) ||
2615 (U2->getOperand(1) == U->getOperand(0) && U2->getOperand(0) == U)) {
2616 UsersToVisit.push_back(U2);
2617 ElemNumToReduce /= 2;
2620 }
else if (isa<ExtractElementInst>(U)) {
2622 if (ElemNumToReduce != 1)
2629 ReduxExtracted =
true;
2634 return ReduxExtracted;
2637 void SelectionDAGBuilder::visitBinary(
const User &I,
unsigned OpCode) {
2644 bool vec_redux =
false;
2648 dyn_cast<const OverflowingBinaryOperator>(&I)) {
2649 nuw = OFBinOp->hasNoUnsignedWrap();
2650 nsw = OFBinOp->hasNoSignedWrap();
2653 dyn_cast<const PossiblyExactOperator>(&I))
2654 exact = ExactOp->isExact();
2655 if (
const FPMathOperator *FPOp = dyn_cast<const FPMathOperator>(&I))
2656 FMF = FPOp->getFastMathFlags();
2660 DEBUG(
dbgs() <<
"Detected a reduction operation:" << I <<
"\n");
2680 void SelectionDAGBuilder::visitShift(
const User &I,
unsigned Opcode) {
2690 unsigned Op2Size = Op2.getValueSizeInBits();
2694 if (ShiftSize > Op2Size)
2701 else if (ShiftSize >=
Log2_32_Ceil(Op2.getValueSizeInBits()))
2716 dyn_cast<const OverflowingBinaryOperator>(&I)) {
2717 nuw = OFBinOp->hasNoUnsignedWrap();
2718 nsw = OFBinOp->hasNoSignedWrap();
2721 dyn_cast<const PossiblyExactOperator>(&I))
2722 exact = ExactOp->isExact();
2733 void SelectionDAGBuilder::visitSDiv(
const User &I) {
2738 Flags.setExact(isa<PossiblyExactOperator>(&I) &&
2739 cast<PossiblyExactOperator>(&I)->isExact());
2744 void SelectionDAGBuilder::visitICmp(
const User &I) {
2746 if (
const ICmpInst *IC = dyn_cast<ICmpInst>(&I))
2747 predicate = IC->getPredicate();
2748 else if (
const ConstantExpr *IC = dyn_cast<ConstantExpr>(&I))
2759 void SelectionDAGBuilder::visitFCmp(
const User &I) {
2761 if (
const FCmpInst *
FC = dyn_cast<FCmpInst>(&I))
2762 predicate =
FC->getPredicate();
2783 return isa<SelectInst>(V);
2787 void SelectionDAGBuilder::visitSelect(
const User &I) {
2791 unsigned NumValues = ValueVTs.
size();
2792 if (NumValues == 0)
return;
2798 auto BaseOps = {Cond};
2804 EVT VT = ValueVTs[0];
2817 bool UseScalarMinMax = VT.
isVector() &&
2823 switch (SPR.Flavor) {
2829 switch (SPR.NaNBehavior) {
2838 else if (UseScalarMinMax)
2846 switch (SPR.NaNBehavior) {
2856 else if (UseScalarMinMax)
2880 for (
unsigned i = 0; i != NumValues; ++i) {
2883 Ops.push_back(
SDValue(RHSVal.getNode(), RHSVal.getResNo() + i));
2885 LHSVal.getNode()->getValueType(LHSVal.getResNo()+i),
2893 void SelectionDAGBuilder::visitTrunc(
const User &I) {
2901 void SelectionDAGBuilder::visitZExt(
const User &I) {
2910 void SelectionDAGBuilder::visitSExt(
const User &I) {
2919 void SelectionDAGBuilder::visitFPTrunc(
const User &I) {
2930 void SelectionDAGBuilder::visitFPExt(
const User &I) {
2938 void SelectionDAGBuilder::visitFPToUI(
const User &I) {
2946 void SelectionDAGBuilder::visitFPToSI(
const User &I) {
2954 void SelectionDAGBuilder::visitUIToFP(
const User &I) {
2962 void SelectionDAGBuilder::visitSIToFP(
const User &I) {
2970 void SelectionDAGBuilder::visitPtrToInt(
const User &I) {
2979 void SelectionDAGBuilder::visitIntToPtr(
const User &I) {
2988 void SelectionDAGBuilder::visitBitCast(
const User &I) {
3010 void SelectionDAGBuilder::visitAddrSpaceCast(
const User &I) {
3025 void SelectionDAGBuilder::visitInsertElement(
const User &I) {
3033 InVec, InVal, InIdx));
3036 void SelectionDAGBuilder::visitExtractElement(
const User &I) {
3046 void SelectionDAGBuilder::visitShuffleVector(
const User &I) {
3053 unsigned MaskNumElts = Mask.
size();
3060 if (SrcNumElts == MaskNumElts) {
3066 if (SrcNumElts < MaskNumElts) {
3070 if (MaskNumElts % SrcNumElts == 0) {
3074 unsigned NumConcat = MaskNumElts / SrcNumElts;
3075 bool IsConcat =
true;
3077 for (
unsigned i = 0; i != MaskNumElts; ++i) {
3083 if ((Idx % SrcNumElts != (i % SrcNumElts)) ||
3084 (ConcatSrcs[i / SrcNumElts] >= 0 &&
3085 ConcatSrcs[i / SrcNumElts] != (
int)(Idx / SrcNumElts))) {
3090 ConcatSrcs[i / SrcNumElts] = Idx / SrcNumElts;
3097 for (
auto Src : ConcatSrcs) {
3110 unsigned PaddedMaskNumElts =
alignTo(MaskNumElts, SrcNumElts);
3111 unsigned NumConcat = PaddedMaskNumElts / SrcNumElts;
3132 for (
unsigned i = 0; i != MaskNumElts; ++i) {
3134 if (Idx >= (
int)SrcNumElts)
3135 Idx -= SrcNumElts - PaddedMaskNumElts;
3143 if (MaskNumElts != PaddedMaskNumElts)
3152 if (SrcNumElts > MaskNumElts) {
3155 int StartIdx[2] = { -1, -1 };
3156 bool CanExtract =
true;
3157 for (
int Idx : Mask) {
3162 if (Idx >= (
int)SrcNumElts) {
3170 int NewStartIdx =
alignDown(Idx, MaskNumElts);
3171 if (NewStartIdx + MaskNumElts > SrcNumElts ||
3172 (StartIdx[Input] >= 0 && StartIdx[Input] != NewStartIdx))
3176 StartIdx[Input] = NewStartIdx;
3179 if (StartIdx[0] < 0 && StartIdx[1] < 0) {
3185 for (
unsigned Input = 0; Input < 2; ++Input) {
3186 SDValue &Src = Input == 0 ? Src1 : Src2;
3187 if (StartIdx[Input] < 0)
3199 for (
int &Idx : MappedOps) {
3200 if (Idx >= (
int)SrcNumElts)
3201 Idx -= SrcNumElts + StartIdx[1] - MaskNumElts;
3217 for (
int Idx : Mask) {
3223 SDValue &Src = Idx < (int)SrcNumElts ? Src1 : Src2;
3224 if (Idx >= (
int)SrcNumElts) Idx -= SrcNumElts;
3236 void SelectionDAGBuilder::visitInsertValue(
const User &I) {
3239 Indices = IV->getIndices();
3241 Indices = cast<ConstantExpr>(&
I)->getIndices();
3247 bool IntoUndef = isa<UndefValue>(Op0);
3248 bool FromUndef = isa<UndefValue>(Op1);
3258 unsigned NumAggValues = AggValueVTs.
size();
3259 unsigned NumValValues = ValValueVTs.size();
3263 if (!NumAggValues) {
3271 for (; i != LinearIndex; ++i)
3272 Values[i] = IntoUndef ?
DAG.
getUNDEF(AggValueVTs[i]) :
3277 for (; i != LinearIndex + NumValValues; ++i)
3278 Values[i] = FromUndef ?
DAG.
getUNDEF(AggValueVTs[i]) :
3282 for (; i != NumAggValues; ++i)
3283 Values[i] = IntoUndef ?
DAG.
getUNDEF(AggValueVTs[i]) :
3290 void SelectionDAGBuilder::visitExtractValue(
const User &I) {
3293 Indices = EV->getIndices();
3295 Indices = cast<ConstantExpr>(&
I)->getIndices();
3300 bool OutOfUndef = isa<UndefValue>(Op0);
3308 unsigned NumValValues = ValValueVTs.
size();
3311 if (!NumValValues) {
3320 for (
unsigned i = LinearIndex; i != LinearIndex + NumValValues; ++i)
3321 Values[i - LinearIndex] =
3330 void SelectionDAGBuilder::visitGetElementPtr(
const User &I) {
3341 cast<VectorType>(I.
getType())->getVectorNumElements() : 0;
3351 const Value *Idx = GTI.getOperand();
3352 if (
StructType *StTy = GTI.getStructTypeOrNull()) {
3353 unsigned Field = cast<Constant>(Idx)->getUniqueInteger().getZExtValue();
3356 uint64_t
Offset = DL->getStructLayout(StTy)->getElementOffset(Field);
3361 if (int64_t(Offset) >= 0 && cast<GEPOperator>(I).isInBounds())
3371 APInt ElementSize(PtrSize, DL->getTypeAllocSize(GTI.getIndexedType()));
3376 if (!CI && isa<ConstantDataVector>(Idx) &&
3378 CI = cast<ConstantInt>(cast<ConstantDataVector>(Idx)->getSplatValue());
3385 SDValue OffsVal = VectorWidth ?
3413 if (ElementSize != 1) {
3414 if (ElementSize.isPowerOf2()) {
3415 unsigned Amt = ElementSize.logBase2();
3417 N.getValueType(), IdxN,
3422 N.getValueType(), IdxN, Scale);
3427 N.getValueType(),
N, IdxN);
3434 void SelectionDAGBuilder::visitAlloca(
const AllocaInst &I) {
3451 if (AllocSize.getValueType() != IntPtr)
3461 unsigned StackAlign =
3463 if (Align <= StackAlign)
3472 AllocSize.getValueType(), AllocSize,
3477 AllocSize.getValueType(), AllocSize,
3490 void SelectionDAGBuilder::visitLoad(
const LoadInst &I) {
3492 return visitAtomicLoad(I);
3499 if (
const Argument *Arg = dyn_cast<Argument>(SV)) {
3500 if (Arg->hasSwiftErrorAttr())
3501 return visitLoadFromSwiftError(I);
3504 if (
const AllocaInst *Alloca = dyn_cast<AllocaInst>(SV)) {
3505 if (Alloca->isSwiftError())
3506 return visitLoadFromSwiftError(I);
3527 unsigned NumValues = ValueVTs.size();
3532 bool ConstantMemory =
false;
3540 ConstantMemory =
true;
3559 unsigned ChainI = 0;
3560 for (
unsigned i = 0; i != NumValues; ++i, ++ChainI) {
3585 if (isDereferenceable)
3591 MMOFlags, AAInfo, Ranges);
3597 if (!ConstantMemory) {
3610 void SelectionDAGBuilder::visitStoreToSwiftError(
const StoreInst &I) {
3612 "call visitStoreToSwiftError when backend supports swifterror");
3619 assert(ValueVTs.size() == 1 && Offsets[0] == 0 &&
3620 "expect a single EVT for swifterror");
3624 unsigned VReg;
bool CreatedVReg;
3629 SDValue(Src.getNode(), Src.getResNo()));
3635 void SelectionDAGBuilder::visitLoadFromSwiftError(
const LoadInst &I) {
3637 "call visitLoadFromSwiftError when backend supports swifterror");
3642 "Support volatile, non temporal, invariant for load_from_swift_error");
3650 "load_from_swift_error should not be constant memory");
3656 assert(ValueVTs.size() == 1 && Offsets[0] == 0 &&
3657 "expect a single EVT for swifterror");
3668 void SelectionDAGBuilder::visitStore(
const StoreInst &I) {
3670 return visitAtomicStore(I);
3679 if (
const Argument *Arg = dyn_cast<Argument>(PtrV)) {
3680 if (Arg->hasSwiftErrorAttr())
3681 return visitStoreToSwiftError(I);
3684 if (
const AllocaInst *Alloca = dyn_cast<AllocaInst>(PtrV)) {
3685 if (Alloca->isSwiftError())
3686 return visitStoreToSwiftError(I);
3694 unsigned NumValues = ValueVTs.
size();
3724 unsigned ChainI = 0;
3725 for (
unsigned i = 0; i != NumValues; ++i, ++ChainI) {
3738 Chains[ChainI] = St;
3746 void SelectionDAGBuilder::visitMaskedStore(
const CallInst &I,
3747 bool IsCompressing) {
3751 unsigned& Alignment) {
3755 Alignment = cast<ConstantInt>(I.
getArgOperand(2))->getZExtValue();
3759 unsigned& Alignment) {
3767 Value *PtrOperand, *MaskOperand, *Src0Operand;
3770 getCompressingStoreOps(PtrOperand, MaskOperand, Src0Operand, Alignment);
3772 getMaskedStoreOps(PtrOperand, MaskOperand, Src0Operand, Alignment);
3821 if (!GEP || GEP->getNumOperands() > 2)
3824 const Value *GEPPtr = GEP->getPointerOperand();
3830 Value *IndexVal = GEP->getOperand(1);
3841 if (
SExtInst* Sext = dyn_cast<SExtInst>(IndexVal)) {
3842 if (SDB->
findValue(Sext->getOperand(0))) {
3843 IndexVal = Sext->getOperand(0);
3848 unsigned GEPWidth = GEP->getType()->getVectorNumElements();
3855 void SelectionDAGBuilder::visitMaskedScatter(
const CallInst &I) {
3863 unsigned Alignment = (cast<ConstantInt>(I.
getArgOperand(2)))->getZExtValue();
3876 const Value *MemOpBasePtr = UniformBase ? BasePtr :
nullptr;
3892 void SelectionDAGBuilder::visitMaskedLoad(
const CallInst &I,
bool IsExpanding) {
3896 unsigned& Alignment) {
3899 Alignment = cast<ConstantInt>(I.
getArgOperand(1))->getZExtValue();
3904 unsigned& Alignment) {
3912 Value *PtrOperand, *MaskOperand, *Src0Operand;
3915 getExpandingLoadOps(PtrOperand, MaskOperand, Src0Operand, Alignment);
3917 getMaskedLoadOps(PtrOperand, MaskOperand, Src0Operand, Alignment);
3940 Alignment, AAInfo, Ranges);
3951 void SelectionDAGBuilder::visitMaskedGather(
const CallInst &I) {
3961 unsigned Alignment = (cast<ConstantInt>(I.
getArgOperand(1)))->getZExtValue();
3974 bool ConstantMemory =
false;
3981 ConstantMemory =
true;
3988 Alignment, AAInfo, Ranges);
3994 SDValue Ops[] = { Root, Src0,
Mask, Base, Index };
3999 if (!ConstantMemory)
4018 0, SuccessOrder, FailureOrder, SSID);
4026 void SelectionDAGBuilder::visitAtomicRMW(
const AtomicRMWInst &I) {
4063 void SelectionDAGBuilder::visitFence(
const FenceInst &I) {
4075 void SelectionDAGBuilder::visitAtomicLoad(
const LoadInst &I) {
4109 void SelectionDAGBuilder::visitAtomicStore(
const StoreInst &I) {
4137 void SelectionDAGBuilder::visitTargetIntrinsic(
const CallInst &I,
4138 unsigned Intrinsic) {
4158 TargetLowering::IntrinsicInfo Info;
4184 if (IsTgtIntrinsic) {
4187 VTs, Ops, Info.memVT,
4189 Info.align, Info.vol,
4190 Info.readMem, Info.writeMem, Info.size);
4191 }
else if (!HasChain) {
4273 SDValue TwoToFractionalPartOfX;
4390 if (LimitFloatPrecision <= 6) {
4405 }
else if (LimitFloatPrecision <= 12) {
4489 if (LimitFloatPrecision <= 6) {
4502 }
else if (LimitFloatPrecision <= 12) {
4587 if (LimitFloatPrecision <= 6) {
4602 }
else if (LimitFloatPrecision <= 12) {
4673 bool IsExp10 =
false;
4678 IsExp10 = LHSC->isExactlyValue(Ten);
4708 unsigned Val = RHSC->getSExtValue();
4709 if ((
int)Val < 0) Val = -Val;
4737 CurSquare, CurSquare);
4742 if (RHSC->getSExtValue() < 0)
4772 bool SelectionDAGBuilder::EmitFuncArgumentDbgValue(
4788 bool IsIndirect =
false;
4805 IsIndirect = IsDbgDeclare;
4814 IsIndirect = IsDbgDeclare;
4822 dyn_cast<FrameIndexSDNode>(LNode->getBasePtr().getNode()))
4829 "Expected inlined-at fields to agree");
4832 BuildMI(MF, DL, TII->
get(TargetOpcode::DBG_VALUE), IsIndirect,
4836 BuildMI(MF, DL, TII->
get(TargetOpcode::DBG_VALUE))
4839 .addMetadata(Variable)
4840 .addMetadata(Expr));
4850 unsigned DbgSDNodeOrder) {
4851 if (
auto *FISDN = dyn_cast<FrameIndexSDNode>(N.
getNode())) {
4859 Offset, dl, DbgSDNodeOrder);
4863 #if defined(_MSC_VER) && defined(setjmp) && \
4864 !defined(setjmp_undefined_for_msvc)
4865 # pragma push_macro("setjmp")
4867 # define setjmp_undefined_for_msvc
4874 SelectionDAGBuilder::visitIntrinsicCall(
const CallInst &I,
unsigned Intrinsic) {
4880 switch (Intrinsic) {
4883 visitTargetIntrinsic(I, Intrinsic);
4885 case Intrinsic::vastart: visitVAStart(I);
return nullptr;
4886 case Intrinsic::vaend: visitVAEnd(I);
return nullptr;
4887 case Intrinsic::vacopy: visitVACopy(I);
return nullptr;
4888 case Intrinsic::returnaddress:
4893 case Intrinsic::addressofreturnaddress:
4897 case Intrinsic::frameaddress:
4902 case Intrinsic::read_register: {
4906 DAG.
getMDNode(cast<MDNode>(cast<MetadataAsValue>(Reg)->getMetadata()));
4914 case Intrinsic::write_register: {
4919 DAG.
getMDNode(cast<MDNode>(cast<MetadataAsValue>(Reg)->getMetadata()));
4924 case Intrinsic::setjmp:
4926 case Intrinsic::longjmp:
4928 case Intrinsic::memcpy: {
4932 unsigned Align = cast<ConstantInt>(I.
getArgOperand(3))->getZExtValue();
4935 bool isVol = cast<ConstantInt>(I.
getArgOperand(4))->getZExtValue();
4941 updateDAGForMaybeTailCall(MC);
4944 case Intrinsic::memset: {
4948 unsigned Align = cast<ConstantInt>(I.
getArgOperand(3))->getZExtValue();
4951 bool isVol = cast<ConstantInt>(I.
getArgOperand(4))->getZExtValue();
4955 updateDAGForMaybeTailCall(MS);
4958 case Intrinsic::memmove: {
4962 unsigned Align = cast<ConstantInt>(I.
getArgOperand(3))->getZExtValue();
4965 bool isVol = cast<ConstantInt>(I.
getArgOperand(4))->getZExtValue();
4970 updateDAGForMaybeTailCall(MM);
4973 case Intrinsic::memcpy_element_unordered_atomic: {
4975 cast<ElementUnorderedAtomicMemCpyInst>(
I);
4982 TargetLowering::ArgListEntry Entry;
4985 Args.push_back(Entry);
4988 Args.push_back(Entry);
4991 Entry.Node = Length;
4992 Args.push_back(Entry);
5001 CLI.setDebugLoc(sdl).setChain(
getRoot()).setLibCallee(
5008 std::pair<SDValue, SDValue> CallResult = TLI.
LowerCallTo(CLI);
5012 case Intrinsic::memmove_element_unordered_atomic: {
5013 auto &MI = cast<ElementUnorderedAtomicMemMoveInst>(
I);
5020 TargetLowering::ArgListEntry Entry;
5023 Args.push_back(Entry);
5026 Args.push_back(Entry);
5029 Entry.Node = Length;
5030 Args.push_back(Entry);
5039 CLI.setDebugLoc(sdl).setChain(
getRoot()).setLibCallee(
5046 std::pair<SDValue, SDValue> CallResult = TLI.
LowerCallTo(CLI);
5050 case Intrinsic::memset_element_unordered_atomic: {
5051 auto &MI = cast<ElementUnorderedAtomicMemSetInst>(
I);
5058 TargetLowering::ArgListEntry Entry;
5061 Args.push_back(Entry);
5065 Args.push_back(Entry);
5068 Entry.Node = Length;
5069 Args.push_back(Entry);
5078 CLI.setDebugLoc(sdl).setChain(
getRoot()).setLibCallee(
5085 std::pair<SDValue, SDValue> CallResult = TLI.
LowerCallTo(CLI);
5089 case Intrinsic::dbg_declare: {
5094 assert(Variable &&
"Missing variable");
5096 DEBUG(
dbgs() <<
"Dropping debug info for " << DI <<
"\n");
5101 if (isa<UndefValue>(Address) ||
5103 DEBUG(
dbgs() <<
"Dropping debug info for " << DI <<
"\n");
5117 N = UnusedArgNodeMap[
Address];
5120 if (
const BitCastInst *BCI = dyn_cast<BitCastInst>(Address))
5121 Address = BCI->getOperand(0);
5123 bool isParameter = Variable->isParameter() || isa<Argument>(
Address);
5125 if (isParameter && FINode) {
5128 FINode->getIndex(), 0, dl, SDNodeOrder);
5129 }
else if (isa<Argument>(Address)) {
5132 EmitFuncArgumentDbgValue(Address, Variable, Expression, dl, 0,
true, N);
5136 true, 0, dl, SDNodeOrder);
5142 if (!EmitFuncArgumentDbgValue(Address, Variable, Expression, dl, 0,
true,
5144 DEBUG(
dbgs() <<
"Dropping debug info for " << DI <<
"\n");
5149 case Intrinsic::dbg_value: {
5161 if (isa<ConstantInt>(V) || isa<ConstantFP>(V) || isa<UndefValue>(V)) {
5171 if (!N.
getNode() && isa<Argument>(V))
5172 N = UnusedArgNodeMap[V];
5174 if (EmitFuncArgumentDbgValue(V, Variable, Expression, dl, Offset,
false,
5177 SDV = getDbgValue(N, Variable, Expression, Offset, dl, SDNodeOrder);
5185 DanglingDebugInfo DDI(&DI, dl, SDNodeOrder);
5186 DanglingDebugInfoMap[V] = DDI;
5190 DEBUG(
dbgs() <<
"Dropping debug location info for:\n " << DI <<
"\n");
5191 DEBUG(
dbgs() <<
" Last seen at:\n " << *V <<
"\n");
5195 case Intrinsic::eh_typeid_for: {
5204 case Intrinsic::eh_return_i32:
5205 case Intrinsic::eh_return_i64:
5213 case Intrinsic::eh_unwind_init:
5216 case Intrinsic::eh_dwarf_cfa: {
5222 case Intrinsic::eh_sjlj_callsite: {
5225 assert(CI &&
"Non-constant call site value in eh.sjlj.callsite!");
5231 case Intrinsic::eh_sjlj_functioncontext: {
5240 case Intrinsic::eh_sjlj_setjmp: {
5250 case Intrinsic::eh_sjlj_longjmp: {
5255 case Intrinsic::eh_sjlj_setup_dispatch: {
5261 case Intrinsic::masked_gather:
5262 visitMaskedGather(I);
5264 case Intrinsic::masked_load:
5267 case Intrinsic::masked_scatter:
5268 visitMaskedScatter(I);
5270 case Intrinsic::masked_store:
5271 visitMaskedStore(I);
5273 case Intrinsic::masked_expandload:
5274 visitMaskedLoad(I,
true );
5276 case Intrinsic::masked_compressstore:
5277 visitMaskedStore(I,
true );
5279 case Intrinsic::x86_mmx_pslli_w:
5280 case Intrinsic::x86_mmx_pslli_d:
5281 case Intrinsic::x86_mmx_pslli_q:
5282 case Intrinsic::x86_mmx_psrli_w:
5283 case Intrinsic::x86_mmx_psrli_d:
5284 case Intrinsic::x86_mmx_psrli_q:
5285 case Intrinsic::x86_mmx_psrai_w:
5286 case Intrinsic::x86_mmx_psrai_d: {
5288 if (isa<ConstantSDNode>(ShAmt)) {
5289 visitTargetIntrinsic(I, Intrinsic);
5292 unsigned NewIntrinsic = 0;
5294 switch (Intrinsic) {
5295 case Intrinsic::x86_mmx_pslli_w:
5296 NewIntrinsic = Intrinsic::x86_mmx_psll_w;
5298 case Intrinsic::x86_mmx_pslli_d:
5299 NewIntrinsic = Intrinsic::x86_mmx_psll_d;
5301 case Intrinsic::x86_mmx_pslli_q:
5302 NewIntrinsic = Intrinsic::x86_mmx_psll_q;
5304 case Intrinsic::x86_mmx_psrli_w:
5305 NewIntrinsic = Intrinsic::x86_mmx_psrl_w;
5307 case Intrinsic::x86_mmx_psrli_d:
5308 NewIntrinsic = Intrinsic::x86_mmx_psrl_d;
5310 case Intrinsic::x86_mmx_psrli_q:
5311 NewIntrinsic = Intrinsic::x86_mmx_psrl_q;
5313 case Intrinsic::x86_mmx_psrai_w:
5314 NewIntrinsic = Intrinsic::x86_mmx_psra_w;
5316 case Intrinsic::x86_mmx_psrai_d:
5317 NewIntrinsic = Intrinsic::x86_mmx_psra_d;
5338 case Intrinsic::powi:
5342 case Intrinsic::log:
5345 case Intrinsic::log2:
5348 case Intrinsic::log10:
5351 case Intrinsic::exp:
5354 case Intrinsic::exp2:
5357 case Intrinsic::pow:
5361 case Intrinsic::sqrt:
5362 case Intrinsic::fabs:
5363 case Intrinsic::sin:
5364 case Intrinsic::cos:
5365 case Intrinsic::floor:
5366 case Intrinsic::ceil:
5367 case Intrinsic::trunc:
5368 case Intrinsic::rint:
5369 case Intrinsic::nearbyint:
5371 case Intrinsic::canonicalize: {
5373 switch (Intrinsic) {
5375 case Intrinsic::sqrt: Opcode =
ISD::FSQRT;
break;
5376 case Intrinsic::fabs: Opcode =
ISD::FABS;
break;
5377 case Intrinsic::sin: Opcode =
ISD::FSIN;
break;
5378 case Intrinsic::cos: Opcode =
ISD::FCOS;
break;
5379 case Intrinsic::floor: Opcode =
ISD::FFLOOR;
break;
5380 case Intrinsic::ceil: Opcode =
ISD::FCEIL;
break;
5381 case Intrinsic::trunc: Opcode =
ISD::FTRUNC;
break;
5382 case Intrinsic::rint: Opcode =
ISD::FRINT;
break;
5415 case Intrinsic::copysign:
5421 case Intrinsic::fma:
5428 case Intrinsic::experimental_constrained_fadd:
5429 case Intrinsic::experimental_constrained_fsub:
5430 case Intrinsic::experimental_constrained_fmul:
5431 case Intrinsic::experimental_constrained_fdiv:
5432 case Intrinsic::experimental_constrained_frem:
5433 case Intrinsic::experimental_constrained_sqrt:
5434 case Intrinsic::experimental_constrained_pow:
5435 case Intrinsic::experimental_constrained_powi:
5436 case Intrinsic::experimental_constrained_sin:
5437 case Intrinsic::experimental_constrained_cos:
5438 case Intrinsic::experimental_constrained_exp:
5439 case Intrinsic::experimental_constrained_exp2:
5440 case Intrinsic::experimental_constrained_log:
5441 case Intrinsic::experimental_constrained_log10:
5442 case Intrinsic::experimental_constrained_log2:
5443 case Intrinsic::experimental_constrained_rint:
5444 case Intrinsic::experimental_constrained_nearbyint:
5445 visitConstrainedFPIntrinsic(cast<ConstrainedFPIntrinsic>(I));
5447 case Intrinsic::fmuladd: {
5470 case Intrinsic::convert_to_fp16:
5477 case Intrinsic::convert_from_fp16:
5483 case Intrinsic::pcmarker: {
5488 case Intrinsic::readcyclecounter: {
5496 case Intrinsic::bitreverse:
5501 case Intrinsic::bswap:
5506 case Intrinsic::cttz: {
5514 case Intrinsic::ctlz: {
5522 case Intrinsic::ctpop: {
5528 case Intrinsic::stacksave: {
5537 case Intrinsic::stackrestore: {
5542 case Intrinsic::get_dynamic_area_offset: {
5557 case Intrinsic::stackguard: {
5566 unsigned Align = DL->getPrefTypeAlignment(Global->
getType());
5575 case Intrinsic::stackprotector: {
5602 case Intrinsic::objectsize: {
5606 assert(CI &&
"Non-constant type in __builtin_object_size?");
5619 case Intrinsic::annotation:
5620 case Intrinsic::ptr_annotation:
5621 case Intrinsic::invariant_group_barrier:
5625 case Intrinsic::assume:
5626 case Intrinsic::var_annotation:
5630 case Intrinsic::init_trampoline: {
5646 case Intrinsic::adjust_trampoline: {
5652 case Intrinsic::gcroot: {
5657 "only valid in functions with gc specified, enforced by Verifier");
5666 case Intrinsic::gcread:
5667 case Intrinsic::gcwrite:
5669 case Intrinsic::flt_rounds:
5673 case Intrinsic::expect: {
5679 case Intrinsic::debugtrap:
5680 case Intrinsic::trap: {
5685 if (TrapFuncName.
empty()) {
5694 CLI.setDebugLoc(sdl).setChain(
getRoot()).setLibCallee(
5700 std::pair<SDValue, SDValue> Result = TLI.
LowerCallTo(CLI);
5705 case Intrinsic::uadd_with_overflow:
5706 case Intrinsic::sadd_with_overflow:
5707 case Intrinsic::usub_with_overflow:
5708 case Intrinsic::ssub_with_overflow:
5709 case Intrinsic::umul_with_overflow:
5710 case Intrinsic::smul_with_overflow: {
5712 switch (Intrinsic) {
5714 case Intrinsic::uadd_with_overflow: Op =
ISD::UADDO;
break;
5715 case Intrinsic::sadd_with_overflow: Op =
ISD::SADDO;
break;
5716 case Intrinsic::usub_with_overflow: Op =
ISD::USUBO;
break;
5717 case Intrinsic::ssub_with_overflow: Op =
ISD::SSUBO;
break;
5718 case Intrinsic::umul_with_overflow: Op =
ISD::UMULO;
break;
5719 case Intrinsic::smul_with_overflow: Op =
ISD::SMULO;
break;
5730 unsigned rw = cast<ConstantInt>(I.
getArgOperand(1))->getZExtValue();
5746 case Intrinsic::lifetime_start:
5747 case Intrinsic::lifetime_end: {
5748 bool IsStart = (Intrinsic == Intrinsic::lifetime_start);
5757 E = Allocas.
end(); Object !=
E; ++Object) {
5758 AllocaInst *LifetimeObject = dyn_cast_or_null<AllocaInst>(*Object);
5761 if (!LifetimeObject)
5770 int FI =
SI->second;
5783 case Intrinsic::invariant_start:
5787 case Intrinsic::invariant_end:
5790 case Intrinsic::clear_cache:
5792 case Intrinsic::donothing:
5795 case Intrinsic::experimental_stackmap: {
5799 case Intrinsic::experimental_patchpoint_void:
5800 case Intrinsic::experimental_patchpoint_i64: {
5801 visitPatchpoint(&I);
5804 case Intrinsic::experimental_gc_statepoint: {
5808 case Intrinsic::experimental_gc_result: {
5809 visitGCResult(cast<GCResultInst>(I));
5812 case Intrinsic::experimental_gc_relocate: {
5813 visitGCRelocate(cast<GCRelocateInst>(I));
5816 case Intrinsic::instrprof_increment:
5818 case Intrinsic::instrprof_value_profile:
5820 case Intrinsic::localescape: {
5828 if (isa<ConstantPointerNull>(Arg))
5832 "can only escape static allocas");
5838 TII->
get(TargetOpcode::LOCAL_ESCAPE))
5839 .addSym(FrameAllocSym)
5846 case Intrinsic::localrecover: {
5854 unsigned IdxVal =
unsigned(Idx->getLimitedValue(INT_MAX));
5874 case Intrinsic::eh_exceptionpointer:
5875 case Intrinsic::eh_exceptioncode: {
5883 if (Intrinsic == Intrinsic::eh_exceptioncode)
5888 case Intrinsic::xray_customevent: {
5919 case Intrinsic::experimental_deoptimize:
5923 case Intrinsic::experimental_vector_reduce_fadd:
5924 case Intrinsic::experimental_vector_reduce_fmul:
5925 case Intrinsic::experimental_vector_reduce_add:
5926 case Intrinsic::experimental_vector_reduce_mul:
5927 case Intrinsic::experimental_vector_reduce_and:
5928 case Intrinsic::experimental_vector_reduce_or:
5929 case Intrinsic::experimental_vector_reduce_xor:
5930 case Intrinsic::experimental_vector_reduce_smax:
5931 case Intrinsic::experimental_vector_reduce_smin:
5932 case Intrinsic::experimental_vector_reduce_umax:
5933 case Intrinsic::experimental_vector_reduce_umin:
5934 case Intrinsic::experimental_vector_reduce_fmax:
5935 case Intrinsic::experimental_vector_reduce_fmin: {
5936 visitVectorReduce(I, Intrinsic);
5943 void SelectionDAGBuilder::visitConstrainedFPIntrinsic(
5949 case Intrinsic::experimental_constrained_fadd:
5952 case Intrinsic::experimental_constrained_fsub:
5955 case Intrinsic::experimental_constrained_fmul:
5958 case Intrinsic::experimental_constrained_fdiv:
5961 case Intrinsic::experimental_constrained_frem:
5964 case Intrinsic::experimental_constrained_sqrt:
5967 case Intrinsic::experimental_constrained_pow:
5970 case Intrinsic::experimental_constrained_powi:
5973 case Intrinsic::experimental_constrained_sin:
5976 case Intrinsic::experimental_constrained_cos:
5979 case Intrinsic::experimental_constrained_exp:
5982 case Intrinsic::experimental_constrained_exp2:
5985 case Intrinsic::experimental_constrained_log:
5988 case Intrinsic::experimental_constrained_log10:
5991 case Intrinsic::experimental_constrained_log2:
5994 case Intrinsic::experimental_constrained_rint:
5997 case Intrinsic::experimental_constrained_nearbyint:
6024 std::pair<SDValue, SDValue>
6039 if (CallSiteIndex) {
6055 std::pair<SDValue, SDValue> Result = TLI.
LowerCallTo(CLI);
6058 "Non-null chain expected with non-tail call!");
6059 assert((Result.second.getNode() || !Result.first.getNode()) &&
6060 "Null value expected with tail call!");
6062 if (!Result.second.getNode()) {
6069 PendingExports.clear();
6085 BeginLabel, EndLabel);
6104 const Value *SwiftErrorVal =
nullptr;
6112 Caller->getAttributes().hasAttrSomewhere(Attribute::SwiftError))
6118 const Value *V = *i;
6135 .getOrCreateSwiftErrorVRegUseAt(
6141 Args.push_back(Entry);
6145 if (Entry.
IsSRet && isa<Instruction>(V))
6162 .
setCallee(RetTy, FTy, Callee, std::move(Args), CS)
6165 std::pair<SDValue, SDValue> Result =
lowerInvokable(CLI, EHPadBB);
6167 if (Result.first.getNode()) {
6179 unsigned VReg;
bool CreatedVReg;
6180 std::tie(VReg, CreatedVReg) =
6195 if (
const Constant *LoadInput = dyn_cast<Constant>(PtrVal)) {
6206 const_cast<Constant *>(LoadInput), LoadTy, *Builder.
DL))
6213 bool ConstantMemory =
false;
6218 ConstantMemory =
true;
6229 if (!ConstantMemory)
6236 void SelectionDAGBuilder::processIntegerCallValue(
const Instruction &I,
6253 bool SelectionDAGBuilder::visitMemCmpCall(
const CallInst &I) {
6268 if (Res.first.getNode()) {
6269 processIntegerCallValue(I, Res.first,
true);
6283 auto hasFastLoadsAndCompare = [&](
unsigned NumBits) {
6306 switch (NumBitsToCompare) {
6318 LoadVT = hasFastLoadsAndCompare(NumBitsToCompare);
6336 processIntegerCallValue(I, Cmp,
false);
6345 bool SelectionDAGBuilder::visitMemChrCall(
const CallInst &I) {
6351 std::pair<SDValue, SDValue> Res =
6355 if (Res.first.getNode()) {
6369 bool SelectionDAGBuilder::visitMemPCpyCall(
const CallInst &I) {
6376 unsigned Align =
std::min(DstAlign, SrcAlign);
6391 "** memcpy should not be lowered as TailCall in mempcpy context **");
6409 bool SelectionDAGBuilder::visitStrCpyCall(
const CallInst &I,
bool isStpcpy) {
6413 std::pair<SDValue, SDValue> Res =
6418 if (Res.first.getNode()) {
6432 bool SelectionDAGBuilder::visitStrCmpCall(
const CallInst &I) {
6436 std::pair<SDValue, SDValue> Res =
6441 if (Res.first.getNode()) {
6442 processIntegerCallValue(I, Res.first,
true);
6455 bool SelectionDAGBuilder::visitStrLenCall(
const CallInst &I) {
6459 std::pair<SDValue, SDValue> Res =
6462 if (Res.first.getNode()) {
6463 processIntegerCallValue(I, Res.first,
false);
6476 bool SelectionDAGBuilder::visitStrNLenCall(
const CallInst &I) {
6480 std::pair<SDValue, SDValue> Res =
6484 if (Res.first.getNode()) {
6485 processIntegerCallValue(I, Res.first,
false);
6498 bool SelectionDAGBuilder::visitUnaryFloatCall(
const CallInst &I,
6514 bool SelectionDAGBuilder::visitBinaryFloatCall(
const CallInst &I,
6527 void SelectionDAGBuilder::visitCall(
const CallInst &I) {
6537 const char *RenameFn =
nullptr;
6541 if (
unsigned IID = II->getIntrinsicID(F)) {
6542 RenameFn = visitIntrinsicCall(I, IID);
6548 RenameFn = visitIntrinsicCall(I, IID);
6563 case LibFunc_copysign:
6564 case LibFunc_copysignf:
6565 case LibFunc_copysignl:
6609 case LibFunc_sqrt_finite:
6610 case LibFunc_sqrtf_finite:
6611 case LibFunc_sqrtl_finite:
6616 case LibFunc_floorf:
6617 case LibFunc_floorl:
6621 case LibFunc_nearbyint:
6622 case LibFunc_nearbyintf:
6623 case LibFunc_nearbyintl:
6640 case LibFunc_roundf:
6641 case LibFunc_roundl:
6646 case LibFunc_truncf:
6647 case LibFunc_truncl:
6663 case LibFunc_memcmp:
6664 if (visitMemCmpCall(I))
6667 case LibFunc_mempcpy:
6668 if (visitMemPCpyCall(I))
6671 case LibFunc_memchr:
6672 if (visitMemChrCall(I))
6675 case LibFunc_strcpy:
6676 if (visitStrCpyCall(I,
false))
6679 case LibFunc_stpcpy:
6680 if (visitStrCpyCall(I,
true))
6683 case LibFunc_strcmp:
6684 if (visitStrCmpCall(I))
6687 case LibFunc_strlen:
6688 if (visitStrLenCall(I))
6691 case LibFunc_strnlen:
6692 if (visitStrNLenCall(I))
6711 "Cannot lower calls with arbitrary operand bundles!");
6747 for (
const auto &Code : Codes)
6761 if (isa<BasicBlock>(CallOperandVal))
6764 llvm::Type *OpTy = CallOperandVal->getType();
6777 if (
StructType *STy = dyn_cast<StructType>(OpTy))
6778 if (STy->getNumElements() == 1)
6779 OpTy = STy->getElementType(0);
6810 SDISelAsmOperandInfo &MatchingOpInfo,
6812 if (OpInfo.ConstraintVT == MatchingOpInfo.ConstraintVT)
6818 std::pair<unsigned, const TargetRegisterClass *> MatchRC =
6820 OpInfo.ConstraintVT);
6821 std::pair<unsigned, const TargetRegisterClass *> InputRC =
6823 MatchingOpInfo.ConstraintVT);
6824 if ((OpInfo.ConstraintVT.isInteger() !=
6825 MatchingOpInfo.ConstraintVT.isInteger()) ||
6826 (MatchRC.second != InputRC.second)) {
6829 " with a matching output constraint of"
6830 " incompatible type!");
6832 MatchingOpInfo.ConstraintVT = OpInfo.ConstraintVT;
6839 SDISelAsmOperandInfo &OpInfo,
6852 const Value *OpVal = OpInfo.CallOperandVal;
6853 if (isa<ConstantFP>(OpVal) || isa<ConstantInt>(OpVal) ||
6854 isa<ConstantVector>(OpVal) || isa<ConstantDataVector>(OpVal)) {
6868 Chain = DAG.
getStore(Chain, Location, OpInfo.CallOperand, StackSlot,
6870 OpInfo.CallOperand = StackSlot;
6885 SDISelAsmOperandInfo &OpInfo) {
6894 std::pair<unsigned, const TargetRegisterClass *> PhysReg =
6896 OpInfo.ConstraintVT);
6898 unsigned NumRegs = 1;
6909 if (RegVT.
getSizeInBits() == OpInfo.CallOperand.getValueSizeInBits()) {
6911 RegVT, OpInfo.CallOperand);
6912 OpInfo.ConstraintVT = RegVT;
6913 }
else if (RegVT.
isInteger() && OpInfo.ConstraintVT.isFloatingPoint()) {
6920 RegVT, OpInfo.CallOperand);
6921 OpInfo.ConstraintVT = RegVT;
6929 EVT ValueVT = OpInfo.ConstraintVT;
6933 if (
unsigned AssignedReg = PhysReg.first) {
6949 for (; *I != AssignedReg; ++
I)
6950 assert(I != RC->
end() &&
"Didn't find reg!");
6954 for (; NumRegs; --NumRegs, ++
I) {
6955 assert(I != RC->
end() &&
"Ran out of registers to allocate!");
6960 OpInfo.AssignedRegs =
RegsForValue(Regs, RegVT, ValueVT);
6973 for (; NumRegs; --NumRegs)
6976 OpInfo.AssignedRegs =
RegsForValue(Regs, RegVT, ValueVT);
6985 const std::vector<SDValue> &AsmNodeOperands) {
6988 for (; OperandNo; --OperandNo) {
6991 cast<ConstantSDNode>(AsmNodeOperands[CurOp])->getZExtValue();
6995 "Skipped past definitions?");
7007 for (
unsigned i = 0, e = NumRegs; i != e; ++i) {
7056 SDISelAsmOperandInfoVector ConstraintOperands;
7062 bool hasMemory =
false;
7069 for (
unsigned i = 0, e = TargetConstraints.size(); i != e; ++i) {
7070 ConstraintOperands.push_back(SDISelAsmOperandInfo(TargetConstraints[i]));
7071 SDISelAsmOperandInfo &OpInfo = ConstraintOperands.back();
7078 OpInfo.CallOperandVal =
const_cast<Value *
>(CS.
getArgument(ArgNo++));
7082 if (
const BasicBlock *BB = dyn_cast<BasicBlock>(OpInfo.CallOperandVal)) {
7085 OpInfo.CallOperand =
getValue(OpInfo.CallOperandVal);
7100 STy->getElementType(ResNo));
7102 assert(ResNo == 0 &&
"Asm only has one result!");
7108 OpInfo.ConstraintVT = OpVT;
7111 hasMemory = OpInfo.hasMemory(TLI);
7115 auto TargetConstraint = TargetConstraints[i];
7120 ExtraInfo.update(TargetConstraint);
7134 for (
unsigned i = 0, e = ConstraintOperands.size(); i != e; ++i) {
7135 SDISelAsmOperandInfo &OpInfo = ConstraintOperands[i];
7141 if (OpInfo.hasMatchingInput()) {
7142 SDISelAsmOperandInfo &Input = ConstraintOperands[OpInfo.MatchingInput];
7156 !OpInfo.isIndirect) {
7157 assert((OpInfo.isMultipleAlternative ||
7159 "Can only indirectify direct input operands!");
7165 OpInfo.CallOperandVal =
nullptr;
7168 OpInfo.isIndirect =
true;
7179 for (
unsigned i = 0, e = ConstraintOperands.size(); i != e; ++i) {
7180 SDISelAsmOperandInfo &OpInfo = ConstraintOperands[i];
7189 std::vector<SDValue> AsmNodeOperands;
7190 AsmNodeOperands.push_back(
SDValue());
7210 std::vector<std::pair<RegsForValue, Value*> > IndirectStoresToEmit;
7212 for (
unsigned i = 0, e = ConstraintOperands.size(); i != e; ++i) {
7213 SDISelAsmOperandInfo &OpInfo = ConstraintOperands[i];
7215 switch (OpInfo.Type) {
7220 assert(OpInfo.isIndirect &&
"Memory output must be indirect operand");
7222 unsigned ConstraintID =
7225 "Failed to convert memory constraint code to constraint id.");
7232 AsmNodeOperands.push_back(OpInfo.CallOperand);
7240 if (OpInfo.AssignedRegs.Regs.empty()) {
7242 CS,
"couldn't allocate output register for constraint '" +
7243 Twine(OpInfo.ConstraintCode) +
"'");
7249 if (OpInfo.isIndirect) {
7250 IndirectStoresToEmit.push_back(std::make_pair(OpInfo.AssignedRegs,
7251 OpInfo.CallOperandVal));
7256 RetValRegs.
append(OpInfo.AssignedRegs);
7262 .AddInlineAsmOperands(OpInfo.isEarlyClobber
7269 SDValue InOperandVal = OpInfo.CallOperand;
7271 if (OpInfo.isMatchingInputConstraint()) {
7277 cast<ConstantSDNode>(AsmNodeOperands[CurOp])->getZExtValue();
7281 if (OpInfo.isIndirect) {
7283 emitInlineAsmError(CS,
"inline asm not supported yet:"
7284 " don't know how to handle tied "
7285 "indirect register inputs");
7289 MVT RegVT = AsmNodeOperands[CurOp+1].getSimpleValueType();
7295 emitInlineAsmError(CS,
"inline asm error: This value type register "
7296 "class is not natively supported!");
7304 MatchedRegs.getCopyToRegs(InOperandVal,
DAG, dl, Chain, &Flag,
7307 true, OpInfo.getMatchedOperand(), dl,
7308 DAG, AsmNodeOperands);
7314 "Unexpected number of operands");
7319 OpInfo.getMatchedOperand());
7322 AsmNodeOperands.push_back(AsmNodeOperands[CurOp+1]);
7332 std::vector<SDValue> Ops;
7336 emitInlineAsmError(CS,
"invalid operand for inline asm constraint '" +
7337 Twine(OpInfo.ConstraintCode) +
"'");
7342 unsigned ResOpType =
7346 AsmNodeOperands.insert(AsmNodeOperands.end(), Ops.begin(), Ops.end());
7351 assert(OpInfo.isIndirect &&
"Operand must be indirect to be a mem!");
7354 "Memory operands expect pointer values");
7356 unsigned ConstraintID =
7359 "Failed to convert memory constraint code to constraint id.");
7367 AsmNodeOperands.push_back(InOperandVal);
7373 "Unknown constraint type!");
7376 if (OpInfo.isIndirect) {
7378 CS,
"Don't know how to handle indirect register inputs yet "
7379 "for constraint '" +
7380 Twine(OpInfo.ConstraintCode) +
"'");
7385 if (OpInfo.AssignedRegs.Regs.empty()) {
7386 emitInlineAsmError(CS,
"couldn't allocate input reg for constraint '" +
7387 Twine(OpInfo.ConstraintCode) +
"'");
7393 OpInfo.AssignedRegs.getCopyToRegs(InOperandVal,
DAG, dl,
7397 dl,
DAG, AsmNodeOperands);
7403 if (!OpInfo.AssignedRegs.Regs.empty())
7414 if (Flag.
getNode()) AsmNodeOperands.push_back(Flag);
7452 if (!IA->
hasSideEffects() && !hasMemory && IndirectStoresToEmit.empty())
7456 std::vector<std::pair<SDValue, const Value *> > StoresToEmit;
7460 for (
unsigned i = 0, e = IndirectStoresToEmit.size(); i != e; ++i) {
7462 const Value *Ptr = IndirectStoresToEmit[i].second;
7465 StoresToEmit.push_back(std::make_pair(OutVal, Ptr));
7470 for (
unsigned i = 0, e = StoresToEmit.size(); i != e; ++i) {
7477 if (!OutChains.
empty())
7484 const Twine &Message) {
7494 void SelectionDAGBuilder::visitVAStart(
const CallInst &I) {
7501 void SelectionDAGBuilder::visitVAArg(
const VAArgInst &I) {
7512 void SelectionDAGBuilder::visitVAEnd(
const CallInst &I) {
7519 void SelectionDAGBuilder::visitVACopy(
const CallInst &I) {
7559 for (
unsigned I = 1; I != NumVals; ++
I)
7573 unsigned ArgIdx,
unsigned NumArgs,
SDValue Callee,
Type *ReturnTy,
7574 bool IsPatchPoint) {
7576 Args.reserve(NumArgs);
7580 for (
unsigned ArgI = ArgIdx, ArgE = ArgIdx + NumArgs;
7581 ArgI != ArgE; ++ArgI) {
7582 const Value *V = CS->getOperand(ArgI);
7589 Entry.setAttributes(&CS, ArgIdx);
7590 Args.push_back(Entry);
7596 .setDiscardResult(CS->use_empty())
7597 .setIsPatchPoint(IsPatchPoint);
7620 for (
unsigned i = StartIdx, e = CS.
arg_size(); i != e; ++i) {
7637 void SelectionDAGBuilder::visitStackmap(
const CallInst &CI) {
7643 SDValue Chain, InFlag, Callee, NullPtr;
7666 cast<ConstantSDNode>(IDVal)->getZExtValue(),
DL,
MVT::i64));
7669 cast<ConstantSDNode>(NBytesVal)->getZExtValue(),
DL,
7686 InFlag = Chain.getValue(1);
7716 if (
auto* ConstCallee = dyn_cast<ConstantSDNode>(Callee))
7719 else if (
auto* SymbolicCallee = dyn_cast<GlobalAddressSDNode>(Callee))
7721 SDLoc(SymbolicCallee),
7722 SymbolicCallee->getValueType(0));
7726 unsigned NumArgs = cast<ConstantSDNode>(NArgVal)->getZExtValue();
7732 "Not enough arguments provided to the patchpoint intrinsic");
7735 unsigned NumCallArgs = IsAnyRegCC ? 0 : NumArgs;
7742 std::pair<SDValue, SDValue> Result =
lowerInvokable(CLI, EHPadBB);
7744 SDNode *CallEnd = Result.second.getNode();
7751 "Expected a callseq node.");
7761 cast<ConstantSDNode>(IDVal)->getZExtValue(), dl,
MVT::i64));
7764 cast<ConstantSDNode>(NBytesVal)->getZExtValue(), dl,
7773 unsigned NumCallRegArgs = Call->getNumOperands() - (HasGlue ? 4 : 3);
7774 NumCallRegArgs = IsAnyRegCC ? NumArgs : NumCallRegArgs;
7783 for (
unsigned i = NumMetaOpers, e = NumMetaOpers + NumArgs; i != e; ++i)
7788 Ops.
append(Call->op_begin() + 2, e);
7808 if (IsAnyRegCC && HasDef) {
7813 assert(ValueVTs.
size() == 1 &&
"Expected only one return value type.");
7838 if (IsAnyRegCC && HasDef) {
7850 void SelectionDAGBuilder::visitVectorReduce(
const CallInst &I,
7851 unsigned Intrinsic) {
7861 if (isa<FPMathOperator>(I))
7866 switch (Intrinsic) {
7867 case Intrinsic::experimental_vector_reduce_fadd:
7873 case Intrinsic::experimental_vector_reduce_fmul:
7879 case Intrinsic::experimental_vector_reduce_add:
7882 case Intrinsic::experimental_vector_reduce_mul:
7885 case Intrinsic::experimental_vector_reduce_and:
7888 case Intrinsic::experimental_vector_reduce_or:
7891 case Intrinsic::experimental_vector_reduce_xor:
7894 case Intrinsic::experimental_vector_reduce_smax:
7897 case Intrinsic::experimental_vector_reduce_smin:
7900 case Intrinsic::experimental_vector_reduce_umax:
7903 case Intrinsic::experimental_vector_reduce_umin:
7906 case Intrinsic::experimental_vector_reduce_fmax: {
7910 case Intrinsic::experimental_vector_reduce_fmin: {
7939 std::pair<SDValue, SDValue>
7953 for (
size_t i = 0, e = OldRetTys.
size(); i != e; ++i) {
7954 EVT RetVT = OldRetTys[i];
7955 uint64_t Offset = OldOffsets[i];
7959 RetTys.
append(NumRegs, RegisterVT);
7960 for (
unsigned j = 0; j != NumRegs; ++j)
7961 Offsets.
push_back(Offset + j * RegisterVTSize);
7973 int DemoteStackIdx = -100;
7974 if (!CanLowerReturn) {
7978 uint64_t TySize = DL.getTypeAllocSize(CLI.
RetTy);
7979 unsigned Align = DL.getPrefTypeAlignment(CLI.
RetTy);
7986 Entry.
Node = DemoteStackSlot;
7987 Entry.
Ty = StackSlotPtrType;
8005 for (
unsigned I = 0, E = RetTys.
size(); I !=
E; ++
I) {
8011 for (
unsigned i = 0; i != NumRegs; ++i) {
8013 MyFlags.
VT = RegisterVT;
8030 for (
unsigned i = 0, e = Args.size(); i != e; ++i) {
8031 if (Args[i].IsSwiftError) {
8044 for (
unsigned i = 0, e = Args.size(); i != e; ++i) {
8048 Type *FinalType = Args[i].Ty;
8049 if (Args[i].IsByVal)
8050 FinalType = cast<PointerType>(Args[i].Ty)->getElementType();
8053 for (
unsigned Value = 0, NumValues = ValueVTs.
size(); Value != NumValues;
8055 EVT VT = ValueVTs[Value];
8058 Args[i].Node.getResNo() + Value);
8070 if (Args[i].IsInReg) {
8074 isa<StructType>(FinalType)) {
8077 Flags.setHvaStart();
8085 if (Args[i].IsSwiftSelf)
8086 Flags.setSwiftSelf();
8087 if (Args[i].IsSwiftError)
8088 Flags.setSwiftError();
8089 if (Args[i].IsByVal)
8091 if (Args[i].IsInAlloca) {
8092 Flags.setInAlloca();
8100 if (Args[i].IsByVal || Args[i].IsInAlloca) {
8103 Flags.setByValSize(DL.getTypeAllocSize(ElementTy));
8106 unsigned FrameAlign;
8107 if (Args[i].Alignment)
8108 FrameAlign = Args[i].Alignment;
8111 Flags.setByValAlign(FrameAlign);
8116 Flags.setInConsecutiveRegs();
8117 Flags.setOrigAlign(OriginalAlignment);
8127 else if (Args[i].IsZExt)
8133 "unexpected use of 'returned'");
8146 CLI.
RetZExt == Args[i].IsZExt))
8147 Flags.setReturned();
8154 for (
unsigned j = 0; j != NumParts; ++j) {
8158 i, j*Parts[j].getValueType().getStoreSize());
8159 if (NumParts > 1 && j == 0)
8162 MyFlags.Flags.setOrigAlign(1);
8163 if (j == NumParts - 1)
8164 MyFlags.Flags.setSplitEnd();
8168 CLI.
OutVals.push_back(Parts[j]);
8171 if (NeedsRegBlock && Value == NumValues - 1)
8172 CLI.
Outs[CLI.
Outs.
size() - 1].Flags.setInConsecutiveRegsLast();
8184 "LowerCall didn't return a valid chain!");
8186 "LowerCall emitted a return value for a tail call!");
8188 "LowerCall didn't emit the correct number of values!");
8200 for (
unsigned i = 0, e = CLI.
Ins.
size(); i != e; ++i) {
8201 assert(InVals[i].getNode() &&
"LowerCall emitted a null value!");
8202 assert(
EVT(CLI.
Ins[i].VT) == InVals[i].getValueType() &&
8203 "LowerCall emitted a value with the wrong type!");
8208 if (!CanLowerReturn) {
8215 assert(PVTs.
size() == 1 &&
"Pointers should fit in one register");
8216 EVT PtrVT = PVTs[0];
8218 unsigned NumValues = RetTys.
size();
8219 ReturnValues.
resize(NumValues);
8227 for (
unsigned i = 0; i < NumValues; ++i) {
8232 RetTys[i], CLI.
DL, CLI.
Chain, Add,
8234 DemoteStackIdx, Offsets[i]),
8236 ReturnValues[i] =
L;
8249 unsigned CurReg = 0;
8250 for (
unsigned I = 0, E = RetTys.
size(); I !=
E; ++
I) {
8258 NumRegs, RegisterVT, VT,
nullptr,
8266 if (ReturnValues.
empty())
8272 return std::make_pair(Res, CLI.
Chain);
8291 "Copy from a reg to the same reg!");
8306 RFV.getCopyToRegs(Op,
DAG,
getCurSDLoc(), Chain,
nullptr, V, ExtendType);
8307 PendingExports.push_back(Chain);
8323 if (cast<Instruction>(U)->getParent() != &Entry || isa<SwitchInst>(U))
8330 std::pair<const AllocaInst *, const StoreInst *>>
8343 enum StaticAllocaInfo { Unknown, Clobbered, Elidable };
8346 StaticAllocas.
reserve(NumArgs * 2);
8348 auto GetInfoIfStaticAlloca = [&](
const Value *V) -> StaticAllocaInfo * {
8351 V = V->stripPointerCasts();
8353 if (!AI || !AI->isStaticAlloca() || !FuncInfo->
StaticAllocaMap.count(AI))
8355 auto Iter = StaticAllocas.
insert({AI, Unknown});
8356 return &Iter.first->second;
8372 if (isa<DbgInfoIntrinsic>(I))
8377 if (StaticAllocaInfo *Info = GetInfoIfStaticAlloca(U))
8378 *Info = StaticAllocaInfo::Clobbered;
8384 if (StaticAllocaInfo *Info = GetInfoIfStaticAlloca(
SI->getValueOperand()))
8385 *Info = StaticAllocaInfo::Clobbered;
8388 const Value *Dst =
SI->getPointerOperand()->stripPointerCasts();
8389 StaticAllocaInfo *Info = GetInfoIfStaticAlloca(Dst);
8392 const AllocaInst *AI = cast<AllocaInst>(Dst);
8400 const Value *Val =
SI->getValueOperand()->stripPointerCasts();
8401 const auto *Arg =
dyn_cast<Argument>(Val);
8402 if (!Arg || Arg->hasInAllocaAttr() || Arg->hasByValAttr() ||
8406 ArgCopyElisionCandidates.
count(Arg)) {
8407 *Info = StaticAllocaInfo::Clobbered;
8411 DEBUG(
dbgs() <<
"Found argument copy elision candidate: " << *AI <<
'\n');
8414 *Info = StaticAllocaInfo::Elidable;
8415 ArgCopyElisionCandidates.
insert({Arg, {AI,
SI}});
8420 if (ArgCopyElisionCandidates.
size() == NumArgs)
8432 SDValue ArgVal,
bool &ArgHasUses) {
8444 auto ArgCopyIter = ArgCopyElisionCandidates.
find(&Arg);
8445 assert(ArgCopyIter != ArgCopyElisionCandidates.
end());
8446 const AllocaInst *AI = ArgCopyIter->second.first;
8447 int FixedIndex = FINode->getIndex();
8449 int OldIndex = AllocaIndex;
8452 DEBUG(
dbgs() <<
" argument copy elision failed due to bad fixed stack "
8456 unsigned RequiredAlignment = AI->getAlignment();
8457 if (!RequiredAlignment) {
8459 AI->getAllocatedType());
8462 DEBUG(
dbgs() <<
" argument copy elision failed: alignment of alloca "
8463 "greater than stack argument alignment ("
8464 << RequiredAlignment <<
" vs "
8472 dbgs() <<
"Eliding argument copy from " << Arg <<
" to " << *AI <<
'\n'
8473 <<
" Replacing frame index " << OldIndex <<
" with " << FixedIndex
8478 AllocaIndex = FixedIndex;
8479 ArgCopyElisionFrameIndexMap.
insert({OldIndex, FixedIndex});
8484 ElidedArgCopyInstrs.
insert(SI);
8488 for (
const Value *U : Arg.
users()) {
8496 void SelectionDAGISel::LowerArguments(
const Function &F) {
8525 for (
const Argument &Arg : F.
args()) {
8526 unsigned ArgNo = Arg.getArgNo();
8530 unsigned PartBase = 0;
8532 if (Arg.hasAttribute(Attribute::ByVal))
8533 FinalType = cast<PointerType>(FinalType)->getElementType();
8536 for (
unsigned Value = 0, NumValues = ValueVTs.
size();
8537 Value != NumValues; ++Value) {
8538 EVT VT = ValueVTs[Value];
8545 unsigned OriginalAlignment =
8548 if (Arg.hasAttribute(Attribute::ZExt))
8550 if (Arg.hasAttribute(Attribute::SExt))
8552 if (Arg.hasAttribute(Attribute::InReg)) {
8556 isa<StructType>(Arg.
getType())) {
8565 if (Arg.hasAttribute(Attribute::StructRet))
8567 if (Arg.hasAttribute(Attribute::SwiftSelf))
8569 if (Arg.hasAttribute(Attribute::SwiftError))
8571 if (Arg.hasAttribute(Attribute::ByVal))
8573 if (Arg.hasAttribute(Attribute::InAlloca)) {
8593 unsigned FrameAlign;
8594 if (Arg.getParamAlignment())
8595 FrameAlign = Arg.getParamAlignment();
8600 if (Arg.hasAttribute(Attribute::Nest))
8605 if (ArgCopyElisionCandidates.
count(&Arg))
8612 for (
unsigned i = 0; i != NumRegs; ++i) {
8613 ISD::InputArg MyFlags(Flags, RegisterVT, VT, isArgValueUsed,
8615 if (NumRegs > 1 && i == 0)
8619 MyFlags.Flags.setOrigAlign(1);
8620 if (i == NumRegs - 1)
8621 MyFlags.Flags.setSplitEnd();
8625 if (NeedsRegBlock && Value == NumValues - 1)
8626 Ins[Ins.
size() - 1].Flags.setInConsecutiveRegsLast();
8638 "LowerFormalArguments didn't return a valid chain!");
8640 "LowerFormalArguments didn't emit the correct number of values!");
8642 for (
unsigned i = 0, e = Ins.
size(); i != e; ++i) {
8643 assert(InVals[i].getNode() &&
8644 "LowerFormalArguments emitted a null value!");
8645 assert(
EVT(Ins[i].VT) == InVals[i].getValueType() &&
8646 "LowerFormalArguments emitted a value with the wrong type!");
8651 DAG.setRoot(NewRoot);
8661 MVT VT = ValueVTs[0].getSimpleVT();
8665 RegVT, VT,
nullptr, AssertOp);
8673 DAG.setRoot(NewRoot);
8681 for (
const Argument &Arg : F.
args()) {
8685 unsigned NumValues = ValueVTs.
size();
8696 InVals[i], ArgHasUses);
8701 bool isSwiftErrorArg =
8703 Arg.hasAttribute(Attribute::SwiftError);
8704 if (!ArgHasUses && !isSwiftErrorArg) {
8709 dyn_cast<FrameIndexSDNode>(InVals[i].getNode()))
8713 for (
unsigned Val = 0; Val != NumValues; ++Val) {
8714 EVT VT = ValueVTs[Val];
8723 if (ArgHasUses || isSwiftErrorArg) {
8725 if (Arg.hasAttribute(Attribute::SExt))
8727 else if (Arg.hasAttribute(Attribute::ZExt))
8731 PartVT, VT,
nullptr, AssertOp,
8739 if (ArgValues.
empty())
8744 dyn_cast<FrameIndexSDNode>(ArgValues[0].getNode()))
8755 dyn_cast<FrameIndexSDNode>(LNode->getBasePtr().getNode()))
8786 if (!Chains.
empty()) {
8791 DAG.setRoot(NewRoot);
8793 assert(i == InVals.
size() &&
"Argument register count mismatch!");
8798 if (!DbgDeclareInfo.empty() && !ArgCopyElisionFrameIndexMap.
empty()) {
8800 auto I = ArgCopyElisionFrameIndexMap.
find(
VI.Slot);
8801 if (I != ArgCopyElisionFrameIndexMap.
end())
8802 VI.Slot = I->second;
8818 SelectionDAGBuilder::HandlePHINodesInSuccessorBlocks(
const BasicBlock *LLVMBB) {
8827 if (!isa<PHINode>(SuccBB->
begin()))
continue;
8832 if (!SuccsHandled.
insert(SuccMBB).second)
8852 if (
const Constant *
C = dyn_cast<Constant>(PHIOp)) {
8865 assert(isa<AllocaInst>(PHIOp) &&
8867 "Didn't codegen value into a register!??");
8878 for (
unsigned vti = 0, vte = ValueVTs.
size(); vti != vte; ++vti) {
8879 EVT VT = ValueVTs[vti];
8881 for (
unsigned i = 0, e = NumRegisters; i != e; ++i)
8883 std::make_pair(&*MBBI++, Reg + i));
8884 Reg += NumRegisters;
8889 ConstantsOut.clear();
8895 SelectionDAGBuilder::StackProtectorDescriptor::
8905 MF->
insert(++BBI, SuccMBB);
8925 void SelectionDAGBuilder::updateDAGForMaybeTailCall(
SDValue MaybeTC) {
8927 if (MaybeTC.
getNode() !=
nullptr)
8928 DAG.setRoot(MaybeTC);
8934 SelectionDAGBuilder::getJumpTableRange(
const CaseClusterVector &Clusters,
8935 unsigned First,
unsigned Last)
const {
8937 const APInt &LowCase = Clusters[First].Low->getValue();
8938 const APInt &HighCase = Clusters[Last].High->getValue();
8945 return (HighCase - LowCase).getLimitedValue((UINT64_MAX - 1) / 100) + 1;
8948 uint64_t SelectionDAGBuilder::getJumpTableNumCases(
8950 unsigned Last)
const {
8952 assert(TotalCases[Last] >= TotalCases[First]);
8954 TotalCases[Last] - (First == 0 ? 0 : TotalCases[First - 1]);
8958 bool SelectionDAGBuilder::buildJumpTable(
const CaseClusterVector &Clusters,
8959 unsigned First,
unsigned Last,
8962 CaseCluster &JTCluster) {
8966 unsigned NumCmps = 0;
8967 std::vector<MachineBasicBlock*> Table;
8971 for (
unsigned I = First; I <= Last; ++
I)
8974 for (
unsigned I = First; I <= Last; ++
I) {
8976 Prob += Clusters[
I].Prob;
8977 const APInt &Low = Clusters[
I].Low->getValue();
8978 const APInt &
High = Clusters[
I].High->getValue();
8979 NumCmps += (Low ==
High) ? 1 : 2;
8982 const APInt &PreviousHigh = Clusters[I - 1].High->getValue();
8984 uint64_t Gap = (Low - PreviousHigh).getLimitedValue() - 1;
8985 for (uint64_t J = 0; J < Gap; J++)
8986 Table.push_back(DefaultMBB);
8988 uint64_t ClusterSize = (High - Low).getLimitedValue() + 1;
8989 for (uint64_t J = 0; J < ClusterSize; ++J)
8990 Table.push_back(Clusters[I].MBB);
8991 JTProbs[Clusters[
I].MBB] += Clusters[
I].Prob;
8995 unsigned NumDests = JTProbs.
size();
8997 NumDests, NumCmps, Clusters[First].Low->getValue(),
8998 Clusters[Last].High->getValue(), DAG.getDataLayout())) {
9012 if (Done.
count(Succ))
9014 addSuccessorWithProb(JumpTableMBB, Succ, JTProbs[Succ]);
9020 ->createJumpTableIndex(Table);
9024 JumpTableHeader JTH(Clusters[First].Low->getValue(),
9027 JTCases.emplace_back(std::move(JTH), std::move(
JT));
9029 JTCluster = CaseCluster::jumpTable(Clusters[First].Low, Clusters[Last].High,
9034 void SelectionDAGBuilder::findJumpTables(CaseClusterVector &Clusters,
9039 assert(!Clusters.empty());
9040 for (CaseCluster &
C : Clusters)
9042 for (
unsigned i = 1, e = Clusters.size(); i < e; ++i)
9043 assert(Clusters[i - 1].High->getValue().
slt(Clusters[i].Low->getValue()));
9050 const int64_t N = Clusters.size();
9052 const unsigned SmallNumberOfEntries = MinJumpTableEntries / 2;
9054 if (N < 2 || N < MinJumpTableEntries)
9059 for (
unsigned i = 0; i <
N; ++i) {
9060 const APInt &
Hi = Clusters[i].High->getValue();
9061 const APInt &
Lo = Clusters[i].Low->getValue();
9062 TotalCases[i] = (Hi -
Lo).getLimitedValue() + 1;
9064 TotalCases[i] += TotalCases[i - 1];
9068 uint64_t Range = getJumpTableRange(Clusters,0, N - 1);
9069 uint64_t NumCases = getJumpTableNumCases(TotalCases, 0, N - 1);
9070 assert(NumCases < UINT64_MAX / 100);
9071 assert(Range >= NumCases);
9073 CaseCluster JTCluster;
9074 if (buildJumpTable(Clusters, 0, N - 1, SI, DefaultMBB, JTCluster)) {
9075 Clusters[0] = JTCluster;
9102 enum PartitionScores :
unsigned {
9110 MinPartitions[N - 1] = 1;
9111 LastElement[N - 1] = N - 1;
9112 PartitionsScore[N - 1] = PartitionScores::SingleCase;
9115 for (int64_t i = N - 2; i >= 0; i--) {
9118 MinPartitions[i] = MinPartitions[i + 1] + 1;
9120 PartitionsScore[i] = PartitionsScore[i + 1] + PartitionScores::SingleCase;
9123 for (int64_t j = N - 1; j > i; j--) {
9125 uint64_t Range = getJumpTableRange(Clusters, i, j);
9126 uint64_t NumCases = getJumpTableNumCases(TotalCases, i, j);
9127 assert(NumCases < UINT64_MAX / 100);
9128 assert(Range >= NumCases);
9130 unsigned NumPartitions = 1 + (j == N - 1 ? 0 : MinPartitions[j + 1]);
9131 unsigned Score = j == N - 1 ? 0 : PartitionsScore[j + 1];
9132 int64_t NumEntries = j - i + 1;
9134 if (NumEntries == 1)
9135 Score += PartitionScores::SingleCase;
9136 else if (NumEntries <= SmallNumberOfEntries)
9137 Score += PartitionScores::FewCases;
9138 else if (NumEntries >= MinJumpTableEntries)
9139 Score += PartitionScores::Table;
9143 if (NumPartitions < MinPartitions[i] ||
9144 (NumPartitions == MinPartitions[i] && Score > PartitionsScore[i])) {
9145 MinPartitions[i] = NumPartitions;
9147 PartitionsScore[i] = Score;
9154 unsigned DstIndex = 0;
9155 for (
unsigned First = 0, Last; First <
N; First = Last + 1) {
9156 Last = LastElement[First];
9158 assert(DstIndex <= First);
9159 unsigned NumClusters = Last - First + 1;
9161 CaseCluster JTCluster;
9162 if (NumClusters >= MinJumpTableEntries &&
9163 buildJumpTable(Clusters, First, Last, SI, DefaultMBB, JTCluster)) {
9164 Clusters[DstIndex++] = JTCluster;
9166 for (
unsigned I = First; I <= Last; ++
I)
9167 std::memmove(&Clusters[DstIndex++], &Clusters[I],
sizeof(Clusters[I]));
9170 Clusters.resize(DstIndex);
9173 bool SelectionDAGBuilder::buildBitTests(CaseClusterVector &Clusters,
9174 unsigned First,
unsigned Last,
9176 CaseCluster &BTCluster) {
9182 unsigned NumCmps = 0;
9183 for (int64_t I = First; I <= Last; ++
I) {
9185 Dests.set(Clusters[I].MBB->
getNumber());
9186 NumCmps += (Clusters[
I].Low == Clusters[
I].High) ? 1 : 2;
9188 unsigned NumDests = Dests.count();
9190 APInt Low = Clusters[First].Low->getValue();
9191 APInt High = Clusters[Last].High->getValue();
9196 if (!TLI.isSuitableForBitTests(NumDests, NumCmps, Low, High, DL))
9202 const int BitWidth = TLI.getPointerTy(DL).getSizeInBits();
9203 assert(TLI.rangeFitsInWord(Low, High, DL) &&
9204 "Case range must fit in bit mask!");
9208 bool ContiguousRange =
true;
9209 for (int64_t I = First + 1; I <= Last; ++
I) {
9210 if (Clusters[I].Low->getValue() != Clusters[I - 1].High->getValue() + 1) {
9211 ContiguousRange =
false;
9221 ContiguousRange =
false;
9224 CmpRange = High - Low;
9229 for (
unsigned i = First; i <= Last; ++i) {
9232 for (j = 0; j < CBV.size(); ++j)
9233 if (CBV[j].BB == Clusters[i].MBB)
9235 if (j == CBV.size())
9238 CaseBits *CB = &CBV[j];
9241 uint64_t Lo = (Clusters[i].Low->getValue() - LowBound).getZExtValue();
9242 uint64_t Hi = (Clusters[i].High->getValue() - LowBound).getZExtValue();
9243 assert(Hi >= Lo && Hi < 64 &&
"Invalid bit case!");
9244 CB->Mask |= (-1ULL >> (63 - (Hi -
Lo))) << Lo;
9245 CB->Bits += Hi - Lo + 1;
9246 CB->ExtraProb += Clusters[i].Prob;
9247 TotalProb += Clusters[i].Prob;
9251 std::sort(CBV.begin(), CBV.end(), [](
const CaseBits &a,
const CaseBits &b) {
9253 if (a.ExtraProb != b.ExtraProb)
9254 return a.ExtraProb > b.ExtraProb;
9255 return a.Bits > b.Bits;
9258 for (
auto &CB : CBV) {
9261 BTI.
push_back(BitTestCase(CB.Mask, BitTestBB, CB.BB, CB.ExtraProb));
9263 BitTestCases.emplace_back(std::move(LowBound), std::move(CmpRange),
9265 ContiguousRange,
nullptr,
nullptr, std::move(BTI),
9268 BTCluster = CaseCluster::bitTests(Clusters[First].Low, Clusters[Last].High,
9273 void SelectionDAGBuilder::findBitTestClusters(CaseClusterVector &Clusters,
9280 assert(!Clusters.empty());
9281 assert(Clusters[0].
Kind == CC_Range || Clusters[0].
Kind == CC_JumpTable);
9282 for (
const CaseCluster &
C : Clusters)
9283 assert(
C.Kind == CC_Range ||
C.Kind == CC_JumpTable);
9284 for (
unsigned i = 1; i < Clusters.size(); ++i)
9285 assert(Clusters[i-1].High->getValue().
slt(Clusters[i].Low->getValue()));
9301 const int64_t N = Clusters.size();
9311 MinPartitions[N - 1] = 1;
9312 LastElement[N - 1] = N - 1;
9315 for (int64_t i = N - 2; i >= 0; --i) {
9318 MinPartitions[i] = MinPartitions[i + 1] + 1;
9323 for (int64_t j =
std::min(N - 1, i + BitWidth - 1); j > i; --j) {
9328 Clusters[j].High->getValue(),
DL))
9333 bool RangesOnly =
true;
9335 for (int64_t k = i; k <= j; k++) {
9336 if (Clusters[k].
Kind != CC_Range) {
9340 Dests.set(Clusters[k].MBB->getNumber());
9342 if (!RangesOnly || Dests.count() > 3)
9346 unsigned NumPartitions = 1 + (j == N - 1 ? 0 : MinPartitions[j + 1]);
9347 if (NumPartitions < MinPartitions[i]) {
9349 MinPartitions[i] = NumPartitions;
9356 unsigned DstIndex = 0;
9357 for (
unsigned First = 0, Last; First <
N; First = Last + 1) {
9358 Last = LastElement[First];
9360 assert(DstIndex <= First);
9362 CaseCluster BitTestCluster;
9363 if (buildBitTests(Clusters, First, Last, SI, BitTestCluster)) {
9364 Clusters[DstIndex++] = BitTestCluster;
9366 size_t NumClusters = Last - First + 1;
9367 std::memmove(&Clusters[DstIndex], &Clusters[First],
9368 sizeof(Clusters[0]) * NumClusters);
9369 DstIndex += NumClusters;
9372 Clusters.resize(DstIndex);
9375 void SelectionDAGBuilder::lowerWorkItem(SwitchWorkListItem W, Value *Cond,
9384 unsigned Size = W.LastCluster - W.FirstCluster + 1;
9388 if (Size == 2 && W.MBB == SwitchMBB) {
9396 CaseCluster &
Small = *W.FirstCluster;
9397 CaseCluster &Big = *W.LastCluster;
9399 if (Small.Low == Small.High && Big.Low == Big.High &&
9400 Small.MBB == Big.MBB) {
9401 const APInt &SmallValue = Small.Low->getValue();
9402 const APInt &BigValue = Big.Low->getValue();
9405 APInt CommonBit = BigValue ^ SmallValue;
9412 DAG.getConstant(CommonBit, DL, VT));
9414 DL,
MVT::i1, Or, DAG.getConstant(BigValue | SmallValue, DL, VT),
9420 addSuccessorWithProb(SwitchMBB, Small.MBB, Small.Prob + Big.Prob);
9422 addSuccessorWithProb(
9423 SwitchMBB, DefaultMBB,
9427 addSuccessorWithProb(SwitchMBB, DefaultMBB);
9432 DAG.getBasicBlock(Small.MBB));
9435 DAG.getBasicBlock(DefaultMBB));
9437 DAG.setRoot(BrCond);
9445 std::sort(W.FirstCluster, W.LastCluster + 1,
9446 [](
const CaseCluster &a,
const CaseCluster &b) {
9447 return a.Prob > b.Prob;
9452 for (CaseClusterIt I = W.LastCluster; I > W.FirstCluster; ) {
9454 if (I->Prob > W.LastCluster->Prob)
9456 if (I->Kind == CC_Range && I->MBB == NextMBB) {
9466 for (CaseClusterIt I = W.FirstCluster; I <= W.LastCluster; ++I)
9467 UnhandledProbs += I->Prob;
9470 for (CaseClusterIt I = W.FirstCluster, E = W.LastCluster; I <= E; ++I) {
9472 if (I == W.LastCluster) {
9474 Fallthrough = DefaultMBB;
9477 CurMF->
insert(BBI, Fallthrough);
9479 ExportFromCurrentBlock(Cond);
9481 UnhandledProbs -= I->Prob;
9484 case CC_JumpTable: {
9486 JumpTableHeader *JTH = &JTCases[I->JTCasesIndex].first;
9491 CurMF->
insert(BBI, JumpMBB);
9493 auto JumpProb = I->Prob;
9494 auto FallthroughProb = UnhandledProbs;
9502 if (*SI == DefaultMBB) {
9503 JumpProb += DefaultProb / 2;
9504 FallthroughProb -= DefaultProb / 2;
9511 addSuccessorWithProb(CurMBB, Fallthrough, FallthroughProb);
9512 addSuccessorWithProb(CurMBB, JumpMBB, JumpProb);
9517 JTH->HeaderBB = CurMBB;
9518 JT->Default = Fallthrough;
9521 if (CurMBB == SwitchMBB) {
9522 visitJumpTableHeader(*JT, *JTH, SwitchMBB);
9523 JTH->Emitted =
true;
9529 BitTestBlock *BTB = &BitTestCases[I->BTCasesIndex];
9532 for (BitTestCase &BTC : BTB->Cases)
9533 CurMF->
insert(BBI, BTC.ThisBB);
9536 BTB->Parent = CurMBB;
9537 BTB->Default = Fallthrough;
9539 BTB->DefaultProb = UnhandledProbs;
9543 if (!BTB->ContiguousRange) {
9544 BTB->Prob += DefaultProb / 2;
9545 BTB->DefaultProb -= DefaultProb / 2;
9549 if (CurMBB == SwitchMBB) {
9550 visitBitTestHeader(*BTB, SwitchMBB);
9551 BTB->Emitted =
true;
9556 const Value *RHS, *LHS, *MHS;
9558 if (I->Low == I->High) {
9573 CaseBlock CB(CC, LHS, RHS, MHS, I->MBB, Fallthrough, CurMBB, I->Prob,
9576 if (CurMBB == SwitchMBB)
9577 visitSwitchCase(CB, SwitchMBB);
9579 SwitchCases.push_back(CB);
9584 CurMBB = Fallthrough;
9588 unsigned SelectionDAGBuilder::caseClusterRank(
const CaseCluster &CC,
9589 CaseClusterIt First,
9590 CaseClusterIt Last) {
9591 return std::count_if(First, Last + 1, [&](
const CaseCluster &
X) {
9592 if (X.Prob != CC.Prob)
9593 return X.Prob > CC.Prob;
9596 return X.Low->getValue().slt(CC.Low->getValue());
9600 void SelectionDAGBuilder::splitWorkItem(SwitchWorkList &WorkList,
9601 const SwitchWorkListItem &W,
9604 assert(W.FirstCluster->Low->getValue().slt(W.LastCluster->Low->getValue()) &&
9605 "Clusters not sorted?");
9607 assert(W.LastCluster - W.FirstCluster + 1 >= 2 &&
"Too small to split!");
9612 CaseClusterIt LastLeft = W.FirstCluster;
9613 CaseClusterIt FirstRight = W.LastCluster;
9614 auto LeftProb = LastLeft->Prob + W.DefaultProb / 2;
9615 auto RightProb = FirstRight->Prob + W.DefaultProb / 2;
9622 while (LastLeft + 1 < FirstRight) {
9623 if (LeftProb < RightProb || (LeftProb == RightProb && (I & 1)))
9624 LeftProb += (++LastLeft)->Prob;
9626 RightProb += (--FirstRight)->Prob;
9636 unsigned NumLeft = LastLeft - W.FirstCluster + 1;
9637 unsigned NumRight = W.LastCluster - FirstRight + 1;
9643 if (NumLeft < NumRight) {
9645 CaseCluster &CC = *FirstRight;
9646 unsigned RightSideRank = caseClusterRank(CC, FirstRight, W.LastCluster);
9647 unsigned LeftSideRank = caseClusterRank(CC, W.FirstCluster, LastLeft);
9648 if (LeftSideRank <= RightSideRank) {
9655 assert(NumRight < NumLeft);
9657 CaseCluster &CC = *LastLeft;
9658 unsigned LeftSideRank = caseClusterRank(CC, W.FirstCluster, LastLeft);
9659 unsigned RightSideRank = caseClusterRank(CC, FirstRight, W.LastCluster);
9660 if (RightSideRank <= LeftSideRank) {
9671 assert(LastLeft + 1 == FirstRight);
9672 assert(LastLeft >= W.FirstCluster);
9673 assert(FirstRight <= W.LastCluster);
9677 CaseClusterIt PivotCluster = FirstRight;
9678 assert(PivotCluster > W.FirstCluster);
9679 assert(PivotCluster <= W.LastCluster);
9681 CaseClusterIt FirstLeft = W.FirstCluster;
9682 CaseClusterIt LastRight = W.LastCluster;
9694 if (FirstLeft == LastLeft && FirstLeft->Kind == CC_Range &&
9695 FirstLeft->Low == W.GE &&
9696 (FirstLeft->High->getValue() + 1LL) == Pivot->
getValue()) {
9697 LeftMBB = FirstLeft->MBB;
9702 {LeftMBB, FirstLeft, LastLeft, W.GE, Pivot, W.DefaultProb / 2});
9711 if (FirstRight == LastRight && FirstRight->Kind == CC_Range &&
9712 W.LT && (FirstRight->High->getValue() + 1ULL) == W.LT->getValue()) {
9713 RightMBB = FirstRight->MBB;
9718 {RightMBB, FirstRight, LastRight, Pivot, W.LT, W.DefaultProb / 2});
9724 CaseBlock CB(
ISD::SETLT, Cond, Pivot,
nullptr, LeftMBB, RightMBB, W.MBB,
9725 LeftProb, RightProb);
9727 if (W.MBB == SwitchMBB)
9733 void SelectionDAGBuilder::visitSwitch(
const SwitchInst &SI) {
9736 CaseClusterVector Clusters;
9738 for (
auto I : SI.
cases()) {
9744 Clusters.push_back(CaseCluster::range(CaseVal, CaseVal, Succ, Prob));
9752 sortAndRangeify(Clusters);
9757 bool UnreachableDefault =
9759 if (UnreachableDefault && !Clusters.empty()) {
9761 unsigned MaxPop = 0;
9763 for (
auto I : SI.
cases()) {
9765 if (++Popularity[BB] > MaxPop) {
9766 MaxPop = Popularity[BB];
9771 assert(MaxPop > 0 && MaxBB);
9776 CaseClusterVector New;
9777 New.reserve(Clusters.size());
9778 for (CaseCluster &CC : Clusters) {
9779 if (CC.MBB != DefaultMBB)
9782 Clusters = std::move(New);
9788 if (Clusters.empty()) {
9790 if (DefaultMBB != NextBlock(SwitchMBB)) {
9797 findJumpTables(Clusters, &SI, DefaultMBB);
9798 findBitTestClusters(Clusters, &SI);
9801 dbgs() <<
"Case clusters: ";
9802 for (
const CaseCluster &
C : Clusters) {
9803 if (
C.Kind == CC_JumpTable)
dbgs() <<
"JT:";
9804 if (
C.Kind == CC_BitTests)
dbgs() <<
"BT:";
9806 C.Low->getValue().print(
dbgs(),
true);
9807 if (
C.Low !=
C.High) {
9809 C.High->getValue().print(
dbgs(),
true);
9816 assert(!Clusters.empty());
9817 SwitchWorkList WorkList;
9818 CaseClusterIt First = Clusters.begin();
9819 CaseClusterIt Last = Clusters.end() - 1;
9820 auto DefaultProb = getEdgeProbability(SwitchMBB, DefaultMBB);
9821 WorkList.push_back({SwitchMBB, First, Last,
nullptr,
nullptr, DefaultProb});
9823 while (!WorkList.empty()) {
9824 SwitchWorkListItem W = WorkList.back();
9825 WorkList.pop_back();
9826 unsigned NumClusters = W.LastCluster - W.FirstCluster + 1;
9831 splitWorkItem(WorkList, W, SI.
getCondition(), SwitchMBB);
9835 lowerWorkItem(W, SI.
getCondition(), SwitchMBB, DefaultMBB);
MVT getSimpleValueType() const
Return the simple ValueType of the referenced return value.
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.
void setHasStackMap(bool s=true)
ADJUST_TRAMPOLINE - This corresponds to the adjust_trampoline intrinsic.
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
void setAllowReciprocal(bool b)
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 ...
BasicBlock * getSuccessor(unsigned i) const
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()
const Value * getCalledValue() const
Get a pointer to the function that is invoked by this instruction.
std::vector< BitTestBlock > BitTestCases
BitTestCases - Vector of BitTestBlock structures used to communicate SwitchInst code generation infor...
static MVT getIntegerVT(unsigned BitWidth)
Value * getRawSource() const
Return the arguments to the instruction.
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.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
bool isEHPad() const
Returns true if the block is a landing pad.
SelectionDAGBuilder * SDB
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 ...
A parsed version of the target data layout string in and methods for querying it. ...
AtomicOrdering getFailureOrdering() const
Returns the failure ordering constraint of this cmpxchg instruction.
AsmDialect getDialect() const
static ConstantInt * getFalse(LLVMContext &Context)
CallingConv::ID getLibcallCallingConv(RTLIB::Libcall Call) const
Get the CallingConv that should be used for the specified libcall.
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...
SDValue getValue(unsigned R) const
This class is the base class for the comparison instructions.
const SelectionDAGTargetInfo & getSelectionDAGInfo() const
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...
bool findValue(const Value *V) const
Constrained versions of libm-equivalent floating point intrinsics.
virtual ConstraintType getConstraintType(StringRef Constraint) const
Given a constraint, return the type of constraint it is for this target.
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 isOnlyUsedInZeroEqualityComparison(const Instruction *CxtI)
iterator_range< CaseIt > cases()
Iteration adapter for range-for loops.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
LLVMContext * getContext() const
This class represents an incoming formal argument to a Function.
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.
const Instruction & back() 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)...
void addStackRoot(int Num, const Constant *Metadata)
addStackRoot - Registers a root that lives on the stack.
virtual SDValue prepareVolatileOrAtomicLoad(SDValue Chain, const SDLoc &DL, SelectionDAG &DAG) const
This callback is used to prepare for a volatile or atomic load.
DELETED_NODE - This is an illegal value that is used to catch errors.
EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR (an vector value) starting with the ...
LegalizeTypeAction getTypeAction(LLVMContext &Context, EVT VT) const
Return how we should legalize values of this type, either it is already legal (return 'Legal') or we ...
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
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...
void setCopyElisionCandidate()
bool isVolatile() const
Return true if this is a store to a volatile memory location.
void ExportFromCurrentBlock(const Value *V)
ExportFromCurrentBlock - If this condition isn't known to be exported from the current basic block...
const TargetLibraryInfo * LibInfo
unsigned getNumRegisters(LLVMContext &Context, EVT VT) const
Return the number of registers that this ValueType will eventually require.
static SDValue expandExp2(const SDLoc &dl, SDValue Op, SelectionDAG &DAG, const TargetLowering &TLI)
expandExp2 - Lower an exp2 intrinsic.
SDDbgValue * getDbgValue(MDNode *Var, MDNode *Expr, SDNode *N, unsigned R, bool IsIndirect, uint64_t Off, const DebugLoc &DL, unsigned O)
Creates a SDDbgValue node.
void setMemRefs(mmo_iterator NewMemRefs, mmo_iterator NewMemRefsEnd)
Assign this MachineSDNodes's memory reference descriptor list.
static void getCopyToParts(SelectionDAG &DAG, const SDLoc &DL, SDValue Val, SDValue *Parts, unsigned NumParts, MVT PartVT, const Value *V, ISD::NodeType ExtendKind=ISD::ANY_EXTEND, bool IsABIRegCopy=false)
getCopyToParts - Create a series of nodes that contain the specified value split into legal parts...
void setCallsUnwindInit(bool b)
bool onlyReadsMemory() const
Determine if the function does not access or only reads memory.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
unsigned getCatchPadExceptionPointerVReg(const Value *CPI, const TargetRegisterClass *RC)
unsigned EnableFastISel
EnableFastISel - This flag enables fast-path instruction selection which trades away generated code q...
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
A Module instance is used to store all the information related to an LLVM module. ...
void LowerDeoptimizeCall(const CallInst *CI)
AtomicOrdering getSuccessOrdering() const
Returns the success ordering constraint of this cmpxchg instruction.
An instruction for ordering other memory operations.
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
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.
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs, and aliases.
const Value * getSplatValue(const Value *V)
Get splat value if the input is a splat vector or return nullptr.
unsigned createVirtualRegister(const TargetRegisterClass *RegClass)
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
Maximum length of the test input libFuzzer tries to guess a good value based on the corpus and reports it always prefer smaller inputs during the corpus shuffle When libFuzzer itself reports a bug this exit code will be used If indicates the maximal total time in seconds to run the fuzzer minimizes the provided crash input Use with tries to cleanse the provided crash input to make it contain fewer original bytes Use with exact_artifact_path to specify the output Experimental Use value profile to guide fuzzing Number of jobs to run If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
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...
virtual unsigned getNumRegistersForCallingConv(LLVMContext &Context, EVT VT) const
Certain targets require unusual breakdowns of certain types.
Attribute getAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return the attribute object that exists at the given index.
static unsigned LimitFloatPrecision
LimitFloatPrecision - Generate low-precision inline sequences for some float libcalls (6...
DILocalScope * getScope() const
Get the local scope for this variable.
void addLandingPadInfo(const LandingPadInst &I, MachineBasicBlock &MBB)
Extract the exception handling information from the landingpad instruction and add them to the specif...
unsigned getNumOperands() const
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this cmpxchg instruction.
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.
const TargetMachine & getTarget() const
unsigned getPrefTypeAlignment(Type *Ty) const
Returns the preferred stack/global alignment for the specified type.
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)
SDNode * getGluedNode() const
If this node has a glue operand, return the node to which the glue operand points.
unsigned getScalarSizeInBits() const
bool isNonNegative() const
Determine if this APInt Value is non-negative (>= 0)
void LowerStatepoint(ImmutableStatepoint Statepoint, const BasicBlock *EHPadBB=nullptr)
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
const TargetSubtargetInfo & getSubtarget() const
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.
bool isConvergent() const
Determine if the call is convergent.
static SDValue getCopyFromParts(SelectionDAG &DAG, const SDLoc &DL, const SDValue *Parts, unsigned NumParts, MVT PartVT, EVT ValueVT, const Value *V, Optional< ISD::NodeType > AssertOp=None, bool IsABIRegCopy=false)
getCopyFromParts - Create a value that contains the specified legal parts combined into the value the...
unsigned InferPtrAlignment(SDValue Ptr) const
Infer alignment of a load / store address.
MVT getSimpleValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
Return the MVT corresponding to this LLVM type. See getValueType.
bool usesUnderscoreSetJmp() const
Determine if we should use _setjmp or setjmp to implement llvm.setjmp.
Predicate getInversePredicate() const
For example, EQ -> NE, UGT -> ULE, SLT -> SGE, OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc.
Libcall
RTLIB::Libcall enum - This enum defines all of the runtime library calls the backend can emit...
const std::string & getAsmString() const
static uint64_t round(uint64_t Acc, uint64_t Input)
const CallInst * getTerminatingDeoptimizeCall() const
Returns the call instruction calling .experimental.deoptimize prior to the terminating return instruc...
gep_type_iterator gep_type_end(const User *GEP)
SDValue getBasicBlock(MachineBasicBlock *MBB)
RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
*p = old <unsigned v ? old : v
void LowerDeoptimizingReturn()
void setValue(const Value *V, SDValue NewN)
unsigned getID() const
Return the register class ID number.
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
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.
*p = old >unsigned v ? old : v
Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
unsigned getSizeInBits() const
This instruction constructs a fixed permutation of two input vectors.
virtual bool functionArgumentNeedsConsecutiveRegisters(Type *Ty, CallingConv::ID CallConv, bool isVarArg) const
For some targets, an LLVM struct type must be broken down into multiple simple types, but the calling convention specifies that the entire struct must be passed in a block of consecutive registers.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
bool isTokenTy() const
Return true if this is 'token'.
void addSuccessorWithoutProb(MachineBasicBlock *Succ)
Add Succ as a successor of this MachineBasicBlock.
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()
FastMathFlags getFastMathFlags() const
Convenience function for getting all the fast-math flags, which must be an operator which supports th...
const Function * getParent() const
Return the enclosing method, or null if none.
unsigned getNumSuccessors() const
Return the number of successors that this terminator has.
Value * getNewValOperand()
Constrained versions of the binary floating point operators.
const SDValue & getOperand(unsigned Num) const
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
CallLoweringInfo & setDebugLoc(const SDLoc &dl)
This class represents a sign extension of integer types.
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...
virtual bool allowsMisalignedMemoryAccesses(EVT, unsigned AddrSpace=0, unsigned Align=1, bool *=nullptr) const
Determine if the target supports unaligned memory accesses.
An instruction for reading from memory.
bool getLibFunc(StringRef funcName, LibFunc &F) const
Searches for a particular function name.
[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.
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...
SDValue getTargetExternalSymbol(const char *Sym, EVT VT, unsigned char TargetFlags=0)
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
SDDbgValue * getFrameIndexDbgValue(MDNode *Var, MDNode *Expr, unsigned FI, uint64_t Off, const DebugLoc &DL, unsigned O)
FrameIndex.
This is the common base class for constrained floating point intrinsics.
bool CanLowerReturn
CanLowerReturn - true iff the function's return value can be lowered to registers.
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.
Type * getElementType() const
virtual unsigned getExceptionPointerRegister(const Constant *PersonalityFn) const
If a physical register, this returns the register that receives the exception address on entry to an ...
bool isNoBuiltin() const
Return true if the call should not be treated as a call to a builtin.
GlobalValue * ExtractTypeInfo(Value *V)
ExtractTypeInfo - Returns the type info, possibly bitcast, encoded in V.
static void diagnosePossiblyInvalidConstraint(LLVMContext &Ctx, const Value *V, const Twine &ErrMsg)
void setNoSignedZeros(bool b)
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
DebugLoc getCurDebugLoc() const
uint64_t getOffset() const
static unsigned getUnderlyingArgReg(const SDValue &N)
EntryToken - This is the marker used to indicate the start of a region.
bool optForSize() const
Optimize this function for size (-Os) or minimum size (-Oz).
OUTCHAIN = ATOMIC_FENCE(INCHAIN, ordering, scope) This corresponds to the fence instruction.
void setCurrentSwiftErrorVReg(const MachineBasicBlock *MBB, const Value *, unsigned)
Set the swifterror virtual register in the SwiftErrorVRegDefMap for this basic block.
void AddDbgValue(SDDbgValue *DB, SDNode *SD, bool isParameter)
Add a dbg_value SDNode.
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
unsigned getResNo() const
get the index which selects a specific result in the SDNode
SDValue getMCSymbol(MCSymbol *Sym, EVT VT)
void ReplaceAllUsesOfValuesWith(const SDValue *From, const SDValue *To, unsigned Num)
Like ReplaceAllUsesOfValueWith, but for multiple values at once.
bool bitsLT(EVT VT) const
Return true if this has less bits than VT.
VariableDbgInfoMapTy & getVariableDbgInfo()
bool IsABIMangled
Records if this value needs to be treated in an ABI dependant manner, different to normal type legali...
bool optForMinSize() const
Optimize this function for minimum size (-Oz).
SDValue getExternalSymbol(const char *Sym, EVT VT)
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
unsigned arg_size() const
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.
RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) This node represents a target in...
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...
iterator begin()
Instruction iterator methods.
AttributeList getAttributes() const
Return the attribute list for this Function.
const Triple & getTargetTriple() const
bool isSingleValueType() const
Return true if the type is a valid type for a register in codegen.
OUTCHAIN = EH_SJLJ_LONGJMP(INCHAIN, buffer) This corresponds to the eh.sjlj.longjmp intrinsic...
X86_INTR - x86 hardware interrupt context.
std::pair< unsigned, bool > getOrCreateSwiftErrorVRegDefAt(const Instruction *)
Get or create the swifterror value virtual register for a def of a swifterror by an instruction...
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
bool isVector() const
Return true if this is a vector value type.
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 ...
Value * getAddress() const
SDValue getRoot()
Return the current virtual root of the Selection DAG, flushing any PendingLoad items.
The address of a basic block.
bool onlyReadsMemory() const
Determine if the call does not access or only reads memory.
bool hasOperandBundlesOtherThan(ArrayRef< uint32_t > IDs) const
Return true if this operand bundle user contains operand bundles with tags other than those specified...
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.
Value * getRawDest() const
bool hasNoNaNs() const
Determine whether the no-NaNs flag is set.
bool isUnconditional() const
A description of a memory reference used in the backend.
unsigned DemoteRegister
DemoteRegister - if CanLowerReturn is false, DemoteRegister is a vreg allocated to hold a pointer to ...
void setHasPatchPoint(bool s=true)
static unsigned getFlagWordForRegClass(unsigned InputFlag, unsigned RC)
getFlagWordForRegClass - Augment an existing flag word returned by getFlagWord with the required regi...
void AddInlineAsmOperands(unsigned Kind, bool HasMatching, unsigned MatchingIdx, const SDLoc &dl, SelectionDAG &DAG, std::vector< SDValue > &Ops) const
Add this value to the specified inlineasm node operand list.
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...
unsigned getNumBlockIDs() const
getNumBlockIDs - Return the number of MBB ID's allocated.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
bool hasGC() const
hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm to use during code generatio...
PCMARKER - This corresponds to the pcmarker intrinsic.
bool noSignedZeros() const
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
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this store instruction.
const APInt & getValue() const
Return the constant as an APInt value reference.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
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)
static bool hasOnlySelectUsers(const Value *Cond)
Shift and rotation operations.
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
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.
Class to represent struct types.
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
A Use represents the edge between a Value definition and its users.
const Value * SwiftErrorArg
The swifterror argument of the current function.
MachineSDNode * getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT)
These are used for target selectors to create a new node with specified return type(s), MachineInstr opcode, and operands.
MachineFunction & getMachineFunction() const
void visitJumpTable(JumpTable &JT)
visitJumpTable - Emit JumpTable node in the current MBB
DenseMap< const Value *, unsigned > ValueMap
ValueMap - Since we emit code for the function a basic block at a time, we must remember which virtua...
ValTy * getCalledValue() const
Return the pointer to function that is being called.
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...
bool isReg() const
isReg - Tests if this is a MO_Register operand.
unsigned getNumArgOperands() const
Return the number of call arguments.
DenseMap< const Argument *, std::pair< const AllocaInst *, const StoreInst * > > ArgCopyElisionMapTy
virtual bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const
Returns true if a cast between SrcAS and DestAS is a noop.
const TargetRegisterClass * getRegClass(unsigned Reg) const
Return the register class of the specified virtual register.
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 ...
const Value * getCalledValue() const
Get a pointer to the function that is invoked by this instruction.
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
iterator begin() const
begin/end - Return all of the registers in this class.
Constant * getPersonalityFn() const
Get the personality function associated with this function.
Reg
All possible values of the reg field in the ModR/M byte.
TypeID
Definitions of all of the base types for the Type system.
NaN behavior not applicable.
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).
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
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.
static bool isRegDefEarlyClobberKind(unsigned Flag)
static unsigned convertMemFlagWordToMatchingFlagWord(unsigned InputFlag)
bool bitsGE(EVT VT) const
Return true if this has no less bits than VT.
void setByValSize(unsigned S)
SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
unsigned getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
MSVC calling convention that passes vectors and vector aggregates in SSE registers.
FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and llvm.returnaddress on the DAG...
void setFunctionContextIndex(int I)
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.
uint32_t getElementSizeInBytes() const
void setIsCleanupFuncletEntry(bool V=true)
Indicates if this is the entry block of a cleanup funclet.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
bool isInteger() const
Return true if this is an integer or a vector integer type.
void LowerCallSiteWithDeoptBundle(ImmutableCallSite CS, SDValue Callee, const BasicBlock *EHPadBB)
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 getEVTAlignment(EVT MemoryVT) const
Compute the default alignment value for the given type.
LLVM_NODISCARD bool empty() const
SmallVector< ISD::InputArg, 32 > Ins
AtomicOrdering
Atomic ordering for LLVM's memory model.
Interval::succ_iterator succ_begin(Interval *I)
succ_begin/succ_end - define methods so that Intervals may be used just like BasicBlocks can with the...
STACKSAVE - STACKSAVE has one operand, an input chain.
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
SDValue getMergeValues(ArrayRef< SDValue > Ops, const SDLoc &dl)
Create a MERGE_VALUES node from the given operands.
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 getVectorElementType() const
Given a vector type, return the type of each element.
void assign(size_type NumElts, const T &Elt)
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...
int getArgumentFrameIndex(const Argument *A)
getArgumentFrameIndex - Get frame index for the byval argument.
auto reverse(ContainerTy &&C, typename std::enable_if< has_rbegin< ContainerTy >::value >::type *=nullptr) -> decltype(make_range(C.rbegin(), C.rend()))
void emitError(unsigned LocCookie, const Twine &ErrorStr)
emitError - Emit an error message to the currently installed error handler with optional location inf...
Value * getPointerOperand()
const AMDGPUAS &AS return SrcAS
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...
bool isOSLinux() const
Tests whether the OS is Linux.
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.
AtomicOrdering getOrdering() const
Returns the ordering constraint of this rmw instruction.
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 ...
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...
unsigned NoNaNsFPMath
NoNaNsFPMath - This flag is enabled when the -enable-no-nans-fp-math flag is specified on the command...
CallingConv::ID getCallingConv() const
Get the calling convention of the call.
CATCHPAD - Represents a catchpad instruction.
[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)
bool usesUnderscoreLongJmp() const
Determine if we should use _longjmp or longjmp to implement llvm.longjmp.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
OUTCHAIN = EH_SJLJ_SETUP_DISPATCH(INCHAIN) The target initializes the dispatch table here...
std::pair< SDValue, SDValue > LowerCallTo(CallLoweringInfo &CLI) const
This function lowers an abstract call to a function into an actual call.
const LiveOutInfo * GetLiveOutRegInfo(unsigned Reg)
GetLiveOutRegInfo - Gets LiveOutInfo for a register, returning NULL if the register is a PHI destinat...
unsigned getNumValues() const
Return the number of values defined/returned by this operator.
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...
SDValue getTargetFrameIndex(int FI, EVT VT)
virtual std::pair< SDValue, SDValue > EmitTargetCodeForStrlen(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Src, MachinePointerInfo SrcPtrInfo) const
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
This contains information for each constraint that we are lowering.
Simple integer binary arithmetic operators.
vt_iterator legalclasstypes_begin(const TargetRegisterClass &RC) const
Loop over all of the value types that can be represented by values.
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.
static void GetRegistersForValue(SelectionDAG &DAG, const TargetLowering &TLI, const SDLoc &DL, SDISelAsmOperandInfo &OpInfo)
GetRegistersForValue - Assign registers (virtual or physical) for the specified operand.
BasicBlock * getSuccessor(unsigned i) const
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.
virtual std::pair< SDValue, SDValue > EmitTargetCodeForStrnlen(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Src, SDValue MaxLength, MachinePointerInfo SrcPtrInfo) const
unsigned getActiveBits() const
Compute the number of active bits in the value.
bool ShouldEmitAsBranches(const std::vector< CaseBlock > &Cases)
If the set of cases should be emitted as a series of branches, return true.
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.
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
An instruction for storing to memory.
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...
virtual SDValue LowerCall(CallLoweringInfo &, SmallVectorImpl< SDValue > &) const
This hook must be implemented to lower calls into the specified DAG.
EVT getValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
Return the EVT corresponding to this LLVM type.
void init(GCFunctionInfo *gfi, AliasAnalysis *AA, const TargetLibraryInfo *li)
bool allowReciprocal() const
CodeGenOpt::Level getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
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)
ConstraintPrefix Type
Type - The basic type of the constraint: input/output/clobber.
static bool isRegDefKind(unsigned Flag)
SDValue getSplatBuildVector(EVT VT, const SDLoc &DL, SDValue Op)
Return a splat ISD::BUILD_VECTOR node, consisting of Op splatted to all elements. ...
void setSuccProbability(succ_iterator I, BranchProbability Prob)
Set successor probability of a given iterator.
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
void setStackProtectorIndex(int I)
BasicBlock * getSuccessor() const
void setOrigAlign(unsigned A)
static SDValue getLimitedPrecisionExp2(SDValue t0, const SDLoc &dl, SelectionDAG &DAG)
RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) This node represents a target intrinsic fun...
bool doesNotAccessMemory() const
Determine if the function does not access memory.
Type * getElementType() const
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
const DataLayout & getDataLayout() const
bool isAtomic() const
Return true if this instruction has an AtomicOrdering of unordered or higher.
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)
Class to represent pointers.
void normalizeSuccProbs()
Normalize probabilities of all successors so that the sum of them becomes one.
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
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.
Interval::succ_iterator succ_end(Interval *I)
virtual bool supportSwiftError() const
Return true if the target supports swifterror attribute.
SelectPatternResult matchSelectPattern(Value *V, Value *&LHS, Value *&RHS, Instruction::CastOps *CastOp=nullptr)
Pattern match integer [SU]MIN, [SU]MAX and ABS idioms, returning the kind and providing the out param...
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.
iterator find(const_arg_type_t< KeyT > Val)
bool unsafeAlgebra() const
static Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
virtual unsigned getVectorTypeBreakdownForCallingConv(LLVMContext &Context, 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 isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
void setAttributes(ImmutableCallSite *CS, unsigned ArgIdx)
Set CallLoweringInfo attribute flags based on a call instruction and called function attributes...
SDNode * getNode() const
get the SDNode which holds the desired result
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 ...
The memory access is volatile.
an instruction for type-safe pointer arithmetic to access elements of arrays and structs ...
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
virtual MachineMemOperand::Flags getMMOFlags(const Instruction &I) const
This callback is used to inspect load/store instructions and add target-specific MachineMemOperand fl...
unsigned getScalarSizeInBits() const
unsigned getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
SDValue getMDNode(const MDNode *MD)
Return an MDNodeSDNode which holds an MDNode.
bool isTypeLegal(EVT VT) const
Return true if the target has native support for the specified value type.
Type * getReturnType() const
Returns the type of the ret val.
initializer< Ty > init(const Ty &Val)
SmallPtrSet< const Instruction *, 4 > ElidedArgCopyInstrs
bool hasOptimizedCodeGen(LibFunc F) const
Tests if the function is both available and a candidate for optimized code generation.
SDValue getVectorShuffle(EVT VT, const SDLoc &dl, SDValue N1, SDValue N2, ArrayRef< int > Mask)
Return an ISD::VECTOR_SHUFFLE node.
std::pair< SDValue, SDValue > lowerInvokable(TargetLowering::CallLoweringInfo &CLI, const BasicBlock *EHPadBB=nullptr)
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.
FPOpFusion::FPOpFusionMode AllowFPOpFusion
AllowFPOpFusion - This flag is set by the -fuse-fp-ops=xxx option.
bool isInteger() const
Return true if this is an integer or a vector integer type.
The landingpad instruction holds all of the information necessary to generate correct exception handl...
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.
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...
virtual unsigned getABIAlignmentForCallingConv(Type *ArgTy, DataLayout DL) const
Certain targets have context senstive alignment requirements, where one type has the alignment requir...
READ_REGISTER, WRITE_REGISTER - This node represents llvm.register on the DAG, which implements the n...
unsigned getAlignment() const
Return the alignment of the access that is being performed.
FunctionType * getFunctionType() const
Subclasses of this class are all able to terminate a basic block.
std::vector< std::pair< MachineInstr *, unsigned > > PHINodesToUpdate
PHINodesToUpdate - A list of phi instructions whose operand list will be updated after processing the...
unsigned const MachineRegisterInfo * MRI
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...
bool HasTailCall
HasTailCall - This is set to true if a call in the current block has been translated as a tail call...
unsigned getVectorNumElements() const
bool rangeFitsInWord(const APInt &Low, const APInt &High, const DataLayout &DL) const
Check whether the range [Low,High] fits in a machine word.
LOCAL_RECOVER - Represents the llvm.localrecover intrinsic.
bool isFullSet() const
Return true if this set contains all of the elements possible for this data-type. ...
bool hasSideEffects() const
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 SDValue & getOperand(unsigned i) const
The instances of the Type class are immutable: once they are created, they are never changed...
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.
DIExpression * getExpression() const
const Function * getParent() const
Simple binary floating point operators.
Conditional or Unconditional Branch instruction.
bool isVectorTy() const
True if this is an instance of VectorType.
static AttributeList getReturnAttrs(TargetLowering::CallLoweringInfo &CLI)
Returns an AttributeList representing the attributes applied to the return value of the given call...
SDValue getMemIntrinsicNode(unsigned Opcode, const SDLoc &dl, SDVTList VTList, ArrayRef< SDValue > Ops, EVT MemVT, MachinePointerInfo PtrInfo, unsigned Align=0, bool Vol=false, bool ReadMem=true, bool WriteMem=true, unsigned Size=0)
Creates a MemIntrinsicNode that may produce a result and takes a list of operands.
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...
unsigned getMinimumJumpTableEntries() const
Return lower limit for number of blocks in a jump table.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
std::pair< unsigned, bool > getOrCreateSwiftErrorVRegUseAt(const Instruction *, const MachineBasicBlock *, const Value *)
This function has undefined behavior.
unsigned countMinLeadingZeros() const
Returns the minimum number of leading zero bits.
This is an important base class in LLVM.
VAEND, VASTART - VAEND and VASTART have three operands: an input chain, pointer, and a SRCVALUE...
bool isVector() const
Return true if this is a vector value type.
Resume the propagation of an exception.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
bool isWrappedSet() const
Return true if this set wraps around the top of the range.
Value * getCompareOperand()
Libcall getMEMMOVE_ELEMENT_UNORDERED_ATOMIC(uint64_t ElementSize)
getMEMMOVE_ELEMENT_UNORDERED_ATOMIC - Return MEMMOVE_ELEMENT_UNORDERED_ATOMIC_* value for the given e...
INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element at IDX replaced with VAL...
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
Indirect Branch Instruction.
bool areJTsAllowed(const Function *Fn) const
Return true if lowering to a jump table is allowed.
bool isOperationLegal(unsigned Op, EVT VT) const
Return true if the specified operation is legal on this target.
unsigned getAlignment() const
Return the alignment of the memory that is being allocated by the 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.
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...
EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
virtual std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const
Given a physical register constraint (e.g.
static Type * getVoidTy(LLVMContext &C)
static cl::opt< unsigned, true > LimitFPPrecision("limit-float-precision", cl::desc("Generate low-precision inline sequences ""for some float libcalls"), cl::location(LimitFloatPrecision), cl::init(0))
INIT_TRAMPOLINE - This corresponds to the init_trampoline intrinsic.
void clear()
Clear the memory usage of this object.
virtual bool isFMAFasterThanFMulAndFAdd(EVT) const
Return true if an FMA operation is faster than a pair of fmul and fadd instructions.
virtual void EmitFunctionEntryCode()
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
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 arithmetic operators which may exhibit overflow - Add, Sub, and Mul.
unsigned getBitWidth() const
Return the number of bits in the APInt.
unsigned getOpcode() const
uint64_t getNumElements() const
TRAP - Trapping instruction.
Value * getOperand(unsigned i) const
MVT getRegisterType(MVT VT) const
Return the type of registers that this ValueType will eventually require.
Value * getPointerOperand()
AssertSext, AssertZext - These nodes record if a register contains a value that has already been zero...
DEBUGTRAP - Trap intended to get the attention of a debugger.
virtual bool useLoadStackGuardNode() const
If this function returns true, SelectionDAGBuilder emits a LOAD_STACK_GUARD node when it is lowering ...
static bool isNot(const Value *V)
void reserve(size_type NumEntries)
Grow the densemap so that it can contain at least NumEntries items before resizing again...
The memory access is non-temporal.
void setAllowContract(bool b)
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
Constant Vector Declarations.
SDLoc getCurSDLoc() const
Predicate getPredicate() const
Return the predicate for this instruction.
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)
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.
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...
Bit counting operators with an undefined result for zero inputs.
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
unsigned ExceptionPointerVirtReg
If the current MBB is a landing pad, the exception pointer and exception selector registers are copie...
Targets can subclass this to parameterize the SelectionDAG lowering and instruction selection process...
unsigned getStackPointerRegisterToSaveRestore() const
If a physical register, this specifies the register that llvm.savestack/llvm.restorestack should save...
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
bool isEmptySet() const
Return true if this set contains no members.
static bool isMemKind(unsigned Flag)
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...
Type * getType() const
Return the type of the instruction that generated this call site.
static bool getUniformBase(const Value *&Ptr, SDValue &Base, SDValue &Index, SelectionDAGBuilder *SDB)
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...
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual unsigned getByValTypeAlignment(Type *Ty, const DataLayout &DL) const
Return the desired alignment for ByVal or InAlloca aggregate function arguments in the caller paramet...
Libcall getMEMCPY_ELEMENT_UNORDERED_ATOMIC(uint64_t ElementSize)
getMEMCPY_ELEMENT_UNORDERED_ATOMIC - Return MEMCPY_ELEMENT_UNORDERED_ATOMIC_* value for the given ele...
LLVMContext & getContext() const
All values hold a context through their type.
void FindMergedConditions(const Value *Cond, MachineBasicBlock *TBB, MachineBasicBlock *FBB, MachineBasicBlock *CurBB, MachineBasicBlock *SwitchBB, Instruction::BinaryOps Opc, BranchProbability TW, BranchProbability FW, bool InvertCond)
FindMergedConditions - If Cond is an expression like.
This structure contains all information that is necessary for lowering calls.
void EmitBranchForMergedCondition(const Value *Cond, MachineBasicBlock *TBB, MachineBasicBlock *FBB, MachineBasicBlock *CurBB, MachineBasicBlock *SwitchBB, BranchProbability TW, BranchProbability FW, bool InvertCond)
EmitBranchForMergedCondition - Helper method for FindMergedConditions.
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
SDDbgValue * getConstantDbgValue(MDNode *Var, MDNode *Expr, const Value *C, uint64_t Off, const DebugLoc &DL, unsigned O)
Constant.
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).
This class contains a discriminated union of information about pointers in memory operands...
bool isPowerOf2() const
Check if this APInt's value is a power of two greater than zero.
LLVM_READONLY APFloat maxnum(const APFloat &A, const APFloat &B)
Implements IEEE maxNum semantics.
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.
const SDValue & getRoot() const
Return the root tag of the SelectionDAG.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
MachineBasicBlock * MBB
MBB - The current block.
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.
unsigned getNumSuccessors() const
virtual SDValue LowerFormalArguments(SDValue, CallingConv::ID, bool, const SmallVectorImpl< ISD::InputArg > &, const SDLoc &, SelectionDAG &, SmallVectorImpl< SDValue > &) const
This hook must be implemented to lower the incoming (formal) arguments, described by the Ins array...
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.
BasicBlock * getSuccessor(unsigned i) const
TargetIntrinsicInfo - Interface to description of machine instruction set.
The memory access writes data.
virtual Value * getSSPStackGuardCheck(const Module &M) const
If the target has a standard stack protection check function that performs validation and error handl...
BasicBlock * getUnwindDest() const
static bool isVectorReductionOp(const User *I)
Checks if the given instruction performs a vector reduction, in which case we have the freedom to alt...
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.
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...
Representation for a specific memory location.
IntegerType * getIntPtrType(LLVMContext &C, unsigned AddressSpace=0) const
Returns an integer type with size at least as big as that of a pointer in the given address space...
bool allowContract() const
virtual const TargetFrameLowering * getFrameLowering() const
TokenFactor - This node takes multiple tokens as input and produces a single token result...
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
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.
DIExpression * getExpression() const
static const fltSemantics & IEEEsingle() LLVM_READNONE
Iterator for intrusive lists based on ilist_node.
void setNoUnsignedWrap(bool b)
AtomicOrdering getOrdering() const
Returns the ordering constraint of this store instruction.
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.
virtual unsigned getJumpTableEncoding() const
Return the entry encoding for a jump table in the current function.
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.
static bool isABIRegCopy(const Value *V)
SmallVector< unsigned, 4 > RegCount
This list holds the number of registers for each value.
InstrTy * getInstruction() const
Returns platform specific canonical encoding of a floating point number.
const char * getLibcallName(RTLIB::Libcall Call) const
Get the libcall routine name for the specified libcall.
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
const MCContext & getContext() const
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this rmw instruction.
ValTy * getArgument(unsigned ArgNo) const
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
virtual unsigned getInlineAsmMemConstraint(StringRef ConstraintCode) const
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...
SmallVector< MachineInstr *, 8 > ArgDbgValues
ArgDbgValues - A list of DBG_VALUE instructions created during isel for function arguments that are i...
Utility class for floating point operations which can have information about relaxed accuracy require...
unsigned getObjectAlignment(int ObjectIdx) const
Return the alignment of the specified stack object.
Module.h This file contains the declarations for the Module class.
Type * getType() const
All values are typed, get the type of this value.
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.
virtual EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context, EVT VT) const
Return the ValueType of the result of SETCC operations.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
void clear()
Clear out the current SelectionDAG and the associated state and prepare this SelectionDAGBuilder obje...
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this load instruction.
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)
static void getCopyToPartsVector(SelectionDAG &DAG, const SDLoc &dl, SDValue Val, SDValue *Parts, unsigned NumParts, MVT PartVT, const Value *V, bool IsABIRegCopy)
getCopyToPartsVector - Create a series of nodes that contain the specified value split into legal par...
This class represents a range of values.
static SDValue getF32Constant(SelectionDAG &DAG, unsigned Flt, const SDLoc &dl)
getF32Constant - Get 32-bit floating point constant.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
bool isVolatile() const
Return true if this is a load from a volatile memory location.
BRCOND - Conditional branch.
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)
Value * getCatchSwitchParentPad() const
Get the parentPad of this catchret's catchpad's catchswitch.
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
SDValue getMemmove(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, bool isVol, bool isTailCall, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo)
static bool isOnlyUsedInEntryBlock(const Argument *A, bool FastISel)
isOnlyUsedInEntryBlock - If the specified argument is only used in the entry block, return true.
bool isStrictlyPositive() const
Determine if this APInt Value is positive.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Function * getCalledFunction() const
Return the function called, or null if this is an indirect function invocation.
void addIPToStateRange(const InvokeInst *II, MCSymbol *InvokeBegin, MCSymbol *InvokeEnd)
AtomicOrdering getOrdering() const
Returns the ordering constraint of this load instruction.
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
Represents one node in the SelectionDAG.
const BasicBlock & getEntryBlock() const
static SDValue expandLog(const SDLoc &dl, SDValue Op, SelectionDAG &DAG, const TargetLowering &TLI)
expandLog - Lower a log intrinsic.
const MachineInstrBuilder & addFrameIndex(int Idx) const
void UpdateSplitBlock(MachineBasicBlock *First, MachineBasicBlock *Last)
UpdateSplitBlock - When an MBB was split during scheduling, update the references that need to refer ...
static const Function * getCalledFunction(const Value *V, bool LookThroughBitCast, bool &IsNoBuiltin)
static ConstantInt * getTrue(LLVMContext &Context)
BinOp getOperation() const
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)
BasicBlock * getSuccessor(unsigned idx) const
Return the specified successor.
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
unsigned CreateRegs(Type *Ty)
CreateRegs - Allocate the appropriate number of virtual registers of the correctly promoted or expand...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
C - The default llvm calling convention, compatible with C.
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
This class represents atomic memcpy intrinsic TODO: Integrate this class into MemIntrinsic hierarchy;...
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
GCFunctionInfo * GFI
GFI - Garbage collection metadata for the function.
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th call argument.
Class to represent vector types.
virtual const char * getClearCacheBuiltinName() const
Return the builtin name for the __builtin___clear_cache intrinsic Default is to invoke the clear cach...
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...
Class for arbitrary precision integers.
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 hasEHFunclets() const
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).
void setIsImmutableObjectIndex(int ObjectIdx, bool Immutable)
Marks the immutability of an object.
Value * getIncomingValueForBlock(const BasicBlock *BB) const
This file defines the FastISel class.
virtual const TargetRegisterClass * getRegClassFor(MVT VT) const
Return the register class that should be used for the specified value type.
iterator_range< user_iterator > users()
ZERO_EXTEND - Used for integer types, zeroing the new bits.
unsigned getVectorNumElements() const
std::vector< JumpTableBlock > JTCases
JTCases - Vector of JumpTable structures used to communicate SwitchInst code generation information...
ANY_EXTEND - Used for integer types. The high bits are undefined.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
Value * getCondition() const
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...
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
bool isMinValue() const
Determine if this is the smallest unsigned value.
int getStackProtectorIndex() const
Return the index for the stack protector object.
const MCPhysReg * iterator
SDValue getBlockAddress(const BlockAddress *BA, EVT VT, int64_t Offset=0, bool isTarget=false, unsigned char TargetFlags=0)
virtual bool CanLowerReturn(CallingConv::ID, MachineFunction &, bool, const SmallVectorImpl< ISD::OutputArg > &, LLVMContext &) const
This hook should be implemented to check whether the return values described by the Outs array can fi...
void setIsEHFuncletEntry(bool V=true)
Indicates if this is the entry block of an EH funclet.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
CATCHRET - Represents a return from a catch block funclet.
llvm_unreachable("Unknown RegBank!")
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.
GET_DYNAMIC_AREA_OFFSET - get offset from native SP to the address of the most recent dynamic alloca...
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)
DenseMap< const Value *, ISD::NodeType > PreferredExtendType
Record the preferred extend type (ISD::SIGN_EXTEND or ISD::ZERO_EXTEND) for a value.
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.
static std::vector< std::string > Flags
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.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
cl::opt< std::string > TrapFuncName("trap-func", cl::Hidden, cl::desc("Emit a call to trap function rather than a trap instruction"), cl::init(""))
These are IR-level optimization flags that may be propagated to SDNodes.
Represents a use of a SDNode.
CallLoweringInfo & setConvergent(bool Value=true)
unsigned ExceptionSelectorVirtReg
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
SmallVector< SDValue, 32 > OutVals
Value * getCondition() const
Analysis providing branch probability information.
BasicBlock * getDefaultDest() const
Bitwise operators - logical and, logical or, logical xor.
static SDValue getCopyFromPartsVector(SelectionDAG &DAG, const SDLoc &DL, const SDValue *Parts, unsigned NumParts, MVT PartVT, EVT ValueVT, const Value *V, bool IsABIRegCopy)
getCopyFromPartsVector - Create a value that contains the specified legal parts combined into the val...
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().
bool isAggregateType() const
Return true if the type is an aggregate type.
SDValue getCopyFromReg(SDValue Chain, const SDLoc &dl, unsigned Reg, EVT VT)
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
AtomicOrdering getOrdering() const
Returns the ordering constraint of this fence instruction.
virtual void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint, std::vector< SDValue > &Ops, SelectionDAG &DAG) const
Lower the specified operand into the Ops vector.
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
virtual const TargetIntrinsicInfo * getIntrinsicInfo() const
If intrinsic information is available, return it. If not, return null.
This represents the llvm.dbg.value instruction.
unsigned getAlignment() const
Return the alignment of the access that is being performed.
Value * getPointerOperand()
void getAAMetadata(AAMDNodes &N, bool Merge=false) const
Fills the AAMDNodes structure with AA metadata from this instruction.
Establish a view to a call site for examination.
unsigned getSizeInBits() const
Return the size of the specified value type in bits.
AttributeList getAttributes() const
Return the parameter attributes for this call.
void ReplaceAllUsesWith(SDValue From, SDValue Op)
Modify anything using 'From' to use 'To' instead.
void push_back(MachineInstr *MI)
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
bool hasOneUse() const
Return true if there is exactly one user of this value.
FunctionLoweringInfo - This contains information that is global to a function that is used when lower...
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...
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...
static Constant * getZeroValueForNegation(Type *Ty)
Floating point negation must be implemented with f(x) = -0.0 - x.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
The memory access always returns the same value (or traps).
bool isCopyElisionCandidate() const
const Value * stripInBoundsConstantOffsets() const
Strip off pointer casts and all-constant inbounds GEPs.
MachineBasicBlock::iterator InsertPt
MBB - The current insert position inside the current block.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this fence instruction.
const WinEHFuncInfo * getWinEHFuncInfo() const
getWinEHFuncInfo - Return information about how the current function uses Windows exception handling...
unsigned CreateReg(MVT VT)
CreateReg - Allocate a single virtual register for the given type.
uint64_t getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
StatepointLoweringState StatepointLowering
State used while lowering a statepoint sequence (gc_statepoint, gc_relocate, and gc_result).
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
DenseMap< const AllocaInst *, int > StaticAllocaMap
StaticAllocaMap - Keep track of frame indices for fixed sized allocas in the entry block...
RESULT, OUTCHAIN = EH_SJLJ_SETJMP(INCHAIN, buffer) This corresponds to the eh.sjlj.setjmp intrinsic.
unsigned getNumCases() const
Return the number of 'cases' in this switch instruction, excluding the default case.
CopyFromReg - This node indicates that the input value is a virtual or physical register that is defi...
int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS, const AllocaInst *Alloca=nullptr)
Create a new statically sized stack object, returning a nonnegative identifier to represent it...
SDValue getCopyFromRegs(const Value *V, Type *Ty)
getCopyFromRegs - If there was virtual register allocated for the value V emit CopyFromReg of the spe...
EVT getValueType() const
Return the ValueType of the referenced return value.
SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
MVT getFrameIndexTy(const DataLayout &DL) const
Return the type for frame index, which is determined by the alloca address space specified through th...
bool hasLocalLinkage() const
OUTCHAIN = EH_RETURN(INCHAIN, OFFSET, HANDLER) - This node represents 'eh_return' gcc dwarf builtin...
LLVM_NODISCARD bool empty() const
void setUnsafeAlgebra(bool b)
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 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 ...
unsigned getReg() const
getReg - Returns the register number.
StringRef getValueAsString() const
Return the attribute's value as a string.
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
void erase(iterator MBBI)
FunctionLoweringInfo & FuncInfo
FuncInfo - Information about the function as a whole.
SmallVector< MVT, 4 > RegVTs
The value types of the registers.
DILocalVariable * getVariable() const
virtual bool getTgtMemIntrinsic(IntrinsicInfo &, const CallInst &, unsigned) const
Given an intrinsic, checks if on the target the intrinsic will need to map to a MemIntrinsicNode (tou...
SDValue getJumpTable(int JTI, EVT VT, bool isTarget=false, unsigned char TargetFlags=0)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void GetReturnInfo(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...
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.
const BasicBlock & front() const
void setUnusedArgValue(const Value *V, SDValue NewN)
bool isEmptyTy() const
Return true if this type is empty, that is, it has no elements or all of its elements are empty...
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...
static SDValue getMemCmpLoad(const Value *PtrVal, MVT LoadVT, SelectionDAGBuilder &Builder)
bool isTypeLegalForClass(const TargetRegisterClass &RC, MVT T) const
Return true if the given TargetRegisterClass has the ValueType T.
virtual const TargetInstrInfo * getInstrInfo() const
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 ...
EVT getTypeToTransformTo(LLVMContext &Context, EVT VT) const
For types supported by the target, this is an identity function.
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
FMA - Perform a * b + c with no intermediate rounding step.
SDValue getRegister(unsigned Reg, EVT VT)
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...
Value * getLength() const
APInt sextOrTrunc(unsigned width) const
Sign extend or truncate to width.
FMIN/FMAX nodes can have flags, for NaN/NoNaN variants.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
DILocalVariable * getVariable() const
static VectorType * get(Type *ElementType, unsigned NumElements)
This static method is the primary way to construct an VectorType.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
void setDebugLoc(DebugLoc dl)
Set source location info.
SDValue getValueType(EVT)
const Value * getArraySize() const
Get the number of elements allocated.
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)
virtual MVT getFenceOperandTy(const DataLayout &DL) const
Return the type for operands of fence.
uint64_t getTypeSizeInBits(Type *Ty) const
Size examples:
const TargetLowering & getTargetLoweringInfo() const
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).
BranchProbability getEdgeProbability(const BasicBlock *Src, unsigned IndexInSuccessors) const
Get an edge's probability, relative to other out-edges of the Src.
std::vector< CaseBlock > SwitchCases
SwitchCases - Vector of CaseBlock structures used to communicate SwitchInst code generation informati...
SDValue getEHLabel(const SDLoc &dl, SDValue Root, MCSymbol *Label)
bool hasOpaqueSPAdjustment() const
Returns true if the function contains opaque dynamic stack adjustments.
const Instruction * getFirstNonPHIOrDbg() const
Returns a pointer to the first instruction in this block that is not a PHINode or a debug intrinsic...
virtual Value * getSDagStackGuard(const Module &M) const
Return the variable that's previously inserted by insertSSPDeclarations, if any, otherwise return nul...
bool isValidLocationForIntrinsic(const DILocation *DL) const
Check that a location is valid for this variable.
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...
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
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.
MachineModuleInfo & getMMI() const
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...
void clearDanglingDebugInfo()
Clear the dangling debug information map.
unsigned TrapUnreachable
Emit target-specific trap instruction for 'unreachable' IR instructions.
static BranchProbability getZero()
void sort(Policy policy, RandomAccessIterator Start, RandomAccessIterator End, const Comparator &Comp=Comparator())
DenseMap< MachineBasicBlock *, SmallVector< unsigned, 4 > > LPadToCallSiteMap
LPadToCallSiteMap - Map a landing pad to the call site indexes.
static SDValue expandLog10(const SDLoc &dl, SDValue Op, SelectionDAG &DAG, const TargetLowering &TLI)
expandLog10 - Lower a log10 intrinsic.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
MERGE_VALUES - This node takes multiple discrete operands and returns them all as its individual resu...
MVT getVectorElementType() const
static bool isVolatile(Instruction *Inst)
static APInt getNullValue(unsigned numBits)
Get the '0' value.
SDValue getEntryNode() const
Return the token chain corresponding to the entry of the function.
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...
unsigned countOperandBundlesOfType(StringRef Name) const
Return the number of operand bundles with the tag Name attached to this instruction.
OUTCHAIN = ATOMIC_STORE(INCHAIN, ptr, val) This corresponds to "store atomic" instruction.
APInt getUnsignedMax() const
Return the largest unsigned value contained in the ConstantRange.
TRUNCATE - Completely drop the high bits.
EVT getShiftAmountTy(EVT LHSTy, const DataLayout &DL) const
bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
const Instruction * getFirstNonPHI() const
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
void setArgumentFrameIndex(const Argument *A, int FI)
setArgumentFrameIndex - Record frame index for the byval argument.
Libcall getMEMSET_ELEMENT_UNORDERED_ATOMIC(uint64_t ElementSize)
getMEMSET_ELEMENT_UNORDERED_ATOMIC - Return MEMSET_ELEMENT_UNORDERED_ATOMIC_* value for the given ele...
DenseMap< const Constant *, unsigned > ConstantsOut
bool isAlignStack() const
DISubprogram * getSubprogram() const
Get the subprogram for this scope.
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)
SDDbgValue - Holds the information from a dbg_value node through SDISel.
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
This represents the llvm.dbg.declare instruction.
FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW, FLOG, FLOG2, FLOG10, FEXP, FEXP2, FCEIL, FTRUNC, FRINT, FNEARBYINT, FROUND, FFLOOR - Perform various unary floating point operations.
virtual unsigned getExceptionSelectorRegister(const Constant *PersonalityFn) const
If a physical register, this returns the register that receives the exception typeid on entry to a la...
static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)
Returns the EVT that represents an integer with the given number of bits.
bool isJumpExpensive() const
Return true if Flow Control is an expensive operation that should be avoided.
SmallVector< unsigned, 4 > Regs
This list holds the registers assigned to the values.
Value * getPointerOperand()
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...
MachineInstr::mmo_iterator allocateMemRefsArray(unsigned long Num)
allocateMemRefsArray - Allocate an array to hold MachineMemOperand pointers.
static IntegerType * getInt8Ty(LLVMContext &C)
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.
static MachineOperand CreateFI(int Idx)
void visitBitTestHeader(BitTestBlock &B, MachineBasicBlock *SwitchBB)
visitBitTestHeader - This function emits necessary code to produce value suitable for "bit tests" ...
LocationClass< Ty > location(Ty &L)
const BasicBlock * getParent() const
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
bool isExportedInst(const Value *V)
isExportedInst - Return true if the specified value is an instruction exported from its block...
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...
LLVM_READONLY APFloat minnum(const APFloat &A, const APFloat &B)
Implements IEEE minNum semantics.
static const unsigned LowestSDNodeOrder
Lowest valid SDNodeOrder.
std::vector< MachineBasicBlock * >::iterator succ_iterator
static BranchProbability getBranchProbStackProtector(bool IsLikely)
FunctionLoweringInfo * FuncInfo
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...
auto count_if(R &&Range, UnaryPredicate P) -> typename std::iterator_traits< decltype(std::begin(Range))>::difference_type
Wrapper function around std::count_if to count the number of times an element satisfying a given pred...
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
SmallVector< int, 16 > getShuffleMask() const
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()
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...
static unsigned getFlagWordForMatchingOp(unsigned InputFlag, unsigned MatchedOperandNo)
getFlagWordForMatchingOp - Augment an existing flag word returned by getFlagWord with information ind...
virtual MVT getRegisterTypeForCallingConv(MVT VT) const
Certain combinations of ABIs, Targets and features require that types are legal for some operations a...
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...
bool noNaNs() const
Flag queries.
This class contains meta information specific to a module.
LLVMContext & getContext() const
Get the global data context.
This file describes how to lower LLVM code to machine code.
bool isVoidTy() const
Return true if this is 'void'.
an instruction to allocate memory on the stack
unsigned getLiveInPhysReg(unsigned VReg) const
getLiveInPhysReg - If VReg is a live-in virtual register, return the corresponding live-in physical r...
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)
unsigned InitializeRegForValue(const Value *V)
gep_type_iterator gep_type_begin(const User *GEP)
APInt getUnsignedMin() const
Return the smallest unsigned value contained in the ConstantRange.
bool slt(const APInt &RHS) const
Signed less than comparison.
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
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...