71 SVEPredicateAsCounter,
77enum class MatrixKind {
Array, Tile, Row, Col };
79enum RegConstraintEqualityTy {
94 static PrefixInfo CreateFromInst(
const MCInst &Inst,
uint64_t TSFlags) {
97 case AArch64::MOVPRFX_ZZ:
101 case AArch64::MOVPRFX_ZPmZ_B:
102 case AArch64::MOVPRFX_ZPmZ_H:
103 case AArch64::MOVPRFX_ZPmZ_S:
104 case AArch64::MOVPRFX_ZPmZ_D:
109 "No destructive element size set for movprfx");
113 case AArch64::MOVPRFX_ZPzZ_B:
114 case AArch64::MOVPRFX_ZPzZ_H:
115 case AArch64::MOVPRFX_ZPzZ_S:
116 case AArch64::MOVPRFX_ZPzZ_D:
121 "No destructive element size set for movprfx");
132 PrefixInfo() =
default;
133 bool isActive()
const {
return Active; }
135 unsigned getElementSize()
const {
148 unsigned ElementSize;
164 std::string &Suggestion);
166 unsigned matchRegisterNameAlias(
StringRef Name, RegKind Kind);
168 bool parseSymbolicImmVal(
const MCExpr *&ImmVal);
174 bool invertCondCode);
175 bool parseImmExpr(int64_t &Out);
177 bool parseRegisterInRange(
unsigned &Out,
unsigned Base,
unsigned First,
183 bool parseAuthExpr(
const MCExpr *&Res,
SMLoc &EndLoc);
185 bool parseDirectiveArch(
SMLoc L);
186 bool parseDirectiveArchExtension(
SMLoc L);
187 bool parseDirectiveCPU(
SMLoc L);
188 bool parseDirectiveInst(
SMLoc L);
190 bool parseDirectiveTLSDescCall(
SMLoc L);
193 bool parseDirectiveLtorg(
SMLoc L);
196 bool parseDirectiveUnreq(
SMLoc L);
197 bool parseDirectiveCFINegateRAState();
198 bool parseDirectiveCFINegateRAStateWithPC();
199 bool parseDirectiveCFIBKeyFrame();
200 bool parseDirectiveCFIMTETaggedFrame();
202 bool parseDirectiveVariantPCS(
SMLoc L);
204 bool parseDirectiveSEHAllocStack(
SMLoc L);
205 bool parseDirectiveSEHPrologEnd(
SMLoc L);
206 bool parseDirectiveSEHSaveR19R20X(
SMLoc L);
207 bool parseDirectiveSEHSaveFPLR(
SMLoc L);
208 bool parseDirectiveSEHSaveFPLRX(
SMLoc L);
209 bool parseDirectiveSEHSaveReg(
SMLoc L);
210 bool parseDirectiveSEHSaveRegX(
SMLoc L);
211 bool parseDirectiveSEHSaveRegP(
SMLoc L);
212 bool parseDirectiveSEHSaveRegPX(
SMLoc L);
213 bool parseDirectiveSEHSaveLRPair(
SMLoc L);
214 bool parseDirectiveSEHSaveFReg(
SMLoc L);
215 bool parseDirectiveSEHSaveFRegX(
SMLoc L);
216 bool parseDirectiveSEHSaveFRegP(
SMLoc L);
217 bool parseDirectiveSEHSaveFRegPX(
SMLoc L);
218 bool parseDirectiveSEHSetFP(
SMLoc L);
219 bool parseDirectiveSEHAddFP(
SMLoc L);
220 bool parseDirectiveSEHNop(
SMLoc L);
221 bool parseDirectiveSEHSaveNext(
SMLoc L);
222 bool parseDirectiveSEHEpilogStart(
SMLoc L);
223 bool parseDirectiveSEHEpilogEnd(
SMLoc L);
224 bool parseDirectiveSEHTrapFrame(
SMLoc L);
225 bool parseDirectiveSEHMachineFrame(
SMLoc L);
226 bool parseDirectiveSEHContext(
SMLoc L);
227 bool parseDirectiveSEHECContext(
SMLoc L);
228 bool parseDirectiveSEHClearUnwoundToCall(
SMLoc L);
229 bool parseDirectiveSEHPACSignLR(
SMLoc L);
230 bool parseDirectiveSEHSaveAnyReg(
SMLoc L,
bool Paired,
bool Writeback);
232 bool validateInstruction(
MCInst &Inst,
SMLoc &IDLoc,
234 unsigned getNumRegsForRegKind(RegKind K);
238 bool MatchingInlineAsm)
override;
242#define GET_ASSEMBLER_HEADER
243#include "AArch64GenAsmMatcher.inc"
257 template <
bool IsSVEPrefetch = false>
264 template <
bool AddFPZeroAsLiteral>
272 template <
bool ParseShiftExtend,
273 RegConstraintEqualityTy EqTy = RegConstraintEqualityTy::EqualsReg>
276 template <
bool ParseShiftExtend,
bool ParseSuffix>
278 template <RegKind RK>
282 template <RegKind VectorKind>
284 bool ExpectMatch =
false);
294 enum AArch64MatchResultTy {
296#define GET_OPERAND_DIAGNOSTIC_TYPES
297#include "AArch64GenAsmMatcher.inc"
300 bool IsWindowsArm64EC;
331 SMLoc &EndLoc)
override;
334 unsigned Kind)
override;
338 static bool classifySymbolRef(
const MCExpr *Expr,
371 SMLoc StartLoc, EndLoc;
380 struct ShiftExtendOp {
383 bool HasExplicitAmount;
393 RegConstraintEqualityTy EqualityTy;
409 ShiftExtendOp ShiftExtend;
414 unsigned ElementWidth;
418 struct MatrixTileListOp {
419 unsigned RegMask = 0;
422 struct VectorListOp {
426 unsigned NumElements;
427 unsigned ElementWidth;
428 RegKind RegisterKind;
431 struct VectorIndexOp {
439 struct ShiftedImmOp {
441 unsigned ShiftAmount;
502 unsigned PStateField;
508 struct MatrixRegOp MatrixReg;
509 struct MatrixTileListOp MatrixTileList;
510 struct VectorListOp VectorList;
511 struct VectorIndexOp VectorIndex;
513 struct ShiftedImmOp ShiftedImm;
514 struct ImmRangeOp ImmRange;
516 struct FPImmOp FPImm;
518 struct SysRegOp SysReg;
519 struct SysCRImmOp SysCRImm;
521 struct PSBHintOp PSBHint;
522 struct PHintOp PHint;
523 struct BTIHintOp BTIHint;
524 struct ShiftExtendOp ShiftExtend;
537 StartLoc =
o.StartLoc;
547 ShiftedImm =
o.ShiftedImm;
550 ImmRange =
o.ImmRange;
564 case k_MatrixRegister:
565 MatrixReg =
o.MatrixReg;
567 case k_MatrixTileList:
568 MatrixTileList =
o.MatrixTileList;
571 VectorList =
o.VectorList;
574 VectorIndex =
o.VectorIndex;
580 SysCRImm =
o.SysCRImm;
595 ShiftExtend =
o.ShiftExtend;
604 SMLoc getStartLoc()
const override {
return StartLoc; }
606 SMLoc getEndLoc()
const override {
return EndLoc; }
609 assert(Kind == k_Token &&
"Invalid access!");
613 bool isTokenSuffix()
const {
614 assert(Kind == k_Token &&
"Invalid access!");
618 const MCExpr *getImm()
const {
619 assert(Kind == k_Immediate &&
"Invalid access!");
623 const MCExpr *getShiftedImmVal()
const {
624 assert(Kind == k_ShiftedImm &&
"Invalid access!");
625 return ShiftedImm.Val;
628 unsigned getShiftedImmShift()
const {
629 assert(Kind == k_ShiftedImm &&
"Invalid access!");
630 return ShiftedImm.ShiftAmount;
633 unsigned getFirstImmVal()
const {
634 assert(Kind == k_ImmRange &&
"Invalid access!");
635 return ImmRange.First;
638 unsigned getLastImmVal()
const {
639 assert(Kind == k_ImmRange &&
"Invalid access!");
640 return ImmRange.Last;
644 assert(Kind == k_CondCode &&
"Invalid access!");
649 assert (Kind == k_FPImm &&
"Invalid access!");
650 return APFloat(APFloat::IEEEdouble(),
APInt(64, FPImm.Val,
true));
653 bool getFPImmIsExact()
const {
654 assert (Kind == k_FPImm &&
"Invalid access!");
655 return FPImm.IsExact;
658 unsigned getBarrier()
const {
659 assert(Kind == k_Barrier &&
"Invalid access!");
664 assert(Kind == k_Barrier &&
"Invalid access!");
668 bool getBarriernXSModifier()
const {
669 assert(Kind == k_Barrier &&
"Invalid access!");
674 assert(Kind == k_Register &&
"Invalid access!");
678 unsigned getMatrixReg()
const {
679 assert(Kind == k_MatrixRegister &&
"Invalid access!");
680 return MatrixReg.RegNum;
683 unsigned getMatrixElementWidth()
const {
684 assert(Kind == k_MatrixRegister &&
"Invalid access!");
685 return MatrixReg.ElementWidth;
688 MatrixKind getMatrixKind()
const {
689 assert(Kind == k_MatrixRegister &&
"Invalid access!");
690 return MatrixReg.Kind;
693 unsigned getMatrixTileListRegMask()
const {
694 assert(isMatrixTileList() &&
"Invalid access!");
695 return MatrixTileList.RegMask;
698 RegConstraintEqualityTy getRegEqualityTy()
const {
699 assert(Kind == k_Register &&
"Invalid access!");
700 return Reg.EqualityTy;
703 unsigned getVectorListStart()
const {
704 assert(Kind == k_VectorList &&
"Invalid access!");
705 return VectorList.RegNum;
708 unsigned getVectorListCount()
const {
709 assert(Kind == k_VectorList &&
"Invalid access!");
710 return VectorList.Count;
713 unsigned getVectorListStride()
const {
714 assert(Kind == k_VectorList &&
"Invalid access!");
715 return VectorList.Stride;
718 int getVectorIndex()
const {
719 assert(Kind == k_VectorIndex &&
"Invalid access!");
720 return VectorIndex.Val;
724 assert(Kind == k_SysReg &&
"Invalid access!");
725 return StringRef(SysReg.Data, SysReg.Length);
728 unsigned getSysCR()
const {
729 assert(Kind == k_SysCR &&
"Invalid access!");
733 unsigned getPrefetch()
const {
734 assert(Kind == k_Prefetch &&
"Invalid access!");
738 unsigned getPSBHint()
const {
739 assert(Kind == k_PSBHint &&
"Invalid access!");
743 unsigned getPHint()
const {
744 assert(Kind == k_PHint &&
"Invalid access!");
749 assert(Kind == k_PSBHint &&
"Invalid access!");
750 return StringRef(PSBHint.Data, PSBHint.Length);
754 assert(Kind == k_PHint &&
"Invalid access!");
755 return StringRef(PHint.Data, PHint.Length);
758 unsigned getBTIHint()
const {
759 assert(Kind == k_BTIHint &&
"Invalid access!");
764 assert(Kind == k_BTIHint &&
"Invalid access!");
765 return StringRef(BTIHint.Data, BTIHint.Length);
769 assert(Kind == k_SVCR &&
"Invalid access!");
770 return StringRef(SVCR.Data, SVCR.Length);
774 assert(Kind == k_Prefetch &&
"Invalid access!");
779 if (Kind == k_ShiftExtend)
780 return ShiftExtend.Type;
781 if (Kind == k_Register)
782 return Reg.ShiftExtend.Type;
786 unsigned getShiftExtendAmount()
const {
787 if (Kind == k_ShiftExtend)
788 return ShiftExtend.Amount;
789 if (Kind == k_Register)
790 return Reg.ShiftExtend.Amount;
794 bool hasShiftExtendAmount()
const {
795 if (Kind == k_ShiftExtend)
796 return ShiftExtend.HasExplicitAmount;
797 if (Kind == k_Register)
798 return Reg.ShiftExtend.HasExplicitAmount;
802 bool isImm()
const override {
return Kind == k_Immediate; }
803 bool isMem()
const override {
return false; }
805 bool isUImm6()
const {
812 return (Val >= 0 && Val < 64);
815 template <
int W
idth>
bool isSImm()
const {
return isSImmScaled<Width, 1>(); }
818 return isImmScaled<Bits, Scale>(
true);
821 template <
int Bits,
int Scale,
int Offset = 0,
bool IsRange = false>
823 if (IsRange && isImmRange() &&
824 (getLastImmVal() != getFirstImmVal() +
Offset))
825 return DiagnosticPredicateTy::NoMatch;
827 return isImmScaled<Bits, Scale, IsRange>(
false);
830 template <
int Bits,
int Scale,
bool IsRange = false>
832 if ((!
isImm() && !isImmRange()) || (
isImm() && IsRange) ||
833 (isImmRange() && !IsRange))
834 return DiagnosticPredicateTy::NoMatch;
838 Val = getFirstImmVal();
842 return DiagnosticPredicateTy::NoMatch;
846 int64_t MinVal, MaxVal;
848 int64_t Shift =
Bits - 1;
849 MinVal = (int64_t(1) << Shift) * -Scale;
850 MaxVal = ((int64_t(1) << Shift) - 1) * Scale;
853 MaxVal = ((int64_t(1) <<
Bits) - 1) * Scale;
856 if (Val >= MinVal && Val <= MaxVal && (Val % Scale) == 0)
857 return DiagnosticPredicateTy::Match;
859 return DiagnosticPredicateTy::NearMatch;
864 return DiagnosticPredicateTy::NoMatch;
865 auto *MCE = dyn_cast<MCConstantExpr>(getImm());
867 return DiagnosticPredicateTy::NoMatch;
869 if (Val >= 0 && Val < 32)
870 return DiagnosticPredicateTy::Match;
871 return DiagnosticPredicateTy::NearMatch;
876 return DiagnosticPredicateTy::NoMatch;
877 auto *MCE = dyn_cast<MCConstantExpr>(getImm());
879 return DiagnosticPredicateTy::NoMatch;
881 if (Val >= 0 && Val <= 1)
882 return DiagnosticPredicateTy::Match;
883 return DiagnosticPredicateTy::NearMatch;
886 bool isSymbolicUImm12Offset(
const MCExpr *Expr)
const {
890 if (!AArch64AsmParser::classifySymbolRef(Expr, ELFRefKind, DarwinRefKind,
924 template <
int Scale>
bool isUImm12Offset()
const {
930 return isSymbolicUImm12Offset(getImm());
933 return (Val % Scale) == 0 && Val >= 0 && (Val / Scale) < 0x1000;
936 template <
int N,
int M>
937 bool isImmInRange()
const {
944 return (Val >=
N && Val <= M);
949 template <
typename T>
950 bool isLogicalImm()
const {
967 bool isShiftedImm()
const {
return Kind == k_ShiftedImm; }
969 bool isImmRange()
const {
return Kind == k_ImmRange; }
974 template <
unsigned W
idth>
975 std::optional<std::pair<int64_t, unsigned>> getShiftedVal()
const {
976 if (isShiftedImm() && Width == getShiftedImmShift())
977 if (
auto *CE = dyn_cast<MCConstantExpr>(getShiftedImmVal()))
978 return std::make_pair(
CE->getValue(), Width);
981 if (
auto *CE = dyn_cast<MCConstantExpr>(getImm())) {
982 int64_t Val =
CE->getValue();
984 return std::make_pair(Val >> Width, Width);
986 return std::make_pair(Val, 0u);
992 bool isAddSubImm()
const {
993 if (!isShiftedImm() && !
isImm())
999 if (isShiftedImm()) {
1000 unsigned Shift = ShiftedImm.ShiftAmount;
1001 Expr = ShiftedImm.Val;
1002 if (Shift != 0 && Shift != 12)
1011 if (AArch64AsmParser::classifySymbolRef(Expr, ELFRefKind,
1012 DarwinRefKind, Addend)) {
1031 if (
auto ShiftedVal = getShiftedVal<12>())
1032 return ShiftedVal->first >= 0 && ShiftedVal->first <= 0xfff;
1039 bool isAddSubImmNeg()
const {
1040 if (!isShiftedImm() && !
isImm())
1044 if (
auto ShiftedVal = getShiftedVal<12>())
1045 return ShiftedVal->first < 0 && -ShiftedVal->first <= 0xfff;
1055 template <
typename T>
1057 if (!isShiftedImm() && (!
isImm() || !isa<MCConstantExpr>(getImm())))
1058 return DiagnosticPredicateTy::NoMatch;
1060 bool IsByte = std::is_same<int8_t, std::make_signed_t<T>>
::value ||
1061 std::is_same<int8_t, T>::value;
1062 if (
auto ShiftedImm = getShiftedVal<8>())
1063 if (!(IsByte && ShiftedImm->second) &&
1064 AArch64_AM::isSVECpyImm<T>(
uint64_t(ShiftedImm->first)
1065 << ShiftedImm->second))
1066 return DiagnosticPredicateTy::Match;
1068 return DiagnosticPredicateTy::NearMatch;
1075 if (!isShiftedImm() && (!
isImm() || !isa<MCConstantExpr>(getImm())))
1076 return DiagnosticPredicateTy::NoMatch;
1078 bool IsByte = std::is_same<int8_t, std::make_signed_t<T>>
::value ||
1079 std::is_same<int8_t, T>::value;
1080 if (
auto ShiftedImm = getShiftedVal<8>())
1081 if (!(IsByte && ShiftedImm->second) &&
1082 AArch64_AM::isSVEAddSubImm<T>(ShiftedImm->first
1083 << ShiftedImm->second))
1084 return DiagnosticPredicateTy::Match;
1086 return DiagnosticPredicateTy::NearMatch;
1090 if (isLogicalImm<T>() && !isSVECpyImm<T>())
1091 return DiagnosticPredicateTy::Match;
1092 return DiagnosticPredicateTy::NoMatch;
1095 bool isCondCode()
const {
return Kind == k_CondCode; }
1097 bool isSIMDImmType10()
const {
1107 bool isBranchTarget()
const {
1116 assert(
N > 0 &&
"Branch target immediate cannot be 0 bits!");
1117 return (Val >= -((1<<(
N-1)) << 2) && Val <= (((1<<(
N-1))-1) << 2));
1128 if (!AArch64AsmParser::classifySymbolRef(getImm(), ELFRefKind,
1129 DarwinRefKind, Addend)) {
1138 bool isMovWSymbolG3()
const {
1142 bool isMovWSymbolG2()
const {
1143 return isMovWSymbol(
1150 bool isMovWSymbolG1()
const {
1151 return isMovWSymbol(
1159 bool isMovWSymbolG0()
const {
1160 return isMovWSymbol(
1168 template<
int RegW
idth,
int Shift>
1169 bool isMOVZMovAlias()
const {
1170 if (!
isImm())
return false;
1183 template<
int RegW
idth,
int Shift>
1184 bool isMOVNMovAlias()
const {
1185 if (!
isImm())
return false;
1188 if (!CE)
return false;
1194 bool isFPImm()
const {
1195 return Kind == k_FPImm &&
1199 bool isBarrier()
const {
1200 return Kind == k_Barrier && !getBarriernXSModifier();
1202 bool isBarriernXS()
const {
1203 return Kind == k_Barrier && getBarriernXSModifier();
1205 bool isSysReg()
const {
return Kind == k_SysReg; }
1207 bool isMRSSystemRegister()
const {
1208 if (!isSysReg())
return false;
1210 return SysReg.MRSReg != -1U;
1213 bool isMSRSystemRegister()
const {
1214 if (!isSysReg())
return false;
1215 return SysReg.MSRReg != -1U;
1218 bool isSystemPStateFieldWithImm0_1()
const {
1219 if (!isSysReg())
return false;
1220 return AArch64PState::lookupPStateImm0_1ByEncoding(SysReg.PStateField);
1223 bool isSystemPStateFieldWithImm0_15()
const {
1226 return AArch64PState::lookupPStateImm0_15ByEncoding(SysReg.PStateField);
1229 bool isSVCR()
const {
1232 return SVCR.PStateField != -1U;
1235 bool isReg()
const override {
1236 return Kind == k_Register;
1239 bool isVectorList()
const {
return Kind == k_VectorList; }
1241 bool isScalarReg()
const {
1242 return Kind == k_Register &&
Reg.Kind == RegKind::Scalar;
1245 bool isNeonVectorReg()
const {
1246 return Kind == k_Register &&
Reg.Kind == RegKind::NeonVector;
1249 bool isNeonVectorRegLo()
const {
1250 return Kind == k_Register &&
Reg.Kind == RegKind::NeonVector &&
1251 (AArch64MCRegisterClasses[AArch64::FPR128_loRegClassID].contains(
1253 AArch64MCRegisterClasses[AArch64::FPR64_loRegClassID].contains(
1257 bool isNeonVectorReg0to7()
const {
1258 return Kind == k_Register &&
Reg.Kind == RegKind::NeonVector &&
1259 (AArch64MCRegisterClasses[AArch64::FPR128_0to7RegClassID].contains(
1263 bool isMatrix()
const {
return Kind == k_MatrixRegister; }
1264 bool isMatrixTileList()
const {
return Kind == k_MatrixTileList; }
1266 template <
unsigned Class>
bool isSVEPredicateAsCounterReg()
const {
1269 case AArch64::PPRRegClassID:
1270 case AArch64::PPR_3bRegClassID:
1271 case AArch64::PPR_p8to15RegClassID:
1272 case AArch64::PNRRegClassID:
1273 case AArch64::PNR_p8to15RegClassID:
1274 case AArch64::PPRorPNRRegClassID:
1275 RK = RegKind::SVEPredicateAsCounter;
1281 return (Kind == k_Register &&
Reg.Kind == RK) &&
1282 AArch64MCRegisterClasses[
Class].contains(
getReg());
1285 template <
unsigned Class>
bool isSVEVectorReg()
const {
1288 case AArch64::ZPRRegClassID:
1289 case AArch64::ZPR_3bRegClassID:
1290 case AArch64::ZPR_4bRegClassID:
1291 case AArch64::ZPRMul2_LoRegClassID:
1292 case AArch64::ZPRMul2_HiRegClassID:
1293 case AArch64::ZPR_KRegClassID:
1294 RK = RegKind::SVEDataVector;
1296 case AArch64::PPRRegClassID:
1297 case AArch64::PPR_3bRegClassID:
1298 case AArch64::PPR_p8to15RegClassID:
1299 case AArch64::PNRRegClassID:
1300 case AArch64::PNR_p8to15RegClassID:
1301 case AArch64::PPRorPNRRegClassID:
1302 RK = RegKind::SVEPredicateVector;
1308 return (Kind == k_Register &&
Reg.Kind == RK) &&
1309 AArch64MCRegisterClasses[
Class].contains(
getReg());
1312 template <
unsigned Class>
bool isFPRasZPR()
const {
1313 return Kind == k_Register &&
Reg.Kind == RegKind::Scalar &&
1314 AArch64MCRegisterClasses[
Class].contains(
getReg());
1317 template <
int ElementW
idth,
unsigned Class>
1319 if (Kind != k_Register ||
Reg.Kind != RegKind::SVEPredicateVector)
1320 return DiagnosticPredicateTy::NoMatch;
1322 if (isSVEVectorReg<Class>() && (
Reg.ElementWidth == ElementWidth))
1323 return DiagnosticPredicateTy::Match;
1325 return DiagnosticPredicateTy::NearMatch;
1328 template <
int ElementW
idth,
unsigned Class>
1330 if (Kind != k_Register || (
Reg.Kind != RegKind::SVEPredicateAsCounter &&
1331 Reg.Kind != RegKind::SVEPredicateVector))
1332 return DiagnosticPredicateTy::NoMatch;
1334 if ((isSVEPredicateAsCounterReg<Class>() ||
1335 isSVEPredicateVectorRegOfWidth<ElementWidth, Class>()) &&
1336 Reg.ElementWidth == ElementWidth)
1337 return DiagnosticPredicateTy::Match;
1339 return DiagnosticPredicateTy::NearMatch;
1342 template <
int ElementW
idth,
unsigned Class>
1344 if (Kind != k_Register ||
Reg.Kind != RegKind::SVEPredicateAsCounter)
1345 return DiagnosticPredicateTy::NoMatch;
1347 if (isSVEPredicateAsCounterReg<Class>() && (
Reg.ElementWidth == ElementWidth))
1348 return DiagnosticPredicateTy::Match;
1350 return DiagnosticPredicateTy::NearMatch;
1353 template <
int ElementW
idth,
unsigned Class>
1355 if (Kind != k_Register ||
Reg.Kind != RegKind::SVEDataVector)
1356 return DiagnosticPredicateTy::NoMatch;
1358 if (isSVEVectorReg<Class>() &&
Reg.ElementWidth == ElementWidth)
1359 return DiagnosticPredicateTy::Match;
1361 return DiagnosticPredicateTy::NearMatch;
1364 template <
int ElementWidth,
unsigned Class,
1366 bool ShiftWidthAlwaysSame>
1368 auto VectorMatch = isSVEDataVectorRegOfWidth<ElementWidth, Class>();
1369 if (!VectorMatch.isMatch())
1370 return DiagnosticPredicateTy::NoMatch;
1375 bool MatchShift = getShiftExtendAmount() ==
Log2_32(ShiftWidth / 8);
1378 !ShiftWidthAlwaysSame && hasShiftExtendAmount() && ShiftWidth == 8)
1379 return DiagnosticPredicateTy::NoMatch;
1381 if (MatchShift && ShiftExtendTy == getShiftExtendType())
1382 return DiagnosticPredicateTy::Match;
1384 return DiagnosticPredicateTy::NearMatch;
1387 bool isGPR32as64()
const {
1388 return Kind == k_Register &&
Reg.Kind == RegKind::Scalar &&
1389 AArch64MCRegisterClasses[AArch64::GPR64RegClassID].contains(
Reg.RegNum);
1392 bool isGPR64as32()
const {
1393 return Kind == k_Register &&
Reg.Kind == RegKind::Scalar &&
1394 AArch64MCRegisterClasses[AArch64::GPR32RegClassID].contains(
Reg.RegNum);
1397 bool isGPR64x8()
const {
1398 return Kind == k_Register &&
Reg.Kind == RegKind::Scalar &&
1399 AArch64MCRegisterClasses[AArch64::GPR64x8ClassRegClassID].contains(
1403 bool isWSeqPair()
const {
1404 return Kind == k_Register &&
Reg.Kind == RegKind::Scalar &&
1405 AArch64MCRegisterClasses[AArch64::WSeqPairsClassRegClassID].contains(
1409 bool isXSeqPair()
const {
1410 return Kind == k_Register &&
Reg.Kind == RegKind::Scalar &&
1411 AArch64MCRegisterClasses[AArch64::XSeqPairsClassRegClassID].contains(
1415 bool isSyspXzrPair()
const {
1416 return isGPR64<AArch64::GPR64RegClassID>() &&
Reg.RegNum == AArch64::XZR;
1419 template<
int64_t Angle,
int64_t Remainder>
1421 if (!
isImm())
return DiagnosticPredicateTy::NoMatch;
1424 if (!CE)
return DiagnosticPredicateTy::NoMatch;
1427 if (
Value % Angle == Remainder &&
Value <= 270)
1428 return DiagnosticPredicateTy::Match;
1429 return DiagnosticPredicateTy::NearMatch;
1432 template <
unsigned RegClassID>
bool isGPR64()
const {
1433 return Kind == k_Register &&
Reg.Kind == RegKind::Scalar &&
1434 AArch64MCRegisterClasses[RegClassID].contains(
getReg());
1437 template <
unsigned RegClassID,
int ExtW
idth>
1439 if (Kind != k_Register ||
Reg.Kind != RegKind::Scalar)
1440 return DiagnosticPredicateTy::NoMatch;
1442 if (isGPR64<RegClassID>() && getShiftExtendType() ==
AArch64_AM::LSL &&
1443 getShiftExtendAmount() ==
Log2_32(ExtWidth / 8))
1444 return DiagnosticPredicateTy::Match;
1445 return DiagnosticPredicateTy::NearMatch;
1450 template <RegKind VectorKind,
unsigned NumRegs,
bool IsConsecutive = false>
1451 bool isImplicitlyTypedVectorList()
const {
1452 return Kind == k_VectorList && VectorList.Count == NumRegs &&
1453 VectorList.NumElements == 0 &&
1454 VectorList.RegisterKind == VectorKind &&
1455 (!IsConsecutive || (VectorList.Stride == 1));
1458 template <RegKind VectorKind,
unsigned NumRegs,
unsigned NumElements,
1459 unsigned ElementWidth,
unsigned Stride = 1>
1460 bool isTypedVectorList()
const {
1461 if (Kind != k_VectorList)
1463 if (VectorList.Count != NumRegs)
1465 if (VectorList.RegisterKind != VectorKind)
1467 if (VectorList.ElementWidth != ElementWidth)
1469 if (VectorList.Stride != Stride)
1471 return VectorList.NumElements == NumElements;
1474 template <RegKind VectorKind,
unsigned NumRegs,
unsigned NumElements,
1475 unsigned ElementWidth,
unsigned RegClass>
1478 isTypedVectorList<VectorKind, NumRegs, NumElements, ElementWidth>();
1480 return DiagnosticPredicateTy::NoMatch;
1481 if (!AArch64MCRegisterClasses[RegClass].
contains(VectorList.RegNum))
1482 return DiagnosticPredicateTy::NearMatch;
1483 return DiagnosticPredicateTy::Match;
1486 template <RegKind VectorKind,
unsigned NumRegs,
unsigned Stride,
1487 unsigned ElementWidth>
1489 bool Res = isTypedVectorList<VectorKind, NumRegs, 0,
1490 ElementWidth, Stride>();
1492 return DiagnosticPredicateTy::NoMatch;
1493 if ((VectorList.RegNum < (AArch64::Z0 + Stride)) ||
1494 ((VectorList.RegNum >= AArch64::Z16) &&
1495 (VectorList.RegNum < (AArch64::Z16 + Stride))))
1496 return DiagnosticPredicateTy::Match;
1497 return DiagnosticPredicateTy::NoMatch;
1500 template <
int Min,
int Max>
1502 if (Kind != k_VectorIndex)
1503 return DiagnosticPredicateTy::NoMatch;
1504 if (VectorIndex.Val >= Min && VectorIndex.Val <= Max)
1505 return DiagnosticPredicateTy::Match;
1506 return DiagnosticPredicateTy::NearMatch;
1509 bool isToken()
const override {
return Kind == k_Token; }
1511 bool isTokenEqual(
StringRef Str)
const {
1512 return Kind == k_Token && getToken() == Str;
1514 bool isSysCR()
const {
return Kind == k_SysCR; }
1515 bool isPrefetch()
const {
return Kind == k_Prefetch; }
1516 bool isPSBHint()
const {
return Kind == k_PSBHint; }
1517 bool isPHint()
const {
return Kind == k_PHint; }
1518 bool isBTIHint()
const {
return Kind == k_BTIHint; }
1519 bool isShiftExtend()
const {
return Kind == k_ShiftExtend; }
1520 bool isShifter()
const {
1521 if (!isShiftExtend())
1531 if (Kind != k_FPImm)
1532 return DiagnosticPredicateTy::NoMatch;
1534 if (getFPImmIsExact()) {
1536 auto *
Desc = AArch64ExactFPImm::lookupExactFPImmByEnum(ImmEnum);
1540 APFloat RealVal(APFloat::IEEEdouble());
1542 RealVal.convertFromString(
Desc->Repr, APFloat::rmTowardZero);
1543 if (
errorToBool(StatusOrErr.takeError()) || *StatusOrErr != APFloat::opOK)
1546 if (
getFPImm().bitwiseIsEqual(RealVal))
1547 return DiagnosticPredicateTy::Match;
1550 return DiagnosticPredicateTy::NearMatch;
1553 template <
unsigned ImmA,
unsigned ImmB>
1556 if ((Res = isExactFPImm<ImmA>()))
1557 return DiagnosticPredicateTy::Match;
1558 if ((Res = isExactFPImm<ImmB>()))
1559 return DiagnosticPredicateTy::Match;
1563 bool isExtend()
const {
1564 if (!isShiftExtend())
1573 getShiftExtendAmount() <= 4;
1576 bool isExtend64()
const {
1586 bool isExtendLSL64()
const {
1592 getShiftExtendAmount() <= 4;
1595 bool isLSLImm3Shift()
const {
1596 if (!isShiftExtend())
1602 template<
int W
idth>
bool isMemXExtend()
const {
1607 (getShiftExtendAmount() ==
Log2_32(Width / 8) ||
1608 getShiftExtendAmount() == 0);
1611 template<
int W
idth>
bool isMemWExtend()
const {
1616 (getShiftExtendAmount() ==
Log2_32(Width / 8) ||
1617 getShiftExtendAmount() == 0);
1620 template <
unsigned w
idth>
1621 bool isArithmeticShifter()
const {
1631 template <
unsigned w
idth>
1632 bool isLogicalShifter()
const {
1640 getShiftExtendAmount() < width;
1643 bool isMovImm32Shifter()
const {
1651 uint64_t Val = getShiftExtendAmount();
1652 return (Val == 0 || Val == 16);
1655 bool isMovImm64Shifter()
const {
1663 uint64_t Val = getShiftExtendAmount();
1664 return (Val == 0 || Val == 16 || Val == 32 || Val == 48);
1667 bool isLogicalVecShifter()
const {
1672 unsigned Shift = getShiftExtendAmount();
1674 (Shift == 0 || Shift == 8 || Shift == 16 || Shift == 24);
1677 bool isLogicalVecHalfWordShifter()
const {
1678 if (!isLogicalVecShifter())
1682 unsigned Shift = getShiftExtendAmount();
1684 (Shift == 0 || Shift == 8);
1687 bool isMoveVecShifter()
const {
1688 if (!isShiftExtend())
1692 unsigned Shift = getShiftExtendAmount();
1694 (Shift == 8 || Shift == 16);
1703 bool isSImm9OffsetFB()
const {
1704 return isSImm<9>() && !isUImm12Offset<Width / 8>();
1707 bool isAdrpLabel()
const {
1714 int64_t Val =
CE->getValue();
1715 int64_t Min = - (4096 * (1LL << (21 - 1)));
1716 int64_t
Max = 4096 * ((1LL << (21 - 1)) - 1);
1717 return (Val % 4096) == 0 && Val >= Min && Val <=
Max;
1723 bool isAdrLabel()
const {
1730 int64_t Val =
CE->getValue();
1731 int64_t Min = - (1LL << (21 - 1));
1732 int64_t
Max = ((1LL << (21 - 1)) - 1);
1733 return Val >= Min && Val <=
Max;
1739 template <MatrixKind Kind,
unsigned EltSize,
unsigned RegClass>
1742 return DiagnosticPredicateTy::NoMatch;
1743 if (getMatrixKind() != Kind ||
1744 !AArch64MCRegisterClasses[RegClass].
contains(getMatrixReg()) ||
1745 EltSize != getMatrixElementWidth())
1746 return DiagnosticPredicateTy::NearMatch;
1747 return DiagnosticPredicateTy::Match;
1750 bool isPAuthPCRelLabel16Operand()
const {
1762 return (Val <= 0) && (Val > -(1 << 18));
1769 else if (
const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(Expr))
1775 void addRegOperands(
MCInst &Inst,
unsigned N)
const {
1776 assert(
N == 1 &&
"Invalid number of operands!");
1780 void addMatrixOperands(
MCInst &Inst,
unsigned N)
const {
1781 assert(
N == 1 &&
"Invalid number of operands!");
1785 void addGPR32as64Operands(
MCInst &Inst,
unsigned N)
const {
1786 assert(
N == 1 &&
"Invalid number of operands!");
1788 AArch64MCRegisterClasses[AArch64::GPR64RegClassID].
contains(
getReg()));
1797 void addGPR64as32Operands(
MCInst &Inst,
unsigned N)
const {
1798 assert(
N == 1 &&
"Invalid number of operands!");
1800 AArch64MCRegisterClasses[AArch64::GPR32RegClassID].
contains(
getReg()));
1809 template <
int W
idth>
1810 void addFPRasZPRRegOperands(
MCInst &Inst,
unsigned N)
const {
1813 case 8:
Base = AArch64::B0;
break;
1814 case 16:
Base = AArch64::H0;
break;
1815 case 32:
Base = AArch64::S0;
break;
1816 case 64:
Base = AArch64::D0;
break;
1817 case 128:
Base = AArch64::Q0;
break;
1824 void addPPRorPNRRegOperands(
MCInst &Inst,
unsigned N)
const {
1825 assert(
N == 1 &&
"Invalid number of operands!");
1828 if (
Reg >= AArch64::PN0 &&
Reg <= AArch64::PN15)
1829 Reg =
Reg - AArch64::PN0 + AArch64::P0;
1833 void addPNRasPPRRegOperands(
MCInst &Inst,
unsigned N)
const {
1834 assert(
N == 1 &&
"Invalid number of operands!");
1839 void addVectorReg64Operands(
MCInst &Inst,
unsigned N)
const {
1840 assert(
N == 1 &&
"Invalid number of operands!");
1842 AArch64MCRegisterClasses[AArch64::FPR128RegClassID].
contains(
getReg()));
1846 void addVectorReg128Operands(
MCInst &Inst,
unsigned N)
const {
1847 assert(
N == 1 &&
"Invalid number of operands!");
1849 AArch64MCRegisterClasses[AArch64::FPR128RegClassID].
contains(
getReg()));
1853 void addVectorRegLoOperands(
MCInst &Inst,
unsigned N)
const {
1854 assert(
N == 1 &&
"Invalid number of operands!");
1858 void addVectorReg0to7Operands(
MCInst &Inst,
unsigned N)
const {
1859 assert(
N == 1 &&
"Invalid number of operands!");
1863 enum VecListIndexType {
1864 VecListIdx_DReg = 0,
1865 VecListIdx_QReg = 1,
1866 VecListIdx_ZReg = 2,
1867 VecListIdx_PReg = 3,
1870 template <VecListIndexType RegTy,
unsigned NumRegs,
1871 bool IsConsecutive =
false>
1872 void addVectorListOperands(
MCInst &Inst,
unsigned N)
const {
1873 assert(
N == 1 &&
"Invalid number of operands!");
1874 assert((!IsConsecutive || (getVectorListStride() == 1)) &&
1875 "Expected consecutive registers");
1876 static const unsigned FirstRegs[][5] = {
1878 AArch64::D0, AArch64::D0_D1,
1879 AArch64::D0_D1_D2, AArch64::D0_D1_D2_D3 },
1881 AArch64::Q0, AArch64::Q0_Q1,
1882 AArch64::Q0_Q1_Q2, AArch64::Q0_Q1_Q2_Q3 },
1884 AArch64::Z0, AArch64::Z0_Z1,
1885 AArch64::Z0_Z1_Z2, AArch64::Z0_Z1_Z2_Z3 },
1887 AArch64::P0, AArch64::P0_P1 }
1890 assert((RegTy != VecListIdx_ZReg || NumRegs <= 4) &&
1891 " NumRegs must be <= 4 for ZRegs");
1893 assert((RegTy != VecListIdx_PReg || NumRegs <= 2) &&
1894 " NumRegs must be <= 2 for PRegs");
1896 unsigned FirstReg = FirstRegs[(
unsigned)RegTy][NumRegs];
1898 FirstRegs[(
unsigned)RegTy][0]));
1901 template <
unsigned NumRegs>
1902 void addStridedVectorListOperands(
MCInst &Inst,
unsigned N)
const {
1903 assert(
N == 1 &&
"Invalid number of operands!");
1904 assert((NumRegs == 2 || NumRegs == 4) &&
" NumRegs must be 2 or 4");
1908 if (getVectorListStart() < AArch64::Z16) {
1909 assert((getVectorListStart() < AArch64::Z8) &&
1910 (getVectorListStart() >= AArch64::Z0) &&
"Invalid Register");
1912 AArch64::Z0_Z8 + getVectorListStart() - AArch64::Z0));
1914 assert((getVectorListStart() < AArch64::Z24) &&
1915 (getVectorListStart() >= AArch64::Z16) &&
"Invalid Register");
1917 AArch64::Z16_Z24 + getVectorListStart() - AArch64::Z16));
1921 if (getVectorListStart() < AArch64::Z16) {
1922 assert((getVectorListStart() < AArch64::Z4) &&
1923 (getVectorListStart() >= AArch64::Z0) &&
"Invalid Register");
1925 AArch64::Z0_Z4_Z8_Z12 + getVectorListStart() - AArch64::Z0));
1927 assert((getVectorListStart() < AArch64::Z20) &&
1928 (getVectorListStart() >= AArch64::Z16) &&
"Invalid Register");
1930 AArch64::Z16_Z20_Z24_Z28 + getVectorListStart() - AArch64::Z16));
1938 void addMatrixTileListOperands(
MCInst &Inst,
unsigned N)
const {
1939 assert(
N == 1 &&
"Invalid number of operands!");
1940 unsigned RegMask = getMatrixTileListRegMask();
1941 assert(RegMask <= 0xFF &&
"Invalid mask!");
1945 void addVectorIndexOperands(
MCInst &Inst,
unsigned N)
const {
1946 assert(
N == 1 &&
"Invalid number of operands!");
1950 template <
unsigned ImmIs0,
unsigned ImmIs1>
1951 void addExactFPImmOperands(
MCInst &Inst,
unsigned N)
const {
1952 assert(
N == 1 &&
"Invalid number of operands!");
1953 assert(
bool(isExactFPImm<ImmIs0, ImmIs1>()) &&
"Invalid operand");
1957 void addImmOperands(
MCInst &Inst,
unsigned N)
const {
1958 assert(
N == 1 &&
"Invalid number of operands!");
1962 addExpr(Inst, getImm());
1965 template <
int Shift>
1966 void addImmWithOptionalShiftOperands(
MCInst &Inst,
unsigned N)
const {
1967 assert(
N == 2 &&
"Invalid number of operands!");
1968 if (
auto ShiftedVal = getShiftedVal<Shift>()) {
1971 }
else if (isShiftedImm()) {
1972 addExpr(Inst, getShiftedImmVal());
1975 addExpr(Inst, getImm());
1980 template <
int Shift>
1981 void addImmNegWithOptionalShiftOperands(
MCInst &Inst,
unsigned N)
const {
1982 assert(
N == 2 &&
"Invalid number of operands!");
1983 if (
auto ShiftedVal = getShiftedVal<Shift>()) {
1990 void addCondCodeOperands(
MCInst &Inst,
unsigned N)
const {
1991 assert(
N == 1 &&
"Invalid number of operands!");
1995 void addAdrpLabelOperands(
MCInst &Inst,
unsigned N)
const {
1996 assert(
N == 1 &&
"Invalid number of operands!");
1999 addExpr(Inst, getImm());
2004 void addAdrLabelOperands(
MCInst &Inst,
unsigned N)
const {
2005 addImmOperands(Inst,
N);
2009 void addUImm12OffsetOperands(
MCInst &Inst,
unsigned N)
const {
2010 assert(
N == 1 &&
"Invalid number of operands!");
2020 void addUImm6Operands(
MCInst &Inst,
unsigned N)
const {
2021 assert(
N == 1 &&
"Invalid number of operands!");
2026 template <
int Scale>
2027 void addImmScaledOperands(
MCInst &Inst,
unsigned N)
const {
2028 assert(
N == 1 &&
"Invalid number of operands!");
2033 template <
int Scale>
2034 void addImmScaledRangeOperands(
MCInst &Inst,
unsigned N)
const {
2035 assert(
N == 1 &&
"Invalid number of operands!");
2039 template <
typename T>
2040 void addLogicalImmOperands(
MCInst &Inst,
unsigned N)
const {
2041 assert(
N == 1 &&
"Invalid number of operands!");
2043 std::make_unsigned_t<T> Val = MCE->
getValue();
2048 template <
typename T>
2049 void addLogicalImmNotOperands(
MCInst &Inst,
unsigned N)
const {
2050 assert(
N == 1 &&
"Invalid number of operands!");
2052 std::make_unsigned_t<T> Val = ~MCE->getValue();
2057 void addSIMDImmType10Operands(
MCInst &Inst,
unsigned N)
const {
2058 assert(
N == 1 &&
"Invalid number of operands!");
2064 void addBranchTarget26Operands(
MCInst &Inst,
unsigned N)
const {
2068 assert(
N == 1 &&
"Invalid number of operands!");
2071 addExpr(Inst, getImm());
2074 assert(MCE &&
"Invalid constant immediate operand!");
2078 void addPAuthPCRelLabel16Operands(
MCInst &Inst,
unsigned N)
const {
2082 assert(
N == 1 &&
"Invalid number of operands!");
2085 addExpr(Inst, getImm());
2091 void addPCRelLabel19Operands(
MCInst &Inst,
unsigned N)
const {
2095 assert(
N == 1 &&
"Invalid number of operands!");
2098 addExpr(Inst, getImm());
2101 assert(MCE &&
"Invalid constant immediate operand!");
2105 void addPCRelLabel9Operands(
MCInst &Inst,
unsigned N)
const {
2109 assert(
N == 1 &&
"Invalid number of operands!");
2112 addExpr(Inst, getImm());
2115 assert(MCE &&
"Invalid constant immediate operand!");
2119 void addBranchTarget14Operands(
MCInst &Inst,
unsigned N)
const {
2123 assert(
N == 1 &&
"Invalid number of operands!");
2126 addExpr(Inst, getImm());
2129 assert(MCE &&
"Invalid constant immediate operand!");
2133 void addFPImmOperands(
MCInst &Inst,
unsigned N)
const {
2134 assert(
N == 1 &&
"Invalid number of operands!");
2139 void addBarrierOperands(
MCInst &Inst,
unsigned N)
const {
2140 assert(
N == 1 &&
"Invalid number of operands!");
2144 void addBarriernXSOperands(
MCInst &Inst,
unsigned N)
const {
2145 assert(
N == 1 &&
"Invalid number of operands!");
2149 void addMRSSystemRegisterOperands(
MCInst &Inst,
unsigned N)
const {
2150 assert(
N == 1 &&
"Invalid number of operands!");
2155 void addMSRSystemRegisterOperands(
MCInst &Inst,
unsigned N)
const {
2156 assert(
N == 1 &&
"Invalid number of operands!");
2161 void addSystemPStateFieldWithImm0_1Operands(
MCInst &Inst,
unsigned N)
const {
2162 assert(
N == 1 &&
"Invalid number of operands!");
2167 void addSVCROperands(
MCInst &Inst,
unsigned N)
const {
2168 assert(
N == 1 &&
"Invalid number of operands!");
2173 void addSystemPStateFieldWithImm0_15Operands(
MCInst &Inst,
unsigned N)
const {
2174 assert(
N == 1 &&
"Invalid number of operands!");
2179 void addSysCROperands(
MCInst &Inst,
unsigned N)
const {
2180 assert(
N == 1 &&
"Invalid number of operands!");
2184 void addPrefetchOperands(
MCInst &Inst,
unsigned N)
const {
2185 assert(
N == 1 &&
"Invalid number of operands!");
2189 void addPSBHintOperands(
MCInst &Inst,
unsigned N)
const {
2190 assert(
N == 1 &&
"Invalid number of operands!");
2194 void addPHintOperands(
MCInst &Inst,
unsigned N)
const {
2195 assert(
N == 1 &&
"Invalid number of operands!");
2199 void addBTIHintOperands(
MCInst &Inst,
unsigned N)
const {
2200 assert(
N == 1 &&
"Invalid number of operands!");
2204 void addShifterOperands(
MCInst &Inst,
unsigned N)
const {
2205 assert(
N == 1 &&
"Invalid number of operands!");
2211 void addLSLImm3ShifterOperands(
MCInst &Inst,
unsigned N)
const {
2212 assert(
N == 1 &&
"Invalid number of operands!");
2213 unsigned Imm = getShiftExtendAmount();
2217 void addSyspXzrPairOperand(
MCInst &Inst,
unsigned N)
const {
2218 assert(
N == 1 &&
"Invalid number of operands!");
2226 if (
Reg != AArch64::XZR)
2232 void addExtendOperands(
MCInst &Inst,
unsigned N)
const {
2233 assert(
N == 1 &&
"Invalid number of operands!");
2240 void addExtend64Operands(
MCInst &Inst,
unsigned N)
const {
2241 assert(
N == 1 &&
"Invalid number of operands!");
2248 void addMemExtendOperands(
MCInst &Inst,
unsigned N)
const {
2249 assert(
N == 2 &&
"Invalid number of operands!");
2260 void addMemExtend8Operands(
MCInst &Inst,
unsigned N)
const {
2261 assert(
N == 2 &&
"Invalid number of operands!");
2269 void addMOVZMovAliasOperands(
MCInst &Inst,
unsigned N)
const {
2270 assert(
N == 1 &&
"Invalid number of operands!");
2277 addExpr(Inst, getImm());
2282 void addMOVNMovAliasOperands(
MCInst &Inst,
unsigned N)
const {
2283 assert(
N == 1 &&
"Invalid number of operands!");
2290 void addComplexRotationEvenOperands(
MCInst &Inst,
unsigned N)
const {
2291 assert(
N == 1 &&
"Invalid number of operands!");
2296 void addComplexRotationOddOperands(
MCInst &Inst,
unsigned N)
const {
2297 assert(
N == 1 &&
"Invalid number of operands!");
2304 static std::unique_ptr<AArch64Operand>
2306 auto Op = std::make_unique<AArch64Operand>(k_Token, Ctx);
2307 Op->Tok.Data = Str.data();
2308 Op->Tok.Length = Str.size();
2309 Op->Tok.IsSuffix = IsSuffix;
2315 static std::unique_ptr<AArch64Operand>
2317 RegConstraintEqualityTy EqTy = RegConstraintEqualityTy::EqualsReg,
2319 unsigned ShiftAmount = 0,
2320 unsigned HasExplicitAmount =
false) {
2321 auto Op = std::make_unique<AArch64Operand>(k_Register, Ctx);
2322 Op->Reg.RegNum = RegNum;
2324 Op->Reg.ElementWidth = 0;
2325 Op->Reg.EqualityTy = EqTy;
2326 Op->Reg.ShiftExtend.Type = ExtTy;
2327 Op->Reg.ShiftExtend.Amount = ShiftAmount;
2328 Op->Reg.ShiftExtend.HasExplicitAmount = HasExplicitAmount;
2334 static std::unique_ptr<AArch64Operand>
2335 CreateVectorReg(
unsigned RegNum, RegKind Kind,
unsigned ElementWidth,
2338 unsigned ShiftAmount = 0,
2339 unsigned HasExplicitAmount =
false) {
2340 assert((Kind == RegKind::NeonVector || Kind == RegKind::SVEDataVector ||
2341 Kind == RegKind::SVEPredicateVector ||
2342 Kind == RegKind::SVEPredicateAsCounter) &&
2343 "Invalid vector kind");
2344 auto Op = CreateReg(RegNum, Kind, S,
E, Ctx, EqualsReg, ExtTy, ShiftAmount,
2346 Op->Reg.ElementWidth = ElementWidth;
2350 static std::unique_ptr<AArch64Operand>
2351 CreateVectorList(
unsigned RegNum,
unsigned Count,
unsigned Stride,
2352 unsigned NumElements,
unsigned ElementWidth,
2354 auto Op = std::make_unique<AArch64Operand>(k_VectorList, Ctx);
2355 Op->VectorList.RegNum = RegNum;
2356 Op->VectorList.Count = Count;
2357 Op->VectorList.Stride = Stride;
2358 Op->VectorList.NumElements = NumElements;
2359 Op->VectorList.ElementWidth = ElementWidth;
2360 Op->VectorList.RegisterKind = RegisterKind;
2366 static std::unique_ptr<AArch64Operand>
2368 auto Op = std::make_unique<AArch64Operand>(k_VectorIndex, Ctx);
2369 Op->VectorIndex.Val =
Idx;
2375 static std::unique_ptr<AArch64Operand>
2377 auto Op = std::make_unique<AArch64Operand>(k_MatrixTileList, Ctx);
2378 Op->MatrixTileList.RegMask = RegMask;
2385 const unsigned ElementWidth) {
2386 static std::map<std::pair<unsigned, unsigned>, std::vector<unsigned>>
2388 {{0, AArch64::ZAB0},
2389 {AArch64::ZAD0, AArch64::ZAD1, AArch64::ZAD2, AArch64::ZAD3,
2390 AArch64::ZAD4, AArch64::ZAD5, AArch64::ZAD6, AArch64::ZAD7}},
2391 {{8, AArch64::ZAB0},
2392 {AArch64::ZAD0, AArch64::ZAD1, AArch64::ZAD2, AArch64::ZAD3,
2393 AArch64::ZAD4, AArch64::ZAD5, AArch64::ZAD6, AArch64::ZAD7}},
2394 {{16, AArch64::ZAH0},
2395 {AArch64::ZAD0, AArch64::ZAD2, AArch64::ZAD4, AArch64::ZAD6}},
2396 {{16, AArch64::ZAH1},
2397 {AArch64::ZAD1, AArch64::ZAD3, AArch64::ZAD5, AArch64::ZAD7}},
2398 {{32, AArch64::ZAS0}, {AArch64::ZAD0, AArch64::ZAD4}},
2399 {{32, AArch64::ZAS1}, {AArch64::ZAD1, AArch64::ZAD5}},
2400 {{32, AArch64::ZAS2}, {AArch64::ZAD2, AArch64::ZAD6}},
2401 {{32, AArch64::ZAS3}, {AArch64::ZAD3, AArch64::ZAD7}},
2404 if (ElementWidth == 64)
2407 std::vector<unsigned> Regs = RegMap[std::make_pair(ElementWidth,
Reg)];
2408 assert(!Regs.empty() &&
"Invalid tile or element width!");
2409 for (
auto OutReg : Regs)
2414 static std::unique_ptr<AArch64Operand> CreateImm(
const MCExpr *Val,
SMLoc S,
2416 auto Op = std::make_unique<AArch64Operand>(k_Immediate, Ctx);
2423 static std::unique_ptr<AArch64Operand> CreateShiftedImm(
const MCExpr *Val,
2424 unsigned ShiftAmount,
2427 auto Op = std::make_unique<AArch64Operand>(k_ShiftedImm, Ctx);
2428 Op->ShiftedImm .Val = Val;
2429 Op->ShiftedImm.ShiftAmount = ShiftAmount;
2435 static std::unique_ptr<AArch64Operand> CreateImmRange(
unsigned First,
2439 auto Op = std::make_unique<AArch64Operand>(k_ImmRange, Ctx);
2441 Op->ImmRange.Last =
Last;
2446 static std::unique_ptr<AArch64Operand>
2448 auto Op = std::make_unique<AArch64Operand>(k_CondCode, Ctx);
2449 Op->CondCode.Code =
Code;
2455 static std::unique_ptr<AArch64Operand>
2457 auto Op = std::make_unique<AArch64Operand>(k_FPImm, Ctx);
2459 Op->FPImm.IsExact = IsExact;
2465 static std::unique_ptr<AArch64Operand> CreateBarrier(
unsigned Val,
2469 bool HasnXSModifier) {
2470 auto Op = std::make_unique<AArch64Operand>(k_Barrier, Ctx);
2471 Op->Barrier.Val = Val;
2472 Op->Barrier.Data = Str.data();
2473 Op->Barrier.Length = Str.size();
2474 Op->Barrier.HasnXSModifier = HasnXSModifier;
2480 static std::unique_ptr<AArch64Operand> CreateSysReg(
StringRef Str,
SMLoc S,
2485 auto Op = std::make_unique<AArch64Operand>(k_SysReg, Ctx);
2486 Op->SysReg.Data = Str.data();
2487 Op->SysReg.Length = Str.size();
2488 Op->SysReg.MRSReg = MRSReg;
2489 Op->SysReg.MSRReg = MSRReg;
2490 Op->SysReg.PStateField = PStateField;
2496 static std::unique_ptr<AArch64Operand>
2498 auto Op = std::make_unique<AArch64Operand>(k_PHint, Ctx);
2499 Op->PHint.Val = Val;
2500 Op->PHint.Data = Str.data();
2501 Op->PHint.Length = Str.size();
2507 static std::unique_ptr<AArch64Operand> CreateSysCR(
unsigned Val,
SMLoc S,
2509 auto Op = std::make_unique<AArch64Operand>(k_SysCR, Ctx);
2510 Op->SysCRImm.Val = Val;
2516 static std::unique_ptr<AArch64Operand> CreatePrefetch(
unsigned Val,
2520 auto Op = std::make_unique<AArch64Operand>(k_Prefetch, Ctx);
2521 Op->Prefetch.Val = Val;
2522 Op->Barrier.Data = Str.data();
2523 Op->Barrier.Length = Str.size();
2529 static std::unique_ptr<AArch64Operand> CreatePSBHint(
unsigned Val,
2533 auto Op = std::make_unique<AArch64Operand>(k_PSBHint, Ctx);
2534 Op->PSBHint.Val = Val;
2535 Op->PSBHint.Data = Str.data();
2536 Op->PSBHint.Length = Str.size();
2542 static std::unique_ptr<AArch64Operand> CreateBTIHint(
unsigned Val,
2546 auto Op = std::make_unique<AArch64Operand>(k_BTIHint, Ctx);
2547 Op->BTIHint.Val = Val | 32;
2548 Op->BTIHint.Data = Str.data();
2549 Op->BTIHint.Length = Str.size();
2555 static std::unique_ptr<AArch64Operand>
2556 CreateMatrixRegister(
unsigned RegNum,
unsigned ElementWidth, MatrixKind Kind,
2558 auto Op = std::make_unique<AArch64Operand>(k_MatrixRegister, Ctx);
2559 Op->MatrixReg.RegNum = RegNum;
2560 Op->MatrixReg.ElementWidth = ElementWidth;
2561 Op->MatrixReg.Kind =
Kind;
2567 static std::unique_ptr<AArch64Operand>
2569 auto Op = std::make_unique<AArch64Operand>(k_SVCR, Ctx);
2570 Op->SVCR.PStateField = PStateField;
2571 Op->SVCR.Data = Str.data();
2572 Op->SVCR.Length = Str.size();
2578 static std::unique_ptr<AArch64Operand>
2581 auto Op = std::make_unique<AArch64Operand>(k_ShiftExtend, Ctx);
2582 Op->ShiftExtend.Type = ShOp;
2583 Op->ShiftExtend.Amount = Val;
2584 Op->ShiftExtend.HasExplicitAmount = HasExplicitAmount;
2596 OS <<
"<fpimm " <<
getFPImm().bitcastToAPInt().getZExtValue();
2597 if (!getFPImmIsExact())
2604 OS <<
"<barrier " <<
Name <<
">";
2606 OS <<
"<barrier invalid #" << getBarrier() <<
">";
2612 case k_ShiftedImm: {
2613 unsigned Shift = getShiftedImmShift();
2614 OS <<
"<shiftedimm ";
2615 OS << *getShiftedImmVal();
2621 OS << getFirstImmVal();
2622 OS <<
":" << getLastImmVal() <<
">";
2628 case k_VectorList: {
2629 OS <<
"<vectorlist ";
2630 unsigned Reg = getVectorListStart();
2631 for (
unsigned i = 0, e = getVectorListCount(); i !=
e; ++i)
2632 OS <<
Reg + i * getVectorListStride() <<
" ";
2637 OS <<
"<vectorindex " << getVectorIndex() <<
">";
2640 OS <<
"<sysreg: " << getSysReg() <<
'>';
2643 OS <<
"'" << getToken() <<
"'";
2646 OS <<
"c" << getSysCR();
2651 OS <<
"<prfop " <<
Name <<
">";
2653 OS <<
"<prfop invalid #" << getPrefetch() <<
">";
2657 OS << getPSBHintName();
2660 OS << getPHintName();
2663 OS << getBTIHintName();
2665 case k_MatrixRegister:
2666 OS <<
"<matrix " << getMatrixReg() <<
">";
2668 case k_MatrixTileList: {
2669 OS <<
"<matrixlist ";
2670 unsigned RegMask = getMatrixTileListRegMask();
2671 unsigned MaxBits = 8;
2672 for (
unsigned I = MaxBits;
I > 0; --
I)
2673 OS << ((RegMask & (1 << (
I - 1))) >> (
I - 1));
2682 OS <<
"<register " <<
getReg() <<
">";
2683 if (!getShiftExtendAmount() && !hasShiftExtendAmount())
2688 << getShiftExtendAmount();
2689 if (!hasShiftExtendAmount())
2705 .
Case(
"v0", AArch64::Q0)
2706 .
Case(
"v1", AArch64::Q1)
2707 .
Case(
"v2", AArch64::Q2)
2708 .
Case(
"v3", AArch64::Q3)
2709 .
Case(
"v4", AArch64::Q4)
2710 .
Case(
"v5", AArch64::Q5)
2711 .
Case(
"v6", AArch64::Q6)
2712 .
Case(
"v7", AArch64::Q7)
2713 .
Case(
"v8", AArch64::Q8)
2714 .
Case(
"v9", AArch64::Q9)
2715 .
Case(
"v10", AArch64::Q10)
2716 .
Case(
"v11", AArch64::Q11)
2717 .
Case(
"v12", AArch64::Q12)
2718 .
Case(
"v13", AArch64::Q13)
2719 .
Case(
"v14", AArch64::Q14)
2720 .
Case(
"v15", AArch64::Q15)
2721 .
Case(
"v16", AArch64::Q16)
2722 .
Case(
"v17", AArch64::Q17)
2723 .
Case(
"v18", AArch64::Q18)
2724 .
Case(
"v19", AArch64::Q19)
2725 .
Case(
"v20", AArch64::Q20)
2726 .
Case(
"v21", AArch64::Q21)
2727 .
Case(
"v22", AArch64::Q22)
2728 .
Case(
"v23", AArch64::Q23)
2729 .
Case(
"v24", AArch64::Q24)
2730 .
Case(
"v25", AArch64::Q25)
2731 .
Case(
"v26", AArch64::Q26)
2732 .
Case(
"v27", AArch64::Q27)
2733 .
Case(
"v28", AArch64::Q28)
2734 .
Case(
"v29", AArch64::Q29)
2735 .
Case(
"v30", AArch64::Q30)
2736 .
Case(
"v31", AArch64::Q31)
2745 RegKind VectorKind) {
2746 std::pair<int, int> Res = {-1, -1};
2748 switch (VectorKind) {
2749 case RegKind::NeonVector:
2752 .Case(
".1d", {1, 64})
2753 .Case(
".1q", {1, 128})
2755 .Case(
".2h", {2, 16})
2756 .Case(
".2b", {2, 8})
2757 .Case(
".2s", {2, 32})
2758 .Case(
".2d", {2, 64})
2761 .Case(
".4b", {4, 8})
2762 .Case(
".4h", {4, 16})
2763 .Case(
".4s", {4, 32})
2764 .Case(
".8b", {8, 8})
2765 .Case(
".8h", {8, 16})
2766 .Case(
".16b", {16, 8})
2771 .Case(
".h", {0, 16})
2772 .Case(
".s", {0, 32})
2773 .Case(
".d", {0, 64})
2776 case RegKind::SVEPredicateAsCounter:
2777 case RegKind::SVEPredicateVector:
2778 case RegKind::SVEDataVector:
2779 case RegKind::Matrix:
2783 .Case(
".h", {0, 16})
2784 .Case(
".s", {0, 32})
2785 .Case(
".d", {0, 64})
2786 .Case(
".q", {0, 128})
2793 if (Res == std::make_pair(-1, -1))
2794 return std::nullopt;
2796 return std::optional<std::pair<int, int>>(Res);
2805 .
Case(
"z0", AArch64::Z0)
2806 .
Case(
"z1", AArch64::Z1)
2807 .
Case(
"z2", AArch64::Z2)
2808 .
Case(
"z3", AArch64::Z3)
2809 .
Case(
"z4", AArch64::Z4)
2810 .
Case(
"z5", AArch64::Z5)
2811 .
Case(
"z6", AArch64::Z6)
2812 .
Case(
"z7", AArch64::Z7)
2813 .
Case(
"z8", AArch64::Z8)
2814 .
Case(
"z9", AArch64::Z9)
2815 .
Case(
"z10", AArch64::Z10)
2816 .
Case(
"z11", AArch64::Z11)
2817 .
Case(
"z12", AArch64::Z12)
2818 .
Case(
"z13", AArch64::Z13)
2819 .
Case(
"z14", AArch64::Z14)
2820 .
Case(
"z15", AArch64::Z15)
2821 .
Case(
"z16", AArch64::Z16)
2822 .
Case(
"z17", AArch64::Z17)
2823 .
Case(
"z18", AArch64::Z18)
2824 .
Case(
"z19", AArch64::Z19)
2825 .
Case(
"z20", AArch64::Z20)
2826 .
Case(
"z21", AArch64::Z21)
2827 .
Case(
"z22", AArch64::Z22)
2828 .
Case(
"z23", AArch64::Z23)
2829 .
Case(
"z24", AArch64::Z24)
2830 .
Case(
"z25", AArch64::Z25)
2831 .
Case(
"z26", AArch64::Z26)
2832 .
Case(
"z27", AArch64::Z27)
2833 .
Case(
"z28", AArch64::Z28)
2834 .
Case(
"z29", AArch64::Z29)
2835 .
Case(
"z30", AArch64::Z30)
2836 .
Case(
"z31", AArch64::Z31)
2842 .
Case(
"p0", AArch64::P0)
2843 .
Case(
"p1", AArch64::P1)
2844 .
Case(
"p2", AArch64::P2)
2845 .
Case(
"p3", AArch64::P3)
2846 .
Case(
"p4", AArch64::P4)
2847 .
Case(
"p5", AArch64::P5)
2848 .
Case(
"p6", AArch64::P6)
2849 .
Case(
"p7", AArch64::P7)
2850 .
Case(
"p8", AArch64::P8)
2851 .
Case(
"p9", AArch64::P9)
2852 .
Case(
"p10", AArch64::P10)
2853 .
Case(
"p11", AArch64::P11)
2854 .
Case(
"p12", AArch64::P12)
2855 .
Case(
"p13", AArch64::P13)
2856 .
Case(
"p14", AArch64::P14)
2857 .
Case(
"p15", AArch64::P15)
2863 .
Case(
"pn0", AArch64::PN0)
2864 .
Case(
"pn1", AArch64::PN1)
2865 .
Case(
"pn2", AArch64::PN2)
2866 .
Case(
"pn3", AArch64::PN3)
2867 .
Case(
"pn4", AArch64::PN4)
2868 .
Case(
"pn5", AArch64::PN5)
2869 .
Case(
"pn6", AArch64::PN6)
2870 .
Case(
"pn7", AArch64::PN7)
2871 .
Case(
"pn8", AArch64::PN8)
2872 .
Case(
"pn9", AArch64::PN9)
2873 .
Case(
"pn10", AArch64::PN10)
2874 .
Case(
"pn11", AArch64::PN11)
2875 .
Case(
"pn12", AArch64::PN12)
2876 .
Case(
"pn13", AArch64::PN13)
2877 .
Case(
"pn14", AArch64::PN14)
2878 .
Case(
"pn15", AArch64::PN15)
2884 .
Case(
"za0.d", AArch64::ZAD0)
2885 .
Case(
"za1.d", AArch64::ZAD1)
2886 .
Case(
"za2.d", AArch64::ZAD2)
2887 .
Case(
"za3.d", AArch64::ZAD3)
2888 .
Case(
"za4.d", AArch64::ZAD4)
2889 .
Case(
"za5.d", AArch64::ZAD5)
2890 .
Case(
"za6.d", AArch64::ZAD6)
2891 .
Case(
"za7.d", AArch64::ZAD7)
2892 .
Case(
"za0.s", AArch64::ZAS0)
2893 .
Case(
"za1.s", AArch64::ZAS1)
2894 .
Case(
"za2.s", AArch64::ZAS2)
2895 .
Case(
"za3.s", AArch64::ZAS3)
2896 .
Case(
"za0.h", AArch64::ZAH0)
2897 .
Case(
"za1.h", AArch64::ZAH1)
2898 .
Case(
"za0.b", AArch64::ZAB0)
2904 .
Case(
"za", AArch64::ZA)
2905 .
Case(
"za0.q", AArch64::ZAQ0)
2906 .
Case(
"za1.q", AArch64::ZAQ1)
2907 .
Case(
"za2.q", AArch64::ZAQ2)
2908 .
Case(
"za3.q", AArch64::ZAQ3)
2909 .
Case(
"za4.q", AArch64::ZAQ4)
2910 .
Case(
"za5.q", AArch64::ZAQ5)
2911 .
Case(
"za6.q", AArch64::ZAQ6)
2912 .
Case(
"za7.q", AArch64::ZAQ7)
2913 .
Case(
"za8.q", AArch64::ZAQ8)
2914 .
Case(
"za9.q", AArch64::ZAQ9)
2915 .
Case(
"za10.q", AArch64::ZAQ10)
2916 .
Case(
"za11.q", AArch64::ZAQ11)
2917 .
Case(
"za12.q", AArch64::ZAQ12)
2918 .
Case(
"za13.q", AArch64::ZAQ13)
2919 .
Case(
"za14.q", AArch64::ZAQ14)
2920 .
Case(
"za15.q", AArch64::ZAQ15)
2921 .
Case(
"za0.d", AArch64::ZAD0)
2922 .
Case(
"za1.d", AArch64::ZAD1)
2923 .
Case(
"za2.d", AArch64::ZAD2)
2924 .
Case(
"za3.d", AArch64::ZAD3)
2925 .
Case(
"za4.d", AArch64::ZAD4)
2926 .
Case(
"za5.d", AArch64::ZAD5)
2927 .
Case(
"za6.d", AArch64::ZAD6)
2928 .
Case(
"za7.d", AArch64::ZAD7)
2929 .
Case(
"za0.s", AArch64::ZAS0)
2930 .
Case(
"za1.s", AArch64::ZAS1)
2931 .
Case(
"za2.s", AArch64::ZAS2)
2932 .
Case(
"za3.s", AArch64::ZAS3)
2933 .
Case(
"za0.h", AArch64::ZAH0)
2934 .
Case(
"za1.h", AArch64::ZAH1)
2935 .
Case(
"za0.b", AArch64::ZAB0)
2936 .
Case(
"za0h.q", AArch64::ZAQ0)
2937 .
Case(
"za1h.q", AArch64::ZAQ1)
2938 .
Case(
"za2h.q", AArch64::ZAQ2)
2939 .
Case(
"za3h.q", AArch64::ZAQ3)
2940 .
Case(
"za4h.q", AArch64::ZAQ4)
2941 .
Case(
"za5h.q", AArch64::ZAQ5)
2942 .
Case(
"za6h.q", AArch64::ZAQ6)
2943 .
Case(
"za7h.q", AArch64::ZAQ7)
2944 .
Case(
"za8h.q", AArch64::ZAQ8)
2945 .
Case(
"za9h.q", AArch64::ZAQ9)
2946 .
Case(
"za10h.q", AArch64::ZAQ10)
2947 .
Case(
"za11h.q", AArch64::ZAQ11)
2948 .
Case(
"za12h.q", AArch64::ZAQ12)
2949 .
Case(
"za13h.q", AArch64::ZAQ13)
2950 .
Case(
"za14h.q", AArch64::ZAQ14)
2951 .
Case(
"za15h.q", AArch64::ZAQ15)
2952 .
Case(
"za0h.d", AArch64::ZAD0)
2953 .
Case(
"za1h.d", AArch64::ZAD1)
2954 .
Case(
"za2h.d", AArch64::ZAD2)
2955 .
Case(
"za3h.d", AArch64::ZAD3)
2956 .
Case(
"za4h.d", AArch64::ZAD4)
2957 .
Case(
"za5h.d", AArch64::ZAD5)
2958 .
Case(
"za6h.d", AArch64::ZAD6)
2959 .
Case(
"za7h.d", AArch64::ZAD7)
2960 .
Case(
"za0h.s", AArch64::ZAS0)
2961 .
Case(
"za1h.s", AArch64::ZAS1)
2962 .
Case(
"za2h.s", AArch64::ZAS2)
2963 .
Case(
"za3h.s", AArch64::ZAS3)
2964 .
Case(
"za0h.h", AArch64::ZAH0)
2965 .
Case(
"za1h.h", AArch64::ZAH1)
2966 .
Case(
"za0h.b", AArch64::ZAB0)
2967 .
Case(
"za0v.q", AArch64::ZAQ0)
2968 .
Case(
"za1v.q", AArch64::ZAQ1)
2969 .
Case(
"za2v.q", AArch64::ZAQ2)
2970 .
Case(
"za3v.q", AArch64::ZAQ3)
2971 .
Case(
"za4v.q", AArch64::ZAQ4)
2972 .
Case(
"za5v.q", AArch64::ZAQ5)
2973 .
Case(
"za6v.q", AArch64::ZAQ6)
2974 .
Case(
"za7v.q", AArch64::ZAQ7)
2975 .
Case(
"za8v.q", AArch64::ZAQ8)
2976 .
Case(
"za9v.q", AArch64::ZAQ9)
2977 .
Case(
"za10v.q", AArch64::ZAQ10)
2978 .
Case(
"za11v.q", AArch64::ZAQ11)
2979 .
Case(
"za12v.q", AArch64::ZAQ12)
2980 .
Case(
"za13v.q", AArch64::ZAQ13)
2981 .
Case(
"za14v.q", AArch64::ZAQ14)
2982 .
Case(
"za15v.q", AArch64::ZAQ15)
2983 .
Case(
"za0v.d", AArch64::ZAD0)
2984 .
Case(
"za1v.d", AArch64::ZAD1)
2985 .
Case(
"za2v.d", AArch64::ZAD2)
2986 .
Case(
"za3v.d", AArch64::ZAD3)
2987 .
Case(
"za4v.d", AArch64::ZAD4)
2988 .
Case(
"za5v.d", AArch64::ZAD5)
2989 .
Case(
"za6v.d", AArch64::ZAD6)
2990 .
Case(
"za7v.d", AArch64::ZAD7)
2991 .
Case(
"za0v.s", AArch64::ZAS0)
2992 .
Case(
"za1v.s", AArch64::ZAS1)
2993 .
Case(
"za2v.s", AArch64::ZAS2)
2994 .
Case(
"za3v.s", AArch64::ZAS3)
2995 .
Case(
"za0v.h", AArch64::ZAH0)
2996 .
Case(
"za1v.h", AArch64::ZAH1)
2997 .
Case(
"za0v.b", AArch64::ZAB0)
3003 return !tryParseRegister(
Reg, StartLoc, EndLoc).isSuccess();
3008 StartLoc = getLoc();
3015unsigned AArch64AsmParser::matchRegisterNameAlias(
StringRef Name,
3017 unsigned RegNum = 0;
3019 return Kind == RegKind::SVEDataVector ? RegNum : 0;
3022 return Kind == RegKind::SVEPredicateVector ? RegNum : 0;
3025 return Kind == RegKind::SVEPredicateAsCounter ? RegNum : 0;
3028 return Kind == RegKind::NeonVector ? RegNum : 0;
3031 return Kind == RegKind::Matrix ? RegNum : 0;
3033 if (
Name.equals_insensitive(
"zt0"))
3034 return Kind == RegKind::LookupTable ?
unsigned(AArch64::ZT0) : 0;
3038 return (Kind == RegKind::Scalar) ? RegNum : 0;
3043 .
Case(
"fp", AArch64::FP)
3044 .
Case(
"lr", AArch64::LR)
3045 .
Case(
"x31", AArch64::XZR)
3046 .
Case(
"w31", AArch64::WZR)
3048 return Kind == RegKind::Scalar ? RegNum : 0;
3054 if (Entry == RegisterReqs.
end())
3058 if (Kind ==
Entry->getValue().first)
3059 RegNum =
Entry->getValue().second;
3064unsigned AArch64AsmParser::getNumRegsForRegKind(RegKind K) {
3066 case RegKind::Scalar:
3067 case RegKind::NeonVector:
3068 case RegKind::SVEDataVector:
3070 case RegKind::Matrix:
3071 case RegKind::SVEPredicateVector:
3072 case RegKind::SVEPredicateAsCounter:
3074 case RegKind::LookupTable:
3089 unsigned Reg = matchRegisterNameAlias(lowerCase, RegKind::Scalar);
3103 return Error(S,
"Expected cN operand where 0 <= N <= 15");
3106 if (Tok[0] !=
'c' && Tok[0] !=
'C')
3107 return Error(S,
"Expected cN operand where 0 <= N <= 15");
3111 if (BadNum || CRNum > 15)
3112 return Error(S,
"Expected cN operand where 0 <= N <= 15");
3116 AArch64Operand::CreateSysCR(CRNum, S, getLoc(), getContext()));
3125 unsigned MaxVal = 63;
3131 if (getParser().parseExpression(ImmVal))
3136 return TokError(
"immediate value expected for prefetch operand");
3139 return TokError(
"prefetch operand out of range, [0," + utostr(MaxVal) +
3142 auto RPRFM = AArch64RPRFM::lookupRPRFMByEncoding(MCE->
getValue());
3143 Operands.push_back(AArch64Operand::CreatePrefetch(
3144 prfop, RPRFM ? RPRFM->Name :
"", S, getContext()));
3149 return TokError(
"prefetch hint expected");
3151 auto RPRFM = AArch64RPRFM::lookupRPRFMByName(Tok.
getString());
3153 return TokError(
"prefetch hint expected");
3155 Operands.push_back(AArch64Operand::CreatePrefetch(
3156 RPRFM->Encoding, Tok.
getString(), S, getContext()));
3162template <
bool IsSVEPrefetch>
3168 if (IsSVEPrefetch) {
3169 if (
auto Res = AArch64SVEPRFM::lookupSVEPRFMByName(
N))
3170 return std::optional<unsigned>(Res->Encoding);
3171 }
else if (
auto Res = AArch64PRFM::lookupPRFMByName(
N))
3172 return std::optional<unsigned>(Res->Encoding);
3173 return std::optional<unsigned>();
3176 auto LookupByEncoding = [](
unsigned E) {
3177 if (IsSVEPrefetch) {
3178 if (
auto Res = AArch64SVEPRFM::lookupSVEPRFMByEncoding(
E))
3179 return std::optional<StringRef>(Res->Name);
3180 }
else if (
auto Res = AArch64PRFM::lookupPRFMByEncoding(
E))
3181 return std::optional<StringRef>(Res->Name);
3182 return std::optional<StringRef>();
3184 unsigned MaxVal = IsSVEPrefetch ? 15 : 31;
3191 if (getParser().parseExpression(ImmVal))
3196 return TokError(
"immediate value expected for prefetch operand");
3199 return TokError(
"prefetch operand out of range, [0," + utostr(MaxVal) +
3202 auto PRFM = LookupByEncoding(MCE->
getValue());
3203 Operands.push_back(AArch64Operand::CreatePrefetch(prfop, PRFM.value_or(
""),
3209 return TokError(
"prefetch hint expected");
3211 auto PRFM = LookupByName(Tok.
getString());
3213 return TokError(
"prefetch hint expected");
3215 Operands.push_back(AArch64Operand::CreatePrefetch(
3216 *PRFM, Tok.
getString(), S, getContext()));
3226 return TokError(
"invalid operand for instruction");
3228 auto PSB = AArch64PSBHint::lookupPSBByName(Tok.
getString());
3230 return TokError(
"invalid operand for instruction");
3232 Operands.push_back(AArch64Operand::CreatePSBHint(
3233 PSB->Encoding, Tok.
getString(), S, getContext()));
3239 SMLoc StartLoc = getLoc();
3245 auto RegTok = getTok();
3246 if (!tryParseScalarRegister(RegNum).isSuccess())
3249 if (RegNum != AArch64::XZR) {
3250 getLexer().UnLex(RegTok);
3257 if (!tryParseScalarRegister(RegNum).isSuccess())
3258 return TokError(
"expected register operand");
3260 if (RegNum != AArch64::XZR)
3261 return TokError(
"xzr must be followed by xzr");
3265 Operands.push_back(AArch64Operand::CreateReg(
3266 RegNum, RegKind::Scalar, StartLoc, getLoc(), getContext()));
3276 return TokError(
"invalid operand for instruction");
3278 auto BTI = AArch64BTIHint::lookupBTIByName(Tok.
getString());
3280 return TokError(
"invalid operand for instruction");
3282 Operands.push_back(AArch64Operand::CreateBTIHint(
3283 BTI->Encoding, Tok.
getString(), S, getContext()));
3292 const MCExpr *Expr =
nullptr;
3298 if (parseSymbolicImmVal(Expr))
3304 if (classifySymbolRef(Expr, ELFRefKind, DarwinRefKind, Addend)) {
3314 return Error(S,
"gotpage label reference not allowed an addend");
3326 return Error(S,
"page or gotpage label reference expected");
3334 Operands.push_back(AArch64Operand::CreateImm(Expr, S,
E, getContext()));
3343 const MCExpr *Expr =
nullptr;
3352 if (parseSymbolicImmVal(Expr))
3358 if (classifySymbolRef(Expr, ELFRefKind, DarwinRefKind, Addend)) {
3371 return Error(S,
"unexpected adr label");
3376 Operands.push_back(AArch64Operand::CreateImm(Expr, S,
E, getContext()));
3381template <
bool AddFPZeroAsLiteral>
3394 return TokError(
"invalid floating point immediate");
3399 if (Tok.
getIntVal() > 255 || isNegative)
3400 return TokError(
"encoded floating point value out of range");
3404 AArch64Operand::CreateFPImm(
F,
true, S, getContext()));
3407 APFloat RealVal(APFloat::IEEEdouble());
3409 RealVal.convertFromString(Tok.
getString(), APFloat::rmTowardZero);
3411 return TokError(
"invalid floating point representation");
3414 RealVal.changeSign();
3416 if (AddFPZeroAsLiteral && RealVal.isPosZero()) {
3417 Operands.push_back(AArch64Operand::CreateToken(
"#0", S, getContext()));
3418 Operands.push_back(AArch64Operand::CreateToken(
".0", S, getContext()));
3420 Operands.push_back(AArch64Operand::CreateFPImm(
3421 RealVal, *StatusOrErr == APFloat::opOK, S, getContext()));
3446 if (parseSymbolicImmVal(Imm))
3450 AArch64Operand::CreateImm(Imm, S, getLoc(), getContext()));
3457 if (!parseOptionalVGOperand(
Operands, VecGroup)) {
3459 AArch64Operand::CreateImm(Imm, S, getLoc(), getContext()));
3461 AArch64Operand::CreateToken(VecGroup, getLoc(), getContext()));
3467 !getTok().getIdentifier().equals_insensitive(
"lsl"))
3468 return Error(getLoc(),
"only 'lsl #+N' valid after immediate");
3476 return Error(getLoc(),
"only 'lsl #+N' valid after immediate");
3478 int64_t ShiftAmount = getTok().getIntVal();
3480 if (ShiftAmount < 0)
3481 return Error(getLoc(),
"positive shift amount required");
3485 if (ShiftAmount == 0 && Imm !=
nullptr) {
3487 AArch64Operand::CreateImm(Imm, S, getLoc(), getContext()));
3491 Operands.push_back(AArch64Operand::CreateShiftedImm(Imm, ShiftAmount, S,
3492 getLoc(), getContext()));
3499AArch64AsmParser::parseCondCodeString(
StringRef Cond, std::string &Suggestion) {
3536 Suggestion =
"nfrst";
3543 bool invertCondCode) {
3549 std::string Suggestion;
3552 std::string Msg =
"invalid condition code";
3553 if (!Suggestion.empty())
3554 Msg +=
", did you mean " + Suggestion +
"?";
3555 return TokError(Msg);
3559 if (invertCondCode) {
3561 return TokError(
"condition codes AL and NV are invalid for this instruction");
3566 AArch64Operand::CreateCondCode(
CC, S, getLoc(), getContext()));
3575 return TokError(
"invalid operand for instruction");
3577 unsigned PStateImm = -1;
3578 const auto *SVCR = AArch64SVCR::lookupSVCRByName(Tok.
getString());
3581 if (SVCR->haveFeatures(getSTI().getFeatureBits()))
3582 PStateImm = SVCR->Encoding;
3585 AArch64Operand::CreateSVCR(PStateImm, Tok.
getString(), S, getContext()));
3596 if (
Name.equals_insensitive(
"za") ||
Name.starts_with_insensitive(
"za.")) {
3598 unsigned ElementWidth = 0;
3599 auto DotPosition =
Name.find(
'.');
3601 const auto &KindRes =
3605 "Expected the register to be followed by element width suffix");
3606 ElementWidth = KindRes->second;
3608 Operands.push_back(AArch64Operand::CreateMatrixRegister(
3609 AArch64::ZA, ElementWidth, MatrixKind::Array, S, getLoc(),
3614 if (parseOperand(
Operands,
false,
false))
3621 unsigned Reg = matchRegisterNameAlias(
Name, RegKind::Matrix);
3625 size_t DotPosition =
Name.find(
'.');
3633 .
Case(
"h", MatrixKind::Row)
3634 .
Case(
"v", MatrixKind::Col)
3641 "Expected the register to be followed by element width suffix");
3642 unsigned ElementWidth = KindRes->second;
3646 Operands.push_back(AArch64Operand::CreateMatrixRegister(
3647 Reg, ElementWidth, Kind, S, getLoc(), getContext()));
3652 if (parseOperand(
Operands,
false,
false))
3694 return TokError(
"expected #imm after shift specifier");
3700 AArch64Operand::CreateShiftExtend(ShOp, 0,
false, S,
E, getContext()));
3709 return Error(
E,
"expected integer shift amount");
3712 if (getParser().parseExpression(ImmVal))
3717 return Error(
E,
"expected constant '#imm' after shift specifier");
3720 Operands.push_back(AArch64Operand::CreateShiftExtend(
3721 ShOp, MCE->
getValue(),
true, S,
E, getContext()));
3729 {
"crc", {AArch64::FeatureCRC}},
3730 {
"sm4", {AArch64::FeatureSM4}},
3731 {
"sha3", {AArch64::FeatureSHA3}},
3732 {
"sha2", {AArch64::FeatureSHA2}},
3733 {
"aes", {AArch64::FeatureAES}},
3734 {
"crypto", {AArch64::FeatureCrypto}},
3735 {
"fp", {AArch64::FeatureFPARMv8}},
3736 {
"simd", {AArch64::FeatureNEON}},
3737 {
"ras", {AArch64::FeatureRAS}},
3738 {
"rasv2", {AArch64::FeatureRASv2}},
3739 {
"lse", {AArch64::FeatureLSE}},
3740 {
"predres", {AArch64::FeaturePredRes}},
3741 {
"predres2", {AArch64::FeatureSPECRES2}},
3742 {
"ccdp", {AArch64::FeatureCacheDeepPersist}},
3743 {
"mte", {AArch64::FeatureMTE}},
3744 {
"memtag", {AArch64::FeatureMTE}},
3745 {
"tlb-rmi", {AArch64::FeatureTLB_RMI}},
3746 {
"pan", {AArch64::FeaturePAN}},
3747 {
"pan-rwv", {AArch64::FeaturePAN_RWV}},
3748 {
"ccpp", {AArch64::FeatureCCPP}},
3749 {
"rcpc", {AArch64::FeatureRCPC}},
3750 {
"rng", {AArch64::FeatureRandGen}},
3751 {
"sve", {AArch64::FeatureSVE}},
3752 {
"sve-b16b16", {AArch64::FeatureSVEB16B16}},
3753 {
"sve2", {AArch64::FeatureSVE2}},
3754 {
"sve-aes", {AArch64::FeatureSVEAES}},
3755 {
"sve2-aes", {AArch64::FeatureAliasSVE2AES, AArch64::FeatureSVEAES}},
3756 {
"sve2-sm4", {AArch64::FeatureSVE2SM4}},
3757 {
"sve2-sha3", {AArch64::FeatureSVE2SHA3}},
3758 {
"sve2-bitperm", {AArch64::FeatureSVE2BitPerm}},
3759 {
"sve2p1", {AArch64::FeatureSVE2p1}},
3760 {
"ls64", {AArch64::FeatureLS64}},
3761 {
"xs", {AArch64::FeatureXS}},
3762 {
"pauth", {AArch64::FeaturePAuth}},
3763 {
"flagm", {AArch64::FeatureFlagM}},
3764 {
"rme", {AArch64::FeatureRME}},
3765 {
"sme", {AArch64::FeatureSME}},
3766 {
"sme-f64f64", {AArch64::FeatureSMEF64F64}},
3767 {
"sme-f16f16", {AArch64::FeatureSMEF16F16}},
3768 {
"sme-i16i64", {AArch64::FeatureSMEI16I64}},
3769 {
"sme2", {AArch64::FeatureSME2}},
3770 {
"sme2p1", {AArch64::FeatureSME2p1}},
3771 {
"sme-b16b16", {AArch64::FeatureSMEB16B16}},
3772 {
"hbc", {AArch64::FeatureHBC}},
3773 {
"mops", {AArch64::FeatureMOPS}},
3774 {
"mec", {AArch64::FeatureMEC}},
3775 {
"the", {AArch64::FeatureTHE}},
3776 {
"d128", {AArch64::FeatureD128}},
3777 {
"lse128", {AArch64::FeatureLSE128}},
3778 {
"ite", {AArch64::FeatureITE}},
3779 {
"cssc", {AArch64::FeatureCSSC}},
3780 {
"rcpc3", {AArch64::FeatureRCPC3}},
3781 {
"gcs", {AArch64::FeatureGCS}},
3782 {
"bf16", {AArch64::FeatureBF16}},
3783 {
"compnum", {AArch64::FeatureComplxNum}},
3784 {
"dotprod", {AArch64::FeatureDotProd}},
3785 {
"f32mm", {AArch64::FeatureMatMulFP32}},
3786 {
"f64mm", {AArch64::FeatureMatMulFP64}},
3787 {
"fp16", {AArch64::FeatureFullFP16}},
3788 {
"fp16fml", {AArch64::FeatureFP16FML}},
3789 {
"i8mm", {AArch64::FeatureMatMulInt8}},
3790 {
"lor", {AArch64::FeatureLOR}},
3791 {
"profile", {AArch64::FeatureSPE}},
3795 {
"rdm", {AArch64::FeatureRDM}},
3796 {
"rdma", {AArch64::FeatureRDM}},
3797 {
"sb", {AArch64::FeatureSB}},
3798 {
"ssbs", {AArch64::FeatureSSBS}},
3799 {
"tme", {AArch64::FeatureTME}},
3800 {
"fp8", {AArch64::FeatureFP8}},
3801 {
"faminmax", {AArch64::FeatureFAMINMAX}},
3802 {
"fp8fma", {AArch64::FeatureFP8FMA}},
3803 {
"ssve-fp8fma", {AArch64::FeatureSSVE_FP8FMA}},
3804 {
"fp8dot2", {AArch64::FeatureFP8DOT2}},
3805 {
"ssve-fp8dot2", {AArch64::FeatureSSVE_FP8DOT2}},
3806 {
"fp8dot4", {AArch64::FeatureFP8DOT4}},
3807 {
"ssve-fp8dot4", {AArch64::FeatureSSVE_FP8DOT4}},
3808 {
"lut", {AArch64::FeatureLUT}},
3809 {
"sme-lutv2", {AArch64::FeatureSME_LUTv2}},
3810 {
"sme-f8f16", {AArch64::FeatureSMEF8F16}},
3811 {
"sme-f8f32", {AArch64::FeatureSMEF8F32}},
3812 {
"sme-fa64", {AArch64::FeatureSMEFA64}},
3813 {
"cpa", {AArch64::FeatureCPA}},
3814 {
"tlbiw", {AArch64::FeatureTLBIW}},
3815 {
"pops", {AArch64::FeaturePoPS}},
3816 {
"cmpbr", {AArch64::FeatureCMPBR}},
3817 {
"f8f32mm", {AArch64::FeatureF8F32MM}},
3818 {
"f8f16mm", {AArch64::FeatureF8F16MM}},
3819 {
"fprcvt", {AArch64::FeatureFPRCVT}},
3820 {
"lsfe", {AArch64::FeatureLSFE}},
3821 {
"sme2p2", {AArch64::FeatureSME2p2}},
3822 {
"ssve-aes", {AArch64::FeatureSSVE_AES}},
3823 {
"sve2p2", {AArch64::FeatureSVE2p2}},
3824 {
"sve-aes2", {AArch64::FeatureSVEAES2}},
3825 {
"sve-bfscale", {AArch64::FeatureSVEBFSCALE}},
3826 {
"sve-f16f32mm", {AArch64::FeatureSVE_F16F32MM}},
3827 {
"lsui", {AArch64::FeatureLSUI}},
3828 {
"occmo", {AArch64::FeatureOCCMO}},
3829 {
"pcdphint", {AArch64::FeaturePCDPHINT}},
3833 if (FBS[AArch64::HasV8_0aOps])
3835 if (FBS[AArch64::HasV8_1aOps])
3837 else if (FBS[AArch64::HasV8_2aOps])
3839 else if (FBS[AArch64::HasV8_3aOps])
3841 else if (FBS[AArch64::HasV8_4aOps])
3843 else if (FBS[AArch64::HasV8_5aOps])
3845 else if (FBS[AArch64::HasV8_6aOps])
3847 else if (FBS[AArch64::HasV8_7aOps])
3849 else if (FBS[AArch64::HasV8_8aOps])
3851 else if (FBS[AArch64::HasV8_9aOps])
3853 else if (FBS[AArch64::HasV9_0aOps])
3855 else if (FBS[AArch64::HasV9_1aOps])
3857 else if (FBS[AArch64::HasV9_2aOps])
3859 else if (FBS[AArch64::HasV9_3aOps])
3861 else if (FBS[AArch64::HasV9_4aOps])
3863 else if (FBS[AArch64::HasV9_5aOps])
3865 else if (FBS[AArch64::HasV9_6aOps])
3867 else if (FBS[AArch64::HasV8_0rOps])
3876 Str += !ExtMatches.
empty() ? llvm::join(ExtMatches,
", ") :
"(unknown)";
3883 const uint16_t Cm = (Encoding & 0x78) >> 3;
3884 const uint16_t Cn = (Encoding & 0x780) >> 7;
3885 const uint16_t Op1 = (Encoding & 0x3800) >> 11;
3890 AArch64Operand::CreateImm(Expr, S, getLoc(), getContext()));
3892 AArch64Operand::CreateSysCR(Cn, S, getLoc(), getContext()));
3894 AArch64Operand::CreateSysCR(Cm, S, getLoc(), getContext()));
3897 AArch64Operand::CreateImm(Expr, S, getLoc(), getContext()));
3904 if (
Name.contains(
'.'))
3905 return TokError(
"invalid operand");
3908 Operands.push_back(AArch64Operand::CreateToken(
"sys", NameLoc, getContext()));
3914 if (Mnemonic ==
"ic") {
3917 return TokError(
"invalid operand for IC instruction");
3918 else if (!IC->
haveFeatures(getSTI().getFeatureBits())) {
3919 std::string Str(
"IC " + std::string(IC->
Name) +
" requires: ");
3921 return TokError(Str);
3924 }
else if (Mnemonic ==
"dc") {
3927 return TokError(
"invalid operand for DC instruction");
3928 else if (!DC->
haveFeatures(getSTI().getFeatureBits())) {
3929 std::string Str(
"DC " + std::string(DC->
Name) +
" requires: ");
3931 return TokError(Str);
3934 }
else if (Mnemonic ==
"at") {
3937 return TokError(
"invalid operand for AT instruction");
3938 else if (!AT->
haveFeatures(getSTI().getFeatureBits())) {
3939 std::string Str(
"AT " + std::string(AT->
Name) +
" requires: ");
3941 return TokError(Str);
3944 }
else if (Mnemonic ==
"tlbi") {
3947 return TokError(
"invalid operand for TLBI instruction");
3948 else if (!TLBI->
haveFeatures(getSTI().getFeatureBits())) {
3949 std::string Str(
"TLBI " + std::string(TLBI->
Name) +
" requires: ");
3951 return TokError(Str);
3954 }
else if (Mnemonic ==
"cfp" || Mnemonic ==
"dvp" || Mnemonic ==
"cpp" || Mnemonic ==
"cosp") {
3956 if (
Op.lower() !=
"rctx")
3957 return TokError(
"invalid operand for prediction restriction instruction");
3959 bool hasAll = getSTI().hasFeature(AArch64::FeatureAll);
3960 bool hasPredres = hasAll || getSTI().hasFeature(AArch64::FeaturePredRes);
3961 bool hasSpecres2 = hasAll || getSTI().hasFeature(AArch64::FeatureSPECRES2);
3963 if (Mnemonic ==
"cosp" && !hasSpecres2)
3964 return TokError(
"COSP requires: predres2");
3966 return TokError(Mnemonic.
upper() +
"RCTX requires: predres");
3968 uint16_t PRCTX_Op2 = Mnemonic ==
"cfp" ? 0b100
3969 : Mnemonic ==
"dvp" ? 0b101
3970 : Mnemonic ==
"cosp" ? 0b110
3971 : Mnemonic ==
"cpp" ? 0b111
3974 "Invalid mnemonic for prediction restriction instruction");
3975 const auto SYS_3_7_3 = 0b01101110011;
3976 const auto Encoding = SYS_3_7_3 << 3 | PRCTX_Op2;
3978 createSysAlias(Encoding,
Operands, S);
3983 bool ExpectRegister = !
Op.contains_insensitive(
"all");
3984 bool HasRegister =
false;
3989 return TokError(
"expected register operand");
3993 if (ExpectRegister && !HasRegister)
3994 return TokError(
"specified " + Mnemonic +
" op requires a register");
3995 else if (!ExpectRegister && HasRegister)
3996 return TokError(
"specified " + Mnemonic +
" op does not use a register");
4008 if (
Name.contains(
'.'))
4009 return TokError(
"invalid operand");
4013 AArch64Operand::CreateToken(
"sysp", NameLoc, getContext()));
4019 if (Mnemonic ==
"tlbip") {
4020 bool HasnXSQualifier =
Op.ends_with_insensitive(
"nXS");
4021 if (HasnXSQualifier) {
4022 Op =
Op.drop_back(3);
4026 return TokError(
"invalid operand for TLBIP instruction");
4028 TLBIorig->
Name, TLBIorig->
Encoding | (HasnXSQualifier ? (1 << 7) : 0),
4035 std::string(TLBI.
Name) + (HasnXSQualifier ?
"nXS" :
"");
4036 std::string Str(
"TLBIP " +
Name +
" requires: ");
4038 return TokError(Str);
4049 return TokError(
"expected register identifier");
4054 return TokError(
"specified " + Mnemonic +
4055 " op requires a pair of registers");
4068 return TokError(
"'csync' operand expected");
4072 SMLoc ExprLoc = getLoc();
4074 if (getParser().parseExpression(ImmVal))
4078 return Error(ExprLoc,
"immediate value expected for barrier operand");
4080 if (Mnemonic ==
"dsb" &&
Value > 15) {
4087 if (Value < 0 || Value > 15)
4088 return Error(ExprLoc,
"barrier operand out of range");
4089 auto DB = AArch64DB::lookupDBByEncoding(
Value);
4090 Operands.push_back(AArch64Operand::CreateBarrier(
Value, DB ?
DB->Name :
"",
4091 ExprLoc, getContext(),
4097 return TokError(
"invalid operand for instruction");
4100 auto TSB = AArch64TSB::lookupTSBByName(Operand);
4101 auto DB = AArch64DB::lookupDBByName(Operand);
4103 if (Mnemonic ==
"isb" && (!DB ||
DB->Encoding != AArch64DB::sy))
4104 return TokError(
"'sy' or #imm operand expected");
4106 if (Mnemonic ==
"tsb" && (!TSB || TSB->Encoding != AArch64TSB::csync))
4107 return TokError(
"'csync' operand expected");
4109 if (Mnemonic ==
"dsb") {
4114 return TokError(
"invalid barrier option name");
4117 Operands.push_back(AArch64Operand::CreateBarrier(
4118 DB ?
DB->Encoding : TSB->Encoding, Tok.
getString(), getLoc(),
4119 getContext(),
false ));
4129 assert(Mnemonic ==
"dsb" &&
"Instruction does not accept nXS operands");
4130 if (Mnemonic !=
"dsb")
4136 SMLoc ExprLoc = getLoc();
4137 if (getParser().parseExpression(ImmVal))
4141 return Error(ExprLoc,
"immediate value expected for barrier operand");
4146 return Error(ExprLoc,
"barrier operand out of range");
4147 auto DB = AArch64DBnXS::lookupDBnXSByImmValue(
Value);
4148 Operands.push_back(AArch64Operand::CreateBarrier(
DB->Encoding,
DB->Name,
4149 ExprLoc, getContext(),
4155 return TokError(
"invalid operand for instruction");
4158 auto DB = AArch64DBnXS::lookupDBnXSByName(Operand);
4161 return TokError(
"invalid barrier option name");
4164 AArch64Operand::CreateBarrier(
DB->Encoding, Tok.
getString(), getLoc(),
4165 getContext(),
true ));
4177 if (AArch64SVCR::lookupSVCRByName(Tok.
getString()))
4182 if (SysReg && SysReg->haveFeatures(getSTI().getFeatureBits())) {
4183 MRSReg = SysReg->Readable ? SysReg->Encoding : -1;
4184 MSRReg = SysReg->Writeable ? SysReg->Encoding : -1;
4188 unsigned PStateImm = -1;
4189 auto PState15 = AArch64PState::lookupPStateImm0_15ByName(Tok.
getString());
4190 if (PState15 && PState15->haveFeatures(getSTI().getFeatureBits()))
4191 PStateImm = PState15->Encoding;
4193 auto PState1 = AArch64PState::lookupPStateImm0_1ByName(Tok.
getString());
4194 if (PState1 && PState1->haveFeatures(getSTI().getFeatureBits()))
4195 PStateImm = PState1->Encoding;
4199 AArch64Operand::CreateSysReg(Tok.
getString(), getLoc(), MRSReg, MSRReg,
4200 PStateImm, getContext()));
4211 return TokError(
"invalid operand for instruction");
4215 return TokError(
"invalid operand for instruction");
4217 Operands.push_back(AArch64Operand::CreatePHintInst(
4218 PH->Encoding, Tok.
getString(), S, getContext()));
4232 ParseStatus Res = tryParseVectorRegister(Reg, Kind, RegKind::NeonVector);
4240 unsigned ElementWidth = KindRes->second;
4242 AArch64Operand::CreateVectorReg(Reg, RegKind::NeonVector, ElementWidth,
4243 S, getLoc(), getContext()));
4248 Operands.push_back(AArch64Operand::CreateToken(Kind, S, getContext()));
4250 return tryParseVectorIndex(
Operands).isFailure();
4254 SMLoc SIdx = getLoc();
4257 if (getParser().parseExpression(ImmVal))
4261 return TokError(
"immediate value expected for vector index");
4268 Operands.push_back(AArch64Operand::CreateVectorIndex(MCE->
getValue(), SIdx,
4281 RegKind MatchKind) {
4290 size_t Start = 0, Next =
Name.find(
'.');
4292 unsigned RegNum = matchRegisterNameAlias(Head, MatchKind);
4298 return TokError(
"invalid vector kind qualifier");
4309ParseStatus AArch64AsmParser::tryParseSVEPredicateOrPredicateAsCounterVector(
4312 tryParseSVEPredicateVector<RegKind::SVEPredicateAsCounter>(
Operands);
4314 Status = tryParseSVEPredicateVector<RegKind::SVEPredicateVector>(
Operands);
4319template <RegKind RK>
4323 const SMLoc S = getLoc();
4326 auto Res = tryParseVectorRegister(RegNum, Kind, RK);
4334 unsigned ElementWidth = KindRes->second;
4335 Operands.push_back(AArch64Operand::CreateVectorReg(
4336 RegNum, RK, ElementWidth, S,
4337 getLoc(), getContext()));
4340 if (RK == RegKind::SVEPredicateAsCounter) {
4347 if (parseOperand(
Operands,
false,
false))
4358 return Error(S,
"not expecting size suffix");
4361 Operands.push_back(AArch64Operand::CreateToken(
"/", getLoc(), getContext()));
4366 auto Pred = getTok().getString().lower();
4367 if (RK == RegKind::SVEPredicateAsCounter && Pred !=
"z")
4368 return Error(getLoc(),
"expecting 'z' predication");
4370 if (RK == RegKind::SVEPredicateVector && Pred !=
"z" && Pred !=
"m")
4371 return Error(getLoc(),
"expecting 'm' or 'z' predication");
4374 const char *ZM = Pred ==
"z" ?
"z" :
"m";
4375 Operands.push_back(AArch64Operand::CreateToken(ZM, getLoc(), getContext()));
4384 if (!tryParseNeonVectorRegister(
Operands))
4387 if (tryParseZTOperand(
Operands).isSuccess())
4391 if (tryParseGPROperand<false>(
Operands).isSuccess())
4397bool AArch64AsmParser::parseSymbolicImmVal(
const MCExpr *&ImmVal) {
4398 bool HasELFModifier =
false;
4402 HasELFModifier =
true;
4405 return TokError(
"expect relocation specifier in operand after ':'");
4407 std::string LowerCase = getTok().getIdentifier().lower();
4463 return TokError(
"expect relocation specifier in operand after ':'");
4467 if (parseToken(
AsmToken::Colon,
"expect ':' after relocation specifier"))
4471 if (getParser().parseExpression(ImmVal))
4484 auto ParseMatrixTile = [
this](
unsigned &
Reg,
4487 size_t DotPosition =
Name.find(
'.');
4496 const std::optional<std::pair<int, int>> &KindRes =
4500 "Expected the register to be followed by element width suffix");
4501 ElementWidth = KindRes->second;
4508 auto LCurly = getTok();
4513 Operands.push_back(AArch64Operand::CreateMatrixTileList(
4514 0, S, getLoc(), getContext()));
4519 if (getTok().getString().equals_insensitive(
"za")) {
4525 Operands.push_back(AArch64Operand::CreateMatrixTileList(
4526 0xFF, S, getLoc(), getContext()));
4530 SMLoc TileLoc = getLoc();
4532 unsigned FirstReg, ElementWidth;
4533 auto ParseRes = ParseMatrixTile(FirstReg, ElementWidth);
4534 if (!ParseRes.isSuccess()) {
4535 getLexer().UnLex(LCurly);
4541 unsigned PrevReg = FirstReg;
4544 AArch64Operand::ComputeRegsForAlias(FirstReg, DRegs, ElementWidth);
4547 SeenRegs.
insert(FirstReg);
4551 unsigned Reg, NextElementWidth;
4552 ParseRes = ParseMatrixTile(Reg, NextElementWidth);
4553 if (!ParseRes.isSuccess())
4557 if (ElementWidth != NextElementWidth)
4558 return Error(TileLoc,
"mismatched register size suffix");
4561 Warning(TileLoc,
"tile list not in ascending order");
4564 Warning(TileLoc,
"duplicate tile in list");
4567 AArch64Operand::ComputeRegsForAlias(Reg, DRegs, ElementWidth);
4576 unsigned RegMask = 0;
4577 for (
auto Reg : DRegs)
4581 AArch64Operand::CreateMatrixTileList(RegMask, S, getLoc(), getContext()));
4586template <RegKind VectorKind>
4596 auto RegTok = getTok();
4597 auto ParseRes = tryParseVectorRegister(Reg, Kind, VectorKind);
4598 if (ParseRes.isSuccess()) {
4605 RegTok.getString().equals_insensitive(
"zt0"))
4609 (ParseRes.isNoMatch() && NoMatchIsError &&
4610 !RegTok.getString().starts_with_insensitive(
"za")))
4611 return Error(Loc,
"vector register expected");
4616 int NumRegs = getNumRegsForRegKind(VectorKind);
4618 auto LCurly = getTok();
4623 auto ParseRes = ParseVector(FirstReg, Kind, getLoc(), ExpectMatch);
4627 if (ParseRes.isNoMatch())
4630 if (!ParseRes.isSuccess())
4633 int64_t PrevReg = FirstReg;
4638 SMLoc Loc = getLoc();
4642 ParseRes = ParseVector(Reg, NextKind, getLoc(),
true);
4643 if (!ParseRes.isSuccess())
4647 if (Kind != NextKind)
4648 return Error(Loc,
"mismatched register size suffix");
4651 (PrevReg <
Reg) ? (Reg - PrevReg) : (
Reg + NumRegs - PrevReg);
4653 if (Space == 0 || Space > 3)
4654 return Error(Loc,
"invalid number of vectors");
4659 bool HasCalculatedStride =
false;
4661 SMLoc Loc = getLoc();
4664 ParseRes = ParseVector(Reg, NextKind, getLoc(),
true);
4665 if (!ParseRes.isSuccess())
4669 if (Kind != NextKind)
4670 return Error(Loc,
"mismatched register size suffix");
4672 unsigned RegVal = getContext().getRegisterInfo()->getEncodingValue(Reg);
4673 unsigned PrevRegVal =
4674 getContext().getRegisterInfo()->getEncodingValue(PrevReg);
4675 if (!HasCalculatedStride) {
4676 Stride = (PrevRegVal < RegVal) ? (RegVal - PrevRegVal)
4677 : (RegVal + NumRegs - PrevRegVal);
4678 HasCalculatedStride =
true;
4682 if (Stride == 0 || RegVal != ((PrevRegVal + Stride) % NumRegs))
4683 return Error(Loc,
"registers must have the same sequential stride");
4694 return Error(S,
"invalid number of vectors");
4696 unsigned NumElements = 0;
4697 unsigned ElementWidth = 0;
4698 if (!
Kind.empty()) {
4700 std::tie(NumElements, ElementWidth) = *VK;
4703 Operands.push_back(AArch64Operand::CreateVectorList(
4704 FirstReg, Count, Stride, NumElements, ElementWidth, VectorKind, S,
4705 getLoc(), getContext()));
4712 auto ParseRes = tryParseVectorList<RegKind::NeonVector>(
Operands,
true);
4713 if (!ParseRes.isSuccess())
4716 return tryParseVectorIndex(
Operands).isFailure();
4720 SMLoc StartLoc = getLoc();
4728 Operands.push_back(AArch64Operand::CreateReg(
4729 RegNum, RegKind::Scalar, StartLoc, getLoc(), getContext()));
4736 return Error(getLoc(),
"index must be absent or #0");
4739 if (getParser().parseExpression(ImmVal) || !isa<MCConstantExpr>(ImmVal) ||
4740 cast<MCConstantExpr>(ImmVal)->getValue() != 0)
4741 return Error(getLoc(),
"index must be absent or #0");
4743 Operands.push_back(AArch64Operand::CreateReg(
4744 RegNum, RegKind::Scalar, StartLoc, getLoc(), getContext()));
4749 SMLoc StartLoc = getLoc();
4753 unsigned RegNum = matchRegisterNameAlias(
Name, RegKind::LookupTable);
4758 Operands.push_back(AArch64Operand::CreateReg(
4759 RegNum, RegKind::LookupTable, StartLoc, getLoc(), getContext()));
4765 AArch64Operand::CreateToken(
"[", getLoc(), getContext()));
4767 if (getParser().parseExpression(ImmVal))
4771 return TokError(
"immediate value expected for vector index");
4772 Operands.push_back(AArch64Operand::CreateImm(
4774 getLoc(), getContext()));
4776 if (parseOptionalMulOperand(
Operands))
4781 AArch64Operand::CreateToken(
"]", getLoc(), getContext()));
4786template <
bool ParseShiftExtend, RegConstra
intEqualityTy EqTy>
4788 SMLoc StartLoc = getLoc();
4797 Operands.push_back(AArch64Operand::CreateReg(
4798 RegNum, RegKind::Scalar, StartLoc, getLoc(), getContext(), EqTy));
4807 Res = tryParseOptionalShiftExtend(ExtOpnd);
4811 auto Ext =
static_cast<AArch64Operand*
>(ExtOpnd.
back().get());
4812 Operands.push_back(AArch64Operand::CreateReg(
4813 RegNum, RegKind::Scalar, StartLoc,
Ext->getEndLoc(), getContext(), EqTy,
4814 Ext->getShiftExtendType(),
Ext->getShiftExtendAmount(),
4815 Ext->hasShiftExtendAmount()));
4829 if (!getTok().getString().equals_insensitive(
"mul") ||
4830 !(NextIsVL || NextIsHash))
4834 AArch64Operand::CreateToken(
"mul", getLoc(), getContext()));
4839 AArch64Operand::CreateToken(
"vl", getLoc(), getContext()));
4851 if (
const MCConstantExpr *MCE = dyn_cast<MCConstantExpr>(ImmVal)) {
4852 Operands.push_back(AArch64Operand::CreateImm(
4859 return Error(getLoc(),
"expected 'vl' or '#<imm>'");
4865 auto Tok = Parser.
getTok();
4870 .
Case(
"vgx2",
"vgx2")
4871 .
Case(
"vgx4",
"vgx4")
4883 auto Tok = getTok();
4893 AArch64Operand::CreateToken(Keyword, Tok.
getLoc(), getContext()));
4902 bool invertCondCode) {
4906 MatchOperandParserImpl(
Operands, Mnemonic,
true);
4920 auto parseOptionalShiftExtend = [&](
AsmToken SavedTok) {
4925 getLexer().UnLex(SavedTok);
4929 switch (getLexer().getKind()) {
4933 if (parseSymbolicImmVal(Expr))
4934 return Error(S,
"invalid operand");
4937 Operands.push_back(AArch64Operand::CreateImm(Expr, S, E, getContext()));
4938 return parseOptionalShiftExtend(getTok());
4942 AArch64Operand::CreateToken(
"[", getLoc(), getContext()));
4947 return parseOperand(
Operands,
false,
false);
4950 if (!parseNeonVectorList(
Operands))
4954 AArch64Operand::CreateToken(
"{", getLoc(), getContext()));
4959 return parseOperand(
Operands,
false,
false);
4964 if (!parseOptionalVGOperand(
Operands, VecGroup)) {
4966 AArch64Operand::CreateToken(VecGroup, getLoc(), getContext()));
4971 return parseCondCode(
Operands, invertCondCode);
4985 Res = tryParseOptionalShiftExtend(
Operands);
4988 getLexer().UnLex(SavedTok);
4995 if (!parseOptionalMulOperand(
Operands))
5000 if (Mnemonic ==
"brb" || Mnemonic ==
"smstart" || Mnemonic ==
"smstop" ||
5002 return parseKeywordOperand(
Operands);
5008 if (getParser().parseExpression(IdVal))
5011 Operands.push_back(AArch64Operand::CreateImm(IdVal, S, E, getContext()));
5023 bool isNegative =
false;
5039 if (Mnemonic !=
"fcmp" && Mnemonic !=
"fcmpe" && Mnemonic !=
"fcmeq" &&
5040 Mnemonic !=
"fcmge" && Mnemonic !=
"fcmgt" && Mnemonic !=
"fcmle" &&
5041 Mnemonic !=
"fcmlt" && Mnemonic !=
"fcmne")
5042 return TokError(
"unexpected floating point literal");
5043 else if (IntVal != 0 || isNegative)
5044 return TokError(
"expected floating-point constant #0.0");
5047 Operands.push_back(AArch64Operand::CreateToken(
"#0", S, getContext()));
5048 Operands.push_back(AArch64Operand::CreateToken(
".0", S, getContext()));
5053 if (parseSymbolicImmVal(ImmVal))
5057 Operands.push_back(AArch64Operand::CreateImm(ImmVal, S, E, getContext()));
5060 return parseOptionalShiftExtend(Tok);
5063 SMLoc Loc = getLoc();
5064 if (Mnemonic !=
"ldr")
5065 return TokError(
"unexpected token in operand");
5067 const MCExpr *SubExprVal;
5068 if (getParser().parseExpression(SubExprVal))
5072 !
static_cast<AArch64Operand &
>(*
Operands[1]).isScalarReg())
5073 return Error(Loc,
"Only valid when first operand is register");
5076 AArch64MCRegisterClasses[AArch64::GPR64allRegClassID].contains(
5082 if (isa<MCConstantExpr>(SubExprVal)) {
5083 uint64_t Imm = (cast<MCConstantExpr>(SubExprVal))->getValue();
5084 uint32_t ShiftAmt = 0, MaxShiftAmt = IsXReg ? 48 : 16;
5089 if (ShiftAmt <= MaxShiftAmt && Imm <= 0xFFFF) {
5090 Operands[0] = AArch64Operand::CreateToken(
"movz", Loc, Ctx);
5091 Operands.push_back(AArch64Operand::CreateImm(
5095 ShiftAmt,
true, S, E, Ctx));
5101 return Error(Loc,
"Immediate too large for register");
5105 getTargetStreamer().addConstantPoolEntry(SubExprVal, IsXReg ? 8 : 4, Loc);
5106 Operands.push_back(AArch64Operand::CreateImm(CPLoc, S, E, Ctx));
5112bool AArch64AsmParser::parseImmExpr(int64_t &Out) {
5113 const MCExpr *Expr =
nullptr;
5115 if (check(getParser().parseExpression(Expr), L,
"expected expression"))
5118 if (check(!
Value, L,
"expected constant expression"))
5120 Out =
Value->getValue();
5124bool AArch64AsmParser::parseComma() {
5132bool AArch64AsmParser::parseRegisterInRange(
unsigned &Out,
unsigned Base,
5136 if (check(parseRegister(Reg, Start,
End), getLoc(),
"expected register"))
5141 unsigned RangeEnd =
Last;
5142 if (
Base == AArch64::X0) {
5143 if (
Last == AArch64::FP) {
5144 RangeEnd = AArch64::X28;
5145 if (Reg == AArch64::FP) {
5150 if (
Last == AArch64::LR) {
5151 RangeEnd = AArch64::X28;
5152 if (Reg == AArch64::FP) {
5155 }
else if (Reg == AArch64::LR) {
5162 if (check(Reg < First || Reg > RangeEnd, Start,
5163 Twine(
"expected register in range ") +
5173 auto &AOp1 =
static_cast<const AArch64Operand&
>(Op1);
5174 auto &AOp2 =
static_cast<const AArch64Operand&
>(Op2);
5176 if (AOp1.isVectorList() && AOp2.isVectorList())
5177 return AOp1.getVectorListCount() == AOp2.getVectorListCount() &&
5178 AOp1.getVectorListStart() == AOp2.getVectorListStart() &&
5179 AOp1.getVectorListStride() == AOp2.getVectorListStride();
5181 if (!AOp1.isReg() || !AOp2.isReg())
5184 if (AOp1.getRegEqualityTy() == RegConstraintEqualityTy::EqualsReg &&
5185 AOp2.getRegEqualityTy() == RegConstraintEqualityTy::EqualsReg)
5188 assert(AOp1.isScalarReg() && AOp2.isScalarReg() &&
5189 "Testing equality of non-scalar registers not supported");
5192 if (AOp1.getRegEqualityTy() == EqualsSuperReg)
5194 if (AOp1.getRegEqualityTy() == EqualsSubReg)
5196 if (AOp2.getRegEqualityTy() == EqualsSuperReg)
5198 if (AOp2.getRegEqualityTy() == EqualsSubReg)
5209 .
Case(
"beq",
"b.eq")
5210 .
Case(
"bne",
"b.ne")
5211 .
Case(
"bhs",
"b.hs")
5212 .
Case(
"bcs",
"b.cs")
5213 .
Case(
"blo",
"b.lo")
5214 .
Case(
"bcc",
"b.cc")
5215 .
Case(
"bmi",
"b.mi")
5216 .
Case(
"bpl",
"b.pl")
5217 .
Case(
"bvs",
"b.vs")
5218 .
Case(
"bvc",
"b.vc")
5219 .
Case(
"bhi",
"b.hi")
5220 .
Case(
"bls",
"b.ls")
5221 .
Case(
"bge",
"b.ge")
5222 .
Case(
"blt",
"b.lt")
5223 .
Case(
"bgt",
"b.gt")
5224 .
Case(
"ble",
"b.le")
5225 .
Case(
"bal",
"b.al")
5226 .
Case(
"bnv",
"b.nv")
5231 getTok().getIdentifier().lower() ==
".req") {
5232 parseDirectiveReq(
Name, NameLoc);
5239 size_t Start = 0, Next =
Name.find(
'.');
5244 if (Head ==
"ic" || Head ==
"dc" || Head ==
"at" || Head ==
"tlbi" ||
5245 Head ==
"cfp" || Head ==
"dvp" || Head ==
"cpp" || Head ==
"cosp")
5246 return parseSysAlias(Head, NameLoc,
Operands);
5249 if (Head ==
"tlbip")
5250 return parseSyspAlias(Head, NameLoc,
Operands);
5252 Operands.push_back(AArch64Operand::CreateToken(Head, NameLoc, getContext()));
5258 Next =
Name.find(
'.', Start + 1);
5259 Head =
Name.slice(Start + 1, Next);
5263 std::string Suggestion;
5266 std::string Msg =
"invalid condition code";
5267 if (!Suggestion.empty())
5268 Msg +=
", did you mean " + Suggestion +
"?";
5269 return Error(SuffixLoc, Msg);
5271 Operands.push_back(AArch64Operand::CreateToken(
".", SuffixLoc, getContext(),
5274 AArch64Operand::CreateCondCode(
CC, NameLoc, NameLoc, getContext()));
5280 Next =
Name.find(
'.', Start + 1);
5281 Head =
Name.slice(Start, Next);
5284 Operands.push_back(AArch64Operand::CreateToken(
5285 Head, SuffixLoc, getContext(),
true));
5290 bool condCodeFourthOperand =
5291 (Head ==
"ccmp" || Head ==
"ccmn" || Head ==
"fccmp" ||
5292 Head ==
"fccmpe" || Head ==
"fcsel" || Head ==
"csel" ||
5293 Head ==
"csinc" || Head ==
"csinv" || Head ==
"csneg");
5301 bool condCodeSecondOperand = (Head ==
"cset" || Head ==
"csetm");
5302 bool condCodeThirdOperand =
5303 (Head ==
"cinc" || Head ==
"cinv" || Head ==
"cneg");
5311 if (parseOperand(
Operands, (
N == 4 && condCodeFourthOperand) ||
5312 (
N == 3 && condCodeThirdOperand) ||
5313 (
N == 2 && condCodeSecondOperand),
5314 condCodeSecondOperand || condCodeThirdOperand)) {
5334 AArch64Operand::CreateToken(
"]", getLoc(), getContext()));
5337 AArch64Operand::CreateToken(
"!", getLoc(), getContext()));
5340 AArch64Operand::CreateToken(
"}", getLoc(), getContext()));
5353 assert((ZReg >= AArch64::Z0) && (ZReg <= AArch64::Z31));
5354 return (ZReg == ((Reg - AArch64::B0) + AArch64::Z0)) ||
5355 (ZReg == ((Reg - AArch64::H0) + AArch64::Z0)) ||
5356 (ZReg == ((Reg - AArch64::S0) + AArch64::Z0)) ||
5357 (ZReg == ((Reg - AArch64::D0) + AArch64::Z0)) ||
5358 (ZReg == ((Reg - AArch64::Q0) + AArch64::Z0)) ||
5359 (ZReg == ((Reg - AArch64::Z0) + AArch64::Z0));
5365bool AArch64AsmParser::validateInstruction(
MCInst &Inst,
SMLoc &IDLoc,
5374 PrefixInfo
Prefix = NextPrefix;
5375 NextPrefix = PrefixInfo::CreateFromInst(Inst, MCID.
TSFlags);
5387 return Error(IDLoc,
"instruction is unpredictable when following a"
5388 " movprfx, suggest replacing movprfx with mov");
5392 return Error(Loc[0],
"instruction is unpredictable when following a"
5393 " movprfx writing to a different destination");
5400 return Error(Loc[0],
"instruction is unpredictable when following a"
5401 " movprfx and destination also used as non-destructive"
5405 auto PPRRegClass = AArch64MCRegisterClasses[AArch64::PPRRegClassID];
5406 if (
Prefix.isPredicated()) {
5420 return Error(IDLoc,
"instruction is unpredictable when following a"
5421 " predicated movprfx, suggest using unpredicated movprfx");
5425 return Error(IDLoc,
"instruction is unpredictable when following a"
5426 " predicated movprfx using a different general predicate");
5430 return Error(IDLoc,
"instruction is unpredictable when following a"
5431 " predicated movprfx with a different element size");
5437 if (IsWindowsArm64EC) {
5443 if ((Reg == AArch64::W13 || Reg == AArch64::X13) ||
5444 (Reg == AArch64::W14 || Reg == AArch64::X14) ||
5445 (Reg == AArch64::W23 || Reg == AArch64::X23) ||
5446 (Reg == AArch64::W24 || Reg == AArch64::X24) ||
5447 (Reg == AArch64::W28 || Reg == AArch64::X28) ||
5448 (Reg >= AArch64::Q16 && Reg <= AArch64::Q31) ||
5449 (Reg >= AArch64::D16 && Reg <= AArch64::D31) ||
5450 (Reg >= AArch64::S16 && Reg <= AArch64::S31) ||
5451 (Reg >= AArch64::H16 && Reg <= AArch64::H31) ||
5452 (Reg >= AArch64::B16 && Reg <= AArch64::B31)) {
5454 " is disallowed on ARM64EC.");
5464 case AArch64::LDPSWpre:
5465 case AArch64::LDPWpost:
5466 case AArch64::LDPWpre:
5467 case AArch64::LDPXpost:
5468 case AArch64::LDPXpre: {
5473 return Error(Loc[0],
"unpredictable LDP instruction, writeback base "
5474 "is also a destination");
5476 return Error(Loc[1],
"unpredictable LDP instruction, writeback base "
5477 "is also a destination");
5480 case AArch64::LDR_ZA:
5481 case AArch64::STR_ZA: {
5484 return Error(Loc[1],
5485 "unpredictable instruction, immediate and offset mismatch.");
5488 case AArch64::LDPDi:
5489 case AArch64::LDPQi:
5490 case AArch64::LDPSi:
5491 case AArch64::LDPSWi:
5492 case AArch64::LDPWi:
5493 case AArch64::LDPXi: {
5497 return Error(Loc[1],
"unpredictable LDP instruction, Rt2==Rt");
5500 case AArch64::LDPDpost:
5501 case AArch64::LDPDpre:
5502 case AArch64::LDPQpost:
5503 case AArch64::LDPQpre:
5504 case AArch64::LDPSpost:
5505 case AArch64::LDPSpre:
5506 case AArch64::LDPSWpost: {
5510 return Error(Loc[1],
"unpredictable LDP instruction, Rt2==Rt");
5513 case AArch64::STPDpost:
5514 case AArch64::STPDpre:
5515 case AArch64::STPQpost:
5516 case AArch64::STPQpre:
5517 case AArch64::STPSpost:
5518 case AArch64::STPSpre:
5519 case AArch64::STPWpost:
5520 case AArch64::STPWpre:
5521 case AArch64::STPXpost:
5522 case AArch64::STPXpre: {
5527 return Error(Loc[0],
"unpredictable STP instruction, writeback base "
5528 "is also a source");
5530 return Error(Loc[1],
"unpredictable STP instruction, writeback base "
5531 "is also a source");
5534 case AArch64::LDRBBpre:
5535 case AArch64::LDRBpre:
5536 case AArch64::LDRHHpre:
5537 case AArch64::LDRHpre:
5538 case AArch64::LDRSBWpre:
5539 case AArch64::LDRSBXpre:
5540 case AArch64::LDRSHWpre:
5541 case AArch64::LDRSHXpre:
5542 case AArch64::LDRSWpre:
5543 case AArch64::LDRWpre:
5544 case AArch64::LDRXpre:
5545 case AArch64::LDRBBpost:
5546 case AArch64::LDRBpost:
5547 case AArch64::LDRHHpost:
5548 case AArch64::LDRHpost:
5549 case AArch64::LDRSBWpost:
5550 case AArch64::LDRSBXpost:
5551 case AArch64::LDRSHWpost:
5552 case AArch64::LDRSHXpost:
5553 case AArch64::LDRSWpost:
5554 case AArch64::LDRWpost:
5555 case AArch64::LDRXpost: {
5559 return Error(Loc[0],
"unpredictable LDR instruction, writeback base "
5560 "is also a source");
5563 case AArch64::STRBBpost:
5564 case AArch64::STRBpost:
5565 case AArch64::STRHHpost:
5566 case AArch64::STRHpost:
5567 case AArch64::STRWpost:
5568 case AArch64::STRXpost:
5569 case AArch64::STRBBpre:
5570 case AArch64::STRBpre:
5571 case AArch64::STRHHpre:
5572 case AArch64::STRHpre:
5573 case AArch64::STRWpre:
5574 case AArch64::STRXpre: {
5578 return Error(Loc[0],
"unpredictable STR instruction, writeback base "
5579 "is also a source");
5582 case AArch64::STXRB:
5583 case AArch64::STXRH:
5584 case AArch64::STXRW:
5585 case AArch64::STXRX:
5586 case AArch64::STLXRB:
5587 case AArch64::STLXRH:
5588 case AArch64::STLXRW:
5589 case AArch64::STLXRX: {
5595 return Error(Loc[0],
5596 "unpredictable STXR instruction, status is also a source");
5599 case AArch64::STXPW:
5600 case AArch64::STXPX:
5601 case AArch64::STLXPW:
5602 case AArch64::STLXPX: {
5609 return Error(Loc[0],
5610 "unpredictable STXP instruction, status is also a source");
5613 case AArch64::LDRABwriteback:
5614 case AArch64::LDRAAwriteback: {
5618 return Error(Loc[0],
5619 "unpredictable LDRA instruction, writeback base"
5620 " is also a destination");
5627 case AArch64::CPYFP:
5628 case AArch64::CPYFPWN:
5629 case AArch64::CPYFPRN:
5630 case AArch64::CPYFPN:
5631 case AArch64::CPYFPWT:
5632 case AArch64::CPYFPWTWN:
5633 case AArch64::CPYFPWTRN:
5634 case AArch64::CPYFPWTN:
5635 case AArch64::CPYFPRT:
5636 case AArch64::CPYFPRTWN:
5637 case AArch64::CPYFPRTRN:
5638 case AArch64::CPYFPRTN:
5639 case AArch64::CPYFPT:
5640 case AArch64::CPYFPTWN:
5641 case AArch64::CPYFPTRN:
5642 case AArch64::CPYFPTN:
5643 case AArch64::CPYFM:
5644 case AArch64::CPYFMWN:
5645 case AArch64::CPYFMRN:
5646 case AArch64::CPYFMN:
5647 case AArch64::CPYFMWT:
5648 case AArch64::CPYFMWTWN:
5649 case AArch64::CPYFMWTRN:
5650 case AArch64::CPYFMWTN:
5651 case AArch64::CPYFMRT:
5652 case AArch64::CPYFMRTWN:
5653 case AArch64::CPYFMRTRN:
5654 case AArch64::CPYFMRTN:
5655 case AArch64::CPYFMT:
5656 case AArch64::CPYFMTWN:
5657 case AArch64::CPYFMTRN:
5658 case AArch64::CPYFMTN:
5659 case AArch64::CPYFE:
5660 case AArch64::CPYFEWN:
5661 case AArch64::CPYFERN:
5662 case AArch64::CPYFEN:
5663 case AArch64::CPYFEWT:
5664 case AArch64::CPYFEWTWN:
5665 case AArch64::CPYFEWTRN:
5666 case AArch64::CPYFEWTN:
5667 case AArch64::CPYFERT:
5668 case AArch64::CPYFERTWN:
5669 case AArch64::CPYFERTRN:
5670 case AArch64::CPYFERTN:
5671 case AArch64::CPYFET:
5672 case AArch64::CPYFETWN:
5673 case AArch64::CPYFETRN:
5674 case AArch64::CPYFETN:
5676 case AArch64::CPYPWN:
5677 case AArch64::CPYPRN:
5678 case AArch64::CPYPN:
5679 case AArch64::CPYPWT:
5680 case AArch64::CPYPWTWN:
5681 case AArch64::CPYPWTRN:
5682 case AArch64::CPYPWTN:
5683 case AArch64::CPYPRT:
5684 case AArch64::CPYPRTWN:
5685 case AArch64::CPYPRTRN:
5686 case AArch64::CPYPRTN:
5687 case AArch64::CPYPT:
5688 case AArch64::CPYPTWN:
5689 case AArch64::CPYPTRN:
5690 case AArch64::CPYPTN:
5692 case AArch64::CPYMWN:
5693 case AArch64::CPYMRN:
5694 case AArch64::CPYMN:
5695 case AArch64::CPYMWT:
5696 case AArch64::CPYMWTWN:
5697 case AArch64::CPYMWTRN:
5698 case AArch64::CPYMWTN:
5699 case AArch64::CPYMRT:
5700 case AArch64::CPYMRTWN:
5701 case AArch64::CPYMRTRN:
5702 case AArch64::CPYMRTN:
5703 case AArch64::CPYMT:
5704 case AArch64::CPYMTWN:
5705 case AArch64::CPYMTRN:
5706 case AArch64::CPYMTN:
5708 case AArch64::CPYEWN:
5709 case AArch64::CPYERN:
5710 case AArch64::CPYEN:
5711 case AArch64::CPYEWT:
5712 case AArch64::CPYEWTWN:
5713 case AArch64::CPYEWTRN:
5714 case AArch64::CPYEWTN:
5715 case AArch64::CPYERT:
5716 case AArch64::CPYERTWN:
5717 case AArch64::CPYERTRN:
5718 case AArch64::CPYERTN:
5719 case AArch64::CPYET:
5720 case AArch64::CPYETWN:
5721 case AArch64::CPYETRN:
5722 case AArch64::CPYETN: {
5730 return Error(Loc[0],
5731 "invalid CPY instruction, Xd_wb and Xd do not match");
5733 return Error(Loc[0],
5734 "invalid CPY instruction, Xs_wb and Xs do not match");
5736 return Error(Loc[0],
5737 "invalid CPY instruction, Xn_wb and Xn do not match");
5739 return Error(Loc[0],
"invalid CPY instruction, destination and source"
5740 " registers are the same");
5742 return Error(Loc[0],
"invalid CPY instruction, destination and size"
5743 " registers are the same");
5745 return Error(Loc[0],
"invalid CPY instruction, source and size"
5746 " registers are the same");
5750 case AArch64::SETPT:
5751 case AArch64::SETPN:
5752 case AArch64::SETPTN:
5754 case AArch64::SETMT:
5755 case AArch64::SETMN:
5756 case AArch64::SETMTN:
5758 case AArch64::SETET:
5759 case AArch64::SETEN:
5760 case AArch64::SETETN:
5761 case AArch64::SETGP:
5762 case AArch64::SETGPT:
5763 case AArch64::SETGPN:
5764 case AArch64::SETGPTN:
5765 case AArch64::SETGM:
5766 case AArch64::SETGMT:
5767 case AArch64::SETGMN:
5768 case AArch64::SETGMTN:
5769 case AArch64::MOPSSETGE:
5770 case AArch64::MOPSSETGET:
5771 case AArch64::MOPSSETGEN:
5772 case AArch64::MOPSSETGETN: {
5779 return Error(Loc[0],
5780 "invalid SET instruction, Xd_wb and Xd do not match");
5782 return Error(Loc[0],
5783 "invalid SET instruction, Xn_wb and Xn do not match");
5785 return Error(Loc[0],
"invalid SET instruction, destination and size"
5786 " registers are the same");
5788 return Error(Loc[0],
"invalid SET instruction, destination and source"
5789 " registers are the same");
5791 return Error(Loc[0],
"invalid SET instruction, source and size"
5792 " registers are the same");
5801 case AArch64::ADDSWri:
5802 case AArch64::ADDSXri:
5803 case AArch64::ADDWri:
5804 case AArch64::ADDXri:
5805 case AArch64::SUBSWri:
5806 case AArch64::SUBSXri:
5807 case AArch64::SUBWri:
5808 case AArch64::SUBXri: {
5816 if (classifySymbolRef(Expr, ELFRefKind, DarwinRefKind, Addend)) {
5845 return Error(Loc.
back(),
"invalid immediate expression");
5858 unsigned VariantID = 0);
5860bool AArch64AsmParser::showMatchError(
SMLoc Loc,
unsigned ErrCode,
5864 case Match_InvalidTiedOperand: {
5866 if (
Op.isVectorList())
5867 return Error(Loc,
"operand must match destination register list");
5869 assert(
Op.isReg() &&
"Unexpected operand type");
5870 switch (
Op.getRegEqualityTy()) {
5871 case RegConstraintEqualityTy::EqualsSubReg:
5872 return Error(Loc,
"operand must be 64-bit form of destination register");
5873 case RegConstraintEqualityTy::EqualsSuperReg:
5874 return Error(Loc,
"operand must be 32-bit form of destination register");
5875 case RegConstraintEqualityTy::EqualsReg:
5876 return Error(Loc,
"operand must match destination register");
5880 case Match_MissingFeature:
5882 "instruction requires a CPU feature not currently enabled");
5883 case Match_InvalidOperand:
5884 return Error(Loc,
"invalid operand for instruction");
5885 case Match_InvalidSuffix:
5886 return Error(Loc,
"invalid type suffix for instruction");
5887 case Match_InvalidCondCode:
5888 return Error(Loc,
"expected AArch64 condition code");
5889 case Match_AddSubRegExtendSmall:
5891 "expected '[su]xt[bhw]' with optional integer in range [0, 4]");
5892 case Match_AddSubRegExtendLarge:
5894 "expected 'sxtx' 'uxtx' or 'lsl' with optional integer in range [0, 4]");
5895 case Match_AddSubSecondSource:
5897 "expected compatible register, symbol or integer in range [0, 4095]");
5898 case Match_LogicalSecondSource:
5899 return Error(Loc,
"expected compatible register or logical immediate");
5900 case Match_InvalidMovImm32Shift:
5901 return Error(Loc,
"expected 'lsl' with optional integer 0 or 16");
5902 case Match_InvalidMovImm64Shift:
5903 return Error(Loc,
"expected 'lsl' with optional integer 0, 16, 32 or 48");
5904 case Match_AddSubRegShift32:
5906 "expected 'lsl', 'lsr' or 'asr' with optional integer in range [0, 31]");
5907 case Match_AddSubRegShift64:
5909 "expected 'lsl', 'lsr' or 'asr' with optional integer in range [0, 63]");
5910 case Match_InvalidFPImm:
5912 "expected compatible register or floating-point constant");
5913 case Match_InvalidMemoryIndexedSImm6:
5914 return Error(Loc,
"index must be an integer in range [-32, 31].");
5915 case Match_InvalidMemoryIndexedSImm5:
5916 return Error(Loc,
"index must be an integer in range [-16, 15].");
5917 case Match_InvalidMemoryIndexed1SImm4:
5918 return Error(Loc,
"index must be an integer in range [-8, 7].");
5919 case Match_InvalidMemoryIndexed2SImm4:
5920 return Error(Loc,
"index must be a multiple of 2 in range [-16, 14].");
5921 case Match_InvalidMemoryIndexed3SImm4:
5922 return Error(Loc,
"index must be a multiple of 3 in range [-24, 21].");
5923 case Match_InvalidMemoryIndexed4SImm4:
5924 return Error(Loc,
"index must be a multiple of 4 in range [-32, 28].");
5925 case Match_InvalidMemoryIndexed16SImm4:
5926 return Error(Loc,
"index must be a multiple of 16 in range [-128, 112].");
5927 case Match_InvalidMemoryIndexed32SImm4:
5928 return Error(Loc,
"index must be a multiple of 32 in range [-256, 224].");
5929 case Match_InvalidMemoryIndexed1SImm6:
5930 return Error(Loc,
"index must be an integer in range [-32, 31].");
5931 case Match_InvalidMemoryIndexedSImm8:
5932 return Error(Loc,
"index must be an integer in range [-128, 127].");
5933 case Match_InvalidMemoryIndexedSImm9:
5934 return Error(Loc,
"index must be an integer in range [-256, 255].");
5935 case Match_InvalidMemoryIndexed16SImm9:
5936 return Error(Loc,
"index must be a multiple of 16 in range [-4096, 4080].");
5937 case Match_InvalidMemoryIndexed8SImm10:
5938 return Error(Loc,
"index must be a multiple of 8 in range [-4096, 4088].");
5939 case Match_InvalidMemoryIndexed4SImm7:
5940 return Error(Loc,
"index must be a multiple of 4 in range [-256, 252].");
5941 case Match_InvalidMemoryIndexed8SImm7:
5942 return Error(Loc,
"index must be a multiple of 8 in range [-512, 504].");
5943 case Match_InvalidMemoryIndexed16SImm7:
5944 return Error(Loc,
"index must be a multiple of 16 in range [-1024, 1008].");
5945 case Match_InvalidMemoryIndexed8UImm5:
5946 return Error(Loc,
"index must be a multiple of 8 in range [0, 248].");
5947 case Match_InvalidMemoryIndexed8UImm3:
5948 return Error(Loc,
"index must be a multiple of 8 in range [0, 56].");
5949 case Match_InvalidMemoryIndexed4UImm5:
5950 return Error(Loc,
"index must be a multiple of 4 in range [0, 124].");
5951 case Match_InvalidMemoryIndexed2UImm5:
5952 return Error(Loc,
"index must be a multiple of 2 in range [0, 62].");
5953 case Match_InvalidMemoryIndexed8UImm6:
5954 return Error(Loc,
"index must be a multiple of 8 in range [0, 504].");
5955 case Match_InvalidMemoryIndexed16UImm6:
5956 return Error(Loc,
"index must be a multiple of 16 in range [0, 1008].");
5957 case Match_InvalidMemoryIndexed4UImm6:
5958 return Error(Loc,
"index must be a multiple of 4 in range [0, 252].");
5959 case Match_InvalidMemoryIndexed2UImm6:
5960 return Error(Loc,
"index must be a multiple of 2 in range [0, 126].");
5961 case Match_InvalidMemoryIndexed1UImm6:
5962 return Error(Loc,
"index must be in range [0, 63].");
5963 case Match_InvalidMemoryWExtend8:
5965 "expected 'uxtw' or 'sxtw' with optional shift of #0");
5966 case Match_InvalidMemoryWExtend16:
5968 "expected 'uxtw' or 'sxtw' with optional shift of #0 or #1");
5969 case Match_InvalidMemoryWExtend32:
5971 "expected 'uxtw' or 'sxtw' with optional shift of #0 or #2");
5972 case Match_InvalidMemoryWExtend64:
5974 "expected 'uxtw' or 'sxtw' with optional shift of #0 or #3");
5975 case Match_InvalidMemoryWExtend128:
5977 "expected 'uxtw' or 'sxtw' with optional shift of #0 or #4");
5978 case Match_InvalidMemoryXExtend8:
5980 "expected 'lsl' or 'sxtx' with optional shift of #0");
5981 case Match_InvalidMemoryXExtend16:
5983 "expected 'lsl' or 'sxtx' with optional shift of #0 or #1");
5984 case Match_InvalidMemoryXExtend32:
5986 "expected 'lsl' or 'sxtx' with optional shift of #0 or #2");
5987 case Match_InvalidMemoryXExtend64:
5989 "expected 'lsl' or 'sxtx' with optional shift of #0 or #3");
5990 case Match_InvalidMemoryXExtend128:
5992 "expected 'lsl' or 'sxtx' with optional shift of #0 or #4");
5993 case Match_InvalidMemoryIndexed1:
5994 return Error(Loc,
"index must be an integer in range [0, 4095].");
5995 case Match_InvalidMemoryIndexed2:
5996 return Error(Loc,
"index must be a multiple of 2 in range [0, 8190].");
5997 case Match_InvalidMemoryIndexed4:
5998 return Error(Loc,
"index must be a multiple of 4 in range [0, 16380].");
5999 case Match_InvalidMemoryIndexed8:
6000 return Error(Loc,
"index must be a multiple of 8 in range [0, 32760].");
6001 case Match_InvalidMemoryIndexed16:
6002 return Error(Loc,
"index must be a multiple of 16 in range [0, 65520].");
6003 case Match_InvalidImm0_0:
6004 return Error(Loc,
"immediate must be 0.");
6005 case Match_InvalidImm0_1:
6006 return Error(Loc,
"immediate must be an integer in range [0, 1].");
6007 case Match_InvalidImm0_3:
6008 return Error(Loc,
"immediate must be an integer in range [0, 3].");
6009 case Match_InvalidImm0_7:
6010 return Error(Loc,
"immediate must be an integer in range [0, 7].");
6011 case Match_InvalidImm0_15:
6012 return Error(Loc,
"immediate must be an integer in range [0, 15].");
6013 case Match_InvalidImm0_31:
6014 return Error(Loc,
"immediate must be an integer in range [0, 31].");
6015 case Match_InvalidImm0_63:
6016 return Error(Loc,
"immediate must be an integer in range [0, 63].");
6017 case Match_InvalidImm0_127:
6018 return Error(Loc,
"immediate must be an integer in range [0, 127].");
6019 case Match_InvalidImm0_255:
6020 return Error(Loc,
"immediate must be an integer in range [0, 255].");
6021 case Match_InvalidImm0_65535:
6022 return Error(Loc,
"immediate must be an integer in range [0, 65535].");
6023 case Match_InvalidImm1_8:
6024 return Error(Loc,
"immediate must be an integer in range [1, 8].");
6025 case Match_InvalidImm1_16:
6026 return Error(Loc,
"immediate must be an integer in range [1, 16].");
6027 case Match_InvalidImm1_32:
6028 return Error(Loc,
"immediate must be an integer in range [1, 32].");
6029 case Match_InvalidImm1_64:
6030 return Error(Loc,
"immediate must be an integer in range [1, 64].");
6031 case Match_InvalidImmM1_62:
6032 return Error(Loc,
"immediate must be an integer in range [-1, 62].");
6033 case Match_InvalidMemoryIndexedRange2UImm0:
6034 return Error(Loc,
"vector select offset must be the immediate range 0:1.");
6035 case Match_InvalidMemoryIndexedRange2UImm1:
6036 return Error(Loc,
"vector select offset must be an immediate range of the "
6037 "form <immf>:<imml>, where the first "
6038 "immediate is a multiple of 2 in the range [0, 2], and "
6039 "the second immediate is immf + 1.");
6040 case Match_InvalidMemoryIndexedRange2UImm2:
6041 case Match_InvalidMemoryIndexedRange2UImm3:
6044 "vector select offset must be an immediate range of the form "
6046 "where the first immediate is a multiple of 2 in the range [0, 6] or "
6048 "depending on the instruction, and the second immediate is immf + 1.");
6049 case Match_InvalidMemoryIndexedRange4UImm0:
6050 return Error(Loc,
"vector select offset must be the immediate range 0:3.");
6051 case Match_InvalidMemoryIndexedRange4UImm1:
6052 case Match_InvalidMemoryIndexedRange4UImm2:
6055 "vector select offset must be an immediate range of the form "
6057 "where the first immediate is a multiple of 4 in the range [0, 4] or "
6059 "depending on the instruction, and the second immediate is immf + 3.");
6060 case Match_InvalidSVEAddSubImm8:
6061 return Error(Loc,
"immediate must be an integer in range [0, 255]"
6062 " with a shift amount of 0");
6063 case Match_InvalidSVEAddSubImm16:
6064 case Match_InvalidSVEAddSubImm32:
6065 case Match_InvalidSVEAddSubImm64:
6066 return Error(Loc,
"immediate must be an integer in range [0, 255] or a "
6067 "multiple of 256 in range [256, 65280]");
6068 case Match_InvalidSVECpyImm8:
6069 return Error(Loc,
"immediate must be an integer in range [-128, 255]"
6070 " with a shift amount of 0");
6071 case Match_InvalidSVECpyImm16:
6072 return Error(Loc,
"immediate must be an integer in range [-128, 127] or a "
6073 "multiple of 256 in range [-32768, 65280]");
6074 case Match_InvalidSVECpyImm32:
6075 case Match_InvalidSVECpyImm64:
6076 return Error(Loc,
"immediate must be an integer in range [-128, 127] or a "
6077 "multiple of 256 in range [-32768, 32512]");
6078 case Match_InvalidIndexRange0_0:
6079 return Error(Loc,
"expected lane specifier '[0]'");
6080 case Match_InvalidIndexRange1_1:
6081 return Error(Loc,
"expected lane specifier '[1]'");
6082 case Match_InvalidIndexRange0_15:
6083 return Error(Loc,
"vector lane must be an integer in range [0, 15].");
6084 case Match_InvalidIndexRange0_7:
6085 return Error(Loc,
"vector lane must be an integer in range [0, 7].");
6086 case Match_InvalidIndexRange0_3:
6087 return Error(Loc,
"vector lane must be an integer in range [0, 3].");
6088 case Match_InvalidIndexRange0_1:
6089 return Error(Loc,
"vector lane must be an integer in range [0, 1].");
6090 case Match_InvalidSVEIndexRange0_63:
6091 return Error(Loc,
"vector lane must be an integer in range [0, 63].");
6092 case Match_InvalidSVEIndexRange0_31:
6093 return Error(Loc,
"vector lane must be an integer in range [0, 31].");
6094 case Match_InvalidSVEIndexRange0_15:
6095 return Error(Loc,
"vector lane must be an integer in range [0, 15].");
6096 case Match_InvalidSVEIndexRange0_7:
6097 return Error(Loc,
"vector lane must be an integer in range [0, 7].");
6098 case Match_InvalidSVEIndexRange0_3:
6099 return Error(Loc,
"vector lane must be an integer in range [0, 3].");
6100 case Match_InvalidLabel:
6101 return Error(Loc,
"expected label or encodable integer pc offset");
6103 return Error(Loc,
"expected readable system register");
6105 case Match_InvalidSVCR:
6106 return Error(Loc,
"expected writable system register or pstate");
6107 case Match_InvalidComplexRotationEven:
6108 return Error(Loc,
"complex rotation must be 0, 90, 180 or 270.");
6109 case Match_InvalidComplexRotationOdd:
6110 return Error(Loc,
"complex rotation must be 90 or 270.");
6111 case Match_MnemonicFail: {
6113 ((AArch64Operand &)*
Operands[0]).getToken(),
6114 ComputeAvailableFeatures(STI->getFeatureBits()));
6115 return Error(Loc,
"unrecognized instruction mnemonic" + Suggestion);
6117 case Match_InvalidGPR64shifted8:
6118 return Error(Loc,
"register must be x0..x30 or xzr, without shift");
6119 case Match_InvalidGPR64shifted16:
6120 return Error(Loc,
"register must be x0..x30 or xzr, with required shift 'lsl #1'");
6121 case Match_InvalidGPR64shifted32:
6122 return Error(Loc,
"register must be x0..x30 or xzr, with required shift 'lsl #2'");
6123 case Match_InvalidGPR64shifted64:
6124 return Error(Loc,
"register must be x0..x30 or xzr, with required shift 'lsl #3'");
6125 case Match_InvalidGPR64shifted128:
6127 Loc,
"register must be x0..x30 or xzr, with required shift 'lsl #4'");
6128 case Match_InvalidGPR64NoXZRshifted8:
6129 return Error(Loc,
"register must be x0..x30 without shift");
6130 case Match_InvalidGPR64NoXZRshifted16:
6131 return Error(Loc,
"register must be x0..x30 with required shift 'lsl #1'");
6132 case Match_InvalidGPR64NoXZRshifted32:
6133 return Error(Loc,
"register must be x0..x30 with required shift 'lsl #2'");
6134 case Match_InvalidGPR64NoXZRshifted64:
6135 return Error(Loc,
"register must be x0..x30 with required shift 'lsl #3'");
6136 case Match_InvalidGPR64NoXZRshifted128:
6137 return Error(Loc,
"register must be x0..x30 with required shift 'lsl #4'");
6138 case Match_InvalidZPR32UXTW8:
6139 case Match_InvalidZPR32SXTW8:
6140 return Error(Loc,
"invalid shift/extend specified, expected 'z[0..31].s, (uxtw|sxtw)'");
6141 case Match_InvalidZPR32UXTW16:
6142 case Match_InvalidZPR32SXTW16:
6143 return Error(Loc,
"invalid shift/extend specified, expected 'z[0..31].s, (uxtw|sxtw) #1'");
6144 case Match_InvalidZPR32UXTW32:
6145 case Match_InvalidZPR32SXTW32:
6146 return Error(Loc,
"invalid shift/extend specified, expected 'z[0..31].s, (uxtw|sxtw) #2'");
6147 case Match_InvalidZPR32UXTW64:
6148 case Match_InvalidZPR32SXTW64:
6149 return Error(Loc,
"invalid shift/extend specified, expected 'z[0..31].s, (uxtw|sxtw) #3'");
6150 case Match_InvalidZPR64UXTW8:
6151 case Match_InvalidZPR64SXTW8:
6152 return Error(Loc,
"invalid shift/extend specified, expected 'z[0..31].d, (uxtw|sxtw)'");
6153 case Match_InvalidZPR64UXTW16:
6154 case Match_InvalidZPR64SXTW16:
6155 return Error(Loc,
"invalid shift/extend specified, expected 'z[0..31].d, (lsl|uxtw|sxtw) #1'");
6156 case Match_InvalidZPR64UXTW32:
6157 case Match_InvalidZPR64SXTW32:
6158 return Error(Loc,
"invalid shift/extend specified, expected 'z[0..31].d, (lsl|uxtw|sxtw) #2'");
6159 case Match_InvalidZPR64UXTW64:
6160 case Match_InvalidZPR64SXTW64:
6161 return Error(Loc,
"invalid shift/extend specified, expected 'z[0..31].d, (lsl|uxtw|sxtw) #3'");
6162 case Match_InvalidZPR32LSL8:
6163 return Error(Loc,
"invalid shift/extend specified, expected 'z[0..31].s'");
6164 case Match_InvalidZPR32LSL16:
6165 return Error(Loc,
"invalid shift/extend specified, expected 'z[0..31].s, lsl #1'");
6166 case Match_InvalidZPR32LSL32:
6167 return Error(Loc,
"invalid shift/extend specified, expected 'z[0..31].s, lsl #2'");
6168 case Match_InvalidZPR32LSL64:
6169 return Error(Loc,
"invalid shift/extend specified, expected 'z[0..31].s, lsl #3'");
6170 case Match_InvalidZPR64LSL8:
6171 return Error(Loc,
"invalid shift/extend specified, expected 'z[0..31].d'");
6172 case Match_InvalidZPR64LSL16:
6173 return Error(Loc,
"invalid shift/extend specified, expected 'z[0..31].d, lsl #1'");
6174 case Match_InvalidZPR64LSL32:
6175 return Error(Loc,
"invalid shift/extend specified, expected 'z[0..31].d, lsl #2'");
6176 case Match_InvalidZPR64LSL64:
6177 return Error(Loc,
"invalid shift/extend specified, expected 'z[0..31].d, lsl #3'");
6178 case Match_InvalidZPR0:
6179 return Error(Loc,
"expected register without element width suffix");
6180 case Match_InvalidZPR8:
6181 case Match_InvalidZPR16:
6182 case Match_InvalidZPR32:
6183 case Match_InvalidZPR64:
6184 case Match_InvalidZPR128:
6185 return Error(Loc,
"invalid element width");
6186 case Match_InvalidZPR_3b8:
6187 return Error(Loc,
"Invalid restricted vector register, expected z0.b..z7.b");
6188 case Match_InvalidZPR_3b16:
6189 return Error(Loc,
"Invalid restricted vector register, expected z0.h..z7.h");
6190 case Match_InvalidZPR_3b32:
6191 return Error(Loc,
"Invalid restricted vector register, expected z0.s..z7.s");
6192 case Match_InvalidZPR_4b8:
6194 "Invalid restricted vector register, expected z0.b..z15.b");
6195 case Match_InvalidZPR_4b16:
6196 return Error(Loc,
"Invalid restricted vector register, expected z0.h..z15.h");
6197 case Match_InvalidZPR_4b32:
6198 return Error(Loc,
"Invalid restricted vector register, expected z0.s..z15.s");
6199 case Match_InvalidZPR_4b64:
6200 return Error(Loc,
"Invalid restricted vector register, expected z0.d..z15.d");
6201 case Match_InvalidZPRMul2_Lo8:
6202 return Error(Loc,
"Invalid restricted vector register, expected even "
6203 "register in z0.b..z14.b");
6204 case Match_InvalidZPRMul2_Hi8:
6205 return Error(Loc,
"Invalid restricted vector register, expected even "
6206 "register in z16.b..z30.b");
6207 case Match_InvalidZPRMul2_Lo16:
6208 return Error(Loc,
"Invalid restricted vector register, expected even "
6209 "register in z0.h..z14.h");
6210 case Match_InvalidZPRMul2_Hi16:
6211 return Error(Loc,
"Invalid restricted vector register, expected even "
6212 "register in z16.h..z30.h");
6213 case Match_InvalidZPRMul2_Lo32:
6214 return Error(Loc,
"Invalid restricted vector register, expected even "
6215 "register in z0.s..z14.s");
6216 case Match_InvalidZPRMul2_Hi32:
6217 return Error(Loc,
"Invalid restricted vector register, expected even "
6218 "register in z16.s..z30.s");
6219 case Match_InvalidZPRMul2_Lo64:
6220 return Error(Loc,
"Invalid restricted vector register, expected even "
6221 "register in z0.d..z14.d");
6222 case Match_InvalidZPRMul2_Hi64:
6223 return Error(Loc,
"Invalid restricted vector register, expected even "
6224 "register in z16.d..z30.d");
6225 case Match_InvalidZPR_K0:
6226 return Error(Loc,
"invalid restricted vector register, expected register "
6227 "in z20..z23 or z28..z31");
6228 case Match_InvalidSVEPattern:
6229 return Error(Loc,
"invalid predicate pattern");
6230 case Match_InvalidSVEPPRorPNRAnyReg:
6231 case Match_InvalidSVEPPRorPNRBReg:
6232 case Match_InvalidSVEPredicateAnyReg:
6233 case Match_InvalidSVEPredicateBReg:
6234 case Match_InvalidSVEPredicateHReg:
6235 case Match_InvalidSVEPredicateSReg:
6236 case Match_InvalidSVEPredicateDReg:
6237 return Error(Loc,
"invalid predicate register.");
6238 case Match_InvalidSVEPredicate3bAnyReg:
6239 return Error(Loc,
"invalid restricted predicate register, expected p0..p7 (without element suffix)");
6240 case Match_InvalidSVEPNPredicateB_p8to15Reg:
6241 case Match_InvalidSVEPNPredicateH_p8to15Reg:
6242 case Match_InvalidSVEPNPredicateS_p8to15Reg:
6243 case Match_InvalidSVEPNPredicateD_p8to15Reg:
6244 return Error(Loc,
"Invalid predicate register, expected PN in range "
6245 "pn8..pn15 with element suffix.");
6246 case Match_InvalidSVEPNPredicateAny_p8to15Reg:
6247 return Error(Loc,
"invalid restricted predicate-as-counter register "
6248 "expected pn8..pn15");
6249 case Match_InvalidSVEPNPredicateBReg:
6250 case Match_InvalidSVEPNPredicateHReg:
6251 case Match_InvalidSVEPNPredicateSReg:
6252 case Match_InvalidSVEPNPredicateDReg:
6253 return Error(Loc,
"Invalid predicate register, expected PN in range "
6254 "pn0..pn15 with element suffix.");
6255 case Match_InvalidSVEVecLenSpecifier:
6256 return Error(Loc,
"Invalid vector length specifier, expected VLx2 or VLx4");
6257 case Match_InvalidSVEPredicateListMul2x8:
6258 case Match_InvalidSVEPredicateListMul2x16:
6259 case Match_InvalidSVEPredicateListMul2x32:
6260 case Match_InvalidSVEPredicateListMul2x64:
6261 return Error(Loc,
"Invalid vector list, expected list with 2 consecutive "
6262 "predicate registers, where the first vector is a multiple of 2 "
6263 "and with correct element type");
6264 case Match_InvalidSVEExactFPImmOperandHalfOne:
6265 return Error(Loc,
"Invalid floating point constant, expected 0.5 or 1.0.");
6266 case Match_InvalidSVEExactFPImmOperandHalfTwo:
6267 return Error(Loc,
"Invalid floating point constant, expected 0.5 or 2.0.");
6268 case Match_InvalidSVEExactFPImmOperandZeroOne:
6269 return Error(Loc,
"Invalid floating point constant, expected 0.0 or 1.0.");
6270 case Match_InvalidMatrixTileVectorH8:
6271 case Match_InvalidMatrixTileVectorV8:
6272 return Error(Loc,
"invalid matrix operand, expected za0h.b or za0v.b");
6273 case Match_InvalidMatrixTileVectorH16:
6274 case Match_InvalidMatrixTileVectorV16:
6276 "invalid matrix operand, expected za[0-1]h.h or za[0-1]v.h");
6277 case Match_InvalidMatrixTileVectorH32:
6278 case Match_InvalidMatrixTileVectorV32:
6280 "invalid matrix operand, expected za[0-3]h.s or za[0-3]v.s");
6281 case Match_InvalidMatrixTileVectorH64:
6282 case Match_InvalidMatrixTileVectorV64:
6284 "invalid matrix operand, expected za[0-7]h.d or za[0-7]v.d");
6285 case Match_InvalidMatrixTileVectorH128:
6286 case Match_InvalidMatrixTileVectorV128:
6288 "invalid matrix operand, expected za[0-15]h.q or za[0-15]v.q");
6289 case Match_InvalidMatrixTile16:
6290 return Error(Loc,
"invalid matrix operand, expected za[0-1].h");
6291 case Match_InvalidMatrixTile32:
6292 return Error(Loc,
"invalid matrix operand, expected za[0-3].s");
6293 case Match_InvalidMatrixTile64:
6294 return Error(Loc,
"invalid matrix operand, expected za[0-7].d");
6295 case Match_InvalidMatrix:
6296 return Error(Loc,
"invalid matrix operand, expected za");
6297 case Match_InvalidMatrix8:
6298 return Error(Loc,
"invalid matrix operand, expected suffix .b");
6299 case Match_InvalidMatrix16:
6300 return Error(Loc,
"invalid matrix operand, expected suffix .h");
6301 case Match_InvalidMatrix32:
6302 return Error(Loc,
"invalid matrix operand, expected suffix .s");
6303 case Match_InvalidMatrix64:
6304 return Error(Loc,
"invalid matrix operand, expected suffix .d");
6305 case Match_InvalidMatrixIndexGPR32_12_15:
6306 return Error(Loc,
"operand must be a register in range [w12, w15]");
6307 case Match_InvalidMatrixIndexGPR32_8_11:
6308 return Error(Loc,
"operand must be a register in range [w8, w11]");
6309 case Match_InvalidSVEVectorList2x8Mul2:
6310 case Match_InvalidSVEVectorList2x16Mul2:
6311 case Match_InvalidSVEVectorList2x32Mul2:
6312 case Match_InvalidSVEVectorList2x64Mul2:
6313 case Match_InvalidSVEVectorList2x128Mul2:
6314 return Error(Loc,
"Invalid vector list, expected list with 2 consecutive "
6315 "SVE vectors, where the first vector is a multiple of 2 "
6316 "and with matching element types");
6317 case Match_InvalidSVEVectorList2x8Mul2_Lo:
6318 case Match_InvalidSVEVectorList2x16Mul2_Lo:
6319 case Match_InvalidSVEVectorList2x32Mul2_Lo:
6320 case Match_InvalidSVEVectorList2x64Mul2_Lo:
6321 return Error(Loc,
"Invalid vector list, expected list with 2 consecutive "
6322 "SVE vectors in the range z0-z14, where the first vector "
6323 "is a multiple of 2 "
6324 "and with matching element types");
6325 case Match_InvalidSVEVectorList2x8Mul2_Hi:
6326 case Match_InvalidSVEVectorList2x16Mul2_Hi:
6327 case Match_InvalidSVEVectorList2x32Mul2_Hi:
6328 case Match_InvalidSVEVectorList2x64Mul2_Hi:
6330 "Invalid vector list, expected list with 2 consecutive "
6331 "SVE vectors in the range z16-z30, where the first vector "
6332 "is a multiple of 2 "
6333 "and with matching element types");
6334 case Match_InvalidSVEVectorList4x8Mul4:
6335 case Match_InvalidSVEVectorList4x16Mul4:
6336 case Match_InvalidSVEVectorList4x32Mul4:
6337 case Match_InvalidSVEVectorList4x64Mul4:
6338 case Match_InvalidSVEVectorList4x128Mul4:
6339 return Error(Loc,
"Invalid vector list, expected list with 4 consecutive "
6340 "SVE vectors, where the first vector is a multiple of 4 "
6341 "and with matching element types");
6342 case Match_InvalidLookupTable:
6343 return Error(Loc,
"Invalid lookup table, expected zt0");
6344 case Match_InvalidSVEVectorListStrided2x8:
6345 case Match_InvalidSVEVectorListStrided2x16:
6346 case Match_InvalidSVEVectorListStrided2x32:
6347 case Match_InvalidSVEVectorListStrided2x64:
6350 "Invalid vector list, expected list with each SVE vector in the list "
6351 "8 registers apart, and the first register in the range [z0, z7] or "
6352 "[z16, z23] and with correct element type");
6353 case Match_InvalidSVEVectorListStrided4x8:
6354 case Match_InvalidSVEVectorListStrided4x16:
6355 case Match_InvalidSVEVectorListStrided4x32:
6356 case Match_InvalidSVEVectorListStrided4x64:
6359 "Invalid vector list, expected list with each SVE vector in the list "
6360 "4 registers apart, and the first register in the range [z0, z3] or "
6361 "[z16, z19] and with correct element type");
6362 case Match_AddSubLSLImm3ShiftLarge:
6364 "expected 'lsl' with optional integer in range [0, 7]");
6372bool AArch64AsmParser::matchAndEmitInstruction(
SMLoc IDLoc,
unsigned &Opcode,
6376 bool MatchingInlineAsm) {
6378 AArch64Operand &
Op =
static_cast<AArch64Operand &
>(*
Operands[0]);
6379 assert(
Op.isToken() &&
"Leading operand should always be a mnemonic!");
6382 unsigned NumOperands =
Operands.size();
6384 if (NumOperands == 4 && Tok ==
"lsl") {
6385 AArch64Operand &Op2 =
static_cast<AArch64Operand &
>(*
Operands[2]);
6386 AArch64Operand &Op3 =
static_cast<AArch64Operand &
>(*
Operands[3]);
6387 if (Op2.isScalarReg() && Op3.isImm()) {
6388 const MCConstantExpr *Op3CE = dyn_cast<MCConstantExpr>(Op3.getImm());
6393 if (AArch64MCRegisterClasses[AArch64::GPR32allRegClassID].
contains(
6395 NewOp3Val = (32 - Op3Val) & 0x1f;
6396 NewOp4Val = 31 - Op3Val;
6398 NewOp3Val = (64 - Op3Val) & 0x3f;
6399 NewOp4Val = 63 - Op3Val;
6406 AArch64Operand::CreateToken(
"ubfm",
Op.getStartLoc(), getContext());
6407 Operands.push_back(AArch64Operand::CreateImm(
6408 NewOp4, Op3.getStartLoc(), Op3.getEndLoc(), getContext()));
6409 Operands[3] = AArch64Operand::CreateImm(NewOp3, Op3.getStartLoc(),
6410 Op3.getEndLoc(), getContext());
6413 }
else if (NumOperands == 4 && Tok ==
"bfc") {
6415 AArch64Operand &Op1 =
static_cast<AArch64Operand &
>(*
Operands[1]);
6416 AArch64Operand LSBOp =
static_cast<AArch64Operand &
>(*
Operands[2]);
6417 AArch64Operand WidthOp =
static_cast<AArch64Operand &
>(*
Operands[3]);
6419 if (Op1.isScalarReg() && LSBOp.isImm() && WidthOp.isImm()) {
6420 const MCConstantExpr *LSBCE = dyn_cast<MCConstantExpr>(LSBOp.getImm());
6421 const MCConstantExpr *WidthCE = dyn_cast<MCConstantExpr>(WidthOp.getImm());
6423 if (LSBCE && WidthCE) {
6428 if (AArch64MCRegisterClasses[AArch64::GPR64allRegClassID].
contains(
6434 if (LSB >= RegWidth)
6435 return Error(LSBOp.getStartLoc(),
6436 "expected integer in range [0, 31]");
6437 if (Width < 1 || Width > RegWidth)
6438 return Error(WidthOp.getStartLoc(),
6439 "expected integer in range [1, 32]");
6443 ImmR = (32 - LSB) & 0x1f;
6445 ImmR = (64 - LSB) & 0x3f;
6449 if (ImmR != 0 && ImmS >= ImmR)
6450 return Error(WidthOp.getStartLoc(),
6451 "requested insert overflows register");
6456 AArch64Operand::CreateToken(
"bfm",
Op.getStartLoc(), getContext());
6457 Operands[2] = AArch64Operand::CreateReg(
6458 RegWidth == 32 ? AArch64::WZR : AArch64::XZR, RegKind::Scalar,
6460 Operands[3] = AArch64Operand::CreateImm(
6461 ImmRExpr, LSBOp.getStartLoc(), LSBOp.getEndLoc(), getContext());
6463 AArch64Operand::CreateImm(ImmSExpr, WidthOp.getStartLoc(),
6464 WidthOp.getEndLoc(), getContext()));
6467 }
else if (NumOperands == 5) {
6470 if (Tok ==
"bfi" || Tok ==
"sbfiz" || Tok ==
"ubfiz") {
6471 AArch64Operand &Op1 =
static_cast<AArch64Operand &
>(*
Operands[1]);
6472 AArch64Operand &Op3 =
static_cast<AArch64Operand &
>(*
Operands[3]);
6473 AArch64Operand &Op4 =
static_cast<AArch64Operand &
>(*
Operands[4]);
6475 if (Op1.isScalarReg() && Op3.isImm() && Op4.isImm()) {
6476 const MCConstantExpr *Op3CE = dyn_cast<MCConstantExpr>(Op3.getImm());
6477 const MCConstantExpr *Op4CE = dyn_cast<MCConstantExpr>(Op4.getImm());
6479 if (Op3CE && Op4CE) {
6484 if (AArch64MCRegisterClasses[AArch64::GPR64allRegClassID].
contains(
6490 if (Op3Val >= RegWidth)
6491 return Error(Op3.getStartLoc(),
6492 "expected integer in range [0, 31]");
6493 if (Op4Val < 1 || Op4Val > RegWidth)
6494 return Error(Op4.getStartLoc(),
6495 "expected integer in range [1, 32]");
6499 NewOp3Val = (32 - Op3Val) & 0x1f;
6501 NewOp3Val = (64 - Op3Val) & 0x3f;
6505 if (NewOp3Val != 0 && NewOp4Val >= NewOp3Val)
6506 return Error(Op4.getStartLoc(),
6507 "requested insert overflows register");
6513 Operands[3] = AArch64Operand::CreateImm(
6514 NewOp3, Op3.getStartLoc(), Op3.getEndLoc(), getContext());
6515 Operands[4] = AArch64Operand::CreateImm(
6516 NewOp4, Op4.getStartLoc(), Op4.getEndLoc(), getContext());
6518 Operands[0] = AArch64Operand::CreateToken(
"bfm",
Op.getStartLoc(),
6520 else if (Tok ==
"sbfiz")
6521 Operands[0] = AArch64Operand::CreateToken(
"sbfm",
Op.getStartLoc(),
6523 else if (Tok ==
"ubfiz")
6524 Operands[0] = AArch64Operand::CreateToken(
"ubfm",
Op.getStartLoc(),
6533 }
else if (NumOperands == 5 &&
6534 (Tok ==
"bfxil" || Tok ==
"sbfx" || Tok ==
"ubfx")) {
6535 AArch64Operand &Op1 =
static_cast<AArch64Operand &
>(*
Operands[1]);
6536 AArch64Operand &Op3 =
static_cast<AArch64Operand &
>(*
Operands[3]);
6537 AArch64Operand &Op4 =
static_cast<AArch64Operand &
>(*
Operands[4]);
6539 if (Op1.isScalarReg() && Op3.isImm() && Op4.isImm()) {
6540 const MCConstantExpr *Op3CE = dyn_cast<MCConstantExpr>(Op3.getImm());
6541 const MCConstantExpr *Op4CE = dyn_cast<MCConstantExpr>(Op4.getImm());
6543 if (Op3CE && Op4CE) {
6548 if (AArch64MCRegisterClasses[AArch64::GPR64allRegClassID].
contains(
6554 if (Op3Val >= RegWidth)
6555 return Error(Op3.getStartLoc(),
6556 "expected integer in range [0, 31]");
6557 if (Op4Val < 1 || Op4Val > RegWidth)
6558 return Error(Op4.getStartLoc(),
6559 "expected integer in range [1, 32]");
6561 uint64_t NewOp4Val = Op3Val + Op4Val - 1;
6563 if (NewOp4Val >= RegWidth || NewOp4Val < Op3Val)
6564 return Error(Op4.getStartLoc(),
6565 "requested extract overflows register");
6569 Operands[4] = AArch64Operand::CreateImm(
6570 NewOp4, Op4.getStartLoc(), Op4.getEndLoc(), getContext());
6572 Operands[0] = AArch64Operand::CreateToken(
"bfm",
Op.getStartLoc(),
6574 else if (Tok ==
"sbfx")
6575 Operands[0] = AArch64Operand::CreateToken(
"sbfm",
Op.getStartLoc(),
6577 else if (Tok ==
"ubfx")
6578 Operands[0] = AArch64Operand::CreateToken(
"ubfm",
Op.getStartLoc(),
6591 if (getSTI().hasFeature(AArch64::FeatureZCZeroingFPWorkaround) &&
6592 NumOperands == 4 && Tok ==
"movi") {
6593 AArch64Operand &Op1 =
static_cast<AArch64Operand &
>(*
Operands[1]);
6594 AArch64Operand &Op2 =
static_cast<AArch64Operand &
>(*
Operands[2]);
6595 AArch64Operand &Op3 =
static_cast<AArch64Operand &
>(*
Operands[3]);
6596 if ((Op1.isToken() && Op2.isNeonVectorReg() && Op3.isImm()) ||
6597 (Op1.isNeonVectorReg() && Op2.isToken() && Op3.isImm())) {
6598 StringRef Suffix = Op1.isToken() ? Op1.getToken() : Op2.getToken();
6599 if (Suffix.
lower() ==
".2d" &&
6600 cast<MCConstantExpr>(Op3.getImm())->getValue() == 0) {
6601 Warning(IDLoc,
"instruction movi.2d with immediate #0 may not function"
6602 " correctly on this CPU, converting to equivalent movi.16b");
6604 unsigned Idx = Op1.isToken() ? 1 : 2;
6606 AArch64Operand::CreateToken(
".16b", IDLoc, getContext());
6614 if (NumOperands == 3 && (Tok ==
"sxtw" || Tok ==
"uxtw")) {
6617 AArch64Operand &
Op =
static_cast<AArch64Operand &
>(*
Operands[2]);
6618 if (
Op.isScalarReg()) {
6620 Operands[2] = AArch64Operand::CreateReg(Reg, RegKind::Scalar,
6621 Op.getStartLoc(),
Op.getEndLoc(),
6626 else if (NumOperands == 3 && (Tok ==
"sxtb" || Tok ==
"sxth")) {
6627 AArch64Operand &
Op =
static_cast<AArch64Operand &
>(*
Operands[1]);
6628 if (
Op.isScalarReg() &&
6629 AArch64MCRegisterClasses[AArch64::GPR64allRegClassID].contains(
6633 AArch64Operand &
Op =
static_cast<AArch64Operand &
>(*
Operands[2]);
6634 if (
Op.isScalarReg()) {
6636 Operands[2] = AArch64Operand::CreateReg(Reg, RegKind::Scalar,
6638 Op.getEndLoc(), getContext());
6643 else if (NumOperands == 3 && (Tok ==
"uxtb" || Tok ==
"uxth")) {
6644 AArch64Operand &
Op =
static_cast<AArch64Operand &
>(*
Operands[1]);
6645 if (
Op.isScalarReg() &&
6646 AArch64MCRegisterClasses[AArch64::GPR64allRegClassID].contains(
6650 AArch64Operand &
Op =
static_cast<AArch64Operand &
>(*
Operands[1]);
6651 if (
Op.isScalarReg()) {
6653 Operands[1] = AArch64Operand::CreateReg(Reg, RegKind::Scalar,
6655 Op.getEndLoc(), getContext());
6664 unsigned MatchResult =
6666 MatchingInlineAsm, 1);
6670 if (MatchResult != Match_Success) {
6673 auto ShortFormNEONErrorInfo =
ErrorInfo;
6674 auto ShortFormNEONMatchResult = MatchResult;
6675 auto ShortFormNEONMissingFeatures = MissingFeatures;
6679 MatchingInlineAsm, 0);
6684 if (MatchResult == Match_InvalidOperand &&
ErrorInfo == 1 &&
6686 ((AArch64Operand &)*
Operands[1]).isTokenSuffix()) {
6687 MatchResult = ShortFormNEONMatchResult;
6689 MissingFeatures = ShortFormNEONMissingFeatures;
6693 switch (MatchResult) {
6694 case Match_Success: {
6698 for (
unsigned i = 1; i < NumOperands; ++i)
6700 if (validateInstruction(Inst, IDLoc, OperandLocs))
6707 case Match_MissingFeature: {
6708 assert(MissingFeatures.
any() &&
"Unknown missing feature!");
6711 std::string Msg =
"instruction requires:";
6712 for (
unsigned i = 0, e = MissingFeatures.
size(); i != e; ++i) {
6713 if (MissingFeatures[i]) {
6718 return Error(IDLoc, Msg);
6720 case Match_MnemonicFail:
6722 case Match_InvalidOperand: {
6723 SMLoc ErrorLoc = IDLoc;
6727 return Error(IDLoc,
"too few operands for instruction",
6728 SMRange(IDLoc, getTok().getLoc()));
6731 if (ErrorLoc ==
SMLoc())
6738 MatchResult = Match_InvalidSuffix;
6742 case Match_InvalidTiedOperand:
6743 case Match_InvalidMemoryIndexed1:
6744 case Match_InvalidMemoryIndexed2:
6745 case Match_InvalidMemoryIndexed4:
6746 case Match_InvalidMemoryIndexed8:
6747 case Match_InvalidMemoryIndexed16:
6748 case Match_InvalidCondCode:
6749 case Match_AddSubLSLImm3ShiftLarge:
6750 case Match_AddSubRegExtendSmall:
6751 case Match_AddSubRegExtendLarge:
6752 case Match_AddSubSecondSource:
6753 case Match_LogicalSecondSource:
6754 case Match_AddSubRegShift32:
6755 case Match_AddSubRegShift64:
6756 case Match_InvalidMovImm32Shift:
6757 case Match_InvalidMovImm64Shift:
6758 case Match_InvalidFPImm:
6759 case Match_InvalidMemoryWExtend8:
6760 case Match_InvalidMemoryWExtend16:
6761 case Match_InvalidMemoryWExtend32:
6762 case Match_InvalidMemoryWExtend64:
6763 case Match_InvalidMemoryWExtend128:
6764 case Match_InvalidMemoryXExtend8:
6765 case Match_InvalidMemoryXExtend16:
6766 case Match_InvalidMemoryXExtend32:
6767 case Match_InvalidMemoryXExtend64:
6768 case Match_InvalidMemoryXExtend128:
6769 case Match_InvalidMemoryIndexed1SImm4:
6770 case Match_InvalidMemoryIndexed2SImm4:
6771 case Match_InvalidMemoryIndexed3SImm4:
6772 case Match_InvalidMemoryIndexed4SImm4:
6773 case Match_InvalidMemoryIndexed1SImm6:
6774 case Match_InvalidMemoryIndexed16SImm4:
6775 case Match_InvalidMemoryIndexed32SImm4:
6776 case Match_InvalidMemoryIndexed4SImm7:
6777 case Match_InvalidMemoryIndexed8SImm7:
6778 case Match_InvalidMemoryIndexed16SImm7:
6779 case Match_InvalidMemoryIndexed8UImm5:
6780 case Match_InvalidMemoryIndexed8UImm3:
6781 case Match_InvalidMemoryIndexed4UImm5:
6782 case Match_InvalidMemoryIndexed2UImm5:
6783 case Match_InvalidMemoryIndexed1UImm6:
6784 case Match_InvalidMemoryIndexed2UImm6:
6785 case Match_InvalidMemoryIndexed4UImm6:
6786 case Match_InvalidMemoryIndexed8UImm6:
6787 case Match_InvalidMemoryIndexed16UImm6:
6788 case Match_InvalidMemoryIndexedSImm6:
6789 case Match_InvalidMemoryIndexedSImm5:
6790 case Match_InvalidMemoryIndexedSImm8:
6791 case Match_InvalidMemoryIndexedSImm9:
6792 case Match_InvalidMemoryIndexed16SImm9:
6793 case Match_InvalidMemoryIndexed8SImm10:
6794 case Match_InvalidImm0_0:
6795 case Match_InvalidImm0_1:
6796 case Match_InvalidImm0_3:
6797 case Match_InvalidImm0_7:
6798 case Match_InvalidImm0_15:
6799 case Match_InvalidImm0_31:
6800 case Match_InvalidImm0_63:
6801 case Match_InvalidImm0_127:
6802 case Match_InvalidImm0_255:
6803 case Match_InvalidImm0_65535:
6804 case Match_InvalidImm1_8:
6805 case Match_InvalidImm1_16:
6806 case Match_InvalidImm1_32:
6807 case Match_InvalidImm1_64:
6808 case Match_InvalidImmM1_62:
6809 case Match_InvalidMemoryIndexedRange2UImm0:
6810 case Match_InvalidMemoryIndexedRange2UImm1:
6811 case Match_InvalidMemoryIndexedRange2UImm2:
6812 case Match_InvalidMemoryIndexedRange2UImm3:
6813 case Match_InvalidMemoryIndexedRange4UImm0:
6814 case Match_InvalidMemoryIndexedRange4UImm1:
6815 case Match_InvalidMemoryIndexedRange4UImm2:
6816 case Match_InvalidSVEAddSubImm8:
6817 case Match_InvalidSVEAddSubImm16:
6818 case Match_InvalidSVEAddSubImm32:
6819 case Match_InvalidSVEAddSubImm64:
6820 case Match_InvalidSVECpyImm8:
6821 case Match_InvalidSVECpyImm16:
6822 case Match_InvalidSVECpyImm32:
6823 case Match_InvalidSVECpyImm64:
6824 case Match_InvalidIndexRange0_0:
6825 case Match_InvalidIndexRange1_1:
6826 case Match_InvalidIndexRange0_15:
6827 case Match_InvalidIndexRange0_7:
6828 case Match_InvalidIndexRange0_3:
6829 case Match_InvalidIndexRange0_1:
6830 case Match_InvalidSVEIndexRange0_63:
6831 case Match_InvalidSVEIndexRange0_31:
6832 case Match_InvalidSVEIndexRange0_15:
6833 case Match_InvalidSVEIndexRange0_7:
6834 case Match_InvalidSVEIndexRange0_3:
6835 case Match_InvalidLabel:
6836 case Match_InvalidComplexRotationEven:
6837 case Match_InvalidComplexRotationOdd:
6838 case Match_InvalidGPR64shifted8:
6839 case Match_InvalidGPR64shifted16:
6840 case Match_InvalidGPR64shifted32:
6841 case Match_InvalidGPR64shifted64:
6842 case Match_InvalidGPR64shifted128:
6843 case Match_InvalidGPR64NoXZRshifted8:
6844 case Match_InvalidGPR64NoXZRshifted16:
6845 case Match_InvalidGPR64NoXZRshifted32:
6846 case Match_InvalidGPR64NoXZRshifted64:
6847 case Match_InvalidGPR64NoXZRshifted128:
6848 case Match_InvalidZPR32UXTW8:
6849 case Match_InvalidZPR32UXTW16:
6850 case Match_InvalidZPR32UXTW32:
6851 case Match_InvalidZPR32UXTW64:
6852 case Match_InvalidZPR32SXTW8:
6853 case Match_InvalidZPR32SXTW16:
6854 case Match_InvalidZPR32SXTW32:
6855 case Match_InvalidZPR32SXTW64:
6856 case Match_InvalidZPR64UXTW8:
6857 case Match_InvalidZPR64SXTW8:
6858 case Match_InvalidZPR64UXTW16:
6859 case Match_InvalidZPR64SXTW16:
6860 case Match_InvalidZPR64UXTW32:
6861 case Match_InvalidZPR64SXTW32:
6862 case Match_InvalidZPR64UXTW64:
6863 case Match_InvalidZPR64SXTW64:
6864 case Match_InvalidZPR32LSL8:
6865 case Match_InvalidZPR32LSL16:
6866 case Match_InvalidZPR32LSL32:
6867 case Match_InvalidZPR32LSL64:
6868 case Match_InvalidZPR64LSL8:
6869 case Match_InvalidZPR64LSL16:
6870 case Match_InvalidZPR64LSL32:
6871 case Match_InvalidZPR64LSL64:
6872 case Match_InvalidZPR0:
6873 case Match_InvalidZPR8:
6874 case Match_InvalidZPR16:
6875 case Match_InvalidZPR32:
6876 case Match_InvalidZPR64:
6877 case Match_InvalidZPR128:
6878 case Match_InvalidZPR_3b8:
6879 case Match_InvalidZPR_3b16:
6880 case Match_InvalidZPR_3b32:
6881 case Match_InvalidZPR_4b8:
6882 case Match_InvalidZPR_4b16:
6883 case Match_InvalidZPR_4b32:
6884 case Match_InvalidZPR_4b64:
6885 case Match_InvalidSVEPPRorPNRAnyReg:
6886 case Match_InvalidSVEPPRorPNRBReg:
6887 case Match_InvalidSVEPredicateAnyReg:
6888 case Match_InvalidSVEPattern:
6889 case Match_InvalidSVEVecLenSpecifier:
6890 case Match_InvalidSVEPredicateBReg:
6891 case Match_InvalidSVEPredicateHReg:
6892 case Match_InvalidSVEPredicateSReg:
6893 case Match_InvalidSVEPredicateDReg:
6894 case Match_InvalidSVEPredicate3bAnyReg:
6895 case Match_InvalidSVEPNPredicateB_p8to15Reg:
6896 case Match_InvalidSVEPNPredicateH_p8to15Reg:
6897 case Match_InvalidSVEPNPredicateS_p8to15Reg:
6898 case Match_InvalidSVEPNPredicateD_p8to15Reg:
6899 case Match_InvalidSVEPNPredicateAny_p8to15Reg:
6900 case Match_InvalidSVEPNPredicateBReg:
6901 case Match_InvalidSVEPNPredicateHReg:
6902 case Match_InvalidSVEPNPredicateSReg:
6903 case Match_InvalidSVEPNPredicateDReg:
6904 case Match_InvalidSVEPredicateListMul2x8:
6905 case Match_InvalidSVEPredicateListMul2x16:
6906 case Match_InvalidSVEPredicateListMul2x32:
6907 case Match_InvalidSVEPredicateListMul2x64:
6908 case Match_InvalidSVEExactFPImmOperandHalfOne:
6909 case Match_InvalidSVEExactFPImmOperandHalfTwo:
6910 case Match_InvalidSVEExactFPImmOperandZeroOne:
6911 case Match_InvalidMatrixTile16:
6912 case Match_InvalidMatrixTile32:
6913 case Match_InvalidMatrixTile64:
6914 case Match_InvalidMatrix:
6915 case Match_InvalidMatrix8:
6916 case Match_InvalidMatrix16:
6917 case Match_InvalidMatrix32:
6918 case Match_InvalidMatrix64:
6919 case Match_InvalidMatrixTileVectorH8:
6920 case Match_InvalidMatrixTileVectorH16:
6921 case Match_InvalidMatrixTileVectorH32:
6922 case Match_InvalidMatrixTileVectorH64:
6923 case Match_InvalidMatrixTileVectorH128:
6924 case Match_InvalidMatrixTileVectorV8:
6925 case Match_InvalidMatrixTileVectorV16:
6926 case Match_InvalidMatrixTileVectorV32:
6927 case Match_InvalidMatrixTileVectorV64:
6928 case Match_InvalidMatrixTileVectorV128:
6929 case Match_InvalidSVCR:
6930 case Match_InvalidMatrixIndexGPR32_12_15:
6931 case Match_InvalidMatrixIndexGPR32_8_11:
6932 case Match_InvalidLookupTable:
6933 case Match_InvalidZPRMul2_Lo8:
6934 case Match_InvalidZPRMul2_Hi8:
6935 case Match_InvalidZPRMul2_Lo16:
6936 case Match_InvalidZPRMul2_Hi16:
6937 case Match_InvalidZPRMul2_Lo32:
6938 case Match_InvalidZPRMul2_Hi32:
6939 case Match_InvalidZPRMul2_Lo64:
6940 case Match_InvalidZPRMul2_Hi64:
6941 case Match_InvalidZPR_K0:
6942 case Match_InvalidSVEVectorList2x8Mul2:
6943 case Match_InvalidSVEVectorList2x16Mul2:
6944 case Match_InvalidSVEVectorList2x32Mul2:
6945 case Match_InvalidSVEVectorList2x64Mul2:
6946 case Match_InvalidSVEVectorList2x128Mul2:
6947 case Match_InvalidSVEVectorList4x8Mul4:
6948 case Match_InvalidSVEVectorList4x16Mul4:
6949 case Match_InvalidSVEVectorList4x32Mul4:
6950 case Match_InvalidSVEVectorList4x64Mul4:
6951 case Match_InvalidSVEVectorList4x128Mul4:
6952 case Match_InvalidSVEVectorList2x8Mul2_Lo:
6953 case Match_InvalidSVEVectorList2x16Mul2_Lo:
6954 case Match_InvalidSVEVectorList2x32Mul2_Lo:
6955 case Match_InvalidSVEVectorList2x64Mul2_Lo:
6956 case Match_InvalidSVEVectorList2x8Mul2_Hi:
6957 case Match_InvalidSVEVectorList2x16Mul2_Hi:
6958 case Match_InvalidSVEVectorList2x32Mul2_Hi:
6959 case Match_InvalidSVEVectorList2x64Mul2_Hi:
6960 case Match_InvalidSVEVectorListStrided2x8:
6961 case Match_InvalidSVEVectorListStrided2x16:
6962 case Match_InvalidSVEVectorListStrided2x32:
6963 case Match_InvalidSVEVectorListStrided2x64:
6964 case Match_InvalidSVEVectorListStrided4x8:
6965 case Match_InvalidSVEVectorListStrided4x16:
6966 case Match_InvalidSVEVectorListStrided4x32:
6967 case Match_InvalidSVEVectorListStrided4x64:
6971 return Error(IDLoc,
"too few operands for instruction",
SMRange(IDLoc, (*
Operands.back()).getEndLoc()));
6975 if (ErrorLoc ==
SMLoc())
6985bool AArch64AsmParser::ParseDirective(
AsmToken DirectiveID) {
6992 if (IDVal ==
".arch")
6993 parseDirectiveArch(Loc);
6994 else if (IDVal ==
".cpu")
6995 parseDirectiveCPU(Loc);
6996 else if (IDVal ==
".tlsdesccall")
6997 parseDirectiveTLSDescCall(Loc);
6998 else if (IDVal ==
".ltorg" || IDVal ==
".pool")
6999 parseDirectiveLtorg(Loc);
7000 else if (IDVal ==
".unreq")
7001 parseDirectiveUnreq(Loc);
7002 else if (IDVal ==
".inst")
7003 parseDirectiveInst(Loc);
7004 else if (IDVal ==
".cfi_negate_ra_state")
7005 parseDirectiveCFINegateRAState();
7006 else if (IDVal ==
".cfi_negate_ra_state_with_pc")
7007 parseDirectiveCFINegateRAStateWithPC();
7008 else if (IDVal ==
".cfi_b_key_frame")
7009 parseDirectiveCFIBKeyFrame();
7010 else if (IDVal ==
".cfi_mte_tagged_frame")
7011 parseDirectiveCFIMTETaggedFrame();
7012 else if (IDVal ==
".arch_extension")
7013 parseDirectiveArchExtension(Loc);
7014 else if (IDVal ==
".variant_pcs")
7015 parseDirectiveVariantPCS(Loc);
7018 parseDirectiveLOH(IDVal, Loc);
7021 }
else if (IsCOFF) {
7022 if (IDVal ==
".seh_stackalloc")
7023 parseDirectiveSEHAllocStack(Loc);
7024 else if (IDVal ==
".seh_endprologue")
7025 parseDirectiveSEHPrologEnd(Loc);
7026 else if (IDVal ==
".seh_save_r19r20_x")
7027 parseDirectiveSEHSaveR19R20X(Loc);
7028 else if (IDVal ==
".seh_save_fplr")
7029 parseDirectiveSEHSaveFPLR(Loc);
7030 else if (IDVal ==
".seh_save_fplr_x")
7031 parseDirectiveSEHSaveFPLRX(Loc);
7032 else if (IDVal ==
".seh_save_reg")
7033 parseDirectiveSEHSaveReg(Loc);
7034 else if (IDVal ==
".seh_save_reg_x")
7035 parseDirectiveSEHSaveRegX(Loc);
7036 else if (IDVal ==
".seh_save_regp")
7037 parseDirectiveSEHSaveRegP(Loc);
7038 else if (IDVal ==
".seh_save_regp_x")
7039 parseDirectiveSEHSaveRegPX(Loc);
7040 else if (IDVal ==
".seh_save_lrpair")
7041 parseDirectiveSEHSaveLRPair(Loc);
7042 else if (IDVal ==
".seh_save_freg")
7043 parseDirectiveSEHSaveFReg(Loc);
7044 else if (IDVal ==
".seh_save_freg_x")
7045 parseDirectiveSEHSaveFRegX(Loc);
7046 else if (IDVal ==
".seh_save_fregp")
7047 parseDirectiveSEHSaveFRegP(Loc);
7048 else if (IDVal ==
".seh_save_fregp_x")
7049 parseDirectiveSEHSaveFRegPX(Loc);
7050 else if (IDVal ==
".seh_set_fp")
7051 parseDirectiveSEHSetFP(Loc);
7052 else if (IDVal ==
".seh_add_fp")
7053 parseDirectiveSEHAddFP(Loc);
7054 else if (IDVal ==
".seh_nop")
7055 parseDirectiveSEHNop(Loc);
7056 else if (IDVal ==
".seh_save_next")
7057 parseDirectiveSEHSaveNext(Loc);
7058 else if (IDVal ==
".seh_startepilogue")
7059 parseDirectiveSEHEpilogStart(Loc);
7060 else if (IDVal ==
".seh_endepilogue")
7061 parseDirectiveSEHEpilogEnd(Loc);
7062 else if (IDVal ==
".seh_trap_frame")
7063 parseDirectiveSEHTrapFrame(Loc);
7064 else if (IDVal ==
".seh_pushframe")
7065 parseDirectiveSEHMachineFrame(Loc);
7066 else if (IDVal ==
".seh_context")
7067 parseDirectiveSEHContext(Loc);
7068 else if (IDVal ==
".seh_ec_context")
7069 parseDirectiveSEHECContext(Loc);
7070 else if (IDVal ==
".seh_clear_unwound_to_call")
7071 parseDirectiveSEHClearUnwoundToCall(Loc);
7072 else if (IDVal ==
".seh_pac_sign_lr")
7073 parseDirectiveSEHPACSignLR(Loc);
7074 else if (IDVal ==
".seh_save_any_reg")
7075 parseDirectiveSEHSaveAnyReg(Loc,
false,
false);
7076 else if (IDVal ==
".seh_save_any_reg_p")
7077 parseDirectiveSEHSaveAnyReg(Loc,
true,
false);
7078 else if (IDVal ==
".seh_save_any_reg_x")
7079 parseDirectiveSEHSaveAnyReg(Loc,
false,
true);
7080 else if (IDVal ==
".seh_save_any_reg_px")
7081 parseDirectiveSEHSaveAnyReg(Loc,
true,
true);
7094 if (!NoCrypto && Crypto) {
7097 if (ArchInfo == AArch64::ARMV8_1A || ArchInfo == AArch64::ARMV8_2A ||
7098 ArchInfo == AArch64::ARMV8_3A) {
7102 if (ArchInfo == AArch64::ARMV8_4A || ArchInfo == AArch64::ARMV8_5A ||
7103 ArchInfo == AArch64::ARMV8_6A || ArchInfo == AArch64::ARMV8_7A ||
7104 ArchInfo == AArch64::ARMV8_8A || ArchInfo == AArch64::ARMV8_9A ||
7105 ArchInfo == AArch64::ARMV9A || ArchInfo == AArch64::ARMV9_1A ||
7106 ArchInfo == AArch64::ARMV9_2A || ArchInfo == AArch64::ARMV9_3A ||
7107 ArchInfo == AArch64::ARMV9_4A || ArchInfo == AArch64::ARMV8R) {
7113 }
else if (NoCrypto) {
7116 if (ArchInfo == AArch64::ARMV8_1A || ArchInfo == AArch64::ARMV8_2A ||
7117 ArchInfo == AArch64::ARMV8_3A) {
7118 RequestedExtensions.
push_back(
"nosha2");
7121 if (ArchInfo == AArch64::ARMV8_4A || ArchInfo == AArch64::ARMV8_5A ||
7122 ArchInfo == AArch64::ARMV8_6A || ArchInfo == AArch64::ARMV8_7A ||
7123 ArchInfo == AArch64::ARMV8_8A || ArchInfo == AArch64::ARMV8_9A ||
7124 ArchInfo == AArch64::ARMV9A || ArchInfo == AArch64::ARMV9_1A ||
7125 ArchInfo == AArch64::ARMV9_2A || ArchInfo == AArch64::ARMV9_3A ||
7126 ArchInfo == AArch64::ARMV9_4A) {
7128 RequestedExtensions.
push_back(
"nosha3");
7129 RequestedExtensions.
push_back(
"nosha2");
7141bool AArch64AsmParser::parseDirectiveArch(
SMLoc L) {
7142 SMLoc CurLoc = getLoc();
7145 std::tie(Arch, ExtensionString) =
7146 getParser().parseStringToEndOfStatement().
trim().
split(
'+');
7150 return Error(CurLoc,
"unknown arch name");
7156 std::vector<StringRef> AArch64Features;
7161 std::vector<std::string> ArchFeatures(AArch64Features.begin(), AArch64Features.end());
7163 join(ArchFeatures.begin(), ArchFeatures.end(),
","));
7166 if (!ExtensionString.
empty())
7167 ExtensionString.
split(RequestedExtensions,
'+');
7172 for (
auto Name : RequestedExtensions) {
7176 bool EnableFeature = !
Name.consume_front_insensitive(
"no");
7183 return Error(CurLoc,
"unsupported architectural extension: " +
Name);
7192 setAvailableFeatures(Features);
7198bool AArch64AsmParser::parseDirectiveArchExtension(
SMLoc L) {
7199 SMLoc ExtLoc = getLoc();
7201 StringRef Name = getParser().parseStringToEndOfStatement().trim();
7206 bool EnableFeature =
true;
7207 if (
Name.starts_with_insensitive(
"no")) {
7208 EnableFeature =
false;
7217 return Error(ExtLoc,
"unsupported architectural extension: " +
Name);
7225 setAvailableFeatures(Features);
7231bool AArch64AsmParser::parseDirectiveCPU(
SMLoc L) {
7232 SMLoc CurLoc = getLoc();
7235 std::tie(CPU, ExtensionString) =
7236 getParser().parseStringToEndOfStatement().
trim().
split(
'+');
7242 if (!ExtensionString.
empty())
7243 ExtensionString.
split(RequestedExtensions,
'+');
7247 Error(CurLoc,
"unknown CPU name");
7256 for (
auto Name : RequestedExtensions) {
7260 bool EnableFeature = !
Name.consume_front_insensitive(
"no");
7267 return Error(CurLoc,
"unsupported architectural extension: " +
Name);
7276 setAvailableFeatures(Features);
7282bool AArch64AsmParser::parseDirectiveInst(
SMLoc Loc) {
7284 return Error(Loc,
"expected expression following '.inst' directive");
7286 auto parseOp = [&]() ->
bool {
7288 const MCExpr *Expr =
nullptr;
7289 if (check(getParser().parseExpression(Expr), L,
"expected expression"))
7292 if (check(!
Value, L,
"expected constant expression"))
7294 getTargetStreamer().emitInst(
Value->getValue());
7298 return parseMany(parseOp);
7303bool AArch64AsmParser::parseDirectiveTLSDescCall(
SMLoc L) {
7305 if (check(getParser().parseIdentifier(
Name), L,
"expected symbol") ||
7317 getParser().getStreamer().emitInstruction(Inst, getSTI());
7323bool AArch64AsmParser::parseDirectiveLOH(
StringRef IDVal,
SMLoc Loc) {
7327 return TokError(
"expected an identifier or a number in directive");
7330 int64_t
Id = getTok().getIntVal();
7332 return TokError(
"invalid numeric identifier in directive");
7341 return TokError(
"invalid identifier in directive");
7349 assert(NbArgs != -1 &&
"Invalid number of arguments");
7352 for (
int Idx = 0;
Idx < NbArgs; ++
Idx) {
7354 if (getParser().parseIdentifier(
Name))
7355 return TokError(
"expected identifier in directive");
7356 Args.push_back(getContext().getOrCreateSymbol(
Name));
7358 if (
Idx + 1 == NbArgs)
7366 getStreamer().emitLOHDirective((
MCLOHType)Kind, Args);
7372bool AArch64AsmParser::parseDirectiveLtorg(
SMLoc L) {
7375 getTargetStreamer().emitCurrentConstantPool();
7383 SMLoc SRegLoc = getLoc();
7384 RegKind RegisterKind = RegKind::Scalar;
7386 ParseStatus ParseRes = tryParseScalarRegister(RegNum);
7390 RegisterKind = RegKind::NeonVector;
7391 ParseRes = tryParseVectorRegister(RegNum, Kind, RegKind::NeonVector);
7397 return Error(SRegLoc,
"vector register without type specifier expected");
7402 RegisterKind = RegKind::SVEDataVector;
7404 tryParseVectorRegister(RegNum, Kind, RegKind::SVEDataVector);
7410 return Error(SRegLoc,
7411 "sve vector register without type specifier expected");
7416 RegisterKind = RegKind::SVEPredicateVector;
7417 ParseRes = tryParseVectorRegister(RegNum, Kind, RegKind::SVEPredicateVector);
7423 return Error(SRegLoc,
7424 "sve predicate register without type specifier expected");
7428 return Error(SRegLoc,
"register name or alias expected");
7434 auto pair = std::make_pair(RegisterKind, (
unsigned) RegNum);
7435 if (RegisterReqs.
insert(std::make_pair(
Name, pair)).first->second != pair)
7436 Warning(L,
"ignoring redefinition of register alias '" +
Name +
"'");
7443bool AArch64AsmParser::parseDirectiveUnreq(
SMLoc L) {
7445 return TokError(
"unexpected input in .unreq directive.");
7446 RegisterReqs.
erase(getTok().getIdentifier().lower());
7451bool AArch64AsmParser::parseDirectiveCFINegateRAState() {
7454 getStreamer().emitCFINegateRAState();
7458bool AArch64AsmParser::parseDirectiveCFINegateRAStateWithPC() {
7461 getStreamer().emitCFINegateRAStateWithPC();
7467bool AArch64AsmParser::parseDirectiveCFIBKeyFrame() {
7470 getStreamer().emitCFIBKeyFrame();
7476bool AArch64AsmParser::parseDirectiveCFIMTETaggedFrame() {
7479 getStreamer().emitCFIMTETaggedFrame();
7485bool AArch64AsmParser::parseDirectiveVariantPCS(
SMLoc L) {
7487 if (getParser().parseIdentifier(
Name))
7488 return TokError(
"expected symbol name");
7491 getTargetStreamer().emitDirectiveVariantPCS(
7492 getContext().getOrCreateSymbol(
Name));
7498bool AArch64AsmParser::parseDirectiveSEHAllocStack(
SMLoc L) {
7500 if (parseImmExpr(
Size))
7502 getTargetStreamer().emitARM64WinCFIAllocStack(
Size);
7508bool AArch64AsmParser::parseDirectiveSEHPrologEnd(
SMLoc L) {
7509 getTargetStreamer().emitARM64WinCFIPrologEnd();
7515bool AArch64AsmParser::parseDirectiveSEHSaveR19R20X(
SMLoc L) {
7517 if (parseImmExpr(
Offset))
7519 getTargetStreamer().emitARM64WinCFISaveR19R20X(
Offset);
7525bool AArch64AsmParser::parseDirectiveSEHSaveFPLR(
SMLoc L) {
7527 if (parseImmExpr(
Offset))
7529 getTargetStreamer().emitARM64WinCFISaveFPLR(
Offset);
7535bool AArch64AsmParser::parseDirectiveSEHSaveFPLRX(
SMLoc L) {
7537 if (parseImmExpr(
Offset))
7539 getTargetStreamer().emitARM64WinCFISaveFPLRX(
Offset);
7545bool AArch64AsmParser::parseDirectiveSEHSaveReg(
SMLoc L) {
7548 if (parseRegisterInRange(Reg, AArch64::X0, AArch64::X19, AArch64::LR) ||
7549 parseComma() || parseImmExpr(
Offset))
7551 getTargetStreamer().emitARM64WinCFISaveReg(Reg,
Offset);
7557bool AArch64AsmParser::parseDirectiveSEHSaveRegX(
SMLoc L) {
7560 if (parseRegisterInRange(Reg, AArch64::X0, AArch64::X19, AArch64::LR) ||
7561 parseComma() || parseImmExpr(
Offset))
7563 getTargetStreamer().emitARM64WinCFISaveRegX(Reg,
Offset);
7569bool AArch64AsmParser::parseDirectiveSEHSaveRegP(
SMLoc L) {
7572 if (parseRegisterInRange(Reg, AArch64::X0, AArch64::X19, AArch64::FP) ||
7573 parseComma() || parseImmExpr(
Offset))
7575 getTargetStreamer().emitARM64WinCFISaveRegP(Reg,
Offset);
7581bool AArch64AsmParser::parseDirectiveSEHSaveRegPX(
SMLoc L) {
7584 if (parseRegisterInRange(Reg, AArch64::X0, AArch64::X19, AArch64::FP) ||
7585 parseComma() || parseImmExpr(
Offset))
7587 getTargetStreamer().emitARM64WinCFISaveRegPX(Reg,
Offset);
7593bool AArch64AsmParser::parseDirectiveSEHSaveLRPair(
SMLoc L) {
7597 if (parseRegisterInRange(Reg, AArch64::X0, AArch64::X19, AArch64::LR) ||
7598 parseComma() || parseImmExpr(
Offset))
7600 if (check(((Reg - 19) % 2 != 0), L,
7601 "expected register with even offset from x19"))
7603 getTargetStreamer().emitARM64WinCFISaveLRPair(Reg,
Offset);
7609bool AArch64AsmParser::parseDirectiveSEHSaveFReg(
SMLoc L) {
7612 if (parseRegisterInRange(Reg, AArch64::D0, AArch64::D8, AArch64::D15) ||
7613 parseComma() || parseImmExpr(
Offset))
7615 getTargetStreamer().emitARM64WinCFISaveFReg(Reg,
Offset);
7621bool AArch64AsmParser::parseDirectiveSEHSaveFRegX(
SMLoc L) {
7624 if (parseRegisterInRange(Reg, AArch64::D0, AArch64::D8, AArch64::D15) ||
7625 parseComma() || parseImmExpr(
Offset))
7627 getTargetStreamer().emitARM64WinCFISaveFRegX(Reg,
Offset);
7633bool AArch64AsmParser::parseDirectiveSEHSaveFRegP(
SMLoc L) {
7636 if (parseRegisterInRange(Reg, AArch64::D0, AArch64::D8, AArch64::D14) ||
7637 parseComma() || parseImmExpr(
Offset))
7639 getTargetStreamer().emitARM64WinCFISaveFRegP(Reg,
Offset);
7645bool AArch64AsmParser::parseDirectiveSEHSaveFRegPX(
SMLoc L) {
7648 if (parseRegisterInRange(Reg, AArch64::D0, AArch64::D8, AArch64::D14) ||
7649 parseComma() || parseImmExpr(
Offset))
7651 getTargetStreamer().emitARM64WinCFISaveFRegPX(Reg,
Offset);
7657bool AArch64AsmParser::parseDirectiveSEHSetFP(
SMLoc L) {
7658 getTargetStreamer().emitARM64WinCFISetFP();
7664bool AArch64AsmParser::parseDirectiveSEHAddFP(
SMLoc L) {
7666 if (parseImmExpr(
Size))
7668 getTargetStreamer().emitARM64WinCFIAddFP(
Size);
7674bool AArch64AsmParser::parseDirectiveSEHNop(
SMLoc L) {
7675 getTargetStreamer().emitARM64WinCFINop();
7681bool AArch64AsmParser::parseDirectiveSEHSaveNext(
SMLoc L) {
7682 getTargetStreamer().emitARM64WinCFISaveNext();
7688bool AArch64AsmParser::parseDirectiveSEHEpilogStart(
SMLoc L) {
7689 getTargetStreamer().emitARM64WinCFIEpilogStart();
7695bool AArch64AsmParser::parseDirectiveSEHEpilogEnd(
SMLoc L) {
7696 getTargetStreamer().emitARM64WinCFIEpilogEnd();
7702bool AArch64AsmParser::parseDirectiveSEHTrapFrame(
SMLoc L) {
7703 getTargetStreamer().emitARM64WinCFITrapFrame();
7709bool AArch64AsmParser::parseDirectiveSEHMachineFrame(
SMLoc L) {
7710 getTargetStreamer().emitARM64WinCFIMachineFrame();
7716bool AArch64AsmParser::parseDirectiveSEHContext(
SMLoc L) {
7717 getTargetStreamer().emitARM64WinCFIContext();
7723bool AArch64AsmParser::parseDirectiveSEHECContext(
SMLoc L) {
7724 getTargetStreamer().emitARM64WinCFIECContext();
7730bool AArch64AsmParser::parseDirectiveSEHClearUnwoundToCall(
SMLoc L) {
7731 getTargetStreamer().emitARM64WinCFIClearUnwoundToCall();
7737bool AArch64AsmParser::parseDirectiveSEHPACSignLR(
SMLoc L) {
7738 getTargetStreamer().emitARM64WinCFIPACSignLR();
7747bool AArch64AsmParser::parseDirectiveSEHSaveAnyReg(
SMLoc L,
bool Paired,
7752 if (check(parseRegister(Reg, Start,
End), getLoc(),
"expected register") ||
7753 parseComma() || parseImmExpr(
Offset))
7756 if (Reg == AArch64::FP || Reg == AArch64::LR ||
7757 (Reg >= AArch64::X0 && Reg <= AArch64::X28)) {
7758 if (
Offset < 0 ||
Offset % (Paired || Writeback ? 16 : 8))
7759 return Error(L,
"invalid save_any_reg offset");
7760 unsigned EncodedReg;
7761 if (Reg == AArch64::FP)
7763 else if (Reg == AArch64::LR)
7766 EncodedReg =
Reg - AArch64::X0;
7768 if (Reg == AArch64::LR)
7769 return Error(Start,
"lr cannot be paired with another register");
7771 getTargetStreamer().emitARM64WinCFISaveAnyRegIPX(EncodedReg,
Offset);
7773 getTargetStreamer().emitARM64WinCFISaveAnyRegIP(EncodedReg,
Offset);
7776 getTargetStreamer().emitARM64WinCFISaveAnyRegIX(EncodedReg,
Offset);
7778 getTargetStreamer().emitARM64WinCFISaveAnyRegI(EncodedReg,
Offset);
7780 }
else if (Reg >= AArch64::D0 && Reg <= AArch64::D31) {
7781 unsigned EncodedReg =
Reg - AArch64::D0;
7782 if (
Offset < 0 ||
Offset % (Paired || Writeback ? 16 : 8))
7783 return Error(L,
"invalid save_any_reg offset");
7785 if (Reg == AArch64::D31)
7786 return Error(Start,
"d31 cannot be paired with another register");
7788 getTargetStreamer().emitARM64WinCFISaveAnyRegDPX(EncodedReg,
Offset);
7790 getTargetStreamer().emitARM64WinCFISaveAnyRegDP(EncodedReg,
Offset);
7793 getTargetStreamer().emitARM64WinCFISaveAnyRegDX(EncodedReg,
Offset);
7795 getTargetStreamer().emitARM64WinCFISaveAnyRegD(EncodedReg,
Offset);
7797 }
else if (Reg >= AArch64::Q0 && Reg <= AArch64::Q31) {
7798 unsigned EncodedReg =
Reg - AArch64::Q0;
7800 return Error(L,
"invalid save_any_reg offset");
7802 if (Reg == AArch64::Q31)
7803 return Error(Start,
"q31 cannot be paired with another register");
7805 getTargetStreamer().emitARM64WinCFISaveAnyRegQPX(EncodedReg,
Offset);
7807 getTargetStreamer().emitARM64WinCFISaveAnyRegQP(EncodedReg,
Offset);
7810 getTargetStreamer().emitARM64WinCFISaveAnyRegQX(EncodedReg,
Offset);
7812 getTargetStreamer().emitARM64WinCFISaveAnyRegQ(EncodedReg,
Offset);
7815 return Error(Start,
"save_any_reg register must be x, q or d register");
7820bool AArch64AsmParser::parsePrimaryExpr(
const MCExpr *&Res,
SMLoc &EndLoc) {
7822 if (!parseAuthExpr(Res, EndLoc))
7824 return getParser().parsePrimaryExpr(Res, EndLoc,
nullptr);
7831bool AArch64AsmParser::parseAuthExpr(
const MCExpr *&Res,
SMLoc &EndLoc) {
7842 "combination of @AUTH with other modifiers not supported");
7865 Tokens[Tokens.
size() - 1].getIdentifier() !=
"AUTH")
7887 return TokError(
"expected key name");
7892 return TokError(
"invalid key '" + KeyStr +
"'");
7899 return TokError(
"expected integer discriminator");
7902 if (!isUInt<16>(Discriminator))
7903 return TokError(
"integer discriminator " +
Twine(Discriminator) +
7904 " out of range [0, 0xFFFF]");
7907 bool UseAddressDiversity =
false;
7912 return TokError(
"expected 'addr'");
7913 UseAddressDiversity =
true;
7922 UseAddressDiversity, Ctx);
7927AArch64AsmParser::classifySymbolRef(
const MCExpr *Expr,
7935 if (
const AArch64MCExpr *AE = dyn_cast<AArch64MCExpr>(Expr)) {
7936 ELFRefKind = AE->getKind();
7937 Expr = AE->getSubExpr();
7943 DarwinRefKind = SE->
getKind();
7950 if (!Relocatable || Res.
getSymB())
7977#define GET_REGISTER_MATCHER
7978#define GET_SUBTARGET_FEATURE_NAME
7979#define GET_MATCHER_IMPLEMENTATION
7980#define GET_MNEMONIC_SPELL_CHECKER
7981#include "AArch64GenAsmMatcher.inc"
7987 AArch64Operand &
Op =
static_cast<AArch64Operand &
>(AsmOp);
7989 auto MatchesOpImmediate = [&](int64_t ExpectedVal) -> MatchResultTy {
7991 return Match_InvalidOperand;
7994 return Match_InvalidOperand;
7995 if (CE->getValue() == ExpectedVal)
7996 return Match_Success;
7997 return Match_InvalidOperand;
8002 return Match_InvalidOperand;
8008 if (
Op.isTokenEqual(
"za"))
8009 return Match_Success;
8010 return Match_InvalidOperand;
8016#define MATCH_HASH(N) \
8017 case MCK__HASH_##N: \
8018 return MatchesOpImmediate(N);
8044#define MATCH_HASH_MINUS(N) \
8045 case MCK__HASH__MINUS_##N: \
8046 return MatchesOpImmediate(-N);
8050#undef MATCH_HASH_MINUS
8059 return Error(S,
"expected register");
8062 ParseStatus Res = tryParseScalarRegister(FirstReg);
8064 return Error(S,
"expected first even register of a consecutive same-size "
8065 "even/odd register pair");
8068 AArch64MCRegisterClasses[AArch64::GPR32RegClassID];
8070 AArch64MCRegisterClasses[AArch64::GPR64RegClassID];
8072 bool isXReg = XRegClass.
contains(FirstReg),
8073 isWReg = WRegClass.
contains(FirstReg);
8074 if (!isXReg && !isWReg)
8075 return Error(S,
"expected first even register of a consecutive same-size "
8076 "even/odd register pair");
8081 if (FirstEncoding & 0x1)
8082 return Error(S,
"expected first even register of a consecutive same-size "
8083 "even/odd register pair");
8086 return Error(getLoc(),
"expected comma");
8092 Res = tryParseScalarRegister(SecondReg);
8094 return Error(E,
"expected second odd register of a consecutive same-size "
8095 "even/odd register pair");
8098 (isXReg && !XRegClass.
contains(SecondReg)) ||
8099 (isWReg && !WRegClass.
contains(SecondReg)))
8100 return Error(E,
"expected second odd register of a consecutive same-size "
8101 "even/odd register pair");
8106 &AArch64MCRegisterClasses[AArch64::XSeqPairsClassRegClassID]);
8109 &AArch64MCRegisterClasses[AArch64::WSeqPairsClassRegClassID]);
8112 Operands.push_back(AArch64Operand::CreateReg(Pair, RegKind::Scalar, S,
8113 getLoc(), getContext()));
8118template <
bool ParseShiftExtend,
bool ParseSuffix>
8120 const SMLoc S = getLoc();
8126 tryParseVectorRegister(RegNum, Kind, RegKind::SVEDataVector);
8131 if (ParseSuffix &&
Kind.empty())
8138 unsigned ElementWidth = KindRes->second;
8142 Operands.push_back(AArch64Operand::CreateVectorReg(
8143 RegNum, RegKind::SVEDataVector, ElementWidth, S, S, getContext()));
8156 Res = tryParseOptionalShiftExtend(ExtOpnd);
8160 auto Ext =
static_cast<AArch64Operand *
>(ExtOpnd.
back().get());
8161 Operands.push_back(AArch64Operand::CreateVectorReg(
8162 RegNum, RegKind::SVEDataVector, ElementWidth, S,
Ext->getEndLoc(),
8163 getContext(),
Ext->getShiftExtendType(),
Ext->getShiftExtendAmount(),
8164 Ext->hasShiftExtendAmount()));
8189 auto *MCE = dyn_cast<MCConstantExpr>(ImmVal);
8191 return TokError(
"invalid operand for instruction");
8196 auto Pat = AArch64SVEPredPattern::lookupSVEPREDPATByName(TokE.
getString());
8207 SS, getLoc(), getContext()));
8218 auto Pat = AArch64SVEVecLenSpecifier::lookupSVEVECLENSPECIFIERByName(
8229 SS, getLoc(), getContext()));
8238 if (!tryParseScalarRegister(XReg).isSuccess())
8244 XReg, AArch64::x8sub_0,
8245 &AArch64MCRegisterClasses[AArch64::GPR64x8ClassRegClassID]);
8248 "expected an even-numbered x-register in the range [x0,x22]");
8251 AArch64Operand::CreateReg(X8Reg, RegKind::Scalar, SS, getLoc(), ctx));
8265 if (getParser().parseExpression(ImmF))
8275 SMLoc E = getTok().getLoc();
8277 if (getParser().parseExpression(ImmL))
8280 unsigned ImmFVal = cast<MCConstantExpr>(ImmF)->getValue();
8281 unsigned ImmLVal = cast<MCConstantExpr>(ImmL)->getValue();
8284 AArch64Operand::CreateImmRange(ImmFVal, ImmLVal, S, E, getContext()));
8299 if (getParser().parseExpression(Ex))
8302 int64_t
Imm = dyn_cast<MCConstantExpr>(Ex)->getValue();
8309 static_assert(Adj == 1 || Adj == -1,
"Unsafe immediate adjustment");
8316 Operands.push_back(AArch64Operand::CreateImm(
#define MATCH_HASH_MINUS(N)
static unsigned matchSVEDataVectorRegName(StringRef Name)
static bool isValidVectorKind(StringRef Suffix, RegKind VectorKind)
static void ExpandCryptoAEK(const AArch64::ArchInfo &ArchInfo, SmallVector< StringRef, 4 > &RequestedExtensions)
static unsigned matchSVEPredicateAsCounterRegName(StringRef Name)
static MCRegister MatchRegisterName(StringRef Name)
static bool isMatchingOrAlias(MCRegister ZReg, MCRegister Reg)
static const char * getSubtargetFeatureName(uint64_t Val)
static unsigned MatchNeonVectorRegName(StringRef Name)
}
static std::optional< std::pair< int, int > > parseVectorKind(StringRef Suffix, RegKind VectorKind)
Returns an optional pair of (#elements, element-width) if Suffix is a valid vector kind.
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAArch64AsmParser()
Force static initialization.
static unsigned matchMatrixRegName(StringRef Name)
static unsigned matchMatrixTileListRegName(StringRef Name)
static std::string AArch64MnemonicSpellCheck(StringRef S, const FeatureBitset &FBS, unsigned VariantID=0)
static SMLoc incrementLoc(SMLoc L, int Offset)
static const struct Extension ExtensionMap[]
static void setRequiredFeatureString(FeatureBitset FBS, std::string &Str)
static unsigned matchSVEPredicateVectorRegName(StringRef Name)
This file defines the StringMap class.
static bool isNot(const MachineRegisterInfo &MRI, const MachineInstr &MI)
This file declares a class to represent arbitrary precision floating point values and provide a varie...
This file implements a class to represent arbitrary precision integral constant values and operations...
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_EXTERNAL_VISIBILITY
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
Given that RA is a live value
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
mir Rename Register Operands
static MSP430CC::CondCodes getCondCode(unsigned Cond)
static unsigned getReg(const MCDisassembler *D, unsigned RC, unsigned RegNo)
static bool isReg(const MCInst &MI, unsigned OpNo)
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
const SmallVectorImpl< MachineOperand > & Cond
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool isImm(const MachineOperand &MO, MachineRegisterInfo *MRI)
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
This file defines the SmallSet class.
This file defines the SmallVector class.
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
static const AArch64AuthMCExpr * create(const MCExpr *Expr, uint16_t Discriminator, AArch64PACKey::ID Key, bool HasAddressDiversity, MCContext &Ctx)
static const char * getRegisterName(MCRegister Reg, unsigned AltIdx=AArch64::NoRegAltName)
static const AArch64MCExpr * create(const MCExpr *Expr, VariantKind Kind, MCContext &Ctx)
APInt bitcastToAPInt() const
Class for arbitrary precision integers.
bool isSignedIntN(unsigned N) const
Check if this APInt has an N-bits signed integer value.
bool isIntN(unsigned N) const
Check if this APInt has an N-bits unsigned integer value.
int64_t getSExtValue() const
Get sign extended value.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Target independent representation for an assembler token.
int64_t getIntVal() const
bool isNot(TokenKind K) const
StringRef getString() const
Get the string for the current token, this includes all characters (for example, the quotes on string...
bool is(TokenKind K) const
StringRef getIdentifier() const
Get the identifier string for the current token, which should be an identifier or a string.
This class represents an Operation in the Expression.
Base class for user error types.
Lightweight error class with error context and mandatory checking.
Container class for subtarget features.
constexpr size_t size() const
void UnLex(AsmToken const &Token)
const AsmToken peekTok(bool ShouldSkipSpace=true)
Look ahead at the next token to be lexed.
virtual size_t peekTokens(MutableArrayRef< AsmToken > Buf, bool ShouldSkipSpace=true)=0
Look ahead an arbitrary number of tokens.
virtual void Initialize(MCAsmParser &Parser)
Initialize the extension for parsing using the given Parser.
MCAsmParser & getParser()
Generic assembler parser interface, for use by target specific assembly parsers.
virtual MCStreamer & getStreamer()=0
Return the output streamer for the assembler.
virtual bool parseExpression(const MCExpr *&Res, SMLoc &EndLoc)=0
Parse an arbitrary expression.
virtual bool parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc, AsmTypeInfo *TypeInfo)=0
Parse a primary expression.
const AsmToken & getTok() const
Get the current AsmToken from the stream.
virtual bool parseIdentifier(StringRef &Res)=0
Parse an identifier or string (as a quoted identifier) and set Res to the identifier contents.
virtual const AsmToken & Lex()=0
Get the next AsmToken in the stream, possibly handling file inclusion first.
virtual MCAsmLexer & getLexer()=0
virtual void addAliasForDirective(StringRef Directive, StringRef Alias)=0
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Context object for machine code objects.
const MCRegisterInfo * getRegisterInfo() const
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Base class for the full range of assembler expressions which are needed for parsing.
bool evaluateAsRelocatable(MCValue &Res, const MCAssembler *Asm, const MCFixup *Fixup) const
Try to evaluate the expression to a relocatable value, i.e.
Instances of this class represent a single low-level machine instruction.
unsigned getNumOperands() const
unsigned getOpcode() const
void addOperand(const MCOperand Op)
void setOpcode(unsigned Op)
const MCOperand & getOperand(unsigned i) const
Describe properties that are true of each instruction in the target description file.
int getOperandConstraint(unsigned OpNum, MCOI::OperandConstraint Constraint) const
Returns the value of the specified operand constraint if it is present.
Interface to description of machine instruction set.
static MCOperand createExpr(const MCExpr *Val)
static MCOperand createReg(MCRegister Reg)
static MCOperand createImm(int64_t Val)
MCRegister getReg() const
Returns the register number.
const MCExpr * getExpr() const
MCParsedAsmOperand - This abstract class represents a source-level assembly instruction operand.
virtual MCRegister getReg() const =0
MCRegisterClass - Base class of TargetRegisterClass.
unsigned getRegister(unsigned i) const
getRegister - Return the specified register in the class.
bool contains(MCRegister Reg) const
contains - Return true if the specified register is included in this register class.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
MCRegister getMatchingSuperReg(MCRegister Reg, unsigned SubIdx, const MCRegisterClass *RC) const
Return a super-register of the specified register Reg so its sub-register of index SubIdx is Reg.
const char * getName(MCRegister RegNo) const
Return the human-readable symbolic target-specific name for the specified physical register.
uint16_t getEncodingValue(MCRegister Reg) const
Returns the encoding for Reg.
bool isSubRegisterEq(MCRegister RegA, MCRegister RegB) const
Returns true if RegB is a sub-register of RegA or if RegB == RegA.
const MCRegisterClass & getRegClass(unsigned i) const
Returns the register class associated with the enumeration value.
Wrapper class representing physical registers. Should be passed by value.
Streaming machine code generation interface.
virtual void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit the given Instruction into the current section.
MCTargetStreamer * getTargetStreamer()
Generic base class for all target subtargets.
const Triple & getTargetTriple() const
const FeatureBitset & getFeatureBits() const
FeatureBitset SetFeatureBitsTransitively(const FeatureBitset &FB)
Set/clear additional feature bits, including all other bits they imply.
void setDefaultFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS)
Set the features to the default for the given CPU and TuneCPU, with ano appended feature string.
FeatureBitset ClearFeatureBitsTransitively(const FeatureBitset &FB)
Represent a reference to a symbol from inside an expression.
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
VariantKind getKind() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
MCTargetAsmParser - Generic interface to target specific assembly parsers.
virtual bool parseInstruction(ParseInstructionInfo &Info, StringRef Name, SMLoc NameLoc, OperandVector &Operands)=0
Parse one assembly instruction.
@ FIRST_TARGET_MATCH_RESULT_TY
virtual bool parseRegister(MCRegister &Reg, SMLoc &StartLoc, SMLoc &EndLoc)=0
virtual bool ParseDirective(AsmToken DirectiveID)
ParseDirective - Parse a target specific assembler directive This method is deprecated,...
virtual bool parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc)
virtual ParseStatus tryParseRegister(MCRegister &Reg, SMLoc &StartLoc, SMLoc &EndLoc)=0
tryParseRegister - parse one register if possible
virtual bool areEqualRegs(const MCParsedAsmOperand &Op1, const MCParsedAsmOperand &Op2) const
Returns whether two operands are registers and are equal.
virtual bool matchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode, OperandVector &Operands, MCStreamer &Out, uint64_t &ErrorInfo, bool MatchingInlineAsm)=0
Recognize a series of operands of a parsed instruction as an actual MCInst and emit it to the specifi...
void setAvailableFeatures(const FeatureBitset &Value)
const MCSubtargetInfo & getSTI() const
virtual unsigned validateTargetOperandClass(MCParsedAsmOperand &Op, unsigned Kind)
Allow a target to add special case operand matching for things that tblgen doesn't/can't handle effec...
Target specific streamer interface.
This represents an "assembler immediate".
int64_t getConstant() const
const MCSymbolRefExpr * getSymB() const
const MCSymbolRefExpr * getSymA() const
Ternary parse status returned by various parse* methods.
constexpr bool isFailure() const
static constexpr StatusTy Failure
constexpr bool isSuccess() const
static constexpr StatusTy Success
static constexpr StatusTy NoMatch
constexpr bool isNoMatch() const
Represents a location in source code.
static SMLoc getFromPointer(const char *Ptr)
constexpr const char * getPointer() const
Represents a range in source code.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
bool contains(const T &V) const
Check if the SmallSet contains the given element.
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
iterator find(StringRef Key)
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
StringRef - Represent a constant reference to a string, i.e.
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
bool getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
constexpr bool empty() const
empty - Check if the string is empty.
StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
std::string upper() const
Convert the given ASCII string to uppercase.
constexpr size_t size() const
size - Get the string size.
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
StringRef take_back(size_t N=1) const
Return a StringRef equal to 'this' but with only the last N elements remaining.
StringRef trim(char Char) const
Return string with consecutive Char characters starting from the left and right removed.
std::string lower() const
bool ends_with(StringRef Suffix) const
Check if this string ends with the given Suffix.
static constexpr size_t npos
StringRef drop_back(size_t N=1) const
Return a StringRef equal to 'this' but with the last N elements dropped.
bool equals_insensitive(StringRef RHS) const
Check for string equality, ignoring case.
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
EnvironmentType getEnvironment() const
Get the parsed environment type of this triple.
bool isWindowsArm64EC() const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static CondCode getInvertedCondCode(CondCode Code)
const PHint * lookupPHintByName(StringRef)
uint32_t parseGenericRegister(StringRef Name)
const SysReg * lookupSysRegByName(StringRef)
static bool isMOVNMovAlias(uint64_t Value, int Shift, int RegWidth)
static unsigned getShiftValue(unsigned Imm)
getShiftValue - Extract the shift value.
static bool isLogicalImmediate(uint64_t imm, unsigned regSize)
isLogicalImmediate - Return true if the immediate is valid for a logical immediate instruction of the...
static unsigned getArithExtendImm(AArch64_AM::ShiftExtendType ET, unsigned Imm)
getArithExtendImm - Encode the extend type and shift amount for an arithmetic instruction: imm: 3-bit...
static float getFPImmFloat(unsigned Imm)
static uint8_t encodeAdvSIMDModImmType10(uint64_t Imm)
static bool isMOVZMovAlias(uint64_t Value, int Shift, int RegWidth)
static uint64_t encodeLogicalImmediate(uint64_t imm, unsigned regSize)
encodeLogicalImmediate - Return the encoded immediate value for a logical immediate instruction of th...
static const char * getShiftExtendName(AArch64_AM::ShiftExtendType ST)
getShiftName - Get the string encoding for the shift type.
static int getFP64Imm(const APInt &Imm)
getFP64Imm - Return an 8-bit floating-point version of the 64-bit floating-point value.
static bool isAdvSIMDModImmType10(uint64_t Imm)
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 ==...
const ArchInfo * parseArch(StringRef Arch)
const ArchInfo * getArchForCpu(StringRef CPU)
@ DestructiveInstTypeMask
bool getExtensionFeatures(const AArch64::ExtensionBitset &Extensions, std::vector< StringRef > &Features)
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
bool isPredicated(const MCInst &MI, const MCInstrInfo *MCII)
@ Tail
Attemps to make calls as fast as possible while guaranteeing that tail call optimization can always b...
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
float getFPImm(unsigned Imm)
@ CE
Windows NT (Windows on ARM)
Reg
All possible values of the reg field in the ModR/M byte.
NodeAddr< CodeNode * > Code
This is an optimization pass for GlobalISel generic memory operations.
static std::optional< AArch64PACKey::ID > AArch64StringToPACKeyID(StringRef Name)
Return numeric key ID for 2-letter identifier string.
bool errorToBool(Error Err)
Helper for converting an Error to a bool.
static int MCLOHNameToId(StringRef Name)
static bool isMem(const MachineInstr &MI, unsigned Op)
Target & getTheAArch64beTarget()
static StringRef MCLOHDirectiveName()
static bool isValidMCLOHType(unsigned Kind)
Target & getTheAArch64leTarget()
int countr_zero(T Val)
Count number of 0's from the least significant bit to the most stopping at the first 1.
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
Target & getTheAArch64_32Target()
Target & getTheARM64_32Target()
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
static int MCLOHIdToNbArgs(MCLOHType Kind)
static MCRegister getXRegFromWReg(MCRegister Reg)
MCLOHType
Linker Optimization Hint Type.
Target & getTheARM64Target()
DWARFExpression::Operation Op
static MCRegister getWRegFromXReg(MCRegister Reg)
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
const FeatureBitset Features
A record for a potential prefetch made during the initial scan of the loop.
AArch64::ExtensionBitset DefaultExts
Description of the encoding of one expression Op.
RegisterMCAsmParser - Helper template for registering a target specific assembly parser,...
bool haveFeatures(FeatureBitset ActiveFeatures) const
FeatureBitset getRequiredFeatures() const
FeatureBitset FeaturesRequired