59#define DEBUG_TYPE "legalizedag"
65struct FloatSignAsInt {
88class SelectionDAGLegalize {
100 EVT getSetCCResultType(
EVT VT)
const {
111 LegalizedNodes(LegalizedNodes), UpdatedNodes(UpdatedNodes) {}
132 std::pair<SDValue, SDValue> ExpandLibCall(RTLIB::Libcall LC,
SDNode *
Node,
134 bool IsSigned,
EVT RetVT);
135 std::pair<SDValue, SDValue> ExpandLibCall(RTLIB::Libcall LC,
SDNode *
Node,
bool isSigned);
137 void ExpandFPLibCall(
SDNode *
Node, RTLIB::Libcall LC,
141 ExpandFastFPLibCall(
SDNode *
Node,
bool IsFast,
142 std::pair<RTLIB::Libcall, RTLIB::Libcall> Call_F32,
143 std::pair<RTLIB::Libcall, RTLIB::Libcall> Call_F64,
144 std::pair<RTLIB::Libcall, RTLIB::Libcall> Call_F80,
145 std::pair<RTLIB::Libcall, RTLIB::Libcall> Call_F128,
146 std::pair<RTLIB::Libcall, RTLIB::Libcall> Call_PPCF128,
150 RTLIB::Libcall Call_I16, RTLIB::Libcall Call_I32,
151 RTLIB::Libcall Call_I64, RTLIB::Libcall Call_I128);
153 RTLIB::Libcall Call_F32, RTLIB::Libcall Call_F64,
154 RTLIB::Libcall Call_F80, RTLIB::Libcall Call_F128,
155 RTLIB::Libcall Call_PPCF128,
158 RTLIB::Libcall CallI64,
159 RTLIB::Libcall CallI128);
173 void getSignAsIntValue(FloatSignAsInt &State,
const SDLoc &
DL,
175 SDValue modifySignAsInt(
const FloatSignAsInt &State,
const SDLoc &
DL,
224 dbgs() <<
" with: "; New->dump(&DAG));
227 "Replacing one node with another that produces a different number "
231 UpdatedNodes->
insert(New);
237 dbgs() <<
" with: "; New->dump(&DAG));
241 UpdatedNodes->
insert(New.getNode());
242 ReplacedNode(Old.getNode());
249 for (
unsigned i = 0, e = Old->
getNumValues(); i != e; ++i) {
260 dbgs() <<
" with: "; New->dump(&DAG));
264 UpdatedNodes->
insert(New.getNode());
265 ReplacedNode(Old.getNode());
275 bool isObjectScalable) {
283 ObjectSize, MFI.getObjectAlign(FI));
290SDValue SelectionDAGLegalize::ShuffleWithNarrowerEltType(
295 unsigned NumEltsGrowth = NumDestElts / NumMaskElts;
297 assert(NumEltsGrowth &&
"Cannot promote to vector type with fewer elts!");
299 if (NumEltsGrowth == 1)
302 SmallVector<int, 8> NewMask;
303 for (
unsigned i = 0; i != NumMaskElts; ++i) {
305 for (
unsigned j = 0;
j != NumEltsGrowth; ++
j) {
309 NewMask.
push_back(Idx * NumEltsGrowth + j);
312 assert(NewMask.
size() == NumDestElts &&
"Non-integer NumEltsGrowth?");
320SelectionDAGLegalize::ExpandConstantFP(ConstantFPSDNode *CFP,
bool UseCP) {
333 assert((VT == MVT::f64 || VT == MVT::f32) &&
"Invalid type expansion");
335 (VT == MVT::f64) ? MVT::i64 : MVT::i32);
345 while (SVT != MVT::f32 && SVT != MVT::f16 && SVT != MVT::bf16) {
384SDValue SelectionDAGLegalize::ExpandConstant(ConstantSDNode *CP) {
416 SmallVector<int, 8> ShufOps;
417 for (
unsigned i = 0; i != NumElts; ++i)
418 ShufOps.
push_back(i != InsertPos->getZExtValue() ? i : NumElts);
423 return ExpandInsertToVectorThroughStack(
Op);
426SDValue SelectionDAGLegalize::OptimizeFloatStore(StoreSDNode* ST) {
441 AAMDNodes AAInfo =
ST->getAAInfo();
452 bitcastToAPInt().zextOrTrunc(32),
453 SDLoc(CFP), MVT::i32);
454 return DAG.
getStore(Chain, dl, Con, Ptr,
ST->getPointerInfo(),
455 ST->getBaseAlign(), MMOFlags, AAInfo);
463 zextOrTrunc(64), SDLoc(CFP), MVT::i64);
464 return DAG.
getStore(Chain, dl, Con, Ptr,
ST->getPointerInfo(),
465 ST->getBaseAlign(), MMOFlags, AAInfo);
479 ST->getBaseAlign(), MMOFlags, AAInfo);
482 ST->getPointerInfo().getWithOffset(4),
483 ST->getBaseAlign(), MMOFlags, AAInfo);
492void SelectionDAGLegalize::LegalizeStoreOps(SDNode *Node) {
499 AAMDNodes AAInfo =
ST->getAAInfo();
501 if (!
ST->isTruncatingStore()) {
503 if (SDNode *OptStore = OptimizeFloatStore(ST).
getNode()) {
504 ReplaceNode(ST, OptStore);
509 MVT VT =
Value.getSimpleValueType();
512 case TargetLowering::Legal: {
515 EVT MemVT =
ST->getMemoryVT();
518 *
ST->getMemOperand())) {
521 ReplaceNode(
SDValue(ST, 0), Result);
526 case TargetLowering::Custom: {
529 if (Res && Res !=
SDValue(Node, 0))
530 ReplaceNode(
SDValue(Node, 0), Res);
533 case TargetLowering::Promote: {
536 "Can only promote stores to same size type");
539 ST->getBaseAlign(), MMOFlags, AAInfo);
540 ReplaceNode(
SDValue(Node, 0), Result);
549 EVT StVT =
ST->getMemoryVT();
554 if (StWidth != StSize) {
562 ST->getBaseAlign(), MMOFlags, AAInfo);
563 ReplaceNode(
SDValue(Node, 0), Result);
568 unsigned LogStWidth =
Log2_32(StWidthBits);
570 unsigned RoundWidth = 1 << LogStWidth;
571 assert(RoundWidth < StWidthBits);
572 unsigned ExtraWidth = StWidthBits - RoundWidth;
573 assert(ExtraWidth < RoundWidth);
574 assert(!(RoundWidth % 8) && !(ExtraWidth % 8) &&
575 "Store size not an integral number of bytes!");
579 unsigned IncrementSize;
581 if (
DL.isLittleEndian()) {
585 RoundVT,
ST->getBaseAlign(), MMOFlags, AAInfo);
588 IncrementSize = RoundWidth / 8;
595 ST->getPointerInfo().getWithOffset(IncrementSize),
596 ExtraVT,
ST->getBaseAlign(), MMOFlags, AAInfo);
605 ST->getBaseAlign(), MMOFlags, AAInfo);
608 IncrementSize = RoundWidth / 8;
613 ST->getPointerInfo().getWithOffset(IncrementSize),
614 ExtraVT,
ST->getBaseAlign(), MMOFlags, AAInfo);
619 ReplaceNode(
SDValue(Node, 0), Result);
622 ST->getAlign(),
ST->getAddressSpace())) {
625 case TargetLowering::Legal: {
626 EVT MemVT =
ST->getMemoryVT();
630 *
ST->getMemOperand())) {
632 ReplaceNode(
SDValue(ST, 0), Result);
636 case TargetLowering::Custom: {
638 if (Res && Res !=
SDValue(Node, 0))
639 ReplaceNode(
SDValue(Node, 0), Res);
642 case TargetLowering::Expand:
644 "Vector Stores are handled in LegalizeVectorOps");
652 ST->getBaseAlign(), MMOFlags, AAInfo);
660 StVT,
ST->getBaseAlign(), MMOFlags, AAInfo);
663 ReplaceNode(
SDValue(Node, 0), Result);
669void SelectionDAGLegalize::LegalizeLoadOps(SDNode *Node) {
678 LLVM_DEBUG(
dbgs() <<
"Legalizing non-extending load operation\n");
679 MVT VT =
Node->getSimpleValueType(0);
685 case TargetLowering::Legal: {
686 EVT MemVT =
LD->getMemoryVT();
691 *
LD->getMemOperand())) {
696 case TargetLowering::Custom:
703 case TargetLowering::Promote: {
706 "Can only promote loads to same size type");
710 if (
const MDNode *MD =
LD->getRanges()) {
714 LD->getMemOperand()->clearRanges();
722 if (RChain.
getNode() != Node) {
723 assert(RVal.
getNode() != Node &&
"Load must be completely replaced");
727 UpdatedNodes->insert(RVal.
getNode());
728 UpdatedNodes->insert(RChain.
getNode());
736 EVT SrcVT =
LD->getMemoryVT();
739 AAMDNodes AAInfo =
LD->getAAInfo();
751 LD->getAddressSpace(), ExtType,
752 false) == TargetLowering::Promote)) {
766 Chain, Ptr,
LD->getPointerInfo(), NVT,
767 LD->getBaseAlign(), MMOFlags, AAInfo);
779 Result.getValueType(), Result,
788 unsigned LogSrcWidth =
Log2_32(SrcWidthBits);
790 unsigned RoundWidth = 1 << LogSrcWidth;
791 assert(RoundWidth < SrcWidthBits);
792 unsigned ExtraWidth = SrcWidthBits - RoundWidth;
793 assert(ExtraWidth < RoundWidth);
794 assert(!(RoundWidth % 8) && !(ExtraWidth % 8) &&
795 "Load size not an integral number of bytes!");
799 unsigned IncrementSize;
802 if (
DL.isLittleEndian()) {
806 LD->getPointerInfo(), RoundVT,
LD->getBaseAlign(),
810 IncrementSize = RoundWidth / 8;
814 LD->getPointerInfo().getWithOffset(IncrementSize),
815 ExtraVT,
LD->getBaseAlign(), MMOFlags, AAInfo);
834 LD->getPointerInfo(), RoundVT,
LD->getBaseAlign(),
838 IncrementSize = RoundWidth / 8;
842 LD->getPointerInfo().getWithOffset(IncrementSize),
843 ExtraVT,
LD->getBaseAlign(), MMOFlags, AAInfo);
861 bool isCustom =
false;
863 LD->getAlign(),
LD->getAddressSpace(), ExtType,
867 case TargetLowering::Custom:
870 case TargetLowering::Legal:
882 EVT MemVT =
LD->getMemoryVT();
885 *
LD->getMemOperand())) {
891 case TargetLowering::Expand: {
892 EVT DestVT =
Node->getValueType(0);
893 if (!TLI.
isLoadLegal(DestVT, SrcVT,
LD->getAlign(),
LD->getAddressSpace(),
902 LD->getAddressSpace(), ExtType,
false))) {
909 SrcVT,
LD->getMemOperand());
922 if (SVT == MVT::f16 || SVT == MVT::bf16) {
929 Ptr, ISrcVT,
LD->getMemOperand());
933 Chain =
Result.getValue(1);
939 "Vector Loads are handled in LegalizeVectorOps");
946 "EXTLOAD should always be supported!");
950 Node->getValueType(0),
952 LD->getMemOperand());
961 Chain =
Result.getValue(1);
970 assert(
Value.getNode() != Node &&
"Load must be completely replaced");
974 UpdatedNodes->insert(
Value.getNode());
975 UpdatedNodes->insert(Chain.
getNode());
982void SelectionDAGLegalize::LegalizeOp(SDNode *Node) {
991 for (
unsigned i = 0, e =
Node->getNumValues(); i != e; ++i)
993 TargetLowering::TypeLegal &&
994 "Unexpected illegal type!");
998 TargetLowering::TypeLegal ||
1001 "Unexpected illegal type!");
1005 TargetLowering::LegalizeAction Action = TargetLowering::Legal;
1006 bool SimpleFinishLegalizing =
true;
1007 switch (
Node->getOpcode()) {
1017 Node->getValueType(0));
1021 Node->getValueType(0));
1022 if (Action != TargetLowering::Promote)
1028 Node->getOperand(1).getValueType());
1040 Node->getOperand(0).getValueType());
1054 Node->getOperand(1).getValueType());
1063 Node->getOperand(1).getValueType());
1071 unsigned Opc =
Node->getOpcode();
1082 MVT OpVT =
Node->getOperand(CompareOperand).getSimpleValueType();
1086 if (Action == TargetLowering::Legal) {
1089 Node->getValueType(0));
1099 SimpleFinishLegalizing =
false;
1106 SimpleFinishLegalizing =
false;
1120 if (Action == TargetLowering::Legal)
1121 Action = TargetLowering::Expand;
1132 if (Action == TargetLowering::Legal)
1133 Action = TargetLowering::Custom;
1151 Action = TargetLowering::Legal;
1155 if (Action == TargetLowering::Expand) {
1159 Node->getOperand(0));
1160 ReplaceNode(Node, NewVal.
getNode());
1167 if (Action == TargetLowering::Expand) {
1171 Node->getOperand(0));
1172 ReplaceNode(Node, NewVal.
getNode());
1197 unsigned Scale =
Node->getConstantOperandVal(2);
1199 Node->getValueType(0), Scale);
1210 case ISD::VP_SCATTER:
1220 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
1244 Node->getOpcode(),
Node->getOperand(0).getValueType());
1248 case ISD::VP_REDUCE_FADD:
1249 case ISD::VP_REDUCE_FMUL:
1250 case ISD::VP_REDUCE_ADD:
1251 case ISD::VP_REDUCE_MUL:
1252 case ISD::VP_REDUCE_AND:
1253 case ISD::VP_REDUCE_OR:
1254 case ISD::VP_REDUCE_XOR:
1255 case ISD::VP_REDUCE_SMAX:
1256 case ISD::VP_REDUCE_SMIN:
1257 case ISD::VP_REDUCE_UMAX:
1258 case ISD::VP_REDUCE_UMIN:
1259 case ISD::VP_REDUCE_FMAX:
1260 case ISD::VP_REDUCE_FMIN:
1261 case ISD::VP_REDUCE_FMAXIMUM:
1262 case ISD::VP_REDUCE_FMINIMUM:
1263 case ISD::VP_REDUCE_SEQ_FADD:
1264 case ISD::VP_REDUCE_SEQ_FMUL:
1266 Node->getOpcode(),
Node->getOperand(1).getValueType());
1270 case ISD::VP_CTTZ_ELTS:
1271 case ISD::VP_CTTZ_ELTS_ZERO_POISON:
1273 Node->getOperand(0).getValueType());
1278 Node->getOpcode(),
Node->getNumOperands(),
Node->getValueType(0));
1294 if (SimpleFinishLegalizing) {
1295 SDNode *NewNode =
Node;
1296 switch (
Node->getOpcode()) {
1343 if (NewNode != Node) {
1344 ReplaceNode(Node, NewNode);
1348 case TargetLowering::Legal:
1351 case TargetLowering::Custom:
1359 if (
Node->getNumValues() == 1) {
1363 Node->getValueType(0) == MVT::Glue) &&
1364 "Type mismatch for custom legalized operation");
1367 ReplaceNode(
SDValue(Node, 0), Res);
1372 for (
unsigned i = 0, e =
Node->getNumValues(); i != e; ++i) {
1376 Node->getValueType(i) == MVT::Glue) &&
1377 "Type mismatch for custom legalized operation");
1381 ReplaceNode(Node, ResultVals.
data());
1386 case TargetLowering::Expand:
1387 if (ExpandNode(Node))
1390 case TargetLowering::LibCall:
1391 ConvertNodeToLibcall(Node);
1393 case TargetLowering::Promote:
1399 switch (
Node->getOpcode()) {
1412 return LegalizeLoadOps(Node);
1414 return LegalizeStoreOps(Node);
1418SDValue SelectionDAGLegalize::ExpandExtractFromVectorThroughStack(
SDValue Op) {
1431 SmallPtrSet<const SDNode *, 32> Visited;
1438 if (
ST->isIndexed() ||
ST->isTruncatingStore() ||
1439 ST->getValue() != Vec)
1444 if (!
ST->getChain().reachesChainWithoutSideEffects(DAG.
getEntryNode()))
1453 ST->hasPredecessor(
Op.getNode()))
1473 Align ElementAlignment =
1478 if (
Op.getValueType().isVector()) {
1480 Op.getValueType(), Idx);
1481 NewLoad = DAG.
getLoad(
Op.getValueType(), dl, Ch, StackPtr,
1482 MachinePointerInfo(), ElementAlignment);
1496 NewLoadOperands[0] = Ch;
1502SDValue SelectionDAGLegalize::ExpandInsertToVectorThroughStack(
SDValue Op) {
1503 assert(
Op.getValueType().isVector() &&
"Non-vector insert subvector!");
1515 MachinePointerInfo PtrInfo =
1519 Align BaseVecAlignment =
1537 Ch, dl, Part, SubStackPtr,
1546 Ch, dl, Part, SubStackPtr,
1552 "ElementAlignment does not match!");
1555 return DAG.
getLoad(
Op.getValueType(), dl, Ch, StackPtr, PtrInfo,
1559SDValue SelectionDAGLegalize::ExpandConcatVectors(SDNode *Node) {
1563 unsigned NumOperands =
Node->getNumOperands();
1565 EVT VectorValueType =
Node->getOperand(0).getValueType();
1569 for (
unsigned I = 0;
I < NumOperands; ++
I) {
1571 for (
unsigned Idx = 0; Idx < NumSubElem; ++Idx) {
1580SDValue SelectionDAGLegalize::ExpandVectorBuildThroughStack(SDNode* Node) {
1583 "Unexpected opcode!");
1589 EVT VT =
Node->getValueType(0);
1591 :
Node->getOperand(0).getValueType();
1595 MachinePointerInfo PtrInfo =
1601 assert(TypeByteSize > 0 &&
"Vector element type too small for stack store!");
1606 MemVT.
bitsLT(
Node->getOperand(0).getValueType());
1609 for (
unsigned i = 0, e =
Node->getNumOperands(); i != e; ++i) {
1611 if (
Node->getOperand(i).isUndef())
continue;
1613 unsigned Offset = TypeByteSize*i;
1620 Node->getOperand(i), Idx,
1628 if (!Stores.
empty())
1634 return DAG.
getLoad(VT, dl, StoreChain, FIPtr, PtrInfo);
1640void SelectionDAGLegalize::getSignAsIntValue(FloatSignAsInt &State,
1643 EVT FloatVT =
Value.getValueType();
1645 State.FloatVT = FloatVT;
1651 State.SignBit = NumBits - 1;
1666 State.FloatPointerInfo);
1669 if (DataLayout.isBigEndian()) {
1673 State.IntPointerInfo = State.FloatPointerInfo;
1676 unsigned ByteOffset = (NumBits / 8) - 1;
1683 State.IntPtr = IntPtr;
1685 State.IntPointerInfo, MVT::i8);
1692SDValue SelectionDAGLegalize::modifySignAsInt(
const FloatSignAsInt &State,
1700 State.IntPointerInfo, MVT::i8);
1701 return DAG.
getLoad(State.FloatVT,
DL, Chain, State.FloatPtr,
1702 State.FloatPointerInfo);
1705SDValue SelectionDAGLegalize::ExpandFCOPYSIGN(SDNode *Node)
const {
1714 FloatSignAsInt SignAsInt;
1715 getSignAsIntValue(SignAsInt,
DL, Sign);
1735 FloatSignAsInt MagAsInt;
1736 getSignAsIntValue(MagAsInt,
DL, Mag);
1743 int ShiftAmount = SignAsInt.SignBit - MagAsInt.SignBit;
1744 EVT ShiftVT = IntVT;
1750 if (ShiftAmount > 0) {
1753 }
else if (ShiftAmount < 0) {
1766 return modifySignAsInt(MagAsInt,
DL, CopiedSign);
1769SDValue SelectionDAGLegalize::ExpandFNEG(SDNode *Node)
const {
1772 if (
Node->getValueType(0).isVector())
1775 FloatSignAsInt SignAsInt;
1776 getSignAsIntValue(SignAsInt,
DL,
Node->getOperand(0));
1785 return modifySignAsInt(SignAsInt,
DL, SignFlip);
1788SDValue SelectionDAGLegalize::ExpandFABS(SDNode *Node)
const {
1793 EVT FloatVT =
Value.getValueType();
1803 FloatSignAsInt ValueAsInt;
1804 getSignAsIntValue(ValueAsInt,
DL,
Value);
1809 return modifySignAsInt(ValueAsInt,
DL, ClearedSign);
1812void SelectionDAGLegalize::ExpandDYNAMIC_STACKALLOC(SDNode* Node,
1813 SmallVectorImpl<SDValue> &
Results) {
1815 assert(
SPReg &&
"Target cannot require DYNAMIC_STACKALLOC expansion and"
1816 " not tell us which reg is the stack pointer!");
1818 EVT VT =
Node->getValueType(0);
1830 Chain =
SP.getValue(1);
1839 if (Alignment > StackAlign)
1854SDValue SelectionDAGLegalize::EmitStackConvert(
SDValue SrcOp, EVT SlotVT,
1855 EVT DestVT,
const SDLoc &dl) {
1856 return EmitStackConvert(SrcOp, SlotVT, DestVT, dl, DAG.
getEntryNode());
1859SDValue SelectionDAGLegalize::EmitStackConvert(
SDValue SrcOp, EVT SlotVT,
1860 EVT DestVT,
const SDLoc &dl,
1870 (SlotVT.
bitsLT(DestVT) &&
1883 MachinePointerInfo PtrInfo =
1890 if (SrcVT.
bitsGT(SlotVT))
1895 Store = DAG.
getStore(Chain, dl, SrcOp, FIPtr, PtrInfo, SrcAlign);
1899 if (SlotVT.
bitsEq(DestVT))
1900 return DAG.
getLoad(DestVT, dl,
Store, FIPtr, PtrInfo, DestAlign);
1907SDValue SelectionDAGLegalize::ExpandSCALAR_TO_VECTOR(SDNode *Node) {
1919 Node->getValueType(0).getVectorElementType());
1921 Node->getValueType(0), dl, Ch, StackPtr,
1928 unsigned NumElems =
Node->getNumOperands();
1930 EVT VT =
Node->getValueType(0);
1942 for (
unsigned i = 0; i < NumElems; ++i) {
1953 while (IntermedVals.
size() > 2) {
1954 NewIntermedVals.
clear();
1955 for (
unsigned i = 0, e = (IntermedVals.
size() & ~1u); i < e; i += 2) {
1961 FinalIndices.
reserve(IntermedVals[i].second.
size() +
1962 IntermedVals[i+1].second.
size());
1965 for (
unsigned j = 0, f = IntermedVals[i].second.
size(); j != f;
1968 FinalIndices.
push_back(IntermedVals[i].second[j]);
1970 for (
unsigned j = 0, f = IntermedVals[i+1].second.
size(); j != f;
1972 ShuffleVec[k] = NumElems + j;
1973 FinalIndices.
push_back(IntermedVals[i+1].second[j]);
1979 IntermedVals[i+1].first,
1984 std::make_pair(Shuffle, std::move(FinalIndices)));
1989 if ((IntermedVals.
size() & 1) != 0)
1992 IntermedVals.
swap(NewIntermedVals);
1996 "Invalid number of intermediate vectors");
1997 SDValue Vec1 = IntermedVals[0].first;
1999 if (IntermedVals.
size() > 1)
2000 Vec2 = IntermedVals[1].first;
2005 for (
unsigned i = 0, e = IntermedVals[0].second.
size(); i != e; ++i)
2006 ShuffleVec[IntermedVals[0].second[i]] = i;
2007 for (
unsigned i = 0, e = IntermedVals[1].second.
size(); i != e; ++i)
2008 ShuffleVec[IntermedVals[1].second[i]] = NumElems + i;
2021SDValue SelectionDAGLegalize::ExpandBUILD_VECTOR(SDNode *Node) {
2022 unsigned NumElems =
Node->getNumOperands();
2025 EVT VT =
Node->getValueType(0);
2026 EVT OpVT =
Node->getOperand(0).getValueType();
2031 bool isOnlyLowElement =
true;
2032 bool MoreThanTwoValues =
false;
2034 for (
unsigned i = 0; i < NumElems; ++i) {
2039 isOnlyLowElement =
false;
2045 }
else if (!Value2.
getNode()) {
2048 }
else if (V != Value1 && V != Value2) {
2049 MoreThanTwoValues =
true;
2056 if (isOnlyLowElement)
2062 for (
unsigned i = 0, e = NumElems; i !=
e; ++i) {
2063 if (ConstantFPSDNode *V =
2066 }
else if (ConstantSDNode *V =
2069 CV.
push_back(
const_cast<ConstantInt *
>(
V->getConstantIntValue()));
2074 const ConstantInt *CI =
V->getConstantIntValue();
2095 SmallSet<SDValue, 16> DefinedValues;
2096 for (
unsigned i = 0; i < NumElems; ++i) {
2097 if (
Node->getOperand(i).isUndef())
2103 if (!MoreThanTwoValues) {
2104 SmallVector<int, 8> ShuffleVec(NumElems, -1);
2105 for (
unsigned i = 0; i < NumElems; ++i) {
2109 ShuffleVec[i] =
V == Value1 ? 0 : NumElems;
2131 return ExpandVectorBuildThroughStack(Node);
2134SDValue SelectionDAGLegalize::ExpandSPLAT_VECTOR(SDNode *Node) {
2136 EVT VT =
Node->getValueType(0);
2147std::pair<SDValue, SDValue>
2148SelectionDAGLegalize::ExpandLibCall(RTLIB::Libcall LC, SDNode *Node,
2149 TargetLowering::ArgListTy &&Args,
2150 bool IsSigned, EVT RetVT) {
2154 if (LCImpl != RTLIB::Unsupported)
2159 Node->getOperationName(&DAG));
2176 (RetTy ==
F.getReturnType() ||
F.getReturnType()->
isVoidTy()) &&
2183 TargetLowering::CallLoweringInfo CLI(DAG);
2185 CLI.setDebugLoc(SDLoc(Node))
2188 Callee, std::move(Args))
2189 .setTailCall(isTailCall)
2190 .setSExtResult(signExtend)
2191 .setZExtResult(!signExtend)
2192 .setIsPostTypeLegalization(
true);
2194 std::pair<SDValue, SDValue> CallInfo = TLI.
LowerCallTo(CLI);
2196 if (!CallInfo.second.getNode()) {
2202 LLVM_DEBUG(
dbgs() <<
"Created libcall: "; CallInfo.first.dump(&DAG));
2206std::pair<SDValue, SDValue> SelectionDAGLegalize::ExpandLibCall(RTLIB::Libcall LC, SDNode *Node,
2208 TargetLowering::ArgListTy
Args;
2210 EVT ArgVT =
Op.getValueType();
2212 TargetLowering::ArgListEntry
Entry(
Op, ArgTy);
2215 Args.push_back(Entry);
2218 return ExpandLibCall(LC, Node, std::move(Args),
isSigned,
2219 Node->getValueType(0));
2222void SelectionDAGLegalize::ExpandFPLibCall(SDNode* Node,
2224 SmallVectorImpl<SDValue> &
Results) {
2225 if (LC == RTLIB::UNKNOWN_LIBCALL)
2228 if (
Node->isStrictFPOpcode()) {
2229 EVT RetVT =
Node->getValueType(0);
2231 if (LCImpl == RTLIB::Unsupported) {
2233 Node->getOperationName(&DAG));
2239 TargetLowering::MakeLibCallOptions CallOptions;
2242 std::pair<SDValue, SDValue> Tmp = TLI.
makeLibCall(
2243 DAG, LCImpl, RetVT,
Ops, CallOptions, SDLoc(Node),
Node->getOperand(0));
2245 Results.push_back(Tmp.second);
2248 SDValue Tmp = ExpandLibCall(LC, Node, IsSignedArgument).first;
2254void SelectionDAGLegalize::ExpandFastFPLibCall(
2255 SDNode *Node,
bool IsFast,
2256 std::pair<RTLIB::Libcall, RTLIB::Libcall> Call_F32,
2257 std::pair<RTLIB::Libcall, RTLIB::Libcall> Call_F64,
2258 std::pair<RTLIB::Libcall, RTLIB::Libcall> Call_F80,
2259 std::pair<RTLIB::Libcall, RTLIB::Libcall> Call_F128,
2260 std::pair<RTLIB::Libcall, RTLIB::Libcall> Call_PPCF128,
2261 SmallVectorImpl<SDValue> &
Results) {
2263 EVT VT =
Node->getSimpleValueType(0);
2272 Call_F128.first, Call_PPCF128.first);
2278 Call_F80.second, Call_F128.second,
2279 Call_PPCF128.second);
2282 ExpandFPLibCall(Node, LC,
Results);
2285SDValue SelectionDAGLegalize::ExpandIntLibCall(SDNode* Node,
bool isSigned,
2286 RTLIB::Libcall Call_I8,
2287 RTLIB::Libcall Call_I16,
2288 RTLIB::Libcall Call_I32,
2289 RTLIB::Libcall Call_I64,
2290 RTLIB::Libcall Call_I128) {
2292 switch (
Node->getSimpleValueType(0).SimpleTy) {
2294 case MVT::i8: LC = Call_I8;
break;
2295 case MVT::i16: LC = Call_I16;
break;
2296 case MVT::i32: LC = Call_I32;
break;
2297 case MVT::i64: LC = Call_I64;
break;
2298 case MVT::i128: LC = Call_I128;
break;
2300 return ExpandLibCall(LC, Node,
isSigned).first;
2305void SelectionDAGLegalize::ExpandArgFPLibCall(SDNode* Node,
2306 RTLIB::Libcall Call_F32,
2307 RTLIB::Libcall Call_F64,
2308 RTLIB::Libcall Call_F80,
2309 RTLIB::Libcall Call_F128,
2310 RTLIB::Libcall Call_PPCF128,
2311 SmallVectorImpl<SDValue> &
Results) {
2312 EVT InVT =
Node->getOperand(
Node->isStrictFPOpcode() ? 1 : 0).getValueType();
2314 Call_F32, Call_F64, Call_F80,
2315 Call_F128, Call_PPCF128);
2316 ExpandFPLibCall(Node, LC,
Results);
2319SDValue SelectionDAGLegalize::ExpandBitCountingLibCall(
2320 SDNode *Node, RTLIB::Libcall CallI32, RTLIB::Libcall CallI64,
2321 RTLIB::Libcall CallI128) {
2323 switch (
Node->getSimpleValueType(0).SimpleTy) {
2344 EVT ArgVT =
Op.getValueType();
2346 TargetLowering::ArgListEntry Arg(
Op, ArgTy);
2348 Arg.IsZExt = !Arg.IsSExt;
2350 SDValue Res = ExpandLibCall(LC, Node, TargetLowering::ArgListTy{Arg},
2363SelectionDAGLegalize::ExpandDivRemLibCall(SDNode *Node,
2364 SmallVectorImpl<SDValue> &
Results) {
2365 unsigned Opcode =
Node->getOpcode();
2369 switch (
Node->getSimpleValueType(0).SimpleTy) {
2371 case MVT::i8: LC=
isSigned ? RTLIB::SDIVREM_I8 : RTLIB::UDIVREM_I8;
break;
2372 case MVT::i16: LC=
isSigned ? RTLIB::SDIVREM_I16 : RTLIB::UDIVREM_I16;
break;
2373 case MVT::i32: LC=
isSigned ? RTLIB::SDIVREM_I32 : RTLIB::UDIVREM_I32;
break;
2374 case MVT::i64: LC=
isSigned ? RTLIB::SDIVREM_I64 : RTLIB::UDIVREM_I64;
break;
2375 case MVT::i128: LC=
isSigned ? RTLIB::SDIVREM_I128:RTLIB::UDIVREM_I128;
break;
2383 EVT RetVT =
Node->getValueType(0);
2386 TargetLowering::ArgListTy
Args;
2388 EVT ArgVT =
Op.getValueType();
2390 TargetLowering::ArgListEntry
Entry(
Op, ArgTy);
2393 Args.push_back(Entry);
2398 TargetLowering::ArgListEntry
Entry(
2399 FIPtr, PointerType::getUnqual(RetTy->
getContext()));
2402 Args.push_back(Entry);
2405 if (LibcallImpl == RTLIB::Unsupported) {
2407 Node->getOperationName(&DAG));
2418 TargetLowering::CallLoweringInfo CLI(DAG);
2422 RetTy, Callee, std::move(Args))
2426 std::pair<SDValue, SDValue> CallInfo = TLI.
LowerCallTo(CLI);
2430 MachinePointerInfo PtrInfo =
2433 SDValue Rem = DAG.
getLoad(RetVT, dl, CallInfo.second, FIPtr, PtrInfo);
2434 Results.push_back(CallInfo.first);
2442 return Libcalls.
getLibcallImpl(RTLIB::getSINCOS(VT)) != RTLIB::Unsupported ||
2463SDValue SelectionDAGLegalize::ExpandSincosStretLibCall(SDNode *Node)
const {
2469 RTLIB::Libcall LC = RTLIB::getSINCOS_STRET(ArgVT);
2471 if (SincosStret == RTLIB::Unsupported)
2486 Type *SincosStretRetTy = FuncTy->getReturnType();
2492 TargetLowering::ArgListTy
Args;
2496 if (FuncTy->getParamType(0)->isPointerTy()) {
2500 AttributeSet PtrAttrs = FuncAttrs.getParamAttrs(0);
2502 const uint64_t ByteSize =
DL.getTypeAllocSize(StructTy);
2503 const Align StackAlign =
DL.getPrefTypeAlign(StructTy);
2508 TargetLowering::ArgListEntry
Entry(SRet, FuncTy->getParamType(0));
2509 Entry.IsSRet =
true;
2510 Entry.IndirectType = StructTy;
2511 Entry.Alignment = StackAlign;
2513 Args.push_back(Entry);
2514 Args.emplace_back(Arg, FuncTy->getParamType(1));
2516 Args.emplace_back(Arg, FuncTy->getParamType(0));
2519 TargetLowering::CallLoweringInfo CLI(DAG);
2522 .setLibCallee(CallConv, SincosStretRetTy, Callee, std::move(Args))
2523 .setIsPostTypeLegalization();
2525 std::pair<SDValue, SDValue> CallResult = TLI.
LowerCallTo(CLI);
2528 MachinePointerInfo PtrInfo =
2530 SDValue LoadSin = DAG.
getLoad(ArgVT, dl, CallResult.second, SRet, PtrInfo);
2539 SDVTList Tys = DAG.
getVTList(ArgVT, ArgVT);
2544 if (!CallResult.first.getValueType().isVector())
2545 return CallResult.first;
2553 SDVTList Tys = DAG.
getVTList(ArgVT, ArgVT);
2557SDValue SelectionDAGLegalize::expandLdexp(SDNode *Node)
const {
2559 EVT VT =
Node->getValueType(0);
2562 EVT ExpVT =
N.getValueType();
2564 if (AsIntVT == EVT())
2578 SDNodeFlags NUW_NSW;
2586 const APFloat::ExponentType MaxExpVal = APFloat::semanticsMaxExponent(FltSem);
2587 const APFloat::ExponentType MinExpVal = APFloat::semanticsMinExponent(FltSem);
2588 const int Precision = APFloat::semanticsPrecision(FltSem);
2595 const APFloat One(FltSem,
"1.0");
2596 APFloat ScaleUpK =
scalbn(One, MaxExpVal, APFloat::rmNearestTiesToEven);
2600 scalbn(One, MinExpVal + Precision, APFloat::rmNearestTiesToEven);
2670 ExponentShiftAmt, NUW_NSW);
2675SDValue SelectionDAGLegalize::expandFrexp(SDNode *Node)
const {
2679 EVT ExpVT =
Node->getValueType(1);
2681 if (AsIntVT == EVT())
2691 const APFloat::ExponentType MinExpVal = APFloat::semanticsMinExponent(FltSem);
2692 const unsigned Precision = APFloat::semanticsPrecision(FltSem);
2725 FractSignMaskVal.
setBit(BitSize - 1);
2732 const APFloat One(FltSem,
"1.0");
2736 scalbn(One, Precision + 1, APFloat::rmNearestTiesToEven);
2748 SDValue AddNegSmallestNormal =
2750 SDValue DenormOrZero = DAG.
getSetCC(dl, SetCCVT, AddNegSmallestNormal,
2783 const APFloat Half(FltSem,
"0.5");
2800SDValue SelectionDAGLegalize::expandModf(SDNode *Node)
const {
2810 if (
Flags.hasNoInfs()) {
2811 FracToUse = FracPart;
2820 FracToUse = DAG.
getSelect(dl, VT, IsInf, Zero, FracPart);
2832SDValue SelectionDAGLegalize::ExpandLegalINT_TO_FP(SDNode *Node,
2836 EVT DestVT =
Node->getValueType(0);
2838 unsigned OpNo =
Node->isStrictFPOpcode() ? 1 : 0;
2844 if (SrcVT == MVT::i32 && TLI.
isTypeLegal(MVT::f64) &&
2845 (DestVT.
bitsLE(MVT::f64) ||
2849 LLVM_DEBUG(
dbgs() <<
"32-bit [signed|unsigned] integer to float/double "
2873 MachinePointerInfo());
2878 DAG.
getStore(MemChain, dl,
Hi, HiPtr, MachinePointerInfo());
2883 DAG.
getLoad(MVT::f64, dl, MemChain, StackSlot, MachinePointerInfo());
2892 if (
Node->isStrictFPOpcode()) {
2894 {
Node->getOperand(0),
Load, Bias});
2896 if (DestVT !=
Sub.getValueType()) {
2897 std::pair<SDValue, SDValue> ResultPair;
2900 Result = ResultPair.first;
2901 Chain = ResultPair.second;
2916 if (((SrcVT == MVT::i32 || SrcVT == MVT::i64) && DestVT == MVT::f32) ||
2917 (SrcVT == MVT::i64 && DestVT == MVT::f64)) {
2918 LLVM_DEBUG(
dbgs() <<
"Converting unsigned i32/i64 to f32/f64\n");
2933 EVT SetCCVT = getSetCCResultType(SrcVT);
2945 if (
Node->isStrictFPOpcode()) {
2953 Flags.setNoFPExcept(
Node->getFlags().hasNoFPExcept());
2956 Flags.setNoFPExcept(
true);
2979 "Cannot perform lossless SINT_TO_FP!");
2982 if (
Node->isStrictFPOpcode()) {
2984 {
Node->getOperand(0), Op0 });
2993 SignSet, Four, Zero);
3002 case MVT::i8 : FF = 0x43800000ULL;
break;
3003 case MVT::i16: FF = 0x47800000ULL;
break;
3004 case MVT::i32: FF = 0x4F800000ULL;
break;
3005 case MVT::i64: FF = 0x5F800000ULL;
break;
3009 Constant *FudgeFactor = ConstantInt::get(
3018 if (DestVT == MVT::f32)
3028 HandleSDNode Handle(
Load);
3029 LegalizeOp(
Load.getNode());
3033 if (
Node->isStrictFPOpcode()) {
3035 { Tmp1.
getValue(1), Tmp1, FudgeInReg });
3036 Chain =
Result.getValue(1);
3048void SelectionDAGLegalize::PromoteLegalINT_TO_FP(
3049 SDNode *
N,
const SDLoc &dl, SmallVectorImpl<SDValue> &
Results) {
3053 EVT DestVT =
N->getValueType(0);
3054 SDValue LegalOp =
N->getOperand(IsStrict ? 1 : 0);
3061 unsigned OpToUse = 0;
3089 DAG.
getNode(OpToUse, dl, {DestVT, MVT::Other},
3092 dl, NewInTy, LegalOp)});
3099 DAG.
getNode(OpToUse, dl, DestVT,
3101 dl, NewInTy, LegalOp)));
3109void SelectionDAGLegalize::PromoteLegalFP_TO_INT(SDNode *
N,
const SDLoc &dl,
3110 SmallVectorImpl<SDValue> &
Results) {
3111 bool IsStrict =
N->isStrictFPOpcode();
3114 EVT DestVT =
N->getValueType(0);
3117 EVT NewOutTy = DestVT;
3119 unsigned OpToUse = 0;
3143 SDVTList VTs = DAG.
getVTList(NewOutTy, MVT::Other);
3159SDValue SelectionDAGLegalize::PromoteLegalFP_TO_INT_SAT(SDNode *Node,
3161 unsigned Opcode =
Node->getOpcode();
3164 EVT NewOutTy =
Node->getValueType(0);
3176 Node->getOperand(1));
3182 EVT VT =
Op.getValueType();
3202SDValue SelectionDAGLegalize::PromoteReduction(SDNode *Node) {
3204 MVT VecVT = IsVPOpcode ?
Node->getOperand(1).getSimpleValueType()
3205 :
Node->getOperand(0).getSimpleValueType();
3207 MVT ScalarVT =
Node->getSimpleValueType(0);
3214 assert(
Node->getOperand(0).getValueType().isFloatingPoint() &&
3215 "Only FP promotion is supported");
3217 for (
unsigned j = 0;
j !=
Node->getNumOperands(); ++
j)
3218 if (
Node->getOperand(j).getValueType().isVector() &&
3223 assert(
Node->getOperand(j).getValueType().isFloatingPoint() &&
3224 "Only FP promotion is supported");
3227 }
else if (
Node->getOperand(j).getValueType().isFloatingPoint()) {
3243bool SelectionDAGLegalize::ExpandNode(SDNode *Node) {
3247 SDValue Tmp1, Tmp2, Tmp3, Tmp4;
3249 switch (
Node->getOpcode()) {
3294 Results.push_back(ExpandPARITY(
Node->getOperand(0), dl));
3346 SDVTList VTs = DAG.
getVTList(
Node->getValueType(0), MVT::Other);
3349 Node->getOperand(0),
Node->getOperand(1), Zero, Zero,
3359 Node->getOperand(0),
Node->getOperand(2),
Node->getOperand(1),
3368 SDVTList VTs = DAG.
getVTList(
Node->getValueType(0), MVT::Other);
3371 Node->getOperand(0),
Node->getOperand(1),
Node->getOperand(2),
3379 EVT OuterType =
Node->getValueType(0);
3412 EVT VT =
Node->getValueType(0);
3417 RHS =
RHS->getOperand(0);
3421 Node->getOperand(0),
Node->getOperand(1),
3429 EVT VT =
Node->getValueType(0);
3433 Node->getOperand(0),
Node->getOperand(1),
3440 ExpandDYNAMIC_STACKALLOC(Node,
Results);
3443 for (
unsigned i = 0; i <
Node->getNumValues(); i++)
3448 EVT VT =
Node->getValueType(0);
3465 Node->getValueType(0))
3466 == TargetLowering::Legal)
3470 if ((Tmp1 = EmitStackConvert(
Node->getOperand(1),
Node->getValueType(0),
3471 Node->getValueType(0), dl,
3472 Node->getOperand(0)))) {
3473 ReplaceNode(Node, Tmp1.
getNode());
3474 LLVM_DEBUG(
dbgs() <<
"Successfully expanded STRICT_FP_ROUND node\n");
3487 if ((Tmp1 = EmitStackConvert(
Node->getOperand(0),
Node->getValueType(0),
3488 Node->getValueType(0), dl)))
3499 Node->getValueType(0))
3500 == TargetLowering::Legal)
3504 if ((Tmp1 = EmitStackConvert(
3505 Node->getOperand(1),
Node->getOperand(1).getValueType(),
3506 Node->getValueType(0), dl,
Node->getOperand(0)))) {
3507 ReplaceNode(Node, Tmp1.
getNode());
3508 LLVM_DEBUG(
dbgs() <<
"Successfully expanded STRICT_FP_EXTEND node\n");
3514 EVT SrcVT =
Op.getValueType();
3515 EVT DstVT =
Node->getValueType(0);
3521 if ((Tmp1 = EmitStackConvert(
Op, SrcVT, DstVT, dl)))
3531 if (
Op.getValueType() == MVT::bf16) {
3541 if (
Node->getValueType(0) != MVT::f32)
3548 if (
Op.getValueType() != MVT::f32)
3560 if (
Node->getValueType(0) == MVT::bf16) {
3577 EVT DstVT =
Node->getValueType(0);
3592 EVT ResVT =
Node->getValueType(0);
3606 EVT VT =
Node->getValueType(0);
3638 if (
Node->isStrictFPOpcode())
3645 if ((Tmp1 = ExpandLegalINT_TO_FP(Node, Tmp2))) {
3647 if (
Node->isStrictFPOpcode())
3657 ReplaceNode(Node, Tmp1.
getNode());
3658 LLVM_DEBUG(
dbgs() <<
"Successfully expanded STRICT_FP_TO_SINT node\n");
3671 ReplaceNodeWithValue(
SDValue(Node, 0), Tmp1);
3672 LLVM_DEBUG(
dbgs() <<
"Successfully expanded STRICT_FP_TO_UINT node\n");
3684 EVT ResVT =
Node->getValueType(0);
3698 if (
Node->getOperand(0).getValueType().getVectorElementCount().isScalar())
3701 Node->getOperand(0));
3703 Tmp1 = ExpandExtractFromVectorThroughStack(
SDValue(Node, 0));
3707 Results.push_back(ExpandExtractFromVectorThroughStack(
SDValue(Node, 0)));
3710 Results.push_back(ExpandInsertToVectorThroughStack(
SDValue(Node, 0)));
3713 if (EVT VectorValueType =
Node->getOperand(0).getValueType();
3716 Results.push_back(ExpandVectorBuildThroughStack(Node));
3718 Results.push_back(ExpandConcatVectors(Node));
3721 Results.push_back(ExpandSCALAR_TO_VECTOR(Node));
3730 EVT VT =
Node->getValueType(0);
3740 if (NewEltVT.
bitsLT(EltVT)) {
3756 unsigned int factor =
3764 for (
unsigned fi = 0; fi < factor; ++fi)
3768 for (
unsigned fi = 0; fi < factor; ++fi)
3779 for (
unsigned i = 0; i != NumElems; ++i) {
3784 unsigned Idx =
Mask[i];
3806 unsigned Factor =
Node->getNumOperands();
3807 if (Factor <= 2 || Factor % 2 != 0)
3810 EVT VecVT =
Node->getValueType(0);
3821 for (
unsigned I = 0;
I < Factor / 2;
I++) {
3824 {
L.getValue(
I),
R.getValue(
I)});
3831 unsigned Factor =
Node->getNumOperands();
3832 if (Factor <= 2 || Factor % 2 != 0)
3834 EVT VecVT =
Node->getValueType(0);
3839 for (
unsigned I = 0;
I < Factor / 2;
I++) {
3842 {
Node->getOperand(
I),
Node->getOperand(
I + Factor / 2)});
3850 for (
unsigned I = 0;
I < Factor / 2;
I++)
3852 for (
unsigned I = 0;
I < Factor / 2;
I++)
3857 EVT OpTy =
Node->getOperand(0).getValueType();
3858 if (
Node->getConstantOperandVal(1)) {
3867 Node->getOperand(0));
3878 Node->getValueType(0)));
3885 ?
"llvm.stackaddress"
3888 Twine(IntrinsicName) +
" is not supported on this target.",
3897 Node->getOperand(1)));
3907 Results.push_back(ExpandFCOPYSIGN(Node));
3910 Results.push_back(ExpandFNEG(Node));
3913 Results.push_back(ExpandFABS(Node));
3919 Test,
Node->getFlags(), SDLoc(Node), DAG))
3929 switch (
Node->getOpcode()) {
3936 Tmp1 =
Node->getOperand(0);
3937 Tmp2 =
Node->getOperand(1);
3938 Tmp1 = DAG.
getSelectCC(dl, Tmp1, Tmp2, Tmp1, Tmp2, Pred);
3961 EVT VT =
Node->getValueType(0);
3977 EVT VT =
Node->getValueType(0);
3978 RTLIB::Libcall LC = RTLIB::getLDEXP(VT);
3984 if (
SDValue Expanded = expandLdexp(Node)) {
3987 Results.push_back(Expanded.getValue(1));
3993 RTLIB::Libcall LC = RTLIB::getFREXP(
Node->getValueType(0));
3999 if (
SDValue Expanded = expandFrexp(Node)) {
4001 Results.push_back(Expanded.getValue(1));
4006 RTLIB::Libcall LC = RTLIB::getMODF(
Node->getValueType(0));
4012 if (
SDValue Expanded = expandModf(Node)) {
4014 Results.push_back(Expanded.getValue(1));
4021 EVT VT =
Node->getValueType(0);
4033 if (
Node->getValueType(0) != MVT::f32) {
4045 if (
Node->getValueType(0) != MVT::f32) {
4050 {Node->getOperand(0), Node->getOperand(1)});
4052 {
Node->getValueType(0), MVT::Other},
4062 MVT SVT =
Op.getSimpleValueType();
4063 if ((SVT == MVT::f64 || SVT == MVT::f80) &&
4081 Results.push_back(ExpandConstantFP(CFP,
true));
4086 Results.push_back(ExpandConstant(CP));
4090 EVT VT =
Node->getValueType(0);
4093 const SDNodeFlags
Flags =
Node->getFlags();
4101 EVT VT =
Node->getValueType(0);
4104 "Don't know how to expand this subtraction!");
4105 Tmp1 = DAG.
getNOT(dl,
Node->getOperand(1), VT);
4119 EVT VT =
Node->getValueType(0);
4122 Tmp1 = DAG.
getNode(DivRemOpc, dl, VTs,
Node->getOperand(0),
4123 Node->getOperand(1));
4130 unsigned ExpandOpcode =
4132 EVT VT =
Node->getValueType(0);
4135 Tmp1 = DAG.
getNode(ExpandOpcode, dl, VTs,
Node->getOperand(0),
4136 Node->getOperand(1));
4144 EVT VT =
LHS.getValueType();
4145 unsigned MULHOpcode =
4159 TargetLowering::MulExpansionKind::Always)) {
4160 for (
unsigned i = 0; i < 2; ++i) {
4173 EVT VT =
Node->getValueType(0);
4184 unsigned OpToUse = 0;
4185 if (HasSMUL_LOHI && !HasMULHS) {
4187 }
else if (HasUMUL_LOHI && !HasMULHU) {
4189 }
else if (HasSMUL_LOHI) {
4191 }
else if (HasUMUL_LOHI) {
4196 Node->getOperand(1)));
4207 TargetLowering::MulExpansionKind::OnlyLegalOrCustom)) {
4264 Node->getOperand(0),
4265 Node->getOperand(1),
4266 Node->getConstantOperandVal(2),
4289 EVT VT =
LHS.getValueType();
4293 EVT CarryType =
Node->getValueType(1);
4294 EVT SetCCType = getSetCCResultType(
Node->getValueType(0));
4341 if (TLI.
expandMULO(Node, Result, Overflow, DAG)) {
4358 Tmp1 =
Node->getOperand(0);
4359 Tmp2 =
Node->getOperand(1);
4360 Tmp3 =
Node->getOperand(2);
4381 unsigned EntrySize =
4417 Tmp1 =
Node->getOperand(0);
4418 Tmp2 =
Node->getOperand(1);
4424 Node->getOperand(2));
4436 Node->getOperand(2));
4447 unsigned Offset = IsStrict ? 1 : 0;
4453 NeedInvert, dl, Chain, IsSignaling);
4461 {Chain, Tmp1, Tmp2, Tmp3},
Node->getFlags());
4464 Tmp1 = DAG.
getNode(
Node->getOpcode(), dl,
Node->getValueType(0), Tmp1,
4465 Tmp2, Tmp3,
Node->getFlags());
4484 assert(!IsStrict &&
"Don't know how to expand for strict nodes.");
4488 EVT VT =
Node->getValueType(0);
4499 Tmp1 =
Node->getOperand(0);
4500 Tmp2 =
Node->getOperand(1);
4501 Tmp3 =
Node->getOperand(2);
4502 Tmp4 =
Node->getOperand(3);
4503 EVT VT =
Node->getValueType(0);
4513 "Cannot expand ISD::SELECT_CC when ISD::SELECT also needs to be "
4515 EVT CCVT = getSetCCResultType(CmpVT);
4523 bool Legalized =
false;
4541 Tmp1 = DAG.
getSelectCC(dl, Tmp2, Tmp1, Tmp4, Tmp3, SwapInvCC,
4548 DAG, getSetCCResultType(Tmp1.
getValueType()), Tmp1, Tmp2, CC,
4549 NeedInvert, dl, Chain);
4551 assert(Legalized &&
"Can't legalize SELECT_CC with legal condition!");
4562 Tmp2, Tmp3, Tmp4, CC,
Node->getFlags());
4567 Tmp2, Tmp3, Tmp4, CC,
Node->getFlags());
4576 Tmp1 =
Node->getOperand(0);
4577 Tmp2 =
Node->getOperand(2);
4578 Tmp3 =
Node->getOperand(3);
4579 Tmp4 =
Node->getOperand(1);
4583 Tmp2, Tmp3, Tmp4, NeedInvert, dl, Chain);
4585 assert(Legalized &&
"Can't legalize BR_CC with legal condition!");
4590 assert(!NeedInvert &&
"Don't know how to invert BR_CC!");
4593 Tmp4, Tmp2, Tmp3,
Node->getOperand(4));
4598 Tmp2, Tmp3,
Node->getOperand(4));
4604 Results.push_back(ExpandBUILD_VECTOR(Node));
4607 Results.push_back(ExpandSPLAT_VECTOR(Node));
4613 EVT VT =
Node->getValueType(0);
4619 for (
unsigned Idx = 0; Idx < NumElem; Idx++) {
4653 case ISD::VP_CTTZ_ELTS:
4654 case ISD::VP_CTTZ_ELTS_ZERO_POISON:
4666 EVT ResVT =
Node->getValueType(0);
4698 switch (
Node->getOpcode()) {
4701 Node->getValueType(0))
4702 == TargetLowering::Legal)
4713 EVT VT =
Node->getValueType(0);
4714 const SDNodeFlags
Flags =
Node->getFlags();
4717 {Node->getOperand(0), Node->getOperand(1), Neg},
4733 Node->getOperand(1).getValueType())
4734 == TargetLowering::Legal)
4747 ReplaceNode(Node,
Results.data());
4759 return Flags.hasApproximateFuncs() && Flags.hasNoNaNs() &&
4760 Flags.hasNoInfs() && Flags.hasNoSignedZeros();
4763void SelectionDAGLegalize::ConvertNodeToLibcall(SDNode *Node) {
4767 TargetLowering::MakeLibCallOptions CallOptions;
4770 unsigned Opc =
Node->getOpcode();
4775 TargetLowering::ArgListTy
Args;
4777 TargetLowering::CallLoweringInfo CLI(DAG);
4779 .setChain(
Node->getOperand(0))
4781 CallingConv::C, Type::getVoidTy(*DAG.
getContext()),
4786 std::pair<SDValue, SDValue> CallResult = TLI.
LowerCallTo(CLI);
4788 Results.push_back(CallResult.second);
4810 EVT RetVT =
Node->getValueType(0);
4815 Ops.push_back(
Node->getOperand(1));
4819 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
4820 "Unexpected atomic op or value type!");
4824 std::pair<SDValue, SDValue> Tmp = TLI.
makeLibCall(DAG, LC, RetVT,
4827 Node->getOperand(0));
4829 Results.push_back(Tmp.second);
4834 TargetLowering::ArgListTy
Args;
4835 TargetLowering::CallLoweringInfo CLI(DAG);
4837 .setChain(
Node->getOperand(0))
4838 .setLibCallee(CallingConv::C, Type::getVoidTy(*DAG.
getContext()),
4842 std::pair<SDValue, SDValue> CallResult = TLI.
LowerCallTo(CLI);
4844 Results.push_back(CallResult.second);
4851 std::pair<SDValue, SDValue> Tmp = TLI.
makeLibCall(
4852 DAG, RTLIB::CLEAR_CACHE, MVT::isVoid, {StartVal, EndVal}, CallOptions,
4853 SDLoc(Node), InputChain);
4854 Results.push_back(Tmp.second);
4859 ExpandFPLibCall(Node, RTLIB::getFMIN(
Node->getSimpleValueType(0)),
Results);
4866 ExpandFPLibCall(Node, RTLIB::getFMAX(
Node->getSimpleValueType(0)),
Results);
4869 ExpandFPLibCall(Node, RTLIB::getFMINIMUM_NUM(
Node->getSimpleValueType(0)),
4873 ExpandFPLibCall(Node, RTLIB::getFMAXIMUM_NUM(
Node->getSimpleValueType(0)),
4881 {RTLIB::FAST_SQRT_F32, RTLIB::SQRT_F32},
4882 {RTLIB::FAST_SQRT_F64, RTLIB::SQRT_F64},
4883 {RTLIB::FAST_SQRT_F80, RTLIB::SQRT_F80},
4884 {RTLIB::FAST_SQRT_F128, RTLIB::SQRT_F128},
4885 {RTLIB::FAST_SQRT_PPCF128, RTLIB::SQRT_PPCF128},
4890 ExpandFPLibCall(Node, RTLIB::getCBRT(
Node->getSimpleValueType(0)),
Results);
4894 ExpandFPLibCall(Node, RTLIB::getSIN(
Node->getSimpleValueType(0)),
Results);
4898 ExpandFPLibCall(Node, RTLIB::getCOS(
Node->getSimpleValueType(0)),
Results);
4902 ExpandFPLibCall(Node, RTLIB::getTAN(
Node->getSimpleValueType(0)),
Results);
4906 ExpandFPLibCall(Node, RTLIB::getASIN(
Node->getSimpleValueType(0)),
Results);
4910 ExpandFPLibCall(Node, RTLIB::getACOS(
Node->getSimpleValueType(0)),
Results);
4914 ExpandFPLibCall(Node, RTLIB::getATAN(
Node->getSimpleValueType(0)),
Results);
4918 ExpandFPLibCall(Node, RTLIB::getATAN2(
Node->getSimpleValueType(0)),
4923 ExpandFPLibCall(Node, RTLIB::getSINH(
Node->getSimpleValueType(0)),
Results);
4927 ExpandFPLibCall(Node, RTLIB::getCOSH(
Node->getSimpleValueType(0)),
Results);
4931 ExpandFPLibCall(Node, RTLIB::getTANH(
Node->getSimpleValueType(0)),
Results);
4935 EVT VT =
Node->getValueType(0);
4938 RTLIB::Libcall SincosStret = RTLIB::getSINCOS_STRET(VT);
4939 if (SincosStret != RTLIB::UNKNOWN_LIBCALL) {
4940 if (
SDValue Expanded = ExpandSincosStretLibCall(Node)) {
4942 Results.push_back(Expanded.getValue(1));
4949 ? RTLIB::getSINCOS(VT)
4950 : RTLIB::getSINCOSPI(VT);
4954 Node->getOperationName(&DAG));
4964 ExpandFPLibCall(Node, RTLIB::getLOG(
Node->getSimpleValueType(0)),
Results);
4968 ExpandFPLibCall(Node, RTLIB::getLOG2(
Node->getSimpleValueType(0)),
Results);
4972 ExpandFPLibCall(Node, RTLIB::getLOG10(
Node->getSimpleValueType(0)),
4977 ExpandFPLibCall(Node, RTLIB::getEXP(
Node->getSimpleValueType(0)),
Results);
4981 ExpandFPLibCall(Node, RTLIB::getEXP2(
Node->getSimpleValueType(0)),
Results);
4984 ExpandFPLibCall(Node, RTLIB::getEXP10(
Node->getSimpleValueType(0)),
4989 ExpandFPLibCall(Node, RTLIB::getTRUNC(
Node->getSimpleValueType(0)),
4994 ExpandFPLibCall(Node, RTLIB::getFLOOR(
Node->getSimpleValueType(0)),
4999 ExpandFPLibCall(Node, RTLIB::getCEIL(
Node->getSimpleValueType(0)),
Results);
5003 ExpandFPLibCall(Node, RTLIB::getRINT(
Node->getSimpleValueType(0)),
Results);
5007 ExpandFPLibCall(Node, RTLIB::getNEARBYINT(
Node->getSimpleValueType(0)),
5012 ExpandFPLibCall(Node, RTLIB::getROUND(
Node->getSimpleValueType(0)),
5017 ExpandFPLibCall(Node, RTLIB::getROUNDEVEN(
Node->getSimpleValueType(0)),
5022 ExpandFPLibCall(Node, RTLIB::getLDEXP(
Node->getSimpleValueType(0)),
5027 EVT VT =
Node->getValueType(0);
5028 RTLIB::Libcall LC =
Node->getOpcode() ==
ISD::FMODF ? RTLIB::getMODF(VT)
5029 : RTLIB::getFREXP(VT);
5034 Node->getOperationName(&DAG));
5035 for (
unsigned I = 0,
E =
Node->getNumValues();
I !=
E; ++
I)
5042 RTLIB::Libcall LC = RTLIB::getPOWI(
Node->getSimpleValueType(0));
5043 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fpowi.");
5046 if (
Node->isStrictFPOpcode()) {
5049 {
Node->getValueType(0),
Node->getValueType(1)},
5050 {
Node->getOperand(0),
Node->getOperand(2)});
5053 {
Node->getValueType(0),
Node->getValueType(1)},
5060 Node->getOperand(1));
5062 Node->getValueType(0),
5067 unsigned Offset =
Node->isStrictFPOpcode() ? 1 : 0;
5068 bool ExponentHasSizeOfInt =
5070 Node->getOperand(1 +
Offset).getValueType().getSizeInBits();
5071 if (!ExponentHasSizeOfInt) {
5078 ExpandFPLibCall(Node, LC,
Results);
5083 ExpandFPLibCall(Node, RTLIB::getPOW(
Node->getSimpleValueType(0)),
Results);
5087 ExpandArgFPLibCall(Node, RTLIB::LROUND_F32,
5088 RTLIB::LROUND_F64, RTLIB::LROUND_F80,
5090 RTLIB::LROUND_PPCF128,
Results);
5094 ExpandArgFPLibCall(Node, RTLIB::LLROUND_F32,
5095 RTLIB::LLROUND_F64, RTLIB::LLROUND_F80,
5096 RTLIB::LLROUND_F128,
5097 RTLIB::LLROUND_PPCF128,
Results);
5101 ExpandArgFPLibCall(Node, RTLIB::LRINT_F32,
5102 RTLIB::LRINT_F64, RTLIB::LRINT_F80,
5104 RTLIB::LRINT_PPCF128,
Results);
5108 ExpandArgFPLibCall(Node, RTLIB::LLRINT_F32,
5109 RTLIB::LLRINT_F64, RTLIB::LLRINT_F80,
5111 RTLIB::LLRINT_PPCF128,
Results);
5116 {RTLIB::FAST_DIV_F32, RTLIB::DIV_F32},
5117 {RTLIB::FAST_DIV_F64, RTLIB::DIV_F64},
5118 {RTLIB::FAST_DIV_F80, RTLIB::DIV_F80},
5119 {RTLIB::FAST_DIV_F128, RTLIB::DIV_F128},
5120 {RTLIB::FAST_DIV_PPCF128, RTLIB::DIV_PPCF128},
Results);
5125 ExpandFPLibCall(Node, RTLIB::getREM(
Node->getSimpleValueType(0)),
Results);
5129 ExpandFPLibCall(Node, RTLIB::getFMA(
Node->getSimpleValueType(0)),
Results);
5134 {RTLIB::FAST_ADD_F32, RTLIB::ADD_F32},
5135 {RTLIB::FAST_ADD_F64, RTLIB::ADD_F64},
5136 {RTLIB::FAST_ADD_F80, RTLIB::ADD_F80},
5137 {RTLIB::FAST_ADD_F128, RTLIB::ADD_F128},
5138 {RTLIB::FAST_ADD_PPCF128, RTLIB::ADD_PPCF128},
Results);
5144 {RTLIB::FAST_MUL_F32, RTLIB::MUL_F32},
5145 {RTLIB::FAST_MUL_F64, RTLIB::MUL_F64},
5146 {RTLIB::FAST_MUL_F80, RTLIB::MUL_F80},
5147 {RTLIB::FAST_MUL_F128, RTLIB::MUL_F128},
5148 {RTLIB::FAST_MUL_PPCF128, RTLIB::MUL_PPCF128},
Results);
5152 if (
Node->getValueType(0) == MVT::f32) {
5153 Results.push_back(ExpandLibCall(RTLIB::FPEXT_F16_F32, Node,
false).first);
5157 if (
Node->getValueType(0) == MVT::f32) {
5158 std::pair<SDValue, SDValue> Tmp = TLI.
makeLibCall(
5159 DAG, RTLIB::FPEXT_BF16_F32, MVT::f32,
Node->getOperand(1),
5160 CallOptions, SDLoc(Node),
Node->getOperand(0));
5162 Results.push_back(Tmp.second);
5166 if (
Node->getValueType(0) == MVT::f32) {
5167 std::pair<SDValue, SDValue> Tmp = TLI.
makeLibCall(
5168 DAG, RTLIB::FPEXT_F16_F32, MVT::f32,
Node->getOperand(1), CallOptions,
5169 SDLoc(Node),
Node->getOperand(0));
5171 Results.push_back(Tmp.second);
5178 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unable to expand fp_to_fp16");
5179 Results.push_back(ExpandLibCall(LC, Node,
false).first);
5185 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unable to expand fp_to_bf16");
5186 Results.push_back(ExpandLibCall(LC, Node,
false).first);
5194 bool IsStrict =
Node->isStrictFPOpcode();
5197 EVT SVT =
Node->getOperand(IsStrict ? 1 : 0).getValueType();
5198 EVT RVT =
Node->getValueType(0);
5205 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5206 for (
unsigned t = MVT::FIRST_INTEGER_VALUETYPE;
5207 t <= MVT::LAST_INTEGER_VALUETYPE && LC == RTLIB::UNKNOWN_LIBCALL;
5215 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unable to legalize as libcall");
5220 NVT,
Node->getOperand(IsStrict ? 1 : 0));
5222 std::pair<SDValue, SDValue> Tmp =
5226 Results.push_back(Tmp.second);
5234 bool IsStrict =
Node->isStrictFPOpcode();
5239 EVT SVT =
Op.getValueType();
5240 EVT RVT =
Node->getValueType(0);
5247 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5248 for (
unsigned IntVT = MVT::FIRST_INTEGER_VALUETYPE;
5249 IntVT <= MVT::LAST_INTEGER_VALUETYPE && LC == RTLIB::UNKNOWN_LIBCALL;
5257 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unable to legalize as libcall");
5260 std::pair<SDValue, SDValue> Tmp =
5266 Results.push_back(Tmp.second);
5277 bool IsStrict =
Node->isStrictFPOpcode();
5280 EVT VT =
Node->getValueType(0);
5282 "Unable to expand as libcall if it is not normal rounding");
5285 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unable to legalize as libcall");
5287 std::pair<SDValue, SDValue> Tmp =
5288 TLI.
makeLibCall(DAG, LC, VT,
Op, CallOptions, SDLoc(Node), Chain);
5291 Results.push_back(Tmp.second);
5297 Node->getValueType(0)),
5298 Node,
false).first);
5304 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5311 Node->getValueType(0));
5313 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unable to legalize as libcall");
5315 std::pair<SDValue, SDValue> Tmp =
5317 CallOptions, SDLoc(Node),
Node->getOperand(0));
5319 Results.push_back(Tmp.second);
5325 {RTLIB::FAST_SUB_F32, RTLIB::SUB_F32},
5326 {RTLIB::FAST_SUB_F64, RTLIB::SUB_F64},
5327 {RTLIB::FAST_SUB_F80, RTLIB::SUB_F80},
5328 {RTLIB::FAST_SUB_F128, RTLIB::SUB_F128},
5329 {RTLIB::FAST_SUB_PPCF128, RTLIB::SUB_PPCF128},
Results);
5333 Results.push_back(ExpandIntLibCall(Node,
true,
5335 RTLIB::SREM_I16, RTLIB::SREM_I32,
5336 RTLIB::SREM_I64, RTLIB::SREM_I128));
5339 Results.push_back(ExpandIntLibCall(Node,
false,
5341 RTLIB::UREM_I16, RTLIB::UREM_I32,
5342 RTLIB::UREM_I64, RTLIB::UREM_I128));
5345 Results.push_back(ExpandIntLibCall(Node,
true,
5347 RTLIB::SDIV_I16, RTLIB::SDIV_I32,
5348 RTLIB::SDIV_I64, RTLIB::SDIV_I128));
5351 Results.push_back(ExpandIntLibCall(Node,
false,
5353 RTLIB::UDIV_I16, RTLIB::UDIV_I32,
5354 RTLIB::UDIV_I64, RTLIB::UDIV_I128));
5359 ExpandDivRemLibCall(Node,
Results);
5362 Results.push_back(ExpandIntLibCall(Node,
false,
5364 RTLIB::MUL_I16, RTLIB::MUL_I32,
5365 RTLIB::MUL_I64, RTLIB::MUL_I128));
5368 Results.push_back(ExpandBitCountingLibCall(
5369 Node, RTLIB::CTLZ_I32, RTLIB::CTLZ_I64, RTLIB::CTLZ_I128));
5372 Results.push_back(ExpandBitCountingLibCall(
5373 Node, RTLIB::CTPOP_I32, RTLIB::CTPOP_I64, RTLIB::CTPOP_I128));
5402 EVT ModeVT =
Node->getValueType(0);
5406 Node->getOperand(0), dl);
5408 ModeVT, dl, Chain, StackPtr,
5418 EVT ModeVT =
Mode.getValueType();
5422 Node->getOperand(0), dl,
Mode, StackPtr,
5436 Node->getOperand(0), dl));
5443 LLVM_DEBUG(
dbgs() <<
"Successfully converted node to libcall\n");
5444 ReplaceNode(Node,
Results.data());
5452 MVT EltVT,
MVT NewEltVT) {
5454 MVT MidVT = OldEltsPerNewElt == 1
5461void SelectionDAGLegalize::PromoteNode(SDNode *Node) {
5464 MVT OVT =
Node->getSimpleValueType(0);
5475 OVT =
Node->getOperand(0).getSimpleValueType();
5486 Node->getOpcode() == ISD::VP_REDUCE_FADD ||
5487 Node->getOpcode() == ISD::VP_REDUCE_FMUL ||
5488 Node->getOpcode() == ISD::VP_REDUCE_FMAX ||
5489 Node->getOpcode() == ISD::VP_REDUCE_FMIN ||
5490 Node->getOpcode() == ISD::VP_REDUCE_FMAXIMUM ||
5491 Node->getOpcode() == ISD::VP_REDUCE_FMINIMUM ||
5492 Node->getOpcode() == ISD::VP_REDUCE_SEQ_FADD)
5493 OVT =
Node->getOperand(1).getSimpleValueType();
5496 OVT =
Node->getOperand(2).getSimpleValueType();
5499 SelectionDAG::FlagInserter FlagsInserter(DAG, FastMathFlags);
5502 SDValue Tmp1, Tmp2, Tmp3, Tmp4;
5503 switch (
Node->getOpcode()) {
5515 unsigned NewOpc =
Node->getOpcode();
5528 Tmp1 = DAG.
getNode(NewOpc, dl, NVT, Tmp1);
5544 auto AnyExtendedNode =
5550 auto LeftShiftResult =
5554 auto CTLZResult = DAG.
getNode(
Node->getOpcode(), dl, NVT, LeftShiftResult);
5576 Tmp1 = DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1);
5587 PromoteLegalFP_TO_INT(Node, dl,
Results);
5591 Results.push_back(PromoteLegalFP_TO_INT_SAT(Node, dl));
5597 PromoteLegalINT_TO_FP(Node, dl,
Results);
5608 &&
"VAARG promotion is supported only for vectors or integer types");
5613 Tmp1 = DAG.
getVAArg(NVT, dl, Chain, Ptr,
Node->getOperand(2),
5614 Node->getConstantOperandVal(3));
5617 Tmp2 = DAG.
getNode(TruncOp, dl, OVT, Tmp1);
5624 UpdatedNodes->insert(Tmp2.
getNode());
5625 UpdatedNodes->insert(Chain.
getNode());
5642 unsigned ExtOp, TruncOp;
5649 switch (
Node->getOpcode()) {
5674 Tmp1 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(0));
5675 Tmp2 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(1));
5677 Tmp1 = DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1, Tmp2);
5686 Tmp1 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(0));
5687 Tmp2 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(1));
5698 unsigned ExtOp, TruncOp;
5699 if (
Node->getValueType(0).isVector() ||
5703 }
else if (
Node->getValueType(0).isInteger()) {
5710 Tmp1 =
Node->getOperand(0);
5712 Tmp2 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(1));
5713 Tmp3 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(2));
5715 Tmp1 = DAG.
getSelect(dl, NVT, Tmp1, Tmp2, Tmp3);
5717 Tmp1 = DAG.
getNode(TruncOp, dl,
Node->getValueType(0), Tmp1);
5719 Tmp1 = DAG.
getNode(TruncOp, dl,
Node->getValueType(0), Tmp1,
5732 Tmp1 = ShuffleWithNarrowerEltType(NVT, OVT, dl, Tmp1, Tmp2, Mask);
5741 Tmp3 = DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1, Tmp2,
5742 Node->getOperand(2));
5750 MVT CVT =
Node->getSimpleValueType(0);
5751 assert(CVT == OVT &&
"not handled");
5760 Tmp1 =
Node->getOperand(0);
5761 Tmp2 =
Node->getOperand(1);
5763 Tmp1 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(0));
5764 Tmp2 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(1));
5767 Tmp3 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(2));
5768 Tmp4 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(3));
5795 if (
Node->isStrictFPOpcode()) {
5797 std::tie(Tmp1, std::ignore) =
5799 std::tie(Tmp2, std::ignore) =
5803 SDVTList VTs = DAG.
getVTList(
Node->getValueType(0), MVT::Other);
5805 {OutChain, Tmp1, Tmp2, Node->getOperand(3)},
5810 Tmp1 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(0));
5811 Tmp2 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(1));
5813 Tmp2,
Node->getOperand(2),
Node->getFlags()));
5823 Tmp1 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(2));
5824 Tmp2 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(3));
5826 Node->getOperand(0),
Node->getOperand(1),
5827 Tmp1, Tmp2,
Node->getOperand(4)));
5849 DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1, Tmp2,
Node->getFlags());
5856 Tmp3 = DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1, Tmp2);
5865 SDVTList VTs = DAG.
getVTList(NVT, MVT::Other);
5867 Node->getOperand(1));
5869 Node->getOperand(2));
5890 {
Node->getOperand(0),
Node->getOperand(1)});
5892 {
Node->getOperand(0),
Node->getOperand(2)});
5895 Tmp1 = DAG.
getNode(
Node->getOpcode(), dl, {NVT, MVT::Other},
5896 {Tmp3, Tmp1, Tmp2});
5921 DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1, Tmp2, Tmp3),
5926 {
Node->getOperand(0),
Node->getOperand(1)});
5928 {
Node->getOperand(0),
Node->getOperand(2)});
5930 {
Node->getOperand(0),
Node->getOperand(3)});
5933 Tmp4 = DAG.
getNode(
Node->getOpcode(), dl, {NVT, MVT::Other},
5934 {Tmp4, Tmp1, Tmp2, Tmp3});
5945 Tmp2 =
Node->getOperand(1);
5946 Tmp3 = DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1, Tmp2);
5961 {
Node->getOperand(0),
Node->getOperand(1)});
5962 Tmp2 =
Node->getOperand(2);
5974 {
Node->getOperand(0),
Node->getOperand(1)});
5975 Tmp2 = DAG.
getNode(
Node->getOpcode(), dl, {NVT, MVT::Other},
5976 {Tmp1.getValue(1), Tmp1, Node->getOperand(2)});
6000 for (
unsigned ResNum = 0; ResNum <
Node->getNumValues(); ResNum++)
6035 Tmp2 = DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1,
Node->getFlags());
6041 Tmp2 = DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1);
6069 {
Node->getOperand(0),
Node->getOperand(1)});
6070 Tmp2 = DAG.
getNode(
Node->getOpcode(), dl, {NVT, MVT::Other},
6071 {Tmp1.getValue(1), Tmp1});
6083 Tmp2 = DAG.
getNode(
Node->getOpcode(), dl,
Node->getValueType(0), Tmp1);
6091 {
Node->getOperand(0),
Node->getOperand(1)});
6092 Tmp2 = DAG.
getNode(
Node->getOpcode(), dl, {NVT, MVT::Other},
6093 {Tmp1.getValue(1), Tmp1});
6108 "Invalid promote type for build_vector");
6141 "Invalid promote type for extract_vector_elt");
6156 for (
unsigned I = 0;
I < NewEltsPerOldElt; ++
I) {
6187 "Invalid promote type for insert_vector_elt");
6205 for (
unsigned I = 0;
I < NewEltsPerOldElt; ++
I) {
6210 CastVal, IdxOffset);
6213 NewVec, Elt, InEltIdx);
6253 "unexpected promotion type");
6255 "unexpected atomic_swap with illegal type");
6279 "unexpected promotion type");
6281 "unexpected atomic_load with illegal type");
6292 MVT ScalarType =
Scalar.getSimpleValueType();
6296 Tmp2 = DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1);
6301 Tmp2 = DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1);
6313 case ISD::VP_REDUCE_FMAX:
6314 case ISD::VP_REDUCE_FMIN:
6315 case ISD::VP_REDUCE_FMAXIMUM:
6316 case ISD::VP_REDUCE_FMINIMUM:
6317 Results.push_back(PromoteReduction(Node));
6324 ReplaceNode(Node,
Results.data());
6342 SelectionDAGLegalize
Legalizer(*
this, LegalizedNodes);
6349 bool AnyLegalized =
false;
6360 if (LegalizedNodes.
insert(
N).second) {
6361 AnyLegalized =
true;
6382 SelectionDAGLegalize
Legalizer(*
this, LegalizedNodes, &UpdatedNodes);
6389 return LegalizedNodes.
count(
N);
aarch64 falkor hwpf fix Falkor HW Prefetch Fix Late Phase
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static msgpack::DocNode getNode(msgpack::DocNode DN, msgpack::Type Type, MCValue Val)
static bool isConstant(const MachineInstr &MI)
This file declares a class to represent arbitrary precision floating point values and provide a varie...
This file implements a class to represent arbitrary precision integral constant values and operations...
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Function Alias Analysis Results
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static bool isSigned(unsigned Opcode)
Utilities for dealing with flags related to floating point properties and mode controls.
static MaybeAlign getAlign(Value *Ptr)
static constexpr Value * getValue(Ty &ValueOrUse)
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
static bool ExpandBVWithShuffles(SDNode *Node, SelectionDAG &DAG, const TargetLowering &TLI, SDValue &Res)
static bool isSinCosLibcallAvailable(SDNode *Node, const LibcallLoweringInfo &Libcalls)
Return true if sincos or __sincos_stret libcall is available.
static bool useSinCos(SDNode *Node)
Only issue sincos libcall if both sin and cos are needed.
static bool canUseFastMathLibcall(const SDNode *Node)
Return if we can use the FAST_* variant of a math libcall for the node.
static MachineMemOperand * getStackAlignedMMO(SDValue StackPtr, MachineFunction &MF, bool isObjectScalable)
static MVT getPromotedVectorElementType(const TargetLowering &TLI, MVT EltVT, MVT NewEltVT)
std::pair< MCSymbol *, MachineModuleInfoImpl::StubValueTy > PairTy
Promote Memory to Register
PowerPC Reduce CR logical Operation
static constexpr MCPhysReg SPReg
const SmallVectorImpl< MachineOperand > & Cond
static cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallPtrSet class.
This file defines the SmallSet class.
This file defines the SmallVector class.
This file describes how to lower LLVM code to machine code.
static constexpr int Concat[]
static APFloat getSmallestNormalized(const fltSemantics &Sem, bool Negative=false)
Returns the smallest (by magnitude) normalized finite number in the given semantics.
APInt bitcastToAPInt() const
static APFloat getInf(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Infinity.
Class for arbitrary precision integers.
static APInt getSignMask(unsigned BitWidth)
Get the SignMask for a specific bit width.
void setBit(unsigned BitPosition)
Set the given bit to 1 whose position is given as "bitPosition".
static APInt getBitsSet(unsigned numBits, unsigned loBit, unsigned hiBit)
Get a value with a block of bits set.
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
static APInt getOneBitSet(unsigned numBits, unsigned BitNo)
Return an APInt with exactly one bit set in the result.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
const SDValue & getBasePtr() const
const SDValue & getVal() const
LLVM_ABI Type * getStructRetType() const
static LLVM_ABI bool isValueValidForType(EVT VT, const APFloat &Val)
const APFloat & getValueAPF() const
const ConstantFP * getConstantFPValue() const
const APFloat & getValueAPF() const
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
const ConstantInt * getConstantIntValue() const
static LLVM_ABI Constant * get(ArrayRef< Constant * > V)
bool isLittleEndian() const
Layout endianness...
unsigned getAllocaAddrSpace() const
LLVM_ABI Align getPrefTypeAlign(Type *Ty) const
Returns the preferred stack/global alignment for the specified type.
const BasicBlock & back() const
LLVM_ABI void emitError(const Instruction *I, const Twine &ErrorStr)
emitError - Emit an error message to the currently installed error handler with optional location inf...
LLVM_ABI void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
Tracks which library functions to use for a particular subtarget or function.
CallingConv::ID getLibcallImplCallingConv(RTLIB::LibcallImpl Call) const
Get the CallingConv that should be used for the specified libcall.
RTLIB::LibcallImpl getLibcallImpl(RTLIB::Libcall Call) const
Return the lowering's selection of implementation call for Call.
static LocationSize precise(uint64_t Value)
static constexpr LocationSize beforeOrAfterPointer()
Any location before or after the base pointer (but still within the underlying object).
uint64_t getScalarSizeInBits() const
bool bitsLE(MVT VT) const
Return true if this has no more bits than VT.
unsigned getVectorNumElements() const
bool isVector() const
Return true if this is a vector value type.
bool isInteger() const
Return true if this is an integer or a vector integer type.
bool bitsLT(MVT VT) const
Return true if this has less bits than VT.
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
static MVT getVectorVT(MVT VT, unsigned NumElements)
MVT getVectorElementType() const
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
LLVM_ABI 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.
Align getObjectAlign(int ObjectIdx) const
Return the alignment of the specified stack object.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
Function & getFunction()
Return the LLVM function that this machine code represents.
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags F, LLT MemTy, Align BaseAlignment, const MMOMetadata &Metadata=MMOMetadata(), SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
const MachineJumpTableInfo * getJumpTableInfo() const
getJumpTableInfo - Return the jump table info object for the current function.
LLVM_ABI unsigned getEntrySize(const DataLayout &TD) const
getEntrySize - Return the size of each entry in the jump table.
A description of a memory reference used in the backend.
Flags
Flags values. These may be or'd together.
@ MOStore
The memory access writes data.
MachineMemOperand * getMemOperand() const
Return the unique MachineMemOperand object describing the memory reference performed by operation.
const SDValue & getChain() const
EVT getMemoryVT() const
Return the type of the in-memory value.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
const DebugLoc & getDebugLoc() const
Represents one node in the SelectionDAG.
bool isStrictFPOpcode()
Test if this node is a strict floating point pseudo-op.
ArrayRef< SDUse > ops() const
LLVM_ABI void dump() const
Dump this node, for debugging.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
static bool hasPredecessorHelper(const SDNode *N, SmallPtrSetImpl< const SDNode * > &Visited, SmallVectorImpl< const SDNode * > &Worklist, unsigned int MaxSteps=0, bool TopologicalPrune=false)
Returns true if N is a predecessor of any node in Worklist.
unsigned getNumValues() const
Return the number of values defined/returned by this operator.
const SDValue & getOperand(unsigned Num) const
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
iterator_range< user_iterator > users()
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
SDNode * getNode() const
get the SDNode which holds the desired result
SDValue getValue(unsigned R) const
EVT getValueType() const
Return the ValueType of the referenced return value.
const SDValue & getOperand(unsigned i) const
uint64_t getScalarValueSizeInBits() const
unsigned getResNo() const
get the index which selects a specific result in the SDNode
MVT getSimpleValueType() const
Return the simple ValueType of the referenced return value.
unsigned getOpcode() const
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
LLVM_ABI SDValue getShiftAmountOperand(EVT LHSTy, SDValue Op)
Return the specified value casted to the target's desired shift amount type.
const SDValue & getRoot() const
Return the root tag of the SelectionDAG.
bool isKnownNeverSNaN(SDValue Op, const APInt &DemandedElts, unsigned Depth=0) const
const TargetSubtargetInfo & getSubtarget() const
SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, Register Reg, SDValue N)
LLVM_ABI SDValue getMergeValues(ArrayRef< SDValue > Ops, const SDLoc &dl)
Create a MERGE_VALUES node from the given operands.
LLVM_ABI SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
LLVM_ABI SDValue getShiftAmountConstant(uint64_t Val, EVT VT, const SDLoc &DL)
LLVM_ABI SDValue getAllOnesConstant(const SDLoc &DL, EVT VT, bool IsTarget=false, bool IsOpaque=false)
LLVM_ABI SDValue getFreeze(SDValue V)
Return a freeze using the SDLoc of the value operand.
LLVM_ABI SDValue getConstantPool(const Constant *C, EVT VT, MaybeAlign Align=std::nullopt, int Offs=0, bool isT=false, unsigned TargetFlags=0)
LLVM_ABI 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.
LLVM_ABI SDValue UnrollVectorOp(SDNode *N, unsigned ResNE=0)
Utility function used by legalize and lowering to "unroll" a vector operation by splitting out the sc...
LLVM_ABI SDValue getConstantFP(double Val, const SDLoc &DL, EVT VT, bool isTarget=false)
Create a ConstantFPSDNode wrapping a constant value.
SDValue getSetCC(const SDLoc &DL, EVT VT, SDValue LHS, SDValue RHS, ISD::CondCode Cond, SDValue Chain=SDValue(), bool IsSignaling=false, SDNodeFlags Flags={})
Helper function to make it easier to build SetCC's if you just have an ISD::CondCode instead of an SD...
LLVM_ABI 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.
LLVM_ABI bool shouldOptForSize() const
bool hasSwiftErrorArg() const
LLVM_ABI SDValue getNOT(const SDLoc &DL, SDValue Val, EVT VT)
Create a bitwise NOT operation as (XOR Val, -1).
const TargetLowering & getTargetLoweringInfo() const
LLVM_ABI SDValue expandVACopy(SDNode *Node)
Expand the specified ISD::VACOPY node as the Legalize pass would.
allnodes_const_iterator allnodes_begin() const
SDValue getUNDEF(EVT VT)
Return an UNDEF node. UNDEF does not have a useful SDLoc.
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).
SDValue getBuildVector(EVT VT, const SDLoc &DL, ArrayRef< SDValue > Ops)
Return an ISD::BUILD_VECTOR node.
allnodes_const_iterator allnodes_end() const
LLVM_ABI void DeleteNode(SDNode *N)
Remove the specified node from the system.
LLVM_ABI SDValue getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, SDValue Offset, MachinePointerInfo PtrInfo, EVT SVT, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
SDValue getCopyFromReg(SDValue Chain, const SDLoc &dl, Register Reg, EVT VT)
SDValue getSelect(const SDLoc &DL, EVT VT, SDValue Cond, SDValue LHS, SDValue RHS, SDNodeFlags Flags=SDNodeFlags())
Helper function to make it easier to build Select's if you just have operands and don't want to check...
LLVM_ABI SDValue getZeroExtendInReg(SDValue Op, const SDLoc &DL, EVT VT)
Return the expression required to zero extend the Op value assuming it was the smaller SrcTy value.
const DataLayout & getDataLayout() const
LLVM_ABI SDValue expandVAArg(SDNode *Node)
Expand the specified ISD::VAARG node as the Legalize pass would.
LLVM_ABI void Legalize()
This transforms the SelectionDAG into a SelectionDAG that is compatible with the target instruction s...
LLVM_ABI SDValue getTokenFactor(const SDLoc &DL, SmallVectorImpl< SDValue > &Vals)
Creates a new TokenFactor containing Vals.
LLVM_ABI SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
Helper function to build ISD::STORE nodes.
LLVM_ABI bool LegalizeOp(SDNode *N, SmallSetVector< SDNode *, 16 > &UpdatedNodes)
Transforms a SelectionDAG node and any operands to it into a node that is compatible with the target ...
LLVM_ABI SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
LLVM_ABI SDValue getMemBasePlusOffset(SDValue Base, TypeSize Offset, const SDLoc &DL, const SDNodeFlags Flags=SDNodeFlags())
Returns sum of the base pointer and offset.
LLVM_ABI 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.
LLVM_ABI void ReplaceAllUsesWith(SDValue From, SDValue To)
Modify anything using 'From' to use 'To' instead.
LLVM_ABI SDValue getExtLoad(ISD::LoadExtType ExtType, const SDLoc &dl, EVT VT, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, EVT MemVT, MaybeAlign Alignment=MaybeAlign(), MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
LLVM_ABI SDValue makeStateFunctionCall(unsigned LibFunc, SDValue Ptr, SDValue InChain, const SDLoc &DLoc)
Helper used to make a call to a library function that has one argument of pointer type.
LLVM_ABI SDValue getSignedConstant(int64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
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 ...
LLVM_ABI void RemoveDeadNodes()
This method deletes all unreachable nodes in the SelectionDAG.
SDValue getSelectCC(const SDLoc &DL, SDValue LHS, SDValue RHS, SDValue True, SDValue False, ISD::CondCode Cond, SDNodeFlags Flags=SDNodeFlags())
Helper function to make it easier to build SelectCC's if you just have an ISD::CondCode instead of an...
LLVM_ABI 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...
LLVM_ABI SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, MaybeAlign Alignment=MaybeAlign(), MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
Loads are not normal binary operators: their result type is not determined by their operands,...
LLVM_ABI SDValue getBoolExtOrTrunc(SDValue Op, const SDLoc &SL, EVT VT, EVT OpVT)
Convert Op, which must be of integer type, to the integer type VT, by using an extension appropriate ...
LLVM_ABI SDValue getExternalSymbol(const char *Sym, EVT VT)
const TargetMachine & getTarget() const
LLVM_ABI std::pair< SDValue, SDValue > getStrictFPExtendOrRound(SDValue Op, SDValue Chain, const SDLoc &DL, EVT VT)
Convert Op, which must be a STRICT operation of float type, to the float type VT, by either extending...
LLVM_ABI 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...
const LibcallLoweringInfo & getLibcalls() const
LLVM_ABI SDValue getIntPtrConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
LLVM_ABI SDValue getValueType(EVT)
LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
LLVM_ABI 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...
LLVM_ABI unsigned AssignTopologicalOrder()
Topological-sort the AllNodes list and a assign a unique node id for each node in the DAG based on th...
const TargetLibraryInfo & getLibInfo() const
LLVM_ABI SDValue getBoolConstant(bool V, const SDLoc &DL, EVT VT, EVT OpVT)
Create a true or false constant of type VT using the target's BooleanContent for type OpVT.
LLVM_ABI SDValue getVectorIdxConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
LLVM_ABI void ReplaceAllUsesOfValueWith(SDValue From, SDValue To)
Replace any uses of From with To, leaving uses of other values produced by From.getNode() alone.
MachineFunction & getMachineFunction() const
SDValue getPOISON(EVT VT)
Return a POISON node. POISON does not have a useful SDLoc.
SDValue getSplatBuildVector(EVT VT, const SDLoc &DL, SDValue Op)
Return a splat ISD::BUILD_VECTOR node, consisting of Op splatted to all elements.
LLVM_ABI SDValue getFrameIndex(int FI, EVT VT, bool isTarget=false)
LLVM_ABI 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...
LLVM_ABI SDValue getCondCode(ISD::CondCode Cond)
SDValue getObjectPtrOffset(const SDLoc &SL, SDValue Ptr, TypeSize Offset)
Create an add instruction with appropriate flags when used for addressing some offset of an object.
LLVMContext * getContext() const
LLVM_ABI SDValue CreateStackTemporary(TypeSize Bytes, Align Alignment)
Create a stack temporary based on the size in bytes and the alignment.
LLVM_ABI SDNode * UpdateNodeOperands(SDNode *N, SDValue Op)
Mutate the specified node in-place to have the specified operands.
SDValue getEntryNode() const
Return the token chain corresponding to the entry of the function.
LLVM_ABI SDValue getVectorShuffle(EVT VT, const SDLoc &dl, SDValue N1, SDValue N2, ArrayRef< int > Mask)
Return an ISD::VECTOR_SHUFFLE node.
LLVM_ABI SDValue getLogicalNOT(const SDLoc &DL, SDValue Val, EVT VT)
Create a logical NOT operation as (XOR Val, BooleanOne).
bool insert(const value_type &X)
Insert a new element into the SetVector.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
bool erase(PtrType Ptr)
Remove pointer from the set.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
A SetVector that performs no allocations if smaller than a certain size.
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void reserve(size_type N)
void swap(SmallVectorImpl &RHS)
void push_back(const T &Elt)
pointer data()
Return a pointer to the vector's buffer, even if empty().
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This class is used to represent ISD::STORE nodes.
Align getStackAlign() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
StackDirection getStackGrowthDirection() const
getStackGrowthDirection - Return the direction the stack grows
unsigned getIntSize() const
Get size of a C-level int or unsigned int, in bits.
bool isOperationExpand(unsigned Op, EVT VT) const
Return true if the specified operation is illegal on this target or unlikely to be made legal with cu...
virtual bool isShuffleMaskLegal(ArrayRef< int >, EVT) const
Targets can use this to indicate that they only support some VECTOR_SHUFFLE operations,...
virtual bool shouldExpandBuildVectorWithShuffles(EVT, unsigned DefinedValues) const
virtual bool isSExtCheaperThanZExt(EVT FromTy, EVT ToTy) const
Return true if sign-extension from FromTy to ToTy is cheaper than zero-extension.
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...
bool isOperationLegalOrPromote(unsigned Op, EVT VT, bool LegalOnly=false) const
Return true if the specified operation is legal on this target or can be made legal using promotion.
MVT getRegisterType(LLVMContext &Context, EVT VT) const
Return the type of registers that this ValueType will eventually require.
LegalizeAction getCondCodeAction(ISD::CondCode CC, MVT VT) const
Return how the condition code should be treated: either it is legal, needs to be expanded to some oth...
virtual bool isFPImmLegal(const APFloat &, EVT, bool ForCodeSize=false) const
Returns true if the target can instruction select the specified FP immediate natively.
LegalizeAction getTruncStoreAction(EVT ValVT, EVT MemVT, Align Alignment, unsigned AddrSpace) const
Return how this store with truncation should be treated: either it is legal, needs to be promoted to ...
Register getStackPointerRegisterToSaveRestore() const
If a physical register, this specifies the register that llvm.savestack/llvm.restorestack should save...
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.
virtual ISD::NodeType getExtendForAtomicOps() const
Returns how the platform's atomic operations are extended (ZERO_EXTEND, SIGN_EXTEND,...
EVT getShiftAmountTy(EVT LHSTy, const DataLayout &DL) const
Returns the type for the shift amount of a shift opcode.
bool isStrictFPEnabled() const
Return true if the target support strict float operation.
virtual EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context, EVT VT) const
Return the ValueType of the result of SETCC operations.
virtual EVT getTypeToTransformTo(LLVMContext &Context, EVT VT) const
For types supported by the target, this is an identity function.
LegalizeAction getVectorInterleaveAction(unsigned Opc, unsigned Factor, EVT VT) const
Return how a VECTOR_INTERLEAVE or VECTOR_DEINTERLEAVE node with the given interleave factor and VT sh...
bool isCondCodeLegal(ISD::CondCode CC, MVT VT) const
Return true if the specified condition code is legal for a comparison of the specified types on this ...
bool isTypeLegal(EVT VT) const
Return true if the target has native support for the specified value type.
MVT getProgramPointerTy(const DataLayout &DL) const
Return the type for code pointers, which is determined by the program address space specified through...
virtual bool isJumpTableRelative() const
virtual bool ShouldShrinkFPConstant(EVT) const
If true, then instruction selection should seek to shrink the FP constant of the specified type to a ...
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...
bool isOperationLegal(unsigned Op, EVT VT) const
Return true if the specified operation is legal on this target.
bool isOperationLegalOrCustom(unsigned Op, EVT VT, bool LegalOnly=false) const
Return true if the specified operation is legal on this target or can be made legal with custom lower...
virtual bool allowsMemoryAccess(LLVMContext &Context, const DataLayout &DL, EVT VT, unsigned AddrSpace=0, Align Alignment=Align(1), MachineMemOperand::Flags Flags=MachineMemOperand::MONone, unsigned *Fast=nullptr) const
Return true if the target supports a memory access of this type for the given address space and align...
virtual LegalizeAction getCustomOperationAction(SDNode &Op) const
How to legalize this custom operation?
LegalizeAction getLoadAction(EVT ValVT, EVT MemVT, Align Alignment, unsigned AddrSpace, unsigned ExtType, bool Atomic) const
Return how this load with extension should be treated: either it is legal, needs to be promoted to a ...
LegalizeAction getStrictFPOperationAction(unsigned Op, EVT VT) const
virtual bool useSoftFloat() const
LegalizeTypeAction getTypeAction(LLVMContext &Context, EVT VT) const
Return how we should legalize values of this type, either it is already legal (return 'Legal') or we ...
virtual bool shouldSignExtendTypeInLibCall(Type *Ty, bool IsSigned) const
Returns true if arguments should be sign-extended in lib calls.
std::vector< ArgListEntry > ArgListTy
bool allowsMemoryAccessForAlignment(LLVMContext &Context, const DataLayout &DL, EVT VT, unsigned AddrSpace=0, Align Alignment=Align(1), MachineMemOperand::Flags Flags=MachineMemOperand::MONone, unsigned *Fast=nullptr) const
This function returns true if the memory access is aligned or if the target allows this specific unal...
bool isTruncStoreLegalOrCustom(EVT ValVT, EVT MemVT, Align Alignment, unsigned AddrSpace) const
Return true if the specified store with truncation has solution on this target.
bool isCondCodeLegalOrCustom(ISD::CondCode CC, MVT VT) const
Return true if the specified condition code is legal or custom for a comparison of the specified type...
MVT getFrameIndexTy(const DataLayout &DL) const
Return the type for frame index, which is determined by the alloca address space specified through th...
bool isLoadLegal(EVT ValVT, EVT MemVT, Align Alignment, unsigned AddrSpace, unsigned ExtType, bool Atomic) const
Return true if the specified load with extension is legal on this target.
bool isLoadLegalOrCustom(EVT ValVT, EVT MemVT, Align Alignment, unsigned AddrSpace, unsigned ExtType, bool Atomic) const
Return true if the specified load with extension is legal or custom on this target.
LegalizeAction getOperationAction(unsigned Op, EVT VT) const
Return how this operation should be treated: either it is legal, needs to be promoted to a larger siz...
MVT getTypeToPromoteTo(unsigned Op, MVT VT) const
If the action for this operation is to promote, this method returns the ValueType to promote to.
const RTLIB::RuntimeLibcallsInfo & getRuntimeLibcallsInfo() const
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
SDValue expandAddSubSat(SDNode *Node, SelectionDAG &DAG) const
Method for building the DAG expansion of ISD::[US][ADD|SUB]SAT.
bool expandMultipleResultFPLibCall(SelectionDAG &DAG, RTLIB::Libcall LC, SDNode *Node, SmallVectorImpl< SDValue > &Results, std::optional< unsigned > CallRetResNo={}) const
Expands a node with multiple results to an FP or vector libcall.
bool expandMULO(SDNode *Node, SDValue &Result, SDValue &Overflow, SelectionDAG &DAG) const
Method for building the DAG expansion of ISD::[US]MULO.
bool expandMUL(SDNode *N, SDValue &Lo, SDValue &Hi, EVT HiLoVT, SelectionDAG &DAG, MulExpansionKind Kind, SDValue LL=SDValue(), SDValue LH=SDValue(), SDValue RL=SDValue(), SDValue RH=SDValue()) const
Expand a MUL into two nodes.
bool LegalizeSetCCCondCode(SelectionDAG &DAG, EVT VT, SDValue &LHS, SDValue &RHS, SDValue &CC, bool &NeedInvert, const SDLoc &dl, SDValue &Chain, bool IsSignaling=false) const
Legalize a SETCC with given LHS and RHS and condition code CC on the current target.
SDValue expandFCANONICALIZE(SDNode *Node, SelectionDAG &DAG) const
Expand FCANONICALIZE to FMUL with 1.
SDValue expandCTLZ(SDNode *N, SelectionDAG &DAG) const
Expand CTLZ/CTLZ_ZERO_POISON nodes.
SDValue expandBITREVERSE(SDNode *N, SelectionDAG &DAG) const
Expand BITREVERSE nodes.
SDValue expandCTTZ(SDNode *N, SelectionDAG &DAG) const
Expand CTTZ/CTTZ_ZERO_POISON nodes.
virtual SDValue expandIndirectJTBranch(const SDLoc &dl, SDValue Value, SDValue Addr, int JTI, SelectionDAG &DAG) const
Expands target specific indirect branch for the case of JumpTable expansion.
SDValue expandABD(SDNode *N, SelectionDAG &DAG) const
Expand ABDS/ABDU nodes.
SDValue expandCLMUL(SDNode *N, SelectionDAG &DAG) const
Expand carryless multiply.
SDValue expandShlSat(SDNode *Node, SelectionDAG &DAG) const
Method for building the DAG expansion of ISD::[US]SHLSAT.
SDValue expandIS_FPCLASS(EVT ResultVT, SDValue Op, FPClassTest Test, SDNodeFlags Flags, const SDLoc &DL, SelectionDAG &DAG) const
Expand check for floating point class.
SDValue expandFP_TO_INT_SAT(SDNode *N, SelectionDAG &DAG) const
Expand FP_TO_[US]INT_SAT into FP_TO_[US]INT and selects or min/max.
SDValue expandUnalignedStore(StoreSDNode *ST, SelectionDAG &DAG) const
Expands an unaligned store to 2 half-size stores for integer values, and possibly more for vectors.
void expandSADDSUBO(SDNode *Node, SDValue &Result, SDValue &Overflow, SelectionDAG &DAG) const
Method for building the DAG expansion of ISD::S(ADD|SUB)O.
SDValue expandABS(SDNode *N, SelectionDAG &DAG, bool IsNegative=false) const
Expand ABS nodes.
SDValue expandVecReduce(SDNode *Node, SelectionDAG &DAG) const
Expand a VECREDUCE_* into an explicit calculation.
SDValue expandVPCTTZElements(SDNode *N, SelectionDAG &DAG) const
Expand VP_CTTZ_ELTS/VP_CTTZ_ELTS_ZERO_POISON nodes.
bool expandFP_TO_UINT(SDNode *N, SDValue &Result, SDValue &Chain, SelectionDAG &DAG) const
Expand float to UINT conversion.
bool expandREM(SDNode *Node, SDValue &Result, SelectionDAG &DAG) const
Expand an SREM or UREM using SDIV/UDIV or SDIVREM/UDIVREM, if legal.
std::pair< SDValue, SDValue > expandUnalignedLoad(LoadSDNode *LD, SelectionDAG &DAG) const
Expands an unaligned load to 2 half-size loads for an integer, and possibly more for vectors.
SDValue expandFMINIMUMNUM_FMAXIMUMNUM(SDNode *N, SelectionDAG &DAG) const
Expand fminimumnum/fmaximumnum into multiple comparison with selects.
SDValue expandVectorSplice(SDNode *Node, SelectionDAG &DAG) const
Method for building the DAG expansion of ISD::VECTOR_SPLICE.
SDValue getVectorSubVecPointer(SelectionDAG &DAG, SDValue VecPtr, EVT VecVT, EVT SubVecVT, SDValue Index, const SDNodeFlags PtrArithFlags=SDNodeFlags()) const
Get a pointer to a sub-vector of type SubVecVT at index Idx located in memory for a vector of type Ve...
SDValue expandCTPOP(SDNode *N, SelectionDAG &DAG) const
Expand CTPOP nodes.
std::pair< SDValue, SDValue > LowerCallTo(CallLoweringInfo &CLI) const
This function lowers an abstract call to a function into an actual call.
SDValue expandBSWAP(SDNode *N, SelectionDAG &DAG) const
Expand BSWAP nodes.
SDValue expandFMINIMUM_FMAXIMUM(SDNode *N, SelectionDAG &DAG) const
Expand fminimum/fmaximum into multiple comparison with selects.
bool expandFP_TO_SINT(SDNode *N, SDValue &Result, SelectionDAG &DAG) const
Expand float(f32) to SINT(i64) conversion.
virtual SDValue getPICJumpTableRelocBase(SDValue Table, SelectionDAG &DAG) const
Returns relocation base for the given PIC jumptable.
bool isInTailCallPosition(SelectionDAG &DAG, SDNode *Node, SDValue &Chain) const
Check whether a given call node is in tail position within its function.
SDValue expandCONVERT_TO_ARBITRARY_FP(SDNode *Node, SelectionDAG &DAG) const
Expand CONVERT_TO_ARBITRARY_FP using bit manipulation.
SDValue expandFunnelShift(SDNode *N, SelectionDAG &DAG) const
Expand funnel shift.
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...
SDValue expandFixedPointDiv(unsigned Opcode, const SDLoc &dl, SDValue LHS, SDValue RHS, unsigned Scale, SelectionDAG &DAG) const
Method for building the DAG expansion of ISD::[US]DIVFIX[SAT].
SDValue expandPEXT(SDNode *N, SelectionDAG &DAG) const
Expand parallel bit extract (compress).
SDValue expandFP_ROUND(SDNode *Node, SelectionDAG &DAG) const
Expand round(fp) to fp conversion.
SDValue expandCONVERT_FROM_ARBITRARY_FP(SDNode *Node, SelectionDAG &DAG) const
Expand CONVERT_FROM_ARBITRARY_FP using bit manipulation.
SDValue expandROT(SDNode *N, bool AllowVectorOps, SelectionDAG &DAG) const
Expand rotations.
SDValue getVectorElementPointer(SelectionDAG &DAG, SDValue VecPtr, EVT VecVT, SDValue Index, const SDNodeFlags PtrArithFlags=SDNodeFlags()) const
Get a pointer to vector element Idx located in memory for a vector of type VecVT starting at a base a...
SDValue expandFMINNUM_FMAXNUM(SDNode *N, SelectionDAG &DAG) const
Expand fminnum/fmaxnum into fminnum_ieee/fmaxnum_ieee with quieted inputs.
std::pair< SDValue, SDValue > makeLibCall(SelectionDAG &DAG, RTLIB::LibcallImpl LibcallImpl, EVT RetVT, ArrayRef< SDValue > Ops, MakeLibCallOptions CallOptions, const SDLoc &dl, SDValue Chain=SDValue()) const
Returns a pair of (return value, chain).
SDValue expandCMP(SDNode *Node, SelectionDAG &DAG) const
Method for building the DAG expansion of ISD::[US]CMP.
SDValue expandFixedPointMul(SDNode *Node, SelectionDAG &DAG) const
Method for building the DAG expansion of ISD::[U|S]MULFIX[SAT].
void expandUADDSUBO(SDNode *Node, SDValue &Result, SDValue &Overflow, SelectionDAG &DAG) const
Method for building the DAG expansion of ISD::U(ADD|SUB)O.
SDValue expandPDEP(SDNode *N, SelectionDAG &DAG) const
Expand parallel bit deposit (expand).
bool expandUINT_TO_FP(SDNode *N, SDValue &Result, SDValue &Chain, SelectionDAG &DAG) const
Expand UINT(i64) to double(f64) conversion.
bool expandMUL_LOHI(unsigned Opcode, EVT VT, const SDLoc &dl, SDValue LHS, SDValue RHS, SmallVectorImpl< SDValue > &Result, EVT HiLoVT, SelectionDAG &DAG, MulExpansionKind Kind, SDValue LL=SDValue(), SDValue LH=SDValue(), SDValue RL=SDValue(), SDValue RH=SDValue()) const
Expand a MUL or [US]MUL_LOHI of n-bit values into two or four nodes, respectively,...
SDValue expandAVG(SDNode *N, SelectionDAG &DAG) const
Expand vector/scalar AVGCEILS/AVGCEILU/AVGFLOORS/AVGFLOORU nodes.
SDValue expandCTLS(SDNode *N, SelectionDAG &DAG) const
Expand CTLS (count leading sign bits) nodes.
Primary interface to the complete machine description for the target machine.
const Triple & getTargetTriple() const
virtual const TargetFrameLowering * getFrameLowering() const
static constexpr TypeSize getFixed(ScalarTy ExactSize)
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
bool isVoidTy() const
Return true if this is 'void'.
static LLVM_ABI UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
LLVM Value Representation.
constexpr ScalarTy getFixedValue() const
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
@ SETCC
SetCC operator - This evaluates to a true value iff the condition is true.
@ MERGE_VALUES
MERGE_VALUES - This node takes multiple discrete operands and returns them all as its individual resu...
@ STACKRESTORE
STACKRESTORE has two operands, an input chain and a pointer to restore to it returns an output chain.
@ STACKSAVE
STACKSAVE - STACKSAVE has one operand, an input chain.
@ STRICT_FSETCC
STRICT_FSETCC/STRICT_FSETCCS - Constrained versions of SETCC, used for floating-point operands only.
@ POISON
POISON - A poison node.
@ SET_FPENV
Sets the current floating-point environment.
@ VECREDUCE_SEQ_FADD
Generic reduction nodes.
@ EH_SJLJ_LONGJMP
OUTCHAIN = EH_SJLJ_LONGJMP(INCHAIN, buffer) This corresponds to the eh.sjlj.longjmp intrinsic.
@ SMUL_LOHI
SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing a signed/unsigned value of type i[2...
@ INSERT_SUBVECTOR
INSERT_SUBVECTOR(VECTOR1, VECTOR2, IDX) - Returns a vector with VECTOR2 inserted into VECTOR1.
@ STACKADDRESS
STACKADDRESS - Represents the llvm.stackaddress intrinsic.
@ BSWAP
Byte Swap and Counting operators.
@ SMULFIX
RESULT = [US]MULFIX(LHS, RHS, SCALE) - Perform fixed point multiplication on 2 integers with the same...
@ VAEND
VAEND, VASTART - VAEND and VASTART have three operands: an input chain, pointer, and a SRCVALUE.
@ ATOMIC_STORE
OUTCHAIN = ATOMIC_STORE(INCHAIN, val, ptr) This corresponds to "store atomic" instruction.
@ FRAME_TO_ARGS_OFFSET
FRAME_TO_ARGS_OFFSET - This node represents offset from frame pointer to first (possible) on-stack ar...
@ RESET_FPENV
Set floating-point environment to default state.
@ FMAD
FMAD - Perform a * b + c, while getting the same result as the separately rounded operations.
@ ADD
Simple integer binary arithmetic operators.
@ LOAD
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
@ SMULFIXSAT
Same as the corresponding unsaturated fixed point instructions, but the result is clamped between the...
@ SET_FPMODE
Sets the current dynamic floating-point control modes.
@ ANY_EXTEND
ANY_EXTEND - Used for integer types. The high bits are undefined.
@ CTTZ_ELTS
Returns the number of number of trailing (least significant) zero elements in a vector.
@ FMA
FMA - Perform a * b + c with no intermediate rounding step.
@ FMODF
FMODF - Decomposes the operand into integral and fractional parts, each having the same type and sign...
@ FATAN2
FATAN2 - atan2, inspired by libm.
@ FSINCOSPI
FSINCOSPI - Compute both the sine and cosine times pi more accurately than FSINCOS(pi*x),...
@ INTRINSIC_VOID
OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...) This node represents a target intrin...
@ EH_SJLJ_SETUP_DISPATCH
OUTCHAIN = EH_SJLJ_SETUP_DISPATCH(INCHAIN) The target initializes the dispatch table here.
@ ATOMIC_CMP_SWAP_WITH_SUCCESS
Val, Success, OUTCHAIN = ATOMIC_CMP_SWAP_WITH_SUCCESS(INCHAIN, ptr, cmp, swap) N.b.
@ SINT_TO_FP
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
@ CONCAT_VECTORS
CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of vector type with the same length ...
@ VECREDUCE_FMAX
FMIN/FMAX nodes can have flags, for NaN/NoNaN variants.
@ FADD
Simple binary floating point operators.
@ VECREDUCE_FMAXIMUM
FMINIMUM/FMAXIMUM nodes propatate NaNs and signed zeroes using the llvm.minimum and llvm....
@ ABS
ABS - Determine the unsigned absolute value of a signed integer value of the same bitwidth.
@ ATOMIC_FENCE
OUTCHAIN = ATOMIC_FENCE(INCHAIN, ordering, scope) This corresponds to the fence instruction.
@ RESET_FPMODE
Sets default dynamic floating-point control modes.
@ SDIVREM
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
@ FP16_TO_FP
FP16_TO_FP, FP_TO_FP16 - These operators are used to perform promotions and truncation for half-preci...
@ BITCAST
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
@ BUILD_PAIR
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
@ CLMUL
Carry-less multiplication operations.
@ INIT_TRAMPOLINE
INIT_TRAMPOLINE - This corresponds to the init_trampoline intrinsic.
@ FLDEXP
FLDEXP - ldexp, inspired by libm (op0 * 2**op1).
@ SDIVFIX
RESULT = [US]DIVFIX(LHS, RHS, SCALE) - Perform fixed point division on 2 integers with the same width...
@ STRICT_FSQRT
Constrained versions of libm-equivalent floating point intrinsics.
@ BUILTIN_OP_END
BUILTIN_OP_END - This must be the last enum value in this list.
@ CONVERT_FROM_ARBITRARY_FP
CONVERT_FROM_ARBITRARY_FP - This operator converts from an arbitrary floating-point represented as an...
@ EH_LABEL
EH_LABEL - Represents a label in mid basic block used to track locations needed for debug and excepti...
@ EH_RETURN
OUTCHAIN = EH_RETURN(INCHAIN, OFFSET, HANDLER) - This node represents 'eh_return' gcc dwarf builtin,...
@ SIGN_EXTEND
Conversion operators.
@ AVGCEILS
AVGCEILS/AVGCEILU - Rounding averaging add - Add two integers using an integer of type i[N+2],...
@ SCALAR_TO_VECTOR
SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a scalar value into element 0 of the...
@ READSTEADYCOUNTER
READSTEADYCOUNTER - This corresponds to the readfixedcounter intrinsic.
@ ADDROFRETURNADDR
ADDROFRETURNADDR - Represents the llvm.addressofreturnaddress intrinsic.
@ VECREDUCE_FADD
These reductions have relaxed evaluation order semantics, and have a single vector operand.
@ PREFETCH
PREFETCH - This corresponds to a prefetch intrinsic.
@ VECREDUCE_FMAXIMUMNUM
FMINIMUMNUM/FMAXIMUMNUM nodes do not propagate NaNs and order signed zeroes using the llvm....
@ FSINCOS
FSINCOS - Compute both fsin and fcos as a single operation.
@ SETCCCARRY
Like SetCC, ops #0 and #1 are the LHS and RHS operands to compare, but op #2 is a boolean indicating ...
@ FNEG
Perform various unary floating-point operations inspired by libm.
@ BR_CC
BR_CC - Conditional branch.
@ SSUBO
Same for subtraction.
@ BR_JT
BR_JT - Jumptable branch.
@ VECTOR_INTERLEAVE
VECTOR_INTERLEAVE(VEC1, VEC2, ...) - Returns N vectors from N input vectors, where N is the factor to...
@ FCANONICALIZE
Returns platform specific canonical encoding of a floating point number.
@ IS_FPCLASS
Performs a check of floating point class property, defined by IEEE-754.
@ SSUBSAT
RESULT = [US]SUBSAT(LHS, RHS) - Perform saturation subtraction on 2 integers with the same bit width ...
@ SELECT
Select(COND, TRUEVAL, FALSEVAL).
@ ATOMIC_LOAD
Val, OUTCHAIN = ATOMIC_LOAD(INCHAIN, ptr) This corresponds to "load atomic" instruction.
@ UNDEF
UNDEF - An undefined node.
@ EXTRACT_ELEMENT
EXTRACT_ELEMENT - This is used to get the lower or upper (determined by a Constant,...
@ SPLAT_VECTOR
SPLAT_VECTOR(VAL) - Returns a vector with the scalar value VAL duplicated in all lanes.
@ VACOPY
VACOPY - VACOPY has 5 operands: an input chain, a destination pointer, a source pointer,...
@ SADDO
RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
@ CTLS
Count leading redundant sign bits.
@ VECREDUCE_ADD
Integer reductions may have a result type larger than the vector element type.
@ GET_ROUNDING
Returns current rounding mode: -1 Undefined 0 Round to 0 1 Round to nearest, ties to even 2 Round to ...
@ MULHU
MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing an unsigned/signed value of...
@ GET_FPMODE
Reads the current dynamic floating-point control modes.
@ SHL
Shift and rotation operations.
@ VECTOR_SHUFFLE
VECTOR_SHUFFLE(VEC1, VEC2) - Returns a vector, of the same type as VEC1/VEC2.
@ EXTRACT_SUBVECTOR
EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR.
@ READ_REGISTER
READ_REGISTER, WRITE_REGISTER - This node represents llvm.register on the DAG, which implements the n...
@ EXTRACT_VECTOR_ELT
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
@ ZERO_EXTEND
ZERO_EXTEND - Used for integer types, zeroing the new bits.
@ DEBUGTRAP
DEBUGTRAP - Trap intended to get the attention of a debugger.
@ SELECT_CC
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
@ ATOMIC_CMP_SWAP
Val, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap) For double-word atomic operations: ValLo,...
@ FMINNUM
FMINNUM/FMAXNUM - Perform floating-point minimum maximum on two values, following IEEE-754 definition...
@ UBSANTRAP
UBSANTRAP - Trap with an immediate describing the kind of sanitizer failure.
@ SSHLSAT
RESULT = [US]SHLSAT(LHS, RHS) - Perform saturation left shift.
@ SMULO
Same for multiplication.
@ DYNAMIC_STACKALLOC
DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned to a specified boundary.
@ VECTOR_SPLICE_LEFT
VECTOR_SPLICE_LEFT(VEC1, VEC2, OFFSET) - Shifts CONCAT_VECTORS(VEC1, VEC2) left by OFFSET elements an...
@ SIGN_EXTEND_INREG
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
@ SMIN
[US]{MIN/MAX} - Binary minimum or maximum of signed or unsigned integers.
@ SDIVFIXSAT
Same as the corresponding unsaturated fixed point instructions, but the result is clamped between the...
@ FP_EXTEND
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
@ GLOBAL_OFFSET_TABLE
The address of the GOT.
@ UADDO_CARRY
Carry-using nodes for multiple precision addition and subtraction.
@ STRICT_SINT_TO_FP
STRICT_[US]INT_TO_FP - Convert a signed or unsigned integer to a floating point value.
@ EH_DWARF_CFA
EH_DWARF_CFA - This node represents the pointer to the DWARF Canonical Frame Address (CFA),...
@ BF16_TO_FP
BF16_TO_FP, FP_TO_BF16 - These operators are used to perform promotions and truncation for bfloat16.
@ FRAMEADDR
FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and llvm.returnaddress on the DAG.
@ PEXT
Parallel bit extract (compress) and parallel bit deposit (expand).
@ STRICT_FP_ROUND
X = STRICT_FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type down to the precision ...
@ STRICT_FP_TO_SINT
STRICT_FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ FMINIMUM
FMINIMUM/FMAXIMUM - NaN-propagating minimum/maximum that also treat -0.0 as less than 0....
@ FP_TO_SINT
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ READCYCLECOUNTER
READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
@ TargetConstant
TargetConstant* - Like Constant*, but the DAG does not do any folding, simplification,...
@ STRICT_FP_EXTEND
X = STRICT_FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
@ AND
Bitwise operators - logical and, logical or, logical xor.
@ TRAP
TRAP - Trapping instruction.
@ INTRINSIC_WO_CHAIN
RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) This node represents a target intrinsic fun...
@ GET_FPENV_MEM
Gets the current floating-point environment.
@ SCMP
[US]CMP - 3-way comparison of signed or unsigned integers.
@ AVGFLOORS
AVGFLOORS/AVGFLOORU - Averaging add - Add two integers using an integer of type i[N+1],...
@ VECTOR_SPLICE_RIGHT
VECTOR_SPLICE_RIGHT(VEC1, VEC2, OFFSET) - Shifts CONCAT_VECTORS(VEC1,VEC2) right by OFFSET elements a...
@ STRICT_FADD
Constrained versions of the binary floating point operators.
@ INSERT_VECTOR_ELT
INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element at IDX replaced with VAL.
@ TokenFactor
TokenFactor - This node takes multiple tokens as input and produces a single token result.
@ ATOMIC_SWAP
Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt) Val, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN,...
@ CTTZ_ZERO_POISON
Bit counting operators with a poisoned result for zero inputs.
@ FFREXP
FFREXP - frexp, extract fractional and exponent component of a floating-point value.
@ FP_ROUND
X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type down to the precision of the ...
@ SPONENTRY
SPONENTRY - Represents the llvm.sponentry intrinsic.
@ CLEAR_CACHE
llvm.clear_cache intrinsic Operands: Input Chain, Start Addres, End Address Outputs: Output Chain
@ ADDRSPACECAST
ADDRSPACECAST - This operator converts between pointers of different address spaces.
@ EXPERIMENTAL_VECTOR_HISTOGRAM
Experimental vector histogram intrinsic Operands: Input Chain, Inc, Mask, Base, Index,...
@ FP_TO_SINT_SAT
FP_TO_[US]INT_SAT - Convert floating point value in operand 0 to a signed or unsigned scalar integer ...
@ EH_SJLJ_SETJMP
RESULT, OUTCHAIN = EH_SJLJ_SETJMP(INCHAIN, buffer) This corresponds to the eh.sjlj....
@ TRUNCATE
TRUNCATE - Completely drop the high bits.
@ VAARG
VAARG - VAARG has four operands: an input chain, a pointer, a SRCVALUE, and the alignment.
@ BRCOND
BRCOND - Conditional branch.
@ CONVERT_TO_ARBITRARY_FP
CONVERT_TO_ARBITRARY_FP - Converts a native FP value to an arbitrary floating-point format,...
@ SHL_PARTS
SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded integer shift operations.
@ AssertSext
AssertSext, AssertZext - These nodes record if a register contains a value that has already been zero...
@ FCOPYSIGN
FCOPYSIGN(X, Y) - Return the value of X with the sign of Y.
@ SADDSAT
RESULT = [US]ADDSAT(LHS, RHS) - Perform saturation addition on 2 integers with the same bit width (W)...
@ CALLSEQ_START
CALLSEQ_START/CALLSEQ_END - These operators mark the beginning and end of a call sequence,...
@ VECTOR_DEINTERLEAVE
VECTOR_DEINTERLEAVE(VEC1, VEC2, ...) - Returns N vectors from N input vectors, where N is the factor ...
@ GET_DYNAMIC_AREA_OFFSET
GET_DYNAMIC_AREA_OFFSET - get offset from native SP to the address of the most recent dynamic alloca.
@ SET_FPENV_MEM
Sets the current floating point environment.
@ FMINIMUMNUM
FMINIMUMNUM/FMAXIMUMNUM - minimumnum/maximumnum that is same with FMINNUM_IEEE and FMAXNUM_IEEE besid...
@ ABDS
ABDS/ABDU - Absolute difference - Return the absolute difference between two numbers interpreted as s...
@ ADJUST_TRAMPOLINE
ADJUST_TRAMPOLINE - This corresponds to the adjust_trampoline intrinsic.
@ INTRINSIC_W_CHAIN
RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) This node represents a target in...
@ ABS_MIN_POISON
ABS with a poison result for INT_MIN.
@ BUILD_VECTOR
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a fixed-width vector with the specified,...
LLVM_ABI NodeType getExtForLoadExtType(bool IsFP, LoadExtType)
bool isNormalStore(const SDNode *N)
Returns true if the specified node is a non-truncating and unindexed store.
LLVM_ABI CondCode getSetCCInverse(CondCode Operation, EVT Type)
Return the operation corresponding to !(X op Y), where 'op' is a valid SetCC operation.
LLVM_ABI std::optional< unsigned > getVPMaskIdx(unsigned Opcode)
The operand position of the vector mask.
LLVM_ABI CondCode getSetCCSwappedOperands(CondCode Operation)
Return the operation corresponding to (Y op X) when given the operation for (X op Y).
bool isSignedIntSetCC(CondCode Code)
Return true if this is a setcc instruction that performs a signed comparison when used with integer o...
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
LLVM_ABI bool isVPOpcode(unsigned Opcode)
Whether this is a vector-predicated Opcode.
LLVM_ABI Libcall getSINTTOFP(EVT OpVT, EVT RetVT)
getSINTTOFP - Return the SINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getSYNC(unsigned Opc, MVT VT)
Return the SYNC_FETCH_AND_* value for the given opcode and type, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getUINTTOFP(EVT OpVT, EVT RetVT)
getUINTTOFP - Return the UINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getFPLibCall(EVT VT, Libcall Call_F32, Libcall Call_F64, Libcall Call_F80, Libcall Call_F128, Libcall Call_PPCF128)
GetFPLibCall - Helper to return the right libcall for the given floating point type,...
LLVM_ABI Libcall getFPTOUINT(EVT OpVT, EVT RetVT)
getFPTOUINT - Return the FPTOUINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getFPTOSINT(EVT OpVT, EVT RetVT)
getFPTOSINT - Return the FPTOSINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getOUTLINE_ATOMIC(unsigned Opc, AtomicOrdering Order, MVT VT)
Return the outline atomics value for the given opcode, atomic ordering and type, or UNKNOWN_LIBCALL i...
LLVM_ABI Libcall getFPEXT(EVT OpVT, EVT RetVT)
getFPEXT - Return the FPEXT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getFPROUND(EVT OpVT, EVT RetVT)
getFPROUND - Return the FPROUND_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract(Y &&MD)
Extract a Value from Metadata.
NodeAddr< NodeBase * > Node
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
unsigned Log2_32_Ceil(uint32_t Value)
Return the ceil log base 2 of the specified value, 32 if the value is zero.
@ Undef
Value of the register doesn't matter.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
@ Load
The value being inserted comes from a load (InsertElement only).
@ Store
The extracted value is stored (ExtractElement only).
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
APFloat scalbn(APFloat X, int Exp, APFloat::roundingMode RM)
Returns: X * 2^Exp for integral exponents.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI Constant * ConstantFoldCastOperand(unsigned Opcode, Constant *C, Type *DestTy, const DataLayout &DL)
Attempt to constant fold a cast with the specified operand.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
AtomicOrdering
Atomic ordering for LLVM's memory model.
To bit_cast(const From &from) noexcept
@ Or
Bitwise or logical OR of integers.
@ And
Bitwise or logical AND of integers.
@ Sub
Subtraction of integers.
@ Fast
Assign the register banks as fast as possible (default).
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI bool isOneConstant(SDValue V)
Returns true if V is a constant integer one.
Align commonAlignment(Align A, uint64_t Offset)
Returns the alignment that satisfies both alignments.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
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.
EVT changeTypeToInteger() const
Return the type converted to an equivalently sized integer or vector with integer element type.
bool bitsGT(EVT VT) const
Return true if this has more bits than VT.
bool bitsLT(EVT VT) const
Return true if this has less bits than VT.
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
bool isByteSized() const
Return true if the bit size is a multiple of 8.
uint64_t getScalarSizeInBits() const
EVT getHalfSizedIntegerVT(LLVMContext &Context) const
Finds the smallest simple value type that is greater than or equal to half the width of this EVT.
TypeSize getStoreSizeInBits() const
Return the number of bits overwritten by a store of the specified value type.
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)
Returns the EVT that represents an integer with the given number of bits.
bool isVector() const
Return true if this is a vector value type.
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
bool bitsGE(EVT VT) const
Return true if this has no less bits than VT.
bool bitsEq(EVT VT) const
Return true if this has the same number of bits as VT.
LLVM_ABI Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
bool isScalableVector() const
Return true if this is a vector type where the runtime length is machine dependent.
EVT getVectorElementType() const
Given a vector type, return the type of each element.
bool isScalarInteger() const
Return true if this is an integer, but not a vector.
LLVM_ABI const fltSemantics & getFltSemantics() const
Returns an APFloat semantics tag appropriate for the value type.
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
bool bitsLE(EVT VT) const
Return true if this has no more bits than VT.
bool isInteger() const
Return true if this is an integer or a vector integer type.
This class contains a discriminated union of information about pointers in memory operands,...
static LLVM_ABI MachinePointerInfo getJumpTable(MachineFunction &MF)
Return a MachinePointerInfo record that refers to a jump table entry.
LLVM_ABI unsigned getAddrSpace() const
Return the LLVM IR address space number that this pointer points into.
static LLVM_ABI MachinePointerInfo getConstantPool(MachineFunction &MF)
Return a MachinePointerInfo record that refers to the constant pool.
MachinePointerInfo getWithOffset(int64_t O) const
static LLVM_ABI MachinePointerInfo getUnknownStack(MachineFunction &MF)
Stack memory without other information.
static LLVM_ABI MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
CallingConv::ID getLibcallImplCallingConv(RTLIB::LibcallImpl Call) const
Get the CallingConv that should be used for the specified libcall.
LLVM_ABI std::pair< FunctionType *, AttributeList > getFunctionTy(LLVMContext &Ctx, const Triple &TT, const DataLayout &DL, RTLIB::LibcallImpl LibcallImpl) const
These are IR-level optimization flags that may be propagated to SDNodes.
void setNoUnsignedWrap(bool b)
void setNoSignedWrap(bool b)
bool IsPostTypeLegalization
MakeLibCallOptions & setIsSigned(bool Value=true)