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);
172 bool tryReadRegister(
SDNode *N);
173 bool tryWriteRegister(
SDNode *N);
176 #include "AArch64GenDAGISel.inc"
179 bool SelectShiftedRegister(
SDValue N,
bool AllowROR,
SDValue &Reg,
183 bool SelectAddrModeIndexed(
SDValue N,
unsigned Size,
SDValue &Base,
185 bool SelectAddrModeUnscaled(
SDValue N,
unsigned Size,
SDValue &Base,
193 bool isWorthFolding(
SDValue V)
const;
194 bool SelectExtendedSHL(
SDValue N,
unsigned Size,
bool WantExtend,
197 template<
unsigned RegW
idth>
199 return SelectCVTFixedPosOperand(N, FixedPos, RegWidth);
202 bool SelectCVTFixedPosOperand(
SDValue N,
SDValue &FixedPos,
unsigned Width);
204 bool SelectCMP_SWAP(
SDNode *N);
213 Imm =
C->getZExtValue();
234 bool AArch64DAGToDAGISel::SelectInlineAsmMemoryOperand(
235 const SDValue &
Op,
unsigned ConstraintID, std::vector<SDValue> &OutOps) {
236 switch(ConstraintID) {
249 SDValue(CurDAG->getMachineNode(TargetOpcode::COPY_TO_REGCLASS,
252 OutOps.push_back(NewOp);
268 if (!isa<ConstantSDNode>(N.
getNode()))
271 uint64_t Immed = cast<ConstantSDNode>(N.
getNode())->getZExtValue();
274 if (Immed >> 12 == 0) {
276 }
else if ((Immed & 0xfff) == 0 && Immed >> 24 == 0) {
284 Val = CurDAG->getTargetConstant(Immed, dl,
MVT::i32);
285 Shift = CurDAG->getTargetConstant(ShVal, dl,
MVT::i32);
291 bool AArch64DAGToDAGISel::SelectNegArithImmed(
SDValue N,
SDValue &Val,
298 if (!isa<ConstantSDNode>(N.
getNode()))
302 uint64_t Immed = cast<ConstantSDNode>(N.
getNode())->getZExtValue();
313 Immed = ~Immed + 1ULL;
314 if (Immed & 0xFFFFFFFFFF000000ULL)
317 Immed &= 0xFFFFFFULL;
318 return SelectArithImmed(CurDAG->getConstant(Immed,
SDLoc(N),
MVT::i32), Val,
356 if (!isa<MemSDNode>(*UI))
358 if (!isa<MemSDNode>(*UII))
364 bool AArch64DAGToDAGISel::isWorthFolding(
SDValue V)
const {
392 bool AArch64DAGToDAGISel::SelectShiftedRegister(
SDValue N,
bool AllowROR,
402 unsigned Val = RHS->getZExtValue() & (BitSize - 1);
406 Shift = CurDAG->getTargetConstant(ShVal,
SDLoc(N),
MVT::i32);
407 return isWorthFolding(N);
421 SrcVT = cast<VTSDNode>(N.
getOperand(1))->getVT();
425 if (!IsLoadStore && SrcVT ==
MVT::i8)
427 else if (!IsLoadStore && SrcVT ==
MVT::i16)
437 if (!IsLoadStore && SrcVT ==
MVT::i8)
439 else if (!IsLoadStore && SrcVT ==
MVT::i16)
483 LaneIdx = DLidx->
getSExtValue() + EVidx->getSExtValue();
492 SDValue &LaneOp,
int &LaneIdx) {
506 bool AArch64DAGToDAGISel::tryMLAV64LaneV128(
SDNode *N) {
526 SDValue Ops[] = { Op0, MLAOp1, MLAOp2, LaneIdxVal };
528 unsigned MLAOpc = ~0U;
534 MLAOpc = AArch64::MLAv4i16_indexed;
537 MLAOpc = AArch64::MLAv8i16_indexed;
540 MLAOpc = AArch64::MLAv2i32_indexed;
543 MLAOpc = AArch64::MLAv4i32_indexed;
547 ReplaceNode(N, CurDAG->getMachineNode(MLAOpc, dl, N->
getValueType(0), Ops));
551 bool AArch64DAGToDAGISel::tryMULLV64LaneV128(
unsigned IntNo,
SDNode *N) {
563 SDValue Ops[] = { SMULLOp0, SMULLOp1, LaneIdxVal };
565 unsigned SMULLOpc = ~0U;
567 if (IntNo == Intrinsic::aarch64_neon_smull) {
572 SMULLOpc = AArch64::SMULLv4i16_indexed;
575 SMULLOpc = AArch64::SMULLv2i32_indexed;
578 }
else if (IntNo == Intrinsic::aarch64_neon_umull) {
583 SMULLOpc = AArch64::UMULLv4i16_indexed;
586 SMULLOpc = AArch64::UMULLv2i32_indexed;
592 ReplaceNode(N, CurDAG->getMachineNode(SMULLOpc, dl, N->
getValueType(0), Ops));
614 bool AArch64DAGToDAGISel::SelectArithExtendedRegister(
SDValue N,
SDValue &Reg,
616 unsigned ShiftVal = 0;
654 return isWorthFolding(N);
681 bool AArch64DAGToDAGISel::SelectAddrModeIndexed7S(
SDValue N,
unsigned Size,
688 int FI = cast<FrameIndexSDNode>(
N)->getIndex();
689 Base = CurDAG->getTargetFrameIndex(FI, TLI->
getPointerTy(DL));
690 OffImm = CurDAG->getTargetConstant(0, dl,
MVT::i64);
697 if (CurDAG->isBaseWithConstantOffset(N)) {
699 int64_t RHSC = RHS->getSExtValue();
700 unsigned Scale =
Log2_32(Size);
701 if ((RHSC & (Size - 1)) == 0 && RHSC >= -(0x40 << Scale) &&
702 RHSC < (0x40 << Scale)) {
705 int FI = cast<FrameIndexSDNode>(Base)->getIndex();
706 Base = CurDAG->getTargetFrameIndex(FI, TLI->
getPointerTy(DL));
708 OffImm = CurDAG->getTargetConstant(RHSC >> Scale, dl,
MVT::i64);
719 OffImm = CurDAG->getTargetConstant(0, dl,
MVT::i64);
726 bool AArch64DAGToDAGISel::SelectAddrModeIndexed(
SDValue N,
unsigned Size,
729 const DataLayout &DL = CurDAG->getDataLayout();
732 int FI = cast<FrameIndexSDNode>(
N)->getIndex();
733 Base = CurDAG->getTargetFrameIndex(FI, TLI->
getPointerTy(DL));
734 OffImm = CurDAG->getTargetConstant(0, dl,
MVT::i64);
749 if (Alignment == 0 && Ty->
isSized())
752 if (Alignment >= Size)
756 if (CurDAG->isBaseWithConstantOffset(N)) {
758 int64_t RHSC = (int64_t)RHS->getZExtValue();
759 unsigned Scale =
Log2_32(Size);
760 if ((RHSC & (Size - 1)) == 0 && RHSC >= 0 && RHSC < (0x1000 << Scale)) {
763 int FI = cast<FrameIndexSDNode>(Base)->getIndex();
764 Base = CurDAG->getTargetFrameIndex(FI, TLI->
getPointerTy(DL));
766 OffImm = CurDAG->getTargetConstant(RHSC >> Scale, dl,
MVT::i64);
774 if (SelectAddrModeUnscaled(N, Size, Base, OffImm))
782 OffImm = CurDAG->getTargetConstant(0, dl,
MVT::i64);
791 bool AArch64DAGToDAGISel::SelectAddrModeUnscaled(
SDValue N,
unsigned Size,
794 if (!CurDAG->isBaseWithConstantOffset(N))
797 int64_t RHSC = RHS->getSExtValue();
799 if ((RHSC & (Size - 1)) == 0 && RHSC >= 0 &&
800 RHSC < (0x1000 <<
Log2_32(Size)))
802 if (RHSC >= -256 && RHSC < 256) {
805 int FI = cast<FrameIndexSDNode>(Base)->getIndex();
807 Base = CurDAG->getTargetFrameIndex(
810 OffImm = CurDAG->getTargetConstant(RHSC,
SDLoc(N),
MVT::i64);
823 TargetOpcode::INSERT_SUBREG, dl,
MVT::i64, ImpDef, N, SubReg);
829 bool AArch64DAGToDAGISel::SelectExtendedSHL(
SDValue N,
unsigned Size,
834 if (!CSD || (CSD->getZExtValue() & 0x7) != CSD->getZExtValue())
849 SignExtend = CurDAG->getTargetConstant(0, dl,
MVT::i32);
852 unsigned LegalShiftVal =
Log2_32(Size);
853 unsigned ShiftVal = CSD->getZExtValue();
855 if (ShiftVal != 0 && ShiftVal != LegalShiftVal)
858 return isWorthFolding(N);
861 bool AArch64DAGToDAGISel::SelectAddrModeWRO(
SDValue N,
unsigned Size,
873 if (isa<ConstantSDNode>(LHS) || isa<ConstantSDNode>(RHS))
881 if (!isa<MemSDNode>(*UI))
886 bool IsExtendedRegisterWorthFolding = isWorthFolding(N);
890 SelectExtendedSHL(RHS, Size,
true, Offset, SignExtend)) {
892 DoShift = CurDAG->getTargetConstant(
true, dl,
MVT::i32);
898 SelectExtendedSHL(LHS, Size,
true, Offset, SignExtend)) {
900 DoShift = CurDAG->getTargetConstant(
true, dl,
MVT::i32);
905 DoShift = CurDAG->getTargetConstant(
false, dl,
MVT::i32);
909 if (IsExtendedRegisterWorthFolding &&
916 if (isWorthFolding(LHS))
921 if (IsExtendedRegisterWorthFolding &&
928 if (isWorthFolding(RHS))
940 if ((ImmOff & 0xfffffffffffff000LL) == 0x0LL)
943 if ((ImmOff & 0xffffffffff000fffLL) == 0x0LL)
945 return (ImmOff & 0xffffffffff00ffffLL) != 0x0LL &&
946 (ImmOff & 0xffffffffffff0fffLL) != 0x0LL;
950 bool AArch64DAGToDAGISel::SelectAddrModeXRO(
SDValue N,
unsigned Size,
965 if (!isa<MemSDNode>(*UI))
980 if (isa<ConstantSDNode>(RHS)) {
981 int64_t ImmOff = (int64_t)cast<ConstantSDNode>(RHS)->getZExtValue();
982 unsigned Scale =
Log2_32(Size);
986 if ((ImmOff % Size == 0 && ImmOff >= 0 && ImmOff < (0x1000 << Scale)) ||
992 CurDAG->getMachineNode(AArch64::MOVi64imm, DL,
MVT::i64, Ops);
999 bool IsExtendedRegisterWorthFolding = isWorthFolding(N);
1003 SelectExtendedSHL(RHS, Size,
false, Offset, SignExtend)) {
1005 DoShift = CurDAG->getTargetConstant(
true, DL,
MVT::i32);
1011 SelectExtendedSHL(LHS, Size,
false, Offset, SignExtend)) {
1013 DoShift = CurDAG->getTargetConstant(
true, DL,
MVT::i32);
1020 SignExtend = CurDAG->getTargetConstant(
false, DL,
MVT::i32);
1021 DoShift = CurDAG->getTargetConstant(
false, DL,
MVT::i32);
1027 static const unsigned RegClassIDs[] = {
1028 AArch64::DDRegClassID, AArch64::DDDRegClassID, AArch64::DDDDRegClassID};
1029 static const unsigned SubRegs[] = {AArch64::dsub0, AArch64::dsub1,
1030 AArch64::dsub2, AArch64::dsub3};
1032 return createTuple(Regs, RegClassIDs, SubRegs);
1036 static const unsigned RegClassIDs[] = {
1037 AArch64::QQRegClassID, AArch64::QQQRegClassID, AArch64::QQQQRegClassID};
1038 static const unsigned SubRegs[] = {AArch64::qsub0, AArch64::qsub1,
1039 AArch64::qsub2, AArch64::qsub3};
1041 return createTuple(Regs, RegClassIDs, SubRegs);
1045 const unsigned RegClassIDs[],
1046 const unsigned SubRegs[]) {
1049 if (Regs.
size() == 1)
1060 CurDAG->getTargetConstant(RegClassIDs[Regs.
size() - 2],
DL,
MVT::i32));
1063 for (
unsigned i = 0; i < Regs.
size(); ++i) {
1069 CurDAG->getMachineNode(TargetOpcode::REG_SEQUENCE, DL,
MVT::Untyped, Ops);
1073 void AArch64DAGToDAGISel::SelectTable(
SDNode *N,
unsigned NumVecs,
unsigned Opc,
1078 unsigned ExtOff = isExt;
1081 unsigned Vec0Off = ExtOff + 1;
1083 N->
op_begin() + Vec0Off + NumVecs);
1084 SDValue RegSeq = createQTuple(Regs);
1091 ReplaceNode(N, CurDAG->getMachineNode(Opc, dl, VT, Ops));
1094 bool AArch64DAGToDAGISel::tryIndexedLoad(
SDNode *N) {
1106 unsigned Opcode = 0;
1109 bool InsertTo64 =
false;
1111 Opcode = IsPre ? AArch64::LDRXpre : AArch64::LDRXpost;
1114 Opcode = IsPre ? AArch64::LDRWpre : AArch64::LDRWpost;
1116 Opcode = IsPre ? AArch64::LDRSWpre : AArch64::LDRSWpost;
1118 Opcode = IsPre ? AArch64::LDRWpre : AArch64::LDRWpost;
1127 Opcode = IsPre ? AArch64::LDRSHXpre : AArch64::LDRSHXpost;
1129 Opcode = IsPre ? AArch64::LDRSHWpre : AArch64::LDRSHWpost;
1131 Opcode = IsPre ? AArch64::LDRHHpre : AArch64::LDRHHpost;
1140 Opcode = IsPre ? AArch64::LDRSBXpre : AArch64::LDRSBXpost;
1142 Opcode = IsPre ? AArch64::LDRSBWpre : AArch64::LDRSBWpost;
1144 Opcode = IsPre ? AArch64::LDRBBpre : AArch64::LDRBBpost;
1151 Opcode = IsPre ? AArch64::LDRHpre : AArch64::LDRHpost;
1153 Opcode = IsPre ? AArch64::LDRSpre : AArch64::LDRSpost;
1155 Opcode = IsPre ? AArch64::LDRDpre : AArch64::LDRDpost;
1157 Opcode = IsPre ? AArch64::LDRQpre : AArch64::LDRQpost;
1167 SDNode *Res = CurDAG->getMachineNode(Opcode, dl,
MVT::i64, DstVT,
1174 SDValue(CurDAG->getMachineNode(
1175 AArch64::SUBREG_TO_REG, dl,
MVT::i64,
1176 CurDAG->getTargetConstant(0, dl,
MVT::i64), LoadedVal,
1181 ReplaceUses(
SDValue(N, 0), LoadedVal);
1184 CurDAG->RemoveDeadNode(N);
1188 void AArch64DAGToDAGISel::SelectLoad(
SDNode *N,
unsigned NumVecs,
unsigned Opc,
1189 unsigned SubRegIdx) {
1199 SDNode *Ld = CurDAG->getMachineNode(Opc, dl, ResTys, Ops);
1201 for (
unsigned i = 0; i < NumVecs; ++i)
1203 CurDAG->getTargetExtractSubreg(SubRegIdx + i, dl, VT, SuperReg));
1209 MemOp[0] = cast<MemIntrinsicSDNode>(
N)->getMemOperand();
1210 cast<MachineSDNode>(Ld)->setMemRefs(MemOp, MemOp + 1);
1212 CurDAG->RemoveDeadNode(N);
1215 void AArch64DAGToDAGISel::SelectPostLoad(
SDNode *N,
unsigned NumVecs,
1216 unsigned Opc,
unsigned SubRegIdx) {
1228 SDNode *Ld = CurDAG->getMachineNode(Opc, dl, ResTys, Ops);
1236 ReplaceUses(
SDValue(N, 0), SuperReg);
1238 for (
unsigned i = 0; i < NumVecs; ++i)
1240 CurDAG->getTargetExtractSubreg(SubRegIdx + i, dl, VT, SuperReg));
1244 CurDAG->RemoveDeadNode(N);
1247 void AArch64DAGToDAGISel::SelectStore(
SDNode *N,
unsigned NumVecs,
1255 SDValue RegSeq = Is128Bit ? createQTuple(Regs) : createDTuple(Regs);
1262 MemOp[0] = cast<MemIntrinsicSDNode>(
N)->getMemOperand();
1263 cast<MachineSDNode>(St)->setMemRefs(MemOp, MemOp + 1);
1268 void AArch64DAGToDAGISel::SelectPostStore(
SDNode *N,
unsigned NumVecs,
1278 SDValue RegSeq = Is128Bit ? createQTuple(Regs) : createDTuple(Regs);
1284 SDNode *St = CurDAG->getMachineNode(Opc, dl, ResTys, Ops);
1306 SDValue(DAG.getMachineNode(TargetOpcode::IMPLICIT_DEF, DL, WideTy), 0);
1307 return DAG.getTargetInsertSubreg(AArch64::dsub, DL, WideTy, Undef, V64Reg);
1324 void AArch64DAGToDAGISel::SelectLoadLane(
SDNode *N,
unsigned NumVecs,
1337 SDValue RegSeq = createQTuple(Regs);
1342 cast<ConstantSDNode>(N->
getOperand(NumVecs + 2))->getZExtValue();
1344 SDValue Ops[] = {RegSeq, CurDAG->getTargetConstant(LaneNo, dl,
MVT::i64),
1346 SDNode *Ld = CurDAG->getMachineNode(Opc, dl, ResTys, Ops);
1349 EVT WideVT = RegSeq.getOperand(1)->getValueType(0);
1350 static const unsigned QSubs[] = { AArch64::qsub0, AArch64::qsub1,
1351 AArch64::qsub2, AArch64::qsub3 };
1352 for (
unsigned i = 0; i < NumVecs; ++i) {
1353 SDValue NV = CurDAG->getTargetExtractSubreg(QSubs[i], dl, WideVT, SuperReg);
1356 ReplaceUses(
SDValue(N, i), NV);
1360 CurDAG->RemoveDeadNode(N);
1363 void AArch64DAGToDAGISel::SelectPostLoadLane(
SDNode *N,
unsigned NumVecs,
1376 SDValue RegSeq = createQTuple(Regs);
1382 cast<ConstantSDNode>(N->
getOperand(NumVecs + 1))->getZExtValue();
1385 CurDAG->getTargetConstant(LaneNo, dl,
1390 SDNode *Ld = CurDAG->getMachineNode(Opc, dl, ResTys, Ops);
1401 EVT WideVT = RegSeq.getOperand(1)->getValueType(0);
1402 static const unsigned QSubs[] = { AArch64::qsub0, AArch64::qsub1,
1403 AArch64::qsub2, AArch64::qsub3 };
1404 for (
unsigned i = 0; i < NumVecs; ++i) {
1405 SDValue NV = CurDAG->getTargetExtractSubreg(QSubs[i], dl, WideVT,
1409 ReplaceUses(
SDValue(N, i), NV);
1415 CurDAG->RemoveDeadNode(N);
1418 void AArch64DAGToDAGISel::SelectStoreLane(
SDNode *N,
unsigned NumVecs,
1431 SDValue RegSeq = createQTuple(Regs);
1434 cast<ConstantSDNode>(N->
getOperand(NumVecs + 2))->getZExtValue();
1436 SDValue Ops[] = {RegSeq, CurDAG->getTargetConstant(LaneNo, dl,
MVT::i64),
1442 MemOp[0] = cast<MemIntrinsicSDNode>(
N)->getMemOperand();
1443 cast<MachineSDNode>(St)->setMemRefs(MemOp, MemOp + 1);
1448 void AArch64DAGToDAGISel::SelectPostStoreLane(
SDNode *N,
unsigned NumVecs,
1461 SDValue RegSeq = createQTuple(Regs);
1467 cast<ConstantSDNode>(N->
getOperand(NumVecs + 1))->getZExtValue();
1469 SDValue Ops[] = {RegSeq, CurDAG->getTargetConstant(LaneNo, dl,
MVT::i64),
1473 SDNode *St = CurDAG->getMachineNode(Opc, dl, ResTys, Ops);
1477 MemOp[0] = cast<MemIntrinsicSDNode>(
N)->getMemOperand();
1478 cast<MachineSDNode>(St)->setMemRefs(MemOp, MemOp + 1);
1485 unsigned &LSB,
unsigned &MSB,
1486 unsigned NumberOfIgnoredLowBits,
1487 bool BiggerPattern) {
1489 "N must be a AND operation to call this function");
1497 "Type checking must have been done before calling this function");
1507 uint64_t AndImm = 0;
1515 AndImm |= (1 << NumberOfIgnoredLowBits) - 1;
1518 if (AndImm & (AndImm + 1))
1521 bool ClampMSB =
false;
1522 uint64_t SrlImm = 0;
1541 }
else if (BiggerPattern) {
1553 if (!BiggerPattern && (SrlImm <= 0 || SrlImm >= VT.getSizeInBits())) {
1555 <<
": Found large shift immediate, this should not happen\n"));
1560 MSB = SrlImm + (VT ==
MVT::i32 ? countTrailingOnes<uint32_t>(AndImm)
1561 : countTrailingOnes<uint64_t>(AndImm)) -
1568 MSB = MSB > 31 ? 31 : MSB;
1570 Opc = VT ==
MVT::i32 ? AArch64::UBFMWri : AArch64::UBFMXri;
1575 SDValue &Opd0,
unsigned &Immr,
1582 "Type checking must have been done before calling this function");
1588 BitWidth = VT.getSizeInBits();
1596 unsigned Width = cast<VTSDNode>(N->
getOperand(1))->getVT().getSizeInBits();
1597 if (ShiftImm + Width > BitWidth)
1600 Opc = (VT ==
MVT::i32) ? AArch64::SBFMWri : AArch64::SBFMXri;
1603 Imms = ShiftImm + Width - 1;
1627 uint64_t AndMask = 0;
1633 uint64_t SrlImm = 0;
1639 if (BitWide &&
isMask_64(AndMask >> SrlImm)) {
1641 Opc = AArch64::UBFMWri;
1643 Opc = AArch64::UBFMXri;
1646 MSB = BitWide + SrlImm - 1;
1654 unsigned &Immr,
unsigned &Imms,
1655 bool BiggerPattern) {
1657 "N must be a SHR/SRA operation to call this function");
1665 "Type checking must have been done before calling this function");
1672 uint64_t ShlImm = 0;
1673 uint64_t TruncBits = 0;
1686 }
else if (BiggerPattern) {
1698 <<
": Found large shift immediate, this should not happen\n"));
1702 uint64_t SrlImm = 0;
1707 "bad amount in shift node!");
1708 int immr = SrlImm - ShlImm;
1719 bool AArch64DAGToDAGISel::tryBitfieldExtractOpFromSExt(
SDNode *N) {
1735 unsigned Immr = ShiftImm;
1737 SDValue Ops[] = {Opd0, CurDAG->getTargetConstant(Immr, dl, VT),
1738 CurDAG->getTargetConstant(Imms, dl, VT)};
1739 CurDAG->SelectNodeTo(N, AArch64::SBFMXri, VT, Ops);
1744 SDValue &Opd0,
unsigned &Immr,
unsigned &Imms,
1745 unsigned NumberOfIgnoredLowBits = 0,
1746 bool BiggerPattern =
false) {
1757 NumberOfIgnoredLowBits, BiggerPattern);
1770 case AArch64::SBFMWri:
1771 case AArch64::UBFMWri:
1772 case AArch64::SBFMXri:
1773 case AArch64::UBFMXri:
1784 bool AArch64DAGToDAGISel::tryBitfieldExtractOp(
SDNode *N) {
1785 unsigned Opc, Immr, Imms;
1795 if ((Opc == AArch64::SBFMXri || Opc == AArch64::UBFMXri) && VT ==
MVT::i32) {
1796 SDValue Ops64[] = {Opd0, CurDAG->getTargetConstant(Immr, dl,
MVT::i64),
1797 CurDAG->getTargetConstant(Imms, dl,
MVT::i64)};
1800 SDValue SubReg = CurDAG->getTargetConstant(AArch64::sub_32, dl,
MVT::i32);
1801 ReplaceNode(N, CurDAG->getMachineNode(TargetOpcode::EXTRACT_SUBREG, dl,
1806 SDValue Ops[] = {Opd0, CurDAG->getTargetConstant(Immr, dl, VT),
1807 CurDAG->getTargetConstant(Imms, dl, VT)};
1808 CurDAG->SelectNodeTo(N, Opc, VT, Ops);
1817 unsigned NumberOfIgnoredHighBits,
EVT VT) {
1819 "i32 or i64 mask type expected!");
1820 unsigned BitWidth = VT.
getSizeInBits() - NumberOfIgnoredHighBits;
1822 APInt SignificantDstMask =
APInt(BitWidth, DstMask);
1823 APInt SignificantBitsToBeInserted = BitsToBeInserted.
zextOrTrunc(BitWidth);
1825 return (SignificantDstMask & SignificantBitsToBeInserted) == 0 &&
1826 (SignificantDstMask | SignificantBitsToBeInserted).isAllOnesValue();
1851 UsefulBits &=
APInt(UsefulBits.getBitWidth(), Imm);
1856 uint64_t Imm, uint64_t MSB,
1859 APInt OpUsefulBits(UsefulBits);
1863 OpUsefulBits <<= MSB - Imm + 1;
1868 OpUsefulBits <<= Imm;
1870 OpUsefulBits <<= MSB + 1;
1873 OpUsefulBits <<= OpUsefulBits.
getBitWidth() - Imm;
1879 UsefulBits &= OpUsefulBits;
1894 uint64_t ShiftTypeAndValue =
1927 APInt OpUsefulBits(UsefulBits);
1938 uint64_t Width = MSB - Imm + 1;
1941 OpUsefulBits <<= Width;
1946 Mask = ResultUsefulBits & OpUsefulBits;
1952 Mask |= (ResultUsefulBits & ~OpUsefulBits);
1955 uint64_t Width = MSB + 1;
1958 OpUsefulBits <<= Width;
1960 OpUsefulBits <<= LSB;
1964 Mask = ResultUsefulBits & OpUsefulBits;
1965 Mask.lshrInPlace(LSB);
1969 Mask |= (ResultUsefulBits & ~OpUsefulBits);
1986 case AArch64::ANDSWri:
1987 case AArch64::ANDSXri:
1988 case AArch64::ANDWri:
1989 case AArch64::ANDXri:
1993 case AArch64::UBFMWri:
1994 case AArch64::UBFMXri:
1997 case AArch64::ORRWrs:
1998 case AArch64::ORRXrs:
2003 case AArch64::BFMWri:
2004 case AArch64::BFMXri:
2007 case AArch64::STRBBui:
2008 case AArch64::STURBBi:
2014 case AArch64::STRHHui:
2015 case AArch64::STURHHi:
2030 UsefulBits =
APInt(Bitwidth, 0);
2039 UsersUsefulBits |= UsefulBitsForUse;
2044 UsefulBits &= UsersUsefulBits;
2057 unsigned UBFMOpc = BitWidth == 32 ? AArch64::UBFMWri : AArch64::UBFMXri;
2060 if (ShlAmount > 0) {
2063 UBFMOpc, dl, VT, Op,
2068 assert(ShlAmount < 0 &&
"expected right shift");
2069 int ShrAmount = -ShlAmount;
2082 SDValue &Src,
int &ShiftAmount,
2087 assert(BitWidth == 32 || BitWidth == 64);
2094 uint64_t NonZeroBits = (~Known.
Zero).getZExtValue();
2125 if (ShlImm - ShiftAmount != 0 && !BiggerPattern)
2174 uint64_t NotKnownZero = (~Known.
Zero).getZExtValue();
2181 if ((OrImm & NotKnownZero) != 0) {
2192 unsigned ImmR = (BitWidth - LSB) % BitWidth;
2193 unsigned ImmS = Width - 1;
2199 bool IsBFI = LSB != 0;
2200 uint64_t BFIImm = OrImm >> LSB;
2204 unsigned OrChunks = 0, BFIChunks = 0;
2205 for (
unsigned Shift = 0; Shift < BitWidth; Shift += 16) {
2206 if (((OrImm >> Shift) & 0xFFFF) != 0)
2208 if (((BFIImm >> Shift) & 0xFFFF) != 0)
2211 if (BFIChunks > OrChunks)
2217 unsigned MOVIOpc = VT ==
MVT::i32 ? AArch64::MOVi32imm : AArch64::MOVi64imm;
2225 unsigned Opc = (VT ==
MVT::i32) ? AArch64::BFMWri : AArch64::BFMXri;
2264 for (
int I = 0;
I < 4; ++
I) {
2267 unsigned ImmR, ImmS;
2268 bool BiggerPattern =
I / 2;
2277 NumberOfIgnoredLowBits, BiggerPattern)) {
2280 if ((BFXOpc != AArch64::UBFMXri && VT ==
MVT::i64) ||
2281 (BFXOpc != AArch64::UBFMWri && VT ==
MVT::i32))
2286 Width = ImmS - ImmR + 1;
2297 Src, DstLSB, Width)) {
2298 ImmR = (BitWidth - DstLSB) % BitWidth;
2316 APInt BitsToBeInserted =
2319 if ((BitsToBeInserted & ~Known.
Zero) != 0)
2337 unsigned Opc = (VT ==
MVT::i32) ? AArch64::BFMWri : AArch64::BFMXri;
2345 uint64_t Mask0Imm, Mask1Imm;
2351 APInt(BitWidth, Mask0Imm) == ~
APInt(BitWidth, Mask1Imm) &&
2370 unsigned ShiftOpc = (VT ==
MVT::i32) ? AArch64::UBFMWri : AArch64::UBFMXri;
2376 unsigned ImmR = (BitWidth - LSB) % BitWidth;
2377 unsigned ImmS = Width - 1;
2383 unsigned Opc = (VT ==
MVT::i32) ? AArch64::BFMWri : AArch64::BFMXri;
2391 bool AArch64DAGToDAGISel::tryBitfieldInsertOp(
SDNode *N) {
2400 CurDAG->SelectNodeTo(N, TargetOpcode::IMPLICIT_DEF, N->
getValueType(0));
2413 bool AArch64DAGToDAGISel::tryBitfieldInsertInZeroOp(
SDNode *N) {
2424 Op0, DstLSB, Width))
2430 unsigned ImmS = Width - 1;
2433 SDValue Ops[] = {Op0, CurDAG->getTargetConstant(ImmR, DL, VT),
2434 CurDAG->getTargetConstant(ImmS, DL, VT)};
2435 unsigned Opc = (VT ==
MVT::i32) ? AArch64::UBFMWri : AArch64::UBFMXri;
2436 CurDAG->SelectNodeTo(N, Opc, VT, Ops);
2441 AArch64DAGToDAGISel::SelectCVTFixedPosOperand(
SDValue N,
SDValue &FixedPos,
2442 unsigned RegWidth) {
2445 FVal = CN->getValueAPF();
2446 else if (
LoadSDNode *LN = dyn_cast<LoadSDNode>(N)) {
2449 !isa<ConstantPoolSDNode>(LN->getOperand(1)->getOperand(1)))
2454 FVal = cast<ConstantFP>(CN->
getConstVal())->getValueAPF();
2473 if (!IsExact || !
IntVal.isPowerOf2())
return false;
2474 unsigned FBits =
IntVal.logBase2();
2478 if (FBits == 0 || FBits > RegWidth)
return false;
2480 FixedPos = CurDAG->getTargetConstant(FBits,
SDLoc(N),
MVT::i32);
2489 RegString.
split(Fields,
':');
2491 if (Fields.
size() == 1)
2495 &&
"Invalid number of fields in read register string");
2498 bool AllIntFields =
true;
2502 AllIntFields &= !
Field.getAsInteger(10, IntField);
2503 Ops.push_back(IntField);
2507 "Unexpected non-integer value in special register string.");
2511 return (Ops[0] << 14) | (Ops[1] << 11) | (Ops[2] << 7) |
2512 (Ops[3] << 3) | (Ops[4]);
2519 bool AArch64DAGToDAGISel::tryReadRegister(
SDNode *N) {
2526 ReplaceNode(N, CurDAG->getMachineNode(
2528 CurDAG->getTargetConstant(Reg, DL,
MVT::i32),
2536 if (TheReg && TheReg->Readable &&
2537 TheReg->haveFeatures(Subtarget->getFeatureBits()))
2543 ReplaceNode(N, CurDAG->getMachineNode(
2545 CurDAG->getTargetConstant(Reg, DL,
MVT::i32),
2557 bool AArch64DAGToDAGISel::tryWriteRegister(
SDNode *N) {
2565 N, CurDAG->getMachineNode(AArch64::MSR, DL,
MVT::Other,
2566 CurDAG->getTargetConstant(Reg, DL,
MVT::i32),
2576 auto PMapper = AArch64PState::lookupPStateByName(RegString->getString());
2579 &&
"Expected a constant integer expression.");
2580 unsigned Reg = PMapper->Encoding;
2581 uint64_t Immed = cast<ConstantSDNode>(N->
getOperand(2))->getZExtValue();
2583 if (Reg == AArch64PState::PAN || Reg == AArch64PState::UAO) {
2584 assert(Immed < 2 &&
"Bad imm");
2585 State = AArch64::MSRpstateImm1;
2587 assert(Immed < 16 &&
"Bad imm");
2588 State = AArch64::MSRpstateImm4;
2590 ReplaceNode(N, CurDAG->getMachineNode(
2592 CurDAG->getTargetConstant(Reg, DL,
MVT::i32),
2593 CurDAG->getTargetConstant(Immed, DL,
MVT::i16),
2602 if (TheReg && TheReg->Writeable &&
2603 TheReg->haveFeatures(Subtarget->getFeatureBits()))
2604 Reg = TheReg->Encoding;
2608 ReplaceNode(N, CurDAG->getMachineNode(
2610 CurDAG->getTargetConstant(Reg, DL,
MVT::i32),
2619 bool AArch64DAGToDAGISel::SelectCMP_SWAP(
SDNode *N) {
2621 EVT MemTy = cast<MemSDNode>(
N)->getMemoryVT();
2624 if (Subtarget->hasLSE())
return false;
2627 Opcode = AArch64::CMP_SWAP_8;
2629 Opcode = AArch64::CMP_SWAP_16;
2631 Opcode = AArch64::CMP_SWAP_32;
2633 Opcode = AArch64::CMP_SWAP_64;
2640 SDNode *CmpSwap = CurDAG->getMachineNode(
2645 MemOp[0] = cast<MemSDNode>(
N)->getMemOperand();
2646 cast<MachineSDNode>(CmpSwap)->setMemRefs(MemOp, MemOp + 1);
2650 CurDAG->RemoveDeadNode(N);
2676 if (SelectCMP_SWAP(Node))
2681 if (tryReadRegister(Node))
2686 if (tryWriteRegister(Node))
2691 if (tryMLAV64LaneV128(Node))
2698 if (tryIndexedLoad(Node))
2707 if (tryBitfieldExtractOp(Node))
2709 if (tryBitfieldInsertInZeroOp(Node))
2714 if (tryBitfieldExtractOpFromSExt(Node))
2719 if (tryBitfieldInsertOp(Node))
2747 SubReg = AArch64::dsub;
2750 SubReg = AArch64::ssub;
2753 SubReg = AArch64::hsub;
2758 SDValue Extract = CurDAG->getTargetExtractSubreg(SubReg,
SDLoc(Node), VT,
2760 DEBUG(
dbgs() <<
"ISEL: Custom selection!\n=> ");
2763 ReplaceNode(Node, Extract.
getNode());
2772 SDValue New = CurDAG->getCopyFromReg(
2773 CurDAG->getEntryNode(),
SDLoc(Node), AArch64::WZR,
MVT::i32);
2774 ReplaceNode(Node, New.
getNode());
2777 SDValue New = CurDAG->getCopyFromReg(
2778 CurDAG->getEntryNode(),
SDLoc(Node), AArch64::XZR,
MVT::i64);
2779 ReplaceNode(Node, New.
getNode());
2788 int FI = cast<FrameIndexSDNode>(Node)->getIndex();
2791 SDValue TFI = CurDAG->getTargetFrameIndex(
2795 CurDAG->getTargetConstant(Shifter, DL,
MVT::i32) };
2796 CurDAG->SelectNodeTo(Node, AArch64::ADDXri,
MVT::i64, Ops);
2800 unsigned IntNo = cast<ConstantSDNode>(Node->
getOperand(1))->getZExtValue();
2804 case Intrinsic::aarch64_ldaxp:
2805 case Intrinsic::aarch64_ldxp: {
2807 IntNo == Intrinsic::aarch64_ldaxp ? AArch64::LDAXPX : AArch64::LDXPX;
2817 MemOp[0] = cast<MemIntrinsicSDNode>(Node)->getMemOperand();
2818 cast<MachineSDNode>(Ld)->setMemRefs(MemOp, MemOp + 1);
2819 ReplaceNode(Node, Ld);
2822 case Intrinsic::aarch64_stlxp:
2823 case Intrinsic::aarch64_stxp: {
2825 IntNo == Intrinsic::aarch64_stlxp ? AArch64::STLXPX : AArch64::STXPX;
2833 SDValue Ops[] = {ValLo, ValHi, MemAddr, Chain};
2838 MemOp[0] = cast<MemIntrinsicSDNode>(Node)->getMemOperand();
2839 cast<MachineSDNode>(St)->setMemRefs(MemOp, MemOp + 1);
2841 ReplaceNode(Node, St);
2844 case Intrinsic::aarch64_neon_ld1x2:
2846 SelectLoad(Node, 2, AArch64::LD1Twov8b, AArch64::dsub0);
2849 SelectLoad(Node, 2, AArch64::LD1Twov16b, AArch64::qsub0);
2852 SelectLoad(Node, 2, AArch64::LD1Twov4h, AArch64::dsub0);
2855 SelectLoad(Node, 2, AArch64::LD1Twov8h, AArch64::qsub0);
2858 SelectLoad(Node, 2, AArch64::LD1Twov2s, AArch64::dsub0);
2861 SelectLoad(Node, 2, AArch64::LD1Twov4s, AArch64::qsub0);
2864 SelectLoad(Node, 2, AArch64::LD1Twov1d, AArch64::dsub0);
2867 SelectLoad(Node, 2, AArch64::LD1Twov2d, AArch64::qsub0);
2871 case Intrinsic::aarch64_neon_ld1x3:
2873 SelectLoad(Node, 3, AArch64::LD1Threev8b, AArch64::dsub0);
2876 SelectLoad(Node, 3, AArch64::LD1Threev16b, AArch64::qsub0);
2879 SelectLoad(Node, 3, AArch64::LD1Threev4h, AArch64::dsub0);
2882 SelectLoad(Node, 3, AArch64::LD1Threev8h, AArch64::qsub0);
2885 SelectLoad(Node, 3, AArch64::LD1Threev2s, AArch64::dsub0);
2888 SelectLoad(Node, 3, AArch64::LD1Threev4s, AArch64::qsub0);
2891 SelectLoad(Node, 3, AArch64::LD1Threev1d, AArch64::dsub0);
2894 SelectLoad(Node, 3, AArch64::LD1Threev2d, AArch64::qsub0);
2898 case Intrinsic::aarch64_neon_ld1x4:
2900 SelectLoad(Node, 4, AArch64::LD1Fourv8b, AArch64::dsub0);
2903 SelectLoad(Node, 4, AArch64::LD1Fourv16b, AArch64::qsub0);
2906 SelectLoad(Node, 4, AArch64::LD1Fourv4h, AArch64::dsub0);
2909 SelectLoad(Node, 4, AArch64::LD1Fourv8h, AArch64::qsub0);
2912 SelectLoad(Node, 4, AArch64::LD1Fourv2s, AArch64::dsub0);
2915 SelectLoad(Node, 4, AArch64::LD1Fourv4s, AArch64::qsub0);
2918 SelectLoad(Node, 4, AArch64::LD1Fourv1d, AArch64::dsub0);
2921 SelectLoad(Node, 4, AArch64::LD1Fourv2d, AArch64::qsub0);
2925 case Intrinsic::aarch64_neon_ld2:
2927 SelectLoad(Node, 2, AArch64::LD2Twov8b, AArch64::dsub0);
2930 SelectLoad(Node, 2, AArch64::LD2Twov16b, AArch64::qsub0);
2933 SelectLoad(Node, 2, AArch64::LD2Twov4h, AArch64::dsub0);
2936 SelectLoad(Node, 2, AArch64::LD2Twov8h, AArch64::qsub0);
2939 SelectLoad(Node, 2, AArch64::LD2Twov2s, AArch64::dsub0);
2942 SelectLoad(Node, 2, AArch64::LD2Twov4s, AArch64::qsub0);
2945 SelectLoad(Node, 2, AArch64::LD1Twov1d, AArch64::dsub0);
2948 SelectLoad(Node, 2, AArch64::LD2Twov2d, AArch64::qsub0);
2952 case Intrinsic::aarch64_neon_ld3:
2954 SelectLoad(Node, 3, AArch64::LD3Threev8b, AArch64::dsub0);
2957 SelectLoad(Node, 3, AArch64::LD3Threev16b, AArch64::qsub0);
2960 SelectLoad(Node, 3, AArch64::LD3Threev4h, AArch64::dsub0);
2963 SelectLoad(Node, 3, AArch64::LD3Threev8h, AArch64::qsub0);
2966 SelectLoad(Node, 3, AArch64::LD3Threev2s, AArch64::dsub0);
2969 SelectLoad(Node, 3, AArch64::LD3Threev4s, AArch64::qsub0);
2972 SelectLoad(Node, 3, AArch64::LD1Threev1d, AArch64::dsub0);
2975 SelectLoad(Node, 3, AArch64::LD3Threev2d, AArch64::qsub0);
2979 case Intrinsic::aarch64_neon_ld4:
2981 SelectLoad(Node, 4, AArch64::LD4Fourv8b, AArch64::dsub0);
2984 SelectLoad(Node, 4, AArch64::LD4Fourv16b, AArch64::qsub0);
2987 SelectLoad(Node, 4, AArch64::LD4Fourv4h, AArch64::dsub0);
2990 SelectLoad(Node, 4, AArch64::LD4Fourv8h, AArch64::qsub0);
2993 SelectLoad(Node, 4, AArch64::LD4Fourv2s, AArch64::dsub0);
2996 SelectLoad(Node, 4, AArch64::LD4Fourv4s, AArch64::qsub0);
2999 SelectLoad(Node, 4, AArch64::LD1Fourv1d, AArch64::dsub0);
3002 SelectLoad(Node, 4, AArch64::LD4Fourv2d, AArch64::qsub0);
3006 case Intrinsic::aarch64_neon_ld2r:
3008 SelectLoad(Node, 2, AArch64::LD2Rv8b, AArch64::dsub0);
3011 SelectLoad(Node, 2, AArch64::LD2Rv16b, AArch64::qsub0);
3014 SelectLoad(Node, 2, AArch64::LD2Rv4h, AArch64::dsub0);
3017 SelectLoad(Node, 2, AArch64::LD2Rv8h, AArch64::qsub0);
3020 SelectLoad(Node, 2, AArch64::LD2Rv2s, AArch64::dsub0);
3023 SelectLoad(Node, 2, AArch64::LD2Rv4s, AArch64::qsub0);
3026 SelectLoad(Node, 2, AArch64::LD2Rv1d, AArch64::dsub0);
3029 SelectLoad(Node, 2, AArch64::LD2Rv2d, AArch64::qsub0);
3033 case Intrinsic::aarch64_neon_ld3r:
3035 SelectLoad(Node, 3, AArch64::LD3Rv8b, AArch64::dsub0);
3038 SelectLoad(Node, 3, AArch64::LD3Rv16b, AArch64::qsub0);
3041 SelectLoad(Node, 3, AArch64::LD3Rv4h, AArch64::dsub0);
3044 SelectLoad(Node, 3, AArch64::LD3Rv8h, AArch64::qsub0);
3047 SelectLoad(Node, 3, AArch64::LD3Rv2s, AArch64::dsub0);
3050 SelectLoad(Node, 3, AArch64::LD3Rv4s, AArch64::qsub0);
3053 SelectLoad(Node, 3, AArch64::LD3Rv1d, AArch64::dsub0);
3056 SelectLoad(Node, 3, AArch64::LD3Rv2d, AArch64::qsub0);
3060 case Intrinsic::aarch64_neon_ld4r:
3062 SelectLoad(Node, 4, AArch64::LD4Rv8b, AArch64::dsub0);
3065 SelectLoad(Node, 4, AArch64::LD4Rv16b, AArch64::qsub0);
3068 SelectLoad(Node, 4, AArch64::LD4Rv4h, AArch64::dsub0);
3071 SelectLoad(Node, 4, AArch64::LD4Rv8h, AArch64::qsub0);
3074 SelectLoad(Node, 4, AArch64::LD4Rv2s, AArch64::dsub0);
3077 SelectLoad(Node, 4, AArch64::LD4Rv4s, AArch64::qsub0);
3080 SelectLoad(Node, 4, AArch64::LD4Rv1d, AArch64::dsub0);
3083 SelectLoad(Node, 4, AArch64::LD4Rv2d, AArch64::qsub0);
3087 case Intrinsic::aarch64_neon_ld2lane:
3089 SelectLoadLane(Node, 2, AArch64::LD2i8);
3093 SelectLoadLane(Node, 2, AArch64::LD2i16);
3097 SelectLoadLane(Node, 2, AArch64::LD2i32);
3101 SelectLoadLane(Node, 2, AArch64::LD2i64);
3105 case Intrinsic::aarch64_neon_ld3lane:
3107 SelectLoadLane(Node, 3, AArch64::LD3i8);
3111 SelectLoadLane(Node, 3, AArch64::LD3i16);
3115 SelectLoadLane(Node, 3, AArch64::LD3i32);
3119 SelectLoadLane(Node, 3, AArch64::LD3i64);
3123 case Intrinsic::aarch64_neon_ld4lane:
3125 SelectLoadLane(Node, 4, AArch64::LD4i8);
3129 SelectLoadLane(Node, 4, AArch64::LD4i16);
3133 SelectLoadLane(Node, 4, AArch64::LD4i32);
3137 SelectLoadLane(Node, 4, AArch64::LD4i64);
3144 unsigned IntNo = cast<ConstantSDNode>(Node->
getOperand(0))->getZExtValue();
3148 case Intrinsic::aarch64_neon_tbl2:
3149 SelectTable(Node, 2,
3150 VT ==
MVT::v8i8 ? AArch64::TBLv8i8Two : AArch64::TBLv16i8Two,
3153 case Intrinsic::aarch64_neon_tbl3:
3154 SelectTable(Node, 3, VT ==
MVT::v8i8 ? AArch64::TBLv8i8Three
3155 : AArch64::TBLv16i8Three,
3158 case Intrinsic::aarch64_neon_tbl4:
3159 SelectTable(Node, 4, VT ==
MVT::v8i8 ? AArch64::TBLv8i8Four
3160 : AArch64::TBLv16i8Four,
3163 case Intrinsic::aarch64_neon_tbx2:
3164 SelectTable(Node, 2,
3165 VT ==
MVT::v8i8 ? AArch64::TBXv8i8Two : AArch64::TBXv16i8Two,
3168 case Intrinsic::aarch64_neon_tbx3:
3169 SelectTable(Node, 3, VT ==
MVT::v8i8 ? AArch64::TBXv8i8Three
3170 : AArch64::TBXv16i8Three,
3173 case Intrinsic::aarch64_neon_tbx4:
3174 SelectTable(Node, 4, VT ==
MVT::v8i8 ? AArch64::TBXv8i8Four
3175 : AArch64::TBXv16i8Four,
3178 case Intrinsic::aarch64_neon_smull:
3179 case Intrinsic::aarch64_neon_umull:
3180 if (tryMULLV64LaneV128(IntNo, Node))
3187 unsigned IntNo = cast<ConstantSDNode>(Node->
getOperand(1))->getZExtValue();
3193 case Intrinsic::aarch64_neon_st1x2: {
3195 SelectStore(Node, 2, AArch64::ST1Twov8b);
3198 SelectStore(Node, 2, AArch64::ST1Twov16b);
3201 SelectStore(Node, 2, AArch64::ST1Twov4h);
3204 SelectStore(Node, 2, AArch64::ST1Twov8h);
3207 SelectStore(Node, 2, AArch64::ST1Twov2s);
3210 SelectStore(Node, 2, AArch64::ST1Twov4s);
3213 SelectStore(Node, 2, AArch64::ST1Twov2d);
3216 SelectStore(Node, 2, AArch64::ST1Twov1d);
3221 case Intrinsic::aarch64_neon_st1x3: {
3223 SelectStore(Node, 3, AArch64::ST1Threev8b);
3226 SelectStore(Node, 3, AArch64::ST1Threev16b);
3229 SelectStore(Node, 3, AArch64::ST1Threev4h);
3232 SelectStore(Node, 3, AArch64::ST1Threev8h);
3235 SelectStore(Node, 3, AArch64::ST1Threev2s);
3238 SelectStore(Node, 3, AArch64::ST1Threev4s);
3241 SelectStore(Node, 3, AArch64::ST1Threev2d);
3244 SelectStore(Node, 3, AArch64::ST1Threev1d);
3249 case Intrinsic::aarch64_neon_st1x4: {
3251 SelectStore(Node, 4, AArch64::ST1Fourv8b);
3254 SelectStore(Node, 4, AArch64::ST1Fourv16b);
3257 SelectStore(Node, 4, AArch64::ST1Fourv4h);
3260 SelectStore(Node, 4, AArch64::ST1Fourv8h);
3263 SelectStore(Node, 4, AArch64::ST1Fourv2s);
3266 SelectStore(Node, 4, AArch64::ST1Fourv4s);
3269 SelectStore(Node, 4, AArch64::ST1Fourv2d);
3272 SelectStore(Node, 4, AArch64::ST1Fourv1d);
3277 case Intrinsic::aarch64_neon_st2: {
3279 SelectStore(Node, 2, AArch64::ST2Twov8b);
3282 SelectStore(Node, 2, AArch64::ST2Twov16b);
3285 SelectStore(Node, 2, AArch64::ST2Twov4h);
3288 SelectStore(Node, 2, AArch64::ST2Twov8h);
3291 SelectStore(Node, 2, AArch64::ST2Twov2s);
3294 SelectStore(Node, 2, AArch64::ST2Twov4s);
3297 SelectStore(Node, 2, AArch64::ST2Twov2d);
3300 SelectStore(Node, 2, AArch64::ST1Twov1d);
3305 case Intrinsic::aarch64_neon_st3: {
3307 SelectStore(Node, 3, AArch64::ST3Threev8b);
3310 SelectStore(Node, 3, AArch64::ST3Threev16b);
3313 SelectStore(Node, 3, AArch64::ST3Threev4h);
3316 SelectStore(Node, 3, AArch64::ST3Threev8h);
3319 SelectStore(Node, 3, AArch64::ST3Threev2s);
3322 SelectStore(Node, 3, AArch64::ST3Threev4s);
3325 SelectStore(Node, 3, AArch64::ST3Threev2d);
3328 SelectStore(Node, 3, AArch64::ST1Threev1d);
3333 case Intrinsic::aarch64_neon_st4: {
3335 SelectStore(Node, 4, AArch64::ST4Fourv8b);
3338 SelectStore(Node, 4, AArch64::ST4Fourv16b);
3341 SelectStore(Node, 4, AArch64::ST4Fourv4h);
3344 SelectStore(Node, 4, AArch64::ST4Fourv8h);
3347 SelectStore(Node, 4, AArch64::ST4Fourv2s);
3350 SelectStore(Node, 4, AArch64::ST4Fourv4s);
3353 SelectStore(Node, 4, AArch64::ST4Fourv2d);
3356 SelectStore(Node, 4, AArch64::ST1Fourv1d);
3361 case Intrinsic::aarch64_neon_st2lane: {
3363 SelectStoreLane(Node, 2, AArch64::ST2i8);
3367 SelectStoreLane(Node, 2, AArch64::ST2i16);
3371 SelectStoreLane(Node, 2, AArch64::ST2i32);
3375 SelectStoreLane(Node, 2, AArch64::ST2i64);
3380 case Intrinsic::aarch64_neon_st3lane: {
3382 SelectStoreLane(Node, 3, AArch64::ST3i8);
3386 SelectStoreLane(Node, 3, AArch64::ST3i16);
3390 SelectStoreLane(Node, 3, AArch64::ST3i32);
3394 SelectStoreLane(Node, 3, AArch64::ST3i64);
3399 case Intrinsic::aarch64_neon_st4lane: {
3401 SelectStoreLane(Node, 4, AArch64::ST4i8);
3405 SelectStoreLane(Node, 4, AArch64::ST4i16);
3409 SelectStoreLane(Node, 4, AArch64::ST4i32);
3413 SelectStoreLane(Node, 4, AArch64::ST4i64);
3423 SelectPostLoad(Node, 2, AArch64::LD2Twov8b_POST, AArch64::dsub0);
3426 SelectPostLoad(Node, 2, AArch64::LD2Twov16b_POST, AArch64::qsub0);
3429 SelectPostLoad(Node, 2, AArch64::LD2Twov4h_POST, AArch64::dsub0);
3432 SelectPostLoad(Node, 2, AArch64::LD2Twov8h_POST, AArch64::qsub0);
3435 SelectPostLoad(Node, 2, AArch64::LD2Twov2s_POST, AArch64::dsub0);
3438 SelectPostLoad(Node, 2, AArch64::LD2Twov4s_POST, AArch64::qsub0);
3441 SelectPostLoad(Node, 2, AArch64::LD1Twov1d_POST, AArch64::dsub0);
3444 SelectPostLoad(Node, 2, AArch64::LD2Twov2d_POST, AArch64::qsub0);
3451 SelectPostLoad(Node, 3, AArch64::LD3Threev8b_POST, AArch64::dsub0);
3454 SelectPostLoad(Node, 3, AArch64::LD3Threev16b_POST, AArch64::qsub0);
3457 SelectPostLoad(Node, 3, AArch64::LD3Threev4h_POST, AArch64::dsub0);
3460 SelectPostLoad(Node, 3, AArch64::LD3Threev8h_POST, AArch64::qsub0);
3463 SelectPostLoad(Node, 3, AArch64::LD3Threev2s_POST, AArch64::dsub0);
3466 SelectPostLoad(Node, 3, AArch64::LD3Threev4s_POST, AArch64::qsub0);
3469 SelectPostLoad(Node, 3, AArch64::LD1Threev1d_POST, AArch64::dsub0);
3472 SelectPostLoad(Node, 3, AArch64::LD3Threev2d_POST, AArch64::qsub0);
3479 SelectPostLoad(Node, 4, AArch64::LD4Fourv8b_POST, AArch64::dsub0);
3482 SelectPostLoad(Node, 4, AArch64::LD4Fourv16b_POST, AArch64::qsub0);
3485 SelectPostLoad(Node, 4, AArch64::LD4Fourv4h_POST, AArch64::dsub0);
3488 SelectPostLoad(Node, 4, AArch64::LD4Fourv8h_POST, AArch64::qsub0);
3491 SelectPostLoad(Node, 4, AArch64::LD4Fourv2s_POST, AArch64::dsub0);
3494 SelectPostLoad(Node, 4, AArch64::LD4Fourv4s_POST, AArch64::qsub0);
3497 SelectPostLoad(Node, 4, AArch64::LD1Fourv1d_POST, AArch64::dsub0);
3500 SelectPostLoad(Node, 4, AArch64::LD4Fourv2d_POST, AArch64::qsub0);
3507 SelectPostLoad(Node, 2, AArch64::LD1Twov8b_POST, AArch64::dsub0);
3510 SelectPostLoad(Node, 2, AArch64::LD1Twov16b_POST, AArch64::qsub0);
3513 SelectPostLoad(Node, 2, AArch64::LD1Twov4h_POST, AArch64::dsub0);
3516 SelectPostLoad(Node, 2, AArch64::LD1Twov8h_POST, AArch64::qsub0);
3519 SelectPostLoad(Node, 2, AArch64::LD1Twov2s_POST, AArch64::dsub0);
3522 SelectPostLoad(Node, 2, AArch64::LD1Twov4s_POST, AArch64::qsub0);
3525 SelectPostLoad(Node, 2, AArch64::LD1Twov1d_POST, AArch64::dsub0);
3528 SelectPostLoad(Node, 2, AArch64::LD1Twov2d_POST, AArch64::qsub0);
3535 SelectPostLoad(Node, 3, AArch64::LD1Threev8b_POST, AArch64::dsub0);
3538 SelectPostLoad(Node, 3, AArch64::LD1Threev16b_POST, AArch64::qsub0);
3541 SelectPostLoad(Node, 3, AArch64::LD1Threev4h_POST, AArch64::dsub0);
3544 SelectPostLoad(Node, 3, AArch64::LD1Threev8h_POST, AArch64::qsub0);
3547 SelectPostLoad(Node, 3, AArch64::LD1Threev2s_POST, AArch64::dsub0);
3550 SelectPostLoad(Node, 3, AArch64::LD1Threev4s_POST, AArch64::qsub0);
3553 SelectPostLoad(Node, 3, AArch64::LD1Threev1d_POST, AArch64::dsub0);
3556 SelectPostLoad(Node, 3, AArch64::LD1Threev2d_POST, AArch64::qsub0);
3563 SelectPostLoad(Node, 4, AArch64::LD1Fourv8b_POST, AArch64::dsub0);
3566 SelectPostLoad(Node, 4, AArch64::LD1Fourv16b_POST, AArch64::qsub0);
3569 SelectPostLoad(Node, 4, AArch64::LD1Fourv4h_POST, AArch64::dsub0);
3572 SelectPostLoad(Node, 4, AArch64::LD1Fourv8h_POST, AArch64::qsub0);
3575 SelectPostLoad(Node, 4, AArch64::LD1Fourv2s_POST, AArch64::dsub0);
3578 SelectPostLoad(Node, 4, AArch64::LD1Fourv4s_POST, AArch64::qsub0);
3581 SelectPostLoad(Node, 4, AArch64::LD1Fourv1d_POST, AArch64::dsub0);
3584 SelectPostLoad(Node, 4, AArch64::LD1Fourv2d_POST, AArch64::qsub0);
3591 SelectPostLoad(Node, 1, AArch64::LD1Rv8b_POST, AArch64::dsub0);
3594 SelectPostLoad(Node, 1, AArch64::LD1Rv16b_POST, AArch64::qsub0);
3597 SelectPostLoad(Node, 1, AArch64::LD1Rv4h_POST, AArch64::dsub0);
3600 SelectPostLoad(Node, 1, AArch64::LD1Rv8h_POST, AArch64::qsub0);
3603 SelectPostLoad(Node, 1, AArch64::LD1Rv2s_POST, AArch64::dsub0);
3606 SelectPostLoad(Node, 1, AArch64::LD1Rv4s_POST, AArch64::qsub0);
3609 SelectPostLoad(Node, 1, AArch64::LD1Rv1d_POST, AArch64::dsub0);
3612 SelectPostLoad(Node, 1, AArch64::LD1Rv2d_POST, AArch64::qsub0);
3619 SelectPostLoad(Node, 2, AArch64::LD2Rv8b_POST, AArch64::dsub0);
3622 SelectPostLoad(Node, 2, AArch64::LD2Rv16b_POST, AArch64::qsub0);
3625 SelectPostLoad(Node, 2, AArch64::LD2Rv4h_POST, AArch64::dsub0);
3628 SelectPostLoad(Node, 2, AArch64::LD2Rv8h_POST, AArch64::qsub0);
3631 SelectPostLoad(Node, 2, AArch64::LD2Rv2s_POST, AArch64::dsub0);
3634 SelectPostLoad(Node, 2, AArch64::LD2Rv4s_POST, AArch64::qsub0);
3637 SelectPostLoad(Node, 2, AArch64::LD2Rv1d_POST, AArch64::dsub0);
3640 SelectPostLoad(Node, 2, AArch64::LD2Rv2d_POST, AArch64::qsub0);
3647 SelectPostLoad(Node, 3, AArch64::LD3Rv8b_POST, AArch64::dsub0);
3650 SelectPostLoad(Node, 3, AArch64::LD3Rv16b_POST, AArch64::qsub0);
3653 SelectPostLoad(Node, 3, AArch64::LD3Rv4h_POST, AArch64::dsub0);
3656 SelectPostLoad(Node, 3, AArch64::LD3Rv8h_POST, AArch64::qsub0);
3659 SelectPostLoad(Node, 3, AArch64::LD3Rv2s_POST, AArch64::dsub0);
3662 SelectPostLoad(Node, 3, AArch64::LD3Rv4s_POST, AArch64::qsub0);
3665 SelectPostLoad(Node, 3, AArch64::LD3Rv1d_POST, AArch64::dsub0);
3668 SelectPostLoad(Node, 3, AArch64::LD3Rv2d_POST, AArch64::qsub0);
3675 SelectPostLoad(Node, 4, AArch64::LD4Rv8b_POST, AArch64::dsub0);
3678 SelectPostLoad(Node, 4, AArch64::LD4Rv16b_POST, AArch64::qsub0);
3681 SelectPostLoad(Node, 4, AArch64::LD4Rv4h_POST, AArch64::dsub0);
3684 SelectPostLoad(Node, 4, AArch64::LD4Rv8h_POST, AArch64::qsub0);
3687 SelectPostLoad(Node, 4, AArch64::LD4Rv2s_POST, AArch64::dsub0);
3690 SelectPostLoad(Node, 4, AArch64::LD4Rv4s_POST, AArch64::qsub0);
3693 SelectPostLoad(Node, 4, AArch64::LD4Rv1d_POST, AArch64::dsub0);
3696 SelectPostLoad(Node, 4, AArch64::LD4Rv2d_POST, AArch64::qsub0);
3703 SelectPostLoadLane(Node, 1, AArch64::LD1i8_POST);
3707 SelectPostLoadLane(Node, 1, AArch64::LD1i16_POST);
3711 SelectPostLoadLane(Node, 1, AArch64::LD1i32_POST);
3715 SelectPostLoadLane(Node, 1, AArch64::LD1i64_POST);
3722 SelectPostLoadLane(Node, 2, AArch64::LD2i8_POST);
3726 SelectPostLoadLane(Node, 2, AArch64::LD2i16_POST);
3730 SelectPostLoadLane(Node, 2, AArch64::LD2i32_POST);
3734 SelectPostLoadLane(Node, 2, AArch64::LD2i64_POST);
3741 SelectPostLoadLane(Node, 3, AArch64::LD3i8_POST);
3745 SelectPostLoadLane(Node, 3, AArch64::LD3i16_POST);
3749 SelectPostLoadLane(Node, 3, AArch64::LD3i32_POST);
3753 SelectPostLoadLane(Node, 3, AArch64::LD3i64_POST);
3760 SelectPostLoadLane(Node, 4, AArch64::LD4i8_POST);
3764 SelectPostLoadLane(Node, 4, AArch64::LD4i16_POST);
3768 SelectPostLoadLane(Node, 4, AArch64::LD4i32_POST);
3772 SelectPostLoadLane(Node, 4, AArch64::LD4i64_POST);
3780 SelectPostStore(Node, 2, AArch64::ST2Twov8b_POST);
3783 SelectPostStore(Node, 2, AArch64::ST2Twov16b_POST);
3786 SelectPostStore(Node, 2, AArch64::ST2Twov4h_POST);
3789 SelectPostStore(Node, 2, AArch64::ST2Twov8h_POST);
3792 SelectPostStore(Node, 2, AArch64::ST2Twov2s_POST);
3795 SelectPostStore(Node, 2, AArch64::ST2Twov4s_POST);
3798 SelectPostStore(Node, 2, AArch64::ST2Twov2d_POST);
3801 SelectPostStore(Node, 2, AArch64::ST1Twov1d_POST);
3809 SelectPostStore(Node, 3, AArch64::ST3Threev8b_POST);
3812 SelectPostStore(Node, 3, AArch64::ST3Threev16b_POST);
3815 SelectPostStore(Node, 3, AArch64::ST3Threev4h_POST);
3818 SelectPostStore(Node, 3, AArch64::ST3Threev8h_POST);
3821 SelectPostStore(Node, 3, AArch64::ST3Threev2s_POST);
3824 SelectPostStore(Node, 3, AArch64::ST3Threev4s_POST);
3827 SelectPostStore(Node, 3, AArch64::ST3Threev2d_POST);
3830 SelectPostStore(Node, 3, AArch64::ST1Threev1d_POST);
3838 SelectPostStore(Node, 4, AArch64::ST4Fourv8b_POST);
3841 SelectPostStore(Node, 4, AArch64::ST4Fourv16b_POST);
3844 SelectPostStore(Node, 4, AArch64::ST4Fourv4h_POST);
3847 SelectPostStore(Node, 4, AArch64::ST4Fourv8h_POST);
3850 SelectPostStore(Node, 4, AArch64::ST4Fourv2s_POST);
3853 SelectPostStore(Node, 4, AArch64::ST4Fourv4s_POST);
3856 SelectPostStore(Node, 4, AArch64::ST4Fourv2d_POST);
3859 SelectPostStore(Node, 4, AArch64::ST1Fourv1d_POST);
3867 SelectPostStore(Node, 2, AArch64::ST1Twov8b_POST);
3870 SelectPostStore(Node, 2, AArch64::ST1Twov16b_POST);
3873 SelectPostStore(Node, 2, AArch64::ST1Twov4h_POST);
3876 SelectPostStore(Node, 2, AArch64::ST1Twov8h_POST);
3879 SelectPostStore(Node, 2, AArch64::ST1Twov2s_POST);
3882 SelectPostStore(Node, 2, AArch64::ST1Twov4s_POST);
3885 SelectPostStore(Node, 2, AArch64::ST1Twov1d_POST);
3888 SelectPostStore(Node, 2, AArch64::ST1Twov2d_POST);
3896 SelectPostStore(Node, 3, AArch64::ST1Threev8b_POST);
3899 SelectPostStore(Node, 3, AArch64::ST1Threev16b_POST);
3902 SelectPostStore(Node, 3, AArch64::ST1Threev4h_POST);
3905 SelectPostStore(Node, 3, AArch64::ST1Threev8h_POST);
3908 SelectPostStore(Node, 3, AArch64::ST1Threev2s_POST);
3911 SelectPostStore(Node, 3, AArch64::ST1Threev4s_POST);
3914 SelectPostStore(Node, 3, AArch64::ST1Threev1d_POST);
3917 SelectPostStore(Node, 3, AArch64::ST1Threev2d_POST);
3925 SelectPostStore(Node, 4, AArch64::ST1Fourv8b_POST);
3928 SelectPostStore(Node, 4, AArch64::ST1Fourv16b_POST);
3931 SelectPostStore(Node, 4, AArch64::ST1Fourv4h_POST);
3934 SelectPostStore(Node, 4, AArch64::ST1Fourv8h_POST);
3937 SelectPostStore(Node, 4, AArch64::ST1Fourv2s_POST);
3940 SelectPostStore(Node, 4, AArch64::ST1Fourv4s_POST);
3943 SelectPostStore(Node, 4, AArch64::ST1Fourv1d_POST);
3946 SelectPostStore(Node, 4, AArch64::ST1Fourv2d_POST);
3954 SelectPostStoreLane(Node, 2, AArch64::ST2i8_POST);
3958 SelectPostStoreLane(Node, 2, AArch64::ST2i16_POST);
3962 SelectPostStoreLane(Node, 2, AArch64::ST2i32_POST);
3966 SelectPostStoreLane(Node, 2, AArch64::ST2i64_POST);
3974 SelectPostStoreLane(Node, 3, AArch64::ST3i8_POST);
3978 SelectPostStoreLane(Node, 3, AArch64::ST3i16_POST);
3982 SelectPostStoreLane(Node, 3, AArch64::ST3i32_POST);
3986 SelectPostStoreLane(Node, 3, AArch64::ST3i64_POST);
3994 SelectPostStoreLane(Node, 4, AArch64::ST4i8_POST);
3998 SelectPostStoreLane(Node, 4, AArch64::ST4i16_POST);
4002 SelectPostStoreLane(Node, 4, AArch64::ST4i32_POST);
4006 SelectPostStoreLane(Node, 4, AArch64::ST4i64_POST);
4021 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)
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...
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
void flipAllBits()
Toggle every bit to its opposite value.
uint64_t getZExtValue() const
Get zero extended value.
DiagnosticInfoOptimizationBase::Argument NV
EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR (an vector value) starting with the ...
static MVT getVectorVT(MVT VT, unsigned NumElements)
bool hasOneUse() const
Return true if there is exactly one node using value ResNo of Node.
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...
Type * getValueType() const
const GlobalValue * getGlobal() const
static bool isSeveralBitsExtractOpFromShr(SDNode *N, unsigned &Opc, SDValue &Opd0, unsigned &LSB, unsigned &MSB)
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
static bool isOpcWithIntImmediate(const SDNode *N, unsigned Opc, uint64_t &Imm)
unsigned getID() const
Return the register class ID number.
bool isUnindexed() const
Return true if this is NOT a pre/post inc/dec load/store.
unsigned getNumOperands() const
Return the number of values used by this operation.
unsigned getValueSizeInBits() const
Returns the size of the value in bits.
const SDValue & getOperand(unsigned Num) const
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
void setNodeId(int Id)
Set unique node id.
const SDValue & getBasePtr() const
INSERT_SUBVECTOR(VECTOR1, VECTOR2, IDX) - Returns a vector with VECTOR2 inserted into VECTOR1 at the ...
APInt zextOrTrunc(unsigned width) const
Zero extend or truncate to width.
bool optForSize() const
Optimize this function for size (-Os) or minimum size (-Oz).
RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) This node represents a target in...
A description of a memory reference used in the backend.
static bool checkV64LaneV128(SDValue Op0, SDValue Op1, SDValue &StdOp, SDValue &LaneOp, int &LaneIdx)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
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.
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
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.
Reg
All possible values of the reg field in the ModR/M byte.
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.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
EVT getVectorElementType() const
Given a vector type, return the type of each element.
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
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)...
EVT getMemoryVT() const
Return the type of the in-memory value.
SDValue getTargetConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
unsigned getBitWidth() const
Get the bit width of this value.
RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) This node represents a target intrinsic fun...
size_t size() const
size - Get the array size.
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.
bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
SDNode * getNode() const
get the SDNode which holds the desired result
static unsigned getShiftValue(unsigned Imm)
getShiftValue - Extract the shift value.
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...
const SDValue & getOperand(unsigned i) const
The instances of the Type class are immutable: once they are created, they are never changed...
static void getUsefulBitsFromBFM(SDValue Op, SDValue Orig, APInt &UsefulBits, unsigned Depth)
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
const Constant * getConstVal() const
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...
unsigned getScalarValueSizeInBits() const
unsigned getBitWidth() const
Return the number of bits in the APInt.
unsigned getOpcode() const
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...
unsigned countPopulation() const
Count the number of bits set.
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...
ISD::MemIndexedMode getAddressingMode() const
Return the addressing mode for this load or store: unindexed, pre-inc, pre-dec, post-inc, or post-dec.
unsigned countTrailingZeros() const
Count the number of trailing zero bits.
static SDValue Widen(SelectionDAG *CurDAG, SDValue N)
const SDValue & getOffset() const
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
const MDOperand & getOperand(unsigned I) const
static void getUsefulBitsFromBitfieldMoveOpd(SDValue Op, APInt &UsefulBits, uint64_t Imm, uint64_t MSB, unsigned Depth)
void dump() const
Dump this node, for debugging.
static bool isStrongerThanMonotonic(AtomicOrdering ao)
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.
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...
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
SDNode * SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT)
These are used for target selectors to mutate the specified node to have the specified return type...
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...
An SDNode that represents everything that will be needed to construct a MachineInstr.
const SDValue & getChain() 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...
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.
ISD::LoadExtType getExtensionType() const
Return whether this is a plain node, or one of the varieties of value-extending loads.
Class for arbitrary precision integers.
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
iterator_range< use_iterator > uses()
int64_t getSExtValue() const
op_iterator op_begin() const
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...
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
static APInt getBitsSet(unsigned numBits, unsigned loBit, unsigned hiBit)
Get a value with a block of bits set.
llvm_unreachable("Unknown RegBank!")
static bool isBitfieldExtractOpFromSExtInReg(SDNode *N, unsigned &Opc, SDValue &Opd0, unsigned &Immr, unsigned &Imms)
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)
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...
unsigned getSizeInBits() const
Return the size of the specified value type in bits.
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
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)
EVT getValueType() const
Return the ValueType of the referenced return value.
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)
bool is128BitVector() const
Return true if this is a 128-bit vector type.
static void getUsefulBitsFromUBFM(SDValue Op, APInt &UsefulBits, unsigned Depth)
const MDNode * getMD() const
unsigned getAlignment() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static void getUsefulBitsFromAndWithImmediate(SDValue Op, APInt &UsefulBits, unsigned Depth)
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...
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.
unsigned countLeadingZeros() const
The APInt version of the countLeadingZeros functions in MathExtras.h.
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.
void dumpr() const
Dump (recursively) this node and its use-def subgraph.
OUTCHAIN = ATOMIC_STORE(INCHAIN, ptr, val) This corresponds to "store atomic" instruction.
TRUNCATE - Completely drop the high bits.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
MVT getSimpleValueType(unsigned ResNo) const
Return the type of a specified result as a simple type.
bool is64BitVector() const
Return true if this is a 64-bit vector type.
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.
virtual const TargetRegisterClass * getPointerRegClass(const MachineFunction &MF, unsigned Kind=0) const
Returns a TargetRegisterClass used for pointer values.
Val, OUTCHAIN = ATOMIC_LOAD(INCHAIN, ptr) This corresponds to "load atomic" instruction.
static bool tryBitfieldInsertOpFromOrAndImm(SDNode *N, SelectionDAG *CurDAG)
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
bool isMachineOpcode() const
Test if this node has a post-isel opcode, directly corresponding to a MachineInstr opcode...
unsigned getMachineOpcode() const
This may only be called if isMachineOpcode returns true.
uint64_t getZExtValue() const
MemIndexedMode
MemIndexedMode enum - This enum defines the load / store indexed addressing modes.
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
This class is used to represent ISD::LOAD nodes.