33#include "llvm/IR/IntrinsicsAArch64.h"
38#define GET_TARGET_REGBANK_IMPL
39#include "AArch64GenRegisterBank.inc"
42#include "AArch64GenRegisterBankInfo.def"
51 static auto InitializeRegisterBankOnce = [&]() {
60 assert(&AArch64::GPRRegBank == &RBGPR &&
61 "The order in RegBanks is messed up");
65 assert(&AArch64::FPRRegBank == &RBFPR &&
66 "The order in RegBanks is messed up");
70 assert(&AArch64::CCRegBank == &RBCCR &&
71 "The order in RegBanks is messed up");
76 "Subclass not added?");
78 "GPRs should hold up to 128-bit");
83 "Subclass not added?");
85 "Subclass not added?");
87 "FPRs should hold up to 512-bit via QQQQ sequence");
92 "CCR should hold up to 32-bit");
98 "PartialMappingIdx's are incorrectly ordered");
102 "PartialMappingIdx's are incorrectly ordered");
105#define CHECK_PARTIALMAP(Idx, ValStartIdx, ValLength, RB) \
108 checkPartialMap(PartialMappingIdx::Idx, ValStartIdx, ValLength, RB) && \
109 #Idx " is incorrectly initialized"); \
123#define CHECK_VALUEMAP_IMPL(RBName, Size, Offset) \
125 assert(checkValueMapImpl(PartialMappingIdx::PMI_##RBName##Size, \
126 PartialMappingIdx::PMI_First##RBName, Size, \
128 #RBName #Size " " #Offset " is incorrectly initialized"); \
131#define CHECK_VALUEMAP(RBName, Size) CHECK_VALUEMAP_IMPL(RBName, Size, 0)
145#define CHECK_VALUEMAP_3OPS(RBName, Size) \
147 CHECK_VALUEMAP_IMPL(RBName, Size, 0); \
148 CHECK_VALUEMAP_IMPL(RBName, Size, 1); \
149 CHECK_VALUEMAP_IMPL(RBName, Size, 2); \
161#define CHECK_VALUEMAP_CROSSREGCPY(RBNameDst, RBNameSrc, Size) \
163 unsigned PartialMapDstIdx = PMI_##RBNameDst##Size - PMI_Min; \
164 unsigned PartialMapSrcIdx = PMI_##RBNameSrc##Size - PMI_Min; \
165 (void)PartialMapDstIdx; \
166 (void)PartialMapSrcIdx; \
167 const ValueMapping *Map = getCopyMapping(AArch64::RBNameDst##RegBankID, \
168 AArch64::RBNameSrc##RegBankID, \
169 TypeSize::getFixed(Size)); \
171 assert(Map[0].BreakDown == \
172 &AArch64GenRegisterBankInfo::PartMappings[PartialMapDstIdx] && \
173 Map[0].NumBreakDowns == 1 && \
174 #RBNameDst #Size " Dst is incorrectly initialized"); \
175 assert(Map[1].BreakDown == \
176 &AArch64GenRegisterBankInfo::PartMappings[PartialMapSrcIdx] && \
177 Map[1].NumBreakDowns == 1 && \
178 #RBNameSrc #Size " Src is incorrectly initialized"); \
191#define CHECK_VALUEMAP_FPEXT(DstSize, SrcSize) \
193 unsigned PartialMapDstIdx = PMI_FPR##DstSize - PMI_Min; \
194 unsigned PartialMapSrcIdx = PMI_FPR##SrcSize - PMI_Min; \
195 (void)PartialMapDstIdx; \
196 (void)PartialMapSrcIdx; \
197 const ValueMapping *Map = getFPExtMapping(DstSize, SrcSize); \
199 assert(Map[0].BreakDown == \
200 &AArch64GenRegisterBankInfo::PartMappings[PartialMapDstIdx] && \
201 Map[0].NumBreakDowns == 1 && "FPR" #DstSize \
202 " Dst is incorrectly initialized"); \
203 assert(Map[1].BreakDown == \
204 &AArch64GenRegisterBankInfo::PartMappings[PartialMapSrcIdx] && \
205 Map[1].NumBreakDowns == 1 && "FPR" #SrcSize \
206 " Src is incorrectly initialized"); \
218 llvm::call_once(InitializeRegisterBankFlag, InitializeRegisterBankOnce);
232 if (&
A == &AArch64::GPRRegBank && &
B == &AArch64::FPRRegBank)
235 if (&
A == &AArch64::FPRRegBank && &
B == &AArch64::GPRRegBank)
245 switch (RC.
getID()) {
246 case AArch64::GPR64sponlyRegClassID:
261 switch (
MI.getOpcode()) {
262 case TargetOpcode::G_OR: {
271 if (
MI.getNumOperands() != 3)
285 case TargetOpcode::G_BITCAST: {
292 if (
MI.getNumOperands() != 2)
307 copyCost(AArch64::GPRRegBank, AArch64::FPRRegBank,
314 copyCost(AArch64::GPRRegBank, AArch64::FPRRegBank,
325 case TargetOpcode::G_LOAD: {
332 if (
MI.getNumOperands() != 2)
361void AArch64RegisterBankInfo::applyMappingImpl(
366 switch (
MI.getOpcode()) {
367 case TargetOpcode::G_STORE: {
369 LLT Ty =
MRI.getType(Dst);
370 if (
MRI.getRegBank(Dst) == &AArch64::GPRRegBank && Ty.isScalar() &&
371 Ty.getSizeInBits() < 32) {
372 Builder.setInsertPt(*
MI.getParent(),
MI.getIterator());
373 auto Ext = Builder.buildAnyExt(
LLT::scalar(32), Dst);
374 MI.getOperand(0).setReg(Ext.getReg(0));
375 MRI.setRegBank(Ext.getReg(0), AArch64::GPRRegBank);
379 case TargetOpcode::G_LOAD: {
381 LLT Ty =
MRI.getType(Dst);
382 if (
MRI.getRegBank(Dst) == &AArch64::GPRRegBank && Ty.
isScalar() &&
387 MI.getOperand(0).setReg(ExtReg);
388 MRI.setRegBank(ExtReg, AArch64::GPRRegBank);
392 case TargetOpcode::G_OR:
393 case TargetOpcode::G_BITCAST:
395 assert((OpdMapper.getInstrMapping().getID() >= 1 &&
396 OpdMapper.getInstrMapping().getID() <= 4) &&
397 "Don't know how to handle that ID");
399 case TargetOpcode::G_INSERT_VECTOR_ELT: {
403 MRI.setRegBank(Ext.getReg(0),
getRegBank(AArch64::GPRRegBankID));
404 MI.getOperand(2).setReg(Ext.getReg(0));
407 case AArch64::G_DUP: {
409 assert(
MRI.getType(
MI.getOperand(1).getReg()).getSizeInBits() < 32 &&
410 "Expected sources smaller than 32-bits");
414 auto ConstMI =
MRI.getVRegDef(
MI.getOperand(1).getReg());
415 if (ConstMI->getOpcode() == TargetOpcode::G_CONSTANT) {
416 auto CstVal = ConstMI->getOperand(1).getCImm()->getValue();
424 MI.getOperand(1).setReg(ConstReg);
433AArch64RegisterBankInfo::getSameKindOfOperandsMapping(
435 const unsigned Opc =
MI.getOpcode();
436 const MachineFunction &MF = *
MI.getParent()->getParent();
439 unsigned NumOperands =
MI.getNumOperands();
440 assert(NumOperands <= 3 &&
441 "This code is for instructions with 3 or less operands");
443 LLT Ty =
MRI.getType(
MI.getOperand(0).getReg());
458 for (
unsigned Idx = 1; Idx != NumOperands; ++Idx) {
459 LLT OpTy =
MRI.getType(
MI.getOperand(Idx).getReg());
464 "Operand has incompatible size");
467 assert(IsFPR == OpIsFPR &&
"Operand has incompatible type");
482 case Intrinsic::aarch64_neon_uaddlv:
483 case Intrinsic::aarch64_neon_uaddv:
484 case Intrinsic::aarch64_neon_saddv:
485 case Intrinsic::aarch64_neon_umaxv:
486 case Intrinsic::aarch64_neon_smaxv:
487 case Intrinsic::aarch64_neon_uminv:
488 case Intrinsic::aarch64_neon_sminv:
489 case Intrinsic::aarch64_neon_faddv:
490 case Intrinsic::aarch64_neon_fmaxv:
491 case Intrinsic::aarch64_neon_fminv:
492 case Intrinsic::aarch64_neon_fmaxnmv:
493 case Intrinsic::aarch64_neon_fminnmv:
494 case Intrinsic::aarch64_neon_fmulx:
495 case Intrinsic::aarch64_neon_frecpe:
496 case Intrinsic::aarch64_neon_frecps:
497 case Intrinsic::aarch64_neon_frecpx:
498 case Intrinsic::aarch64_neon_frsqrte:
499 case Intrinsic::aarch64_neon_frsqrts:
500 case Intrinsic::aarch64_neon_facge:
501 case Intrinsic::aarch64_neon_facgt:
502 case Intrinsic::aarch64_neon_fabd:
503 case Intrinsic::aarch64_neon_sqrdmlah:
504 case Intrinsic::aarch64_neon_sqrdmlsh:
505 case Intrinsic::aarch64_neon_sqrdmulh:
506 case Intrinsic::aarch64_neon_sqadd:
507 case Intrinsic::aarch64_neon_sqsub:
508 case Intrinsic::aarch64_neon_srshl:
509 case Intrinsic::aarch64_neon_urshl:
510 case Intrinsic::aarch64_neon_sqshl:
511 case Intrinsic::aarch64_neon_uqshl:
512 case Intrinsic::aarch64_neon_sqrshl:
513 case Intrinsic::aarch64_neon_uqrshl:
514 case Intrinsic::aarch64_neon_ushl:
515 case Intrinsic::aarch64_neon_sshl:
516 case Intrinsic::aarch64_neon_sqshrn:
517 case Intrinsic::aarch64_neon_sqshrun:
518 case Intrinsic::aarch64_neon_sqrshrn:
519 case Intrinsic::aarch64_neon_sqrshrun:
520 case Intrinsic::aarch64_neon_uqshrn:
521 case Intrinsic::aarch64_neon_uqrshrn:
522 case Intrinsic::aarch64_crypto_sha1h:
523 case Intrinsic::aarch64_crypto_sha1c:
524 case Intrinsic::aarch64_crypto_sha1p:
525 case Intrinsic::aarch64_crypto_sha1m:
526 case Intrinsic::aarch64_sisd_fcvtxn:
527 case Intrinsic::aarch64_sisd_fabd:
529 case Intrinsic::aarch64_neon_saddlv: {
530 const LLT SrcTy =
MRI.getType(
MI.getOperand(2).getReg());
531 return SrcTy.getElementType().getSizeInBits() >= 16 &&
532 SrcTy.getElementCount().getFixedValue() >= 4;
537bool AArch64RegisterBankInfo::isPHIWithFPConstraints(
540 if (!
MI.isPHI() ||
Depth > MaxFPRSearchDepth)
543 return any_of(
MRI.use_nodbg_instructions(
MI.getOperand(0).getReg()),
544 [&](
const MachineInstr &
UseMI) {
545 if (onlyUsesFP(UseMI, MRI, TRI, Depth + 1))
547 return isPHIWithFPConstraints(UseMI, MRI, TRI, Depth + 1);
551bool AArch64RegisterBankInfo::hasFPConstraints(
const MachineInstr &
MI,
554 unsigned Depth)
const {
555 unsigned Op =
MI.getOpcode();
565 if (
Op != TargetOpcode::COPY && !
MI.isPHI() &&
571 if (RB == &AArch64::FPRRegBank)
573 if (RB == &AArch64::GPRRegBank)
580 if (!
MI.isPHI() ||
Depth > MaxFPRSearchDepth)
583 return any_of(
MI.explicit_uses(), [&](
const MachineOperand &
Op) {
585 onlyDefinesFP(*MRI.getVRegDef(Op.getReg()), MRI, TRI, Depth + 1);
592 unsigned Depth)
const {
593 switch (
MI.getOpcode()) {
594 case TargetOpcode::G_FPTOSI:
595 case TargetOpcode::G_FPTOUI:
596 case TargetOpcode::G_FPTOSI_SAT:
597 case TargetOpcode::G_FPTOUI_SAT:
598 case TargetOpcode::G_FCMP:
599 case TargetOpcode::G_LROUND:
600 case TargetOpcode::G_LLROUND:
601 case AArch64::G_PMULL:
605 case TargetOpcode::G_INTRINSIC:
607 case Intrinsic::aarch64_neon_fcvtas:
608 case Intrinsic::aarch64_neon_fcvtau:
609 case Intrinsic::aarch64_neon_fcvtzs:
610 case Intrinsic::aarch64_neon_fcvtzu:
611 case Intrinsic::aarch64_neon_fcvtms:
612 case Intrinsic::aarch64_neon_fcvtmu:
613 case Intrinsic::aarch64_neon_fcvtns:
614 case Intrinsic::aarch64_neon_fcvtnu:
615 case Intrinsic::aarch64_neon_fcvtps:
616 case Intrinsic::aarch64_neon_fcvtpu:
628bool AArch64RegisterBankInfo::onlyDefinesFP(
const MachineInstr &
MI,
631 unsigned Depth)
const {
632 switch (
MI.getOpcode()) {
634 case AArch64::G_SADDLP:
635 case AArch64::G_UADDLP:
636 case TargetOpcode::G_SITOFP:
637 case TargetOpcode::G_UITOFP:
638 case TargetOpcode::G_EXTRACT_VECTOR_ELT:
639 case TargetOpcode::G_INSERT_VECTOR_ELT:
640 case TargetOpcode::G_BUILD_VECTOR:
641 case TargetOpcode::G_BUILD_VECTOR_TRUNC:
645 case TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS:
647 case Intrinsic::aarch64_neon_ld1x2:
648 case Intrinsic::aarch64_neon_ld1x3:
649 case Intrinsic::aarch64_neon_ld1x4:
650 case Intrinsic::aarch64_neon_ld2:
651 case Intrinsic::aarch64_neon_ld2lane:
652 case Intrinsic::aarch64_neon_ld2r:
653 case Intrinsic::aarch64_neon_ld3:
654 case Intrinsic::aarch64_neon_ld3lane:
655 case Intrinsic::aarch64_neon_ld3r:
656 case Intrinsic::aarch64_neon_ld4:
657 case Intrinsic::aarch64_neon_ld4lane:
658 case Intrinsic::aarch64_neon_ld4r:
673 unsigned Depth)
const {
674 switch (
MI.getOpcode()) {
675 case TargetOpcode::G_SITOFP:
676 case TargetOpcode::G_UITOFP:
677 return MRI.getType(
MI.getOperand(0).getReg()).getSizeInBits() ==
678 MRI.getType(
MI.getOperand(1).getReg()).getSizeInBits();
683bool AArch64RegisterBankInfo::isLoadFromFPType(
const MachineInstr &
MI)
const {
686 const Value *LdVal = MemOp->getMMO().getValue();
690 Type *EltTy =
nullptr;
692 EltTy = GV->getValueType();
696 if (StructEltTy->getNumElements() == 0)
698 EltTy = StructEltTy->getTypeAtIndex(0U);
706 for (
const auto *LdUser : LdVal->
users()) {
708 EltTy = LdUser->getType();
712 EltTy = LdUser->getOperand(0)->getType();
722 const unsigned Opc =
MI.getOpcode();
727 Opc == TargetOpcode::G_PHI) {
742 case TargetOpcode::G_ADD:
743 case TargetOpcode::G_SUB:
744 case TargetOpcode::G_PTR_ADD:
745 case TargetOpcode::G_MUL:
746 case TargetOpcode::G_SDIV:
747 case TargetOpcode::G_UDIV:
749 case TargetOpcode::G_AND:
750 case TargetOpcode::G_OR:
751 case TargetOpcode::G_XOR:
753 case TargetOpcode::G_FADD:
754 case TargetOpcode::G_FSUB:
755 case TargetOpcode::G_FMUL:
756 case TargetOpcode::G_FDIV:
757 case TargetOpcode::G_FMAXIMUM:
758 case TargetOpcode::G_FMINIMUM:
759 return getSameKindOfOperandsMapping(
MI);
760 case TargetOpcode::G_FPEXT: {
761 LLT DstTy =
MRI.getType(
MI.getOperand(0).getReg());
762 LLT SrcTy =
MRI.getType(
MI.getOperand(1).getReg());
769 case TargetOpcode::G_SHL:
770 case TargetOpcode::G_LSHR:
771 case TargetOpcode::G_ASHR: {
772 LLT ShiftAmtTy =
MRI.getType(
MI.getOperand(2).getReg());
773 LLT SrcTy =
MRI.getType(
MI.getOperand(1).getReg());
774 if (ShiftAmtTy.
getSizeInBits() == 64 && SrcTy.getSizeInBits() == 32)
777 return getSameKindOfOperandsMapping(
MI);
779 case TargetOpcode::COPY: {
783 if ((DstReg.
isPhysical() || !
MRI.getType(DstReg).isValid()) ||
793 assert(DstRB && SrcRB &&
"Both RegBank were nullptr");
804 case TargetOpcode::G_BITCAST: {
805 LLT DstTy =
MRI.getType(
MI.getOperand(0).getReg());
806 LLT SrcTy =
MRI.getType(
MI.getOperand(1).getReg());
809 bool SrcIsGPR = !SrcTy.isVector() && SrcTy.getSizeInBits() <= 64;
811 DstIsGPR ? AArch64::GPRRegBank : AArch64::FPRRegBank;
813 SrcIsGPR ? AArch64::GPRRegBank : AArch64::FPRRegBank;
818 Opc == TargetOpcode::G_BITCAST ? 2 : 1);
824 unsigned NumOperands =
MI.getNumOperands();
830 for (
unsigned Idx = 0; Idx < NumOperands; ++Idx) {
831 auto &MO =
MI.getOperand(Idx);
832 if (!MO.isReg() || !MO.getReg())
835 LLT Ty =
MRI.getType(MO.getReg());
838 OpSize[Idx] = Ty.getSizeInBits().getKnownMinValue();
846 (MO.isDef() && onlyDefinesFP(
MI,
MRI,
TRI)) ||
847 (MO.isUse() && onlyUsesFP(
MI,
MRI,
TRI)) ||
848 Ty.getSizeInBits() > 64)
858 case AArch64::G_DUP: {
859 Register ScalarReg =
MI.getOperand(1).getReg();
860 LLT ScalarTy =
MRI.getType(ScalarReg);
861 auto ScalarDef =
MRI.getVRegDef(ScalarReg);
863 if (ScalarDef->getOpcode() == TargetOpcode::G_LOAD)
868 onlyDefinesFP(*ScalarDef,
MRI,
TRI)))
880 case TargetOpcode::G_TRUNC: {
881 LLT SrcTy =
MRI.getType(
MI.getOperand(1).getReg());
882 if (!SrcTy.isVector() && SrcTy.getSizeInBits() == 128)
886 case TargetOpcode::G_SITOFP:
887 case TargetOpcode::G_UITOFP: {
888 if (
MRI.getType(
MI.getOperand(0).getReg()).isVector())
894 MRI.getType(SrcReg).getSizeInBits() ==
895 MRI.getType(
MI.getOperand(0).getReg()).getSizeInBits())
901 case TargetOpcode::G_FPTOSI_SAT:
902 case TargetOpcode::G_FPTOUI_SAT:
903 case TargetOpcode::G_FPTOSI:
904 case TargetOpcode::G_FPTOUI:
905 case TargetOpcode::G_INTRINSIC_LRINT:
906 case TargetOpcode::G_INTRINSIC_LLRINT:
907 case TargetOpcode::G_LROUND:
908 case TargetOpcode::G_LLROUND: {
909 LLT DstType =
MRI.getType(
MI.getOperand(0).getReg());
910 if (DstType.isVector())
918 if (((DstSize == SrcSize) || STI.hasFeature(AArch64::FeatureFPRCVT)) &&
919 all_of(
MRI.use_nodbg_instructions(
MI.getOperand(0).getReg()),
921 return onlyUsesFP(UseMI, MRI, TRI) ||
922 prefersFPUse(UseMI, MRI, TRI);
929 case TargetOpcode::G_FCMP: {
934 OpRegBankIdx = {Idx0,
938 case TargetOpcode::G_BITCAST:
940 if (OpRegBankIdx[0] != OpRegBankIdx[1])
946 case TargetOpcode::G_LOAD: {
961 if (
MRI.getType(
MI.getOperand(0).getReg()).getSizeInBits() < 32)
967 if (isLoadFromFPType(
MI)) {
975 if (
any_of(
MRI.use_nodbg_instructions(
MI.getOperand(0).getReg()),
986 if (isPHIWithFPConstraints(UseMI, MRI, TRI))
989 return onlyUsesFP(UseMI, MRI, TRI) ||
990 prefersFPUse(UseMI, MRI, TRI);
995 LLT Ty =
MRI.getType(
MI.getOperand(0).getReg());
996 if (Ty.isScalar() && Ty.getSizeInBits() < 32)
1000 case TargetOpcode::G_STORE:
1013 LLT Ty =
MRI.getType(
MI.getOperand(0).getReg());
1014 if (Ty.isScalar() && Ty.getSizeInBits() < 32)
1018 case TargetOpcode::G_INDEXED_STORE:
1029 case TargetOpcode::G_INDEXED_SEXTLOAD:
1030 case TargetOpcode::G_INDEXED_ZEXTLOAD:
1034 case TargetOpcode::G_INDEXED_LOAD: {
1035 if (isLoadFromFPType(
MI))
1039 case TargetOpcode::G_SELECT: {
1046 LLT SrcTy =
MRI.getType(
MI.getOperand(2).getReg());
1047 if (SrcTy.isVector()) {
1063 if (
any_of(
MRI.use_nodbg_instructions(
MI.getOperand(0).getReg()),
1080 for (
unsigned Idx = 2; Idx < 4; ++Idx) {
1095 case TargetOpcode::G_UNMERGE_VALUES: {
1101 LLT SrcTy =
MRI.getType(
MI.getOperand(
MI.getNumOperands()-1).getReg());
1104 if (SrcTy.isVector() || SrcTy ==
LLT::scalar(128) ||
1105 any_of(
MRI.use_nodbg_instructions(
MI.getOperand(0).getReg()),
1108 for (
unsigned Idx = 0, NumOperands =
MI.getNumOperands();
1109 Idx < NumOperands; ++Idx)
1114 case TargetOpcode::G_EXTRACT_VECTOR_ELT:
1122 case AArch64::G_SQSHLU_I:
1131 case TargetOpcode::G_INSERT_VECTOR_ELT:
1141 LLT Ty =
MRI.getType(
MI.getOperand(2).getReg());
1142 if (Ty.getSizeInBits() == 8 || Ty.getSizeInBits() == 16) {
1152 case TargetOpcode::G_EXTRACT: {
1154 auto Src =
MI.getOperand(1).getReg();
1155 LLT SrcTy =
MRI.getType(
MI.getOperand(1).getReg());
1156 if (SrcTy.getSizeInBits() != 128)
1158 auto Idx =
MRI.getRegClassOrNull(Src) == &AArch64::XSeqPairsClassRegClass
1161 OpRegBankIdx[0] = Idx;
1162 OpRegBankIdx[1] = Idx;
1165 case TargetOpcode::G_BUILD_VECTOR: {
1180 unsigned DefOpc =
DefMI->getOpcode();
1181 const LLT SrcTy =
MRI.getType(VReg);
1183 return Op.isDef() || MRI.getVRegDef(Op.getReg())->getOpcode() ==
1184 TargetOpcode::G_CONSTANT;
1188 SrcTy.getSizeInBits() < 32 ||
1192 unsigned NumOperands =
MI.getNumOperands();
1193 for (
unsigned Idx = 0; Idx < NumOperands; ++Idx)
1198 case TargetOpcode::G_VECREDUCE_FADD:
1199 case TargetOpcode::G_VECREDUCE_FMUL:
1200 case TargetOpcode::G_VECREDUCE_FMAX:
1201 case TargetOpcode::G_VECREDUCE_FMIN:
1202 case TargetOpcode::G_VECREDUCE_FMAXIMUM:
1203 case TargetOpcode::G_VECREDUCE_FMINIMUM:
1204 case TargetOpcode::G_VECREDUCE_ADD:
1205 case TargetOpcode::G_VECREDUCE_MUL:
1206 case TargetOpcode::G_VECREDUCE_AND:
1207 case TargetOpcode::G_VECREDUCE_OR:
1208 case TargetOpcode::G_VECREDUCE_XOR:
1209 case TargetOpcode::G_VECREDUCE_SMAX:
1210 case TargetOpcode::G_VECREDUCE_SMIN:
1211 case TargetOpcode::G_VECREDUCE_UMAX:
1212 case TargetOpcode::G_VECREDUCE_UMIN:
1217 case TargetOpcode::G_VECREDUCE_SEQ_FADD:
1218 case TargetOpcode::G_VECREDUCE_SEQ_FMUL:
1223 case TargetOpcode::G_INTRINSIC:
1224 case TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS: {
1226 case Intrinsic::aarch64_neon_fcvtas:
1227 case Intrinsic::aarch64_neon_fcvtau:
1228 case Intrinsic::aarch64_neon_fcvtzs:
1229 case Intrinsic::aarch64_neon_fcvtzu:
1230 case Intrinsic::aarch64_neon_fcvtms:
1231 case Intrinsic::aarch64_neon_fcvtmu:
1232 case Intrinsic::aarch64_neon_fcvtns:
1233 case Intrinsic::aarch64_neon_fcvtnu:
1234 case Intrinsic::aarch64_neon_fcvtps:
1235 case Intrinsic::aarch64_neon_fcvtpu: {
1237 if (
MRI.getType(
MI.getOperand(0).getReg()).isVector()) {
1243 if (((DstSize == SrcSize) || STI.hasFeature(AArch64::FeatureFPRCVT)) &&
1244 all_of(
MRI.use_nodbg_instructions(
MI.getOperand(0).getReg()),
1246 return onlyUsesFP(UseMI, MRI, TRI) ||
1247 prefersFPUse(UseMI, MRI, TRI);
1254 case Intrinsic::aarch64_neon_vcvtfxs2fp:
1255 case Intrinsic::aarch64_neon_vcvtfxu2fp:
1256 case Intrinsic::aarch64_neon_vcvtfp2fxs:
1257 case Intrinsic::aarch64_neon_vcvtfp2fxu:
1271 for (
const auto &
Op :
MI.defs()) {
1277 Idx +=
MI.getNumExplicitDefs();
1280 for (
const auto &
Op :
MI.explicit_uses()) {
1294 for (
unsigned Idx = 0; Idx < NumOperands; ++Idx) {
1295 if (
MI.getOperand(Idx).isReg() &&
MI.getOperand(Idx).getReg()) {
1296 LLT Ty =
MRI.getType(
MI.getOperand(Idx).getReg());
1301 if (!Mapping->isValid())
1304 OpdsMapping[Idx] = Mapping;
unsigned const MachineRegisterInfo * MRI
MachineInstrBuilder & UseMI
MachineInstrBuilder MachineInstrBuilder & DefMI
static unsigned getIntrinsicID(const SDNode *N)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#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)
This file declares the targeting of the RegisterBankInfo class for AArch64.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Declares convenience wrapper classes for interpreting MachineInstr instances as specific generic oper...
Implement a low-level type suitable for MachineInstr level instruction selection.
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
constexpr bool isScalar() const
static constexpr LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
constexpr bool isVector() const
constexpr TypeSize getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
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.
Helper class to build MachineInstr.
void setInsertPt(MachineBasicBlock &MBB, MachineBasicBlock::iterator II)
Set the insertion point before the specified position.
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.
MachineOperand class - Representation of each machine instruction operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
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.
unsigned getID() const
Return the register class ID number.
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()
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
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.
bool isPreISelGenericOptimizationHint(unsigned Opcode)
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...
The llvm::once_flag structure.