31#include "llvm/IR/IntrinsicsLoongArch.h"
41#define DEBUG_TYPE "loongarch-isel-lowering"
56 cl::desc(
"Maximum number of instructions used (including code sequence "
57 "to generate the value and moving the value to FPR) when "
58 "materializing floating-point immediates (default = 3)"),
62 "Materialize FP immediate within 2 instructions"),
64 "Materialize FP immediate within 3 instructions"),
66 "Materialize FP immediate within 4 instructions"),
68 "Materialize FP immediate within 5 instructions"),
70 "Materialize FP immediate within 6 instructions "
71 "(behaves same as 5 on loongarch64)")));
74 cl::desc(
"Trap on integer division by zero."),
81 MVT GRLenVT = Subtarget.getGRLenVT();
86 if (Subtarget.hasBasicF())
88 if (Subtarget.hasBasicD())
92 MVT::v16i8, MVT::v8i16, MVT::v4i32, MVT::v2i64, MVT::v4f32, MVT::v2f64};
94 MVT::v32i8, MVT::v16i16, MVT::v8i32, MVT::v4i64, MVT::v8f32, MVT::v4f64};
96 if (Subtarget.hasExtLSX())
100 if (Subtarget.hasExtLASX())
101 for (
MVT VT : LASXVTs)
169 if (Subtarget.is64Bit()) {
197 if (!Subtarget.is64Bit()) {
203 if (Subtarget.hasBasicD())
215 if (Subtarget.hasBasicF()) {
247 if (Subtarget.is64Bit())
250 if (!Subtarget.hasBasicD()) {
252 if (Subtarget.is64Bit()) {
261 if (Subtarget.hasBasicD()) {
294 if (Subtarget.is64Bit())
300 if (Subtarget.hasExtLSX()) {
315 for (
MVT VT : LSXVTs) {
329 for (
MVT VT : {MVT::v16i8, MVT::v8i16, MVT::v4i32, MVT::v2i64}) {
350 for (
MVT VT : {MVT::v16i8, MVT::v8i16, MVT::v4i32})
352 for (
MVT VT : {MVT::v8i16, MVT::v4i32, MVT::v2i64})
354 for (
MVT VT : {MVT::v4i32, MVT::v2i64}) {
358 for (
MVT VT : {MVT::v4f32, MVT::v2f64}) {
376 {MVT::v16i8, MVT::v8i8, MVT::v4i8, MVT::v2i8, MVT::v8i16, MVT::v4i16,
377 MVT::v2i16, MVT::v4i32, MVT::v2i32, MVT::v2i64}) {
392 if (Subtarget.hasExtLASX()) {
393 for (
MVT VT : LASXVTs) {
408 for (
MVT VT : {MVT::v4i64, MVT::v8i32, MVT::v16i16, MVT::v32i8}) {
430 for (
MVT VT : {MVT::v32i8, MVT::v16i16, MVT::v8i32})
432 for (
MVT VT : {MVT::v16i16, MVT::v8i32, MVT::v4i64})
434 for (
MVT VT : {MVT::v8i32, MVT::v4i32, MVT::v4i64}) {
438 for (
MVT VT : {MVT::v8f32, MVT::v4f64}) {
460 if (Subtarget.hasExtLSX()) {
467 if (Subtarget.hasExtLASX())
490 if (Subtarget.hasLAMCAS())
493 if (Subtarget.hasSCQ()) {
510 switch (
Op.getOpcode()) {
511 case ISD::ATOMIC_FENCE:
512 return lowerATOMIC_FENCE(
Op, DAG);
514 return lowerEH_DWARF_CFA(
Op, DAG);
516 return lowerGlobalAddress(
Op, DAG);
518 return lowerGlobalTLSAddress(
Op, DAG);
520 return lowerINTRINSIC_WO_CHAIN(
Op, DAG);
522 return lowerINTRINSIC_W_CHAIN(
Op, DAG);
524 return lowerINTRINSIC_VOID(
Op, DAG);
526 return lowerBlockAddress(
Op, DAG);
528 return lowerJumpTable(
Op, DAG);
530 return lowerShiftLeftParts(
Op, DAG);
532 return lowerShiftRightParts(
Op, DAG,
true);
534 return lowerShiftRightParts(
Op, DAG,
false);
536 return lowerConstantPool(
Op, DAG);
538 return lowerFP_TO_SINT(
Op, DAG);
540 return lowerBITCAST(
Op, DAG);
542 return lowerUINT_TO_FP(
Op, DAG);
544 return lowerSINT_TO_FP(
Op, DAG);
546 return lowerVASTART(
Op, DAG);
548 return lowerFRAMEADDR(
Op, DAG);
550 return lowerRETURNADDR(
Op, DAG);
552 return lowerWRITE_REGISTER(
Op, DAG);
554 return lowerINSERT_VECTOR_ELT(
Op, DAG);
556 return lowerEXTRACT_VECTOR_ELT(
Op, DAG);
558 return lowerBUILD_VECTOR(
Op, DAG);
560 return lowerCONCAT_VECTORS(
Op, DAG);
562 return lowerVECTOR_SHUFFLE(
Op, DAG);
564 return lowerBITREVERSE(
Op, DAG);
566 return lowerSCALAR_TO_VECTOR(
Op, DAG);
568 return lowerPREFETCH(
Op, DAG);
570 return lowerSELECT(
Op, DAG);
572 return lowerBRCOND(
Op, DAG);
573 case ISD::FP_TO_FP16:
574 return lowerFP_TO_FP16(
Op, DAG);
575 case ISD::FP16_TO_FP:
576 return lowerFP16_TO_FP(
Op, DAG);
577 case ISD::FP_TO_BF16:
578 return lowerFP_TO_BF16(
Op, DAG);
579 case ISD::BF16_TO_FP:
580 return lowerBF16_TO_FP(
Op, DAG);
581 case ISD::VECREDUCE_ADD:
582 return lowerVECREDUCE_ADD(
Op, DAG);
583 case ISD::VECREDUCE_AND:
584 case ISD::VECREDUCE_OR:
585 case ISD::VECREDUCE_XOR:
586 case ISD::VECREDUCE_SMAX:
587 case ISD::VECREDUCE_SMIN:
588 case ISD::VECREDUCE_UMAX:
589 case ISD::VECREDUCE_UMIN:
590 return lowerVECREDUCE(
Op, DAG);
592 return lowerConstantFP(
Op, DAG);
599 EVT VT =
Op.getValueType();
604 assert((VT == MVT::f32 && Subtarget.hasBasicF()) ||
605 (VT == MVT::f64 && Subtarget.hasBasicD()));
622 int InsNum = Seq.size() + ((VT == MVT::f64 && !Subtarget.
is64Bit()) ? 2 : 1);
664 MVT OpVT =
Op.getSimpleValueType();
671 unsigned LegalVecSize = 128;
672 bool isLASX256Vector =
682 if (isLASX256Vector) {
687 for (
unsigned i = 1; i < NumEles; i *= 2, EleBits *= 2) {
693 if (isLASX256Vector) {
719 MVT OpVT =
Op.getSimpleValueType();
732 MVT GRLenVT = Subtarget.getGRLenVT();
734 for (
int i = NumEles; i > 1; i /= 2) {
737 Val = DAG.
getNode(Opcode,
DL, VecTy, Tmp, Val);
746 unsigned IsData =
Op.getConstantOperandVal(4);
751 return Op.getOperand(0);
766 if (
LHS == LHS2 &&
RHS == RHS2) {
771 }
else if (
LHS == RHS2 &&
RHS == LHS2) {
787 MVT VT =
N->getSimpleValueType(0);
818 if (~TrueVal == FalseVal) {
858 unsigned SelOpNo = 0;
868 unsigned ConstSelOpNo = 1;
869 unsigned OtherSelOpNo = 2;
876 if (!ConstSelOpNode || ConstSelOpNode->
isOpaque())
881 if (!ConstBinOpNode || ConstBinOpNode->
isOpaque())
887 SDValue NewConstOps[2] = {ConstSelOp, ConstBinOp};
889 std::swap(NewConstOps[0], NewConstOps[1]);
901 SDValue NewNonConstOps[2] = {OtherSelOp, ConstBinOp};
903 std::swap(NewNonConstOps[0], NewNonConstOps[1]);
906 SDValue NewT = (ConstSelOpNo == 1) ? NewConstOp : NewNonConstOp;
907 SDValue NewF = (ConstSelOpNo == 1) ? NewNonConstOp : NewConstOp;
927 ShAmt =
LHS.getValueSizeInBits() - 1 -
Log2_64(Mask);
941 int64_t
C = RHSC->getSExtValue();
984 MVT VT =
Op.getSimpleValueType();
985 MVT GRLenVT = Subtarget.getGRLenVT();
990 if (
Op.hasOneUse()) {
991 unsigned UseOpc =
Op->user_begin()->getOpcode();
993 SDNode *BinOp = *
Op->user_begin();
1000 return lowerSELECT(NewSel, DAG);
1040 if (TrueVal - 1 == FalseVal)
1042 if (TrueVal + 1 == FalseVal)
1049 RHS == TrueV &&
LHS == FalseV) {
1081 MVT GRLenVT = Subtarget.getGRLenVT();
1093 Op.getOperand(0),
LHS,
RHS, TargetCC,
1097 Op.getOperand(0), CondV,
Op.getOperand(2));
1107LoongArchTargetLowering::lowerSCALAR_TO_VECTOR(
SDValue Op,
1110 MVT OpVT =
Op.getSimpleValueType();
1121 EVT ResTy =
Op->getValueType(0);
1126 if (!Subtarget.is64Bit() && (ResTy == MVT::v16i8 || ResTy == MVT::v32i8))
1136 for (
unsigned int i = 0; i < NewEltNum; i++) {
1139 unsigned RevOp = (ResTy == MVT::v16i8 || ResTy == MVT::v32i8)
1158 for (
unsigned int i = 0; i < NewEltNum; i++)
1159 for (
int j = OrigEltNum / NewEltNum - 1;
j >= 0;
j--)
1160 Mask.push_back(j + (OrigEltNum / NewEltNum) * i);
1178 if (EltBits > 32 || EltBits == 1)
1206 int MaskOffset,
const APInt &Zeroable) {
1207 int Size = Mask.size();
1208 unsigned SizeInBits =
Size * ScalarSizeInBits;
1210 auto CheckZeros = [&](
int Shift,
int Scale,
bool Left) {
1211 for (
int i = 0; i <
Size; i += Scale)
1212 for (
int j = 0; j < Shift; ++j)
1213 if (!Zeroable[i + j + (
Left ? 0 : (Scale - Shift))])
1221 for (
unsigned i = Pos, e = Pos +
Size; i != e; ++i,
Low += Step)
1222 if (!(Mask[i] == -1 || Mask[i] ==
Low))
1227 auto MatchShift = [&](
int Shift,
int Scale,
bool Left) {
1228 for (
int i = 0; i !=
Size; i += Scale) {
1229 unsigned Pos =
Left ? i + Shift : i;
1230 unsigned Low =
Left ? i : i + Shift;
1231 unsigned Len = Scale - Shift;
1236 int ShiftEltBits = ScalarSizeInBits * Scale;
1237 bool ByteShift = ShiftEltBits > 64;
1240 int ShiftAmt = Shift * ScalarSizeInBits / (ByteShift ? 8 : 1);
1244 Scale = ByteShift ? Scale / 2 : Scale;
1250 return (
int)ShiftAmt;
1253 unsigned MaxWidth = 128;
1254 for (
int Scale = 2; Scale * ScalarSizeInBits <= MaxWidth; Scale *= 2)
1255 for (
int Shift = 1; Shift != Scale; ++Shift)
1256 for (
bool Left : {
true,
false})
1257 if (CheckZeros(Shift, Scale,
Left)) {
1258 int ShiftAmt = MatchShift(Shift, Scale,
Left);
1283 const APInt &Zeroable) {
1284 int Size = Mask.size();
1298 Mask,
Size, Zeroable);
1306 "Illegal integer vector type");
1315template <
typename ValType>
1318 unsigned CheckStride,
1320 ValType ExpectedIndex,
unsigned ExpectedIndexStride) {
1324 if (*
I != -1 && *
I != ExpectedIndex)
1326 ExpectedIndex += ExpectedIndexStride;
1330 for (
unsigned n = 0; n < CheckStride &&
I != End; ++n, ++
I)
1342 int Size = Mask.size();
1352 int ScalarSizeInBits = VectorSizeInBits /
Size;
1353 assert(!(VectorSizeInBits % ScalarSizeInBits) &&
"Illegal shuffle mask size");
1354 (void)ScalarSizeInBits;
1356 for (
int i = 0; i <
Size; ++i) {
1362 if ((M >= 0 && M <
Size && V1IsZero) || (M >=
Size && V2IsZero)) {
1379 RepeatedMask.
assign(LaneSize, -1);
1380 int Size = Mask.size();
1381 for (
int i = 0; i <
Size; ++i) {
1382 assert(Mask[i] == -1 || Mask[i] >= 0);
1385 if ((Mask[i] %
Size) / LaneSize != i / LaneSize)
1392 Mask[i] <
Size ? Mask[i] % LaneSize : Mask[i] % LaneSize + LaneSize;
1393 if (RepeatedMask[i % LaneSize] < 0)
1395 RepeatedMask[i % LaneSize] = LocalM;
1396 else if (RepeatedMask[i % LaneSize] != LocalM)
1413 int NumElts = RepeatedMask.
size();
1415 int Scale = 16 / NumElts;
1417 for (
int i = 0; i < NumElts; ++i) {
1418 int M = RepeatedMask[i];
1419 assert((M == -1 || (0 <= M && M < (2 * NumElts))) &&
1420 "Unexpected mask index.");
1425 int StartIdx = i - (M % NumElts);
1432 int CandidateRotation = StartIdx < 0 ? -StartIdx : NumElts - StartIdx;
1435 Rotation = CandidateRotation;
1436 else if (Rotation != CandidateRotation)
1440 SDValue MaskV = M < NumElts ? V1 : V2;
1451 else if (TargetV != MaskV)
1456 assert(Rotation != 0 &&
"Failed to locate a viable rotation!");
1457 assert((
Lo ||
Hi) &&
"Failed to find a rotated input vector!");
1466 return Rotation * Scale;
1485 if (ByteRotation <= 0)
1492 int LoByteShift = 16 - ByteRotation;
1493 int HiByteShift = ByteRotation;
1516 const APInt &Zeroable) {
1530 for (
int i = 0; i < NumElements; i++) {
1534 if (i % Scale != 0) {
1545 SDValue V = M < NumElements ? V1 : V2;
1546 M = M % NumElements;
1549 Offset = M - (i / Scale);
1552 if (
Offset % (NumElements / Scale))
1554 }
else if (InputV != V)
1557 if (M != (
Offset + (i / Scale)))
1568 if (
Offset >= (NumElements / 2)) {
1570 Offset -= (NumElements / 2);
1577 InputV = DAG.
getNode(VilVLoHi,
DL, InputVT, Ext, InputV);
1581 }
while (Scale > 1);
1587 for (
int NumExtElements = Bits / 64; NumExtElements < NumElements;
1588 NumExtElements *= 2) {
1608 int SplatIndex = -1;
1609 for (
const auto &M : Mask) {
1616 if (SplatIndex == -1)
1619 assert(SplatIndex < (
int)Mask.size() &&
"Out of bounds mask index");
1651 unsigned SubVecSize = 4;
1652 if (VT == MVT::v2f64 || VT == MVT::v2i64)
1655 int SubMask[4] = {-1, -1, -1, -1};
1656 for (
unsigned i = 0; i < SubVecSize; ++i) {
1657 for (
unsigned j = i; j < Mask.size(); j += SubVecSize) {
1663 M -= 4 * (j / SubVecSize);
1664 if (M < 0 || M >= 4)
1670 if (SubMask[i] == -1)
1674 else if (M != -1 && M != SubMask[i])
1681 for (
int i = SubVecSize - 1; i >= 0; --i) {
1694 if (VT == MVT::v2f64 || VT == MVT::v2i64)
1721 const auto &Begin = Mask.begin();
1722 const auto &End = Mask.end();
1723 SDValue OriV1 = V1, OriV2 = V2;
1761 const auto &Begin = Mask.begin();
1762 const auto &End = Mask.end();
1763 SDValue OriV1 = V1, OriV2 = V2;
1802 const auto &Begin = Mask.begin();
1803 const auto &End = Mask.end();
1804 unsigned HalfSize = Mask.size() / 2;
1805 SDValue OriV1 = V1, OriV2 = V2;
1845 const auto &Begin = Mask.begin();
1846 const auto &End = Mask.end();
1847 SDValue OriV1 = V1, OriV2 = V2;
1885 const auto &Begin = Mask.begin();
1886 const auto &Mid = Mask.begin() + Mask.size() / 2;
1887 const auto &End = Mask.end();
1888 SDValue OriV1 = V1, OriV2 = V2;
1927 const auto &Begin = Mask.begin();
1928 const auto &Mid = Mask.begin() + Mask.size() / 2;
1929 const auto &End = Mask.end();
1930 SDValue OriV1 = V1, OriV2 = V2;
1985 "Vector type is unsupported for lsx!");
1987 "Two operands have different types!");
1989 "Unexpected mask size for shuffle!");
1990 assert(Mask.size() % 2 == 0 &&
"Expected even mask size.");
1992 APInt KnownUndef, KnownZero;
1994 APInt Zeroable = KnownUndef | KnownZero;
2058 int SplatIndex = -1;
2059 for (
const auto &M : Mask) {
2066 if (SplatIndex == -1)
2069 const auto &Begin = Mask.begin();
2070 const auto &End = Mask.end();
2071 int HalfSize = Mask.size() / 2;
2073 if (SplatIndex >= HalfSize)
2076 assert(SplatIndex < (
int)Mask.size() &&
"Out of bounds mask index");
2094 if (Mask.size() <= 4)
2105 if (Mask.size() != 4 || (VT != MVT::v4i64 && VT != MVT::v4f64))
2108 unsigned MaskImm = 0;
2109 for (
unsigned i = 0; i < Mask.size(); ++i) {
2112 MaskImm |= Mask[i] << (i * 2);
2124 if (Mask.size() != 8 || (VT != MVT::v8i32 && VT != MVT::v8f32))
2128 unsigned HalfSize = NumElts / 2;
2129 bool FrontLo =
true, FrontHi =
true;
2130 bool BackLo =
true, BackHi =
true;
2132 auto inRange = [](
int val,
int low,
int high) {
2133 return (val == -1) || (val >= low && val < high);
2136 for (
unsigned i = 0; i < HalfSize; ++i) {
2137 int Fronti = Mask[i];
2138 int Backi = Mask[i + HalfSize];
2140 FrontLo &=
inRange(Fronti, 0, HalfSize);
2141 FrontHi &=
inRange(Fronti, HalfSize, NumElts);
2142 BackLo &=
inRange(Backi, 0, HalfSize);
2143 BackHi &=
inRange(Backi, HalfSize, NumElts);
2149 if ((FrontLo || FrontHi) && (BackLo || BackHi))
2154 for (
unsigned i = 0; i < NumElts; ++i)
2181 const auto &Begin = Mask.begin();
2182 const auto &End = Mask.end();
2183 unsigned HalfSize = Mask.size() / 2;
2184 unsigned LeftSize = HalfSize / 2;
2185 SDValue OriV1 = V1, OriV2 = V2;
2192 Mask.size() + HalfSize - LeftSize, 1) &&
2194 Mask.size() + HalfSize + LeftSize, 1))
2205 Mask.size() + HalfSize - LeftSize, 1) &&
2207 Mask.size() + HalfSize + LeftSize, 1))
2220 const auto &Begin = Mask.begin();
2221 const auto &End = Mask.end();
2222 unsigned HalfSize = Mask.size() / 2;
2223 SDValue OriV1 = V1, OriV2 = V2;
2230 Mask.size() + HalfSize, 1))
2241 Mask.size() + HalfSize, 1))
2254 const auto &Begin = Mask.begin();
2255 const auto &LeftMid = Mask.begin() + Mask.size() / 4;
2256 const auto &Mid = Mask.begin() + Mask.size() / 2;
2257 const auto &RightMid = Mask.end() - Mask.size() / 4;
2258 const auto &End = Mask.end();
2259 unsigned HalfSize = Mask.size() / 2;
2260 SDValue OriV1 = V1, OriV2 = V2;
2289 const auto &Begin = Mask.begin();
2290 const auto &LeftMid = Mask.begin() + Mask.size() / 4;
2291 const auto &Mid = Mask.begin() + Mask.size() / 2;
2292 const auto &RightMid = Mask.end() - Mask.size() / 4;
2293 const auto &End = Mask.end();
2294 unsigned HalfSize = Mask.size() / 2;
2295 SDValue OriV1 = V1, OriV2 = V2;
2325 int MaskSize = Mask.size();
2326 int HalfSize = Mask.size() / 2;
2327 const auto &Begin = Mask.begin();
2328 const auto &Mid = Mask.begin() + HalfSize;
2329 const auto &End = Mask.end();
2341 for (
auto it = Begin; it < Mid; it++) {
2344 else if ((*it >= 0 && *it < HalfSize) ||
2345 (*it >= MaskSize && *it < MaskSize + HalfSize)) {
2346 int M = *it < HalfSize ? *it : *it - HalfSize;
2351 assert((
int)MaskAlloc.
size() == HalfSize &&
"xvshuf convert failed!");
2353 for (
auto it = Mid; it < End; it++) {
2356 else if ((*it >= HalfSize && *it < MaskSize) ||
2357 (*it >= MaskSize + HalfSize && *it < MaskSize * 2)) {
2358 int M = *it < MaskSize ? *it - HalfSize : *it - MaskSize;
2363 assert((
int)MaskAlloc.
size() == MaskSize &&
"xvshuf convert failed!");
2395 enum HalfMaskType { HighLaneTy, LowLaneTy,
None };
2397 int MaskSize = Mask.size();
2398 int HalfSize = Mask.size() / 2;
2401 HalfMaskType preMask =
None, postMask =
None;
2403 if (std::all_of(Mask.begin(), Mask.begin() + HalfSize, [&](
int M) {
2404 return M < 0 || (M >= 0 && M < HalfSize) ||
2405 (M >= MaskSize && M < MaskSize + HalfSize);
2407 preMask = HighLaneTy;
2408 else if (std::all_of(Mask.begin(), Mask.begin() + HalfSize, [&](
int M) {
2409 return M < 0 || (M >= HalfSize && M < MaskSize) ||
2410 (M >= MaskSize + HalfSize && M < MaskSize * 2);
2412 preMask = LowLaneTy;
2414 if (std::all_of(Mask.begin() + HalfSize, Mask.end(), [&](
int M) {
2415 return M < 0 || (M >= HalfSize && M < MaskSize) ||
2416 (M >= MaskSize + HalfSize && M < MaskSize * 2);
2418 postMask = LowLaneTy;
2419 else if (std::all_of(Mask.begin() + HalfSize, Mask.end(), [&](
int M) {
2420 return M < 0 || (M >= 0 && M < HalfSize) ||
2421 (M >= MaskSize && M < MaskSize + HalfSize);
2423 postMask = HighLaneTy;
2431 if (preMask == HighLaneTy && postMask == LowLaneTy) {
2434 if (preMask == LowLaneTy && postMask == HighLaneTy) {
2447 for (
auto it = Mask.begin(); it < Mask.begin() + HalfSize; it++) {
2448 *it = *it < 0 ? *it : *it - HalfSize;
2450 for (
auto it = Mask.begin() + HalfSize; it < Mask.end(); it++) {
2451 *it = *it < 0 ? *it : *it + HalfSize;
2453 }
else if (preMask == LowLaneTy && postMask == LowLaneTy) {
2466 for (
auto it = Mask.begin(); it < Mask.begin() + HalfSize; it++) {
2467 *it = *it < 0 ? *it : *it - HalfSize;
2469 }
else if (preMask == HighLaneTy && postMask == HighLaneTy) {
2482 for (
auto it = Mask.begin() + HalfSize; it < Mask.end(); it++) {
2483 *it = *it < 0 ? *it : *it + HalfSize;
2508 int Size = Mask.size();
2509 int LaneSize =
Size / 2;
2511 bool LaneCrossing[2] = {
false,
false};
2512 for (
int i = 0; i <
Size; ++i)
2513 if (Mask[i] >= 0 && ((Mask[i] %
Size) / LaneSize) != (i / LaneSize))
2514 LaneCrossing[(Mask[i] %
Size) / LaneSize] =
true;
2517 if (!LaneCrossing[0] && !LaneCrossing[1])
2521 InLaneMask.
assign(Mask.begin(), Mask.end());
2522 for (
int i = 0; i <
Size; ++i) {
2523 int &M = InLaneMask[i];
2526 if (((M %
Size) / LaneSize) != (i / LaneSize))
2527 M = (M % LaneSize) + ((i / LaneSize) * LaneSize) +
Size;
2532 DAG.
getUNDEF(MVT::v4i64), {2, 3, 0, 1});
2547 "Vector type is unsupported for lasx!");
2549 "Two operands have different types!");
2551 "Unexpected mask size for shuffle!");
2552 assert(Mask.size() % 2 == 0 &&
"Expected even mask size.");
2553 assert(Mask.size() >= 4 &&
"Mask size is less than 4.");
2555 APInt KnownUndef, KnownZero;
2557 APInt Zeroable = KnownUndef | KnownZero;
2625 ArrayRef<int> OrigMask = SVOp->
getMask();
2628 MVT VT =
Op.getSimpleValueType();
2632 bool V1IsUndef = V1.
isUndef();
2633 bool V2IsUndef = V2.
isUndef();
2634 if (V1IsUndef && V2IsUndef)
2647 any_of(OrigMask, [NumElements](
int M) {
return M >= NumElements; })) {
2648 SmallVector<int, 8> NewMask(OrigMask);
2649 for (
int &M : NewMask)
2650 if (M >= NumElements)
2656 int MaskUpperLimit = OrigMask.
size() * (V2IsUndef ? 1 : 2);
2657 (void)MaskUpperLimit;
2659 [&](
int M) {
return -1 <=
M &&
M < MaskUpperLimit; }) &&
2660 "Out of bounds shuffle index");
2682 std::tie(Res, Chain) =
2683 makeLibCall(DAG, LC, MVT::f32, Op0, CallOptions,
DL, Chain);
2684 if (Subtarget.is64Bit())
2701 std::tie(Res, Chain) =
makeLibCall(DAG, RTLIB::FPEXT_F16_F32, MVT::f32, Arg,
2702 CallOptions,
DL, Chain);
2708 assert(Subtarget.hasBasicF() &&
"Unexpected custom legalization");
2714 makeLibCall(DAG, LC, MVT::f32,
Op.getOperand(0), CallOptions,
DL).first;
2715 if (Subtarget.is64Bit())
2722 assert(Subtarget.hasBasicF() &&
"Unexpected custom legalization");
2723 MVT VT =
Op.getSimpleValueType();
2732 return DAG.
getNode(ISD::FP_EXTEND,
DL, VT, Res);
2749 "Unsupported vector type for broadcast.");
2752 bool IsIdeneity =
true;
2754 for (
int i = 0; i !=
NumOps; i++) {
2756 if (
Op.getOpcode() != ISD::LOAD || (IdentitySrc &&
Op != IdentitySrc)) {
2768 auto ExtType = LN->getExtensionType();
2774 ? DAG.
getVTList(VT, LN->getBasePtr().getValueType(), MVT::Other)
2776 SDValue Ops[] = {LN->getChain(), LN->getBasePtr(), LN->getOffset()};
2794 for (
unsigned i = 1; i <
Ops.size(); ++i) {
2808 EVT ResTy,
unsigned first) {
2812 first + NumElts <= Node->getSimpleValueType(0).getVectorNumElements());
2815 Node->op_begin() + first + NumElts);
2824 MVT VT =
Node->getSimpleValueType(0);
2825 EVT ResTy =
Op->getValueType(0);
2828 APInt SplatValue, SplatUndef;
2829 unsigned SplatBitSize;
2832 bool UseSameConstant =
true;
2837 if ((!Subtarget.hasExtLSX() || !Is128Vec) &&
2838 (!Subtarget.hasExtLASX() || !Is256Vec))
2844 if (
Node->isConstantSplat(SplatValue, SplatUndef, SplatBitSize, HasAnyUndefs,
2846 SplatBitSize <= 64) {
2848 if (SplatBitSize != 8 && SplatBitSize != 16 && SplatBitSize != 32 &&
2852 if (SplatBitSize == 64 && !Subtarget.is64Bit()) {
2859 if ((Is128Vec && ResTy == MVT::v4i32) ||
2860 (Is256Vec && ResTy == MVT::v8i32))
2866 switch (SplatBitSize) {
2870 ViaVecTy = Is128Vec ? MVT::v16i8 : MVT::v32i8;
2873 ViaVecTy = Is128Vec ? MVT::v8i16 : MVT::v16i16;
2876 ViaVecTy = Is128Vec ? MVT::v4i32 : MVT::v8i32;
2879 ViaVecTy = Is128Vec ? MVT::v2i64 : MVT::v4i64;
2887 if (ViaVecTy != ResTy)
2888 Result = DAG.
getNode(ISD::BITCAST, SDLoc(Node), ResTy, Result);
2896 for (
unsigned i = 0; i < NumElts; ++i) {
2901 ConstantValue = Opi;
2902 else if (ConstantValue != Opi)
2903 UseSameConstant =
false;
2908 if (IsConstant && UseSameConstant && ResTy != MVT::v2f64) {
2910 for (
unsigned i = 0; i < NumElts; ++i) {
2928 BitVector UndefElements;
2929 if (
Node->getRepeatedSequence(Sequence, &UndefElements) &&
2930 UndefElements.
count() == 0) {
2934 EVT FillTy = Is256Vec
2940 fillVector(Sequence, DAG,
DL, Subtarget, FillVec, FillTy);
2943 unsigned SplatLen = NumElts / SeqLen;
2949 if (SplatEltTy == MVT::i128)
2950 SplatTy = MVT::v4i64;
2960 DL, SplatTy, SrcVec);
2975 if (ResTy == MVT::v8i32 || ResTy == MVT::v8f32 || ResTy == MVT::v4i64 ||
2976 ResTy == MVT::v4f64) {
2977 unsigned NonUndefCount = 0;
2978 for (
unsigned i = NumElts / 2; i < NumElts; ++i) {
2979 if (!
Node->getOperand(i).isUndef()) {
2981 if (NonUndefCount > 1)
2985 if (NonUndefCount == 1)
2998 VecTy, NumElts / 2);
3009 MVT ResVT =
Op.getSimpleValueType();
3013 unsigned NumFreezeUndef = 0;
3014 unsigned NumZero = 0;
3015 unsigned NumNonZero = 0;
3016 unsigned NonZeros = 0;
3017 SmallSet<SDValue, 4> Undefs;
3018 for (
unsigned i = 0; i != NumOperands; ++i) {
3033 assert(i <
sizeof(NonZeros) * CHAR_BIT);
3040 if (NumNonZero > 2) {
3044 Ops.slice(0, NumOperands / 2));
3046 Ops.slice(NumOperands / 2));
3059 MVT SubVT =
Op.getOperand(0).getSimpleValueType();
3061 for (
unsigned i = 0; i != NumOperands; ++i) {
3062 if ((NonZeros & (1 << i)) == 0)
3073LoongArchTargetLowering::lowerEXTRACT_VECTOR_ELT(
SDValue Op,
3075 MVT EltVT =
Op.getSimpleValueType();
3080 MVT GRLenVT = Subtarget.getGRLenVT();
3112 DAG.
getBitcast((VecTy == MVT::v4f64) ? MVT::v4i64 : VecTy, IdxVec);
3132LoongArchTargetLowering::lowerINSERT_VECTOR_ELT(
SDValue Op,
3134 MVT VT =
Op.getSimpleValueType();
3157 if (!Subtarget.is64Bit() && IdxTy == MVT::i64) {
3159 for (
unsigned i = 0; i < NumElts; ++i) {
3167 for (
unsigned i = 0; i < NumElts; ++i) {
3176 for (
unsigned i = 0; i < NumElts; ++i)
3200 return DAG.
getNode(ISD::MEMBARRIER,
DL, MVT::Other,
Op.getOperand(0));
3208 if (Subtarget.is64Bit() &&
Op.getOperand(2).getValueType() == MVT::i32) {
3210 "On LA64, only 64-bit registers can be written.");
3211 return Op.getOperand(0);
3214 if (!Subtarget.is64Bit() &&
Op.getOperand(2).getValueType() == MVT::i64) {
3216 "On LA32, only 32-bit registers can be written.");
3217 return Op.getOperand(0);
3227 "be a constant integer");
3233 Register FrameReg = Subtarget.getRegisterInfo()->getFrameRegister(MF);
3234 EVT VT =
Op.getValueType();
3237 unsigned Depth =
Op.getConstantOperandVal(0);
3238 int GRLenInBytes = Subtarget.getGRLen() / 8;
3241 int Offset = -(GRLenInBytes * 2);
3253 if (
Op.getConstantOperandVal(0) != 0) {
3255 "return address can only be determined for the current frame");
3261 MVT GRLenVT = Subtarget.getGRLenVT();
3273 auto Size = Subtarget.getGRLen() / 8;
3281 auto *FuncInfo = MF.
getInfo<LoongArchMachineFunctionInfo>();
3291 MachinePointerInfo(SV));
3296 assert(Subtarget.is64Bit() && Subtarget.hasBasicF() &&
3297 !Subtarget.hasBasicD() &&
"unexpected target features");
3303 if (
C &&
C->getZExtValue() < UINT64_C(0xFFFFFFFF))
3317 EVT RetVT =
Op.getValueType();
3323 std::tie(Result, Chain) =
3330 assert(Subtarget.is64Bit() && Subtarget.hasBasicF() &&
3331 !Subtarget.hasBasicD() &&
"unexpected target features");
3342 EVT RetVT =
Op.getValueType();
3348 std::tie(Result, Chain) =
3357 EVT VT =
Op.getValueType();
3361 if (
Op.getValueType() == MVT::f32 && Op0VT == MVT::i32 &&
3362 Subtarget.is64Bit() && Subtarget.hasBasicF()) {
3366 if (VT == MVT::f64 && Op0VT == MVT::i64 && !Subtarget.is64Bit()) {
3381 Op0 = DAG.
getNode(ISD::FP_EXTEND,
DL, MVT::f32, Op0);
3383 if (
Op.getValueSizeInBits() > 32 && Subtarget.hasBasicF() &&
3384 !Subtarget.hasBasicD()) {
3391 return DAG.
getNode(ISD::BITCAST,
DL,
Op.getValueType(), Trunc);
3408 N->getOffset(), Flags);
3416template <
class NodeTy>
3419 bool IsLocal)
const {
3430 assert(Subtarget.is64Bit() &&
"Large code model requires LA64");
3501 assert(
N->getOffset() == 0 &&
"unexpected offset in global node");
3503 const GlobalValue *GV =
N->getGlobal();
3515 unsigned Opc,
bool UseGOT,
3519 MVT GRLenVT = Subtarget.getGRLenVT();
3533 if (
Opc == LoongArch::PseudoLA_TLS_LE && !Large)
3571 Args.emplace_back(Load, CallTy);
3574 TargetLowering::CallLoweringInfo CLI(DAG);
3589 const GlobalValue *GV =
N->getGlobal();
3603LoongArchTargetLowering::lowerGlobalTLSAddress(
SDValue Op,
3610 assert((!Large || Subtarget.is64Bit()) &&
"Large code model requires LA64");
3613 assert(
N->getOffset() == 0 &&
"unexpected offset in global node");
3626 return getDynamicTLSAddr(
N, DAG,
3627 Large ? LoongArch::PseudoLA_TLS_GD_LARGE
3628 : LoongArch::PseudoLA_TLS_GD,
3635 return getDynamicTLSAddr(
N, DAG,
3636 Large ? LoongArch::PseudoLA_TLS_LD_LARGE
3637 : LoongArch::PseudoLA_TLS_LD,
3642 return getStaticTLSAddr(
N, DAG,
3643 Large ? LoongArch::PseudoLA_TLS_IE_LARGE
3644 : LoongArch::PseudoLA_TLS_IE,
3651 return getStaticTLSAddr(
N, DAG, LoongArch::PseudoLA_TLS_LE,
3655 return getTLSDescAddr(
N, DAG,
3656 Large ? LoongArch::PseudoLA_TLS_DESC_LARGE
3657 : LoongArch::PseudoLA_TLS_DESC,
3661template <
unsigned N>
3666 if ((IsSigned && !
isInt<N>(CImm->getSExtValue())) ||
3667 (!IsSigned && !
isUInt<N>(CImm->getZExtValue()))) {
3669 ": argument out of range.");
3676LoongArchTargetLowering::lowerINTRINSIC_WO_CHAIN(
SDValue Op,
3678 switch (
Op.getConstantOperandVal(0)) {
3681 case Intrinsic::thread_pointer: {
3685 case Intrinsic::loongarch_lsx_vpickve2gr_d:
3686 case Intrinsic::loongarch_lsx_vpickve2gr_du:
3687 case Intrinsic::loongarch_lsx_vreplvei_d:
3688 case Intrinsic::loongarch_lasx_xvrepl128vei_d:
3690 case Intrinsic::loongarch_lsx_vreplvei_w:
3691 case Intrinsic::loongarch_lasx_xvrepl128vei_w:
3692 case Intrinsic::loongarch_lasx_xvpickve2gr_d:
3693 case Intrinsic::loongarch_lasx_xvpickve2gr_du:
3694 case Intrinsic::loongarch_lasx_xvpickve_d:
3695 case Intrinsic::loongarch_lasx_xvpickve_d_f:
3697 case Intrinsic::loongarch_lasx_xvinsve0_d:
3699 case Intrinsic::loongarch_lsx_vsat_b:
3700 case Intrinsic::loongarch_lsx_vsat_bu:
3701 case Intrinsic::loongarch_lsx_vrotri_b:
3702 case Intrinsic::loongarch_lsx_vsllwil_h_b:
3703 case Intrinsic::loongarch_lsx_vsllwil_hu_bu:
3704 case Intrinsic::loongarch_lsx_vsrlri_b:
3705 case Intrinsic::loongarch_lsx_vsrari_b:
3706 case Intrinsic::loongarch_lsx_vreplvei_h:
3707 case Intrinsic::loongarch_lasx_xvsat_b:
3708 case Intrinsic::loongarch_lasx_xvsat_bu:
3709 case Intrinsic::loongarch_lasx_xvrotri_b:
3710 case Intrinsic::loongarch_lasx_xvsllwil_h_b:
3711 case Intrinsic::loongarch_lasx_xvsllwil_hu_bu:
3712 case Intrinsic::loongarch_lasx_xvsrlri_b:
3713 case Intrinsic::loongarch_lasx_xvsrari_b:
3714 case Intrinsic::loongarch_lasx_xvrepl128vei_h:
3715 case Intrinsic::loongarch_lasx_xvpickve_w:
3716 case Intrinsic::loongarch_lasx_xvpickve_w_f:
3718 case Intrinsic::loongarch_lasx_xvinsve0_w:
3720 case Intrinsic::loongarch_lsx_vsat_h:
3721 case Intrinsic::loongarch_lsx_vsat_hu:
3722 case Intrinsic::loongarch_lsx_vrotri_h:
3723 case Intrinsic::loongarch_lsx_vsllwil_w_h:
3724 case Intrinsic::loongarch_lsx_vsllwil_wu_hu:
3725 case Intrinsic::loongarch_lsx_vsrlri_h:
3726 case Intrinsic::loongarch_lsx_vsrari_h:
3727 case Intrinsic::loongarch_lsx_vreplvei_b:
3728 case Intrinsic::loongarch_lasx_xvsat_h:
3729 case Intrinsic::loongarch_lasx_xvsat_hu:
3730 case Intrinsic::loongarch_lasx_xvrotri_h:
3731 case Intrinsic::loongarch_lasx_xvsllwil_w_h:
3732 case Intrinsic::loongarch_lasx_xvsllwil_wu_hu:
3733 case Intrinsic::loongarch_lasx_xvsrlri_h:
3734 case Intrinsic::loongarch_lasx_xvsrari_h:
3735 case Intrinsic::loongarch_lasx_xvrepl128vei_b:
3737 case Intrinsic::loongarch_lsx_vsrlni_b_h:
3738 case Intrinsic::loongarch_lsx_vsrani_b_h:
3739 case Intrinsic::loongarch_lsx_vsrlrni_b_h:
3740 case Intrinsic::loongarch_lsx_vsrarni_b_h:
3741 case Intrinsic::loongarch_lsx_vssrlni_b_h:
3742 case Intrinsic::loongarch_lsx_vssrani_b_h:
3743 case Intrinsic::loongarch_lsx_vssrlni_bu_h:
3744 case Intrinsic::loongarch_lsx_vssrani_bu_h:
3745 case Intrinsic::loongarch_lsx_vssrlrni_b_h:
3746 case Intrinsic::loongarch_lsx_vssrarni_b_h:
3747 case Intrinsic::loongarch_lsx_vssrlrni_bu_h:
3748 case Intrinsic::loongarch_lsx_vssrarni_bu_h:
3749 case Intrinsic::loongarch_lasx_xvsrlni_b_h:
3750 case Intrinsic::loongarch_lasx_xvsrani_b_h:
3751 case Intrinsic::loongarch_lasx_xvsrlrni_b_h:
3752 case Intrinsic::loongarch_lasx_xvsrarni_b_h:
3753 case Intrinsic::loongarch_lasx_xvssrlni_b_h:
3754 case Intrinsic::loongarch_lasx_xvssrani_b_h:
3755 case Intrinsic::loongarch_lasx_xvssrlni_bu_h:
3756 case Intrinsic::loongarch_lasx_xvssrani_bu_h:
3757 case Intrinsic::loongarch_lasx_xvssrlrni_b_h:
3758 case Intrinsic::loongarch_lasx_xvssrarni_b_h:
3759 case Intrinsic::loongarch_lasx_xvssrlrni_bu_h:
3760 case Intrinsic::loongarch_lasx_xvssrarni_bu_h:
3762 case Intrinsic::loongarch_lsx_vsat_w:
3763 case Intrinsic::loongarch_lsx_vsat_wu:
3764 case Intrinsic::loongarch_lsx_vrotri_w:
3765 case Intrinsic::loongarch_lsx_vsllwil_d_w:
3766 case Intrinsic::loongarch_lsx_vsllwil_du_wu:
3767 case Intrinsic::loongarch_lsx_vsrlri_w:
3768 case Intrinsic::loongarch_lsx_vsrari_w:
3769 case Intrinsic::loongarch_lsx_vslei_bu:
3770 case Intrinsic::loongarch_lsx_vslei_hu:
3771 case Intrinsic::loongarch_lsx_vslei_wu:
3772 case Intrinsic::loongarch_lsx_vslei_du:
3773 case Intrinsic::loongarch_lsx_vslti_bu:
3774 case Intrinsic::loongarch_lsx_vslti_hu:
3775 case Intrinsic::loongarch_lsx_vslti_wu:
3776 case Intrinsic::loongarch_lsx_vslti_du:
3777 case Intrinsic::loongarch_lsx_vbsll_v:
3778 case Intrinsic::loongarch_lsx_vbsrl_v:
3779 case Intrinsic::loongarch_lasx_xvsat_w:
3780 case Intrinsic::loongarch_lasx_xvsat_wu:
3781 case Intrinsic::loongarch_lasx_xvrotri_w:
3782 case Intrinsic::loongarch_lasx_xvsllwil_d_w:
3783 case Intrinsic::loongarch_lasx_xvsllwil_du_wu:
3784 case Intrinsic::loongarch_lasx_xvsrlri_w:
3785 case Intrinsic::loongarch_lasx_xvsrari_w:
3786 case Intrinsic::loongarch_lasx_xvslei_bu:
3787 case Intrinsic::loongarch_lasx_xvslei_hu:
3788 case Intrinsic::loongarch_lasx_xvslei_wu:
3789 case Intrinsic::loongarch_lasx_xvslei_du:
3790 case Intrinsic::loongarch_lasx_xvslti_bu:
3791 case Intrinsic::loongarch_lasx_xvslti_hu:
3792 case Intrinsic::loongarch_lasx_xvslti_wu:
3793 case Intrinsic::loongarch_lasx_xvslti_du:
3794 case Intrinsic::loongarch_lasx_xvbsll_v:
3795 case Intrinsic::loongarch_lasx_xvbsrl_v:
3797 case Intrinsic::loongarch_lsx_vseqi_b:
3798 case Intrinsic::loongarch_lsx_vseqi_h:
3799 case Intrinsic::loongarch_lsx_vseqi_w:
3800 case Intrinsic::loongarch_lsx_vseqi_d:
3801 case Intrinsic::loongarch_lsx_vslei_b:
3802 case Intrinsic::loongarch_lsx_vslei_h:
3803 case Intrinsic::loongarch_lsx_vslei_w:
3804 case Intrinsic::loongarch_lsx_vslei_d:
3805 case Intrinsic::loongarch_lsx_vslti_b:
3806 case Intrinsic::loongarch_lsx_vslti_h:
3807 case Intrinsic::loongarch_lsx_vslti_w:
3808 case Intrinsic::loongarch_lsx_vslti_d:
3809 case Intrinsic::loongarch_lasx_xvseqi_b:
3810 case Intrinsic::loongarch_lasx_xvseqi_h:
3811 case Intrinsic::loongarch_lasx_xvseqi_w:
3812 case Intrinsic::loongarch_lasx_xvseqi_d:
3813 case Intrinsic::loongarch_lasx_xvslei_b:
3814 case Intrinsic::loongarch_lasx_xvslei_h:
3815 case Intrinsic::loongarch_lasx_xvslei_w:
3816 case Intrinsic::loongarch_lasx_xvslei_d:
3817 case Intrinsic::loongarch_lasx_xvslti_b:
3818 case Intrinsic::loongarch_lasx_xvslti_h:
3819 case Intrinsic::loongarch_lasx_xvslti_w:
3820 case Intrinsic::loongarch_lasx_xvslti_d:
3822 case Intrinsic::loongarch_lsx_vsrlni_h_w:
3823 case Intrinsic::loongarch_lsx_vsrani_h_w:
3824 case Intrinsic::loongarch_lsx_vsrlrni_h_w:
3825 case Intrinsic::loongarch_lsx_vsrarni_h_w:
3826 case Intrinsic::loongarch_lsx_vssrlni_h_w:
3827 case Intrinsic::loongarch_lsx_vssrani_h_w:
3828 case Intrinsic::loongarch_lsx_vssrlni_hu_w:
3829 case Intrinsic::loongarch_lsx_vssrani_hu_w:
3830 case Intrinsic::loongarch_lsx_vssrlrni_h_w:
3831 case Intrinsic::loongarch_lsx_vssrarni_h_w:
3832 case Intrinsic::loongarch_lsx_vssrlrni_hu_w:
3833 case Intrinsic::loongarch_lsx_vssrarni_hu_w:
3834 case Intrinsic::loongarch_lsx_vfrstpi_b:
3835 case Intrinsic::loongarch_lsx_vfrstpi_h:
3836 case Intrinsic::loongarch_lasx_xvsrlni_h_w:
3837 case Intrinsic::loongarch_lasx_xvsrani_h_w:
3838 case Intrinsic::loongarch_lasx_xvsrlrni_h_w:
3839 case Intrinsic::loongarch_lasx_xvsrarni_h_w:
3840 case Intrinsic::loongarch_lasx_xvssrlni_h_w:
3841 case Intrinsic::loongarch_lasx_xvssrani_h_w:
3842 case Intrinsic::loongarch_lasx_xvssrlni_hu_w:
3843 case Intrinsic::loongarch_lasx_xvssrani_hu_w:
3844 case Intrinsic::loongarch_lasx_xvssrlrni_h_w:
3845 case Intrinsic::loongarch_lasx_xvssrarni_h_w:
3846 case Intrinsic::loongarch_lasx_xvssrlrni_hu_w:
3847 case Intrinsic::loongarch_lasx_xvssrarni_hu_w:
3848 case Intrinsic::loongarch_lasx_xvfrstpi_b:
3849 case Intrinsic::loongarch_lasx_xvfrstpi_h:
3851 case Intrinsic::loongarch_lsx_vsat_d:
3852 case Intrinsic::loongarch_lsx_vsat_du:
3853 case Intrinsic::loongarch_lsx_vrotri_d:
3854 case Intrinsic::loongarch_lsx_vsrlri_d:
3855 case Intrinsic::loongarch_lsx_vsrari_d:
3856 case Intrinsic::loongarch_lasx_xvsat_d:
3857 case Intrinsic::loongarch_lasx_xvsat_du:
3858 case Intrinsic::loongarch_lasx_xvrotri_d:
3859 case Intrinsic::loongarch_lasx_xvsrlri_d:
3860 case Intrinsic::loongarch_lasx_xvsrari_d:
3862 case Intrinsic::loongarch_lsx_vsrlni_w_d:
3863 case Intrinsic::loongarch_lsx_vsrani_w_d:
3864 case Intrinsic::loongarch_lsx_vsrlrni_w_d:
3865 case Intrinsic::loongarch_lsx_vsrarni_w_d:
3866 case Intrinsic::loongarch_lsx_vssrlni_w_d:
3867 case Intrinsic::loongarch_lsx_vssrani_w_d:
3868 case Intrinsic::loongarch_lsx_vssrlni_wu_d:
3869 case Intrinsic::loongarch_lsx_vssrani_wu_d:
3870 case Intrinsic::loongarch_lsx_vssrlrni_w_d:
3871 case Intrinsic::loongarch_lsx_vssrarni_w_d:
3872 case Intrinsic::loongarch_lsx_vssrlrni_wu_d:
3873 case Intrinsic::loongarch_lsx_vssrarni_wu_d:
3874 case Intrinsic::loongarch_lasx_xvsrlni_w_d:
3875 case Intrinsic::loongarch_lasx_xvsrani_w_d:
3876 case Intrinsic::loongarch_lasx_xvsrlrni_w_d:
3877 case Intrinsic::loongarch_lasx_xvsrarni_w_d:
3878 case Intrinsic::loongarch_lasx_xvssrlni_w_d:
3879 case Intrinsic::loongarch_lasx_xvssrani_w_d:
3880 case Intrinsic::loongarch_lasx_xvssrlni_wu_d:
3881 case Intrinsic::loongarch_lasx_xvssrani_wu_d:
3882 case Intrinsic::loongarch_lasx_xvssrlrni_w_d:
3883 case Intrinsic::loongarch_lasx_xvssrarni_w_d:
3884 case Intrinsic::loongarch_lasx_xvssrlrni_wu_d:
3885 case Intrinsic::loongarch_lasx_xvssrarni_wu_d:
3887 case Intrinsic::loongarch_lsx_vsrlni_d_q:
3888 case Intrinsic::loongarch_lsx_vsrani_d_q:
3889 case Intrinsic::loongarch_lsx_vsrlrni_d_q:
3890 case Intrinsic::loongarch_lsx_vsrarni_d_q:
3891 case Intrinsic::loongarch_lsx_vssrlni_d_q:
3892 case Intrinsic::loongarch_lsx_vssrani_d_q:
3893 case Intrinsic::loongarch_lsx_vssrlni_du_q:
3894 case Intrinsic::loongarch_lsx_vssrani_du_q:
3895 case Intrinsic::loongarch_lsx_vssrlrni_d_q:
3896 case Intrinsic::loongarch_lsx_vssrarni_d_q:
3897 case Intrinsic::loongarch_lsx_vssrlrni_du_q:
3898 case Intrinsic::loongarch_lsx_vssrarni_du_q:
3899 case Intrinsic::loongarch_lasx_xvsrlni_d_q:
3900 case Intrinsic::loongarch_lasx_xvsrani_d_q:
3901 case Intrinsic::loongarch_lasx_xvsrlrni_d_q:
3902 case Intrinsic::loongarch_lasx_xvsrarni_d_q:
3903 case Intrinsic::loongarch_lasx_xvssrlni_d_q:
3904 case Intrinsic::loongarch_lasx_xvssrani_d_q:
3905 case Intrinsic::loongarch_lasx_xvssrlni_du_q:
3906 case Intrinsic::loongarch_lasx_xvssrani_du_q:
3907 case Intrinsic::loongarch_lasx_xvssrlrni_d_q:
3908 case Intrinsic::loongarch_lasx_xvssrarni_d_q:
3909 case Intrinsic::loongarch_lasx_xvssrlrni_du_q:
3910 case Intrinsic::loongarch_lasx_xvssrarni_du_q:
3912 case Intrinsic::loongarch_lsx_vnori_b:
3913 case Intrinsic::loongarch_lsx_vshuf4i_b:
3914 case Intrinsic::loongarch_lsx_vshuf4i_h:
3915 case Intrinsic::loongarch_lsx_vshuf4i_w:
3916 case Intrinsic::loongarch_lasx_xvnori_b:
3917 case Intrinsic::loongarch_lasx_xvshuf4i_b:
3918 case Intrinsic::loongarch_lasx_xvshuf4i_h:
3919 case Intrinsic::loongarch_lasx_xvshuf4i_w:
3920 case Intrinsic::loongarch_lasx_xvpermi_d:
3922 case Intrinsic::loongarch_lsx_vshuf4i_d:
3923 case Intrinsic::loongarch_lsx_vpermi_w:
3924 case Intrinsic::loongarch_lsx_vbitseli_b:
3925 case Intrinsic::loongarch_lsx_vextrins_b:
3926 case Intrinsic::loongarch_lsx_vextrins_h:
3927 case Intrinsic::loongarch_lsx_vextrins_w:
3928 case Intrinsic::loongarch_lsx_vextrins_d:
3929 case Intrinsic::loongarch_lasx_xvshuf4i_d:
3930 case Intrinsic::loongarch_lasx_xvpermi_w:
3931 case Intrinsic::loongarch_lasx_xvpermi_q:
3932 case Intrinsic::loongarch_lasx_xvbitseli_b:
3933 case Intrinsic::loongarch_lasx_xvextrins_b:
3934 case Intrinsic::loongarch_lasx_xvextrins_h:
3935 case Intrinsic::loongarch_lasx_xvextrins_w:
3936 case Intrinsic::loongarch_lasx_xvextrins_d:
3938 case Intrinsic::loongarch_lsx_vrepli_b:
3939 case Intrinsic::loongarch_lsx_vrepli_h:
3940 case Intrinsic::loongarch_lsx_vrepli_w:
3941 case Intrinsic::loongarch_lsx_vrepli_d:
3942 case Intrinsic::loongarch_lasx_xvrepli_b:
3943 case Intrinsic::loongarch_lasx_xvrepli_h:
3944 case Intrinsic::loongarch_lasx_xvrepli_w:
3945 case Intrinsic::loongarch_lasx_xvrepli_d:
3947 case Intrinsic::loongarch_lsx_vldi:
3948 case Intrinsic::loongarch_lasx_xvldi:
3964LoongArchTargetLowering::lowerINTRINSIC_W_CHAIN(
SDValue Op,
3967 MVT GRLenVT = Subtarget.getGRLenVT();
3968 EVT VT =
Op.getValueType();
3970 const StringRef ErrorMsgOOR =
"argument out of range";
3971 const StringRef ErrorMsgReqLA64 =
"requires loongarch64";
3972 const StringRef ErrorMsgReqF =
"requires basic 'f' target feature";
3974 switch (
Op.getConstantOperandVal(1)) {
3977 case Intrinsic::loongarch_crc_w_b_w:
3978 case Intrinsic::loongarch_crc_w_h_w:
3979 case Intrinsic::loongarch_crc_w_w_w:
3980 case Intrinsic::loongarch_crc_w_d_w:
3981 case Intrinsic::loongarch_crcc_w_b_w:
3982 case Intrinsic::loongarch_crcc_w_h_w:
3983 case Intrinsic::loongarch_crcc_w_w_w:
3984 case Intrinsic::loongarch_crcc_w_d_w:
3986 case Intrinsic::loongarch_csrrd_w:
3987 case Intrinsic::loongarch_csrrd_d: {
3988 unsigned Imm =
Op.getConstantOperandVal(2);
3994 case Intrinsic::loongarch_csrwr_w:
3995 case Intrinsic::loongarch_csrwr_d: {
3996 unsigned Imm =
Op.getConstantOperandVal(3);
4000 {Chain,
Op.getOperand(2),
4003 case Intrinsic::loongarch_csrxchg_w:
4004 case Intrinsic::loongarch_csrxchg_d: {
4005 unsigned Imm =
Op.getConstantOperandVal(4);
4009 {Chain,
Op.getOperand(2),
Op.getOperand(3),
4012 case Intrinsic::loongarch_iocsrrd_d: {
4017#define IOCSRRD_CASE(NAME, NODE) \
4018 case Intrinsic::loongarch_##NAME: { \
4019 return DAG.getNode(LoongArchISD::NODE, DL, {GRLenVT, MVT::Other}, \
4020 {Chain, Op.getOperand(2)}); \
4026 case Intrinsic::loongarch_cpucfg: {
4028 {Chain,
Op.getOperand(2)});
4030 case Intrinsic::loongarch_lddir_d: {
4031 unsigned Imm =
Op.getConstantOperandVal(3);
4036 case Intrinsic::loongarch_movfcsr2gr: {
4037 if (!Subtarget.hasBasicF())
4039 unsigned Imm =
Op.getConstantOperandVal(2);
4045 case Intrinsic::loongarch_lsx_vld:
4046 case Intrinsic::loongarch_lsx_vldrepl_b:
4047 case Intrinsic::loongarch_lasx_xvld:
4048 case Intrinsic::loongarch_lasx_xvldrepl_b:
4052 case Intrinsic::loongarch_lsx_vldrepl_h:
4053 case Intrinsic::loongarch_lasx_xvldrepl_h:
4057 Op,
"argument out of range or not a multiple of 2", DAG)
4059 case Intrinsic::loongarch_lsx_vldrepl_w:
4060 case Intrinsic::loongarch_lasx_xvldrepl_w:
4064 Op,
"argument out of range or not a multiple of 4", DAG)
4066 case Intrinsic::loongarch_lsx_vldrepl_d:
4067 case Intrinsic::loongarch_lasx_xvldrepl_d:
4071 Op,
"argument out of range or not a multiple of 8", DAG)
4082 return Op.getOperand(0);
4088 MVT GRLenVT = Subtarget.getGRLenVT();
4090 uint64_t IntrinsicEnum =
Op.getConstantOperandVal(1);
4092 const StringRef ErrorMsgOOR =
"argument out of range";
4093 const StringRef ErrorMsgReqLA64 =
"requires loongarch64";
4094 const StringRef ErrorMsgReqLA32 =
"requires loongarch32";
4095 const StringRef ErrorMsgReqF =
"requires basic 'f' target feature";
4097 switch (IntrinsicEnum) {
4101 case Intrinsic::loongarch_cacop_d:
4102 case Intrinsic::loongarch_cacop_w: {
4103 if (IntrinsicEnum == Intrinsic::loongarch_cacop_d && !Subtarget.is64Bit())
4105 if (IntrinsicEnum == Intrinsic::loongarch_cacop_w && Subtarget.is64Bit())
4114 case Intrinsic::loongarch_dbar: {
4121 case Intrinsic::loongarch_ibar: {
4128 case Intrinsic::loongarch_break: {
4135 case Intrinsic::loongarch_movgr2fcsr: {
4136 if (!Subtarget.hasBasicF())
4146 case Intrinsic::loongarch_syscall: {
4153#define IOCSRWR_CASE(NAME, NODE) \
4154 case Intrinsic::loongarch_##NAME: { \
4155 SDValue Op3 = Op.getOperand(3); \
4156 return Subtarget.is64Bit() \
4157 ? DAG.getNode(LoongArchISD::NODE, DL, MVT::Other, Chain, \
4158 DAG.getNode(ISD::ANY_EXTEND, DL, MVT::i64, Op2), \
4159 DAG.getNode(ISD::ANY_EXTEND, DL, MVT::i64, Op3)) \
4160 : DAG.getNode(LoongArchISD::NODE, DL, MVT::Other, Chain, Op2, \
4167 case Intrinsic::loongarch_iocsrwr_d: {
4168 return !Subtarget.is64Bit()
4175#define ASRT_LE_GT_CASE(NAME) \
4176 case Intrinsic::loongarch_##NAME: { \
4177 return !Subtarget.is64Bit() \
4178 ? emitIntrinsicErrorMessage(Op, ErrorMsgReqLA64, DAG) \
4183#undef ASRT_LE_GT_CASE
4184 case Intrinsic::loongarch_ldpte_d: {
4185 unsigned Imm =
Op.getConstantOperandVal(3);
4186 return !Subtarget.is64Bit()
4191 case Intrinsic::loongarch_lsx_vst:
4192 case Intrinsic::loongarch_lasx_xvst:
4196 case Intrinsic::loongarch_lasx_xvstelm_b:
4201 case Intrinsic::loongarch_lsx_vstelm_b:
4206 case Intrinsic::loongarch_lasx_xvstelm_h:
4211 Op,
"argument out of range or not a multiple of 2", DAG)
4213 case Intrinsic::loongarch_lsx_vstelm_h:
4218 Op,
"argument out of range or not a multiple of 2", DAG)
4220 case Intrinsic::loongarch_lasx_xvstelm_w:
4225 Op,
"argument out of range or not a multiple of 4", DAG)
4227 case Intrinsic::loongarch_lsx_vstelm_w:
4232 Op,
"argument out of range or not a multiple of 4", DAG)
4234 case Intrinsic::loongarch_lasx_xvstelm_d:
4239 Op,
"argument out of range or not a multiple of 8", DAG)
4241 case Intrinsic::loongarch_lsx_vstelm_d:
4246 Op,
"argument out of range or not a multiple of 8", DAG)
4257 EVT VT =
Lo.getValueType();
4298 EVT VT =
Lo.getValueType();
4390 NewOp0 = DAG.
getNode(ExtOpc,
DL, MVT::i64,
N->getOperand(0));
4391 NewRes = DAG.
getNode(WOpcode,
DL, MVT::i64, NewOp0);
4395 NewOp0 = DAG.
getNode(ExtOpc,
DL, MVT::i64,
N->getOperand(0));
4401 NewRes = DAG.
getNode(WOpcode,
DL, MVT::i64, NewOp0, NewOp1);
4428 StringRef ErrorMsg,
bool WithChain =
true) {
4433 Results.push_back(
N->getOperand(0));
4436template <
unsigned N>
4441 const StringRef ErrorMsgOOR =
"argument out of range";
4442 unsigned Imm =
Node->getConstantOperandVal(2);
4476 switch (
N->getConstantOperandVal(0)) {
4479 case Intrinsic::loongarch_lsx_vpickve2gr_b:
4483 case Intrinsic::loongarch_lsx_vpickve2gr_h:
4484 case Intrinsic::loongarch_lasx_xvpickve2gr_w:
4488 case Intrinsic::loongarch_lsx_vpickve2gr_w:
4492 case Intrinsic::loongarch_lsx_vpickve2gr_bu:
4496 case Intrinsic::loongarch_lsx_vpickve2gr_hu:
4497 case Intrinsic::loongarch_lasx_xvpickve2gr_wu:
4501 case Intrinsic::loongarch_lsx_vpickve2gr_wu:
4505 case Intrinsic::loongarch_lsx_bz_b:
4506 case Intrinsic::loongarch_lsx_bz_h:
4507 case Intrinsic::loongarch_lsx_bz_w:
4508 case Intrinsic::loongarch_lsx_bz_d:
4509 case Intrinsic::loongarch_lasx_xbz_b:
4510 case Intrinsic::loongarch_lasx_xbz_h:
4511 case Intrinsic::loongarch_lasx_xbz_w:
4512 case Intrinsic::loongarch_lasx_xbz_d:
4516 case Intrinsic::loongarch_lsx_bz_v:
4517 case Intrinsic::loongarch_lasx_xbz_v:
4521 case Intrinsic::loongarch_lsx_bnz_b:
4522 case Intrinsic::loongarch_lsx_bnz_h:
4523 case Intrinsic::loongarch_lsx_bnz_w:
4524 case Intrinsic::loongarch_lsx_bnz_d:
4525 case Intrinsic::loongarch_lasx_xbnz_b:
4526 case Intrinsic::loongarch_lasx_xbnz_h:
4527 case Intrinsic::loongarch_lasx_xbnz_w:
4528 case Intrinsic::loongarch_lasx_xbnz_d:
4532 case Intrinsic::loongarch_lsx_bnz_v:
4533 case Intrinsic::loongarch_lasx_xbnz_v:
4543 assert(
N->getValueType(0) == MVT::i128 &&
4544 "AtomicCmpSwap on types less than 128 should be legal");
4548 switch (
MemOp->getMergedOrdering()) {
4552 Opcode = LoongArch::PseudoCmpXchg128Acquire;
4556 Opcode = LoongArch::PseudoCmpXchg128;
4563 auto CmpVal = DAG.
SplitScalar(
N->getOperand(2),
DL, MVT::i64, MVT::i64);
4564 auto NewVal = DAG.
SplitScalar(
N->getOperand(3),
DL, MVT::i64, MVT::i64);
4565 SDValue Ops[] = {
N->getOperand(1), CmpVal.first, CmpVal.second,
4566 NewVal.first, NewVal.second,
N->getOperand(0)};
4569 Opcode,
SDLoc(
N), DAG.
getVTList(MVT::i64, MVT::i64, MVT::i64, MVT::Other),
4580 EVT VT =
N->getValueType(0);
4581 switch (
N->getOpcode()) {
4586 assert(
N->getValueType(0) == MVT::i32 && Subtarget.is64Bit() &&
4587 "Unexpected custom legalisation");
4594 assert(VT == MVT::i32 && Subtarget.is64Bit() &&
4595 "Unexpected custom legalisation");
4597 Subtarget.hasDiv32() && VT == MVT::i32
4604 assert(VT == MVT::i32 && Subtarget.is64Bit() &&
4605 "Unexpected custom legalisation");
4613 assert(VT == MVT::i32 && Subtarget.is64Bit() &&
4614 "Unexpected custom legalisation");
4618 assert(VT == MVT::i32 && Subtarget.is64Bit() &&
4619 "Unexpected custom legalisation");
4626 if (Src.getValueType() == MVT::f16)
4627 Src = DAG.
getNode(ISD::FP_EXTEND,
DL, MVT::f32, Src);
4637 EVT OpVT = Src.getValueType();
4641 std::tie(Result, Chain) =
4646 case ISD::BITCAST: {
4648 EVT SrcVT = Src.getValueType();
4649 if (VT == MVT::i32 && SrcVT == MVT::f32 && Subtarget.is64Bit() &&
4650 Subtarget.hasBasicF()) {
4654 }
else if (VT == MVT::i64 && SrcVT == MVT::f64 && !Subtarget.is64Bit()) {
4656 DAG.
getVTList(MVT::i32, MVT::i32), Src);
4664 assert(VT == MVT::i32 && Subtarget.is64Bit() &&
4665 "Unexpected custom legalisation");
4668 TLI.expandFP_TO_UINT(
N, Tmp1, Tmp2, DAG);
4674 assert((VT == MVT::i16 || VT == MVT::i32) &&
4675 "Unexpected custom legalization");
4676 MVT GRLenVT = Subtarget.getGRLenVT();
4696 assert((VT == MVT::i8 || (VT == MVT::i32 && Subtarget.is64Bit())) &&
4697 "Unexpected custom legalization");
4698 MVT GRLenVT = Subtarget.getGRLenVT();
4716 assert(VT == MVT::i32 && Subtarget.is64Bit() &&
4717 "Unexpected custom legalisation");
4724 MVT GRLenVT = Subtarget.getGRLenVT();
4725 const StringRef ErrorMsgOOR =
"argument out of range";
4726 const StringRef ErrorMsgReqLA64 =
"requires loongarch64";
4727 const StringRef ErrorMsgReqF =
"requires basic 'f' target feature";
4729 switch (
N->getConstantOperandVal(1)) {
4732 case Intrinsic::loongarch_movfcsr2gr: {
4733 if (!Subtarget.hasBasicF()) {
4750#define CRC_CASE_EXT_BINARYOP(NAME, NODE) \
4751 case Intrinsic::loongarch_##NAME: { \
4752 SDValue NODE = DAG.getNode( \
4753 LoongArchISD::NODE, DL, {MVT::i64, MVT::Other}, \
4754 {Chain, DAG.getNode(ISD::ANY_EXTEND, DL, MVT::i64, Op2), \
4755 DAG.getNode(ISD::ANY_EXTEND, DL, MVT::i64, N->getOperand(3))}); \
4756 Results.push_back(DAG.getNode(ISD::TRUNCATE, DL, VT, NODE.getValue(0))); \
4757 Results.push_back(NODE.getValue(1)); \
4766#undef CRC_CASE_EXT_BINARYOP
4768#define CRC_CASE_EXT_UNARYOP(NAME, NODE) \
4769 case Intrinsic::loongarch_##NAME: { \
4770 SDValue NODE = DAG.getNode( \
4771 LoongArchISD::NODE, DL, {MVT::i64, MVT::Other}, \
4773 DAG.getNode(ISD::ANY_EXTEND, DL, MVT::i64, N->getOperand(3))}); \
4774 Results.push_back(DAG.getNode(ISD::TRUNCATE, DL, VT, NODE.getValue(0))); \
4775 Results.push_back(NODE.getValue(1)); \
4780#undef CRC_CASE_EXT_UNARYOP
4781#define CSR_CASE(ID) \
4782 case Intrinsic::loongarch_##ID: { \
4783 if (!Subtarget.is64Bit()) \
4784 emitErrorAndReplaceIntrinsicResults(N, Results, DAG, ErrorMsgReqLA64); \
4792 case Intrinsic::loongarch_csrrd_w: {
4806 case Intrinsic::loongarch_csrwr_w: {
4807 unsigned Imm =
N->getConstantOperandVal(3);
4821 case Intrinsic::loongarch_csrxchg_w: {
4822 unsigned Imm =
N->getConstantOperandVal(4);
4837#define IOCSRRD_CASE(NAME, NODE) \
4838 case Intrinsic::loongarch_##NAME: { \
4839 SDValue IOCSRRDResults = \
4840 DAG.getNode(LoongArchISD::NODE, DL, {MVT::i64, MVT::Other}, \
4841 {Chain, DAG.getNode(ISD::ANY_EXTEND, DL, MVT::i64, Op2)}); \
4842 Results.push_back( \
4843 DAG.getNode(ISD::TRUNCATE, DL, VT, IOCSRRDResults.getValue(0))); \
4844 Results.push_back(IOCSRRDResults.getValue(1)); \
4851 case Intrinsic::loongarch_cpucfg: {
4860 case Intrinsic::loongarch_lddir_d: {
4861 if (!Subtarget.is64Bit()) {
4871 if (Subtarget.is64Bit())
4873 "On LA64, only 64-bit registers can be read.");
4876 "On LA32, only 32-bit registers can be read.");
4878 Results.push_back(
N->getOperand(0));
4889 OpVT == MVT::f64 ? RTLIB::LROUND_F64 : RTLIB::LROUND_F32;
4897 case ISD::ATOMIC_CMP_SWAP: {
4902 MVT VT =
N->getSimpleValueType(0);
4908 EVT InVT = In.getValueType();
4919 for (
unsigned I = 0;
I < MinElts; ++
I)
4920 TruncMask[
I] = Scale *
I;
4922 unsigned WidenNumElts = 128 / In.getScalarValueSizeInBits();
4923 MVT SVT = In.getSimpleValueType().getScalarType();
4929 "Illegal vector type in truncation");
4948 SDValue FirstOperand =
N->getOperand(0);
4949 SDValue SecondOperand =
N->getOperand(1);
4950 unsigned FirstOperandOpc = FirstOperand.
getOpcode();
4951 EVT ValTy =
N->getValueType(0);
4954 unsigned SMIdx, SMLen;
4960 if (!Subtarget.has32S())
4982 if (SMIdx != 0 || lsb + SMLen > ValTy.getSizeInBits())
4997 if (SMIdx + SMLen > ValTy.getSizeInBits())
5016 NewOperand = FirstOperand;
5019 msb = lsb + SMLen - 1;
5023 if (FirstOperandOpc ==
ISD::SRA || FirstOperandOpc ==
ISD::SRL || lsb == 0)
5036 if (!Subtarget.has32S())
5048 SDValue FirstOperand =
N->getOperand(0);
5050 EVT ValTy =
N->getValueType(0);
5053 unsigned MaskIdx, MaskLen;
5068 if (MaskIdx <= Shamt && Shamt <= MaskIdx + MaskLen - 1)
5084 switch (Src.getOpcode()) {
5087 return Src.getOperand(0).getValueSizeInBits() ==
Size;
5097 return Src.getOperand(0).getScalarValueSizeInBits() == 1 &&
5110 switch (Src.getOpcode()) {
5120 Src.getOpcode(),
DL, SExtVT,
5126 DL, SExtVT, Src.getOperand(0),
5138 EVT VT =
N->getValueType(0);
5140 EVT SrcVT = Src.getValueType();
5142 if (Src.getOpcode() !=
ISD::SETCC || !Src.hasOneUse())
5147 EVT CmpVT = Src.getOperand(0).getValueType();
5152 else if (Subtarget.has32S() && Subtarget.hasExtLASX() &&
5180 (EltVT == MVT::i8 || EltVT == MVT::i16 || EltVT == MVT::i32 ||
5187 (EltVT == MVT::i8 || EltVT == MVT::i16 || EltVT == MVT::i32 ||
5211 EVT VT =
N->getValueType(0);
5213 EVT SrcVT = Src.getValueType();
5230 bool UseLASX =
false;
5231 bool PropagateSExt =
false;
5233 if (Src.getOpcode() ==
ISD::SETCC && Src.hasOneUse()) {
5234 EVT CmpVT = Src.getOperand(0).getValueType();
5243 SExtVT = MVT::v2i64;
5246 SExtVT = MVT::v4i32;
5248 SExtVT = MVT::v4i64;
5250 PropagateSExt =
true;
5254 SExtVT = MVT::v8i16;
5256 SExtVT = MVT::v8i32;
5258 PropagateSExt =
true;
5262 SExtVT = MVT::v16i8;
5264 SExtVT = MVT::v16i16;
5266 PropagateSExt =
true;
5270 SExtVT = MVT::v32i8;
5278 if (!Subtarget.has32S() || !Subtarget.hasExtLASX()) {
5279 if (Src.getSimpleValueType() == MVT::v32i8) {
5287 }
else if (UseLASX) {
5306 EVT ValTy =
N->getValueType(0);
5307 SDValue N0 =
N->getOperand(0), N1 =
N->getOperand(1);
5310 unsigned ValBits = ValTy.getSizeInBits();
5311 unsigned MaskIdx0, MaskLen0, MaskIdx1, MaskLen1;
5313 bool SwapAndRetried =
false;
5316 if (!Subtarget.has32S())
5322 if (ValBits != 32 && ValBits != 64)
5337 MaskIdx0 == MaskIdx1 && MaskLen0 == MaskLen1 &&
5340 (MaskIdx0 + MaskLen0 <= ValBits)) {
5361 MaskLen0 == MaskLen1 && MaskIdx1 == 0 &&
5362 (MaskIdx0 + MaskLen0 <= ValBits)) {
5379 (MaskIdx0 + MaskLen0 <= 64) &&
5387 ? (MaskIdx0 + (MaskLen0 & 31) - 1)
5388 : (MaskIdx0 + MaskLen0 - 1),
5404 (MaskIdx0 + MaskLen0 <= ValBits)) {
5427 DAG.
getConstant(ValBits == 32 ? (MaskIdx0 + (MaskLen0 & 31) - 1)
5428 : (MaskIdx0 + MaskLen0 - 1),
5443 unsigned MaskIdx, MaskLen;
5444 if (N1.getOpcode() ==
ISD::SHL && N1.getOperand(0).getOpcode() ==
ISD::AND &&
5471 N1.getOperand(0).getOpcode() ==
ISD::SHL &&
5485 if (!SwapAndRetried) {
5487 SwapAndRetried =
true;
5491 SwapAndRetried =
false;
5517 if (!SwapAndRetried) {
5519 SwapAndRetried =
true;
5529 switch (V.getNode()->getOpcode()) {
5541 if ((TypeNode->
getVT() == MVT::i8) || (TypeNode->
getVT() == MVT::i16)) {
5549 if ((TypeNode->
getVT() == MVT::i8) || (TypeNode->
getVT() == MVT::i16)) {
5626 SDNode *AndNode =
N->getOperand(0).getNode();
5634 SDValue CmpInputValue =
N->getOperand(1);
5645 AndInputValue1 = AndInputValue1.
getOperand(0);
5649 if (AndInputValue2 != CmpInputValue)
5682 TruncInputValue1, TruncInputValue2);
5684 DAG.
getSetCC(
SDLoc(
N),
N->getValueType(0), NewAnd, TruncInputValue2, CC);
5725 LHS.getOperand(0).getValueType() == Subtarget.
getGRLenVT()) {
5753 ShAmt =
LHS.getValueSizeInBits() - 1 - ShAmt;
5787 N->getOperand(0),
LHS,
RHS, CC,
N->getOperand(4));
5803 EVT VT =
N->getValueType(0);
5806 if (TrueV == FalseV)
5838 {LHS, RHS, CC, TrueV, FalseV});
5843template <
unsigned N>
5847 bool IsSigned =
false) {
5851 if ((IsSigned && !
isInt<N>(CImm->getSExtValue())) ||
5852 (!IsSigned && !
isUInt<N>(CImm->getZExtValue()))) {
5854 ": argument out of range.");
5860template <
unsigned N>
5864 EVT ResTy =
Node->getValueType(0);
5868 if ((IsSigned && !
isInt<N>(CImm->getSExtValue())) ||
5869 (!IsSigned && !
isUInt<N>(CImm->getZExtValue()))) {
5871 ": argument out of range.");
5876 IsSigned ? CImm->getSExtValue() : CImm->getZExtValue(), IsSigned),
5882 EVT ResTy =
Node->getValueType(0);
5890 EVT ResTy =
Node->getValueType(0);
5899template <
unsigned N>
5902 EVT ResTy =
Node->getValueType(0);
5907 ": argument out of range.");
5917template <
unsigned N>
5920 EVT ResTy =
Node->getValueType(0);
5925 ": argument out of range.");
5934template <
unsigned N>
5937 EVT ResTy =
Node->getValueType(0);
5942 ": argument out of range.");
5951template <
unsigned W>
5954 unsigned Imm =
N->getConstantOperandVal(2);
5956 const StringRef ErrorMsg =
"argument out of range";
5958 return DAG.
getUNDEF(
N->getValueType(0));
5964 return DAG.
getNode(ResOp,
DL,
N->getValueType(0), Vec, Idx, EltVT);
5972 switch (
N->getConstantOperandVal(0)) {
5975 case Intrinsic::loongarch_lsx_vadd_b:
5976 case Intrinsic::loongarch_lsx_vadd_h:
5977 case Intrinsic::loongarch_lsx_vadd_w:
5978 case Intrinsic::loongarch_lsx_vadd_d:
5979 case Intrinsic::loongarch_lasx_xvadd_b:
5980 case Intrinsic::loongarch_lasx_xvadd_h:
5981 case Intrinsic::loongarch_lasx_xvadd_w:
5982 case Intrinsic::loongarch_lasx_xvadd_d:
5985 case Intrinsic::loongarch_lsx_vaddi_bu:
5986 case Intrinsic::loongarch_lsx_vaddi_hu:
5987 case Intrinsic::loongarch_lsx_vaddi_wu:
5988 case Intrinsic::loongarch_lsx_vaddi_du:
5989 case Intrinsic::loongarch_lasx_xvaddi_bu:
5990 case Intrinsic::loongarch_lasx_xvaddi_hu:
5991 case Intrinsic::loongarch_lasx_xvaddi_wu:
5992 case Intrinsic::loongarch_lasx_xvaddi_du:
5995 case Intrinsic::loongarch_lsx_vsub_b:
5996 case Intrinsic::loongarch_lsx_vsub_h:
5997 case Intrinsic::loongarch_lsx_vsub_w:
5998 case Intrinsic::loongarch_lsx_vsub_d:
5999 case Intrinsic::loongarch_lasx_xvsub_b:
6000 case Intrinsic::loongarch_lasx_xvsub_h:
6001 case Intrinsic::loongarch_lasx_xvsub_w:
6002 case Intrinsic::loongarch_lasx_xvsub_d:
6005 case Intrinsic::loongarch_lsx_vsubi_bu:
6006 case Intrinsic::loongarch_lsx_vsubi_hu:
6007 case Intrinsic::loongarch_lsx_vsubi_wu:
6008 case Intrinsic::loongarch_lsx_vsubi_du:
6009 case Intrinsic::loongarch_lasx_xvsubi_bu:
6010 case Intrinsic::loongarch_lasx_xvsubi_hu:
6011 case Intrinsic::loongarch_lasx_xvsubi_wu:
6012 case Intrinsic::loongarch_lasx_xvsubi_du:
6015 case Intrinsic::loongarch_lsx_vneg_b:
6016 case Intrinsic::loongarch_lsx_vneg_h:
6017 case Intrinsic::loongarch_lsx_vneg_w:
6018 case Intrinsic::loongarch_lsx_vneg_d:
6019 case Intrinsic::loongarch_lasx_xvneg_b:
6020 case Intrinsic::loongarch_lasx_xvneg_h:
6021 case Intrinsic::loongarch_lasx_xvneg_w:
6022 case Intrinsic::loongarch_lasx_xvneg_d:
6026 APInt(
N->getValueType(0).getScalarType().getSizeInBits(), 0,
6028 SDLoc(
N),
N->getValueType(0)),
6030 case Intrinsic::loongarch_lsx_vmax_b:
6031 case Intrinsic::loongarch_lsx_vmax_h:
6032 case Intrinsic::loongarch_lsx_vmax_w:
6033 case Intrinsic::loongarch_lsx_vmax_d:
6034 case Intrinsic::loongarch_lasx_xvmax_b:
6035 case Intrinsic::loongarch_lasx_xvmax_h:
6036 case Intrinsic::loongarch_lasx_xvmax_w:
6037 case Intrinsic::loongarch_lasx_xvmax_d:
6040 case Intrinsic::loongarch_lsx_vmax_bu:
6041 case Intrinsic::loongarch_lsx_vmax_hu:
6042 case Intrinsic::loongarch_lsx_vmax_wu:
6043 case Intrinsic::loongarch_lsx_vmax_du:
6044 case Intrinsic::loongarch_lasx_xvmax_bu:
6045 case Intrinsic::loongarch_lasx_xvmax_hu:
6046 case Intrinsic::loongarch_lasx_xvmax_wu:
6047 case Intrinsic::loongarch_lasx_xvmax_du:
6050 case Intrinsic::loongarch_lsx_vmaxi_b:
6051 case Intrinsic::loongarch_lsx_vmaxi_h:
6052 case Intrinsic::loongarch_lsx_vmaxi_w:
6053 case Intrinsic::loongarch_lsx_vmaxi_d:
6054 case Intrinsic::loongarch_lasx_xvmaxi_b:
6055 case Intrinsic::loongarch_lasx_xvmaxi_h:
6056 case Intrinsic::loongarch_lasx_xvmaxi_w:
6057 case Intrinsic::loongarch_lasx_xvmaxi_d:
6060 case Intrinsic::loongarch_lsx_vmaxi_bu:
6061 case Intrinsic::loongarch_lsx_vmaxi_hu:
6062 case Intrinsic::loongarch_lsx_vmaxi_wu:
6063 case Intrinsic::loongarch_lsx_vmaxi_du:
6064 case Intrinsic::loongarch_lasx_xvmaxi_bu:
6065 case Intrinsic::loongarch_lasx_xvmaxi_hu:
6066 case Intrinsic::loongarch_lasx_xvmaxi_wu:
6067 case Intrinsic::loongarch_lasx_xvmaxi_du:
6070 case Intrinsic::loongarch_lsx_vmin_b:
6071 case Intrinsic::loongarch_lsx_vmin_h:
6072 case Intrinsic::loongarch_lsx_vmin_w:
6073 case Intrinsic::loongarch_lsx_vmin_d:
6074 case Intrinsic::loongarch_lasx_xvmin_b:
6075 case Intrinsic::loongarch_lasx_xvmin_h:
6076 case Intrinsic::loongarch_lasx_xvmin_w:
6077 case Intrinsic::loongarch_lasx_xvmin_d:
6080 case Intrinsic::loongarch_lsx_vmin_bu:
6081 case Intrinsic::loongarch_lsx_vmin_hu:
6082 case Intrinsic::loongarch_lsx_vmin_wu:
6083 case Intrinsic::loongarch_lsx_vmin_du:
6084 case Intrinsic::loongarch_lasx_xvmin_bu:
6085 case Intrinsic::loongarch_lasx_xvmin_hu:
6086 case Intrinsic::loongarch_lasx_xvmin_wu:
6087 case Intrinsic::loongarch_lasx_xvmin_du:
6090 case Intrinsic::loongarch_lsx_vmini_b:
6091 case Intrinsic::loongarch_lsx_vmini_h:
6092 case Intrinsic::loongarch_lsx_vmini_w:
6093 case Intrinsic::loongarch_lsx_vmini_d:
6094 case Intrinsic::loongarch_lasx_xvmini_b:
6095 case Intrinsic::loongarch_lasx_xvmini_h:
6096 case Intrinsic::loongarch_lasx_xvmini_w:
6097 case Intrinsic::loongarch_lasx_xvmini_d:
6100 case Intrinsic::loongarch_lsx_vmini_bu:
6101 case Intrinsic::loongarch_lsx_vmini_hu:
6102 case Intrinsic::loongarch_lsx_vmini_wu:
6103 case Intrinsic::loongarch_lsx_vmini_du:
6104 case Intrinsic::loongarch_lasx_xvmini_bu:
6105 case Intrinsic::loongarch_lasx_xvmini_hu:
6106 case Intrinsic::loongarch_lasx_xvmini_wu:
6107 case Intrinsic::loongarch_lasx_xvmini_du:
6110 case Intrinsic::loongarch_lsx_vmul_b:
6111 case Intrinsic::loongarch_lsx_vmul_h:
6112 case Intrinsic::loongarch_lsx_vmul_w:
6113 case Intrinsic::loongarch_lsx_vmul_d:
6114 case Intrinsic::loongarch_lasx_xvmul_b:
6115 case Intrinsic::loongarch_lasx_xvmul_h:
6116 case Intrinsic::loongarch_lasx_xvmul_w:
6117 case Intrinsic::loongarch_lasx_xvmul_d:
6120 case Intrinsic::loongarch_lsx_vmadd_b:
6121 case Intrinsic::loongarch_lsx_vmadd_h:
6122 case Intrinsic::loongarch_lsx_vmadd_w:
6123 case Intrinsic::loongarch_lsx_vmadd_d:
6124 case Intrinsic::loongarch_lasx_xvmadd_b:
6125 case Intrinsic::loongarch_lasx_xvmadd_h:
6126 case Intrinsic::loongarch_lasx_xvmadd_w:
6127 case Intrinsic::loongarch_lasx_xvmadd_d: {
6128 EVT ResTy =
N->getValueType(0);
6133 case Intrinsic::loongarch_lsx_vmsub_b:
6134 case Intrinsic::loongarch_lsx_vmsub_h:
6135 case Intrinsic::loongarch_lsx_vmsub_w:
6136 case Intrinsic::loongarch_lsx_vmsub_d:
6137 case Intrinsic::loongarch_lasx_xvmsub_b:
6138 case Intrinsic::loongarch_lasx_xvmsub_h:
6139 case Intrinsic::loongarch_lasx_xvmsub_w:
6140 case Intrinsic::loongarch_lasx_xvmsub_d: {
6141 EVT ResTy =
N->getValueType(0);
6146 case Intrinsic::loongarch_lsx_vdiv_b:
6147 case Intrinsic::loongarch_lsx_vdiv_h:
6148 case Intrinsic::loongarch_lsx_vdiv_w:
6149 case Intrinsic::loongarch_lsx_vdiv_d:
6150 case Intrinsic::loongarch_lasx_xvdiv_b:
6151 case Intrinsic::loongarch_lasx_xvdiv_h:
6152 case Intrinsic::loongarch_lasx_xvdiv_w:
6153 case Intrinsic::loongarch_lasx_xvdiv_d:
6156 case Intrinsic::loongarch_lsx_vdiv_bu:
6157 case Intrinsic::loongarch_lsx_vdiv_hu:
6158 case Intrinsic::loongarch_lsx_vdiv_wu:
6159 case Intrinsic::loongarch_lsx_vdiv_du:
6160 case Intrinsic::loongarch_lasx_xvdiv_bu:
6161 case Intrinsic::loongarch_lasx_xvdiv_hu:
6162 case Intrinsic::loongarch_lasx_xvdiv_wu:
6163 case Intrinsic::loongarch_lasx_xvdiv_du:
6166 case Intrinsic::loongarch_lsx_vmod_b:
6167 case Intrinsic::loongarch_lsx_vmod_h:
6168 case Intrinsic::loongarch_lsx_vmod_w:
6169 case Intrinsic::loongarch_lsx_vmod_d:
6170 case Intrinsic::loongarch_lasx_xvmod_b:
6171 case Intrinsic::loongarch_lasx_xvmod_h:
6172 case Intrinsic::loongarch_lasx_xvmod_w:
6173 case Intrinsic::loongarch_lasx_xvmod_d:
6176 case Intrinsic::loongarch_lsx_vmod_bu:
6177 case Intrinsic::loongarch_lsx_vmod_hu:
6178 case Intrinsic::loongarch_lsx_vmod_wu:
6179 case Intrinsic::loongarch_lsx_vmod_du:
6180 case Intrinsic::loongarch_lasx_xvmod_bu:
6181 case Intrinsic::loongarch_lasx_xvmod_hu:
6182 case Intrinsic::loongarch_lasx_xvmod_wu:
6183 case Intrinsic::loongarch_lasx_xvmod_du:
6186 case Intrinsic::loongarch_lsx_vand_v:
6187 case Intrinsic::loongarch_lasx_xvand_v:
6190 case Intrinsic::loongarch_lsx_vor_v:
6191 case Intrinsic::loongarch_lasx_xvor_v:
6194 case Intrinsic::loongarch_lsx_vxor_v:
6195 case Intrinsic::loongarch_lasx_xvxor_v:
6198 case Intrinsic::loongarch_lsx_vnor_v:
6199 case Intrinsic::loongarch_lasx_xvnor_v: {
6204 case Intrinsic::loongarch_lsx_vandi_b:
6205 case Intrinsic::loongarch_lasx_xvandi_b:
6208 case Intrinsic::loongarch_lsx_vori_b:
6209 case Intrinsic::loongarch_lasx_xvori_b:
6212 case Intrinsic::loongarch_lsx_vxori_b:
6213 case Intrinsic::loongarch_lasx_xvxori_b:
6216 case Intrinsic::loongarch_lsx_vsll_b:
6217 case Intrinsic::loongarch_lsx_vsll_h:
6218 case Intrinsic::loongarch_lsx_vsll_w:
6219 case Intrinsic::loongarch_lsx_vsll_d:
6220 case Intrinsic::loongarch_lasx_xvsll_b:
6221 case Intrinsic::loongarch_lasx_xvsll_h:
6222 case Intrinsic::loongarch_lasx_xvsll_w:
6223 case Intrinsic::loongarch_lasx_xvsll_d:
6226 case Intrinsic::loongarch_lsx_vslli_b:
6227 case Intrinsic::loongarch_lasx_xvslli_b:
6230 case Intrinsic::loongarch_lsx_vslli_h:
6231 case Intrinsic::loongarch_lasx_xvslli_h:
6234 case Intrinsic::loongarch_lsx_vslli_w:
6235 case Intrinsic::loongarch_lasx_xvslli_w:
6238 case Intrinsic::loongarch_lsx_vslli_d:
6239 case Intrinsic::loongarch_lasx_xvslli_d:
6242 case Intrinsic::loongarch_lsx_vsrl_b:
6243 case Intrinsic::loongarch_lsx_vsrl_h:
6244 case Intrinsic::loongarch_lsx_vsrl_w:
6245 case Intrinsic::loongarch_lsx_vsrl_d:
6246 case Intrinsic::loongarch_lasx_xvsrl_b:
6247 case Intrinsic::loongarch_lasx_xvsrl_h:
6248 case Intrinsic::loongarch_lasx_xvsrl_w:
6249 case Intrinsic::loongarch_lasx_xvsrl_d:
6252 case Intrinsic::loongarch_lsx_vsrli_b:
6253 case Intrinsic::loongarch_lasx_xvsrli_b:
6256 case Intrinsic::loongarch_lsx_vsrli_h:
6257 case Intrinsic::loongarch_lasx_xvsrli_h:
6260 case Intrinsic::loongarch_lsx_vsrli_w:
6261 case Intrinsic::loongarch_lasx_xvsrli_w:
6264 case Intrinsic::loongarch_lsx_vsrli_d:
6265 case Intrinsic::loongarch_lasx_xvsrli_d:
6268 case Intrinsic::loongarch_lsx_vsra_b:
6269 case Intrinsic::loongarch_lsx_vsra_h:
6270 case Intrinsic::loongarch_lsx_vsra_w:
6271 case Intrinsic::loongarch_lsx_vsra_d:
6272 case Intrinsic::loongarch_lasx_xvsra_b:
6273 case Intrinsic::loongarch_lasx_xvsra_h:
6274 case Intrinsic::loongarch_lasx_xvsra_w:
6275 case Intrinsic::loongarch_lasx_xvsra_d:
6278 case Intrinsic::loongarch_lsx_vsrai_b:
6279 case Intrinsic::loongarch_lasx_xvsrai_b:
6282 case Intrinsic::loongarch_lsx_vsrai_h:
6283 case Intrinsic::loongarch_lasx_xvsrai_h:
6286 case Intrinsic::loongarch_lsx_vsrai_w:
6287 case Intrinsic::loongarch_lasx_xvsrai_w:
6290 case Intrinsic::loongarch_lsx_vsrai_d:
6291 case Intrinsic::loongarch_lasx_xvsrai_d:
6294 case Intrinsic::loongarch_lsx_vclz_b:
6295 case Intrinsic::loongarch_lsx_vclz_h:
6296 case Intrinsic::loongarch_lsx_vclz_w:
6297 case Intrinsic::loongarch_lsx_vclz_d:
6298 case Intrinsic::loongarch_lasx_xvclz_b:
6299 case Intrinsic::loongarch_lasx_xvclz_h:
6300 case Intrinsic::loongarch_lasx_xvclz_w:
6301 case Intrinsic::loongarch_lasx_xvclz_d:
6303 case Intrinsic::loongarch_lsx_vpcnt_b:
6304 case Intrinsic::loongarch_lsx_vpcnt_h:
6305 case Intrinsic::loongarch_lsx_vpcnt_w:
6306 case Intrinsic::loongarch_lsx_vpcnt_d:
6307 case Intrinsic::loongarch_lasx_xvpcnt_b:
6308 case Intrinsic::loongarch_lasx_xvpcnt_h:
6309 case Intrinsic::loongarch_lasx_xvpcnt_w:
6310 case Intrinsic::loongarch_lasx_xvpcnt_d:
6312 case Intrinsic::loongarch_lsx_vbitclr_b:
6313 case Intrinsic::loongarch_lsx_vbitclr_h:
6314 case Intrinsic::loongarch_lsx_vbitclr_w:
6315 case Intrinsic::loongarch_lsx_vbitclr_d:
6316 case Intrinsic::loongarch_lasx_xvbitclr_b:
6317 case Intrinsic::loongarch_lasx_xvbitclr_h:
6318 case Intrinsic::loongarch_lasx_xvbitclr_w:
6319 case Intrinsic::loongarch_lasx_xvbitclr_d:
6321 case Intrinsic::loongarch_lsx_vbitclri_b:
6322 case Intrinsic::loongarch_lasx_xvbitclri_b:
6324 case Intrinsic::loongarch_lsx_vbitclri_h:
6325 case Intrinsic::loongarch_lasx_xvbitclri_h:
6327 case Intrinsic::loongarch_lsx_vbitclri_w:
6328 case Intrinsic::loongarch_lasx_xvbitclri_w:
6330 case Intrinsic::loongarch_lsx_vbitclri_d:
6331 case Intrinsic::loongarch_lasx_xvbitclri_d:
6333 case Intrinsic::loongarch_lsx_vbitset_b:
6334 case Intrinsic::loongarch_lsx_vbitset_h:
6335 case Intrinsic::loongarch_lsx_vbitset_w:
6336 case Intrinsic::loongarch_lsx_vbitset_d:
6337 case Intrinsic::loongarch_lasx_xvbitset_b:
6338 case Intrinsic::loongarch_lasx_xvbitset_h:
6339 case Intrinsic::loongarch_lasx_xvbitset_w:
6340 case Intrinsic::loongarch_lasx_xvbitset_d: {
6341 EVT VecTy =
N->getValueType(0);
6347 case Intrinsic::loongarch_lsx_vbitseti_b:
6348 case Intrinsic::loongarch_lasx_xvbitseti_b:
6350 case Intrinsic::loongarch_lsx_vbitseti_h:
6351 case Intrinsic::loongarch_lasx_xvbitseti_h:
6353 case Intrinsic::loongarch_lsx_vbitseti_w:
6354 case Intrinsic::loongarch_lasx_xvbitseti_w:
6356 case Intrinsic::loongarch_lsx_vbitseti_d:
6357 case Intrinsic::loongarch_lasx_xvbitseti_d:
6359 case Intrinsic::loongarch_lsx_vbitrev_b:
6360 case Intrinsic::loongarch_lsx_vbitrev_h:
6361 case Intrinsic::loongarch_lsx_vbitrev_w:
6362 case Intrinsic::loongarch_lsx_vbitrev_d:
6363 case Intrinsic::loongarch_lasx_xvbitrev_b:
6364 case Intrinsic::loongarch_lasx_xvbitrev_h:
6365 case Intrinsic::loongarch_lasx_xvbitrev_w:
6366 case Intrinsic::loongarch_lasx_xvbitrev_d: {
6367 EVT VecTy =
N->getValueType(0);
6373 case Intrinsic::loongarch_lsx_vbitrevi_b:
6374 case Intrinsic::loongarch_lasx_xvbitrevi_b:
6376 case Intrinsic::loongarch_lsx_vbitrevi_h:
6377 case Intrinsic::loongarch_lasx_xvbitrevi_h:
6379 case Intrinsic::loongarch_lsx_vbitrevi_w:
6380 case Intrinsic::loongarch_lasx_xvbitrevi_w:
6382 case Intrinsic::loongarch_lsx_vbitrevi_d:
6383 case Intrinsic::loongarch_lasx_xvbitrevi_d:
6385 case Intrinsic::loongarch_lsx_vfadd_s:
6386 case Intrinsic::loongarch_lsx_vfadd_d:
6387 case Intrinsic::loongarch_lasx_xvfadd_s:
6388 case Intrinsic::loongarch_lasx_xvfadd_d:
6391 case Intrinsic::loongarch_lsx_vfsub_s:
6392 case Intrinsic::loongarch_lsx_vfsub_d:
6393 case Intrinsic::loongarch_lasx_xvfsub_s:
6394 case Intrinsic::loongarch_lasx_xvfsub_d:
6397 case Intrinsic::loongarch_lsx_vfmul_s:
6398 case Intrinsic::loongarch_lsx_vfmul_d:
6399 case Intrinsic::loongarch_lasx_xvfmul_s:
6400 case Intrinsic::loongarch_lasx_xvfmul_d:
6403 case Intrinsic::loongarch_lsx_vfdiv_s:
6404 case Intrinsic::loongarch_lsx_vfdiv_d:
6405 case Intrinsic::loongarch_lasx_xvfdiv_s:
6406 case Intrinsic::loongarch_lasx_xvfdiv_d:
6409 case Intrinsic::loongarch_lsx_vfmadd_s:
6410 case Intrinsic::loongarch_lsx_vfmadd_d:
6411 case Intrinsic::loongarch_lasx_xvfmadd_s:
6412 case Intrinsic::loongarch_lasx_xvfmadd_d:
6414 N->getOperand(2),
N->getOperand(3));
6415 case Intrinsic::loongarch_lsx_vinsgr2vr_b:
6417 N->getOperand(1),
N->getOperand(2),
6419 case Intrinsic::loongarch_lsx_vinsgr2vr_h:
6420 case Intrinsic::loongarch_lasx_xvinsgr2vr_w:
6422 N->getOperand(1),
N->getOperand(2),
6424 case Intrinsic::loongarch_lsx_vinsgr2vr_w:
6425 case Intrinsic::loongarch_lasx_xvinsgr2vr_d:
6427 N->getOperand(1),
N->getOperand(2),
6429 case Intrinsic::loongarch_lsx_vinsgr2vr_d:
6431 N->getOperand(1),
N->getOperand(2),
6433 case Intrinsic::loongarch_lsx_vreplgr2vr_b:
6434 case Intrinsic::loongarch_lsx_vreplgr2vr_h:
6435 case Intrinsic::loongarch_lsx_vreplgr2vr_w:
6436 case Intrinsic::loongarch_lsx_vreplgr2vr_d:
6437 case Intrinsic::loongarch_lasx_xvreplgr2vr_b:
6438 case Intrinsic::loongarch_lasx_xvreplgr2vr_h:
6439 case Intrinsic::loongarch_lasx_xvreplgr2vr_w:
6440 case Intrinsic::loongarch_lasx_xvreplgr2vr_d:
6444 case Intrinsic::loongarch_lsx_vreplve_b:
6445 case Intrinsic::loongarch_lsx_vreplve_h:
6446 case Intrinsic::loongarch_lsx_vreplve_w:
6447 case Intrinsic::loongarch_lsx_vreplve_d:
6448 case Intrinsic::loongarch_lasx_xvreplve_b:
6449 case Intrinsic::loongarch_lasx_xvreplve_h:
6450 case Intrinsic::loongarch_lasx_xvreplve_w:
6451 case Intrinsic::loongarch_lasx_xvreplve_d:
6456 case Intrinsic::loongarch_lsx_vpickve2gr_b:
6460 case Intrinsic::loongarch_lsx_vpickve2gr_h:
6461 case Intrinsic::loongarch_lasx_xvpickve2gr_w:
6465 case Intrinsic::loongarch_lsx_vpickve2gr_w:
6469 case Intrinsic::loongarch_lsx_vpickve2gr_bu:
6473 case Intrinsic::loongarch_lsx_vpickve2gr_hu:
6474 case Intrinsic::loongarch_lasx_xvpickve2gr_wu:
6478 case Intrinsic::loongarch_lsx_vpickve2gr_wu:
6482 case Intrinsic::loongarch_lsx_bz_b:
6483 case Intrinsic::loongarch_lsx_bz_h:
6484 case Intrinsic::loongarch_lsx_bz_w:
6485 case Intrinsic::loongarch_lsx_bz_d:
6486 case Intrinsic::loongarch_lasx_xbz_b:
6487 case Intrinsic::loongarch_lasx_xbz_h:
6488 case Intrinsic::loongarch_lasx_xbz_w:
6489 case Intrinsic::loongarch_lasx_xbz_d:
6494 case Intrinsic::loongarch_lsx_bz_v:
6495 case Intrinsic::loongarch_lasx_xbz_v:
6500 case Intrinsic::loongarch_lsx_bnz_b:
6501 case Intrinsic::loongarch_lsx_bnz_h:
6502 case Intrinsic::loongarch_lsx_bnz_w:
6503 case Intrinsic::loongarch_lsx_bnz_d:
6504 case Intrinsic::loongarch_lasx_xbnz_b:
6505 case Intrinsic::loongarch_lasx_xbnz_h:
6506 case Intrinsic::loongarch_lasx_xbnz_w:
6507 case Intrinsic::loongarch_lasx_xbnz_d:
6512 case Intrinsic::loongarch_lsx_bnz_v:
6513 case Intrinsic::loongarch_lasx_xbnz_v:
6543 "Unexpected value type!");
6552 MVT VT =
N->getSimpleValueType(0);
6586 APInt V =
C->getValueAPF().bitcastToAPInt();
6602 MVT EltVT =
N->getSimpleValueType(0);
6634 switch (
N->getOpcode()) {
6688 MF->
insert(It, BreakMBB);
6692 SinkMBB->splice(SinkMBB->end(),
MBB, std::next(
MI.getIterator()),
MBB->end());
6693 SinkMBB->transferSuccessorsAndUpdatePHIs(
MBB);
6705 MBB->addSuccessor(BreakMBB);
6706 MBB->addSuccessor(SinkMBB);
6712 BreakMBB->addSuccessor(SinkMBB);
6724 switch (
MI.getOpcode()) {
6727 case LoongArch::PseudoVBZ:
6728 CondOpc = LoongArch::VSETEQZ_V;
6730 case LoongArch::PseudoVBZ_B:
6731 CondOpc = LoongArch::VSETANYEQZ_B;
6733 case LoongArch::PseudoVBZ_H:
6734 CondOpc = LoongArch::VSETANYEQZ_H;
6736 case LoongArch::PseudoVBZ_W:
6737 CondOpc = LoongArch::VSETANYEQZ_W;
6739 case LoongArch::PseudoVBZ_D:
6740 CondOpc = LoongArch::VSETANYEQZ_D;
6742 case LoongArch::PseudoVBNZ:
6743 CondOpc = LoongArch::VSETNEZ_V;
6745 case LoongArch::PseudoVBNZ_B:
6746 CondOpc = LoongArch::VSETALLNEZ_B;
6748 case LoongArch::PseudoVBNZ_H:
6749 CondOpc = LoongArch::VSETALLNEZ_H;
6751 case LoongArch::PseudoVBNZ_W:
6752 CondOpc = LoongArch::VSETALLNEZ_W;
6754 case LoongArch::PseudoVBNZ_D:
6755 CondOpc = LoongArch::VSETALLNEZ_D;
6757 case LoongArch::PseudoXVBZ:
6758 CondOpc = LoongArch::XVSETEQZ_V;
6760 case LoongArch::PseudoXVBZ_B:
6761 CondOpc = LoongArch::XVSETANYEQZ_B;
6763 case LoongArch::PseudoXVBZ_H:
6764 CondOpc = LoongArch::XVSETANYEQZ_H;
6766 case LoongArch::PseudoXVBZ_W:
6767 CondOpc = LoongArch::XVSETANYEQZ_W;
6769 case LoongArch::PseudoXVBZ_D:
6770 CondOpc = LoongArch::XVSETANYEQZ_D;
6772 case LoongArch::PseudoXVBNZ:
6773 CondOpc = LoongArch::XVSETNEZ_V;
6775 case LoongArch::PseudoXVBNZ_B:
6776 CondOpc = LoongArch::XVSETALLNEZ_B;
6778 case LoongArch::PseudoXVBNZ_H:
6779 CondOpc = LoongArch::XVSETALLNEZ_H;
6781 case LoongArch::PseudoXVBNZ_W:
6782 CondOpc = LoongArch::XVSETALLNEZ_W;
6784 case LoongArch::PseudoXVBNZ_D:
6785 CondOpc = LoongArch::XVSETALLNEZ_D;
6800 F->insert(It, FalseBB);
6801 F->insert(It, TrueBB);
6802 F->insert(It, SinkBB);
6805 SinkBB->
splice(SinkBB->
end(), BB, std::next(
MI.getIterator()), BB->
end());
6809 Register FCC =
MRI.createVirtualRegister(&LoongArch::CFRRegClass);
6818 Register RD1 =
MRI.createVirtualRegister(&LoongArch::GPRRegClass);
6826 Register RD2 =
MRI.createVirtualRegister(&LoongArch::GPRRegClass);
6834 MI.getOperand(0).getReg())
6841 MI.eraseFromParent();
6849 unsigned BroadcastOp;
6851 switch (
MI.getOpcode()) {
6854 case LoongArch::PseudoXVINSGR2VR_B:
6856 BroadcastOp = LoongArch::XVREPLGR2VR_B;
6857 InsOp = LoongArch::XVEXTRINS_B;
6859 case LoongArch::PseudoXVINSGR2VR_H:
6861 BroadcastOp = LoongArch::XVREPLGR2VR_H;
6862 InsOp = LoongArch::XVEXTRINS_H;
6874 unsigned Idx =
MI.getOperand(3).getImm();
6876 if (XSrc.
isVirtual() &&
MRI.getVRegDef(XSrc)->isImplicitDef() &&
6878 Register ScratchSubReg1 =
MRI.createVirtualRegister(SubRC);
6879 Register ScratchSubReg2 =
MRI.createVirtualRegister(SubRC);
6882 .
addReg(XSrc, 0, LoongArch::sub_128);
6884 TII->get(HalfSize == 8 ? LoongArch::VINSGR2VR_H
6885 : LoongArch::VINSGR2VR_B),
6894 .
addImm(LoongArch::sub_128);
6896 Register ScratchReg1 =
MRI.createVirtualRegister(RC);
6897 Register ScratchReg2 =
MRI.createVirtualRegister(RC);
6901 BuildMI(*BB,
MI,
DL,
TII->get(LoongArch::XVPERMI_Q), ScratchReg2)
6904 .
addImm(Idx >= HalfSize ? 48 : 18);
6909 .
addImm((Idx >= HalfSize ? Idx - HalfSize : Idx) * 17);
6912 MI.eraseFromParent();
6919 assert(Subtarget.hasExtLSX());
6926 Register ScratchReg1 =
MRI.createVirtualRegister(RC);
6927 Register ScratchReg2 =
MRI.createVirtualRegister(RC);
6928 Register ScratchReg3 =
MRI.createVirtualRegister(RC);
6932 TII->get(Subtarget.
is64Bit() ? LoongArch::VINSGR2VR_D
6933 : LoongArch::VINSGR2VR_W),
6940 TII->get(Subtarget.
is64Bit() ? LoongArch::VPCNT_D : LoongArch::VPCNT_W),
6944 TII->get(Subtarget.
is64Bit() ? LoongArch::VPICKVE2GR_D
6945 : LoongArch::VPICKVE2GR_W),
6950 MI.eraseFromParent();
6964 unsigned EleBits = 8;
6965 unsigned NotOpc = 0;
6968 switch (
MI.getOpcode()) {
6971 case LoongArch::PseudoVMSKLTZ_B:
6972 MskOpc = LoongArch::VMSKLTZ_B;
6974 case LoongArch::PseudoVMSKLTZ_H:
6975 MskOpc = LoongArch::VMSKLTZ_H;
6978 case LoongArch::PseudoVMSKLTZ_W:
6979 MskOpc = LoongArch::VMSKLTZ_W;
6982 case LoongArch::PseudoVMSKLTZ_D:
6983 MskOpc = LoongArch::VMSKLTZ_D;
6986 case LoongArch::PseudoVMSKGEZ_B:
6987 MskOpc = LoongArch::VMSKGEZ_B;
6989 case LoongArch::PseudoVMSKEQZ_B:
6990 MskOpc = LoongArch::VMSKNZ_B;
6991 NotOpc = LoongArch::VNOR_V;
6993 case LoongArch::PseudoVMSKNEZ_B:
6994 MskOpc = LoongArch::VMSKNZ_B;
6996 case LoongArch::PseudoXVMSKLTZ_B:
6997 MskOpc = LoongArch::XVMSKLTZ_B;
6998 RC = &LoongArch::LASX256RegClass;
7000 case LoongArch::PseudoXVMSKLTZ_H:
7001 MskOpc = LoongArch::XVMSKLTZ_H;
7002 RC = &LoongArch::LASX256RegClass;
7005 case LoongArch::PseudoXVMSKLTZ_W:
7006 MskOpc = LoongArch::XVMSKLTZ_W;
7007 RC = &LoongArch::LASX256RegClass;
7010 case LoongArch::PseudoXVMSKLTZ_D:
7011 MskOpc = LoongArch::XVMSKLTZ_D;
7012 RC = &LoongArch::LASX256RegClass;
7015 case LoongArch::PseudoXVMSKGEZ_B:
7016 MskOpc = LoongArch::XVMSKGEZ_B;
7017 RC = &LoongArch::LASX256RegClass;
7019 case LoongArch::PseudoXVMSKEQZ_B:
7020 MskOpc = LoongArch::XVMSKNZ_B;
7021 NotOpc = LoongArch::XVNOR_V;
7022 RC = &LoongArch::LASX256RegClass;
7024 case LoongArch::PseudoXVMSKNEZ_B:
7025 MskOpc = LoongArch::XVMSKNZ_B;
7026 RC = &LoongArch::LASX256RegClass;
7041 if (
TRI->getRegSizeInBits(*RC) > 128) {
7042 Register Lo =
MRI.createVirtualRegister(&LoongArch::GPRRegClass);
7043 Register Hi =
MRI.createVirtualRegister(&LoongArch::GPRRegClass);
7051 TII->get(Subtarget.
is64Bit() ? LoongArch::BSTRINS_D
7052 : LoongArch::BSTRINS_W),
7056 .
addImm(256 / EleBits - 1)
7064 MI.eraseFromParent();
7071 assert(
MI.getOpcode() == LoongArch::SplitPairF64Pseudo &&
7072 "Unexpected instruction");
7084 MI.eraseFromParent();
7091 assert(
MI.getOpcode() == LoongArch::BuildPairF64Pseudo &&
7092 "Unexpected instruction");
7098 Register TmpReg =
MRI.createVirtualRegister(&LoongArch::FPR64RegClass);
7108 MI.eraseFromParent();
7113 switch (
MI.getOpcode()) {
7116 case LoongArch::Select_GPR_Using_CC_GPR:
7152 if (
MI.getOperand(2).isReg())
7153 RHS =
MI.getOperand(2).getReg();
7154 auto CC =
static_cast<unsigned>(
MI.getOperand(3).
getImm());
7158 SelectDests.
insert(
MI.getOperand(0).getReg());
7162 SequenceMBBI !=
E; ++SequenceMBBI) {
7163 if (SequenceMBBI->isDebugInstr())
7166 if (SequenceMBBI->getOperand(1).getReg() !=
LHS ||
7167 !SequenceMBBI->getOperand(2).isReg() ||
7168 SequenceMBBI->getOperand(2).getReg() !=
RHS ||
7169 SequenceMBBI->getOperand(3).getImm() != CC ||
7170 SelectDests.
count(SequenceMBBI->getOperand(4).getReg()) ||
7171 SelectDests.
count(SequenceMBBI->getOperand(5).getReg()))
7173 LastSelectPseudo = &*SequenceMBBI;
7175 SelectDests.
insert(SequenceMBBI->getOperand(0).getReg());
7178 if (SequenceMBBI->hasUnmodeledSideEffects() ||
7179 SequenceMBBI->mayLoadOrStore() ||
7180 SequenceMBBI->usesCustomInsertionHook())
7183 return MO.isReg() && MO.isUse() && SelectDests.count(MO.getReg());
7198 F->insert(
I, IfFalseMBB);
7199 F->insert(
I, TailMBB);
7202 unsigned CallFrameSize =
TII.getCallFrameSizeAt(*LastSelectPseudo);
7208 TailMBB->
push_back(DebugInstr->removeFromParent());
7212 TailMBB->
splice(TailMBB->
end(), HeadMBB,
7222 if (
MI.getOperand(2).isImm())
7234 auto SelectMBBI =
MI.getIterator();
7235 auto SelectEnd = std::next(LastSelectPseudo->
getIterator());
7237 while (SelectMBBI != SelectEnd) {
7238 auto Next = std::next(SelectMBBI);
7242 TII.get(LoongArch::PHI), SelectMBBI->getOperand(0).getReg())
7243 .
addReg(SelectMBBI->getOperand(4).getReg())
7245 .
addReg(SelectMBBI->getOperand(5).getReg())
7252 F->getProperties().resetNoPHIs();
7258 const TargetInstrInfo *
TII = Subtarget.getInstrInfo();
7261 switch (
MI.getOpcode()) {
7264 case LoongArch::DIV_W:
7265 case LoongArch::DIV_WU:
7266 case LoongArch::MOD_W:
7267 case LoongArch::MOD_WU:
7268 case LoongArch::DIV_D:
7269 case LoongArch::DIV_DU:
7270 case LoongArch::MOD_D:
7271 case LoongArch::MOD_DU:
7274 case LoongArch::WRFCSR: {
7276 LoongArch::FCSR0 +
MI.getOperand(0).getImm())
7277 .
addReg(
MI.getOperand(1).getReg());
7278 MI.eraseFromParent();
7281 case LoongArch::RDFCSR: {
7282 MachineInstr *ReadFCSR =
7284 MI.getOperand(0).getReg())
7285 .
addReg(LoongArch::FCSR0 +
MI.getOperand(1).getImm());
7287 MI.eraseFromParent();
7290 case LoongArch::Select_GPR_Using_CC_GPR:
7292 case LoongArch::BuildPairF64Pseudo:
7294 case LoongArch::SplitPairF64Pseudo:
7296 case LoongArch::PseudoVBZ:
7297 case LoongArch::PseudoVBZ_B:
7298 case LoongArch::PseudoVBZ_H:
7299 case LoongArch::PseudoVBZ_W:
7300 case LoongArch::PseudoVBZ_D:
7301 case LoongArch::PseudoVBNZ:
7302 case LoongArch::PseudoVBNZ_B:
7303 case LoongArch::PseudoVBNZ_H:
7304 case LoongArch::PseudoVBNZ_W:
7305 case LoongArch::PseudoVBNZ_D:
7306 case LoongArch::PseudoXVBZ:
7307 case LoongArch::PseudoXVBZ_B:
7308 case LoongArch::PseudoXVBZ_H:
7309 case LoongArch::PseudoXVBZ_W:
7310 case LoongArch::PseudoXVBZ_D:
7311 case LoongArch::PseudoXVBNZ:
7312 case LoongArch::PseudoXVBNZ_B:
7313 case LoongArch::PseudoXVBNZ_H:
7314 case LoongArch::PseudoXVBNZ_W:
7315 case LoongArch::PseudoXVBNZ_D:
7317 case LoongArch::PseudoXVINSGR2VR_B:
7318 case LoongArch::PseudoXVINSGR2VR_H:
7320 case LoongArch::PseudoCTPOP:
7322 case LoongArch::PseudoVMSKLTZ_B:
7323 case LoongArch::PseudoVMSKLTZ_H:
7324 case LoongArch::PseudoVMSKLTZ_W:
7325 case LoongArch::PseudoVMSKLTZ_D:
7326 case LoongArch::PseudoVMSKGEZ_B:
7327 case LoongArch::PseudoVMSKEQZ_B:
7328 case LoongArch::PseudoVMSKNEZ_B:
7329 case LoongArch::PseudoXVMSKLTZ_B:
7330 case LoongArch::PseudoXVMSKLTZ_H:
7331 case LoongArch::PseudoXVMSKLTZ_W:
7332 case LoongArch::PseudoXVMSKLTZ_D:
7333 case LoongArch::PseudoXVMSKGEZ_B:
7334 case LoongArch::PseudoXVMSKEQZ_B:
7335 case LoongArch::PseudoXVMSKNEZ_B:
7337 case TargetOpcode::STATEPOINT:
7343 MI.addOperand(*
MI.getMF(),
7345 LoongArch::R1,
true,
7348 if (!Subtarget.is64Bit())
7356 unsigned *
Fast)
const {
7357 if (!Subtarget.hasUAL())
7371#define NODE_NAME_CASE(node) \
7372 case LoongArchISD::node: \
7373 return "LoongArchISD::" #node;
7478#undef NODE_NAME_CASE
7491 LoongArch::R7, LoongArch::R8, LoongArch::R9,
7492 LoongArch::R10, LoongArch::R11};
7496 LoongArch::F3, LoongArch::F4, LoongArch::F5,
7497 LoongArch::F6, LoongArch::F7};
7500 LoongArch::F0_64, LoongArch::F1_64, LoongArch::F2_64, LoongArch::F3_64,
7501 LoongArch::F4_64, LoongArch::F5_64, LoongArch::F6_64, LoongArch::F7_64};
7504 LoongArch::VR3, LoongArch::VR4, LoongArch::VR5,
7505 LoongArch::VR6, LoongArch::VR7};
7508 LoongArch::XR3, LoongArch::XR4, LoongArch::XR5,
7509 LoongArch::XR6, LoongArch::XR7};
7515 unsigned ValNo2,
MVT ValVT2,
MVT LocVT2,
7517 unsigned GRLenInBytes = GRLen / 8;
7528 State.AllocateStack(GRLenInBytes, StackAlign),
7531 ValNo2, ValVT2, State.AllocateStack(GRLenInBytes,
Align(GRLenInBytes)),
7542 ValNo2, ValVT2, State.AllocateStack(GRLenInBytes,
Align(GRLenInBytes)),
7550 unsigned ValNo,
MVT ValVT,
7553 unsigned GRLen =
DL.getLargestLegalIntTypeSizeInBits();
7554 assert((GRLen == 32 || GRLen == 64) &&
"Unspport GRLen");
7555 MVT GRLenVT = GRLen == 32 ? MVT::i32 : MVT::i64;
7560 if (IsRet && ValNo > 1)
7564 bool UseGPRForFloat =
true;
7574 UseGPRForFloat = ArgFlags.
isVarArg();
7587 unsigned TwoGRLenInBytes = (2 * GRLen) / 8;
7590 DL.getTypeAllocSize(OrigTy) == TwoGRLenInBytes) {
7591 unsigned RegIdx = State.getFirstUnallocated(
ArgGPRs);
7593 if (RegIdx != std::size(
ArgGPRs) && RegIdx % 2 == 1)
7599 State.getPendingArgFlags();
7602 "PendingLocs and PendingArgFlags out of sync");
7606 UseGPRForFloat =
true;
7608 if (UseGPRForFloat && ValVT == MVT::f32) {
7611 }
else if (UseGPRForFloat && GRLen == 64 && ValVT == MVT::f64) {
7614 }
else if (UseGPRForFloat && GRLen == 32 && ValVT == MVT::f64) {
7617 assert(PendingLocs.
empty() &&
"Can't lower f64 if it is split");
7659 PendingLocs.
size() <= 2) {
7660 assert(PendingLocs.
size() == 2 &&
"Unexpected PendingLocs.size()");
7665 PendingLocs.
clear();
7666 PendingArgFlags.
clear();
7673 unsigned StoreSizeBytes = GRLen / 8;
7676 if (ValVT == MVT::f32 && !UseGPRForFloat) {
7678 }
else if (ValVT == MVT::f64 && !UseGPRForFloat) {
7682 UseGPRForFloat =
false;
7683 StoreSizeBytes = 16;
7684 StackAlign =
Align(16);
7687 UseGPRForFloat =
false;
7688 StoreSizeBytes = 32;
7689 StackAlign =
Align(32);
7695 Reg ? 0 : State.AllocateStack(StoreSizeBytes, StackAlign);
7699 if (!PendingLocs.
empty()) {
7701 assert(PendingLocs.
size() > 2 &&
"Unexpected PendingLocs.size()");
7702 for (
auto &It : PendingLocs) {
7704 It.convertToReg(
Reg);
7709 PendingLocs.clear();
7710 PendingArgFlags.
clear();
7713 assert((!UseGPRForFloat || LocVT == GRLenVT) &&
7714 "Expected an GRLenVT at this stage");
7731void LoongArchTargetLowering::analyzeInputArgs(
7734 LoongArchCCAssignFn Fn)
const {
7736 for (
unsigned i = 0, e =
Ins.size(); i != e; ++i) {
7737 MVT ArgVT =
Ins[i].VT;
7738 Type *ArgTy =
nullptr;
7740 ArgTy = FType->getReturnType();
7741 else if (Ins[i].isOrigArg())
7742 ArgTy = FType->getParamType(Ins[i].getOrigArgIndex());
7746 CCInfo, IsRet, ArgTy)) {
7747 LLVM_DEBUG(
dbgs() <<
"InputArg #" << i <<
" has unhandled type " << ArgVT
7754void LoongArchTargetLowering::analyzeOutputArgs(
7757 CallLoweringInfo *CLI, LoongArchCCAssignFn Fn)
const {
7758 for (
unsigned i = 0, e = Outs.
size(); i != e; ++i) {
7759 MVT ArgVT = Outs[i].VT;
7760 Type *OrigTy = CLI ? CLI->getArgs()[Outs[i].OrigArgIndex].Ty :
nullptr;
7764 CCInfo, IsRet, OrigTy)) {
7765 LLVM_DEBUG(
dbgs() <<
"OutputArg #" << i <<
" has unhandled type " << ArgVT
7806 if (In.isOrigArg()) {
7811 if ((
BitWidth <= 32 && In.Flags.isSExt()) ||
7812 (
BitWidth < 32 && In.Flags.isZExt())) {
7862 Register LoVReg =
RegInfo.createVirtualRegister(&LoongArch::GPRRegClass);
7875 Register HiVReg =
RegInfo.createVirtualRegister(&LoongArch::GPRRegClass);
7895 Val = DAG.
getNode(ISD::BITCAST,
DL, LocVT, Val);
7905 if (LocVT == MVT::i32 || LocVT == MVT::i64) {
7909 LoongArch::R23, LoongArch::R24, LoongArch::R25,
7910 LoongArch::R26, LoongArch::R27, LoongArch::R28,
7911 LoongArch::R29, LoongArch::R30, LoongArch::R31};
7918 if (LocVT == MVT::f32) {
7921 static const MCPhysReg FPR32List[] = {LoongArch::F24, LoongArch::F25,
7922 LoongArch::F26, LoongArch::F27};
7929 if (LocVT == MVT::f64) {
7932 static const MCPhysReg FPR64List[] = {LoongArch::F28_64, LoongArch::F29_64,
7933 LoongArch::F30_64, LoongArch::F31_64};
7963 "GHC calling convention requires the F and D extensions");
7967 MVT GRLenVT = Subtarget.getGRLenVT();
7968 unsigned GRLenInBytes = Subtarget.getGRLen() / 8;
7970 std::vector<SDValue> OutChains;
7979 analyzeInputArgs(MF, CCInfo, Ins,
false,
CC_LoongArch);
7981 for (
unsigned i = 0, e = ArgLocs.
size(), InsIdx = 0; i != e; ++i, ++InsIdx) {
7998 unsigned ArgIndex = Ins[InsIdx].OrigArgIndex;
7999 unsigned ArgPartOffset = Ins[InsIdx].PartOffset;
8000 assert(ArgPartOffset == 0);
8001 while (i + 1 != e && Ins[InsIdx + 1].OrigArgIndex == ArgIndex) {
8003 unsigned PartOffset = Ins[InsIdx + 1].PartOffset - ArgPartOffset;
8027 int VaArgOffset, VarArgsSaveSize;
8031 if (ArgRegs.
size() == Idx) {
8033 VarArgsSaveSize = 0;
8035 VarArgsSaveSize = GRLenInBytes * (ArgRegs.
size() - Idx);
8036 VaArgOffset = -VarArgsSaveSize;
8042 LoongArchFI->setVarArgsFrameIndex(FI);
8050 VarArgsSaveSize += GRLenInBytes;
8055 for (
unsigned I = Idx;
I < ArgRegs.
size();
8056 ++
I, VaArgOffset += GRLenInBytes) {
8057 const Register Reg = RegInfo.createVirtualRegister(RC);
8058 RegInfo.addLiveIn(ArgRegs[
I], Reg);
8066 ->setValue((
Value *)
nullptr);
8067 OutChains.push_back(Store);
8069 LoongArchFI->setVarArgsSaveSize(VarArgsSaveSize);
8074 if (!OutChains.empty()) {
8075 OutChains.push_back(Chain);
8090 if (
N->getNumValues() != 1)
8092 if (!
N->hasNUsesOfValue(1, 0))
8095 SDNode *Copy = *
N->user_begin();
8101 if (Copy->getGluedNode())
8105 bool HasRet =
false;
8115 Chain = Copy->getOperand(0);
8120bool LoongArchTargetLowering::isEligibleForTailCallOptimization(
8124 auto CalleeCC = CLI.CallConv;
8125 auto &Outs = CLI.Outs;
8127 auto CallerCC = Caller.getCallingConv();
8134 for (
auto &VA : ArgLocs)
8140 auto IsCallerStructRet = Caller.hasStructRetAttr();
8141 auto IsCalleeStructRet = Outs.
empty() ?
false : Outs[0].Flags.isSRet();
8142 if (IsCallerStructRet || IsCalleeStructRet)
8146 for (
auto &Arg : Outs)
8147 if (Arg.Flags.isByVal())
8152 const uint32_t *CallerPreserved =
TRI->getCallPreservedMask(MF, CallerCC);
8153 if (CalleeCC != CallerCC) {
8154 const uint32_t *CalleePreserved =
TRI->getCallPreservedMask(MF, CalleeCC);
8155 if (!
TRI->regmaskSubsetEqual(CallerPreserved, CalleePreserved))
8181 MVT GRLenVT = Subtarget.getGRLenVT();
8193 analyzeOutputArgs(MF, ArgCCInfo, Outs,
false, &CLI,
CC_LoongArch);
8197 IsTailCall = isEligibleForTailCallOptimization(ArgCCInfo, CLI, MF, ArgLocs);
8203 "site marked musttail");
8210 for (
unsigned i = 0, e = Outs.
size(); i != e; ++i) {
8212 if (!Flags.isByVal())
8216 unsigned Size = Flags.getByValSize();
8217 Align Alignment = Flags.getNonZeroByValAlign();
8224 Chain = DAG.
getMemcpy(Chain,
DL, FIPtr, Arg, SizeNode, Alignment,
8226 false,
nullptr, std::nullopt,
8238 for (
unsigned i = 0, j = 0, e = ArgLocs.
size(), OutIdx = 0; i != e;
8241 SDValue ArgValue = OutVals[OutIdx];
8250 DAG.
getVTList(MVT::i32, MVT::i32), ArgValue);
8262 if (!StackPtr.getNode())
8274 RegsToPass.
push_back(std::make_pair(RegHigh,
Hi));
8289 unsigned ArgIndex = Outs[OutIdx].OrigArgIndex;
8290 unsigned ArgPartOffset = Outs[OutIdx].PartOffset;
8291 assert(ArgPartOffset == 0);
8296 while (i + 1 != e && Outs[OutIdx + 1].OrigArgIndex == ArgIndex) {
8297 SDValue PartValue = OutVals[OutIdx + 1];
8298 unsigned PartOffset = Outs[OutIdx + 1].PartOffset - ArgPartOffset;
8313 for (
const auto &Part : Parts) {
8314 SDValue PartValue = Part.first;
8315 SDValue PartOffset = Part.second;
8322 ArgValue = SpillSlot;
8328 if (Flags.isByVal())
8329 ArgValue = ByValArgs[j++];
8336 assert(!IsTailCall &&
"Tail call not allowed if stack is used "
8337 "for passing parameters");
8340 if (!StackPtr.getNode())
8353 if (!MemOpChains.
empty())
8359 for (
auto &Reg : RegsToPass) {
8360 Chain = DAG.
getCopyToReg(Chain,
DL, Reg.first, Reg.second, Glue);
8382 Ops.push_back(Chain);
8383 Ops.push_back(Callee);
8387 for (
auto &Reg : RegsToPass)
8388 Ops.push_back(DAG.
getRegister(Reg.first, Reg.second.getValueType()));
8393 const uint32_t *Mask =
TRI->getCallPreservedMask(MF, CallConv);
8394 assert(Mask &&
"Missing call preserved mask for calling convention");
8400 Ops.push_back(Glue);
8412 assert(Subtarget.is64Bit() &&
"Medium code model requires LA64");
8416 assert(Subtarget.is64Bit() &&
"Large code model requires LA64");
8439 analyzeInputArgs(MF, RetCCInfo, Ins,
true,
CC_LoongArch);
8442 for (
unsigned i = 0, e = RVLocs.
size(); i != e; ++i) {
8443 auto &VA = RVLocs[i];
8451 if (VA.getLocVT() == MVT::i32 && VA.getValVT() == MVT::f64) {
8452 assert(VA.needsCustom());
8458 RetValue, RetValue2);
8471 const Type *RetTy)
const {
8473 CCState CCInfo(CallConv, IsVarArg, MF, RVLocs, Context);
8475 for (
unsigned i = 0, e = Outs.
size(); i != e; ++i) {
8479 Outs[i].Flags, CCInfo,
true,
nullptr))
8505 for (
unsigned i = 0, e = RVLocs.
size(), OutIdx = 0; i < e; ++i, ++OutIdx) {
8506 SDValue Val = OutVals[OutIdx];
8515 DAG.
getVTList(MVT::i32, MVT::i32), Val);
8519 Register RegHi = RVLocs[++i].getLocReg();
8552 const APInt &SplatValue,
const unsigned SplatBitSize)
const {
8555 if (SplatBitSize == 16 && !(V & 0x00FF)) {
8557 RequiredImm = (0b10101 << 8) | (V >> 8);
8558 return {
true, RequiredImm};
8559 }
else if (SplatBitSize == 32) {
8561 if (!(V & 0xFFFF00FF)) {
8562 RequiredImm = (0b10001 << 8) | (V >> 8);
8563 return {
true, RequiredImm};
8566 if (!(V & 0xFF00FFFF)) {
8567 RequiredImm = (0b10010 << 8) | (V >> 16);
8568 return {
true, RequiredImm};
8571 if (!(V & 0x00FFFFFF)) {
8572 RequiredImm = (0b10011 << 8) | (V >> 24);
8573 return {
true, RequiredImm};
8576 if ((V & 0xFFFF00FF) == 0xFF) {
8577 RequiredImm = (0b10110 << 8) | (V >> 8);
8578 return {
true, RequiredImm};
8581 if ((V & 0xFF00FFFF) == 0xFFFF) {
8582 RequiredImm = (0b10111 << 8) | (V >> 16);
8583 return {
true, RequiredImm};
8586 if ((V & 0x7E07FFFF) == 0x3E000000 || (V & 0x7E07FFFF) == 0x40000000) {
8588 (0b11010 << 8) | (((V >> 24) & 0xC0) ^ 0x40) | ((V >> 19) & 0x3F);
8589 return {
true, RequiredImm};
8591 }
else if (SplatBitSize == 64) {
8593 if ((V & 0xFFFFFFFF7E07FFFFULL) == 0x3E000000ULL ||
8594 (V & 0xFFFFFFFF7E07FFFFULL) == 0x40000000ULL) {
8596 (0b11011 << 8) | (((V >> 24) & 0xC0) ^ 0x40) | ((V >> 19) & 0x3F);
8597 return {
true, RequiredImm};
8600 if ((V & 0x7FC0FFFFFFFFFFFFULL) == 0x4000000000000000ULL ||
8601 (V & 0x7FC0FFFFFFFFFFFFULL) == 0x3FC0000000000000ULL) {
8603 (0b11100 << 8) | (((V >> 56) & 0xC0) ^ 0x40) | ((V >> 48) & 0x3F);
8604 return {
true, RequiredImm};
8607 auto sameBitsPreByte = [](
uint64_t x) -> std::pair<bool, uint8_t> {
8609 for (
int i = 0; i < 8; ++i) {
8611 if (
byte == 0 ||
byte == 0xFF)
8612 res |= ((
byte & 1) << i);
8619 auto [IsSame, Suffix] = sameBitsPreByte(V);
8621 RequiredImm = (0b11001 << 8) | Suffix;
8622 return {
true, RequiredImm};
8625 return {
false, RequiredImm};
8630 if (!Subtarget.hasExtLSX())
8633 if (VT == MVT::f32) {
8634 uint64_t masked = Imm.bitcastToAPInt().getZExtValue() & 0x7e07ffff;
8635 return (masked == 0x3e000000 || masked == 0x40000000);
8638 if (VT == MVT::f64) {
8639 uint64_t masked = Imm.bitcastToAPInt().getZExtValue() & 0x7fc0ffffffffffff;
8640 return (masked == 0x3fc0000000000000 || masked == 0x4000000000000000);
8646bool LoongArchTargetLowering::isFPImmLegal(
const APFloat &Imm,
EVT VT,
8647 bool ForCodeSize)
const {
8649 if (VT == MVT::f32 && !Subtarget.hasBasicF())
8651 if (VT == MVT::f64 && !Subtarget.hasBasicD())
8653 return (Imm.isZero() || Imm.isExactlyValue(1.0) ||
isFPImmVLDILegal(Imm, VT));
8664bool LoongArchTargetLowering::shouldInsertFencesForAtomic(
8674 Type *Ty =
I->getOperand(0)->getType();
8676 unsigned Size = Ty->getIntegerBitWidth();
8692 EVT VT =
Y.getValueType();
8695 return Subtarget.hasExtLSX() && VT.
isInteger();
8707 case Intrinsic::loongarch_masked_atomicrmw_xchg_i32:
8708 case Intrinsic::loongarch_masked_atomicrmw_add_i32:
8709 case Intrinsic::loongarch_masked_atomicrmw_sub_i32:
8710 case Intrinsic::loongarch_masked_atomicrmw_nand_i32:
8712 Info.memVT = MVT::i32;
8713 Info.ptrVal =
I.getArgOperand(0);
8715 Info.align =
Align(4);
8732 "Unable to expand");
8733 unsigned MinWordSize = 4;
8745 Value *AlignedAddr = Builder.CreateIntrinsic(
8746 Intrinsic::ptrmask, {PtrTy, IntTy},
8747 {Addr, ConstantInt::get(IntTy, ~(
uint64_t)(MinWordSize - 1))},
nullptr,
8750 Value *AddrInt = Builder.CreatePtrToInt(Addr, IntTy);
8751 Value *PtrLSB = Builder.CreateAnd(AddrInt, MinWordSize - 1,
"PtrLSB");
8752 Value *ShiftAmt = Builder.CreateShl(PtrLSB, 3);
8753 ShiftAmt = Builder.CreateTrunc(ShiftAmt, WordType,
"ShiftAmt");
8754 Value *Mask = Builder.CreateShl(
8755 ConstantInt::get(WordType,
8758 Value *Inv_Mask = Builder.CreateNot(Mask,
"Inv_Mask");
8759 Value *ValOperand_Shifted =
8760 Builder.CreateShl(Builder.CreateZExt(AI->
getValOperand(), WordType),
8761 ShiftAmt,
"ValOperand_Shifted");
8764 NewOperand = Builder.CreateOr(ValOperand_Shifted, Inv_Mask,
"AndOperand");
8766 NewOperand = ValOperand_Shifted;
8769 Builder.CreateAtomicRMW(
Op, AlignedAddr, NewOperand,
Align(MinWordSize),
8772 Value *Shift = Builder.CreateLShr(NewAI, ShiftAmt,
"shifted");
8773 Value *Trunc = Builder.CreateTrunc(Shift,
ValueType,
"extracted");
8792 if (Subtarget.hasLAM_BH() && Subtarget.is64Bit() &&
8800 if (Subtarget.hasLAMCAS()) {
8822 return Intrinsic::loongarch_masked_atomicrmw_xchg_i64;
8824 return Intrinsic::loongarch_masked_atomicrmw_add_i64;
8826 return Intrinsic::loongarch_masked_atomicrmw_sub_i64;
8828 return Intrinsic::loongarch_masked_atomicrmw_nand_i64;
8830 return Intrinsic::loongarch_masked_atomicrmw_umax_i64;
8832 return Intrinsic::loongarch_masked_atomicrmw_umin_i64;
8834 return Intrinsic::loongarch_masked_atomicrmw_max_i64;
8836 return Intrinsic::loongarch_masked_atomicrmw_min_i64;
8846 return Intrinsic::loongarch_masked_atomicrmw_xchg_i32;
8848 return Intrinsic::loongarch_masked_atomicrmw_add_i32;
8850 return Intrinsic::loongarch_masked_atomicrmw_sub_i32;
8852 return Intrinsic::loongarch_masked_atomicrmw_nand_i32;
8854 return Intrinsic::loongarch_masked_atomicrmw_umax_i32;
8856 return Intrinsic::loongarch_masked_atomicrmw_umin_i32;
8858 return Intrinsic::loongarch_masked_atomicrmw_max_i32;
8860 return Intrinsic::loongarch_masked_atomicrmw_min_i32;
8872 if (Subtarget.hasLAMCAS())
8884 unsigned GRLen = Subtarget.getGRLen();
8886 Value *FailureOrdering =
8887 Builder.getIntN(Subtarget.getGRLen(),
static_cast<uint64_t>(FailOrd));
8888 Intrinsic::ID CmpXchgIntrID = Intrinsic::loongarch_masked_cmpxchg_i32;
8890 CmpXchgIntrID = Intrinsic::loongarch_masked_cmpxchg_i64;
8891 CmpVal = Builder.CreateSExt(CmpVal, Builder.getInt64Ty());
8892 NewVal = Builder.CreateSExt(NewVal, Builder.getInt64Ty());
8893 Mask = Builder.CreateSExt(Mask, Builder.getInt64Ty());
8896 Value *Result = Builder.CreateIntrinsic(
8897 CmpXchgIntrID, Tys, {AlignedAddr, CmpVal, NewVal, Mask, FailureOrdering});
8899 Result = Builder.CreateTrunc(Result, Builder.getInt32Ty());
8915 Builder.CreateNot(Mask,
"Inv_Mask"),
8922 unsigned GRLen = Subtarget.getGRLen();
8931 Incr = Builder.CreateSExt(Incr, Builder.getInt64Ty());
8932 Mask = Builder.CreateSExt(Mask, Builder.getInt64Ty());
8933 ShiftAmt = Builder.CreateSExt(ShiftAmt, Builder.getInt64Ty());
8949 Builder.CreateSub(Builder.getIntN(GRLen, GRLen - ValWidth), ShiftAmt);
8950 Result = Builder.CreateCall(LlwOpScwLoop,
8951 {AlignedAddr, Incr, Mask, SextShamt, Ordering});
8954 Builder.CreateCall(LlwOpScwLoop, {AlignedAddr, Incr, Mask, Ordering});
8958 Result = Builder.CreateTrunc(Result, Builder.getInt32Ty());
8981 const Constant *PersonalityFn)
const {
8982 return LoongArch::R4;
8986 const Constant *PersonalityFn)
const {
8987 return LoongArch::R5;
8998 int RefinementSteps = VT.
getScalarType() == MVT::f64 ? 2 : 1;
8999 return RefinementSteps;
9004 int &RefinementSteps,
9005 bool &UseOneConstNR,
9006 bool Reciprocal)
const {
9007 if (Subtarget.hasFrecipe()) {
9011 if (VT == MVT::f32 || (VT == MVT::f64 && Subtarget.hasBasicD()) ||
9012 (VT == MVT::v4f32 && Subtarget.hasExtLSX()) ||
9013 (VT == MVT::v2f64 && Subtarget.hasExtLSX()) ||
9014 (VT == MVT::v8f32 && Subtarget.hasExtLASX()) ||
9015 (VT == MVT::v4f64 && Subtarget.hasExtLASX())) {
9034 int &RefinementSteps)
const {
9035 if (Subtarget.hasFrecipe()) {
9039 if (VT == MVT::f32 || (VT == MVT::f64 && Subtarget.hasBasicD()) ||
9040 (VT == MVT::v4f32 && Subtarget.hasExtLSX()) ||
9041 (VT == MVT::v2f64 && Subtarget.hasExtLSX()) ||
9042 (VT == MVT::v8f32 && Subtarget.hasExtLASX()) ||
9043 (VT == MVT::v4f64 && Subtarget.hasExtLASX())) {
9060LoongArchTargetLowering::getConstraintType(
StringRef Constraint)
const {
9080 if (Constraint.
size() == 1) {
9081 switch (Constraint[0]) {
9097 if (Constraint ==
"ZC" || Constraint ==
"ZB")
9106 return StringSwitch<InlineAsm::ConstraintCode>(ConstraintCode)
9113std::pair<unsigned, const TargetRegisterClass *>
9114LoongArchTargetLowering::getRegForInlineAsmConstraint(
9118 if (Constraint.
size() == 1) {
9119 switch (Constraint[0]) {
9124 return std::make_pair(0U, &LoongArch::GPRRegClass);
9126 return std::make_pair(0U, &LoongArch::GPRNoR0R1RegClass);
9128 if (Subtarget.hasBasicF() && VT == MVT::f32)
9129 return std::make_pair(0U, &LoongArch::FPR32RegClass);
9130 if (Subtarget.hasBasicD() && VT == MVT::f64)
9131 return std::make_pair(0U, &LoongArch::FPR64RegClass);
9132 if (Subtarget.hasExtLSX() &&
9133 TRI->isTypeLegalForClass(LoongArch::LSX128RegClass, VT))
9134 return std::make_pair(0U, &LoongArch::LSX128RegClass);
9135 if (Subtarget.hasExtLASX() &&
9136 TRI->isTypeLegalForClass(LoongArch::LASX256RegClass, VT))
9137 return std::make_pair(0U, &LoongArch::LASX256RegClass);
9157 bool IsFP = Constraint[2] ==
'f';
9158 std::pair<StringRef, StringRef> Temp = Constraint.
split(
'$');
9159 std::pair<unsigned, const TargetRegisterClass *>
R;
9164 unsigned RegNo =
R.first;
9165 if (LoongArch::F0 <= RegNo && RegNo <= LoongArch::F31) {
9166 if (Subtarget.hasBasicD() && (VT == MVT::f64 || VT == MVT::Other)) {
9167 unsigned DReg = RegNo - LoongArch::F0 + LoongArch::F0_64;
9168 return std::make_pair(DReg, &LoongArch::FPR64RegClass);
9178void LoongArchTargetLowering::LowerAsmOperandForConstraint(
9182 if (Constraint.
size() == 1) {
9183 switch (Constraint[0]) {
9187 uint64_t CVal =
C->getSExtValue();
9190 Subtarget.getGRLenVT()));
9196 uint64_t CVal =
C->getSExtValue();
9199 Subtarget.getGRLenVT()));
9205 if (
C->getZExtValue() == 0)
9212 uint64_t CVal =
C->getZExtValue();
9225#define GET_REGISTER_MATCHER
9226#include "LoongArchGenAsmMatcher.inc"
9232 std::string NewRegName = Name.second.str();
9238 BitVector ReservedRegs = Subtarget.getRegisterInfo()->getReservedRegs(MF);
9239 if (!ReservedRegs.
test(Reg))
9256 const APInt &Imm = ConstNode->getAPIntValue();
9258 if ((Imm + 1).isPowerOf2() || (Imm - 1).isPowerOf2() ||
9259 (1 - Imm).isPowerOf2() || (-1 - Imm).isPowerOf2())
9262 if (ConstNode->hasOneUse() &&
9263 ((Imm - 2).isPowerOf2() || (Imm - 4).isPowerOf2() ||
9264 (Imm - 8).isPowerOf2() || (Imm - 16).isPowerOf2()))
9270 if (ConstNode->hasOneUse() && !(Imm.sge(-2048) && Imm.sle(4095))) {
9271 unsigned Shifts = Imm.countr_zero();
9277 APInt ImmPop = Imm.ashr(Shifts);
9278 if (ImmPop == 3 || ImmPop == 5 || ImmPop == 9 || ImmPop == 17)
9282 APInt ImmSmall =
APInt(Imm.getBitWidth(), 1ULL << Shifts,
true);
9283 if ((Imm - ImmSmall).isPowerOf2() || (Imm + ImmSmall).isPowerOf2() ||
9284 (ImmSmall - Imm).isPowerOf2())
9294 Type *Ty,
unsigned AS,
9349 EVT MemVT = LD->getMemoryVT();
9350 if ((MemVT == MVT::i8 || MemVT == MVT::i16) &&
9361 return Subtarget.is64Bit() && SrcVT == MVT::i32 && DstVT == MVT::i64;
9370 if (
Y.getValueType().isVector())
9382 Type *Ty,
bool IsSigned)
const {
9383 if (Subtarget.is64Bit() && Ty->isIntegerTy(32))
9392 if (Subtarget.isSoftFPABI() && (
Type.isFloatingPoint() && !
Type.isVector() &&
9393 Type.getSizeInBits() < Subtarget.getGRLen()))
9403 Align &PrefAlign)
const {
9407 if (Subtarget.is64Bit()) {
9409 PrefAlign =
Align(8);
9412 PrefAlign =
Align(4);
9427bool LoongArchTargetLowering::splitValueIntoRegisterParts(
9429 unsigned NumParts,
MVT PartVT, std::optional<CallingConv::ID> CC)
const {
9430 bool IsABIRegCopy = CC.has_value();
9433 if (IsABIRegCopy && (ValueVT == MVT::f16 || ValueVT == MVT::bf16) &&
9434 PartVT == MVT::f32) {
9437 Val = DAG.
getNode(ISD::BITCAST,
DL, MVT::i16, Val);
9441 Val = DAG.
getNode(ISD::BITCAST,
DL, MVT::f32, Val);
9449SDValue LoongArchTargetLowering::joinRegisterPartsIntoValue(
9451 MVT PartVT,
EVT ValueVT, std::optional<CallingConv::ID> CC)
const {
9452 bool IsABIRegCopy = CC.has_value();
9454 if (IsABIRegCopy && (ValueVT == MVT::f16 || ValueVT == MVT::bf16) &&
9455 PartVT == MVT::f32) {
9459 Val = DAG.
getNode(ISD::BITCAST,
DL, MVT::i32, Val);
9461 Val = DAG.
getNode(ISD::BITCAST,
DL, ValueVT, Val);
9472 if (VT == MVT::f16 && Subtarget.hasBasicF())
9478unsigned LoongArchTargetLowering::getNumRegistersForCallingConv(
9481 if (VT == MVT::f16 && Subtarget.hasBasicF())
9490 unsigned Depth)
const {
9491 EVT VT =
Op.getValueType();
9493 unsigned Opc =
Op.getOpcode();
9500 MVT SrcVT = Src.getSimpleValueType();
9505 if (OriginalDemandedBits.
countr_zero() >= NumElts)
9509 APInt KnownUndef, KnownZero;
9525 if (KnownSrc.
One[SrcBits - 1])
9527 else if (KnownSrc.
Zero[SrcBits - 1])
9532 Src, DemandedSrcBits, DemandedElts, TLO.
DAG,
Depth + 1))
9539 Op, OriginalDemandedBits, OriginalDemandedElts, Known, TLO,
Depth);
unsigned const MachineRegisterInfo * MRI
static MCRegister MatchRegisterName(StringRef Name)
static bool checkValueWidth(SDValue V, unsigned width, ISD::LoadExtType &ExtType)
static SDValue performORCombine(SDNode *N, TargetLowering::DAGCombinerInfo &DCI, const AArch64Subtarget *Subtarget, const AArch64TargetLowering &TLI)
static SDValue performANDCombine(SDNode *N, TargetLowering::DAGCombinerInfo &DCI)
static SDValue performSETCCCombine(SDNode *N, TargetLowering::DAGCombinerInfo &DCI, SelectionDAG &DAG)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static msgpack::DocNode getNode(msgpack::DocNode DN, msgpack::Type Type, MCValue Val)
#define NODE_NAME_CASE(node)
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static MCRegister MatchRegisterAltName(StringRef Name)
Maps from the set of all alternative registernames to a register number.
Function Alias Analysis Results
static uint64_t getConstant(const Value *IndexValue)
static SDValue getTargetNode(ConstantPoolSDNode *N, const SDLoc &DL, EVT Ty, SelectionDAG &DAG, unsigned Flags)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static SDValue convertValVTToLocVT(SelectionDAG &DAG, SDValue Val, const CCValAssign &VA, const SDLoc &DL)
static SDValue unpackFromMemLoc(SelectionDAG &DAG, SDValue Chain, const CCValAssign &VA, const SDLoc &DL)
static SDValue convertLocVTToValVT(SelectionDAG &DAG, SDValue Val, const CCValAssign &VA, const SDLoc &DL)
static MachineBasicBlock * emitSelectPseudo(MachineInstr &MI, MachineBasicBlock *BB, unsigned Opcode)
static SDValue unpackFromRegLoc(const CSKYSubtarget &Subtarget, SelectionDAG &DAG, SDValue Chain, const CCValAssign &VA, const SDLoc &DL)
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
const HexagonInstrInfo * TII
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
static SDValue performINTRINSIC_WO_CHAINCombine(SDNode *N, SelectionDAG &DAG, TargetLowering::DAGCombinerInfo &DCI, const LoongArchSubtarget &Subtarget)
const MCPhysReg ArgFPR32s[]
static SDValue lower128BitShuffle(const SDLoc &DL, ArrayRef< int > Mask, MVT VT, SDValue V1, SDValue V2, SelectionDAG &DAG, const LoongArchSubtarget &Subtarget)
Dispatching routine to lower various 128-bit LoongArch vector shuffles.
static SDValue lowerVECTOR_SHUFFLE_XVSHUF4I(const SDLoc &DL, ArrayRef< int > Mask, MVT VT, SDValue V1, SDValue V2, SelectionDAG &DAG, const LoongArchSubtarget &Subtarget)
Lower VECTOR_SHUFFLE into XVSHUF4I (if possible).
static SDValue lowerVECTOR_SHUFFLE_VPICKEV(const SDLoc &DL, ArrayRef< int > Mask, MVT VT, SDValue V1, SDValue V2, SelectionDAG &DAG)
Lower VECTOR_SHUFFLE into VPICKEV (if possible).
static SDValue combineSelectToBinOp(SDNode *N, SelectionDAG &DAG, const LoongArchSubtarget &Subtarget)
static SDValue lowerVECTOR_SHUFFLE_XVPICKOD(const SDLoc &DL, ArrayRef< int > Mask, MVT VT, SDValue V1, SDValue V2, SelectionDAG &DAG)
Lower VECTOR_SHUFFLE into XVPICKOD (if possible).
static SDValue unpackF64OnLA32DSoftABI(SelectionDAG &DAG, SDValue Chain, const CCValAssign &VA, const CCValAssign &HiVA, const SDLoc &DL)
static bool fitsRegularPattern(typename SmallVectorImpl< ValType >::const_iterator Begin, unsigned CheckStride, typename SmallVectorImpl< ValType >::const_iterator End, ValType ExpectedIndex, unsigned ExpectedIndexStride)
Determine whether a range fits a regular pattern of values.
static SDValue emitIntrinsicErrorMessage(SDValue Op, StringRef ErrorMsg, SelectionDAG &DAG)
static cl::opt< bool > ZeroDivCheck("loongarch-check-zero-division", cl::Hidden, cl::desc("Trap on integer division by zero."), cl::init(false))
static SDValue lowerVECTOR_SHUFFLE_VSHUF(const SDLoc &DL, ArrayRef< int > Mask, MVT VT, SDValue V1, SDValue V2, SelectionDAG &DAG, const LoongArchSubtarget &Subtarget)
Lower VECTOR_SHUFFLE into VSHUF.
static int getEstimateRefinementSteps(EVT VT, const LoongArchSubtarget &Subtarget)
static void emitErrorAndReplaceIntrinsicResults(SDNode *N, SmallVectorImpl< SDValue > &Results, SelectionDAG &DAG, StringRef ErrorMsg, bool WithChain=true)
static SDValue lowerVECTOR_SHUFFLEAsByteRotate(const SDLoc &DL, ArrayRef< int > Mask, MVT VT, SDValue V1, SDValue V2, SelectionDAG &DAG, const LoongArchSubtarget &Subtarget)
Lower VECTOR_SHUFFLE as byte rotate (if possible).
static SDValue checkIntrinsicImmArg(SDValue Op, unsigned ImmOp, SelectionDAG &DAG, bool IsSigned=false)
static SDValue performMOVFR2GR_SCombine(SDNode *N, SelectionDAG &DAG, TargetLowering::DAGCombinerInfo &DCI, const LoongArchSubtarget &Subtarget)
static SDValue lowerVECTOR_SHUFFLE_VILVH(const SDLoc &DL, ArrayRef< int > Mask, MVT VT, SDValue V1, SDValue V2, SelectionDAG &DAG)
Lower VECTOR_SHUFFLE into VILVH (if possible).
static bool CC_LoongArch(const DataLayout &DL, LoongArchABI::ABI ABI, unsigned ValNo, MVT ValVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State, bool IsRet, Type *OrigTy)
static Align getPrefTypeAlign(EVT VT, SelectionDAG &DAG)
static SDValue performSPLIT_PAIR_F64Combine(SDNode *N, SelectionDAG &DAG, TargetLowering::DAGCombinerInfo &DCI, const LoongArchSubtarget &Subtarget)
static SDValue performBITCASTCombine(SDNode *N, SelectionDAG &DAG, TargetLowering::DAGCombinerInfo &DCI, const LoongArchSubtarget &Subtarget)
static SDValue performSRLCombine(SDNode *N, SelectionDAG &DAG, TargetLowering::DAGCombinerInfo &DCI, const LoongArchSubtarget &Subtarget)
static MachineBasicBlock * emitSplitPairF64Pseudo(MachineInstr &MI, MachineBasicBlock *BB, const LoongArchSubtarget &Subtarget)
static SDValue lowerVectorBitSetImm(SDNode *Node, SelectionDAG &DAG)
static SDValue performSETCC_BITCASTCombine(SDNode *N, SelectionDAG &DAG, TargetLowering::DAGCombinerInfo &DCI, const LoongArchSubtarget &Subtarget)
static SDValue lowerVECTOR_SHUFFLE_XVPACKOD(const SDLoc &DL, ArrayRef< int > Mask, MVT VT, SDValue V1, SDValue V2, SelectionDAG &DAG)
Lower VECTOR_SHUFFLE into XVPACKOD (if possible).
static std::optional< bool > matchSetCC(SDValue LHS, SDValue RHS, ISD::CondCode CC, SDValue Val)
static SDValue lowerBUILD_VECTORAsBroadCastLoad(BuildVectorSDNode *BVOp, const SDLoc &DL, SelectionDAG &DAG)
#define CRC_CASE_EXT_BINARYOP(NAME, NODE)
static SDValue lowerVectorBitRevImm(SDNode *Node, SelectionDAG &DAG)
static bool checkBitcastSrcVectorSize(SDValue Src, unsigned Size, unsigned Depth)
static SDValue lowerVECTOR_SHUFFLEAsShift(const SDLoc &DL, ArrayRef< int > Mask, MVT VT, SDValue V1, SDValue V2, SelectionDAG &DAG, const LoongArchSubtarget &Subtarget, const APInt &Zeroable)
Lower VECTOR_SHUFFLE as shift (if possible).
static SDValue lowerVECTOR_SHUFFLE_VSHUF4I(const SDLoc &DL, ArrayRef< int > Mask, MVT VT, SDValue V1, SDValue V2, SelectionDAG &DAG, const LoongArchSubtarget &Subtarget)
Lower VECTOR_SHUFFLE into VSHUF4I (if possible).
static SDValue truncateVecElts(SDNode *Node, SelectionDAG &DAG)
static bool CC_LoongArch_GHC(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, Type *OrigTy, CCState &State)
static MachineBasicBlock * insertDivByZeroTrap(MachineInstr &MI, MachineBasicBlock *MBB)
static SDValue customLegalizeToWOpWithSExt(SDNode *N, SelectionDAG &DAG)
static SDValue lowerVectorBitClear(SDNode *Node, SelectionDAG &DAG)
static SDValue lowerVECTOR_SHUFFLE_VPACKEV(const SDLoc &DL, ArrayRef< int > Mask, MVT VT, SDValue V1, SDValue V2, SelectionDAG &DAG)
Lower VECTOR_SHUFFLE into VPACKEV (if possible).
static MachineBasicBlock * emitPseudoVMSKCOND(MachineInstr &MI, MachineBasicBlock *BB, const LoongArchSubtarget &Subtarget)
static SDValue performSELECT_CCCombine(SDNode *N, SelectionDAG &DAG, TargetLowering::DAGCombinerInfo &DCI, const LoongArchSubtarget &Subtarget)
static void replaceVPICKVE2GRResults(SDNode *Node, SmallVectorImpl< SDValue > &Results, SelectionDAG &DAG, const LoongArchSubtarget &Subtarget, unsigned ResOp)
static SDValue lowerVECTOR_SHUFFLEAsZeroOrAnyExtend(const SDLoc &DL, ArrayRef< int > Mask, MVT VT, SDValue V1, SDValue V2, SelectionDAG &DAG, const APInt &Zeroable)
Lower VECTOR_SHUFFLE as ZERO_EXTEND Or ANY_EXTEND (if possible).
static SDValue legalizeIntrinsicImmArg(SDNode *Node, unsigned ImmOp, SelectionDAG &DAG, const LoongArchSubtarget &Subtarget, bool IsSigned=false)
static cl::opt< MaterializeFPImm > MaterializeFPImmInsNum("loongarch-materialize-float-imm", cl::Hidden, cl::desc("Maximum number of instructions used (including code sequence " "to generate the value and moving the value to FPR) when " "materializing floating-point immediates (default = 3)"), cl::init(MaterializeFPImm3Ins), cl::values(clEnumValN(NoMaterializeFPImm, "0", "Use constant pool"), clEnumValN(MaterializeFPImm2Ins, "2", "Materialize FP immediate within 2 instructions"), clEnumValN(MaterializeFPImm3Ins, "3", "Materialize FP immediate within 3 instructions"), clEnumValN(MaterializeFPImm4Ins, "4", "Materialize FP immediate within 4 instructions"), clEnumValN(MaterializeFPImm5Ins, "5", "Materialize FP immediate within 5 instructions"), clEnumValN(MaterializeFPImm6Ins, "6", "Materialize FP immediate within 6 instructions " "(behaves same as 5 on loongarch64)")))
static SDValue lowerVECTOR_SHUFFLE_XVPERMI(const SDLoc &DL, ArrayRef< int > Mask, MVT VT, SDValue V1, SelectionDAG &DAG, const LoongArchSubtarget &Subtarget)
Lower VECTOR_SHUFFLE into XVPERMI (if possible).
static SDValue emitIntrinsicWithChainErrorMessage(SDValue Op, StringRef ErrorMsg, SelectionDAG &DAG)
static bool CC_LoongArchAssign2GRLen(unsigned GRLen, CCState &State, CCValAssign VA1, ISD::ArgFlagsTy ArgFlags1, unsigned ValNo2, MVT ValVT2, MVT LocVT2, ISD::ArgFlagsTy ArgFlags2)
const MCPhysReg ArgFPR64s[]
static MachineBasicBlock * emitPseudoCTPOP(MachineInstr &MI, MachineBasicBlock *BB, const LoongArchSubtarget &Subtarget)
static SDValue performMOVGR2FR_WCombine(SDNode *N, SelectionDAG &DAG, TargetLowering::DAGCombinerInfo &DCI, const LoongArchSubtarget &Subtarget)
#define IOCSRWR_CASE(NAME, NODE)
#define CRC_CASE_EXT_UNARYOP(NAME, NODE)
static SDValue lowerVECTOR_SHUFFLE_VPACKOD(const SDLoc &DL, ArrayRef< int > Mask, MVT VT, SDValue V1, SDValue V2, SelectionDAG &DAG)
Lower VECTOR_SHUFFLE into VPACKOD (if possible).
static SDValue signExtendBitcastSrcVector(SelectionDAG &DAG, EVT SExtVT, SDValue Src, const SDLoc &DL)
static SDValue lower256BitShuffle(const SDLoc &DL, ArrayRef< int > Mask, MVT VT, SDValue V1, SDValue V2, SelectionDAG &DAG, const LoongArchSubtarget &Subtarget)
Dispatching routine to lower various 256-bit LoongArch vector shuffles.
static SDValue lowerVECTOR_SHUFFLE_VREPLVEI(const SDLoc &DL, ArrayRef< int > Mask, MVT VT, SDValue V1, SelectionDAG &DAG, const LoongArchSubtarget &Subtarget)
Lower VECTOR_SHUFFLE into VREPLVEI (if possible).
static MachineBasicBlock * emitPseudoXVINSGR2VR(MachineInstr &MI, MachineBasicBlock *BB, const LoongArchSubtarget &Subtarget)
static void fillVector(ArrayRef< SDValue > Ops, SelectionDAG &DAG, SDLoc DL, const LoongArchSubtarget &Subtarget, SDValue &Vector, EVT ResTy)
static SDValue performEXTRACT_VECTOR_ELTCombine(SDNode *N, SelectionDAG &DAG, TargetLowering::DAGCombinerInfo &DCI, const LoongArchSubtarget &Subtarget)
static SDValue fillSubVectorFromBuildVector(BuildVectorSDNode *Node, SelectionDAG &DAG, SDLoc DL, const LoongArchSubtarget &Subtarget, EVT ResTy, unsigned first)
static bool isSelectPseudo(MachineInstr &MI)
static SDValue foldBinOpIntoSelectIfProfitable(SDNode *BO, SelectionDAG &DAG, const LoongArchSubtarget &Subtarget)
static SDValue lowerVectorSplatImm(SDNode *Node, unsigned ImmOp, SelectionDAG &DAG, bool IsSigned=false)
const MCPhysReg ArgGPRs[]
static SDValue lowerVECTOR_SHUFFLE_XVPERM(const SDLoc &DL, ArrayRef< int > Mask, MVT VT, SDValue V1, SelectionDAG &DAG, const LoongArchSubtarget &Subtarget)
Lower VECTOR_SHUFFLE into XVPERM (if possible).
static SDValue lowerVECTOR_SHUFFLE_XVILVL(const SDLoc &DL, ArrayRef< int > Mask, MVT VT, SDValue V1, SDValue V2, SelectionDAG &DAG)
Lower VECTOR_SHUFFLE into XVILVL (if possible).
static SDValue customLegalizeToWOp(SDNode *N, SelectionDAG &DAG, int NumOp, unsigned ExtOpc=ISD::ANY_EXTEND)
static void replaceVecCondBranchResults(SDNode *N, SmallVectorImpl< SDValue > &Results, SelectionDAG &DAG, const LoongArchSubtarget &Subtarget, unsigned ResOp)
#define ASRT_LE_GT_CASE(NAME)
static SDValue lowerVECTOR_SHUFFLE_XVPACKEV(const SDLoc &DL, ArrayRef< int > Mask, MVT VT, SDValue V1, SDValue V2, SelectionDAG &DAG)
Lower VECTOR_SHUFFLE into XVPACKEV (if possible).
static SDValue performBR_CCCombine(SDNode *N, SelectionDAG &DAG, TargetLowering::DAGCombinerInfo &DCI, const LoongArchSubtarget &Subtarget)
static void computeZeroableShuffleElements(ArrayRef< int > Mask, SDValue V1, SDValue V2, APInt &KnownUndef, APInt &KnownZero)
Compute whether each element of a shuffle is zeroable.
static bool combine_CC(SDValue &LHS, SDValue &RHS, SDValue &CC, const SDLoc &DL, SelectionDAG &DAG, const LoongArchSubtarget &Subtarget)
static SDValue widenShuffleMask(const SDLoc &DL, ArrayRef< int > Mask, MVT VT, SDValue V1, SDValue V2, SelectionDAG &DAG)
static MachineBasicBlock * emitVecCondBranchPseudo(MachineInstr &MI, MachineBasicBlock *BB, const LoongArchSubtarget &Subtarget)
static bool canonicalizeShuffleVectorByLane(const SDLoc &DL, MutableArrayRef< int > Mask, MVT VT, SDValue &V1, SDValue &V2, SelectionDAG &DAG, const LoongArchSubtarget &Subtarget)
Shuffle vectors by lane to generate more optimized instructions.
static SDValue lowerVECTOR_SHUFFLE_XVILVH(const SDLoc &DL, ArrayRef< int > Mask, MVT VT, SDValue V1, SDValue V2, SelectionDAG &DAG)
Lower VECTOR_SHUFFLE into XVILVH (if possible).
static SDValue lowerVECTOR_SHUFFLE_XVSHUF(const SDLoc &DL, ArrayRef< int > Mask, MVT VT, SDValue V1, SDValue V2, SelectionDAG &DAG)
Lower VECTOR_SHUFFLE into XVSHUF (if possible).
static void replaceCMP_XCHG_128Results(SDNode *N, SmallVectorImpl< SDValue > &Results, SelectionDAG &DAG)
static SDValue lowerVectorPickVE2GR(SDNode *N, SelectionDAG &DAG, unsigned ResOp)
static SDValue performBITREV_WCombine(SDNode *N, SelectionDAG &DAG, TargetLowering::DAGCombinerInfo &DCI, const LoongArchSubtarget &Subtarget)
#define IOCSRRD_CASE(NAME, NODE)
static int matchShuffleAsByteRotate(MVT VT, SDValue &V1, SDValue &V2, ArrayRef< int > Mask)
Attempts to match vector shuffle as byte rotation.
static SDValue lowerVECTOR_SHUFFLE_XVPICKEV(const SDLoc &DL, ArrayRef< int > Mask, MVT VT, SDValue V1, SDValue V2, SelectionDAG &DAG)
Lower VECTOR_SHUFFLE into XVPICKEV (if possible).
static SDValue lowerVECTOR_SHUFFLE_XVREPLVEI(const SDLoc &DL, ArrayRef< int > Mask, MVT VT, SDValue V1, SelectionDAG &DAG, const LoongArchSubtarget &Subtarget)
Lower VECTOR_SHUFFLE into XVREPLVEI (if possible).
static int matchShuffleAsShift(MVT &ShiftVT, unsigned &Opcode, unsigned ScalarSizeInBits, ArrayRef< int > Mask, int MaskOffset, const APInt &Zeroable)
Attempts to match a shuffle mask against the VBSLL, VBSRL, VSLLI and VSRLI instruction.
static SDValue lowerVECTOR_SHUFFLE_VILVL(const SDLoc &DL, ArrayRef< int > Mask, MVT VT, SDValue V1, SDValue V2, SelectionDAG &DAG)
Lower VECTOR_SHUFFLE into VILVL (if possible).
static SDValue lowerVectorBitClearImm(SDNode *Node, SelectionDAG &DAG)
static MachineBasicBlock * emitBuildPairF64Pseudo(MachineInstr &MI, MachineBasicBlock *BB, const LoongArchSubtarget &Subtarget)
static SDValue lowerVECTOR_SHUFFLEAsLanePermuteAndShuffle(const SDLoc &DL, ArrayRef< int > Mask, MVT VT, SDValue V1, SDValue V2, SelectionDAG &DAG)
Lower VECTOR_SHUFFLE as lane permute and then shuffle (if possible).
static SDValue performVMSKLTZCombine(SDNode *N, SelectionDAG &DAG, TargetLowering::DAGCombinerInfo &DCI, const LoongArchSubtarget &Subtarget)
static void replaceINTRINSIC_WO_CHAINResults(SDNode *N, SmallVectorImpl< SDValue > &Results, SelectionDAG &DAG, const LoongArchSubtarget &Subtarget)
static SDValue lowerVECTOR_SHUFFLE_VPICKOD(const SDLoc &DL, ArrayRef< int > Mask, MVT VT, SDValue V1, SDValue V2, SelectionDAG &DAG)
Lower VECTOR_SHUFFLE into VPICKOD (if possible).
static Intrinsic::ID getIntrinsicForMaskedAtomicRMWBinOp(unsigned GRLen, AtomicRMWInst::BinOp BinOp)
static void translateSetCCForBranch(const SDLoc &DL, SDValue &LHS, SDValue &RHS, ISD::CondCode &CC, SelectionDAG &DAG)
static bool isRepeatedShuffleMask(unsigned LaneSizeInBits, MVT VT, ArrayRef< int > Mask, SmallVectorImpl< int > &RepeatedMask)
Test whether a shuffle mask is equivalent within each sub-lane.
static LoongArchISD::NodeType getLoongArchWOpcode(unsigned Opcode)
Register const TargetRegisterInfo * TRI
Promote Memory to Register
static CodeModel::Model getCodeModel(const PPCSubtarget &S, const TargetMachine &TM, const MachineOperand &MO)
This file defines the SmallSet class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
static bool inRange(const MCExpr *Expr, int64_t MinValue, int64_t MaxValue, bool AllowSymbol=false)
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
static bool isSequentialOrUndefInRange(ArrayRef< int > Mask, unsigned Pos, unsigned Size, int Low, int Step=1)
Return true if every element in Mask, beginning from position Pos and ending in Pos + Size,...
bool isExactlyValue(double V) const
We don't rely on operator== working on double values, as it returns true for things that are clearly ...
APInt bitcastToAPInt() const
Class for arbitrary precision integers.
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
LLVM_ABI APInt zext(unsigned width) const
Zero extend to a new width.
static APInt getSignMask(unsigned BitWidth)
Get the SignMask for a specific bit width.
uint64_t getZExtValue() const
Get zero extended value.
void setHighBits(unsigned hiBits)
Set the top hiBits bits.
LLVM_ABI APInt zextOrTrunc(unsigned width) const
Zero extend or truncate to width.
LLVM_ABI APInt trunc(unsigned width) const
Truncate to new width.
void setBit(unsigned BitPosition)
Set the given bit to 1 whose position is given as "bitPosition".
bool isAllOnes() const
Determine if all bits are set. This is true for zero-width values.
bool isZero() const
Determine if this value is zero, i.e. all bits are clear.
unsigned getBitWidth() const
Return the number of bits in the APInt.
unsigned countr_zero() const
Count the number of trailing zero bits.
bool isSignedIntN(unsigned N) const
Check if this APInt has an N-bits signed integer value.
bool isSubsetOf(const APInt &RHS) const
This operation checks that all bits set in this APInt are also set in RHS.
static APInt getZero(unsigned numBits)
Get the '0' value for the specified bit-width.
void setLowBits(unsigned loBits)
Set the bottom loBits bits.
static APInt getBitsSetFrom(unsigned numBits, unsigned loBit)
Constructs an APInt value that has a contiguous range of bits set.
int64_t getSExtValue() const
Get sign extended value.
APInt lshr(unsigned shiftAmt) const
Logical right-shift function.
This class represents an incoming formal argument to a Function.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
An instruction that atomically checks whether a specified value is in a memory location,...
Value * getCompareOperand()
AtomicOrdering getFailureOrdering() const
Returns the failure ordering constraint of this cmpxchg instruction.
an instruction that atomically reads a memory location, combines it with another value,...
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
BinOp
This enumeration lists the possible modifications atomicrmw can make.
@ USubCond
Subtract only if no unsigned overflow.
@ Min
*p = old <signed v ? old : v
@ USubSat
*p = usub.sat(old, v) usub.sat matches the behavior of llvm.usub.sat.
@ UIncWrap
Increment one up to a maximum value.
@ Max
*p = old >signed v ? old : v
@ UMin
*p = old <unsigned v ? old : v
@ UMax
*p = old >unsigned v ? old : v
@ UDecWrap
Decrement one until a minimum value or zero.
Value * getPointerOperand()
bool isFloatingPointOperation() const
BinOp getOperation() const
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this rmw instruction.
AtomicOrdering getOrdering() const
Returns the ordering constraint of this rmw instruction.
LLVM Basic Block Representation.
bool test(unsigned Idx) const
size_type count() const
count - Returns the number of bits which are set.
A "pseudo-class" with methods for operating on BUILD_VECTORs.
CCState - This class holds information needed while lowering arguments and return values.
unsigned getFirstUnallocated(ArrayRef< MCPhysReg > Regs) const
getFirstUnallocated - Return the index of the first unallocated register in the set,...
LLVM_ABI void AnalyzeCallOperands(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
AnalyzeCallOperands - Analyze the outgoing arguments to a call, incorporating info about the passed v...
uint64_t getStackSize() const
Returns the size of the currently allocated portion of the stack.
LLVM_ABI void AnalyzeFormalArguments(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
AnalyzeFormalArguments - Analyze an array of argument values, incorporating info about the formals in...
CCValAssign - Represent assignment of one arg/retval to a location.
static CCValAssign getPending(unsigned ValNo, MVT ValVT, MVT LocVT, LocInfo HTP, unsigned ExtraInfo=0)
Register getLocReg() const
LocInfo getLocInfo() const
static CCValAssign getReg(unsigned ValNo, MVT ValVT, MCRegister Reg, MVT LocVT, LocInfo HTP, bool IsCustom=false)
static CCValAssign getCustomReg(unsigned ValNo, MVT ValVT, MCRegister Reg, MVT LocVT, LocInfo HTP)
static CCValAssign getMem(unsigned ValNo, MVT ValVT, int64_t Offset, MVT LocVT, LocInfo HTP, bool IsCustom=false)
int64_t getLocMemOffset() const
unsigned getValNo() const
static CCValAssign getCustomMem(unsigned ValNo, MVT ValVT, int64_t Offset, MVT LocVT, LocInfo HTP)
LLVM_ABI bool isMustTailCall() const
Tests if this call site must be tail call optimized.
This class represents a function call, abstracting a target machine's calling convention.
const APFloat & getValueAPF() const
This is the shared class of boolean and integer constants.
bool isMinusOne() const
This function will return true iff every bit in this constant is set to true.
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
uint64_t getZExtValue() const
int64_t getSExtValue() const
This is an important base class in LLVM.
uint64_t getNumOperands() const
A parsed version of the target data layout string in and methods for querying it.
unsigned getPointerSizeInBits(unsigned AS=0) const
The size in bits of the pointer representation in a given address space.
LLVM_ABI Align getPrefTypeAlign(Type *Ty) const
Returns the preferred stack/global alignment for the specified type.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
Argument * getArg(unsigned i) const
Common base class shared among various IRBuilders.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
LLVM_ABI const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
LLVM_ABI InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
LLVM_ABI const DataLayout & getDataLayout() const
Get the data layout of the module this instruction belongs to.
Class to represent integer types.
This is an important class for using LLVM in a threaded context.
LLVM_ABI void emitError(const Instruction *I, const Twine &ErrorStr)
emitError - Emit an error message to the currently installed error handler with optional location inf...
This class is used to represent ISD::LOAD nodes.
ISD::LoadExtType getExtensionType() const
Return whether this is a plain node, or one of the varieties of value-extending loads.
LoongArchMachineFunctionInfo - This class is derived from MachineFunctionInfo and contains private Lo...
void addSExt32Register(Register Reg)
const LoongArchRegisterInfo * getRegisterInfo() const override
const LoongArchInstrInfo * getInstrInfo() const override
unsigned getGRLen() const
bool isUsedByReturnOnly(SDNode *N, SDValue &Chain) const override
Return true if result of the specified node is used by a return node only.
SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override
This method will be invoked for all target nodes and for any target-independent nodes that the target...
SDValue getSqrtEstimate(SDValue Operand, SelectionDAG &DAG, int Enabled, int &RefinementSteps, bool &UseOneConstNR, bool Reciprocal) const override
Hooks for building estimates in place of slower divisions and square roots.
bool isLegalICmpImmediate(int64_t Imm) const override
Return true if the specified immediate is legal icmp immediate, that is the target has icmp instructi...
TargetLowering::AtomicExpansionKind shouldExpandAtomicCmpXchgInIR(AtomicCmpXchgInst *CI) const override
Returns how the given atomic cmpxchg should be expanded by the IR-level AtomicExpand pass.
Value * emitMaskedAtomicCmpXchgIntrinsic(IRBuilderBase &Builder, AtomicCmpXchgInst *CI, Value *AlignedAddr, Value *CmpVal, Value *NewVal, Value *Mask, AtomicOrdering Ord) const override
Perform a masked cmpxchg using a target-specific intrinsic.
EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context, EVT VT) const override
Return the ValueType of the result of SETCC operations.
std::pair< bool, uint64_t > isImmVLDILegalForMode1(const APInt &SplatValue, const unsigned SplatBitSize) const
Check if a constant splat can be generated using [x]vldi, where imm[12] is 1.
bool isFMAFasterThanFMulAndFAdd(const MachineFunction &MF, EVT VT) const override
Return true if an FMA operation is faster than a pair of fmul and fadd instructions.
SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI, SmallVectorImpl< SDValue > &InVals) const override
This hook must be implemented to lower calls into the specified DAG.
bool decomposeMulByConstant(LLVMContext &Context, EVT VT, SDValue C) const override
Return true if it is profitable to transform an integer multiplication-by-constant into simpler opera...
LegalizeTypeAction getPreferredVectorAction(MVT VT) const override
Return the preferred vector type legalization action.
bool isSExtCheaperThanZExt(EVT SrcVT, EVT DstVT) const override
Return true if sign-extension from FromTy to ToTy is cheaper than zero-extension.
TargetLowering::AtomicExpansionKind shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const override
Returns how the IR-level AtomicExpand pass should expand the given AtomicRMW, if at all.
bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AddrSpace=0, Align Alignment=Align(1), MachineMemOperand::Flags Flags=MachineMemOperand::MONone, unsigned *Fast=nullptr) const override
Determine if the target supports unaligned memory accesses.
bool isCheapToSpeculateCtlz(Type *Ty) const override
Return true if it is cheap to speculate a call to intrinsic ctlz.
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override
This callback is invoked for operations that are unsupported by the target, which are registered to u...
bool shouldAlignPointerArgs(CallInst *CI, unsigned &MinSize, Align &PrefAlign) const override
Return true if the pointer arguments to CI should be aligned by aligning the object whose address is ...
Value * emitMaskedAtomicRMWIntrinsic(IRBuilderBase &Builder, AtomicRMWInst *AI, Value *AlignedAddr, Value *Incr, Value *Mask, Value *ShiftAmt, AtomicOrdering Ord) const override
Perform a masked atomicrmw using a target-specific intrinsic.
bool isZExtFree(SDValue Val, EVT VT2) const override
Return true if zero-extending the specific node Val to type VT2 is free (either because it's implicit...
Register getExceptionPointerRegister(const Constant *PersonalityFn) const override
If a physical register, this returns the register that receives the exception address on entry to an ...
bool signExtendConstant(const ConstantInt *CI) const override
Return true if this constant should be sign extended when promoting to a larger type.
const char * getTargetNodeName(unsigned Opcode) const override
This method returns the name of a target specific DAG node.
bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallInst &I, MachineFunction &MF, unsigned Intrinsic) const override
Given an intrinsic, checks if on the target the intrinsic will need to map to a MemIntrinsicNode (tou...
bool isLegalAddImmediate(int64_t Imm) const override
Return true if the specified immediate is legal add immediate, that is the target has add instruction...
bool isCheapToSpeculateCttz(Type *Ty) const override
Return true if it is cheap to speculate a call to intrinsic cttz.
bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty, unsigned AS, Instruction *I=nullptr) const override
Return true if the addressing mode represented by AM is legal for this target, for a load/store of th...
bool shouldSignExtendTypeInLibCall(Type *Ty, bool IsSigned) const override
Returns true if arguments should be sign-extended in lib calls.
bool shouldScalarizeBinop(SDValue VecOp) const override
Try to convert an extract element of a vector binary operation into an extract element followed by a ...
bool isFPImmVLDILegal(const APFloat &Imm, EVT VT) const
bool shouldExtendTypeInLibCall(EVT Type) const override
Returns true if arguments should be extended in lib calls.
Register getRegisterByName(const char *RegName, LLT VT, const MachineFunction &MF) const override
Return the register ID of the name passed in.
bool hasAndNot(SDValue Y) const override
Return true if the target has a bitwise and-not operation: X = ~A & B This can be used to simplify se...
bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override
Return true if folding a constant offset with the given GlobalAddress is legal.
Register getExceptionSelectorRegister(const Constant *PersonalityFn) const override
If a physical register, this returns the register that receives the exception typeid on entry to a la...
void ReplaceNodeResults(SDNode *N, SmallVectorImpl< SDValue > &Results, SelectionDAG &DAG) const override
This callback is invoked when a node result type is illegal for the target, and the operation was reg...
bool SimplifyDemandedBitsForTargetNode(SDValue Op, const APInt &DemandedBits, const APInt &DemandedElts, KnownBits &Known, TargetLoweringOpt &TLO, unsigned Depth) const override
Attempt to simplify any target nodes based on the demanded bits/elts, returning true on success.
void emitExpandAtomicRMW(AtomicRMWInst *AI) const override
Perform a atomicrmw expansion using a target-specific way.
ISD::NodeType getExtendForAtomicCmpSwapArg() const override
Returns how the platform's atomic compare and swap expects its comparison value to be extended (ZERO_...
LoongArchTargetLowering(const TargetMachine &TM, const LoongArchSubtarget &STI)
SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, const SmallVectorImpl< ISD::OutputArg > &Outs, const SmallVectorImpl< SDValue > &OutVals, const SDLoc &DL, SelectionDAG &DAG) const override
This hook must be implemented to lower outgoing return values, described by the Outs array,...
bool hasAndNotCompare(SDValue Y) const override
Return true if the target should transform: (X & Y) == Y ---> (~X & Y) == 0 (X & Y) !...
SDValue getRecipEstimate(SDValue Operand, SelectionDAG &DAG, int Enabled, int &RefinementSteps) const override
Return a reciprocal estimate value for the input operand.
bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF, bool IsVarArg, const SmallVectorImpl< ISD::OutputArg > &Outs, LLVMContext &Context, const Type *RetTy) const override
This hook should be implemented to check whether the return values described by the Outs array can fi...
SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, const SmallVectorImpl< ISD::InputArg > &Ins, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl< SDValue > &InVals) const override
This hook must be implemented to lower the incoming (formal) arguments, described by the Ins array,...
bool mayBeEmittedAsTailCall(const CallInst *CI) const override
Return true if the target may be able emit the call instruction as a tail call.
Wrapper class representing physical registers. Should be passed by value.
bool hasFeature(unsigned Feature) const
static MVT getFloatingPointVT(unsigned BitWidth)
bool is128BitVector() const
Return true if this is a 128-bit vector type.
uint64_t getScalarSizeInBits() const
unsigned getVectorNumElements() const
bool isVector() const
Return true if this is a vector value type.
bool isScalableVector() const
Return true if this is a vector value type where the runtime length is machine dependent.
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
static auto fixedlen_vector_valuetypes()
bool is256BitVector() const
Return true if this is a 256-bit vector type.
bool isScalarInteger() const
Return true if this is an integer, not including vectors.
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.
static MVT getIntegerVT(unsigned BitWidth)
MVT getHalfNumVectorElementsVT() const
Return a VT for a vector type with the same element type but half the number of elements.
MVT changeVectorElementTypeToInteger() const
Return a vector with the same number of elements as this vector, but with the element type converted ...
LLVM_ABI void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB)
Transfers all the successors, as in transferSuccessors, and update PHI operands in the successor bloc...
void push_back(MachineInstr *MI)
void setCallFrameSize(unsigned N)
Set the call frame size on entry to this basic block.
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
LLVM_ABI void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB 'Other' at the position From, and insert it into this MBB right before '...
MachineInstrBundleIterator< MachineInstr > iterator
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
LLVM_ABI int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool IsImmutable, bool isAliased=false)
Create a new object at a fixed location on the stack.
LLVM_ABI int CreateStackObject(uint64_t Size, Align Alignment, bool isSpillSlot, const AllocaInst *Alloca=nullptr, uint8_t ID=0)
Create a new statically sized stack object, returning a nonnegative identifier to represent it.
void setFrameAddressIsTaken(bool T)
void setHasTailCall(bool V=true)
void setReturnAddressIsTaken(bool s)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
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.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
Function & getFunction()
Return the LLVM function that this machine code represents.
BasicBlockListType::iterator iterator
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
Register addLiveIn(MCRegister PReg, const TargetRegisterClass *RC)
addLiveIn - Add the specified physical register as a live-in value and create a corresponding virtual...
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *BB=nullptr, std::optional< UniqueBBID > BBID=std::nullopt)
CreateMachineInstr - Allocate a new MachineInstr.
void insert(iterator MBBI, MachineBasicBlock *MBB)
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
Representation of each machine instruction.
LLVM_ABI void collectDebugValues(SmallVectorImpl< MachineInstr * > &DbgValues)
Scan instructions immediately following MI and collect any matching DBG_VALUEs.
LLVM_ABI void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
const MachineOperand & getOperand(unsigned i) const
A description of a memory reference used in the backend.
Flags
Flags values. These may be or'd together.
@ MOVolatile
The memory access is volatile.
@ MODereferenceable
The memory access is dereferenceable (i.e., doesn't trap).
@ MOLoad
The memory access reads data.
@ MOInvariant
The memory access always returns the same value (or traps).
@ MOStore
The memory access writes data.
MachineOperand class - Representation of each machine instruction operand.
void setIsKill(bool Val=true)
void setIsUndef(bool Val=true)
Register getReg() const
getReg - Returns the register number.
static MachineOperand CreateReg(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false, bool isRenamable=false)
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
EVT getMemoryVT() const
Return the type of the in-memory value.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Class to represent pointers.
unsigned getAddressSpace() const
Return the address space of the Pointer type.
Wrapper class representing virtual and physical registers.
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
const APInt & getAsAPIntVal() const
Helper method returns the APInt value of a ConstantSDNode.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
LLVM_ABI bool isOnlyUserOf(const SDNode *N) const
Return true if this node is the only use of N.
size_t use_size() const
Return the number of uses of this node.
MVT getSimpleValueType(unsigned ResNo) const
Return the type of a specified result as a simple type.
uint64_t getAsZExtVal() const
Helper method returns the zero-extended integer value of a ConstantSDNode.
unsigned getNumOperands() const
Return the number of values used by this operation.
const SDValue & getOperand(unsigned Num) const
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
bool isUndef() const
Returns true if the node type is UNDEF or POISON.
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
bool hasOneUse() const
Return true if there is exactly one node using value ResNo of Node.
SDValue getValue(unsigned R) const
EVT getValueType() const
Return the ValueType of the referenced return value.
TypeSize getValueSizeInBits() const
Returns the size of the value in bits.
const SDValue & getOperand(unsigned i) const
uint64_t getScalarValueSizeInBits() const
uint64_t getConstantOperandVal(unsigned i) const
MVT getSimpleValueType() const
Return the simple ValueType of the referenced return value.
unsigned getOpcode() const
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
LLVM_ABI SDValue getExtLoad(ISD::LoadExtType ExtType, const SDLoc &dl, EVT VT, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, EVT MemVT, MaybeAlign Alignment=MaybeAlign(), MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
SDValue getTargetGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT, int64_t offset=0, unsigned TargetFlags=0)
SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, Register Reg, SDValue N)
LLVM_ABI SDValue getMergeValues(ArrayRef< SDValue > Ops, const SDLoc &dl)
Create a MERGE_VALUES node from the given operands.
LLVM_ABI SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
LLVM_ABI SDValue getShiftAmountConstant(uint64_t Val, EVT VT, const SDLoc &DL)
LLVM_ABI SDValue getAllOnesConstant(const SDLoc &DL, EVT VT, bool IsTarget=false, bool IsOpaque=false)
LLVM_ABI MachineSDNode * getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT)
These are used for target selectors to create a new node with specified return type(s),...
LLVM_ABI SDValue getFreeze(SDValue V)
Return a freeze using the SDLoc of the value operand.
SDValue getSetCC(const SDLoc &DL, EVT VT, SDValue LHS, SDValue RHS, ISD::CondCode Cond, SDValue Chain=SDValue(), bool IsSignaling=false)
Helper function to make it easier to build SetCC's if you just have an ISD::CondCode instead of an SD...
bool isSafeToSpeculativelyExecute(unsigned Opcode) const
Some opcodes may create immediate undefined behavior when used with some values (integer division-by-...
SDValue getExtractSubvector(const SDLoc &DL, EVT VT, SDValue Vec, unsigned Idx)
Return the VT typed sub-vector of Vec at Idx.
LLVM_ABI SDValue getRegister(Register Reg, EVT VT)
LLVM_ABI SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, MaybeAlign Alignment=MaybeAlign(), MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr)
Loads are not normal binary operators: their result type is not determined by their operands,...
SDValue getInsertSubvector(const SDLoc &DL, SDValue Vec, SDValue SubVec, unsigned Idx)
Insert SubVec at the Idx element of Vec.
LLVM_ABI SDValue getMemcpy(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, Align Alignment, bool isVol, bool AlwaysInline, const CallInst *CI, std::optional< bool > OverrideTailCall, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo, const AAMDNodes &AAInfo=AAMDNodes(), BatchAAResults *BatchAA=nullptr)
void addNoMergeSiteInfo(const SDNode *Node, bool NoMerge)
Set NoMergeSiteInfo to be associated with Node if NoMerge is true.
LLVM_ABI SDValue getNOT(const SDLoc &DL, SDValue Val, EVT VT)
Create a bitwise NOT operation as (XOR Val, -1).
const TargetLowering & getTargetLoweringInfo() const
static constexpr unsigned MaxRecursionDepth
SDValue getTargetJumpTable(int JTI, EVT VT, unsigned TargetFlags=0)
SDValue getUNDEF(EVT VT)
Return an UNDEF node. UNDEF does not have a useful SDLoc.
SDValue getCALLSEQ_END(SDValue Chain, SDValue Op1, SDValue Op2, SDValue InGlue, const SDLoc &DL)
Return a new CALLSEQ_END node, which always must have a glue result (to ensure it's not CSE'd).
SDValue getBuildVector(EVT VT, const SDLoc &DL, ArrayRef< SDValue > Ops)
Return an ISD::BUILD_VECTOR node.
LLVM_ABI bool isSplatValue(SDValue V, const APInt &DemandedElts, APInt &UndefElts, unsigned Depth=0) const
Test whether V has a splatted value for all the demanded elements.
LLVM_ABI SDValue getBitcast(EVT VT, SDValue V)
Return a bitcast using the SDLoc of the value operand, and casting to the provided type.
SDValue getCopyFromReg(SDValue Chain, const SDLoc &dl, Register Reg, EVT VT)
SDValue getSelect(const SDLoc &DL, EVT VT, SDValue Cond, SDValue LHS, SDValue RHS, SDNodeFlags Flags=SDNodeFlags())
Helper function to make it easier to build Select's if you just have operands and don't want to check...
LLVM_ABI SDValue getNegative(SDValue Val, const SDLoc &DL, EVT VT)
Create negative operation as (SUB 0, Val).
LLVM_ABI void setNodeMemRefs(MachineSDNode *N, ArrayRef< MachineMemOperand * > NewMemRefs)
Mutate the specified machine node's memory references to the provided list.
const DataLayout & getDataLayout() const
LLVM_ABI SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
SDValue getSignedTargetConstant(int64_t Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
LLVM_ABI void ReplaceAllUsesWith(SDValue From, SDValue To)
Modify anything using 'From' to use 'To' instead.
LLVM_ABI SDValue getCommutedVectorShuffle(const ShuffleVectorSDNode &SV)
Returns an ISD::VECTOR_SHUFFLE node semantically equivalent to the shuffle node in input but with swa...
LLVM_ABI std::pair< SDValue, SDValue > SplitVector(const SDValue &N, const SDLoc &DL, const EVT &LoVT, const EVT &HiVT)
Split the vector with EXTRACT_SUBVECTOR using the provided VTs and return the low/high part.
LLVM_ABI SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
Helper function to build ISD::STORE nodes.
LLVM_ABI SDValue getSignedConstant(int64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
SDValue getCALLSEQ_START(SDValue Chain, uint64_t InSize, uint64_t OutSize, const SDLoc &DL)
Return a new CALLSEQ_START node, that starts new call frame, in which InSize bytes are set up inside ...
LLVM_ABI SDValue FoldConstantArithmetic(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDValue > Ops, SDNodeFlags Flags=SDNodeFlags())
LLVM_ABI SDValue getExternalSymbol(const char *Sym, EVT VT)
const TargetMachine & getTarget() const
LLVM_ABI SDValue WidenVector(const SDValue &N, const SDLoc &DL)
Widen the vector up to the next power of two using INSERT_SUBVECTOR.
LLVM_ABI SDValue getIntPtrConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
LLVM_ABI SDValue getValueType(EVT)
LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
SDValue getTargetConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
SDValue getTargetBlockAddress(const BlockAddress *BA, EVT VT, int64_t Offset=0, unsigned TargetFlags=0)
LLVM_ABI SDValue getVectorIdxConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
LLVM_ABI void ReplaceAllUsesOfValueWith(SDValue From, SDValue To)
Replace any uses of From with To, leaving uses of other values produced by From.getNode() alone.
MachineFunction & getMachineFunction() const
SDValue getSplatBuildVector(EVT VT, const SDLoc &DL, SDValue Op)
Return a splat ISD::BUILD_VECTOR node, consisting of Op splatted to all elements.
LLVM_ABI SDValue getFrameIndex(int FI, EVT VT, bool isTarget=false)
LLVM_ABI KnownBits computeKnownBits(SDValue Op, unsigned Depth=0) const
Determine which bits of Op are known to be either zero or one and return them in Known.
LLVM_ABI SDValue getRegisterMask(const uint32_t *RegMask)
LLVM_ABI SDValue getZExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either zero-extending or trunca...
LLVM_ABI SDValue getCondCode(ISD::CondCode Cond)
LLVM_ABI bool MaskedValueIsZero(SDValue Op, const APInt &Mask, unsigned Depth=0) const
Return true if 'Op & Mask' is known to be zero.
LLVMContext * getContext() const
LLVM_ABI SDValue getTargetExternalSymbol(const char *Sym, EVT VT, unsigned TargetFlags=0)
LLVM_ABI SDValue CreateStackTemporary(TypeSize Bytes, Align Alignment)
Create a stack temporary based on the size in bytes and the alignment.
SDValue getTargetConstantPool(const Constant *C, EVT VT, MaybeAlign Align=std::nullopt, int Offset=0, unsigned TargetFlags=0)
SDValue getEntryNode() const
Return the token chain corresponding to the entry of the function.
LLVM_ABI std::pair< SDValue, SDValue > SplitScalar(const SDValue &N, const SDLoc &DL, const EVT &LoVT, const EVT &HiVT)
Split the scalar node with EXTRACT_ELEMENT using the provided VTs and return the low/high part.
LLVM_ABI SDValue getVectorShuffle(EVT VT, const SDLoc &dl, SDValue N1, SDValue N2, ArrayRef< int > Mask)
Return an ISD::VECTOR_SHUFFLE node.
ArrayRef< int > getMask() const
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.
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 assign(size_type NumElts, ValueParamT Elt)
typename SuperClass::const_iterator const_iterator
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StackOffset holds a fixed and a scalable offset in bytes.
StringRef - Represent a constant reference to a string, i.e.
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
constexpr size_t size() const
size - Get the string size.
TargetInstrInfo - Interface to description of machine instruction set.
void setBooleanVectorContents(BooleanContent Ty)
Specify how the target extends the result of a vector boolean value from a vector of i1 to a wider ty...
void setOperationAction(unsigned Op, MVT VT, LegalizeAction Action)
Indicate that the specified operation does not work with the specified type and indicate what to do a...
MachineBasicBlock * emitPatchPoint(MachineInstr &MI, MachineBasicBlock *MBB) const
Replace/modify any TargetFrameIndex operands with a targte-dependent sequence of memory operands that...
virtual const TargetRegisterClass * getRegClassFor(MVT VT, bool isDivergent=false) const
Return the register class that should be used for the specified value type.
const TargetMachine & getTargetMachine() const
virtual unsigned getNumRegistersForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const
Certain targets require unusual breakdowns of certain types.
virtual bool isZExtFree(Type *FromTy, Type *ToTy) const
Return true if any actual instruction that defines a value of type FromTy implicitly zero-extends the...
virtual MVT getRegisterTypeForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const
Certain combinations of ABIs, Targets and features require that types are legal for some operations a...
LegalizeTypeAction
This enum indicates whether a types are legal for a target, and if not, what action should be used to...
void setMaxBytesForAlignment(unsigned MaxBytes)
void setPrefLoopAlignment(Align Alignment)
Set the target's preferred loop alignment.
void setMaxAtomicSizeInBitsSupported(unsigned SizeInBits)
Set the maximum atomic operation size supported by the backend.
virtual TargetLoweringBase::LegalizeTypeAction getPreferredVectorAction(MVT VT) const
Return the preferred vector type legalization action.
void setMinFunctionAlignment(Align Alignment)
Set the target's minimum function alignment.
void setBooleanContents(BooleanContent Ty)
Specify how the target extends the result of integer and floating point boolean values from i1 to a w...
void computeRegisterProperties(const TargetRegisterInfo *TRI)
Once all of the register classes are added, this allows us to compute derived properties we expose.
virtual EVT getTypeToTransformTo(LLVMContext &Context, EVT VT) const
For types supported by the target, this is an identity function.
void addRegisterClass(MVT VT, const TargetRegisterClass *RC)
Add the specified register class as an available regclass for the specified value type.
bool isTypeLegal(EVT VT) const
Return true if the target has native support for the specified value type.
virtual MVT getPointerTy(const DataLayout &DL, uint32_t AS=0) const
Return the pointer type for the given address space, defaults to the pointer type from the data layou...
void setPrefFunctionAlignment(Align Alignment)
Set the target's preferred function alignment.
void setTruncStoreAction(MVT ValVT, MVT MemVT, LegalizeAction Action)
Indicate that the specified truncating store does not work with the specified type and indicate what ...
@ ZeroOrOneBooleanContent
@ ZeroOrNegativeOneBooleanContent
virtual bool isBinOp(unsigned Opcode) const
Return true if the node is a math/logic binary operator.
void setMinCmpXchgSizeInBits(unsigned SizeInBits)
Sets the minimum cmpxchg or ll/sc size supported by the backend.
void setStackPointerRegisterToSaveRestore(Register R)
If set to a physical register, this specifies the register that llvm.savestack/llvm....
AtomicExpansionKind
Enum that specifies what an atomic load/AtomicRMWInst is expanded to, if at all.
void setCondCodeAction(ArrayRef< ISD::CondCode > CCs, MVT VT, LegalizeAction Action)
Indicate that the specified condition code is or isn't supported on the target and indicate what to d...
void setTargetDAGCombine(ArrayRef< ISD::NodeType > NTs)
Targets should invoke this method for each target independent node that they want to provide a custom...
void setLoadExtAction(unsigned ExtType, MVT ValVT, MVT MemVT, LegalizeAction Action)
Indicate that the specified load with extension does not work with the specified type and indicate wh...
LegalizeTypeAction getTypeAction(LLVMContext &Context, EVT VT) const
Return how we should legalize values of this type, either it is already legal (return 'Legal') or we ...
std::vector< ArgListEntry > ArgListTy
bool isOperationLegalOrCustomOrPromote(unsigned Op, EVT VT, bool LegalOnly=false) const
Return true if the specified operation is legal on this target or can be made legal with custom lower...
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
bool SimplifyDemandedVectorElts(SDValue Op, const APInt &DemandedEltMask, APInt &KnownUndef, APInt &KnownZero, TargetLoweringOpt &TLO, unsigned Depth=0, bool AssumeSingleUse=false) const
Look at Vector Op.
std::pair< SDValue, SDValue > makeLibCall(SelectionDAG &DAG, RTLIB::Libcall LC, EVT RetVT, ArrayRef< SDValue > Ops, MakeLibCallOptions CallOptions, const SDLoc &dl, SDValue Chain=SDValue()) const
Returns a pair of (return value, chain).
virtual InlineAsm::ConstraintCode getInlineAsmMemConstraint(StringRef ConstraintCode) const
SDValue SimplifyMultipleUseDemandedBits(SDValue Op, const APInt &DemandedBits, const APInt &DemandedElts, SelectionDAG &DAG, unsigned Depth=0) const
More limited version of SimplifyDemandedBits that can be used to "lookthrough" ops that don't contrib...
virtual ConstraintType getConstraintType(StringRef Constraint) const
Given a constraint, return the type of constraint it is for this target.
std::pair< SDValue, SDValue > LowerCallTo(CallLoweringInfo &CLI) const
This function lowers an abstract call to a function into an actual call.
virtual std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const
Given a physical register constraint (e.g.
bool SimplifyDemandedBits(SDValue Op, const APInt &DemandedBits, const APInt &DemandedElts, KnownBits &Known, TargetLoweringOpt &TLO, unsigned Depth=0, bool AssumeSingleUse=false) const
Look at Op.
virtual bool SimplifyDemandedBitsForTargetNode(SDValue Op, const APInt &DemandedBits, const APInt &DemandedElts, KnownBits &Known, TargetLoweringOpt &TLO, unsigned Depth=0) const
Attempt to simplify any target nodes based on the demanded bits/elts, returning true on success.
TargetLowering(const TargetLowering &)=delete
virtual void LowerAsmOperandForConstraint(SDValue Op, StringRef Constraint, std::vector< SDValue > &Ops, SelectionDAG &DAG) const
Lower the specified operand into the Ops vector.
Primary interface to the complete machine description for the target machine.
bool useTLSDESC() const
Returns true if this target uses TLS Descriptors.
bool useEmulatedTLS() const
Returns true if this target uses emulated TLS.
bool shouldAssumeDSOLocal(const GlobalValue *GV) const
CodeModel::Model getCodeModel() const
Returns the code model.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual const TargetInstrInfo * getInstrInfo() const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM_ABI unsigned getIntegerBitWidth() const
LLVM_ABI TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
bool isIntegerTy() const
True if this is an instance of IntegerType.
static LLVM_ABI IntegerType * getIntNTy(LLVMContext &C, unsigned N)
This class is used to represent EVT's, which are used to parameterize some operations.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
self_iterator getIterator()
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ PreserveMost
Used for runtime calls that preserves most registers.
@ GHC
Used by the Glasgow Haskell Compiler (GHC).
@ Fast
Attempts to make calls as fast as possible (e.g.
@ C
The default llvm calling convention, compatible with C.
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
@ SETCC
SetCC operator - This evaluates to a true value iff the condition is true.
@ STRICT_FSETCC
STRICT_FSETCC/STRICT_FSETCCS - Constrained versions of SETCC, used for floating-point operands only.
@ DELETED_NODE
DELETED_NODE - This is an illegal value that is used to catch errors.
@ 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.
@ ADD
Simple integer binary arithmetic operators.
@ ANY_EXTEND
ANY_EXTEND - Used for integer types. The high bits are undefined.
@ FMA
FMA - Perform a * b + c with no intermediate rounding step.
@ INTRINSIC_VOID
OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...) This node represents a target intrin...
@ 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 ...
@ FADD
Simple binary floating point operators.
@ BUILD_PAIR
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
@ BUILTIN_OP_END
BUILTIN_OP_END - This must be the last enum value in this list.
@ SIGN_EXTEND
Conversion operators.
@ SCALAR_TO_VECTOR
SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a scalar value into element 0 of the...
@ 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).
@ UNDEF
UNDEF - An undefined node.
@ MULHU
MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing an unsigned/signed value of...
@ 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...
@ CopyToReg
CopyToReg - This node has three operands: a chain, a register number to set to this value,...
@ ZERO_EXTEND
ZERO_EXTEND - Used for integer types, zeroing the new bits.
@ SELECT_CC
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
@ 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.
@ VSELECT
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
@ EH_DWARF_CFA
EH_DWARF_CFA - This node represents the pointer to the DWARF Canonical Frame Address (CFA),...
@ FRAMEADDR
FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and llvm.returnaddress on the DAG.
@ FP_TO_SINT
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ AND
Bitwise operators - logical and, logical or, logical xor.
@ INTRINSIC_WO_CHAIN
RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) This node represents a target intrinsic fun...
@ FREEZE
FREEZE - FREEZE(VAL) returns an arbitrary value if VAL is UNDEF (or is evaluated to UNDEF),...
@ 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.
@ TRUNCATE
TRUNCATE - Completely drop the high bits.
@ 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...
@ SADDSAT
RESULT = [US]ADDSAT(LHS, RHS) - Perform saturation addition on 2 integers with the same bit width (W)...
@ ABDS
ABDS/ABDU - Absolute difference - Return the absolute difference between two numbers interpreted as s...
@ 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 CondCode getSetCCInverse(CondCode Operation, EVT Type)
Return the operation corresponding to !(X op Y), where 'op' is a valid SetCC operation.
LLVM_ABI bool isFreezeUndef(const SDNode *N)
Return true if the specified node is FREEZE(UNDEF).
LLVM_ABI CondCode getSetCCSwappedOperands(CondCode Operation)
Return the operation corresponding to (Y op X) when given the operation for (X op Y).
LLVM_ABI bool isBuildVectorAllZeros(const SDNode *N)
Return true if the specified node is a BUILD_VECTOR where all of the elements are 0 or undef.
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
LLVM_ABI bool isBuildVectorAllOnes(const SDNode *N)
Return true if the specified node is a BUILD_VECTOR where all of the elements are ~0 or undef.
LLVM_ABI NodeType getVecReduceBaseOpcode(unsigned VecReduceOpcode)
Get underlying scalar opcode for VECREDUCE opcode.
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
bool isIntEqualitySetCC(CondCode Code)
Return true if this is a setcc instruction that performs an equality comparison when used with intege...
This namespace contains an enum with a value for every intrinsic/builtin function known by LLVM.
LLVM_ABI Function * getOrInsertDeclaration(Module *M, ID id, ArrayRef< Type * > Tys={})
Look up the Function declaration of the intrinsic id in the Module M.
ABI getTargetABI(StringRef ABIName)
InstSeq generateInstSeq(int64_t Val)
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 getUINTTOFP(EVT OpVT, EVT RetVT)
getUINTTOFP - Return the UINTTOFP_*_* 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 getFPROUND(EVT OpVT, EVT RetVT)
getFPROUND - Return the FPROUND_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
@ Kill
The last use of a register.
@ SingleThread
Synchronized with respect to signal handlers executing in the same thread.
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
initializer< Ty > init(const Ty &Val)
Sequence
A sequence of states that a pointer may go through in which an objc_retain and objc_release are actua...
NodeAddr< NodeBase * > Node
This is an optimization pass for GlobalISel generic memory operations.
@ Low
Lower the current thread's priority such that it does not affect foreground tasks significantly.
FunctionAddr VTableAddr Value
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
LLVM_ABI bool isNullConstant(SDValue V)
Returns true if V is a constant integer zero.
LLVM_ABI SDValue peekThroughBitcasts(SDValue V)
Return the non-bitcasted source operand of V if it exists.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
bool isIntOrFPConstant(SDValue V)
Return true if V is either a integer or FP constant.
int bit_width(T Value)
Returns the number of bits needed to represent Value if Value is nonzero.
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
LLVM_ABI bool widenShuffleMaskElts(int Scale, ArrayRef< int > Mask, SmallVectorImpl< int > &ScaledMask)
Try to transform a shuffle mask by replacing elements with the scaled index for an equivalent mask of...
unsigned Log2_64(uint64_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
constexpr bool isShiftedMask_64(uint64_t Value)
Return true if the argument contains a non-empty sequence of ones with the remainder zero (64 bit ver...
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
MachineInstr * getImm(const MachineOperand &MO, const MachineRegisterInfo *MRI)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
constexpr bool isMask_64(uint64_t Value)
Return true if the argument is a non-empty sequence of ones starting at the least significant bit wit...
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
AtomicOrdering
Atomic ordering for LLVM's memory model.
unsigned getKillRegState(bool B)
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
FunctionAddr VTableAddr Next
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
constexpr bool isShiftedInt(int64_t x)
Checks if a signed integer is an N bit number shifted left by S.
constexpr unsigned BitWidth
std::string join_items(Sep Separator, Args &&... Items)
Joins the strings in the parameter pack Items, adding Separator between the elements....
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI bool isOneConstant(SDValue V)
Returns true if V is a constant integer one.
PointerUnion< const Value *, const PseudoSourceValue * > ValueType
LLVM_ABI bool isAllOnesConstant(SDValue V)
Returns true if V is an integer constant with all bits set.
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
This struct is a compact representation of a valid (non-zero power of two) alignment.
EVT changeVectorElementTypeToInteger() const
Return a vector with the same number of elements as this vector, but with the element type converted ...
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
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.
uint64_t getScalarSizeInBits() const
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
bool is128BitVector() const
Return true if this is a 128-bit vector type.
static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)
Returns the EVT that represents an integer with the given number of bits.
uint64_t getFixedSizeInBits() const
Return the size of the specified fixed width value type in bits.
static EVT getFloatingPointVT(unsigned BitWidth)
Returns the EVT that represents a floating-point type 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 is256BitVector() const
Return true if this is a 256-bit vector type.
LLVM_ABI Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
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.
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
EVT getHalfNumVectorElementsVT(LLVMContext &Context) const
bool isInteger() const
Return true if this is an integer or a vector integer type.
Align getNonZeroOrigAlign() const
This class contains a discriminated union of information about pointers in memory operands,...
static LLVM_ABI MachinePointerInfo getStack(MachineFunction &MF, int64_t Offset, uint8_t ID=0)
Stack pointer relative access.
static LLVM_ABI MachinePointerInfo getGOT(MachineFunction &MF)
Return a MachinePointerInfo record that refers to a GOT entry.
static LLVM_ABI MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
This represents a list of ValueType's that has been intern'd by a SelectionDAG.
This represents an addressing mode of: BaseGV + BaseOffs + BaseReg + Scale*ScaleReg + ScalableOffset*...
This structure contains all information that is necessary for lowering calls.
SmallVector< ISD::InputArg, 32 > Ins
SmallVector< ISD::OutputArg, 32 > Outs
SmallVector< SDValue, 32 > OutVals
bool isBeforeLegalizeOps() const
bool isBeforeLegalize() const
LLVM_ABI SDValue CombineTo(SDNode *N, ArrayRef< SDValue > To, bool AddTo=true)
This structure is used to pass arguments to makeLibCall function.
MakeLibCallOptions & setTypeListBeforeSoften(ArrayRef< EVT > OpsVT, EVT RetVT)
A convenience struct that encapsulates a DAG, and two SDValues for returning information from TargetL...
bool CombineTo(SDValue O, SDValue N)