58#define DEBUG_TYPE "legalizedag"
64struct FloatSignAsInt {
87class SelectionDAGLegalize {
99 EVT getSetCCResultType(
EVT VT)
const {
110 LegalizedNodes(LegalizedNodes), UpdatedNodes(UpdatedNodes) {}
165 void getSignAsIntValue(FloatSignAsInt &State,
const SDLoc &
DL,
167 SDValue modifySignAsInt(
const FloatSignAsInt &State,
const SDLoc &
DL,
214 dbgs() <<
" with: "; New->dump(&DAG));
217 "Replacing one node with another that produces a different number "
221 UpdatedNodes->
insert(New);
227 dbgs() <<
" with: "; New->dump(&DAG));
231 UpdatedNodes->
insert(New.getNode());
232 ReplacedNode(Old.getNode());
239 for (
unsigned i = 0, e = Old->
getNumValues(); i != e; ++i) {
250 dbgs() <<
" with: "; New->dump(&DAG));
254 UpdatedNodes->
insert(New.getNode());
255 ReplacedNode(Old.getNode());
265 bool isObjectScalable) {
267 int FI = cast<FrameIndexSDNode>(StackPtr)->getIndex();
273 ObjectSize, MFI.getObjectAlign(FI));
280SDValue SelectionDAGLegalize::ShuffleWithNarrowerEltType(
285 unsigned NumEltsGrowth = NumDestElts / NumMaskElts;
287 assert(NumEltsGrowth &&
"Cannot promote to vector type with fewer elts!");
289 if (NumEltsGrowth == 1)
290 return DAG.getVectorShuffle(NVT, dl, N1, N2, Mask);
293 for (
unsigned i = 0; i != NumMaskElts; ++i) {
295 for (
unsigned j = 0;
j != NumEltsGrowth; ++
j) {
302 assert(NewMask.
size() == NumDestElts &&
"Non-integer NumEltsGrowth?");
303 assert(TLI.isShuffleMaskLegal(NewMask, NVT) &&
"Shuffle not legal?");
304 return DAG.getVectorShuffle(NVT, dl, N1, N2, NewMask);
323 assert((VT == MVT::f64 || VT == MVT::f32) &&
"Invalid type expansion");
325 (VT == MVT::f64) ? MVT::i64 : MVT::i32);
335 while (SVT != MVT::f32 && SVT != MVT::f16 && SVT != MVT::bf16) {
341 TLI.ShouldShrinkFPConstant(OrigVT)) {
344 Instruction::FPTrunc, LLVMC, SType, DAG.getDataLayout()));
352 DAG.getConstantPool(LLVMC, TLI.getPointerTy(DAG.getDataLayout()));
353 Align Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlign();
362 OrigVT, dl, DAG.getEntryNode(), CPIdx,
370 EVT VT =
CP->getValueType(0);
371 SDValue CPIdx = DAG.getConstantPool(
CP->getConstantIntValue(),
372 TLI.getPointerTy(DAG.getDataLayout()));
373 Align Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlign();
375 VT, dl, DAG.getEntryNode(), CPIdx,
401 for (
unsigned i = 0; i != NumElts; ++i)
402 ShufOps.
push_back(i != InsertPos->getZExtValue() ? i : NumElts);
404 return DAG.getVectorShuffle(Vec.
getValueType(), dl, Vec, ScVec, ShufOps);
407 return ExpandInsertToVectorThroughStack(
Op);
434 TLI.isTypeLegal(MVT::i32)) {
436 bitcastToAPInt().zextOrTrunc(32),
437 SDLoc(CFP), MVT::i32);
438 return DAG.getStore(Chain, dl, Con,
Ptr,
ST->getPointerInfo(),
439 ST->getOriginalAlign(), MMOFlags, AAInfo);
445 if (TLI.isTypeLegal(MVT::i64)) {
447 zextOrTrunc(64),
SDLoc(CFP), MVT::i64);
448 return DAG.getStore(Chain, dl, Con,
Ptr,
ST->getPointerInfo(),
449 ST->getOriginalAlign(), MMOFlags, AAInfo);
452 if (TLI.isTypeLegal(MVT::i32) && !
ST->isVolatile()) {
459 if (DAG.getDataLayout().isBigEndian())
462 Lo = DAG.getStore(Chain, dl,
Lo,
Ptr,
ST->getPointerInfo(),
463 ST->getOriginalAlign(), MMOFlags, AAInfo);
465 Hi = DAG.getStore(Chain, dl,
Hi,
Ptr,
466 ST->getPointerInfo().getWithOffset(4),
467 ST->getOriginalAlign(), MMOFlags, AAInfo);
476void SelectionDAGLegalize::LegalizeStoreOps(
SDNode *
Node) {
485 if (!
ST->isTruncatingStore()) {
488 ReplaceNode(ST, OptStore);
493 MVT VT =
Value.getSimpleValueType();
494 switch (TLI.getOperationAction(
ISD::STORE, VT)) {
496 case TargetLowering::Legal: {
499 EVT MemVT =
ST->getMemoryVT();
501 if (!TLI.allowsMemoryAccessForAlignment(*DAG.getContext(),
DL, MemVT,
502 *
ST->getMemOperand())) {
505 ReplaceNode(
SDValue(ST, 0), Result);
510 case TargetLowering::Custom: {
517 case TargetLowering::Promote: {
520 "Can only promote stores to same size type");
523 ST->getOriginalAlign(), MMOFlags, AAInfo);
533 EVT StVT =
ST->getMemoryVT();
536 auto &
DL = DAG.getDataLayout();
538 if (StWidth != StSize) {
543 Value = DAG.getZeroExtendInReg(
Value, dl, StVT);
545 DAG.getTruncStore(Chain, dl,
Value,
Ptr,
ST->getPointerInfo(), NVT,
546 ST->getOriginalAlign(), MMOFlags, AAInfo);
552 unsigned LogStWidth =
Log2_32(StWidthBits);
554 unsigned RoundWidth = 1 << LogStWidth;
555 assert(RoundWidth < StWidthBits);
556 unsigned ExtraWidth = StWidthBits - RoundWidth;
557 assert(ExtraWidth < RoundWidth);
558 assert(!(RoundWidth % 8) && !(ExtraWidth % 8) &&
559 "Store size not an integral number of bytes!");
563 unsigned IncrementSize;
565 if (
DL.isLittleEndian()) {
568 Lo = DAG.getTruncStore(Chain, dl,
Value,
Ptr,
ST->getPointerInfo(),
569 RoundVT,
ST->getOriginalAlign(), MMOFlags, AAInfo);
572 IncrementSize = RoundWidth / 8;
577 DAG.getConstant(RoundWidth, dl,
578 TLI.getShiftAmountTy(
Value.getValueType(),
DL)));
579 Hi = DAG.getTruncStore(Chain, dl,
Hi,
Ptr,
580 ST->getPointerInfo().getWithOffset(IncrementSize),
581 ExtraVT,
ST->getOriginalAlign(), MMOFlags, AAInfo);
588 DAG.getConstant(ExtraWidth, dl,
589 TLI.getShiftAmountTy(
Value.getValueType(),
DL)));
590 Hi = DAG.getTruncStore(Chain, dl,
Hi,
Ptr,
ST->getPointerInfo(), RoundVT,
591 ST->getOriginalAlign(), MMOFlags, AAInfo);
594 IncrementSize = RoundWidth / 8;
596 DAG.getConstant(IncrementSize, dl,
597 Ptr.getValueType()));
599 ST->getPointerInfo().getWithOffset(IncrementSize),
600 ExtraVT,
ST->getOriginalAlign(), MMOFlags, AAInfo);
607 switch (TLI.getTruncStoreAction(
ST->getValue().getValueType(), StVT)) {
609 case TargetLowering::Legal: {
610 EVT MemVT =
ST->getMemoryVT();
613 if (!TLI.allowsMemoryAccessForAlignment(*DAG.getContext(),
DL, MemVT,
614 *
ST->getMemOperand())) {
616 ReplaceNode(
SDValue(ST, 0), Result);
620 case TargetLowering::Custom: {
626 case TargetLowering::Expand:
628 "Vector Stores are handled in LegalizeVectorOps");
633 if (TLI.isTypeLegal(StVT)) {
636 ST->getOriginalAlign(), MMOFlags, AAInfo);
641 TLI.getTypeToTransformTo(*DAG.getContext(), StVT),
644 DAG.getTruncStore(Chain, dl,
Value,
Ptr,
ST->getPointerInfo(), StVT,
645 ST->getOriginalAlign(), MMOFlags, AAInfo);
654void SelectionDAGLegalize::LegalizeLoadOps(
SDNode *
Node) {
663 LLVM_DEBUG(
dbgs() <<
"Legalizing non-extending load operation\n");
664 MVT VT =
Node->getSimpleValueType(0);
668 switch (TLI.getOperationAction(
Node->getOpcode(), VT)) {
670 case TargetLowering::Legal: {
671 EVT MemVT =
LD->getMemoryVT();
675 if (!TLI.allowsMemoryAccessForAlignment(*DAG.getContext(),
DL, MemVT,
676 *
LD->getMemOperand())) {
677 std::tie(RVal, RChain) = TLI.expandUnalignedLoad(LD, DAG);
681 case TargetLowering::Custom:
682 if (
SDValue Res = TLI.LowerOperation(RVal, DAG)) {
688 case TargetLowering::Promote: {
689 MVT NVT = TLI.getTypeToPromoteTo(
Node->getOpcode(), VT);
691 "Can only promote loads to same size type");
693 SDValue Res = DAG.getLoad(NVT, dl, Chain,
Ptr,
LD->getMemOperand());
701 DAG.ReplaceAllUsesOfValueWith(
SDValue(
Node, 0), RVal);
702 DAG.ReplaceAllUsesOfValueWith(
SDValue(
Node, 1), RChain);
704 UpdatedNodes->insert(RVal.
getNode());
705 UpdatedNodes->insert(RChain.
getNode());
713 EVT SrcVT =
LD->getMemoryVT();
727 TLI.getLoadExtAction(ExtType,
Node->getValueType(0), MVT::i1) ==
728 TargetLowering::Promote)) {
742 Chain,
Ptr,
LD->getPointerInfo(), NVT,
743 LD->getOriginalAlign(), MMOFlags, AAInfo);
751 Result, DAG.getValueType(SrcVT));
755 Result.getValueType(), Result,
756 DAG.getValueType(SrcVT));
764 unsigned LogSrcWidth =
Log2_32(SrcWidthBits);
766 unsigned RoundWidth = 1 << LogSrcWidth;
767 assert(RoundWidth < SrcWidthBits);
768 unsigned ExtraWidth = SrcWidthBits - RoundWidth;
769 assert(ExtraWidth < RoundWidth);
770 assert(!(RoundWidth % 8) && !(ExtraWidth % 8) &&
771 "Load size not an integral number of bytes!");
775 unsigned IncrementSize;
776 auto &
DL = DAG.getDataLayout();
778 if (
DL.isLittleEndian()) {
782 LD->getPointerInfo(), RoundVT,
LD->getOriginalAlign(),
786 IncrementSize = RoundWidth / 8;
789 Hi = DAG.getExtLoad(ExtType, dl,
Node->getValueType(0), Chain,
Ptr,
790 LD->getPointerInfo().getWithOffset(IncrementSize),
791 ExtraVT,
LD->getOriginalAlign(), MMOFlags, AAInfo);
801 DAG.getConstant(RoundWidth, dl,
802 TLI.getShiftAmountTy(
Hi.getValueType(),
DL)));
810 Hi = DAG.getExtLoad(ExtType, dl,
Node->getValueType(0), Chain,
Ptr,
811 LD->getPointerInfo(), RoundVT,
LD->getOriginalAlign(),
815 IncrementSize = RoundWidth / 8;
819 LD->getPointerInfo().getWithOffset(IncrementSize),
820 ExtraVT,
LD->getOriginalAlign(), MMOFlags, AAInfo);
830 DAG.getConstant(ExtraWidth, dl,
831 TLI.getShiftAmountTy(
Hi.getValueType(),
DL)));
839 bool isCustom =
false;
840 switch (TLI.getLoadExtAction(ExtType,
Node->getValueType(0),
843 case TargetLowering::Custom:
846 case TargetLowering::Legal:
858 EVT MemVT =
LD->getMemoryVT();
860 if (!TLI.allowsMemoryAccess(*DAG.getContext(),
DL, MemVT,
861 *
LD->getMemOperand())) {
862 std::tie(
Value, Chain) = TLI.expandUnalignedLoad(LD, DAG);
867 case TargetLowering::Expand: {
868 EVT DestVT =
Node->getValueType(0);
874 (TLI.isTypeLegal(SrcVT) ||
875 TLI.isLoadExtLegal(ExtType, LoadVT, SrcVT))) {
882 SrcVT,
LD->getMemOperand());
885 Value = DAG.getNode(ExtendOp, dl,
Node->getValueType(0), Load);
886 Chain =
Load.getValue(1);
895 if (SVT == MVT::f16 || SVT == MVT::bf16) {
901 Ptr, ISrcVT,
LD->getMemOperand());
905 Chain =
Result.getValue(1);
911 "Vector Loads are handled in LegalizeVectorOps");
918 "EXTLOAD should always be supported!");
922 Node->getValueType(0),
924 LD->getMemOperand());
929 Result, DAG.getValueType(SrcVT));
931 ValRes = DAG.getZeroExtendInReg(Result, dl, SrcVT);
933 Chain =
Result.getValue(1);
944 DAG.ReplaceAllUsesOfValueWith(
SDValue(
Node, 1), Chain);
946 UpdatedNodes->insert(
Value.getNode());
947 UpdatedNodes->insert(Chain.
getNode());
954void SelectionDAGLegalize::LegalizeOp(
SDNode *
Node) {
963 for (
unsigned i = 0, e =
Node->getNumValues(); i != e; ++i)
964 assert(TLI.getTypeAction(*DAG.getContext(),
Node->getValueType(i)) ==
965 TargetLowering::TypeLegal &&
966 "Unexpected illegal type!");
969 assert((TLI.getTypeAction(*DAG.getContext(),
Op.getValueType()) ==
970 TargetLowering::TypeLegal ||
973 "Unexpected illegal type!");
978 bool SimpleFinishLegalizing =
true;
979 switch (
Node->getOpcode()) {
984 Action = TLI.getOperationAction(
Node->getOpcode(), MVT::Other);
987 Action = TLI.getOperationAction(
Node->getOpcode(),
988 Node->getValueType(0));
991 Action = TLI.getOperationAction(
Node->getOpcode(),
992 Node->getValueType(0));
993 if (Action != TargetLowering::Promote)
994 Action = TLI.getOperationAction(
Node->getOpcode(), MVT::Other);
998 Action = TLI.getOperationAction(
Node->getOpcode(),
999 Node->getOperand(1).getValueType());
1010 Action = TLI.getOperationAction(
Node->getOpcode(),
1011 Node->getOperand(0).getValueType());
1024 Action = TLI.getOperationAction(
Node->getOpcode(),
1025 Node->getOperand(1).getValueType());
1028 EVT InnerType = cast<VTSDNode>(
Node->getOperand(1))->getVT();
1029 Action = TLI.getOperationAction(
Node->getOpcode(), InnerType);
1033 Action = TLI.getOperationAction(
Node->getOpcode(),
1034 Node->getOperand(1).getValueType());
1043 unsigned Opc =
Node->getOpcode();
1048 : (Opc ==
ISD::SETCC || Opc == ISD::VP_SETCC) ? 2
1050 unsigned CompareOperand = Opc ==
ISD::BR_CC ? 2
1054 MVT OpVT =
Node->getOperand(CompareOperand).getSimpleValueType();
1056 cast<CondCodeSDNode>(
Node->getOperand(CCOperand))->get();
1057 Action = TLI.getCondCodeAction(CCCode, OpVT);
1058 if (Action == TargetLowering::Legal) {
1060 Action = TLI.getOperationAction(
Node->getOpcode(),
1061 Node->getValueType(0));
1063 Action = TLI.getOperationAction(
Node->getOpcode(), OpVT);
1071 SimpleFinishLegalizing =
false;
1078 SimpleFinishLegalizing =
false;
1091 Action = TLI.getOperationAction(
Node->getOpcode(),
Node->getValueType(0));
1092 if (Action == TargetLowering::Legal)
1093 Action = TargetLowering::Expand;
1103 Action = TLI.getOperationAction(
Node->getOpcode(),
Node->getValueType(0));
1104 if (Action == TargetLowering::Legal)
1105 Action = TargetLowering::Custom;
1110 Action = TLI.getOperationAction(
Node->getOpcode(),
Node->getValueType(0));
1116 Action = TLI.getOperationAction(
Node->getOpcode(), MVT::i64);
1123 Action = TargetLowering::Legal;
1126 Action = TLI.getOperationAction(
Node->getOpcode(),
Node->getValueType(0));
1127 if (Action == TargetLowering::Expand) {
1131 Node->getOperand(0));
1138 Action = TLI.getOperationAction(
Node->getOpcode(),
Node->getValueType(0));
1139 if (Action == TargetLowering::Expand) {
1143 Node->getOperand(0));
1159 Action = TLI.getOperationAction(
Node->getOpcode(),
Node->getValueType(0));
1169 unsigned Scale =
Node->getConstantOperandVal(2);
1170 Action = TLI.getFixedPointOperationAction(
Node->getOpcode(),
1171 Node->getValueType(0), Scale);
1175 Action = TLI.getOperationAction(
Node->getOpcode(),
1176 cast<MaskedScatterSDNode>(
Node)->getValue().getValueType());
1179 Action = TLI.getOperationAction(
Node->getOpcode(),
1180 cast<MaskedStoreSDNode>(
Node)->getValue().getValueType());
1182 case ISD::VP_SCATTER:
1183 Action = TLI.getOperationAction(
1185 cast<VPScatterSDNode>(
Node)->getValue().getValueType());
1188 Action = TLI.getOperationAction(
1190 cast<VPStoreSDNode>(
Node)->getValue().getValueType());
1192 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
1193 Action = TLI.getOperationAction(
1195 cast<VPStridedStoreSDNode>(
Node)->getValue().getValueType());
1213 Action = TLI.getOperationAction(
1214 Node->getOpcode(),
Node->getOperand(0).getValueType());
1218 case ISD::VP_REDUCE_FADD:
1219 case ISD::VP_REDUCE_FMUL:
1220 case ISD::VP_REDUCE_ADD:
1221 case ISD::VP_REDUCE_MUL:
1222 case ISD::VP_REDUCE_AND:
1223 case ISD::VP_REDUCE_OR:
1224 case ISD::VP_REDUCE_XOR:
1225 case ISD::VP_REDUCE_SMAX:
1226 case ISD::VP_REDUCE_SMIN:
1227 case ISD::VP_REDUCE_UMAX:
1228 case ISD::VP_REDUCE_UMIN:
1229 case ISD::VP_REDUCE_FMAX:
1230 case ISD::VP_REDUCE_FMIN:
1231 case ISD::VP_REDUCE_FMAXIMUM:
1232 case ISD::VP_REDUCE_FMINIMUM:
1233 case ISD::VP_REDUCE_SEQ_FADD:
1234 case ISD::VP_REDUCE_SEQ_FMUL:
1235 Action = TLI.getOperationAction(
1236 Node->getOpcode(),
Node->getOperand(1).getValueType());
1238 case ISD::VP_CTTZ_ELTS:
1239 case ISD::VP_CTTZ_ELTS_ZERO_UNDEF:
1240 Action = TLI.getOperationAction(
Node->getOpcode(),
1241 Node->getOperand(0).getValueType());
1244 Action = TLI.getOperationAction(
1246 cast<MaskedHistogramSDNode>(
Node)->getIndex().getValueType());
1250 Action = TLI.getCustomOperationAction(*
Node);
1252 Action = TLI.getOperationAction(
Node->getOpcode(),
Node->getValueType(0));
1257 if (SimpleFinishLegalizing) {
1259 switch (
Node->getOpcode()) {
1278 NewNode = DAG.UpdateNodeOperands(
Node, Op0, SAO);
1298 NewNode = DAG.UpdateNodeOperands(
Node, Op0, Op1, SAO);
1304 if (NewNode !=
Node) {
1305 ReplaceNode(
Node, NewNode);
1309 case TargetLowering::Legal:
1312 case TargetLowering::Custom:
1320 if (
Node->getNumValues() == 1) {
1324 Node->getValueType(0) == MVT::Glue) &&
1325 "Type mismatch for custom legalized operation");
1333 for (
unsigned i = 0, e =
Node->getNumValues(); i != e; ++i) {
1337 Node->getValueType(i) == MVT::Glue) &&
1338 "Type mismatch for custom legalized operation");
1342 ReplaceNode(
Node, ResultVals.
data());
1347 case TargetLowering::Expand:
1348 if (ExpandNode(
Node))
1351 case TargetLowering::LibCall:
1352 ConvertNodeToLibcall(
Node);
1354 case TargetLowering::Promote:
1360 switch (
Node->getOpcode()) {
1373 return LegalizeLoadOps(
Node);
1375 return LegalizeStoreOps(
Node);
1379SDValue SelectionDAGLegalize::ExpandExtractFromVectorThroughStack(
SDValue Op) {
1399 if (
ST->isIndexed() ||
ST->isTruncatingStore() ||
1400 ST->getValue() != Vec)
1405 if (!
ST->getChain().reachesChainWithoutSideEffects(DAG.getEntryNode()))
1414 ST->hasPredecessor(
Op.getNode()))
1427 StackPtr = DAG.CreateStackTemporary(VecVT);
1430 Ch = DAG.getStore(DAG.getEntryNode(), dl, Vec, StackPtr, StoreMMO);
1434 Align ElementAlignment =
1435 std::min(cast<StoreSDNode>(Ch)->
getAlign(),
1436 DAG.getDataLayout().getPrefTypeAlign(
1437 Op.getValueType().getTypeForEVT(*DAG.getContext())));
1439 if (
Op.getValueType().isVector()) {
1440 StackPtr = TLI.getVectorSubVecPointer(DAG, StackPtr, VecVT,
1441 Op.getValueType(),
Idx);
1442 NewLoad = DAG.getLoad(
Op.getValueType(), dl, Ch, StackPtr,
1445 StackPtr = TLI.getVectorElementPointer(DAG, StackPtr, VecVT,
Idx);
1446 NewLoad = DAG.getExtLoad(
ISD::EXTLOAD, dl,
Op.getValueType(), Ch, StackPtr,
1452 DAG.ReplaceAllUsesOfValueWith(Ch,
SDValue(NewLoad.
getNode(), 1));
1457 NewLoadOperands[0] = Ch;
1459 SDValue(DAG.UpdateNodeOperands(NewLoad.
getNode(), NewLoadOperands), 0);
1463SDValue SelectionDAGLegalize::ExpandInsertToVectorThroughStack(
SDValue Op) {
1464 assert(
Op.getValueType().isVector() &&
"Non-vector insert subvector!");
1475 int FI = cast<FrameIndexSDNode>(
StackPtr.getNode())->getIndex();
1480 Align BaseVecAlignment =
1481 DAG.getMachineFunction().getFrameInfo().getObjectAlign(FI);
1482 SDValue Ch = DAG.getStore(DAG.getEntryNode(), dl, Vec, StackPtr, PtrInfo,
1486 Idx = DAG.getFreeze(
Idx);
1489 Align PartAlignment = DAG.getDataLayout().getPrefTypeAlign(PartTy);
1494 TLI.getVectorSubVecPointer(DAG, StackPtr, VecVT, PartVT,
Idx);
1498 Ch, dl, Part, SubStackPtr,
1503 TLI.getVectorElementPointer(DAG, StackPtr, VecVT,
Idx);
1506 Ch = DAG.getTruncStore(
1507 Ch, dl, Part, SubStackPtr,
1513 "ElementAlignment does not match!");
1516 return DAG.getLoad(
Op.getValueType(), dl, Ch, StackPtr, PtrInfo,
1523 "Unexpected opcode!");
1529 EVT VT =
Node->getValueType(0);
1531 :
Node->getOperand(0).getValueType();
1533 SDValue FIPtr = DAG.CreateStackTemporary(VT);
1534 int FI = cast<FrameIndexSDNode>(FIPtr.
getNode())->getIndex();
1541 assert(TypeByteSize > 0 &&
"Vector element type too small for stack store!");
1545 bool Truncate = isa<BuildVectorSDNode>(
Node) &&
1546 MemVT.
bitsLT(
Node->getOperand(0).getValueType());
1549 for (
unsigned i = 0, e =
Node->getNumOperands(); i != e; ++i) {
1551 if (
Node->getOperand(i).isUndef())
continue;
1553 unsigned Offset = TypeByteSize*i;
1559 Stores.
push_back(DAG.getTruncStore(DAG.getEntryNode(), dl,
1563 Stores.
push_back(DAG.getStore(DAG.getEntryNode(), dl,
Node->getOperand(i),
1568 if (!Stores.
empty())
1571 StoreChain = DAG.getEntryNode();
1574 return DAG.getLoad(VT, dl, StoreChain, FIPtr, PtrInfo);
1580void SelectionDAGLegalize::getSignAsIntValue(FloatSignAsInt &State,
1583 EVT FloatVT =
Value.getValueType();
1585 State.FloatVT = FloatVT;
1588 if (TLI.isTypeLegal(IVT)) {
1591 State.SignBit = NumBits - 1;
1597 MVT LoadTy = TLI.getRegisterType(MVT::i8);
1600 int FI = cast<FrameIndexSDNode>(
StackPtr.getNode())->getIndex();
1605 State.Chain = DAG.getStore(DAG.getEntryNode(),
DL,
Value, State.FloatPtr,
1606 State.FloatPointerInfo);
1613 State.IntPointerInfo = State.FloatPointerInfo;
1616 unsigned ByteOffset = (NumBits / 8) - 1;
1623 State.IntPtr = IntPtr;
1624 State.IntValue = DAG.getExtLoad(
ISD::EXTLOAD,
DL, LoadTy, State.Chain, IntPtr,
1625 State.IntPointerInfo, MVT::i8);
1632SDValue SelectionDAGLegalize::modifySignAsInt(
const FloatSignAsInt &State,
1639 SDValue Chain = DAG.getTruncStore(State.Chain,
DL, NewIntValue, State.IntPtr,
1640 State.IntPointerInfo, MVT::i8);
1641 return DAG.getLoad(State.FloatVT,
DL, Chain, State.FloatPtr,
1642 State.FloatPointerInfo);
1651 FloatSignAsInt SignAsInt;
1652 getSignAsIntValue(SignAsInt,
DL, Sign);
1654 EVT IntVT = SignAsInt.IntValue.getValueType();
1655 SDValue SignMask = DAG.getConstant(SignAsInt.SignMask,
DL, IntVT);
1662 if (TLI.isOperationLegalOrCustom(
ISD::FABS, FloatVT) &&
1663 TLI.isOperationLegalOrCustom(
ISD::FNEG, FloatVT)) {
1666 SDValue Cond = DAG.getSetCC(
DL, getSetCCResultType(IntVT), SignBit,
1668 return DAG.getSelect(
DL, FloatVT,
Cond, NegValue, AbsValue);
1672 FloatSignAsInt MagAsInt;
1673 getSignAsIntValue(MagAsInt,
DL, Mag);
1674 EVT MagVT = MagAsInt.IntValue.getValueType();
1675 SDValue ClearSignMask = DAG.getConstant(~MagAsInt.SignMask,
DL, MagVT);
1680 int ShiftAmount = SignAsInt.SignBit - MagAsInt.SignBit;
1681 EVT ShiftVT = IntVT;
1687 if (ShiftAmount > 0) {
1688 SDValue ShiftCnst = DAG.getConstant(ShiftAmount,
DL, ShiftVT);
1690 }
else if (ShiftAmount < 0) {
1691 SDValue ShiftCnst = DAG.getConstant(-ShiftAmount,
DL, ShiftVT);
1703 return modifySignAsInt(MagAsInt,
DL, CopiedSign);
1709 FloatSignAsInt SignAsInt;
1710 getSignAsIntValue(SignAsInt,
DL,
Node->getOperand(0));
1711 EVT IntVT = SignAsInt.IntValue.getValueType();
1714 SDValue SignMask = DAG.getConstant(SignAsInt.SignMask,
DL, IntVT);
1719 return modifySignAsInt(SignAsInt,
DL, SignFlip);
1727 EVT FloatVT =
Value.getValueType();
1734 FloatSignAsInt ValueAsInt;
1735 getSignAsIntValue(ValueAsInt,
DL,
Value);
1736 EVT IntVT = ValueAsInt.IntValue.getValueType();
1737 SDValue ClearSignMask = DAG.getConstant(~ValueAsInt.SignMask,
DL, IntVT);
1740 return modifySignAsInt(ValueAsInt,
DL, ClearedSign);
1743void SelectionDAGLegalize::ExpandDYNAMIC_STACKALLOC(
SDNode*
Node,
1745 Register SPReg = TLI.getStackPointerRegisterToSaveRestore();
1746 assert(
SPReg &&
"Target cannot require DYNAMIC_STACKALLOC expansion and"
1747 " not tell us which reg is the stack pointer!");
1749 EVT VT =
Node->getValueType(0);
1757 Chain = DAG.getCALLSEQ_START(Chain, 0, 0, dl);
1762 Align Alignment = cast<ConstantSDNode>(Tmp3)->getAlignValue();
1770 if (Alignment > StackAlign)
1772 DAG.getSignedConstant(-Alignment.
value(), dl, VT));
1773 Chain = DAG.getCopyToReg(Chain, dl,
SPReg, Tmp1);
1775 Tmp2 = DAG.getCALLSEQ_END(Chain, 0, 0,
SDValue(), dl);
1787 return EmitStackConvert(
SrcOp, SlotVT, DestVT, dl, DAG.getEntryNode());
1795 Align DestAlign = DAG.getDataLayout().getPrefTypeAlign(DestType);
1798 if ((SrcVT.
bitsGT(SlotVT) &&
1799 !TLI.isTruncStoreLegalOrCustom(
SrcOp.getValueType(), SlotVT)) ||
1800 (SlotVT.
bitsLT(DestVT) &&
1801 !TLI.isLoadExtLegalOrCustom(
ISD::EXTLOAD, DestVT, SlotVT)))
1805 Align SrcAlign = DAG.getDataLayout().getPrefTypeAlign(
1806 SrcOp.getValueType().getTypeForEVT(*DAG.getContext()));
1818 if (SrcVT.
bitsGT(SlotVT))
1819 Store = DAG.getTruncStore(Chain, dl,
SrcOp, FIPtr, PtrInfo,
1823 Store = DAG.getStore(Chain, dl,
SrcOp, FIPtr, PtrInfo, SrcAlign);
1827 if (SlotVT.
bitsEq(DestVT))
1828 return DAG.getLoad(DestVT, dl, Store, FIPtr, PtrInfo, DestAlign);
1831 return DAG.getExtLoad(
ISD::EXTLOAD, dl, DestVT, Store, FIPtr, PtrInfo, SlotVT,
1844 SDValue Ch = DAG.getTruncStore(
1845 DAG.getEntryNode(), dl,
Node->getOperand(0), StackPtr,
1847 Node->getValueType(0).getVectorElementType());
1849 Node->getValueType(0), dl, Ch, StackPtr,
1856 unsigned NumElems =
Node->getNumOperands();
1858 EVT VT =
Node->getValueType(0);
1870 for (
unsigned i = 0; i < NumElems; ++i) {
1881 while (IntermedVals.
size() > 2) {
1882 NewIntermedVals.
clear();
1883 for (
unsigned i = 0, e = (IntermedVals.
size() & ~1u); i < e; i += 2) {
1889 FinalIndices.
reserve(IntermedVals[i].second.
size() +
1890 IntermedVals[i+1].second.
size());
1893 for (
unsigned j = 0, f = IntermedVals[i].second.
size(); j != f;
1896 FinalIndices.
push_back(IntermedVals[i].second[j]);
1898 for (
unsigned j = 0, f = IntermedVals[i+1].second.
size(); j != f;
1900 ShuffleVec[k] = NumElems + j;
1901 FinalIndices.
push_back(IntermedVals[i+1].second[j]);
1907 IntermedVals[i+1].first,
1912 std::make_pair(Shuffle, std::move(FinalIndices)));
1917 if ((IntermedVals.
size() & 1) != 0)
1920 IntermedVals.
swap(NewIntermedVals);
1924 "Invalid number of intermediate vectors");
1925 SDValue Vec1 = IntermedVals[0].first;
1927 if (IntermedVals.
size() > 1)
1928 Vec2 = IntermedVals[1].first;
1933 for (
unsigned i = 0, e = IntermedVals[0].second.
size(); i != e; ++i)
1934 ShuffleVec[IntermedVals[0].second[i]] = i;
1935 for (
unsigned i = 0, e = IntermedVals[1].second.
size(); i != e; ++i)
1936 ShuffleVec[IntermedVals[1].second[i]] = NumElems + i;
1950 unsigned NumElems =
Node->getNumOperands();
1953 EVT VT =
Node->getValueType(0);
1954 EVT OpVT =
Node->getOperand(0).getValueType();
1959 bool isOnlyLowElement =
true;
1960 bool MoreThanTwoValues =
false;
1962 for (
unsigned i = 0; i < NumElems; ++i) {
1967 isOnlyLowElement =
false;
1968 if (!isa<ConstantFPSDNode>(V) && !isa<ConstantSDNode>(V))
1973 }
else if (!Value2.
getNode()) {
1976 }
else if (V != Value1 && V != Value2) {
1977 MoreThanTwoValues =
true;
1982 return DAG.getUNDEF(VT);
1984 if (isOnlyLowElement)
1990 for (
unsigned i = 0, e = NumElems; i !=
e; ++i) {
1992 dyn_cast<ConstantFPSDNode>(
Node->getOperand(i))) {
1995 dyn_cast<ConstantSDNode>(
Node->getOperand(i))) {
2014 DAG.getConstantPool(CP, TLI.getPointerTy(DAG.getDataLayout()));
2015 Align Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlign();
2017 VT, dl, DAG.getEntryNode(), CPIdx,
2023 for (
unsigned i = 0; i < NumElems; ++i) {
2024 if (
Node->getOperand(i).isUndef())
2029 if (TLI.shouldExpandBuildVectorWithShuffles(VT, DefinedValues.
size())) {
2030 if (!MoreThanTwoValues) {
2032 for (
unsigned i = 0; i < NumElems; ++i) {
2036 ShuffleVec[i] =
V == Value1 ? 0 : NumElems;
2038 if (TLI.isShuffleMaskLegal(ShuffleVec,
Node->getValueType(0))) {
2045 Vec2 = DAG.getUNDEF(VT);
2048 return DAG.getVectorShuffle(VT, dl, Vec1, Vec2, ShuffleVec);
2058 return ExpandVectorBuildThroughStack(
Node);
2063 EVT VT =
Node->getValueType(0);
2066 return DAG.getSplatBuildVector(VT,
DL, SplatVal);
2077 EVT CodePtrTy = TLI.getPointerTy(DAG.getDataLayout());
2079 if (
const char *LibcallName = TLI.getLibcallName(LC))
2080 Callee = DAG.getExternalSymbol(LibcallName, CodePtrTy);
2082 Callee = DAG.getUNDEF(CodePtrTy);
2083 DAG.getContext()->emitError(
Twine(
"no libcall available for ") +
2084 Node->getOperationName(&DAG));
2087 EVT RetVT =
Node->getValueType(0);
2094 SDValue InChain = DAG.getEntryNode();
2099 const Function &
F = DAG.getMachineFunction().getFunction();
2101 TLI.isInTailCallPosition(DAG,
Node, TCChain) &&
2102 (
RetTy ==
F.getReturnType() ||
F.getReturnType()->isVoidTy());
2107 bool signExtend = TLI.shouldSignExtendTypeInLibCall(
RetTy,
isSigned);
2110 .setLibCallee(TLI.getLibcallCallingConv(LC),
RetTy, Callee,
2112 .setTailCall(isTailCall)
2113 .setSExtResult(signExtend)
2114 .setZExtResult(!signExtend)
2115 .setIsPostTypeLegalization(
true);
2117 std::pair<SDValue, SDValue>
CallInfo = TLI.LowerCallTo(CLI);
2122 return {DAG.getRoot(), DAG.getRoot()};
2134 EVT ArgVT =
Op.getValueType();
2138 Entry.IsSExt = TLI.shouldSignExtendTypeInLibCall(ArgTy,
isSigned);
2140 Args.push_back(Entry);
2143 return ExpandLibCall(LC,
Node, std::move(Args),
isSigned);
2146void SelectionDAGLegalize::ExpandFPLibCall(
SDNode*
Node,
2149 if (LC == RTLIB::UNKNOWN_LIBCALL)
2152 if (
Node->isStrictFPOpcode()) {
2153 EVT RetVT =
Node->getValueType(0);
2158 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, RetVT,
2161 Node->getOperand(0));
2163 Results.push_back(Tmp.second);
2166 SDValue Tmp = ExpandLibCall(LC,
Node, IsSignedArgument).first;
2172void SelectionDAGLegalize::ExpandFPLibCall(
SDNode*
Node,
2180 Call_F32, Call_F64, Call_F80,
2181 Call_F128, Call_PPCF128);
2192 switch (
Node->getSimpleValueType(0).SimpleTy) {
2194 case MVT::i8: LC = Call_I8;
break;
2195 case MVT::i16: LC = Call_I16;
break;
2196 case MVT::i32: LC = Call_I32;
break;
2197 case MVT::i64: LC = Call_I64;
break;
2198 case MVT::i128: LC = Call_I128;
break;
2205void SelectionDAGLegalize::ExpandArgFPLibCall(
SDNode*
Node,
2212 EVT InVT =
Node->getOperand(
Node->isStrictFPOpcode() ? 1 : 0).getValueType();
2214 Call_F32, Call_F64, Call_F80,
2215 Call_F128, Call_PPCF128);
2221SelectionDAGLegalize::ExpandDivRemLibCall(
SDNode *
Node,
2223 unsigned Opcode =
Node->getOpcode();
2227 switch (
Node->getSimpleValueType(0).SimpleTy) {
2229 case MVT::i8: LC=
isSigned ? RTLIB::SDIVREM_I8 : RTLIB::UDIVREM_I8;
break;
2230 case MVT::i16: LC=
isSigned ? RTLIB::SDIVREM_I16 : RTLIB::UDIVREM_I16;
break;
2231 case MVT::i32: LC=
isSigned ? RTLIB::SDIVREM_I32 : RTLIB::UDIVREM_I32;
break;
2232 case MVT::i64: LC=
isSigned ? RTLIB::SDIVREM_I64 : RTLIB::UDIVREM_I64;
break;
2233 case MVT::i128: LC=
isSigned ? RTLIB::SDIVREM_I128:RTLIB::UDIVREM_I128;
break;
2239 SDValue InChain = DAG.getEntryNode();
2241 EVT RetVT =
Node->getValueType(0);
2247 EVT ArgVT =
Op.getValueType();
2253 Args.push_back(Entry);
2257 SDValue FIPtr = DAG.CreateStackTemporary(RetVT);
2259 Entry.Ty = PointerType::getUnqual(
RetTy->getContext());
2262 Args.push_back(Entry);
2264 SDValue Callee = DAG.getExternalSymbol(TLI.getLibcallName(LC),
2265 TLI.getPointerTy(DAG.getDataLayout()));
2271 .setLibCallee(TLI.getLibcallCallingConv(LC),
RetTy, Callee,
2276 std::pair<SDValue, SDValue>
CallInfo = TLI.LowerCallTo(CLI);
2309 EVT VT =
Node->getValueType(0);
2312 EVT ExpVT =
N.getValueType();
2314 if (AsIntVT ==
EVT())
2327 TLI.getSetCCResultType(DAG.getDataLayout(), *DAG.getContext(), ExpVT);
2332 const int Precision = APFloat::semanticsPrecision(FltSem);
2334 const SDValue MaxExp = DAG.getSignedConstant(MaxExpVal, dl, ExpVT);
2335 const SDValue MinExp = DAG.getSignedConstant(MinExpVal, dl, ExpVT);
2337 const SDValue DoubleMaxExp = DAG.getSignedConstant(2 * MaxExpVal, dl, ExpVT);
2339 const APFloat One(FltSem,
"1.0");
2340 APFloat ScaleUpK =
scalbn(One, MaxExpVal, APFloat::rmNearestTiesToEven);
2344 scalbn(One, MinExpVal + Precision, APFloat::rmNearestTiesToEven);
2353 SDValue ClampMaxVal = DAG.getConstant(3 * MaxExpVal, dl, ExpVT);
2359 DAG.getSetCC(dl, SetCCVT,
N, DoubleMaxExp,
ISD::SETUGT);
2361 const SDValue ScaleUpVal = DAG.getConstantFP(ScaleUpK, dl, VT);
2373 SDValue Increment0 = DAG.getConstant(-(MinExpVal + Precision), dl, ExpVT);
2374 SDValue Increment1 = DAG.getConstant(-2 * (MinExpVal + Precision), dl, ExpVT);
2379 DAG.getSignedConstant(3 * MinExpVal + 2 * Precision, dl, ExpVT);
2384 const SDValue ScaleDownVal = DAG.getConstantFP(ScaleDownK, dl, VT);
2388 SDValue ScaleDownTwice = DAG.getSetCC(
2390 DAG.getSignedConstant(2 * MinExpVal + Precision, dl, ExpVT),
ISD::SETULT);
2401 DAG.getNode(
ISD::SELECT, dl, VT, NLtMinExp, SelectX_Small,
X));
2405 DAG.getNode(
ISD::SELECT, dl, ExpVT, NLtMinExp, SelectN_Small,
N));
2410 DAG.getShiftAmountConstant(Precision - 1, ExpVT, dl);
2411 SDValue CastExpToValTy = DAG.getZExtOrTrunc(BiasedN, dl, AsIntVT);
2414 ExponentShiftAmt, NUW_NSW);
2416 return DAG.getNode(
ISD::FMUL, dl, VT, NewX, AsFP);
2423 EVT ExpVT =
Node->getValueType(1);
2425 if (AsIntVT ==
EVT())
2430 const unsigned Precision = APFloat::semanticsPrecision(FltSem);
2447 SDValue NegSmallestNormalizedInt = DAG.getConstant(
2451 SDValue SmallestNormalizedInt = DAG.getConstant(
2457 DAG.getConstant(
APFloat::getInf(FltSem).bitcastToAPInt(), dl, AsIntVT);
2463 FractSignMaskVal.
setBit(BitSize - 1);
2466 SDValue SignMask = DAG.getConstant(SignMaskVal, dl, AsIntVT);
2468 SDValue FractSignMask = DAG.getConstant(FractSignMaskVal, dl, AsIntVT);
2470 const APFloat One(FltSem,
"1.0");
2474 scalbn(One, Precision + 1, APFloat::rmNearestTiesToEven);
2476 SDValue ScaleUpK = DAG.getConstantFP(ScaleUpKVal, dl, VT);
2480 TLI.getSetCCResultType(DAG.getDataLayout(), *DAG.getContext(), VT);
2486 SDValue AddNegSmallestNormal =
2488 SDValue DenormOrZero = DAG.getSetCC(dl, SetCCVT, AddNegSmallestNormal,
2492 DAG.getSetCC(dl, SetCCVT, Abs, SmallestNormalizedInt,
ISD::SETULT);
2494 SDValue MinExp = DAG.getSignedConstant(MinExpVal, dl, ExpVT);
2509 DAG.getShiftAmountConstant(Precision - 1, AsIntVT, dl);
2512 SDValue Exp = DAG.getSExtOrTrunc(ShiftedExp, dl, ExpVT);
2515 SDValue DenormalOffset = DAG.getConstant(-Precision - 1, dl, ExpVT);
2521 const APFloat Half(FltSem,
"0.5");
2522 SDValue FPHalf = DAG.getConstant(Half.bitcastToAPInt(), dl, AsIntVT);
2535 return DAG.getMergeValues({Result0, Result1}, dl);
2546 EVT DestVT =
Node->getValueType(0);
2548 unsigned OpNo =
Node->isStrictFPOpcode() ? 1 : 0;
2554 if (SrcVT == MVT::i32 && TLI.isTypeLegal(MVT::f64) &&
2555 (DestVT.
bitsLE(MVT::f64) ||
2559 LLVM_DEBUG(
dbgs() <<
"32-bit [signed|unsigned] integer to float/double "
2563 SDValue StackSlot = DAG.CreateStackTemporary(MVT::f64);
2570 DAG.getConstant(0x80000000u, dl, MVT::i32));
2573 SDValue Hi = DAG.getConstant(0x43300000u, dl, MVT::i32);
2576 if (DAG.getDataLayout().isBigEndian())
2579 SDValue MemChain = DAG.getEntryNode();
2582 SDValue Store1 = DAG.getStore(MemChain, dl,
Lo, StackSlot,
2595 SDValue Bias = DAG.getConstantFP(
2596 isSigned ? llvm::bit_cast<double>(0x4330000080000000ULL)
2597 : llvm::bit_cast<double>(0x4330000000000000ULL),
2602 if (
Node->isStrictFPOpcode()) {
2604 {
Node->getOperand(0), Load, Bias});
2607 std::pair<SDValue, SDValue> ResultPair;
2609 DAG.getStrictFPExtendOrRound(Sub, Chain, dl, DestVT);
2610 Result = ResultPair.first;
2611 Chain = ResultPair.second;
2617 Result = DAG.getFPExtendOrRound(Sub, dl, DestVT);
2626 if (((SrcVT == MVT::i32 || SrcVT == MVT::i64) && DestVT == MVT::f32) ||
2627 (SrcVT == MVT::i64 && DestVT == MVT::f64)) {
2628 LLVM_DEBUG(
dbgs() <<
"Converting unsigned i32/i64 to f32/f64\n");
2643 EVT SetCCVT = getSetCCResultType(SrcVT);
2645 SDValue SignBitTest = DAG.getSetCC(
2646 dl, SetCCVT, Op0, DAG.getConstant(0, dl, SrcVT),
ISD::SETLT);
2648 EVT ShiftVT = TLI.getShiftAmountTy(SrcVT, DAG.getDataLayout());
2649 SDValue ShiftConst = DAG.getConstant(1, dl, ShiftVT);
2651 SDValue AndConst = DAG.getConstant(1, dl, SrcVT);
2656 if (
Node->isStrictFPOpcode()) {
2659 SDValue InCvt = DAG.getSelect(dl, SrcVT, SignBitTest,
Or, Op0);
2661 {
Node->getOperand(0), InCvt });
2669 Flags.setNoFPExcept(
Node->getFlags().hasNoFPExcept());
2670 Fast->setFlags(Flags);
2671 Flags.setNoFPExcept(
true);
2679 return DAG.getSelect(dl, DestVT, SignBitTest, Slow,
Fast);
2683 if (!TLI.isOperationLegalOrCustom(
2692 "Cannot perform lossless SINT_TO_FP!");
2695 if (
Node->isStrictFPOpcode()) {
2697 {
Node->getOperand(0), Op0 });
2701 SDValue SignSet = DAG.getSetCC(dl, getSetCCResultType(SrcVT), Op0,
2704 Four = DAG.getIntPtrConstant(4, dl);
2705 SDValue CstOffset = DAG.getSelect(dl,
Zero.getValueType(),
2706 SignSet, Four, Zero);
2715 case MVT::i8 : FF = 0x43800000ULL;
break;
2716 case MVT::i16: FF = 0x47800000ULL;
break;
2717 case MVT::i32: FF = 0x4F800000ULL;
break;
2718 case MVT::i64: FF = 0x5F800000ULL;
break;
2720 if (DAG.getDataLayout().isLittleEndian())
2722 Constant *FudgeFactor = ConstantInt::get(
2726 DAG.getConstantPool(FudgeFactor, TLI.getPointerTy(DAG.getDataLayout()));
2727 Align Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlign();
2731 if (DestVT == MVT::f32)
2732 FudgeInReg = DAG.getLoad(
2733 MVT::f32, dl, DAG.getEntryNode(), CPIdx,
2742 LegalizeOp(
Load.getNode());
2746 if (
Node->isStrictFPOpcode()) {
2748 { Tmp1.
getValue(1), Tmp1, FudgeInReg });
2749 Chain =
Result.getValue(1);
2753 return DAG.getNode(
ISD::FADD, dl, DestVT, Tmp1, FudgeInReg);
2761void SelectionDAGLegalize::PromoteLegalINT_TO_FP(
2763 bool IsStrict =
N->isStrictFPOpcode();
2766 EVT DestVT =
N->getValueType(0);
2767 SDValue LegalOp =
N->getOperand(IsStrict ? 1 : 0);
2774 unsigned OpToUse = 0;
2782 if (TLI.isOperationLegalOrCustom(SIntOp, NewInTy)) {
2790 if (TLI.isOperationLegalOrCustom(UIntOp, NewInTy)) {
2802 DAG.
getNode(OpToUse, dl, {DestVT, MVT::Other},
2805 dl, NewInTy, LegalOp)});
2812 DAG.getNode(OpToUse, dl, DestVT,
2814 dl, NewInTy, LegalOp)));
2822void SelectionDAGLegalize::PromoteLegalFP_TO_INT(
SDNode *
N,
const SDLoc &dl,
2824 bool IsStrict =
N->isStrictFPOpcode();
2827 EVT DestVT =
N->getValueType(0);
2828 SDValue LegalOp =
N->getOperand(IsStrict ? 1 : 0);
2830 EVT NewOutTy = DestVT;
2832 unsigned OpToUse = 0;
2842 if (TLI.isOperationLegalOrCustom(OpToUse, NewOutTy))
2847 if (!IsSigned && TLI.isOperationLegalOrCustom(OpToUse, NewOutTy))
2856 SDVTList VTs = DAG.getVTList(NewOutTy, MVT::Other);
2857 Operation = DAG.getNode(OpToUse, dl, VTs,
N->getOperand(0), LegalOp);
2859 Operation = DAG.getNode(OpToUse, dl, NewOutTy, LegalOp);
2874 unsigned Opcode =
Node->getOpcode();
2877 EVT NewOutTy =
Node->getValueType(0);
2882 if (TLI.isOperationLegalOrCustom(Opcode, NewOutTy))
2889 Node->getOperand(1));
2895 EVT VT =
Op.getValueType();
2896 EVT ShVT = TLI.getShiftAmountTy(VT, DAG.getDataLayout());
2901 if (TLI.isOperationLegalOrPromote(
ISD::CTPOP, VT)) {
2907 DAG.getConstant(1ULL << (--i), dl, ShVT));
2912 return DAG.getNode(
ISD::AND, dl, VT, Result, DAG.getConstant(1, dl, VT));
2916 MVT VecVT =
Node->getOperand(1).getSimpleValueType();
2917 MVT NewVecVT = TLI.getTypeToPromoteTo(
Node->getOpcode(), VecVT);
2918 MVT ScalarVT =
Node->getSimpleValueType(0);
2926 assert(
Node->getOperand(0).getValueType().isFloatingPoint() &&
2927 "Only FP promotion is supported");
2931 for (
unsigned j = 1;
j !=
Node->getNumOperands(); ++
j)
2932 if (
Node->getOperand(j).getValueType().isVector() &&
2937 assert(
Node->getOperand(j).getValueType().isFloatingPoint() &&
2938 "Only FP promotion is supported");
2950 DAG.getIntPtrConstant(0,
DL,
true));
2953bool SelectionDAGLegalize::ExpandNode(
SDNode *
Node) {
2957 SDValue Tmp1, Tmp2, Tmp3, Tmp4;
2959 switch (
Node->getOpcode()) {
2961 if ((Tmp1 = TLI.expandABS(
Node, DAG)))
2966 if ((Tmp1 = TLI.expandABD(
Node, DAG)))
2973 if ((Tmp1 = TLI.expandAVG(
Node, DAG)))
2977 if ((Tmp1 = TLI.expandCTPOP(
Node, DAG)))
2982 if ((Tmp1 = TLI.expandCTLZ(
Node, DAG)))
2987 if ((Tmp1 = TLI.expandCTTZ(
Node, DAG)))
2991 if ((Tmp1 = TLI.expandBITREVERSE(
Node, DAG)))
2995 if ((Tmp1 = TLI.expandBSWAP(
Node, DAG)))
2999 Results.push_back(ExpandPARITY(
Node->getOperand(0), dl));
3004 Results.push_back(DAG.getConstant(0, dl,
Node->getValueType(0)));
3007 SDValue CfaArg = DAG.getSExtOrTrunc(
Node->getOperand(0), dl,
3008 TLI.getPointerTy(DAG.getDataLayout()));
3016 DAG.getConstant(0, dl, TLI.getPointerTy(DAG.getDataLayout())));
3022 Results.push_back(DAG.getConstant(1, dl,
Node->getValueType(0)));
3039 DAG.getConstant(0, dl,
Node->getValueType(0)));
3045 Results.push_back(DAG.getConstant(0, dl, MVT::i32));
3051 SDVTList VTs = DAG.getVTList(
Node->getValueType(0), MVT::Other);
3052 SDValue Swap = DAG.getAtomicCmpSwap(
3054 Node->getOperand(0),
Node->getOperand(1), Zero, Zero,
3055 cast<AtomicSDNode>(
Node)->getMemOperand());
3064 Node->getOperand(0),
Node->getOperand(2),
Node->getOperand(1),
3065 cast<AtomicSDNode>(
Node)->getMemOperand());
3073 SDVTList VTs = DAG.getVTList(
Node->getValueType(0), MVT::Other);
3074 SDValue Res = DAG.getAtomicCmpSwap(
3076 Node->getOperand(0),
Node->getOperand(1),
Node->getOperand(2),
3077 Node->getOperand(3), cast<MemSDNode>(
Node)->getMemOperand());
3083 EVT AtomicType = cast<AtomicSDNode>(
Node)->getMemoryVT();
3084 EVT OuterType =
Node->getValueType(0);
3085 switch (TLI.getExtendForAtomicOps()) {
3088 DAG.getValueType(AtomicType));
3090 Node->getOperand(2), DAG.getValueType(AtomicType));
3095 DAG.getValueType(AtomicType));
3096 RHS = DAG.getZeroExtendInReg(
Node->getOperand(2), dl, AtomicType);
3100 LHS = DAG.getZeroExtendInReg(Res, dl, AtomicType);
3101 RHS = DAG.getZeroExtendInReg(
Node->getOperand(2), dl, AtomicType);
3117 EVT VT =
Node->getValueType(0);
3121 cast<VTSDNode>(
RHS->getOperand(1))->getVT() == AN->
getMemoryVT())
3122 RHS =
RHS->getOperand(0);
3126 Node->getOperand(0),
Node->getOperand(1),
3136 for (
unsigned i = 0; i <
Node->getNumValues(); i++)
3140 EVT VT =
Node->getValueType(0);
3142 Results.push_back(DAG.getConstant(0, dl, VT));
3145 Results.push_back(DAG.getConstantFP(0, dl, VT));
3152 if (TLI.isStrictFPEnabled())
3156 if (TLI.getStrictFPOperationAction(
Node->getOpcode(),
3157 Node->getValueType(0))
3158 == TargetLowering::Legal)
3162 if ((Tmp1 = EmitStackConvert(
Node->getOperand(1),
Node->getValueType(0),
3163 Node->getValueType(0), dl,
3164 Node->getOperand(0)))) {
3166 LLVM_DEBUG(
dbgs() <<
"Successfully expanded STRICT_FP_ROUND node\n");
3171 if ((Tmp1 = TLI.expandFP_ROUND(
Node, DAG))) {
3179 if ((Tmp1 = EmitStackConvert(
Node->getOperand(0),
Node->getValueType(0),
3180 Node->getValueType(0), dl)))
3186 if (TLI.isStrictFPEnabled())
3190 if (TLI.getStrictFPOperationAction(
Node->getOpcode(),
3191 Node->getValueType(0))
3192 == TargetLowering::Legal)
3196 if ((Tmp1 = EmitStackConvert(
3197 Node->getOperand(1),
Node->getOperand(1).getValueType(),
3198 Node->getValueType(0), dl,
Node->getOperand(0)))) {
3200 LLVM_DEBUG(
dbgs() <<
"Successfully expanded STRICT_FP_EXTEND node\n");
3206 EVT SrcVT =
Op.getValueType();
3207 EVT DstVT =
Node->getValueType(0);
3213 if ((Tmp1 = EmitStackConvert(
Op, SrcVT, DstVT, dl)))
3223 if (
Op.getValueType() == MVT::bf16) {
3227 Op = DAG.getAnyExtOrTrunc(
Op, dl, MVT::i32);
3231 DAG.getConstant(16, dl,
3232 TLI.getShiftAmountTy(MVT::i32, DAG.getDataLayout())));
3235 if (
Node->getValueType(0) != MVT::f32)
3242 if (
Op.getValueType() != MVT::f32)
3244 DAG.getIntPtrConstant(0, dl,
true));
3246 if (!DAG.isKnownNeverSNaN(
Op)) {
3251 DAG.getConstant(16, dl,
3252 TLI.getShiftAmountTy(MVT::i32, DAG.getDataLayout())));
3255 if (
Node->getValueType(0) == MVT::bf16) {
3259 Op = DAG.getAnyExtOrTrunc(
Op, dl,
Node->getValueType(0));
3265 EVT ExtraVT = cast<VTSDNode>(
Node->getOperand(1))->getVT();
3266 EVT VT =
Node->getValueType(0);
3276 SDValue One = DAG.getConstant(1, dl, VT);
3286 EVT ShiftAmountTy = TLI.getShiftAmountTy(VT, DAG.getDataLayout());
3289 SDValue ShiftCst = DAG.getConstant(BitsDiff, dl, ShiftAmountTy);
3291 Node->getOperand(0), ShiftCst);
3298 if (TLI.expandUINT_TO_FP(
Node, Tmp1, Tmp2, DAG)) {
3300 if (
Node->isStrictFPOpcode())
3307 if ((Tmp1 = ExpandLegalINT_TO_FP(
Node, Tmp2))) {
3309 if (
Node->isStrictFPOpcode())
3314 if (TLI.expandFP_TO_SINT(
Node, Tmp1, DAG))
3318 if (TLI.expandFP_TO_SINT(
Node, Tmp1, DAG)) {
3320 LLVM_DEBUG(
dbgs() <<
"Successfully expanded STRICT_FP_TO_SINT node\n");
3325 if (TLI.expandFP_TO_UINT(
Node, Tmp1, Tmp2, DAG))
3329 if (TLI.expandFP_TO_UINT(
Node, Tmp1, Tmp2, DAG)) {
3331 DAG.ReplaceAllUsesOfValueWith(
SDValue(
Node,1), Tmp2);
3334 LLVM_DEBUG(
dbgs() <<
"Successfully expanded STRICT_FP_TO_UINT node\n");
3340 Results.push_back(TLI.expandFP_TO_INT_SAT(
Node, DAG));
3346 EVT ResVT =
Node->getValueType(0);
3360 if (
Node->getOperand(0).getValueType().getVectorElementCount().isScalar())
3363 Node->getOperand(0));
3365 Tmp1 = ExpandExtractFromVectorThroughStack(
SDValue(
Node, 0));
3375 Results.push_back(ExpandVectorBuildThroughStack(
Node));
3387 EVT VT =
Node->getValueType(0);
3391 if (!TLI.isTypeLegal(EltVT)) {
3392 EVT NewEltVT = TLI.getTypeToTransformTo(*DAG.getContext(), EltVT);
3397 if (NewEltVT.
bitsLT(EltVT)) {
3413 unsigned int factor =
3421 for (
unsigned fi = 0; fi < factor; ++fi)
3425 for (
unsigned fi = 0; fi < factor; ++fi)
3436 for (
unsigned i = 0; i != NumElems; ++i) {
3444 DAG.getVectorIdxConstant(
Idx, dl)));
3448 DAG.getVectorIdxConstant(
Idx - NumElems, dl)));
3451 Tmp1 = DAG.getBuildVector(VT, dl, Ops);
3458 Results.push_back(TLI.expandVectorSplice(
Node, DAG));
3462 EVT OpTy =
Node->getOperand(0).getValueType();
3463 if (
Node->getConstantOperandVal(1)) {
3467 TLI.getShiftAmountTy(
3468 Node->getOperand(0).getValueType(),
3469 DAG.getDataLayout())));
3474 Node->getOperand(0));
3482 if (
Register SP = TLI.getStackPointerRegisterToSaveRestore()) {
3483 Results.push_back(DAG.getCopyFromReg(
Node->getOperand(0), dl, SP,
3484 Node->getValueType(0)));
3487 Results.push_back(DAG.getUNDEF(
Node->getValueType(0)));
3494 if (
Register SP = TLI.getStackPointerRegisterToSaveRestore()) {
3495 Results.push_back(DAG.getCopyToReg(
Node->getOperand(0), dl, SP,
3496 Node->getOperand(1)));
3502 Results.push_back(DAG.getConstant(0, dl,
Node->getValueType(0)));
3517 TLI.expandIS_FPCLASS(
Node->getValueType(0),
Node->getOperand(0),
3528 switch (
Node->getOpcode()) {
3535 Tmp1 =
Node->getOperand(0);
3536 Tmp2 =
Node->getOperand(1);
3537 Tmp1 = DAG.getSelectCC(dl, Tmp1, Tmp2, Tmp1, Tmp2, Pred);
3543 if (
SDValue Expanded = TLI.expandFMINNUM_FMAXNUM(
Node, DAG))
3549 if (
SDValue Expanded = TLI.expandFMINIMUM_FMAXIMUM(
Node, DAG))
3555 Results.push_back(TLI.expandFMINIMUMNUM_FMAXIMUMNUM(
Node, DAG));
3560 EVT VT =
Node->getValueType(0);
3566 SDVTList VTs = DAG.getVTList(VT, VT);
3576 EVT VT =
Node->getValueType(0);
3580 if (TLI.getLibcallName(LC))
3586 Results.push_back(Expanded.getValue(1));
3595 if (TLI.getLibcallName(LC))
3600 Results.push_back(Expanded.getValue(1));
3607 EVT VT =
Node->getValueType(0);
3619 if (
Node->getValueType(0) != MVT::f32) {
3631 if (
Node->getValueType(0) != MVT::f32) {
3636 {Node->getOperand(0), Node->getOperand(1)});
3638 {
Node->getValueType(0), MVT::Other},
3646 if (!TLI.useSoftFloat() &&
TM.Options.UnsafeFPMath) {
3648 MVT SVT =
Op.getSimpleValueType();
3649 if ((SVT == MVT::f64 || SVT == MVT::f80) &&
3655 DAG.getIntPtrConstant(0, dl,
true));
3666 DAG.shouldOptForSize()))
3667 Results.push_back(ExpandConstantFP(CFP,
true));
3672 Results.push_back(ExpandConstant(CP));
3676 EVT VT =
Node->getValueType(0);
3677 if (TLI.isOperationLegalOrCustom(
ISD::FADD, VT) &&
3678 TLI.isOperationLegalOrCustom(
ISD::FNEG, VT)) {
3687 EVT VT =
Node->getValueType(0);
3689 TLI.isOperationLegalOrCustom(
ISD::XOR, VT) &&
3690 "Don't know how to expand this subtraction!");
3691 Tmp1 = DAG.getNOT(dl,
Node->getOperand(1), VT);
3692 Tmp1 = DAG.
getNode(
ISD::ADD, dl, VT, Tmp1, DAG.getConstant(1, dl, VT));
3698 if (TLI.expandREM(
Node, Tmp1, DAG))
3705 EVT VT =
Node->getValueType(0);
3706 if (TLI.isOperationLegalOrCustom(DivRemOpc, VT)) {
3707 SDVTList VTs = DAG.getVTList(VT, VT);
3708 Tmp1 = DAG.
getNode(DivRemOpc, dl, VTs,
Node->getOperand(0),
3709 Node->getOperand(1));
3716 unsigned ExpandOpcode =
3718 EVT VT =
Node->getValueType(0);
3719 SDVTList VTs = DAG.getVTList(VT, VT);
3721 Tmp1 = DAG.
getNode(ExpandOpcode, dl, VTs,
Node->getOperand(0),
3722 Node->getOperand(1));
3730 MVT VT =
LHS.getSimpleValueType();
3731 unsigned MULHOpcode =
3734 if (TLI.isOperationLegalOrCustom(MULHOpcode, VT)) {
3736 Results.push_back(DAG.getNode(MULHOpcode, dl, VT, LHS, RHS));
3742 assert(TLI.isTypeLegal(HalfType));
3743 if (TLI.expandMUL_LOHI(
Node->getOpcode(), VT, dl, LHS, RHS, Halves,
3745 TargetLowering::MulExpansionKind::Always)) {
3746 for (
unsigned i = 0; i < 2; ++i) {
3749 SDValue Shift = DAG.getConstant(
3751 TLI.getShiftAmountTy(HalfType, DAG.getDataLayout()));
3760 EVT VT =
Node->getValueType(0);
3761 SDVTList VTs = DAG.getVTList(VT, VT);
3767 bool HasSMUL_LOHI = TLI.isOperationLegalOrCustom(
ISD::SMUL_LOHI, VT);
3768 bool HasUMUL_LOHI = TLI.isOperationLegalOrCustom(
ISD::UMUL_LOHI, VT);
3769 bool HasMULHS = TLI.isOperationLegalOrCustom(
ISD::MULHS, VT);
3770 bool HasMULHU = TLI.isOperationLegalOrCustom(
ISD::MULHU, VT);
3771 unsigned OpToUse = 0;
3772 if (HasSMUL_LOHI && !HasMULHS) {
3774 }
else if (HasUMUL_LOHI && !HasMULHU) {
3776 }
else if (HasSMUL_LOHI) {
3778 }
else if (HasUMUL_LOHI) {
3782 Results.push_back(DAG.getNode(OpToUse, dl, VTs,
Node->getOperand(0),
3783 Node->getOperand(1)));
3791 TLI.isOperationLegalOrCustom(
ISD::SHL, VT) &&
3792 TLI.isOperationLegalOrCustom(
ISD::OR, VT) &&
3793 TLI.expandMUL(
Node,
Lo,
Hi, HalfType, DAG,
3794 TargetLowering::MulExpansionKind::OnlyLegalOrCustom)) {
3799 TLI.getShiftAmountTy(HalfType, DAG.getDataLayout()));
3807 if (
SDValue Expanded = TLI.expandFunnelShift(
Node, DAG))
3812 if (
SDValue Expanded = TLI.expandROT(
Node,
true , DAG))
3819 Results.push_back(TLI.expandAddSubSat(
Node, DAG));
3833 Results.push_back(TLI.expandFixedPointMul(
Node, DAG));
3840 Node->getOperand(0),
3841 Node->getOperand(1),
3842 Node->getConstantOperandVal(2),
3865 EVT VT =
LHS.getValueType();
3869 EVT CarryType =
Node->getValueType(1);
3870 EVT SetCCType = getSetCCResultType(
Node->getValueType(0));
3872 SDValue Overflow = DAG.getSetCC(dl, SetCCType, Sum, LHS,
CC);
3875 SDValue One = DAG.getConstant(1, dl, VT);
3877 DAG.
getNode(
ISD::AND, dl, VT, DAG.getZExtOrTrunc(Carry, dl, VT), One);
3886 IsAdd ? DAG.getSetCC(dl, SetCCType, Sum2, Zero,
ISD::SETEQ)
3887 : DAG.getSetCC(dl, SetCCType, Sum, Zero,
ISD::SETEQ);
3889 DAG.getZExtOrTrunc(Carry, dl, SetCCType));
3895 Results.push_back(DAG.getBoolExtOrTrunc(ResultCarry, dl, CarryType, VT));
3901 TLI.expandSADDSUBO(
Node, Result, Overflow, DAG);
3909 TLI.expandUADDSUBO(
Node, Result, Overflow, DAG);
3917 if (TLI.expandMULO(
Node, Result, Overflow, DAG)) {
3929 DAG.getConstant(
PairTy.getSizeInBits() / 2, dl,
3930 TLI.getShiftAmountTy(
PairTy, DAG.getDataLayout())));
3935 Tmp1 =
Node->getOperand(0);
3936 Tmp2 =
Node->getOperand(1);
3937 Tmp3 =
Node->getOperand(2);
3941 cast<CondCodeSDNode>(Tmp1.
getOperand(2))->get());
3943 Tmp1 = DAG.getSelectCC(dl, Tmp1,
3954 int JTI = cast<JumpTableSDNode>(Table.
getNode())->getIndex();
3957 EVT PTy = TLI.getPointerTy(TD);
3959 unsigned EntrySize =
3960 DAG.getMachineFunction().getJumpTableInfo()->getEntrySize(TD);
3967 Index = DAG.getNode(
3972 DAG.getConstant(EntrySize, dl,
Index.getValueType()));
3981 if (TLI.isJumpTableRelative()) {
3986 TLI.getPICJumpTableRelocBase(Table, DAG));
3989 Tmp1 = TLI.expandIndirectJTBranch(dl,
LD.getValue(1),
Addr, JTI, DAG);
3996 Tmp1 =
Node->getOperand(0);
3997 Tmp2 =
Node->getOperand(1);
4003 Node->getOperand(2));
4015 Node->getOperand(2));
4023 bool IsVP =
Node->getOpcode() == ISD::VP_SETCC;
4028 unsigned Offset = IsStrict ? 1 : 0;
4037 bool Legalized = TLI.LegalizeSetCCCondCode(
4038 DAG,
Node->getValueType(0), Tmp1, Tmp2, Tmp3, Mask, EVL, NeedInvert, dl,
4039 Chain, IsSignaling);
4047 {Chain, Tmp1, Tmp2, Tmp3},
Node->getFlags());
4051 {Tmp1, Tmp2, Tmp3, Mask, EVL},
Node->getFlags());
4053 Tmp1 = DAG.
getNode(
Node->getOpcode(), dl,
Node->getValueType(0), Tmp1,
4054 Tmp2, Tmp3,
Node->getFlags());
4062 Tmp1 = DAG.getLogicalNOT(dl, Tmp1, Tmp1->
getValueType(0));
4065 DAG.getVPLogicalNOT(dl, Tmp1, Mask, EVL, Tmp1->
getValueType(0));
4077 assert(!IsStrict &&
"Don't know how to expand for strict nodes.");
4082 EVT VT =
Node->getValueType(0);
4085 DAG.getBoolConstant(
true, dl, VT, Tmp1VT),
4086 DAG.getBoolConstant(
false, dl, VT, Tmp1VT), Tmp3);
4093 Tmp1 =
Node->getOperand(0);
4094 Tmp2 =
Node->getOperand(1);
4095 Tmp3 =
Node->getOperand(2);
4096 Tmp4 =
Node->getOperand(3);
4097 EVT VT =
Node->getValueType(0);
4107 "Cannot expand ISD::SELECT_CC when ISD::SELECT also needs to be "
4109 EVT CCVT = getSetCCResultType(CmpVT);
4112 DAG.getSelect(dl, VT,
Cond, Tmp3, Tmp4,
Node->getFlags()));
4117 bool Legalized =
false;
4125 Tmp1 = DAG.getSelectCC(dl, Tmp1, Tmp2, Tmp4, Tmp3, InvCC);
4135 Tmp1 = DAG.getSelectCC(dl, Tmp2, Tmp1, Tmp4, Tmp3, SwapInvCC);
4141 Legalized = TLI.LegalizeSetCCCondCode(
4145 assert(Legalized &&
"Can't legalize SELECT_CC with legal condition!");
4156 Tmp1, Tmp2, Tmp3, Tmp4,
CC);
4161 Tmp2, Tmp3, Tmp4,
CC);
4171 Tmp1 =
Node->getOperand(0);
4172 Tmp2 =
Node->getOperand(2);
4173 Tmp3 =
Node->getOperand(3);
4174 Tmp4 =
Node->getOperand(1);
4176 bool Legalized = TLI.LegalizeSetCCCondCode(
4177 DAG, getSetCCResultType(Tmp2.
getValueType()), Tmp2, Tmp3, Tmp4,
4180 assert(Legalized &&
"Can't legalize BR_CC with legal condition!");
4185 assert(!NeedInvert &&
"Don't know how to invert BR_CC!");
4188 Tmp4, Tmp2, Tmp3,
Node->getOperand(4));
4193 Tmp2, Tmp3,
Node->getOperand(4));
4208 EVT VT =
Node->getValueType(0);
4214 for (
unsigned Idx = 0;
Idx < NumElem;
Idx++) {
4217 Node->getOperand(0), DAG.getVectorIdxConstant(
Idx, dl));
4220 Node->getOperand(1), DAG.getVectorIdxConstant(
Idx, dl));
4244 Results.push_back(TLI.expandVecReduce(
Node, DAG));
4246 case ISD::VP_CTTZ_ELTS:
4247 case ISD::VP_CTTZ_ELTS_ZERO_UNDEF:
4248 Results.push_back(TLI.expandVPCTTZElements(
Node, DAG));
4259 EVT ResVT =
Node->getValueType(0);
4283 if (!TLI.isStrictFPEnabled() &&
Results.
empty() &&
Node->isStrictFPOpcode()) {
4289 switch (
Node->getOpcode()) {
4291 if (TLI.getStrictFPOperationAction(
Node->getOpcode(),
4292 Node->getValueType(0))
4293 == TargetLowering::Legal)
4297 if (TLI.getStrictFPOperationAction(
4300 if (TLI.getStrictFPOperationAction(
4304 EVT VT =
Node->getValueType(0);
4308 {Node->getOperand(0), Node->getOperand(1), Neg},
4323 if (TLI.getStrictFPOperationAction(
Node->getOpcode(),
4324 Node->getOperand(1).getValueType())
4325 == TargetLowering::Legal)
4342void SelectionDAGLegalize::ConvertNodeToLibcall(
SDNode *
Node) {
4349 unsigned Opc =
Node->getOpcode();
4358 .setChain(
Node->getOperand(0))
4361 DAG.getExternalSymbol(
"__sync_synchronize",
4362 TLI.getPointerTy(DAG.getDataLayout())),
4365 std::pair<SDValue, SDValue> CallResult = TLI.LowerCallTo(CLI);
4367 Results.push_back(CallResult.second);
4389 EVT RetVT =
Node->getValueType(0);
4391 if (TLI.getLibcallName(LC)) {
4398 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
4399 "Unexpected atomic op or value type!");
4403 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, RetVT,
4406 Node->getOperand(0));
4408 Results.push_back(Tmp.second);
4416 .setChain(
Node->getOperand(0))
4418 DAG.getExternalSymbol(
4419 "abort", TLI.getPointerTy(DAG.getDataLayout())),
4421 std::pair<SDValue, SDValue> CallResult = TLI.LowerCallTo(CLI);
4423 Results.push_back(CallResult.second);
4430 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(
4431 DAG, RTLIB::CLEAR_CACHE, MVT::isVoid, {StartVal, EndVal}, CallOptions,
4433 Results.push_back(Tmp.second);
4438 ExpandFPLibCall(
Node, RTLIB::FMIN_F32, RTLIB::FMIN_F64,
4439 RTLIB::FMIN_F80, RTLIB::FMIN_F128,
4440 RTLIB::FMIN_PPCF128,
Results);
4447 ExpandFPLibCall(
Node, RTLIB::FMAX_F32, RTLIB::FMAX_F64,
4448 RTLIB::FMAX_F80, RTLIB::FMAX_F128,
4449 RTLIB::FMAX_PPCF128,
Results);
4452 ExpandFPLibCall(
Node, RTLIB::FMINIMUMNUM_F32, RTLIB::FMINIMUMNUM_F64,
4453 RTLIB::FMINIMUMNUM_F80, RTLIB::FMINIMUMNUM_F128,
4454 RTLIB::FMINIMUMNUM_PPCF128,
Results);
4457 ExpandFPLibCall(
Node, RTLIB::FMAXIMUMNUM_F32, RTLIB::FMAXIMUMNUM_F64,
4458 RTLIB::FMAXIMUMNUM_F80, RTLIB::FMAXIMUMNUM_F128,
4459 RTLIB::FMAXIMUMNUM_PPCF128,
Results);
4463 ExpandFPLibCall(
Node, RTLIB::SQRT_F32, RTLIB::SQRT_F64,
4464 RTLIB::SQRT_F80, RTLIB::SQRT_F128,
4465 RTLIB::SQRT_PPCF128,
Results);
4468 ExpandFPLibCall(
Node, RTLIB::CBRT_F32, RTLIB::CBRT_F64,
4469 RTLIB::CBRT_F80, RTLIB::CBRT_F128,
4470 RTLIB::CBRT_PPCF128,
Results);
4474 ExpandFPLibCall(
Node, RTLIB::SIN_F32, RTLIB::SIN_F64,
4475 RTLIB::SIN_F80, RTLIB::SIN_F128,
4480 ExpandFPLibCall(
Node, RTLIB::COS_F32, RTLIB::COS_F64,
4481 RTLIB::COS_F80, RTLIB::COS_F128,
4486 ExpandFPLibCall(
Node, RTLIB::TAN_F32, RTLIB::TAN_F64, RTLIB::TAN_F80,
4487 RTLIB::TAN_F128, RTLIB::TAN_PPCF128,
Results);
4491 ExpandFPLibCall(
Node, RTLIB::ASIN_F32, RTLIB::ASIN_F64, RTLIB::ASIN_F80,
4492 RTLIB::ASIN_F128, RTLIB::ASIN_PPCF128,
Results);
4496 ExpandFPLibCall(
Node, RTLIB::ACOS_F32, RTLIB::ACOS_F64, RTLIB::ACOS_F80,
4497 RTLIB::ACOS_F128, RTLIB::ACOS_PPCF128,
Results);
4501 ExpandFPLibCall(
Node, RTLIB::ATAN_F32, RTLIB::ATAN_F64, RTLIB::ATAN_F80,
4502 RTLIB::ATAN_F128, RTLIB::ATAN_PPCF128,
Results);
4506 ExpandFPLibCall(
Node, RTLIB::ATAN2_F32, RTLIB::ATAN2_F64, RTLIB::ATAN2_F80,
4507 RTLIB::ATAN2_F128, RTLIB::ATAN2_PPCF128,
Results);
4511 ExpandFPLibCall(
Node, RTLIB::SINH_F32, RTLIB::SINH_F64, RTLIB::SINH_F80,
4512 RTLIB::SINH_F128, RTLIB::SINH_PPCF128,
Results);
4516 ExpandFPLibCall(
Node, RTLIB::COSH_F32, RTLIB::COSH_F64, RTLIB::COSH_F80,
4517 RTLIB::COSH_F128, RTLIB::COSH_PPCF128,
Results);
4521 ExpandFPLibCall(
Node, RTLIB::TANH_F32, RTLIB::TANH_F64, RTLIB::TANH_F80,
4522 RTLIB::TANH_F128, RTLIB::TANH_PPCF128,
Results);
4526 bool Expanded = DAG.expandMultipleResultFPLibCall(LC,
Node,
Results);
4533 ExpandFPLibCall(
Node, RTLIB::LOG_F32, RTLIB::LOG_F64, RTLIB::LOG_F80,
4534 RTLIB::LOG_F128, RTLIB::LOG_PPCF128,
Results);
4538 ExpandFPLibCall(
Node, RTLIB::LOG2_F32, RTLIB::LOG2_F64, RTLIB::LOG2_F80,
4539 RTLIB::LOG2_F128, RTLIB::LOG2_PPCF128,
Results);
4543 ExpandFPLibCall(
Node, RTLIB::LOG10_F32, RTLIB::LOG10_F64, RTLIB::LOG10_F80,
4544 RTLIB::LOG10_F128, RTLIB::LOG10_PPCF128,
Results);
4548 ExpandFPLibCall(
Node, RTLIB::EXP_F32, RTLIB::EXP_F64, RTLIB::EXP_F80,
4549 RTLIB::EXP_F128, RTLIB::EXP_PPCF128,
Results);
4553 ExpandFPLibCall(
Node, RTLIB::EXP2_F32, RTLIB::EXP2_F64, RTLIB::EXP2_F80,
4554 RTLIB::EXP2_F128, RTLIB::EXP2_PPCF128,
Results);
4557 ExpandFPLibCall(
Node, RTLIB::EXP10_F32, RTLIB::EXP10_F64, RTLIB::EXP10_F80,
4558 RTLIB::EXP10_F128, RTLIB::EXP10_PPCF128,
Results);
4562 ExpandFPLibCall(
Node, RTLIB::TRUNC_F32, RTLIB::TRUNC_F64,
4563 RTLIB::TRUNC_F80, RTLIB::TRUNC_F128,
4564 RTLIB::TRUNC_PPCF128,
Results);
4568 ExpandFPLibCall(
Node, RTLIB::FLOOR_F32, RTLIB::FLOOR_F64,
4569 RTLIB::FLOOR_F80, RTLIB::FLOOR_F128,
4570 RTLIB::FLOOR_PPCF128,
Results);
4574 ExpandFPLibCall(
Node, RTLIB::CEIL_F32, RTLIB::CEIL_F64,
4575 RTLIB::CEIL_F80, RTLIB::CEIL_F128,
4576 RTLIB::CEIL_PPCF128,
Results);
4580 ExpandFPLibCall(
Node, RTLIB::RINT_F32, RTLIB::RINT_F64,
4581 RTLIB::RINT_F80, RTLIB::RINT_F128,
4582 RTLIB::RINT_PPCF128,
Results);
4586 ExpandFPLibCall(
Node, RTLIB::NEARBYINT_F32,
4587 RTLIB::NEARBYINT_F64,
4588 RTLIB::NEARBYINT_F80,
4589 RTLIB::NEARBYINT_F128,
4590 RTLIB::NEARBYINT_PPCF128,
Results);
4594 ExpandFPLibCall(
Node, RTLIB::ROUND_F32,
4598 RTLIB::ROUND_PPCF128,
Results);
4602 ExpandFPLibCall(
Node, RTLIB::ROUNDEVEN_F32,
4603 RTLIB::ROUNDEVEN_F64,
4604 RTLIB::ROUNDEVEN_F80,
4605 RTLIB::ROUNDEVEN_F128,
4606 RTLIB::ROUNDEVEN_PPCF128,
Results);
4610 ExpandFPLibCall(
Node, RTLIB::LDEXP_F32, RTLIB::LDEXP_F64, RTLIB::LDEXP_F80,
4611 RTLIB::LDEXP_F128, RTLIB::LDEXP_PPCF128,
Results);
4615 bool Expanded = DAG.expandMultipleResultFPLibCall(LC,
Node,
Results,
4624 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fpowi.");
4625 if (!TLI.getLibcallName(LC)) {
4627 if (
Node->isStrictFPOpcode()) {
4630 {
Node->getValueType(0),
Node->getValueType(1)},
4631 {
Node->getOperand(0),
Node->getOperand(2)});
4634 {
Node->getValueType(0),
Node->getValueType(1)},
4641 Node->getOperand(1));
4643 Node->getValueType(0),
4648 unsigned Offset =
Node->isStrictFPOpcode() ? 1 : 0;
4649 bool ExponentHasSizeOfInt =
4650 DAG.getLibInfo().getIntSize() ==
4651 Node->getOperand(1 +
Offset).getValueType().getSizeInBits();
4652 if (!ExponentHasSizeOfInt) {
4655 DAG.getContext()->emitError(
"POWI exponent does not match sizeof(int)");
4656 Results.push_back(DAG.getUNDEF(
Node->getValueType(0)));
4664 ExpandFPLibCall(
Node, RTLIB::POW_F32, RTLIB::POW_F64, RTLIB::POW_F80,
4665 RTLIB::POW_F128, RTLIB::POW_PPCF128,
Results);
4669 ExpandArgFPLibCall(
Node, RTLIB::LROUND_F32,
4670 RTLIB::LROUND_F64, RTLIB::LROUND_F80,
4672 RTLIB::LROUND_PPCF128,
Results);
4676 ExpandArgFPLibCall(
Node, RTLIB::LLROUND_F32,
4677 RTLIB::LLROUND_F64, RTLIB::LLROUND_F80,
4678 RTLIB::LLROUND_F128,
4679 RTLIB::LLROUND_PPCF128,
Results);
4683 ExpandArgFPLibCall(
Node, RTLIB::LRINT_F32,
4684 RTLIB::LRINT_F64, RTLIB::LRINT_F80,
4686 RTLIB::LRINT_PPCF128,
Results);
4690 ExpandArgFPLibCall(
Node, RTLIB::LLRINT_F32,
4691 RTLIB::LLRINT_F64, RTLIB::LLRINT_F80,
4693 RTLIB::LLRINT_PPCF128,
Results);
4697 ExpandFPLibCall(
Node, RTLIB::DIV_F32, RTLIB::DIV_F64,
4698 RTLIB::DIV_F80, RTLIB::DIV_F128,
4703 ExpandFPLibCall(
Node, RTLIB::REM_F32, RTLIB::REM_F64,
4704 RTLIB::REM_F80, RTLIB::REM_F128,
4709 ExpandFPLibCall(
Node, RTLIB::FMA_F32, RTLIB::FMA_F64,
4710 RTLIB::FMA_F80, RTLIB::FMA_F128,
4715 ExpandFPLibCall(
Node, RTLIB::ADD_F32, RTLIB::ADD_F64,
4716 RTLIB::ADD_F80, RTLIB::ADD_F128,
4721 ExpandFPLibCall(
Node, RTLIB::MUL_F32, RTLIB::MUL_F64,
4722 RTLIB::MUL_F80, RTLIB::MUL_F128,
4726 if (
Node->getValueType(0) == MVT::f32) {
4727 Results.push_back(ExpandLibCall(RTLIB::FPEXT_F16_F32,
Node,
false).first);
4731 if (
Node->getValueType(0) == MVT::f32) {
4732 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(
4733 DAG, RTLIB::FPEXT_BF16_F32, MVT::f32,
Node->getOperand(1),
4736 Results.push_back(Tmp.second);
4740 if (
Node->getValueType(0) == MVT::f32) {
4741 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(
4742 DAG, RTLIB::FPEXT_F16_F32, MVT::f32,
Node->getOperand(1), CallOptions,
4745 Results.push_back(Tmp.second);
4752 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unable to expand fp_to_fp16");
4753 Results.push_back(ExpandLibCall(LC,
Node,
false).first);
4759 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unable to expand fp_to_bf16");
4760 Results.push_back(ExpandLibCall(LC,
Node,
false).first);
4768 bool IsStrict =
Node->isStrictFPOpcode();
4771 EVT SVT =
Node->getOperand(IsStrict ? 1 : 0).getValueType();
4772 EVT RVT =
Node->getValueType(0);
4780 for (
unsigned t = MVT::FIRST_INTEGER_VALUETYPE;
4781 t <= MVT::LAST_INTEGER_VALUETYPE && LC == RTLIB::UNKNOWN_LIBCALL;
4789 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unable to legalize as libcall");
4794 NVT,
Node->getOperand(IsStrict ? 1 : 0));
4796 std::pair<SDValue, SDValue> Tmp =
4797 TLI.makeLibCall(DAG, LC, RVT,
Op, CallOptions, dl, Chain);
4800 Results.push_back(Tmp.second);
4808 bool IsStrict =
Node->isStrictFPOpcode();
4813 EVT SVT =
Op.getValueType();
4814 EVT RVT =
Node->getValueType(0);
4822 for (
unsigned IntVT = MVT::FIRST_INTEGER_VALUETYPE;
4823 IntVT <= MVT::LAST_INTEGER_VALUETYPE && LC == RTLIB::UNKNOWN_LIBCALL;
4831 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unable to legalize as libcall");
4834 std::pair<SDValue, SDValue> Tmp =
4835 TLI.makeLibCall(DAG, LC, NVT,
Op, CallOptions, dl, Chain);
4840 Results.push_back(Tmp.second);
4851 bool IsStrict =
Node->isStrictFPOpcode();
4854 EVT VT =
Node->getValueType(0);
4855 assert(cast<ConstantSDNode>(
Node->getOperand(IsStrict ? 2 : 1))->isZero() &&
4856 "Unable to expand as libcall if it is not normal rounding");
4859 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unable to legalize as libcall");
4861 std::pair<SDValue, SDValue> Tmp =
4862 TLI.makeLibCall(DAG, LC, VT,
Op, CallOptions,
SDLoc(
Node), Chain);
4865 Results.push_back(Tmp.second);
4871 Node->getValueType(0)),
4872 Node,
false).first);
4885 Node->getValueType(0));
4887 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unable to legalize as libcall");
4889 std::pair<SDValue, SDValue> Tmp =
4890 TLI.makeLibCall(DAG, LC,
Node->getValueType(0),
Node->getOperand(1),
4893 Results.push_back(Tmp.second);
4898 ExpandFPLibCall(
Node, RTLIB::SUB_F32, RTLIB::SUB_F64,
4899 RTLIB::SUB_F80, RTLIB::SUB_F128,
4905 RTLIB::SREM_I16, RTLIB::SREM_I32,
4906 RTLIB::SREM_I64, RTLIB::SREM_I128));
4911 RTLIB::UREM_I16, RTLIB::UREM_I32,
4912 RTLIB::UREM_I64, RTLIB::UREM_I128));
4917 RTLIB::SDIV_I16, RTLIB::SDIV_I32,
4918 RTLIB::SDIV_I64, RTLIB::SDIV_I128));
4923 RTLIB::UDIV_I16, RTLIB::UDIV_I32,
4924 RTLIB::UDIV_I64, RTLIB::UDIV_I128));
4934 RTLIB::MUL_I16, RTLIB::MUL_I32,
4935 RTLIB::MUL_I64, RTLIB::MUL_I128));
4938 switch (
Node->getSimpleValueType(0).SimpleTy) {
4942 Results.push_back(ExpandLibCall(RTLIB::CTLZ_I32,
Node,
false).first);
4945 Results.push_back(ExpandLibCall(RTLIB::CTLZ_I64,
Node,
false).first);
4948 Results.push_back(ExpandLibCall(RTLIB::CTLZ_I128,
Node,
false).first);
4955 EVT PtrTy = TLI.getPointerTy(DAG.getDataLayout());
4956 SDValue Ptr = DAG.getAllOnesConstant(dl, PtrTy);
4959 DAG.makeStateFunctionCall(RTLIB::FESETENV,
Ptr, Chain, dl));
4966 DAG.makeStateFunctionCall(RTLIB::FEGETENV, EnvPtr, Chain, dl));
4973 DAG.makeStateFunctionCall(RTLIB::FESETENV, EnvPtr, Chain, dl));
4979 EVT ModeVT =
Node->getValueType(0);
4981 int SPFI = cast<FrameIndexSDNode>(
StackPtr.getNode())->getIndex();
4982 SDValue Chain = DAG.makeStateFunctionCall(RTLIB::FEGETMODE, StackPtr,
4983 Node->getOperand(0), dl);
4985 ModeVT, dl, Chain, StackPtr,
4995 EVT ModeVT =
Mode.getValueType();
4997 int SPFI = cast<FrameIndexSDNode>(
StackPtr.getNode())->getIndex();
4998 SDValue StInst = DAG.getStore(
4999 Node->getOperand(0), dl, Mode, StackPtr,
5002 DAG.makeStateFunctionCall(RTLIB::FESETMODE, StackPtr, StInst, dl));
5010 EVT PtrTy = TLI.getPointerTy(
DL);
5012 Results.push_back(DAG.makeStateFunctionCall(RTLIB::FESETMODE, Mode,
5013 Node->getOperand(0), dl));
5020 LLVM_DEBUG(
dbgs() <<
"Successfully converted node to libcall\n");
5029 MVT EltVT,
MVT NewEltVT) {
5031 MVT MidVT = OldEltsPerNewElt == 1
5038void SelectionDAGLegalize::PromoteNode(
SDNode *
Node) {
5041 MVT OVT =
Node->getSimpleValueType(0);
5047 OVT =
Node->getOperand(0).getSimpleValueType();
5054 Node->getOpcode() == ISD::VP_REDUCE_FADD ||
5055 Node->getOpcode() == ISD::VP_REDUCE_FMUL ||
5056 Node->getOpcode() == ISD::VP_REDUCE_FMAX ||
5057 Node->getOpcode() == ISD::VP_REDUCE_FMIN ||
5058 Node->getOpcode() == ISD::VP_REDUCE_FMAXIMUM ||
5059 Node->getOpcode() == ISD::VP_REDUCE_FMINIMUM ||
5060 Node->getOpcode() == ISD::VP_REDUCE_SEQ_FADD)
5061 OVT =
Node->getOperand(1).getSimpleValueType();
5064 OVT =
Node->getOperand(2).getSimpleValueType();
5065 MVT NVT = TLI.getTypeToPromoteTo(
Node->getOpcode(), OVT);
5067 SDValue Tmp1, Tmp2, Tmp3, Tmp4;
5068 switch (
Node->getOpcode()) {
5080 unsigned NewOpc =
Node->getOpcode();
5088 DAG.getConstant(TopBit, dl, NVT));
5093 Tmp1 = DAG.
getNode(NewOpc, dl, NVT, Tmp1);
5108 auto AnyExtendedNode =
5112 auto ShiftConstant = DAG.getShiftAmountConstant(
5114 auto LeftShiftResult =
5115 DAG.getNode(
ISD::SHL, dl, NVT, AnyExtendedNode, ShiftConstant);
5118 auto CTLZResult = DAG.getNode(
Node->getOpcode(), dl, NVT, LeftShiftResult);
5126 Tmp1 = DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1);
5129 DAG.getConstant(DiffBits, dl,
5130 TLI.getShiftAmountTy(NVT, DAG.getDataLayout())));
5143 Results.push_back(PromoteLegalFP_TO_INT_SAT(
Node, dl));
5160 &&
"VAARG promotion is supported only for vectors or integer types");
5165 Tmp1 = DAG.getVAArg(NVT, dl, Chain,
Ptr,
Node->getOperand(2),
5166 Node->getConstantOperandVal(3));
5169 Tmp2 = DAG.
getNode(TruncOp, dl, OVT, Tmp1);
5173 DAG.ReplaceAllUsesOfValueWith(
SDValue(
Node, 0), Tmp2);
5174 DAG.ReplaceAllUsesOfValueWith(
SDValue(
Node, 1), Chain);
5176 UpdatedNodes->insert(Tmp2.
getNode());
5177 UpdatedNodes->insert(Chain.
getNode());
5194 unsigned ExtOp, TruncOp;
5201 switch (
Node->getOpcode()) {
5217 if (TLI.isSExtCheaperThanZExt(OVT, NVT))
5226 Tmp1 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(0));
5227 Tmp2 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(1));
5229 Tmp1 = DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1, Tmp2);
5230 Results.push_back(DAG.getNode(TruncOp, dl, OVT, Tmp1));
5238 Tmp1 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(0));
5239 Tmp2 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(1));
5242 auto &
DL = DAG.getDataLayout();
5246 DAG.getConstant(OriginalSize, dl, TLI.getScalarShiftAmountTy(
DL, NVT)));
5252 unsigned ExtOp, TruncOp;
5253 if (
Node->getValueType(0).isVector() ||
5257 }
else if (
Node->getValueType(0).isInteger()) {
5264 Tmp1 =
Node->getOperand(0);
5266 Tmp2 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(1));
5267 Tmp3 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(2));
5269 Tmp1 = DAG.getSelect(dl, NVT, Tmp1, Tmp2, Tmp3);
5272 Tmp1 = DAG.
getNode(TruncOp, dl,
Node->getValueType(0), Tmp1);
5274 Tmp1 = DAG.
getNode(TruncOp, dl,
Node->getValueType(0), Tmp1,
5275 DAG.getIntPtrConstant(0, dl,
true));
5287 Tmp1 = ShuffleWithNarrowerEltType(NVT, OVT, dl, Tmp1, Tmp2, Mask);
5296 Node->getOperand(2));
5304 MVT CVT =
Node->getSimpleValueType(0);
5305 assert(CVT == OVT &&
"not handled");
5313 if (TLI.isCondCodeLegal(CCCode, CVT)) {
5314 Tmp1 =
Node->getOperand(0);
5315 Tmp2 =
Node->getOperand(1);
5317 Tmp1 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(0));
5318 Tmp2 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(1));
5321 Tmp3 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(2));
5322 Tmp4 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(3));
5332 DAG.getIntPtrConstant(0, dl,
true));
5344 TLI.isSExtCheaperThanZExt(
Node->getOperand(0).getValueType(), NVT))
5349 if (
Node->isStrictFPOpcode()) {
5351 std::tie(Tmp1, std::ignore) =
5352 DAG.getStrictFPExtendOrRound(
Node->getOperand(1), InChain, dl, NVT);
5353 std::tie(Tmp2, std::ignore) =
5354 DAG.getStrictFPExtendOrRound(
Node->getOperand(2), InChain, dl, NVT);
5356 SDValue OutChain = DAG.getTokenFactor(dl, TmpChains);
5357 SDVTList VTs = DAG.getVTList(
Node->getValueType(0), MVT::Other);
5358 Results.push_back(DAG.getNode(
Node->getOpcode(), dl, VTs,
5359 {OutChain, Tmp1, Tmp2, Node->getOperand(3)},
5364 Tmp1 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(0));
5365 Tmp2 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(1));
5367 Tmp2,
Node->getOperand(2),
Node->getFlags()));
5374 cast<CondCodeSDNode>(
Node->getOperand(1))->get();
5377 Tmp1 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(2));
5378 Tmp2 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(3));
5380 Node->getOperand(0),
Node->getOperand(1),
5381 Tmp1, Tmp2,
Node->getOperand(4)));
5399 Tmp3 = DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1, Tmp2,
5403 DAG.getIntPtrConstant(0, dl,
true)));
5415 {
Node->getOperand(0),
Node->getOperand(1)});
5417 {
Node->getOperand(0),
Node->getOperand(2)});
5420 Tmp1 = DAG.
getNode(
Node->getOpcode(), dl, {NVT, MVT::Other},
5421 {Tmp3, Tmp1, Tmp2});
5424 DAG.getIntPtrConstant(0, dl,
true)});
5434 DAG.getNode(
Node->getOpcode(), dl, NVT, Tmp1, Tmp2, Tmp3),
5435 DAG.getIntPtrConstant(0, dl,
true)));
5439 {
Node->getOperand(0),
Node->getOperand(1)});
5441 {
Node->getOperand(0),
Node->getOperand(2)});
5443 {
Node->getOperand(0),
Node->getOperand(3)});
5446 Tmp4 = DAG.
getNode(
Node->getOpcode(), dl, {NVT, MVT::Other},
5447 {Tmp4, Tmp1, Tmp2, Tmp3});
5450 DAG.getIntPtrConstant(0, dl,
true)});
5458 Tmp2 =
Node->getOperand(1);
5459 Tmp3 = DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1, Tmp2);
5469 DAG.getIntPtrConstant(isTrunc, dl,
true)));
5474 {
Node->getOperand(0),
Node->getOperand(1)});
5475 Tmp2 =
Node->getOperand(2);
5480 DAG.getIntPtrConstant(0, dl,
true)});
5487 {
Node->getOperand(0),
Node->getOperand(1)});
5488 Tmp2 = DAG.
getNode(
Node->getOpcode(), dl, {NVT, MVT::Other},
5492 DAG.getIntPtrConstant(0, dl,
true)});
5502 DAG.getIntPtrConstant(0, dl,
true)));
5511 Tmp3 = DAG.getIntPtrConstant(0, dl,
true);
5512 for (
unsigned ResNum = 0; ResNum <
Node->getNumValues(); ResNum++)
5544 Tmp2 = DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1);
5547 DAG.getIntPtrConstant(0, dl,
true)));
5572 {
Node->getOperand(0),
Node->getOperand(1)});
5573 Tmp2 = DAG.
getNode(
Node->getOpcode(), dl, {NVT, MVT::Other},
5577 DAG.getIntPtrConstant(0, dl,
true)});
5592 "Invalid promote type for build_vector");
5625 "Invalid promote type for extract_vector_elt");
5632 EVT IdxVT =
Idx.getValueType();
5634 SDValue Factor = DAG.getConstant(NewEltsPerOldElt, SL, IdxVT);
5640 for (
unsigned I = 0;
I < NewEltsPerOldElt; ++
I) {
5641 SDValue IdxOffset = DAG.getConstant(
I, SL, IdxVT);
5649 SDValue NewVec = DAG.getBuildVector(MidVT, SL, NewOps);
5671 "Invalid promote type for insert_vector_elt");
5679 EVT IdxVT =
Idx.getValueType();
5682 SDValue Factor = DAG.getConstant(NewEltsPerOldElt,
SDLoc(), IdxVT);
5689 for (
unsigned I = 0;
I < NewEltsPerOldElt; ++
I) {
5690 SDValue IdxOffset = DAG.getConstant(
I, SL, IdxVT);
5694 CastVal, IdxOffset);
5697 NewVec, Elt, InEltIdx);
5737 "unexpected promotion type");
5739 "unexpected atomic_swap with illegal type");
5763 "unexpected promotion type");
5765 "unexpected atomic_load with illegal type");
5776 MVT ScalarType =
Scalar.getSimpleValueType();
5780 Tmp2 = DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1);
5785 Tmp2 = DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1);
5788 DAG.getIntPtrConstant(0, dl,
true)));
5791 case ISD::VP_REDUCE_FMAX:
5792 case ISD::VP_REDUCE_FMIN:
5793 case ISD::VP_REDUCE_FMAXIMUM:
5794 case ISD::VP_REDUCE_FMINIMUM:
5820 SelectionDAGLegalize
Legalizer(*
this, LegalizedNodes);
5827 bool AnyLegalized =
false;
5838 if (LegalizedNodes.
insert(
N).second) {
5839 AnyLegalized =
true;
5860 SelectionDAGLegalize
Legalizer(*
this, LegalizedNodes, &UpdatedNodes);
5867 return LegalizedNodes.
count(
N);
aarch64 falkor hwpf fix Falkor HW Prefetch Fix Late Phase
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...
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
static bool isSigned(unsigned int Opcode)
Utilities for dealing with flags related to floating point properties and mode controls.
static MaybeAlign getAlign(Value *Ptr)
static bool ExpandBVWithShuffles(SDNode *Node, SelectionDAG &DAG, const TargetLowering &TLI, SDValue &Res)
static bool isSinCosLibcallAvailable(SDNode *Node, const TargetLowering &TLI)
Return true if sincos libcall is available.
static bool useSinCos(SDNode *Node)
Only issue sincos libcall if both sin and cos are needed.
static MachineMemOperand * getStackAlignedMMO(SDValue StackPtr, MachineFunction &MF, bool isObjectScalable)
static MVT getPromotedVectorElementType(const TargetLowering &TLI, MVT EltVT, MVT NewEltVT)
mir Rename Register Operands
std::pair< MCSymbol *, MachineModuleInfoImpl::StubValueTy > PairTy
PowerPC Reduce CR logical Operation
static constexpr Register SPReg
const SmallVectorImpl< MachineOperand > & Cond
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallPtrSet class.
This file defines the SmallSet class.
This file defines the SmallVector class.
This file describes how to lower LLVM code to machine code.
static constexpr int Concat[]
support::ulittle16_t & Lo
support::ulittle16_t & Hi
DEMANGLE_DUMP_METHOD void dump() const
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),...
This is an SDNode representing atomic operations.
const SDValue & getBasePtr() const
const SDValue & getVal() const
static bool isValueValidForType(EVT VT, const APFloat &Val)
const APFloat & getValueAPF() const
const ConstantFP * getConstantFPValue() const
ConstantFP - Floating Point Values [float, double].
const APFloat & getValueAPF() const
This is the shared class of boolean and integer constants.
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
static Constant * get(ArrayRef< Constant * > V)
This is an important base class in LLVM.
This class represents an Operation in the Expression.
A parsed version of the target data layout string in and methods for querying it.
const BasicBlock & back() const
This class is used to form a handle around another node that is persistent and is updated across invo...
This class is used to represent ISD::LOAD nodes.
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.
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.
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 representing virtual and physical registers.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
ArrayRef< SDUse > ops() const
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.
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
iterator_range< user_iterator > users()
void setFlags(SDNodeFlags NewFlags)
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...
const SDValue & getRoot() const
Return the root tag of the SelectionDAG.
const TargetLowering & getTargetLoweringInfo() const
allnodes_const_iterator allnodes_begin() const
SDValue getUNDEF(EVT VT)
Return an UNDEF node. UNDEF does not have a useful SDLoc.
allnodes_const_iterator allnodes_end() const
void DeleteNode(SDNode *N)
Remove the specified node from the system.
const DataLayout & getDataLayout() const
void Legalize()
This transforms the SelectionDAG into a SelectionDAG that is compatible with the target instruction s...
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 ...
void ReplaceAllUsesWith(SDValue From, SDValue To)
Modify anything using 'From' to use 'To' instead.
void RemoveDeadNodes()
This method deletes all unreachable nodes in the SelectionDAG.
const TargetMachine & getTarget() const
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
unsigned AssignTopologicalOrder()
Topological-sort the AllNodes list and a assign a unique node id for each node in the DAG based on th...
void ReplaceAllUsesOfValueWith(SDValue From, SDValue To)
Replace any uses of From with To, leaving uses of other values produced by From.getNode() alone.
LLVMContext * getContext() const
SDValue getVectorShuffle(EVT VT, const SDLoc &dl, SDValue N1, SDValue N2, ArrayRef< int > Mask)
Return an ISD::VECTOR_SHUFFLE node.
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.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
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 append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
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.
Information about stack frame layout on the target.
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
virtual bool isShuffleMaskLegal(ArrayRef< int >, EVT) const
Targets can use this to indicate that they only support some VECTOR_SHUFFLE operations,...
LegalizeAction
This enum indicates whether operations are valid for a target, and if not, what action should be used...
virtual EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context, EVT VT) const
Return the ValueType of the result of SETCC operations.
bool isTypeLegal(EVT VT) const
Return true if the target has native support for the specified value type.
const char * getLibcallName(RTLIB::Libcall Call) const
Get the libcall routine name for the specified libcall.
std::vector< ArgListEntry > ArgListTy
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
Primary interface to the complete machine description for the target machine.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static constexpr TypeSize getFixed(ScalarTy ExactSize)
The instances of the Type class are immutable: once they are created, they are never changed.
static Type * getVoidTy(LLVMContext &C)
static IntegerType * getInt64Ty(LLVMContext &C)
static 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 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.
@ C
The default llvm calling convention, compatible with C.
@ 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.
@ 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.
@ FATAN2
FATAN2 - atan2, inspired by libm.
@ 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.
@ 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 or maximum on two values.
@ 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.
@ ADDRSPACECAST
ADDRSPACECAST - This operator converts between pointers of different address spaces.
@ EXPERIMENTAL_VECTOR_HISTOGRAM
@ 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,...
@ 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,...
NodeType getExtForLoadExtType(bool IsFP, LoadExtType)
bool isNormalStore(const SDNode *N)
Returns true if the specified node is a non-truncating and unindexed store.
CondCode getSetCCInverse(CondCode Operation, EVT Type)
Return the operation corresponding to !(X op Y), where 'op' is a valid SetCC operation.
std::optional< unsigned > getVPMaskIdx(unsigned Opcode)
The operand position of the vector mask.
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).
bool isVPOpcode(unsigned Opcode)
Whether this is a vector-predicated Opcode.
Libcall getFSINCOS(EVT RetVT)
getFSINCOS - Return the FSINCOS_* value for the given types, or UNKNOWN_LIBCALL if there is none.
Libcall getPOWI(EVT RetVT)
getPOWI - Return the POWI_* value for the given types, or UNKNOWN_LIBCALL if there is none.
Libcall getSINTTOFP(EVT OpVT, EVT RetVT)
getSINTTOFP - Return the SINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
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.
Libcall getLDEXP(EVT RetVT)
getLDEXP - Return the LDEXP_* value for the given types, or UNKNOWN_LIBCALL if there is none.
Libcall getUINTTOFP(EVT OpVT, EVT RetVT)
getUINTTOFP - Return the UINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
Libcall getFREXP(EVT RetVT)
getFREXP - Return the FREXP_* value for the given types, or UNKNOWN_LIBCALL if there is none.
Libcall
RTLIB::Libcall enum - This enum defines all of the runtime library calls the backend can emit.
Libcall getFPTOUINT(EVT OpVT, EVT RetVT)
getFPTOUINT - Return the FPTOUINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
Libcall getFPTOSINT(EVT OpVT, EVT RetVT)
getFPTOSINT - Return the FPTOSINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
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...
Libcall getFPEXT(EVT OpVT, EVT RetVT)
getFPEXT - Return the FPEXT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
Libcall getFPROUND(EVT OpVT, EVT RetVT)
getFPROUND - Return the FPROUND_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
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,...
@ Undef
Value of the register doesn't matter.
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.
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)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Constant * ConstantFoldCastOperand(unsigned Opcode, Constant *C, Type *DestTy, const DataLayout &DL)
Attempt to constant fold a cast with the specified operand.
AtomicOrdering
Atomic ordering for LLVM's memory model.
@ Or
Bitwise or logical OR of integers.
@ And
Bitwise or logical AND of integers.
DWARFExpression::Operation Op
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.
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
int32_t ExponentType
A signed type to represent a floating point numbers unbiased exponent.
This struct is a compact representation of a valid (non-zero power of two) alignment.
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.
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.
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 MachinePointerInfo getJumpTable(MachineFunction &MF)
Return a MachinePointerInfo record that refers to a jump table entry.
static MachinePointerInfo getConstantPool(MachineFunction &MF)
Return a MachinePointerInfo record that refers to the constant pool.
MachinePointerInfo getWithOffset(int64_t O) const
static MachinePointerInfo getUnknownStack(MachineFunction &MF)
Stack memory without other information.
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
These are IR-level optimization flags that may be propagated to SDNodes.
void setNoUnsignedWrap(bool b)
void setNoSignedWrap(bool b)
This represents a list of ValueType's that has been intern'd by a SelectionDAG.
This structure contains all information that is necessary for lowering calls.
This structure is used to pass arguments to makeLibCall function.
bool IsPostTypeLegalization
MakeLibCallOptions & setIsSigned(bool Value=true)