58#define DEBUG_TYPE "legalizedag"
64struct FloatSignAsInt {
87class SelectionDAGLegalize {
99 EVT getSetCCResultType(
EVT VT)
const {
110 LegalizedNodes(LegalizedNodes), UpdatedNodes(UpdatedNodes) {}
131 std::pair<SDValue, SDValue> ExpandLibCall(RTLIB::Libcall LC,
SDNode *
Node,
133 bool IsSigned,
EVT RetVT);
134 std::pair<SDValue, SDValue> ExpandLibCall(RTLIB::Libcall LC,
SDNode *
Node,
bool isSigned);
136 void ExpandFPLibCall(
SDNode *
Node, RTLIB::Libcall LC,
138 void ExpandFPLibCall(
SDNode *
Node, RTLIB::Libcall Call_F32,
139 RTLIB::Libcall Call_F64, RTLIB::Libcall Call_F80,
140 RTLIB::Libcall Call_F128,
141 RTLIB::Libcall Call_PPCF128,
145 ExpandFastFPLibCall(
SDNode *
Node,
bool IsFast,
146 std::pair<RTLIB::Libcall, RTLIB::Libcall> Call_F32,
147 std::pair<RTLIB::Libcall, RTLIB::Libcall> Call_F64,
148 std::pair<RTLIB::Libcall, RTLIB::Libcall> Call_F80,
149 std::pair<RTLIB::Libcall, RTLIB::Libcall> Call_F128,
150 std::pair<RTLIB::Libcall, RTLIB::Libcall> Call_PPCF128,
154 RTLIB::Libcall Call_I16, RTLIB::Libcall Call_I32,
155 RTLIB::Libcall Call_I64, RTLIB::Libcall Call_I128);
157 RTLIB::Libcall Call_F32, RTLIB::Libcall Call_F64,
158 RTLIB::Libcall Call_F80, RTLIB::Libcall Call_F128,
159 RTLIB::Libcall Call_PPCF128,
162 RTLIB::Libcall CallI64,
163 RTLIB::Libcall CallI128);
177 void getSignAsIntValue(FloatSignAsInt &State,
const SDLoc &
DL,
179 SDValue modifySignAsInt(
const FloatSignAsInt &State,
const SDLoc &
DL,
227 dbgs() <<
" with: "; New->dump(&DAG));
230 "Replacing one node with another that produces a different number "
234 UpdatedNodes->
insert(New);
240 dbgs() <<
" with: "; New->dump(&DAG));
244 UpdatedNodes->
insert(New.getNode());
245 ReplacedNode(Old.getNode());
252 for (
unsigned i = 0, e = Old->
getNumValues(); i != e; ++i) {
263 dbgs() <<
" with: "; New->dump(&DAG));
267 UpdatedNodes->
insert(New.getNode());
268 ReplacedNode(Old.getNode());
278 bool isObjectScalable) {
286 ObjectSize, MFI.getObjectAlign(FI));
293SDValue SelectionDAGLegalize::ShuffleWithNarrowerEltType(
298 unsigned NumEltsGrowth = NumDestElts / NumMaskElts;
300 assert(NumEltsGrowth &&
"Cannot promote to vector type with fewer elts!");
302 if (NumEltsGrowth == 1)
305 SmallVector<int, 8> NewMask;
306 for (
unsigned i = 0; i != NumMaskElts; ++i) {
308 for (
unsigned j = 0;
j != NumEltsGrowth; ++
j) {
312 NewMask.
push_back(Idx * NumEltsGrowth + j);
315 assert(NewMask.
size() == NumDestElts &&
"Non-integer NumEltsGrowth?");
323SelectionDAGLegalize::ExpandConstantFP(ConstantFPSDNode *CFP,
bool UseCP) {
336 assert((VT == MVT::f64 || VT == MVT::f32) &&
"Invalid type expansion");
338 (VT == MVT::f64) ? MVT::i64 : MVT::i32);
348 while (SVT != MVT::f32 && SVT != MVT::f16 && SVT != MVT::bf16) {
381SDValue SelectionDAGLegalize::ExpandConstant(ConstantSDNode *CP) {
383 EVT VT =
CP->getValueType(0);
413 SmallVector<int, 8> ShufOps;
414 for (
unsigned i = 0; i != NumElts; ++i)
415 ShufOps.
push_back(i != InsertPos->getZExtValue() ? i : NumElts);
420 return ExpandInsertToVectorThroughStack(
Op);
423SDValue SelectionDAGLegalize::OptimizeFloatStore(StoreSDNode* ST) {
438 AAMDNodes AAInfo =
ST->getAAInfo();
449 bitcastToAPInt().zextOrTrunc(32),
450 SDLoc(CFP), MVT::i32);
451 return DAG.
getStore(Chain, dl, Con, Ptr,
ST->getPointerInfo(),
452 ST->getBaseAlign(), MMOFlags, AAInfo);
460 zextOrTrunc(64), SDLoc(CFP), MVT::i64);
461 return DAG.
getStore(Chain, dl, Con, Ptr,
ST->getPointerInfo(),
462 ST->getBaseAlign(), MMOFlags, AAInfo);
476 ST->getBaseAlign(), MMOFlags, AAInfo);
479 ST->getPointerInfo().getWithOffset(4),
480 ST->getBaseAlign(), MMOFlags, AAInfo);
489void SelectionDAGLegalize::LegalizeStoreOps(SDNode *Node) {
496 AAMDNodes AAInfo =
ST->getAAInfo();
498 if (!
ST->isTruncatingStore()) {
500 if (SDNode *OptStore = OptimizeFloatStore(ST).
getNode()) {
501 ReplaceNode(ST, OptStore);
506 MVT VT =
Value.getSimpleValueType();
509 case TargetLowering::Legal: {
512 EVT MemVT =
ST->getMemoryVT();
515 *
ST->getMemOperand())) {
518 ReplaceNode(
SDValue(ST, 0), Result);
523 case TargetLowering::Custom: {
526 if (Res && Res !=
SDValue(Node, 0))
527 ReplaceNode(
SDValue(Node, 0), Res);
530 case TargetLowering::Promote: {
533 "Can only promote stores to same size type");
536 ST->getBaseAlign(), MMOFlags, AAInfo);
537 ReplaceNode(
SDValue(Node, 0), Result);
546 EVT StVT =
ST->getMemoryVT();
551 if (StWidth != StSize) {
559 ST->getBaseAlign(), MMOFlags, AAInfo);
560 ReplaceNode(
SDValue(Node, 0), Result);
565 unsigned LogStWidth =
Log2_32(StWidthBits);
567 unsigned RoundWidth = 1 << LogStWidth;
568 assert(RoundWidth < StWidthBits);
569 unsigned ExtraWidth = StWidthBits - RoundWidth;
570 assert(ExtraWidth < RoundWidth);
571 assert(!(RoundWidth % 8) && !(ExtraWidth % 8) &&
572 "Store size not an integral number of bytes!");
576 unsigned IncrementSize;
578 if (
DL.isLittleEndian()) {
582 RoundVT,
ST->getBaseAlign(), MMOFlags, AAInfo);
585 IncrementSize = RoundWidth / 8;
592 ST->getPointerInfo().getWithOffset(IncrementSize),
593 ExtraVT,
ST->getBaseAlign(), MMOFlags, AAInfo);
602 ST->getBaseAlign(), MMOFlags, AAInfo);
605 IncrementSize = RoundWidth / 8;
610 ST->getPointerInfo().getWithOffset(IncrementSize),
611 ExtraVT,
ST->getBaseAlign(), MMOFlags, AAInfo);
616 ReplaceNode(
SDValue(Node, 0), Result);
620 case TargetLowering::Legal: {
621 EVT MemVT =
ST->getMemoryVT();
625 *
ST->getMemOperand())) {
627 ReplaceNode(
SDValue(ST, 0), Result);
631 case TargetLowering::Custom: {
633 if (Res && Res !=
SDValue(Node, 0))
634 ReplaceNode(
SDValue(Node, 0), Res);
637 case TargetLowering::Expand:
639 "Vector Stores are handled in LegalizeVectorOps");
647 ST->getBaseAlign(), MMOFlags, AAInfo);
655 StVT,
ST->getBaseAlign(), MMOFlags, AAInfo);
658 ReplaceNode(
SDValue(Node, 0), Result);
664void SelectionDAGLegalize::LegalizeLoadOps(SDNode *Node) {
673 LLVM_DEBUG(
dbgs() <<
"Legalizing non-extending load operation\n");
674 MVT VT =
Node->getSimpleValueType(0);
680 case TargetLowering::Legal: {
681 EVT MemVT =
LD->getMemoryVT();
686 *
LD->getMemOperand())) {
691 case TargetLowering::Custom:
698 case TargetLowering::Promote: {
701 "Can only promote loads to same size type");
705 if (
const MDNode *MD =
LD->getRanges()) {
709 LD->getMemOperand()->clearRanges();
717 if (RChain.
getNode() != Node) {
718 assert(RVal.
getNode() != Node &&
"Load must be completely replaced");
722 UpdatedNodes->insert(RVal.
getNode());
723 UpdatedNodes->insert(RChain.
getNode());
731 EVT SrcVT =
LD->getMemoryVT();
734 AAMDNodes AAInfo =
LD->getAAInfo();
746 TargetLowering::Promote)) {
760 Chain, Ptr,
LD->getPointerInfo(), NVT,
761 LD->getBaseAlign(), MMOFlags, AAInfo);
773 Result.getValueType(), Result,
782 unsigned LogSrcWidth =
Log2_32(SrcWidthBits);
784 unsigned RoundWidth = 1 << LogSrcWidth;
785 assert(RoundWidth < SrcWidthBits);
786 unsigned ExtraWidth = SrcWidthBits - RoundWidth;
787 assert(ExtraWidth < RoundWidth);
788 assert(!(RoundWidth % 8) && !(ExtraWidth % 8) &&
789 "Load size not an integral number of bytes!");
793 unsigned IncrementSize;
796 if (
DL.isLittleEndian()) {
800 LD->getPointerInfo(), RoundVT,
LD->getBaseAlign(),
804 IncrementSize = RoundWidth / 8;
808 LD->getPointerInfo().getWithOffset(IncrementSize),
809 ExtraVT,
LD->getBaseAlign(), MMOFlags, AAInfo);
828 LD->getPointerInfo(), RoundVT,
LD->getBaseAlign(),
832 IncrementSize = RoundWidth / 8;
836 LD->getPointerInfo().getWithOffset(IncrementSize),
837 ExtraVT,
LD->getBaseAlign(), MMOFlags, AAInfo);
855 bool isCustom =
false;
859 case TargetLowering::Custom:
862 case TargetLowering::Legal:
874 EVT MemVT =
LD->getMemoryVT();
877 *
LD->getMemOperand())) {
883 case TargetLowering::Expand: {
884 EVT DestVT =
Node->getValueType(0);
898 SrcVT,
LD->getMemOperand());
902 Chain =
Load.getValue(1);
911 if (SVT == MVT::f16 || SVT == MVT::bf16) {
917 Ptr, ISrcVT,
LD->getMemOperand());
921 Chain =
Result.getValue(1);
927 "Vector Loads are handled in LegalizeVectorOps");
934 "EXTLOAD should always be supported!");
938 Node->getValueType(0),
940 LD->getMemOperand());
949 Chain =
Result.getValue(1);
958 assert(
Value.getNode() != Node &&
"Load must be completely replaced");
962 UpdatedNodes->insert(
Value.getNode());
963 UpdatedNodes->insert(Chain.
getNode());
970void SelectionDAGLegalize::LegalizeOp(SDNode *Node) {
979 for (
unsigned i = 0, e =
Node->getNumValues(); i != e; ++i)
981 TargetLowering::TypeLegal &&
982 "Unexpected illegal type!");
986 TargetLowering::TypeLegal ||
989 "Unexpected illegal type!");
993 TargetLowering::LegalizeAction Action = TargetLowering::Legal;
994 bool SimpleFinishLegalizing =
true;
995 switch (
Node->getOpcode()) {
1006 ReplaceNode(Node, UndefNode.
getNode());
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());
1072 unsigned Opc =
Node->getOpcode();
1083 MVT OpVT =
Node->getOperand(CompareOperand).getSimpleValueType();
1087 if (Action == TargetLowering::Legal) {
1090 Node->getValueType(0));
1100 SimpleFinishLegalizing =
false;
1107 SimpleFinishLegalizing =
false;
1121 if (Action == TargetLowering::Legal)
1122 Action = TargetLowering::Expand;
1133 if (Action == TargetLowering::Legal)
1134 Action = TargetLowering::Custom;
1152 Action = TargetLowering::Legal;
1156 if (Action == TargetLowering::Expand) {
1160 Node->getOperand(0));
1161 ReplaceNode(Node, NewVal.
getNode());
1168 if (Action == TargetLowering::Expand) {
1172 Node->getOperand(0));
1173 ReplaceNode(Node, NewVal.
getNode());
1198 unsigned Scale =
Node->getConstantOperandVal(2);
1200 Node->getValueType(0), Scale);
1211 case ISD::VP_SCATTER:
1221 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
1243 Node->getOpcode(),
Node->getOperand(0).getValueType());
1247 case ISD::VP_REDUCE_FADD:
1248 case ISD::VP_REDUCE_FMUL:
1249 case ISD::VP_REDUCE_ADD:
1250 case ISD::VP_REDUCE_MUL:
1251 case ISD::VP_REDUCE_AND:
1252 case ISD::VP_REDUCE_OR:
1253 case ISD::VP_REDUCE_XOR:
1254 case ISD::VP_REDUCE_SMAX:
1255 case ISD::VP_REDUCE_SMIN:
1256 case ISD::VP_REDUCE_UMAX:
1257 case ISD::VP_REDUCE_UMIN:
1258 case ISD::VP_REDUCE_FMAX:
1259 case ISD::VP_REDUCE_FMIN:
1260 case ISD::VP_REDUCE_FMAXIMUM:
1261 case ISD::VP_REDUCE_FMINIMUM:
1262 case ISD::VP_REDUCE_SEQ_FADD:
1263 case ISD::VP_REDUCE_SEQ_FMUL:
1265 Node->getOpcode(),
Node->getOperand(1).getValueType());
1267 case ISD::VP_CTTZ_ELTS:
1268 case ISD::VP_CTTZ_ELTS_ZERO_UNDEF:
1270 Node->getOperand(0).getValueType());
1286 if (SimpleFinishLegalizing) {
1287 SDNode *NewNode =
Node;
1288 switch (
Node->getOpcode()) {
1335 if (NewNode != Node) {
1336 ReplaceNode(Node, NewNode);
1340 case TargetLowering::Legal:
1343 case TargetLowering::Custom:
1351 if (
Node->getNumValues() == 1) {
1355 Node->getValueType(0) == MVT::Glue) &&
1356 "Type mismatch for custom legalized operation");
1359 ReplaceNode(
SDValue(Node, 0), Res);
1364 for (
unsigned i = 0, e =
Node->getNumValues(); i != e; ++i) {
1368 Node->getValueType(i) == MVT::Glue) &&
1369 "Type mismatch for custom legalized operation");
1373 ReplaceNode(Node, ResultVals.
data());
1378 case TargetLowering::Expand:
1379 if (ExpandNode(Node))
1382 case TargetLowering::LibCall:
1383 ConvertNodeToLibcall(Node);
1385 case TargetLowering::Promote:
1391 switch (
Node->getOpcode()) {
1404 return LegalizeLoadOps(Node);
1406 return LegalizeStoreOps(Node);
1410SDValue SelectionDAGLegalize::ExpandExtractFromVectorThroughStack(
SDValue Op) {
1423 SmallPtrSet<const SDNode *, 32> Visited;
1430 if (
ST->isIndexed() ||
ST->isTruncatingStore() ||
1431 ST->getValue() != Vec)
1436 if (!
ST->getChain().reachesChainWithoutSideEffects(DAG.
getEntryNode()))
1445 ST->hasPredecessor(
Op.getNode()))
1465 Align ElementAlignment =
1470 if (
Op.getValueType().isVector()) {
1472 Op.getValueType(), Idx);
1473 NewLoad = DAG.
getLoad(
Op.getValueType(), dl, Ch, StackPtr,
1474 MachinePointerInfo(), ElementAlignment);
1488 NewLoadOperands[0] = Ch;
1494SDValue SelectionDAGLegalize::ExpandInsertToVectorThroughStack(
SDValue Op) {
1495 assert(
Op.getValueType().isVector() &&
"Non-vector insert subvector!");
1507 MachinePointerInfo PtrInfo =
1511 Align BaseVecAlignment =
1529 Ch, dl, Part, SubStackPtr,
1538 Ch, dl, Part, SubStackPtr,
1544 "ElementAlignment does not match!");
1547 return DAG.
getLoad(
Op.getValueType(), dl, Ch, StackPtr, PtrInfo,
1551SDValue SelectionDAGLegalize::ExpandConcatVectors(SDNode *Node) {
1555 unsigned NumOperands =
Node->getNumOperands();
1557 EVT VectorValueType =
Node->getOperand(0).getValueType();
1561 for (
unsigned I = 0;
I < NumOperands; ++
I) {
1563 for (
unsigned Idx = 0; Idx < NumSubElem; ++Idx) {
1572SDValue SelectionDAGLegalize::ExpandVectorBuildThroughStack(SDNode* Node) {
1575 "Unexpected opcode!");
1581 EVT VT =
Node->getValueType(0);
1583 :
Node->getOperand(0).getValueType();
1587 MachinePointerInfo PtrInfo =
1593 assert(TypeByteSize > 0 &&
"Vector element type too small for stack store!");
1598 MemVT.
bitsLT(
Node->getOperand(0).getValueType());
1601 for (
unsigned i = 0, e =
Node->getNumOperands(); i != e; ++i) {
1603 if (
Node->getOperand(i).isUndef())
continue;
1605 unsigned Offset = TypeByteSize*i;
1612 Node->getOperand(i), Idx,
1620 if (!Stores.
empty())
1626 return DAG.
getLoad(VT, dl, StoreChain, FIPtr, PtrInfo);
1632void SelectionDAGLegalize::getSignAsIntValue(FloatSignAsInt &State,
1635 EVT FloatVT =
Value.getValueType();
1637 State.FloatVT = FloatVT;
1643 State.SignBit = NumBits - 1;
1658 State.FloatPointerInfo);
1661 if (DataLayout.isBigEndian()) {
1665 State.IntPointerInfo = State.FloatPointerInfo;
1668 unsigned ByteOffset = (NumBits / 8) - 1;
1675 State.IntPtr = IntPtr;
1677 State.IntPointerInfo, MVT::i8);
1684SDValue SelectionDAGLegalize::modifySignAsInt(
const FloatSignAsInt &State,
1692 State.IntPointerInfo, MVT::i8);
1693 return DAG.
getLoad(State.FloatVT,
DL, Chain, State.FloatPtr,
1694 State.FloatPointerInfo);
1697SDValue SelectionDAGLegalize::ExpandFCOPYSIGN(SDNode *Node)
const {
1703 FloatSignAsInt SignAsInt;
1704 getSignAsIntValue(SignAsInt,
DL, Sign);
1724 FloatSignAsInt MagAsInt;
1725 getSignAsIntValue(MagAsInt,
DL, Mag);
1732 int ShiftAmount = SignAsInt.SignBit - MagAsInt.SignBit;
1733 EVT ShiftVT = IntVT;
1739 if (ShiftAmount > 0) {
1742 }
else if (ShiftAmount < 0) {
1755 return modifySignAsInt(MagAsInt,
DL, CopiedSign);
1758SDValue SelectionDAGLegalize::ExpandFNEG(SDNode *Node)
const {
1761 FloatSignAsInt SignAsInt;
1762 getSignAsIntValue(SignAsInt,
DL,
Node->getOperand(0));
1771 return modifySignAsInt(SignAsInt,
DL, SignFlip);
1774SDValue SelectionDAGLegalize::ExpandFABS(SDNode *Node)
const {
1779 EVT FloatVT =
Value.getValueType();
1786 FloatSignAsInt ValueAsInt;
1787 getSignAsIntValue(ValueAsInt,
DL,
Value);
1792 return modifySignAsInt(ValueAsInt,
DL, ClearedSign);
1795void SelectionDAGLegalize::ExpandDYNAMIC_STACKALLOC(SDNode* Node,
1796 SmallVectorImpl<SDValue> &
Results) {
1798 assert(
SPReg &&
"Target cannot require DYNAMIC_STACKALLOC expansion and"
1799 " not tell us which reg is the stack pointer!");
1801 EVT VT =
Node->getValueType(0);
1813 Chain =
SP.getValue(1);
1822 if (Alignment > StackAlign)
1837SDValue SelectionDAGLegalize::EmitStackConvert(
SDValue SrcOp, EVT SlotVT,
1838 EVT DestVT,
const SDLoc &dl) {
1839 return EmitStackConvert(SrcOp, SlotVT, DestVT, dl, DAG.
getEntryNode());
1842SDValue SelectionDAGLegalize::EmitStackConvert(
SDValue SrcOp, EVT SlotVT,
1843 EVT DestVT,
const SDLoc &dl,
1850 if ((SrcVT.
bitsGT(SlotVT) &&
1852 (SlotVT.
bitsLT(DestVT) &&
1863 MachinePointerInfo PtrInfo =
1870 if (SrcVT.
bitsGT(SlotVT))
1875 Store = DAG.
getStore(Chain, dl, SrcOp, FIPtr, PtrInfo, SrcAlign);
1879 if (SlotVT.
bitsEq(DestVT))
1880 return DAG.
getLoad(DestVT, dl, Store, FIPtr, PtrInfo, DestAlign);
1887SDValue SelectionDAGLegalize::ExpandSCALAR_TO_VECTOR(SDNode *Node) {
1899 Node->getValueType(0).getVectorElementType());
1901 Node->getValueType(0), dl, Ch, StackPtr,
1908 unsigned NumElems =
Node->getNumOperands();
1910 EVT VT =
Node->getValueType(0);
1922 for (
unsigned i = 0; i < NumElems; ++i) {
1933 while (IntermedVals.
size() > 2) {
1934 NewIntermedVals.
clear();
1935 for (
unsigned i = 0, e = (IntermedVals.
size() & ~1u); i < e; i += 2) {
1941 FinalIndices.
reserve(IntermedVals[i].second.
size() +
1942 IntermedVals[i+1].second.
size());
1945 for (
unsigned j = 0, f = IntermedVals[i].second.
size(); j != f;
1948 FinalIndices.
push_back(IntermedVals[i].second[j]);
1950 for (
unsigned j = 0, f = IntermedVals[i+1].second.
size(); j != f;
1952 ShuffleVec[k] = NumElems + j;
1953 FinalIndices.
push_back(IntermedVals[i+1].second[j]);
1959 IntermedVals[i+1].first,
1964 std::make_pair(Shuffle, std::move(FinalIndices)));
1969 if ((IntermedVals.
size() & 1) != 0)
1972 IntermedVals.
swap(NewIntermedVals);
1976 "Invalid number of intermediate vectors");
1977 SDValue Vec1 = IntermedVals[0].first;
1979 if (IntermedVals.
size() > 1)
1980 Vec2 = IntermedVals[1].first;
1985 for (
unsigned i = 0, e = IntermedVals[0].second.
size(); i != e; ++i)
1986 ShuffleVec[IntermedVals[0].second[i]] = i;
1987 for (
unsigned i = 0, e = IntermedVals[1].second.
size(); i != e; ++i)
1988 ShuffleVec[IntermedVals[1].second[i]] = NumElems + i;
2001SDValue SelectionDAGLegalize::ExpandBUILD_VECTOR(SDNode *Node) {
2002 unsigned NumElems =
Node->getNumOperands();
2005 EVT VT =
Node->getValueType(0);
2006 EVT OpVT =
Node->getOperand(0).getValueType();
2011 bool isOnlyLowElement =
true;
2012 bool MoreThanTwoValues =
false;
2014 for (
unsigned i = 0; i < NumElems; ++i) {
2019 isOnlyLowElement =
false;
2025 }
else if (!Value2.
getNode()) {
2028 }
else if (V != Value1 && V != Value2) {
2029 MoreThanTwoValues =
true;
2036 if (isOnlyLowElement)
2042 for (
unsigned i = 0, e = NumElems; i !=
e; ++i) {
2043 if (ConstantFPSDNode *V =
2046 }
else if (ConstantSDNode *V =
2049 CV.
push_back(
const_cast<ConstantInt *
>(
V->getConstantIntValue()));
2054 const ConstantInt *CI =
V->getConstantIntValue();
2075 SmallSet<SDValue, 16> DefinedValues;
2076 for (
unsigned i = 0; i < NumElems; ++i) {
2077 if (
Node->getOperand(i).isUndef())
2083 if (!MoreThanTwoValues) {
2084 SmallVector<int, 8> ShuffleVec(NumElems, -1);
2085 for (
unsigned i = 0; i < NumElems; ++i) {
2089 ShuffleVec[i] =
V == Value1 ? 0 : NumElems;
2111 return ExpandVectorBuildThroughStack(Node);
2114SDValue SelectionDAGLegalize::ExpandSPLAT_VECTOR(SDNode *Node) {
2116 EVT VT =
Node->getValueType(0);
2127std::pair<SDValue, SDValue>
2128SelectionDAGLegalize::ExpandLibCall(RTLIB::Libcall LC, SDNode *Node,
2129 TargetLowering::ArgListTy &&Args,
2130 bool IsSigned, EVT RetVT) {
2134 if (LCImpl != RTLIB::Unsupported)
2139 Node->getOperationName(&DAG));
2156 (RetTy ==
F.getReturnType() ||
F.getReturnType()->
isVoidTy());
2160 TargetLowering::CallLoweringInfo CLI(DAG);
2162 CLI.setDebugLoc(SDLoc(Node))
2166 .setTailCall(isTailCall)
2167 .setSExtResult(signExtend)
2168 .setZExtResult(!signExtend)
2169 .setIsPostTypeLegalization(
true);
2171 std::pair<SDValue, SDValue> CallInfo = TLI.
LowerCallTo(CLI);
2173 if (!CallInfo.second.getNode()) {
2179 LLVM_DEBUG(
dbgs() <<
"Created libcall: "; CallInfo.first.dump(&DAG));
2183std::pair<SDValue, SDValue> SelectionDAGLegalize::ExpandLibCall(RTLIB::Libcall LC, SDNode *Node,
2185 TargetLowering::ArgListTy
Args;
2187 EVT ArgVT =
Op.getValueType();
2189 TargetLowering::ArgListEntry
Entry(
Op, ArgTy);
2192 Args.push_back(Entry);
2195 return ExpandLibCall(LC, Node, std::move(Args), isSigned,
2196 Node->getValueType(0));
2199void SelectionDAGLegalize::ExpandFPLibCall(SDNode* Node,
2201 SmallVectorImpl<SDValue> &
Results) {
2202 if (LC == RTLIB::UNKNOWN_LIBCALL)
2205 if (
Node->isStrictFPOpcode()) {
2206 EVT RetVT =
Node->getValueType(0);
2208 TargetLowering::MakeLibCallOptions CallOptions;
2211 std::pair<SDValue, SDValue> Tmp = TLI.
makeLibCall(DAG, LC, RetVT,
2214 Node->getOperand(0));
2216 Results.push_back(Tmp.second);
2219 SDValue Tmp = ExpandLibCall(LC, Node, IsSignedArgument).first;
2225void SelectionDAGLegalize::ExpandFPLibCall(SDNode* Node,
2226 RTLIB::Libcall Call_F32,
2227 RTLIB::Libcall Call_F64,
2228 RTLIB::Libcall Call_F80,
2229 RTLIB::Libcall Call_F128,
2230 RTLIB::Libcall Call_PPCF128,
2231 SmallVectorImpl<SDValue> &
Results) {
2233 Call_F32, Call_F64, Call_F80,
2234 Call_F128, Call_PPCF128);
2235 ExpandFPLibCall(Node, LC,
Results);
2238void SelectionDAGLegalize::ExpandFastFPLibCall(
2239 SDNode *Node,
bool IsFast,
2240 std::pair<RTLIB::Libcall, RTLIB::Libcall> Call_F32,
2241 std::pair<RTLIB::Libcall, RTLIB::Libcall> Call_F64,
2242 std::pair<RTLIB::Libcall, RTLIB::Libcall> Call_F80,
2243 std::pair<RTLIB::Libcall, RTLIB::Libcall> Call_F128,
2244 std::pair<RTLIB::Libcall, RTLIB::Libcall> Call_PPCF128,
2245 SmallVectorImpl<SDValue> &
Results) {
2247 EVT VT =
Node->getSimpleValueType(0);
2256 Call_F128.first, Call_PPCF128.first);
2262 Call_F80.second, Call_F128.second,
2263 Call_PPCF128.second);
2266 ExpandFPLibCall(Node, LC,
Results);
2269SDValue SelectionDAGLegalize::ExpandIntLibCall(SDNode* Node,
bool isSigned,
2270 RTLIB::Libcall Call_I8,
2271 RTLIB::Libcall Call_I16,
2272 RTLIB::Libcall Call_I32,
2273 RTLIB::Libcall Call_I64,
2274 RTLIB::Libcall Call_I128) {
2276 switch (
Node->getSimpleValueType(0).SimpleTy) {
2278 case MVT::i8: LC = Call_I8;
break;
2279 case MVT::i16: LC = Call_I16;
break;
2280 case MVT::i32: LC = Call_I32;
break;
2281 case MVT::i64: LC = Call_I64;
break;
2282 case MVT::i128: LC = Call_I128;
break;
2284 return ExpandLibCall(LC, Node, isSigned).first;
2289void SelectionDAGLegalize::ExpandArgFPLibCall(SDNode* Node,
2290 RTLIB::Libcall Call_F32,
2291 RTLIB::Libcall Call_F64,
2292 RTLIB::Libcall Call_F80,
2293 RTLIB::Libcall Call_F128,
2294 RTLIB::Libcall Call_PPCF128,
2295 SmallVectorImpl<SDValue> &
Results) {
2296 EVT InVT =
Node->getOperand(
Node->isStrictFPOpcode() ? 1 : 0).getValueType();
2298 Call_F32, Call_F64, Call_F80,
2299 Call_F128, Call_PPCF128);
2300 ExpandFPLibCall(Node, LC,
Results);
2303SDValue SelectionDAGLegalize::ExpandBitCountingLibCall(
2304 SDNode *Node, RTLIB::Libcall CallI32, RTLIB::Libcall CallI64,
2305 RTLIB::Libcall CallI128) {
2307 switch (
Node->getSimpleValueType(0).SimpleTy) {
2328 EVT ArgVT =
Op.getValueType();
2330 TargetLowering::ArgListEntry Arg(
Op, ArgTy);
2332 Arg.IsZExt = !Arg.IsSExt;
2334 SDValue Res = ExpandLibCall(LC, Node, TargetLowering::ArgListTy{Arg},
2347SelectionDAGLegalize::ExpandDivRemLibCall(SDNode *Node,
2348 SmallVectorImpl<SDValue> &
Results) {
2349 unsigned Opcode =
Node->getOpcode();
2353 switch (
Node->getSimpleValueType(0).SimpleTy) {
2355 case MVT::i8: LC= isSigned ? RTLIB::SDIVREM_I8 : RTLIB::UDIVREM_I8;
break;
2356 case MVT::i16: LC= isSigned ? RTLIB::SDIVREM_I16 : RTLIB::UDIVREM_I16;
break;
2357 case MVT::i32: LC= isSigned ? RTLIB::SDIVREM_I32 : RTLIB::UDIVREM_I32;
break;
2358 case MVT::i64: LC= isSigned ? RTLIB::SDIVREM_I64 : RTLIB::UDIVREM_I64;
break;
2359 case MVT::i128: LC= isSigned ? RTLIB::SDIVREM_I128:RTLIB::UDIVREM_I128;
break;
2367 EVT RetVT =
Node->getValueType(0);
2370 TargetLowering::ArgListTy
Args;
2372 EVT ArgVT =
Op.getValueType();
2374 TargetLowering::ArgListEntry
Entry(
Op, ArgTy);
2375 Entry.IsSExt = isSigned;
2376 Entry.IsZExt = !isSigned;
2377 Args.push_back(Entry);
2382 TargetLowering::ArgListEntry
Entry(
2383 FIPtr, PointerType::getUnqual(RetTy->
getContext()));
2384 Entry.IsSExt = isSigned;
2385 Entry.IsZExt = !isSigned;
2386 Args.push_back(Entry);
2389 if (LibcallImpl == RTLIB::Unsupported) {
2391 Node->getOperationName(&DAG));
2402 TargetLowering::CallLoweringInfo CLI(DAG);
2407 .setSExtResult(isSigned)
2408 .setZExtResult(!isSigned);
2410 std::pair<SDValue, SDValue> CallInfo = TLI.
LowerCallTo(CLI);
2414 MachinePointerInfo PtrInfo =
2417 SDValue Rem = DAG.
getLoad(RetVT, dl, CallInfo.second, FIPtr, PtrInfo);
2418 Results.push_back(CallInfo.first);
2445SDValue SelectionDAGLegalize::ExpandSincosStretLibCall(SDNode *Node)
const {
2453 if (SincosStret == RTLIB::Unsupported)
2468 Type *SincosStretRetTy = FuncTy->getReturnType();
2474 TargetLowering::ArgListTy
Args;
2478 if (FuncTy->getParamType(0)->isPointerTy()) {
2482 AttributeSet PtrAttrs = FuncAttrs.getParamAttrs(0);
2484 const uint64_t ByteSize =
DL.getTypeAllocSize(StructTy);
2485 const Align StackAlign =
DL.getPrefTypeAlign(StructTy);
2490 TargetLowering::ArgListEntry
Entry(SRet, FuncTy->getParamType(0));
2491 Entry.IsSRet =
true;
2492 Entry.IndirectType = StructTy;
2493 Entry.Alignment = StackAlign;
2495 Args.push_back(Entry);
2496 Args.emplace_back(Arg, FuncTy->getParamType(1));
2498 Args.emplace_back(Arg, FuncTy->getParamType(0));
2501 TargetLowering::CallLoweringInfo CLI(DAG);
2504 .setLibCallee(CallConv, SincosStretRetTy, Callee, std::move(Args))
2505 .setIsPostTypeLegalization();
2507 std::pair<SDValue, SDValue> CallResult = TLI.
LowerCallTo(CLI);
2510 MachinePointerInfo PtrInfo =
2512 SDValue LoadSin = DAG.
getLoad(ArgVT, dl, CallResult.second, SRet, PtrInfo);
2521 SDVTList Tys = DAG.
getVTList(ArgVT, ArgVT);
2526 if (!CallResult.first.getValueType().isVector())
2527 return CallResult.first;
2535 SDVTList Tys = DAG.
getVTList(ArgVT, ArgVT);
2539SDValue SelectionDAGLegalize::expandLdexp(SDNode *Node)
const {
2541 EVT VT =
Node->getValueType(0);
2544 EVT ExpVT =
N.getValueType();
2546 if (AsIntVT == EVT())
2554 SDNodeFlags NUW_NSW;
2562 const APFloat::ExponentType MaxExpVal = APFloat::semanticsMaxExponent(FltSem);
2563 const APFloat::ExponentType MinExpVal = APFloat::semanticsMinExponent(FltSem);
2564 const int Precision = APFloat::semanticsPrecision(FltSem);
2571 const APFloat One(FltSem,
"1.0");
2572 APFloat ScaleUpK =
scalbn(One, MaxExpVal, APFloat::rmNearestTiesToEven);
2576 scalbn(One, MinExpVal + Precision, APFloat::rmNearestTiesToEven);
2646 ExponentShiftAmt, NUW_NSW);
2651SDValue SelectionDAGLegalize::expandFrexp(SDNode *Node)
const {
2655 EVT ExpVT =
Node->getValueType(1);
2657 if (AsIntVT == EVT())
2661 const APFloat::ExponentType MinExpVal = APFloat::semanticsMinExponent(FltSem);
2662 const unsigned Precision = APFloat::semanticsPrecision(FltSem);
2695 FractSignMaskVal.
setBit(BitSize - 1);
2702 const APFloat One(FltSem,
"1.0");
2706 scalbn(One, Precision + 1, APFloat::rmNearestTiesToEven);
2718 SDValue AddNegSmallestNormal =
2720 SDValue DenormOrZero = DAG.
getSetCC(dl, SetCCVT, AddNegSmallestNormal,
2753 const APFloat Half(FltSem,
"0.5");
2774SDValue SelectionDAGLegalize::ExpandLegalINT_TO_FP(SDNode *Node,
2778 EVT DestVT =
Node->getValueType(0);
2780 unsigned OpNo =
Node->isStrictFPOpcode() ? 1 : 0;
2786 if (SrcVT == MVT::i32 && TLI.
isTypeLegal(MVT::f64) &&
2787 (DestVT.
bitsLE(MVT::f64) ||
2791 LLVM_DEBUG(
dbgs() <<
"32-bit [signed|unsigned] integer to float/double "
2815 MachinePointerInfo());
2820 DAG.
getStore(MemChain, dl,
Hi, HiPtr, MachinePointerInfo());
2825 DAG.
getLoad(MVT::f64, dl, MemChain, StackSlot, MachinePointerInfo());
2834 if (
Node->isStrictFPOpcode()) {
2836 {
Node->getOperand(0),
Load, Bias});
2838 if (DestVT !=
Sub.getValueType()) {
2839 std::pair<SDValue, SDValue> ResultPair;
2842 Result = ResultPair.first;
2843 Chain = ResultPair.second;
2858 if (((SrcVT == MVT::i32 || SrcVT == MVT::i64) && DestVT == MVT::f32) ||
2859 (SrcVT == MVT::i64 && DestVT == MVT::f64)) {
2860 LLVM_DEBUG(
dbgs() <<
"Converting unsigned i32/i64 to f32/f64\n");
2875 EVT SetCCVT = getSetCCResultType(SrcVT);
2887 if (
Node->isStrictFPOpcode()) {
2895 Flags.setNoFPExcept(
Node->getFlags().hasNoFPExcept());
2898 Flags.setNoFPExcept(
true);
2921 "Cannot perform lossless SINT_TO_FP!");
2924 if (
Node->isStrictFPOpcode()) {
2926 {
Node->getOperand(0), Op0 });
2935 SignSet, Four, Zero);
2944 case MVT::i8 : FF = 0x43800000ULL;
break;
2945 case MVT::i16: FF = 0x47800000ULL;
break;
2946 case MVT::i32: FF = 0x4F800000ULL;
break;
2947 case MVT::i64: FF = 0x5F800000ULL;
break;
2951 Constant *FudgeFactor = ConstantInt::get(
2960 if (DestVT == MVT::f32)
2970 HandleSDNode Handle(Load);
2971 LegalizeOp(
Load.getNode());
2975 if (
Node->isStrictFPOpcode()) {
2977 { Tmp1.
getValue(1), Tmp1, FudgeInReg });
2978 Chain =
Result.getValue(1);
2990void SelectionDAGLegalize::PromoteLegalINT_TO_FP(
2991 SDNode *
N,
const SDLoc &dl, SmallVectorImpl<SDValue> &
Results) {
2995 EVT DestVT =
N->getValueType(0);
2996 SDValue LegalOp =
N->getOperand(IsStrict ? 1 : 0);
3003 unsigned OpToUse = 0;
3031 DAG.
getNode(OpToUse, dl, {DestVT, MVT::Other},
3034 dl, NewInTy, LegalOp)});
3041 DAG.
getNode(OpToUse, dl, DestVT,
3043 dl, NewInTy, LegalOp)));
3051void SelectionDAGLegalize::PromoteLegalFP_TO_INT(SDNode *
N,
const SDLoc &dl,
3052 SmallVectorImpl<SDValue> &
Results) {
3053 bool IsStrict =
N->isStrictFPOpcode();
3056 EVT DestVT =
N->getValueType(0);
3059 EVT NewOutTy = DestVT;
3061 unsigned OpToUse = 0;
3085 SDVTList VTs = DAG.
getVTList(NewOutTy, MVT::Other);
3101SDValue SelectionDAGLegalize::PromoteLegalFP_TO_INT_SAT(SDNode *Node,
3103 unsigned Opcode =
Node->getOpcode();
3106 EVT NewOutTy =
Node->getValueType(0);
3118 Node->getOperand(1));
3124 EVT VT =
Op.getValueType();
3144SDValue SelectionDAGLegalize::PromoteReduction(SDNode *Node) {
3146 MVT VecVT = IsVPOpcode ?
Node->getOperand(1).getSimpleValueType()
3147 :
Node->getOperand(0).getSimpleValueType();
3149 MVT ScalarVT =
Node->getSimpleValueType(0);
3156 assert(
Node->getOperand(0).getValueType().isFloatingPoint() &&
3157 "Only FP promotion is supported");
3159 for (
unsigned j = 0;
j !=
Node->getNumOperands(); ++
j)
3160 if (
Node->getOperand(j).getValueType().isVector() &&
3165 assert(
Node->getOperand(j).getValueType().isFloatingPoint() &&
3166 "Only FP promotion is supported");
3169 }
else if (
Node->getOperand(j).getValueType().isFloatingPoint()) {
3174 Operands[
j] =
Node->getOperand(j);
3185bool SelectionDAGLegalize::ExpandNode(SDNode *Node) {
3189 SDValue Tmp1, Tmp2, Tmp3, Tmp4;
3191 switch (
Node->getOpcode()) {
3231 Results.push_back(ExpandPARITY(
Node->getOperand(0), dl));
3283 SDVTList VTs = DAG.
getVTList(
Node->getValueType(0), MVT::Other);
3286 Node->getOperand(0),
Node->getOperand(1), Zero, Zero,
3296 Node->getOperand(0),
Node->getOperand(2),
Node->getOperand(1),
3305 SDVTList VTs = DAG.
getVTList(
Node->getValueType(0), MVT::Other);
3308 Node->getOperand(0),
Node->getOperand(1),
Node->getOperand(2),
3316 EVT OuterType =
Node->getValueType(0);
3349 EVT VT =
Node->getValueType(0);
3354 RHS =
RHS->getOperand(0);
3358 Node->getOperand(0),
Node->getOperand(1),
3365 ExpandDYNAMIC_STACKALLOC(Node,
Results);
3368 for (
unsigned i = 0; i <
Node->getNumValues(); i++)
3373 EVT VT =
Node->getValueType(0);
3390 Node->getValueType(0))
3391 == TargetLowering::Legal)
3395 if ((Tmp1 = EmitStackConvert(
Node->getOperand(1),
Node->getValueType(0),
3396 Node->getValueType(0), dl,
3397 Node->getOperand(0)))) {
3398 ReplaceNode(Node, Tmp1.
getNode());
3399 LLVM_DEBUG(
dbgs() <<
"Successfully expanded STRICT_FP_ROUND node\n");
3412 if ((Tmp1 = EmitStackConvert(
Node->getOperand(0),
Node->getValueType(0),
3413 Node->getValueType(0), dl)))
3424 Node->getValueType(0))
3425 == TargetLowering::Legal)
3429 if ((Tmp1 = EmitStackConvert(
3430 Node->getOperand(1),
Node->getOperand(1).getValueType(),
3431 Node->getValueType(0), dl,
Node->getOperand(0)))) {
3432 ReplaceNode(Node, Tmp1.
getNode());
3433 LLVM_DEBUG(
dbgs() <<
"Successfully expanded STRICT_FP_EXTEND node\n");
3439 EVT SrcVT =
Op.getValueType();
3440 EVT DstVT =
Node->getValueType(0);
3446 if ((Tmp1 = EmitStackConvert(
Op, SrcVT, DstVT, dl)))
3456 if (
Op.getValueType() == MVT::bf16) {
3466 if (
Node->getValueType(0) != MVT::f32)
3473 if (
Op.getValueType() != MVT::f32)
3485 if (
Node->getValueType(0) == MVT::bf16) {
3510 SDNodeFlags CanonicalizeFlags =
Node->getFlags();
3513 {Chain, Operand, One}, CanonicalizeFlags);
3520 EVT VT =
Node->getValueType(0);
3552 if (
Node->isStrictFPOpcode())
3559 if ((Tmp1 = ExpandLegalINT_TO_FP(Node, Tmp2))) {
3561 if (
Node->isStrictFPOpcode())
3571 ReplaceNode(Node, Tmp1.
getNode());
3572 LLVM_DEBUG(
dbgs() <<
"Successfully expanded STRICT_FP_TO_SINT node\n");
3585 ReplaceNodeWithValue(
SDValue(Node, 0), Tmp1);
3586 LLVM_DEBUG(
dbgs() <<
"Successfully expanded STRICT_FP_TO_UINT node\n");
3598 EVT ResVT =
Node->getValueType(0);
3612 if (
Node->getOperand(0).getValueType().getVectorElementCount().isScalar())
3615 Node->getOperand(0));
3617 Tmp1 = ExpandExtractFromVectorThroughStack(
SDValue(Node, 0));
3621 Results.push_back(ExpandExtractFromVectorThroughStack(
SDValue(Node, 0)));
3624 Results.push_back(ExpandInsertToVectorThroughStack(
SDValue(Node, 0)));
3627 if (EVT VectorValueType =
Node->getOperand(0).getValueType();
3630 Results.push_back(ExpandVectorBuildThroughStack(Node));
3632 Results.push_back(ExpandConcatVectors(Node));
3635 Results.push_back(ExpandSCALAR_TO_VECTOR(Node));
3644 EVT VT =
Node->getValueType(0);
3654 if (NewEltVT.
bitsLT(EltVT)) {
3670 unsigned int factor =
3678 for (
unsigned fi = 0; fi < factor; ++fi)
3682 for (
unsigned fi = 0; fi < factor; ++fi)
3693 for (
unsigned i = 0; i != NumElems; ++i) {
3698 unsigned Idx =
Mask[i];
3719 unsigned Factor =
Node->getNumOperands();
3723 EVT VecVT =
Node->getValueType(0);
3734 for (
unsigned I = 0;
I < Factor / 2;
I++) {
3737 {
L.getValue(
I),
R.getValue(
I)});
3744 unsigned Factor =
Node->getNumOperands();
3747 EVT VecVT =
Node->getValueType(0);
3752 for (
unsigned I = 0;
I < Factor / 2;
I++) {
3755 {
Node->getOperand(
I),
Node->getOperand(
I + Factor / 2)});
3763 for (
unsigned I = 0;
I < Factor / 2;
I++)
3765 for (
unsigned I = 0;
I < Factor / 2;
I++)
3770 EVT OpTy =
Node->getOperand(0).getValueType();
3771 if (
Node->getConstantOperandVal(1)) {
3780 Node->getOperand(0));
3790 Node->getValueType(0)));
3802 Node->getOperand(1)));
3812 Results.push_back(ExpandFCOPYSIGN(Node));
3815 Results.push_back(ExpandFNEG(Node));
3818 Results.push_back(ExpandFABS(Node));
3824 Test,
Node->getFlags(), SDLoc(Node), DAG))
3834 switch (
Node->getOpcode()) {
3841 Tmp1 =
Node->getOperand(0);
3842 Tmp2 =
Node->getOperand(1);
3843 Tmp1 = DAG.
getSelectCC(dl, Tmp1, Tmp2, Tmp1, Tmp2, Pred);
3866 EVT VT =
Node->getValueType(0);
3882 EVT VT =
Node->getValueType(0);
3889 if (
SDValue Expanded = expandLdexp(Node)) {
3892 Results.push_back(Expanded.getValue(1));
3904 if (
SDValue Expanded = expandFrexp(Node)) {
3906 Results.push_back(Expanded.getValue(1));
3913 EVT VT =
Node->getValueType(0);
3925 if (
Node->getValueType(0) != MVT::f32) {
3937 if (
Node->getValueType(0) != MVT::f32) {
3942 {Node->getOperand(0), Node->getOperand(1)});
3944 {
Node->getValueType(0), MVT::Other},
3954 MVT SVT =
Op.getSimpleValueType();
3955 if ((SVT == MVT::f64 || SVT == MVT::f80) &&
3973 Results.push_back(ExpandConstantFP(CFP,
true));
3978 Results.push_back(ExpandConstant(CP));
3982 EVT VT =
Node->getValueType(0);
3985 const SDNodeFlags
Flags =
Node->getFlags();
3993 EVT VT =
Node->getValueType(0);
3996 "Don't know how to expand this subtraction!");
3997 Tmp1 = DAG.
getNOT(dl,
Node->getOperand(1), VT);
4011 EVT VT =
Node->getValueType(0);
4014 Tmp1 = DAG.
getNode(DivRemOpc, dl, VTs,
Node->getOperand(0),
4015 Node->getOperand(1));
4022 unsigned ExpandOpcode =
4024 EVT VT =
Node->getValueType(0);
4027 Tmp1 = DAG.
getNode(ExpandOpcode, dl, VTs,
Node->getOperand(0),
4028 Node->getOperand(1));
4036 MVT VT =
LHS.getSimpleValueType();
4037 unsigned MULHOpcode =
4047 EVT HalfType = EVT(VT).getHalfSizedIntegerVT(*DAG.
getContext());
4051 TargetLowering::MulExpansionKind::Always)) {
4052 for (
unsigned i = 0; i < 2; ++i) {
4065 EVT VT =
Node->getValueType(0);
4076 unsigned OpToUse = 0;
4077 if (HasSMUL_LOHI && !HasMULHS) {
4079 }
else if (HasUMUL_LOHI && !HasMULHU) {
4081 }
else if (HasSMUL_LOHI) {
4083 }
else if (HasUMUL_LOHI) {
4088 Node->getOperand(1)));
4099 TargetLowering::MulExpansionKind::OnlyLegalOrCustom)) {
4144 Node->getOperand(0),
4145 Node->getOperand(1),
4146 Node->getConstantOperandVal(2),
4169 EVT VT =
LHS.getValueType();
4173 EVT CarryType =
Node->getValueType(1);
4174 EVT SetCCType = getSetCCResultType(
Node->getValueType(0));
4221 if (TLI.
expandMULO(Node, Result, Overflow, DAG)) {
4238 Tmp1 =
Node->getOperand(0);
4239 Tmp2 =
Node->getOperand(1);
4240 Tmp3 =
Node->getOperand(2);
4261 unsigned EntrySize =
4297 Tmp1 =
Node->getOperand(0);
4298 Tmp2 =
Node->getOperand(1);
4304 Node->getOperand(2));
4316 Node->getOperand(2));
4324 bool IsVP =
Node->getOpcode() == ISD::VP_SETCC;
4329 unsigned Offset = IsStrict ? 1 : 0;
4339 DAG,
Node->getValueType(0), Tmp1, Tmp2, Tmp3, Mask, EVL, NeedInvert, dl,
4340 Chain, IsSignaling);
4348 {Chain, Tmp1, Tmp2, Tmp3},
Node->getFlags());
4352 {Tmp1, Tmp2, Tmp3, Mask, EVL},
Node->getFlags());
4354 Tmp1 = DAG.
getNode(
Node->getOpcode(), dl,
Node->getValueType(0), Tmp1,
4355 Tmp2, Tmp3,
Node->getFlags());
4378 assert(!IsStrict &&
"Don't know how to expand for strict nodes.");
4383 EVT VT =
Node->getValueType(0);
4394 Tmp1 =
Node->getOperand(0);
4395 Tmp2 =
Node->getOperand(1);
4396 Tmp3 =
Node->getOperand(2);
4397 Tmp4 =
Node->getOperand(3);
4398 EVT VT =
Node->getValueType(0);
4408 "Cannot expand ISD::SELECT_CC when ISD::SELECT also needs to be "
4410 EVT CCVT = getSetCCResultType(CmpVT);
4418 bool Legalized =
false;
4436 Tmp1 = DAG.
getSelectCC(dl, Tmp2, Tmp1, Tmp4, Tmp3, SwapInvCC,
4443 DAG, getSetCCResultType(Tmp1.
getValueType()), Tmp1, Tmp2, CC,
4446 assert(Legalized &&
"Can't legalize SELECT_CC with legal condition!");
4457 Tmp2, Tmp3, Tmp4, CC,
Node->getFlags());
4462 Tmp2, Tmp3, Tmp4, CC,
Node->getFlags());
4471 Tmp1 =
Node->getOperand(0);
4472 Tmp2 =
Node->getOperand(2);
4473 Tmp3 =
Node->getOperand(3);
4474 Tmp4 =
Node->getOperand(1);
4477 DAG, getSetCCResultType(Tmp2.
getValueType()), Tmp2, Tmp3, Tmp4,
4480 assert(Legalized &&
"Can't legalize BR_CC with legal condition!");
4485 assert(!NeedInvert &&
"Don't know how to invert BR_CC!");
4488 Tmp4, Tmp2, Tmp3,
Node->getOperand(4));
4493 Tmp2, Tmp3,
Node->getOperand(4));
4499 Results.push_back(ExpandBUILD_VECTOR(Node));
4502 Results.push_back(ExpandSPLAT_VECTOR(Node));
4508 EVT VT =
Node->getValueType(0);
4514 for (
unsigned Idx = 0; Idx < NumElem; Idx++) {
4546 case ISD::VP_CTTZ_ELTS:
4547 case ISD::VP_CTTZ_ELTS_ZERO_UNDEF:
4559 EVT ResVT =
Node->getValueType(0);
4589 switch (
Node->getOpcode()) {
4592 Node->getValueType(0))
4593 == TargetLowering::Legal)
4604 EVT VT =
Node->getValueType(0);
4605 const SDNodeFlags
Flags =
Node->getFlags();
4608 {Node->getOperand(0), Node->getOperand(1), Neg},
4624 Node->getOperand(1).getValueType())
4625 == TargetLowering::Legal)
4638 ReplaceNode(Node,
Results.data());
4650 return Flags.hasApproximateFuncs() && Flags.hasNoNaNs() &&
4651 Flags.hasNoInfs() && Flags.hasNoSignedZeros();
4654void SelectionDAGLegalize::ConvertNodeToLibcall(SDNode *Node) {
4658 TargetLowering::MakeLibCallOptions CallOptions;
4661 unsigned Opc =
Node->getOpcode();
4666 TargetLowering::ArgListTy
Args;
4668 TargetLowering::CallLoweringInfo CLI(DAG);
4670 .setChain(
Node->getOperand(0))
4672 CallingConv::C, Type::getVoidTy(*DAG.
getContext()),
4677 std::pair<SDValue, SDValue> CallResult = TLI.
LowerCallTo(CLI);
4679 Results.push_back(CallResult.second);
4701 EVT RetVT =
Node->getValueType(0);
4706 Ops.push_back(
Node->getOperand(1));
4710 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
4711 "Unexpected atomic op or value type!");
4715 std::pair<SDValue, SDValue> Tmp = TLI.
makeLibCall(DAG, LC, RetVT,
4718 Node->getOperand(0));
4720 Results.push_back(Tmp.second);
4725 TargetLowering::ArgListTy
Args;
4726 TargetLowering::CallLoweringInfo CLI(DAG);
4728 .setChain(
Node->getOperand(0))
4729 .setLibCallee(CallingConv::C, Type::getVoidTy(*DAG.
getContext()),
4733 std::pair<SDValue, SDValue> CallResult = TLI.
LowerCallTo(CLI);
4735 Results.push_back(CallResult.second);
4742 std::pair<SDValue, SDValue> Tmp = TLI.
makeLibCall(
4743 DAG, RTLIB::CLEAR_CACHE, MVT::isVoid, {StartVal, EndVal}, CallOptions,
4744 SDLoc(Node), InputChain);
4745 Results.push_back(Tmp.second);
4750 ExpandFPLibCall(Node, RTLIB::FMIN_F32, RTLIB::FMIN_F64,
4751 RTLIB::FMIN_F80, RTLIB::FMIN_F128,
4752 RTLIB::FMIN_PPCF128,
Results);
4759 ExpandFPLibCall(Node, RTLIB::FMAX_F32, RTLIB::FMAX_F64,
4760 RTLIB::FMAX_F80, RTLIB::FMAX_F128,
4761 RTLIB::FMAX_PPCF128,
Results);
4764 ExpandFPLibCall(Node, RTLIB::FMINIMUM_NUM_F32, RTLIB::FMINIMUM_NUM_F64,
4765 RTLIB::FMINIMUM_NUM_F80, RTLIB::FMINIMUM_NUM_F128,
4766 RTLIB::FMINIMUM_NUM_PPCF128,
Results);
4769 ExpandFPLibCall(Node, RTLIB::FMAXIMUM_NUM_F32, RTLIB::FMAXIMUM_NUM_F64,
4770 RTLIB::FMAXIMUM_NUM_F80, RTLIB::FMAXIMUM_NUM_F128,
4771 RTLIB::FMAXIMUM_NUM_PPCF128,
Results);
4778 {RTLIB::FAST_SQRT_F32, RTLIB::SQRT_F32},
4779 {RTLIB::FAST_SQRT_F64, RTLIB::SQRT_F64},
4780 {RTLIB::FAST_SQRT_F80, RTLIB::SQRT_F80},
4781 {RTLIB::FAST_SQRT_F128, RTLIB::SQRT_F128},
4782 {RTLIB::FAST_SQRT_PPCF128, RTLIB::SQRT_PPCF128},
4787 ExpandFPLibCall(Node, RTLIB::CBRT_F32, RTLIB::CBRT_F64,
4788 RTLIB::CBRT_F80, RTLIB::CBRT_F128,
4789 RTLIB::CBRT_PPCF128,
Results);
4793 ExpandFPLibCall(Node, RTLIB::SIN_F32, RTLIB::SIN_F64,
4794 RTLIB::SIN_F80, RTLIB::SIN_F128,
4799 ExpandFPLibCall(Node, RTLIB::COS_F32, RTLIB::COS_F64,
4800 RTLIB::COS_F80, RTLIB::COS_F128,
4805 ExpandFPLibCall(Node, RTLIB::TAN_F32, RTLIB::TAN_F64, RTLIB::TAN_F80,
4806 RTLIB::TAN_F128, RTLIB::TAN_PPCF128,
Results);
4810 ExpandFPLibCall(Node, RTLIB::ASIN_F32, RTLIB::ASIN_F64, RTLIB::ASIN_F80,
4811 RTLIB::ASIN_F128, RTLIB::ASIN_PPCF128,
Results);
4815 ExpandFPLibCall(Node, RTLIB::ACOS_F32, RTLIB::ACOS_F64, RTLIB::ACOS_F80,
4816 RTLIB::ACOS_F128, RTLIB::ACOS_PPCF128,
Results);
4820 ExpandFPLibCall(Node, RTLIB::ATAN_F32, RTLIB::ATAN_F64, RTLIB::ATAN_F80,
4821 RTLIB::ATAN_F128, RTLIB::ATAN_PPCF128,
Results);
4825 ExpandFPLibCall(Node, RTLIB::ATAN2_F32, RTLIB::ATAN2_F64, RTLIB::ATAN2_F80,
4826 RTLIB::ATAN2_F128, RTLIB::ATAN2_PPCF128,
Results);
4830 ExpandFPLibCall(Node, RTLIB::SINH_F32, RTLIB::SINH_F64, RTLIB::SINH_F80,
4831 RTLIB::SINH_F128, RTLIB::SINH_PPCF128,
Results);
4835 ExpandFPLibCall(Node, RTLIB::COSH_F32, RTLIB::COSH_F64, RTLIB::COSH_F80,
4836 RTLIB::COSH_F128, RTLIB::COSH_PPCF128,
Results);
4840 ExpandFPLibCall(Node, RTLIB::TANH_F32, RTLIB::TANH_F64, RTLIB::TANH_F80,
4841 RTLIB::TANH_F128, RTLIB::TANH_PPCF128,
Results);
4845 EVT VT =
Node->getValueType(0);
4849 if (SincosStret != RTLIB::UNKNOWN_LIBCALL) {
4850 if (
SDValue Expanded = ExpandSincosStretLibCall(Node)) {
4852 Results.push_back(Expanded.getValue(1));
4864 Node->getOperationName(&DAG));
4874 ExpandFPLibCall(Node, RTLIB::LOG_F32, RTLIB::LOG_F64, RTLIB::LOG_F80,
4875 RTLIB::LOG_F128, RTLIB::LOG_PPCF128,
Results);
4879 ExpandFPLibCall(Node, RTLIB::LOG2_F32, RTLIB::LOG2_F64, RTLIB::LOG2_F80,
4880 RTLIB::LOG2_F128, RTLIB::LOG2_PPCF128,
Results);
4884 ExpandFPLibCall(Node, RTLIB::LOG10_F32, RTLIB::LOG10_F64, RTLIB::LOG10_F80,
4885 RTLIB::LOG10_F128, RTLIB::LOG10_PPCF128,
Results);
4889 ExpandFPLibCall(Node, RTLIB::EXP_F32, RTLIB::EXP_F64, RTLIB::EXP_F80,
4890 RTLIB::EXP_F128, RTLIB::EXP_PPCF128,
Results);
4894 ExpandFPLibCall(Node, RTLIB::EXP2_F32, RTLIB::EXP2_F64, RTLIB::EXP2_F80,
4895 RTLIB::EXP2_F128, RTLIB::EXP2_PPCF128,
Results);
4898 ExpandFPLibCall(Node, RTLIB::EXP10_F32, RTLIB::EXP10_F64, RTLIB::EXP10_F80,
4899 RTLIB::EXP10_F128, RTLIB::EXP10_PPCF128,
Results);
4903 ExpandFPLibCall(Node, RTLIB::TRUNC_F32, RTLIB::TRUNC_F64,
4904 RTLIB::TRUNC_F80, RTLIB::TRUNC_F128,
4905 RTLIB::TRUNC_PPCF128,
Results);
4909 ExpandFPLibCall(Node, RTLIB::FLOOR_F32, RTLIB::FLOOR_F64,
4910 RTLIB::FLOOR_F80, RTLIB::FLOOR_F128,
4911 RTLIB::FLOOR_PPCF128,
Results);
4915 ExpandFPLibCall(Node, RTLIB::CEIL_F32, RTLIB::CEIL_F64,
4916 RTLIB::CEIL_F80, RTLIB::CEIL_F128,
4917 RTLIB::CEIL_PPCF128,
Results);
4921 ExpandFPLibCall(Node, RTLIB::RINT_F32, RTLIB::RINT_F64,
4922 RTLIB::RINT_F80, RTLIB::RINT_F128,
4923 RTLIB::RINT_PPCF128,
Results);
4927 ExpandFPLibCall(Node, RTLIB::NEARBYINT_F32,
4928 RTLIB::NEARBYINT_F64,
4929 RTLIB::NEARBYINT_F80,
4930 RTLIB::NEARBYINT_F128,
4931 RTLIB::NEARBYINT_PPCF128,
Results);
4935 ExpandFPLibCall(Node, RTLIB::ROUND_F32,
4939 RTLIB::ROUND_PPCF128,
Results);
4943 ExpandFPLibCall(Node, RTLIB::ROUNDEVEN_F32,
4944 RTLIB::ROUNDEVEN_F64,
4945 RTLIB::ROUNDEVEN_F80,
4946 RTLIB::ROUNDEVEN_F128,
4947 RTLIB::ROUNDEVEN_PPCF128,
Results);
4951 ExpandFPLibCall(Node, RTLIB::LDEXP_F32, RTLIB::LDEXP_F64, RTLIB::LDEXP_F80,
4952 RTLIB::LDEXP_F128, RTLIB::LDEXP_PPCF128,
Results);
4956 EVT VT =
Node->getValueType(0);
4968 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fpowi.");
4971 if (
Node->isStrictFPOpcode()) {
4974 {
Node->getValueType(0),
Node->getValueType(1)},
4975 {
Node->getOperand(0),
Node->getOperand(2)});
4978 {
Node->getValueType(0),
Node->getValueType(1)},
4985 Node->getOperand(1));
4987 Node->getValueType(0),
4992 unsigned Offset =
Node->isStrictFPOpcode() ? 1 : 0;
4993 bool ExponentHasSizeOfInt =
4995 Node->getOperand(1 +
Offset).getValueType().getSizeInBits();
4996 if (!ExponentHasSizeOfInt) {
5003 ExpandFPLibCall(Node, LC,
Results);
5008 ExpandFPLibCall(Node, RTLIB::POW_F32, RTLIB::POW_F64, RTLIB::POW_F80,
5009 RTLIB::POW_F128, RTLIB::POW_PPCF128,
Results);
5013 ExpandArgFPLibCall(Node, RTLIB::LROUND_F32,
5014 RTLIB::LROUND_F64, RTLIB::LROUND_F80,
5016 RTLIB::LROUND_PPCF128,
Results);
5020 ExpandArgFPLibCall(Node, RTLIB::LLROUND_F32,
5021 RTLIB::LLROUND_F64, RTLIB::LLROUND_F80,
5022 RTLIB::LLROUND_F128,
5023 RTLIB::LLROUND_PPCF128,
Results);
5027 ExpandArgFPLibCall(Node, RTLIB::LRINT_F32,
5028 RTLIB::LRINT_F64, RTLIB::LRINT_F80,
5030 RTLIB::LRINT_PPCF128,
Results);
5034 ExpandArgFPLibCall(Node, RTLIB::LLRINT_F32,
5035 RTLIB::LLRINT_F64, RTLIB::LLRINT_F80,
5037 RTLIB::LLRINT_PPCF128,
Results);
5042 {RTLIB::FAST_DIV_F32, RTLIB::DIV_F32},
5043 {RTLIB::FAST_DIV_F64, RTLIB::DIV_F64},
5044 {RTLIB::FAST_DIV_F80, RTLIB::DIV_F80},
5045 {RTLIB::FAST_DIV_F128, RTLIB::DIV_F128},
5046 {RTLIB::FAST_DIV_PPCF128, RTLIB::DIV_PPCF128},
Results);
5051 ExpandFPLibCall(Node, RTLIB::REM_F32, RTLIB::REM_F64,
5052 RTLIB::REM_F80, RTLIB::REM_F128,
5057 ExpandFPLibCall(Node, RTLIB::FMA_F32, RTLIB::FMA_F64,
5058 RTLIB::FMA_F80, RTLIB::FMA_F128,
5064 {RTLIB::FAST_ADD_F32, RTLIB::ADD_F32},
5065 {RTLIB::FAST_ADD_F64, RTLIB::ADD_F64},
5066 {RTLIB::FAST_ADD_F80, RTLIB::ADD_F80},
5067 {RTLIB::FAST_ADD_F128, RTLIB::ADD_F128},
5068 {RTLIB::FAST_ADD_PPCF128, RTLIB::ADD_PPCF128},
Results);
5074 {RTLIB::FAST_MUL_F32, RTLIB::MUL_F32},
5075 {RTLIB::FAST_MUL_F64, RTLIB::MUL_F64},
5076 {RTLIB::FAST_MUL_F80, RTLIB::MUL_F80},
5077 {RTLIB::FAST_MUL_F128, RTLIB::MUL_F128},
5078 {RTLIB::FAST_MUL_PPCF128, RTLIB::MUL_PPCF128},
Results);
5082 if (
Node->getValueType(0) == MVT::f32) {
5083 Results.push_back(ExpandLibCall(RTLIB::FPEXT_F16_F32, Node,
false).first);
5087 if (
Node->getValueType(0) == MVT::f32) {
5088 std::pair<SDValue, SDValue> Tmp = TLI.
makeLibCall(
5089 DAG, RTLIB::FPEXT_BF16_F32, MVT::f32,
Node->getOperand(1),
5090 CallOptions, SDLoc(Node),
Node->getOperand(0));
5092 Results.push_back(Tmp.second);
5096 if (
Node->getValueType(0) == MVT::f32) {
5097 std::pair<SDValue, SDValue> Tmp = TLI.
makeLibCall(
5098 DAG, RTLIB::FPEXT_F16_F32, MVT::f32,
Node->getOperand(1), CallOptions,
5099 SDLoc(Node),
Node->getOperand(0));
5101 Results.push_back(Tmp.second);
5108 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unable to expand fp_to_fp16");
5109 Results.push_back(ExpandLibCall(LC, Node,
false).first);
5115 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unable to expand fp_to_bf16");
5116 Results.push_back(ExpandLibCall(LC, Node,
false).first);
5124 bool IsStrict =
Node->isStrictFPOpcode();
5127 EVT SVT =
Node->getOperand(IsStrict ? 1 : 0).getValueType();
5128 EVT RVT =
Node->getValueType(0);
5135 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5136 for (
unsigned t = MVT::FIRST_INTEGER_VALUETYPE;
5137 t <= MVT::LAST_INTEGER_VALUETYPE && LC == RTLIB::UNKNOWN_LIBCALL;
5145 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unable to legalize as libcall");
5150 NVT,
Node->getOperand(IsStrict ? 1 : 0));
5152 std::pair<SDValue, SDValue> Tmp =
5156 Results.push_back(Tmp.second);
5164 bool IsStrict =
Node->isStrictFPOpcode();
5169 EVT SVT =
Op.getValueType();
5170 EVT RVT =
Node->getValueType(0);
5177 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5178 for (
unsigned IntVT = MVT::FIRST_INTEGER_VALUETYPE;
5179 IntVT <= MVT::LAST_INTEGER_VALUETYPE && LC == RTLIB::UNKNOWN_LIBCALL;
5187 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unable to legalize as libcall");
5190 std::pair<SDValue, SDValue> Tmp =
5196 Results.push_back(Tmp.second);
5207 bool IsStrict =
Node->isStrictFPOpcode();
5210 EVT VT =
Node->getValueType(0);
5212 "Unable to expand as libcall if it is not normal rounding");
5215 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unable to legalize as libcall");
5217 std::pair<SDValue, SDValue> Tmp =
5218 TLI.
makeLibCall(DAG, LC, VT,
Op, CallOptions, SDLoc(Node), Chain);
5221 Results.push_back(Tmp.second);
5227 Node->getValueType(0)),
5228 Node,
false).first);
5234 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5241 Node->getValueType(0));
5243 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unable to legalize as libcall");
5245 std::pair<SDValue, SDValue> Tmp =
5247 CallOptions, SDLoc(Node),
Node->getOperand(0));
5249 Results.push_back(Tmp.second);
5255 {RTLIB::FAST_SUB_F32, RTLIB::SUB_F32},
5256 {RTLIB::FAST_SUB_F64, RTLIB::SUB_F64},
5257 {RTLIB::FAST_SUB_F80, RTLIB::SUB_F80},
5258 {RTLIB::FAST_SUB_F128, RTLIB::SUB_F128},
5259 {RTLIB::FAST_SUB_PPCF128, RTLIB::SUB_PPCF128},
Results);
5263 Results.push_back(ExpandIntLibCall(Node,
true,
5265 RTLIB::SREM_I16, RTLIB::SREM_I32,
5266 RTLIB::SREM_I64, RTLIB::SREM_I128));
5269 Results.push_back(ExpandIntLibCall(Node,
false,
5271 RTLIB::UREM_I16, RTLIB::UREM_I32,
5272 RTLIB::UREM_I64, RTLIB::UREM_I128));
5275 Results.push_back(ExpandIntLibCall(Node,
true,
5277 RTLIB::SDIV_I16, RTLIB::SDIV_I32,
5278 RTLIB::SDIV_I64, RTLIB::SDIV_I128));
5281 Results.push_back(ExpandIntLibCall(Node,
false,
5283 RTLIB::UDIV_I16, RTLIB::UDIV_I32,
5284 RTLIB::UDIV_I64, RTLIB::UDIV_I128));
5289 ExpandDivRemLibCall(Node,
Results);
5292 Results.push_back(ExpandIntLibCall(Node,
false,
5294 RTLIB::MUL_I16, RTLIB::MUL_I32,
5295 RTLIB::MUL_I64, RTLIB::MUL_I128));
5298 Results.push_back(ExpandBitCountingLibCall(
5299 Node, RTLIB::CTLZ_I32, RTLIB::CTLZ_I64, RTLIB::CTLZ_I128));
5302 Results.push_back(ExpandBitCountingLibCall(
5303 Node, RTLIB::CTPOP_I32, RTLIB::CTPOP_I64, RTLIB::CTPOP_I128));
5332 EVT ModeVT =
Node->getValueType(0);
5336 Node->getOperand(0), dl);
5338 ModeVT, dl, Chain, StackPtr,
5348 EVT ModeVT =
Mode.getValueType();
5352 Node->getOperand(0), dl,
Mode, StackPtr,
5366 Node->getOperand(0), dl));
5373 LLVM_DEBUG(
dbgs() <<
"Successfully converted node to libcall\n");
5374 ReplaceNode(Node,
Results.data());
5382 MVT EltVT,
MVT NewEltVT) {
5384 MVT MidVT = OldEltsPerNewElt == 1
5391void SelectionDAGLegalize::PromoteNode(SDNode *Node) {
5394 MVT OVT =
Node->getSimpleValueType(0);
5404 OVT =
Node->getOperand(0).getSimpleValueType();
5411 Node->getOpcode() == ISD::VP_REDUCE_FADD ||
5412 Node->getOpcode() == ISD::VP_REDUCE_FMUL ||
5413 Node->getOpcode() == ISD::VP_REDUCE_FMAX ||
5414 Node->getOpcode() == ISD::VP_REDUCE_FMIN ||
5415 Node->getOpcode() == ISD::VP_REDUCE_FMAXIMUM ||
5416 Node->getOpcode() == ISD::VP_REDUCE_FMINIMUM ||
5417 Node->getOpcode() == ISD::VP_REDUCE_SEQ_FADD)
5418 OVT =
Node->getOperand(1).getSimpleValueType();
5421 OVT =
Node->getOperand(2).getSimpleValueType();
5424 SelectionDAG::FlagInserter FlagsInserter(DAG, FastMathFlags);
5427 SDValue Tmp1, Tmp2, Tmp3, Tmp4;
5428 switch (
Node->getOpcode()) {
5440 unsigned NewOpc =
Node->getOpcode();
5453 Tmp1 = DAG.
getNode(NewOpc, dl, NVT, Tmp1);
5469 auto AnyExtendedNode =
5475 auto LeftShiftResult =
5479 auto CTLZResult = DAG.
getNode(
Node->getOpcode(), dl, NVT, LeftShiftResult);
5487 Tmp1 = DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1);
5498 PromoteLegalFP_TO_INT(Node, dl,
Results);
5502 Results.push_back(PromoteLegalFP_TO_INT_SAT(Node, dl));
5508 PromoteLegalINT_TO_FP(Node, dl,
Results);
5519 &&
"VAARG promotion is supported only for vectors or integer types");
5524 Tmp1 = DAG.
getVAArg(NVT, dl, Chain, Ptr,
Node->getOperand(2),
5525 Node->getConstantOperandVal(3));
5528 Tmp2 = DAG.
getNode(TruncOp, dl, OVT, Tmp1);
5535 UpdatedNodes->insert(Tmp2.
getNode());
5536 UpdatedNodes->insert(Chain.
getNode());
5553 unsigned ExtOp, TruncOp;
5560 switch (
Node->getOpcode()) {
5585 Tmp1 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(0));
5586 Tmp2 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(1));
5588 Tmp1 = DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1, Tmp2);
5597 Tmp1 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(0));
5598 Tmp2 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(1));
5609 unsigned ExtOp, TruncOp;
5610 if (
Node->getValueType(0).isVector() ||
5614 }
else if (
Node->getValueType(0).isInteger()) {
5621 Tmp1 =
Node->getOperand(0);
5623 Tmp2 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(1));
5624 Tmp3 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(2));
5626 Tmp1 = DAG.
getSelect(dl, NVT, Tmp1, Tmp2, Tmp3);
5628 Tmp1 = DAG.
getNode(TruncOp, dl,
Node->getValueType(0), Tmp1);
5630 Tmp1 = DAG.
getNode(TruncOp, dl,
Node->getValueType(0), Tmp1,
5643 Tmp1 = ShuffleWithNarrowerEltType(NVT, OVT, dl, Tmp1, Tmp2, Mask);
5652 Node->getOperand(2));
5660 MVT CVT =
Node->getSimpleValueType(0);
5661 assert(CVT == OVT &&
"not handled");
5670 Tmp1 =
Node->getOperand(0);
5671 Tmp2 =
Node->getOperand(1);
5673 Tmp1 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(0));
5674 Tmp2 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(1));
5677 Tmp3 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(2));
5678 Tmp4 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(3));
5705 if (
Node->isStrictFPOpcode()) {
5707 std::tie(Tmp1, std::ignore) =
5709 std::tie(Tmp2, std::ignore) =
5713 SDVTList VTs = DAG.
getVTList(
Node->getValueType(0), MVT::Other);
5715 {OutChain, Tmp1, Tmp2, Node->getOperand(3)},
5720 Tmp1 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(0));
5721 Tmp2 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(1));
5723 Tmp2,
Node->getOperand(2),
Node->getFlags()));
5733 Tmp1 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(2));
5734 Tmp2 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(3));
5736 Node->getOperand(0),
Node->getOperand(1),
5737 Tmp1, Tmp2,
Node->getOperand(4)));
5755 Tmp3 = DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1, Tmp2);
5764 SDVTList VTs = DAG.
getVTList(NVT, MVT::Other);
5766 Node->getOperand(1));
5768 Node->getOperand(2));
5789 {
Node->getOperand(0),
Node->getOperand(1)});
5791 {
Node->getOperand(0),
Node->getOperand(2)});
5794 Tmp1 = DAG.
getNode(
Node->getOpcode(), dl, {NVT, MVT::Other},
5795 {Tmp3, Tmp1, Tmp2});
5808 DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1, Tmp2, Tmp3),
5813 {
Node->getOperand(0),
Node->getOperand(1)});
5815 {
Node->getOperand(0),
Node->getOperand(2)});
5817 {
Node->getOperand(0),
Node->getOperand(3)});
5820 Tmp4 = DAG.
getNode(
Node->getOpcode(), dl, {NVT, MVT::Other},
5821 {Tmp4, Tmp1, Tmp2, Tmp3});
5832 Tmp2 =
Node->getOperand(1);
5833 Tmp3 = DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1, Tmp2);
5848 {
Node->getOperand(0),
Node->getOperand(1)});
5849 Tmp2 =
Node->getOperand(2);
5861 {
Node->getOperand(0),
Node->getOperand(1)});
5862 Tmp2 = DAG.
getNode(
Node->getOpcode(), dl, {NVT, MVT::Other},
5863 {Tmp1.getValue(1), Tmp1, Node->getOperand(2)});
5887 for (
unsigned ResNum = 0; ResNum <
Node->getNumValues(); ResNum++)
5919 Tmp2 = DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1);
5947 {
Node->getOperand(0),
Node->getOperand(1)});
5948 Tmp2 = DAG.
getNode(
Node->getOpcode(), dl, {NVT, MVT::Other},
5949 {Tmp1.getValue(1), Tmp1});
5967 "Invalid promote type for build_vector");
6000 "Invalid promote type for extract_vector_elt");
6015 for (
unsigned I = 0;
I < NewEltsPerOldElt; ++
I) {
6046 "Invalid promote type for insert_vector_elt");
6064 for (
unsigned I = 0;
I < NewEltsPerOldElt; ++
I) {
6069 CastVal, IdxOffset);
6072 NewVec, Elt, InEltIdx);
6112 "unexpected promotion type");
6114 "unexpected atomic_swap with illegal type");
6138 "unexpected promotion type");
6140 "unexpected atomic_load with illegal type");
6151 MVT ScalarType =
Scalar.getSimpleValueType();
6155 Tmp2 = DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1);
6160 Tmp2 = DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1);
6170 case ISD::VP_REDUCE_FMAX:
6171 case ISD::VP_REDUCE_FMIN:
6172 case ISD::VP_REDUCE_FMAXIMUM:
6173 case ISD::VP_REDUCE_FMINIMUM:
6174 Results.push_back(PromoteReduction(Node));
6181 ReplaceNode(Node,
Results.data());
6199 SelectionDAGLegalize
Legalizer(*
this, LegalizedNodes);
6206 bool AnyLegalized =
false;
6217 if (LegalizedNodes.
insert(
N).second) {
6218 AnyLegalized =
true;
6239 SelectionDAGLegalize
Legalizer(*
this, LegalizedNodes, &UpdatedNodes);
6246 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
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Utilities for dealing with flags related to floating point properties and mode controls.
static MaybeAlign getAlign(Value *Ptr)
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 TargetLowering &TLI)
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.
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton 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.
ArrayRef - 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...
static LLVM_ABI Constant * get(ArrayRef< Constant * > V)
bool isLittleEndian() const
Layout endianness...
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...
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.
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, LLT MemTy, Align base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
Function & getFunction()
Return the LLVM function that this machine code represents.
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 a 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...
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.
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 AAMDNodes &AAInfo=AAMDNodes())
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.
SDValue getSetCC(const SDLoc &DL, EVT VT, SDValue LHS, SDValue RHS, ISD::CondCode Cond, SDValue Chain=SDValue(), bool IsSignaling=false)
Helper function to make it easier to build SetCC's if you just have an ISD::CondCode instead of an SD...
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.
LLVM_ABI SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, MaybeAlign Alignment=MaybeAlign(), MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr)
Loads are not normal binary operators: their result type is not determined by their operands,...
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
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.
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 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 SDValue getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, EVT SVT, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
LLVM_ABI void ReplaceAllUsesWith(SDValue From, SDValue To)
Modify anything using 'From' to use 'To' instead.
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 getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
Helper function to build ISD::STORE nodes.
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 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 getVPLogicalNOT(const SDLoc &DL, SDValue Val, SDValue Mask, SDValue EVL, EVT VT)
Create a vector-predicated logical NOT operation as (VP_XOR Val, BooleanOne, Mask,...
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...
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.
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...
CallingConv::ID getLibcallImplCallingConv(RTLIB::LibcallImpl Call) const
Get the CallingConv that should be used for the specified libcall implementation.
virtual bool isFPImmLegal(const APFloat &, EVT, bool ForCodeSize=false) const
Returns true if the target can instruction select the specified FP immediate natively.
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.
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.
LegalizeAction getTruncStoreAction(EVT ValVT, EVT MemVT) const
Return how this store with truncation should be treated: either it is legal, needs to be promoted to ...
LegalizeAction getLoadExtAction(unsigned ExtType, EVT ValVT, EVT MemVT) const
Return how this load with extension should be treated: either it is legal, needs to be promoted to a ...
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?
bool isLoadExtLegalOrCustom(unsigned ExtType, EVT ValVT, EVT MemVT) const
Return true if the specified load with extension is legal or custom on this target.
LegalizeAction getStrictFPOperationAction(unsigned Op, EVT VT) const
bool isLoadExtLegal(unsigned ExtType, EVT ValVT, EVT MemVT) const
Return true if the specified load with extension is legal on this target.
RTLIB::LibcallImpl getLibcallImpl(RTLIB::Libcall Call) const
Get the libcall impl routine name for the specified libcall.
virtual bool useSoftFloat() const
bool isTruncStoreLegalOrCustom(EVT ValVT, EVT MemVT) const
Return true if the specified store with truncation has solution on this target.
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 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...
MVT getRegisterType(MVT VT) const
Return the type of registers that this ValueType will eventually require.
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.
SDValue expandCTLZ(SDNode *N, SelectionDAG &DAG) const
Expand CTLZ/CTLZ_ZERO_UNDEF nodes.
SDValue expandBITREVERSE(SDNode *N, SelectionDAG &DAG) const
Expand BITREVERSE nodes.
SDValue expandCTTZ(SDNode *N, SelectionDAG &DAG) const
Expand CTTZ/CTTZ_ZERO_UNDEF 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 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_UNDEF 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 expandFunnelShift(SDNode *N, SelectionDAG &DAG) const
Expand funnel shift.
bool LegalizeSetCCCondCode(SelectionDAG &DAG, EVT VT, SDValue &LHS, SDValue &RHS, SDValue &CC, SDValue Mask, SDValue EVL, bool &NeedInvert, const SDLoc &dl, SDValue &Chain, bool IsSignaling=false) const
Legalize a SETCC or VP_SETCC with given LHS and RHS and condition code CC on the current target.
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 expandFP_ROUND(SDNode *Node, SelectionDAG &DAG) const
Expand round(fp) to fp conversion.
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.
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.
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.
@ Fast
Attempts to make calls as fast as possible (e.g.
@ 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.
@ 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.
@ 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.
@ 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.
@ 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.
@ CTTZ_ZERO_UNDEF
Bit counting operators with an undefined result for zero inputs.
@ PREFETCH
PREFETCH - This corresponds to a prefetch intrinsic.
@ 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.
@ 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.
@ 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.
@ 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],...
@ 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.
@ VECTOR_SPLICE
VECTOR_SPLICE(VEC1, VEC2, IMM) - Returns a subvector of the same type as VEC1/VEC2 from CONCAT_VECTOR...
@ ATOMIC_SWAP
Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt) Val, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN,...
@ 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.
@ 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...
@ 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 getPOWI(EVT RetVT)
getPOWI - Return the POWI_* value for the given types, or UNKNOWN_LIBCALL if there is none.
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 getLDEXP(EVT RetVT)
getLDEXP - Return the LDEXP_* value for the given types, 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 getFREXP(EVT RetVT)
getFREXP - Return the FREXP_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getSINCOSPI(EVT RetVT)
getSINCOSPI - Return the SINCOSPI_* 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 getMODF(EVT VT)
getMODF - Return the MODF_* 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.
LLVM_ABI Libcall getSINCOS_STRET(EVT RetVT)
Return the SINCOS_STRET_ value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getSINCOS(EVT RetVT)
getSINCOS - Return the SINCOS_* value for the given types, or UNKNOWN_LIBCALL if there is none.
@ Undef
Value of the register doesn't matter.
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.
FunctionAddr VTableAddr Value
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
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.
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.
constexpr uint64_t value() const
This is a hole in the type system and should not be abused.
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.
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.
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 setNoFPExcept(bool b)
void setNoUnsignedWrap(bool b)
void setNoSignedWrap(bool b)
bool IsPostTypeLegalization
MakeLibCallOptions & setIsSigned(bool Value=true)