29 #define DEBUG_TYPE "aarch64-isel" 52 return "AArch64 Instruction Selection";
65 bool SelectInlineAsmMemoryOperand(
const SDValue &
Op,
66 unsigned ConstraintID,
67 std::vector<SDValue> &OutOps)
override;
69 bool tryMLAV64LaneV128(
SDNode *
N);
70 bool tryMULLV64LaneV128(
unsigned IntNo,
SDNode *N);
75 return SelectShiftedRegister(N,
false, Reg, Shift);
78 return SelectShiftedRegister(N,
true, Reg, Shift);
81 return SelectAddrModeIndexed7S(N, 1, Base, OffImm);
84 return SelectAddrModeIndexed7S(N, 2, Base, OffImm);
87 return SelectAddrModeIndexed7S(N, 4, Base, OffImm);
90 return SelectAddrModeIndexed7S(N, 8, Base, OffImm);
93 return SelectAddrModeIndexed7S(N, 16, Base, OffImm);
96 return SelectAddrModeIndexed(N, 1, Base, OffImm);
99 return SelectAddrModeIndexed(N, 2, Base, OffImm);
102 return SelectAddrModeIndexed(N, 4, Base, OffImm);
105 return SelectAddrModeIndexed(N, 8, Base, OffImm);
108 return SelectAddrModeIndexed(N, 16, Base, OffImm);
111 return SelectAddrModeUnscaled(N, 1, Base, OffImm);
114 return SelectAddrModeUnscaled(N, 2, Base, OffImm);
117 return SelectAddrModeUnscaled(N, 4, Base, OffImm);
120 return SelectAddrModeUnscaled(N, 8, Base, OffImm);
123 return SelectAddrModeUnscaled(N, 16, Base, OffImm);
129 return SelectAddrModeWRO(N, Width / 8, Base, Offset, SignExtend, DoShift);
135 return SelectAddrModeXRO(N, Width / 8, Base, Offset, SignExtend, DoShift);
149 const unsigned SubRegs[]);
151 void SelectTable(
SDNode *N,
unsigned NumVecs,
unsigned Opc,
bool isExt);
153 bool tryIndexedLoad(
SDNode *N);
155 void SelectLoad(
SDNode *N,
unsigned NumVecs,
unsigned Opc,
157 void SelectPostLoad(
SDNode *N,
unsigned NumVecs,
unsigned Opc,
159 void SelectLoadLane(
SDNode *N,
unsigned NumVecs,
unsigned Opc);
160 void SelectPostLoadLane(
SDNode *N,
unsigned NumVecs,
unsigned Opc);
162 void SelectStore(
SDNode *N,
unsigned NumVecs,
unsigned Opc);
163 void SelectPostStore(
SDNode *N,
unsigned NumVecs,
unsigned Opc);
164 void SelectStoreLane(
SDNode *N,
unsigned NumVecs,
unsigned Opc);
165 void SelectPostStoreLane(
SDNode *N,
unsigned NumVecs,
unsigned Opc);
167 bool tryBitfieldExtractOp(
SDNode *N);
168 bool tryBitfieldExtractOpFromSExt(
SDNode *N);
169 bool tryBitfieldInsertOp(
SDNode *N);
170 bool tryBitfieldInsertInZeroOp(
SDNode *N);
171 bool tryShiftAmountMod(
SDNode *N);
173 bool tryReadRegister(
SDNode *N);
174 bool tryWriteRegister(
SDNode *N);
177 #include "AArch64GenDAGISel.inc" 180 bool SelectShiftedRegister(
SDValue N,
bool AllowROR,
SDValue &Reg,
184 bool SelectAddrModeIndexed(
SDValue N,
unsigned Size,
SDValue &Base,
186 bool SelectAddrModeUnscaled(
SDValue N,
unsigned Size,
SDValue &Base,
194 bool isWorthFolding(
SDValue V)
const;
195 bool SelectExtendedSHL(
SDValue N,
unsigned Size,
bool WantExtend,
198 template<
unsigned RegW
idth>
200 return SelectCVTFixedPosOperand(N, FixedPos, RegWidth);
203 bool SelectCVTFixedPosOperand(
SDValue N,
SDValue &FixedPos,
unsigned Width);
205 bool SelectCMP_SWAP(
SDNode *N);
214 Imm =
C->getZExtValue();
235 bool AArch64DAGToDAGISel::SelectInlineAsmMemoryOperand(
236 const SDValue &
Op,
unsigned ConstraintID, std::vector<SDValue> &OutOps) {
237 switch(ConstraintID) {
250 SDValue(CurDAG->getMachineNode(TargetOpcode::COPY_TO_REGCLASS,
253 OutOps.push_back(NewOp);
269 if (!isa<ConstantSDNode>(N.
getNode()))
272 uint64_t Immed = cast<ConstantSDNode>(N.
getNode())->getZExtValue();
275 if (Immed >> 12 == 0) {
277 }
else if ((Immed & 0xfff) == 0 && Immed >> 24 == 0) {
285 Val = CurDAG->getTargetConstant(Immed, dl,
MVT::i32);
286 Shift = CurDAG->getTargetConstant(ShVal, dl,
MVT::i32);
292 bool AArch64DAGToDAGISel::SelectNegArithImmed(
SDValue N,
SDValue &Val,
299 if (!isa<ConstantSDNode>(N.
getNode()))
303 uint64_t Immed = cast<ConstantSDNode>(N.
getNode())->getZExtValue();
314 Immed = ~Immed + 1ULL;
315 if (Immed & 0xFFFFFFFFFF000000ULL)
318 Immed &= 0xFFFFFFULL;
319 return SelectArithImmed(CurDAG->getConstant(Immed,
SDLoc(N),
MVT::i32), Val,
357 if (!isa<MemSDNode>(*UI))
359 if (!isa<MemSDNode>(*UII))
365 bool AArch64DAGToDAGISel::isWorthFolding(
SDValue V)
const {
393 bool AArch64DAGToDAGISel::SelectShiftedRegister(
SDValue N,
bool AllowROR,
403 unsigned Val = RHS->getZExtValue() & (BitSize - 1);
407 Shift = CurDAG->getTargetConstant(ShVal,
SDLoc(N),
MVT::i32);
408 return isWorthFolding(N);
422 SrcVT = cast<VTSDNode>(N.
getOperand(1))->getVT();
426 if (!IsLoadStore && SrcVT ==
MVT::i8)
428 else if (!IsLoadStore && SrcVT ==
MVT::i16)
438 if (!IsLoadStore && SrcVT ==
MVT::i8)
440 else if (!IsLoadStore && SrcVT ==
MVT::i16)
484 LaneIdx = DLidx->
getSExtValue() + EVidx->getSExtValue();
493 SDValue &LaneOp,
int &LaneIdx) {
507 bool AArch64DAGToDAGISel::tryMLAV64LaneV128(
SDNode *N) {
527 SDValue Ops[] = { Op0, MLAOp1, MLAOp2, LaneIdxVal };
529 unsigned MLAOpc = ~0U;
535 MLAOpc = AArch64::MLAv4i16_indexed;
538 MLAOpc = AArch64::MLAv8i16_indexed;
541 MLAOpc = AArch64::MLAv2i32_indexed;
544 MLAOpc = AArch64::MLAv4i32_indexed;
548 ReplaceNode(N, CurDAG->getMachineNode(MLAOpc, dl, N->
getValueType(0), Ops));
552 bool AArch64DAGToDAGISel::tryMULLV64LaneV128(
unsigned IntNo,
SDNode *N) {
564 SDValue Ops[] = { SMULLOp0, SMULLOp1, LaneIdxVal };
566 unsigned SMULLOpc = ~0U;
568 if (IntNo == Intrinsic::aarch64_neon_smull) {
573 SMULLOpc = AArch64::SMULLv4i16_indexed;
576 SMULLOpc = AArch64::SMULLv2i32_indexed;
579 }
else if (IntNo == Intrinsic::aarch64_neon_umull) {
584 SMULLOpc = AArch64::UMULLv4i16_indexed;
587 SMULLOpc = AArch64::UMULLv2i32_indexed;
593 ReplaceNode(N, CurDAG->getMachineNode(SMULLOpc, dl, N->
getValueType(0), Ops));
615 bool AArch64DAGToDAGISel::SelectArithExtendedRegister(
SDValue N,
SDValue &Reg,
617 unsigned ShiftVal = 0;
655 return isWorthFolding(N);
682 bool AArch64DAGToDAGISel::SelectAddrModeIndexed7S(
SDValue N,
unsigned Size,
686 const DataLayout &DL = CurDAG->getDataLayout();
689 int FI = cast<FrameIndexSDNode>(
N)->getIndex();
690 Base = CurDAG->getTargetFrameIndex(FI, TLI->
getPointerTy(DL));
691 OffImm = CurDAG->getTargetConstant(0, dl,
MVT::i64);
698 if (CurDAG->isBaseWithConstantOffset(N)) {
700 int64_t RHSC = RHS->getSExtValue();
701 unsigned Scale =
Log2_32(Size);
702 if ((RHSC & (Size - 1)) == 0 && RHSC >= -(0x40 << Scale) &&
703 RHSC < (0x40 << Scale)) {
706 int FI = cast<FrameIndexSDNode>(Base)->getIndex();
707 Base = CurDAG->getTargetFrameIndex(FI, TLI->
getPointerTy(DL));
709 OffImm = CurDAG->getTargetConstant(RHSC >> Scale, dl,
MVT::i64);
720 OffImm = CurDAG->getTargetConstant(0, dl,
MVT::i64);
727 bool AArch64DAGToDAGISel::SelectAddrModeIndexed(
SDValue N,
unsigned Size,
730 const DataLayout &DL = CurDAG->getDataLayout();
733 int FI = cast<FrameIndexSDNode>(
N)->getIndex();
734 Base = CurDAG->getTargetFrameIndex(FI, TLI->
getPointerTy(DL));
735 OffImm = CurDAG->getTargetConstant(0, dl,
MVT::i64);
751 if (Alignment == 0 && Ty->
isSized())
754 if (Alignment >= Size)
759 if (CurDAG->isBaseWithConstantOffset(N)) {
761 int64_t RHSC = (int64_t)RHS->getZExtValue();
762 unsigned Scale =
Log2_32(Size);
763 if ((RHSC & (Size - 1)) == 0 && RHSC >= 0 && RHSC < (0x1000 << Scale)) {
766 int FI = cast<FrameIndexSDNode>(Base)->getIndex();
767 Base = CurDAG->getTargetFrameIndex(FI, TLI->
getPointerTy(DL));
769 OffImm = CurDAG->getTargetConstant(RHSC >> Scale, dl,
MVT::i64);
777 if (SelectAddrModeUnscaled(N, Size, Base, OffImm))
785 OffImm = CurDAG->getTargetConstant(0, dl,
MVT::i64);
794 bool AArch64DAGToDAGISel::SelectAddrModeUnscaled(
SDValue N,
unsigned Size,
797 if (!CurDAG->isBaseWithConstantOffset(N))
800 int64_t RHSC = RHS->getSExtValue();
802 if ((RHSC & (Size - 1)) == 0 && RHSC >= 0 &&
803 RHSC < (0x1000 <<
Log2_32(Size)))
805 if (RHSC >= -256 && RHSC < 256) {
808 int FI = cast<FrameIndexSDNode>(Base)->getIndex();
810 Base = CurDAG->getTargetFrameIndex(
813 OffImm = CurDAG->getTargetConstant(RHSC,
SDLoc(N),
MVT::i64);
826 TargetOpcode::INSERT_SUBREG, dl,
MVT::i64, ImpDef, N, SubReg);
832 bool AArch64DAGToDAGISel::SelectExtendedSHL(
SDValue N,
unsigned Size,
837 if (!CSD || (CSD->getZExtValue() & 0x7) != CSD->getZExtValue())
852 SignExtend = CurDAG->getTargetConstant(0, dl,
MVT::i32);
855 unsigned LegalShiftVal =
Log2_32(Size);
856 unsigned ShiftVal = CSD->getZExtValue();
858 if (ShiftVal != 0 && ShiftVal != LegalShiftVal)
861 return isWorthFolding(N);
864 bool AArch64DAGToDAGISel::SelectAddrModeWRO(
SDValue N,
unsigned Size,
876 if (isa<ConstantSDNode>(LHS) || isa<ConstantSDNode>(RHS))
884 if (!isa<MemSDNode>(*UI))
889 bool IsExtendedRegisterWorthFolding = isWorthFolding(N);
893 SelectExtendedSHL(RHS, Size,
true, Offset, SignExtend)) {
895 DoShift = CurDAG->getTargetConstant(
true, dl,
MVT::i32);
901 SelectExtendedSHL(LHS, Size,
true, Offset, SignExtend)) {
903 DoShift = CurDAG->getTargetConstant(
true, dl,
MVT::i32);
908 DoShift = CurDAG->getTargetConstant(
false, dl,
MVT::i32);
912 if (IsExtendedRegisterWorthFolding &&
919 if (isWorthFolding(LHS))
924 if (IsExtendedRegisterWorthFolding &&
931 if (isWorthFolding(RHS))
943 if ((ImmOff & 0xfffffffffffff000LL) == 0x0LL)
946 if ((ImmOff & 0xffffffffff000fffLL) == 0x0LL)
948 return (ImmOff & 0xffffffffff00ffffLL) != 0x0LL &&
949 (ImmOff & 0xffffffffffff0fffLL) != 0x0LL;
953 bool AArch64DAGToDAGISel::SelectAddrModeXRO(
SDValue N,
unsigned Size,
968 if (!isa<MemSDNode>(*UI))
983 if (isa<ConstantSDNode>(RHS)) {
984 int64_t ImmOff = (int64_t)cast<ConstantSDNode>(RHS)->getZExtValue();
985 unsigned Scale =
Log2_32(Size);
989 if ((ImmOff % Size == 0 && ImmOff >= 0 && ImmOff < (0x1000 << Scale)) ||
995 CurDAG->getMachineNode(AArch64::MOVi64imm, DL,
MVT::i64, Ops);
1002 bool IsExtendedRegisterWorthFolding = isWorthFolding(N);
1006 SelectExtendedSHL(RHS, Size,
false, Offset, SignExtend)) {
1008 DoShift = CurDAG->getTargetConstant(
true, DL,
MVT::i32);
1014 SelectExtendedSHL(LHS, Size,
false, Offset, SignExtend)) {
1016 DoShift = CurDAG->getTargetConstant(
true, DL,
MVT::i32);
1023 SignExtend = CurDAG->getTargetConstant(
false, DL,
MVT::i32);
1024 DoShift = CurDAG->getTargetConstant(
false, DL,
MVT::i32);
1030 static const unsigned RegClassIDs[] = {
1031 AArch64::DDRegClassID, AArch64::DDDRegClassID, AArch64::DDDDRegClassID};
1032 static const unsigned SubRegs[] = {AArch64::dsub0, AArch64::dsub1,
1033 AArch64::dsub2, AArch64::dsub3};
1035 return createTuple(Regs, RegClassIDs, SubRegs);
1039 static const unsigned RegClassIDs[] = {
1040 AArch64::QQRegClassID, AArch64::QQQRegClassID, AArch64::QQQQRegClassID};
1041 static const unsigned SubRegs[] = {AArch64::qsub0, AArch64::qsub1,
1042 AArch64::qsub2, AArch64::qsub3};
1044 return createTuple(Regs, RegClassIDs, SubRegs);
1048 const unsigned RegClassIDs[],
1049 const unsigned SubRegs[]) {
1052 if (Regs.
size() == 1)
1063 CurDAG->getTargetConstant(RegClassIDs[Regs.
size() - 2], DL,
MVT::i32));
1066 for (
unsigned i = 0; i < Regs.
size(); ++i) {
1072 CurDAG->getMachineNode(TargetOpcode::REG_SEQUENCE, DL,
MVT::Untyped, Ops);
1076 void AArch64DAGToDAGISel::SelectTable(
SDNode *N,
unsigned NumVecs,
unsigned Opc,
1081 unsigned ExtOff = isExt;
1084 unsigned Vec0Off = ExtOff + 1;
1086 N->
op_begin() + Vec0Off + NumVecs);
1087 SDValue RegSeq = createQTuple(Regs);
1094 ReplaceNode(N, CurDAG->getMachineNode(Opc, dl, VT, Ops));
1097 bool AArch64DAGToDAGISel::tryIndexedLoad(
SDNode *N) {
1109 unsigned Opcode = 0;
1112 bool InsertTo64 =
false;
1114 Opcode = IsPre ? AArch64::LDRXpre : AArch64::LDRXpost;
1117 Opcode = IsPre ? AArch64::LDRWpre : AArch64::LDRWpost;
1119 Opcode = IsPre ? AArch64::LDRSWpre : AArch64::LDRSWpost;
1121 Opcode = IsPre ? AArch64::LDRWpre : AArch64::LDRWpost;
1130 Opcode = IsPre ? AArch64::LDRSHXpre : AArch64::LDRSHXpost;
1132 Opcode = IsPre ? AArch64::LDRSHWpre : AArch64::LDRSHWpost;
1134 Opcode = IsPre ? AArch64::LDRHHpre : AArch64::LDRHHpost;
1143 Opcode = IsPre ? AArch64::LDRSBXpre : AArch64::LDRSBXpost;
1145 Opcode = IsPre ? AArch64::LDRSBWpre : AArch64::LDRSBWpost;
1147 Opcode = IsPre ? AArch64::LDRBBpre : AArch64::LDRBBpost;
1154 Opcode = IsPre ? AArch64::LDRHpre : AArch64::LDRHpost;
1156 Opcode = IsPre ? AArch64::LDRSpre : AArch64::LDRSpost;
1158 Opcode = IsPre ? AArch64::LDRDpre : AArch64::LDRDpost;
1160 Opcode = IsPre ? AArch64::LDRQpre : AArch64::LDRQpost;
1170 SDNode *Res = CurDAG->getMachineNode(Opcode, dl,
MVT::i64, DstVT,
1177 SDValue(CurDAG->getMachineNode(
1178 AArch64::SUBREG_TO_REG, dl,
MVT::i64,
1179 CurDAG->getTargetConstant(0, dl,
MVT::i64), LoadedVal,
1184 ReplaceUses(
SDValue(N, 0), LoadedVal);
1187 CurDAG->RemoveDeadNode(N);
1191 void AArch64DAGToDAGISel::SelectLoad(
SDNode *N,
unsigned NumVecs,
unsigned Opc,
1192 unsigned SubRegIdx) {
1202 SDNode *Ld = CurDAG->getMachineNode(Opc, dl, ResTys, Ops);
1204 for (
unsigned i = 0; i < NumVecs; ++i)
1206 CurDAG->getTargetExtractSubreg(SubRegIdx + i, dl, VT, SuperReg));
1212 MemOp[0] = cast<MemIntrinsicSDNode>(
N)->getMemOperand();
1213 cast<MachineSDNode>(Ld)->setMemRefs(MemOp, MemOp + 1);
1215 CurDAG->RemoveDeadNode(N);
1218 void AArch64DAGToDAGISel::SelectPostLoad(
SDNode *N,
unsigned NumVecs,
1219 unsigned Opc,
unsigned SubRegIdx) {
1231 SDNode *Ld = CurDAG->getMachineNode(Opc, dl, ResTys, Ops);
1239 ReplaceUses(
SDValue(N, 0), SuperReg);
1241 for (
unsigned i = 0; i < NumVecs; ++i)
1243 CurDAG->getTargetExtractSubreg(SubRegIdx + i, dl, VT, SuperReg));
1247 CurDAG->RemoveDeadNode(N);
1250 void AArch64DAGToDAGISel::SelectStore(
SDNode *N,
unsigned NumVecs,
1258 SDValue RegSeq = Is128Bit ? createQTuple(Regs) : createDTuple(Regs);
1265 MemOp[0] = cast<MemIntrinsicSDNode>(
N)->getMemOperand();
1266 cast<MachineSDNode>(St)->setMemRefs(MemOp, MemOp + 1);
1271 void AArch64DAGToDAGISel::SelectPostStore(
SDNode *N,
unsigned NumVecs,
1281 SDValue RegSeq = Is128Bit ? createQTuple(Regs) : createDTuple(Regs);
1287 SDNode *St = CurDAG->getMachineNode(Opc, dl, ResTys, Ops);
1327 void AArch64DAGToDAGISel::SelectLoadLane(
SDNode *N,
unsigned NumVecs,
1340 SDValue RegSeq = createQTuple(Regs);
1345 cast<ConstantSDNode>(N->
getOperand(NumVecs + 2))->getZExtValue();
1347 SDValue Ops[] = {RegSeq, CurDAG->getTargetConstant(LaneNo, dl,
MVT::i64),
1349 SDNode *Ld = CurDAG->getMachineNode(Opc, dl, ResTys, Ops);
1352 EVT WideVT = RegSeq.getOperand(1)->getValueType(0);
1353 static const unsigned QSubs[] = { AArch64::qsub0, AArch64::qsub1,
1354 AArch64::qsub2, AArch64::qsub3 };
1355 for (
unsigned i = 0; i < NumVecs; ++i) {
1356 SDValue NV = CurDAG->getTargetExtractSubreg(QSubs[i], dl, WideVT, SuperReg);
1359 ReplaceUses(
SDValue(N, i), NV);
1363 CurDAG->RemoveDeadNode(N);
1366 void AArch64DAGToDAGISel::SelectPostLoadLane(
SDNode *N,
unsigned NumVecs,
1379 SDValue RegSeq = createQTuple(Regs);
1385 cast<ConstantSDNode>(N->
getOperand(NumVecs + 1))->getZExtValue();
1388 CurDAG->getTargetConstant(LaneNo, dl,
1393 SDNode *Ld = CurDAG->getMachineNode(Opc, dl, ResTys, Ops);
1404 EVT WideVT = RegSeq.getOperand(1)->getValueType(0);
1405 static const unsigned QSubs[] = { AArch64::qsub0, AArch64::qsub1,
1406 AArch64::qsub2, AArch64::qsub3 };
1407 for (
unsigned i = 0; i < NumVecs; ++i) {
1408 SDValue NV = CurDAG->getTargetExtractSubreg(QSubs[i], dl, WideVT,
1412 ReplaceUses(
SDValue(N, i), NV);
1418 CurDAG->RemoveDeadNode(N);
1421 void AArch64DAGToDAGISel::SelectStoreLane(
SDNode *N,
unsigned NumVecs,
1434 SDValue RegSeq = createQTuple(Regs);
1437 cast<ConstantSDNode>(N->
getOperand(NumVecs + 2))->getZExtValue();
1439 SDValue Ops[] = {RegSeq, CurDAG->getTargetConstant(LaneNo, dl,
MVT::i64),
1445 MemOp[0] = cast<MemIntrinsicSDNode>(
N)->getMemOperand();
1446 cast<MachineSDNode>(St)->setMemRefs(MemOp, MemOp + 1);
1451 void AArch64DAGToDAGISel::SelectPostStoreLane(
SDNode *N,
unsigned NumVecs,
1464 SDValue RegSeq = createQTuple(Regs);
1470 cast<ConstantSDNode>(N->
getOperand(NumVecs + 1))->getZExtValue();
1472 SDValue Ops[] = {RegSeq, CurDAG->getTargetConstant(LaneNo, dl,
MVT::i64),
1476 SDNode *St = CurDAG->getMachineNode(Opc, dl, ResTys, Ops);
1480 MemOp[0] = cast<MemIntrinsicSDNode>(
N)->getMemOperand();
1481 cast<MachineSDNode>(St)->setMemRefs(MemOp, MemOp + 1);
1488 unsigned &LSB,
unsigned &MSB,
1489 unsigned NumberOfIgnoredLowBits,
1490 bool BiggerPattern) {
1492 "N must be a AND operation to call this function");
1500 "Type checking must have been done before calling this function");
1510 uint64_t AndImm = 0;
1518 AndImm |= maskTrailingOnes<uint64_t>(NumberOfIgnoredLowBits);
1521 if (AndImm & (AndImm + 1))
1524 bool ClampMSB =
false;
1525 uint64_t SrlImm = 0;
1544 }
else if (BiggerPattern) {
1556 if (!BiggerPattern && (SrlImm <= 0 || SrlImm >= VT.getSizeInBits())) {
1559 <<
": Found large shift immediate, this should not happen\n"));
1564 MSB = SrlImm + (VT ==
MVT::i32 ? countTrailingOnes<uint32_t>(AndImm)
1565 : countTrailingOnes<uint64_t>(AndImm)) -
1572 MSB = MSB > 31 ? 31 : MSB;
1574 Opc = VT ==
MVT::i32 ? AArch64::UBFMWri : AArch64::UBFMXri;
1579 SDValue &Opd0,
unsigned &Immr,
1586 "Type checking must have been done before calling this function");
1592 BitWidth = VT.getSizeInBits();
1600 unsigned Width = cast<VTSDNode>(N->
getOperand(1))->getVT().getSizeInBits();
1601 if (ShiftImm + Width > BitWidth)
1604 Opc = (VT ==
MVT::i32) ? AArch64::SBFMWri : AArch64::SBFMXri;
1607 Imms = ShiftImm + Width - 1;
1631 uint64_t AndMask = 0;
1637 uint64_t SrlImm = 0;
1643 if (BitWide &&
isMask_64(AndMask >> SrlImm)) {
1645 Opc = AArch64::UBFMWri;
1647 Opc = AArch64::UBFMXri;
1650 MSB = BitWide + SrlImm - 1;
1658 unsigned &Immr,
unsigned &Imms,
1659 bool BiggerPattern) {
1661 "N must be a SHR/SRA operation to call this function");
1669 "Type checking must have been done before calling this function");
1676 uint64_t ShlImm = 0;
1677 uint64_t TruncBits = 0;
1690 }
else if (BiggerPattern) {
1703 <<
": Found large shift immediate, this should not happen\n"));
1707 uint64_t SrlImm = 0;
1712 "bad amount in shift node!");
1713 int immr = SrlImm - ShlImm;
1724 bool AArch64DAGToDAGISel::tryBitfieldExtractOpFromSExt(
SDNode *N) {
1740 unsigned Immr = ShiftImm;
1742 SDValue Ops[] = {Opd0, CurDAG->getTargetConstant(Immr, dl, VT),
1743 CurDAG->getTargetConstant(Imms, dl, VT)};
1744 CurDAG->SelectNodeTo(N, AArch64::SBFMXri, VT, Ops);
1749 SDValue &Opd0,
unsigned &Immr,
unsigned &Imms,
1750 unsigned NumberOfIgnoredLowBits = 0,
1751 bool BiggerPattern =
false) {
1762 NumberOfIgnoredLowBits, BiggerPattern);
1775 case AArch64::SBFMWri:
1776 case AArch64::UBFMWri:
1777 case AArch64::SBFMXri:
1778 case AArch64::UBFMXri:
1789 bool AArch64DAGToDAGISel::tryBitfieldExtractOp(
SDNode *N) {
1790 unsigned Opc, Immr, Imms;
1800 if ((Opc == AArch64::SBFMXri || Opc == AArch64::UBFMXri) && VT ==
MVT::i32) {
1801 SDValue Ops64[] = {Opd0, CurDAG->getTargetConstant(Immr, dl,
MVT::i64),
1802 CurDAG->getTargetConstant(Imms, dl,
MVT::i64)};
1806 ReplaceNode(N, CurDAG->getMachineNode(TargetOpcode::EXTRACT_SUBREG, dl,
1811 SDValue Ops[] = {Opd0, CurDAG->getTargetConstant(Immr, dl, VT),
1812 CurDAG->getTargetConstant(Imms, dl, VT)};
1813 CurDAG->SelectNodeTo(N, Opc, VT, Ops);
1822 unsigned NumberOfIgnoredHighBits,
EVT VT) {
1824 "i32 or i64 mask type expected!");
1825 unsigned BitWidth = VT.
getSizeInBits() - NumberOfIgnoredHighBits;
1827 APInt SignificantDstMask =
APInt(BitWidth, DstMask);
1828 APInt SignificantBitsToBeInserted = BitsToBeInserted.
zextOrTrunc(BitWidth);
1830 return (SignificantDstMask & SignificantBitsToBeInserted) == 0 &&
1831 (SignificantDstMask | SignificantBitsToBeInserted).isAllOnesValue();
1856 UsefulBits &=
APInt(UsefulBits.getBitWidth(), Imm);
1861 uint64_t Imm, uint64_t MSB,
1864 APInt OpUsefulBits(UsefulBits);
1868 OpUsefulBits <<= MSB - Imm + 1;
1873 OpUsefulBits <<= Imm;
1875 OpUsefulBits <<= MSB + 1;
1878 OpUsefulBits <<= OpUsefulBits.
getBitWidth() - Imm;
1884 UsefulBits &= OpUsefulBits;
1899 uint64_t ShiftTypeAndValue =
1932 APInt OpUsefulBits(UsefulBits);
1943 uint64_t Width = MSB - Imm + 1;
1946 OpUsefulBits <<= Width;
1951 Mask = ResultUsefulBits & OpUsefulBits;
1957 Mask |= (ResultUsefulBits & ~OpUsefulBits);
1960 uint64_t Width = MSB + 1;
1963 OpUsefulBits <<= Width;
1965 OpUsefulBits <<= LSB;
1969 Mask = ResultUsefulBits & OpUsefulBits;
1970 Mask.lshrInPlace(LSB);
1974 Mask |= (ResultUsefulBits & ~OpUsefulBits);
1991 case AArch64::ANDSWri:
1992 case AArch64::ANDSXri:
1993 case AArch64::ANDWri:
1994 case AArch64::ANDXri:
1998 case AArch64::UBFMWri:
1999 case AArch64::UBFMXri:
2002 case AArch64::ORRWrs:
2003 case AArch64::ORRXrs:
2008 case AArch64::BFMWri:
2009 case AArch64::BFMXri:
2012 case AArch64::STRBBui:
2013 case AArch64::STURBBi:
2019 case AArch64::STRHHui:
2020 case AArch64::STURHHi:
2035 UsefulBits =
APInt(Bitwidth, 0);
2044 UsersUsefulBits |= UsefulBitsForUse;
2049 UsefulBits &= UsersUsefulBits;
2062 unsigned UBFMOpc = BitWidth == 32 ? AArch64::UBFMWri : AArch64::UBFMXri;
2065 if (ShlAmount > 0) {
2068 UBFMOpc, dl, VT, Op,
2073 assert(ShlAmount < 0 &&
"expected right shift");
2074 int ShrAmount = -ShlAmount;
2087 SDValue &Src,
int &ShiftAmount,
2092 assert(BitWidth == 32 || BitWidth == 64);
2099 uint64_t NonZeroBits = (~Known.
Zero).getZExtValue();
2130 if (ShlImm - ShiftAmount != 0 && !BiggerPattern)
2179 uint64_t NotKnownZero = (~Known.
Zero).getZExtValue();
2186 if ((OrImm & NotKnownZero) != 0) {
2197 unsigned ImmR = (BitWidth - LSB) % BitWidth;
2198 unsigned ImmS = Width - 1;
2204 bool IsBFI = LSB != 0;
2205 uint64_t BFIImm = OrImm >> LSB;
2209 unsigned OrChunks = 0, BFIChunks = 0;
2210 for (
unsigned Shift = 0; Shift < BitWidth; Shift += 16) {
2211 if (((OrImm >> Shift) & 0xFFFF) != 0)
2213 if (((BFIImm >> Shift) & 0xFFFF) != 0)
2216 if (BFIChunks > OrChunks)
2222 unsigned MOVIOpc = VT ==
MVT::i32 ? AArch64::MOVi32imm : AArch64::MOVi64imm;
2230 unsigned Opc = (VT ==
MVT::i32) ? AArch64::BFMWri : AArch64::BFMXri;
2269 for (
int I = 0;
I < 4; ++
I) {
2272 unsigned ImmR, ImmS;
2273 bool BiggerPattern =
I / 2;
2282 NumberOfIgnoredLowBits, BiggerPattern)) {
2285 if ((BFXOpc != AArch64::UBFMXri && VT ==
MVT::i64) ||
2286 (BFXOpc != AArch64::UBFMWri && VT ==
MVT::i32))
2291 Width = ImmS - ImmR + 1;
2302 Src, DstLSB, Width)) {
2303 ImmR = (BitWidth - DstLSB) % BitWidth;
2321 APInt BitsToBeInserted =
2324 if ((BitsToBeInserted & ~Known.
Zero) != 0)
2342 unsigned Opc = (VT ==
MVT::i32) ? AArch64::BFMWri : AArch64::BFMXri;
2350 uint64_t Mask0Imm, Mask1Imm;
2356 APInt(BitWidth, Mask0Imm) == ~
APInt(BitWidth, Mask1Imm) &&
2375 unsigned ShiftOpc = (VT ==
MVT::i32) ? AArch64::UBFMWri : AArch64::UBFMXri;
2381 unsigned ImmR = (BitWidth - LSB) % BitWidth;
2382 unsigned ImmS = Width - 1;
2388 unsigned Opc = (VT ==
MVT::i32) ? AArch64::BFMWri : AArch64::BFMXri;
2396 bool AArch64DAGToDAGISel::tryBitfieldInsertOp(
SDNode *N) {
2405 CurDAG->SelectNodeTo(N, TargetOpcode::IMPLICIT_DEF, N->
getValueType(0));
2418 bool AArch64DAGToDAGISel::tryBitfieldInsertInZeroOp(
SDNode *N) {
2429 Op0, DstLSB, Width))
2435 unsigned ImmS = Width - 1;
2438 SDValue Ops[] = {Op0, CurDAG->getTargetConstant(ImmR, DL, VT),
2439 CurDAG->getTargetConstant(ImmS, DL, VT)};
2440 unsigned Opc = (VT ==
MVT::i32) ? AArch64::UBFMWri : AArch64::UBFMXri;
2441 CurDAG->SelectNodeTo(N, Opc, VT, Ops);
2447 bool AArch64DAGToDAGISel::tryShiftAmountMod(
SDNode *N) {
2453 Opc = (VT ==
MVT::i32) ? AArch64::RORVWr : AArch64::RORVXr;
2456 Opc = (VT ==
MVT::i32) ? AArch64::LSLVWr : AArch64::LSLVXr;
2459 Opc = (VT ==
MVT::i32) ? AArch64::LSRVWr : AArch64::LSRVXr;
2462 Opc = (VT ==
MVT::i32) ? AArch64::ASRVWr : AArch64::ASRVXr;
2501 (Add0Imm % Size == 0)) {
2506 NegOpc = AArch64::SUBWrr;
2507 ZeroReg = AArch64::WZR;
2510 NegOpc = AArch64::SUBXrr;
2511 ZeroReg = AArch64::XZR;
2514 CurDAG->getCopyFromReg(CurDAG->getEntryNode(), DL, ZeroReg, SubVT);
2516 CurDAG->getMachineNode(NegOpc, DL, SubVT, Zero, Add1);
2517 NewShiftAmt =
SDValue(Neg, 0);
2540 AArch64::SUBREG_TO_REG, DL, VT,
2541 CurDAG->getTargetConstant(0, DL,
MVT::i64), NewShiftAmt,
SubReg);
2542 NewShiftAmt =
SDValue(Ext, 0);
2546 CurDAG->SelectNodeTo(N, Opc, VT, Ops);
2551 AArch64DAGToDAGISel::SelectCVTFixedPosOperand(
SDValue N,
SDValue &FixedPos,
2552 unsigned RegWidth) {
2555 FVal = CN->getValueAPF();
2556 else if (
LoadSDNode *LN = dyn_cast<LoadSDNode>(N)) {
2559 !isa<ConstantPoolSDNode>(LN->getOperand(1)->getOperand(1)))
2564 FVal = cast<ConstantFP>(CN->
getConstVal())->getValueAPF();
2583 if (!IsExact || !IntVal.
isPowerOf2())
return false;
2584 unsigned FBits = IntVal.
logBase2();
2588 if (FBits == 0 || FBits > RegWidth)
return false;
2590 FixedPos = CurDAG->getTargetConstant(FBits,
SDLoc(N),
MVT::i32);
2599 RegString.
split(Fields,
':');
2601 if (Fields.
size() == 1)
2605 &&
"Invalid number of fields in read register string");
2608 bool AllIntFields =
true;
2612 AllIntFields &= !
Field.getAsInteger(10, IntField);
2613 Ops.push_back(IntField);
2617 "Unexpected non-integer value in special register string.");
2621 return (Ops[0] << 14) | (Ops[1] << 11) | (Ops[2] << 7) |
2622 (Ops[3] << 3) | (Ops[4]);
2629 bool AArch64DAGToDAGISel::tryReadRegister(
SDNode *N) {
2636 ReplaceNode(N, CurDAG->getMachineNode(
2638 CurDAG->getTargetConstant(Reg, DL,
MVT::i32),
2646 if (TheReg && TheReg->Readable &&
2647 TheReg->haveFeatures(Subtarget->getFeatureBits()))
2653 ReplaceNode(N, CurDAG->getMachineNode(
2655 CurDAG->getTargetConstant(Reg, DL,
MVT::i32),
2667 bool AArch64DAGToDAGISel::tryWriteRegister(
SDNode *N) {
2675 N, CurDAG->getMachineNode(AArch64::MSR, DL,
MVT::Other,
2676 CurDAG->getTargetConstant(Reg, DL,
MVT::i32),
2686 auto PMapper = AArch64PState::lookupPStateByName(RegString->getString());
2689 &&
"Expected a constant integer expression.");
2690 unsigned Reg = PMapper->Encoding;
2691 uint64_t Immed = cast<ConstantSDNode>(N->
getOperand(2))->getZExtValue();
2693 if (Reg == AArch64PState::PAN || Reg == AArch64PState::UAO) {
2694 assert(Immed < 2 &&
"Bad imm");
2695 State = AArch64::MSRpstateImm1;
2697 assert(Immed < 16 &&
"Bad imm");
2698 State = AArch64::MSRpstateImm4;
2700 ReplaceNode(N, CurDAG->getMachineNode(
2702 CurDAG->getTargetConstant(Reg, DL,
MVT::i32),
2703 CurDAG->getTargetConstant(Immed, DL,
MVT::i16),
2712 if (TheReg && TheReg->Writeable &&
2713 TheReg->haveFeatures(Subtarget->getFeatureBits()))
2718 ReplaceNode(N, CurDAG->getMachineNode(
2720 CurDAG->getTargetConstant(Reg, DL,
MVT::i32),
2729 bool AArch64DAGToDAGISel::SelectCMP_SWAP(
SDNode *N) {
2731 EVT MemTy = cast<MemSDNode>(
N)->getMemoryVT();
2734 if (Subtarget->hasLSE())
return false;
2737 Opcode = AArch64::CMP_SWAP_8;
2739 Opcode = AArch64::CMP_SWAP_16;
2741 Opcode = AArch64::CMP_SWAP_32;
2743 Opcode = AArch64::CMP_SWAP_64;
2750 SDNode *CmpSwap = CurDAG->getMachineNode(
2755 MemOp[0] = cast<MemSDNode>(
N)->getMemOperand();
2756 cast<MachineSDNode>(CmpSwap)->setMemRefs(MemOp, MemOp + 1);
2760 CurDAG->RemoveDeadNode(N);
2781 if (SelectCMP_SWAP(Node))
2786 if (tryReadRegister(Node))
2791 if (tryWriteRegister(Node))
2796 if (tryMLAV64LaneV128(Node))
2803 if (tryIndexedLoad(Node))
2812 if (tryBitfieldExtractOp(Node))
2814 if (tryBitfieldInsertInZeroOp(Node))
2819 if (tryShiftAmountMod(Node))
2824 if (tryBitfieldExtractOpFromSExt(Node))
2829 if (tryBitfieldInsertOp(Node))
2857 SubReg = AArch64::dsub;
2860 SubReg = AArch64::ssub;
2863 SubReg = AArch64::hsub;
2868 SDValue Extract = CurDAG->getTargetExtractSubreg(SubReg,
SDLoc(Node), VT,
2873 ReplaceNode(Node, Extract.
getNode());
2882 SDValue New = CurDAG->getCopyFromReg(
2883 CurDAG->getEntryNode(),
SDLoc(Node), AArch64::WZR,
MVT::i32);
2884 ReplaceNode(Node, New.
getNode());
2887 SDValue New = CurDAG->getCopyFromReg(
2888 CurDAG->getEntryNode(),
SDLoc(Node), AArch64::XZR,
MVT::i64);
2889 ReplaceNode(Node, New.
getNode());
2898 int FI = cast<FrameIndexSDNode>(Node)->getIndex();
2901 SDValue TFI = CurDAG->getTargetFrameIndex(
2905 CurDAG->getTargetConstant(Shifter, DL,
MVT::i32) };
2906 CurDAG->SelectNodeTo(Node, AArch64::ADDXri,
MVT::i64, Ops);
2910 unsigned IntNo = cast<ConstantSDNode>(Node->
getOperand(1))->getZExtValue();
2914 case Intrinsic::aarch64_ldaxp:
2915 case Intrinsic::aarch64_ldxp: {
2917 IntNo == Intrinsic::aarch64_ldaxp ? AArch64::LDAXPX : AArch64::LDXPX;
2927 MemOp[0] = cast<MemIntrinsicSDNode>(Node)->getMemOperand();
2928 cast<MachineSDNode>(Ld)->setMemRefs(MemOp, MemOp + 1);
2929 ReplaceNode(Node, Ld);
2932 case Intrinsic::aarch64_stlxp:
2933 case Intrinsic::aarch64_stxp: {
2935 IntNo == Intrinsic::aarch64_stlxp ? AArch64::STLXPX : AArch64::STXPX;
2943 SDValue Ops[] = {ValLo, ValHi, MemAddr, Chain};
2948 MemOp[0] = cast<MemIntrinsicSDNode>(Node)->getMemOperand();
2949 cast<MachineSDNode>(St)->setMemRefs(MemOp, MemOp + 1);
2951 ReplaceNode(Node, St);
2954 case Intrinsic::aarch64_neon_ld1x2:
2956 SelectLoad(Node, 2, AArch64::LD1Twov8b, AArch64::dsub0);
2959 SelectLoad(Node, 2, AArch64::LD1Twov16b, AArch64::qsub0);
2962 SelectLoad(Node, 2, AArch64::LD1Twov4h, AArch64::dsub0);
2965 SelectLoad(Node, 2, AArch64::LD1Twov8h, AArch64::qsub0);
2968 SelectLoad(Node, 2, AArch64::LD1Twov2s, AArch64::dsub0);
2971 SelectLoad(Node, 2, AArch64::LD1Twov4s, AArch64::qsub0);
2974 SelectLoad(Node, 2, AArch64::LD1Twov1d, AArch64::dsub0);
2977 SelectLoad(Node, 2, AArch64::LD1Twov2d, AArch64::qsub0);
2981 case Intrinsic::aarch64_neon_ld1x3:
2983 SelectLoad(Node, 3, AArch64::LD1Threev8b, AArch64::dsub0);
2986 SelectLoad(Node, 3, AArch64::LD1Threev16b, AArch64::qsub0);
2989 SelectLoad(Node, 3, AArch64::LD1Threev4h, AArch64::dsub0);
2992 SelectLoad(Node, 3, AArch64::LD1Threev8h, AArch64::qsub0);
2995 SelectLoad(Node, 3, AArch64::LD1Threev2s, AArch64::dsub0);
2998 SelectLoad(Node, 3, AArch64::LD1Threev4s, AArch64::qsub0);
3001 SelectLoad(Node, 3, AArch64::LD1Threev1d, AArch64::dsub0);
3004 SelectLoad(Node, 3, AArch64::LD1Threev2d, AArch64::qsub0);
3008 case Intrinsic::aarch64_neon_ld1x4:
3010 SelectLoad(Node, 4, AArch64::LD1Fourv8b, AArch64::dsub0);
3013 SelectLoad(Node, 4, AArch64::LD1Fourv16b, AArch64::qsub0);
3016 SelectLoad(Node, 4, AArch64::LD1Fourv4h, AArch64::dsub0);
3019 SelectLoad(Node, 4, AArch64::LD1Fourv8h, AArch64::qsub0);
3022 SelectLoad(Node, 4, AArch64::LD1Fourv2s, AArch64::dsub0);
3025 SelectLoad(Node, 4, AArch64::LD1Fourv4s, AArch64::qsub0);
3028 SelectLoad(Node, 4, AArch64::LD1Fourv1d, AArch64::dsub0);
3031 SelectLoad(Node, 4, AArch64::LD1Fourv2d, AArch64::qsub0);
3035 case Intrinsic::aarch64_neon_ld2:
3037 SelectLoad(Node, 2, AArch64::LD2Twov8b, AArch64::dsub0);
3040 SelectLoad(Node, 2, AArch64::LD2Twov16b, AArch64::qsub0);
3043 SelectLoad(Node, 2, AArch64::LD2Twov4h, AArch64::dsub0);
3046 SelectLoad(Node, 2, AArch64::LD2Twov8h, AArch64::qsub0);
3049 SelectLoad(Node, 2, AArch64::LD2Twov2s, AArch64::dsub0);
3052 SelectLoad(Node, 2, AArch64::LD2Twov4s, AArch64::qsub0);
3055 SelectLoad(Node, 2, AArch64::LD1Twov1d, AArch64::dsub0);
3058 SelectLoad(Node, 2, AArch64::LD2Twov2d, AArch64::qsub0);
3062 case Intrinsic::aarch64_neon_ld3:
3064 SelectLoad(Node, 3, AArch64::LD3Threev8b, AArch64::dsub0);
3067 SelectLoad(Node, 3, AArch64::LD3Threev16b, AArch64::qsub0);
3070 SelectLoad(Node, 3, AArch64::LD3Threev4h, AArch64::dsub0);
3073 SelectLoad(Node, 3, AArch64::LD3Threev8h, AArch64::qsub0);
3076 SelectLoad(Node, 3, AArch64::LD3Threev2s, AArch64::dsub0);
3079 SelectLoad(Node, 3, AArch64::LD3Threev4s, AArch64::qsub0);
3082 SelectLoad(Node, 3, AArch64::LD1Threev1d, AArch64::dsub0);
3085 SelectLoad(Node, 3, AArch64::LD3Threev2d, AArch64::qsub0);
3089 case Intrinsic::aarch64_neon_ld4:
3091 SelectLoad(Node, 4, AArch64::LD4Fourv8b, AArch64::dsub0);
3094 SelectLoad(Node, 4, AArch64::LD4Fourv16b, AArch64::qsub0);
3097 SelectLoad(Node, 4, AArch64::LD4Fourv4h, AArch64::dsub0);
3100 SelectLoad(Node, 4, AArch64::LD4Fourv8h, AArch64::qsub0);
3103 SelectLoad(Node, 4, AArch64::LD4Fourv2s, AArch64::dsub0);
3106 SelectLoad(Node, 4, AArch64::LD4Fourv4s, AArch64::qsub0);
3109 SelectLoad(Node, 4, AArch64::LD1Fourv1d, AArch64::dsub0);
3112 SelectLoad(Node, 4, AArch64::LD4Fourv2d, AArch64::qsub0);
3116 case Intrinsic::aarch64_neon_ld2r:
3118 SelectLoad(Node, 2, AArch64::LD2Rv8b, AArch64::dsub0);
3121 SelectLoad(Node, 2, AArch64::LD2Rv16b, AArch64::qsub0);
3124 SelectLoad(Node, 2, AArch64::LD2Rv4h, AArch64::dsub0);
3127 SelectLoad(Node, 2, AArch64::LD2Rv8h, AArch64::qsub0);
3130 SelectLoad(Node, 2, AArch64::LD2Rv2s, AArch64::dsub0);
3133 SelectLoad(Node, 2, AArch64::LD2Rv4s, AArch64::qsub0);
3136 SelectLoad(Node, 2, AArch64::LD2Rv1d, AArch64::dsub0);
3139 SelectLoad(Node, 2, AArch64::LD2Rv2d, AArch64::qsub0);
3143 case Intrinsic::aarch64_neon_ld3r:
3145 SelectLoad(Node, 3, AArch64::LD3Rv8b, AArch64::dsub0);
3148 SelectLoad(Node, 3, AArch64::LD3Rv16b, AArch64::qsub0);
3151 SelectLoad(Node, 3, AArch64::LD3Rv4h, AArch64::dsub0);
3154 SelectLoad(Node, 3, AArch64::LD3Rv8h, AArch64::qsub0);
3157 SelectLoad(Node, 3, AArch64::LD3Rv2s, AArch64::dsub0);
3160 SelectLoad(Node, 3, AArch64::LD3Rv4s, AArch64::qsub0);
3163 SelectLoad(Node, 3, AArch64::LD3Rv1d, AArch64::dsub0);
3166 SelectLoad(Node, 3, AArch64::LD3Rv2d, AArch64::qsub0);
3170 case Intrinsic::aarch64_neon_ld4r:
3172 SelectLoad(Node, 4, AArch64::LD4Rv8b, AArch64::dsub0);
3175 SelectLoad(Node, 4, AArch64::LD4Rv16b, AArch64::qsub0);
3178 SelectLoad(Node, 4, AArch64::LD4Rv4h, AArch64::dsub0);
3181 SelectLoad(Node, 4, AArch64::LD4Rv8h, AArch64::qsub0);
3184 SelectLoad(Node, 4, AArch64::LD4Rv2s, AArch64::dsub0);
3187 SelectLoad(Node, 4, AArch64::LD4Rv4s, AArch64::qsub0);
3190 SelectLoad(Node, 4, AArch64::LD4Rv1d, AArch64::dsub0);
3193 SelectLoad(Node, 4, AArch64::LD4Rv2d, AArch64::qsub0);
3197 case Intrinsic::aarch64_neon_ld2lane:
3199 SelectLoadLane(Node, 2, AArch64::LD2i8);
3203 SelectLoadLane(Node, 2, AArch64::LD2i16);
3207 SelectLoadLane(Node, 2, AArch64::LD2i32);
3211 SelectLoadLane(Node, 2, AArch64::LD2i64);
3215 case Intrinsic::aarch64_neon_ld3lane:
3217 SelectLoadLane(Node, 3, AArch64::LD3i8);
3221 SelectLoadLane(Node, 3, AArch64::LD3i16);
3225 SelectLoadLane(Node, 3, AArch64::LD3i32);
3229 SelectLoadLane(Node, 3, AArch64::LD3i64);
3233 case Intrinsic::aarch64_neon_ld4lane:
3235 SelectLoadLane(Node, 4, AArch64::LD4i8);
3239 SelectLoadLane(Node, 4, AArch64::LD4i16);
3243 SelectLoadLane(Node, 4, AArch64::LD4i32);
3247 SelectLoadLane(Node, 4, AArch64::LD4i64);
3254 unsigned IntNo = cast<ConstantSDNode>(Node->
getOperand(0))->getZExtValue();
3258 case Intrinsic::aarch64_neon_tbl2:
3259 SelectTable(Node, 2,
3260 VT ==
MVT::v8i8 ? AArch64::TBLv8i8Two : AArch64::TBLv16i8Two,
3263 case Intrinsic::aarch64_neon_tbl3:
3264 SelectTable(Node, 3, VT ==
MVT::v8i8 ? AArch64::TBLv8i8Three
3265 : AArch64::TBLv16i8Three,
3268 case Intrinsic::aarch64_neon_tbl4:
3269 SelectTable(Node, 4, VT ==
MVT::v8i8 ? AArch64::TBLv8i8Four
3270 : AArch64::TBLv16i8Four,
3273 case Intrinsic::aarch64_neon_tbx2:
3274 SelectTable(Node, 2,
3275 VT ==
MVT::v8i8 ? AArch64::TBXv8i8Two : AArch64::TBXv16i8Two,
3278 case Intrinsic::aarch64_neon_tbx3:
3279 SelectTable(Node, 3, VT ==
MVT::v8i8 ? AArch64::TBXv8i8Three
3280 : AArch64::TBXv16i8Three,
3283 case Intrinsic::aarch64_neon_tbx4:
3284 SelectTable(Node, 4, VT ==
MVT::v8i8 ? AArch64::TBXv8i8Four
3285 : AArch64::TBXv16i8Four,
3288 case Intrinsic::aarch64_neon_smull:
3289 case Intrinsic::aarch64_neon_umull:
3290 if (tryMULLV64LaneV128(IntNo, Node))
3297 unsigned IntNo = cast<ConstantSDNode>(Node->
getOperand(1))->getZExtValue();
3303 case Intrinsic::aarch64_neon_st1x2: {
3305 SelectStore(Node, 2, AArch64::ST1Twov8b);
3308 SelectStore(Node, 2, AArch64::ST1Twov16b);
3311 SelectStore(Node, 2, AArch64::ST1Twov4h);
3314 SelectStore(Node, 2, AArch64::ST1Twov8h);
3317 SelectStore(Node, 2, AArch64::ST1Twov2s);
3320 SelectStore(Node, 2, AArch64::ST1Twov4s);
3323 SelectStore(Node, 2, AArch64::ST1Twov2d);
3326 SelectStore(Node, 2, AArch64::ST1Twov1d);
3331 case Intrinsic::aarch64_neon_st1x3: {
3333 SelectStore(Node, 3, AArch64::ST1Threev8b);
3336 SelectStore(Node, 3, AArch64::ST1Threev16b);
3339 SelectStore(Node, 3, AArch64::ST1Threev4h);
3342 SelectStore(Node, 3, AArch64::ST1Threev8h);
3345 SelectStore(Node, 3, AArch64::ST1Threev2s);
3348 SelectStore(Node, 3, AArch64::ST1Threev4s);
3351 SelectStore(Node, 3, AArch64::ST1Threev2d);
3354 SelectStore(Node, 3, AArch64::ST1Threev1d);
3359 case Intrinsic::aarch64_neon_st1x4: {
3361 SelectStore(Node, 4, AArch64::ST1Fourv8b);
3364 SelectStore(Node, 4, AArch64::ST1Fourv16b);
3367 SelectStore(Node, 4, AArch64::ST1Fourv4h);
3370 SelectStore(Node, 4, AArch64::ST1Fourv8h);
3373 SelectStore(Node, 4, AArch64::ST1Fourv2s);
3376 SelectStore(Node, 4, AArch64::ST1Fourv4s);
3379 SelectStore(Node, 4, AArch64::ST1Fourv2d);
3382 SelectStore(Node, 4, AArch64::ST1Fourv1d);
3387 case Intrinsic::aarch64_neon_st2: {
3389 SelectStore(Node, 2, AArch64::ST2Twov8b);
3392 SelectStore(Node, 2, AArch64::ST2Twov16b);
3395 SelectStore(Node, 2, AArch64::ST2Twov4h);
3398 SelectStore(Node, 2, AArch64::ST2Twov8h);
3401 SelectStore(Node, 2, AArch64::ST2Twov2s);
3404 SelectStore(Node, 2, AArch64::ST2Twov4s);
3407 SelectStore(Node, 2, AArch64::ST2Twov2d);
3410 SelectStore(Node, 2, AArch64::ST1Twov1d);
3415 case Intrinsic::aarch64_neon_st3: {
3417 SelectStore(Node, 3, AArch64::ST3Threev8b);
3420 SelectStore(Node, 3, AArch64::ST3Threev16b);
3423 SelectStore(Node, 3, AArch64::ST3Threev4h);
3426 SelectStore(Node, 3, AArch64::ST3Threev8h);
3429 SelectStore(Node, 3, AArch64::ST3Threev2s);
3432 SelectStore(Node, 3, AArch64::ST3Threev4s);
3435 SelectStore(Node, 3, AArch64::ST3Threev2d);
3438 SelectStore(Node, 3, AArch64::ST1Threev1d);
3443 case Intrinsic::aarch64_neon_st4: {
3445 SelectStore(Node, 4, AArch64::ST4Fourv8b);
3448 SelectStore(Node, 4, AArch64::ST4Fourv16b);
3451 SelectStore(Node, 4, AArch64::ST4Fourv4h);
3454 SelectStore(Node, 4, AArch64::ST4Fourv8h);
3457 SelectStore(Node, 4, AArch64::ST4Fourv2s);
3460 SelectStore(Node, 4, AArch64::ST4Fourv4s);
3463 SelectStore(Node, 4, AArch64::ST4Fourv2d);
3466 SelectStore(Node, 4, AArch64::ST1Fourv1d);
3471 case Intrinsic::aarch64_neon_st2lane: {
3473 SelectStoreLane(Node, 2, AArch64::ST2i8);
3477 SelectStoreLane(Node, 2, AArch64::ST2i16);
3481 SelectStoreLane(Node, 2, AArch64::ST2i32);
3485 SelectStoreLane(Node, 2, AArch64::ST2i64);
3490 case Intrinsic::aarch64_neon_st3lane: {
3492 SelectStoreLane(Node, 3, AArch64::ST3i8);
3496 SelectStoreLane(Node, 3, AArch64::ST3i16);
3500 SelectStoreLane(Node, 3, AArch64::ST3i32);
3504 SelectStoreLane(Node, 3, AArch64::ST3i64);
3509 case Intrinsic::aarch64_neon_st4lane: {
3511 SelectStoreLane(Node, 4, AArch64::ST4i8);
3515 SelectStoreLane(Node, 4, AArch64::ST4i16);
3519 SelectStoreLane(Node, 4, AArch64::ST4i32);
3523 SelectStoreLane(Node, 4, AArch64::ST4i64);
3533 SelectPostLoad(Node, 2, AArch64::LD2Twov8b_POST, AArch64::dsub0);
3536 SelectPostLoad(Node, 2, AArch64::LD2Twov16b_POST, AArch64::qsub0);
3539 SelectPostLoad(Node, 2, AArch64::LD2Twov4h_POST, AArch64::dsub0);
3542 SelectPostLoad(Node, 2, AArch64::LD2Twov8h_POST, AArch64::qsub0);
3545 SelectPostLoad(Node, 2, AArch64::LD2Twov2s_POST, AArch64::dsub0);
3548 SelectPostLoad(Node, 2, AArch64::LD2Twov4s_POST, AArch64::qsub0);
3551 SelectPostLoad(Node, 2, AArch64::LD1Twov1d_POST, AArch64::dsub0);
3554 SelectPostLoad(Node, 2, AArch64::LD2Twov2d_POST, AArch64::qsub0);
3561 SelectPostLoad(Node, 3, AArch64::LD3Threev8b_POST, AArch64::dsub0);
3564 SelectPostLoad(Node, 3, AArch64::LD3Threev16b_POST, AArch64::qsub0);
3567 SelectPostLoad(Node, 3, AArch64::LD3Threev4h_POST, AArch64::dsub0);
3570 SelectPostLoad(Node, 3, AArch64::LD3Threev8h_POST, AArch64::qsub0);
3573 SelectPostLoad(Node, 3, AArch64::LD3Threev2s_POST, AArch64::dsub0);
3576 SelectPostLoad(Node, 3, AArch64::LD3Threev4s_POST, AArch64::qsub0);
3579 SelectPostLoad(Node, 3, AArch64::LD1Threev1d_POST, AArch64::dsub0);
3582 SelectPostLoad(Node, 3, AArch64::LD3Threev2d_POST, AArch64::qsub0);
3589 SelectPostLoad(Node, 4, AArch64::LD4Fourv8b_POST, AArch64::dsub0);
3592 SelectPostLoad(Node, 4, AArch64::LD4Fourv16b_POST, AArch64::qsub0);
3595 SelectPostLoad(Node, 4, AArch64::LD4Fourv4h_POST, AArch64::dsub0);
3598 SelectPostLoad(Node, 4, AArch64::LD4Fourv8h_POST, AArch64::qsub0);
3601 SelectPostLoad(Node, 4, AArch64::LD4Fourv2s_POST, AArch64::dsub0);
3604 SelectPostLoad(Node, 4, AArch64::LD4Fourv4s_POST, AArch64::qsub0);
3607 SelectPostLoad(Node, 4, AArch64::LD1Fourv1d_POST, AArch64::dsub0);
3610 SelectPostLoad(Node, 4, AArch64::LD4Fourv2d_POST, AArch64::qsub0);
3617 SelectPostLoad(Node, 2, AArch64::LD1Twov8b_POST, AArch64::dsub0);
3620 SelectPostLoad(Node, 2, AArch64::LD1Twov16b_POST, AArch64::qsub0);
3623 SelectPostLoad(Node, 2, AArch64::LD1Twov4h_POST, AArch64::dsub0);
3626 SelectPostLoad(Node, 2, AArch64::LD1Twov8h_POST, AArch64::qsub0);
3629 SelectPostLoad(Node, 2, AArch64::LD1Twov2s_POST, AArch64::dsub0);
3632 SelectPostLoad(Node, 2, AArch64::LD1Twov4s_POST, AArch64::qsub0);
3635 SelectPostLoad(Node, 2, AArch64::LD1Twov1d_POST, AArch64::dsub0);
3638 SelectPostLoad(Node, 2, AArch64::LD1Twov2d_POST, AArch64::qsub0);
3645 SelectPostLoad(Node, 3, AArch64::LD1Threev8b_POST, AArch64::dsub0);
3648 SelectPostLoad(Node, 3, AArch64::LD1Threev16b_POST, AArch64::qsub0);
3651 SelectPostLoad(Node, 3, AArch64::LD1Threev4h_POST, AArch64::dsub0);
3654 SelectPostLoad(Node, 3, AArch64::LD1Threev8h_POST, AArch64::qsub0);
3657 SelectPostLoad(Node, 3, AArch64::LD1Threev2s_POST, AArch64::dsub0);
3660 SelectPostLoad(Node, 3, AArch64::LD1Threev4s_POST, AArch64::qsub0);
3663 SelectPostLoad(Node, 3, AArch64::LD1Threev1d_POST, AArch64::dsub0);
3666 SelectPostLoad(Node, 3, AArch64::LD1Threev2d_POST, AArch64::qsub0);
3673 SelectPostLoad(Node, 4, AArch64::LD1Fourv8b_POST, AArch64::dsub0);
3676 SelectPostLoad(Node, 4, AArch64::LD1Fourv16b_POST, AArch64::qsub0);
3679 SelectPostLoad(Node, 4, AArch64::LD1Fourv4h_POST, AArch64::dsub0);
3682 SelectPostLoad(Node, 4, AArch64::LD1Fourv8h_POST, AArch64::qsub0);
3685 SelectPostLoad(Node, 4, AArch64::LD1Fourv2s_POST, AArch64::dsub0);
3688 SelectPostLoad(Node, 4, AArch64::LD1Fourv4s_POST, AArch64::qsub0);
3691 SelectPostLoad(Node, 4, AArch64::LD1Fourv1d_POST, AArch64::dsub0);
3694 SelectPostLoad(Node, 4, AArch64::LD1Fourv2d_POST, AArch64::qsub0);
3701 SelectPostLoad(Node, 1, AArch64::LD1Rv8b_POST, AArch64::dsub0);
3704 SelectPostLoad(Node, 1, AArch64::LD1Rv16b_POST, AArch64::qsub0);
3707 SelectPostLoad(Node, 1, AArch64::LD1Rv4h_POST, AArch64::dsub0);
3710 SelectPostLoad(Node, 1, AArch64::LD1Rv8h_POST, AArch64::qsub0);
3713 SelectPostLoad(Node, 1, AArch64::LD1Rv2s_POST, AArch64::dsub0);
3716 SelectPostLoad(Node, 1, AArch64::LD1Rv4s_POST, AArch64::qsub0);
3719 SelectPostLoad(Node, 1, AArch64::LD1Rv1d_POST, AArch64::dsub0);
3722 SelectPostLoad(Node, 1, AArch64::LD1Rv2d_POST, AArch64::qsub0);
3729 SelectPostLoad(Node, 2, AArch64::LD2Rv8b_POST, AArch64::dsub0);
3732 SelectPostLoad(Node, 2, AArch64::LD2Rv16b_POST, AArch64::qsub0);
3735 SelectPostLoad(Node, 2, AArch64::LD2Rv4h_POST, AArch64::dsub0);
3738 SelectPostLoad(Node, 2, AArch64::LD2Rv8h_POST, AArch64::qsub0);
3741 SelectPostLoad(Node, 2, AArch64::LD2Rv2s_POST, AArch64::dsub0);
3744 SelectPostLoad(Node, 2, AArch64::LD2Rv4s_POST, AArch64::qsub0);
3747 SelectPostLoad(Node, 2, AArch64::LD2Rv1d_POST, AArch64::dsub0);
3750 SelectPostLoad(Node, 2, AArch64::LD2Rv2d_POST, AArch64::qsub0);
3757 SelectPostLoad(Node, 3, AArch64::LD3Rv8b_POST, AArch64::dsub0);
3760 SelectPostLoad(Node, 3, AArch64::LD3Rv16b_POST, AArch64::qsub0);
3763 SelectPostLoad(Node, 3, AArch64::LD3Rv4h_POST, AArch64::dsub0);
3766 SelectPostLoad(Node, 3, AArch64::LD3Rv8h_POST, AArch64::qsub0);
3769 SelectPostLoad(Node, 3, AArch64::LD3Rv2s_POST, AArch64::dsub0);
3772 SelectPostLoad(Node, 3, AArch64::LD3Rv4s_POST, AArch64::qsub0);
3775 SelectPostLoad(Node, 3, AArch64::LD3Rv1d_POST, AArch64::dsub0);
3778 SelectPostLoad(Node, 3, AArch64::LD3Rv2d_POST, AArch64::qsub0);
3785 SelectPostLoad(Node, 4, AArch64::LD4Rv8b_POST, AArch64::dsub0);
3788 SelectPostLoad(Node, 4, AArch64::LD4Rv16b_POST, AArch64::qsub0);
3791 SelectPostLoad(Node, 4, AArch64::LD4Rv4h_POST, AArch64::dsub0);
3794 SelectPostLoad(Node, 4, AArch64::LD4Rv8h_POST, AArch64::qsub0);
3797 SelectPostLoad(Node, 4, AArch64::LD4Rv2s_POST, AArch64::dsub0);
3800 SelectPostLoad(Node, 4, AArch64::LD4Rv4s_POST, AArch64::qsub0);
3803 SelectPostLoad(Node, 4, AArch64::LD4Rv1d_POST, AArch64::dsub0);
3806 SelectPostLoad(Node, 4, AArch64::LD4Rv2d_POST, AArch64::qsub0);
3813 SelectPostLoadLane(Node, 1, AArch64::LD1i8_POST);
3817 SelectPostLoadLane(Node, 1, AArch64::LD1i16_POST);
3821 SelectPostLoadLane(Node, 1, AArch64::LD1i32_POST);
3825 SelectPostLoadLane(Node, 1, AArch64::LD1i64_POST);
3832 SelectPostLoadLane(Node, 2, AArch64::LD2i8_POST);
3836 SelectPostLoadLane(Node, 2, AArch64::LD2i16_POST);
3840 SelectPostLoadLane(Node, 2, AArch64::LD2i32_POST);
3844 SelectPostLoadLane(Node, 2, AArch64::LD2i64_POST);
3851 SelectPostLoadLane(Node, 3, AArch64::LD3i8_POST);
3855 SelectPostLoadLane(Node, 3, AArch64::LD3i16_POST);
3859 SelectPostLoadLane(Node, 3, AArch64::LD3i32_POST);
3863 SelectPostLoadLane(Node, 3, AArch64::LD3i64_POST);
3870 SelectPostLoadLane(Node, 4, AArch64::LD4i8_POST);
3874 SelectPostLoadLane(Node, 4, AArch64::LD4i16_POST);
3878 SelectPostLoadLane(Node, 4, AArch64::LD4i32_POST);
3882 SelectPostLoadLane(Node, 4, AArch64::LD4i64_POST);
3890 SelectPostStore(Node, 2, AArch64::ST2Twov8b_POST);
3893 SelectPostStore(Node, 2, AArch64::ST2Twov16b_POST);
3896 SelectPostStore(Node, 2, AArch64::ST2Twov4h_POST);
3899 SelectPostStore(Node, 2, AArch64::ST2Twov8h_POST);
3902 SelectPostStore(Node, 2, AArch64::ST2Twov2s_POST);
3905 SelectPostStore(Node, 2, AArch64::ST2Twov4s_POST);
3908 SelectPostStore(Node, 2, AArch64::ST2Twov2d_POST);
3911 SelectPostStore(Node, 2, AArch64::ST1Twov1d_POST);
3919 SelectPostStore(Node, 3, AArch64::ST3Threev8b_POST);
3922 SelectPostStore(Node, 3, AArch64::ST3Threev16b_POST);
3925 SelectPostStore(Node, 3, AArch64::ST3Threev4h_POST);
3928 SelectPostStore(Node, 3, AArch64::ST3Threev8h_POST);
3931 SelectPostStore(Node, 3, AArch64::ST3Threev2s_POST);
3934 SelectPostStore(Node, 3, AArch64::ST3Threev4s_POST);
3937 SelectPostStore(Node, 3, AArch64::ST3Threev2d_POST);
3940 SelectPostStore(Node, 3, AArch64::ST1Threev1d_POST);
3948 SelectPostStore(Node, 4, AArch64::ST4Fourv8b_POST);
3951 SelectPostStore(Node, 4, AArch64::ST4Fourv16b_POST);
3954 SelectPostStore(Node, 4, AArch64::ST4Fourv4h_POST);
3957 SelectPostStore(Node, 4, AArch64::ST4Fourv8h_POST);
3960 SelectPostStore(Node, 4, AArch64::ST4Fourv2s_POST);
3963 SelectPostStore(Node, 4, AArch64::ST4Fourv4s_POST);
3966 SelectPostStore(Node, 4, AArch64::ST4Fourv2d_POST);
3969 SelectPostStore(Node, 4, AArch64::ST1Fourv1d_POST);
3977 SelectPostStore(Node, 2, AArch64::ST1Twov8b_POST);
3980 SelectPostStore(Node, 2, AArch64::ST1Twov16b_POST);
3983 SelectPostStore(Node, 2, AArch64::ST1Twov4h_POST);
3986 SelectPostStore(Node, 2, AArch64::ST1Twov8h_POST);
3989 SelectPostStore(Node, 2, AArch64::ST1Twov2s_POST);
3992 SelectPostStore(Node, 2, AArch64::ST1Twov4s_POST);
3995 SelectPostStore(Node, 2, AArch64::ST1Twov1d_POST);
3998 SelectPostStore(Node, 2, AArch64::ST1Twov2d_POST);
4006 SelectPostStore(Node, 3, AArch64::ST1Threev8b_POST);
4009 SelectPostStore(Node, 3, AArch64::ST1Threev16b_POST);
4012 SelectPostStore(Node, 3, AArch64::ST1Threev4h_POST);
4015 SelectPostStore(Node, 3, AArch64::ST1Threev8h_POST);
4018 SelectPostStore(Node, 3, AArch64::ST1Threev2s_POST);
4021 SelectPostStore(Node, 3, AArch64::ST1Threev4s_POST);
4024 SelectPostStore(Node, 3, AArch64::ST1Threev1d_POST);
4027 SelectPostStore(Node, 3, AArch64::ST1Threev2d_POST);
4035 SelectPostStore(Node, 4, AArch64::ST1Fourv8b_POST);
4038 SelectPostStore(Node, 4, AArch64::ST1Fourv16b_POST);
4041 SelectPostStore(Node, 4, AArch64::ST1Fourv4h_POST);
4044 SelectPostStore(Node, 4, AArch64::ST1Fourv8h_POST);
4047 SelectPostStore(Node, 4, AArch64::ST1Fourv2s_POST);
4050 SelectPostStore(Node, 4, AArch64::ST1Fourv4s_POST);
4053 SelectPostStore(Node, 4, AArch64::ST1Fourv1d_POST);
4056 SelectPostStore(Node, 4, AArch64::ST1Fourv2d_POST);
4064 SelectPostStoreLane(Node, 2, AArch64::ST2i8_POST);
4068 SelectPostStoreLane(Node, 2, AArch64::ST2i16_POST);
4072 SelectPostStoreLane(Node, 2, AArch64::ST2i32_POST);
4076 SelectPostStoreLane(Node, 2, AArch64::ST2i64_POST);
4084 SelectPostStoreLane(Node, 3, AArch64::ST3i8_POST);
4088 SelectPostStoreLane(Node, 3, AArch64::ST3i16_POST);
4092 SelectPostStoreLane(Node, 3, AArch64::ST3i32_POST);
4096 SelectPostStoreLane(Node, 3, AArch64::ST3i64_POST);
4104 SelectPostStoreLane(Node, 4, AArch64::ST4i8_POST);
4108 SelectPostStoreLane(Node, 4, AArch64::ST4i16_POST);
4112 SelectPostStoreLane(Node, 4, AArch64::ST4i32_POST);
4116 SelectPostStoreLane(Node, 4, AArch64::ST4i64_POST);
4131 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)
void push_back(const T &Elt)
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 ...
Compute iterated dominance frontiers using a linear time algorithm.
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.
const SDValue & getBasePtr() const
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...
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.
unsigned const TargetRegisterInfo * TRI
MVT getSimpleValueType(unsigned ResNo) const
Return the type of a specified result as a simple type.
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.
unsigned getValueSizeInBits() const
Returns the size of the value in bits.
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...
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.
std::size_t countTrailingOnes(T Value, ZeroBehavior ZB=ZB_Width)
Count the number of ones from the least significant bit to the first zero bit.
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
unsigned getScalarValueSizeInBits() 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.
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
unsigned getSizeInBits() const
Return the size of the specified value type in bits.
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...
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)
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...
std::size_t 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...
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...
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...
bool optForSize() const
Optimize this function for size (-Os) or minimum size (-Oz).
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...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
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.
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
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...
const Function & getFunction() const
Return the LLVM function that this machine code represents.
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 ...
void computeKnownBits(SDValue Op, KnownBits &Known, unsigned Depth=0) const
Determine which bits of Op are known to be either zero or one and return them in Known.
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
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
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())
void dumpr() const
Dump (recursively) this node and its use-def subgraph.
static void getUsefulBitsFromAndWithImmediate(SDValue Op, APInt &UsefulBits, unsigned Depth)
unsigned getMachineOpcode() const
This may only be called if isMachineOpcode returns true.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
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.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
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.
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...
std::size_t countLeadingOnes(T Value, ZeroBehavior ZB=ZB_Width)
Count the number of ones from the most significant bit to the first zero bit.
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.