89 #include "llvm/IR/IntrinsicsAArch64.h" 90 #include "llvm/IR/IntrinsicsWebAssembly.h" 129 using namespace llvm;
133 #define DEBUG_TYPE "isel" 141 cl::desc(
"Generate low-precision inline sequences " 142 "for some float libcalls"),
148 cl::desc(
"Set the case probability threshold for peeling the case from a " 149 "switch statement. A value greater than 100 will void this " 172 if (
auto *R = dyn_cast<ReturnInst>(V))
173 return R->getParent()->getParent()->getCallingConv();
175 if (
auto *CI = dyn_cast<CallInst>(V)) {
176 const bool IsInlineAsm = CI->isInlineAsm();
177 const bool IsIndirectFunctionCall =
178 !IsInlineAsm && !CI->getCalledFunction();
183 const bool IsInstrinsicCall =
184 !IsInlineAsm && !IsIndirectFunctionCall &&
187 if (!IsInlineAsm && !IsInstrinsicCall)
188 return CI->getCallingConv();
195 const SDValue *Parts,
unsigned NumParts,
205 const SDValue *Parts,
unsigned NumParts,
213 assert(NumParts > 0 &&
"No parts to assemble!");
224 unsigned RoundParts =
225 (NumParts & (NumParts - 1)) ? 1 <<
Log2_32(NumParts) : NumParts;
226 unsigned RoundBits = PartBits * RoundParts;
227 EVT RoundVT = RoundBits == ValueBits ?
233 if (RoundParts > 2) {
237 RoundParts / 2, PartVT, HalfVT, V);
248 if (RoundParts < NumParts) {
250 unsigned OddParts = NumParts - RoundParts;
281 !PartVT.
isVector() &&
"Unexpected split");
292 if (PartEVT == ValueVT)
296 ValueVT.
bitsLT(PartEVT)) {
309 if (ValueVT.
bitsLT(PartEVT)) {
313 if (AssertOp.hasValue())
314 Val = DAG.
getNode(*AssertOp, DL, PartEVT, Val,
334 ValueVT.
bitsLT(PartEVT)) {
343 const Twine &ErrMsg) {
344 const Instruction *
I = dyn_cast_or_null<Instruction>(V);
348 const char *AsmError =
", possible invalid constraint for vector type";
349 if (
const CallInst *CI = dyn_cast<CallInst>(I))
350 if (isa<InlineAsm>(CI->getCalledValue()))
351 return Ctx.
emitError(I, ErrMsg + AsmError);
362 const SDValue *Parts,
unsigned NumParts,
366 assert(NumParts > 0 &&
"No parts to assemble!");
367 const bool IsABIRegCopy = CallConv.
hasValue();
376 unsigned NumIntermediates;
382 NumIntermediates, RegisterVT);
386 NumIntermediates, RegisterVT);
389 assert(NumRegs == NumParts &&
"Part count doesn't match vector breakdown!");
391 assert(RegisterVT == PartVT &&
"Part type doesn't match vector breakdown!");
394 "Part type sizes don't match!");
398 if (NumIntermediates == NumParts) {
401 for (
unsigned i = 0; i != NumParts; ++i)
403 PartVT, IntermediateVT, V);
404 }
else if (NumParts > 0) {
407 assert(NumParts % NumIntermediates == 0 &&
408 "Must expand into a divisible number of parts!");
409 unsigned Factor = NumParts / NumIntermediates;
410 for (
unsigned i = 0; i != NumIntermediates; ++i)
412 PartVT, IntermediateVT, V);
421 : NumIntermediates));
424 DL, BuiltVectorTy, Ops);
430 if (PartEVT == ValueVT)
440 "Cannot narrow, it would be a lossy transformation");
451 "Cannot handle this kind of promotion");
481 *DAG.
getContext(), V,
"non-trivial scalar-to-vector conversion");
503 SDValue *Parts,
unsigned NumParts,
MVT PartVT,
515 unsigned OrigNumParts = NumParts;
517 "Copying to an illegal type!");
523 EVT PartEVT = PartVT;
524 if (PartEVT == ValueVT) {
525 assert(NumParts == 1 &&
"No-op copy with multiple parts!");
533 assert(NumParts == 1 &&
"Do not know what to promote to!");
544 "Unknown mismatch!");
546 Val = DAG.
getNode(ExtendKind, DL, ValueVT, Val);
552 assert(NumParts == 1 && PartEVT != ValueVT);
558 "Unknown mismatch!");
568 "Failed to tile the value with PartVT!");
571 if (PartEVT != ValueVT) {
573 "scalar-to-vector conversion failed");
582 if (NumParts & (NumParts - 1)) {
585 "Do not know what to expand to!");
586 unsigned RoundParts = 1 <<
Log2_32(NumParts);
587 unsigned RoundBits = RoundParts * PartBits;
588 unsigned OddParts = NumParts - RoundParts;
592 getCopyToParts(DAG, DL, OddVal, Parts + RoundParts, OddParts, PartVT, V,
599 NumParts = RoundParts;
611 for (
unsigned StepSize = NumParts; StepSize > 1; StepSize /= 2) {
612 for (
unsigned i = 0; i < NumParts; i += StepSize) {
613 unsigned ThisBits = StepSize * PartBits / 2;
616 SDValue &Part1 = Parts[i+StepSize/2];
623 if (ThisBits == PartBits && ThisVT != PartVT) {
642 if (PartNumElts > ValueNumElts &&
650 for (
unsigned i = ValueNumElts,
e = PartNumElts; i !=
e; ++i)
669 const bool IsABIRegCopy = CallConv.
hasValue();
672 EVT PartEVT = PartVT;
673 if (PartEVT == ValueVT) {
694 "lossy conversion of vector to scalar type");
695 EVT IntermediateType =
710 unsigned NumIntermediates;
713 NumRegs = TLI.getVectorTypeBreakdownForCallingConv(
715 NumIntermediates, RegisterVT);
718 TLI.getVectorTypeBreakdown(*DAG.
getContext(), ValueVT, IntermediateVT,
719 NumIntermediates, RegisterVT);
722 assert(NumRegs == NumParts &&
"Part count doesn't match vector breakdown!");
724 assert(RegisterVT == PartVT &&
"Part type doesn't match vector breakdown!");
726 unsigned IntermediateNumElts = IntermediateVT.
isVector() ?
730 unsigned DestVectorNoElts = NumIntermediates * IntermediateNumElts;
735 if (ValueVT != BuiltVectorTy) {
744 for (
unsigned i = 0; i != NumIntermediates; ++i) {
747 DAG.
getConstant(i * IntermediateNumElts, DL, IdxVT));
756 if (NumParts == NumIntermediates) {
759 for (
unsigned i = 0; i != NumParts; ++i)
760 getCopyToParts(DAG, DL, Ops[i], &Parts[i], 1, PartVT, V, CallConv);
761 }
else if (NumParts > 0) {
764 assert(NumIntermediates != 0 &&
"division by zero");
765 assert(NumParts % NumIntermediates == 0 &&
766 "Must expand into a divisible number of parts!");
767 unsigned Factor = NumParts / NumIntermediates;
768 for (
unsigned i = 0; i != NumIntermediates; ++i)
769 getCopyToParts(DAG, DL, Ops[i], &Parts[i * Factor], Factor, PartVT, V,
776 : ValueVTs(1, valuevt), RegVTs(1, regvt), Regs(regs),
777 RegCount(1, regs.
size()), CallConv(CC) {}
795 for (
unsigned i = 0; i != NumRegs; ++i)
797 RegVTs.push_back(RegisterVT);
826 for (
unsigned i = 0; i != NumRegs; ++i) {
853 if (NumZeroBits == RegSize) {
868 }
else if (NumSignBits > 1) {
912 NumParts, RegisterVT, V, CallConv, ExtendKind);
918 for (
unsigned i = 0; i != NumRegs; ++i) {
930 if (NumRegs == 1 || Flag)
941 Chain = Chains[NumRegs-1];
947 unsigned MatchingIdx,
const SDLoc &dl,
949 std::vector<SDValue> &Ops)
const {
974 "No 1:1 mapping from clobbers to regs?");
982 "If we clobbered the stack pointer, MFI should know about it.");
990 for (
unsigned i = 0; i != NumRegs; ++i) {
1003 unsigned RegCount = std::get<0>(CountAndVT);
1004 MVT RegisterVT = std::get<1>(CountAndVT);
1006 for (
unsigned E = I + RegCount; I !=
E; ++
I)
1019 LPadToCallSiteMap.clear();
1025 UnusedArgNodeMap.clear();
1026 PendingLoads.clear();
1027 PendingExports.clear();
1028 PendingConstrainedFP.clear();
1029 PendingConstrainedFPStrict.clear();
1031 HasTailCall =
false;
1032 SDNodeOrder = LowestSDNodeOrder;
1033 StatepointLowering.clear();
1037 DanglingDebugInfoMap.clear();
1044 if (Pending.
empty())
1050 unsigned i = 0,
e = Pending.
size();
1051 for (; i !=
e; ++i) {
1052 assert(Pending[i].getNode()->getNumOperands() > 1);
1053 if (Pending[i].getNode()->getOperand(0) == Root)
1061 if (Pending.
size() == 1)
1072 return updateRoot(PendingLoads);
1079 PendingLoads.reserve(PendingLoads.size() +
1080 PendingConstrainedFP.size() +
1081 PendingConstrainedFPStrict.size());
1082 PendingLoads.append(PendingConstrainedFP.begin(),
1083 PendingConstrainedFP.end());
1084 PendingLoads.append(PendingConstrainedFPStrict.begin(),
1085 PendingConstrainedFPStrict.end());
1086 PendingConstrainedFP.clear();
1087 PendingConstrainedFPStrict.clear();
1088 return getMemoryRoot();
1094 PendingExports.append(PendingConstrainedFPStrict.begin(),
1095 PendingConstrainedFPStrict.end());
1096 PendingConstrainedFPStrict.clear();
1097 return updateRoot(PendingExports);
1103 HandlePHINodesInSuccessorBlocks(I.
getParent());
1107 if (!isa<DbgInfoIntrinsic>(I))
1114 if (
auto *FPMO = dyn_cast<FPMathOperator>(&I)) {
1120 if (
SDNode *Node = getNodeForIRValue(&I)) {
1123 if (!Node->getFlags().isDefined())
1124 Node->setFlags(IncomingFlags);
1126 Node->intersectFlagsWith(IncomingFlags);
1131 if (
auto *FPI = dyn_cast<ConstrainedFPIntrinsic>(&I))
1133 if (
SDNode *Node = getNodeForIRValue(&I)) {
1136 Node->setFlags(Flags);
1141 CopyToExportRegsIfNeeded(&I);
1146 void SelectionDAGBuilder::visitPHI(
const PHINode &) {
1156 #define HANDLE_INST(NUM, OPCODE, CLASS) \ 1157 case Instruction::OPCODE: visit##OPCODE((const CLASS&)I); break; 1158 #include "llvm/IR/Instruction.def" 1164 auto isMatchingDbgValue = [&](DanglingDebugInfo &DDI) {
1168 if (DanglingVariable == Variable && Expr->
fragmentsOverlap(DanglingExpr)) {
1169 LLVM_DEBUG(
dbgs() <<
"Dropping dangling debug info for " << *DI <<
"\n");
1175 for (
auto &DDIMI : DanglingDebugInfoMap) {
1176 DanglingDebugInfoVector &DDIV = DDIMI.second;
1180 for (
auto &DDI : DDIV)
1181 if (isMatchingDbgValue(DDI))
1182 salvageUnresolvedDbgValue(DDI);
1184 DDIV.erase(
remove_if(DDIV, isMatchingDbgValue), DDIV.end());
1192 auto DanglingDbgInfoIt = DanglingDebugInfoMap.find(V);
1193 if (DanglingDbgInfoIt == DanglingDebugInfoMap.end())
1196 DanglingDebugInfoVector &DDIV = DanglingDbgInfoIt->second;
1197 for (
auto &DDI : DDIV) {
1199 assert(DI &&
"Ill-formed DanglingDebugInfo");
1202 unsigned DbgSDNodeOrder = DDI.getSDNodeOrder();
1206 "Expected inlined-at fields to agree");
1215 if (!EmitFuncArgumentDbgValue(V, Variable, Expr, dl,
false, Val)) {
1217 << DbgSDNodeOrder <<
"] for:\n " << *DI <<
"\n");
1224 <<
"changing SDNodeOrder from " << DbgSDNodeOrder <<
" to " 1225 << ValSDNodeOrder <<
"\n");
1226 SDV = getDbgValue(Val, Variable, Expr, dl,
1227 std::max(DbgSDNodeOrder, ValSDNodeOrder));
1231 <<
"in EmitFuncArgumentDbgValue\n");
1245 Value *V = DDI.getDI()->getValue();
1249 DebugLoc InstDL = DDI.getDI()->getDebugLoc();
1250 unsigned SDOrder = DDI.getSDNodeOrder();
1254 assert(isa<DbgValueInst>(DDI.getDI()));
1255 bool StackValue =
true;
1258 if (handleDebugValue(V, Var, Expr, DL, InstDL, SDOrder))
1264 while (isa<Instruction>(V)) {
1279 if (handleDebugValue(V, Var, Expr, DL, InstDL, SDOrder)) {
1281 << DDI.getDI() <<
"\nBy stripping back to:\n " << V);
1293 LLVM_DEBUG(
dbgs() <<
"Dropping debug value info for:\n " << DDI.getDI()
1295 LLVM_DEBUG(
dbgs() <<
" Last seen at:\n " << *DDI.getDI()->getOperand(0)
1304 if (isa<ConstantInt>(V) || isa<ConstantFP>(V) || isa<UndefValue>(V) ||
1305 isa<ConstantPointerNull>(V)) {
1313 if (
const AllocaInst *AI = dyn_cast<AllocaInst>(V)) {
1314 auto SI = FuncInfo.StaticAllocaMap.find(AI);
1315 if (
SI != FuncInfo.StaticAllocaMap.end()) {
1318 false, dl, SDNodeOrder);
1329 if (!N.
getNode() && isa<Argument>(V))
1330 N = UnusedArgNodeMap[V];
1332 if (EmitFuncArgumentDbgValue(V, Var, Expr, dl,
false, N))
1334 SDV = getDbgValue(N, Var, Expr, dl, SDNodeOrder);
1343 bool IsParamOfFunc = isa<Argument>(V) && Var->
isParameter() &&
1345 if (!IsParamOfFunc) {
1349 auto VMI = FuncInfo.ValueMap.find(V);
1350 if (VMI != FuncInfo.ValueMap.end()) {
1351 unsigned Reg = VMI->second;
1356 if (RFV.occupiesMultipleRegs()) {
1358 unsigned BitsToDescribe = 0;
1360 BitsToDescribe = *VarSize;
1362 BitsToDescribe = Fragment->SizeInBits;
1363 for (
auto RegAndSize : RFV.getRegsAndSizes()) {
1364 unsigned RegisterSize = RegAndSize.second;
1366 if (Offset >= BitsToDescribe)
1368 unsigned FragmentSize = (Offset + RegisterSize > BitsToDescribe)
1369 ? BitsToDescribe - Offset
1372 Expr, Offset, FragmentSize);
1376 false, dl, SDNodeOrder);
1378 Offset += RegisterSize;
1393 for (
auto &Pair : DanglingDebugInfoMap)
1394 for (
auto &DDI : Pair.second)
1395 salvageUnresolvedDbgValue(DDI);
1396 clearDanglingDebugInfo();
1405 if (It != FuncInfo.ValueMap.
end()) {
1406 unsigned InReg = It->second;
1412 Result = RFV.getCopyFromRegs(DAG, FuncInfo, getCurSDLoc(), Chain,
nullptr,
1414 resolveDanglingDebugInfo(V, Result);
1434 SDValue Val = getValueImpl(V);
1436 resolveDanglingDebugInfo(V, Val);
1442 return (NodeMap.find(V) != NodeMap.end()) ||
1443 (FuncInfo.ValueMap.find(V) != FuncInfo.ValueMap.end());
1452 if (isa<ConstantSDNode>(N) || isa<ConstantFPSDNode>(
N)) {
1463 SDValue Val = getValueImpl(V);
1465 resolveDanglingDebugInfo(V, Val);
1474 if (
const Constant *
C = dyn_cast<Constant>(V)) {
1483 if (isa<ConstantPointerNull>(
C)) {
1489 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
C))
1496 visit(CE->getOpcode(), *CE);
1498 assert(N1.getNode() &&
"visit didn't populate the NodeMap!");
1502 if (isa<ConstantStruct>(
C) || isa<ConstantArray>(
C)) {
1519 dyn_cast<ConstantDataSequential>(
C)) {
1521 for (
unsigned i = 0,
e = CDS->getNumElements(); i !=
e; ++i) {
1522 SDNode *Val = getValue(CDS->getElementAsConstant(i)).getNode();
1529 if (isa<ArrayType>(CDS->getType()))
1535 assert((isa<ConstantAggregateZero>(
C) || isa<UndefValue>(
C)) &&
1536 "Unknown struct or array constant!");
1540 unsigned NumElts = ValueVTs.
size();
1544 for (
unsigned i = 0; i != NumElts; ++i) {
1545 EVT EltVT = ValueVTs[i];
1546 if (isa<UndefValue>(
C))
1547 Constants[i] = DAG.
getUNDEF(EltVT);
1551 Constants[i] = DAG.
getConstant(0, getCurSDLoc(), EltVT);
1567 for (
unsigned i = 0; i != NumElements; ++i)
1568 Ops.
push_back(getValue(CV->getOperand(i)));
1570 assert(isa<ConstantAggregateZero>(
C) &&
"Unknown vector constant!");
1579 Ops.
assign(NumElements, Op);
1588 if (
const AllocaInst *AI = dyn_cast<AllocaInst>(V)) {
1590 FuncInfo.StaticAllocaMap.find(AI);
1591 if (SI != FuncInfo.StaticAllocaMap.end())
1597 if (
const Instruction *Inst = dyn_cast<Instruction>(V)) {
1598 unsigned InReg = FuncInfo.InitializeRegForValue(Inst);
1603 return RFV.getCopyFromRegs(DAG, FuncInfo, getCurSDLoc(), Chain,
nullptr, V);
1609 void SelectionDAGBuilder::visitCatchPad(
const CatchPadInst &
I) {
1619 if (IsMSVCCXX || IsCoreCLR)
1637 if (TargetMBB != NextBlock(FuncInfo.MBB) ||
1650 if (isa<ConstantTokenNone>(ParentPad))
1651 SuccessorColor = &FuncInfo.Fn->getEntryBlock();
1653 SuccessorColor = cast<Instruction>(ParentPad)->
getParent();
1654 assert(SuccessorColor &&
"No parent funclet for catchret!");
1656 assert(SuccessorColorMBB &&
"No MBB for SuccessorColor!");
1665 void SelectionDAGBuilder::visitCleanupPad(
const CleanupPadInst &CPI) {
1668 FuncInfo.MBB->setIsEHScopeEntry();
1671 FuncInfo.MBB->setIsEHFuncletEntry();
1672 FuncInfo.MBB->setIsCleanupFuncletEntry();
1687 if (isa<CleanupPadInst>(Pad)) {
1689 UnwindDests.emplace_back(FuncInfo.
MBBMap[EHPadBB], Prob);
1690 UnwindDests.back().first->setIsEHScopeEntry();
1692 }
else if (
auto *CatchSwitch = dyn_cast<CatchSwitchInst>(Pad)) {
1695 for (
const BasicBlock *CatchPadBB : CatchSwitch->handlers()) {
1696 UnwindDests.emplace_back(FuncInfo.
MBBMap[CatchPadBB], Prob);
1697 UnwindDests.back().first->setIsEHScopeEntry();
1728 assert(UnwindDests.size() <= 1 &&
1729 "There should be at most one unwind destination for wasm");
1736 if (isa<LandingPadInst>(Pad)) {
1738 UnwindDests.emplace_back(FuncInfo.
MBBMap[EHPadBB], Prob);
1740 }
else if (isa<CleanupPadInst>(Pad)) {
1743 UnwindDests.emplace_back(FuncInfo.
MBBMap[EHPadBB], Prob);
1744 UnwindDests.
back().first->setIsEHScopeEntry();
1745 UnwindDests.back().first->setIsEHFuncletEntry();
1747 }
else if (
auto *CatchSwitch = dyn_cast<CatchSwitchInst>(Pad)) {
1749 for (
const BasicBlock *CatchPadBB : CatchSwitch->handlers()) {
1750 UnwindDests.emplace_back(FuncInfo.
MBBMap[CatchPadBB], Prob);
1752 if (IsMSVCCXX || IsCoreCLR)
1753 UnwindDests.back().first->setIsEHFuncletEntry();
1755 UnwindDests.back().first->setIsEHScopeEntry();
1757 NewEHPadBB = CatchSwitch->getUnwindDest();
1763 if (BPI && NewEHPadBB)
1765 EHPadBB = NewEHPadBB;
1779 for (
auto &UnwindDest : UnwindDests) {
1780 UnwindDest.first->setIsEHPad();
1781 addSuccessorWithProb(FuncInfo.MBB, UnwindDest.first, UnwindDest.second);
1783 FuncInfo.MBB->normalizeSuccProbs();
1791 void SelectionDAGBuilder::visitCatchSwitch(
const CatchSwitchInst &CSI) {
1795 void SelectionDAGBuilder::visitRet(
const ReturnInst &I) {
1798 SDValue Chain = getControlRoot();
1810 LowerDeoptimizingReturn();
1814 if (!FuncInfo.CanLowerReturn) {
1815 unsigned DemoteReg = FuncInfo.DemoteRegister;
1828 DemoteReg, PtrValueVTs[0]);
1835 unsigned NumValues = ValueVTs.size();
1838 for (
unsigned i = 0; i != NumValues; ++i) {
1844 if (MemVTs[i] != ValueVTs[i])
1846 Chains[i] = DAG.
getStore(Chain, getCurSDLoc(), Val,
1856 unsigned NumValues = ValueVTs.
size();
1875 bool RetInReg = F->getAttributes().hasAttribute(
1878 for (
unsigned j = 0; j != NumValues; ++j) {
1879 EVT VT = ValueVTs[j];
1891 &Parts[0], NumParts, PartVT, &I, CC, ExtendKind);
1904 if (NeedsRegBlock) {
1906 if (j == NumValues - 1)
1916 for (
unsigned i = 0; i < NumParts; ++i) {
1931 assert(SwiftError.getFunctionArg() &&
"Need a swift error argument");
1933 Flags.setSwiftError();
1941 &I, FuncInfo.MBB, SwiftError.getFunctionArg()),
1949 Chain, CallConv, isVarArg, Outs, OutVals, getCurSDLoc(), DAG);
1953 "LowerReturn didn't return a valid chain!");
1968 if (VMI != FuncInfo.ValueMap.
end()) {
1969 assert(!V->
use_empty() &&
"Unused value assigned virtual registers!");
1970 CopyValueToVirtualRegister(V, VMI->second);
1979 if (!isa<Instruction>(V) && !isa<Argument>(V))
return;
1982 if (FuncInfo.isExportedInst(V))
return;
1984 unsigned Reg = FuncInfo.InitializeRegForValue(V);
1985 CopyValueToVirtualRegister(V, Reg);
1994 if (
VI->getParent() == FromBB)
1998 return FuncInfo.isExportedInst(V);
2003 if (isa<Argument>(V)) {
2008 return FuncInfo.isExportedInst(V);
2025 auto SuccSize = std::max<uint32_t>(
succ_size(SrcBB), 1);
2038 Prob = getEdgeProbability(Src, Dst);
2044 if (
const Instruction *I = dyn_cast<Instruction>(V))
2065 if (
const CmpInst *BOp = dyn_cast<CmpInst>(Cond)) {
2069 if (CurBB == SwitchBB ||
2070 (isExportableFromCurrentBlock(BOp->getOperand(0), BB) &&
2071 isExportableFromCurrentBlock(BOp->getOperand(1), BB))) {
2073 if (
const ICmpInst *IC = dyn_cast<ICmpInst>(Cond)) {
2075 InvertCond ? IC->getInversePredicate() : IC->getPredicate();
2082 if (
TM.Options.NoNaNsFPMath)
2086 CaseBlock CB(Condition, BOp->getOperand(0), BOp->getOperand(1),
nullptr,
2087 TBB, FBB, CurBB, getCurSDLoc(), TProb, FProb);
2088 SL->SwitchCases.push_back(CB);
2096 nullptr, TBB, FBB, CurBB, getCurSDLoc(), TProb, FProb);
2097 SL->SwitchCases.push_back(CB);
2114 FindMergedConditions(NotCond, TBB, FBB, CurBB, SwitchBB, Opc, TProb, FProb,
2129 if (BOpc == Instruction::And)
2130 BOpc = Instruction::Or;
2131 else if (BOpc == Instruction::Or)
2132 BOpc = Instruction::And;
2137 if (!BOp || !(isa<BinaryOperator>(BOp) || isa<CmpInst>(BOp)) ||
2138 BOpc !=
unsigned(Opc) || !BOp->
hasOneUse() ||
2142 EmitBranchForMergedCondition(Cond, TBB, FBB, CurBB, SwitchBB,
2143 TProb, FProb, InvertCond);
2153 if (Opc == Instruction::Or) {
2174 auto NewTrueProb = TProb / 2;
2175 auto NewFalseProb = TProb / 2 + FProb;
2177 FindMergedConditions(BOp->
getOperand(0), TBB, TmpBB, CurBB, SwitchBB, Opc,
2178 NewTrueProb, NewFalseProb, InvertCond);
2184 FindMergedConditions(BOp->
getOperand(1), TBB, FBB, TmpBB, SwitchBB, Opc,
2185 Probs[0], Probs[1], InvertCond);
2187 assert(Opc == Instruction::And &&
"Unknown merge op!");
2207 auto NewTrueProb = TProb + FProb / 2;
2208 auto NewFalseProb = FProb / 2;
2210 FindMergedConditions(BOp->
getOperand(0), TmpBB, FBB, CurBB, SwitchBB, Opc,
2211 NewTrueProb, NewFalseProb, InvertCond);
2217 FindMergedConditions(BOp->
getOperand(1), TBB, FBB, TmpBB, SwitchBB, Opc,
2218 Probs[0], Probs[1], InvertCond);
2227 if (Cases.size() != 2)
return true;
2231 if ((Cases[0].CmpLHS == Cases[1].CmpLHS &&
2232 Cases[0].CmpRHS == Cases[1].CmpRHS) ||
2233 (Cases[0].CmpRHS == Cases[1].CmpLHS &&
2234 Cases[0].CmpLHS == Cases[1].CmpRHS)) {
2240 if (Cases[0].CmpRHS == Cases[1].CmpRHS &&
2241 Cases[0].CC == Cases[1].CC &&
2242 isa<Constant>(Cases[0].CmpRHS) &&
2243 cast<Constant>(Cases[0].CmpRHS)->isNullValue()) {
2244 if (Cases[0].CC ==
ISD::SETEQ && Cases[0].TrueBB == Cases[1].ThisBB)
2246 if (Cases[0].CC ==
ISD::SETNE && Cases[0].FalseBB == Cases[1].ThisBB)
2253 void SelectionDAGBuilder::visitBr(
const BranchInst &I) {
2293 if (
const BinaryOperator *BOp = dyn_cast<BinaryOperator>(CondVal)) {
2297 (Opcode == Instruction::And || Opcode == Instruction::Or)) {
2298 FindMergedConditions(BOp, Succ0MBB, Succ1MBB, BrMBB, BrMBB,
2300 getEdgeProbability(BrMBB, Succ0MBB),
2301 getEdgeProbability(BrMBB, Succ1MBB),
2306 assert(SL->SwitchCases[0].ThisBB == BrMBB &&
"Unexpected lowering!");
2309 if (ShouldEmitAsBranches(SL->SwitchCases)) {
2310 for (
unsigned i = 1,
e = SL->SwitchCases.size(); i !=
e; ++i) {
2311 ExportFromCurrentBlock(SL->SwitchCases[i].CmpLHS);
2312 ExportFromCurrentBlock(SL->SwitchCases[i].CmpRHS);
2316 visitSwitchCase(SL->SwitchCases[0], BrMBB);
2317 SL->SwitchCases.erase(SL->SwitchCases.begin());
2323 for (
unsigned i = 1,
e = SL->SwitchCases.size(); i !=
e; ++i)
2324 FuncInfo.MF->erase(SL->SwitchCases[i].ThisBB);
2326 SL->SwitchCases.clear();
2332 nullptr, Succ0MBB, Succ1MBB, BrMBB, getCurSDLoc());
2336 visitSwitchCase(CB, BrMBB);
2344 SDValue CondLHS = getValue(CB.CmpLHS);
2349 addSuccessorWithProb(SwitchBB, CB.TrueBB, CB.TrueProb);
2351 if (CB.TrueBB != NextBlock(SwitchBB)) {
2359 EVT MemVT = TLI.getMemValueType(DAG.
getDataLayout(), CB.CmpLHS->getType());
2373 SDValue CondRHS = getValue(CB.CmpRHS);
2387 const APInt& Low = cast<ConstantInt>(CB.CmpLHS)->getValue();
2388 const APInt&
High = cast<ConstantInt>(CB.CmpRHS)->getValue();
2390 SDValue CmpOp = getValue(CB.CmpMHS);
2393 if (cast<ConstantInt>(CB.CmpLHS)->isMinValue(
true)) {
2405 addSuccessorWithProb(SwitchBB, CB.TrueBB, CB.TrueProb);
2408 if (CB.TrueBB != CB.FalseBB)
2409 addSuccessorWithProb(SwitchBB, CB.FalseBB, CB.FalseProb);
2414 if (CB.TrueBB == NextBlock(SwitchBB)) {
2436 assert(JT.
Reg != -1U &&
"Should lower JT Header first!");
2450 JumpTableHeader &JTH,
2452 SDLoc dl = getCurSDLoc();
2455 SDValue SwitchOp = getValue(JTH.SValue);
2468 unsigned JumpTableReg =
2471 JumpTableReg, SwitchOp);
2472 JT.
Reg = JumpTableReg;
2474 if (!JTH.OmitRangeCheck) {
2488 if (JT.
MBB != NextBlock(SwitchBB))
2495 if (JT.
MBB != NextBlock(SwitchBB))
2513 DAG.
getMachineNode(TargetOpcode::LOAD_STACK_GUARD, DL, PtrTy, Chain);
2522 if (PtrTy != PtrMemTy)
2545 SDLoc dl = getCurSDLoc();
2569 Entry.
Node = GuardVal;
2571 if (GuardCheckFn->hasAttribute(1, Attribute::AttrKind::InReg))
2573 Args.push_back(Entry);
2578 .setCallee(GuardCheckFn->getCallingConv(), FnTy->
getReturnType(),
2579 getValue(GuardCheckFn), std::move(Args));
2581 std::pair<SDValue, SDValue> Result = TLI.
LowerCallTo(CLI);
2593 SDValue GuardPtr = getValue(IRGuard);
2595 Guard = DAG.
getLoad(PtrMemTy, dl, Chain, GuardPtr,
2637 None, CallOptions, getCurSDLoc()).second;
2641 if (
TM.getTargetTriple().isPS4CPU())
2651 SDLoc dl = getCurSDLoc();
2654 SDValue SwitchOp = getValue(B.SValue);
2661 bool UsePtrType =
false;
2665 for (
unsigned i = 0,
e = B.Cases.size(); i !=
e; ++i)
2680 B.Reg = FuncInfo.CreateReg(B.RegVT);
2685 if (!B.OmitRangeCheck)
2686 addSuccessorWithProb(SwitchBB, B.Default, B.DefaultProb);
2687 addSuccessorWithProb(SwitchBB, MBB, B.Prob);
2691 if (!B.OmitRangeCheck) {
2704 if (MBB != NextBlock(SwitchBB))
2717 SDLoc dl = getCurSDLoc();
2723 if (PopCount == 1) {
2730 }
else if (PopCount == BB.Range) {
2750 addSuccessorWithProb(SwitchBB, B.TargetBB, B.ExtraProb);
2752 addSuccessorWithProb(SwitchBB, NextMBB, BranchProbToNext);
2763 if (NextMBB != NextBlock(SwitchBB))
2770 void SelectionDAGBuilder::visitInvoke(
const InvokeInst &I) {
2781 LLVMContext::OB_funclet,
2782 LLVMContext::OB_cfguardtarget}) &&
2783 "Cannot lower invokes with arbitrary operand bundles yet!");
2787 if (isa<InlineAsm>(
Callee))
2789 else if (Fn && Fn->isIntrinsic()) {
2790 switch (Fn->getIntrinsicID()) {
2793 case Intrinsic::donothing:
2796 case Intrinsic::experimental_patchpoint_void:
2797 case Intrinsic::experimental_patchpoint_i64:
2798 visitPatchpoint(&I, EHPadBB);
2800 case Intrinsic::experimental_gc_statepoint:
2803 case Intrinsic::wasm_rethrow_in_catch: {
2823 LowerCallSiteWithDeoptBundle(&I, getValue(
Callee), EHPadBB);
2825 LowerCallTo(&I, getValue(
Callee),
false, EHPadBB);
2833 CopyToExportRegsIfNeeded(&I);
2844 addSuccessorWithProb(InvokeMBB, Return);
2845 for (
auto &UnwindDest : UnwindDests) {
2846 UnwindDest.first->setIsEHPad();
2847 addSuccessorWithProb(InvokeMBB, UnwindDest.first, UnwindDest.second);
2856 void SelectionDAGBuilder::visitCallBr(
const CallBrInst &I) {
2862 {LLVMContext::OB_deopt, LLVMContext::OB_funclet}) &&
2863 "Cannot lower callbrs with arbitrary operand bundles yet!");
2866 "Only know how to handle inlineasm callbr");
2873 addSuccessorWithProb(CallBrMBB, Return);
2876 addSuccessorWithProb(CallBrMBB, Target);
2886 void SelectionDAGBuilder::visitResume(
const ResumeInst &RI) {
2887 llvm_unreachable(
"SelectionDAGBuilder shouldn't visit resume instructions!");
2890 void SelectionDAGBuilder::visitLandingPad(
const LandingPadInst &LP) {
2891 assert(FuncInfo.MBB->isEHPad() &&
2892 "Call to landingpad not in landing pad!");
2897 const Constant *PersonalityFn = FuncInfo.Fn->getPersonalityFn();
2898 if (TLI.getExceptionPointerRegister(PersonalityFn) == 0 &&
2899 TLI.getExceptionSelectorRegister(PersonalityFn) == 0)
2910 SDLoc dl = getCurSDLoc();
2912 assert(ValueVTs.
size() == 2 &&
"Only two-valued landingpads are supported");
2917 if (FuncInfo.ExceptionPointerVirtReg) {
2920 FuncInfo.ExceptionPointerVirtReg,
2928 FuncInfo.ExceptionSelectorVirtReg,
2941 for (
unsigned i = 0,
e = SL->JTCases.size(); i !=
e; ++i)
2942 if (SL->JTCases[i].first.HeaderBB == First)
2943 SL->JTCases[i].first.HeaderBB = Last;
2946 for (
unsigned i = 0,
e = SL->BitTestCases.size(); i !=
e; ++i)
2947 if (SL->BitTestCases[i].Parent == First)
2948 SL->BitTestCases[i].Parent = Last;
2951 void SelectionDAGBuilder::visitIndirectBr(
const IndirectBrInst &I) {
2958 bool Inserted = Done.
insert(BB).second;
2963 addSuccessorWithProb(IndirectBrMBB, Succ);
2972 void SelectionDAGBuilder::visitUnreachable(
const UnreachableInst &I) {
2979 if (&I != &BB.
front()) {
2982 if (
const CallInst *Call = dyn_cast<CallInst>(&*PredI)) {
2983 if (Call->doesNotReturn())
2992 void SelectionDAGBuilder::visitFSub(
const User &I) {
3017 case Instruction::Mul:
3018 case Instruction::And:
3019 case Instruction::Or:
3020 case Instruction::Xor:
3022 case Instruction::FAdd:
3023 case Instruction::FMul:
3024 if (
const FPMathOperator *FPOp = dyn_cast<const FPMathOperator>(Inst))
3025 if (FPOp->getFastMathFlags().isFast())
3037 unsigned ElemNumToReduce = ElemNum;
3060 bool ReduxExtracted =
false;
3062 while (!UsersToVisit.empty()) {
3063 auto User = UsersToVisit.back();
3064 UsersToVisit.pop_back();
3073 if (Inst->
getOpcode() == OpCode || isa<PHINode>(U)) {
3074 if (
const FPMathOperator *FPOp = dyn_cast<const FPMathOperator>(Inst))
3075 if (!isa<PHINode>(FPOp) && !FPOp->getFastMathFlags().isFast())
3077 UsersToVisit.push_back(U);
3079 dyn_cast<ShuffleVectorInst>(U)) {
3086 if (ResultElements < ElemNum)
3089 if (ElemNumToReduce == 1)
3091 if (!isa<UndefValue>(U->getOperand(1)))
3093 for (
unsigned i = 0; i < ElemNumToReduce / 2; ++i)
3094 if (ShufInst->getMaskValue(i) != int(i + ElemNumToReduce / 2))
3096 for (
unsigned i = ElemNumToReduce / 2; i < ElemNum; ++i)
3097 if (ShufInst->getMaskValue(i) != -1)
3102 if (!U->hasOneUse())
3106 if (!U2 || U2->getOpcode() != OpCode)
3110 if ((U2->getOperand(0) == U->getOperand(0) && U2->getOperand(1) == U) ||
3111 (U2->getOperand(1) == U->getOperand(0) && U2->getOperand(0) == U)) {
3112 UsersToVisit.push_back(U2);
3113 ElemNumToReduce /= 2;
3116 }
else if (isa<ExtractElementInst>(U)) {
3118 if (ElemNumToReduce != 1)
3122 if (!Val || !Val->
isZero())
3125 ReduxExtracted =
true;
3130 return ReduxExtracted;
3133 void SelectionDAGBuilder::visitUnary(
const User &I,
unsigned Opcode) {
3139 setValue(&I, UnNodeValue);
3142 void SelectionDAGBuilder::visitBinary(
const User &I,
unsigned Opcode) {
3144 if (
auto *OFBinOp = dyn_cast<OverflowingBinaryOperator>(&I)) {
3148 if (
auto *ExactOp = dyn_cast<PossiblyExactOperator>(&I)) {
3149 Flags.
setExact(ExactOp->isExact());
3153 LLVM_DEBUG(
dbgs() <<
"Detected a reduction operation:" << I <<
"\n");
3158 if (
auto *FPOp = dyn_cast<FPMathOperator>(&I)) {
3167 setValue(&I, BinNodeValue);
3170 void SelectionDAGBuilder::visitShift(
const User &I,
unsigned Opcode) {
3180 unsigned Op2Size = Op2.getValueSizeInBits();
3181 SDLoc DL = getCurSDLoc();
3184 if (ShiftSize > Op2Size)
3191 else if (ShiftSize >=
Log2_32_Ceil(Op2.getValueSizeInBits()))
3206 dyn_cast<const OverflowingBinaryOperator>(&I)) {
3207 nuw = OFBinOp->hasNoUnsignedWrap();
3208 nsw = OFBinOp->hasNoSignedWrap();
3211 dyn_cast<const PossiblyExactOperator>(&I))
3212 exact = ExactOp->isExact();
3223 void SelectionDAGBuilder::visitSDiv(
const User &I) {
3228 Flags.
setExact(isa<PossiblyExactOperator>(&I) &&
3229 cast<PossiblyExactOperator>(&I)->isExact());
3234 void SelectionDAGBuilder::visitICmp(
const User &I) {
3236 if (
const ICmpInst *IC = dyn_cast<ICmpInst>(&I))
3237 predicate = IC->getPredicate();
3238 else if (
const ConstantExpr *IC = dyn_cast<ConstantExpr>(&I))
3251 if (Op1.getValueType() != MemVT) {
3258 setValue(&I, DAG.
getSetCC(getCurSDLoc(), DestVT, Op1, Op2, Opcode));
3261 void SelectionDAGBuilder::visitFCmp(
const User &I) {
3263 if (
const FCmpInst *
FC = dyn_cast<FCmpInst>(&I))
3264 predicate =
FC->getPredicate();
3272 if ((FPMO && FPMO->hasNoNaNs()) ||
TM.Options.NoNaNsFPMath)
3277 setValue(&I, DAG.
getSetCC(getCurSDLoc(), DestVT, Op1, Op2, Condition));
3284 return isa<SelectInst>(V);
3288 void SelectionDAGBuilder::visitSelect(
const User &I) {
3292 unsigned NumValues = ValueVTs.
size();
3293 if (NumValues == 0)
return;
3299 auto BaseOps = {Cond};
3303 bool IsUnaryAbs =
false;
3307 EVT VT = ValueVTs[0];
3314 VT = TLI.getTypeToTransformTo(Ctx, VT);
3319 bool UseScalarMinMax = VT.
isVector() &&
3325 switch (SPR.Flavor) {
3331 switch (SPR.NaNBehavior) {
3340 else if (UseScalarMinMax)
3348 switch (SPR.NaNBehavior) {
3358 else if (UseScalarMinMax)
3374 (TLI.isOperationLegalOrCustom(Opc, VT) ||
3382 LHSVal = getValue(LHS);
3383 RHSVal = getValue(RHS);
3389 LHSVal = getValue(LHS);
3395 for (
unsigned i = 0; i != NumValues; ++i) {
3397 DAG.
getNode(OpCode, getCurSDLoc(),
3398 LHSVal.getNode()->getValueType(LHSVal.getResNo() + i),
3399 SDValue(LHSVal.getNode(), LHSVal.getResNo() + i));
3402 for (
unsigned i = 0; i != NumValues; ++i) {
3405 Ops.push_back(
SDValue(RHSVal.getNode(), RHSVal.getResNo() + i));
3407 OpCode, getCurSDLoc(),
3408 LHSVal.getNode()->getValueType(LHSVal.getResNo() + i), Ops);
3416 void SelectionDAGBuilder::visitTrunc(
const User &I) {
3424 void SelectionDAGBuilder::visitZExt(
const User &I) {
3433 void SelectionDAGBuilder::visitSExt(
const User &I) {
3442 void SelectionDAGBuilder::visitFPTrunc(
const User &I) {
3445 SDLoc dl = getCurSDLoc();
3453 void SelectionDAGBuilder::visitFPExt(
const User &I) {
3461 void SelectionDAGBuilder::visitFPToUI(
const User &I) {
3469 void SelectionDAGBuilder::visitFPToSI(
const User &I) {
3477 void SelectionDAGBuilder::visitUIToFP(
const User &I) {
3485 void SelectionDAGBuilder::visitSIToFP(
const User &I) {
3493 void SelectionDAGBuilder::visitPtrToInt(
const User &I) {
3507 void SelectionDAGBuilder::visitIntToPtr(
const User &I) {
3519 void SelectionDAGBuilder::visitBitCast(
const User &I) {
3521 SDLoc dl = getCurSDLoc();
3535 setValue(&I, DAG.
getConstant(
C->getValue(), dl, DestVT,
false,
3541 void SelectionDAGBuilder::visitAddrSpaceCast(
const User &I) {
3556 void SelectionDAGBuilder::visitInsertElement(
const User &I) {
3564 InVec, InVal, InIdx));
3567 void SelectionDAGBuilder::visitExtractElement(
const User &I) {
3577 void SelectionDAGBuilder::visitShuffleVector(
const User &I) {
3581 SDLoc DL = getCurSDLoc();
3604 unsigned MaskNumElts = Mask.size();
3606 if (SrcNumElts == MaskNumElts) {
3612 if (SrcNumElts < MaskNumElts) {
3616 if (MaskNumElts % SrcNumElts == 0) {
3620 unsigned NumConcat = MaskNumElts / SrcNumElts;
3621 bool IsConcat =
true;
3623 for (
unsigned i = 0; i != MaskNumElts; ++i) {
3629 if ((Idx % SrcNumElts != (i % SrcNumElts)) ||
3630 (ConcatSrcs[i / SrcNumElts] >= 0 &&
3631 ConcatSrcs[i / SrcNumElts] != (
int)(Idx / SrcNumElts))) {
3636 ConcatSrcs[i / SrcNumElts] = Idx / SrcNumElts;
3643 for (
auto Src : ConcatSrcs) {
3656 unsigned PaddedMaskNumElts =
alignTo(MaskNumElts, SrcNumElts);
3657 unsigned NumConcat = PaddedMaskNumElts / SrcNumElts;
3674 for (
unsigned i = 0; i != MaskNumElts; ++i) {
3676 if (Idx >= (
int)SrcNumElts)
3677 Idx -= SrcNumElts - PaddedMaskNumElts;
3685 if (MaskNumElts != PaddedMaskNumElts)
3690 setValue(&I, Result);
3694 if (SrcNumElts > MaskNumElts) {
3697 int StartIdx[2] = { -1, -1 };
3698 bool CanExtract =
true;
3699 for (
int Idx : Mask) {
3704 if (Idx >= (
int)SrcNumElts) {
3712 int NewStartIdx =
alignDown(Idx, MaskNumElts);
3713 if (NewStartIdx + MaskNumElts > SrcNumElts ||
3714 (StartIdx[Input] >= 0 && StartIdx[Input] != NewStartIdx))
3718 StartIdx[Input] = NewStartIdx;
3721 if (StartIdx[0] < 0 && StartIdx[1] < 0) {
3727 for (
unsigned Input = 0; Input < 2; ++Input) {
3728 SDValue &Src = Input == 0 ? Src1 : Src2;
3729 if (StartIdx[Input] < 0)
3741 for (
int &Idx : MappedOps) {
3742 if (Idx >= (
int)SrcNumElts)
3743 Idx -= SrcNumElts + StartIdx[1] - MaskNumElts;
3759 for (
int Idx : Mask) {
3765 SDValue &Src = Idx < (int)SrcNumElts ? Src1 : Src2;
3766 if (Idx >= (
int)SrcNumElts) Idx -= SrcNumElts;
3778 void SelectionDAGBuilder::visitInsertValue(
const User &I) {
3781 Indices = IV->getIndices();
3783 Indices = cast<ConstantExpr>(&
I)->getIndices();
3789 bool IntoUndef = isa<UndefValue>(Op0);
3790 bool FromUndef = isa<UndefValue>(Op1);
3800 unsigned NumAggValues = AggValueVTs.
size();
3801 unsigned NumValValues = ValValueVTs.size();
3805 if (!NumAggValues) {
3813 for (; i != LinearIndex; ++i)
3814 Values[i] = IntoUndef ? DAG.
getUNDEF(AggValueVTs[i]) :
3819 for (; i != LinearIndex + NumValValues; ++i)
3820 Values[i] = FromUndef ? DAG.
getUNDEF(AggValueVTs[i]) :
3824 for (; i != NumAggValues; ++i)
3825 Values[i] = IntoUndef ? DAG.
getUNDEF(AggValueVTs[i]) :
3832 void SelectionDAGBuilder::visitExtractValue(
const User &I) {
3835 Indices = EV->getIndices();
3837 Indices = cast<ConstantExpr>(&
I)->getIndices();
3842 bool OutOfUndef = isa<UndefValue>(Op0);
3850 unsigned NumValValues = ValValueVTs.
size();
3853 if (!NumValValues) {
3862 for (
unsigned i = LinearIndex; i != LinearIndex + NumValValues; ++i)
3863 Values[i - LinearIndex] =
3872 void SelectionDAGBuilder::visitGetElementPtr(
const User &I) {
3878 SDLoc dl = getCurSDLoc();
3896 const Value *Idx = GTI.getOperand();
3897 if (
StructType *StTy = GTI.getStructTypeOrNull()) {
3898 unsigned Field = cast<Constant>(Idx)->getUniqueInteger().getZExtValue();
3901 uint64_t
Offset = DL->getStructLayout(StTy)->getElementOffset(Field);
3906 if (int64_t(Offset) >= 0 && cast<GEPOperator>(I).isInBounds())
3915 APInt ElementSize(IdxSize, DL->getTypeAllocSize(GTI.getIndexedType()));
3921 C =
C->getSplatValue();
3923 if (
const auto *CI = dyn_cast_or_null<ConstantInt>(
C)) {
3928 SDValue OffsVal = VectorWidth ?
3958 if (ElementSize != 1) {
3960 unsigned Amt = ElementSize.
logBase2();
3977 if (PtrMemTy != PtrTy && !cast<GEPOperator>(I).isInBounds())
3983 void SelectionDAGBuilder::visitAlloca(
const AllocaInst &I) {
3986 if (FuncInfo.StaticAllocaMap.count(&I))
3989 SDLoc dl = getCurSDLoc();
3993 uint64_t TySize = DL.getTypeAllocSize(Ty);
4000 if (AllocSize.getValueType() != IntPtr)
4010 unsigned StackAlign =
4012 if (Align <= StackAlign)
4020 AllocSize = DAG.
getNode(
ISD::ADD, dl, AllocSize.getValueType(), AllocSize,
4021 DAG.
getConstant(StackAlign - 1, dl, IntPtr), Flags);
4026 DAG.
getConstant(~(uint64_t)(StackAlign - 1), dl, IntPtr));
4034 assert(FuncInfo.MF->getFrameInfo().hasVarSizedObjects());
4037 void SelectionDAGBuilder::visitLoad(
const LoadInst &I) {
4039 return visitAtomicLoad(I);
4046 if (
const Argument *
Arg = dyn_cast<Argument>(SV)) {
4047 if (
Arg->hasSwiftErrorAttr())
4048 return visitLoadFromSwiftError(I);
4051 if (
const AllocaInst *Alloca = dyn_cast<AllocaInst>(SV)) {
4052 if (Alloca->isSwiftError())
4053 return visitLoadFromSwiftError(I);
4062 bool isNonTemporal = I.
hasMetadata(LLVMContext::MD_nontemporal);
4063 bool isInvariant = I.
hasMetadata(LLVMContext::MD_invariant_load);
4064 bool isDereferenceable =
4075 unsigned NumValues = ValueVTs.size();
4080 bool ConstantMemory =
false;
4084 else if (NumValues > MaxParallelChains)
4085 Root = getMemoryRoot();
4093 ConstantMemory =
true;
4099 SDLoc dl = getCurSDLoc();
4112 unsigned ChainI = 0;
4113 for (
unsigned i = 0; i != NumValues; ++i, ++ChainI) {
4120 if (ChainI == MaxParallelChains) {
4121 assert(PendingLoads.empty() &&
"PendingLoads must be serialized first");
4138 if (isDereferenceable)
4144 MMOFlags, AAInfo, Ranges);
4147 if (MemVTs[i] != ValueVTs[i])
4153 if (!ConstantMemory) {
4159 PendingLoads.push_back(Chain);
4166 void SelectionDAGBuilder::visitStoreToSwiftError(
const StoreInst &I) {
4168 "call visitStoreToSwiftError when backend supports swifterror");
4175 assert(ValueVTs.size() == 1 && Offsets[0] == 0 &&
4176 "expect a single EVT for swifterror");
4185 SDValue(Src.getNode(), Src.getResNo()));
4189 void SelectionDAGBuilder::visitLoadFromSwiftError(
const LoadInst &I) {
4191 "call visitLoadFromSwiftError when backend supports swifterror");
4196 "Support volatile, non temporal, invariant for load_from_swift_error");
4207 "load_from_swift_error should not be constant memory");
4213 assert(ValueVTs.size() == 1 && Offsets[0] == 0 &&
4214 "expect a single EVT for swifterror");
4218 getRoot(), getCurSDLoc(),
4219 SwiftError.getOrCreateVRegUseAt(&I, FuncInfo.MBB, SV), ValueVTs[0]);
4224 void SelectionDAGBuilder::visitStore(
const StoreInst &I) {
4226 return visitAtomicStore(I);
4235 if (
const Argument *
Arg = dyn_cast<Argument>(PtrV)) {
4236 if (
Arg->hasSwiftErrorAttr())
4237 return visitStoreToSwiftError(I);
4240 if (
const AllocaInst *Alloca = dyn_cast<AllocaInst>(PtrV)) {
4241 if (Alloca->isSwiftError())
4242 return visitStoreToSwiftError(I);
4250 unsigned NumValues = ValueVTs.
size();
4262 SDLoc dl = getCurSDLoc();
4279 unsigned ChainI = 0;
4280 for (
unsigned i = 0; i != NumValues; ++i, ++ChainI) {
4282 if (ChainI == MaxParallelChains) {
4290 if (MemVTs[i] != ValueVTs[i])
4294 Alignment, MMOFlags, AAInfo);
4295 Chains[ChainI] = St;
4303 void SelectionDAGBuilder::visitMaskedStore(
const CallInst &I,
4304 bool IsCompressing) {
4305 SDLoc sdl = getCurSDLoc();
4308 unsigned& Alignment) {
4312 Alignment = cast<ConstantInt>(I.
getArgOperand(2))->getZExtValue();
4316 unsigned& Alignment) {
4324 Value *PtrOperand, *MaskOperand, *Src0Operand;
4327 getCompressingStoreOps(PtrOperand, MaskOperand, Src0Operand, Alignment);
4329 getMaskedStoreOps(PtrOperand, MaskOperand, Src0Operand, Alignment);
4331 SDValue Ptr = getValue(PtrOperand);
4332 SDValue Src0 = getValue(Src0Operand);
4333 SDValue Mask = getValue(MaskOperand);
4352 DAG.
getMaskedStore(getMemoryRoot(), sdl, Src0, Ptr, Offset, Mask, VT, MMO,
4355 setValue(&I, StoreNode);
4384 const Value *GEPPtr = GEP->getPointerOperand();
4390 unsigned FinalIndex = GEP->getNumOperands() - 1;
4391 Value *IndexVal = GEP->getOperand(FinalIndex);
4395 for (
unsigned i = 1; i < FinalIndex; ++i, ++GTI) {
4400 C =
C->getSplatValue();
4401 auto *CI = dyn_cast_or_null<ConstantInt>(
C);
4402 if (!CI || !CI->isZero())
4420 if (isa<VectorType>(C->
getType())) {
4427 auto *CI = cast<ConstantInt>(
C);
4441 unsigned GEPWidth = GEP->getType()->getVectorNumElements();
4448 void SelectionDAGBuilder::visitMaskedScatter(
const CallInst &I) {
4449 SDLoc sdl = getCurSDLoc();
4456 unsigned Alignment = (cast<ConstantInt>(I.
getArgOperand(2)))->getZExtValue();
4468 const Value *BasePtr = Ptr;
4469 bool UniformBase =
getUniformBase(BasePtr, Base, Index, IndexType, Scale,
4472 const Value *MemOpBasePtr = UniformBase ? BasePtr :
nullptr;
4478 VT.getStoreSize().getKnownMinSize(),
4482 Index = getValue(Ptr);
4488 Ops, MMO, IndexType);
4490 setValue(&I, Scatter);
4493 void SelectionDAGBuilder::visitMaskedLoad(
const CallInst &I,
bool IsExpanding) {
4494 SDLoc sdl = getCurSDLoc();
4497 unsigned& Alignment) {
4500 Alignment = cast<ConstantInt>(I.
getArgOperand(1))->getZExtValue();
4505 unsigned& Alignment) {
4513 Value *PtrOperand, *MaskOperand, *Src0Operand;
4516 getExpandingLoadOps(PtrOperand, MaskOperand, Src0Operand, Alignment);
4518 getMaskedLoadOps(PtrOperand, MaskOperand, Src0Operand, Alignment);
4520 SDValue Ptr = getValue(PtrOperand);
4521 SDValue Src0 = getValue(Src0Operand);
4522 SDValue Mask = getValue(MaskOperand);
4541 bool AddToChain = !AA || !AA->pointsToConstantMemory(ML);
4552 Alignment, AAInfo, Ranges);
4555 DAG.
getMaskedLoad(VT, sdl, InChain, Ptr, Offset, Mask, Src0, VT, MMO,
4558 PendingLoads.push_back(Load.getValue(1));
4562 void SelectionDAGBuilder::visitMaskedGather(
const CallInst &I) {
4563 SDLoc sdl = getCurSDLoc();
4572 unsigned Alignment = (cast<ConstantInt>(I.
getArgOperand(1)))->getZExtValue();
4585 const Value *BasePtr = Ptr;
4586 bool UniformBase =
getUniformBase(BasePtr, Base, Index, IndexType, Scale,
4588 bool ConstantMemory =
false;
4589 if (UniformBase && AA &&
4590 AA->pointsToConstantMemory(
4597 ConstantMemory =
true;
4607 Alignment, AAInfo, Ranges);
4611 Index = getValue(Ptr);
4617 Ops, MMO, IndexType);
4620 if (!ConstantMemory)
4621 PendingLoads.push_back(OutChain);
4622 setValue(&I, Gather);
4626 SDLoc dl = getCurSDLoc();
4647 AAMDNodes(),
nullptr, SSID, SuccessOrdering,
4651 dl, MemVT, VTs, InChain,
4662 void SelectionDAGBuilder::visitAtomicRMW(
const AtomicRMWInst &I) {
4663 SDLoc dl = getCurSDLoc();
4686 auto MemVT = getValue(I.
getValOperand()).getSimpleValueType();
4697 MemVT.getStoreSize(), Alignment,
AAMDNodes(),
4698 nullptr, SSID, Ordering);
4711 void SelectionDAGBuilder::visitFence(
const FenceInst &I) {
4712 SDLoc dl = getCurSDLoc();
4723 void SelectionDAGBuilder::visitAtomicLoad(
const LoadInst &I) {
4724 SDLoc dl = getCurSDLoc();
4741 if (I.
hasMetadata(LLVMContext::MD_invariant_load))
4773 PendingLoads.push_back(OutChain);
4788 void SelectionDAGBuilder::visitAtomicStore(
const StoreInst &I) {
4789 SDLoc dl = getCurSDLoc();
4812 nullptr, SSID, Ordering);
4835 void SelectionDAGBuilder::visitTargetIntrinsic(
const CallInst &I,
4836 unsigned Intrinsic) {
4856 TargetLowering::IntrinsicInfo
Info;
4878 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(Arg)) {
4879 assert(CI->getBitWidth() <= 64 &&
4880 "large intrinsic immediates not handled");
4898 if (IsTgtIntrinsic) {
4903 Info.opc, getCurSDLoc(), VTs, Ops, Info.memVT,
4905 Info.align ? Info.align->value() : 0, Info.flags, Info.size, AAInfo);
4906 }
else if (!HasChain) {
4917 PendingLoads.push_back(Chain);
4927 Result = lowerRangeToAssertZExt(DAG, I, Result);
4929 setValue(&I, Result);
4988 SDValue TwoToFractionalPartOfX;
4989 if (LimitFloatPrecision <= 6) {
5004 }
else if (LimitFloatPrecision <= 12) {
5066 LimitFloatPrecision > 0 && LimitFloatPrecision <= 18) {
5090 LimitFloatPrecision > 0 && LimitFloatPrecision <= 18) {
5104 if (LimitFloatPrecision <= 6) {
5119 }
else if (LimitFloatPrecision <= 12) {
5189 LimitFloatPrecision > 0 && LimitFloatPrecision <= 18) {
5202 if (LimitFloatPrecision <= 6) {
5215 }
else if (LimitFloatPrecision <= 12) {
5286 LimitFloatPrecision > 0 && LimitFloatPrecision <= 18) {
5299 if (LimitFloatPrecision <= 6) {
5314 }
else if (LimitFloatPrecision <= 12) {
5374 LimitFloatPrecision > 0 && LimitFloatPrecision <= 18)
5385 bool IsExp10 =
false;
5387 LimitFloatPrecision > 0 && LimitFloatPrecision <= 18) {
5390 IsExp10 = LHSC->isExactlyValue(Ten);
5419 unsigned Val = RHSC->getSExtValue();
5420 if ((
int)Val < 0) Val = -Val;
5448 CurSquare, CurSquare);
5453 if (RHSC->getSExtValue() < 0)
5486 unsigned ScaleInt = cast<ConstantSDNode>(Scale)->getZExtValue();
5491 Opcode, VT, ScaleInt);
5515 return DAG.
getNode(Opcode, DL, VT, LHS, RHS, Scale);
5550 bool SelectionDAGBuilder::EmitFuncArgumentDbgValue(
5557 if (!IsDbgDeclare) {
5561 bool IsInEntryBlock = FuncInfo.MBB == &FuncInfo.MF->front();
5562 if (!IsInEntryBlock)
5578 bool VariableIsFunctionInputArg = Variable->
isParameter() &&
5579 !DL->getInlinedAt();
5580 bool IsInPrologue = SDNodeOrder == LowestSDNodeOrder;
5581 if (!IsInPrologue && !VariableIsFunctionInputArg)
5612 if (VariableIsFunctionInputArg) {
5614 if (ArgNo >= FuncInfo.DescribedArgs.size())
5615 FuncInfo.DescribedArgs.resize(ArgNo + 1,
false);
5616 else if (!IsInPrologue && FuncInfo.DescribedArgs.test(ArgNo))
5618 FuncInfo.DescribedArgs.set(ArgNo);
5625 bool IsIndirect =
false;
5628 int FI = FuncInfo.getArgumentFrameIndex(Arg);
5636 if (ArgRegsAndSizes.
size() == 1)
5637 Reg = ArgRegsAndSizes.
front().first;
5647 IsIndirect = IsDbgDeclare;
5656 dyn_cast<FrameIndexSDNode>(LNode->getBasePtr().getNode()))
5662 auto splitMultiRegDbgValue
5665 for (
auto RegAndSize : SplitRegs) {
5669 int RegFragmentSizeInBits = RegAndSize.second;
5671 uint64_t ExprFragmentSizeInBits = ExprFragmentInfo->SizeInBits;
5674 if (Offset >= ExprFragmentSizeInBits)
5678 if (Offset + RegFragmentSizeInBits > ExprFragmentSizeInBits) {
5679 RegFragmentSizeInBits = ExprFragmentSizeInBits -
Offset;
5684 Expr, Offset, RegFragmentSizeInBits);
5685 Offset += RegAndSize.second;
5688 if (!FragmentExpr) {
5694 assert(!IsDbgDeclare &&
"DbgDeclare operand is not in memory?");
5695 FuncInfo.ArgDbgValues.push_back(
5696 BuildMI(MF, DL, TII->
get(TargetOpcode::DBG_VALUE), IsDbgDeclare,
5697 RegAndSize.first, Variable, *FragmentExpr));
5703 VMI = FuncInfo.ValueMap.
find(V);
5704 if (VMI != FuncInfo.ValueMap.
end()) {
5708 if (RFV.occupiesMultipleRegs()) {
5709 splitMultiRegDbgValue(RFV.getRegsAndSizes());
5714 IsIndirect = IsDbgDeclare;
5715 }
else if (ArgRegsAndSizes.
size() > 1) {
5718 splitMultiRegDbgValue(ArgRegsAndSizes);
5727 "Expected inlined-at fields to agree");
5728 IsIndirect = (Op->
isReg()) ? IsIndirect :
true;
5729 FuncInfo.ArgDbgValues.push_back(
5730 BuildMI(MF, DL, TII->
get(TargetOpcode::DBG_VALUE), IsIndirect,
5731 *
Op, Variable, Expr));
5741 unsigned DbgSDNodeOrder) {
5742 if (
auto *FISDN = dyn_cast<FrameIndexSDNode>(N.
getNode())) {
5754 false, dl, DbgSDNodeOrder);
5757 false, dl, DbgSDNodeOrder);
5761 switch (Intrinsic) {
5762 case Intrinsic::smul_fix:
5764 case Intrinsic::umul_fix:
5766 case Intrinsic::smul_fix_sat:
5768 case Intrinsic::umul_fix_sat:
5770 case Intrinsic::sdiv_fix:
5772 case Intrinsic::udiv_fix:
5779 void SelectionDAGBuilder::lowerCallToExternalSymbol(
const CallInst &I,
5780 const char *FunctionName) {
5781 assert(FunctionName &&
"FunctionName must not be nullptr");
5789 void SelectionDAGBuilder::visitIntrinsicCall(
const CallInst &I,
5790 unsigned Intrinsic) {
5792 SDLoc sdl = getCurSDLoc();
5796 switch (Intrinsic) {
5799 visitTargetIntrinsic(I, Intrinsic);
5801 case Intrinsic::vastart: visitVAStart(I);
return;
5802 case Intrinsic::vaend: visitVAEnd(I);
return;
5803 case Intrinsic::vacopy: visitVACopy(I);
return;
5804 case Intrinsic::returnaddress:
5809 case Intrinsic::addressofreturnaddress:
5813 case Intrinsic::sponentry:
5817 case Intrinsic::frameaddress:
5822 case Intrinsic::read_register: {
5826 DAG.
getMDNode(cast<MDNode>(cast<MetadataAsValue>(Reg)->getMetadata()));
5834 case Intrinsic::write_register: {
5839 DAG.
getMDNode(cast<MDNode>(cast<MetadataAsValue>(Reg)->getMetadata()));
5841 RegName, getValue(RegValue)));
5844 case Intrinsic::memcpy: {
5845 const auto &MCI = cast<MemCpyInst>(
I);
5850 unsigned DstAlign = std::max<unsigned>(MCI.getDestAlignment(), 1);
5851 unsigned SrcAlign = std::max<unsigned>(MCI.getSourceAlignment(), 1);
5853 bool isVol = MCI.isVolatile();
5857 SDValue Root = isVol ? getRoot() : getMemoryRoot();
5862 updateDAGForMaybeTailCall(MC);
5865 case Intrinsic::memset: {
5866 const auto &MSI = cast<MemSetInst>(
I);
5871 unsigned Align = std::max<unsigned>(MSI.getDestAlignment(), 1);
5872 bool isVol = MSI.isVolatile();
5874 SDValue Root = isVol ? getRoot() : getMemoryRoot();
5877 updateDAGForMaybeTailCall(MS);
5880 case Intrinsic::memmove: {
5881 const auto &MMI = cast<MemMoveInst>(
I);
5886 unsigned DstAlign = std::max<unsigned>(MMI.getDestAlignment(), 1);
5887 unsigned SrcAlign = std::max<unsigned>(MMI.getSourceAlignment(), 1);
5889 bool isVol = MMI.isVolatile();
5893 SDValue Root = isVol ? getRoot() : getMemoryRoot();
5897 updateDAGForMaybeTailCall(MM);
5900 case Intrinsic::memcpy_element_unordered_atomic: {
5912 SrcAlign, Length, LengthTy, ElemSz, isTC,
5915 updateDAGForMaybeTailCall(MC);
5918 case Intrinsic::memmove_element_unordered_atomic: {
5919 auto &
MI = cast<AtomicMemMoveInst>(
I);
5920 SDValue Dst = getValue(
MI.getRawDest());
5921 SDValue Src = getValue(
MI.getRawSource());
5922 SDValue Length = getValue(
MI.getLength());
5924 unsigned DstAlign =
MI.getDestAlignment();
5925 unsigned SrcAlign =
MI.getSourceAlignment();
5926 Type *LengthTy =
MI.getLength()->getType();
5927 unsigned ElemSz =
MI.getElementSizeInBytes();
5930 SrcAlign, Length, LengthTy, ElemSz, isTC,
5933 updateDAGForMaybeTailCall(MC);
5936 case Intrinsic::memset_element_unordered_atomic: {
5937 auto &
MI = cast<AtomicMemSetInst>(
I);
5938 SDValue Dst = getValue(
MI.getRawDest());
5940 SDValue Length = getValue(
MI.getLength());
5942 unsigned DstAlign =
MI.getDestAlignment();
5943 Type *LengthTy =
MI.getLength()->getType();
5944 unsigned ElemSz =
MI.getElementSizeInBytes();
5947 LengthTy, ElemSz, isTC,
5949 updateDAGForMaybeTailCall(MC);
5952 case Intrinsic::dbg_addr:
5953 case Intrinsic::dbg_declare: {
5954 const auto &DI = cast<DbgVariableIntrinsic>(
I);
5957 dropDanglingDebugInfo(Variable, Expression);
5958 assert(Variable &&
"Missing variable");
5962 if (!Address || isa<UndefValue>(Address) ||
5968 bool isParameter = Variable->isParameter() || isa<Argument>(
Address);
5973 if (
const auto *AI =
5975 if (AI->isStaticAlloca()) {
5976 auto I = FuncInfo.StaticAllocaMap.find(AI);
5977 if (I != FuncInfo.StaticAllocaMap.end())
5980 }
else if (
const auto *
Arg = dyn_cast<Argument>(
5982 FI = FuncInfo.getArgumentFrameIndex(
Arg);
5989 if (Intrinsic == Intrinsic::dbg_addr) {
5991 Variable, Expression, FI,
true, dl, SDNodeOrder);
5992 DAG.
AddDbgValue(SDV, getRoot().getNode(), isParameter);
6000 N = UnusedArgNodeMap[
Address];
6003 if (
const BitCastInst *BCI = dyn_cast<BitCastInst>(Address))
6004 Address = BCI->getOperand(0);
6007 if (isParameter && FINode) {
6011 true, dl, SDNodeOrder);
6012 }
else if (isa<Argument>(Address)) {
6015 EmitFuncArgumentDbgValue(Address, Variable, Expression, dl,
true, N);
6019 true, dl, SDNodeOrder);
6025 if (!EmitFuncArgumentDbgValue(Address, Variable, Expression, dl,
true,
6032 case Intrinsic::dbg_label: {
6035 assert(Label &&
"Missing label");
6042 case Intrinsic::dbg_value: {
6048 dropDanglingDebugInfo(Variable, Expression);
6053 if (handleDebugValue(V, Variable, Expression, dl, DI.
getDebugLoc(),
6062 DanglingDebugInfoMap[V].emplace_back(&DI, dl, SDNodeOrder);
6066 case Intrinsic::eh_typeid_for: {
6075 case Intrinsic::eh_return_i32:
6076 case Intrinsic::eh_return_i64:
6084 case Intrinsic::eh_unwind_init:
6087 case Intrinsic::eh_dwarf_cfa:
6092 case Intrinsic::eh_sjlj_callsite: {
6095 assert(CI &&
"Non-constant call site value in eh.sjlj.callsite!");
6101 case Intrinsic::eh_sjlj_functioncontext: {
6106 int FI = FuncInfo.StaticAllocaMap[FnCtx];
6110 case Intrinsic::eh_sjlj_setjmp: {
6116 setValue(&I, Op.getValue(0));
6120 case Intrinsic::eh_sjlj_longjmp:
6124 case Intrinsic::eh_sjlj_setup_dispatch:
6128 case Intrinsic::masked_gather:
6129 visitMaskedGather(I);
6131 case Intrinsic::masked_load:
6134 case Intrinsic::masked_scatter:
6135 visitMaskedScatter(I);
6137 case Intrinsic::masked_store:
6138 visitMaskedStore(I);
6140 case Intrinsic::masked_expandload:
6141 visitMaskedLoad(I,
true );
6143 case Intrinsic::masked_compressstore:
6144 visitMaskedStore(I,
true );
6146 case Intrinsic::powi:
6150 case Intrinsic::log:
6156 case Intrinsic::log10:
6159 case Intrinsic::exp:
6162 case Intrinsic::exp2:
6165 case Intrinsic::pow:
6169 case Intrinsic::sqrt:
6170 case Intrinsic::fabs:
6171 case Intrinsic::sin:
6172 case Intrinsic::cos:
6173 case Intrinsic::floor:
6174 case Intrinsic::ceil:
6175 case Intrinsic::trunc:
6176 case Intrinsic::rint:
6177 case Intrinsic::nearbyint:
6179 case Intrinsic::canonicalize: {
6181 switch (Intrinsic) {
6183 case Intrinsic::sqrt: Opcode =
ISD::FSQRT;
break;
6184 case Intrinsic::fabs: Opcode =
ISD::FABS;
break;
6185 case Intrinsic::sin: Opcode =
ISD::FSIN;
break;
6186 case Intrinsic::cos: Opcode =
ISD::FCOS;
break;
6187 case Intrinsic::floor: Opcode =
ISD::FFLOOR;
break;
6188 case Intrinsic::ceil: Opcode =
ISD::FCEIL;
break;
6189 case Intrinsic::trunc: Opcode =
ISD::FTRUNC;
break;
6190 case Intrinsic::rint: Opcode =
ISD::FRINT;
break;
6196 setValue(&I, DAG.
getNode(Opcode, sdl,
6201 case Intrinsic::lround:
6202 case Intrinsic::llround:
6203 case Intrinsic::lrint:
6204 case Intrinsic::llrint: {
6206 switch (Intrinsic) {
6208 case Intrinsic::lround: Opcode =
ISD::LROUND;
break;
6210 case Intrinsic::lrint: Opcode =
ISD::LRINT;
break;
6211 case Intrinsic::llrint: Opcode =
ISD::LLRINT;
break;
6215 setValue(&I, DAG.
getNode(Opcode, sdl, RetVT,
6243 case Intrinsic::copysign:
6249 case Intrinsic::fma:
6256 #define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC, DAGN) \ 6257 case Intrinsic::INTRINSIC: 6258 #include "llvm/IR/ConstrainedOps.def" 6259 visitConstrainedFPIntrinsic(cast<ConstrainedFPIntrinsic>(I));
6261 case Intrinsic::fmuladd: {
6284 case Intrinsic::convert_to_fp16:
6291 case Intrinsic::convert_from_fp16:
6297 case Intrinsic::pcmarker: {
6302 case Intrinsic::readcyclecounter: {
6310 case Intrinsic::bitreverse:
6315 case Intrinsic::bswap:
6320 case Intrinsic::cttz: {
6328 case Intrinsic::ctlz: {
6336 case Intrinsic::ctpop: {
6342 case Intrinsic::fshl:
6343 case Intrinsic::fshr: {
6344 bool IsFSHL = Intrinsic == Intrinsic::fshl;
6355 setValue(&I, DAG.
getNode(FunnelOpcode, sdl, VT, X, Y, Z));
6365 setValue(&I, DAG.
getNode(RotateOpcode, sdl, VT, X, Z));
6374 setValue(&I, DAG.
getNode(RotateOpcode, sdl, VT, X, NegShAmt));
6404 setValue(&I, DAG.
getSelect(sdl, VT, IsZeroShift, IsFSHL ? X : Y, Or));
6407 case Intrinsic::sadd_sat: {
6413 case Intrinsic::uadd_sat: {
6419 case Intrinsic::ssub_sat: {
6425 case Intrinsic::usub_sat: {
6431 case Intrinsic::smul_fix:
6432 case Intrinsic::umul_fix:
6433 case Intrinsic::smul_fix_sat:
6434 case Intrinsic::umul_fix_sat: {
6442 case Intrinsic::sdiv_fix:
6443 case Intrinsic::udiv_fix: {
6448 Op1, Op2, Op3, DAG, TLI));
6451 case Intrinsic::stacksave: {
6460 case Intrinsic::stackrestore:
6464 case Intrinsic::get_dynamic_area_offset: {
6479 case Intrinsic::stackguard: {
6488 unsigned Align = DL->getPrefTypeAlignment(Global->
getType());
6489 Res = DAG.
getLoad(PtrTy, sdl, Chain, getValue(Global),
6499 case Intrinsic::stackprotector: {
6504 SDValue Src, Chain = getRoot();
6513 int FI = FuncInfo.StaticAllocaMap[Slot];
6526 case Intrinsic::objectsize:
6529 case Intrinsic::is_constant:
6532 case Intrinsic::annotation:
6533 case Intrinsic::ptr_annotation:
6534 case Intrinsic::launder_invariant_group:
6535 case Intrinsic::strip_invariant_group:
6539 case Intrinsic::assume:
6540 case Intrinsic::var_annotation:
6541 case Intrinsic::sideeffect:
6545 case Intrinsic::codeview_annotation: {
6557 case Intrinsic::init_trampoline: {
6573 case Intrinsic::adjust_trampoline:
6578 case Intrinsic::gcroot: {
6580 "only valid in functions with gc specified, enforced by Verifier");
6581 assert(GFI &&
"implied by previous");
6586 GFI->addStackRoot(FI->getIndex(), TypeMap);
6589 case Intrinsic::gcread:
6590 case Intrinsic::gcwrite:
6592 case Intrinsic::flt_rounds:
6596 case Intrinsic::expect:
6601 case Intrinsic::debugtrap:
6602 case Intrinsic::trap: {
6607 if (TrapFuncName.
empty()) {
6622 std::pair<SDValue, SDValue> Result = TLI.
LowerCallTo(CLI);
6627 case Intrinsic::uadd_with_overflow:
6628 case Intrinsic::sadd_with_overflow:
6629 case Intrinsic::usub_with_overflow:
6630 case Intrinsic::ssub_with_overflow:
6631 case Intrinsic::umul_with_overflow:
6632 case Intrinsic::smul_with_overflow: {
6634 switch (Intrinsic) {
6636 case Intrinsic::uadd_with_overflow: Op =
ISD::UADDO;
break;
6637 case Intrinsic::sadd_with_overflow: Op =
ISD::SADDO;
break;
6638 case Intrinsic::usub_with_overflow: Op =
ISD::USUBO;
break;
6639 case Intrinsic::ssub_with_overflow: Op =
ISD::SSUBO;
break;
6640 case Intrinsic::umul_with_overflow: Op =
ISD::UMULO;
break;
6641 case Intrinsic::smul_with_overflow: Op =
ISD::SMULO;
break;
6648 if (ResultVT.isVector())
6653 setValue(&I, DAG.
getNode(Op, sdl, VTs, Op1, Op2));
6658 unsigned rw = cast<ConstantInt>(I.
getArgOperand(1))->getZExtValue();
6674 PendingLoads.push_back(Result);
6679 case Intrinsic::lifetime_start:
6680 case Intrinsic::lifetime_end: {
6681 bool IsStart = (Intrinsic == Intrinsic::lifetime_start);
6686 const int64_t ObjectSize =
6693 E = Allocas.
end(); Object !=
E; ++Object) {
6694 const AllocaInst *LifetimeObject = dyn_cast_or_null<AllocaInst>(*Object);
6697 if (!LifetimeObject)
6702 auto SI = FuncInfo.StaticAllocaMap.find(LifetimeObject);
6703 if (
SI == FuncInfo.StaticAllocaMap.end())
6711 Res = DAG.
getLifetimeNode(IsStart, sdl, getRoot(), FrameIndex, ObjectSize,
6717 case Intrinsic::invariant_start:
6721 case Intrinsic::invariant_end:
6724 case Intrinsic::clear_cache:
6727 lowerCallToExternalSymbol(I, FunctionName);
6729 case Intrinsic::donothing:
6732 case Intrinsic::experimental_stackmap:
6735 case Intrinsic::experimental_patchpoint_void:
6736 case Intrinsic::experimental_patchpoint_i64:
6737 visitPatchpoint(&I);
6739 case Intrinsic::experimental_gc_statepoint:
6742 case Intrinsic::experimental_gc_result:
6743 visitGCResult(cast<GCResultInst>(I));
6745 case Intrinsic::experimental_gc_relocate:
6746 visitGCRelocate(cast<GCRelocateInst>(I));
6748 case Intrinsic::instrprof_increment:
6750 case Intrinsic::instrprof_value_profile:
6752 case Intrinsic::localescape: {
6760 if (isa<ConstantPointerNull>(Arg))
6763 assert(FuncInfo.StaticAllocaMap.count(Slot) &&
6764 "can only escape static allocas");
6765 int FI = FuncInfo.StaticAllocaMap[Slot];
6769 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, dl,
6770 TII->
get(TargetOpcode::LOCAL_ESCAPE))
6771 .addSym(FrameAllocSym)
6778 case Intrinsic::localrecover: {
6807 case Intrinsic::eh_exceptionpointer:
6808 case Intrinsic::eh_exceptioncode: {
6813 unsigned VReg = FuncInfo.getCatchPadExceptionPointerVReg(CPI, PtrRC);
6816 if (Intrinsic == Intrinsic::eh_exceptioncode)
6821 case Intrinsic::xray_customevent: {
6829 SDLoc DL = getCurSDLoc();
6849 setValue(&I, patchableNode);
6852 case Intrinsic::xray_typedevent: {
6860 SDLoc DL = getCurSDLoc();
6881 TargetOpcode::PATCHABLE_TYPED_EVENT_CALL, DL, NodeTys, Ops);
6884 setValue(&I, patchableNode);
6887 case Intrinsic::experimental_deoptimize:
6888 LowerDeoptimizeCall(&I);
6891 case Intrinsic::experimental_vector_reduce_v2_fadd:
6892 case Intrinsic::experimental_vector_reduce_v2_fmul:
6893 case Intrinsic::experimental_vector_reduce_add:
6894 case Intrinsic::experimental_vector_reduce_mul:
6895 case Intrinsic::experimental_vector_reduce_and:
6896 case Intrinsic::experimental_vector_reduce_or:
6897 case Intrinsic::experimental_vector_reduce_xor:
6898 case Intrinsic::experimental_vector_reduce_smax:
6899 case Intrinsic::experimental_vector_reduce_smin:
6900 case Intrinsic::experimental_vector_reduce_umax:
6901 case Intrinsic::experimental_vector_reduce_umin:
6902 case Intrinsic::experimental_vector_reduce_fmax:
6903 case Intrinsic::experimental_vector_reduce_fmin:
6904 visitVectorReduce(I, Intrinsic);
6907 case Intrinsic::icall_branch_funnel: {
6916 "llvm.icall.branch.funnel operand must be a GlobalValue");
6919 struct BranchFunnelTarget {
6928 if (ElemBase !=
Base)
6930 "to the same GlobalValue");
6936 "llvm.icall.branch.funnel operand must be a GlobalValue");
6938 GA->getGlobal(), getCurSDLoc(),
6942 [](
const BranchFunnelTarget &
T1,
const BranchFunnelTarget &T2) {
6943 return T1.Offset < T2.Offset;
6946 for (
auto &
T : Targets) {
6961 case Intrinsic::wasm_landingpad_index:
6967 case Intrinsic::aarch64_settag:
6968 case Intrinsic::aarch64_settag_zero: {
6970 bool ZeroMemory = Intrinsic == Intrinsic::aarch64_settag_zero;
6972 DAG, getCurSDLoc(), getRoot(), getValue(I.
getArgOperand(0)),
6979 case Intrinsic::ptrmask: {
6993 void SelectionDAGBuilder::visitConstrainedFPIntrinsic(
6995 SDLoc sdl = getCurSDLoc();
7022 #define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC, DAGN) \ 7023 case Intrinsic::INTRINSIC: \ 7024 Opcode = ISD::STRICT_##DAGN; \ 7026 #include "llvm/IR/ConstrainedOps.def" 7062 PendingConstrainedFP.push_back(OutChain);
7068 PendingConstrainedFPStrict.push_back(OutChain);
7073 setValue(&FPI, FPResult);
7076 std::pair<SDValue, SDValue>
7091 if (CallSiteIndex) {
7093 LPadToCallSiteMap[FuncInfo.MBBMap[EHPadBB]].push_back(CallSiteIndex);
7107 std::pair<SDValue, SDValue> Result = TLI.
LowerCallTo(CLI);
7110 "Non-null chain expected with non-tail call!");
7111 assert((Result.second.getNode() || !Result.first.getNode()) &&
7112 "Null value expected with tail call!");
7114 if (!Result.second.getNode()) {
7121 PendingExports.clear();
7140 BeginLabel, EndLabel);
7142 MF.
addInvoke(FuncInfo.MBBMap[EHPadBB], BeginLabel, EndLabel);
7159 const Value *SwiftErrorVal =
nullptr;
7166 if (Caller->getFnAttribute(
"disable-tail-calls").getValueAsString() ==
7174 Caller->getAttributes().hasAttrSomewhere(Attribute::SwiftError))
7181 const Value *V = *i;
7187 SDValue ArgNode = getValue(V);
7198 SwiftError.getOrCreateVRegUseAt(CS.
getInstruction(), FuncInfo.MBB, V),
7202 Args.push_back(Entry);
7206 if (Entry.
IsSRet && isa<Instruction>(V))
7214 Value *V = Bundle->Inputs[0];
7215 SDValue ArgNode = getValue(V);
7216 Entry.
Node = ArgNode;
7219 Args.push_back(Entry);
7235 .
setCallee(RetTy, FTy, Callee, std::move(Args), CS)
7238 std::pair<SDValue, SDValue> Result = lowerInvokable(CLI, EHPadBB);
7240 if (Result.first.getNode()) {
7242 Result.first = lowerRangeToAssertZExt(DAG, *Inst, Result.first);
7243 setValue(Inst, Result.first);
7252 Register VReg = SwiftError.getOrCreateVRegDefAt(
7263 if (
const Constant *LoadInput = dyn_cast<Constant>(PtrVal)) {
7274 const_cast<Constant *>(LoadInput), LoadTy, *Builder.
DL))
7281 bool ConstantMemory =
false;
7286 ConstantMemory =
true;
7297 if (!ConstantMemory)
7304 void SelectionDAGBuilder::processIntegerCallValue(
const Instruction &I,
7313 setValue(&I, Value);
7321 bool SelectionDAGBuilder::visitMemCmpCall(
const CallInst &I) {
7328 setValue(&I, DAG.
getConstant(0, getCurSDLoc(), CallVT));
7334 DAG, getCurSDLoc(), DAG.
getRoot(), getValue(LHS), getValue(RHS),
7336 if (Res.first.getNode()) {
7337 processIntegerCallValue(I, Res.first,
true);
7338 PendingLoads.push_back(Res.second);
7351 auto hasFastLoadsAndCompare = [&](
unsigned NumBits) {
7359 unsigned SrcAS = RHS->getType()->getPointerAddressSpace();
7374 switch (NumBitsToCompare) {
7386 LoadVT = hasFastLoadsAndCompare(NumBitsToCompare);
7404 processIntegerCallValue(I, Cmp,
false);
7413 bool SelectionDAGBuilder::visitMemChrCall(
const CallInst &I) {
7419 std::pair<SDValue, SDValue> Res =
7421 getValue(Src), getValue(Char), getValue(Length),
7423 if (Res.first.getNode()) {
7424 setValue(&I, Res.first);
7425 PendingLoads.push_back(Res.second);
7437 bool SelectionDAGBuilder::visitMemPCpyCall(
const CallInst &I) {
7444 unsigned Align = std::min(DstAlign, SrcAlign);
7449 SDLoc sdl = getCurSDLoc();
7454 SDValue Root = isVol ? getRoot() : getMemoryRoot();
7460 "** memcpy should not be lowered as TailCall in mempcpy context **");
7469 setValue(&I, DstPlusSize);
7478 bool SelectionDAGBuilder::visitStrCpyCall(
const CallInst &I,
bool isStpcpy) {
7482 std::pair<SDValue, SDValue> Res =
7484 getValue(Arg0), getValue(Arg1),
7487 if (Res.first.getNode()) {
7488 setValue(&I, Res.first);
7501 bool SelectionDAGBuilder::visitStrCmpCall(
const CallInst &I) {
7505 std::pair<SDValue, SDValue> Res =
7507 getValue(Arg0), getValue(Arg1),
7510 if (Res.first.getNode()) {
7511 processIntegerCallValue(I, Res.first,
true);
7512 PendingLoads.push_back(Res.second);
7524 bool SelectionDAGBuilder::visitStrLenCall(
const CallInst &I) {
7528 std::pair<SDValue, SDValue> Res =
7531 if (Res.first.getNode()) {
7532 processIntegerCallValue(I, Res.first,
false);
7533 PendingLoads.push_back(Res.second);
7545 bool SelectionDAGBuilder::visitStrNLenCall(
const CallInst &I) {
7549 std::pair<SDValue, SDValue> Res =
7551 getValue(Arg0), getValue(Arg1),
7553 if (Res.first.getNode()) {
7554 processIntegerCallValue(I, Res.first,
false);
7555 PendingLoads.push_back(Res.second);
7567 bool SelectionDAGBuilder::visitUnaryFloatCall(
const CallInst &I,
7583 bool SelectionDAGBuilder::visitBinaryFloatCall(
const CallInst &I,
7592 setValue(&I, DAG.
getNode(Opcode, getCurSDLoc(), VT, Tmp0, Tmp1));
7596 void SelectionDAGBuilder::visitCall(
const CallInst &I) {
7604 if (
F->isDeclaration()) {
7606 unsigned IID =
F->getIntrinsicID();
7609 IID = II->getIntrinsicID(
F);
7612 visitIntrinsicCall(I, IID);
7622 F->hasName() && LibInfo->getLibFunc(*
F, Func) &&
7623 LibInfo->hasOptimizedCodeGen(Func)) {
7626 case LibFunc_copysign:
7627 case LibFunc_copysignf:
7628 case LibFunc_copysignl:
7672 case LibFunc_sqrt_finite:
7673 case LibFunc_sqrtf_finite:
7674 case LibFunc_sqrtl_finite:
7679 case LibFunc_floorf:
7680 case LibFunc_floorl:
7684 case LibFunc_nearbyint:
7685 case LibFunc_nearbyintf:
7686 case LibFunc_nearbyintl:
7703 case LibFunc_roundf:
7704 case LibFunc_roundl:
7709 case LibFunc_truncf:
7710 case LibFunc_truncl:
7726 case LibFunc_memcmp:
7727 if (visitMemCmpCall(I))
7730 case LibFunc_mempcpy:
7731 if (visitMemPCpyCall(I))
7734 case LibFunc_memchr:
7735 if (visitMemChrCall(I))
7738 case LibFunc_strcpy:
7739 if (visitStrCpyCall(I,
false))
7742 case LibFunc_stpcpy:
7743 if (visitStrCpyCall(I,
true))
7746 case LibFunc_strcmp:
7747 if (visitStrCmpCall(I))
7750 case LibFunc_strlen:
7751 if (visitStrLenCall(I))
7754 case LibFunc_strnlen:
7755 if (visitStrNLenCall(I))
7766 LLVMContext::OB_funclet,
7767 LLVMContext::OB_cfguardtarget}) &&
7768 "Cannot lower calls with arbitrary operand bundles!");
7773 LowerCallSiteWithDeoptBundle(&I, Callee,
nullptr);
7806 for (
const auto &Code : Codes)
7820 if (isa<BasicBlock>(CallOperandVal))
7823 llvm::Type *OpTy = CallOperandVal->getType();
7836 if (
StructType *STy = dyn_cast<StructType>(OpTy))
7837 if (STy->getNumElements() == 1)
7838 OpTy = STy->getElementType(0);
7869 SDISelAsmOperandInfo &MatchingOpInfo,
7871 if (OpInfo.ConstraintVT == MatchingOpInfo.ConstraintVT)
7877 std::pair<unsigned, const TargetRegisterClass *> MatchRC =
7879 OpInfo.ConstraintVT);
7880 std::pair<unsigned, const TargetRegisterClass *> InputRC =
7881 TLI.getRegForInlineAsmConstraint(TRI, MatchingOpInfo.ConstraintCode,
7882 MatchingOpInfo.ConstraintVT);
7883 if ((OpInfo.ConstraintVT.isInteger() !=
7884 MatchingOpInfo.ConstraintVT.isInteger()) ||
7885 (MatchRC.second != InputRC.second)) {
7888 " with a matching output constraint of" 7889 " incompatible type!");
7891 MatchingOpInfo.ConstraintVT = OpInfo.ConstraintVT;
7898 SDISelAsmOperandInfo &OpInfo,
7911 const Value *OpVal = OpInfo.CallOperandVal;
7912 if (isa<ConstantFP>(OpVal) || isa<ConstantInt>(OpVal) ||
7913 isa<ConstantVector>(OpVal) || isa<ConstantDataVector>(OpVal)) {
7922 uint64_t TySize = DL.getTypeAllocSize(Ty);
7923 unsigned Align = DL.getPrefTypeAlignment(Ty);
7927 Chain = DAG.
getTruncStore(Chain, Location, OpInfo.CallOperand, StackSlot,
7930 OpInfo.CallOperand = StackSlot;
7944 SDISelAsmOperandInfo &OpInfo,
7945 SDISelAsmOperandInfo &RefOpInfo) {
7959 unsigned AssignedReg;
7962 &TRI, RefOpInfo.ConstraintCode, RefOpInfo.ConstraintVT);
7986 if (RegVT.
getSizeInBits() == OpInfo.ConstraintVT.getSizeInBits()) {
7991 OpInfo.CallOperand =
7993 OpInfo.ConstraintVT = RegVT;
7997 }
else if (RegVT.
isInteger() && OpInfo.ConstraintVT.isFloatingPoint()) {
8000 OpInfo.CallOperand =
8002 OpInfo.ConstraintVT = VT;
8009 if (OpInfo.isMatchingInputConstraint())
8012 EVT ValueVT = OpInfo.ConstraintVT;
8017 unsigned NumRegs = 1;
8033 for (; *I != AssignedReg; ++
I)
8034 assert(I != RC->
end() &&
"AssignedReg should be member of RC");
8037 for (; NumRegs; --NumRegs, ++
I) {
8038 assert(I != RC->
end() &&
"Ran out of registers to allocate!");
8043 OpInfo.AssignedRegs =
RegsForValue(Regs, RegVT, ValueVT);
8048 const std::vector<SDValue> &AsmNodeOperands) {
8051 for (; OperandNo; --OperandNo) {
8054 cast<ConstantSDNode>(AsmNodeOperands[CurOp])->getZExtValue();
8058 "Skipped past definitions?");
8097 unsigned get()
const {
return Flags; }
8107 SDISelAsmOperandInfoVector ConstraintOperands;
8116 ExtraFlags ExtraInfo(CS);
8120 for (
auto &
T : TargetConstraints) {
8121 ConstraintOperands.push_back(SDISelAsmOperandInfo(
T));
8122 SDISelAsmOperandInfo &OpInfo = ConstraintOperands.back();
8127 OpInfo.CallOperandVal =
const_cast<Value *
>(CS.
getArgument(ArgNo++));
8132 if (isa<CallBrInst>(I) &&
8133 (ArgNo - 1) >= (cast<CallBrInst>(I)->getNumArgOperands() -
8134 cast<CallBrInst>(I)->getNumIndirectDests())) {
8135 const auto *BA = cast<BlockAddress>(OpInfo.CallOperandVal);
8138 }
else if (
const auto *BB = dyn_cast<BasicBlock>(OpInfo.CallOperandVal)) {
8139 OpInfo.CallOperand = DAG.
getBasicBlock(FuncInfo.MBBMap[BB]);
8141 OpInfo.CallOperand = getValue(OpInfo.CallOperandVal);
8144 OpInfo.ConstraintVT =
8156 assert(ResNo == 0 &&
"Asm only has one result!");
8157 OpInfo.ConstraintVT =
8166 HasSideEffect = OpInfo.hasMemory(TLI);
8175 OpInfo.CallOperand && !isa<ConstantSDNode>(OpInfo.CallOperand))
8178 return emitInlineAsmError(
8179 CS,
"constraint '" +
Twine(
T.ConstraintCode) +
"' expects an " 8180 "integer constant expression");
8182 ExtraInfo.update(
T);
8195 Chain = getControlRoot();
8199 for (SDISelAsmOperandInfo &OpInfo : ConstraintOperands) {
8204 if (OpInfo.hasMatchingInput()) {
8205 SDISelAsmOperandInfo &Input = ConstraintOperands[OpInfo.MatchingInput];
8219 !OpInfo.isIndirect) {
8220 assert((OpInfo.isMultipleAlternative ||
8222 "Can only indirectify direct input operands!");
8228 OpInfo.CallOperandVal =
nullptr;
8231 OpInfo.isIndirect =
true;
8237 std::vector<SDValue> AsmNodeOperands;
8238 AsmNodeOperands.push_back(
SDValue());
8246 AsmNodeOperands.push_back(DAG.
getMDNode(SrcLoc));
8255 for (SDISelAsmOperandInfo &OpInfo : ConstraintOperands) {
8257 SDISelAsmOperandInfo &RefOpInfo =
8258 OpInfo.isMatchingInputConstraint()
8259 ? ConstraintOperands[OpInfo.getMatchedOperand()]
8263 switch (OpInfo.Type) {
8266 unsigned ConstraintID =
8269 "Failed to convert memory constraint code to constraint id.");
8276 AsmNodeOperands.push_back(OpInfo.CallOperand);
8281 if (OpInfo.AssignedRegs.Regs.empty()) {
8283 CS,
"couldn't allocate output register for constraint '" +
8284 Twine(OpInfo.ConstraintCode) +
"'");
8290 OpInfo.AssignedRegs.AddInlineAsmOperands(
8293 false, 0, getCurSDLoc(), DAG, AsmNodeOperands);
8298 SDValue InOperandVal = OpInfo.CallOperand;
8300 if (OpInfo.isMatchingInputConstraint()) {
8306 cast<ConstantSDNode>(AsmNodeOperands[CurOp])->getZExtValue();
8310 if (OpInfo.isIndirect) {
8312 emitInlineAsmError(CS,
"inline asm not supported yet:" 8313 " don't know how to handle tied " 8314 "indirect register inputs");
8318 MVT RegVT = AsmNodeOperands[CurOp+1].getSimpleValueType();
8325 for (
unsigned i = 0; i != NumRegs; ++i)
8328 emitInlineAsmError(CS,
"inline asm error: This value type register " 8329 "class is not natively supported!");
8335 SDLoc dl = getCurSDLoc();
8337 MatchedRegs.getCopyToRegs(InOperandVal, DAG, dl, Chain, &Flag,
8340 true, OpInfo.getMatchedOperand(), dl,
8341 DAG, AsmNodeOperands);
8347 "Unexpected number of operands");
8352 OpInfo.getMatchedOperand());
8355 AsmNodeOperands.push_back(AsmNodeOperands[CurOp+1]);
8366 std::vector<SDValue> Ops;
8371 if (isa<ConstantSDNode>(InOperandVal)) {
8372 emitInlineAsmError(CS,
"value out of range for constraint '" +
8373 Twine(OpInfo.ConstraintCode) +
"'");
8377 emitInlineAsmError(CS,
"invalid operand for inline asm constraint '" +
8378 Twine(OpInfo.ConstraintCode) +
"'");
8383 unsigned ResOpType =
8387 AsmNodeOperands.insert(AsmNodeOperands.end(), Ops.begin(), Ops.end());
8392 assert(OpInfo.isIndirect &&
"Operand must be indirect to be a mem!");
8395 "Memory operands expect pointer values");
8397 unsigned ConstraintID =
8400 "Failed to convert memory constraint code to constraint id.");
8408 AsmNodeOperands.push_back(InOperandVal);
8414 "Unknown constraint type!");
8417 if (OpInfo.isIndirect) {
8419 CS,
"Don't know how to handle indirect register inputs yet " 8420 "for constraint '" +
8421 Twine(OpInfo.ConstraintCode) +
"'");
8426 if (OpInfo.AssignedRegs.Regs.empty()) {
8427 emitInlineAsmError(CS,
"couldn't allocate input reg for constraint '" +
8428 Twine(OpInfo.ConstraintCode) +
"'");
8432 SDLoc dl = getCurSDLoc();
8434 OpInfo.AssignedRegs.getCopyToRegs(InOperandVal, DAG, dl,
8438 dl, DAG, AsmNodeOperands);
8444 if (!OpInfo.AssignedRegs.Regs.empty())
8446 false, 0, getCurSDLoc(), DAG,
8454 if (Flag.
getNode()) AsmNodeOperands.push_back(Flag);
8457 Chain = DAG.
getNode(ISDOpc, getCurSDLoc(),
8469 if (
StructType *StructResult = dyn_cast<StructType>(CSResultType))
8470 ResultTypes = StructResult->elements();
8471 else if (!CSResultType->
isVoidTy())
8474 auto CurResultType = ResultTypes.
begin();
8475 auto handleRegAssign = [&](
SDValue V) {
8476 assert(CurResultType != ResultTypes.
end() &&
"Unexpected value");
8477 assert((*CurResultType)->isSized() &&
"Unexpected unsized type");
8490 if (ResultVT != V.getValueType() &&
8491 ResultVT.getSizeInBits() == V.getValueSizeInBits())
8493 else if (ResultVT != V.getValueType() && ResultVT.isInteger() &&
8494 V.getValueType().isInteger()) {
8500 assert(ResultVT == V.getValueType() &&
"Asm result value mismatch!");
8506 for (SDISelAsmOperandInfo &OpInfo : ConstraintOperands) {
8510 if (OpInfo.AssignedRegs.Regs.empty())
8513 switch (OpInfo.ConstraintType) {
8516 Val = OpInfo.AssignedRegs.getCopyFromRegs(
8517 DAG, FuncInfo, getCurSDLoc(), Chain, &Flag, CS.
getInstruction());
8527 assert(
false &&
"Unexpected unknown constraint");
8531 if (OpInfo.isIndirect) {
8532 const Value *Ptr = OpInfo.CallOperandVal;
8533 assert(Ptr &&
"Expected value CallOperandVal for indirect asm operand");
8544 handleRegAssign(Val);
8550 if (!ResultValues.
empty()) {
8551 assert(CurResultType == ResultTypes.
end() &&
8552 "Mismatch in number of ResultTypes");
8554 "Mismatch in number of output operands in asm result");
8557 DAG.
getVTList(ResultVTs), ResultValues);
8562 if (!OutChains.
empty())
8566 if (ResultValues.
empty() || HasSideEffect || !OutChains.
empty() || IsCallBr)
8571 const Twine &Message) {
8580 if (ValueVTs.
empty())
8584 for (
unsigned i = 0,
e = ValueVTs.
size(); i !=
e; ++i)
8590 void SelectionDAGBuilder::visitVAStart(
const CallInst &I) {
8597 void SelectionDAGBuilder::visitVAArg(
const VAArgInst &I) {
8612 void SelectionDAGBuilder::visitVAEnd(
const CallInst &I) {
8619 void SelectionDAGBuilder::visitVACopy(
const CallInst &I) {
8649 SDLoc SL = getCurSDLoc();
8660 for (
unsigned I = 1; I != NumVals; ++
I)
8674 unsigned ArgIdx,
unsigned NumArgs,
SDValue Callee,
Type *ReturnTy,
8675 bool IsPatchPoint) {
8677 Args.reserve(NumArgs);
8681 for (
unsigned ArgI = ArgIdx, ArgE = ArgIdx + NumArgs;
8682 ArgI != ArgE; ++ArgI) {
8688 Entry.Node = getValue(V);
8690 Entry.setAttributes(Call, ArgI);
8691 Args.push_back(Entry);
8698 .setIsPatchPoint(IsPatchPoint);
8721 for (
unsigned i = StartIdx,
e = CS.
arg_size(); i !=
e; ++i) {
8738 void SelectionDAGBuilder::visitStackmap(
const CallInst &CI) {
8747 SDLoc DL = getCurSDLoc();
8767 cast<ConstantSDNode>(IDVal)->getZExtValue(), DL,
MVT::i64));
8770 cast<ConstantSDNode>(NBytesVal)->getZExtValue(), DL,
8787 InFlag = Chain.getValue(1);
8797 FuncInfo.MF->getFrameInfo().setHasStackMap();
8813 SDLoc dl = getCurSDLoc();
8817 if (
auto* ConstCallee = dyn_cast<ConstantSDNode>(Callee))
8820 else if (
auto* SymbolicCallee = dyn_cast<GlobalAddressSDNode>(Callee))
8822 SDLoc(SymbolicCallee),
8823 SymbolicCallee->getValueType(0));
8827 unsigned NumArgs = cast<ConstantSDNode>(NArgVal)->getZExtValue();
8833 "Not enough arguments provided to the patchpoint intrinsic");
8836 unsigned NumCallArgs = IsAnyRegCC ? 0 : NumArgs;
8841 populateCallLoweringInfo(CLI, cast<CallBase>(CS.
getInstruction()),
8842 NumMetaOpers, NumCallArgs, Callee, ReturnTy,
true);
8843 std::pair<SDValue, SDValue> Result = lowerInvokable(CLI, EHPadBB);
8845 SDNode *CallEnd = Result.second.getNode();
8852 "Expected a callseq node.");
8862 cast<ConstantSDNode>(IDVal)->getZExtValue(), dl,
MVT::i64));
8865 cast<ConstantSDNode>(NBytesVal)->getZExtValue(), dl,
8874 unsigned NumCallRegArgs = Call->getNumOperands() - (HasGlue ? 4 : 3);
8875 NumCallRegArgs = IsAnyRegCC ? NumArgs : NumCallRegArgs;
8884 for (
unsigned i = NumMetaOpers,
e = NumMetaOpers + NumArgs; i !=
e; ++i)
8889 Ops.
append(Call->op_begin() + 2,
e);
8909 if (IsAnyRegCC && HasDef) {
8914 assert(ValueVTs.
size() == 1 &&
"Expected only one return value type.");
8939 if (IsAnyRegCC && HasDef) {
8948 FuncInfo.MF->getFrameInfo().setHasPatchPoint();
8951 void SelectionDAGBuilder::visitVectorReduce(
const CallInst &I,
8952 unsigned Intrinsic) {
8958 SDLoc dl = getCurSDLoc();
8962 if (isa<FPMathOperator>(I))
8965 switch (Intrinsic) {
8966 case Intrinsic::experimental_vector_reduce_v2_fadd:
8973 case Intrinsic::experimental_vector_reduce_v2_fmul:
8980 case Intrinsic::experimental_vector_reduce_add:
8983 case Intrinsic::experimental_vector_reduce_mul:
8986 case Intrinsic::experimental_vector_reduce_and:
8989 case Intrinsic::experimental_vector_reduce_or:
8992 case Intrinsic::experimental_vector_reduce_xor:
8995 case Intrinsic::experimental_vector_reduce_smax:
8998 case Intrinsic::experimental_vector_reduce_smin:
9001 case Intrinsic::experimental_vector_reduce_umax:
9004 case Intrinsic::experimental_vector_reduce_umin:
9007 case Intrinsic::experimental_vector_reduce_fmax:
9010 case Intrinsic::experimental_vector_reduce_fmin:
9038 std::pair<SDValue, SDValue>
9052 RetTys.
swap(OldRetTys);
9053 Offsets.
swap(OldOffsets);
9055 for (
size_t i = 0,
e = OldRetTys.
size(); i !=
e; ++i) {
9056 EVT RetVT = OldRetTys[i];
9057 uint64_t
Offset = OldOffsets[i];
9061 RetTys.
append(NumRegs, RegisterVT);
9062 for (
unsigned j = 0; j != NumRegs; ++j)
9063 Offsets.
push_back(Offset + j * RegisterVTByteSZ);
9070 bool CanLowerReturn =
9075 int DemoteStackIdx = -100;
9076 if (!CanLowerReturn) {
9080 uint64_t TySize = DL.getTypeAllocSize(CLI.
RetTy);
9081 unsigned Align = DL.getPrefTypeAlignment(CLI.
RetTy);
9085 DL.getAllocaAddrSpace());
9087 DemoteStackSlot = CLI.
DAG.
getFrameIndex(DemoteStackIdx, getFrameIndexTy(DL));
9089 Entry.
Node = DemoteStackSlot;
9090 Entry.
Ty = StackSlotPtrType;
9110 bool NeedsRegBlock = functionArgumentNeedsConsecutiveRegisters(
9112 for (
unsigned I = 0,
E = RetTys.
size(); I !=
E; ++
I) {
9114 if (NeedsRegBlock) {
9116 if (I == RetTys.
size() - 1)
9122 unsigned NumRegs = getNumRegistersForCallingConv(CLI.
RetTy->
getContext(),
9124 for (
unsigned i = 0; i != NumRegs; ++i) {
9126 MyFlags.
Flags = Flags;
9127 MyFlags.
VT = RegisterVT;
9133 cast<PointerType>(CLI.
RetTy)->getAddressSpace());
9141 CLI.
Ins.push_back(MyFlags);
9148 if (supportSwiftError()) {
9149 for (
unsigned i = 0,
e = Args.size(); i !=
e; ++i) {
9150 if (Args[i].IsSwiftError) {
9152 MyFlags.
VT = getPointerTy(DL);
9153 MyFlags.
ArgVT =
EVT(getPointerTy(DL));
9155 CLI.
Ins.push_back(MyFlags);
9163 for (
unsigned i = 0,
e = Args.size(); i !=
e; ++i) {
9167 Type *FinalType = Args[i].Ty;
9168 if (Args[i].IsByVal)
9169 FinalType = cast<PointerType>(Args[i].Ty)->getElementType();
9170 bool NeedsRegBlock = functionArgumentNeedsConsecutiveRegisters(
9172 for (
unsigned Value = 0, NumValues = ValueVTs.
size(); Value != NumValues;
9177 Args[i].Node.getResNo() +
Value);
9183 const Align OriginalAlignment(getABIAlignmentForCallingConv(ArgTy, DL));
9185 if (Args[i].Ty->isPointerTy()) {
9187 Flags.setPointerAddrSpace(
9188 cast<PointerType>(Args[i].Ty)->getAddressSpace());
9194 if (Args[i].IsInReg) {
9198 isa<StructType>(FinalType)) {
9201 Flags.setHvaStart();
9209 if (Args[i].IsSwiftSelf)
9210 Flags.setSwiftSelf();
9211 if (Args[i].IsSwiftError)
9212 Flags.setSwiftError();
9213 if (Args[i].IsCFGuardTarget)
9214 Flags.setCFGuardTarget();
9215 if (Args[i].IsByVal)
9217 if (Args[i].IsInAlloca) {
9218 Flags.setInAlloca();
9226 if (Args[i].IsByVal || Args[i].IsInAlloca) {
9230 unsigned FrameSize = DL.getTypeAllocSize(
9231 Args[i].ByValType ? Args[i].ByValType : ElementTy);
9232 Flags.setByValSize(FrameSize);
9235 unsigned FrameAlign;
9236 if (Args[i].Alignment)
9237 FrameAlign = Args[i].Alignment;
9239 FrameAlign = getByValTypeAlignment(ElementTy, DL);
9240 Flags.setByValAlign(
Align(FrameAlign));
9245 Flags.setInConsecutiveRegs();
9246 Flags.setOrigAlign(OriginalAlignment);
9250 unsigned NumParts = getNumRegistersForCallingConv(CLI.
RetTy->
getContext(),
9257 else if (Args[i].IsZExt)
9267 Args[i].Ty->getPointerAddressSpace())) &&
9268 RetTys.
size() == NumValues &&
"unexpected use of 'returned'");
9281 CLI.
RetZExt == Args[i].IsZExt))
9282 Flags.setReturned();
9288 for (
unsigned j = 0; j != NumParts; ++j) {
9294 j*Parts[j].getValueType().getStoreSize().getKnownMinSize());
9295 if (NumParts > 1 && j == 0)
9299 if (j == NumParts - 1)
9300 MyFlags.Flags.setSplitEnd();
9303 CLI.
Outs.push_back(MyFlags);
9304 CLI.
OutVals.push_back(Parts[j]);
9307 if (NeedsRegBlock && Value == NumValues - 1)
9308 CLI.
Outs[CLI.
Outs.size() - 1].Flags.setInConsecutiveRegsLast();
9313 CLI.
Chain = LowerCall(CLI, InVals);
9320 "LowerCall didn't return a valid chain!");
9322 "LowerCall emitted a return value for a tail call!");
9324 "LowerCall didn't emit the correct number of values!");
9336 for (
unsigned i = 0,
e = CLI.
Ins.size(); i !=
e; ++i) {
9337 assert(InVals[i].getNode() &&
"LowerCall emitted a null value!");
9338 assert(
EVT(CLI.
Ins[i].VT) == InVals[i].getValueType() &&
9339 "LowerCall emitted a value with the wrong type!");
9344 if (!CanLowerReturn) {
9351 assert(PVTs.
size() == 1 &&
"Pointers should fit in one register");
9352 EVT PtrVT = PVTs[0];
9354 unsigned NumValues = RetTys.
size();
9355 ReturnValues.resize(NumValues);
9363 for (
unsigned i = 0; i < NumValues; ++i) {
9368 RetTys[i], CLI.
DL, CLI.
Chain, Add,
9370 DemoteStackIdx, Offsets[i]),
9372 ReturnValues[i] = L;
9385 unsigned CurReg = 0;
9386 for (
unsigned I = 0,
E = RetTys.
size(); I !=
E; ++
I) {
9390 unsigned NumRegs = getNumRegistersForCallingConv(CLI.
RetTy->
getContext(),
9394 NumRegs, RegisterVT, VT,
nullptr,
9402 if (ReturnValues.empty())
9408 return std::make_pair(Res, CLI.
Chain);
9427 "Copy from a reg to the same reg!");
9438 ISD::NodeType ExtendType = (FuncInfo.PreferredExtendType.find(V) ==
9439 FuncInfo.PreferredExtendType.end())
9441 : FuncInfo.PreferredExtendType[V];
9442 RFV.getCopyToRegs(Op, DAG, getCurSDLoc(), Chain,
nullptr, V, ExtendType);
9443 PendingExports.push_back(Chain);
9459 if (cast<Instruction>(U)->getParent() != &Entry || isa<SwitchInst>(U))
9467 std::pair<const AllocaInst *, const StoreInst *>>;
9479 enum StaticAllocaInfo {
Unknown, Clobbered, Elidable };
9482 StaticAllocas.
reserve(NumArgs * 2);
9484 auto GetInfoIfStaticAlloca = [&](
const Value *V) -> StaticAllocaInfo * {
9489 if (!AI || !AI->isStaticAlloca() || !FuncInfo->
StaticAllocaMap.count(AI))
9492 return &Iter.first->second;
9508 if (isa<DbgInfoIntrinsic>(I))
9513 if (StaticAllocaInfo *
Info = GetInfoIfStaticAlloca(U))
9514 *
Info = StaticAllocaInfo::Clobbered;
9520 if (StaticAllocaInfo *
Info = GetInfoIfStaticAlloca(
SI->getValueOperand()))
9521 *
Info = StaticAllocaInfo::Clobbered;
9524 const Value *Dst =
SI->getPointerOperand()->stripPointerCasts();
9525 StaticAllocaInfo *
Info = GetInfoIfStaticAlloca(Dst);
9528 const AllocaInst *AI = cast<AllocaInst>(Dst);
9536 const Value *Val =
SI->getValueOperand()->stripPointerCasts();
9538 if (!
Arg ||
Arg->hasInAllocaAttr() ||
Arg->hasByValAttr() ||
9539 Arg->getType()->isEmptyTy() ||
9542 ArgCopyElisionCandidates.
count(
Arg)) {
9543 *Info = StaticAllocaInfo::Clobbered;
9547 LLVM_DEBUG(
dbgs() <<
"Found argument copy elision candidate: " << *AI
9551 *Info = StaticAllocaInfo::Elidable;
9557 if (ArgCopyElisionCandidates.
size() == NumArgs)
9569 SDValue ArgVal,
bool &ArgHasUses) {
9581 auto ArgCopyIter = ArgCopyElisionCandidates.
find(&Arg);
9582 assert(ArgCopyIter != ArgCopyElisionCandidates.
end());
9583 const AllocaInst *AI = ArgCopyIter->second.first;
9584 int FixedIndex = FINode->getIndex();
9586 int OldIndex = AllocaIndex;
9590 dbgs() <<
" argument copy elision failed due to bad fixed stack " 9594 unsigned RequiredAlignment = AI->getAlignment();
9595 if (!RequiredAlignment) {
9597 AI->getAllocatedType());
9600 LLVM_DEBUG(
dbgs() <<
" argument copy elision failed: alignment of alloca " 9601 "greater than stack argument alignment (" 9602 << RequiredAlignment <<
" vs " 9610 dbgs() <<
"Eliding argument copy from " << Arg <<
" to " << *AI <<
'\n' 9611 <<
" Replacing frame index " << OldIndex <<
" with " << FixedIndex
9616 AllocaIndex = FixedIndex;
9617 ArgCopyElisionFrameIndexMap.
insert({OldIndex, FixedIndex});
9622 ElidedArgCopyInstrs.
insert(SI);
9626 for (
const Value *U : Arg.
users()) {
9634 void SelectionDAGISel::LowerArguments(
const Function &
F) {
9636 SDLoc dl = SDB->getCurSDLoc();
9640 if (!FuncInfo->CanLowerReturn) {
9652 MVT RegisterVT = TLI->getRegisterType(*DAG.
getContext(), ValueVTs[0]);
9663 ArgCopyElisionCandidates);
9666 for (
const Argument &
Arg : F.
args()) {
9667 unsigned ArgNo =
Arg.getArgNo();
9670 bool isArgValueUsed = !
Arg.use_empty();
9671 unsigned PartBase = 0;
9672 Type *FinalType =
Arg.getType();
9673 if (
Arg.hasAttribute(Attribute::ByVal))
9674 FinalType =
Arg.getParamByValType();
9675 bool NeedsRegBlock = TLI->functionArgumentNeedsConsecutiveRegisters(
9677 for (
unsigned Value = 0, NumValues = ValueVTs.
size();
9678 Value != NumValues; ++
Value) {
9686 const Align OriginalAlignment(
9687 TLI->getABIAlignmentForCallingConv(ArgTy, DL));
9689 if (
Arg.getType()->isPointerTy()) {
9692 cast<PointerType>(
Arg.getType())->getAddressSpace());
9694 if (
Arg.hasAttribute(Attribute::ZExt))
9696 if (
Arg.hasAttribute(Attribute::SExt))
9698 if (
Arg.hasAttribute(Attribute::InReg)) {
9702 isa<StructType>(
Arg.getType())) {
9711 if (
Arg.hasAttribute(Attribute::StructRet))
9713 if (
Arg.hasAttribute(Attribute::SwiftSelf))
9715 if (
Arg.hasAttribute(Attribute::SwiftError))
9717 if (
Arg.hasAttribute(Attribute::ByVal))
9719 if (
Arg.hasAttribute(Attribute::InAlloca)) {
9734 Type *ElementTy =
Arg.getParamByValType();
9742 unsigned FrameAlign;
9743 if (
Arg.getParamAlignment())
9744 FrameAlign =
Arg.getParamAlignment();
9746 FrameAlign = TLI->getByValTypeAlignment(ElementTy, DL);
9749 if (
Arg.hasAttribute(Attribute::Nest))
9754 if (ArgCopyElisionCandidates.
count(&
Arg))
9756 if (
Arg.hasAttribute(Attribute::Returned))
9759 MVT RegisterVT = TLI->getRegisterTypeForCallingConv(
9761 unsigned NumRegs = TLI->getNumRegistersForCallingConv(
9763 for (
unsigned i = 0; i != NumRegs; ++i) {
9767 ISD::InputArg MyFlags(Flags, RegisterVT, VT, isArgValueUsed,
9769 if (NumRegs > 1 && i == 0)
9774 if (i == NumRegs - 1)
9775 MyFlags.Flags.setSplitEnd();
9779 if (NeedsRegBlock && Value == NumValues - 1)
9780 Ins[Ins.
size() - 1].Flags.setInConsecutiveRegsLast();
9787 SDValue NewRoot = TLI->LowerFormalArguments(
9792 "LowerFormalArguments didn't return a valid chain!");
9794 "LowerFormalArguments didn't emit the correct number of values!");
9796 for (
unsigned i = 0,
e = Ins.
size(); i !=
e; ++i) {
9797 assert(InVals[i].getNode() &&
9798 "LowerFormalArguments emitted a null value!");
9799 assert(
EVT(Ins[i].VT) == InVals[i].getValueType() &&
9800 "LowerFormalArguments emitted a value with the wrong type!");
9805 DAG.setRoot(NewRoot);
9809 if (!FuncInfo->CanLowerReturn) {
9815 DAG.getDataLayout().getAllocaAddrSpace()),
9817 MVT VT = ValueVTs[0].getSimpleVT();
9818 MVT RegVT = TLI->getRegisterType(*CurDAG->getContext(), VT);
9827 FuncInfo->DemoteRegister = SRetReg;
9829 SDB->DAG.getCopyToReg(NewRoot, SDB->getCurSDLoc(), SRetReg, ArgValue);
9830 DAG.setRoot(NewRoot);
9838 for (
const Argument &
Arg : F.
args()) {
9842 unsigned NumValues = ValueVTs.
size();
9846 bool ArgHasUses = !
Arg.use_empty();
9850 if (Ins[i].Flags.isCopyElisionCandidate()) {
9852 ElidedArgCopyInstrs, ArgCopyElisionCandidates,
Arg,
9853 InVals[i], ArgHasUses);
9858 bool isSwiftErrorArg =
9859 TLI->supportSwiftError() &&
9860 Arg.hasAttribute(Attribute::SwiftError);
9861 if (!ArgHasUses && !isSwiftErrorArg) {
9862 SDB->setUnusedArgValue(&
Arg, InVals[i]);
9866 dyn_cast<FrameIndexSDNode>(InVals[i].getNode()))
9867 FuncInfo->setArgumentFrameIndex(&
Arg, FI->getIndex());
9870 for (
unsigned Val = 0; Val != NumValues; ++Val) {
9871 EVT VT = ValueVTs[Val];
9872 MVT PartVT = TLI->getRegisterTypeForCallingConv(*CurDAG->getContext(),
9874 unsigned NumParts = TLI->getNumRegistersForCallingConv(
9880 if (ArgHasUses || isSwiftErrorArg) {
9882 if (
Arg.hasAttribute(Attribute::SExt))
9884 else if (
Arg.hasAttribute(Attribute::ZExt))
9888 PartVT, VT,
nullptr,
9896 if (ArgValues.
empty())
9901 dyn_cast<FrameIndexSDNode>(ArgValues[0].getNode()))
9902 FuncInfo->setArgumentFrameIndex(&
Arg, FI->getIndex());
9905 SDB->getCurSDLoc());
9907 SDB->setValue(&
Arg, Res);
9916 unsigned LowAddressOp = DAG.getDataLayout().isBigEndian() ? 1 : 0;
9920 dyn_cast<FrameIndexSDNode>(LNode->getBasePtr().getNode()))
9921 FuncInfo->setArgumentFrameIndex(&
Arg, FI->getIndex());
9932 SwiftError->setCurrentVReg(FuncInfo->MBB, SwiftError->getFunctionArg(),
9944 FuncInfo->ValueMap[&
Arg] =
Reg;
9949 FuncInfo->InitializeRegForValue(&
Arg);
9950 SDB->CopyToExportRegsIfNeeded(&
Arg);
9954 if (!Chains.
empty()) {
9959 DAG.setRoot(NewRoot);
9961 assert(i == InVals.
size() &&
"Argument register count mismatch!");
9966 if (!DbgDeclareInfo.empty() && !ArgCopyElisionFrameIndexMap.
empty()) {
9968 auto I = ArgCopyElisionFrameIndexMap.
find(
VI.Slot);
9969 if (I != ArgCopyElisionFrameIndexMap.
end())
9970 VI.Slot = I->second;
9975 EmitFunctionEntryCode();
9985 SelectionDAGBuilder::HandlePHINodesInSuccessorBlocks(
const BasicBlock *LLVMBB) {
9994 if (!isa<PHINode>(SuccBB->
begin()))
continue;
9999 if (!SuccsHandled.
insert(SuccMBB).second)
10009 if (PN.use_empty())
10013 if (PN.getType()->isEmptyTy())
10017 const Value *PHIOp = PN.getIncomingValueForBlock(LLVMBB);
10019 if (
const Constant *
C = dyn_cast<Constant>(PHIOp)) {
10020 unsigned &RegOut = ConstantsOut[
C];
10022 RegOut = FuncInfo.CreateRegs(
C);
10023 CopyValueToVirtualRegister(
C, RegOut);
10028 FuncInfo.ValueMap.find(PHIOp);
10029 if (I != FuncInfo.ValueMap.
end())
10032 assert(isa<AllocaInst>(PHIOp) &&
10033 FuncInfo.StaticAllocaMap.count(cast<AllocaInst>(PHIOp)) &&
10034 "Didn't codegen value into a register!??");
10035 Reg = FuncInfo.CreateRegs(PHIOp);
10036 CopyValueToVirtualRegister(PHIOp, Reg);
10045 for (
unsigned vti = 0, vte = ValueVTs.
size(); vti != vte; ++vti) {
10046 EVT VT = ValueVTs[vti];
10048 for (
unsigned i = 0,
e = NumRegisters; i !=
e; ++i)
10049 FuncInfo.PHINodesToUpdate.push_back(
10050 std::make_pair(&*MBBI++,
Reg + i));
10051 Reg += NumRegisters;
10056 ConstantsOut.clear();
10062 SelectionDAGBuilder::StackProtectorDescriptor::
10072 MF->
insert(++BBI, SuccMBB);
10082 if (++I == FuncInfo.MF->end())
10092 void SelectionDAGBuilder::updateDAGForMaybeTailCall(
SDValue MaybeTC) {
10094 if (MaybeTC.
getNode() !=
nullptr)
10095 DAG.setRoot(MaybeTC);
10097 HasTailCall =
true;
10100 void SelectionDAGBuilder::lowerWorkItem(SwitchWorkListItem
W,
Value *Cond,
10106 if (++BBI != FuncInfo.MF->end())
10109 unsigned Size = W.LastCluster - W.FirstCluster + 1;
10113 if (Size == 2 && W.MBB == SwitchMBB) {
10121 CaseCluster &
Small = *W.FirstCluster;
10122 CaseCluster &Big = *W.LastCluster;
10124 if (Small.Low == Small.High && Big.Low == Big.High &&
10125 Small.MBB == Big.MBB) {
10126 const APInt &SmallValue = Small.Low->getValue();
10127 const APInt &BigValue = Big.Low->getValue();
10130 APInt CommonBit = BigValue ^ SmallValue;
10132 SDValue CondLHS = getValue(Cond);
10134 SDLoc DL = getCurSDLoc();
10137 DAG.getConstant(CommonBit, DL, VT));
10139 DL,
MVT::i1, Or, DAG.getConstant(BigValue | SmallValue, DL, VT),
10145 addSuccessorWithProb(SwitchMBB, Small.MBB, Small.Prob + Big.Prob);
10147 addSuccessorWithProb(
10148 SwitchMBB, DefaultMBB,
10152 addSuccessorWithProb(SwitchMBB, DefaultMBB);
10157 DAG.getBasicBlock(Small.MBB));
10160 DAG.getBasicBlock(DefaultMBB));
10162 DAG.setRoot(BrCond);
10173 llvm::sort(W.FirstCluster, W.LastCluster + 1,
10174 [](
const CaseCluster &a,
const CaseCluster &b) {
10175 return a.Prob != b.Prob ?
10177 a.Low->getValue().slt(b.Low->getValue());
10184 if (
I->Prob > W.LastCluster->Prob)
10186 if (
I->Kind ==
CC_Range &&
I->MBB == NextMBB) {
10197 UnhandledProbs +=
I->Prob;
10201 bool FallthroughUnreachable =
false;
10203 if (
I == W.LastCluster) {
10205 Fallthrough = DefaultMBB;
10206 FallthroughUnreachable = isa<UnreachableInst>(
10210 CurMF->
insert(BBI, Fallthrough);
10212 ExportFromCurrentBlock(Cond);
10214 UnhandledProbs -=
I->Prob;
10219 JumpTableHeader *JTH = &SL->JTCases[
I->JTCasesIndex].first;
10224 CurMF->
insert(BBI, JumpMBB);
10226 auto JumpProb =
I->Prob;
10227 auto FallthroughProb = UnhandledProbs;
10235 if (*
SI == DefaultMBB) {
10236 JumpProb += DefaultProb / 2;
10237 FallthroughProb -= DefaultProb / 2;
10244 if (FallthroughUnreachable) {
10246 JTH->OmitRangeCheck =
true;
10249 if (!JTH->OmitRangeCheck)
10250 addSuccessorWithProb(CurMBB, Fallthrough, FallthroughProb);
10251 addSuccessorWithProb(CurMBB, JumpMBB, JumpProb);
10256 JTH->HeaderBB = CurMBB;
10260 if (CurMBB == SwitchMBB) {
10261 visitJumpTableHeader(*JT, *JTH, SwitchMBB);
10262 JTH->Emitted =
true;
10268 BitTestBlock *BTB = &SL->BitTestCases[
I->BTCasesIndex];
10271 for (BitTestCase &BTC : BTB->Cases)
10272 CurMF->
insert(BBI, BTC.ThisBB);
10275 BTB->Parent = CurMBB;
10276 BTB->Default = Fallthrough;
10278 BTB->DefaultProb = UnhandledProbs;
10282 if (!BTB->ContiguousRange) {
10283 BTB->Prob += DefaultProb / 2;
10284 BTB->DefaultProb -= DefaultProb / 2;
10287 if (FallthroughUnreachable) {
10289 BTB->OmitRangeCheck =
true;
10293 if (CurMBB == SwitchMBB) {
10294 visitBitTestHeader(*BTB, SwitchMBB);
10295 BTB->Emitted =
true;
10300 const Value *RHS, *LHS, *MHS;
10302 if (
I->Low ==
I->High) {
10317 if (FallthroughUnreachable)
10321 CaseBlock CB(CC, LHS, RHS, MHS,
I->MBB, Fallthrough, CurMBB,
10322 getCurSDLoc(),
I->Prob, UnhandledProbs);
10324 if (CurMBB == SwitchMBB)
10325 visitSwitchCase(CB, SwitchMBB);
10327 SL->SwitchCases.push_back(CB);
10332 CurMBB = Fallthrough;
10336 unsigned SelectionDAGBuilder::caseClusterRank(
const CaseCluster &CC,
10339 return std::count_if(First, Last + 1, [&](
const CaseCluster &
X) {
10340 if (X.Prob != CC.Prob)
10341 return X.Prob > CC.Prob;
10344 return X.Low->getValue().slt(CC.Low->getValue());
10348 void SelectionDAGBuilder::splitWorkItem(
SwitchWorkList &WorkList,
10349 const SwitchWorkListItem &W,
10352 assert(W.FirstCluster->Low->getValue().slt(W.LastCluster->Low->getValue()) &&
10353 "Clusters not sorted?");
10355 assert(W.LastCluster - W.FirstCluster + 1 >= 2 &&
"Too small to split!");
10362 auto LeftProb = LastLeft->Prob + W.DefaultProb / 2;
10363 auto RightProb = FirstRight->Prob + W.DefaultProb / 2;
10370 while (LastLeft + 1 < FirstRight) {
10371 if (LeftProb < RightProb || (LeftProb == RightProb && (I & 1)))
10372 LeftProb += (++LastLeft)->Prob;
10374 RightProb += (--FirstRight)->Prob;
10384 unsigned NumLeft = LastLeft - W.FirstCluster + 1;
10385 unsigned NumRight = W.LastCluster - FirstRight + 1;
10387 if (std::min(NumLeft, NumRight) < 3 &&
std::max(NumLeft, NumRight) > 3) {
10391 if (NumLeft < NumRight) {
10393 CaseCluster &CC = *FirstRight;
10394 unsigned RightSideRank = caseClusterRank(CC, FirstRight, W.LastCluster);
10395 unsigned LeftSideRank = caseClusterRank(CC, W.FirstCluster, LastLeft);
10396 if (LeftSideRank <= RightSideRank) {
10403 assert(NumRight < NumLeft);
10405 CaseCluster &CC = *LastLeft;
10406 unsigned LeftSideRank = caseClusterRank(CC, W.FirstCluster, LastLeft);
10407 unsigned RightSideRank = caseClusterRank(CC, FirstRight, W.LastCluster);
10408 if (RightSideRank <= LeftSideRank) {
10419 assert(LastLeft + 1 == FirstRight);
10420 assert(LastLeft >= W.FirstCluster);
10421 assert(FirstRight <= W.LastCluster);
10426 assert(PivotCluster > W.FirstCluster);
10427 assert(PivotCluster <= W.LastCluster);
10442 if (FirstLeft == LastLeft && FirstLeft->Kind ==
CC_Range &&
10443 FirstLeft->Low == W.GE &&
10444 (FirstLeft->High->getValue() + 1LL) == Pivot->
getValue()) {
10445 LeftMBB = FirstLeft->MBB;
10447 LeftMBB = FuncInfo.MF->CreateMachineBasicBlock(W.MBB->getBasicBlock());
10448 FuncInfo.MF->
insert(BBI, LeftMBB);
10449 WorkList.push_back(
10450 {LeftMBB, FirstLeft, LastLeft, W.GE, Pivot, W.DefaultProb / 2});
10452 ExportFromCurrentBlock(Cond);
10459 if (FirstRight == LastRight && FirstRight->Kind ==
CC_Range &&
10460 W.LT && (FirstRight->High->getValue() + 1ULL) == W.LT->getValue()) {
10461 RightMBB = FirstRight->MBB;
10463 RightMBB = FuncInfo.MF->CreateMachineBasicBlock(W.MBB->getBasicBlock());
10464 FuncInfo.MF->
insert(BBI, RightMBB);
10465 WorkList.push_back(
10466 {RightMBB, FirstRight, LastRight, Pivot, W.LT, W.DefaultProb / 2});
10468 ExportFromCurrentBlock(Cond);
10472 CaseBlock CB(
ISD::SETLT, Cond, Pivot,
nullptr, LeftMBB, RightMBB, W.MBB,
10473 getCurSDLoc(), LeftProb, RightProb);
10475 if (W.MBB == SwitchMBB)
10476 visitSwitchCase(CB, SwitchMBB);
10478 SL->SwitchCases.push_back(CB);
10511 unsigned PeeledCaseIndex = 0;
10512 bool SwitchPeeled =
false;
10514 CaseCluster &CC = Clusters[
Index];
10515 if (CC.Prob < TopCaseProb)
10517 TopCaseProb = CC.Prob;
10518 PeeledCaseIndex =
Index;
10519 SwitchPeeled =
true;
10524 LLVM_DEBUG(
dbgs() <<
"Peeled one top case in switch stmt, prob: " 10525 << TopCaseProb <<
"\n");
10531 FuncInfo.MF->CreateMachineBasicBlock(SwitchMBB->
getBasicBlock());
10532 FuncInfo.MF->
insert(BBI, PeeledSwitchMBB);
10535 auto PeeledCaseIt = Clusters.begin() + PeeledCaseIndex;
10536 SwitchWorkListItem W = {SwitchMBB, PeeledCaseIt, PeeledCaseIt,
10537 nullptr,
nullptr, TopCaseProb.
getCompl()};
10538 lowerWorkItem(W, SI.
getCondition(), SwitchMBB, PeeledSwitchMBB);
10540 Clusters.erase(PeeledCaseIt);
10541 for (CaseCluster &CC : Clusters) {
10543 dbgs() <<
"Scale the probablity for one cluster, before scaling: " 10544 << CC.Prob <<
"\n");
10548 PeeledCaseProb = TopCaseProb;
10549 return PeeledSwitchMBB;
10552 void SelectionDAGBuilder::visitSwitch(
const SwitchInst &SI) {
10557 for (
auto I : SI.
cases()) {
10563 Clusters.push_back(CaseCluster::range(CaseVal, CaseVal, Succ, Prob));
10576 peelDominantCaseCluster(SI, Clusters, PeeledCaseProb);
10580 if (Clusters.empty()) {
10581 assert(PeeledSwitchMBB == SwitchMBB);
10583 if (DefaultMBB != NextBlock(SwitchMBB)) {
10585 getControlRoot(), DAG.getBasicBlock(DefaultMBB)));
10590 SL->findJumpTables(Clusters, &SI, DefaultMBB, DAG.getPSI(), DAG.getBFI());
10591 SL->findBitTestClusters(Clusters, &SI);
10594 dbgs() <<
"Case clusters: ";
10595 for (
const CaseCluster &
C : Clusters) {
10602 if (
C.Low !=
C.High) {
10611 assert(!Clusters.empty());
10615 auto DefaultProb = getEdgeProbability(PeeledSwitchMBB, DefaultMBB);
10621 WorkList.push_back(
10622 {PeeledSwitchMBB, First, Last,
nullptr,
nullptr, DefaultProb});
10624 while (!WorkList.empty()) {
10625 SwitchWorkListItem W = WorkList.back();
10626 WorkList.pop_back();
10627 unsigned NumClusters = W.LastCluster - W.FirstCluster + 1;
10632 splitWorkItem(WorkList, W, SI.
getCondition(), SwitchMBB);
10636 lowerWorkItem(W, SI.
getCondition(), SwitchMBB, DefaultMBB);
10640 void SelectionDAGBuilder::visitFreeze(
const FreezeInst &
I) {
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
ANNOTATION_LABEL - Represents a mid basic block label used by annotations.
SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
Helper function to build ISD::STORE nodes.
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
ADJUST_TRAMPOLINE - This corresponds to the adjust_trampoline intrinsic.
bool onlyReadsMemory() const
Determine if the function does not access or only reads memory.
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type down to the precision of the ...
Return a value (possibly void), from a function.
Value * getValueOperand()
unsigned getNumCases() const
Return the number of 'cases' in this switch instruction, excluding the default case.
MSVC calling convention that passes vectors and vector aggregates in SSE registers.
static MVT getIntegerVT(unsigned BitWidth)
unsigned Log2_32_Ceil(uint32_t Value)
Return the ceil log base 2 of the specified value, 32 if the value is zero.
A parsed version of the target data layout string in and methods for querying it. ...
static SDValue widenVectorToPartType(SelectionDAG &DAG, SDValue Val, const SDLoc &DL, EVT PartVT)
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
reference emplace_back(ArgTypes &&... Args)
static ConstantInt * getFalse(LLVMContext &Context)
ISD::CondCode getICmpCondCode(ICmpInst::Predicate Pred)
getICmpCondCode - Return the ISD condition code corresponding to the given LLVM IR integer condition ...
FMINNUM/FMAXNUM - Perform floating-point minimum or maximum on two values.
static void findArgumentCopyElisionCandidates(const DataLayout &DL, FunctionLoweringInfo *FuncInfo, ArgCopyElisionMapTy &ArgCopyElisionCandidates)
Scan the entry block of the function in FuncInfo for arguments that look like copies into a local all...
virtual MVT getVectorIdxTy(const DataLayout &DL) const
Returns the type to be used for the index operand of: ISD::INSERT_VECTOR_ELT, ISD::EXTRACT_VECTOR_ELT...
EVT getValueType() const
Return the ValueType of the referenced return value.
class_match< Value > m_Value()
Match an arbitrary value and ignore it.
bool isInteger() const
Return true if this is an integer or a vector integer type.
This class is the base class for the comparison instructions.
virtual std::pair< SDValue, SDValue > EmitTargetCodeForStrnlen(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Src, SDValue MaxLength, MachinePointerInfo SrcPtrInfo) const
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
unsigned getIndexSizeInBits(unsigned AS) const
Size in bits of index used for address calculation in getelementptr.
Value * GetPointerBaseWithConstantOffset(Value *Ptr, int64_t &Offset, const DataLayout &DL, bool AllowNonInbounds=true)
Analyze the specified pointer to see if it can be expressed as a base pointer plus a constant offset...
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.
uint64_t getZExtValue() const
Get zero extended value.
*p = old <signed v ? old : v
bool isOnlyUsedInZeroEqualityComparison(const Instruction *CxtI)
iterator_range< CaseIt > cases()
Iteration adapter for range-for loops.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
This class represents an incoming formal argument to a Function.
BranchProbability getCompl() const
static SDValue getAddressForMemoryInput(SDValue Chain, const SDLoc &Location, SDISelAsmOperandInfo &OpInfo, SelectionDAG &DAG)
Get a direct memory input to behave well as an indirect operand.
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)...
bool ShouldEmitAsBranches(const std::vector< SwitchCG::CaseBlock > &Cases)
If the set of cases should be emitted as a series of branches, return true.
CaseClusterVector::iterator CaseClusterIt
This represents the llvm.dbg.label instruction.
Atomic ordering constants.
static bool fragmentsOverlap(const FragmentInfo &A, const FragmentInfo &B)
Check if fragments overlap between a pair of FragmentInfos.
DELETED_NODE - This is an illegal value that is used to catch errors.
virtual std::pair< SDValue, SDValue > EmitTargetCodeForStrcmp(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Op1, SDValue Op2, MachinePointerInfo Op1PtrInfo, MachinePointerInfo Op2PtrInfo) const
Emit target-specific code that performs a strcmp, in cases where that is faster than a libcall...
EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR (an vector value) starting with the ...
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
void setCopyElisionCandidate()
void ExportFromCurrentBlock(const Value *V)
ExportFromCurrentBlock - If this condition isn't known to be exported from the current basic block...
bool isAtomic() const
Return true if this instruction has an AtomicOrdering of unordered or higher.
static SDValue expandExp2(const SDLoc &dl, SDValue Op, SelectionDAG &DAG, const TargetLowering &TLI)
expandExp2 - Lower an exp2 intrinsic.
Type * getParamType(unsigned i) const
Parameter type accessors.
void setCallsUnwindInit(bool b)
FMINIMUM/FMAXIMUM - NaN-propagating minimum/maximum that also treat -0.0 as less than 0...
iterator begin() const
begin/end - Return all of the registers in this class.
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
A Module instance is used to store all the information related to an LLVM module. ...
bool isSized(SmallPtrSetImpl< Type *> *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
SDValue getPtrExtendInReg(SDValue Op, const SDLoc &DL, EVT VT)
Return the expression required to extend the Op as a pointer value assuming it was the smaller SrcTy ...
BasicBlock * getSuccessor(unsigned Idx) const
Return the specified successor. This instruction must be a terminator.
An instruction for ordering other memory operations.
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
This structure is used to pass arguments to makeLibCall function.
SDValue getAtomicMemcpy(SDValue Chain, const SDLoc &dl, SDValue Dst, unsigned DstAlign, SDValue Src, unsigned SrcAlign, SDValue Size, Type *SizeTy, unsigned ElemSz, bool isTailCall, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo)
void CopyValueToVirtualRegister(const Value *V, unsigned Reg)
An instruction that atomically checks whether a specified value is in a memory location, and, if it is, stores a new value there.
Same as the corresponding unsaturated fixed point instructions, but the result is clamped between the...
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
const Value * getSplatValue(const Value *V)
Get splat value if the input is a splat vector or return nullptr.
bool isVector() const
Return true if this is a vector value type.
unsigned getIROrder() const
Return the node ordering.
static unsigned LimitFloatPrecision
LimitFloatPrecision - Generate low-precision inline sequences for some float libcalls (6...
SDValue getMaskedLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Base, SDValue Offset, SDValue Mask, SDValue Src0, EVT MemVT, MachineMemOperand *MMO, ISD::MemIndexedMode AM, ISD::LoadExtType, bool IsExpanding=false)
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 StructLayout * getStructLayout(StructType *Ty) const
Returns a StructLayout object, indicating the alignment of the struct, its size, and the offsets of i...
bool isABIMangled() const
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
void push_back(const T &Elt)
virtual void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint, std::vector< SDValue > &Ops, SelectionDAG &DAG) const
Lower the specified operand into the Ops vector.
void visitBitTestCase(SwitchCG::BitTestBlock &BB, MachineBasicBlock *NextMBB, BranchProbability BranchProbToNext, unsigned Reg, SwitchCG::BitTestCase &B, MachineBasicBlock *SwitchBB)
visitBitTestCase - this function produces one "bit test"
virtual unsigned getVectorTypeBreakdownForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT, EVT &IntermediateVT, unsigned &NumIntermediates, MVT &RegisterVT) const
Certain targets such as MIPS require that some types such as vectors are always broken down into scal...
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
bool hasOpaqueSPAdjustment() const
Returns true if the function contains opaque dynamic stack adjustments.
MCSymbol * getOrCreateFrameAllocSymbol(StringRef FuncName, unsigned Idx)
Gets a symbol that will be defined to the final stack offset of a local variable after codegen...
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
static unsigned getFlagWord(unsigned Kind, unsigned NumOps)
static void GetRegistersForValue(SelectionDAG &DAG, const SDLoc &DL, SDISelAsmOperandInfo &OpInfo, SDISelAsmOperandInfo &RefOpInfo)
GetRegistersForValue - Assign registers (virtual or physical) for the specified operand.
bool isScalarInteger() const
Return true if this is an integer, but not a vector.
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.
SDValue getTargetExternalSymbol(const char *Sym, EVT VT, unsigned TargetFlags=0)
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
Value * getCondition() const
unsigned getSourceAlignment() const
FIXME: Remove this function once transition to Align is over.
bool isUpperWrapped() const
Return true if the exclusive upper bound wraps around the unsigned domain.
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space...
static uint64_t round(uint64_t Acc, uint64_t Input)
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this store instruction.
gep_type_iterator gep_type_end(const User *GEP)
SDValue getBasicBlock(MachineBasicBlock *MBB)
RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
const std::string & getAsmString() const
*p = old <unsigned v ? old : v
unsigned getVectorNumElements() const
This class represents the atomic memcpy intrinsic i.e.
void copyFMF(const FPMathOperator &FPMO)
Propagate the fast-math-flags from an IR FPMathOperator.
AtomicOrdering getOrdering() const
Returns the ordering constraint of this load instruction.
Function Alias Analysis Results
*p = old >unsigned v ? old : v
SDValue getTokenFactor(const SDLoc &DL, SmallVectorImpl< SDValue > &Vals)
Creates a new TokenFactor containing Vals.
This instruction constructs a fixed permutation of two input vectors.
Minimum number of bits that can be specified.
SPLAT_VECTOR(VAL) - Returns a vector with the scalar value VAL duplicated in all lanes.
Optional< CallingConv::ID > CallConv
Records if this value needs to be treated in an ABI dependant manner, different to normal type legali...
LLVMContext & getContext() const
All values hold a context through their type.
bool isTerminator() const
static LocationSize precise(uint64_t Value)
virtual std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const
Given a physical register constraint (e.g.
void addSuccessorWithoutProb(MachineBasicBlock *Succ)
Add Succ as a successor of this MachineBasicBlock.
auto count_if(R &&Range, UnaryPredicate P) -> typename std::iterator_traits< decltype(adl_begin(Range))>::difference_type
Wrapper function around std::count_if to count the number of times an element satisfying a given pred...
bool isScalableVector() const
Return true if this is a vector type where the runtime length is machine dependent.
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...
C - The default llvm calling convention, compatible with C.
BasicBlock * getSuccessor(unsigned i) const
void setInConsecutiveRegs()
Value * getNewValOperand()
unsigned const TargetRegisterInfo * TRI
virtual AsmOperandInfoVector ParseConstraints(const DataLayout &DL, const TargetRegisterInfo *TRI, ImmutableCallSite CS) const
Split up the constraint string from the inline assembly value into the specific constraints and their...
bool isInteger() const
Return true if this is an integer or a vector integer type.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
static SDValue getCopyFromParts(SelectionDAG &DAG, const SDLoc &DL, const SDValue *Parts, unsigned NumParts, MVT PartVT, EVT ValueVT, const Value *V, Optional< CallingConv::ID > CC=None, Optional< ISD::NodeType > AssertOp=None)
getCopyFromParts - Create a value that contains the specified legal parts combined into the value the...
MachineModuleInfo & getMMI() const
virtual bool lowerAtomicLoadAsLoadSDNode(const LoadInst &LI) const
Should SelectionDAG lower an atomic load of the given kind as a normal LoadSDNode (as opposed to an A...
CallLoweringInfo & setDebugLoc(const SDLoc &dl)
SDValue getSelect(const SDLoc &DL, EVT VT, SDValue Cond, SDValue LHS, SDValue RHS)
Helper function to make it easier to build Select's if you just have operands and don't want to check...
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
An instruction for reading from memory.
Optional< OperandBundleUse > getOperandBundle(StringRef Name) const
[US]{MIN/MAX} - Binary minimum or maximum or signed or unsigned integers.
an instruction that atomically reads a memory location, combines it with another value, and then stores the result back.
SDNode * getNode() const
get the SDNode which holds the desired result
Value * getCondition() const
TypeSize getTypeSizeInBits(Type *Ty) const
Size examples:
BasicBlock * getUnwindDest() const
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
bool isVectorTy() const
True if this is an instance of VectorType.
static BranchProbability getOne()
LLVM_READONLY APFloat maximum(const APFloat &A, const APFloat &B)
Implements IEEE 754-2018 maximum semantics.
This is the common base class for constrained floating point intrinsics.
virtual bool isZExtFree(Type *FromTy, Type *ToTy) const
Return true if any actual instruction that defines a value of type FromTy implicitly zero-extends the...
BasicBlock * getSuccessor() const
SDValue getConstantPool(const Constant *C, EVT VT, unsigned Align=0, int Offs=0, bool isT=false, unsigned TargetFlags=0)
unsigned getTypeIDFor(const GlobalValue *TI)
Return the type id for the specified typeinfo. This is function wide.
const SDValue & setRoot(SDValue N)
Set the current root tag of the SelectionDAG.
bool isOperationLegalOrCustom(unsigned Op, EVT VT) const
Return true if the specified operation is legal on this target or can be made legal with custom lower...
void setAttributes(const CallBase *Call, unsigned ArgIdx)
Set CallLoweringInfo attribute flags based on a call instruction and called function attributes...
LegalizeAction getFixedPointOperationAction(unsigned Op, EVT VT, unsigned Scale) const
Some fixed point operations may be natively supported by the target but only for specific scales...
Value * getLength() const
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 DeleteNode(SDNode *N)
Remove the specified node from the system.
static bool getUniformBase(const Value *&Ptr, SDValue &Base, SDValue &Index, ISD::MemIndexType &IndexType, SDValue &Scale, SelectionDAGBuilder *SDB)
SDValue getValueImpl(const Value *V)
getValueImpl - Helper function for getValue and getNonRegisterValue.
*p = old >signed v ? old : v
unsigned NoTrapAfterNoreturn
Do not emit a trap instruction for 'unreachable' IR instructions behind noreturn calls, even if TrapUnreachable is true.
EntryToken - This is the marker used to indicate the start of a region.
virtual bool getTgtMemIntrinsic(IntrinsicInfo &, const CallInst &, MachineFunction &, unsigned) const
Given an intrinsic, checks if on the target the intrinsic will need to map to a MemIntrinsicNode (tou...
static void getUnderlyingArgRegs(SmallVectorImpl< std::pair< unsigned, unsigned >> &Regs, const SDValue &N)
OUTCHAIN = ATOMIC_FENCE(INCHAIN, ordering, scope) This corresponds to the fence instruction.
void AddDbgValue(SDDbgValue *DB, SDNode *SD, bool isParameter)
Add a dbg_value SDNode.
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
SDValue getMCSymbol(MCSymbol *Sym, EVT VT)
void FindMergedConditions(const Value *Cond, MachineBasicBlock *TBB, MachineBasicBlock *FBB, MachineBasicBlock *CurBB, MachineBasicBlock *SwitchBB, Instruction::BinaryOps Opc, BranchProbability TProb, BranchProbability FProb, bool InvertCond)
void ReplaceAllUsesOfValuesWith(const SDValue *From, const SDValue *To, unsigned Num)
Like ReplaceAllUsesOfValueWith, but for multiple values at once.
void EmitBranchForMergedCondition(const Value *Cond, MachineBasicBlock *TBB, MachineBasicBlock *FBB, MachineBasicBlock *CurBB, MachineBasicBlock *SwitchBB, BranchProbability TProb, BranchProbability FProb, bool InvertCond)
EmitBranchForMergedCondition - Helper method for FindMergedConditions.
FunctionType * getFunctionType() const
BasicBlock * getSuccessor(unsigned i) const
SDValue getExternalSymbol(const char *Sym, EVT VT)
void visitBitTestHeader(SwitchCG::BitTestBlock &B, MachineBasicBlock *SwitchBB)
visitBitTestHeader - This function emits necessary code to produce value suitable for "bit tests" ...
virtual bool lowerAtomicStoreAsStoreSDNode(const StoreInst &SI) const
Should SelectionDAG lower an atomic store of the given kind as a normal StoreSDNode (as opposed to an...
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
virtual std::pair< SDValue, SDValue > EmitTargetCodeForMemchr(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Src, SDValue Char, SDValue Length, MachinePointerInfo SrcPtrInfo) const
Emit target-specific code that performs a memchr, in cases where that is faster than a libcall...
RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) This node represents a target in...
SDValue getAtomicMemset(SDValue Chain, const SDLoc &dl, SDValue Dst, unsigned DstAlign, SDValue Value, SDValue Size, Type *SizeTy, unsigned ElemSz, bool isTailCall, MachinePointerInfo DstPtrInfo)
void setCurrentCallSite(unsigned Site)
Set the call site currently being processed.
CallingConv::ID getCallingConv() const
Get the calling convention of the call.
SDValue getValue(const Value *V)
getValue - Return an SDValue for the given Value.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
AtomicOrdering getFailureOrdering() const
Returns the failure ordering constraint of this cmpxchg instruction.
iterator begin()
Instruction iterator methods.
bool hasSideEffects() const
MVT getRegisterType(MVT VT) const
Return the type of registers that this ValueType will eventually require.
OUTCHAIN = EH_SJLJ_LONGJMP(INCHAIN, buffer) This corresponds to the eh.sjlj.longjmp intrinsic...
Value * getArgOperand(unsigned i) const
unsigned 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 isFloatingPoint() const
Return true if this is a FP or a vector FP type.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
SDValue getIntPtrConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
void setNoSignedWrap(bool b)
void visitSPDescriptorParent(StackProtectorDescriptor &SPD, MachineBasicBlock *ParentBB)
Codegen a new tail for a stack protector check ParentMBB which has had its tail spliced into a stack ...
SDValue getRoot()
Similar to getMemoryRoot, but also flushes PendingConstrainedFP(Strict) items.
The address of a basic block.
void setInConsecutiveRegsLast()
bool match(Val *V, const Pattern &P)
unsigned getAllocaAddrSpace() const
uint64_t alignDown(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the largest uint64_t less than or equal to Value and is Skew mod Align.
Used to lazily calculate structure layout information for a target machine, based on the DataLayout s...
CLEANUPRET - Represents a return from a cleanup block funclet.
bool isVolatile() const
Return true if this is a load from a volatile memory location.
A description of a memory reference used in the backend.
const CallInst * getTerminatingDeoptimizeCall() const
Returns the call instruction calling @llvm.experimental.deoptimize prior to the terminating return in...
unsigned countOperandBundlesOfType(StringRef Name) const
Return the number of operand bundles with the tag Name attached to this instruction.
static unsigned getFlagWordForRegClass(unsigned InputFlag, unsigned RC)
getFlagWordForRegClass - Augment an existing flag word returned by getFlagWord with the required regi...
PCMARKER - This corresponds to the pcmarker intrinsic.
Predicate getInversePredicate() const
For example, EQ -> NE, UGT -> ULE, SLT -> SGE, OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc.
void setVectorReduction(bool b)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
SDValue getBlockAddress(const BlockAddress *BA, EVT VT, int64_t Offset=0, bool isTarget=false, unsigned TargetFlags=0)
const HexagonInstrInfo * TII
unsigned getAlignment() const
Return the alignment of the memory that is being allocated by the instruction.
bool isNonNegative() const
Determine if this APInt Value is non-negative (>= 0)
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
unsigned getNumSuccessors() const
static bool hasOnlySelectUsers(const Value *Cond)
Shift and rotation operations.
Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
virtual MVT getRegisterTypeForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const
Certain combinations of ABIs, Targets and features require that types are legal for some operations a...
Class to represent struct types.
LLVMContext & getContext() const
Get the global data context.
ABS - Determine the unsigned absolute value of a signed integer value of the same bitwidth...
A Use represents the edge between a Value definition and its users.
ValTy * getCalledValue() const
Return the pointer to function that is being called.
void resolveOrClearDbgInfo()
Evict any dangling debug information, attempting to salvage it first.
DILabel * getLabel() const
MachineSDNode * getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT)
These are used for target selectors to create a new node with specified return type(s), MachineInstr opcode, and operands.
PointerType * getPointerTo(unsigned AddrSpace=0) const
Return a pointer to the current type.
BinOp getOperation() const
TargetLowering::ConstraintType ConstraintType
Information about the constraint code, e.g.
SDValue getObjectPtrOffset(const SDLoc &SL, SDValue Ptr, int64_t Offset)
Create an add instruction with appropriate flags when used for addressing some offset of an object...
CallLoweringInfo & setChain(SDValue InChain)
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
RESULT = [US]MULFIX(LHS, RHS, SCALE) - Perform fixed point multiplication on 2 integers with the same...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
SDValue getLifetimeNode(bool IsStart, const SDLoc &dl, SDValue Chain, int FrameIndex, int64_t Size, int64_t Offset=-1)
Creates a LifetimeSDNode that starts (IsStart==true) or ends (IsStart==false) the lifetime of the por...
static unsigned findMatchingInlineAsmOperand(unsigned OperandNo, const std::vector< SDValue > &AsmNodeOperands)
A cluster of cases suitable for jump table lowering.
FLT_ROUNDS_ - Returns current rounding mode: -1 Undefined 0 Round to 0 1 Round to nearest 2 Round to ...
virtual bool useLoadStackGuardNode() const
If this function returns true, SelectionDAGBuilder emits a LOAD_STACK_GUARD node when it is lowering ...
SmallVector< EVT, 4 > ValueVTs
The value types of the values, which may not be legal, and may need be promoted or synthesized from o...
bool IsPostTypeLegalization
This file contains the simple types necessary to represent the attributes associated with functions a...
TypeID
Definitions of all of the base types for the Type system.
NaN behavior not applicable.
LLVM_READONLY APFloat minimum(const APFloat &A, const APFloat &B)
Implements IEEE 754-2018 minimum semantics.
EH_DWARF_CFA - This node represents the pointer to the DWARF Canonical Frame Address (CFA)...
The memory access is dereferenceable (i.e., doesn't trap).
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt) Val, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN, ptr, amt) For double-word atomic operations: ValLo, ValHi, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amtLo, amtHi) ValLo, ValHi, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN, ptr, amtLo, amtHi) These correspond to the atomicrmw instruction.
bool hasBigEndianPartOrdering(EVT VT, const DataLayout &DL) const
When splitting a value of the specified type into parts, does the Lo or Hi part come first...
bool hasMetadata() const
Return true if this instruction has any metadata attached to it.
static bool isRegDefEarlyClobberKind(unsigned Flag)
std::vector< CaseCluster > CaseClusterVector
static unsigned convertMemFlagWordToMatchingFlagWord(unsigned InputFlag)
SDValue getEntryNode() const
Return the token chain corresponding to the entry of the function.
bool isVolatile() const
Return true if this is a cmpxchg from a volatile memory location.
const DataLayout & getDataLayout() const
unsigned getDestAlignment() const
FIXME: Remove this function once transition to Align is over.
void setByValSize(unsigned S)
Type * getType() const
Return the type of the instruction that generated this call site.
SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and llvm.returnaddress on the DAG...
void setFunctionContextIndex(int I)
uint64_t getNumElements() const
For scalable vectors, this will return the minimum number of elements in the vector.
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.
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
unsigned getID() const
Return the register class ID number.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Determine whether the argument or parameter has the given attribute.
This file implements a class to represent arbitrary precision integral constant values and operations...
INLINEASM - Represents an inline asm block.
OutputArg - This struct carries flags and a value for a single outgoing (actual) argument or outgoing...
This represents a list of ValueType's that has been intern'd by a SelectionDAG.
unsigned getLiveInPhysReg(unsigned VReg) const
getLiveInPhysReg - If VReg is a live-in virtual register, return the corresponding live-in physical r...
SmallVector< ISD::InputArg, 32 > Ins
AtomicOrdering
Atomic ordering for LLVM's memory model.
static SDValue getCopyFromPartsVector(SelectionDAG &DAG, const SDLoc &DL, const SDValue *Parts, unsigned NumParts, MVT PartVT, EVT ValueVT, const Value *V, Optional< CallingConv::ID > CC)
getCopyFromPartsVector - Create a value that contains the specified legal parts combined into the val...
STACKSAVE - STACKSAVE has one operand, an input chain.
SDValue getMergeValues(ArrayRef< SDValue > Ops, const SDLoc &dl)
Create a MERGE_VALUES node from the given operands.
void assign(size_type NumElts, const T &Elt)
bool isScopedEHPersonality(EHPersonality Pers)
Returns true if this personality uses scope-style EH IR instructions: catchswitch, catchpad/ret, and cleanuppad/ret.
virtual SDValue prepareVolatileOrAtomicLoad(SDValue Chain, const SDLoc &DL, SelectionDAG &DAG) const
This callback is used to prepare for a volatile or atomic load.
auto reverse(ContainerTy &&C, typename std::enable_if< has_rbegin< ContainerTy >::value >::type *=nullptr) -> decltype(make_range(C.rbegin(), C.rend()))
InstrTy * getInstruction() const
void emitError(unsigned LocCookie, const Twine &ErrorStr)
emitError - Emit an error message to the currently installed error handler with optional location inf...
Value * getPointerOperand()
unsigned getActiveBits() const
Compute the number of active bits in the value.
SDValue getSExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either sign-extending or trunca...
SDValue getCopyFromRegs(SelectionDAG &DAG, FunctionLoweringInfo &FuncInfo, const SDLoc &dl, SDValue &Chain, SDValue *Flag, const Value *V=nullptr) const
Emit a series of CopyFromReg nodes that copies from this value and returns the result as a ValueVTs v...
static BranchProbability scaleCaseProbality(BranchProbability CaseProb, BranchProbability PeeledCaseProb)
This is a fast-path instruction selection class that generates poor code and doesn't support illegal ...
Class to represent function types.
A constant value that is initialized with an expression using other constant values.
STRICT_FSETCC/STRICT_FSETCCS - Constrained versions of SETCC, used for floating-point operands only...
Constrained floating point compare intrinsics.
static SDValue getLoadStackGuard(SelectionDAG &DAG, const SDLoc &DL, SDValue &Chain)
Create a LOAD_STACK_GUARD node, and let it carry the target specific global variable if there exists ...
FastMathFlags getFastMathFlags() const
Convenience function for getting all the fast-math flags, which must be an operator which supports th...
bool hasOperandBundlesOtherThan(ArrayRef< uint32_t > IDs) const
Return true if this operand bundle user contains operand bundles with tags other than those specified...
Type * getType() const
All values are typed, get the type of this value.
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.
CATCHPAD - Represents a catchpad instruction.
void getCopyToRegs(SDValue Val, SelectionDAG &DAG, const SDLoc &dl, SDValue &Chain, SDValue *Flag, const Value *V=nullptr, ISD::NodeType PreferredExtendType=ISD::ANY_EXTEND) const
Emit a series of CopyToReg nodes that copies the specified value into the registers specified by this...
MachineFunction & getMachineFunction() const
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
OUTCHAIN = EH_SJLJ_SETUP_DISPATCH(INCHAIN) The target initializes the dispatch table here...
virtual const TargetRegisterClass * getRegClassFor(MVT VT, bool isDivergent=false) const
Return the register class that should be used for the specified value type.
const LiveOutInfo * GetLiveOutRegInfo(unsigned Reg)
GetLiveOutRegInfo - Gets LiveOutInfo for a register, returning NULL if the register is a PHI destinat...
TypeSize getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
static void normalizeProbabilities(ProbabilityIter Begin, ProbabilityIter End)
ConstantDataSequential - A vector or array constant whose element type is a simple 1/2/4/8-byte integ...
virtual bool supportSwiftError() const
Return true if the target supports swifterror attribute.
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
SDValue getTargetFrameIndex(int FI, EVT VT)
bool isStatepoint(const CallBase *Call)
AtomicOrdering getSuccessOrdering() const
Returns the success ordering constraint of this cmpxchg instruction.
const TargetMachine & getTarget() const
const T & getValue() const LLVM_LVALUE_FUNCTION
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
const MCContext & getContext() const
SDValue peekThroughBitcasts(SDValue V)
Return the non-bitcasted source operand of V if it exists.
This contains information for each constraint that we are lowering.
APInt sextOrTrunc(unsigned width) const
Sign extend or truncate to width.
Simple integer binary arithmetic operators.
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.
SmallVector< ISD::OutputArg, 32 > Outs
void setCallSiteBeginLabel(MCSymbol *BeginLabel, unsigned Site)
Map the begin label for a call site.
static void patchMatchingInput(const SDISelAsmOperandInfo &OpInfo, SDISelAsmOperandInfo &MatchingOpInfo, SelectionDAG &DAG)
Make sure that the output operand OpInfo and its corresponding input operand MatchingOpInfo have comp...
This class represents a no-op cast from one type to another.
unsigned getCurrentCallSite()
Get the call site currently being processed, if any.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
SDValue getSetCC(const SDLoc &DL, EVT VT, SDValue LHS, SDValue RHS, ISD::CondCode Cond, SDValue Chain=SDValue(), bool IsSignaling=false)
Helper function to make it easier to build SetCC's if you just have an ISD::CondCode instead of an SD...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
MemIndexType
MemIndexType enum - This enum defines how to interpret MGATHER/SCATTER's index parameter when calcula...
const APInt & getValue() const
Return the constant as an APInt value reference.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
This corresponds to "fpexcept.maytrap".
static Optional< FragmentInfo > getFragmentInfo(expr_op_iterator Start, expr_op_iterator End)
Retrieve the details of this fragment expression.
SDValue lowerRangeToAssertZExt(SelectionDAG &DAG, const Instruction &I, SDValue Op)
SDValue getMemoryRoot()
Return the current virtual root of the Selection DAG, flushing any PendingLoad items.
static SDValue expandPow(const SDLoc &dl, SDValue LHS, SDValue RHS, SelectionDAG &DAG, const TargetLowering &TLI)
visitPow - Lower a pow intrinsic.
SDValue getUNDEF(EVT VT)
Return an UNDEF node. UNDEF does not have a useful SDLoc.
AttributeList getAttributes() const
Return the attribute list for this Function.
An instruction for storing to memory.
SDDbgValue * getVRegDbgValue(DIVariable *Var, DIExpression *Expr, unsigned VReg, bool IsIndirect, const DebugLoc &DL, unsigned O)
Creates a VReg SDDbgValue node.
bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out...
virtual SDValue LowerAsmOutputForConstraint(SDValue &Chain, SDValue &Flag, SDLoc DL, const AsmOperandInfo &OpInfo, SelectionDAG &DAG) const
void init(GCFunctionInfo *gfi, AliasAnalysis *AA, const TargetLibraryInfo *li)
virtual const TargetInstrInfo * getInstrInfo() const
ISD::CondCode getFCmpCondCode(FCmpInst::Predicate Pred)
getFCmpCondCode - Return the ISD condition code corresponding to the given LLVM IR floating-point con...
READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
SDValue getTargetConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
ConstraintPrefix Type
Type - The basic type of the constraint: input/output/clobber.
virtual unsigned getInlineAsmMemConstraint(StringRef ConstraintCode) const
static bool isRegDefKind(unsigned Flag)
SDValue getSplatBuildVector(EVT VT, const SDLoc &DL, SDValue Op)
Return a splat ISD::BUILD_VECTOR node, consisting of Op splatted to all elements. ...
SDValue getLabelNode(unsigned Opcode, const SDLoc &dl, SDValue Root, MCSymbol *Label)
void setSuccProbability(succ_iterator I, BranchProbability Prob)
Set successor probability of a given iterator.
bool findValue(const Value *V) const
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
void setStackProtectorIndex(int I)
static cl::opt< unsigned > SwitchPeelThreshold("switch-peel-threshold", cl::Hidden, cl::init(66), cl::desc("Set the case probability threshold for peeling the case from a " "switch statement. A value greater than 100 will void this " "optimization"))
bool isTypeLegalForClass(const TargetRegisterClass &RC, MVT T) const
Return true if the given TargetRegisterClass has the ValueType T.
static SDValue getLimitedPrecisionExp2(SDValue t0, const SDLoc &dl, SelectionDAG &DAG)
RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) This node represents a target intrinsic fun...
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
SDValue getTargetConstantFP(double Val, const SDLoc &DL, EVT VT)
APInt getUnsignedMin() const
Return the smallest unsigned value contained in the ConstantRange.
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
void ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL, Type *Ty, SmallVectorImpl< EVT > &ValueVTs, SmallVectorImpl< uint64_t > *Offsets=nullptr, uint64_t StartingOffset=0)
ComputeValueVTs - Given an LLVM IR type, compute a sequence of EVTs that represent all the individual...
void visitJumpTable(SwitchCG::JumpTable &JT)
visitJumpTable - Emit JumpTable node in the current MBB
SDValue getAtomic(unsigned Opcode, const SDLoc &dl, EVT MemVT, SDValue Chain, SDValue Ptr, SDValue Val, MachineMemOperand *MMO)
Gets a node for an atomic op, produces result (if relevant) and chain and takes 2 operands...
unsigned getNumSuccessors() const
Return the number of successors that this instruction has.
Value * getOperand(unsigned i) const
Analysis containing CSE Info
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
unsigned JTI
The JumpTableIndex for this jump table in the function.
Class to represent pointers.
void normalizeSuccProbs()
Normalize probabilities of all successors so that the sum of them becomes one.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
bool isJumpExpensive() const
Return true if Flow Control is an expensive operation that should be avoided.
void salvageUnresolvedDbgValue(DanglingDebugInfo &DDI)
For the given dangling debuginfo record, perform last-ditch efforts to resolve the debuginfo to somet...
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.
MVT getSimpleValueType() const
Return the simple ValueType of the referenced return value.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
iterator find(const_arg_type_t< KeyT > Val)
bool doesNotAccessMemory() const
Determine if the function does not access memory.
OneUse_match< SubPat > m_OneUse(const SubPat &SP)
bool handleDebugValue(const Value *V, DILocalVariable *Var, DIExpression *Expr, DebugLoc CurDL, DebugLoc InstDL, unsigned Order)
For a given Value, attempt to create and record a SDDbgValue in the SelectionDAG. ...
X86_INTR - x86 hardware interrupt context.
static Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Constant * getSplatValue(bool AllowUndefs=false) const
If all elements of the vector constant have the same value, return that value.
bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal=false)
Checks whether the given location points to constant memory, or if OrLocal is true whether it points ...
bool isVoidTy() const
Return true if this is 'void'.
The memory access is volatile.
const BasicBlock & getEntryBlock() const
constexpr uint64_t MinAlign(uint64_t A, uint64_t B)
A and B are either alignments or offsets.
unsigned getNumValues() const
Return the number of values defined/returned by this operator.
an instruction for type-safe pointer arithmetic to access elements of arrays and structs ...
bool hasAttrSomewhere(Attribute::AttrKind Kind, unsigned *Index=nullptr) const
Return true if the specified attribute is set for at least one parameter or for the return value...
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
void getAAMetadata(AAMDNodes &N, bool Merge=false) const
Fills the AAMDNodes structure with AA metadata from this instruction.
void setIsEHScopeEntry(bool V=true)
Indicates if this is the entry block of an EH scope, i.e., the block that that used to have a catchpa...
SDDbgValue * getConstantDbgValue(DIVariable *Var, DIExpression *Expr, const Value *C, const DebugLoc &DL, unsigned O)
Creates a constant SDDbgValue node.
unsigned getObjectAlignment(int ObjectIdx) const
Return the alignment of the specified stack object.
SDValue getMDNode(const MDNode *MD)
Return an MDNodeSDNode which holds an MDNode.
static SDValue expandDivFix(unsigned Opcode, const SDLoc &DL, SDValue LHS, SDValue RHS, SDValue Scale, SelectionDAG &DAG, const TargetLowering &TLI)
initializer< Ty > init(const Ty &Val)
bool bitsGE(EVT VT) const
Return true if this has no less bits than VT.
SDValue getVectorShuffle(EVT VT, const SDLoc &dl, SDValue N1, SDValue N2, ArrayRef< int > Mask)
Return an ISD::VECTOR_SHUFFLE node.
Type * getReturnType() const
Returns the type of the ret val.
std::pair< SDValue, SDValue > lowerInvokable(TargetLowering::CallLoweringInfo &CLI, const BasicBlock *EHPadBB=nullptr)
static MachinePointerInfo getUnknownStack(MachineFunction &MF)
Stack memory without other information.
SmallVector< SDValue, 4 > InVals
std::vector< AsmOperandInfo > AsmOperandInfoVector
OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...) This node represents a target intrin...
These reductions are non-strict, and have a single vector operand.
MVT getSimpleValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
Return the MVT corresponding to this LLVM type. See getValueType.
unsigned getNumIndirectDests() const
Return the number of callbr indirect dest labels.
Optional< fp::ExceptionBehavior > getExceptionBehavior() const
The landingpad instruction holds all of the information necessary to generate correct exception handl...
const Instruction * getFirstNonPHI() const
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
Control flow instructions. These all have token chains.
void GetUnderlyingObjects(const Value *V, SmallVectorImpl< const 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...
MCSymbol * createTempSymbol(bool CanBeUnnamed=true)
Create and return a new assembler temporary symbol with a unique but unspecified name.
READ_REGISTER, WRITE_REGISTER - This node represents llvm.register on the DAG, which implements the n...
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this rmw instruction.
unsigned const MachineRegisterInfo * MRI
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
LOCAL_RECOVER - Represents the llvm.localrecover intrinsic.
ConstantRange getConstantRangeFromMetadata(const MDNode &RangeMD)
Parse out a conservative ConstantRange from !range metadata.
Value * getCalledValue() const
LLVM Basic Block Representation.
void addInvoke(MachineBasicBlock *LandingPad, MCSymbol *BeginLabel, MCSymbol *EndLabel)
Provide the begin and end labels of an invoke style call and associate it with a try landing pad bloc...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
The instances of the Type class are immutable: once they are created, they are never changed...
const SelectionDAGTargetInfo & getSelectionDAGInfo() const
This is an important class for using LLVM in a threaded context.
void RemoveStackObject(int ObjectIdx)
Remove or mark dead a statically sized stack object.
virtual ConstraintType getConstraintType(StringRef Constraint) const
Given a constraint, return the type of constraint it is for this target.
void swap(SmallVectorImpl &RHS)
Simple binary floating point operators.
Conditional or Unconditional Branch instruction.
bool is_splat(R &&Range)
Wrapper function around std::equal to detect if all elements in a container are same.
MakeLibCallOptions & setDiscardResult(bool Value=true)
bool isNoBuiltin() const
Return true if the call should not be treated as a call to a builtin.
static AttributeList getReturnAttrs(TargetLowering::CallLoweringInfo &CLI)
Returns an AttributeList representing the attributes applied to the return value of the given call...
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
size_t size() const
size - Get the array size.
This function has undefined behavior.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
bool hasEHFunclets() const
VAEND, VASTART - VAEND and VASTART have three operands: an input chain, pointer, and a SRCVALUE...
iterator_range< value_op_iterator > op_values() const
Resume the propagation of an exception.
const SDValue & getOperand(unsigned Num) const
Value * getCompareOperand()
MachineBasicBlock * MBB
The MBB into which to emit the code for the indirect jump.
INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element at IDX replaced with VAL...
void sortAndRangeify(CaseClusterVector &Clusters)
Sort Clusters and merge adjacent cases.
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 isPointerTy() const
True if this is an instance of PointerType.
virtual bool allowsMisalignedMemoryAccesses(EVT, unsigned AddrSpace=0, unsigned Align=1, MachineMemOperand::Flags Flags=MachineMemOperand::MONone, bool *=nullptr) const
Determine if the target supports unaligned memory accesses.
const Instruction & front() const
Indirect Branch Instruction.
void setByValAlign(Align A)
TypeSize getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
ValTy * getArgument(unsigned ArgNo) const
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
ConstantFP - Floating Point Values [float, double].
SmallVector< SwitchWorkListItem, 4 > SwitchWorkList
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SDValue getCALLSEQ_START(SDValue Chain, uint64_t InSize, uint64_t OutSize, const SDLoc &DL)
Return a new CALLSEQ_START node, that starts new call frame, in which InSize bytes are set up inside ...
SDValue getAddrSpaceCast(const SDLoc &dl, EVT VT, SDValue Ptr, unsigned SrcAS, unsigned DestAS)
Return an AddrSpaceCastSDNode.
void dropDanglingDebugInfo(const DILocalVariable *Variable, const DIExpression *Expr)
If we have dangling debug info that describes Variable, or an overlapping part of variable considerin...
int getStackProtectorIndex() const
Return the index for the stack protector object.
virtual SDValue emitStackGuardXorFP(SelectionDAG &DAG, SDValue Val, const SDLoc &DL) const
BasicBlock * getDefaultDest() const
DIExpression * getExpression() const
SDValue getMaskedScatter(SDVTList VTs, EVT VT, const SDLoc &dl, ArrayRef< SDValue > Ops, MachineMemOperand *MMO, ISD::MemIndexType IndexType)
virtual SDValue EmitTargetCodeForSetTag(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Addr, SDValue Size, MachinePointerInfo DstPtrInfo, bool ZeroData) const
APInt getUnsignedMax() const
Return the largest unsigned value contained in the ConstantRange.
static unsigned getNumOperandRegisters(unsigned Flag)
getNumOperandRegisters - Extract the number of registers field from the inline asm operand flag...
A udiv or sdiv instruction, which can be marked as "exact", indicating that no bits are destroyed...
bool isValidLocationForIntrinsic(const DILocation *DL) const
Check that a location is valid for this variable.
EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
This file declares a class to represent arbitrary precision floating point values and provide a varie...
static Type * getVoidTy(LLVMContext &C)
INIT_TRAMPOLINE - This corresponds to the init_trampoline intrinsic.
const Instruction & back() const
This instruction compares its operands according to the predicate given to the constructor.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Utility class for integer operators which may exhibit overflow - Add, Sub, Mul, and Shl...
void print(raw_ostream &O, bool IsForDebug=false) const
Implement operator<< on Value.
void ReplaceAllUsesWith(SDValue From, SDValue To)
Modify anything using 'From' to use 'To' instead.
MVT getPointerMemTy(const DataLayout &DL, uint32_t AS=0) const
Return the in-memory pointer type for the given address space, defaults to the pointer type from the ...
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
TRAP - Trapping instruction.
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
const Triple & getTargetTriple() const
Value * getPointerOperand()
AssertSext, AssertZext - These nodes record if a register contains a value that has already been zero...
Base class for variables.
DEBUGTRAP - Trap intended to get the attention of a debugger.
virtual MVT getFenceOperandTy(const DataLayout &DL) const
Return the type for operands of fence.
SDNode * getGluedNode() const
If this node has a glue operand, return the node to which the glue operand points.
void reserve(size_type NumEntries)
Grow the densemap so that it can contain at least NumEntries items before resizing again...
The memory access is non-temporal.
bool isFullSet() const
Return true if this set contains all of the elements possible for this data-type. ...
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
Constant Vector Declarations.
DIExpression * salvageDebugInfoImpl(Instruction &I, DIExpression *DIExpr, bool StackVal)
Given an instruction I and DIExpression DIExpr operating on it, write the effects of I into the retur...
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...
static unsigned getFlagWordForMem(unsigned InputFlag, unsigned Constraint)
Augment an existing flag word returned by getFlagWord with the constraint code for a memory constrain...
Constant * ConstantFoldLoadFromConstPtr(Constant *C, Type *Ty, const DataLayout &DL)
ConstantFoldLoadFromConstPtr - Return the value that a load from C would produce if it is constant an...
auto remove_if(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
Provide wrappers to std::remove_if which take ranges instead of having to pass begin/end explicitly...
SDValue getAtomicCmpSwap(unsigned Opcode, const SDLoc &dl, EVT MemVT, SDVTList VTs, SDValue Chain, SDValue Ptr, SDValue Cmp, SDValue Swp, MachineMemOperand *MMO)
Gets a node for an atomic cmpxchg op.
const MachineInstrBuilder & addFrameIndex(int Idx) const
static double log2(double V)
Bit counting operators with an undefined result for zero inputs.
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
static MachineOperand CreateReg(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false, bool isRenamable=false)
bool supportsUnalignedAtomics() const
Whether the target supports unaligned atomic operations.
Targets can subclass this to parameterize the SelectionDAG lowering and instruction selection process...
virtual EVT getTypeForExtReturn(LLVMContext &Context, EVT VT, ISD::NodeType) const
Return the type that should be used to zero or sign extend a zeroext/signext integer return value...
virtual MVT getPointerTy(const DataLayout &DL, uint32_t AS=0) const
Return the pointer type for the given address space, defaults to the pointer type from the data layou...
succ_iterator succ_begin()
static SDValue ExpandPowI(const SDLoc &DL, SDValue LHS, SDValue RHS, SelectionDAG &DAG)
ExpandPowI - Expand a llvm.powi intrinsic.
static void findWasmUnwindDestinations(FunctionLoweringInfo &FuncInfo, const BasicBlock *EHPadBB, BranchProbability Prob, SmallVectorImpl< std::pair< MachineBasicBlock *, BranchProbability >> &UnwindDests)
std::vector< ArgListEntry > ArgListTy
static bool isMemKind(unsigned Flag)
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.
detail::zippy< detail::zip_first, T, U, Args... > zip_first(T &&t, U &&u, Args &&... args)
zip iterator that, for the sake of efficiency, assumes the first iteratee to be the shortest...
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
static constexpr const Align None()
Returns a default constructed Align which corresponds to no alignment.
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this cmpxchg instruction.
Attribute getAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return the attribute object that exists at the given index.
bool isAlignStack() const
BasicBlock * getSuccessor(unsigned i) const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
uint32_t getElementSizeInBytes() const
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
const Value * getArraySize() const
Get the number of elements allocated.
This structure contains all information that is necessary for lowering calls.
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
AtomicOrdering getOrdering() const
Returns the ordering constraint of this rmw instruction.
This class contains a discriminated union of information about pointers in memory operands...
virtual bool useStackGuardXorFP() const
If this function returns true, stack protection checks should XOR the frame pointer (or whichever poi...
DILocation * getInlinedAt() const
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
LLVM_READONLY APFloat maxnum(const APFloat &A, const APFloat &B)
Implements IEEE maxNum semantics.
EVT getValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
Return the EVT corresponding to this LLVM type.
SDLoc getCurSDLoc() const
static SDValue expandExp(const SDLoc &dl, SDValue Op, SelectionDAG &DAG, const TargetLowering &TLI)
expandExp - Lower an exp intrinsic.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
bool isInTailCallPosition(ImmutableCallSite CS, const TargetMachine &TM)
Test if the given instruction is in a position to be optimized with a tail-call.
SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr)
Loads are not normal binary operators: their result type is not determined by their operands...
Triple - Helper class for working with autoconf configuration names.
CallBr instruction, tracking function calls that may not return control but instead transfer it to a ...
SDValue getTargetBlockAddress(const BlockAddress *BA, EVT VT, int64_t Offset=0, unsigned TargetFlags=0)
BranchProbability getEdgeProbability(const BasicBlock *Src, unsigned IndexInSuccessors) const
Get an edge's probability, relative to other out-edges of the Src.
void sort(IteratorTy Start, IteratorTy End)
TargetIntrinsicInfo - Interface to description of machine instruction set.
The memory access writes data.
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
static bool isVectorReductionOp(const User *I)
Checks if the given instruction performs a vector reduction, in which case we have the freedom to alt...
unsigned getVectorTypeBreakdown(LLVMContext &Context, EVT VT, EVT &IntermediateVT, unsigned &NumIntermediates, MVT &RegisterVT) const
Vector types are broken down into some number of legal first class types.
SDDbgValue * getDbgValue(DIVariable *Var, DIExpression *Expr, SDNode *N, unsigned R, bool IsIndirect, const DebugLoc &DL, unsigned O)
Creates a SDDbgValue node.
virtual void LowerOperationWrapper(SDNode *N, SmallVectorImpl< SDValue > &Results, SelectionDAG &DAG) const
This callback is invoked by the type legalizer to legalize nodes with an illegal operand type but leg...
bool isEmptySet() const
Return true if this set contains no members.
void CopyToExportRegsIfNeeded(const Value *V)
CopyToExportRegsIfNeeded - If the given value has virtual registers created for it, emit nodes to copy the value into the virtual registers.
void GetReturnInfo(CallingConv::ID CC, Type *ReturnType, AttributeList attr, SmallVectorImpl< ISD::OutputArg > &Outs, const TargetLowering &TLI, const DataLayout &DL)
Given an LLVM IR type and return type attributes, compute the return value EVTs and flags...
Given one NaN input, returns the non-NaN.
LegalizeAction
This enum indicates whether operations are valid for a target, and if not, what action should be used...
SDValue getBitcast(EVT VT, SDValue V)
Return a bitcast using the SDLoc of the value operand, and casting to the provided type...
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
Representation for a specific memory location.
virtual MVT hasFastEqualityCompare(unsigned NumBits) const
Return the preferred operand type if the target has a quick way to compare integer values of the give...
RESULT = [US]ADDSAT(LHS, RHS) - Perform saturation addition on 2 integers with the same bit width (W)...
TokenFactor - This node takes multiple tokens as input and produces a single token result...
void visitSPDescriptorFailure(StackProtectorDescriptor &SPD)
Codegen the failure basic block for a stack protector check.
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
void setOrigAlign(Align A)
static const fltSemantics & IEEEsingle() LLVM_READNONE
const TargetLowering & getTargetLoweringInfo() const
Iterator for intrusive lists based on ilist_node.
StructType * getStructTypeOrNull() const
unsigned getNumOperands() const
virtual unsigned getNumRegistersForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const
Certain targets require unusual breakdowns of certain types.
void setNoUnsignedWrap(bool b)
SDValue getTargetGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT, int64_t offset=0, unsigned TargetFlags=0)
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.
SDValue getMemBasePlusOffset(SDValue Base, int64_t Offset, const SDLoc &DL, const SDNodeFlags Flags=SDNodeFlags())
Returns sum of the base pointer and offset.
void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the generic address space (address sp...
This is the shared class of boolean and integer constants.
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
virtual std::pair< SDValue, SDValue > EmitTargetCodeForStrcpy(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Dest, SDValue Src, MachinePointerInfo DestPtrInfo, MachinePointerInfo SrcPtrInfo, bool isStpcpy) const
Emit target-specific code that performs a strcpy or stpcpy, in cases where that is faster than a libc...
static uint32_t getDenominator()
BlockVerifier::State From
SmallVector< unsigned, 4 > RegCount
This list holds the number of registers for each value.
Returns platform specific canonical encoding of a floating point number.
Align max(MaybeAlign Lhs, Align Rhs)
bool isDereferenceablePointer(const Value *V, Type *Ty, const DataLayout &DL, const Instruction *CtxI=nullptr, const DominatorTree *DT=nullptr)
Return true if this is always a dereferenceable pointer.
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
bool isFuncletEHPersonality(EHPersonality Pers)
Returns true if this is a personality function that invokes handler funclets (which must return to it...
EVT getVectorElementType() const
Given a vector type, return the type of each element.
virtual const char * getClearCacheBuiltinName() const
Return the builtin name for the __builtin___clear_cache intrinsic Default is to invoke the clear cach...
Optional< uint64_t > getSizeInBits() const
Determines the size of the variable's type.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
SDDbgValue * getFrameIndexDbgValue(DIVariable *Var, DIExpression *Expr, unsigned FI, bool IsIndirect, const DebugLoc &DL, unsigned O)
Creates a FrameIndex SDDbgValue node.
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...
This struct represents the registers (physical or virtual) that a particular set of values is assigne...
CallLoweringInfo & setCallee(CallingConv::ID CC, Type *ResultType, SDValue Target, ArgListTy &&ArgsList)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Utility class for floating point operations which can have information about relaxed accuracy require...
Module.h This file contains the declarations for the Module class.
SDValue getBuildVector(EVT VT, const SDLoc &DL, ArrayRef< SDValue > Ops)
Return an ISD::BUILD_VECTOR node.
Provides information about what library functions are available for the current target.
BasicBlock * getIndirectDest(unsigned i) const
void clear()
Clear out the current SelectionDAG and the associated state and prepare this SelectionDAGBuilder obje...
bool isConvergent() const
Determine if the call is convergent.
void setNoFPExcept(bool b)
unsigned arg_size() const
SDValue getMemcpy(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, bool isVol, bool AlwaysInline, bool isTailCall, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo)
This class represents a range of values.
static SDValue getF32Constant(SelectionDAG &DAG, unsigned Flt, const SDLoc &dl)
getF32Constant - Get 32-bit floating point constant.
This class represents a freeze function that returns random concrete value if an operand is either a ...
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
BRCOND - Conditional branch.
bool isAggregateType() const
Return true if the type is an aggregate type.
bool isOSLinux() const
Tests whether the OS is Linux.
An SDNode that represents everything that will be needed to construct a MachineInstr.
Promote Memory to Register
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
Byte Swap and Counting operators.
Type * getReturnType() const
void setCallsEHReturn(bool b)
void visit(const Instruction &I)
virtual Function * getSSPStackGuardCheck(const Module &M) const
If the target has a standard stack protection check function that performs validation and error handl...
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)
const WinEHFuncInfo * getWinEHFuncInfo() const
getWinEHFuncInfo - Return information about how the current function uses Windows exception handling...
static bool isOnlyUsedInEntryBlock(const Argument *A, bool FastISel)
isOnlyUsedInEntryBlock - If the specified argument is only used in the entry block, return true.
TypeSize getScalarSizeInBits() const
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
uint64_t scale(uint64_t Num) const
Scale a large integer.
void ExtractVectorElements(SDValue Op, SmallVectorImpl< SDValue > &Args, unsigned Start=0, unsigned Count=0)
Append the extracted elements from Start to Count out of the vector Op in Args.
void addIPToStateRange(const InvokeInst *II, MCSymbol *InvokeBegin, MCSymbol *InvokeEnd)
static Optional< CallingConv::ID > getABIRegCopyCC(const Value *V)
Represents one node in the SelectionDAG.
Value * getRawSource() const
Return the arguments to the instruction.
static SDValue expandLog(const SDLoc &dl, SDValue Op, SelectionDAG &DAG, const TargetLowering &TLI)
expandLog - Lower a log intrinsic.
void UpdateSplitBlock(MachineBasicBlock *First, MachineBasicBlock *Last)
When an MBB was split during scheduling, update the references that need to refer to the last resulti...
AttributeList getAttributes() const
Return the parameter attributes for this call.
unsigned getEVTAlignment(EVT MemoryVT) const
Compute the default alignment value for the given type.
static ConstantInt * getTrue(LLVMContext &Context)
ISD::CondCode getFCmpCodeWithoutNaN(ISD::CondCode CC)
getFCmpCodeWithoutNaN - Given an ISD condition code comparing floats, return the equivalent code if w...
SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, unsigned Reg, SDValue N)
const Function & getFunction() const
Return the LLVM function that this machine code represents.
unsigned logBase2() const
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
SDValue getPtrExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either truncating it or perform...
unsigned getVectorNumElements() const
Class to represent vector types.
SmallVector< std::pair< unsigned, unsigned >, 4 > getRegsAndSizes() const
Return a list of registers and their sizes.
static const unsigned MaxParallelChains
static EVT getVectorVT(LLVMContext &Context, EVT VT, unsigned NumElements, bool IsScalable=false)
Returns the EVT that represents a vector NumElements in length, where each element is of type VT...
Target - Wrapper for Target specific information.
bool isTypeLegal(EVT VT) const
Return true if the target has native support for the specified value type.
Class for arbitrary precision integers.
virtual void ComputeConstraintToUse(AsmOperandInfo &OpInfo, SDValue Op, SelectionDAG *DAG=nullptr) const
Determines the constraint code and constraint type to use for the specific AsmOperandInfo, setting OpInfo.ConstraintCode and OpInfo.ConstraintType.
static StringRef dropLLVMManglingEscape(StringRef Name)
If the given string begins with the GlobalValue name mangling escape character '\1', drop it.
virtual bool isFMAFasterThanFMulAndFAdd(const MachineFunction &MF, EVT) const
Return true if an FMA operation is faster than a pair of fmul and fadd instructions.
SDValue getConstantFP(double Val, const SDLoc &DL, EVT VT, bool isTarget=false)
Create a ConstantFPSDNode wrapping a constant value.
amdgpu Simplify well known AMD library false FunctionCallee Callee
static unsigned getReg(const void *D, unsigned RC, unsigned RegNo)
BranchProbabilityInfo * BPI
Select(COND, TRUEVAL, FALSEVAL).
bool bitsLT(EVT VT) const
Return true if this has less bits than VT.
unsigned getArgNo() const
Return the index of this formal argument in its containing function.
bool isPowerOf2() const
Check if this APInt's value is a power of two greater than zero.
unsigned Reg
The virtual register containing the index of the jump table entry to jump to.
iterator_range< user_iterator > users()
ZERO_EXTEND - Used for integer types, zeroing the new bits.
void AddDbgLabel(SDDbgLabel *DB)
Add a dbg_label SDNode.
ANY_EXTEND - Used for integer types. The high bits are undefined.
virtual std::pair< SDValue, SDValue > EmitTargetCodeForStrlen(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Src, MachinePointerInfo SrcPtrInfo) const
SDValue getGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT, int64_t offset=0, bool isTargetGA=false, unsigned TargetFlags=0)
FCOPYSIGN(X, Y) - Return the value of X with the sign of Y.
ElementCount getVectorElementCount() const
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
void setPointerAddrSpace(unsigned AS)
void setIsEHFuncletEntry(bool V=true)
Indicates if this is the entry block of an EH funclet.
virtual std::pair< SDValue, SDValue > EmitTargetCodeForMemcmp(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Op1, SDValue Op2, SDValue Op3, MachinePointerInfo Op1PtrInfo, MachinePointerInfo Op2PtrInfo) const
Emit target-specific code that performs a memcmp, in cases where that is faster than a libcall...
CATCHRET - Represents a return from a catch block funclet.
static void getCopyToParts(SelectionDAG &DAG, const SDLoc &DL, SDValue Val, SDValue *Parts, unsigned NumParts, MVT PartVT, const Value *V, Optional< CallingConv::ID > CallConv=None, ISD::NodeType ExtendKind=ISD::ANY_EXTEND)
getCopyToParts - Create a series of nodes that contain the specified value split into legal parts...
SmallVector< SDValue, 8 > 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.
SDDbgLabel * getDbgLabel(DILabel *Label, const DebugLoc &DL, unsigned O)
Creates a SDDbgLabel node.
GET_DYNAMIC_AREA_OFFSET - get offset from native SP to the address of the most recent dynamic alloca...
std::pair< SDValue, SDValue > LowerCallTo(CallLoweringInfo &CLI) const
This function lowers an abstract call to a function into an actual call.
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
CallLoweringInfo & setTailCall(bool Value=true)
BR_JT - Jumptable branch.
VACOPY - VACOPY has 5 operands: an input chain, a destination pointer, a source pointer, a SRCVALUE for the destination, and a SRCVALUE for the source.
Predicate getPredicate() const
Return the predicate for this instruction.
unsigned succ_size(const Instruction *I)
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
BasicBlock * getDefaultDest() const
These are IR-level optimization flags that may be propagated to SDNodes.
Represents a use of a SDNode.
CallLoweringInfo & setConvergent(bool Value=true)
SmallVector< SDValue, 32 > OutVals
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this fence instruction.
bool hasGC() const
hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm to use during code generatio...
bool isVolatile() const
Return true if this is a store to a volatile memory location.
Analysis providing branch probability information.
unsigned getNumArgOperands() const
bool isVector() const
Return true if this is a vector value type.
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
Bitwise operators - logical and, logical or, logical xor.
Holds the information from a dbg_label node through SDISel.
static SDValue GetExponent(SelectionDAG &DAG, SDValue Op, const TargetLowering &TLI, const SDLoc &dl)
GetExponent - Get the exponent:
pointer data()
Return a pointer to the vector's buffer, even if empty().
const Function * getParent() const
uint64_t getElementOffset(unsigned Idx) const
SDValue getCopyFromReg(SDValue Chain, const SDLoc &dl, unsigned Reg, EVT VT)
unsigned getAlignment() const
Return the alignment of the access that is being performed.
This corresponds to "fpexcept.ignore".
MachineBasicBlock * Default
The MBB of the default bb, which is a successor of the range check MBB.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
A cluster of adjacent case labels with the same destination, or just one case.
LLVM_NODISCARD bool empty() const
StringRef getValueAsString() const
Return the attribute's value as a string.
AtomicOrdering getOrdering() const
Returns the ordering constraint of this store instruction.
This represents the llvm.dbg.value instruction.
bool isTokenTy() const
Return true if this is 'token'.
This file provides utility analysis objects describing memory locations.
CallingConv::ID getCallingConv() const
uint64_t getKnownMinSize() const
Value * getPointerOperand()
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
virtual EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context, EVT VT) const
Return the ValueType of the result of SETCC operations.
Establish a view to a call site for examination.
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation.
const Function * getParent() const
Return the enclosing method, or null if none.
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this load instruction.
bool onlyReadsMemory(unsigned OpNo) const
const TargetSubtargetInfo & getSubtarget() const
FunctionLoweringInfo - This contains information that is global to a function that is used when lower...
static void addStackMapLiveVars(ImmutableCallSite CS, unsigned StartIdx, const SDLoc &DL, SmallVectorImpl< SDValue > &Ops, SelectionDAGBuilder &Builder)
Add a stack map intrinsic call's live variable operands to a stackmap or patchpoint target node's ope...
static Constant * getZeroValueForNegation(Type *Ty)
Floating point negation must be implemented with f(x) = -0.0 - x.
void visitJumpTableHeader(SwitchCG::JumpTable &JT, SwitchCG::JumpTableHeader &JTH, MachineBasicBlock *SwitchBB)
visitJumpTableHeader - This function emits necessary code to produce index in the JumpTable from swit...
virtual const TargetFrameLowering * getFrameLowering() const
bool hasMinSize() const
Optimize this function for minimum size (-Oz).
The memory access always returns the same value (or traps).
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
unsigned InferPtrAlignment(SDValue Ptr) const
Infer alignment of a load / store address.
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
SDValue getShiftAmountConstant(uint64_t Val, EVT VT, const SDLoc &DL, bool LegalTypes=true)
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
RESULT = [US]SUBSAT(LHS, RHS) - Perform saturation subtraction on 2 integers with the same bit width ...
X = STRICT_FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type down to the precision ...
Value * getCatchSwitchParentPad() const
Get the parentPad of this catchret's catchpad's catchswitch.
iterator_range< const_phi_iterator > phis() const
Returns a range that iterates over the phis in the basic block.
DILocalVariable * getVariable() const
unsigned getOpcode() const
SDValue getValue(unsigned R) const
virtual Value * getSDagStackGuard(const Module &M) const
Return the variable that's previously inserted by insertSSPDeclarations, if any, otherwise return nul...
virtual MachineMemOperand::Flags getMMOFlags(const Instruction &I) const
This callback is used to inspect load/store instructions and add target-specific MachineMemOperand fl...
bool isUnconditional() const
DenseMap< const AllocaInst *, int > StaticAllocaMap
StaticAllocaMap - Keep track of frame indices for fixed sized allocas in the entry block...
unsigned getNumRegisters(LLVMContext &Context, EVT VT) const
Return the number of registers that this ValueType will eventually require.
RESULT, OUTCHAIN = EH_SJLJ_SETJMP(INCHAIN, buffer) This corresponds to the eh.sjlj.setjmp intrinsic.
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
unsigned getAlignment() const
Return the alignment of the access that is being performed FIXME: Remove this function once transitio...
SDValue getAtomicMemmove(SDValue Chain, const SDLoc &dl, SDValue Dst, unsigned DstAlign, SDValue Src, unsigned SrcAlign, SDValue Size, Type *SizeTy, unsigned ElemSz, bool isTailCall, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo)
EVT getMemValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
LLVM_NODISCARD bool empty() const
CopyFromReg - This node indicates that the input value is a virtual or physical register that is defi...
bool isStrictFP() const
Determine if the call requires strict floating point semantics.
const SDValue & getRoot() const
Return the root tag of the SelectionDAG.
SDValue getCopyFromRegs(const Value *V, Type *Ty)
If there was virtual register allocated for the value V emit CopyFromReg of the specified type Ty...
bool isReg() const
isReg - Tests if this is a MO_Register operand.
SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
bool isMinValue() const
Determine if this is the smallest unsigned value.
SDValue getCondCode(ISD::CondCode Cond)
OUTCHAIN = EH_RETURN(INCHAIN, OFFSET, HANDLER) - This node represents 'eh_return' gcc dwarf builtin...
AsmDialect getDialect() const
void setIsImmutableObjectIndex(int ObjectIdx, bool IsImmutable)
Marks the immutability of an object.
SDValue 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)
SDValue getMemIntrinsicNode(unsigned Opcode, const SDLoc &dl, SDVTList VTList, ArrayRef< SDValue > Ops, EVT MemVT, MachinePointerInfo PtrInfo, unsigned Align=0, MachineMemOperand::Flags Flags=MachineMemOperand::MOLoad|MachineMemOperand::MOStore, uint64_t Size=0, const AAMDNodes &AAInfo=AAMDNodes())
Creates a MemIntrinsicNode that may produce a result and takes a list of operands.
CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of vector type with the same length ...
LLVM_NODISCARD const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
SmallVector< MVT, 4 > RegVTs
The value types of the registers.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SDValue getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, EVT SVT, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
const BasicBlock & front() const
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.
Given one NaN input, returns the NaN.
SmallVector< int, 16 > getShuffleMask() const
static unsigned FixedPointIntrinsicToOpcode(unsigned Intrinsic)
INLINEASM_BR - Terminator version of inline asm. Used by asm-goto.
int CreateStackObject(uint64_t Size, Align Alignment, bool isSpillSlot, const AllocaInst *Alloca=nullptr, uint8_t ID=0)
Create a new statically sized stack object, returning a nonnegative identifier to represent it...
TypeSize getScalarSizeInBits() const
static SDValue getMemCmpLoad(const Value *PtrVal, MVT LoadVT, SelectionDAGBuilder &Builder)
bool isSingleValueType() const
Return true if the type is a valid type for a register in codegen.
static void findUnwindDestinations(FunctionLoweringInfo &FuncInfo, const BasicBlock *EHPadBB, BranchProbability Prob, SmallVectorImpl< std::pair< MachineBasicBlock *, BranchProbability >> &UnwindDests)
When an invoke or a cleanupret unwinds to the next EH pad, there are many places it could ultimately ...
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
Constant * getPersonalityFn() const
Get the personality function associated with this function.
FMA - Perform a * b + c with no intermediate rounding step.
Integer reductions may have a result type larger than the vector element type.
SDValue getRegister(unsigned Reg, EVT VT)
unsigned getResNo() const
get the index which selects a specific result in the SDNode
This corresponds to "fpexcept.strict".
SDValue getAnyExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either any-extending or truncat...
FMIN/FMAX nodes can have flags, for NaN/NoNaN variants.
SelectPatternResult matchSelectPattern(Value *V, Value *&LHS, Value *&RHS, Instruction::CastOps *CastOp=nullptr, unsigned Depth=0)
Pattern match integer [SU]MIN, [SU]MAX and ABS idioms, returning the kind and providing the out param...
unsigned countTrailingOnes(T Value, ZeroBehavior ZB=ZB_Width)
Count the number of ones from the least significant bit to the first zero bit.
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
SDValue getJumpTable(int JTI, EVT VT, bool isTarget=false, unsigned TargetFlags=0)
static MachineMemOperand * getMachineMemOperand(MachineFunction &MF, FrameIndexSDNode &FI)
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
void setDebugLoc(DebugLoc dl)
Set source location info.
unsigned getStackPointerRegisterToSaveRestore() const
If a physical register, this specifies the register that llvm.savestack/llvm.restorestack should save...
SDValue getValueType(EVT)
std::pair< SDValue, SDValue > makeLibCall(SelectionDAG &DAG, RTLIB::Libcall LC, EVT RetVT, ArrayRef< SDValue > Ops, MakeLibCallOptions CallOptions, const SDLoc &dl, SDValue Chain=SDValue()) const
Returns a pair of (return value, chain).
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
SDValue getFPExtendOrRound(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of float type, to the float type VT, by either extending or rounding (by tr...
PREFETCH - This corresponds to a prefetch intrinsic.
static const Function * getParent(const Value *V)
void populateCallLoweringInfo(TargetLowering::CallLoweringInfo &CLI, const CallBase *Call, unsigned ArgIdx, unsigned NumArgs, SDValue Callee, Type *ReturnTy, bool IsPatchPoint)
Populate a CallLowerinInfo (into CLI) based on the properties of the call being lowered.
SDValue getMaskedStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Base, SDValue Offset, SDValue Mask, EVT MemVT, MachineMemOperand *MMO, ISD::MemIndexedMode AM, bool IsTruncating=false, bool IsCompressing=false)
void AddInlineAsmOperands(unsigned Code, bool HasMatching, unsigned MatchingIdx, const SDLoc &dl, SelectionDAG &DAG, std::vector< SDValue > &Ops) const
Add this value to the specified inlineasm node operand list.
MVT getFrameIndexTy(const DataLayout &DL) const
Return the type for frame index, which is determined by the alloca address space specified through th...
bool allowReassoc() const
Flag queries.
SDValue getEHLabel(const SDLoc &dl, SDValue Root, MCSymbol *Label)
unsigned countMinLeadingZeros() const
Returns the minimum number of leading zero bits.
Type * getElementType() const
SDValue getSrcValue(const Value *v)
Construct a node to track a Value* through the backend.
DenseMap< const BasicBlock *, MachineBasicBlock * > MBBMap
MBBMap - A mapping from LLVM basic blocks to their machine code entry.
SDValue getControlRoot()
Similar to getRoot, but instead of flushing all the PendingLoad items, flush all the PendingExports (...
bool hasOneUse() const
Return true if there is exactly one user of this value.
Convenience struct for specifying and reasoning about fast-math flags.
StringRef - Represent a constant reference to a string, i.e.
Garbage collection metadata for a single function.
void clearDanglingDebugInfo()
Clear the dangling debug information map.
unsigned TrapUnreachable
Emit target-specific trap instruction for 'unreachable' IR instructions.
static cl::opt< unsigned, true > LimitFPPrecision("limit-float-precision", cl::desc("Generate low-precision inline sequences " "for some float libcalls"), cl::location(LimitFloatPrecision), cl::Hidden, cl::init(0))
const Instruction * getFirstNonPHIOrDbg() const
Returns a pointer to the first instruction in this block that is not a PHINode or a debug intrinsic...
AtomicOrdering getOrdering() const
Returns the ordering constraint of this fence instruction.
static BranchProbability getZero()
bool isEmptyTy() const
Return true if this type is empty, that is, it has no elements or all of its elements are empty...
static SDValue expandLog10(const SDLoc &dl, SDValue Op, SelectionDAG &DAG, const TargetLowering &TLI)
expandLog10 - Lower a log10 intrinsic.
MERGE_VALUES - This node takes multiple discrete operands and returns them all as its individual resu...
static bool isVolatile(Instruction *Inst)
A cluster of cases suitable for bit test lowering.
void addCodeViewAnnotation(MCSymbol *Label, MDNode *MD)
Record annotations associated with a particular label.
const SDValue & getOperand(unsigned i) const
OUTCHAIN = ATOMIC_STORE(INCHAIN, ptr, val) This corresponds to "store atomic" instruction.
SDValue getMaskedGather(SDVTList VTs, EVT VT, const SDLoc &dl, ArrayRef< SDValue > Ops, MachineMemOperand *MMO, ISD::MemIndexType IndexType)
const Value * stripInBoundsConstantOffsets() const
Strip off pointer casts and all-constant inbounds GEPs.
TRUNCATE - Completely drop the high bits.
bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
for(unsigned i=Desc.getNumOperands(), e=OldMI.getNumOperands();i !=e;++i)
void setNodeMemRefs(MachineSDNode *N, ArrayRef< MachineMemOperand *> NewMemRefs)
Mutate the specified machine node's memory references to the provided list.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
unsigned ComputeLinearIndex(Type *Ty, const unsigned *Indices, const unsigned *IndicesEnd, unsigned CurIndex=0)
Compute the linearized index of a member in a nested aggregate/struct/array.
bool isExportableFromCurrentBlock(const Value *V, const BasicBlock *FromBB)
Holds the information from a dbg_value node through SDISel.
RESULT = [US]DIVFIX(LHS, RHS, SCALE) - Perform fixed point division on 2 integers with the same width...
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...
Perform various unary floating-point operations inspired by libm.
static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)
Returns the EVT that represents an integer with the given number of bits.
SmallVector< unsigned, 4 > Regs
This list holds the registers assigned to the values.
Value * getPointerOperand()
virtual bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const
Returns true if a cast between SrcAS and DestAS is a noop.
SDValue getMemset(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, bool isVol, bool isTailCall, MachinePointerInfo DstPtrInfo)
bool shouldOptForSize() const
Val, OUTCHAIN = ATOMIC_LOAD(INCHAIN, ptr) This corresponds to "load atomic" instruction.
Value * getRawDest() const
static MachineOperand CreateFI(int Idx)
uint32_t getNumerator() const
LocationClass< Ty > location(Ty &L)
LLVMContext * getContext() const
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Type * getElementType() const
LLVM_READONLY APFloat minnum(const APFloat &A, const APFloat &B)
Implements IEEE minNum semantics.
CallLoweringInfo & setLibCallee(CallingConv::ID CC, Type *ResultType, SDValue Target, ArgListTy &&ArgsList)
std::vector< MachineBasicBlock * >::iterator succ_iterator
EVT getShiftAmountTy(EVT LHSTy, const DataLayout &DL, bool LegalTypes=true) const
static BranchProbability getBranchProbStackProtector(bool IsLikely)
void visitSwitchCase(SwitchCG::CaseBlock &CB, MachineBasicBlock *SwitchBB)
visitSwitchCase - Emits the necessary code to represent a single node in the binary search tree resul...
bool isVolatile() const
Return true if this is a RMW on a volatile memory location.
void resolveDanglingDebugInfo(const Value *V, SDValue Val)
If we saw an earlier dbg_value referring to V, generate the debug data structures now that we've seen...
static AttributeList get(LLVMContext &C, ArrayRef< std::pair< unsigned, Attribute >> Attrs)
Create an AttributeList with the specified parameters in it.
BinaryOp_match< ValTy, cst_pred_ty< is_all_ones >, Instruction::Xor, true > m_Not(const ValTy &V)
Matches a 'Not' as 'xor V, -1' or 'xor -1, V'.
iterator_range< arg_iterator > args()
Wrapper class representing virtual and physical registers.
bool isStructTy() const
True if this is an instance of StructType.
static unsigned getFlagWordForMatchingOp(unsigned InputFlag, unsigned MatchedOperandNo)
getFlagWordForMatchingOp - Augment an existing flag word returned by getFlagWord with information ind...
bool isArrayTy() const
True if this is an instance of ArrayType.
static Optional< DIExpression * > createFragmentExpression(const DIExpression *Expr, unsigned OffsetInBits, unsigned SizeInBits)
Create a DIExpression to describe one part of an aggregate variable that is fragmented across multipl...
This class contains meta information specific to a module.
This file describes how to lower LLVM code to machine code.
const BasicBlock * getParent() const
an instruction to allocate memory on the stack
vt_iterator legalclasstypes_begin(const TargetRegisterClass &RC) const
Loop over all of the value types that can be represented by values in the given register class...
This instruction inserts a struct field of array element value into an aggregate value.
gep_type_iterator gep_type_begin(const User *GEP)
static bool InBlock(const Value *V, const BasicBlock *BB)
This class is used to represent ISD::LOAD nodes.
DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned to a specified boundary...
static void getCopyToPartsVector(SelectionDAG &DAG, const SDLoc &dl, SDValue Val, SDValue *Parts, unsigned NumParts, MVT PartVT, const Value *V, Optional< CallingConv::ID > CallConv)
getCopyToPartsVector - Create a series of nodes that contain the specified value split into legal par...