46#include "llvm/IR/IntrinsicsHexagon.h"
66#define DEBUG_TYPE "hexagon-lowering"
70 cl::desc(
"Control jump table emission on Hexagon target"));
74 cl::desc(
"Enable Hexagon SDNode scheduling"));
78 cl::desc(
"Set minimum jump tables"));
82 cl::desc(
"Convert constant loads to immediate values."));
86 cl::desc(
"Rewrite unaligned loads as a pair of aligned loads"));
91 cl::desc(
"Disable minimum alignment of 1 for "
92 "arguments passed by value on stack"));
100 Hexagon::R0, Hexagon::R1, Hexagon::R2,
101 Hexagon::R3, Hexagon::R4, Hexagon::R5
103 const unsigned NumArgRegs = std::size(ArgRegs);
104 unsigned RegNum = State.getFirstUnallocated(ArgRegs);
107 if (RegNum != NumArgRegs && RegNum % 2 == 1)
108 State.AllocateReg(ArgRegs[RegNum]);
131 if (!VA.isMemLoc() || !VA.needsCustom())
133 VA.convertToMem(
Size);
134 Size += VA.getLocVT().getStoreSize();
139#define GET_CALLING_CONV_IMPL
140#include "HexagonGenCallingConv.inc"
144 unsigned &NumIntermediates,
MVT &RegisterVT)
const {
152 if (isBoolVector && !Subtarget.useHVXOps() && isPowerOf2 && NumElts >= 8) {
153 RegisterVT = MVT::v8i8;
154 IntermediateVT = MVT::v8i1;
155 NumIntermediates = NumElts / 8;
156 return NumIntermediates;
161 if (isBoolVector && Subtarget.useHVX64BOps() && isPowerOf2 && NumElts >= 64) {
162 RegisterVT = MVT::v64i8;
163 IntermediateVT = MVT::v64i1;
164 NumIntermediates = NumElts / 64;
165 return NumIntermediates;
170 if (isBoolVector && Subtarget.useHVX128BOps() && isPowerOf2 &&
172 RegisterVT = MVT::v128i8;
173 IntermediateVT = MVT::v128i1;
174 NumIntermediates = NumElts / 128;
175 return NumIntermediates;
179 Context,
CC, VT, IntermediateVT, NumIntermediates, RegisterVT);
182std::pair<MVT, unsigned>
192 if (!Subtarget.useHVXOps() && NumElems >= 8)
193 return {MVT::v8i8, NumElems / 8};
195 if (Subtarget.useHVX64BOps() && NumElems >= 64)
196 return {MVT::v64i8, NumElems / 64};
198 if (Subtarget.useHVX128BOps() && NumElems >= 128)
199 return {MVT::v128i8, NumElems / 128};
209 auto [RegisterVT, NumRegisters] =
221 unsigned IntNo =
Op.getConstantOperandVal(0);
226 case Intrinsic::thread_pointer: {
228 return DAG.
getNode(HexagonISD::THREAD_POINTER, dl, PtrVT);
242 Align Alignment = Flags.getNonZeroByValAlign();
243 return DAG.
getMemcpy(Chain, dl, Dst, Src, SizeNode, Alignment, Alignment,
255 CCState CCInfo(CallConv, IsVarArg, MF, RVLocs, Context);
283 for (
unsigned i = 0; i != RVLocs.
size(); ++i) {
320 return DAG.
getNode(HexagonISD::RET_GLUE, dl, MVT::Other, RetOps);
332 .
Case(
"r0", Hexagon::R0)
333 .
Case(
"r1", Hexagon::R1)
334 .
Case(
"r2", Hexagon::R2)
335 .
Case(
"r3", Hexagon::R3)
336 .
Case(
"r4", Hexagon::R4)
337 .
Case(
"r5", Hexagon::R5)
338 .
Case(
"r6", Hexagon::R6)
339 .
Case(
"r7", Hexagon::R7)
340 .
Case(
"r8", Hexagon::R8)
341 .
Case(
"r9", Hexagon::R9)
342 .
Case(
"r10", Hexagon::R10)
343 .
Case(
"r11", Hexagon::R11)
344 .
Case(
"r12", Hexagon::R12)
345 .
Case(
"r13", Hexagon::R13)
346 .
Case(
"r14", Hexagon::R14)
347 .
Case(
"r15", Hexagon::R15)
348 .
Case(
"r16", Hexagon::R16)
349 .
Case(
"r17", Hexagon::R17)
350 .
Case(
"r18", Hexagon::R18)
351 .
Case(
"r19", Hexagon::R19)
352 .
Case(
"r20", Hexagon::R20)
353 .
Case(
"r21", Hexagon::R21)
354 .
Case(
"r22", Hexagon::R22)
355 .
Case(
"r23", Hexagon::R23)
356 .
Case(
"r24", Hexagon::R24)
357 .
Case(
"r25", Hexagon::R25)
358 .
Case(
"r26", Hexagon::R26)
359 .
Case(
"r27", Hexagon::R27)
360 .
Case(
"r28", Hexagon::R28)
361 .
Case(
"r29", Hexagon::R29)
362 .
Case(
"r30", Hexagon::R30)
363 .
Case(
"r31", Hexagon::R31)
364 .
Case(
"r1:0", Hexagon::D0)
365 .
Case(
"r3:2", Hexagon::D1)
366 .
Case(
"r5:4", Hexagon::D2)
367 .
Case(
"r7:6", Hexagon::D3)
368 .
Case(
"r9:8", Hexagon::D4)
369 .
Case(
"r11:10", Hexagon::D5)
370 .
Case(
"r13:12", Hexagon::D6)
371 .
Case(
"r15:14", Hexagon::D7)
372 .
Case(
"r17:16", Hexagon::D8)
373 .
Case(
"r19:18", Hexagon::D9)
374 .
Case(
"r21:20", Hexagon::D10)
375 .
Case(
"r23:22", Hexagon::D11)
376 .
Case(
"r25:24", Hexagon::D12)
377 .
Case(
"r27:26", Hexagon::D13)
378 .
Case(
"r29:28", Hexagon::D14)
379 .
Case(
"r31:30", Hexagon::D15)
380 .
Case(
"sp", Hexagon::R29)
381 .
Case(
"fp", Hexagon::R30)
382 .
Case(
"lr", Hexagon::R31)
383 .
Case(
"p0", Hexagon::P0)
384 .
Case(
"p1", Hexagon::P1)
385 .
Case(
"p2", Hexagon::P2)
386 .
Case(
"p3", Hexagon::P3)
387 .
Case(
"sa0", Hexagon::SA0)
388 .
Case(
"lc0", Hexagon::LC0)
389 .
Case(
"sa1", Hexagon::SA1)
390 .
Case(
"lc1", Hexagon::LC1)
391 .
Case(
"m0", Hexagon::M0)
392 .
Case(
"m1", Hexagon::M1)
393 .
Case(
"usr", Hexagon::USR)
394 .
Case(
"ugp", Hexagon::UGP)
395 .
Case(
"cs0", Hexagon::CS0)
396 .
Case(
"cs1", Hexagon::CS1)
420 for (
unsigned i = 0; i != RVLocs.
size(); ++i) {
422 if (RVLocs[i].getValVT() == MVT::i1) {
432 Register PredR =
MRI.createVirtualRegister(&Hexagon::PredRegsRegClass);
444 RVLocs[i].getValVT(), Glue);
470 bool IsStructRet = Outs.
empty() ?
false : Outs[0].Flags.isSRet();
479 bool TreatAsVarArg = !Subtarget.isEnvironmentMusl() && IsVarArg;
494 IsVarArg, IsStructRet, StructAttrFlag, Outs,
503 :
"Argument must be passed on stack. "
504 "Not eligible for Tail Call\n"));
522 bool NeedsArgAlign =
false;
523 Align LargestAlignSeen;
525 for (
unsigned i = 0, e = ArgLocs.
size(); i != e; ++i) {
530 bool ArgAlign = Subtarget.isHVXVectorType(VA.
getValVT());
531 NeedsArgAlign |= ArgAlign;
558 DAG.
getConstant(LocMemOffset, dl, BasePtr.getValueType());
561 LargestAlignSeen = std::max(
563 if (Flags.isByVal()) {
572 splitHlxPairArgStore(DAG, dl, Chain, Arg, MemAddr, VA.
getLocVT(),
588 if (NeedsArgAlign && Subtarget.hasV60Ops()) {
589 LLVM_DEBUG(
dbgs() <<
"Function needs byte stack align due to call args\n");
590 Align VecAlign = HRI.getSpillAlign(Hexagon::HvxVRRegClass);
591 LargestAlignSeen = std::max(LargestAlignSeen, VecAlign);
596 if (!MemOpChains.
empty())
610 for (
const auto &R : RegsToPass) {
611 Chain = DAG.
getCopyToReg(Chain, dl, R.first, R.second, Glue);
626 for (
const auto &R : RegsToPass) {
627 Chain = DAG.
getCopyToReg(Chain, dl, R.first, R.second, Glue);
648 Ops.push_back(Chain);
649 Ops.push_back(Callee);
653 for (
const auto &R : RegsToPass)
661 (Hexagon::HlxLRRegClass.contains(VA.
getLocReg()) ||
662 Hexagon::HlxLLRRegClass.contains(VA.
getLocReg()));
665 return Subtarget.isHLXVectorType(In.VT);
669 assert(Mask &&
"Missing call preserved mask for calling convention");
677 return DAG.
getNode(HexagonISD::TC_RETURN, dl, MVT::Other,
Ops);
685 unsigned OpCode = DoesNotReturn ? HexagonISD::CALLnr : HexagonISD::CALL;
686 Chain = DAG.
getNode(OpCode, dl, {MVT::Other, MVT::Glue},
Ops);
698 InVals, OutVals, Callee);
713 bool IsLegalType = VT == MVT::i8 || VT == MVT::i16 || VT == MVT::i32 ||
714 VT == MVT::i64 || VT == MVT::f32 || VT == MVT::f64 ||
715 VT == MVT::v2i16 || VT == MVT::v2i32 || VT == MVT::v4i8 ||
716 VT == MVT::v4i16 || VT == MVT::v8i8 ||
730 return Subtarget.getInstrInfo()->isValidAutoIncImm(VT, V);
745 unsigned LR = HRI.getRARegister();
751 unsigned NumOps =
Op.getNumOperands();
752 if (
Op.getOperand(
NumOps-1).getValueType() == MVT::Glue)
757 unsigned NumVals = Flags.getNumOperandRegisters();
760 switch (Flags.getKind()) {
771 for (; NumVals; --NumVals, ++i) {
775 HMFI.setHasClobberLR(
true);
797 return DAG.
getNode(HexagonISD::DCFETCH,
DL, MVT::Other, Chain, Addr,
Zero);
803 unsigned IntNo =
Op.getConstantOperandVal(1);
805 if (IntNo == Intrinsic::hexagon_prefetch) {
809 return DAG.
getNode(HexagonISD::DCFETCH,
DL, MVT::Other, Chain, Addr,
Zero);
823 assert(AlignConst &&
"Non-constant Align in LowerDYNAMIC_STACKALLOC");
826 auto &HFI = *Subtarget.getFrameLowering();
829 A = HFI.getStackAlign().value();
832 dbgs () << __func__ <<
" Align: " <<
A <<
" Size: ";
833 Size.getNode()->dump(&DAG);
847 EVT OpVT =
Op.getValueType();
866 switch (
Op.getOpcode()) {
893 bool TreatAsVarArg = !Subtarget.isEnvironmentMusl() && IsVarArg;
912 switch (RC.
getID()) {
913 case Hexagon::IntRegsRegClassID:
914 return Reg - Hexagon::R0 + 1;
915 case Hexagon::DoubleRegsRegClassID:
916 return (Reg - Hexagon::D0 + 1) * 2;
917 case Hexagon::HvxVRRegClassID:
918 return Reg - Hexagon::V0 + 1;
919 case Hexagon::HvxWRRegClassID:
920 return (Reg - Hexagon::W0 + 1) * 2;
921 case Hexagon::HlxLRRegClassID:
922 return Reg - Hexagon::L0 + 1;
923 case Hexagon::HlxLLRRegClassID:
924 return (Reg - Hexagon::LL0 + 1) * 2;
931 HFL.FirstVarArgSavedReg = 0;
934 for (
unsigned i = 0, e = ArgLocs.
size(); i != e; ++i) {
937 bool ByVal = Flags.isByVal();
943 if (VA.
isRegLoc() && ByVal && Flags.getByValSize() <= 8)
947 (!ByVal || (ByVal && Flags.getByValSize() > 8));
971 Subtarget.isHVXVectorType(RegVT) ||
972 Subtarget.isHLXVectorType(RegVT));
977 HFL.FirstVarArgSavedReg = NextSingleReg(*RC, VA.
getLocReg());
983 unsigned ObjSize = Flags.isByVal()
984 ? Flags.getByValSize()
999 if (Flags.isByVal()) {
1004 }
else if (isHlxPairTy(VA.
getValVT())) {
1006 splitHlxPairArgLoad(DAG, dl, Chain, FIN, VA.
getValVT(),
1016 if (IsVarArg && Subtarget.isEnvironmentMusl()) {
1017 for (
int i = HFL.FirstVarArgSavedReg; i < 6; i++)
1018 MRI.addLiveIn(Hexagon::R0+i);
1021 if (IsVarArg && Subtarget.isEnvironmentMusl()) {
1022 HMFI.setFirstNamedArgFrameIndex(HMFI.getFirstNamedArgFrameIndex() - 1);
1026 int NumVarArgRegs = 6 - HFL.FirstVarArgSavedReg;
1027 bool RequiresPadding = (NumVarArgRegs & 1);
1028 int RegSaveAreaSizePlusPadding = RequiresPadding
1029 ? (NumVarArgRegs + 1) * 4
1030 : NumVarArgRegs * 4;
1032 if (RegSaveAreaSizePlusPadding > 0) {
1035 if (!(RegAreaStart % 8))
1036 RegAreaStart = (RegAreaStart + 7) & -8;
1038 int RegSaveAreaFrameIndex =
1040 HMFI.setRegSavedAreaStartFrameIndex(RegSaveAreaFrameIndex);
1043 int Offset = RegAreaStart + RegSaveAreaSizePlusPadding;
1045 HMFI.setVarArgsFrameIndex(FI);
1051 HMFI.setRegSavedAreaStartFrameIndex(FI);
1052 HMFI.setVarArgsFrameIndex(FI);
1057 if (IsVarArg && !Subtarget.isEnvironmentMusl()) {
1061 HMFI.setVarArgsFrameIndex(FI);
1076 if (!Subtarget.isEnvironmentMusl()) {
1081 auto &HFL = *Subtarget.getFrameLowering();
1094 SDValue SavedRegAreaStartFrameIndex =
1095 DAG.
getFrameIndex(FuncInfo.getRegSavedAreaStartFrameIndex(), MVT::i32);
1099 if (HFL.FirstVarArgSavedReg & 1)
1100 SavedRegAreaStartFrameIndex =
1102 DAG.
getFrameIndex(FuncInfo.getRegSavedAreaStartFrameIndex(),
1109 SavedRegAreaStartFrameIndex,
1137 assert(Subtarget.isEnvironmentMusl() &&
"Linux ABI should be enabled");
1148 false,
false,
nullptr,
1161 if (
OpTy == MVT::v2i16 ||
OpTy == MVT::v4i8) {
1162 assert(
OpTy.getVectorElementType().isScalarInteger());
1163 MVT WideTy =
OpTy.widenIntegerElementType();
1177 auto isSExtFree = [
this](
SDValue N) {
1178 switch (
N.getOpcode()) {
1190 return ThisBW >= OrigBW;
1208 bool IsNegative =
C &&
C->getAPIntValue().isNegative();
1209 if (IsNegative || isSExtFree(LHS) || isSExtFree(RHS))
1221 SDValue Op1 =
Op.getOperand(1), Op2 =
Op.getOperand(2);
1225 if (
OpTy == MVT::v2i16 ||
OpTy == MVT::v4i8) {
1226 assert(
OpTy.getVectorElementType().isScalarInteger());
1227 MVT WideTy =
OpTy.widenIntegerElementType();
1241 EVT ValTy =
Op.getValueType();
1244 bool isVTi1Type =
false;
1248 unsigned VecLen = CV->getNumOperands();
1250 "conversion only supported for pow2 VectorSize");
1251 for (
unsigned i = 0; i < VecLen; ++i)
1253 CV->getOperand(i)->isNullValue()));
1268 else if (isVTi1Type)
1275 "Inconsistent target flag encountered");
1277 if (IsPositionIndependent)
1284 EVT VT =
Op.getValueType();
1302 EVT VT =
Op.getValueType();
1304 unsigned Depth =
Op.getConstantOperandVal(0);
1324 EVT VT =
Op.getValueType();
1326 unsigned Depth =
Op.getConstantOperandVal(0);
1338 return DAG.
getNode(HexagonISD::BARRIER, dl, MVT::Other,
Op.getOperand(0));
1346 auto *GV = GAN->getGlobal();
1347 int64_t
Offset = GAN->getOffset();
1349 auto &HLOF = *HTM.getObjFileLowering();
1355 if (GO && Subtarget.useSmallData() && HLOF.isGlobalInSmallSection(GO, HTM))
1356 return DAG.
getNode(HexagonISD::CONST32_GP, dl, PtrVT, GA);
1357 return DAG.
getNode(HexagonISD::CONST32, dl, PtrVT, GA);
1364 return DAG.
getNode(HexagonISD::AT_PCREL, dl, PtrVT, GA);
1371 return DAG.
getNode(HexagonISD::AT_GOT, dl, PtrVT, GOT, GA,
Off);
1384 return DAG.
getNode(HexagonISD::CONST32_GP, dl, PtrVT,
A);
1388 return DAG.
getNode(HexagonISD::AT_PCREL, dl, PtrVT,
A);
1397 return DAG.
getNode(HexagonISD::AT_PCREL,
SDLoc(
Op), PtrVT, GOTSym);
1403 unsigned char OperandFlags)
const {
1420 const auto &HRI = *Subtarget.getRegisterInfo();
1422 assert(Mask &&
"Missing call preserved mask for calling convention");
1425 Chain = DAG.
getNode(HexagonISD::CALL, dl, NodeTys,
Ops);
1457 if (IsPositionIndependent) {
1529 Hexagon::R0, Flags);
1542 switch (HTM.getTLSModel(GA->
getGlobal())) {
1562 auto &HRI = *Subtarget.getRegisterInfo();
1657 if (Subtarget.isEnvironmentMusl())
1672 for (
unsigned LegalIntOp :
1712 for (
unsigned IntExpOp :
1760 static const unsigned VectExpOps[] = {
1788 for (
unsigned VectExpOp : VectExpOps)
1802 if (VT.getVectorElementType() != MVT::i32) {
1829 for (
MVT NativeVT : {MVT::v8i1, MVT::v4i1, MVT::v2i1, MVT::v4i8,
1830 MVT::v8i8, MVT::v2i16, MVT::v4i16, MVT::v2i32}) {
1845 if (NativeVT.getVectorElementType() != MVT::i1) {
1852 for (
MVT VT : {MVT::v8i8, MVT::v4i16, MVT::v2i32}) {
1863 for (
MVT VT : {MVT::i16, MVT::i32, MVT::v4i8, MVT::i64, MVT::v8i8,
1864 MVT::v2i16, MVT::v4i16, MVT::v2i32}) {
1870 for (
MVT VT : {MVT::v2i1, MVT::v4i1, MVT::v8i1}) {
1876 for (
MVT VT : {MVT::v2i16, MVT::v4i8, MVT::v8i8, MVT::v2i32, MVT::v4i16,
1888 for (
MVT VT : {MVT::i1, MVT::v2i1, MVT::v4i1, MVT::v8i1}) {
1953 for (
MVT VT : {MVT::i8, MVT::i16, MVT::i32, MVT::i64, MVT::f32, MVT::f64,
1954 MVT::v2i16, MVT::v2i32, MVT::v4i8, MVT::v4i16, MVT::v8i8}) {
1961 if (Subtarget.hasV60Ops()) {
1967 if (Subtarget.hasV66Ops()) {
1971 if (Subtarget.hasV67Ops()) {
1983 if (Subtarget.useHVXOps())
1984 initializeHVXLowering();
1986 if (Subtarget.useHLXOps())
1987 initializeHLXLowering();
1993HexagonTargetLowering::validateConstPtrAlignment(
SDValue Ptr,
Align NeedAlign,
1998 unsigned Addr = CA->getZExtValue();
2001 if (HaveAlign >= NeedAlign)
2007 DiagnosticInfoMisalignedTrap(
StringRef M)
2012 static bool classof(
const DiagnosticInfo *DI) {
2013 return DI->
getKind() == DK_MisalignedTrap;
2019 raw_string_ostream
O(ErrMsg);
2020 O <<
"Misaligned constant address: " <<
format_hex(Addr, 10)
2021 <<
" has alignment " << HaveAlign.
value()
2022 <<
", but the memory access requires " << NeedAlign.
value();
2025 O <<
". The instruction has been replaced with a trap.";
2034 const SDLoc &dl(
Op);
2036 assert(!
LS->isIndexed() &&
"Not expecting indexed ops on constant address");
2049 return (ID == Intrinsic::hexagon_L2_loadrd_pbr ||
2050 ID == Intrinsic::hexagon_L2_loadri_pbr ||
2051 ID == Intrinsic::hexagon_L2_loadrh_pbr ||
2052 ID == Intrinsic::hexagon_L2_loadruh_pbr ||
2053 ID == Intrinsic::hexagon_L2_loadrb_pbr ||
2054 ID == Intrinsic::hexagon_L2_loadrub_pbr);
2078 if (Blk == Parent) {
2083 BaseVal = BackEdgeVal;
2085 }
while ((BaseVal != BackEdgeVal) && (IntrBaseVal != BackEdgeVal));
2088 if (IntrBaseVal == BackEdgeVal)
2095 assert(Idx >= 0 &&
"Unexpected index to incoming argument in PHI");
2127 Sum += CN->getSExtValue();
2131 }
while (BaseVal !=
V);
2135 if (HasOffset && Sum >= 0 &&
isUInt<16>(Sum))
2154 Type *RetTy =
I.getCalledFunction()->getReturnType();
2156 Type *VecTy = IsLoad ? RetTy :
I.getArgOperand(1)->getType();
2158 "Expected HLX vector type in HLX intrinsic");
2162 Info.ptrVal =
I.getArgOperand(0);
2164 Info.align =
Align(ST.getHLXVectorLength());
2176 case Intrinsic::hexagon_LX_L16b_tmp:
2177 case Intrinsic::hexagon_LX_LL16b_tmp:
2178 case Intrinsic::hexagon_LX_S16b_new:
2179 case Intrinsic::hexagon_LX_SS16b_new:
2183 case Intrinsic::hexagon_L2_loadrd_pbr:
2184 case Intrinsic::hexagon_L2_loadri_pbr:
2185 case Intrinsic::hexagon_L2_loadrh_pbr:
2186 case Intrinsic::hexagon_L2_loadruh_pbr:
2187 case Intrinsic::hexagon_L2_loadrb_pbr:
2188 case Intrinsic::hexagon_L2_loadrub_pbr: {
2190 auto &
DL =
I.getDataLayout();
2191 auto &Cont =
I.getCalledFunction()->getParent()->getContext();
2195 Type *ElTy =
I.getCalledFunction()->getReturnType()->getStructElementType(0);
2202 bool HasOffset =
false;
2204 Value *UnderlyingObj =
2215 Info.ptrVal = UnderlyingObj;
2216 Info.align =
DL.getABITypeAlign(Info.memVT.getTypeForEVT(Cont));
2221 case Intrinsic::hexagon_V6_vgathermw:
2222 case Intrinsic::hexagon_V6_vgathermw_128B:
2223 case Intrinsic::hexagon_V6_vgathermh:
2224 case Intrinsic::hexagon_V6_vgathermh_128B:
2225 case Intrinsic::hexagon_V6_vgathermhw:
2226 case Intrinsic::hexagon_V6_vgathermhw_128B:
2227 case Intrinsic::hexagon_V6_vgathermwq:
2228 case Intrinsic::hexagon_V6_vgathermwq_128B:
2229 case Intrinsic::hexagon_V6_vgathermhq:
2230 case Intrinsic::hexagon_V6_vgathermhq_128B:
2231 case Intrinsic::hexagon_V6_vgathermhwq:
2232 case Intrinsic::hexagon_V6_vgathermhwq_128B:
2233 case Intrinsic::hexagon_V6_vgather_vscattermh:
2234 case Intrinsic::hexagon_V6_vgather_vscattermh_128B: {
2235 const Module &M = *
I.getParent()->getParent()->getParent();
2237 Type *VecTy =
I.getArgOperand(
I.arg_size() - 1)->getType();
2240 Info.ptrVal =
I.getArgOperand(0);
2243 MaybeAlign(M.getDataLayout().getTypeAllocSizeInBits(VecTy) / 8);
2255 return X.getValueType().isScalarInteger();
2275 unsigned DefinedValues)
const {
2281 unsigned Index)
const {
2291 if (SrcTy.getVectorNumElements() <= 8)
2314 if (Subtarget.useHVXOps()) {
2315 unsigned Action = getPreferredHvxVectorAction(VT);
2334 if (Subtarget.useHVXOps()) {
2335 unsigned Action = getCustomHvxOperationAction(
Op);
2342std::pair<SDValue, int>
2343HexagonTargetLowering::getBaseAndOffset(
SDValue Addr)
const {
2347 return { Addr.
getOperand(0), CN->getSExtValue() };
2359 assert(AM.
size() <= 8 &&
"Unexpected shuffle mask");
2360 unsigned VecLen = AM.
size();
2363 assert(!Subtarget.isHVXVectorType(VecTy,
true) &&
2364 "HVX shuffles should be legal");
2374 if (ty(Op0) != VecTy || ty(Op1) != VecTy)
2383 if (AM[
F] >=
int(VecLen)) {
2391 for (
int M : Mask) {
2393 for (
unsigned j = 0; j != ElemBytes; ++j)
2396 for (
unsigned j = 0; j != ElemBytes; ++j)
2407 uint64_t MaskIdx = 0;
2408 uint64_t MaskUnd = 0;
2409 for (
unsigned i = 0, e = ByteMask.
size(); i != e; ++i) {
2411 uint64_t M = ByteMask[i] & 0xFF;
2417 if (ByteMask.
size() == 4) {
2419 if (MaskIdx == (0x03020100 | MaskUnd))
2422 if (MaskIdx == (0x00010203 | MaskUnd)) {
2430 getCombine(Op1, Op0, dl, typeJoin({ty(Op1), ty(Op0)}), DAG);
2431 if (MaskIdx == (0x06040200 | MaskUnd))
2432 return getInstr(Hexagon::S2_vtrunehb, dl, VecTy, {Concat10}, DAG);
2433 if (MaskIdx == (0x07050301 | MaskUnd))
2434 return getInstr(Hexagon::S2_vtrunohb, dl, VecTy, {Concat10}, DAG);
2437 getCombine(Op0, Op1, dl, typeJoin({ty(Op0), ty(Op1)}), DAG);
2438 if (MaskIdx == (0x02000604 | MaskUnd))
2439 return getInstr(Hexagon::S2_vtrunehb, dl, VecTy, {Concat01}, DAG);
2440 if (MaskIdx == (0x03010705 | MaskUnd))
2441 return getInstr(Hexagon::S2_vtrunohb, dl, VecTy, {Concat01}, DAG);
2444 if (ByteMask.
size() == 8) {
2446 if (MaskIdx == (0x0706050403020100ull | MaskUnd))
2449 if (MaskIdx == (0x0001020304050607ull | MaskUnd)) {
2456 if (MaskIdx == (0x0d0c050409080100ull | MaskUnd))
2457 return getInstr(Hexagon::S2_shuffeh, dl, VecTy, {Op1, Op0}, DAG);
2458 if (MaskIdx == (0x0f0e07060b0a0302ull | MaskUnd))
2459 return getInstr(Hexagon::S2_shuffoh, dl, VecTy, {Op1, Op0}, DAG);
2460 if (MaskIdx == (0x0d0c090805040100ull | MaskUnd))
2461 return getInstr(Hexagon::S2_vtrunewh, dl, VecTy, {Op1, Op0}, DAG);
2462 if (MaskIdx == (0x0f0e0b0a07060302ull | MaskUnd))
2463 return getInstr(Hexagon::S2_vtrunowh, dl, VecTy, {Op1, Op0}, DAG);
2464 if (MaskIdx == (0x0706030205040100ull | MaskUnd)) {
2465 VectorPair
P = opSplit(Op0, dl, DAG);
2466 return getInstr(Hexagon::S2_packhl, dl, VecTy, {
P.second,
P.first}, DAG);
2470 if (MaskIdx == (0x0e060c040a020800ull | MaskUnd))
2471 return getInstr(Hexagon::S2_shuffeb, dl, VecTy, {Op1, Op0}, DAG);
2472 if (MaskIdx == (0x0f070d050b030901ull | MaskUnd))
2473 return getInstr(Hexagon::S2_shuffob, dl, VecTy, {Op1, Op0}, DAG);
2481 switch (
Op.getOpcode()) {
2487 return Op.getOperand(0);
2497 switch (
Op.getOpcode()) {
2499 NewOpc = HexagonISD::VASL;
2502 NewOpc = HexagonISD::VASR;
2505 NewOpc = HexagonISD::VLSR;
2510 if (
SDValue Sp = getSplatValue(
Op.getOperand(1), DAG)) {
2518 "Hexagon vector shift-by-int must use i32 shift operand");
2519 return DAG.
getNode(NewOpc, dl, ty(
Op),
Op.getOperand(0), Sh);
2533 if (
SDValue S = getVectorShiftByInt(
Op, DAG))
2538 case HexagonISD::VASR:
2539 case HexagonISD::VLSR:
2540 case HexagonISD::VASL:
2547 MVT ResTy = ty(Res);
2565 return ShiftPartI8(
Opc, Val, Amt);
2567 auto [LoV, HiV] = opSplit(Val, dl, DAG);
2569 {ShiftPartI8(
Opc, LoV, Amt), ShiftPartI8(
Opc, HiV, Amt)});
2583 MVT InpTy = ty(InpV);
2588 if (InpTy == MVT::i8) {
2589 if (ResTy == MVT::v8i1) {
2592 return getInstr(Hexagon::C2_tfrrp, dl, ResTy, Ext, DAG);
2605 unsigned ElemWidth =
ElemTy.getSizeInBits();
2607 bool AllConst =
true;
2609 for (
unsigned i = 0, e =
Values.size(); i != e; ++i) {
2612 Consts[i] = ConstantInt::get(IntTy, 0);
2617 const ConstantInt *CI = CN->getConstantIntValue();
2621 const ConstantFP *CF = CN->getConstantFPValue();
2623 Consts[i] = ConstantInt::get(IntTy,
A.getZExtValue());
2638 bool AllConst = getBuildVectorConstInts(Elem, VecTy, DAG, Consts);
2642 if (!isUndef(Elem[
First]))
2650 return getZero(dl, VecTy, DAG);
2652 if (ElemTy == MVT::i16 || ElemTy == MVT::f16) {
2657 uint32_t
V = (Consts[0]->getZExtValue() & 0xFFFF) |
2658 Consts[1]->getZExtValue() << 16;
2662 if (ElemTy == MVT::f16) {
2669 SDValue N = getInstr(Hexagon::A2_combine_ll, dl, MVT::i32, {E1,
E0}, DAG);
2673 if (ElemTy == MVT::i8) {
2676 uint32_t
V = (Consts[0]->getZExtValue() & 0xFF) |
2677 (Consts[1]->getZExtValue() & 0xFF) << 8 |
2678 (Consts[2]->getZExtValue() & 0xFF) << 16 |
2679 Consts[3]->getZExtValue() << 24;
2684 bool IsSplat =
true;
2685 for (
unsigned i =
First+1; i != Num; ++i) {
2686 if (Elem[i] == Elem[
First] || isUndef(Elem[i]))
2702 for (
unsigned i = 0; i != 4; ++i) {
2712 SDValue R = getInstr(Hexagon::A2_combine_ll, dl, MVT::i32, {
B1,
B0}, DAG);
2717 dbgs() <<
"VecTy: " << VecTy <<
'\n';
2729 bool AllConst = getBuildVectorConstInts(Elem, VecTy, DAG, Consts);
2733 if (!isUndef(Elem[
First]))
2741 return getZero(dl, VecTy, DAG);
2744 if (ElemTy == MVT::i16 || ElemTy == MVT::f16) {
2745 bool IsSplat =
true;
2746 for (
unsigned i =
First+1; i != Num; ++i) {
2747 if (Elem[i] == Elem[
First] || isUndef(Elem[i]))
2766 for (
unsigned i = 0; i != Num; ++i)
2767 Val = (Val << W) | (Consts[Num-1-i]->getZExtValue() & Mask);
2776 : buildVector32(Elem.take_front(Num/2), dl, HalfTy, DAG);
2779 : buildVector32(Elem.
drop_front(Num/2), dl, HalfTy, DAG);
2780 return getCombine(
H, L, dl, VecTy, DAG);
2787 MVT VecTy = ty(VecV);
2791 return extractVectorPred(VecV, IdxV, dl, ValTy, ResTy, DAG);
2796 assert((VecWidth % ElemWidth) == 0);
2797 assert(VecWidth == 32 || VecWidth == 64);
2800 MVT ScalarTy = tyScalar(VecTy);
2807 unsigned Off = IdxN->getZExtValue() * ElemWidth;
2808 if (VecWidth == 64 && ValWidth == 32) {
2810 ExtV =
Off == 0 ? LoHalf(VecV, DAG) : HiHalf(VecV, DAG);
2811 }
else if (
Off == 0 && (ValWidth % 8) == 0) {
2817 ExtV = DAG.
getNode(HexagonISD::EXTRACTU, dl, ScalarTy,
2818 {VecV, WidthV, OffV});
2821 if (ty(IdxV) != MVT::i32)
2825 ExtV = DAG.
getNode(HexagonISD::EXTRACTU, dl, ScalarTy,
2826 {VecV, WidthV, OffV});
2836HexagonTargetLowering::extractVectorPred(
SDValue VecV,
SDValue IdxV,
2841 MVT VecTy = ty(VecV);
2845 "Vector elements should equal vector width size");
2846 assert(VecWidth == 8 || VecWidth == 4 || VecWidth == 2);
2857 if (ValWidth == 1) {
2858 SDValue A0 = getInstr(Hexagon::C2_tfrpr, dl, MVT::i32, {VecV}, DAG);
2861 return DAG.
getNode(HexagonISD::TSTBIT, dl, MVT::i1, A0, I0);
2868 unsigned Scale = VecWidth / ValWidth;
2872 assert(ty(IdxV) == MVT::i32);
2873 unsigned VecRep = 8 / VecWidth;
2881 T1 = LoHalf(
T1, DAG);
2882 T1 = expandPredicate(
T1, dl, DAG);
2893 MVT VecTy = ty(VecV);
2895 return insertVectorPred(VecV, ValV, IdxV, dl, ValTy, DAG);
2899 assert(VecWidth == 32 || VecWidth == 64);
2900 assert((VecWidth % ValWidth) == 0);
2906 unsigned VW = ty(ValV).getSizeInBits();
2916 unsigned W =
C->getZExtValue() * ValWidth;
2918 InsV = DAG.
getNode(HexagonISD::INSERT, dl, ScalarTy,
2919 {VecV, ValV, WidthV, OffV});
2921 if (ty(IdxV) != MVT::i32)
2924 InsV = DAG.
getNode(HexagonISD::INSERT, dl, ScalarTy,
2925 {VecV, ValV, WidthV, OffV});
2932HexagonTargetLowering::insertVectorPred(
SDValue VecV,
SDValue ValV,
2935 MVT VecTy = ty(VecV);
2938 if (ValTy == MVT::i1) {
2939 SDValue ToReg = getInstr(Hexagon::C2_tfrpr, dl, MVT::i32, {VecV}, DAG);
2944 DAG.
getNode(HexagonISD::INSERT, dl, MVT::i32, {ToReg, Ext, Width,
Idx});
2945 return getInstr(Hexagon::C2_tfrrp, dl, VecTy, {Ins}, DAG);
2956 for (
unsigned R = Scale;
R > 1;
R /= 2) {
2957 ValR = contractPredicate(ValR, dl, DAG);
2958 ValR = getCombine(DAG.
getUNDEF(MVT::i32), ValR, dl, MVT::i64, DAG);
2965 DAG.
getNode(HexagonISD::INSERT, dl, MVT::i64, {VecR, ValR, Width,
Idx});
2970HexagonTargetLowering::expandPredicate(
SDValue Vec32,
const SDLoc &dl,
2972 assert(ty(Vec32).getSizeInBits() == 32);
2981HexagonTargetLowering::contractPredicate(
SDValue Vec64,
const SDLoc &dl,
2983 assert(ty(Vec64).getSizeInBits() == 64);
2989 {0, 2, 4, 6, 1, 3, 5, 7});
2990 return extractVector(S, DAG.
getConstant(0, dl, MVT::i32), dl, MVT::v4i8,
3014 MVT ValTy = ty(Val);
3019 if (ValLen == ResLen)
3022 const SDLoc &dl(Val);
3024 assert(ResLen % ValLen == 0);
3027 for (
unsigned i = 1, e = ResLen / ValLen; i <
e; ++i)
3036 MVT ElemTy = ty(
Hi);
3050 {DAG.getBitcast(IntTy, Lo), DAG.getBitcast(IntTy, Hi)});
3060 for (
unsigned i = 0, e =
Op.getNumOperands(); i != e; ++i)
3061 Ops.push_back(
Op.getOperand(i));
3064 return buildVector32(
Ops, dl, VecTy, DAG);
3066 return buildVector64(
Ops, dl, VecTy, DAG);
3068 if (VecTy == MVT::v8i1 || VecTy == MVT::v4i1 || VecTy == MVT::v2i1) {
3070 bool All0 =
true, All1 =
true;
3073 if (CN ==
nullptr) {
3074 All0 = All1 =
false;
3082 return DAG.
getNode(HexagonISD::PFALSE, dl, VecTy);
3084 return DAG.
getNode(HexagonISD::PTRUE, dl, VecTy);
3090 SDValue Z = getZero(dl, MVT::i32, DAG);
3093 for (
unsigned i = 0; i != 8; ++i) {
3098 for (
unsigned i = 0, e =
A.size()/2; i != e; ++i)
3102 return getInstr(Hexagon::C2_tfrrp, dl, VecTy, {Rs[0]}, DAG);
3115 return getCombine(
Op.getOperand(1),
Op.getOperand(0), dl, VecTy, DAG);
3120 assert(VecTy == MVT::v2i1 || VecTy == MVT::v4i1 || VecTy == MVT::v8i1);
3125 assert(Scale ==
Op.getNumOperands() && Scale > 1);
3134 for (
SDValue P :
Op.getNode()->op_values()) {
3136 for (
unsigned R = Scale; R > 1; R /= 2) {
3137 W = contractPredicate(W, dl, DAG);
3138 W = getCombine(DAG.
getUNDEF(MVT::i32), W, dl, MVT::i64, DAG);
3146 Words[IdxW ^ 1].
clear();
3148 for (
unsigned i = 0, e = Words[IdxW].
size(); i != e; i += 2) {
3149 SDValue W0 = Words[IdxW][i], W1 = Words[IdxW][i+1];
3152 {W0, W1, WidthV, WidthV});
3160 assert(Scale == 2 && Words[IdxW].
size() == 2);
3162 SDValue WW = getCombine(Words[IdxW][1], Words[IdxW][0], dl, MVT::i64, DAG);
3173 MVT ElemTy = ty(Vec).getVectorElementType();
3180 return extractVector(
Op.getOperand(0),
Op.getOperand(1),
SDLoc(
Op),
3181 ty(
Op), ty(
Op), DAG);
3187 return insertVector(
Op.getOperand(0),
Op.getOperand(1),
Op.getOperand(2),
3195 return insertVector(
Op.getOperand(0), ValV,
Op.getOperand(2),
3220 bool LoadPred = MemTy == MVT::v2i1 || MemTy == MVT::v4i1 || MemTy == MVT::v8i1;
3231 if (!validateConstPtrAlignment(LN->
getBasePtr(), ClaimAlign, dl, DAG))
3232 return replaceMemWithUndef(
Op, DAG);
3238 SDValue TP = getInstr(Hexagon::C2_tfrrp, dl, MemTy, {LU}, DAG);
3257 if (Ty == MVT::v2i1 || Ty == MVT::v4i1 || Ty == MVT::v8i1) {
3259 SDValue TR = getInstr(Hexagon::C2_tfrpr, dl, MVT::i32, {Val}, DAG);
3270 if (!validateConstPtrAlignment(SN->
getBasePtr(), ClaimAlign, dl, DAG))
3271 return replaceMemWithUndef(
Op, DAG);
3274 Align NeedAlign = Subtarget.getTypeAlignment(StoreTy);
3275 if (ClaimAlign < NeedAlign)
3284 MVT LoadTy = ty(
Op);
3285 unsigned NeedAlign = Subtarget.getTypeAlignment(LoadTy).
value();
3287 if (HaveAlign >= NeedAlign)
3296 bool DoDefault =
false;
3307 if (!DoDefault && (2 * HaveAlign) == NeedAlign) {
3326 unsigned LoadLen = NeedAlign;
3329 auto BO = getBaseAndOffset(
Base);
3330 unsigned BaseOpc = BO.first.getOpcode();
3331 if (BaseOpc == HexagonISD::VALIGNADDR && BO.second % LoadLen == 0)
3334 if (BO.second % LoadLen != 0) {
3336 DAG.
getConstant(BO.second % LoadLen, dl, MVT::i32));
3337 BO.second -= BO.second % LoadLen;
3339 SDValue BaseNoOff = (BaseOpc != HexagonISD::VALIGNADDR)
3340 ? DAG.
getNode(HexagonISD::VALIGNADDR, dl, MVT::i32, BO.first,
3352 MMO->getPointerInfo(), MMO->getFlags(), 2 * LoadLen,
Align(LoadLen),
3353 MMOMetadata(MMO->getAAInfo(), MMO->getRanges()), MMO->getSyncScopeID(),
3354 MMO->getSuccessOrdering(), MMO->getFailureOrdering());
3379 unsigned Opc =
Op.getOpcode();
3382 uint64_t VY = CY->getZExtValue();
3383 assert(VY != 0 &&
"This should have been folded");
3408 unsigned Opc =
Op.getOpcode();
3412 return DAG.
getNode(HexagonISD::ADDC, dl,
Op.getNode()->getVTList(),
3415 EVT CarryTy =
C.getValueType();
3416 SDValue SubC = DAG.
getNode(HexagonISD::SUBC, dl,
Op.getNode()->getVTList(),
3417 { X, Y, DAG.getLogicalNOT(dl, C, CarryTy) });
3436 unsigned OffsetReg = Hexagon::R28;
3447 return DAG.
getNode(HexagonISD::EH_RETURN, dl, MVT::Other, Chain);
3452 unsigned Opc =
Op.getOpcode();
3457 if (isHlxOperation(
Op.getNode(), DAG)) {
3459 if (
SDValue V = LowerHlxOperation(
Op, DAG))
3461 }
else if (isHvxOperation(
Op.getNode(), DAG)) {
3463 if (
SDValue V = LowerHvxOperation(
Op, DAG))
3470 Op.getNode()->dumpr(&DAG);
3531 if (isHvxOperation(
N, DAG)) {
3532 LowerHvxOperationWrapper(
N,
Results, DAG);
3538 unsigned Opc =
N->getOpcode();
3541 case HexagonISD::SSAT:
3542 case HexagonISD::USAT:
3562 if (isHvxOperation(
N, DAG)) {
3563 ReplaceHvxNodeResults(
N,
Results, DAG);
3569 switch (
N->getOpcode()) {
3576 if (
N->getValueType(0) == MVT::i8) {
3577 if (
N->getOperand(0).getValueType() == MVT::v8i1) {
3578 SDValue P = getInstr(Hexagon::C2_tfrpr, dl, MVT::i32,
3579 N->getOperand(0), DAG);
3593 unsigned Opc =
Op.getOpcode();
3607 if (
SDValue V = splitExtendingPartialReduceMLA(
N, DCI.
DAG))
3618 if (
C1->getOpcode() == HexagonISD::PTRUE) {
3620 Op.getOperand(2),
Op.getOperand(1));
3629 if (isHvxOperation(
N, DCI.
DAG)) {
3630 if (
SDValue V = PerformHvxDAGCombine(
N, DCI))
3639 EVT TruncTy =
Op.getValueType();
3656 switch (
P.getOpcode()) {
3657 case HexagonISD::PTRUE:
3659 case HexagonISD::PFALSE:
3660 return getZero(dl, ty(
Op), DCI.
DAG);
3670 MVT TruncTy = ty(
Op);
3673 if (ty(Elem0) == TruncTy)
3676 if (ty(Elem0).bitsGT(TruncTy))
3685 if (ty(
Op) != MVT::i64)
3697 if (Amt && Amt->getZExtValue() >= 32 && ty(Z).getSizeInBits() <= 32) {
3698 unsigned A = Amt->getZExtValue();
3704 return DCI.
DAG.
getNode(HexagonISD::COMBINE, dl, MVT::i64, {T1, T2});
3734 if (Constraint.
size() == 1) {
3735 switch (Constraint[0]) {
3738 if (Subtarget.useHVXOps())
3750std::pair<unsigned, const TargetRegisterClass*>
3754 if (Constraint.
size() == 1) {
3755 switch (Constraint[0]) {
3759 return {0u,
nullptr};
3765 return {0u, &Hexagon::IntRegsRegClass};
3768 return {0u, &Hexagon::DoubleRegsRegClass};
3773 return {0u,
nullptr};
3774 return {0u, &Hexagon::ModRegsRegClass};
3778 return {0u,
nullptr};
3781 return {0u, &Hexagon::HvxQRRegClass};
3787 return {0u,
nullptr};
3789 return {0u, &Hexagon::HvxVRRegClass};
3791 if (Subtarget.hasV60Ops() && Subtarget.useHVX128BOps())
3792 return {0u, &Hexagon::HvxVRRegClass};
3793 return {0u, &Hexagon::HvxWRRegClass};
3795 return {0u, &Hexagon::HvxWRRegClass};
3799 return {0u,
nullptr};
3809 bool ForCodeSize)
const {
3820 assert(Ty->isIntegerTy());
3821 unsigned BitSize = Ty->getPrimitiveSizeInBits();
3822 return (BitSize > 0 && BitSize <= 64);
3830 if (Ty->isSized()) {
3851 int Scale = AM.
Scale;
3875 return Imm >= -512 &&
Imm <= 511;
3885 bool IsCalleeStructRet,
3886 bool IsCallerStructRet,
3893 bool CCMatch = CallerCC == CalleeCC;
3922 if (IsCalleeStructRet || IsCallerStructRet)
3946 if (
Op.size() >= 8 &&
Op.isAligned(
Align(8)))
3948 if (
Op.size() >= 4 &&
Op.isAligned(
Align(4)))
3950 if (
Op.size() >= 2 &&
Op.isAligned(
Align(2)))
3964 assert(
Op != Instruction::ICmp &&
Op != Instruction::FCmp);
3970 "Reduction emission only supported for non-zero length vectors!");
3974 for (
unsigned ExtractIdx = 1; ExtractIdx < VF; ++ExtractIdx) {
3976 Result = DAG.
getNode(
Op,
DL, EltT, {Result, Ext});
3984 assert(
Op != Instruction::ICmp &&
Op != Instruction::FCmp);
3994 "Reduction emission only supported for pow2 vectors!");
4000 for (
unsigned i = VF; i > 1; i >>= 1) {
4002 for (
unsigned j = 0; j != i / 2; ++j)
4003 ShuffleMask[j] = i / 2 + j;
4005 std::fill(&ShuffleMask[i / 2], ShuffleMask.end(), -1);
4033 if (Subtarget.isHLXVectorType(SVT))
4034 return allowsHlxMemoryAccess(SVT, Flags,
Fast);
4035 if (Subtarget.isHVXVectorType(SVT,
true))
4036 return allowsHvxMemoryAccess(SVT, Flags,
Fast);
4038 Context,
DL, VT, AddrSpace, Alignment, Flags,
Fast);
4043 unsigned *
Fast)
const {
4047 if (Subtarget.isHVXVectorType(SVT,
true))
4048 return allowsHvxMisalignedMemoryAccesses(SVT, Flags,
Fast);
4054std::pair<const TargetRegisterClass*, uint8_t>
4057 if (
Subtarget.isHVXVectorType(VT,
true)) {
4059 unsigned VecWidth =
Subtarget.getVectorLength() * 8;
4062 return std::make_pair(&Hexagon::HvxQRRegClass, 1);
4064 return std::make_pair(&Hexagon::HvxVRRegClass, 1);
4066 return std::make_pair(&Hexagon::HvxWRRegClass, 1);
4074 std::optional<unsigned> ByteOffset)
const {
4081 std::pair<SDValue, int> BO = getBaseAndOffset(L->getBasePtr());
4083 if (BO.first.getOpcode() == HexagonISD::CONST32_GP)
4088 return !GO || !HTM.getObjFileLowering()->isGlobalInSmallSection(GO, HTM);
4095 AdjustHvxInstrPostInstrSelection(
MI,
Node);
4101 unsigned SZ = ValueTy->getPrimitiveSizeInBits();
4102 assert((SZ == 32 || SZ == 64) &&
"Only 32/64-bit atomic loads supported");
4103 Intrinsic::ID IntID = (SZ == 32) ? Intrinsic::hexagon_L2_loadw_locked
4104 : Intrinsic::hexagon_L4_loadd_locked;
4107 Builder.CreateIntrinsic(IntID, Addr,
nullptr,
"larx");
4109 return Builder.CreateBitCast(
Call, ValueTy);
4123 assert((SZ == 32 || SZ == 64) &&
"Only 32/64-bit atomic stores supported");
4124 Intrinsic::ID IntID = (SZ == 32) ? Intrinsic::hexagon_S2_storew_locked
4125 : Intrinsic::hexagon_S4_stored_locked;
4127 Val = Builder.CreateBitCast(Val, CastTy);
4129 Value *
Call = Builder.CreateIntrinsic(IntID, {Addr, Val},
4131 Value *Cmp = Builder.CreateICmpEQ(
Call, Builder.getInt32(0),
"");
4147 return SI->getValueOperand()->getType()->getPrimitiveSizeInBits() > 64
4160 switch (
MI.getOpcode()) {
4161 case TargetOpcode::PATCHABLE_EVENT_CALL:
4162 case TargetOpcode::PATCHABLE_TYPED_EVENT_CALL:
4175 "Invalid call instruction for a KCFI check");
4177 switch (
MBBI->getOpcode()) {
4178 case Hexagon::J2_callr:
4179 case Hexagon::PS_callr_nr:
4186 assert(
Target.isReg() &&
"Invalid target operand for an indirect call");
4187 Target.setIsRenamable(
false);
4202 return Mask->getValue().isPowerOf2();
4209 if (
N->getNumValues() != 1)
4211 if (!
N->hasNUsesOfValue(1, 0))
4214 SDNode *Copy = *
N->user_begin();
4226 if (Copy->getOperand(Copy->getNumOperands() - 1).getValueType() == MVT::Glue)
4230 bool HasRet =
false;
4232 if (
Node->getOpcode() != HexagonISD::RET_GLUE)
4239 Chain = Copy->getOperand(0);
4252 Align StackAlign)
const {
4254 unsigned StackProbeSize =
4258 return StackProbeSize ? StackProbeSize : StackAlign.
value();
const AArch64Subtarget & Subtarget
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file implements a class to represent arbitrary precision integral constant values and operations...
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
Function Alias Analysis Results
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
const HexagonInstrInfo * TII
static cl::opt< bool > ConstantLoadsToImm("constant-loads-to-imm", cl::Hidden, cl::init(true), cl::desc("Convert constant loads to immediate values."))
static bool CC_SkipOdd(unsigned &ValNo, MVT &ValVT, MVT &LocVT, CCValAssign::LocInfo &LocInfo, ISD::ArgFlagsTy &ArgFlags, CCState &State)
static void getHlxMemIntrinsicInfo(const CallBase &I, const HexagonSubtarget &ST, TargetLowering::IntrinsicInfo &Info)
Infer IntrinsicInfo for an HLX memory intrinsic from its IR signature.
static cl::opt< bool > AlignLoads("hexagon-align-loads", cl::Hidden, cl::init(false), cl::desc("Rewrite unaligned loads as a pair of aligned loads"))
static bool isBrevLdIntrinsic(const Value *Inst)
static Value * getUnderLyingObjectForBrevLdIntr(Value *V, int &Offset, bool &HasOffset)
static Value * getBrevLdObject(Value *V)
static cl::opt< bool > DisableArgsMinAlignment("hexagon-disable-args-min-alignment", cl::Hidden, cl::init(false), cl::desc("Disable minimum alignment of 1 for " "arguments passed by value on stack"))
static Value * returnEdge(const PHINode *PN, Value *IntrBaseVal)
static SDValue CreateCopyOfByValArgument(SDValue Src, SDValue Dst, SDValue Chain, ISD::ArgFlagsTy Flags, SelectionDAG &DAG, const SDLoc &dl)
CreateCopyOfByValArgument - Make a copy of an aggregate at address specified by "Src" to address "Dst...
static cl::opt< bool > EmitJumpTables("hexagon-emit-jump-tables", cl::init(true), cl::Hidden, cl::desc("Control jump table emission on Hexagon target"))
static unsigned assignVTCMStackOffsets(SmallVectorImpl< CCValAssign > &ArgLocs)
static cl::opt< int > MinimumJumpTables("minimum-jump-tables", cl::Hidden, cl::init(5), cl::desc("Set minimum jump tables"))
static cl::opt< bool > EnableHexSDNodeSched("enable-hexagon-sdnode-sched", cl::Hidden, cl::desc("Enable Hexagon SDNode scheduling"))
static bool CC_Hexagon_VTCM_Stack(unsigned &ValNo, MVT &ValVT, MVT &LocVT, CCValAssign::LocInfo &LocInfo, ISD::ArgFlagsTy &ArgFlags, CCState &State)
#define Hexagon_PointerSize
#define HEXAGON_LRFP_SIZE
#define HEXAGON_GOT_SYM_NAME
Module.h This file contains the declarations for the Module class.
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
std::pair< MCSymbol *, MachineModuleInfoImpl::StubValueTy > PairTy
Register const TargetRegisterInfo * TRI
Promote Memory to Register
SmallVector< MachineOperand, 4 > Cond
MachineRegisterInfo & MRI
This file defines the SmallVector class.
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
APInt bitcastToAPInt() const
Class for arbitrary precision integers.
uint64_t getZExtValue() const
Get zero extended value.
LLVM_ABI APInt trunc(unsigned width) const
Truncate to new width.
LLVM_ABI APInt reverseBits() const
Represent a constant reference to an array (0 or more elements consecutively in memory),...
ArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
size_t size() const
Get the array size.
An instruction that atomically checks whether a specified value is in a memory location,...
LLVM_ABI StringRef getValueAsString() const
Return the attribute's value as a string.
LLVM Basic Block Representation.
const Function * getParent() const
Return the enclosing method, or null if none.
The address of a basic block.
CCState - This class holds information needed while lowering arguments and return values.
LLVM_ABI void AnalyzeCallResult(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
AnalyzeCallResult - Analyze the return values of a call, incorporating info about the passed values i...
LLVM_ABI bool CheckReturn(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
CheckReturn - Analyze the return values of a function, returning true if the return can be performed ...
LLVM_ABI void AnalyzeReturn(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
AnalyzeReturn - Analyze the returned values of a return, incorporating info about the result values i...
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.
Register getLocReg() const
LocInfo getLocInfo() const
int64_t getLocMemOffset() const
static CCValAssign getCustomMem(unsigned ValNo, MVT ValVT, int64_t Offset, MVT LocVT, LocInfo HTP)
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
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 isZero() const
This is just a convenience method to make client code smaller for a common code.
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
const APInt & getValue() const
Return the constant as an APInt value reference.
MachineConstantPoolValue * getMachineCPVal() const
bool isMachineConstantPoolEntry() const
const Constant * getConstVal() const
int64_t getSExtValue() const
static LLVM_ABI Constant * get(ArrayRef< Constant * > V)
This is an important base class in LLVM.
A parsed version of the target data layout string in and methods for querying it.
This is the base abstract class for diagnostic reporting in the backend.
Interface for custom diagnostic printing.
bool hasOptSize() const
Optimize this function for size (-Os) or minimum size (-Oz).
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
uint64_t getFnAttributeAsParsedInteger(StringRef Kind, uint64_t Default=0) const
For a string attribute Kind, parse attribute as an integer.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
bool hasStructRetAttr() const
Determine if the function returns a structure through first or second pointer argument.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
int64_t getOffset() const
const GlobalValue * getGlobal() const
Module * getParent()
Get the module that this global value is contained inside of...
LLVM_ABI const GlobalObject * getAliaseeObject() const
Hexagon target-specific information for each MachineFunction.
int getVarArgsFrameIndex()
void setFirstNamedArgFrameIndex(int v)
void setHasEHReturn(bool H=true)
Register getVTCMStackRegister() const
Register getStackRegister() const
const uint32_t * getHLXCallPreservedMask() const
Mask for calls that pass or return values in HLX registers.
Register getFrameRegister(const MachineFunction &MF) const override
const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID) const override
SDValue getPICJumpTableRelocBase(SDValue Table, SelectionDAG &DAG) const override
Returns relocation base for the given PIC jumptable.
SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const
SDValue LowerFMINFMAX(SDValue Op, SelectionDAG &DAG) const
MachineInstr * EmitKCFICheck(MachineBasicBlock &MBB, MachineBasicBlock::instr_iterator &MBBI, const TargetInstrInfo *TII) const override
SDValue LowerGLOBAL_OFFSET_TABLE(SDValue Op, SelectionDAG &DAG) const
bool isMaskAndCmp0FoldingBeneficial(const Instruction &AndI) const override
Return if the target supports combining a chain like:
SDValue LowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const
void AdjustInstrPostInstrSelection(MachineInstr &MI, SDNode *Node) const override
This method should be implemented by targets that mark instructions with the 'hasPostISelHook' flag.
bool isTargetCanonicalConstantNode(SDValue Op) const override
Returns true if the given Opc is considered a canonical constant for the target, which should not be ...
ConstraintType getConstraintType(StringRef Constraint) const override
Given a constraint, return the type of constraint it is for this target.
bool isTruncateFree(Type *Ty1, Type *Ty2) const override
Return true if it's free to truncate a value of type FromTy to type ToTy.
MVT getRegisterTypeForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const override
Certain combinations of ABIs, Targets and features require that types are legal for some operations a...
unsigned getStackProbeSize(const MachineFunction &MF, Align StackAlign) const
SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const
SDValue LowerEH_RETURN(SDValue Op, SelectionDAG &DAG) const
ExtractSubvectorCost getExtractSubvectorCost(EVT ResVT, EVT SrcVT, unsigned Index) const override
Return the cost of extracting a subvector of type ResVT from a vector of type SrcVT,...
SDValue LowerUAddSubO(SDValue Op, SelectionDAG &DAG) const
Value * emitLoadLinked(IRBuilderBase &Builder, Type *ValueTy, Value *Addr, AtomicOrdering Ord) const override
Perform a load-linked operation on Addr, returning a "Value *" with the corresponding pointee type.
bool isLegalICmpImmediate(int64_t Imm) const override
isLegalICmpImmediate - Return true if the specified immediate is legal icmp immediate,...
bool shouldReduceLoadWidth(SDNode *Load, ISD::LoadExtType ExtTy, EVT NewVT, std::optional< unsigned > ByteOffset) const override
Return true if it is profitable to reduce a load to a smaller type.
bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty, unsigned AS, Instruction *I=nullptr) const override
isLegalAddressingMode - Return true if the addressing mode represented by AM is legal for this target...
SDValue LowerINLINEASM(SDValue Op, SelectionDAG &DAG) const
AtomicExpansionKind shouldExpandAtomicStoreInIR(StoreInst *SI) const override
Returns how the given (atomic) store should be expanded by the IR-level AtomicExpand pass into.
SDValue GetDynamicTLSAddr(SelectionDAG &DAG, SDValue Chain, GlobalAddressSDNode *GA, SDValue InGlue, EVT PtrVT, unsigned ReturnReg, unsigned char OperandGlues) const
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,...
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 LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const
bool getPostIndexedAddressParts(SDNode *N, SDNode *Op, SDValue &Base, SDValue &Offset, ISD::MemIndexedMode &AM, SelectionDAG &DAG) const override
Returns true by value, base pointer and offset pointer and addressing mode by reference if this node ...
SDValue LowerUnalignedLoad(SDValue Op, SelectionDAG &DAG) const
SDValue LowerFDIV(SDValue Op, SelectionDAG &DAG) const
SDValue LowerVACOPY(SDValue Op, SelectionDAG &DAG) const
unsigned getVectorTypeBreakdownForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT, EVT &IntermediateVT, unsigned &NumIntermediates, MVT &RegisterVT) const override
Certain targets such as MIPS require that some types such as vectors are always broken down into scal...
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.
AtomicExpansionKind shouldExpandAtomicLoadInIR(LoadInst *LI) const override
Returns how the given (atomic) load should be expanded by the IR-level AtomicExpand pass.
bool isUsedByReturnOnly(SDNode *N, SDValue &Chain) const override
Return true if result of the specified node is used by a return node only.
SDValue LowerCallResult(SDValue Chain, SDValue InGlue, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl< ISD::InputArg > &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl< SDValue > &InVals, const SmallVectorImpl< SDValue > &OutVals, SDValue Callee) const
LowerCallResult - Lower the result values of an ISD::CALL into the appropriate copies out of appropri...
SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const
SDValue LowerToTLSInitialExecModel(GlobalAddressSDNode *GA, SelectionDAG &DAG) const
SDValue LowerToTLSGeneralDynamicModel(GlobalAddressSDNode *GA, SelectionDAG &DAG) const
bool allowsMemoryAccess(LLVMContext &Context, const DataLayout &DL, EVT VT, unsigned AddrSpace, Align Alignment, MachineMemOperand::Flags Flags, unsigned *Fast) const override
Return true if the target supports a memory access of this type for the given address space and align...
SDValue LowerINSERT_SUBVECTOR(SDValue Op, SelectionDAG &DAG) const
MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr &MI, MachineBasicBlock *BB) const override
This method should be implemented by targets that mark instructions with the 'usesCustomInserter' fla...
SDValue LowerROTL(SDValue Op, SelectionDAG &DAG) const
SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const
SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const
SDValue LowerLoad(SDValue Op, SelectionDAG &DAG) const
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 isShuffleMaskLegal(ArrayRef< int > Mask, EVT VT) const override
Targets can use this to indicate that they only support some VECTOR_SHUFFLE operations,...
LegalizeAction getCustomOperationAction(SDNode &Op) const override
How to legalize this custom operation?
SDValue LowerToTLSLocalExecModel(GlobalAddressSDNode *GA, SelectionDAG &DAG) const
SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const
bool allowTruncateForTailCall(Type *Ty1, Type *Ty2) const override
Return true if a truncation from FromTy to ToTy is permitted when deciding whether a call is in tail ...
SDValue LowerUAddSubOCarry(SDValue Op, SelectionDAG &DAG) const
bool shouldExpandBuildVectorWithShuffles(EVT VT, unsigned DefinedValues) const override
bool shouldConvertConstantLoadToIntImm(const APInt &Imm, Type *Ty) const override
Returns true if it is beneficial to convert a load of a constant to just the constant itself.
SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG) const
SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI, SmallVectorImpl< SDValue > &InVals) const override
LowerCall - Functions arguments are copied from virtual regs to (physical regs)/(stack frame),...
bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AddrSpace, Align Alignment, MachineMemOperand::Flags Flags, unsigned *Fast) const override
Determine if the target supports unaligned memory accesses.
SDValue LowerStore(SDValue Op, SelectionDAG &DAG) const
SDValue LowerPREFETCH(SDValue Op, SelectionDAG &DAG) const
bool hasInlineStackProbe(const MachineFunction &MF) const override
SDValue LowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const
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...
Value * emitStoreConditional(IRBuilderBase &Builder, Value *Val, Value *Addr, AtomicOrdering Ord) const override
Perform a store-conditional operation to Addr.
bool hasBitTest(SDValue X, SDValue Y) const override
Return true if the target has a bit-test instruction: (X & (1 << Y)) ==/!= 0 This knowledge can be us...
HexagonTargetLowering(const TargetMachine &TM, const HexagonSubtarget &ST)
SDValue LowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG) const
bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override
Return true if folding a constant offset with the given GlobalAddress is legal.
bool IsEligibleForTailCallOptimization(SDValue Callee, CallingConv::ID CalleeCC, bool isVarArg, bool isCalleeStructRet, bool isCallerStructRet, const SmallVectorImpl< ISD::OutputArg > &Outs, const SmallVectorImpl< SDValue > &OutVals, const SmallVectorImpl< ISD::InputArg > &Ins, SelectionDAG &DAG) const
IsEligibleForTailCallOptimization - Check whether the call is eligible for tail call optimization.
SDValue LowerVSELECT(SDValue Op, SelectionDAG &DAG) const
void LowerOperationWrapper(SDNode *N, SmallVectorImpl< SDValue > &Results, SelectionDAG &DAG) const override
This callback is invoked by the type legalizer to legalize nodes with an illegal operand type but leg...
SDValue LowerCONCAT_VECTORS(SDValue Op, SelectionDAG &DAG) const
SDValue LowerVECTOR_SHIFT(SDValue Op, SelectionDAG &DAG) const
SDValue LowerINTRINSIC_VOID(SDValue Op, SelectionDAG &DAG) const
SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const
FPImmAction getFPImmAction(const APFloat &Imm, EVT VT, bool ForCodeSize) const override
Returns how to materialize the specified FP immediate.
std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const override
Given a physical register constraint (e.g.
SDValue LowerBITCAST(SDValue Op, SelectionDAG &DAG) const
bool isFMAFasterThanFMulAndFAdd(const MachineFunction &, EVT) const override
Return true if an FMA operation is faster than a pair of mul and add instructions.
SDValue LowerEXTRACT_SUBVECTOR(SDValue Op, SelectionDAG &DAG) const
EVT getOptimalMemOpType(LLVMContext &Context, const MemOp &Op, const AttributeList &FuncAttributes) const override
Returns the target specific optimal type for load and store operations as a result of memset,...
SDValue LowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG) const
LegalizeTypeAction getPreferredVectorAction(MVT VT) const override
Return the preferred vector type legalization action.
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 LowerGLOBALADDRESS(SDValue Op, SelectionDAG &DAG) const
Register getRegisterByName(const char *RegName, LLT VT, const MachineFunction &MF) const override
Return the register ID of the name passed in.
void getTgtMemIntrinsic(SmallVectorImpl< IntrinsicInfo > &Infos, const CallBase &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...
AtomicExpansionKind shouldExpandAtomicCmpXchgInIR(const AtomicCmpXchgInst *AI) const override
Returns how the given atomic cmpxchg should be expanded by the IR-level AtomicExpand pass.
std::pair< MVT, unsigned > handleMaskRegisterForCallingConv(const HexagonSubtarget &Subtarget, EVT VT) const
SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const
SDValue LowerATOMIC_FENCE(SDValue Op, SelectionDAG &DAG) const
Common base class shared among various IRBuilders.
Class to represent integer types.
static LLVM_ABI IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
This is an important class for using LLVM in a threaded context.
LLVM_ABI void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
Base class for LoadSDNode and StoreSDNode.
ISD::MemIndexedMode getAddressingMode() const
Return the addressing mode for this load or store: unindexed, pre-inc, pre-dec, post-inc,...
bool isUnindexed() const
Return true if this is NOT a pre/post inc/dec load/store.
bool isIndexed() const
Return true if this is a pre/post inc/dec load/store.
An instruction for reading from memory.
This class is used to represent ISD::LOAD nodes.
const SDValue & getBasePtr() const
const SDValue & getOffset() const
ISD::LoadExtType getExtensionType() const
Return whether this is a plain node, or one of the varieties of value-extending loads.
unsigned getID() const
getID() - Return the register class ID number.
@ INVALID_SIMPLE_VALUE_TYPE
unsigned getVectorMinNumElements() const
Given a vector type, return the minimum number of elements it contains.
unsigned getVectorNumElements() const
bool isVector() const
Return true if this is a vector value type.
bool isInteger() const
Return true if this is an integer or a vector integer type.
bool isScalableVector() const
Return true if this is a vector value type where the runtime length is machine dependent.
static LLVM_ABI MVT getVT(Type *Ty, bool HandleUnknown=false)
Return the value type corresponding to the specified type.
MVT widenIntegerElementType() const
static auto integer_valuetypes()
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
static auto fixedlen_vector_valuetypes()
bool isScalarInteger() const
Return true if this is an integer, not including vectors.
TypeSize getStoreSizeInBits() const
Return the number of bits overwritten by a store of the specified value type.
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)
static auto fp_valuetypes()
LLVM_ABI void print(raw_ostream &OS, const SlotIndexes *=nullptr, bool IsStandalone=true) const
Instructions::iterator instr_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.
void setAdjustsStack(bool V)
LLVM_ABI void ensureMaxAlignment(Align Alignment)
Make sure the function's frame is at least Align bytes aligned.
void setFrameAddressIsTaken(bool T)
void setStackID(int ObjectIdx, uint8_t ID)
void setHasTailCall(bool V=true)
void setReturnAddressIsTaken(bool s)
unsigned getNumFixedObjects() const
Return the number of fixed objects.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
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.
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...
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags F, LLT MemTy, Align BaseAlignment, const MMOMetadata &Metadata=MMOMetadata(), SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
MachineInstr * getInstr() const
If conversion operators fail, use this method to get the MachineInstr explicitly.
Representation of each machine instruction.
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.
@ MOLoad
The memory access reads data.
@ MOStore
The memory access writes data.
Flags getFlags() const
Return the raw flags of the source value,.
MachineOperand class - Representation of each machine instruction operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
const MDNode * getRanges() const
Returns the Ranges that describes the dereference.
AAMDNodes getAAInfo() const
Returns the AA info that describes the dereference.
MachineMemOperand * getMemOperand() const
Return the unique MachineMemOperand object describing the memory reference performed by operation.
const MachinePointerInfo & getPointerInfo() const
const SDValue & getChain() const
EVT getMemoryVT() const
Return the type of the in-memory value.
A Module instance is used to store all the information related to an LLVM module.
Represent a mutable reference to an array (0 or more elements consecutively in memory),...
unsigned getOpcode() const
Return the opcode for this Instruction or ConstantExpr.
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
unsigned getNumIncomingValues() const
Return the number of incoming edges.
Wrapper class representing virtual and physical registers.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
const DebugLoc & getDebugLoc() const
Represents one node in the SelectionDAG.
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
void setCFIType(uint32_t Type)
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
SDNode * getNode() const
get the SDNode which holds the desired result
SDValue getValue(unsigned R) const
EVT getValueType() const
Return the ValueType of the referenced return value.
const SDValue & getOperand(unsigned i) const
unsigned getOpcode() const
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
SDValue getTargetGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT, int64_t offset=0, unsigned TargetFlags=0)
SDValue getExtractVectorElt(const SDLoc &DL, EVT VT, SDValue Vec, unsigned Idx)
Extract element at Idx from Vec.
const TargetSubtargetInfo & getSubtarget() const
SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, Register Reg, SDValue N)
LLVM_ABI SDValue getMergeValues(ArrayRef< SDValue > Ops, const SDLoc &dl)
Create a MERGE_VALUES node from the given operands.
LLVM_ABI SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
LLVM_ABI SDValue getAllOnesConstant(const SDLoc &DL, EVT VT, bool IsTarget=false, bool IsOpaque=false)
LLVM_ABI SDValue getConstantFP(double Val, const SDLoc &DL, EVT VT, bool isTarget=false)
Create a ConstantFPSDNode wrapping a constant value.
LLVM_ABI SDValue getRegister(Register Reg, EVT VT)
SDValue getGLOBAL_OFFSET_TABLE(EVT VT)
Return a GLOBAL_OFFSET_TABLE node. This does not have a useful SDLoc.
SDValue getSetCC(const SDLoc &DL, EVT VT, SDValue LHS, SDValue RHS, ISD::CondCode Cond, SDValue Chain=SDValue(), bool IsSignaling=false, SDNodeFlags Flags={})
Helper function to make it easier to build SetCC's if you just have an ISD::CondCode instead of an SD...
LLVM_ABI SDValue getMemcpy(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, Align DstAlign, Align SrcAlign, bool isVol, bool AlwaysInline, const CallInst *CI, std::optional< bool > OverrideTailCall, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo, const AAMDNodes &AAInfo=AAMDNodes(), BatchAAResults *BatchAA=nullptr)
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).
LLVM_ABI SDValue getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, SDValue Offset, MachinePointerInfo PtrInfo, EVT SVT, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
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 getZeroExtendInReg(SDValue Op, const SDLoc &DL, EVT VT)
Return the expression required to zero extend the Op value assuming it was the smaller SrcTy value.
const DataLayout & getDataLayout() const
LLVM_ABI SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
Helper function to build ISD::STORE nodes.
LLVM_ABI SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
LLVM_ABI SDValue getMemBasePlusOffset(SDValue Base, TypeSize Offset, const SDLoc &DL, const SDNodeFlags Flags=SDNodeFlags())
Returns sum of the base pointer and offset.
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 getSExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either sign-extending or trunca...
LLVM_ABI SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, MaybeAlign Alignment=MaybeAlign(), MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
Loads are not normal binary operators: their result type is not determined by their operands,...
LLVM_ABI SDValue getIndexedStore(SDValue OrigStore, const SDLoc &dl, SDValue Base, SDValue Offset, ISD::MemIndexedMode AM)
LLVM_ABI SDValue getAnyExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either any-extending or truncat...
LLVM_ABI SDValue getIntPtrConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
SDValue getTargetBlockAddress(const BlockAddress *BA, EVT VT, int64_t Offset=0, unsigned TargetFlags=0)
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
LLVM_ABI SDValue getFrameIndex(int FI, EVT VT, bool isTarget=false)
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...
LLVMContext * getContext() const
LLVM_ABI SDValue getTargetExternalSymbol(const char *Sym, EVT VT, unsigned TargetFlags=0)
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 SDValue getVectorShuffle(EVT VT, const SDLoc &dl, SDValue N1, SDValue N2, ArrayRef< int > Mask)
Return an ISD::VECTOR_SHUFFLE node.
LLVM_ABI SDValue getLogicalNOT(const SDLoc &DL, SDValue Val, EVT VT)
Create a logical NOT operation as (XOR Val, BooleanOne).
static void commuteMask(MutableArrayRef< int > Mask)
Change values in a shuffle permute mask assuming the two vector operands have swapped position.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
This class is used to represent ISD::STORE nodes.
const SDValue & getBasePtr() const
const SDValue & getOffset() const
const SDValue & getValue() const
Represent a constant reference to a string, i.e.
constexpr size_t size() const
Get the string size.
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
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...
virtual bool shouldReduceLoadWidth(SDNode *Load, ISD::LoadExtType ExtTy, EVT NewVT, std::optional< unsigned > ByteOffset=std::nullopt) const
Return true if it is profitable to reduce a load to a smaller type.
LegalizeAction
This enum indicates whether operations are valid for a target, and if not, what action should be used...
unsigned MaxStoresPerMemcpyOptSize
Likewise for functions with the OptSize attribute.
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 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 setIndexedLoadAction(ArrayRef< unsigned > IdxModes, MVT VT, LegalizeAction Action)
Indicate that the specified indexed load does or does not work with the specified type and indicate w...
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 unsigned getVectorTypeBreakdownForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT, EVT &IntermediateVT, unsigned &NumIntermediates, MVT &RegisterVT) const
Certain targets such as MIPS require that some types such as vectors are always broken down into scal...
void setMinFunctionAlignment(Align Alignment)
Set the target's minimum function alignment.
unsigned MaxStoresPerMemsetOptSize
Likewise for functions with the OptSize attribute.
void setBooleanContents(BooleanContent Ty)
Specify how the target extends the result of integer and floating point boolean values from i1 to a w...
unsigned MaxStoresPerMemmove
Specify maximum number of store instructions per memmove call.
void computeRegisterProperties(const TargetRegisterInfo *TRI)
Once all of the register classes are added, this allows us to compute derived properties we expose.
unsigned MaxStoresPerMemmoveOptSize
Likewise for functions with the OptSize attribute.
void addRegisterClass(MVT VT, const TargetRegisterClass *RC)
Add the specified register class as an available regclass for the specified value type.
void setIndexedStoreAction(ArrayRef< unsigned > IdxModes, MVT VT, LegalizeAction Action)
Indicate that the specified indexed store does or does not work with the specified type and indicate ...
ExtractSubvectorCost
Enum that specifies how expensive lowering an EXTRACT_SUBVECTOR is.
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.
unsigned MaxStoresPerMemset
Specify maximum number of store instructions per memset call.
void setMinimumJumpTableEntries(unsigned Val)
Indicate the minimum number of blocks to generate jump tables.
FPImmAction
How the legalizer should materialize a floating-point immediate.
@ Legal
The target can instruction select the immediate natively.
void setTruncStoreAction(MVT ValVT, MVT MemVT, LegalizeAction Action)
Indicate that the specified truncating store does not work with the specified type and indicate what ...
@ UndefinedBooleanContent
bool isOperationLegalOrCustom(unsigned Op, EVT VT, bool LegalOnly=false) const
Return true if the specified operation is legal on this target or can be made legal with custom lower...
virtual bool allowsMemoryAccess(LLVMContext &Context, const DataLayout &DL, EVT VT, unsigned AddrSpace=0, Align Alignment=Align(1), MachineMemOperand::Flags Flags=MachineMemOperand::MONone, unsigned *Fast=nullptr) const
Return true if the target supports a memory access of this type for the given address space and align...
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....
void AddPromotedToType(unsigned Opc, MVT OrigVT, MVT DestVT)
If Opc/OrigVT is specified as being promoted, the promotion code defaults to trying a larger integer/...
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...
virtual std::pair< const TargetRegisterClass *, uint8_t > findRepresentativeClass(const TargetRegisterInfo *TRI, MVT VT) const
Return the largest legal super-reg register class of the register class for the specified type and it...
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...
bool allowsMemoryAccessForAlignment(LLVMContext &Context, const DataLayout &DL, EVT VT, unsigned AddrSpace=0, Align Alignment=Align(1), MachineMemOperand::Flags Flags=MachineMemOperand::MONone, unsigned *Fast=nullptr) const
This function returns true if the memory access is aligned or if the target allows this specific unal...
unsigned MaxStoresPerMemcpy
Specify maximum number of store instructions per memcpy call.
void setSchedulingPreference(Sched::Preference Pref)
Specify the target scheduling preference.
virtual bool isTargetCanonicalConstantNode(SDValue Op) const
Returns true if the given Opc is considered a canonical constant for the target, which should not be ...
SDValue expandUnalignedStore(StoreSDNode *ST, SelectionDAG &DAG) const
Expands an unaligned store to 2 half-size stores for integer values, and possibly more for vectors.
virtual ConstraintType getConstraintType(StringRef Constraint) const
Given a constraint, return the type of constraint it is for this target.
std::pair< SDValue, SDValue > expandUnalignedLoad(LoadSDNode *LD, SelectionDAG &DAG) const
Expands an unaligned load to 2 half-size loads for an integer, and possibly more for vectors.
bool isPositionIndependent() const
virtual std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const
Given a physical register constraint (e.g.
TargetLowering(const TargetLowering &)=delete
virtual void LowerOperationWrapper(SDNode *N, SmallVectorImpl< SDValue > &Results, SelectionDAG &DAG) const
This callback is invoked by the type legalizer to legalize nodes with an illegal operand type but leg...
Primary interface to the complete machine description for the target machine.
bool shouldAssumeDSOLocal(const GlobalValue *GV) const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Target - Wrapper for Target specific information.
static constexpr TypeSize getFixed(ScalarTy ExactSize)
The instances of the Type class are immutable: once they are created, they are never changed.
bool isVectorTy() const
True if this is an instance of VectorType.
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
bool isPointerTy() const
True if this is an instance of PointerType.
static LLVM_ABI IntegerType * getInt8Ty(LLVMContext &C)
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)
Value * getOperand(unsigned i) const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI Align getPointerAlignment(const DataLayout &DL) const
Returns an alignment of the pointer value.
const ParentTy * getParent() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Abstract Attribute helper functions.
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.
@ Fast
Attempts to make calls as fast as possible (e.g.
@ C
The default llvm calling convention, compatible with C.
@ MO_PCREL
MO_PCREL - On a symbol operand, indicates a PC-relative relocation Used for computing a global addres...
@ MO_GOT
MO_GOT - Indicates a GOT-relative relocation.
@ SETCC
SetCC operator - This evaluates to a true value iff the condition is true.
@ STACKRESTORE
STACKRESTORE has two operands, an input chain and a pointer to restore to it returns an output chain.
@ STACKSAVE
STACKSAVE - STACKSAVE has one operand, an input chain.
@ PARTIAL_REDUCE_SMLA
PARTIAL_REDUCE_[U|S]MLA(Accumulator, Input1, Input2) The partial reduction nodes sign or zero extend ...
@ 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.
@ VAEND
VAEND, VASTART - VAEND and VASTART have three operands: an input chain, pointer, and a SRCVALUE.
@ ADD
Simple integer binary arithmetic operators.
@ LOAD
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
@ 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.
@ ABS
ABS - Determine the unsigned absolute value of a signed integer value of the same bitwidth.
@ ATOMIC_FENCE
OUTCHAIN = ATOMIC_FENCE(INCHAIN, ordering, scope) This corresponds to the fence instruction.
@ SDIVREM
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
@ FP16_TO_FP
FP16_TO_FP, FP_TO_FP16 - These operators are used to perform promotions and truncation for half-preci...
@ BITCAST
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
@ BUILD_PAIR
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
@ FLDEXP
FLDEXP - ldexp, inspired by libm (op0 * 2**op1).
@ EH_RETURN
OUTCHAIN = EH_RETURN(INCHAIN, OFFSET, HANDLER) - This node represents 'eh_return' gcc dwarf builtin,...
@ 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...
@ READSTEADYCOUNTER
READSTEADYCOUNTER - This corresponds to the readfixedcounter intrinsic.
@ PREFETCH
PREFETCH - This corresponds to a prefetch intrinsic.
@ FSINCOS
FSINCOS - Compute both fsin and fcos as a single operation.
@ FNEG
Perform various unary floating-point operations inspired by libm.
@ BR_CC
BR_CC - Conditional branch.
@ SSUBO
Same for subtraction.
@ BR_JT
BR_JT - Jumptable branch.
@ SELECT
Select(COND, TRUEVAL, FALSEVAL).
@ SPLAT_VECTOR
SPLAT_VECTOR(VAL) - Returns a vector with the scalar value VAL duplicated in all lanes.
@ VACOPY
VACOPY - VACOPY has 5 operands: an input chain, a destination pointer, a source pointer,...
@ SADDO
RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
@ VECREDUCE_ADD
Integer reductions may have a result type larger than the vector element type.
@ 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.
@ 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.
@ DEBUGTRAP
DEBUGTRAP - Trap intended to get the attention of a debugger.
@ SELECT_CC
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
@ FMINNUM
FMINNUM/FMAXNUM - Same semantics as the llvm.minnum/maxnum intrinsics.
@ DYNAMIC_STACKALLOC
DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned to a specified boundary.
@ SIGN_EXTEND_INREG
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
@ SMIN
[US]{MIN/MAX} - Binary minimum or maximum of signed or unsigned integers.
@ GLOBAL_OFFSET_TABLE
The address of the GOT.
@ VSELECT
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
@ UADDO_CARRY
Carry-using nodes for multiple precision addition and subtraction.
@ INLINEASM_BR
INLINEASM_BR - Branching version of inline asm. Used by asm-goto.
@ BF16_TO_FP
BF16_TO_FP, FP_TO_BF16 - These operators are used to perform promotions and truncation for bfloat16.
@ FRAMEADDR
FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and llvm.returnaddress on the DAG.
@ FMINIMUM
FMINIMUM/FMAXIMUM - Same semantics as the llvm.minimum/maximum intrinsics.
@ FP_TO_SINT
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ READCYCLECOUNTER
READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
@ AND
Bitwise operators - logical and, logical or, logical xor.
@ TRAP
TRAP - Trapping instruction.
@ INTRINSIC_WO_CHAIN
RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) This node represents a target intrinsic fun...
@ 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.
@ INLINEASM
INLINEASM - Represents an inline asm block.
@ TRUNCATE
TRUNCATE - Completely drop the high bits.
@ VAARG
VAARG - VAARG has four operands: an input chain, a pointer, a SRCVALUE, and the alignment.
@ SHL_PARTS
SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded integer shift operations.
@ AssertSext
AssertSext, AssertZext - These nodes record if a register contains a value that has already been zero...
@ FCOPYSIGN
FCOPYSIGN(X, Y) - Return the value of X with the sign of Y.
@ SADDSAT
RESULT = [US]ADDSAT(LHS, RHS) - Perform saturation addition on 2 integers with the same bit width (W)...
@ FMINIMUMNUM
FMINIMUMNUM/FMAXIMUMNUM - Same semantics as the llvm.minimumnum/maximumnum intrinsics.
@ 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,...
MemIndexedMode
MemIndexedMode enum - This enum defines the load / store indexed addressing modes.
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
bool 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.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
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.
RelativeUniformCounterPtr Values
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
bool isAligned(Align Lhs, uint64_t SizeInBytes)
Checks that SizeInBytes is a multiple of the alignment.
@ Load
The value being inserted comes from a load (InsertElement only).
@ Store
The extracted value is stored (ExtractElement only).
constexpr T alignDown(U Value, V Align, W Skew=0)
Returns the largest unsigned integer less than or equal to Value and is Skew mod Align.
LLVM_ABI Value * getSplatValue(const Value *V)
Get splat value if the input is a splat vector or return nullptr.
int countr_zero(T Val)
Count number of 0's from the least significant bit to the most stopping at the first 1.
auto dyn_cast_or_null(const Y &Val)
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI Value * getShuffleReduction(IRBuilderBase &Builder, Value *Src, unsigned Op, TargetTransformInfo::ReductionShuffle RS, RecurKind MinMaxKind=RecurKind::None)
Generates a vector reduction using shufflevectors to reduce the value.
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...
FormattedNumber format_hex(uint64_t N, unsigned Width, bool Upper=false)
format_hex - Output N as a fixed width hexadecimal.
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.
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
@ Fast
Assign the register banks as fast as possible (default).
DWARFExpression::Operation Op
LLVM_ABI int getNextAvailablePluginDiagnosticKind()
Get the next available kind ID for a plugin diagnostic.
unsigned M0(unsigned Val)
constexpr unsigned BitWidth
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
unsigned Log2(Align A)
Returns the log2 of the alignment.
LLVM_ABI Value * getOrderedReduction(IRBuilderBase &Builder, Value *Acc, Value *Src, unsigned Op, RecurKind MinMaxKind=RecurKind::None)
Generates an ordered vector reduction using extracts to reduce the value.
MCRegisterClass TargetRegisterClass
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.
constexpr uint64_t value() const
This is a hole in the type system and should not be abused.
static constexpr Align fromLog2(unsigned Log2Value)
Returns an alignment of 1 << Log2Value bytes.
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
bool bitsGT(EVT VT) const
Return true if this has more bits than VT.
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
bool isPow2VectorType() const
Returns true if the given vector is a power of 2.
static LLVM_ABI EVT getEVT(Type *Ty, bool HandleUnknown=false)
Return the value type corresponding to the specified type.
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
EVT getVectorElementType() const
Given a vector type, return the type of each element.
bool isVectorOf(EVT EltVT) const
Return true if this is a vector with matching element type.
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
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 getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
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
const ConstantInt * CFIType
SmallVector< ISD::OutputArg, 32 > Outs
SmallVector< SDValue, 32 > OutVals
bool isBeforeLegalizeOps() const