20 #include "llvm/IR/IntrinsicsAArch64.h" 29 #define DEBUG_TYPE "aarch64-isel" 49 return "AArch64 Instruction Selection";
61 bool SelectInlineAsmMemoryOperand(
const SDValue &
Op,
62 unsigned ConstraintID,
63 std::vector<SDValue> &OutOps)
override;
65 bool tryMLAV64LaneV128(
SDNode *
N);
66 bool tryMULLV64LaneV128(
unsigned IntNo,
SDNode *N);
71 return SelectShiftedRegister(N,
false, Reg, Shift);
74 return SelectShiftedRegister(N,
true, Reg, Shift);
77 return SelectAddrModeIndexed7S(N, 1, Base, OffImm);
80 return SelectAddrModeIndexed7S(N, 2, Base, OffImm);
83 return SelectAddrModeIndexed7S(N, 4, Base, OffImm);
86 return SelectAddrModeIndexed7S(N, 8, Base, OffImm);
89 return SelectAddrModeIndexed7S(N, 16, Base, OffImm);
92 return SelectAddrModeIndexedBitWidth(N,
true, 9, 16, Base, OffImm);
95 return SelectAddrModeIndexedBitWidth(N,
false, 6, 16, Base, OffImm);
98 return SelectAddrModeIndexed(N, 1, Base, OffImm);
101 return SelectAddrModeIndexed(N, 2, Base, OffImm);
104 return SelectAddrModeIndexed(N, 4, Base, OffImm);
107 return SelectAddrModeIndexed(N, 8, Base, OffImm);
110 return SelectAddrModeIndexed(N, 16, Base, OffImm);
113 return SelectAddrModeUnscaled(N, 1, Base, OffImm);
116 return SelectAddrModeUnscaled(N, 2, Base, OffImm);
119 return SelectAddrModeUnscaled(N, 4, Base, OffImm);
122 return SelectAddrModeUnscaled(N, 8, Base, OffImm);
125 return SelectAddrModeUnscaled(N, 16, Base, OffImm);
131 return SelectAddrModeWRO(N,
Width / 8, Base, Offset, SignExtend, DoShift);
137 return SelectAddrModeXRO(N,
Width / 8, Base, Offset, SignExtend, DoShift);
140 bool SelectDupZeroOrUndef(
SDValue N) {
147 if (
auto CN = dyn_cast<ConstantSDNode>(Opnd0))
148 if (CN->isNullValue())
150 if (
auto CN = dyn_cast<ConstantFPSDNode>(Opnd0))
162 template<MVT::SimpleValueType VT>
164 return SelectSVEAddSubImm(N, VT, Imm, Shift);
167 template<MVT::SimpleValueType VT>
169 return SelectSVELogicalImm(N, VT, Imm);
173 template<
signed Min,
signed Max,
signed Scale,
bool Shift>
175 if (!isa<ConstantSDNode>(N))
178 int64_t MulImm = cast<ConstantSDNode>(
N)->getSExtValue();
180 MulImm = 1LL << MulImm;
182 if ((MulImm %
std::abs(Scale)) != 0)
186 if ((MulImm >= Min) && (MulImm <= Max)) {
204 const unsigned SubRegs[]);
206 void SelectTable(
SDNode *N,
unsigned NumVecs,
unsigned Opc,
bool isExt);
208 bool tryIndexedLoad(
SDNode *N);
210 bool trySelectStackSlotTagP(
SDNode *N);
211 void SelectTagP(
SDNode *N);
213 void SelectLoad(
SDNode *N,
unsigned NumVecs,
unsigned Opc,
215 void SelectPostLoad(
SDNode *N,
unsigned NumVecs,
unsigned Opc,
217 void SelectLoadLane(
SDNode *N,
unsigned NumVecs,
unsigned Opc);
218 void SelectPostLoadLane(
SDNode *N,
unsigned NumVecs,
unsigned Opc);
220 void SelectStore(
SDNode *N,
unsigned NumVecs,
unsigned Opc);
221 void SelectPostStore(
SDNode *N,
unsigned NumVecs,
unsigned Opc);
222 void SelectStoreLane(
SDNode *N,
unsigned NumVecs,
unsigned Opc);
223 void SelectPostStoreLane(
SDNode *N,
unsigned NumVecs,
unsigned Opc);
225 bool tryBitfieldExtractOp(
SDNode *N);
226 bool tryBitfieldExtractOpFromSExt(
SDNode *N);
227 bool tryBitfieldInsertOp(
SDNode *N);
228 bool tryBitfieldInsertInZeroOp(
SDNode *N);
229 bool tryShiftAmountMod(
SDNode *N);
230 bool tryHighFPExt(
SDNode *N);
232 bool tryReadRegister(
SDNode *N);
233 bool tryWriteRegister(
SDNode *N);
236 #include "AArch64GenDAGISel.inc" 239 bool SelectShiftedRegister(
SDValue N,
bool AllowROR,
SDValue &Reg,
243 return SelectAddrModeIndexedBitWidth(N,
true, 7, Size, Base, OffImm);
245 bool SelectAddrModeIndexedBitWidth(
SDValue N,
bool IsSignedImm,
unsigned BW,
248 bool SelectAddrModeIndexed(
SDValue N,
unsigned Size,
SDValue &Base,
250 bool SelectAddrModeUnscaled(
SDValue N,
unsigned Size,
SDValue &Base,
258 bool isWorthFolding(
SDValue V)
const;
259 bool SelectExtendedSHL(
SDValue N,
unsigned Size,
bool WantExtend,
262 template<
unsigned RegW
idth>
264 return SelectCVTFixedPosOperand(N, FixedPos, RegWidth);
269 bool SelectCMP_SWAP(
SDNode *N);
285 Imm =
C->getZExtValue();
306 bool AArch64DAGToDAGISel::SelectInlineAsmMemoryOperand(
307 const SDValue &
Op,
unsigned ConstraintID, std::vector<SDValue> &OutOps) {
308 switch(ConstraintID) {
320 SDValue(CurDAG->getMachineNode(TargetOpcode::COPY_TO_REGCLASS,
323 OutOps.push_back(NewOp);
339 if (!isa<ConstantSDNode>(N.
getNode()))
342 uint64_t Immed = cast<ConstantSDNode>(N.
getNode())->getZExtValue();
345 if (Immed >> 12 == 0) {
347 }
else if ((Immed & 0xfff) == 0 && Immed >> 24 == 0) {
355 Val = CurDAG->getTargetConstant(Immed, dl,
MVT::i32);
356 Shift = CurDAG->getTargetConstant(ShVal, dl,
MVT::i32);
362 bool AArch64DAGToDAGISel::SelectNegArithImmed(
SDValue N,
SDValue &Val,
369 if (!isa<ConstantSDNode>(N.
getNode()))
373 uint64_t Immed = cast<ConstantSDNode>(N.
getNode())->getZExtValue();
384 Immed = ~Immed + 1ULL;
385 if (Immed & 0xFFFFFFFFFF000000ULL)
388 Immed &= 0xFFFFFFULL;
389 return SelectArithImmed(CurDAG->getConstant(Immed,
SDLoc(N),
MVT::i32), Val,
427 if (!isa<MemSDNode>(*UI))
429 if (!isa<MemSDNode>(*UII))
435 bool AArch64DAGToDAGISel::isWorthFolding(
SDValue V)
const {
438 if (CurDAG->shouldOptForSize() || V.
hasOneUse())
463 bool AArch64DAGToDAGISel::SelectShiftedRegister(
SDValue N,
bool AllowROR,
473 unsigned Val = RHS->getZExtValue() & (BitSize - 1);
477 Shift = CurDAG->getTargetConstant(ShVal,
SDLoc(N),
MVT::i32);
478 return isWorthFolding(N);
492 SrcVT = cast<VTSDNode>(N.
getOperand(1))->getVT();
496 if (!IsLoadStore && SrcVT ==
MVT::i8)
498 else if (!IsLoadStore && SrcVT ==
MVT::i16)
508 if (!IsLoadStore && SrcVT ==
MVT::i8)
510 else if (!IsLoadStore && SrcVT ==
MVT::i16)
554 LaneIdx = DLidx->
getSExtValue() + EVidx->getSExtValue();
563 SDValue &LaneOp,
int &LaneIdx) {
577 bool AArch64DAGToDAGISel::tryMLAV64LaneV128(
SDNode *N) {
597 SDValue Ops[] = { Op0, MLAOp1, MLAOp2, LaneIdxVal };
599 unsigned MLAOpc = ~0U;
605 MLAOpc = AArch64::MLAv4i16_indexed;
608 MLAOpc = AArch64::MLAv8i16_indexed;
611 MLAOpc = AArch64::MLAv2i32_indexed;
614 MLAOpc = AArch64::MLAv4i32_indexed;
618 ReplaceNode(N, CurDAG->getMachineNode(MLAOpc, dl, N->
getValueType(0), Ops));
622 bool AArch64DAGToDAGISel::tryMULLV64LaneV128(
unsigned IntNo,
SDNode *N) {
634 SDValue Ops[] = { SMULLOp0, SMULLOp1, LaneIdxVal };
636 unsigned SMULLOpc = ~0U;
638 if (IntNo == Intrinsic::aarch64_neon_smull) {
643 SMULLOpc = AArch64::SMULLv4i16_indexed;
646 SMULLOpc = AArch64::SMULLv2i32_indexed;
649 }
else if (IntNo == Intrinsic::aarch64_neon_umull) {
654 SMULLOpc = AArch64::UMULLv4i16_indexed;
657 SMULLOpc = AArch64::UMULLv2i32_indexed;
663 ReplaceNode(N, CurDAG->getMachineNode(SMULLOpc, dl, N->
getValueType(0), Ops));
685 bool AArch64DAGToDAGISel::SelectArithExtendedRegister(
SDValue N,
SDValue &Reg,
687 unsigned ShiftVal = 0;
725 return isWorthFolding(N);
752 bool AArch64DAGToDAGISel::SelectAddrModeIndexedBitWidth(
SDValue N,
bool IsSignedImm,
753 unsigned BW,
unsigned Size,
757 const DataLayout &DL = CurDAG->getDataLayout();
760 int FI = cast<FrameIndexSDNode>(
N)->getIndex();
761 Base = CurDAG->getTargetFrameIndex(FI, TLI->
getPointerTy(DL));
762 OffImm = CurDAG->getTargetConstant(0, dl,
MVT::i64);
768 if (CurDAG->isBaseWithConstantOffset(N)) {
771 int64_t RHSC = RHS->getSExtValue();
772 unsigned Scale =
Log2_32(Size);
773 int64_t Range = 0x1LL << (BW - 1);
775 if ((RHSC & (Size - 1)) == 0 && RHSC >= -(Range << Scale) &&
776 RHSC < (Range << Scale)) {
779 int FI = cast<FrameIndexSDNode>(Base)->getIndex();
780 Base = CurDAG->getTargetFrameIndex(FI, TLI->
getPointerTy(DL));
782 OffImm = CurDAG->getTargetConstant(RHSC >> Scale, dl,
MVT::i64);
787 uint64_t RHSC = RHS->getZExtValue();
788 unsigned Scale =
Log2_32(Size);
789 uint64_t Range = 0x1ULL << BW;
791 if ((RHSC & (Size - 1)) == 0 && RHSC < (Range << Scale)) {
794 int FI = cast<FrameIndexSDNode>(Base)->getIndex();
795 Base = CurDAG->getTargetFrameIndex(FI, TLI->
getPointerTy(DL));
797 OffImm = CurDAG->getTargetConstant(RHSC >> Scale, dl,
MVT::i64);
808 OffImm = CurDAG->getTargetConstant(0, dl,
MVT::i64);
815 bool AArch64DAGToDAGISel::SelectAddrModeIndexed(
SDValue N,
unsigned Size,
818 const DataLayout &DL = CurDAG->getDataLayout();
821 int FI = cast<FrameIndexSDNode>(
N)->getIndex();
822 Base = CurDAG->getTargetFrameIndex(FI, TLI->
getPointerTy(DL));
823 OffImm = CurDAG->getTargetConstant(0, dl,
MVT::i64);
839 if (Alignment == 0 && Ty->
isSized())
842 if (Alignment >= Size)
847 if (CurDAG->isBaseWithConstantOffset(N)) {
849 int64_t RHSC = (int64_t)RHS->getZExtValue();
850 unsigned Scale =
Log2_32(Size);
851 if ((RHSC & (Size - 1)) == 0 && RHSC >= 0 && RHSC < (0x1000 << Scale)) {
854 int FI = cast<FrameIndexSDNode>(Base)->getIndex();
855 Base = CurDAG->getTargetFrameIndex(FI, TLI->
getPointerTy(DL));
857 OffImm = CurDAG->getTargetConstant(RHSC >> Scale, dl,
MVT::i64);
865 if (SelectAddrModeUnscaled(N, Size, Base, OffImm))
873 OffImm = CurDAG->getTargetConstant(0, dl,
MVT::i64);
882 bool AArch64DAGToDAGISel::SelectAddrModeUnscaled(
SDValue N,
unsigned Size,
885 if (!CurDAG->isBaseWithConstantOffset(N))
888 int64_t RHSC = RHS->getSExtValue();
890 if ((RHSC & (Size - 1)) == 0 && RHSC >= 0 &&
891 RHSC < (0x1000 <<
Log2_32(Size)))
893 if (RHSC >= -256 && RHSC < 256) {
896 int FI = cast<FrameIndexSDNode>(Base)->getIndex();
898 Base = CurDAG->getTargetFrameIndex(
901 OffImm = CurDAG->getTargetConstant(RHSC,
SDLoc(N),
MVT::i64);
914 TargetOpcode::INSERT_SUBREG, dl,
MVT::i64, ImpDef, N, SubReg);
920 bool AArch64DAGToDAGISel::SelectExtendedSHL(
SDValue N,
unsigned Size,
925 if (!CSD || (CSD->getZExtValue() & 0x7) != CSD->getZExtValue())
940 SignExtend = CurDAG->getTargetConstant(0, dl,
MVT::i32);
943 unsigned LegalShiftVal =
Log2_32(Size);
944 unsigned ShiftVal = CSD->getZExtValue();
946 if (ShiftVal != 0 && ShiftVal != LegalShiftVal)
949 return isWorthFolding(N);
952 bool AArch64DAGToDAGISel::SelectAddrModeWRO(
SDValue N,
unsigned Size,
964 if (isa<ConstantSDNode>(LHS) || isa<ConstantSDNode>(RHS))
972 if (!isa<MemSDNode>(*UI))
977 bool IsExtendedRegisterWorthFolding = isWorthFolding(N);
981 SelectExtendedSHL(RHS, Size,
true, Offset, SignExtend)) {
983 DoShift = CurDAG->getTargetConstant(
true, dl,
MVT::i32);
989 SelectExtendedSHL(LHS, Size,
true, Offset, SignExtend)) {
991 DoShift = CurDAG->getTargetConstant(
true, dl,
MVT::i32);
996 DoShift = CurDAG->getTargetConstant(
false, dl,
MVT::i32);
1000 if (IsExtendedRegisterWorthFolding &&
1007 if (isWorthFolding(LHS))
1012 if (IsExtendedRegisterWorthFolding &&
1019 if (isWorthFolding(RHS))
1031 if ((ImmOff & 0xfffffffffffff000LL) == 0x0LL)
1034 if ((ImmOff & 0xffffffffff000fffLL) == 0x0LL)
1036 return (ImmOff & 0xffffffffff00ffffLL) != 0x0LL &&
1037 (ImmOff & 0xffffffffffff0fffLL) != 0x0LL;
1041 bool AArch64DAGToDAGISel::SelectAddrModeXRO(
SDValue N,
unsigned Size,
1056 if (!isa<MemSDNode>(*UI))
1071 if (isa<ConstantSDNode>(RHS)) {
1072 int64_t ImmOff = (int64_t)cast<ConstantSDNode>(RHS)->getZExtValue();
1073 unsigned Scale =
Log2_32(Size);
1077 if ((ImmOff % Size == 0 && ImmOff >= 0 && ImmOff < (0x1000 << Scale)) ||
1083 CurDAG->getMachineNode(AArch64::MOVi64imm, DL,
MVT::i64, Ops);
1090 bool IsExtendedRegisterWorthFolding = isWorthFolding(N);
1094 SelectExtendedSHL(RHS, Size,
false, Offset, SignExtend)) {
1096 DoShift = CurDAG->getTargetConstant(
true, DL,
MVT::i32);
1102 SelectExtendedSHL(LHS, Size,
false, Offset, SignExtend)) {
1104 DoShift = CurDAG->getTargetConstant(
true, DL,
MVT::i32);
1111 SignExtend = CurDAG->getTargetConstant(
false, DL,
MVT::i32);
1112 DoShift = CurDAG->getTargetConstant(
false, DL,
MVT::i32);
1118 static const unsigned RegClassIDs[] = {
1119 AArch64::DDRegClassID, AArch64::DDDRegClassID, AArch64::DDDDRegClassID};
1120 static const unsigned SubRegs[] = {AArch64::dsub0, AArch64::dsub1,
1121 AArch64::dsub2, AArch64::dsub3};
1123 return createTuple(Regs, RegClassIDs, SubRegs);
1127 static const unsigned RegClassIDs[] = {
1128 AArch64::QQRegClassID, AArch64::QQQRegClassID, AArch64::QQQQRegClassID};
1129 static const unsigned SubRegs[] = {AArch64::qsub0, AArch64::qsub1,
1130 AArch64::qsub2, AArch64::qsub3};
1132 return createTuple(Regs, RegClassIDs, SubRegs);
1136 const unsigned RegClassIDs[],
1137 const unsigned SubRegs[]) {
1140 if (Regs.
size() == 1)
1151 CurDAG->getTargetConstant(RegClassIDs[Regs.
size() - 2], DL,
MVT::i32));
1154 for (
unsigned i = 0; i < Regs.
size(); ++i) {
1160 CurDAG->getMachineNode(TargetOpcode::REG_SEQUENCE, DL,
MVT::Untyped, Ops);
1164 void AArch64DAGToDAGISel::SelectTable(
SDNode *N,
unsigned NumVecs,
unsigned Opc,
1169 unsigned ExtOff = isExt;
1172 unsigned Vec0Off = ExtOff + 1;
1174 N->
op_begin() + Vec0Off + NumVecs);
1175 SDValue RegSeq = createQTuple(Regs);
1182 ReplaceNode(N, CurDAG->getMachineNode(Opc, dl, VT, Ops));
1185 bool AArch64DAGToDAGISel::tryIndexedLoad(
SDNode *N) {
1197 unsigned Opcode = 0;
1200 bool InsertTo64 =
false;
1202 Opcode = IsPre ? AArch64::LDRXpre : AArch64::LDRXpost;
1205 Opcode = IsPre ? AArch64::LDRWpre : AArch64::LDRWpost;
1207 Opcode = IsPre ? AArch64::LDRSWpre : AArch64::LDRSWpost;
1209 Opcode = IsPre ? AArch64::LDRWpre : AArch64::LDRWpost;
1218 Opcode = IsPre ? AArch64::LDRSHXpre : AArch64::LDRSHXpost;
1220 Opcode = IsPre ? AArch64::LDRSHWpre : AArch64::LDRSHWpost;
1222 Opcode = IsPre ? AArch64::LDRHHpre : AArch64::LDRHHpost;
1231 Opcode = IsPre ? AArch64::LDRSBXpre : AArch64::LDRSBXpost;
1233 Opcode = IsPre ? AArch64::LDRSBWpre : AArch64::LDRSBWpost;
1235 Opcode = IsPre ? AArch64::LDRBBpre : AArch64::LDRBBpost;
1242 Opcode = IsPre ? AArch64::LDRHpre : AArch64::LDRHpost;
1244 Opcode = IsPre ? AArch64::LDRSpre : AArch64::LDRSpost;
1246 Opcode = IsPre ? AArch64::LDRDpre : AArch64::LDRDpost;
1248 Opcode = IsPre ? AArch64::LDRQpre : AArch64::LDRQpost;
1258 SDNode *Res = CurDAG->getMachineNode(Opcode, dl,
MVT::i64, DstVT,
1265 SDValue(CurDAG->getMachineNode(
1266 AArch64::SUBREG_TO_REG, dl,
MVT::i64,
1267 CurDAG->getTargetConstant(0, dl,
MVT::i64), LoadedVal,
1272 ReplaceUses(
SDValue(N, 0), LoadedVal);
1275 CurDAG->RemoveDeadNode(N);
1279 void AArch64DAGToDAGISel::SelectLoad(
SDNode *N,
unsigned NumVecs,
unsigned Opc,
1280 unsigned SubRegIdx) {
1290 SDNode *Ld = CurDAG->getMachineNode(Opc, dl, ResTys, Ops);
1292 for (
unsigned i = 0; i < NumVecs; ++i)
1294 CurDAG->getTargetExtractSubreg(SubRegIdx + i, dl, VT, SuperReg));
1300 CurDAG->setNodeMemRefs(cast<MachineSDNode>(Ld), {MemOp});
1302 CurDAG->RemoveDeadNode(N);
1305 void AArch64DAGToDAGISel::SelectPostLoad(
SDNode *N,
unsigned NumVecs,
1306 unsigned Opc,
unsigned SubRegIdx) {
1318 SDNode *Ld = CurDAG->getMachineNode(Opc, dl, ResTys, Ops);
1326 ReplaceUses(
SDValue(N, 0), SuperReg);
1328 for (
unsigned i = 0; i < NumVecs; ++i)
1330 CurDAG->getTargetExtractSubreg(SubRegIdx + i, dl, VT, SuperReg));
1334 CurDAG->RemoveDeadNode(N);
1337 void AArch64DAGToDAGISel::SelectStore(
SDNode *N,
unsigned NumVecs,
1345 SDValue RegSeq = Is128Bit ? createQTuple(Regs) : createDTuple(Regs);
1352 CurDAG->setNodeMemRefs(cast<MachineSDNode>(St), {MemOp});
1357 void AArch64DAGToDAGISel::SelectPostStore(
SDNode *N,
unsigned NumVecs,
1367 SDValue RegSeq = Is128Bit ? createQTuple(Regs) : createDTuple(Regs);
1373 SDNode *St = CurDAG->getMachineNode(Opc, dl, ResTys, Ops);
1413 void AArch64DAGToDAGISel::SelectLoadLane(
SDNode *N,
unsigned NumVecs,
1426 SDValue RegSeq = createQTuple(Regs);
1431 cast<ConstantSDNode>(N->
getOperand(NumVecs + 2))->getZExtValue();
1433 SDValue Ops[] = {RegSeq, CurDAG->getTargetConstant(LaneNo, dl,
MVT::i64),
1435 SDNode *Ld = CurDAG->getMachineNode(Opc, dl, ResTys, Ops);
1438 EVT WideVT = RegSeq.getOperand(1)->getValueType(0);
1439 static const unsigned QSubs[] = { AArch64::qsub0, AArch64::qsub1,
1440 AArch64::qsub2, AArch64::qsub3 };
1441 for (
unsigned i = 0; i < NumVecs; ++i) {
1442 SDValue NV = CurDAG->getTargetExtractSubreg(QSubs[i], dl, WideVT, SuperReg);
1445 ReplaceUses(
SDValue(N, i), NV);
1449 CurDAG->RemoveDeadNode(N);
1452 void AArch64DAGToDAGISel::SelectPostLoadLane(
SDNode *N,
unsigned NumVecs,
1465 SDValue RegSeq = createQTuple(Regs);
1471 cast<ConstantSDNode>(N->
getOperand(NumVecs + 1))->getZExtValue();
1474 CurDAG->getTargetConstant(LaneNo, dl,
1479 SDNode *Ld = CurDAG->getMachineNode(Opc, dl, ResTys, Ops);
1490 EVT WideVT = RegSeq.getOperand(1)->getValueType(0);
1491 static const unsigned QSubs[] = { AArch64::qsub0, AArch64::qsub1,
1492 AArch64::qsub2, AArch64::qsub3 };
1493 for (
unsigned i = 0; i < NumVecs; ++i) {
1494 SDValue NV = CurDAG->getTargetExtractSubreg(QSubs[i], dl, WideVT,
1498 ReplaceUses(
SDValue(N, i), NV);
1504 CurDAG->RemoveDeadNode(N);
1507 void AArch64DAGToDAGISel::SelectStoreLane(
SDNode *N,
unsigned NumVecs,
1520 SDValue RegSeq = createQTuple(Regs);
1523 cast<ConstantSDNode>(N->
getOperand(NumVecs + 2))->getZExtValue();
1525 SDValue Ops[] = {RegSeq, CurDAG->getTargetConstant(LaneNo, dl,
MVT::i64),
1531 CurDAG->setNodeMemRefs(cast<MachineSDNode>(St), {MemOp});
1536 void AArch64DAGToDAGISel::SelectPostStoreLane(
SDNode *N,
unsigned NumVecs,
1549 SDValue RegSeq = createQTuple(Regs);
1555 cast<ConstantSDNode>(N->
getOperand(NumVecs + 1))->getZExtValue();
1557 SDValue Ops[] = {RegSeq, CurDAG->getTargetConstant(LaneNo, dl,
MVT::i64),
1561 SDNode *St = CurDAG->getMachineNode(Opc, dl, ResTys, Ops);
1565 CurDAG->setNodeMemRefs(cast<MachineSDNode>(St), {MemOp});
1572 unsigned &LSB,
unsigned &MSB,
1573 unsigned NumberOfIgnoredLowBits,
1574 bool BiggerPattern) {
1576 "N must be a AND operation to call this function");
1584 "Type checking must have been done before calling this function");
1594 uint64_t AndImm = 0;
1602 AndImm |= maskTrailingOnes<uint64_t>(NumberOfIgnoredLowBits);
1605 if (AndImm & (AndImm + 1))
1608 bool ClampMSB =
false;
1609 uint64_t SrlImm = 0;
1628 }
else if (BiggerPattern) {
1640 if (!BiggerPattern && (SrlImm <= 0 || SrlImm >= VT.getSizeInBits())) {
1643 <<
": Found large shift immediate, this should not happen\n"));
1648 MSB = SrlImm + (VT ==
MVT::i32 ? countTrailingOnes<uint32_t>(AndImm)
1649 : countTrailingOnes<uint64_t>(AndImm)) -
1656 MSB = MSB > 31 ? 31 : MSB;
1658 Opc = VT ==
MVT::i32 ? AArch64::UBFMWri : AArch64::UBFMXri;
1663 SDValue &Opd0,
unsigned &Immr,
1670 "Type checking must have been done before calling this function");
1676 BitWidth = VT.getSizeInBits();
1684 unsigned Width = cast<VTSDNode>(N->
getOperand(1))->getVT().getSizeInBits();
1685 if (ShiftImm + Width > BitWidth)
1688 Opc = (VT ==
MVT::i32) ? AArch64::SBFMWri : AArch64::SBFMXri;
1691 Imms = ShiftImm + Width - 1;
1715 uint64_t AndMask = 0;
1721 uint64_t SrlImm = 0;
1727 if (BitWide &&
isMask_64(AndMask >> SrlImm)) {
1729 Opc = AArch64::UBFMWri;
1731 Opc = AArch64::UBFMXri;
1734 MSB = BitWide + SrlImm - 1;
1742 unsigned &Immr,
unsigned &Imms,
1743 bool BiggerPattern) {
1745 "N must be a SHR/SRA operation to call this function");
1753 "Type checking must have been done before calling this function");
1760 uint64_t ShlImm = 0;
1761 uint64_t TruncBits = 0;
1774 }
else if (BiggerPattern) {
1787 <<
": Found large shift immediate, this should not happen\n"));
1791 uint64_t SrlImm = 0;
1796 "bad amount in shift node!");
1797 int immr = SrlImm - ShlImm;
1808 bool AArch64DAGToDAGISel::tryBitfieldExtractOpFromSExt(
SDNode *N) {
1824 unsigned Immr = ShiftImm;
1826 SDValue Ops[] = {Opd0, CurDAG->getTargetConstant(Immr, dl, VT),
1827 CurDAG->getTargetConstant(Imms, dl, VT)};
1828 CurDAG->SelectNodeTo(N, AArch64::SBFMXri, VT, Ops);
1834 bool AArch64DAGToDAGISel::tryHighFPExt(
SDNode *N) {
1840 EVT NarrowVT = Extract.getValueType();
1852 unsigned ExtractIndex = Extract.getConstantOperandVal(1);
1853 if (ExtractIndex != Extract.getValueType().getVectorNumElements())
1856 auto Opcode = VT ==
MVT::v2f64 ? AArch64::FCVTLv4i32 : AArch64::FCVTLv8i16;
1857 CurDAG->SelectNodeTo(N, Opcode, VT, Extract.getOperand(0));
1862 SDValue &Opd0,
unsigned &Immr,
unsigned &Imms,
1863 unsigned NumberOfIgnoredLowBits = 0,
1864 bool BiggerPattern =
false) {
1875 NumberOfIgnoredLowBits, BiggerPattern);
1888 case AArch64::SBFMWri:
1889 case AArch64::UBFMWri:
1890 case AArch64::SBFMXri:
1891 case AArch64::UBFMXri:
1902 bool AArch64DAGToDAGISel::tryBitfieldExtractOp(
SDNode *N) {
1903 unsigned Opc, Immr, Imms;
1913 if ((Opc == AArch64::SBFMXri || Opc == AArch64::UBFMXri) && VT ==
MVT::i32) {
1914 SDValue Ops64[] = {Opd0, CurDAG->getTargetConstant(Immr, dl,
MVT::i64),
1915 CurDAG->getTargetConstant(Imms, dl,
MVT::i64)};
1919 ReplaceNode(N, CurDAG->getMachineNode(TargetOpcode::EXTRACT_SUBREG, dl,
1924 SDValue Ops[] = {Opd0, CurDAG->getTargetConstant(Immr, dl, VT),
1925 CurDAG->getTargetConstant(Imms, dl, VT)};
1926 CurDAG->SelectNodeTo(N, Opc, VT, Ops);
1935 unsigned NumberOfIgnoredHighBits,
EVT VT) {
1937 "i32 or i64 mask type expected!");
1938 unsigned BitWidth = VT.
getSizeInBits() - NumberOfIgnoredHighBits;
1940 APInt SignificantDstMask =
APInt(BitWidth, DstMask);
1941 APInt SignificantBitsToBeInserted = BitsToBeInserted.
zextOrTrunc(BitWidth);
1943 return (SignificantDstMask & SignificantBitsToBeInserted) == 0 &&
1944 (SignificantDstMask | SignificantBitsToBeInserted).isAllOnesValue();
1969 UsefulBits &=
APInt(UsefulBits.getBitWidth(), Imm);
1974 uint64_t Imm, uint64_t MSB,
1977 APInt OpUsefulBits(UsefulBits);
1981 OpUsefulBits <<= MSB - Imm + 1;
1986 OpUsefulBits <<= Imm;
1988 OpUsefulBits <<= MSB + 1;
1991 OpUsefulBits <<= OpUsefulBits.
getBitWidth() - Imm;
1997 UsefulBits &= OpUsefulBits;
2012 uint64_t ShiftTypeAndValue =
2045 APInt OpUsefulBits(UsefulBits);
2056 uint64_t
Width = MSB - Imm + 1;
2059 OpUsefulBits <<=
Width;
2064 Mask = ResultUsefulBits & OpUsefulBits;
2070 Mask |= (ResultUsefulBits & ~OpUsefulBits);
2073 uint64_t
Width = MSB + 1;
2076 OpUsefulBits <<=
Width;
2078 OpUsefulBits <<= LSB;
2082 Mask = ResultUsefulBits & OpUsefulBits;
2083 Mask.lshrInPlace(LSB);
2087 Mask |= (ResultUsefulBits & ~OpUsefulBits);
2104 case AArch64::ANDSWri:
2105 case AArch64::ANDSXri:
2106 case AArch64::ANDWri:
2107 case AArch64::ANDXri:
2111 case AArch64::UBFMWri:
2112 case AArch64::UBFMXri:
2115 case AArch64::ORRWrs:
2116 case AArch64::ORRXrs:
2121 case AArch64::BFMWri:
2122 case AArch64::BFMXri:
2125 case AArch64::STRBBui:
2126 case AArch64::STURBBi:
2132 case AArch64::STRHHui:
2133 case AArch64::STURHHi:
2148 UsefulBits =
APInt(Bitwidth, 0);
2157 UsersUsefulBits |= UsefulBitsForUse;
2162 UsefulBits &= UsersUsefulBits;
2175 unsigned UBFMOpc = BitWidth == 32 ? AArch64::UBFMWri : AArch64::UBFMXri;
2178 if (ShlAmount > 0) {
2181 UBFMOpc, dl, VT, Op,
2186 assert(ShlAmount < 0 &&
"expected right shift");
2187 int ShrAmount = -ShlAmount;
2200 SDValue &Src,
int &ShiftAmount,
2205 assert(BitWidth == 32 || BitWidth == 64);
2211 uint64_t NonZeroBits = (~Known.
Zero).getZExtValue();
2242 if (ShlImm - ShiftAmount != 0 && !BiggerPattern)
2290 uint64_t NotKnownZero = (~Known.
Zero).getZExtValue();
2297 if ((OrImm & NotKnownZero) != 0) {
2308 unsigned ImmR = (BitWidth - LSB) % BitWidth;
2309 unsigned ImmS = Width - 1;
2315 bool IsBFI = LSB != 0;
2316 uint64_t BFIImm = OrImm >> LSB;
2320 unsigned OrChunks = 0, BFIChunks = 0;
2321 for (
unsigned Shift = 0; Shift < BitWidth; Shift += 16) {
2322 if (((OrImm >> Shift) & 0xFFFF) != 0)
2324 if (((BFIImm >> Shift) & 0xFFFF) != 0)
2327 if (BFIChunks > OrChunks)
2333 unsigned MOVIOpc = VT ==
MVT::i32 ? AArch64::MOVi32imm : AArch64::MOVi64imm;
2341 unsigned Opc = (VT ==
MVT::i32) ? AArch64::BFMWri : AArch64::BFMXri;
2380 for (
int I = 0;
I < 4; ++
I) {
2383 unsigned ImmR, ImmS;
2384 bool BiggerPattern =
I / 2;
2393 NumberOfIgnoredLowBits, BiggerPattern)) {
2396 if ((BFXOpc != AArch64::UBFMXri && VT ==
MVT::i64) ||
2397 (BFXOpc != AArch64::UBFMWri && VT ==
MVT::i32))
2402 Width = ImmS - ImmR + 1;
2413 Src, DstLSB, Width)) {
2414 ImmR = (BitWidth - DstLSB) % BitWidth;
2431 APInt BitsToBeInserted =
2434 if ((BitsToBeInserted & ~Known.
Zero) != 0)
2452 unsigned Opc = (VT ==
MVT::i32) ? AArch64::BFMWri : AArch64::BFMXri;
2460 uint64_t Mask0Imm, Mask1Imm;
2466 APInt(BitWidth, Mask0Imm) == ~
APInt(BitWidth, Mask1Imm) &&
2485 unsigned ShiftOpc = (VT ==
MVT::i32) ? AArch64::UBFMWri : AArch64::UBFMXri;
2491 unsigned ImmR = (BitWidth - LSB) % BitWidth;
2492 unsigned ImmS = Width - 1;
2498 unsigned Opc = (VT ==
MVT::i32) ? AArch64::BFMWri : AArch64::BFMXri;
2506 bool AArch64DAGToDAGISel::tryBitfieldInsertOp(
SDNode *N) {
2515 CurDAG->SelectNodeTo(N, TargetOpcode::IMPLICIT_DEF, N->
getValueType(0));
2528 bool AArch64DAGToDAGISel::tryBitfieldInsertInZeroOp(
SDNode *N) {
2539 Op0, DstLSB, Width))
2545 unsigned ImmS = Width - 1;
2548 SDValue Ops[] = {Op0, CurDAG->getTargetConstant(ImmR, DL, VT),
2549 CurDAG->getTargetConstant(ImmS, DL, VT)};
2550 unsigned Opc = (VT ==
MVT::i32) ? AArch64::UBFMWri : AArch64::UBFMXri;
2551 CurDAG->SelectNodeTo(N, Opc, VT, Ops);
2557 bool AArch64DAGToDAGISel::tryShiftAmountMod(
SDNode *N) {
2563 Opc = (VT ==
MVT::i32) ? AArch64::RORVWr : AArch64::RORVXr;
2566 Opc = (VT ==
MVT::i32) ? AArch64::LSLVWr : AArch64::LSLVXr;
2569 Opc = (VT ==
MVT::i32) ? AArch64::LSRVWr : AArch64::LSRVXr;
2572 Opc = (VT ==
MVT::i32) ? AArch64::ASRVWr : AArch64::ASRVXr;
2611 (Add0Imm % Size == 0)) {
2616 NegOpc = AArch64::SUBWrr;
2617 ZeroReg = AArch64::WZR;
2620 NegOpc = AArch64::SUBXrr;
2621 ZeroReg = AArch64::XZR;
2624 CurDAG->getCopyFromReg(CurDAG->getEntryNode(), DL, ZeroReg, SubVT);
2626 CurDAG->getMachineNode(NegOpc, DL, SubVT, Zero, Add1);
2627 NewShiftAmt =
SDValue(Neg, 0);
2650 AArch64::SUBREG_TO_REG, DL, VT,
2651 CurDAG->getTargetConstant(0, DL,
MVT::i64), NewShiftAmt,
SubReg);
2652 NewShiftAmt =
SDValue(Ext, 0);
2656 CurDAG->SelectNodeTo(N, Opc, VT, Ops);
2661 AArch64DAGToDAGISel::SelectCVTFixedPosOperand(
SDValue N,
SDValue &FixedPos,
2662 unsigned RegWidth) {
2665 FVal = CN->getValueAPF();
2666 else if (
LoadSDNode *LN = dyn_cast<LoadSDNode>(N)) {
2669 !isa<ConstantPoolSDNode>(LN->getOperand(1)->getOperand(1)))
2674 FVal = cast<ConstantFP>(CN->
getConstVal())->getValueAPF();
2693 if (!IsExact || !IntVal.
isPowerOf2())
return false;
2694 unsigned FBits = IntVal.
logBase2();
2698 if (FBits == 0 || FBits > RegWidth)
return false;
2700 FixedPos = CurDAG->getTargetConstant(FBits,
SDLoc(N),
MVT::i32);
2709 RegString.
split(Fields,
':');
2711 if (Fields.
size() == 1)
2715 &&
"Invalid number of fields in read register string");
2718 bool AllIntFields =
true;
2722 AllIntFields &= !
Field.getAsInteger(10, IntField);
2723 Ops.push_back(IntField);
2727 "Unexpected non-integer value in special register string.");
2731 return (Ops[0] << 14) | (Ops[1] << 11) | (Ops[2] << 7) |
2732 (Ops[3] << 3) | (Ops[4]);
2739 bool AArch64DAGToDAGISel::tryReadRegister(
SDNode *N) {
2746 ReplaceNode(N, CurDAG->getMachineNode(
2748 CurDAG->getTargetConstant(Reg, DL,
MVT::i32),
2756 if (TheReg && TheReg->Readable &&
2757 TheReg->haveFeatures(Subtarget->getFeatureBits()))
2763 ReplaceNode(N, CurDAG->getMachineNode(
2765 CurDAG->getTargetConstant(Reg, DL,
MVT::i32),
2770 if (RegString->getString() ==
"pc") {
2771 ReplaceNode(N, CurDAG->getMachineNode(
2773 CurDAG->getTargetConstant(0, DL,
MVT::i32),
2785 bool AArch64DAGToDAGISel::tryWriteRegister(
SDNode *N) {
2793 N, CurDAG->getMachineNode(AArch64::MSR, DL,
MVT::Other,
2794 CurDAG->getTargetConstant(Reg, DL,
MVT::i32),
2804 auto PMapper = AArch64PState::lookupPStateByName(RegString->getString());
2807 &&
"Expected a constant integer expression.");
2808 unsigned Reg = PMapper->Encoding;
2809 uint64_t Immed = cast<ConstantSDNode>(N->
getOperand(2))->getZExtValue();
2811 if (Reg == AArch64PState::PAN || Reg == AArch64PState::UAO || Reg == AArch64PState::SSBS) {
2812 assert(Immed < 2 &&
"Bad imm");
2813 State = AArch64::MSRpstateImm1;
2815 assert(Immed < 16 &&
"Bad imm");
2816 State = AArch64::MSRpstateImm4;
2818 ReplaceNode(N, CurDAG->getMachineNode(
2820 CurDAG->getTargetConstant(Reg, DL,
MVT::i32),
2821 CurDAG->getTargetConstant(Immed, DL,
MVT::i16),
2830 if (TheReg && TheReg->Writeable &&
2831 TheReg->haveFeatures(Subtarget->getFeatureBits()))
2836 ReplaceNode(N, CurDAG->getMachineNode(
2838 CurDAG->getTargetConstant(Reg, DL,
MVT::i32),
2847 bool AArch64DAGToDAGISel::SelectCMP_SWAP(
SDNode *N) {
2849 EVT MemTy = cast<MemSDNode>(
N)->getMemoryVT();
2852 if (Subtarget->hasLSE())
return false;
2855 Opcode = AArch64::CMP_SWAP_8;
2857 Opcode = AArch64::CMP_SWAP_16;
2859 Opcode = AArch64::CMP_SWAP_32;
2861 Opcode = AArch64::CMP_SWAP_64;
2868 SDNode *CmpSwap = CurDAG->getMachineNode(
2873 CurDAG->setNodeMemRefs(cast<MachineSDNode>(CmpSwap), {MemOp});
2877 CurDAG->RemoveDeadNode(N);
2883 if (
auto CNode = dyn_cast<ConstantSDNode>(N)) {
2884 const int64_t ImmVal = CNode->getZExtValue();
2889 if ((ImmVal & 0xFF) == ImmVal) {
2890 Shift = CurDAG->getTargetConstant(0, DL,
MVT::i32);
2891 Imm = CurDAG->getTargetConstant(ImmVal, DL,
MVT::i32);
2898 if ((ImmVal & 0xFF) == ImmVal) {
2899 Shift = CurDAG->getTargetConstant(0, DL,
MVT::i32);
2900 Imm = CurDAG->getTargetConstant(ImmVal, DL,
MVT::i32);
2902 }
else if ((ImmVal & 0xFF00) == ImmVal) {
2903 Shift = CurDAG->getTargetConstant(8, DL,
MVT::i32);
2904 Imm = CurDAG->getTargetConstant(ImmVal >> 8, DL,
MVT::i32);
2916 bool AArch64DAGToDAGISel::SelectSVESignedArithImm(
SDValue N,
SDValue &Imm) {
2917 if (
auto CNode = dyn_cast<ConstantSDNode>(N)) {
2918 int64_t ImmVal = CNode->getSExtValue();
2920 if (ImmVal >= -127 && ImmVal < 127) {
2921 Imm = CurDAG->getTargetConstant(ImmVal, DL,
MVT::i32);
2928 bool AArch64DAGToDAGISel::SelectSVEArithImm(
SDValue N,
SDValue &Imm) {
2929 if (
auto CNode = dyn_cast<ConstantSDNode>(N)) {
2930 uint64_t ImmVal = CNode->getSExtValue();
2932 ImmVal = ImmVal & 0xFF;
2934 Imm = CurDAG->getTargetConstant(ImmVal, DL,
MVT::i32);
2941 bool AArch64DAGToDAGISel::SelectSVELogicalImm(
SDValue N,
MVT VT,
SDValue &Imm) {
2942 if (
auto CNode = dyn_cast<ConstantSDNode>(N)) {
2943 uint64_t ImmVal = CNode->getZExtValue();
2950 ImmVal |= ImmVal << 8;
2951 ImmVal |= ImmVal << 16;
2952 ImmVal |= ImmVal << 32;
2956 ImmVal |= ImmVal << 16;
2957 ImmVal |= ImmVal << 32;
2960 ImmVal &= 0xFFFFFFFF;
2961 ImmVal |= ImmVal << 32;
2971 Imm = CurDAG->getTargetConstant(encoding, DL,
MVT::i64);
2978 bool AArch64DAGToDAGISel::trySelectStackSlotTagP(
SDNode *N) {
2982 if (!(isa<FrameIndexSDNode>(N->
getOperand(1)))) {
2988 cast<ConstantSDNode>(IRG_SP->
getOperand(1))->getZExtValue() !=
2989 Intrinsic::aarch64_irg_sp) {
2995 int FI = cast<FrameIndexSDNode>(N->
getOperand(1))->getIndex();
2996 SDValue FiOp = CurDAG->getTargetFrameIndex(
2998 int TagOffset = cast<ConstantSDNode>(N->
getOperand(3))->getZExtValue();
3000 SDNode *Out = CurDAG->getMachineNode(
3003 CurDAG->getTargetConstant(TagOffset, DL,
MVT::i64)});
3004 ReplaceNode(N, Out);
3008 void AArch64DAGToDAGISel::SelectTagP(
SDNode *N) {
3010 "llvm.aarch64.tagp third argument must be an immediate");
3011 if (trySelectStackSlotTagP(N))
3018 int TagOffset = cast<ConstantSDNode>(N->
getOperand(3))->getZExtValue();
3021 SDNode *N2 = CurDAG->getMachineNode(AArch64::ADDXrr, DL,
MVT::i64,
3023 SDNode *N3 = CurDAG->getMachineNode(
3026 CurDAG->getTargetConstant(TagOffset, DL,
MVT::i64)});
3046 if (SelectCMP_SWAP(Node))
3051 if (tryReadRegister(Node))
3056 if (tryWriteRegister(Node))
3061 if (tryMLAV64LaneV128(Node))
3068 if (tryIndexedLoad(Node))
3077 if (tryBitfieldExtractOp(Node))
3079 if (tryBitfieldInsertInZeroOp(Node))
3084 if (tryShiftAmountMod(Node))
3089 if (tryBitfieldExtractOpFromSExt(Node))
3094 if (tryHighFPExt(Node))
3099 if (tryBitfieldInsertOp(Node))
3109 SDValue New = CurDAG->getCopyFromReg(
3110 CurDAG->getEntryNode(),
SDLoc(Node), AArch64::WZR,
MVT::i32);
3111 ReplaceNode(Node, New.
getNode());
3114 SDValue New = CurDAG->getCopyFromReg(
3115 CurDAG->getEntryNode(),
SDLoc(Node), AArch64::XZR,
MVT::i64);
3116 ReplaceNode(Node, New.
getNode());
3125 int FI = cast<FrameIndexSDNode>(Node)->getIndex();
3128 SDValue TFI = CurDAG->getTargetFrameIndex(
3132 CurDAG->getTargetConstant(Shifter, DL,
MVT::i32) };
3133 CurDAG->SelectNodeTo(Node, AArch64::ADDXri,
MVT::i64, Ops);
3137 unsigned IntNo = cast<ConstantSDNode>(Node->
getOperand(1))->getZExtValue();
3141 case Intrinsic::aarch64_ldaxp:
3142 case Intrinsic::aarch64_ldxp: {
3144 IntNo == Intrinsic::aarch64_ldaxp ? AArch64::LDAXPX : AArch64::LDXPX;
3154 cast<MemIntrinsicSDNode>(Node)->getMemOperand();
3155 CurDAG->setNodeMemRefs(cast<MachineSDNode>(Ld), {MemOp});
3156 ReplaceNode(Node, Ld);
3159 case Intrinsic::aarch64_stlxp:
3160 case Intrinsic::aarch64_stxp: {
3162 IntNo == Intrinsic::aarch64_stlxp ? AArch64::STLXPX : AArch64::STXPX;
3170 SDValue Ops[] = {ValLo, ValHi, MemAddr, Chain};
3175 cast<MemIntrinsicSDNode>(Node)->getMemOperand();
3176 CurDAG->setNodeMemRefs(cast<MachineSDNode>(St), {MemOp});
3178 ReplaceNode(Node, St);
3181 case Intrinsic::aarch64_neon_ld1x2:
3183 SelectLoad(Node, 2, AArch64::LD1Twov8b, AArch64::dsub0);
3186 SelectLoad(Node, 2, AArch64::LD1Twov16b, AArch64::qsub0);
3189 SelectLoad(Node, 2, AArch64::LD1Twov4h, AArch64::dsub0);
3192 SelectLoad(Node, 2, AArch64::LD1Twov8h, AArch64::qsub0);
3195 SelectLoad(Node, 2, AArch64::LD1Twov2s, AArch64::dsub0);
3198 SelectLoad(Node, 2, AArch64::LD1Twov4s, AArch64::qsub0);
3201 SelectLoad(Node, 2, AArch64::LD1Twov1d, AArch64::dsub0);
3204 SelectLoad(Node, 2, AArch64::LD1Twov2d, AArch64::qsub0);
3208 case Intrinsic::aarch64_neon_ld1x3:
3210 SelectLoad(Node, 3, AArch64::LD1Threev8b, AArch64::dsub0);
3213 SelectLoad(Node, 3, AArch64::LD1Threev16b, AArch64::qsub0);
3216 SelectLoad(Node, 3, AArch64::LD1Threev4h, AArch64::dsub0);
3219 SelectLoad(Node, 3, AArch64::LD1Threev8h, AArch64::qsub0);
3222 SelectLoad(Node, 3, AArch64::LD1Threev2s, AArch64::dsub0);
3225 SelectLoad(Node, 3, AArch64::LD1Threev4s, AArch64::qsub0);
3228 SelectLoad(Node, 3, AArch64::LD1Threev1d, AArch64::dsub0);
3231 SelectLoad(Node, 3, AArch64::LD1Threev2d, AArch64::qsub0);
3235 case Intrinsic::aarch64_neon_ld1x4:
3237 SelectLoad(Node, 4, AArch64::LD1Fourv8b, AArch64::dsub0);
3240 SelectLoad(Node, 4, AArch64::LD1Fourv16b, AArch64::qsub0);
3243 SelectLoad(Node, 4, AArch64::LD1Fourv4h, AArch64::dsub0);
3246 SelectLoad(Node, 4, AArch64::LD1Fourv8h, AArch64::qsub0);
3249 SelectLoad(Node, 4, AArch64::LD1Fourv2s, AArch64::dsub0);
3252 SelectLoad(Node, 4, AArch64::LD1Fourv4s, AArch64::qsub0);
3255 SelectLoad(Node, 4, AArch64::LD1Fourv1d, AArch64::dsub0);
3258 SelectLoad(Node, 4, AArch64::LD1Fourv2d, AArch64::qsub0);
3262 case Intrinsic::aarch64_neon_ld2:
3264 SelectLoad(Node, 2, AArch64::LD2Twov8b, AArch64::dsub0);
3267 SelectLoad(Node, 2, AArch64::LD2Twov16b, AArch64::qsub0);
3270 SelectLoad(Node, 2, AArch64::LD2Twov4h, AArch64::dsub0);
3273 SelectLoad(Node, 2, AArch64::LD2Twov8h, AArch64::qsub0);
3276 SelectLoad(Node, 2, AArch64::LD2Twov2s, AArch64::dsub0);
3279 SelectLoad(Node, 2, AArch64::LD2Twov4s, AArch64::qsub0);
3282 SelectLoad(Node, 2, AArch64::LD1Twov1d, AArch64::dsub0);
3285 SelectLoad(Node, 2, AArch64::LD2Twov2d, AArch64::qsub0);
3289 case Intrinsic::aarch64_neon_ld3:
3291 SelectLoad(Node, 3, AArch64::LD3Threev8b, AArch64::dsub0);
3294 SelectLoad(Node, 3, AArch64::LD3Threev16b, AArch64::qsub0);
3297 SelectLoad(Node, 3, AArch64::LD3Threev4h, AArch64::dsub0);
3300 SelectLoad(Node, 3, AArch64::LD3Threev8h, AArch64::qsub0);
3303 SelectLoad(Node, 3, AArch64::LD3Threev2s, AArch64::dsub0);
3306 SelectLoad(Node, 3, AArch64::LD3Threev4s, AArch64::qsub0);
3309 SelectLoad(Node, 3, AArch64::LD1Threev1d, AArch64::dsub0);
3312 SelectLoad(Node, 3, AArch64::LD3Threev2d, AArch64::qsub0);
3316 case Intrinsic::aarch64_neon_ld4:
3318 SelectLoad(Node, 4, AArch64::LD4Fourv8b, AArch64::dsub0);
3321 SelectLoad(Node, 4, AArch64::LD4Fourv16b, AArch64::qsub0);
3324 SelectLoad(Node, 4, AArch64::LD4Fourv4h, AArch64::dsub0);
3327 SelectLoad(Node, 4, AArch64::LD4Fourv8h, AArch64::qsub0);
3330 SelectLoad(Node, 4, AArch64::LD4Fourv2s, AArch64::dsub0);
3333 SelectLoad(Node, 4, AArch64::LD4Fourv4s, AArch64::qsub0);
3336 SelectLoad(Node, 4, AArch64::LD1Fourv1d, AArch64::dsub0);
3339 SelectLoad(Node, 4, AArch64::LD4Fourv2d, AArch64::qsub0);
3343 case Intrinsic::aarch64_neon_ld2r:
3345 SelectLoad(Node, 2, AArch64::LD2Rv8b, AArch64::dsub0);
3348 SelectLoad(Node, 2, AArch64::LD2Rv16b, AArch64::qsub0);
3351 SelectLoad(Node, 2, AArch64::LD2Rv4h, AArch64::dsub0);
3354 SelectLoad(Node, 2, AArch64::LD2Rv8h, AArch64::qsub0);
3357 SelectLoad(Node, 2, AArch64::LD2Rv2s, AArch64::dsub0);
3360 SelectLoad(Node, 2, AArch64::LD2Rv4s, AArch64::qsub0);
3363 SelectLoad(Node, 2, AArch64::LD2Rv1d, AArch64::dsub0);
3366 SelectLoad(Node, 2, AArch64::LD2Rv2d, AArch64::qsub0);
3370 case Intrinsic::aarch64_neon_ld3r:
3372 SelectLoad(Node, 3, AArch64::LD3Rv8b, AArch64::dsub0);
3375 SelectLoad(Node, 3, AArch64::LD3Rv16b, AArch64::qsub0);
3378 SelectLoad(Node, 3, AArch64::LD3Rv4h, AArch64::dsub0);
3381 SelectLoad(Node, 3, AArch64::LD3Rv8h, AArch64::qsub0);
3384 SelectLoad(Node, 3, AArch64::LD3Rv2s, AArch64::dsub0);
3387 SelectLoad(Node, 3, AArch64::LD3Rv4s, AArch64::qsub0);
3390 SelectLoad(Node, 3, AArch64::LD3Rv1d, AArch64::dsub0);
3393 SelectLoad(Node, 3, AArch64::LD3Rv2d, AArch64::qsub0);
3397 case Intrinsic::aarch64_neon_ld4r:
3399 SelectLoad(Node, 4, AArch64::LD4Rv8b, AArch64::dsub0);
3402 SelectLoad(Node, 4, AArch64::LD4Rv16b, AArch64::qsub0);
3405 SelectLoad(Node, 4, AArch64::LD4Rv4h, AArch64::dsub0);
3408 SelectLoad(Node, 4, AArch64::LD4Rv8h, AArch64::qsub0);
3411 SelectLoad(Node, 4, AArch64::LD4Rv2s, AArch64::dsub0);
3414 SelectLoad(Node, 4, AArch64::LD4Rv4s, AArch64::qsub0);
3417 SelectLoad(Node, 4, AArch64::LD4Rv1d, AArch64::dsub0);
3420 SelectLoad(Node, 4, AArch64::LD4Rv2d, AArch64::qsub0);
3424 case Intrinsic::aarch64_neon_ld2lane:
3426 SelectLoadLane(Node, 2, AArch64::LD2i8);
3430 SelectLoadLane(Node, 2, AArch64::LD2i16);
3434 SelectLoadLane(Node, 2, AArch64::LD2i32);
3438 SelectLoadLane(Node, 2, AArch64::LD2i64);
3442 case Intrinsic::aarch64_neon_ld3lane:
3444 SelectLoadLane(Node, 3, AArch64::LD3i8);
3448 SelectLoadLane(Node, 3, AArch64::LD3i16);
3452 SelectLoadLane(Node, 3, AArch64::LD3i32);
3456 SelectLoadLane(Node, 3, AArch64::LD3i64);
3460 case Intrinsic::aarch64_neon_ld4lane:
3462 SelectLoadLane(Node, 4, AArch64::LD4i8);
3466 SelectLoadLane(Node, 4, AArch64::LD4i16);
3470 SelectLoadLane(Node, 4, AArch64::LD4i32);
3474 SelectLoadLane(Node, 4, AArch64::LD4i64);
3481 unsigned IntNo = cast<ConstantSDNode>(Node->
getOperand(0))->getZExtValue();
3485 case Intrinsic::aarch64_tagp:
3488 case Intrinsic::aarch64_neon_tbl2:
3489 SelectTable(Node, 2,
3490 VT ==
MVT::v8i8 ? AArch64::TBLv8i8Two : AArch64::TBLv16i8Two,
3493 case Intrinsic::aarch64_neon_tbl3:
3494 SelectTable(Node, 3, VT ==
MVT::v8i8 ? AArch64::TBLv8i8Three
3495 : AArch64::TBLv16i8Three,
3498 case Intrinsic::aarch64_neon_tbl4:
3499 SelectTable(Node, 4, VT ==
MVT::v8i8 ? AArch64::TBLv8i8Four
3500 : AArch64::TBLv16i8Four,
3503 case Intrinsic::aarch64_neon_tbx2:
3504 SelectTable(Node, 2,
3505 VT ==
MVT::v8i8 ? AArch64::TBXv8i8Two : AArch64::TBXv16i8Two,
3508 case Intrinsic::aarch64_neon_tbx3:
3509 SelectTable(Node, 3, VT ==
MVT::v8i8 ? AArch64::TBXv8i8Three
3510 : AArch64::TBXv16i8Three,
3513 case Intrinsic::aarch64_neon_tbx4:
3514 SelectTable(Node, 4, VT ==
MVT::v8i8 ? AArch64::TBXv8i8Four
3515 : AArch64::TBXv16i8Four,
3518 case Intrinsic::aarch64_neon_smull:
3519 case Intrinsic::aarch64_neon_umull:
3520 if (tryMULLV64LaneV128(IntNo, Node))
3527 unsigned IntNo = cast<ConstantSDNode>(Node->
getOperand(1))->getZExtValue();
3533 case Intrinsic::aarch64_neon_st1x2: {
3535 SelectStore(Node, 2, AArch64::ST1Twov8b);
3538 SelectStore(Node, 2, AArch64::ST1Twov16b);
3541 SelectStore(Node, 2, AArch64::ST1Twov4h);
3544 SelectStore(Node, 2, AArch64::ST1Twov8h);
3547 SelectStore(Node, 2, AArch64::ST1Twov2s);
3550 SelectStore(Node, 2, AArch64::ST1Twov4s);
3553 SelectStore(Node, 2, AArch64::ST1Twov2d);
3556 SelectStore(Node, 2, AArch64::ST1Twov1d);
3561 case Intrinsic::aarch64_neon_st1x3: {
3563 SelectStore(Node, 3, AArch64::ST1Threev8b);
3566 SelectStore(Node, 3, AArch64::ST1Threev16b);
3569 SelectStore(Node, 3, AArch64::ST1Threev4h);
3572 SelectStore(Node, 3, AArch64::ST1Threev8h);
3575 SelectStore(Node, 3, AArch64::ST1Threev2s);
3578 SelectStore(Node, 3, AArch64::ST1Threev4s);
3581 SelectStore(Node, 3, AArch64::ST1Threev2d);
3584 SelectStore(Node, 3, AArch64::ST1Threev1d);
3589 case Intrinsic::aarch64_neon_st1x4: {
3591 SelectStore(Node, 4, AArch64::ST1Fourv8b);
3594 SelectStore(Node, 4, AArch64::ST1Fourv16b);
3597 SelectStore(Node, 4, AArch64::ST1Fourv4h);
3600 SelectStore(Node, 4, AArch64::ST1Fourv8h);
3603 SelectStore(Node, 4, AArch64::ST1Fourv2s);
3606 SelectStore(Node, 4, AArch64::ST1Fourv4s);
3609 SelectStore(Node, 4, AArch64::ST1Fourv2d);
3612 SelectStore(Node, 4, AArch64::ST1Fourv1d);
3617 case Intrinsic::aarch64_neon_st2: {
3619 SelectStore(Node, 2, AArch64::ST2Twov8b);
3622 SelectStore(Node, 2, AArch64::ST2Twov16b);
3625 SelectStore(Node, 2, AArch64::ST2Twov4h);
3628 SelectStore(Node, 2, AArch64::ST2Twov8h);
3631 SelectStore(Node, 2, AArch64::ST2Twov2s);
3634 SelectStore(Node, 2, AArch64::ST2Twov4s);
3637 SelectStore(Node, 2, AArch64::ST2Twov2d);
3640 SelectStore(Node, 2, AArch64::ST1Twov1d);
3645 case Intrinsic::aarch64_neon_st3: {
3647 SelectStore(Node, 3, AArch64::ST3Threev8b);
3650 SelectStore(Node, 3, AArch64::ST3Threev16b);
3653 SelectStore(Node, 3, AArch64::ST3Threev4h);
3656 SelectStore(Node, 3, AArch64::ST3Threev8h);
3659 SelectStore(Node, 3, AArch64::ST3Threev2s);
3662 SelectStore(Node, 3, AArch64::ST3Threev4s);
3665 SelectStore(Node, 3, AArch64::ST3Threev2d);
3668 SelectStore(Node, 3, AArch64::ST1Threev1d);
3673 case Intrinsic::aarch64_neon_st4: {
3675 SelectStore(Node, 4, AArch64::ST4Fourv8b);
3678 SelectStore(Node, 4, AArch64::ST4Fourv16b);
3681 SelectStore(Node, 4, AArch64::ST4Fourv4h);
3684 SelectStore(Node, 4, AArch64::ST4Fourv8h);
3687 SelectStore(Node, 4, AArch64::ST4Fourv2s);
3690 SelectStore(Node, 4, AArch64::ST4Fourv4s);
3693 SelectStore(Node, 4, AArch64::ST4Fourv2d);
3696 SelectStore(Node, 4, AArch64::ST1Fourv1d);
3701 case Intrinsic::aarch64_neon_st2lane: {
3703 SelectStoreLane(Node, 2, AArch64::ST2i8);
3707 SelectStoreLane(Node, 2, AArch64::ST2i16);
3711 SelectStoreLane(Node, 2, AArch64::ST2i32);
3715 SelectStoreLane(Node, 2, AArch64::ST2i64);
3720 case Intrinsic::aarch64_neon_st3lane: {
3722 SelectStoreLane(Node, 3, AArch64::ST3i8);
3726 SelectStoreLane(Node, 3, AArch64::ST3i16);
3730 SelectStoreLane(Node, 3, AArch64::ST3i32);
3734 SelectStoreLane(Node, 3, AArch64::ST3i64);
3739 case Intrinsic::aarch64_neon_st4lane: {
3741 SelectStoreLane(Node, 4, AArch64::ST4i8);
3745 SelectStoreLane(Node, 4, AArch64::ST4i16);
3749 SelectStoreLane(Node, 4, AArch64::ST4i32);
3753 SelectStoreLane(Node, 4, AArch64::ST4i64);
3763 SelectPostLoad(Node, 2, AArch64::LD2Twov8b_POST, AArch64::dsub0);
3766 SelectPostLoad(Node, 2, AArch64::LD2Twov16b_POST, AArch64::qsub0);
3769 SelectPostLoad(Node, 2, AArch64::LD2Twov4h_POST, AArch64::dsub0);
3772 SelectPostLoad(Node, 2, AArch64::LD2Twov8h_POST, AArch64::qsub0);
3775 SelectPostLoad(Node, 2, AArch64::LD2Twov2s_POST, AArch64::dsub0);
3778 SelectPostLoad(Node, 2, AArch64::LD2Twov4s_POST, AArch64::qsub0);
3781 SelectPostLoad(Node, 2, AArch64::LD1Twov1d_POST, AArch64::dsub0);
3784 SelectPostLoad(Node, 2, AArch64::LD2Twov2d_POST, AArch64::qsub0);
3791 SelectPostLoad(Node, 3, AArch64::LD3Threev8b_POST, AArch64::dsub0);
3794 SelectPostLoad(Node, 3, AArch64::LD3Threev16b_POST, AArch64::qsub0);
3797 SelectPostLoad(Node, 3, AArch64::LD3Threev4h_POST, AArch64::dsub0);
3800 SelectPostLoad(Node, 3, AArch64::LD3Threev8h_POST, AArch64::qsub0);
3803 SelectPostLoad(Node, 3, AArch64::LD3Threev2s_POST, AArch64::dsub0);
3806 SelectPostLoad(Node, 3, AArch64::LD3Threev4s_POST, AArch64::qsub0);
3809 SelectPostLoad(Node, 3, AArch64::LD1Threev1d_POST, AArch64::dsub0);
3812 SelectPostLoad(Node, 3, AArch64::LD3Threev2d_POST, AArch64::qsub0);
3819 SelectPostLoad(Node, 4, AArch64::LD4Fourv8b_POST, AArch64::dsub0);
3822 SelectPostLoad(Node, 4, AArch64::LD4Fourv16b_POST, AArch64::qsub0);
3825 SelectPostLoad(Node, 4, AArch64::LD4Fourv4h_POST, AArch64::dsub0);
3828 SelectPostLoad(Node, 4, AArch64::LD4Fourv8h_POST, AArch64::qsub0);
3831 SelectPostLoad(Node, 4, AArch64::LD4Fourv2s_POST, AArch64::dsub0);
3834 SelectPostLoad(Node, 4, AArch64::LD4Fourv4s_POST, AArch64::qsub0);
3837 SelectPostLoad(Node, 4, AArch64::LD1Fourv1d_POST, AArch64::dsub0);
3840 SelectPostLoad(Node, 4, AArch64::LD4Fourv2d_POST, AArch64::qsub0);
3847 SelectPostLoad(Node, 2, AArch64::LD1Twov8b_POST, AArch64::dsub0);
3850 SelectPostLoad(Node, 2, AArch64::LD1Twov16b_POST, AArch64::qsub0);
3853 SelectPostLoad(Node, 2, AArch64::LD1Twov4h_POST, AArch64::dsub0);
3856 SelectPostLoad(Node, 2, AArch64::LD1Twov8h_POST, AArch64::qsub0);
3859 SelectPostLoad(Node, 2, AArch64::LD1Twov2s_POST, AArch64::dsub0);
3862 SelectPostLoad(Node, 2, AArch64::LD1Twov4s_POST, AArch64::qsub0);
3865 SelectPostLoad(Node, 2, AArch64::LD1Twov1d_POST, AArch64::dsub0);
3868 SelectPostLoad(Node, 2, AArch64::LD1Twov2d_POST, AArch64::qsub0);
3875 SelectPostLoad(Node, 3, AArch64::LD1Threev8b_POST, AArch64::dsub0);
3878 SelectPostLoad(Node, 3, AArch64::LD1Threev16b_POST, AArch64::qsub0);
3881 SelectPostLoad(Node, 3, AArch64::LD1Threev4h_POST, AArch64::dsub0);
3884 SelectPostLoad(Node, 3, AArch64::LD1Threev8h_POST, AArch64::qsub0);
3887 SelectPostLoad(Node, 3, AArch64::LD1Threev2s_POST, AArch64::dsub0);
3890 SelectPostLoad(Node, 3, AArch64::LD1Threev4s_POST, AArch64::qsub0);
3893 SelectPostLoad(Node, 3, AArch64::LD1Threev1d_POST, AArch64::dsub0);
3896 SelectPostLoad(Node, 3, AArch64::LD1Threev2d_POST, AArch64::qsub0);
3903 SelectPostLoad(Node, 4, AArch64::LD1Fourv8b_POST, AArch64::dsub0);
3906 SelectPostLoad(Node, 4, AArch64::LD1Fourv16b_POST, AArch64::qsub0);
3909 SelectPostLoad(Node, 4, AArch64::LD1Fourv4h_POST, AArch64::dsub0);
3912 SelectPostLoad(Node, 4, AArch64::LD1Fourv8h_POST, AArch64::qsub0);
3915 SelectPostLoad(Node, 4, AArch64::LD1Fourv2s_POST, AArch64::dsub0);
3918 SelectPostLoad(Node, 4, AArch64::LD1Fourv4s_POST, AArch64::qsub0);
3921 SelectPostLoad(Node, 4, AArch64::LD1Fourv1d_POST, AArch64::dsub0);
3924 SelectPostLoad(Node, 4, AArch64::LD1Fourv2d_POST, AArch64::qsub0);
3931 SelectPostLoad(Node, 1, AArch64::LD1Rv8b_POST, AArch64::dsub0);
3934 SelectPostLoad(Node, 1, AArch64::LD1Rv16b_POST, AArch64::qsub0);
3937 SelectPostLoad(Node, 1, AArch64::LD1Rv4h_POST, AArch64::dsub0);
3940 SelectPostLoad(Node, 1, AArch64::LD1Rv8h_POST, AArch64::qsub0);
3943 SelectPostLoad(Node, 1, AArch64::LD1Rv2s_POST, AArch64::dsub0);
3946 SelectPostLoad(Node, 1, AArch64::LD1Rv4s_POST, AArch64::qsub0);
3949 SelectPostLoad(Node, 1, AArch64::LD1Rv1d_POST, AArch64::dsub0);
3952 SelectPostLoad(Node, 1, AArch64::LD1Rv2d_POST, AArch64::qsub0);
3959 SelectPostLoad(Node, 2, AArch64::LD2Rv8b_POST, AArch64::dsub0);
3962 SelectPostLoad(Node, 2, AArch64::LD2Rv16b_POST, AArch64::qsub0);
3965 SelectPostLoad(Node, 2, AArch64::LD2Rv4h_POST, AArch64::dsub0);
3968 SelectPostLoad(Node, 2, AArch64::LD2Rv8h_POST, AArch64::qsub0);
3971 SelectPostLoad(Node, 2, AArch64::LD2Rv2s_POST, AArch64::dsub0);
3974 SelectPostLoad(Node, 2, AArch64::LD2Rv4s_POST, AArch64::qsub0);
3977 SelectPostLoad(Node, 2, AArch64::LD2Rv1d_POST, AArch64::dsub0);
3980 SelectPostLoad(Node, 2, AArch64::LD2Rv2d_POST, AArch64::qsub0);
3987 SelectPostLoad(Node, 3, AArch64::LD3Rv8b_POST, AArch64::dsub0);
3990 SelectPostLoad(Node, 3, AArch64::LD3Rv16b_POST, AArch64::qsub0);
3993 SelectPostLoad(Node, 3, AArch64::LD3Rv4h_POST, AArch64::dsub0);
3996 SelectPostLoad(Node, 3, AArch64::LD3Rv8h_POST, AArch64::qsub0);
3999 SelectPostLoad(Node, 3, AArch64::LD3Rv2s_POST, AArch64::dsub0);
4002 SelectPostLoad(Node, 3, AArch64::LD3Rv4s_POST, AArch64::qsub0);
4005 SelectPostLoad(Node, 3, AArch64::LD3Rv1d_POST, AArch64::dsub0);
4008 SelectPostLoad(Node, 3, AArch64::LD3Rv2d_POST, AArch64::qsub0);
4015 SelectPostLoad(Node, 4, AArch64::LD4Rv8b_POST, AArch64::dsub0);
4018 SelectPostLoad(Node, 4, AArch64::LD4Rv16b_POST, AArch64::qsub0);
4021 SelectPostLoad(Node, 4, AArch64::LD4Rv4h_POST, AArch64::dsub0);
4024 SelectPostLoad(Node, 4, AArch64::LD4Rv8h_POST, AArch64::qsub0);
4027 SelectPostLoad(Node, 4, AArch64::LD4Rv2s_POST, AArch64::dsub0);
4030 SelectPostLoad(Node, 4, AArch64::LD4Rv4s_POST, AArch64::qsub0);
4033 SelectPostLoad(Node, 4, AArch64::LD4Rv1d_POST, AArch64::dsub0);
4036 SelectPostLoad(Node, 4, AArch64::LD4Rv2d_POST, AArch64::qsub0);
4043 SelectPostLoadLane(Node, 1, AArch64::LD1i8_POST);
4047 SelectPostLoadLane(Node, 1, AArch64::LD1i16_POST);
4051 SelectPostLoadLane(Node, 1, AArch64::LD1i32_POST);
4055 SelectPostLoadLane(Node, 1, AArch64::LD1i64_POST);
4062 SelectPostLoadLane(Node, 2, AArch64::LD2i8_POST);
4066 SelectPostLoadLane(Node, 2, AArch64::LD2i16_POST);
4070 SelectPostLoadLane(Node, 2, AArch64::LD2i32_POST);
4074 SelectPostLoadLane(Node, 2, AArch64::LD2i64_POST);
4081 SelectPostLoadLane(Node, 3, AArch64::LD3i8_POST);
4085 SelectPostLoadLane(Node, 3, AArch64::LD3i16_POST);
4089 SelectPostLoadLane(Node, 3, AArch64::LD3i32_POST);
4093 SelectPostLoadLane(Node, 3, AArch64::LD3i64_POST);
4100 SelectPostLoadLane(Node, 4, AArch64::LD4i8_POST);
4104 SelectPostLoadLane(Node, 4, AArch64::LD4i16_POST);
4108 SelectPostLoadLane(Node, 4, AArch64::LD4i32_POST);
4112 SelectPostLoadLane(Node, 4, AArch64::LD4i64_POST);
4120 SelectPostStore(Node, 2, AArch64::ST2Twov8b_POST);
4123 SelectPostStore(Node, 2, AArch64::ST2Twov16b_POST);
4126 SelectPostStore(Node, 2, AArch64::ST2Twov4h_POST);
4129 SelectPostStore(Node, 2, AArch64::ST2Twov8h_POST);
4132 SelectPostStore(Node, 2, AArch64::ST2Twov2s_POST);
4135 SelectPostStore(Node, 2, AArch64::ST2Twov4s_POST);
4138 SelectPostStore(Node, 2, AArch64::ST2Twov2d_POST);
4141 SelectPostStore(Node, 2, AArch64::ST1Twov1d_POST);
4149 SelectPostStore(Node, 3, AArch64::ST3Threev8b_POST);
4152 SelectPostStore(Node, 3, AArch64::ST3Threev16b_POST);
4155 SelectPostStore(Node, 3, AArch64::ST3Threev4h_POST);
4158 SelectPostStore(Node, 3, AArch64::ST3Threev8h_POST);
4161 SelectPostStore(Node, 3, AArch64::ST3Threev2s_POST);
4164 SelectPostStore(Node, 3, AArch64::ST3Threev4s_POST);
4167 SelectPostStore(Node, 3, AArch64::ST3Threev2d_POST);
4170 SelectPostStore(Node, 3, AArch64::ST1Threev1d_POST);
4178 SelectPostStore(Node, 4, AArch64::ST4Fourv8b_POST);
4181 SelectPostStore(Node, 4, AArch64::ST4Fourv16b_POST);
4184 SelectPostStore(Node, 4, AArch64::ST4Fourv4h_POST);
4187 SelectPostStore(Node, 4, AArch64::ST4Fourv8h_POST);
4190 SelectPostStore(Node, 4, AArch64::ST4Fourv2s_POST);
4193 SelectPostStore(Node, 4, AArch64::ST4Fourv4s_POST);
4196 SelectPostStore(Node, 4, AArch64::ST4Fourv2d_POST);
4199 SelectPostStore(Node, 4, AArch64::ST1Fourv1d_POST);
4207 SelectPostStore(Node, 2, AArch64::ST1Twov8b_POST);
4210 SelectPostStore(Node, 2, AArch64::ST1Twov16b_POST);
4213 SelectPostStore(Node, 2, AArch64::ST1Twov4h_POST);
4216 SelectPostStore(Node, 2, AArch64::ST1Twov8h_POST);
4219 SelectPostStore(Node, 2, AArch64::ST1Twov2s_POST);
4222 SelectPostStore(Node, 2, AArch64::ST1Twov4s_POST);
4225 SelectPostStore(Node, 2, AArch64::ST1Twov1d_POST);
4228 SelectPostStore(Node, 2, AArch64::ST1Twov2d_POST);
4236 SelectPostStore(Node, 3, AArch64::ST1Threev8b_POST);
4239 SelectPostStore(Node, 3, AArch64::ST1Threev16b_POST);
4242 SelectPostStore(Node, 3, AArch64::ST1Threev4h_POST);
4245 SelectPostStore(Node, 3, AArch64::ST1Threev8h_POST);
4248 SelectPostStore(Node, 3, AArch64::ST1Threev2s_POST);
4251 SelectPostStore(Node, 3, AArch64::ST1Threev4s_POST);
4254 SelectPostStore(Node, 3, AArch64::ST1Threev1d_POST);
4257 SelectPostStore(Node, 3, AArch64::ST1Threev2d_POST);
4265 SelectPostStore(Node, 4, AArch64::ST1Fourv8b_POST);
4268 SelectPostStore(Node, 4, AArch64::ST1Fourv16b_POST);
4271 SelectPostStore(Node, 4, AArch64::ST1Fourv4h_POST);
4274 SelectPostStore(Node, 4, AArch64::ST1Fourv8h_POST);
4277 SelectPostStore(Node, 4, AArch64::ST1Fourv2s_POST);
4280 SelectPostStore(Node, 4, AArch64::ST1Fourv4s_POST);
4283 SelectPostStore(Node, 4, AArch64::ST1Fourv1d_POST);
4286 SelectPostStore(Node, 4, AArch64::ST1Fourv2d_POST);
4294 SelectPostStoreLane(Node, 2, AArch64::ST2i8_POST);
4298 SelectPostStoreLane(Node, 2, AArch64::ST2i16_POST);
4302 SelectPostStoreLane(Node, 2, AArch64::ST2i32_POST);
4306 SelectPostStoreLane(Node, 2, AArch64::ST2i64_POST);
4314 SelectPostStoreLane(Node, 3, AArch64::ST3i8_POST);
4318 SelectPostStoreLane(Node, 3, AArch64::ST3i16_POST);
4322 SelectPostStoreLane(Node, 3, AArch64::ST3i32_POST);
4326 SelectPostStoreLane(Node, 3, AArch64::ST3i64_POST);
4334 SelectPostStoreLane(Node, 4, AArch64::ST4i8_POST);
4338 SelectPostStoreLane(Node, 4, AArch64::ST4i16_POST);
4342 SelectPostStoreLane(Node, 4, AArch64::ST4i32_POST);
4346 SelectPostStoreLane(Node, 4, AArch64::ST4i64_POST);
4361 return new AArch64DAGToDAGISel(TM, OptLevel);
void clearAllBits()
Set every bit to 0.
static bool isBitfieldExtractOp(SelectionDAG *CurDAG, SDNode *N, unsigned &Opc, SDValue &Opd0, unsigned &Immr, unsigned &Imms, unsigned NumberOfIgnoredLowBits=0, bool BiggerPattern=false)
SDNode * SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT)
These are used for target selectors to mutate the specified node to have the specified return type...
A parsed version of the target data layout string in and methods for querying it. ...
static bool isBitfieldPositioningOp(SelectionDAG *CurDAG, SDValue Op, bool BiggerPattern, SDValue &Src, int &ShiftAmount, int &MaskWidth)
Does this tree qualify as an attempt to move a bitfield into position, essentially "(and (shl VAL...
EVT getValueType() const
Return the ValueType of the referenced return value.
const SDValue & getOffset() const
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
void flipAllBits()
Toggle every bit to its opposite value.
const GlobalValue * getGlobal() const
uint64_t getZExtValue() const
Get zero extended value.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
DiagnosticInfoOptimizationBase::Argument NV
EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR (an vector value) starting with the ...
This class represents lattice values for constants.
static MVT getVectorVT(MVT VT, unsigned NumElements)
bool isSized(SmallPtrSetImpl< Type *> *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
unsigned countLeadingOnes(T Value, ZeroBehavior ZB=ZB_Width)
Count the number of ones from the most significant bit to the first zero bit.
const SDValue & getBasePtr() const
void push_back(const T &Elt)
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
static SDValue NarrowVector(SDValue V128Reg, SelectionDAG &DAG)
NarrowVector - Given a value in the V128 register class, produce the equivalent value in the V64 regi...
static void getUsefulBitsForUse(SDNode *UserNode, APInt &UsefulBits, SDValue Orig, unsigned Depth)
static bool isWorthFoldingADDlow(SDValue N)
If there's a use of this ADDlow that's not itself a load/store then we'll need to create a real ADD i...
static bool processLogicalImmediate(uint64_t Imm, unsigned RegSize, uint64_t &Encoding)
processLogicalImmediate - Determine if an immediate value can be encoded as the immediate operand of ...
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
static bool isSeveralBitsExtractOpFromShr(SDNode *N, unsigned &Opc, SDValue &Opd0, unsigned &LSB, unsigned &MSB)
const SDValue & getChain() const
static bool isOpcWithIntImmediate(const SDNode *N, unsigned Opc, uint64_t &Imm)
ISD::MemIndexedMode getAddressingMode() const
Return the addressing mode for this load or store: unindexed, pre-inc, pre-dec, post-inc, or post-dec.
SPLAT_VECTOR(VAL) - Returns a vector with the scalar value VAL duplicated in all lanes.
unsigned const TargetRegisterInfo * TRI
MVT getSimpleValueType(unsigned ResNo) const
Return the type of a specified result as a simple type.
TypeSize getScalarValueSizeInBits() const
const MDOperand & getOperand(unsigned I) const
APInt zextOrTrunc(unsigned width) const
Zero extend or truncate to width.
void setNodeId(int Id)
Set unique node id.
SDNode * getNode() const
get the SDNode which holds the desired result
INSERT_SUBVECTOR(VECTOR1, VECTOR2, IDX) - Returns a vector with VECTOR2 inserted into VECTOR1 at the ...
unsigned getBitWidth() const
Get the bit width of this value.
bool hasOneUse() const
Return true if there is exactly one node using value ResNo of Node.
unsigned getBitWidth() const
Return the number of bits in the APInt.
RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) This node represents a target in...
unsigned countTrailingZeros(T Val, ZeroBehavior ZB=ZB_Width)
Count number of 0's from the least significant bit to the most stopping at the first 1...
opStatus convertToInteger(MutableArrayRef< integerPart > Input, unsigned int Width, bool IsSigned, roundingMode RM, bool *IsExact) const
unsigned countTrailingZeros() const
Count the number of trailing zero bits.
A description of a memory reference used in the backend.
static bool checkV64LaneV128(SDValue Op0, SDValue Op1, SDValue &StdOp, SDValue &LaneOp, int &LaneIdx)
static bool isPreferredADD(int64_t ImmOff)
Shift and rotation operations.
A Use represents the edge between a Value definition and its users.
SDValue getTargetExtractSubreg(int SRIdx, const SDLoc &DL, EVT VT, SDValue Operand)
A convenience function for creating TargetInstrInfo::EXTRACT_SUBREG nodes.
MachineSDNode * getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT)
These are used for target selectors to create a new node with specified return type(s), MachineInstr opcode, and operands.
const MDNode * getMD() const
ISD::LoadExtType getExtensionType() const
Return whether this is a plain node, or one of the varieties of value-extending loads.
static bool isLogicalImmediate(uint64_t imm, unsigned regSize)
isLogicalImmediate - Return true if the immediate is valid for a logical immediate instruction of the...
static bool isWorthFoldingSHL(SDValue V)
Determine whether it is worth it to fold SHL into the addressing mode.
TypeSize getValueSizeInBits() const
Returns the size of the value in bits.
void lshrInPlace(unsigned ShiftAmt)
Logical right-shift this APInt by ShiftAmt in place.
unsigned getID() const
Return the register class ID number.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
int64_t getSExtValue() const
static bool tryBitfieldInsertOpFromOr(SDNode *N, const APInt &UsefulBits, SelectionDAG *CurDAG)
static void getUsefulBits(SDValue Op, APInt &UsefulBits, unsigned Depth=0)
static bool isBitfieldExtractOpFromAnd(SelectionDAG *CurDAG, SDNode *N, unsigned &Opc, SDValue &Opd0, unsigned &LSB, unsigned &MSB, unsigned NumberOfIgnoredLowBits, bool BiggerPattern)
constexpr bool isMask_64(uint64_t Value)
Return true if the argument is a non-empty sequence of ones starting at the least significant bit wit...
SDValue peekThroughBitcasts(SDValue V)
Return the non-bitcasted source operand of V if it exists.
Simple integer binary arithmetic operators.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
op_iterator op_begin() const
unsigned getAlignment() const
SDValue getTargetConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
bool isStrongerThanMonotonic(AtomicOrdering ao)
RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) This node represents a target intrinsic fun...
static SDValue WidenVector(SDValue V64Reg, SelectionDAG &DAG)
WidenVector - Given a value in the V64 register class, produce the equivalent value in the V128 regis...
static void getUsefulBitsFromOrWithShiftedReg(SDValue Op, APInt &UsefulBits, unsigned Depth)
UNDEF - An undefined node.
static unsigned getShifterImm(AArch64_AM::ShiftExtendType ST, unsigned Imm)
getShifterImm - Encode the shift type and amount: imm: 6-bit shift amount shifter: 000 ==> lsl 001 ==...
static AArch64_AM::ShiftExtendType getShiftTypeForNode(SDValue N)
getShiftTypeForNode - Translate a shift node to the corresponding ShiftType value.
static unsigned getShiftValue(unsigned Imm)
getShiftValue - Extract the shift value.
int64_t getOffset() const
OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...) This node represents a target intrin...
READ_REGISTER, WRITE_REGISTER - This node represents llvm.register on the DAG, which implements the n...
unsigned countPopulation() const
Count the number of bits set.
The instances of the Type class are immutable: once they are created, they are never changed...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
static void getUsefulBitsFromBFM(SDValue Op, SDValue Orig, APInt &UsefulBits, unsigned Depth)
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
size_t size() const
size - Get the array size.
const SDValue & getOperand(unsigned Num) const
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
static uint64_t decodeLogicalImmediate(uint64_t val, unsigned regSize)
decodeLogicalImmediate - Decode a logical immediate value in the form "N:immr:imms" (where the immr a...
FunctionPass class - This class is used to implement most global optimizations.
static SDValue narrowIfNeeded(SelectionDAG *CurDAG, SDValue N)
Instructions that accept extend modifiers like UXTW expect the register being extended to be a GPR32...
Val, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap) For double-word atomic operations: ValLo...
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
virtual MVT getPointerTy(const DataLayout &DL, uint32_t AS=0) const
Return the pointer type for the given address space, defaults to the pointer type from the data layou...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
bool isMachineOpcode() const
Test if this node has a post-isel opcode, directly corresponding to a MachineInstr opcode...
unsigned getNumOperands() const
Return the number of values used by this operation.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static SDValue Widen(SelectionDAG *CurDAG, SDValue N)
bool isUnindexed() const
Return true if this is NOT a pre/post inc/dec load/store.
void dump() const
Dump this node, for debugging.
static void getUsefulBitsFromBitfieldMoveOpd(SDValue Op, APInt &UsefulBits, uint64_t Imm, uint64_t MSB, unsigned Depth)
static bool isIntImmediate(const SDNode *N, uint64_t &Imm)
isIntImmediate - This method tests to see if the node is a constant operand.
EVT getVectorElementType() const
Given a vector type, return the type of each element.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
static SDValue getLeftShift(SelectionDAG *CurDAG, SDValue Op, int ShlAmount)
Create a machine node performing a notional SHL of Op by ShlAmount.
static AArch64_AM::ShiftExtendType getExtendTypeForNode(SDValue N, bool IsLoadStore=false)
getExtendTypeForNode - Translate an extend node to the corresponding ExtendType value.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
An SDNode that represents everything that will be needed to construct a MachineInstr.
const Constant * getConstVal() const
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
SelectionDAGISel - This is the common base class used for SelectionDAG-based pattern-matching instruc...
unsigned logBase2() const
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
EVT getMemoryVT() const
Return the type of the in-memory value.
Class for arbitrary precision integers.
iterator_range< use_iterator > uses()
bool isPowerOf2() const
Check if this APInt's value is a power of two greater than zero.
const SysReg * lookupSysRegByName(StringRef)
ZERO_EXTEND - Used for integer types, zeroing the new bits.
ANY_EXTEND - Used for integer types. The high bits are undefined.
uint32_t parseGenericRegister(StringRef Name)
static unsigned getArithExtendImm(AArch64_AM::ShiftExtendType ET, unsigned Imm)
getArithExtendImm - Encode the extend type and shift amount for an arithmetic instruction: imm: 3-bit...
FunctionPass * createAArch64ISelDag(AArch64TargetMachine &TM, CodeGenOpt::Level OptLevel)
createAArch64ISelDag - This pass converts a legalized DAG into a AArch64-specific DAG...
static APInt getBitsSet(unsigned numBits, unsigned loBit, unsigned hiBit)
Get a value with a block of bits set.
static bool isBitfieldExtractOpFromSExtInReg(SDNode *N, unsigned &Opc, SDValue &Opd0, unsigned &Immr, unsigned &Imms)
bool is64BitVector() const
Return true if this is a 64-bit vector type.
constexpr bool isShiftedMask_64(uint64_t Value)
Return true if the argument contains a non-empty sequence of ones with the remainder zero (64 bit ver...
static bool checkHighLaneIndex(SDNode *DL, SDValue &LaneOp, int &LaneIdx)
Bitwise operators - logical and, logical or, logical xor.
static AArch64_AM::ShiftExtendType getShiftType(unsigned Imm)
getShiftType - Extract the shift type.
static bool isBitfieldExtractOpFromShr(SDNode *N, unsigned &Opc, SDValue &Opd0, unsigned &Immr, unsigned &Imms, bool BiggerPattern)
bool is128BitVector() const
Return true if this is a 128-bit vector type.
static int getIntOperandFromRegisterString(StringRef RegString)
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
APFloat abs(APFloat X)
Returns the absolute value of the argument.
static bool isBitfieldDstMask(uint64_t DstMask, const APInt &BitsToBeInserted, unsigned NumberOfIgnoredHighBits, EVT VT)
Does DstMask form a complementary pair with the mask provided by BitsToBeInserted, suitable for use in a BFI instruction.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Type * getValueType() const
static constexpr unsigned MaxRecursionDepth
unsigned getOpcode() const
OutputIt transform(R &&Range, OutputIt d_first, UnaryPredicate P)
Wrapper function around std::transform to apply a function to a range and store the result elsewhere...
static bool isShiftedMask(uint64_t Mask, EVT VT)
static void getUsefulBitsFromUBFM(SDValue Op, APInt &UsefulBits, unsigned Depth)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static void getUsefulBitsFromAndWithImmediate(SDValue Op, APInt &UsefulBits, unsigned Depth)
unsigned getMachineOpcode() const
This may only be called if isMachineOpcode returns true.
unsigned countTrailingOnes(T Value, ZeroBehavior ZB=ZB_Width)
Count the number of ones from the least significant bit to the first zero bit.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
constexpr bool isShiftedMask_32(uint32_t Value)
Return true if the argument contains a non-empty sequence of ones with the remainder zero (32 bit ver...
StringRef - Represent a constant reference to a string, i.e.
unsigned countLeadingZeros() const
The APInt version of the countLeadingZeros functions in MathExtras.h.
KnownBits computeKnownBits(SDValue Op, unsigned Depth=0) const
Determine which bits of Op are known to be either zero or one and return them in Known.
const SDValue & getOperand(unsigned i) const
OUTCHAIN = ATOMIC_STORE(INCHAIN, ptr, val) This corresponds to "store atomic" instruction.
uint64_t getZExtValue() const
SDValue getTargetInsertSubreg(int SRIdx, const SDLoc &DL, EVT VT, SDValue Operand, SDValue Subreg)
A convenience function for creating TargetInstrInfo::INSERT_SUBREG nodes.
TRUNCATE - Completely drop the high bits.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
Val, OUTCHAIN = ATOMIC_LOAD(INCHAIN, ptr) This corresponds to "load atomic" instruction.
static bool tryBitfieldInsertOpFromOrAndImm(SDNode *N, SelectionDAG *CurDAG)
virtual const TargetRegisterClass * getPointerRegClass(const MachineFunction &MF, unsigned Kind=0) const
Returns a TargetRegisterClass used for pointer values.
MemIndexedMode
MemIndexedMode enum - This enum defines the load / store indexed addressing modes.
This class is used to represent ISD::LOAD nodes.