58#define DEBUG_TYPE "legalizedag"
64struct FloatSignAsInt {
87class SelectionDAGLegalize {
99 EVT getSetCCResultType(
EVT VT)
const {
110 LegalizedNodes(LegalizedNodes), UpdatedNodes(UpdatedNodes) {}
131 std::pair<SDValue, SDValue> ExpandLibCall(RTLIB::Libcall LC,
SDNode *
Node,
133 bool IsSigned,
EVT RetVT);
134 std::pair<SDValue, SDValue> ExpandLibCall(RTLIB::Libcall LC,
SDNode *
Node,
bool isSigned);
136 void ExpandFPLibCall(
SDNode *
Node, RTLIB::Libcall LC,
138 void ExpandFPLibCall(
SDNode *
Node, RTLIB::Libcall Call_F32,
139 RTLIB::Libcall Call_F64, RTLIB::Libcall Call_F80,
140 RTLIB::Libcall Call_F128,
141 RTLIB::Libcall Call_PPCF128,
145 ExpandFastFPLibCall(
SDNode *
Node,
bool IsFast,
146 std::pair<RTLIB::Libcall, RTLIB::Libcall> Call_F32,
147 std::pair<RTLIB::Libcall, RTLIB::Libcall> Call_F64,
148 std::pair<RTLIB::Libcall, RTLIB::Libcall> Call_F80,
149 std::pair<RTLIB::Libcall, RTLIB::Libcall> Call_F128,
150 std::pair<RTLIB::Libcall, RTLIB::Libcall> Call_PPCF128,
154 RTLIB::Libcall Call_I16, RTLIB::Libcall Call_I32,
155 RTLIB::Libcall Call_I64, RTLIB::Libcall Call_I128);
157 RTLIB::Libcall Call_F32, RTLIB::Libcall Call_F64,
158 RTLIB::Libcall Call_F80, RTLIB::Libcall Call_F128,
159 RTLIB::Libcall Call_PPCF128,
162 RTLIB::Libcall CallI64,
163 RTLIB::Libcall CallI128);
175 void getSignAsIntValue(FloatSignAsInt &State,
const SDLoc &
DL,
177 SDValue modifySignAsInt(
const FloatSignAsInt &State,
const SDLoc &
DL,
225 dbgs() <<
" with: "; New->dump(&DAG));
228 "Replacing one node with another that produces a different number "
232 UpdatedNodes->
insert(New);
238 dbgs() <<
" with: "; New->dump(&DAG));
242 UpdatedNodes->
insert(New.getNode());
243 ReplacedNode(Old.getNode());
250 for (
unsigned i = 0, e = Old->
getNumValues(); i != e; ++i) {
261 dbgs() <<
" with: "; New->dump(&DAG));
265 UpdatedNodes->
insert(New.getNode());
266 ReplacedNode(Old.getNode());
276 bool isObjectScalable) {
278 int FI = cast<FrameIndexSDNode>(StackPtr)->getIndex();
284 ObjectSize, MFI.getObjectAlign(FI));
291SDValue SelectionDAGLegalize::ShuffleWithNarrowerEltType(
296 unsigned NumEltsGrowth = NumDestElts / NumMaskElts;
298 assert(NumEltsGrowth &&
"Cannot promote to vector type with fewer elts!");
300 if (NumEltsGrowth == 1)
301 return DAG.getVectorShuffle(NVT, dl, N1, N2, Mask);
304 for (
unsigned i = 0; i != NumMaskElts; ++i) {
306 for (
unsigned j = 0;
j != NumEltsGrowth; ++
j) {
313 assert(NewMask.
size() == NumDestElts &&
"Non-integer NumEltsGrowth?");
314 assert(TLI.isShuffleMaskLegal(NewMask, NVT) &&
"Shuffle not legal?");
315 return DAG.getVectorShuffle(NVT, dl, N1, N2, NewMask);
334 assert((VT == MVT::f64 || VT == MVT::f32) &&
"Invalid type expansion");
336 (VT == MVT::f64) ? MVT::i64 : MVT::i32);
346 while (SVT != MVT::f32 && SVT != MVT::f16 && SVT != MVT::bf16) {
352 TLI.ShouldShrinkFPConstant(OrigVT)) {
355 Instruction::FPTrunc, LLVMC, SType, DAG.getDataLayout()));
363 DAG.getConstantPool(LLVMC, TLI.getPointerTy(DAG.getDataLayout()));
364 Align Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlign();
373 OrigVT, dl, DAG.getEntryNode(), CPIdx,
381 EVT VT =
CP->getValueType(0);
382 SDValue CPIdx = DAG.getConstantPool(
CP->getConstantIntValue(),
383 TLI.getPointerTy(DAG.getDataLayout()));
384 Align Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlign();
386 VT, dl, DAG.getEntryNode(), CPIdx,
412 for (
unsigned i = 0; i != NumElts; ++i)
413 ShufOps.
push_back(i != InsertPos->getZExtValue() ? i : NumElts);
415 return DAG.getVectorShuffle(Vec.
getValueType(), dl, Vec, ScVec, ShufOps);
418 return ExpandInsertToVectorThroughStack(
Op);
445 TLI.isTypeLegal(MVT::i32)) {
447 bitcastToAPInt().zextOrTrunc(32),
448 SDLoc(CFP), MVT::i32);
449 return DAG.getStore(Chain, dl, Con,
Ptr,
ST->getPointerInfo(),
450 ST->getBaseAlign(), MMOFlags, AAInfo);
456 if (TLI.isTypeLegal(MVT::i64)) {
458 zextOrTrunc(64),
SDLoc(CFP), MVT::i64);
459 return DAG.getStore(Chain, dl, Con,
Ptr,
ST->getPointerInfo(),
460 ST->getBaseAlign(), MMOFlags, AAInfo);
463 if (TLI.isTypeLegal(MVT::i32) && !
ST->isVolatile()) {
470 if (DAG.getDataLayout().isBigEndian())
473 Lo = DAG.getStore(Chain, dl,
Lo,
Ptr,
ST->getPointerInfo(),
474 ST->getBaseAlign(), MMOFlags, AAInfo);
476 Hi = DAG.getStore(Chain, dl,
Hi,
Ptr,
477 ST->getPointerInfo().getWithOffset(4),
478 ST->getBaseAlign(), MMOFlags, AAInfo);
487void SelectionDAGLegalize::LegalizeStoreOps(
SDNode *
Node) {
496 if (!
ST->isTruncatingStore()) {
499 ReplaceNode(ST, OptStore);
504 MVT VT =
Value.getSimpleValueType();
505 switch (TLI.getOperationAction(
ISD::STORE, VT)) {
507 case TargetLowering::Legal: {
510 EVT MemVT =
ST->getMemoryVT();
512 if (!TLI.allowsMemoryAccessForAlignment(*DAG.getContext(),
DL, MemVT,
513 *
ST->getMemOperand())) {
516 ReplaceNode(
SDValue(ST, 0), Result);
521 case TargetLowering::Custom: {
528 case TargetLowering::Promote: {
531 "Can only promote stores to same size type");
534 ST->getBaseAlign(), MMOFlags, AAInfo);
544 EVT StVT =
ST->getMemoryVT();
547 auto &
DL = DAG.getDataLayout();
549 if (StWidth != StSize) {
554 Value = DAG.getZeroExtendInReg(
Value, dl, StVT);
556 DAG.getTruncStore(Chain, dl,
Value,
Ptr,
ST->getPointerInfo(), NVT,
557 ST->getBaseAlign(), MMOFlags, AAInfo);
563 unsigned LogStWidth =
Log2_32(StWidthBits);
565 unsigned RoundWidth = 1 << LogStWidth;
566 assert(RoundWidth < StWidthBits);
567 unsigned ExtraWidth = StWidthBits - RoundWidth;
568 assert(ExtraWidth < RoundWidth);
569 assert(!(RoundWidth % 8) && !(ExtraWidth % 8) &&
570 "Store size not an integral number of bytes!");
574 unsigned IncrementSize;
576 if (
DL.isLittleEndian()) {
579 Lo = DAG.getTruncStore(Chain, dl,
Value,
Ptr,
ST->getPointerInfo(),
580 RoundVT,
ST->getBaseAlign(), MMOFlags, AAInfo);
583 IncrementSize = RoundWidth / 8;
588 DAG.getConstant(RoundWidth, dl,
589 TLI.getShiftAmountTy(
Value.getValueType(),
DL)));
590 Hi = DAG.getTruncStore(Chain, dl,
Hi,
Ptr,
591 ST->getPointerInfo().getWithOffset(IncrementSize),
592 ExtraVT,
ST->getBaseAlign(), MMOFlags, AAInfo);
599 DAG.getConstant(ExtraWidth, dl,
600 TLI.getShiftAmountTy(
Value.getValueType(),
DL)));
601 Hi = DAG.getTruncStore(Chain, dl,
Hi,
Ptr,
ST->getPointerInfo(), RoundVT,
602 ST->getBaseAlign(), MMOFlags, AAInfo);
605 IncrementSize = RoundWidth / 8;
607 DAG.getConstant(IncrementSize, dl,
608 Ptr.getValueType()));
610 ST->getPointerInfo().getWithOffset(IncrementSize),
611 ExtraVT,
ST->getBaseAlign(), MMOFlags, AAInfo);
618 switch (TLI.getTruncStoreAction(
ST->getValue().getValueType(), StVT)) {
620 case TargetLowering::Legal: {
621 EVT MemVT =
ST->getMemoryVT();
624 if (!TLI.allowsMemoryAccessForAlignment(*DAG.getContext(),
DL, MemVT,
625 *
ST->getMemOperand())) {
627 ReplaceNode(
SDValue(ST, 0), Result);
631 case TargetLowering::Custom: {
637 case TargetLowering::Expand:
639 "Vector Stores are handled in LegalizeVectorOps");
644 if (TLI.isTypeLegal(StVT)) {
647 ST->getBaseAlign(), MMOFlags, AAInfo);
652 TLI.getTypeToTransformTo(*DAG.getContext(), StVT),
655 StVT,
ST->getBaseAlign(), MMOFlags, AAInfo);
664void SelectionDAGLegalize::LegalizeLoadOps(
SDNode *
Node) {
673 LLVM_DEBUG(
dbgs() <<
"Legalizing non-extending load operation\n");
674 MVT VT =
Node->getSimpleValueType(0);
678 switch (TLI.getOperationAction(
Node->getOpcode(), VT)) {
680 case TargetLowering::Legal: {
681 EVT MemVT =
LD->getMemoryVT();
685 if (!TLI.allowsMemoryAccessForAlignment(*DAG.getContext(),
DL, MemVT,
686 *
LD->getMemOperand())) {
687 std::tie(RVal, RChain) = TLI.expandUnalignedLoad(LD, DAG);
691 case TargetLowering::Custom:
692 if (
SDValue Res = TLI.LowerOperation(RVal, DAG)) {
698 case TargetLowering::Promote: {
699 MVT NVT = TLI.getTypeToPromoteTo(
Node->getOpcode(), VT);
701 "Can only promote loads to same size type");
705 if (
const MDNode *MD =
LD->getRanges()) {
709 LD->getMemOperand()->clearRanges();
711 SDValue Res = DAG.getLoad(NVT, dl, Chain,
Ptr,
LD->getMemOperand());
719 DAG.ReplaceAllUsesOfValueWith(
SDValue(
Node, 0), RVal);
720 DAG.ReplaceAllUsesOfValueWith(
SDValue(
Node, 1), RChain);
722 UpdatedNodes->insert(RVal.
getNode());
723 UpdatedNodes->insert(RChain.
getNode());
731 EVT SrcVT =
LD->getMemoryVT();
745 TLI.getLoadExtAction(ExtType,
Node->getValueType(0), MVT::i1) ==
746 TargetLowering::Promote)) {
760 Chain,
Ptr,
LD->getPointerInfo(), NVT,
761 LD->getBaseAlign(), MMOFlags, AAInfo);
769 Result, DAG.getValueType(SrcVT));
773 Result.getValueType(), Result,
774 DAG.getValueType(SrcVT));
782 unsigned LogSrcWidth =
Log2_32(SrcWidthBits);
784 unsigned RoundWidth = 1 << LogSrcWidth;
785 assert(RoundWidth < SrcWidthBits);
786 unsigned ExtraWidth = SrcWidthBits - RoundWidth;
787 assert(ExtraWidth < RoundWidth);
788 assert(!(RoundWidth % 8) && !(ExtraWidth % 8) &&
789 "Load size not an integral number of bytes!");
793 unsigned IncrementSize;
794 auto &
DL = DAG.getDataLayout();
796 if (
DL.isLittleEndian()) {
800 LD->getPointerInfo(), RoundVT,
LD->getBaseAlign(),
804 IncrementSize = RoundWidth / 8;
807 Hi = DAG.getExtLoad(ExtType, dl,
Node->getValueType(0), Chain,
Ptr,
808 LD->getPointerInfo().getWithOffset(IncrementSize),
809 ExtraVT,
LD->getBaseAlign(), MMOFlags, AAInfo);
819 DAG.getConstant(RoundWidth, dl,
820 TLI.getShiftAmountTy(
Hi.getValueType(),
DL)));
828 Hi = DAG.getExtLoad(ExtType, dl,
Node->getValueType(0), Chain,
Ptr,
829 LD->getPointerInfo(), RoundVT,
LD->getBaseAlign(),
833 IncrementSize = RoundWidth / 8;
837 LD->getPointerInfo().getWithOffset(IncrementSize),
838 ExtraVT,
LD->getBaseAlign(), MMOFlags, AAInfo);
848 DAG.getConstant(ExtraWidth, dl,
849 TLI.getShiftAmountTy(
Hi.getValueType(),
DL)));
857 bool isCustom =
false;
858 switch (TLI.getLoadExtAction(ExtType,
Node->getValueType(0),
861 case TargetLowering::Custom:
864 case TargetLowering::Legal:
876 EVT MemVT =
LD->getMemoryVT();
878 if (!TLI.allowsMemoryAccess(*DAG.getContext(),
DL, MemVT,
879 *
LD->getMemOperand())) {
880 std::tie(
Value, Chain) = TLI.expandUnalignedLoad(LD, DAG);
885 case TargetLowering::Expand: {
886 EVT DestVT =
Node->getValueType(0);
892 (TLI.isTypeLegal(SrcVT) ||
893 TLI.isLoadExtLegal(ExtType, LoadVT, SrcVT))) {
900 SrcVT,
LD->getMemOperand());
903 Value = DAG.getNode(ExtendOp, dl,
Node->getValueType(0), Load);
904 Chain =
Load.getValue(1);
913 if (SVT == MVT::f16 || SVT == MVT::bf16) {
919 Ptr, ISrcVT,
LD->getMemOperand());
923 Chain =
Result.getValue(1);
929 "Vector Loads are handled in LegalizeVectorOps");
936 "EXTLOAD should always be supported!");
940 Node->getValueType(0),
942 LD->getMemOperand());
947 Result, DAG.getValueType(SrcVT));
949 ValRes = DAG.getZeroExtendInReg(Result, dl, SrcVT);
951 Chain =
Result.getValue(1);
962 DAG.ReplaceAllUsesOfValueWith(
SDValue(
Node, 1), Chain);
964 UpdatedNodes->insert(
Value.getNode());
965 UpdatedNodes->insert(Chain.
getNode());
972void SelectionDAGLegalize::LegalizeOp(
SDNode *
Node) {
981 for (
unsigned i = 0, e =
Node->getNumValues(); i != e; ++i)
982 assert(TLI.getTypeAction(*DAG.getContext(),
Node->getValueType(i)) ==
983 TargetLowering::TypeLegal &&
984 "Unexpected illegal type!");
987 assert((TLI.getTypeAction(*DAG.getContext(),
Op.getValueType()) ==
988 TargetLowering::TypeLegal ||
991 "Unexpected illegal type!");
996 bool SimpleFinishLegalizing =
true;
997 switch (
Node->getOpcode()) {
1007 SDValue UndefNode = DAG.getUNDEF(
Node->getValueType(0));
1015 Action = TLI.getOperationAction(
Node->getOpcode(), MVT::Other);
1018 Action = TLI.getOperationAction(
Node->getOpcode(),
1019 Node->getValueType(0));
1022 Action = TLI.getOperationAction(
Node->getOpcode(),
1023 Node->getValueType(0));
1024 if (Action != TargetLowering::Promote)
1025 Action = TLI.getOperationAction(
Node->getOpcode(), MVT::Other);
1029 Action = TLI.getOperationAction(
Node->getOpcode(),
1030 Node->getOperand(1).getValueType());
1041 Action = TLI.getOperationAction(
Node->getOpcode(),
1042 Node->getOperand(0).getValueType());
1055 Action = TLI.getOperationAction(
Node->getOpcode(),
1056 Node->getOperand(1).getValueType());
1059 EVT InnerType = cast<VTSDNode>(
Node->getOperand(1))->getVT();
1060 Action = TLI.getOperationAction(
Node->getOpcode(), InnerType);
1064 Action = TLI.getOperationAction(
Node->getOpcode(),
1065 Node->getOperand(1).getValueType());
1074 unsigned Opc =
Node->getOpcode();
1085 MVT OpVT =
Node->getOperand(CompareOperand).getSimpleValueType();
1087 cast<CondCodeSDNode>(
Node->getOperand(CCOperand))->get();
1088 Action = TLI.getCondCodeAction(CCCode, OpVT);
1089 if (Action == TargetLowering::Legal) {
1091 Action = TLI.getOperationAction(
Node->getOpcode(),
1092 Node->getValueType(0));
1094 Action = TLI.getOperationAction(
Node->getOpcode(), OpVT);
1102 SimpleFinishLegalizing =
false;
1109 SimpleFinishLegalizing =
false;
1122 Action = TLI.getOperationAction(
Node->getOpcode(),
Node->getValueType(0));
1123 if (Action == TargetLowering::Legal)
1124 Action = TargetLowering::Expand;
1134 Action = TLI.getOperationAction(
Node->getOpcode(),
Node->getValueType(0));
1135 if (Action == TargetLowering::Legal)
1136 Action = TargetLowering::Custom;
1141 Action = TLI.getOperationAction(
Node->getOpcode(),
Node->getValueType(0));
1147 Action = TLI.getOperationAction(
Node->getOpcode(), MVT::i64);
1154 Action = TargetLowering::Legal;
1157 Action = TLI.getOperationAction(
Node->getOpcode(),
Node->getValueType(0));
1158 if (Action == TargetLowering::Expand) {
1162 Node->getOperand(0));
1169 Action = TLI.getOperationAction(
Node->getOpcode(),
Node->getValueType(0));
1170 if (Action == TargetLowering::Expand) {
1174 Node->getOperand(0));
1190 Action = TLI.getOperationAction(
Node->getOpcode(),
Node->getValueType(0));
1200 unsigned Scale =
Node->getConstantOperandVal(2);
1201 Action = TLI.getFixedPointOperationAction(
Node->getOpcode(),
1202 Node->getValueType(0), Scale);
1206 Action = TLI.getOperationAction(
Node->getOpcode(),
1207 cast<MaskedScatterSDNode>(
Node)->getValue().getValueType());
1210 Action = TLI.getOperationAction(
Node->getOpcode(),
1211 cast<MaskedStoreSDNode>(
Node)->getValue().getValueType());
1213 case ISD::VP_SCATTER:
1214 Action = TLI.getOperationAction(
1216 cast<VPScatterSDNode>(
Node)->getValue().getValueType());
1219 Action = TLI.getOperationAction(
1221 cast<VPStoreSDNode>(
Node)->getValue().getValueType());
1223 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
1224 Action = TLI.getOperationAction(
1226 cast<VPStridedStoreSDNode>(
Node)->getValue().getValueType());
1244 Action = TLI.getOperationAction(
1245 Node->getOpcode(),
Node->getOperand(0).getValueType());
1249 case ISD::VP_REDUCE_FADD:
1250 case ISD::VP_REDUCE_FMUL:
1251 case ISD::VP_REDUCE_ADD:
1252 case ISD::VP_REDUCE_MUL:
1253 case ISD::VP_REDUCE_AND:
1254 case ISD::VP_REDUCE_OR:
1255 case ISD::VP_REDUCE_XOR:
1256 case ISD::VP_REDUCE_SMAX:
1257 case ISD::VP_REDUCE_SMIN:
1258 case ISD::VP_REDUCE_UMAX:
1259 case ISD::VP_REDUCE_UMIN:
1260 case ISD::VP_REDUCE_FMAX:
1261 case ISD::VP_REDUCE_FMIN:
1262 case ISD::VP_REDUCE_FMAXIMUM:
1263 case ISD::VP_REDUCE_FMINIMUM:
1264 case ISD::VP_REDUCE_SEQ_FADD:
1265 case ISD::VP_REDUCE_SEQ_FMUL:
1266 Action = TLI.getOperationAction(
1267 Node->getOpcode(),
Node->getOperand(1).getValueType());
1269 case ISD::VP_CTTZ_ELTS:
1270 case ISD::VP_CTTZ_ELTS_ZERO_UNDEF:
1271 Action = TLI.getOperationAction(
Node->getOpcode(),
1272 Node->getOperand(0).getValueType());
1275 Action = TLI.getOperationAction(
1277 cast<MaskedHistogramSDNode>(
Node)->getIndex().getValueType());
1281 Action = TLI.getCustomOperationAction(*
Node);
1283 Action = TLI.getOperationAction(
Node->getOpcode(),
Node->getValueType(0));
1288 if (SimpleFinishLegalizing) {
1290 switch (
Node->getOpcode()) {
1309 NewNode = DAG.UpdateNodeOperands(
Node, Op0, SAO);
1329 NewNode = DAG.UpdateNodeOperands(
Node, Op0, Op1, SAO);
1335 if (NewNode !=
Node) {
1336 ReplaceNode(
Node, NewNode);
1340 case TargetLowering::Legal:
1343 case TargetLowering::Custom:
1351 if (
Node->getNumValues() == 1) {
1355 Node->getValueType(0) == MVT::Glue) &&
1356 "Type mismatch for custom legalized operation");
1364 for (
unsigned i = 0, e =
Node->getNumValues(); i != e; ++i) {
1368 Node->getValueType(i) == MVT::Glue) &&
1369 "Type mismatch for custom legalized operation");
1373 ReplaceNode(
Node, ResultVals.
data());
1378 case TargetLowering::Expand:
1379 if (ExpandNode(
Node))
1382 case TargetLowering::LibCall:
1383 ConvertNodeToLibcall(
Node);
1385 case TargetLowering::Promote:
1391 switch (
Node->getOpcode()) {
1404 return LegalizeLoadOps(
Node);
1406 return LegalizeStoreOps(
Node);
1410SDValue SelectionDAGLegalize::ExpandExtractFromVectorThroughStack(
SDValue Op) {
1430 if (
ST->isIndexed() ||
ST->isTruncatingStore() ||
1431 ST->getValue() != Vec)
1436 if (!
ST->getChain().reachesChainWithoutSideEffects(DAG.getEntryNode()))
1445 ST->hasPredecessor(
Op.getNode()))
1458 StackPtr = DAG.CreateStackTemporary(VecVT);
1461 Ch = DAG.getStore(DAG.getEntryNode(), dl, Vec, StackPtr, StoreMMO);
1465 Align ElementAlignment =
1466 std::min(cast<StoreSDNode>(Ch)->
getAlign(),
1467 DAG.getDataLayout().getPrefTypeAlign(
1468 Op.getValueType().getTypeForEVT(*DAG.getContext())));
1470 if (
Op.getValueType().isVector()) {
1471 StackPtr = TLI.getVectorSubVecPointer(DAG, StackPtr, VecVT,
1472 Op.getValueType(),
Idx);
1473 NewLoad = DAG.getLoad(
Op.getValueType(), dl, Ch, StackPtr,
1476 StackPtr = TLI.getVectorElementPointer(DAG, StackPtr, VecVT,
Idx);
1477 NewLoad = DAG.getExtLoad(
ISD::EXTLOAD, dl,
Op.getValueType(), Ch, StackPtr,
1483 DAG.ReplaceAllUsesOfValueWith(Ch,
SDValue(NewLoad.
getNode(), 1));
1488 NewLoadOperands[0] = Ch;
1490 SDValue(DAG.UpdateNodeOperands(NewLoad.
getNode(), NewLoadOperands), 0);
1494SDValue SelectionDAGLegalize::ExpandInsertToVectorThroughStack(
SDValue Op) {
1495 assert(
Op.getValueType().isVector() &&
"Non-vector insert subvector!");
1506 int FI = cast<FrameIndexSDNode>(
StackPtr.getNode())->getIndex();
1511 Align BaseVecAlignment =
1512 DAG.getMachineFunction().getFrameInfo().getObjectAlign(FI);
1513 SDValue Ch = DAG.getStore(DAG.getEntryNode(), dl, Vec, StackPtr, PtrInfo,
1517 Idx = DAG.getFreeze(
Idx);
1520 Align PartAlignment = DAG.getDataLayout().getPrefTypeAlign(PartTy);
1525 TLI.getVectorSubVecPointer(DAG, StackPtr, VecVT, PartVT,
Idx);
1529 Ch, dl, Part, SubStackPtr,
1534 TLI.getVectorElementPointer(DAG, StackPtr, VecVT,
Idx);
1537 Ch = DAG.getTruncStore(
1538 Ch, dl, Part, SubStackPtr,
1544 "ElementAlignment does not match!");
1547 return DAG.getLoad(
Op.getValueType(), dl, Ch, StackPtr, PtrInfo,
1555 unsigned NumOperands =
Node->getNumOperands();
1556 MVT VectorIdxType = TLI.getVectorIdxTy(DAG.getDataLayout());
1557 EVT VectorValueType =
Node->getOperand(0).getValueType();
1559 EVT ElementValueType = TLI.getTypeToTransformTo(
1561 for (
unsigned I = 0;
I < NumOperands; ++
I) {
1563 for (
unsigned Idx = 0;
Idx < NumSubElem; ++
Idx) {
1566 DAG.getConstant(
Idx,
DL, VectorIdxType)));
1569 return DAG.getBuildVector(
Node->getValueType(0),
DL, Ops);
1575 "Unexpected opcode!");
1581 EVT VT =
Node->getValueType(0);
1583 :
Node->getOperand(0).getValueType();
1585 SDValue FIPtr = DAG.CreateStackTemporary(VT);
1586 int FI = cast<FrameIndexSDNode>(FIPtr.
getNode())->getIndex();
1593 assert(TypeByteSize > 0 &&
"Vector element type too small for stack store!");
1597 bool Truncate = isa<BuildVectorSDNode>(
Node) &&
1598 MemVT.
bitsLT(
Node->getOperand(0).getValueType());
1601 for (
unsigned i = 0, e =
Node->getNumOperands(); i != e; ++i) {
1603 if (
Node->getOperand(i).isUndef())
continue;
1605 unsigned Offset = TypeByteSize*i;
1611 Stores.
push_back(DAG.getTruncStore(DAG.getEntryNode(), dl,
1615 Stores.
push_back(DAG.getStore(DAG.getEntryNode(), dl,
Node->getOperand(i),
1620 if (!Stores.
empty())
1623 StoreChain = DAG.getEntryNode();
1626 return DAG.getLoad(VT, dl, StoreChain, FIPtr, PtrInfo);
1632void SelectionDAGLegalize::getSignAsIntValue(FloatSignAsInt &State,
1635 EVT FloatVT =
Value.getValueType();
1637 State.FloatVT = FloatVT;
1640 if (TLI.isTypeLegal(IVT)) {
1643 State.SignBit = NumBits - 1;
1649 MVT LoadTy = TLI.getRegisterType(MVT::i8);
1652 int FI = cast<FrameIndexSDNode>(
StackPtr.getNode())->getIndex();
1657 State.Chain = DAG.getStore(DAG.getEntryNode(),
DL,
Value, State.FloatPtr,
1658 State.FloatPointerInfo);
1665 State.IntPointerInfo = State.FloatPointerInfo;
1668 unsigned ByteOffset = (NumBits / 8) - 1;
1675 State.IntPtr = IntPtr;
1676 State.IntValue = DAG.getExtLoad(
ISD::EXTLOAD,
DL, LoadTy, State.Chain, IntPtr,
1677 State.IntPointerInfo, MVT::i8);
1684SDValue SelectionDAGLegalize::modifySignAsInt(
const FloatSignAsInt &State,
1691 SDValue Chain = DAG.getTruncStore(State.Chain,
DL, NewIntValue, State.IntPtr,
1692 State.IntPointerInfo, MVT::i8);
1693 return DAG.getLoad(State.FloatVT,
DL, Chain, State.FloatPtr,
1694 State.FloatPointerInfo);
1703 FloatSignAsInt SignAsInt;
1704 getSignAsIntValue(SignAsInt,
DL, Sign);
1706 EVT IntVT = SignAsInt.IntValue.getValueType();
1707 SDValue SignMask = DAG.getConstant(SignAsInt.SignMask,
DL, IntVT);
1714 if (TLI.isOperationLegalOrCustom(
ISD::FABS, FloatVT) &&
1715 TLI.isOperationLegalOrCustom(
ISD::FNEG, FloatVT)) {
1718 SDValue Cond = DAG.getSetCC(
DL, getSetCCResultType(IntVT), SignBit,
1720 return DAG.getSelect(
DL, FloatVT,
Cond, NegValue, AbsValue);
1724 FloatSignAsInt MagAsInt;
1725 getSignAsIntValue(MagAsInt,
DL, Mag);
1726 EVT MagVT = MagAsInt.IntValue.getValueType();
1727 SDValue ClearSignMask = DAG.getConstant(~MagAsInt.SignMask,
DL, MagVT);
1732 int ShiftAmount = SignAsInt.SignBit - MagAsInt.SignBit;
1733 EVT ShiftVT = IntVT;
1739 if (ShiftAmount > 0) {
1740 SDValue ShiftCnst = DAG.getConstant(ShiftAmount,
DL, ShiftVT);
1742 }
else if (ShiftAmount < 0) {
1743 SDValue ShiftCnst = DAG.getConstant(-ShiftAmount,
DL, ShiftVT);
1755 return modifySignAsInt(MagAsInt,
DL, CopiedSign);
1761 FloatSignAsInt SignAsInt;
1762 getSignAsIntValue(SignAsInt,
DL,
Node->getOperand(0));
1763 EVT IntVT = SignAsInt.IntValue.getValueType();
1766 SDValue SignMask = DAG.getConstant(SignAsInt.SignMask,
DL, IntVT);
1771 return modifySignAsInt(SignAsInt,
DL, SignFlip);
1779 EVT FloatVT =
Value.getValueType();
1786 FloatSignAsInt ValueAsInt;
1787 getSignAsIntValue(ValueAsInt,
DL,
Value);
1788 EVT IntVT = ValueAsInt.IntValue.getValueType();
1789 SDValue ClearSignMask = DAG.getConstant(~ValueAsInt.SignMask,
DL, IntVT);
1792 return modifySignAsInt(ValueAsInt,
DL, ClearedSign);
1795void SelectionDAGLegalize::ExpandDYNAMIC_STACKALLOC(
SDNode*
Node,
1797 Register SPReg = TLI.getStackPointerRegisterToSaveRestore();
1798 assert(
SPReg &&
"Target cannot require DYNAMIC_STACKALLOC expansion and"
1799 " not tell us which reg is the stack pointer!");
1801 EVT VT =
Node->getValueType(0);
1809 Chain = DAG.getCALLSEQ_START(Chain, 0, 0, dl);
1813 Chain =
SP.getValue(1);
1814 Align Alignment = cast<ConstantSDNode>(Tmp3)->getAlignValue();
1822 if (Alignment > StackAlign)
1824 DAG.getSignedConstant(-Alignment.
value(), dl, VT));
1825 Chain = DAG.getCopyToReg(Chain, dl,
SPReg, Tmp1);
1827 Tmp2 = DAG.getCALLSEQ_END(Chain, 0, 0,
SDValue(), dl);
1839 return EmitStackConvert(
SrcOp, SlotVT, DestVT, dl, DAG.getEntryNode());
1847 Align DestAlign = DAG.getDataLayout().getPrefTypeAlign(DestType);
1850 if ((SrcVT.
bitsGT(SlotVT) &&
1851 !TLI.isTruncStoreLegalOrCustom(
SrcOp.getValueType(), SlotVT)) ||
1852 (SlotVT.
bitsLT(DestVT) &&
1853 !TLI.isLoadExtLegalOrCustom(
ISD::EXTLOAD, DestVT, SlotVT)))
1857 Align SrcAlign = DAG.getDataLayout().getPrefTypeAlign(
1858 SrcOp.getValueType().getTypeForEVT(*DAG.getContext()));
1870 if (SrcVT.
bitsGT(SlotVT))
1871 Store = DAG.getTruncStore(Chain, dl,
SrcOp, FIPtr, PtrInfo,
1875 Store = DAG.getStore(Chain, dl,
SrcOp, FIPtr, PtrInfo, SrcAlign);
1879 if (SlotVT.
bitsEq(DestVT))
1880 return DAG.getLoad(DestVT, dl, Store, FIPtr, PtrInfo, DestAlign);
1883 return DAG.getExtLoad(
ISD::EXTLOAD, dl, DestVT, Store, FIPtr, PtrInfo, SlotVT,
1896 SDValue Ch = DAG.getTruncStore(
1897 DAG.getEntryNode(), dl,
Node->getOperand(0), StackPtr,
1899 Node->getValueType(0).getVectorElementType());
1901 Node->getValueType(0), dl, Ch, StackPtr,
1908 unsigned NumElems =
Node->getNumOperands();
1910 EVT VT =
Node->getValueType(0);
1922 for (
unsigned i = 0; i < NumElems; ++i) {
1933 while (IntermedVals.
size() > 2) {
1934 NewIntermedVals.
clear();
1935 for (
unsigned i = 0, e = (IntermedVals.
size() & ~1u); i < e; i += 2) {
1941 FinalIndices.
reserve(IntermedVals[i].second.
size() +
1942 IntermedVals[i+1].second.
size());
1945 for (
unsigned j = 0, f = IntermedVals[i].second.
size(); j != f;
1948 FinalIndices.
push_back(IntermedVals[i].second[j]);
1950 for (
unsigned j = 0, f = IntermedVals[i+1].second.
size(); j != f;
1952 ShuffleVec[k] = NumElems + j;
1953 FinalIndices.
push_back(IntermedVals[i+1].second[j]);
1959 IntermedVals[i+1].first,
1964 std::make_pair(Shuffle, std::move(FinalIndices)));
1969 if ((IntermedVals.
size() & 1) != 0)
1972 IntermedVals.
swap(NewIntermedVals);
1976 "Invalid number of intermediate vectors");
1977 SDValue Vec1 = IntermedVals[0].first;
1979 if (IntermedVals.
size() > 1)
1980 Vec2 = IntermedVals[1].first;
1985 for (
unsigned i = 0, e = IntermedVals[0].second.
size(); i != e; ++i)
1986 ShuffleVec[IntermedVals[0].second[i]] = i;
1987 for (
unsigned i = 0, e = IntermedVals[1].second.
size(); i != e; ++i)
1988 ShuffleVec[IntermedVals[1].second[i]] = NumElems + i;
2002 unsigned NumElems =
Node->getNumOperands();
2005 EVT VT =
Node->getValueType(0);
2006 EVT OpVT =
Node->getOperand(0).getValueType();
2011 bool isOnlyLowElement =
true;
2012 bool MoreThanTwoValues =
false;
2014 for (
unsigned i = 0; i < NumElems; ++i) {
2019 isOnlyLowElement =
false;
2020 if (!isa<ConstantFPSDNode>(V) && !isa<ConstantSDNode>(V))
2025 }
else if (!Value2.
getNode()) {
2028 }
else if (V != Value1 && V != Value2) {
2029 MoreThanTwoValues =
true;
2034 return DAG.getUNDEF(VT);
2036 if (isOnlyLowElement)
2042 for (
unsigned i = 0, e = NumElems; i !=
e; ++i) {
2044 dyn_cast<ConstantFPSDNode>(
Node->getOperand(i))) {
2047 dyn_cast<ConstantSDNode>(
Node->getOperand(i))) {
2066 DAG.getConstantPool(CP, TLI.getPointerTy(DAG.getDataLayout()));
2067 Align Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlign();
2069 VT, dl, DAG.getEntryNode(), CPIdx,
2075 for (
unsigned i = 0; i < NumElems; ++i) {
2076 if (
Node->getOperand(i).isUndef())
2081 if (TLI.shouldExpandBuildVectorWithShuffles(VT, DefinedValues.
size())) {
2082 if (!MoreThanTwoValues) {
2084 for (
unsigned i = 0; i < NumElems; ++i) {
2088 ShuffleVec[i] =
V == Value1 ? 0 : NumElems;
2090 if (TLI.isShuffleMaskLegal(ShuffleVec,
Node->getValueType(0))) {
2097 Vec2 = DAG.getUNDEF(VT);
2100 return DAG.getVectorShuffle(VT, dl, Vec1, Vec2, ShuffleVec);
2110 return ExpandVectorBuildThroughStack(
Node);
2115 EVT VT =
Node->getValueType(0);
2118 return DAG.getSplatBuildVector(VT,
DL, SplatVal);
2126std::pair<SDValue, SDValue>
2127SelectionDAGLegalize::ExpandLibCall(RTLIB::Libcall LC,
SDNode *
Node,
2129 bool IsSigned,
EVT RetVT) {
2130 EVT CodePtrTy = TLI.getPointerTy(DAG.getDataLayout());
2132 if (
const char *LibcallName = TLI.getLibcallName(LC))
2133 Callee = DAG.getExternalSymbol(LibcallName, CodePtrTy);
2135 Callee = DAG.getUNDEF(CodePtrTy);
2136 DAG.getContext()->emitError(
Twine(
"no libcall available for ") +
2137 Node->getOperationName(&DAG));
2146 SDValue InChain = DAG.getEntryNode();
2151 const Function &
F = DAG.getMachineFunction().getFunction();
2153 TLI.isInTailCallPosition(DAG,
Node, TCChain) &&
2154 (
RetTy ==
F.getReturnType() ||
F.getReturnType()->isVoidTy());
2159 bool signExtend = TLI.shouldSignExtendTypeInLibCall(
RetTy, IsSigned);
2162 .setLibCallee(TLI.getLibcallCallingConv(LC),
RetTy, Callee,
2164 .setTailCall(isTailCall)
2165 .setSExtResult(signExtend)
2166 .setZExtResult(!signExtend)
2167 .setIsPostTypeLegalization(
true);
2169 std::pair<SDValue, SDValue>
CallInfo = TLI.LowerCallTo(CLI);
2174 return {DAG.getRoot(), DAG.getRoot()};
2181std::pair<SDValue, SDValue> SelectionDAGLegalize::ExpandLibCall(RTLIB::Libcall LC,
SDNode *
Node,
2185 EVT ArgVT =
Op.getValueType();
2188 Entry.IsSExt = TLI.shouldSignExtendTypeInLibCall(ArgTy,
isSigned);
2190 Args.push_back(Entry);
2193 return ExpandLibCall(LC,
Node, std::move(Args),
isSigned,
2194 Node->getValueType(0));
2197void SelectionDAGLegalize::ExpandFPLibCall(
SDNode*
Node,
2200 if (LC == RTLIB::UNKNOWN_LIBCALL)
2203 if (
Node->isStrictFPOpcode()) {
2204 EVT RetVT =
Node->getValueType(0);
2209 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, RetVT,
2212 Node->getOperand(0));
2214 Results.push_back(Tmp.second);
2217 SDValue Tmp = ExpandLibCall(LC,
Node, IsSignedArgument).first;
2223void SelectionDAGLegalize::ExpandFPLibCall(
SDNode*
Node,
2224 RTLIB::Libcall Call_F32,
2225 RTLIB::Libcall Call_F64,
2226 RTLIB::Libcall Call_F80,
2227 RTLIB::Libcall Call_F128,
2228 RTLIB::Libcall Call_PPCF128,
2231 Call_F32, Call_F64, Call_F80,
2232 Call_F128, Call_PPCF128);
2236void SelectionDAGLegalize::ExpandFastFPLibCall(
2238 std::pair<RTLIB::Libcall, RTLIB::Libcall> Call_F32,
2239 std::pair<RTLIB::Libcall, RTLIB::Libcall> Call_F64,
2240 std::pair<RTLIB::Libcall, RTLIB::Libcall> Call_F80,
2241 std::pair<RTLIB::Libcall, RTLIB::Libcall> Call_F128,
2242 std::pair<RTLIB::Libcall, RTLIB::Libcall> Call_PPCF128,
2245 EVT VT =
Node->getSimpleValueType(0);
2254 Call_F128.first, Call_PPCF128.first);
2257 if (!IsFast || TLI.getLibcallImpl(LC) == RTLIB::Unsupported) {
2260 Call_F80.second, Call_F128.second,
2261 Call_PPCF128.second);
2268 RTLIB::Libcall Call_I8,
2269 RTLIB::Libcall Call_I16,
2270 RTLIB::Libcall Call_I32,
2271 RTLIB::Libcall Call_I64,
2272 RTLIB::Libcall Call_I128) {
2274 switch (
Node->getSimpleValueType(0).SimpleTy) {
2276 case MVT::i8: LC = Call_I8;
break;
2277 case MVT::i16: LC = Call_I16;
break;
2278 case MVT::i32: LC = Call_I32;
break;
2279 case MVT::i64: LC = Call_I64;
break;
2280 case MVT::i128: LC = Call_I128;
break;
2287void SelectionDAGLegalize::ExpandArgFPLibCall(
SDNode*
Node,
2288 RTLIB::Libcall Call_F32,
2289 RTLIB::Libcall Call_F64,
2290 RTLIB::Libcall Call_F80,
2291 RTLIB::Libcall Call_F128,
2292 RTLIB::Libcall Call_PPCF128,
2294 EVT InVT =
Node->getOperand(
Node->isStrictFPOpcode() ? 1 : 0).getValueType();
2296 Call_F32, Call_F64, Call_F80,
2297 Call_F128, Call_PPCF128);
2301SDValue SelectionDAGLegalize::ExpandBitCountingLibCall(
2302 SDNode *
Node, RTLIB::Libcall CallI32, RTLIB::Libcall CallI64,
2303 RTLIB::Libcall CallI128) {
2305 switch (
Node->getSimpleValueType(0).SimpleTy) {
2326 EVT ArgVT =
Op.getValueType();
2329 Arg.IsSExt = TLI.shouldSignExtendTypeInLibCall(ArgTy,
false);
2330 Arg.IsZExt = !Arg.IsSExt;
2339 Res = DAG.getSExtOrTrunc(Res,
SDLoc(
Node),
Node->getValueType(0));
2345SelectionDAGLegalize::ExpandDivRemLibCall(
SDNode *
Node,
2347 unsigned Opcode =
Node->getOpcode();
2351 switch (
Node->getSimpleValueType(0).SimpleTy) {
2353 case MVT::i8: LC=
isSigned ? RTLIB::SDIVREM_I8 : RTLIB::UDIVREM_I8;
break;
2354 case MVT::i16: LC=
isSigned ? RTLIB::SDIVREM_I16 : RTLIB::UDIVREM_I16;
break;
2355 case MVT::i32: LC=
isSigned ? RTLIB::SDIVREM_I32 : RTLIB::UDIVREM_I32;
break;
2356 case MVT::i64: LC=
isSigned ? RTLIB::SDIVREM_I64 : RTLIB::UDIVREM_I64;
break;
2357 case MVT::i128: LC=
isSigned ? RTLIB::SDIVREM_I128:RTLIB::UDIVREM_I128;
break;
2363 SDValue InChain = DAG.getEntryNode();
2365 EVT RetVT =
Node->getValueType(0);
2370 EVT ArgVT =
Op.getValueType();
2375 Args.push_back(Entry);
2379 SDValue FIPtr = DAG.CreateStackTemporary(RetVT);
2381 FIPtr, PointerType::getUnqual(
RetTy->getContext()));
2384 Args.push_back(Entry);
2386 SDValue Callee = DAG.getExternalSymbol(TLI.getLibcallName(LC),
2387 TLI.getPointerTy(DAG.getDataLayout()));
2393 .setLibCallee(TLI.getLibcallCallingConv(LC),
RetTy, Callee,
2398 std::pair<SDValue, SDValue>
CallInfo = TLI.LowerCallTo(CLI);
2431 EVT VT =
Node->getValueType(0);
2434 EVT ExpVT =
N.getValueType();
2436 if (AsIntVT ==
EVT())
2449 TLI.getSetCCResultType(DAG.getDataLayout(), *DAG.getContext(), ExpVT);
2454 const int Precision = APFloat::semanticsPrecision(FltSem);
2456 const SDValue MaxExp = DAG.getSignedConstant(MaxExpVal, dl, ExpVT);
2457 const SDValue MinExp = DAG.getSignedConstant(MinExpVal, dl, ExpVT);
2459 const SDValue DoubleMaxExp = DAG.getSignedConstant(2 * MaxExpVal, dl, ExpVT);
2461 const APFloat One(FltSem,
"1.0");
2462 APFloat ScaleUpK =
scalbn(One, MaxExpVal, APFloat::rmNearestTiesToEven);
2466 scalbn(One, MinExpVal + Precision, APFloat::rmNearestTiesToEven);
2475 SDValue ClampMaxVal = DAG.getConstant(3 * MaxExpVal, dl, ExpVT);
2481 DAG.getSetCC(dl, SetCCVT,
N, DoubleMaxExp,
ISD::SETUGT);
2483 const SDValue ScaleUpVal = DAG.getConstantFP(ScaleUpK, dl, VT);
2495 SDValue Increment0 = DAG.getConstant(-(MinExpVal + Precision), dl, ExpVT);
2496 SDValue Increment1 = DAG.getConstant(-2 * (MinExpVal + Precision), dl, ExpVT);
2501 DAG.getSignedConstant(3 * MinExpVal + 2 * Precision, dl, ExpVT);
2506 const SDValue ScaleDownVal = DAG.getConstantFP(ScaleDownK, dl, VT);
2510 SDValue ScaleDownTwice = DAG.getSetCC(
2512 DAG.getSignedConstant(2 * MinExpVal + Precision, dl, ExpVT),
ISD::SETULT);
2523 DAG.getNode(
ISD::SELECT, dl, VT, NLtMinExp, SelectX_Small,
X));
2527 DAG.getNode(
ISD::SELECT, dl, ExpVT, NLtMinExp, SelectN_Small,
N));
2532 DAG.getShiftAmountConstant(Precision - 1, ExpVT, dl);
2533 SDValue CastExpToValTy = DAG.getZExtOrTrunc(BiasedN, dl, AsIntVT);
2536 ExponentShiftAmt, NUW_NSW);
2538 return DAG.getNode(
ISD::FMUL, dl, VT, NewX, AsFP);
2545 EVT ExpVT =
Node->getValueType(1);
2547 if (AsIntVT ==
EVT())
2552 const unsigned Precision = APFloat::semanticsPrecision(FltSem);
2569 SDValue NegSmallestNormalizedInt = DAG.getConstant(
2573 SDValue SmallestNormalizedInt = DAG.getConstant(
2579 DAG.getConstant(
APFloat::getInf(FltSem).bitcastToAPInt(), dl, AsIntVT);
2585 FractSignMaskVal.
setBit(BitSize - 1);
2588 SDValue SignMask = DAG.getConstant(SignMaskVal, dl, AsIntVT);
2590 SDValue FractSignMask = DAG.getConstant(FractSignMaskVal, dl, AsIntVT);
2592 const APFloat One(FltSem,
"1.0");
2596 scalbn(One, Precision + 1, APFloat::rmNearestTiesToEven);
2598 SDValue ScaleUpK = DAG.getConstantFP(ScaleUpKVal, dl, VT);
2602 TLI.getSetCCResultType(DAG.getDataLayout(), *DAG.getContext(), VT);
2608 SDValue AddNegSmallestNormal =
2610 SDValue DenormOrZero = DAG.getSetCC(dl, SetCCVT, AddNegSmallestNormal,
2614 DAG.getSetCC(dl, SetCCVT, Abs, SmallestNormalizedInt,
ISD::SETULT);
2616 SDValue MinExp = DAG.getSignedConstant(MinExpVal, dl, ExpVT);
2631 DAG.getShiftAmountConstant(Precision - 1, AsIntVT, dl);
2634 SDValue Exp = DAG.getSExtOrTrunc(ShiftedExp, dl, ExpVT);
2637 SDValue DenormalOffset = DAG.getConstant(-Precision - 1, dl, ExpVT);
2643 const APFloat Half(FltSem,
"0.5");
2644 SDValue FPHalf = DAG.getConstant(Half.bitcastToAPInt(), dl, AsIntVT);
2657 return DAG.getMergeValues({Result0, Result1}, dl);
2668 EVT DestVT =
Node->getValueType(0);
2670 unsigned OpNo =
Node->isStrictFPOpcode() ? 1 : 0;
2676 if (SrcVT == MVT::i32 && TLI.isTypeLegal(MVT::f64) &&
2677 (DestVT.
bitsLE(MVT::f64) ||
2681 LLVM_DEBUG(
dbgs() <<
"32-bit [signed|unsigned] integer to float/double "
2685 SDValue StackSlot = DAG.CreateStackTemporary(MVT::f64);
2692 DAG.getConstant(0x80000000u, dl, MVT::i32));
2695 SDValue Hi = DAG.getConstant(0x43300000u, dl, MVT::i32);
2698 if (DAG.getDataLayout().isBigEndian())
2701 SDValue MemChain = DAG.getEntryNode();
2704 SDValue Store1 = DAG.getStore(MemChain, dl,
Lo, StackSlot,
2717 SDValue Bias = DAG.getConstantFP(
2718 isSigned ? llvm::bit_cast<double>(0x4330000080000000ULL)
2719 : llvm::bit_cast<double>(0x4330000000000000ULL),
2724 if (
Node->isStrictFPOpcode()) {
2726 {
Node->getOperand(0), Load, Bias});
2727 Chain =
Sub.getValue(1);
2728 if (DestVT !=
Sub.getValueType()) {
2729 std::pair<SDValue, SDValue> ResultPair;
2731 DAG.getStrictFPExtendOrRound(
Sub, Chain, dl, DestVT);
2732 Result = ResultPair.first;
2733 Chain = ResultPair.second;
2738 Sub = DAG.getNode(
ISD::FSUB, dl, MVT::f64, Load, Bias);
2739 Result = DAG.getFPExtendOrRound(
Sub, dl, DestVT);
2748 if (((SrcVT == MVT::i32 || SrcVT == MVT::i64) && DestVT == MVT::f32) ||
2749 (SrcVT == MVT::i64 && DestVT == MVT::f64)) {
2750 LLVM_DEBUG(
dbgs() <<
"Converting unsigned i32/i64 to f32/f64\n");
2765 EVT SetCCVT = getSetCCResultType(SrcVT);
2767 SDValue SignBitTest = DAG.getSetCC(
2768 dl, SetCCVT, Op0, DAG.getConstant(0, dl, SrcVT),
ISD::SETLT);
2770 EVT ShiftVT = TLI.getShiftAmountTy(SrcVT, DAG.getDataLayout());
2771 SDValue ShiftConst = DAG.getConstant(1, dl, ShiftVT);
2773 SDValue AndConst = DAG.getConstant(1, dl, SrcVT);
2778 if (
Node->isStrictFPOpcode()) {
2781 SDValue InCvt = DAG.getSelect(dl, SrcVT, SignBitTest,
Or, Op0);
2786 Flags.setNoFPExcept(
Node->getFlags().hasNoFPExcept());
2789 Flags.setNoFPExcept(
true);
2799 return DAG.getSelect(dl, DestVT, SignBitTest, Slow,
Fast);
2803 if (!TLI.isOperationLegalOrCustom(
2812 "Cannot perform lossless SINT_TO_FP!");
2815 if (
Node->isStrictFPOpcode()) {
2817 {
Node->getOperand(0), Op0 });
2821 SDValue SignSet = DAG.getSetCC(dl, getSetCCResultType(SrcVT), Op0,
2824 Four = DAG.getIntPtrConstant(4, dl);
2825 SDValue CstOffset = DAG.getSelect(dl,
Zero.getValueType(),
2826 SignSet, Four, Zero);
2835 case MVT::i8 : FF = 0x43800000ULL;
break;
2836 case MVT::i16: FF = 0x47800000ULL;
break;
2837 case MVT::i32: FF = 0x4F800000ULL;
break;
2838 case MVT::i64: FF = 0x5F800000ULL;
break;
2840 if (DAG.getDataLayout().isLittleEndian())
2842 Constant *FudgeFactor = ConstantInt::get(
2846 DAG.getConstantPool(FudgeFactor, TLI.getPointerTy(DAG.getDataLayout()));
2847 Align Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlign();
2851 if (DestVT == MVT::f32)
2852 FudgeInReg = DAG.getLoad(
2853 MVT::f32, dl, DAG.getEntryNode(), CPIdx,
2862 LegalizeOp(
Load.getNode());
2866 if (
Node->isStrictFPOpcode()) {
2868 { Tmp1.
getValue(1), Tmp1, FudgeInReg });
2869 Chain =
Result.getValue(1);
2873 return DAG.getNode(
ISD::FADD, dl, DestVT, Tmp1, FudgeInReg);
2881void SelectionDAGLegalize::PromoteLegalINT_TO_FP(
2883 bool IsStrict =
N->isStrictFPOpcode();
2886 EVT DestVT =
N->getValueType(0);
2887 SDValue LegalOp =
N->getOperand(IsStrict ? 1 : 0);
2894 unsigned OpToUse = 0;
2902 if (TLI.isOperationLegalOrCustom(SIntOp, NewInTy)) {
2910 if (TLI.isOperationLegalOrCustom(UIntOp, NewInTy)) {
2922 DAG.
getNode(OpToUse, dl, {DestVT, MVT::Other},
2925 dl, NewInTy, LegalOp)});
2932 DAG.getNode(OpToUse, dl, DestVT,
2934 dl, NewInTy, LegalOp)));
2942void SelectionDAGLegalize::PromoteLegalFP_TO_INT(
SDNode *
N,
const SDLoc &dl,
2944 bool IsStrict =
N->isStrictFPOpcode();
2947 EVT DestVT =
N->getValueType(0);
2948 SDValue LegalOp =
N->getOperand(IsStrict ? 1 : 0);
2950 EVT NewOutTy = DestVT;
2952 unsigned OpToUse = 0;
2962 if (TLI.isOperationLegalOrCustom(OpToUse, NewOutTy))
2967 if (!IsSigned && TLI.isOperationLegalOrCustom(OpToUse, NewOutTy))
2976 SDVTList VTs = DAG.getVTList(NewOutTy, MVT::Other);
2977 Operation = DAG.getNode(OpToUse, dl, VTs,
N->getOperand(0), LegalOp);
2979 Operation = DAG.getNode(OpToUse, dl, NewOutTy, LegalOp);
2994 unsigned Opcode =
Node->getOpcode();
2997 EVT NewOutTy =
Node->getValueType(0);
3002 if (TLI.isOperationLegalOrCustom(Opcode, NewOutTy))
3009 Node->getOperand(1));
3015 EVT VT =
Op.getValueType();
3016 EVT ShVT = TLI.getShiftAmountTy(VT, DAG.getDataLayout());
3021 if (TLI.isOperationLegalOrPromote(
ISD::CTPOP, VT)) {
3027 DAG.getConstant(1ULL << (--i), dl, ShVT));
3032 return DAG.getNode(
ISD::AND, dl, VT, Result, DAG.getConstant(1, dl, VT));
3037 MVT VecVT = IsVPOpcode ?
Node->getOperand(1).getSimpleValueType()
3038 :
Node->getOperand(0).getSimpleValueType();
3039 MVT NewVecVT = TLI.getTypeToPromoteTo(
Node->getOpcode(), VecVT);
3040 MVT ScalarVT =
Node->getSimpleValueType(0);
3047 assert(
Node->getOperand(0).getValueType().isFloatingPoint() &&
3048 "Only FP promotion is supported");
3050 for (
unsigned j = 0;
j !=
Node->getNumOperands(); ++
j)
3051 if (
Node->getOperand(j).getValueType().isVector() &&
3056 assert(
Node->getOperand(j).getValueType().isFloatingPoint() &&
3057 "Only FP promotion is supported");
3060 }
else if (
Node->getOperand(j).getValueType().isFloatingPoint()) {
3073 DAG.getIntPtrConstant(0,
DL,
true));
3076bool SelectionDAGLegalize::ExpandNode(
SDNode *
Node) {
3080 SDValue Tmp1, Tmp2, Tmp3, Tmp4;
3082 switch (
Node->getOpcode()) {
3084 if ((Tmp1 = TLI.expandABS(
Node, DAG)))
3089 if ((Tmp1 = TLI.expandABD(
Node, DAG)))
3096 if ((Tmp1 = TLI.expandAVG(
Node, DAG)))
3100 if ((Tmp1 = TLI.expandCTPOP(
Node, DAG)))
3105 if ((Tmp1 = TLI.expandCTLZ(
Node, DAG)))
3110 if ((Tmp1 = TLI.expandCTTZ(
Node, DAG)))
3114 if ((Tmp1 = TLI.expandBITREVERSE(
Node, DAG)))
3118 if ((Tmp1 = TLI.expandBSWAP(
Node, DAG)))
3122 Results.push_back(ExpandPARITY(
Node->getOperand(0), dl));
3127 Results.push_back(DAG.getConstant(0, dl,
Node->getValueType(0)));
3130 SDValue CfaArg = DAG.getSExtOrTrunc(
Node->getOperand(0), dl,
3131 TLI.getPointerTy(DAG.getDataLayout()));
3139 DAG.getConstant(0, dl, TLI.getPointerTy(DAG.getDataLayout())));
3145 Results.push_back(DAG.getConstant(1, dl,
Node->getValueType(0)));
3162 DAG.getConstant(0, dl,
Node->getValueType(0)));
3168 Results.push_back(DAG.getConstant(0, dl, MVT::i32));
3174 SDVTList VTs = DAG.getVTList(
Node->getValueType(0), MVT::Other);
3175 SDValue Swap = DAG.getAtomicCmpSwap(
3177 Node->getOperand(0),
Node->getOperand(1), Zero, Zero,
3178 cast<AtomicSDNode>(
Node)->getMemOperand());
3187 Node->getOperand(0),
Node->getOperand(2),
Node->getOperand(1),
3188 cast<AtomicSDNode>(
Node)->getMemOperand());
3196 SDVTList VTs = DAG.getVTList(
Node->getValueType(0), MVT::Other);
3197 SDValue Res = DAG.getAtomicCmpSwap(
3199 Node->getOperand(0),
Node->getOperand(1),
Node->getOperand(2),
3200 Node->getOperand(3), cast<MemSDNode>(
Node)->getMemOperand());
3206 EVT AtomicType = cast<AtomicSDNode>(
Node)->getMemoryVT();
3207 EVT OuterType =
Node->getValueType(0);
3208 switch (TLI.getExtendForAtomicOps()) {
3211 DAG.getValueType(AtomicType));
3213 Node->getOperand(2), DAG.getValueType(AtomicType));
3218 DAG.getValueType(AtomicType));
3219 RHS = DAG.getZeroExtendInReg(
Node->getOperand(2), dl, AtomicType);
3223 LHS = DAG.getZeroExtendInReg(Res, dl, AtomicType);
3224 RHS = DAG.getZeroExtendInReg(
Node->getOperand(2), dl, AtomicType);
3240 EVT VT =
Node->getValueType(0);
3244 cast<VTSDNode>(
RHS->getOperand(1))->getVT() == AN->
getMemoryVT())
3245 RHS =
RHS->getOperand(0);
3249 Node->getOperand(0),
Node->getOperand(1),
3259 for (
unsigned i = 0; i <
Node->getNumValues(); i++)
3264 EVT VT =
Node->getValueType(0);
3266 Results.push_back(DAG.getConstant(0, dl, VT));
3269 Results.push_back(DAG.getConstantFP(0, dl, VT));
3276 if (TLI.isStrictFPEnabled())
3280 if (TLI.getStrictFPOperationAction(
Node->getOpcode(),
3281 Node->getValueType(0))
3282 == TargetLowering::Legal)
3286 if ((Tmp1 = EmitStackConvert(
Node->getOperand(1),
Node->getValueType(0),
3287 Node->getValueType(0), dl,
3288 Node->getOperand(0)))) {
3290 LLVM_DEBUG(
dbgs() <<
"Successfully expanded STRICT_FP_ROUND node\n");
3295 if ((Tmp1 = TLI.expandFP_ROUND(
Node, DAG))) {
3303 if ((Tmp1 = EmitStackConvert(
Node->getOperand(0),
Node->getValueType(0),
3304 Node->getValueType(0), dl)))
3310 if (TLI.isStrictFPEnabled())
3314 if (TLI.getStrictFPOperationAction(
Node->getOpcode(),
3315 Node->getValueType(0))
3316 == TargetLowering::Legal)
3320 if ((Tmp1 = EmitStackConvert(
3321 Node->getOperand(1),
Node->getOperand(1).getValueType(),
3322 Node->getValueType(0), dl,
Node->getOperand(0)))) {
3324 LLVM_DEBUG(
dbgs() <<
"Successfully expanded STRICT_FP_EXTEND node\n");
3330 EVT SrcVT =
Op.getValueType();
3331 EVT DstVT =
Node->getValueType(0);
3337 if ((Tmp1 = EmitStackConvert(
Op, SrcVT, DstVT, dl)))
3347 if (
Op.getValueType() == MVT::bf16) {
3351 Op = DAG.getAnyExtOrTrunc(
Op, dl, MVT::i32);
3355 DAG.getConstant(16, dl,
3356 TLI.getShiftAmountTy(MVT::i32, DAG.getDataLayout())));
3359 if (
Node->getValueType(0) != MVT::f32)
3366 if (
Op.getValueType() != MVT::f32)
3368 DAG.getIntPtrConstant(0, dl,
true));
3370 if (!DAG.isKnownNeverSNaN(
Op)) {
3375 DAG.getConstant(16, dl,
3376 TLI.getShiftAmountTy(MVT::i32, DAG.getDataLayout())));
3379 if (
Node->getValueType(0) == MVT::bf16) {
3383 Op = DAG.getAnyExtOrTrunc(
Op, dl,
Node->getValueType(0));
3400 SDValue One = DAG.getConstantFP(1.0, dl, VT);
3401 SDValue Chain = DAG.getEntryNode();
3407 {Chain, Operand, One}, CanonicalizeFlags);
3413 EVT ExtraVT = cast<VTSDNode>(
Node->getOperand(1))->getVT();
3414 EVT VT =
Node->getValueType(0);
3424 SDValue One = DAG.getConstant(1, dl, VT);
3434 EVT ShiftAmountTy = TLI.getShiftAmountTy(VT, DAG.getDataLayout());
3437 SDValue ShiftCst = DAG.getConstant(BitsDiff, dl, ShiftAmountTy);
3439 Node->getOperand(0), ShiftCst);
3446 if (TLI.expandUINT_TO_FP(
Node, Tmp1, Tmp2, DAG)) {
3448 if (
Node->isStrictFPOpcode())
3455 if ((Tmp1 = ExpandLegalINT_TO_FP(
Node, Tmp2))) {
3457 if (
Node->isStrictFPOpcode())
3462 if (TLI.expandFP_TO_SINT(
Node, Tmp1, DAG))
3466 if (TLI.expandFP_TO_SINT(
Node, Tmp1, DAG)) {
3468 LLVM_DEBUG(
dbgs() <<
"Successfully expanded STRICT_FP_TO_SINT node\n");
3473 if (TLI.expandFP_TO_UINT(
Node, Tmp1, Tmp2, DAG))
3477 if (TLI.expandFP_TO_UINT(
Node, Tmp1, Tmp2, DAG)) {
3479 DAG.ReplaceAllUsesOfValueWith(
SDValue(
Node,1), Tmp2);
3482 LLVM_DEBUG(
dbgs() <<
"Successfully expanded STRICT_FP_TO_UINT node\n");
3488 Results.push_back(TLI.expandFP_TO_INT_SAT(
Node, DAG));
3494 EVT ResVT =
Node->getValueType(0);
3508 if (
Node->getOperand(0).getValueType().getVectorElementCount().isScalar())
3511 Node->getOperand(0));
3513 Tmp1 = ExpandExtractFromVectorThroughStack(
SDValue(
Node, 0));
3523 if (
EVT VectorValueType =
Node->getOperand(0).getValueType();
3526 Results.push_back(ExpandVectorBuildThroughStack(
Node));
3540 EVT VT =
Node->getValueType(0);
3544 if (!TLI.isTypeLegal(EltVT)) {
3545 EVT NewEltVT = TLI.getTypeToTransformTo(*DAG.getContext(), EltVT);
3550 if (NewEltVT.
bitsLT(EltVT)) {
3566 unsigned int factor =
3574 for (
unsigned fi = 0; fi < factor; ++fi)
3578 for (
unsigned fi = 0; fi < factor; ++fi)
3589 for (
unsigned i = 0; i != NumElems; ++i) {
3597 DAG.getVectorIdxConstant(
Idx, dl)));
3601 DAG.getVectorIdxConstant(
Idx - NumElems, dl)));
3604 Tmp1 = DAG.getBuildVector(VT, dl, Ops);
3611 Results.push_back(TLI.expandVectorSplice(
Node, DAG));
3615 unsigned Factor =
Node->getNumOperands();
3619 EVT VecVT =
Node->getValueType(0);
3624 ArrayRef(Ops).take_front(Factor / 2));
3626 ArrayRef(Ops).take_back(Factor / 2));
3630 for (
unsigned I = 0;
I < Factor / 2;
I++) {
3633 {
L.getValue(
I),
R.getValue(
I)});
3640 unsigned Factor =
Node->getNumOperands();
3643 EVT VecVT =
Node->getValueType(0);
3648 for (
unsigned I = 0;
I < Factor / 2;
I++) {
3651 {
Node->getOperand(
I),
Node->getOperand(
I + Factor / 2)});
3659 for (
unsigned I = 0;
I < Factor / 2;
I++)
3661 for (
unsigned I = 0;
I < Factor / 2;
I++)
3666 EVT OpTy =
Node->getOperand(0).getValueType();
3667 if (
Node->getConstantOperandVal(1)) {
3671 TLI.getShiftAmountTy(
3672 Node->getOperand(0).getValueType(),
3673 DAG.getDataLayout())));
3678 Node->getOperand(0));
3686 if (
Register SP = TLI.getStackPointerRegisterToSaveRestore()) {
3687 Results.push_back(DAG.getCopyFromReg(
Node->getOperand(0), dl, SP,
3688 Node->getValueType(0)));
3691 Results.push_back(DAG.getUNDEF(
Node->getValueType(0)));
3698 if (
Register SP = TLI.getStackPointerRegisterToSaveRestore()) {
3699 Results.push_back(DAG.getCopyToReg(
Node->getOperand(0), dl, SP,
3700 Node->getOperand(1)));
3706 Results.push_back(DAG.getConstant(0, dl,
Node->getValueType(0)));
3721 TLI.expandIS_FPCLASS(
Node->getValueType(0),
Node->getOperand(0),
3732 switch (
Node->getOpcode()) {
3739 Tmp1 =
Node->getOperand(0);
3740 Tmp2 =
Node->getOperand(1);
3741 Tmp1 = DAG.getSelectCC(dl, Tmp1, Tmp2, Tmp1, Tmp2, Pred);
3747 if (
SDValue Expanded = TLI.expandFMINNUM_FMAXNUM(
Node, DAG))
3753 if (
SDValue Expanded = TLI.expandFMINIMUM_FMAXIMUM(
Node, DAG))
3759 Results.push_back(TLI.expandFMINIMUMNUM_FMAXIMUMNUM(
Node, DAG));
3764 EVT VT =
Node->getValueType(0);
3770 SDVTList VTs = DAG.getVTList(VT, VT);
3780 EVT VT =
Node->getValueType(0);
3784 if (TLI.getLibcallName(LC))
3790 Results.push_back(Expanded.getValue(1));
3799 if (TLI.getLibcallName(LC))
3804 Results.push_back(Expanded.getValue(1));
3811 EVT VT =
Node->getValueType(0);
3823 if (
Node->getValueType(0) != MVT::f32) {
3835 if (
Node->getValueType(0) != MVT::f32) {
3840 {Node->getOperand(0), Node->getOperand(1)});
3842 {
Node->getValueType(0), MVT::Other},
3850 if (
Node->getFlags().hasApproximateFuncs() && !TLI.useSoftFloat()) {
3852 MVT SVT =
Op.getSimpleValueType();
3853 if ((SVT == MVT::f64 || SVT == MVT::f80) &&
3859 DAG.getIntPtrConstant(0, dl,
true));
3870 DAG.shouldOptForSize()))
3871 Results.push_back(ExpandConstantFP(CFP,
true));
3876 Results.push_back(ExpandConstant(CP));
3880 EVT VT =
Node->getValueType(0);
3881 if (TLI.isOperationLegalOrCustom(
ISD::FADD, VT) &&
3882 TLI.isOperationLegalOrCustom(
ISD::FNEG, VT)) {
3891 EVT VT =
Node->getValueType(0);
3893 TLI.isOperationLegalOrCustom(
ISD::XOR, VT) &&
3894 "Don't know how to expand this subtraction!");
3895 Tmp1 = DAG.getNOT(dl,
Node->getOperand(1), VT);
3896 Tmp1 = DAG.
getNode(
ISD::ADD, dl, VT, Tmp1, DAG.getConstant(1, dl, VT));
3902 if (TLI.expandREM(
Node, Tmp1, DAG))
3909 EVT VT =
Node->getValueType(0);
3910 if (TLI.isOperationLegalOrCustom(DivRemOpc, VT)) {
3911 SDVTList VTs = DAG.getVTList(VT, VT);
3912 Tmp1 = DAG.
getNode(DivRemOpc, dl, VTs,
Node->getOperand(0),
3913 Node->getOperand(1));
3920 unsigned ExpandOpcode =
3922 EVT VT =
Node->getValueType(0);
3923 SDVTList VTs = DAG.getVTList(VT, VT);
3925 Tmp1 = DAG.
getNode(ExpandOpcode, dl, VTs,
Node->getOperand(0),
3926 Node->getOperand(1));
3934 MVT VT =
LHS.getSimpleValueType();
3935 unsigned MULHOpcode =
3938 if (TLI.isOperationLegalOrCustom(MULHOpcode, VT)) {
3940 Results.push_back(DAG.getNode(MULHOpcode, dl, VT, LHS, RHS));
3946 assert(TLI.isTypeLegal(HalfType));
3947 if (TLI.expandMUL_LOHI(
Node->getOpcode(), VT, dl, LHS, RHS, Halves,
3949 TargetLowering::MulExpansionKind::Always)) {
3950 for (
unsigned i = 0; i < 2; ++i) {
3953 SDValue Shift = DAG.getConstant(
3955 TLI.getShiftAmountTy(HalfType, DAG.getDataLayout()));
3964 EVT VT =
Node->getValueType(0);
3965 SDVTList VTs = DAG.getVTList(VT, VT);
3971 bool HasSMUL_LOHI = TLI.isOperationLegalOrCustom(
ISD::SMUL_LOHI, VT);
3972 bool HasUMUL_LOHI = TLI.isOperationLegalOrCustom(
ISD::UMUL_LOHI, VT);
3973 bool HasMULHS = TLI.isOperationLegalOrCustom(
ISD::MULHS, VT);
3974 bool HasMULHU = TLI.isOperationLegalOrCustom(
ISD::MULHU, VT);
3975 unsigned OpToUse = 0;
3976 if (HasSMUL_LOHI && !HasMULHS) {
3978 }
else if (HasUMUL_LOHI && !HasMULHU) {
3980 }
else if (HasSMUL_LOHI) {
3982 }
else if (HasUMUL_LOHI) {
3986 Results.push_back(DAG.getNode(OpToUse, dl, VTs,
Node->getOperand(0),
3987 Node->getOperand(1)));
3995 TLI.isOperationLegalOrCustom(
ISD::SHL, VT) &&
3996 TLI.isOperationLegalOrCustom(
ISD::OR, VT) &&
3997 TLI.expandMUL(
Node,
Lo,
Hi, HalfType, DAG,
3998 TargetLowering::MulExpansionKind::OnlyLegalOrCustom)) {
4003 TLI.getShiftAmountTy(HalfType, DAG.getDataLayout()));
4011 if (
SDValue Expanded = TLI.expandFunnelShift(
Node, DAG))
4016 if (
SDValue Expanded = TLI.expandROT(
Node,
true , DAG))
4023 Results.push_back(TLI.expandAddSubSat(
Node, DAG));
4037 Results.push_back(TLI.expandFixedPointMul(
Node, DAG));
4044 Node->getOperand(0),
4045 Node->getOperand(1),
4046 Node->getConstantOperandVal(2),
4069 EVT VT =
LHS.getValueType();
4073 EVT CarryType =
Node->getValueType(1);
4074 EVT SetCCType = getSetCCResultType(
Node->getValueType(0));
4076 SDValue Overflow = DAG.getSetCC(dl, SetCCType, Sum, LHS, CC);
4079 SDValue One = DAG.getConstant(1, dl, VT);
4081 DAG.
getNode(
ISD::AND, dl, VT, DAG.getZExtOrTrunc(Carry, dl, VT), One);
4090 IsAdd ? DAG.getSetCC(dl, SetCCType, Sum2, Zero,
ISD::SETEQ)
4091 : DAG.getSetCC(dl, SetCCType, Sum, Zero,
ISD::SETEQ);
4093 DAG.getZExtOrTrunc(Carry, dl, SetCCType));
4099 Results.push_back(DAG.getBoolExtOrTrunc(ResultCarry, dl, CarryType, VT));
4105 TLI.expandSADDSUBO(
Node, Result, Overflow, DAG);
4113 TLI.expandUADDSUBO(
Node, Result, Overflow, DAG);
4121 if (TLI.expandMULO(
Node, Result, Overflow, DAG)) {
4133 DAG.getConstant(
PairTy.getSizeInBits() / 2, dl,
4134 TLI.getShiftAmountTy(
PairTy, DAG.getDataLayout())));
4139 Tmp1 =
Node->getOperand(0);
4140 Tmp2 =
Node->getOperand(1);
4141 Tmp3 =
Node->getOperand(2);
4143 Tmp1 = DAG.getSelectCC(
4145 cast<CondCodeSDNode>(Tmp1.
getOperand(2))->get(),
Node->getFlags());
4148 DAG.getSelectCC(dl, Tmp1, DAG.getConstant(0, dl, Tmp1.
getValueType()),
4157 int JTI = cast<JumpTableSDNode>(Table.
getNode())->getIndex();
4160 EVT PTy = TLI.getPointerTy(TD);
4162 unsigned EntrySize =
4163 DAG.getMachineFunction().getJumpTableInfo()->getEntrySize(TD);
4170 Index = DAG.getNode(
4175 DAG.getConstant(EntrySize, dl,
Index.getValueType()));
4176 SDValue Addr = DAG.getMemBasePlusOffset(Table, Index, dl);
4183 if (TLI.isJumpTableRelative()) {
4187 Addr = DAG.getMemBasePlusOffset(TLI.getPICJumpTableRelocBase(Table, DAG),
4191 Tmp1 = TLI.expandIndirectJTBranch(dl,
LD.getValue(1),
Addr, JTI, DAG);
4198 Tmp1 =
Node->getOperand(0);
4199 Tmp2 =
Node->getOperand(1);
4205 Node->getOperand(2));
4217 Node->getOperand(2));
4225 bool IsVP =
Node->getOpcode() == ISD::VP_SETCC;
4230 unsigned Offset = IsStrict ? 1 : 0;
4239 bool Legalized = TLI.LegalizeSetCCCondCode(
4240 DAG,
Node->getValueType(0), Tmp1, Tmp2, Tmp3, Mask, EVL, NeedInvert, dl,
4241 Chain, IsSignaling);
4249 {Chain, Tmp1, Tmp2, Tmp3},
Node->getFlags());
4253 {Tmp1, Tmp2, Tmp3, Mask, EVL},
Node->getFlags());
4255 Tmp1 = DAG.
getNode(
Node->getOpcode(), dl,
Node->getValueType(0), Tmp1,
4256 Tmp2, Tmp3,
Node->getFlags());
4264 Tmp1 = DAG.getLogicalNOT(dl, Tmp1, Tmp1->
getValueType(0));
4267 DAG.getVPLogicalNOT(dl, Tmp1, Mask, EVL, Tmp1->
getValueType(0));
4279 assert(!IsStrict &&
"Don't know how to expand for strict nodes.");
4284 EVT VT =
Node->getValueType(0);
4287 DAG.getBoolConstant(
true, dl, VT, Tmp1VT),
4288 DAG.getBoolConstant(
false, dl, VT, Tmp1VT), Tmp3,
4295 Tmp1 =
Node->getOperand(0);
4296 Tmp2 =
Node->getOperand(1);
4297 Tmp3 =
Node->getOperand(2);
4298 Tmp4 =
Node->getOperand(3);
4299 EVT VT =
Node->getValueType(0);
4309 "Cannot expand ISD::SELECT_CC when ISD::SELECT also needs to be "
4311 EVT CCVT = getSetCCResultType(CmpVT);
4314 DAG.getSelect(dl, VT,
Cond, Tmp3, Tmp4,
Node->getFlags()));
4319 bool Legalized =
false;
4328 DAG.getSelectCC(dl, Tmp1, Tmp2, Tmp4, Tmp3, InvCC,
Node->getFlags());
4337 Tmp1 = DAG.getSelectCC(dl, Tmp2, Tmp1, Tmp4, Tmp3, SwapInvCC,
4343 Legalized = TLI.LegalizeSetCCCondCode(
4344 DAG, getSetCCResultType(Tmp1.
getValueType()), Tmp1, Tmp2, CC,
4347 assert(Legalized &&
"Can't legalize SELECT_CC with legal condition!");
4358 Tmp2, Tmp3, Tmp4, CC,
Node->getFlags());
4363 Tmp2, Tmp3, Tmp4, CC,
Node->getFlags());
4372 Tmp1 =
Node->getOperand(0);
4373 Tmp2 =
Node->getOperand(2);
4374 Tmp3 =
Node->getOperand(3);
4375 Tmp4 =
Node->getOperand(1);
4377 bool Legalized = TLI.LegalizeSetCCCondCode(
4378 DAG, getSetCCResultType(Tmp2.
getValueType()), Tmp2, Tmp3, Tmp4,
4381 assert(Legalized &&
"Can't legalize BR_CC with legal condition!");
4386 assert(!NeedInvert &&
"Don't know how to invert BR_CC!");
4389 Tmp4, Tmp2, Tmp3,
Node->getOperand(4));
4394 Tmp2, Tmp3,
Node->getOperand(4));
4409 EVT VT =
Node->getValueType(0);
4415 for (
unsigned Idx = 0;
Idx < NumElem;
Idx++) {
4418 Node->getOperand(0), DAG.getVectorIdxConstant(
Idx, dl));
4421 Node->getOperand(1), DAG.getVectorIdxConstant(
Idx, dl));
4445 Results.push_back(TLI.expandVecReduce(
Node, DAG));
4447 case ISD::VP_CTTZ_ELTS:
4448 case ISD::VP_CTTZ_ELTS_ZERO_UNDEF:
4449 Results.push_back(TLI.expandVPCTTZElements(
Node, DAG));
4460 EVT ResVT =
Node->getValueType(0);
4484 if (!TLI.isStrictFPEnabled() &&
Results.
empty() &&
Node->isStrictFPOpcode()) {
4490 switch (
Node->getOpcode()) {
4492 if (TLI.getStrictFPOperationAction(
Node->getOpcode(),
4493 Node->getValueType(0))
4494 == TargetLowering::Legal)
4498 if (TLI.getStrictFPOperationAction(
4501 if (TLI.getStrictFPOperationAction(
4505 EVT VT =
Node->getValueType(0);
4509 {Node->getOperand(0), Node->getOperand(1), Neg},
4524 if (TLI.getStrictFPOperationAction(
Node->getOpcode(),
4525 Node->getOperand(1).getValueType())
4526 == TargetLowering::Legal)
4551 return Flags.hasApproximateFuncs() && Flags.hasNoNaNs() &&
4552 Flags.hasNoInfs() && Flags.hasNoSignedZeros();
4555void SelectionDAGLegalize::ConvertNodeToLibcall(
SDNode *
Node) {
4562 unsigned Opc =
Node->getOpcode();
4571 .setChain(
Node->getOperand(0))
4574 DAG.getExternalSymbol(
"__sync_synchronize",
4575 TLI.getPointerTy(DAG.getDataLayout())),
4578 std::pair<SDValue, SDValue> CallResult = TLI.LowerCallTo(CLI);
4580 Results.push_back(CallResult.second);
4602 EVT RetVT =
Node->getValueType(0);
4604 if (TLI.getLibcallName(LC)) {
4611 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
4612 "Unexpected atomic op or value type!");
4616 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, RetVT,
4619 Node->getOperand(0));
4621 Results.push_back(Tmp.second);
4629 .setChain(
Node->getOperand(0))
4631 DAG.getExternalSymbol(
4632 "abort", TLI.getPointerTy(DAG.getDataLayout())),
4634 std::pair<SDValue, SDValue> CallResult = TLI.LowerCallTo(CLI);
4636 Results.push_back(CallResult.second);
4643 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(
4644 DAG, RTLIB::CLEAR_CACHE, MVT::isVoid, {StartVal, EndVal}, CallOptions,
4646 Results.push_back(Tmp.second);
4651 ExpandFPLibCall(
Node, RTLIB::FMIN_F32, RTLIB::FMIN_F64,
4652 RTLIB::FMIN_F80, RTLIB::FMIN_F128,
4653 RTLIB::FMIN_PPCF128,
Results);
4660 ExpandFPLibCall(
Node, RTLIB::FMAX_F32, RTLIB::FMAX_F64,
4661 RTLIB::FMAX_F80, RTLIB::FMAX_F128,
4662 RTLIB::FMAX_PPCF128,
Results);
4665 ExpandFPLibCall(
Node, RTLIB::FMINIMUM_NUM_F32, RTLIB::FMINIMUM_NUM_F64,
4666 RTLIB::FMINIMUM_NUM_F80, RTLIB::FMINIMUM_NUM_F128,
4667 RTLIB::FMINIMUM_NUM_PPCF128,
Results);
4670 ExpandFPLibCall(
Node, RTLIB::FMAXIMUM_NUM_F32, RTLIB::FMAXIMUM_NUM_F64,
4671 RTLIB::FMAXIMUM_NUM_F80, RTLIB::FMAXIMUM_NUM_F128,
4672 RTLIB::FMAXIMUM_NUM_PPCF128,
Results);
4679 {RTLIB::FAST_SQRT_F32, RTLIB::SQRT_F32},
4680 {RTLIB::FAST_SQRT_F64, RTLIB::SQRT_F64},
4681 {RTLIB::FAST_SQRT_F80, RTLIB::SQRT_F80},
4682 {RTLIB::FAST_SQRT_F128, RTLIB::SQRT_F128},
4683 {RTLIB::FAST_SQRT_PPCF128, RTLIB::SQRT_PPCF128},
4688 ExpandFPLibCall(
Node, RTLIB::CBRT_F32, RTLIB::CBRT_F64,
4689 RTLIB::CBRT_F80, RTLIB::CBRT_F128,
4690 RTLIB::CBRT_PPCF128,
Results);
4694 ExpandFPLibCall(
Node, RTLIB::SIN_F32, RTLIB::SIN_F64,
4695 RTLIB::SIN_F80, RTLIB::SIN_F128,
4700 ExpandFPLibCall(
Node, RTLIB::COS_F32, RTLIB::COS_F64,
4701 RTLIB::COS_F80, RTLIB::COS_F128,
4706 ExpandFPLibCall(
Node, RTLIB::TAN_F32, RTLIB::TAN_F64, RTLIB::TAN_F80,
4707 RTLIB::TAN_F128, RTLIB::TAN_PPCF128,
Results);
4711 ExpandFPLibCall(
Node, RTLIB::ASIN_F32, RTLIB::ASIN_F64, RTLIB::ASIN_F80,
4712 RTLIB::ASIN_F128, RTLIB::ASIN_PPCF128,
Results);
4716 ExpandFPLibCall(
Node, RTLIB::ACOS_F32, RTLIB::ACOS_F64, RTLIB::ACOS_F80,
4717 RTLIB::ACOS_F128, RTLIB::ACOS_PPCF128,
Results);
4721 ExpandFPLibCall(
Node, RTLIB::ATAN_F32, RTLIB::ATAN_F64, RTLIB::ATAN_F80,
4722 RTLIB::ATAN_F128, RTLIB::ATAN_PPCF128,
Results);
4726 ExpandFPLibCall(
Node, RTLIB::ATAN2_F32, RTLIB::ATAN2_F64, RTLIB::ATAN2_F80,
4727 RTLIB::ATAN2_F128, RTLIB::ATAN2_PPCF128,
Results);
4731 ExpandFPLibCall(
Node, RTLIB::SINH_F32, RTLIB::SINH_F64, RTLIB::SINH_F80,
4732 RTLIB::SINH_F128, RTLIB::SINH_PPCF128,
Results);
4736 ExpandFPLibCall(
Node, RTLIB::COSH_F32, RTLIB::COSH_F64, RTLIB::COSH_F80,
4737 RTLIB::COSH_F128, RTLIB::COSH_PPCF128,
Results);
4741 ExpandFPLibCall(
Node, RTLIB::TANH_F32, RTLIB::TANH_F64, RTLIB::TANH_F80,
4742 RTLIB::TANH_F128, RTLIB::TANH_PPCF128,
Results);
4746 EVT VT =
Node->getValueType(0);
4750 bool Expanded = DAG.expandMultipleResultFPLibCall(LC,
Node,
Results);
4757 ExpandFPLibCall(
Node, RTLIB::LOG_F32, RTLIB::LOG_F64, RTLIB::LOG_F80,
4758 RTLIB::LOG_F128, RTLIB::LOG_PPCF128,
Results);
4762 ExpandFPLibCall(
Node, RTLIB::LOG2_F32, RTLIB::LOG2_F64, RTLIB::LOG2_F80,
4763 RTLIB::LOG2_F128, RTLIB::LOG2_PPCF128,
Results);
4767 ExpandFPLibCall(
Node, RTLIB::LOG10_F32, RTLIB::LOG10_F64, RTLIB::LOG10_F80,
4768 RTLIB::LOG10_F128, RTLIB::LOG10_PPCF128,
Results);
4772 ExpandFPLibCall(
Node, RTLIB::EXP_F32, RTLIB::EXP_F64, RTLIB::EXP_F80,
4773 RTLIB::EXP_F128, RTLIB::EXP_PPCF128,
Results);
4777 ExpandFPLibCall(
Node, RTLIB::EXP2_F32, RTLIB::EXP2_F64, RTLIB::EXP2_F80,
4778 RTLIB::EXP2_F128, RTLIB::EXP2_PPCF128,
Results);
4781 ExpandFPLibCall(
Node, RTLIB::EXP10_F32, RTLIB::EXP10_F64, RTLIB::EXP10_F80,
4782 RTLIB::EXP10_F128, RTLIB::EXP10_PPCF128,
Results);
4786 ExpandFPLibCall(
Node, RTLIB::TRUNC_F32, RTLIB::TRUNC_F64,
4787 RTLIB::TRUNC_F80, RTLIB::TRUNC_F128,
4788 RTLIB::TRUNC_PPCF128,
Results);
4792 ExpandFPLibCall(
Node, RTLIB::FLOOR_F32, RTLIB::FLOOR_F64,
4793 RTLIB::FLOOR_F80, RTLIB::FLOOR_F128,
4794 RTLIB::FLOOR_PPCF128,
Results);
4798 ExpandFPLibCall(
Node, RTLIB::CEIL_F32, RTLIB::CEIL_F64,
4799 RTLIB::CEIL_F80, RTLIB::CEIL_F128,
4800 RTLIB::CEIL_PPCF128,
Results);
4804 ExpandFPLibCall(
Node, RTLIB::RINT_F32, RTLIB::RINT_F64,
4805 RTLIB::RINT_F80, RTLIB::RINT_F128,
4806 RTLIB::RINT_PPCF128,
Results);
4810 ExpandFPLibCall(
Node, RTLIB::NEARBYINT_F32,
4811 RTLIB::NEARBYINT_F64,
4812 RTLIB::NEARBYINT_F80,
4813 RTLIB::NEARBYINT_F128,
4814 RTLIB::NEARBYINT_PPCF128,
Results);
4818 ExpandFPLibCall(
Node, RTLIB::ROUND_F32,
4822 RTLIB::ROUND_PPCF128,
Results);
4826 ExpandFPLibCall(
Node, RTLIB::ROUNDEVEN_F32,
4827 RTLIB::ROUNDEVEN_F64,
4828 RTLIB::ROUNDEVEN_F80,
4829 RTLIB::ROUNDEVEN_F128,
4830 RTLIB::ROUNDEVEN_PPCF128,
Results);
4834 ExpandFPLibCall(
Node, RTLIB::LDEXP_F32, RTLIB::LDEXP_F64, RTLIB::LDEXP_F80,
4835 RTLIB::LDEXP_F128, RTLIB::LDEXP_PPCF128,
Results);
4839 EVT VT =
Node->getValueType(0);
4842 bool Expanded = DAG.expandMultipleResultFPLibCall(LC,
Node,
Results,
4851 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fpowi.");
4852 if (!TLI.getLibcallName(LC)) {
4854 if (
Node->isStrictFPOpcode()) {
4857 {
Node->getValueType(0),
Node->getValueType(1)},
4858 {
Node->getOperand(0),
Node->getOperand(2)});
4861 {
Node->getValueType(0),
Node->getValueType(1)},
4868 Node->getOperand(1));
4870 Node->getValueType(0),
4875 unsigned Offset =
Node->isStrictFPOpcode() ? 1 : 0;
4876 bool ExponentHasSizeOfInt =
4877 DAG.getLibInfo().getIntSize() ==
4878 Node->getOperand(1 +
Offset).getValueType().getSizeInBits();
4879 if (!ExponentHasSizeOfInt) {
4882 DAG.getContext()->emitError(
"POWI exponent does not match sizeof(int)");
4883 Results.push_back(DAG.getUNDEF(
Node->getValueType(0)));
4891 ExpandFPLibCall(
Node, RTLIB::POW_F32, RTLIB::POW_F64, RTLIB::POW_F80,
4892 RTLIB::POW_F128, RTLIB::POW_PPCF128,
Results);
4896 ExpandArgFPLibCall(
Node, RTLIB::LROUND_F32,
4897 RTLIB::LROUND_F64, RTLIB::LROUND_F80,
4899 RTLIB::LROUND_PPCF128,
Results);
4903 ExpandArgFPLibCall(
Node, RTLIB::LLROUND_F32,
4904 RTLIB::LLROUND_F64, RTLIB::LLROUND_F80,
4905 RTLIB::LLROUND_F128,
4906 RTLIB::LLROUND_PPCF128,
Results);
4910 ExpandArgFPLibCall(
Node, RTLIB::LRINT_F32,
4911 RTLIB::LRINT_F64, RTLIB::LRINT_F80,
4913 RTLIB::LRINT_PPCF128,
Results);
4917 ExpandArgFPLibCall(
Node, RTLIB::LLRINT_F32,
4918 RTLIB::LLRINT_F64, RTLIB::LLRINT_F80,
4920 RTLIB::LLRINT_PPCF128,
Results);
4925 {RTLIB::FAST_DIV_F32, RTLIB::DIV_F32},
4926 {RTLIB::FAST_DIV_F64, RTLIB::DIV_F64},
4927 {RTLIB::FAST_DIV_F80, RTLIB::DIV_F80},
4928 {RTLIB::FAST_DIV_F128, RTLIB::DIV_F128},
4929 {RTLIB::FAST_DIV_PPCF128, RTLIB::DIV_PPCF128},
Results);
4934 ExpandFPLibCall(
Node, RTLIB::REM_F32, RTLIB::REM_F64,
4935 RTLIB::REM_F80, RTLIB::REM_F128,
4940 ExpandFPLibCall(
Node, RTLIB::FMA_F32, RTLIB::FMA_F64,
4941 RTLIB::FMA_F80, RTLIB::FMA_F128,
4947 {RTLIB::FAST_ADD_F32, RTLIB::ADD_F32},
4948 {RTLIB::FAST_ADD_F64, RTLIB::ADD_F64},
4949 {RTLIB::FAST_ADD_F80, RTLIB::ADD_F80},
4950 {RTLIB::FAST_ADD_F128, RTLIB::ADD_F128},
4951 {RTLIB::FAST_ADD_PPCF128, RTLIB::ADD_PPCF128},
Results);
4957 {RTLIB::FAST_MUL_F32, RTLIB::MUL_F32},
4958 {RTLIB::FAST_MUL_F64, RTLIB::MUL_F64},
4959 {RTLIB::FAST_MUL_F80, RTLIB::MUL_F80},
4960 {RTLIB::FAST_MUL_F128, RTLIB::MUL_F128},
4961 {RTLIB::FAST_MUL_PPCF128, RTLIB::MUL_PPCF128},
Results);
4965 if (
Node->getValueType(0) == MVT::f32) {
4966 Results.push_back(ExpandLibCall(RTLIB::FPEXT_F16_F32,
Node,
false).first);
4970 if (
Node->getValueType(0) == MVT::f32) {
4971 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(
4972 DAG, RTLIB::FPEXT_BF16_F32, MVT::f32,
Node->getOperand(1),
4975 Results.push_back(Tmp.second);
4979 if (
Node->getValueType(0) == MVT::f32) {
4980 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(
4981 DAG, RTLIB::FPEXT_F16_F32, MVT::f32,
Node->getOperand(1), CallOptions,
4984 Results.push_back(Tmp.second);
4991 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unable to expand fp_to_fp16");
4992 Results.push_back(ExpandLibCall(LC,
Node,
false).first);
4998 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unable to expand fp_to_bf16");
4999 Results.push_back(ExpandLibCall(LC,
Node,
false).first);
5007 bool IsStrict =
Node->isStrictFPOpcode();
5010 EVT SVT =
Node->getOperand(IsStrict ? 1 : 0).getValueType();
5011 EVT RVT =
Node->getValueType(0);
5018 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5019 for (
unsigned t = MVT::FIRST_INTEGER_VALUETYPE;
5020 t <= MVT::LAST_INTEGER_VALUETYPE && LC == RTLIB::UNKNOWN_LIBCALL;
5028 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unable to legalize as libcall");
5033 NVT,
Node->getOperand(IsStrict ? 1 : 0));
5035 std::pair<SDValue, SDValue> Tmp =
5036 TLI.makeLibCall(DAG, LC, RVT,
Op, CallOptions, dl, Chain);
5039 Results.push_back(Tmp.second);
5047 bool IsStrict =
Node->isStrictFPOpcode();
5052 EVT SVT =
Op.getValueType();
5053 EVT RVT =
Node->getValueType(0);
5060 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5061 for (
unsigned IntVT = MVT::FIRST_INTEGER_VALUETYPE;
5062 IntVT <= MVT::LAST_INTEGER_VALUETYPE && LC == RTLIB::UNKNOWN_LIBCALL;
5070 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unable to legalize as libcall");
5073 std::pair<SDValue, SDValue> Tmp =
5074 TLI.makeLibCall(DAG, LC, NVT,
Op, CallOptions, dl, Chain);
5079 Results.push_back(Tmp.second);
5090 bool IsStrict =
Node->isStrictFPOpcode();
5093 EVT VT =
Node->getValueType(0);
5094 assert(cast<ConstantSDNode>(
Node->getOperand(IsStrict ? 2 : 1))->isZero() &&
5095 "Unable to expand as libcall if it is not normal rounding");
5098 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unable to legalize as libcall");
5100 std::pair<SDValue, SDValue> Tmp =
5101 TLI.makeLibCall(DAG, LC, VT,
Op, CallOptions,
SDLoc(
Node), Chain);
5104 Results.push_back(Tmp.second);
5110 Node->getValueType(0)),
5111 Node,
false).first);
5117 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5124 Node->getValueType(0));
5126 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unable to legalize as libcall");
5128 std::pair<SDValue, SDValue> Tmp =
5129 TLI.makeLibCall(DAG, LC,
Node->getValueType(0),
Node->getOperand(1),
5132 Results.push_back(Tmp.second);
5138 {RTLIB::FAST_SUB_F32, RTLIB::SUB_F32},
5139 {RTLIB::FAST_SUB_F64, RTLIB::SUB_F64},
5140 {RTLIB::FAST_SUB_F80, RTLIB::SUB_F80},
5141 {RTLIB::FAST_SUB_F128, RTLIB::SUB_F128},
5142 {RTLIB::FAST_SUB_PPCF128, RTLIB::SUB_PPCF128},
Results);
5148 RTLIB::SREM_I16, RTLIB::SREM_I32,
5149 RTLIB::SREM_I64, RTLIB::SREM_I128));
5154 RTLIB::UREM_I16, RTLIB::UREM_I32,
5155 RTLIB::UREM_I64, RTLIB::UREM_I128));
5160 RTLIB::SDIV_I16, RTLIB::SDIV_I32,
5161 RTLIB::SDIV_I64, RTLIB::SDIV_I128));
5166 RTLIB::UDIV_I16, RTLIB::UDIV_I32,
5167 RTLIB::UDIV_I64, RTLIB::UDIV_I128));
5177 RTLIB::MUL_I16, RTLIB::MUL_I32,
5178 RTLIB::MUL_I64, RTLIB::MUL_I128));
5181 Results.push_back(ExpandBitCountingLibCall(
5182 Node, RTLIB::CTLZ_I32, RTLIB::CTLZ_I64, RTLIB::CTLZ_I128));
5185 Results.push_back(ExpandBitCountingLibCall(
5186 Node, RTLIB::CTPOP_I32, RTLIB::CTPOP_I64, RTLIB::CTPOP_I128));
5191 EVT PtrTy = TLI.getPointerTy(DAG.getDataLayout());
5192 SDValue Ptr = DAG.getAllOnesConstant(dl, PtrTy);
5195 DAG.makeStateFunctionCall(RTLIB::FESETENV,
Ptr, Chain, dl));
5202 DAG.makeStateFunctionCall(RTLIB::FEGETENV, EnvPtr, Chain, dl));
5209 DAG.makeStateFunctionCall(RTLIB::FESETENV, EnvPtr, Chain, dl));
5215 EVT ModeVT =
Node->getValueType(0);
5217 int SPFI = cast<FrameIndexSDNode>(
StackPtr.getNode())->getIndex();
5218 SDValue Chain = DAG.makeStateFunctionCall(RTLIB::FEGETMODE, StackPtr,
5219 Node->getOperand(0), dl);
5221 ModeVT, dl, Chain, StackPtr,
5231 EVT ModeVT =
Mode.getValueType();
5233 int SPFI = cast<FrameIndexSDNode>(
StackPtr.getNode())->getIndex();
5234 SDValue StInst = DAG.getStore(
5235 Node->getOperand(0), dl, Mode, StackPtr,
5238 DAG.makeStateFunctionCall(RTLIB::FESETMODE, StackPtr, StInst, dl));
5246 EVT PtrTy = TLI.getPointerTy(
DL);
5248 Results.push_back(DAG.makeStateFunctionCall(RTLIB::FESETMODE, Mode,
5249 Node->getOperand(0), dl));
5256 LLVM_DEBUG(
dbgs() <<
"Successfully converted node to libcall\n");
5265 MVT EltVT,
MVT NewEltVT) {
5267 MVT MidVT = OldEltsPerNewElt == 1
5274void SelectionDAGLegalize::PromoteNode(
SDNode *
Node) {
5277 MVT OVT =
Node->getSimpleValueType(0);
5287 OVT =
Node->getOperand(0).getSimpleValueType();
5294 Node->getOpcode() == ISD::VP_REDUCE_FADD ||
5295 Node->getOpcode() == ISD::VP_REDUCE_FMUL ||
5296 Node->getOpcode() == ISD::VP_REDUCE_FMAX ||
5297 Node->getOpcode() == ISD::VP_REDUCE_FMIN ||
5298 Node->getOpcode() == ISD::VP_REDUCE_FMAXIMUM ||
5299 Node->getOpcode() == ISD::VP_REDUCE_FMINIMUM ||
5300 Node->getOpcode() == ISD::VP_REDUCE_SEQ_FADD)
5301 OVT =
Node->getOperand(1).getSimpleValueType();
5304 OVT =
Node->getOperand(2).getSimpleValueType();
5308 MVT NVT = TLI.getTypeToPromoteTo(
Node->getOpcode(), OVT);
5310 SDValue Tmp1, Tmp2, Tmp3, Tmp4;
5311 switch (
Node->getOpcode()) {
5323 unsigned NewOpc =
Node->getOpcode();
5331 DAG.getConstant(TopBit, dl, NVT));
5336 Tmp1 = DAG.
getNode(NewOpc, dl, NVT, Tmp1);
5352 auto AnyExtendedNode =
5356 auto ShiftConstant = DAG.getShiftAmountConstant(
5358 auto LeftShiftResult =
5359 DAG.getNode(
ISD::SHL, dl, NVT, AnyExtendedNode, ShiftConstant);
5362 auto CTLZResult = DAG.getNode(
Node->getOpcode(), dl, NVT, LeftShiftResult);
5370 Tmp1 = DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1);
5373 DAG.getConstant(DiffBits, dl,
5374 TLI.getShiftAmountTy(NVT, DAG.getDataLayout())));
5387 Results.push_back(PromoteLegalFP_TO_INT_SAT(
Node, dl));
5404 &&
"VAARG promotion is supported only for vectors or integer types");
5409 Tmp1 = DAG.getVAArg(NVT, dl, Chain,
Ptr,
Node->getOperand(2),
5410 Node->getConstantOperandVal(3));
5413 Tmp2 = DAG.
getNode(TruncOp, dl, OVT, Tmp1);
5417 DAG.ReplaceAllUsesOfValueWith(
SDValue(
Node, 0), Tmp2);
5418 DAG.ReplaceAllUsesOfValueWith(
SDValue(
Node, 1), Chain);
5420 UpdatedNodes->insert(Tmp2.
getNode());
5421 UpdatedNodes->insert(Chain.
getNode());
5438 unsigned ExtOp, TruncOp;
5445 switch (
Node->getOpcode()) {
5461 if (TLI.isSExtCheaperThanZExt(OVT, NVT))
5470 Tmp1 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(0));
5471 Tmp2 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(1));
5473 Tmp1 = DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1, Tmp2);
5474 Results.push_back(DAG.getNode(TruncOp, dl, OVT, Tmp1));
5482 Tmp1 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(0));
5483 Tmp2 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(1));
5486 auto &
DL = DAG.getDataLayout();
5490 DAG.getConstant(OriginalSize, dl, TLI.getScalarShiftAmountTy(
DL, NVT)));
5496 unsigned ExtOp, TruncOp;
5497 if (
Node->getValueType(0).isVector() ||
5501 }
else if (
Node->getValueType(0).isInteger()) {
5508 Tmp1 =
Node->getOperand(0);
5510 Tmp2 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(1));
5511 Tmp3 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(2));
5513 Tmp1 = DAG.getSelect(dl, NVT, Tmp1, Tmp2, Tmp3);
5515 Tmp1 = DAG.
getNode(TruncOp, dl,
Node->getValueType(0), Tmp1);
5517 Tmp1 = DAG.
getNode(TruncOp, dl,
Node->getValueType(0), Tmp1,
5518 DAG.getIntPtrConstant(0, dl,
true));
5530 Tmp1 = ShuffleWithNarrowerEltType(NVT, OVT, dl, Tmp1, Tmp2, Mask);
5539 Node->getOperand(2));
5547 MVT CVT =
Node->getSimpleValueType(0);
5548 assert(CVT == OVT &&
"not handled");
5556 if (TLI.isCondCodeLegal(CCCode, CVT)) {
5557 Tmp1 =
Node->getOperand(0);
5558 Tmp2 =
Node->getOperand(1);
5560 Tmp1 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(0));
5561 Tmp2 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(1));
5564 Tmp3 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(2));
5565 Tmp4 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(3));
5575 DAG.getIntPtrConstant(0, dl,
true));
5587 TLI.isSExtCheaperThanZExt(
Node->getOperand(0).getValueType(), NVT))
5592 if (
Node->isStrictFPOpcode()) {
5594 std::tie(Tmp1, std::ignore) =
5595 DAG.getStrictFPExtendOrRound(
Node->getOperand(1), InChain, dl, NVT);
5596 std::tie(Tmp2, std::ignore) =
5597 DAG.getStrictFPExtendOrRound(
Node->getOperand(2), InChain, dl, NVT);
5599 SDValue OutChain = DAG.getTokenFactor(dl, TmpChains);
5600 SDVTList VTs = DAG.getVTList(
Node->getValueType(0), MVT::Other);
5601 Results.push_back(DAG.getNode(
Node->getOpcode(), dl, VTs,
5602 {OutChain, Tmp1, Tmp2, Node->getOperand(3)},
5607 Tmp1 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(0));
5608 Tmp2 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(1));
5610 Tmp2,
Node->getOperand(2),
Node->getFlags()));
5617 cast<CondCodeSDNode>(
Node->getOperand(1))->get();
5620 Tmp1 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(2));
5621 Tmp2 = DAG.
getNode(ExtOp, dl, NVT,
Node->getOperand(3));
5623 Node->getOperand(0),
Node->getOperand(1),
5624 Tmp1, Tmp2,
Node->getOperand(4)));
5642 Tmp3 = DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1, Tmp2);
5645 DAG.getIntPtrConstant(0, dl,
true)));
5651 SDVTList VTs = DAG.getVTList(NVT, MVT::Other);
5653 Node->getOperand(1));
5655 Node->getOperand(2));
5657 Tmp3 = DAG.
getNode(
Node->getOpcode(), dl, VTs, Ops,
Node->getFlags());
5660 DAG.getIntPtrConstant(0, dl,
true));
5676 {
Node->getOperand(0),
Node->getOperand(1)});
5678 {
Node->getOperand(0),
Node->getOperand(2)});
5681 Tmp1 = DAG.
getNode(
Node->getOpcode(), dl, {NVT, MVT::Other},
5682 {Tmp3, Tmp1, Tmp2});
5685 DAG.getIntPtrConstant(0, dl,
true)});
5695 DAG.getNode(
Node->getOpcode(), dl, NVT, Tmp1, Tmp2, Tmp3),
5696 DAG.getIntPtrConstant(0, dl,
true)));
5700 {
Node->getOperand(0),
Node->getOperand(1)});
5702 {
Node->getOperand(0),
Node->getOperand(2)});
5704 {
Node->getOperand(0),
Node->getOperand(3)});
5707 Tmp4 = DAG.
getNode(
Node->getOpcode(), dl, {NVT, MVT::Other},
5708 {Tmp4, Tmp1, Tmp2, Tmp3});
5711 DAG.getIntPtrConstant(0, dl,
true)});
5719 Tmp2 =
Node->getOperand(1);
5720 Tmp3 = DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1, Tmp2);
5730 DAG.getIntPtrConstant(isTrunc, dl,
true)));
5735 {
Node->getOperand(0),
Node->getOperand(1)});
5736 Tmp2 =
Node->getOperand(2);
5741 DAG.getIntPtrConstant(0, dl,
true)});
5748 {
Node->getOperand(0),
Node->getOperand(1)});
5749 Tmp2 = DAG.
getNode(
Node->getOpcode(), dl, {NVT, MVT::Other},
5753 DAG.getIntPtrConstant(0, dl,
true)});
5763 DAG.getIntPtrConstant(0, dl,
true)));
5772 Tmp2 = DAG.
getNode(
Node->getOpcode(), dl, DAG.getVTList(NVT, NVT), Tmp1);
5773 Tmp3 = DAG.getIntPtrConstant(0, dl,
true);
5774 for (
unsigned ResNum = 0; ResNum <
Node->getNumValues(); ResNum++)
5806 Tmp2 = DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1);
5809 DAG.getIntPtrConstant(0, dl,
true)));
5834 {
Node->getOperand(0),
Node->getOperand(1)});
5835 Tmp2 = DAG.
getNode(
Node->getOpcode(), dl, {NVT, MVT::Other},
5839 DAG.getIntPtrConstant(0, dl,
true)});
5854 "Invalid promote type for build_vector");
5887 "Invalid promote type for extract_vector_elt");
5894 EVT IdxVT =
Idx.getValueType();
5896 SDValue Factor = DAG.getConstant(NewEltsPerOldElt, SL, IdxVT);
5902 for (
unsigned I = 0;
I < NewEltsPerOldElt; ++
I) {
5903 SDValue IdxOffset = DAG.getConstant(
I, SL, IdxVT);
5911 SDValue NewVec = DAG.getBuildVector(MidVT, SL, NewOps);
5933 "Invalid promote type for insert_vector_elt");
5941 EVT IdxVT =
Idx.getValueType();
5944 SDValue Factor = DAG.getConstant(NewEltsPerOldElt,
SDLoc(), IdxVT);
5951 for (
unsigned I = 0;
I < NewEltsPerOldElt; ++
I) {
5952 SDValue IdxOffset = DAG.getConstant(
I, SL, IdxVT);
5956 CastVal, IdxOffset);
5959 NewVec, Elt, InEltIdx);
5999 "unexpected promotion type");
6001 "unexpected atomic_swap with illegal type");
6025 "unexpected promotion type");
6027 "unexpected atomic_load with illegal type");
6038 MVT ScalarType = Scalar.getSimpleValueType();
6042 Tmp2 = DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1);
6047 Tmp2 = DAG.
getNode(
Node->getOpcode(), dl, NVT, Tmp1);
6050 DAG.getIntPtrConstant(0, dl,
true)));
6057 case ISD::VP_REDUCE_FMAX:
6058 case ISD::VP_REDUCE_FMIN:
6059 case ISD::VP_REDUCE_FMAXIMUM:
6060 case ISD::VP_REDUCE_FMINIMUM:
6086 SelectionDAGLegalize
Legalizer(*
this, LegalizedNodes);
6093 bool AnyLegalized =
false;
6104 if (LegalizedNodes.
insert(
N).second) {
6105 AnyLegalized =
true;
6126 SelectionDAGLegalize
Legalizer(*
this, LegalizedNodes, &UpdatedNodes);
6133 return LegalizedNodes.
count(
N);
aarch64 falkor hwpf fix Falkor HW Prefetch Fix Late Phase
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static msgpack::DocNode getNode(msgpack::DocNode DN, msgpack::Type Type, MCValue Val)
static bool isConstant(const MachineInstr &MI)
This file declares a class to represent arbitrary precision floating point values and provide a varie...
This file implements a class to represent arbitrary precision integral constant values and operations...
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Function Alias Analysis Results
This file contains the declarations for the subclasses of Constant, which represent the different fla...
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 bool canUseFastMathLibcall(const SDNode *Node)
Return if we can use the FAST_* variant of a math libcall for the node.
static MachineMemOperand * getStackAlignedMMO(SDValue StackPtr, MachineFunction &MF, bool isObjectScalable)
static MVT getPromotedVectorElementType(const TargetLowering &TLI, MVT EltVT, MVT NewEltVT)
mir Rename Register Operands
std::pair< MCSymbol *, MachineModuleInfoImpl::StubValueTy > PairTy
PowerPC Reduce CR logical Operation
static constexpr MCPhysReg SPReg
const SmallVectorImpl< MachineOperand > & Cond
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 LLVM_ABI 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 LLVM_ABI 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.
Convenience struct for specifying and reasoning about fast-math flags.
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
LLVM_ABI void dump() const
Dump this node, for debugging.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
static bool hasPredecessorHelper(const SDNode *N, SmallPtrSetImpl< const SDNode * > &Visited, SmallVectorImpl< const SDNode * > &Worklist, unsigned int MaxSteps=0, bool TopologicalPrune=false)
Returns true if N is a predecessor of any node in Worklist.
unsigned getNumValues() const
Return the number of values defined/returned by this operator.
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
iterator_range< user_iterator > users()
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
SDNode * getNode() const
get the SDNode which holds the desired result
SDValue getValue(unsigned R) const
EVT getValueType() const
Return the ValueType of the referenced return value.
const SDValue & getOperand(unsigned i) const
uint64_t getScalarValueSizeInBits() const
unsigned getResNo() const
get the index which selects a specific result in the SDNode
MVT getSimpleValueType() const
Return the simple ValueType of the referenced return value.
unsigned getOpcode() const
Help to insert SDNodeFlags automatically in transforming.
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
LLVM_ABI void DeleteNode(SDNode *N)
Remove the specified node from the system.
const DataLayout & getDataLayout() const
LLVM_ABI void Legalize()
This transforms the SelectionDAG into a SelectionDAG that is compatible with the target instruction s...
LLVM_ABI bool LegalizeOp(SDNode *N, SmallSetVector< SDNode *, 16 > &UpdatedNodes)
Transforms a SelectionDAG node and any operands to it into a node that is compatible with the target ...
LLVM_ABI void ReplaceAllUsesWith(SDValue From, SDValue To)
Modify anything using 'From' to use 'To' instead.
LLVM_ABI void RemoveDeadNodes()
This method deletes all unreachable nodes in the SelectionDAG.
const TargetMachine & getTarget() const
LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
LLVM_ABI unsigned AssignTopologicalOrder()
Topological-sort the AllNodes list and a assign a unique node id for each node in the DAG based on th...
LLVM_ABI void ReplaceAllUsesOfValueWith(SDValue From, SDValue To)
Replace any uses of From with To, leaving uses of other values produced by From.getNode() alone.
LLVMContext * getContext() const
LLVM_ABI 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 LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
static LLVM_ABI UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
LLVM Value Representation.
constexpr ScalarTy getFixedValue() const
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char 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.
@ POISON
POISON - A poison node.
@ SET_FPENV
Sets the current floating-point environment.
@ VECREDUCE_SEQ_FADD
Generic reduction nodes.
@ EH_SJLJ_LONGJMP
OUTCHAIN = EH_SJLJ_LONGJMP(INCHAIN, buffer) This corresponds to the eh.sjlj.longjmp intrinsic.
@ SMUL_LOHI
SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing a signed/unsigned value of type i[2...
@ INSERT_SUBVECTOR
INSERT_SUBVECTOR(VECTOR1, VECTOR2, IDX) - Returns a vector with VECTOR2 inserted into VECTOR1.
@ BSWAP
Byte Swap and Counting operators.
@ SMULFIX
RESULT = [US]MULFIX(LHS, RHS, SCALE) - Perform fixed point multiplication on 2 integers with the same...
@ VAEND
VAEND, VASTART - VAEND and VASTART have three operands: an input chain, pointer, and a SRCVALUE.
@ ATOMIC_STORE
OUTCHAIN = ATOMIC_STORE(INCHAIN, val, ptr) This corresponds to "store atomic" instruction.
@ FRAME_TO_ARGS_OFFSET
FRAME_TO_ARGS_OFFSET - This node represents offset from frame pointer to first (possible) on-stack ar...
@ RESET_FPENV
Set floating-point environment to default state.
@ FMAD
FMAD - Perform a * b + c, while getting the same result as the separately rounded operations.
@ ADD
Simple integer binary arithmetic operators.
@ LOAD
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
@ SMULFIXSAT
Same as the corresponding unsaturated fixed point instructions, but the result is clamped between the...
@ SET_FPMODE
Sets the current dynamic floating-point control modes.
@ ANY_EXTEND
ANY_EXTEND - Used for integer types. The high bits are undefined.
@ FMA
FMA - Perform a * b + c with no intermediate rounding step.
@ FMODF
FMODF - Decomposes the operand into integral and fractional parts, each having the same type and sign...
@ FATAN2
FATAN2 - atan2, inspired by libm.
@ FSINCOSPI
FSINCOSPI - Compute both the sine and cosine times pi more accurately than FSINCOS(pi*x),...
@ INTRINSIC_VOID
OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...) This node represents a target intrin...
@ EH_SJLJ_SETUP_DISPATCH
OUTCHAIN = EH_SJLJ_SETUP_DISPATCH(INCHAIN) The target initializes the dispatch table here.
@ ATOMIC_CMP_SWAP_WITH_SUCCESS
Val, Success, OUTCHAIN = ATOMIC_CMP_SWAP_WITH_SUCCESS(INCHAIN, ptr, cmp, swap) N.b.
@ SINT_TO_FP
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
@ CONCAT_VECTORS
CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of vector type with the same length ...
@ VECREDUCE_FMAX
FMIN/FMAX nodes can have flags, for NaN/NoNaN variants.
@ FADD
Simple binary floating point operators.
@ VECREDUCE_FMAXIMUM
FMINIMUM/FMAXIMUM nodes propatate NaNs and signed zeroes using the llvm.minimum and llvm....
@ ABS
ABS - Determine the unsigned absolute value of a signed integer value of the same bitwidth.
@ ATOMIC_FENCE
OUTCHAIN = ATOMIC_FENCE(INCHAIN, ordering, scope) This corresponds to the fence instruction.
@ RESET_FPMODE
Sets default dynamic floating-point control modes.
@ SDIVREM
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
@ FP16_TO_FP
FP16_TO_FP, FP_TO_FP16 - These operators are used to perform promotions and truncation for half-preci...
@ BITCAST
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
@ BUILD_PAIR
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
@ INIT_TRAMPOLINE
INIT_TRAMPOLINE - This corresponds to the init_trampoline intrinsic.
@ FLDEXP
FLDEXP - ldexp, inspired by libm (op0 * 2**op1).
@ SDIVFIX
RESULT = [US]DIVFIX(LHS, RHS, SCALE) - Perform fixed point division on 2 integers with the same width...
@ STRICT_FSQRT
Constrained versions of libm-equivalent floating point intrinsics.
@ BUILTIN_OP_END
BUILTIN_OP_END - This must be the last enum value in this list.
@ EH_LABEL
EH_LABEL - Represents a label in mid basic block used to track locations needed for debug and excepti...
@ EH_RETURN
OUTCHAIN = EH_RETURN(INCHAIN, OFFSET, HANDLER) - This node represents 'eh_return' gcc dwarf builtin,...
@ SIGN_EXTEND
Conversion operators.
@ AVGCEILS
AVGCEILS/AVGCEILU - Rounding averaging add - Add two integers using an integer of type i[N+2],...
@ SCALAR_TO_VECTOR
SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a scalar value into element 0 of the...
@ READSTEADYCOUNTER
READSTEADYCOUNTER - This corresponds to the readfixedcounter intrinsic.
@ ADDROFRETURNADDR
ADDROFRETURNADDR - Represents the llvm.addressofreturnaddress intrinsic.
@ VECREDUCE_FADD
These reductions have relaxed evaluation order semantics, and have a single vector operand.
@ CTTZ_ZERO_UNDEF
Bit counting operators with an undefined result for zero inputs.
@ PREFETCH
PREFETCH - This corresponds to a prefetch intrinsic.
@ FSINCOS
FSINCOS - Compute both fsin and fcos as a single operation.
@ SETCCCARRY
Like SetCC, ops #0 and #1 are the LHS and RHS operands to compare, but op #2 is a boolean indicating ...
@ FNEG
Perform various unary floating-point operations inspired by libm.
@ BR_CC
BR_CC - Conditional branch.
@ SSUBO
Same for subtraction.
@ BR_JT
BR_JT - Jumptable branch.
@ VECTOR_INTERLEAVE
VECTOR_INTERLEAVE(VEC1, VEC2, ...) - Returns N vectors from N input vectors, where N is the factor to...
@ FCANONICALIZE
Returns platform specific canonical encoding of a floating point number.
@ IS_FPCLASS
Performs a check of floating point class property, defined by IEEE-754.
@ SSUBSAT
RESULT = [US]SUBSAT(LHS, RHS) - Perform saturation subtraction on 2 integers with the same bit width ...
@ SELECT
Select(COND, TRUEVAL, FALSEVAL).
@ ATOMIC_LOAD
Val, OUTCHAIN = ATOMIC_LOAD(INCHAIN, ptr) This corresponds to "load atomic" instruction.
@ UNDEF
UNDEF - An undefined node.
@ EXTRACT_ELEMENT
EXTRACT_ELEMENT - This is used to get the lower or upper (determined by a Constant,...
@ SPLAT_VECTOR
SPLAT_VECTOR(VAL) - Returns a vector with the scalar value VAL duplicated in all lanes.
@ VACOPY
VACOPY - VACOPY has 5 operands: an input chain, a destination pointer, a source pointer,...
@ SADDO
RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
@ VECREDUCE_ADD
Integer reductions may have a result type larger than the vector element type.
@ GET_ROUNDING
Returns current rounding mode: -1 Undefined 0 Round to 0 1 Round to nearest, ties to even 2 Round to ...
@ MULHU
MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing an unsigned/signed value of...
@ GET_FPMODE
Reads the current dynamic floating-point control modes.
@ SHL
Shift and rotation operations.
@ VECTOR_SHUFFLE
VECTOR_SHUFFLE(VEC1, VEC2) - Returns a vector, of the same type as VEC1/VEC2.
@ EXTRACT_SUBVECTOR
EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR.
@ READ_REGISTER
READ_REGISTER, WRITE_REGISTER - This node represents llvm.register on the DAG, which implements the n...
@ EXTRACT_VECTOR_ELT
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
@ ZERO_EXTEND
ZERO_EXTEND - Used for integer types, zeroing the new bits.
@ DEBUGTRAP
DEBUGTRAP - Trap intended to get the attention of a debugger.
@ SELECT_CC
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
@ ATOMIC_CMP_SWAP
Val, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap) For double-word atomic operations: ValLo,...
@ FMINNUM
FMINNUM/FMAXNUM - Perform floating-point minimum maximum on two values, following IEEE-754 definition...
@ UBSANTRAP
UBSANTRAP - Trap with an immediate describing the kind of sanitizer failure.
@ SSHLSAT
RESULT = [US]SHLSAT(LHS, RHS) - Perform saturation left shift.
@ SMULO
Same for multiplication.
@ DYNAMIC_STACKALLOC
DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned to a specified boundary.
@ SIGN_EXTEND_INREG
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
@ SMIN
[US]{MIN/MAX} - Binary minimum or maximum of signed or unsigned integers.
@ SDIVFIXSAT
Same as the corresponding unsaturated fixed point instructions, but the result is clamped between the...
@ FP_EXTEND
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
@ GLOBAL_OFFSET_TABLE
The address of the GOT.
@ UADDO_CARRY
Carry-using nodes for multiple precision addition and subtraction.
@ STRICT_SINT_TO_FP
STRICT_[US]INT_TO_FP - Convert a signed or unsigned integer to a floating point value.
@ EH_DWARF_CFA
EH_DWARF_CFA - This node represents the pointer to the DWARF Canonical Frame Address (CFA),...
@ BF16_TO_FP
BF16_TO_FP, FP_TO_BF16 - These operators are used to perform promotions and truncation for bfloat16.
@ FRAMEADDR
FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and llvm.returnaddress on the DAG.
@ STRICT_FP_ROUND
X = STRICT_FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type down to the precision ...
@ STRICT_FP_TO_SINT
STRICT_FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ FMINIMUM
FMINIMUM/FMAXIMUM - NaN-propagating minimum/maximum that also treat -0.0 as less than 0....
@ FP_TO_SINT
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ READCYCLECOUNTER
READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
@ TargetConstant
TargetConstant* - Like Constant*, but the DAG does not do any folding, simplification,...
@ STRICT_FP_EXTEND
X = STRICT_FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
@ AND
Bitwise operators - logical and, logical or, logical xor.
@ TRAP
TRAP - Trapping instruction.
@ INTRINSIC_WO_CHAIN
RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) This node represents a target intrinsic fun...
@ GET_FPENV_MEM
Gets the current floating-point environment.
@ SCMP
[US]CMP - 3-way comparison of signed or unsigned integers.
@ AVGFLOORS
AVGFLOORS/AVGFLOORU - Averaging add - Add two integers using an integer of type i[N+1],...
@ STRICT_FADD
Constrained versions of the binary floating point operators.
@ INSERT_VECTOR_ELT
INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element at IDX replaced with VAL.
@ TokenFactor
TokenFactor - This node takes multiple tokens as input and produces a single token result.
@ VECTOR_SPLICE
VECTOR_SPLICE(VEC1, VEC2, IMM) - Returns a subvector of the same type as VEC1/VEC2 from CONCAT_VECTOR...
@ ATOMIC_SWAP
Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt) Val, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN,...
@ FFREXP
FFREXP - frexp, extract fractional and exponent component of a floating-point value.
@ FP_ROUND
X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type down to the precision of the ...
@ SPONENTRY
SPONENTRY - Represents the llvm.sponentry intrinsic.
@ 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,...
@ VECTOR_DEINTERLEAVE
VECTOR_DEINTERLEAVE(VEC1, VEC2, ...) - Returns N vectors from N input vectors, where N is the factor ...
@ GET_DYNAMIC_AREA_OFFSET
GET_DYNAMIC_AREA_OFFSET - get offset from native SP to the address of the most recent dynamic alloca.
@ SET_FPENV_MEM
Sets the current floating point environment.
@ FMINIMUMNUM
FMINIMUMNUM/FMAXIMUMNUM - minimumnum/maximumnum that is same with FMINNUM_IEEE and FMAXNUM_IEEE besid...
@ ABDS
ABDS/ABDU - Absolute difference - Return the absolute difference between two numbers interpreted as s...
@ ADJUST_TRAMPOLINE
ADJUST_TRAMPOLINE - This corresponds to the adjust_trampoline intrinsic.
@ INTRINSIC_W_CHAIN
RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) This node represents a target in...
@ BUILD_VECTOR
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a fixed-width vector with the specified,...
LLVM_ABI NodeType getExtForLoadExtType(bool IsFP, LoadExtType)
bool isNormalStore(const SDNode *N)
Returns true if the specified node is a non-truncating and unindexed store.
LLVM_ABI CondCode getSetCCInverse(CondCode Operation, EVT Type)
Return the operation corresponding to !(X op Y), where 'op' is a valid SetCC operation.
LLVM_ABI std::optional< unsigned > getVPMaskIdx(unsigned Opcode)
The operand position of the vector mask.
LLVM_ABI CondCode getSetCCSwappedOperands(CondCode Operation)
Return the operation corresponding to (Y op X) when given the operation for (X op Y).
bool isSignedIntSetCC(CondCode Code)
Return true if this is a setcc instruction that performs a signed comparison when used with integer o...
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
LLVM_ABI bool isVPOpcode(unsigned Opcode)
Whether this is a vector-predicated Opcode.
LLVM_ABI Libcall getPOWI(EVT RetVT)
getPOWI - Return the POWI_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getSINTTOFP(EVT OpVT, EVT RetVT)
getSINTTOFP - Return the SINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getSYNC(unsigned Opc, MVT VT)
Return the SYNC_FETCH_AND_* value for the given opcode and type, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getLDEXP(EVT RetVT)
getLDEXP - Return the LDEXP_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getUINTTOFP(EVT OpVT, EVT RetVT)
getUINTTOFP - Return the UINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getFREXP(EVT RetVT)
getFREXP - Return the FREXP_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getSINCOSPI(EVT RetVT)
getSINCOSPI - Return the SINCOSPI_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getMODF(EVT RetVT)
getMODF - Return the MODF_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getFPLibCall(EVT VT, Libcall Call_F32, Libcall Call_F64, Libcall Call_F80, Libcall Call_F128, Libcall Call_PPCF128)
GetFPLibCall - Helper to return the right libcall for the given floating point type,...
LLVM_ABI Libcall getFPTOUINT(EVT OpVT, EVT RetVT)
getFPTOUINT - Return the FPTOUINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getFPTOSINT(EVT OpVT, EVT RetVT)
getFPTOSINT - Return the FPTOSINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getOUTLINE_ATOMIC(unsigned Opc, AtomicOrdering Order, MVT VT)
Return the outline atomics value for the given opcode, atomic ordering and type, or UNKNOWN_LIBCALL i...
LLVM_ABI Libcall getFPEXT(EVT OpVT, EVT RetVT)
getFPEXT - Return the FPEXT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getFPROUND(EVT OpVT, EVT RetVT)
getFPROUND - Return the FPROUND_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getSINCOS(EVT RetVT)
getSINCOS - Return the SINCOS_* value for the given types, or UNKNOWN_LIBCALL if there is none.
@ Undef
Value of the register doesn't matter.
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)
Returns: X * 2^Exp for integral exponents.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI Constant * ConstantFoldCastOperand(unsigned Opcode, Constant *C, Type *DestTy, const DataLayout &DL)
Attempt to constant fold a cast with the specified operand.
AtomicOrdering
Atomic ordering for LLVM's memory model.
@ Sub
Subtraction of integers.
DWARFExpression::Operation Op
LLVM_ABI bool isOneConstant(SDValue V)
Returns true if V is a constant integer one.
Align commonAlignment(Align A, uint64_t Offset)
Returns the alignment that satisfies both alignments.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
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.
LLVM_ABI Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
bool isScalableVector() const
Return true if this is a vector type where the runtime length is machine dependent.
EVT getVectorElementType() const
Given a vector type, return the type of each element.
bool isScalarInteger() const
Return true if this is an integer, but not a vector.
LLVM_ABI const fltSemantics & getFltSemantics() const
Returns an APFloat semantics tag appropriate for the value type.
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
bool bitsLE(EVT VT) const
Return true if this has no more bits than VT.
bool isInteger() const
Return true if this is an integer or a vector integer type.
This class contains a discriminated union of information about pointers in memory operands,...
static LLVM_ABI MachinePointerInfo getJumpTable(MachineFunction &MF)
Return a MachinePointerInfo record that refers to a jump table entry.
static LLVM_ABI MachinePointerInfo getConstantPool(MachineFunction &MF)
Return a MachinePointerInfo record that refers to the constant pool.
MachinePointerInfo getWithOffset(int64_t O) const
static LLVM_ABI MachinePointerInfo getUnknownStack(MachineFunction &MF)
Stack memory without other information.
static LLVM_ABI MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
These are IR-level optimization flags that may be propagated to SDNodes.
void setNoFPExcept(bool b)
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)