38#include "llvm/IR/IntrinsicsAArch64.h"
43#define GET_TARGET_REGBANK_IMPL
44#include "AArch64GenRegisterBank.inc"
47#include "AArch64GenRegisterBankInfo.def"
57 static auto InitializeRegisterBankOnce = [&]() {
66 assert(&AArch64::GPRRegBank == &RBGPR &&
67 "The order in RegBanks is messed up");
71 assert(&AArch64::FPRRegBank == &RBFPR &&
72 "The order in RegBanks is messed up");
76 assert(&AArch64::CCRegBank == &RBCCR &&
77 "The order in RegBanks is messed up");
82 "Subclass not added?");
84 "GPRs should hold up to 128-bit");
89 "Subclass not added?");
91 "Subclass not added?");
93 "FPRs should hold up to 512-bit via QQQQ sequence");
98 "CCR should hold up to 32-bit");
104 "PartialMappingIdx's are incorrectly ordered");
108 "PartialMappingIdx's are incorrectly ordered");
111#define CHECK_PARTIALMAP(Idx, ValStartIdx, ValLength, RB) \
114 checkPartialMap(PartialMappingIdx::Idx, ValStartIdx, ValLength, RB) && \
115 #Idx " is incorrectly initialized"); \
129#define CHECK_VALUEMAP_IMPL(RBName, Size, Offset) \
131 assert(checkValueMapImpl(PartialMappingIdx::PMI_##RBName##Size, \
132 PartialMappingIdx::PMI_First##RBName, Size, \
134 #RBName #Size " " #Offset " is incorrectly initialized"); \
137#define CHECK_VALUEMAP(RBName, Size) CHECK_VALUEMAP_IMPL(RBName, Size, 0)
151#define CHECK_VALUEMAP_3OPS(RBName, Size) \
153 CHECK_VALUEMAP_IMPL(RBName, Size, 0); \
154 CHECK_VALUEMAP_IMPL(RBName, Size, 1); \
155 CHECK_VALUEMAP_IMPL(RBName, Size, 2); \
167#define CHECK_VALUEMAP_CROSSREGCPY(RBNameDst, RBNameSrc, Size) \
169 unsigned PartialMapDstIdx = PMI_##RBNameDst##Size - PMI_Min; \
170 unsigned PartialMapSrcIdx = PMI_##RBNameSrc##Size - PMI_Min; \
171 (void)PartialMapDstIdx; \
172 (void)PartialMapSrcIdx; \
173 const ValueMapping *Map = getCopyMapping(AArch64::RBNameDst##RegBankID, \
174 AArch64::RBNameSrc##RegBankID, \
175 TypeSize::getFixed(Size)); \
177 assert(Map[0].BreakDown == \
178 &AArch64GenRegisterBankInfo::PartMappings[PartialMapDstIdx] && \
179 Map[0].NumBreakDowns == 1 && \
180 #RBNameDst #Size " Dst is incorrectly initialized"); \
181 assert(Map[1].BreakDown == \
182 &AArch64GenRegisterBankInfo::PartMappings[PartialMapSrcIdx] && \
183 Map[1].NumBreakDowns == 1 && \
184 #RBNameSrc #Size " Src is incorrectly initialized"); \
197#define CHECK_VALUEMAP_FPEXT(DstSize, SrcSize) \
199 unsigned PartialMapDstIdx = PMI_FPR##DstSize - PMI_Min; \
200 unsigned PartialMapSrcIdx = PMI_FPR##SrcSize - PMI_Min; \
201 (void)PartialMapDstIdx; \
202 (void)PartialMapSrcIdx; \
203 const ValueMapping *Map = getFPExtMapping(DstSize, SrcSize); \
205 assert(Map[0].BreakDown == \
206 &AArch64GenRegisterBankInfo::PartMappings[PartialMapDstIdx] && \
207 Map[0].NumBreakDowns == 1 && "FPR" #DstSize \
208 " Dst is incorrectly initialized"); \
209 assert(Map[1].BreakDown == \
210 &AArch64GenRegisterBankInfo::PartMappings[PartialMapSrcIdx] && \
211 Map[1].NumBreakDowns == 1 && "FPR" #SrcSize \
212 " Src is incorrectly initialized"); \
224 llvm::call_once(InitializeRegisterBankFlag, InitializeRegisterBankOnce);
238 if (&
A == &AArch64::GPRRegBank && &
B == &AArch64::FPRRegBank)
241 if (&
A == &AArch64::FPRRegBank && &
B == &AArch64::GPRRegBank)
251 switch (RC.
getID()) {
252 case AArch64::GPR64sponlyRegClassID:
253 return AArch64::GPRRegBank;
267 switch (
MI.getOpcode()) {
268 case TargetOpcode::G_OR: {
277 if (
MI.getNumOperands() != 3)
291 case TargetOpcode::G_BITCAST: {
298 if (
MI.getNumOperands() != 2)
313 copyCost(AArch64::GPRRegBank, AArch64::FPRRegBank,
320 copyCost(AArch64::GPRRegBank, AArch64::FPRRegBank,
331 case TargetOpcode::G_LOAD: {
338 if (
MI.getNumOperands() != 2)
370 assert(
MI.getOpcode() == TargetOpcode::G_FCONSTANT);
374 unsigned Size = Ty.getSizeInBits();
381 const APFloat Imm =
MI.getOperand(1).getFPImm()->getValueAPF();
382 const APInt ImmBits =
Imm.bitcastToAPInt();
386 return UseMI.getOpcode() == TargetOpcode::G_STORE &&
387 UseMI.getOperand(0).getReg() == Dst;
408 return !IsFMov && IsLegal;
422 if (!TruncMI || TruncMI->
getOpcode() != TargetOpcode::G_TRUNC)
427 if (!SrcDef || SrcDef->
getOpcode() != TargetOpcode::G_CONSTANT)
436 MRI.
setRegBank(TruncSrc, AArch64::GPRRegBank);
444void AArch64RegisterBankInfo::applyMappingImpl(
446 MachineInstr &
MI = OpdMapper.getMI();
447 MachineRegisterInfo &MRI = OpdMapper.getMRI();
449 switch (
MI.getOpcode()) {
450 case TargetOpcode::G_CONSTANT: {
452 [[maybe_unused]] LLT DstTy = MRI.
getType(Dst);
455 "Expected a scalar smaller than 32 bits on a GPR.");
460 APInt Val =
MI.getOperand(1).getCImm()->getValue().zext(32);
462 MI.getOperand(1).setCImm(ConstantInt::get(Ctx, Val));
463 MI.getOperand(0).setReg(ExtReg);
468 case TargetOpcode::G_FCONSTANT: {
471 "Expected Dst to be on a GPR.");
472 const APFloat &
Imm =
MI.getOperand(1).getFPImm()->getValueAPF();
473 APInt
Bits =
Imm.bitcastToAPInt();
475 if (
Bits.getBitWidth() < 32) {
483 MI.eraseFromParent();
486 case TargetOpcode::G_STORE: {
498 MI.getOperand(0).setReg(Ext.getReg(0));
499 MRI.
setRegBank(Ext.getReg(0), AArch64::GPRRegBank);
503 case TargetOpcode::G_LOAD: {
511 MI.getOperand(0).setReg(ExtReg);
516 case TargetOpcode::G_OR:
517 case TargetOpcode::G_BITCAST:
519 assert((OpdMapper.getInstrMapping().getID() >= 1 &&
520 OpdMapper.getInstrMapping().getID() <= 4) &&
521 "Don't know how to handle that ID");
523 case AArch64::G_DUP: {
529 "Expected sources smaller than 32-bits");
535 MRI.
setRegBank(ConstReg, AArch64::GPRRegBank);
536 MI.getOperand(1).setReg(ConstReg);
546AArch64RegisterBankInfo::getSameKindOfOperandsMapping(
548 const unsigned Opc =
MI.getOpcode();
550 const MachineRegisterInfo &MRI = MF.
getRegInfo();
552 unsigned NumOperands =
MI.getNumOperands();
553 assert(NumOperands <= 3 &&
554 "This code is for instructions with 3 or less operands");
556 LLT Ty = MRI.
getType(
MI.getOperand(0).getReg());
571 for (
unsigned Idx = 1; Idx != NumOperands; ++Idx) {
572 LLT OpTy = MRI.
getType(
MI.getOperand(Idx).getReg());
577 "Operand has incompatible size");
580 assert(IsFPR == OpIsFPR &&
"Operand has incompatible type");
595 case Intrinsic::aarch64_neon_uaddlv:
596 case Intrinsic::aarch64_neon_uaddv:
597 case Intrinsic::aarch64_neon_saddv:
598 case Intrinsic::aarch64_neon_umaxv:
599 case Intrinsic::aarch64_neon_smaxv:
600 case Intrinsic::aarch64_neon_uminv:
601 case Intrinsic::aarch64_neon_sminv:
602 case Intrinsic::aarch64_neon_faddv:
603 case Intrinsic::aarch64_neon_fmaxv:
604 case Intrinsic::aarch64_neon_fminv:
605 case Intrinsic::aarch64_neon_fmaxnmv:
606 case Intrinsic::aarch64_neon_fminnmv:
607 case Intrinsic::aarch64_neon_fmulx:
608 case Intrinsic::aarch64_neon_frecpe:
609 case Intrinsic::aarch64_neon_frecps:
610 case Intrinsic::aarch64_neon_frecpx:
611 case Intrinsic::aarch64_neon_frsqrte:
612 case Intrinsic::aarch64_neon_frsqrts:
613 case Intrinsic::aarch64_neon_facge:
614 case Intrinsic::aarch64_neon_facgt:
615 case Intrinsic::aarch64_neon_fabd:
616 case Intrinsic::aarch64_neon_sqrdmlah:
617 case Intrinsic::aarch64_neon_sqrdmlsh:
618 case Intrinsic::aarch64_neon_sqrdmulh:
619 case Intrinsic::aarch64_neon_suqadd:
620 case Intrinsic::aarch64_neon_usqadd:
621 case Intrinsic::aarch64_neon_uqadd:
622 case Intrinsic::aarch64_neon_sqadd:
623 case Intrinsic::aarch64_neon_uqsub:
624 case Intrinsic::aarch64_neon_sqsub:
625 case Intrinsic::aarch64_neon_sqdmulh:
626 case Intrinsic::aarch64_neon_sqdmulls_scalar:
627 case Intrinsic::aarch64_neon_srshl:
628 case Intrinsic::aarch64_neon_urshl:
629 case Intrinsic::aarch64_neon_sqshl:
630 case Intrinsic::aarch64_neon_uqshl:
631 case Intrinsic::aarch64_neon_sqrshl:
632 case Intrinsic::aarch64_neon_uqrshl:
633 case Intrinsic::aarch64_neon_ushl:
634 case Intrinsic::aarch64_neon_sshl:
635 case Intrinsic::aarch64_neon_sqshrn:
636 case Intrinsic::aarch64_neon_sqshrun:
637 case Intrinsic::aarch64_neon_sqrshrn:
638 case Intrinsic::aarch64_neon_sqrshrun:
639 case Intrinsic::aarch64_neon_uqshrn:
640 case Intrinsic::aarch64_neon_uqrshrn:
641 case Intrinsic::aarch64_neon_sqneg:
642 case Intrinsic::aarch64_neon_sqabs:
643 case Intrinsic::aarch64_neon_scalar_uqxtn:
644 case Intrinsic::aarch64_neon_scalar_sqxtn:
645 case Intrinsic::aarch64_neon_scalar_sqxtun:
646 case Intrinsic::aarch64_crypto_sha1h:
647 case Intrinsic::aarch64_crypto_sha1c:
648 case Intrinsic::aarch64_crypto_sha1p:
649 case Intrinsic::aarch64_crypto_sha1m:
650 case Intrinsic::aarch64_sisd_fcvtxn:
651 case Intrinsic::aarch64_sisd_fabd:
653 case Intrinsic::aarch64_neon_saddlv: {
654 const LLT SrcTy = MRI.
getType(
MI.getOperand(2).getReg());
661bool AArch64RegisterBankInfo::isPHIWithFPConstraints(
664 if (!
MI.isPHI() ||
Depth > MaxFPRSearchDepth)
668 [&](
const MachineInstr &
UseMI) {
669 if (onlyUsesFP(UseMI, MRI, TRI, Depth + 1))
671 return isPHIWithFPConstraints(UseMI, MRI, TRI, Depth + 1);
675bool AArch64RegisterBankInfo::hasFPConstraints(
const MachineInstr &
MI,
678 unsigned Depth)
const {
679 unsigned Op =
MI.getOpcode();
689 if (
Op != TargetOpcode::COPY && !
MI.isPHI() &&
695 if (RB == &AArch64::FPRRegBank)
697 if (RB == &AArch64::GPRRegBank)
704 if (!
MI.isPHI() ||
Depth > MaxFPRSearchDepth)
707 return any_of(
MI.explicit_uses(), [&](
const MachineOperand &
Op) {
709 onlyDefinesFP(*MRI.getVRegDef(Op.getReg()), MRI, TRI, Depth + 1);
716 unsigned Depth)
const {
717 switch (
MI.getOpcode()) {
718 case TargetOpcode::G_BITCAST: {
721 [&](
const MachineInstr &
UseMI) {
722 return onlyUsesFP(UseMI, MRI, TRI, Depth + 1) ||
723 prefersFPUse(UseMI, MRI, TRI);
727 case TargetOpcode::G_FPTOSI:
728 case TargetOpcode::G_FPTOUI:
729 case TargetOpcode::G_FPTOSI_SAT:
730 case TargetOpcode::G_FPTOUI_SAT:
731 case TargetOpcode::G_FCMP:
732 case TargetOpcode::G_LROUND:
733 case TargetOpcode::G_LLROUND:
734 case TargetOpcode::G_CLMUL:
735 case AArch64::G_PMULL:
738 case AArch64::G_FPTRUNC_ODD:
740 case TargetOpcode::G_INTRINSIC:
742 case Intrinsic::aarch64_neon_fcvtas:
743 case Intrinsic::aarch64_neon_fcvtau:
744 case Intrinsic::aarch64_neon_fcvtzs:
745 case Intrinsic::aarch64_neon_fcvtzu:
746 case Intrinsic::aarch64_neon_fcvtms:
747 case Intrinsic::aarch64_neon_fcvtmu:
748 case Intrinsic::aarch64_neon_fcvtns:
749 case Intrinsic::aarch64_neon_fcvtnu:
750 case Intrinsic::aarch64_neon_fcvtps:
751 case Intrinsic::aarch64_neon_fcvtpu:
763bool AArch64RegisterBankInfo::onlyDefinesFP(
const MachineInstr &
MI,
766 unsigned Depth)
const {
767 switch (
MI.getOpcode()) {
769 case AArch64::G_SADDLP:
770 case AArch64::G_UADDLP:
771 case TargetOpcode::G_SITOFP:
772 case TargetOpcode::G_UITOFP:
773 case TargetOpcode::G_EXTRACT_VECTOR_ELT:
774 case TargetOpcode::G_INSERT_VECTOR_ELT:
775 case TargetOpcode::G_BUILD_VECTOR:
776 case TargetOpcode::G_BUILD_VECTOR_TRUNC:
779 case AArch64::G_FPTRUNC_ODD:
781 case TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS:
783 case Intrinsic::aarch64_neon_ld1x2:
784 case Intrinsic::aarch64_neon_ld1x3:
785 case Intrinsic::aarch64_neon_ld1x4:
786 case Intrinsic::aarch64_neon_ld2:
787 case Intrinsic::aarch64_neon_ld2lane:
788 case Intrinsic::aarch64_neon_ld2r:
789 case Intrinsic::aarch64_neon_ld3:
790 case Intrinsic::aarch64_neon_ld3lane:
791 case Intrinsic::aarch64_neon_ld3r:
792 case Intrinsic::aarch64_neon_ld4:
793 case Intrinsic::aarch64_neon_ld4lane:
794 case Intrinsic::aarch64_neon_ld4r:
809 unsigned Depth)
const {
810 switch (
MI.getOpcode()) {
811 case TargetOpcode::G_SITOFP:
812 case TargetOpcode::G_UITOFP:
819bool AArch64RegisterBankInfo::shouldUseFPRForCvtOperand(
820 const MachineInstr &
MI,
bool BankedOpIsDef,
bool ForceFPRForBankedOp16,
821 bool ForceFPRForOtherOp16,
bool AllowFPRCVT,
bool CheckBankedOpUses)
const {
823 const MachineRegisterInfo &MRI = MF.
getRegInfo();
824 const AArch64Subtarget &STI = MF.
getSubtarget<AArch64Subtarget>();
827 unsigned BankedOpIdx = BankedOpIsDef ? 0 : 2;
828 unsigned OtherOpIdx = BankedOpIsDef ? 2 : 0;
830 Register BankedReg =
MI.getOperand(BankedOpIdx).getReg();
837 if ((ForceFPRForBankedOp16 && BankedSize == 16) ||
838 (ForceFPRForOtherOp16 && OtherSize == 16))
841 if (BankedSize != OtherSize && !AllowFPRCVT)
844 if (CheckBankedOpUses)
847 return onlyUsesFP(UseMI, MRI, TRI) || prefersFPUse(UseMI, MRI, TRI);
855bool AArch64RegisterBankInfo::isLoadFromFPType(
const MachineInstr &
MI)
const {
858 const Value *LdVal = MemOp->getMMO().getValue();
862 Type *EltTy =
nullptr;
864 EltTy = GV->getValueType();
868 if (StructEltTy->getNumElements() == 0)
870 EltTy = StructEltTy->getTypeAtIndex(0U);
878 for (
const auto *LdUser : LdVal->
users()) {
880 EltTy = LdUser->getType();
884 EltTy = LdUser->getOperand(0)->getType();
894 const unsigned Opc =
MI.getOpcode();
899 Opc == TargetOpcode::G_PHI) {
914 case TargetOpcode::G_ADD:
915 case TargetOpcode::G_SUB:
916 case TargetOpcode::G_PTR_ADD:
917 case TargetOpcode::G_MUL:
918 case TargetOpcode::G_SDIV:
919 case TargetOpcode::G_UDIV:
921 case TargetOpcode::G_AND:
922 case TargetOpcode::G_OR:
923 case TargetOpcode::G_XOR:
925 case TargetOpcode::G_FADD:
926 case TargetOpcode::G_FSUB:
927 case TargetOpcode::G_FMUL:
928 case TargetOpcode::G_FDIV:
929 case TargetOpcode::G_FMAXIMUM:
930 case TargetOpcode::G_FMINIMUM:
931 return getSameKindOfOperandsMapping(
MI);
932 case TargetOpcode::G_FPEXT: {
941 case TargetOpcode::G_SHL:
942 case TargetOpcode::G_LSHR:
943 case TargetOpcode::G_ASHR: {
944 LLT ShiftAmtTy = MRI.
getType(
MI.getOperand(2).getReg());
946 if (ShiftAmtTy.
getSizeInBits() == 64 && SrcTy.getSizeInBits() == 32)
949 return getSameKindOfOperandsMapping(
MI);
951 case TargetOpcode::G_BITCAST: {
964 case TargetOpcode::COPY: {
978 assert(DstRB && SrcRB &&
"Both RegBank were nullptr");
991 bool SrcIsGPR = !SrcTy.isVector() && SrcTy.getSizeInBits() <= 64;
993 DstIsGPR ? AArch64::GPRRegBank : AArch64::FPRRegBank;
995 SrcIsGPR ? AArch64::GPRRegBank : AArch64::FPRRegBank;
1000 Opc == TargetOpcode::G_BITCAST ? 2 : 1);
1002 case TargetOpcode::G_CONSTANT: {
1010 case TargetOpcode::G_BRCOND:
1011 case TargetOpcode::G_FRAME_INDEX: {
1026 unsigned NumOperands =
MI.getNumOperands();
1032 for (
unsigned Idx = 0; Idx < NumOperands; ++Idx) {
1033 auto &MO =
MI.getOperand(Idx);
1034 if (!MO.isReg() || !MO.getReg())
1040 OpSize[Idx] = Ty.getSizeInBits().getKnownMinValue();
1048 (MO.isDef() && onlyDefinesFP(
MI, MRI,
TRI)) ||
1049 (MO.isUse() && onlyUsesFP(
MI, MRI,
TRI)) ||
1050 Ty.getSizeInBits() > 64)
1060 case TargetOpcode::G_CONSTANT: {
1067 case TargetOpcode::G_FCONSTANT: {
1075 case AArch64::G_DUP: {
1076 Register ScalarReg =
MI.getOperand(1).getReg();
1080 if (ScalarDef->getOpcode() == TargetOpcode::G_LOAD)
1085 onlyDefinesFP(*ScalarDef, MRI,
TRI)))
1097 case TargetOpcode::G_TRUNC: {
1099 if (!SrcTy.isVector() && SrcTy.getSizeInBits() == 128)
1103 case TargetOpcode::G_SITOFP:
1104 case TargetOpcode::G_UITOFP: {
1118 case TargetOpcode::G_FPTOSI_SAT:
1119 case TargetOpcode::G_FPTOUI_SAT:
1120 case TargetOpcode::G_FPTOSI:
1121 case TargetOpcode::G_FPTOUI:
1122 case TargetOpcode::G_INTRINSIC_LRINT:
1123 case TargetOpcode::G_INTRINSIC_LLRINT:
1124 case TargetOpcode::G_LROUND:
1125 case TargetOpcode::G_LLROUND: {
1127 if (DstType.isVector())
1135 if (((DstSize == SrcSize) || STI.hasFeature(AArch64::FeatureFPRCVT)) &&
1138 return onlyUsesFP(UseMI, MRI, TRI) ||
1139 prefersFPUse(UseMI, MRI, TRI);
1146 case TargetOpcode::G_FCMP: {
1151 OpRegBankIdx = {Idx0,
1155 case TargetOpcode::G_BITCAST:
1157 if (OpRegBankIdx[0] != OpRegBankIdx[1])
1163 case TargetOpcode::G_LOAD: {
1184 if (isLoadFromFPType(
MI)) {
1203 if (isPHIWithFPConstraints(UseMI, MRI, TRI))
1206 return onlyUsesFP(UseMI, MRI, TRI) ||
1207 prefersFPUse(UseMI, MRI, TRI);
1213 if (Ty.isScalar() && Ty.getSizeInBits() < 32)
1217 case TargetOpcode::G_STORE:
1223 if (onlyDefinesFP(*
DefMI, MRI,
TRI)) {
1231 if (Ty.isScalar() && Ty.getSizeInBits() < 32)
1235 case TargetOpcode::G_INDEXED_STORE:
1241 if (onlyDefinesFP(*
DefMI, MRI,
TRI))
1246 case TargetOpcode::G_INDEXED_SEXTLOAD:
1247 case TargetOpcode::G_INDEXED_ZEXTLOAD:
1251 case TargetOpcode::G_INDEXED_LOAD: {
1252 if (isLoadFromFPType(
MI))
1256 case TargetOpcode::G_SELECT: {
1264 if (SrcTy.isVector()) {
1297 for (
unsigned Idx = 2; Idx < 4; ++Idx) {
1312 case TargetOpcode::G_UNMERGE_VALUES: {
1318 LLT SrcTy = MRI.
getType(
MI.getOperand(
MI.getNumOperands()-1).getReg());
1321 if (SrcTy.isVector() || SrcTy ==
LLT::scalar(128) ||
1325 for (
unsigned Idx = 0, NumOperands =
MI.getNumOperands();
1326 Idx < NumOperands; ++Idx)
1331 case TargetOpcode::G_EXTRACT_VECTOR_ELT:
1339 case AArch64::G_SQSHLU_I:
1348 case TargetOpcode::G_INSERT_VECTOR_ELT:
1353 if (
getRegBank(
MI.getOperand(2).getReg(), MRI,
TRI) == &AArch64::FPRRegBank)
1362 case TargetOpcode::G_EXTRACT: {
1364 auto Src =
MI.getOperand(1).getReg();
1366 if (SrcTy.getSizeInBits() != 128)
1371 OpRegBankIdx[0] = Idx;
1372 OpRegBankIdx[1] = Idx;
1375 case TargetOpcode::G_BUILD_VECTOR: {
1390 unsigned DefOpc =
DefMI->getOpcode();
1394 return Op.isDef() || mi_match(Op.getReg(), MRI, m_ICst(Cst));
1398 SrcTy.getSizeInBits() < 32 ||
1402 unsigned NumOperands =
MI.getNumOperands();
1403 for (
unsigned Idx = 0; Idx < NumOperands; ++Idx)
1408 case TargetOpcode::G_VECREDUCE_FADD:
1409 case TargetOpcode::G_VECREDUCE_FMUL:
1410 case TargetOpcode::G_VECREDUCE_FMAX:
1411 case TargetOpcode::G_VECREDUCE_FMIN:
1412 case TargetOpcode::G_VECREDUCE_FMAXIMUM:
1413 case TargetOpcode::G_VECREDUCE_FMINIMUM:
1414 case TargetOpcode::G_VECREDUCE_ADD:
1415 case TargetOpcode::G_VECREDUCE_MUL:
1416 case TargetOpcode::G_VECREDUCE_AND:
1417 case TargetOpcode::G_VECREDUCE_OR:
1418 case TargetOpcode::G_VECREDUCE_XOR:
1419 case TargetOpcode::G_VECREDUCE_SMAX:
1420 case TargetOpcode::G_VECREDUCE_SMIN:
1421 case TargetOpcode::G_VECREDUCE_UMAX:
1422 case TargetOpcode::G_VECREDUCE_UMIN:
1427 case TargetOpcode::G_VECREDUCE_SEQ_FADD:
1428 case TargetOpcode::G_VECREDUCE_SEQ_FMUL:
1433 case TargetOpcode::G_INTRINSIC:
1434 case TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS: {
1436 case Intrinsic::aarch64_neon_fcvtas:
1437 case Intrinsic::aarch64_neon_fcvtau:
1438 case Intrinsic::aarch64_neon_fcvtzs:
1439 case Intrinsic::aarch64_neon_fcvtzu:
1440 case Intrinsic::aarch64_neon_fcvtms:
1441 case Intrinsic::aarch64_neon_fcvtmu:
1442 case Intrinsic::aarch64_neon_fcvtns:
1443 case Intrinsic::aarch64_neon_fcvtnu:
1444 case Intrinsic::aarch64_neon_fcvtps:
1445 case Intrinsic::aarch64_neon_fcvtpu: {
1447 if (shouldUseFPRForCvtOperand(
MI,
true,
1457 case Intrinsic::aarch64_neon_vcvtfxs2fp:
1458 case Intrinsic::aarch64_neon_vcvtfxu2fp: {
1460 if (shouldUseFPRForCvtOperand(
MI,
false,
1470 case Intrinsic::aarch64_neon_vcvtfp2fxs:
1471 case Intrinsic::aarch64_neon_vcvtfp2fxu: {
1473 if (shouldUseFPRForCvtOperand(
MI,
true,
1487 if (onlyDefinesFP(
MI, MRI,
TRI))
1488 for (
const auto &
Op :
MI.defs()) {
1494 Idx +=
MI.getNumExplicitDefs();
1496 if (onlyUsesFP(
MI, MRI,
TRI))
1497 for (
const auto &
Op :
MI.explicit_uses()) {
1511 for (
unsigned Idx = 0; Idx < NumOperands; ++Idx) {
1512 if (
MI.getOperand(Idx).isReg() &&
MI.getOperand(Idx).getReg()) {
1518 if (!Mapping->isValid())
1521 OpdsMapping[Idx] = Mapping;
MachineInstrBuilder & UseMI
MachineInstrBuilder MachineInstrBuilder & DefMI
static unsigned getIntrinsicID(const SDNode *N)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static bool foldTruncOfI32Constant(MachineInstr &MI, unsigned OpIdx, MachineRegisterInfo &MRI)
#define CHECK_VALUEMAP(RBName, Size)
static bool isFPIntrinsic(const MachineRegisterInfo &MRI, const MachineInstr &MI)
#define CHECK_VALUEMAP_3OPS(RBName, Size)
static const unsigned CustomMappingID
#define CHECK_PARTIALMAP(Idx, ValStartIdx, ValLength, RB)
#define CHECK_VALUEMAP_CROSSREGCPY(RBNameDst, RBNameSrc, Size)
#define CHECK_VALUEMAP_FPEXT(DstSize, SrcSize)
static bool preferGPRForFPImm(const MachineInstr &MI, const MachineRegisterInfo &MRI, const AArch64Subtarget &STI)
This file declares the targeting of the RegisterBankInfo class for AArch64.
This file implements a class to represent arbitrary precision integral constant values and operations...
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Declares convenience wrapper classes for interpreting MachineInstr instances as specific generic oper...
Implement a low-level type suitable for MachineInstr level instruction selection.
Contains matchers for matching SSA Machine Instructions.
This file declares the MachineIRBuilder class.
Register const TargetRegisterInfo * TRI
Promote Memory to Register
static const MCPhysReg FPR[]
FPR - The set of FP registers that should be allocated for arguments on Darwin and AIX.
This file defines the SmallVector class.
static unsigned getRegBankBaseIdxOffset(unsigned RBIdx, TypeSize Size)
static const RegisterBankInfo::ValueMapping * getCopyMapping(unsigned DstBankID, unsigned SrcBankID, TypeSize Size)
Get the pointer to the ValueMapping of the operands of a copy instruction from the SrcBankID register...
static bool checkPartialMappingIdx(PartialMappingIdx FirstAlias, PartialMappingIdx LastAlias, ArrayRef< PartialMappingIdx > Order)
static const RegisterBankInfo::PartialMapping PartMappings[]
static const RegisterBankInfo::ValueMapping * getFPExtMapping(unsigned DstSize, unsigned SrcSize)
Get the instruction mapping for G_FPEXT.
static const RegisterBankInfo::ValueMapping * getValueMapping(PartialMappingIdx RBIdx, TypeSize Size)
Get the pointer to the ValueMapping representing the RegisterBank at RBIdx with a size of Size.
static const RegisterBankInfo::ValueMapping ValMappings[]
InstructionMappings getInstrAlternativeMappings(const MachineInstr &MI) const override
Get the alternative mappings for MI.
unsigned copyCost(const RegisterBank &A, const RegisterBank &B, TypeSize Size) const override
Get the cost of a copy from B to A, or put differently, get the cost of A = COPY B.
const RegisterBank & getRegBankFromRegClass(const TargetRegisterClass &RC, LLT Ty) const override
Get a register bank that covers RC.
AArch64RegisterBankInfo(const TargetRegisterInfo &TRI)
const InstructionMapping & getInstrMapping(const MachineInstr &MI) const override
Get the mapping of the different operands of MI on the register bank.
const AArch64RegisterInfo * getRegisterInfo() const override
const AArch64TargetLowering * getTargetLowering() const override
bool isFPImmLegal(const APFloat &Imm, EVT VT, bool ForCodeSize) const override
Returns true if the target can instruction select the specified FP immediate natively.
bool isFPImmLegalAsFMov(const APFloat &Imm, EVT VT) const
Class for arbitrary precision integers.
uint64_t getZExtValue() const
Get zero extended value.
static LLVM_ABI APInt getSplat(unsigned NewLen, const APInt &V)
Return a value containing V broadcasted over NewLen bits.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
constexpr bool isScalar() const
static constexpr LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
constexpr bool isValid() const
constexpr bool isVector() const
constexpr TypeSize getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
constexpr bool isPointer() const
static LLT integer(unsigned SizeInBits)
LLT getElementType() const
Returns the vector's element type. Only valid for vector types.
unsigned getID() const
getID() - Return the register class ID number.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
Helper class to build MachineInstr.
void setInsertPt(MachineBasicBlock &MBB, MachineBasicBlock::iterator II)
Set the insertion point before the specified position.
MachineFunction & getMF()
Getter for the function we currently build.
MachineInstrBuilder buildTrunc(const DstOp &Res, const SrcOp &Op, std::optional< unsigned > Flags=std::nullopt)
Build and insert Res = G_TRUNC Op.
MachineInstrBuilder buildAnyExt(const DstOp &Res, const SrcOp &Op)
Build and insert Res = G_ANYEXT Op0.
virtual MachineInstrBuilder buildConstant(const DstOp &Res, const ConstantInt &Val)
Build and insert Res = G_CONSTANT Val.
Register getReg(unsigned Idx) const
Get the register for the operand index.
Representation of each machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const MachineOperand & getOperand(unsigned i) const
LLVM_ABI MachineInstrBundleIterator< MachineInstr > eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
MachineOperand class - Representation of each machine instruction operand.
Register getReg() const
getReg - Returns the register number.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
LLVM_ABI LLVM_READONLY MachineInstr * getVRegDef(Register Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
const RegisterBank * getRegBank(Register Reg) const
Return the register bank of Reg.
LLT getType(Register Reg) const
Get the low-level type of Reg or LLT{} if Reg is not a generic (target independent) virtual register.
LLVM_ABI void setRegBank(Register Reg, const RegisterBank &RegBank)
Set the register bank to RegBank for Reg.
iterator_range< use_instr_nodbg_iterator > use_nodbg_instructions(Register Reg) const
LLVM_ABI Register createGenericVirtualRegister(LLT Ty, StringRef Name="")
Create and return a new generic virtual register with low-level type Ty.
const TargetRegisterClass * getRegClassOrNull(Register Reg) const
Return the register class of Reg, or null if Reg has not been assigned a register class yet.
bool use_empty(Register RegNo) const
use_empty - Return true if there are no instructions using the specified register.
Helper class that represents how the value of an instruction may be mapped and what is the related co...
bool isValid() const
Check whether this object is valid.
virtual InstructionMappings getInstrAlternativeMappings(const MachineInstr &MI) const
Get the alternative mappings for MI.
const InstructionMapping & getInstructionMapping(unsigned ID, unsigned Cost, const ValueMapping *OperandsMapping, unsigned NumOperands) const
Method to get a uniquely generated InstructionMapping.
static void applyDefaultMapping(const OperandsMapper &OpdMapper)
Helper method to apply something that is like the default mapping.
const InstructionMapping & getInvalidInstructionMapping() const
Method to get a uniquely generated invalid InstructionMapping.
const RegisterBank & getRegBank(unsigned ID)
Get the register bank identified by ID.
unsigned getMaximumSize(unsigned RegBankID) const
Get the maximum size in bits that fits in the given register bank.
TypeSize getSizeInBits(Register Reg, const MachineRegisterInfo &MRI, const TargetRegisterInfo &TRI) const
Get the size in bits of Reg.
virtual const RegisterBank & getRegBankFromRegClass(const TargetRegisterClass &RC, LLT Ty) const
Get a register bank that covers RC.
const ValueMapping * getOperandsMapping(Iterator Begin, Iterator End) const
Get the uniquely generated array of ValueMapping for the elements of between Begin and End.
static const unsigned DefaultMappingID
Identifier used when the related instruction mapping instance is generated by target independent code...
SmallVector< const InstructionMapping *, 4 > InstructionMappings
Convenient type to represent the alternatives for mapping an instruction.
virtual unsigned copyCost(const RegisterBank &A, const RegisterBank &B, TypeSize Size) const
Get the cost of a copy from B to A, or put differently, get the cost of A = COPY B.
const InstructionMapping & getInstrMappingImpl(const MachineInstr &MI) const
Try to get the mapping of MI.
This class implements the register bank concept.
LLVM_ABI bool covers(const TargetRegisterClass &RC) const
Check whether this register bank covers RC.
unsigned getID() const
Get the identifier of this register bank.
Wrapper class representing virtual and physical registers.
constexpr bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
TargetSubtargetInfo - Generic base class for all target subtargets.
virtual const TargetRegisterInfo * getRegisterInfo() const =0
Return the target's register information.
static constexpr TypeSize getFixed(ScalarTy ExactSize)
Type * getArrayElementType() const
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
iterator_range< user_iterator > users()
constexpr ScalarTy getFixedValue() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static bool isAdvSIMDModImmType4(uint64_t Imm)
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.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
bool isPreISelGenericOpcode(unsigned Opcode)
Check whether the given Opcode is a generic opcode that is not supposed to appear after ISel.
LLVM_ABI bool shouldOptimizeForSize(const MachineFunction *MF, ProfileSummaryInfo *PSI, const MachineBlockFrequencyInfo *BFI, PGSOQueryType QueryType=PGSOQueryType::Other)
Returns true if machine function MF is suggested to be size-optimized based on the profile.
bool isPreISelGenericOptimizationHint(unsigned Opcode)
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
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...
DWARFExpression::Operation Op
void call_once(once_flag &flag, Function &&F, Args &&... ArgList)
Execute the function specified as a parameter once.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI bool isPreISelGenericFloatingPointOpcode(unsigned Opc)
Returns whether opcode Opc is a pre-isel generic floating-point opcode, having only floating-point op...
MCRegisterClass TargetRegisterClass
static EVT getFloatingPointVT(unsigned BitWidth)
Returns the EVT that represents a floating-point type with the given number of bits.
The llvm::once_flag structure.