35#define DEBUG_TYPE "ve-asmparser"
47#define GET_ASSEMBLER_HEADER
48#include "VEGenAsmMatcher.inc"
53 bool matchAndEmitInstruction(
SMLoc IDLoc,
unsigned &Opcode,
56 bool MatchingInlineAsm)
override;
60 SMLoc &EndLoc)
override;
66 unsigned Kind)
override;
75 ParseStatus parseVEAsmOperand(std::unique_ptr<VEOperand> &Operand);
79 bool parseExpression(
const MCExpr *&EVal);
85 bool parseLiteralValues(
unsigned Size,
SMLoc L);
92 setAvailableFeatures(ComputeAvailableFeatures(getSTI().getFeatureBits()));
99 VE::SW0, VE::SW1, VE::SW2, VE::SW3, VE::SW4, VE::SW5, VE::SW6,
100 VE::SW7, VE::SW8, VE::SW9, VE::SW10, VE::SW11, VE::SW12, VE::SW13,
101 VE::SW14, VE::SW15, VE::SW16, VE::SW17, VE::SW18, VE::SW19, VE::SW20,
102 VE::SW21, VE::SW22, VE::SW23, VE::SW24, VE::SW25, VE::SW26, VE::SW27,
103 VE::SW28, VE::SW29, VE::SW30, VE::SW31, VE::SW32, VE::SW33, VE::SW34,
104 VE::SW35, VE::SW36, VE::SW37, VE::SW38, VE::SW39, VE::SW40, VE::SW41,
105 VE::SW42, VE::SW43, VE::SW44, VE::SW45, VE::SW46, VE::SW47, VE::SW48,
106 VE::SW49, VE::SW50, VE::SW51, VE::SW52, VE::SW53, VE::SW54, VE::SW55,
107 VE::SW56, VE::SW57, VE::SW58, VE::SW59, VE::SW60, VE::SW61, VE::SW62,
111 VE::SF0, VE::SF1, VE::SF2, VE::SF3, VE::SF4, VE::SF5, VE::SF6,
112 VE::SF7, VE::SF8, VE::SF9, VE::SF10, VE::SF11, VE::SF12, VE::SF13,
113 VE::SF14, VE::SF15, VE::SF16, VE::SF17, VE::SF18, VE::SF19, VE::SF20,
114 VE::SF21, VE::SF22, VE::SF23, VE::SF24, VE::SF25, VE::SF26, VE::SF27,
115 VE::SF28, VE::SF29, VE::SF30, VE::SF31, VE::SF32, VE::SF33, VE::SF34,
116 VE::SF35, VE::SF36, VE::SF37, VE::SF38, VE::SF39, VE::SF40, VE::SF41,
117 VE::SF42, VE::SF43, VE::SF44, VE::SF45, VE::SF46, VE::SF47, VE::SF48,
118 VE::SF49, VE::SF50, VE::SF51, VE::SF52, VE::SF53, VE::SF54, VE::SF55,
119 VE::SF56, VE::SF57, VE::SF58, VE::SF59, VE::SF60, VE::SF61, VE::SF62,
123 VE::Q0, VE::Q1, VE::Q2, VE::Q3, VE::Q4, VE::Q5, VE::Q6, VE::Q7,
124 VE::Q8, VE::Q9, VE::Q10, VE::Q11, VE::Q12, VE::Q13, VE::Q14, VE::Q15,
125 VE::Q16, VE::Q17, VE::Q18, VE::Q19, VE::Q20, VE::Q21, VE::Q22, VE::Q23,
126 VE::Q24, VE::Q25, VE::Q26, VE::Q27, VE::Q28, VE::Q29, VE::Q30, VE::Q31};
129 VE::VMP4, VE::VMP5, VE::VMP6, VE::VMP7};
132 VE::USRCC, VE::PSW, VE::SAR, VE::NoRegister,
133 VE::NoRegister, VE::NoRegister, VE::NoRegister, VE::PMMR,
134 VE::PMCR0, VE::PMCR1, VE::PMCR2, VE::PMCR3,
135 VE::NoRegister, VE::NoRegister, VE::NoRegister, VE::NoRegister,
136 VE::PMC0, VE::PMC1, VE::PMC2, VE::PMC3,
137 VE::PMC4, VE::PMC5, VE::PMC6, VE::PMC7,
138 VE::PMC8, VE::PMC9, VE::PMC10, VE::PMC11,
139 VE::PMC12, VE::PMC13, VE::PMC14};
165 SMLoc StartLoc, EndLoc;
184 const MCExpr *Offset;
211 VEOperand(KindTy K) : Kind(
K) {}
213 bool isToken()
const override {
return Kind == k_Token; }
214 bool isReg()
const override {
return Kind == k_Register; }
215 bool isImm()
const override {
return Kind == k_Immediate; }
216 bool isMem()
const override {
217 return isMEMrri() || isMEMrii() || isMEMzri() || isMEMzii() || isMEMri() ||
220 bool isMEMrri()
const {
return Kind == k_MemoryRegRegImm; }
221 bool isMEMrii()
const {
return Kind == k_MemoryRegImmImm; }
222 bool isMEMzri()
const {
return Kind == k_MemoryZeroRegImm; }
223 bool isMEMzii()
const {
return Kind == k_MemoryZeroImmImm; }
224 bool isMEMri()
const {
return Kind == k_MemoryRegImm; }
225 bool isMEMzi()
const {
return Kind == k_MemoryZeroImm; }
226 bool isCCOp()
const {
return Kind == k_CCOp; }
227 bool isRDOp()
const {
return Kind == k_RDOp; }
234 int64_t
Value = ConstExpr->getValue();
245 int64_t
Value = ConstExpr->getValue();
256 int64_t
Value = ConstExpr->getValue();
267 int64_t
Value = ConstExpr->getValue();
278 int64_t
Value = ConstExpr->getValue();
289 int64_t
Value = ConstExpr->getValue();
300 int64_t
Value = ConstExpr->getValue();
311 int64_t
Value = ConstExpr->getValue();
322 int64_t
Value = ConstExpr->getValue();
328 if (Kind != k_MImmOp)
333 int64_t
Value = ConstExpr->getValue();
340 assert(Kind == k_Token &&
"Invalid access!");
341 return StringRef(Tok.Data, Tok.Length);
344 MCRegister
getReg()
const override {
345 assert((Kind == k_Register) &&
"Invalid access!");
349 const MCExpr *
getImm()
const {
350 assert((Kind == k_Immediate) &&
"Invalid access!");
354 MCRegister getMemBase()
const {
355 assert((Kind == k_MemoryRegRegImm || Kind == k_MemoryRegImmImm ||
356 Kind == k_MemoryRegImm) &&
361 MCRegister getMemIndexReg()
const {
362 assert((Kind == k_MemoryRegRegImm || Kind == k_MemoryZeroRegImm) &&
367 const MCExpr *getMemIndex()
const {
368 assert((Kind == k_MemoryRegImmImm || Kind == k_MemoryZeroImmImm) &&
373 const MCExpr *getMemOffset()
const {
374 assert((Kind == k_MemoryRegRegImm || Kind == k_MemoryRegImmImm ||
375 Kind == k_MemoryZeroImmImm || Kind == k_MemoryZeroRegImm ||
376 Kind == k_MemoryRegImm || Kind == k_MemoryZeroImm) &&
381 void setMemOffset(
const MCExpr *off) {
382 assert((Kind == k_MemoryRegRegImm || Kind == k_MemoryRegImmImm ||
383 Kind == k_MemoryZeroImmImm || Kind == k_MemoryZeroRegImm ||
384 Kind == k_MemoryRegImm || Kind == k_MemoryZeroImm) &&
389 unsigned getCCVal()
const {
390 assert((Kind == k_CCOp) &&
"Invalid access!");
394 unsigned getRDVal()
const {
395 assert((Kind == k_RDOp) &&
"Invalid access!");
399 const MCExpr *getMImmVal()
const {
400 assert((Kind == k_MImmOp) &&
"Invalid access!");
403 bool getM0Flag()
const {
404 assert((Kind == k_MImmOp) &&
"Invalid access!");
409 SMLoc getStartLoc()
const override {
return StartLoc; }
411 SMLoc getEndLoc()
const override {
return EndLoc; }
413 void print(raw_ostream &OS,
const MCAsmInfo &MAI)
const override {
416 OS <<
"Token: " <<
getToken() <<
"\n";
419 OS <<
"Reg: #" <<
getReg().
id() <<
"\n";
422 OS <<
"Imm: " <<
getImm() <<
"\n";
424 case k_MemoryRegRegImm:
425 assert(getMemOffset() !=
nullptr);
426 OS <<
"Mem: #" << getMemBase().id() <<
"+#" << getMemIndexReg().id()
431 case k_MemoryRegImmImm:
432 assert(getMemIndex() !=
nullptr && getMemOffset() !=
nullptr);
433 OS <<
"Mem: #" << getMemBase().id() <<
"+";
439 case k_MemoryZeroRegImm:
440 assert(getMemOffset() !=
nullptr);
441 OS <<
"Mem: 0+#" << getMemIndexReg().id() <<
"+";
445 case k_MemoryZeroImmImm:
446 assert(getMemIndex() !=
nullptr && getMemOffset() !=
nullptr);
454 assert(getMemOffset() !=
nullptr);
455 OS <<
"Mem: #" << getMemBase().id() <<
"+";
459 case k_MemoryZeroImm:
460 assert(getMemOffset() !=
nullptr);
466 OS <<
"CCOp: " << getCCVal() <<
"\n";
469 OS <<
"RDOp: " << getRDVal() <<
"\n";
472 OS <<
"MImm: (" << getMImmVal() << (getM0Flag() ?
")0" :
")1") <<
"\n";
477 void addRegOperands(MCInst &Inst,
unsigned N)
const {
478 assert(
N == 1 &&
"Invalid number of operands!");
482 void addImmOperands(MCInst &Inst,
unsigned N)
const {
483 assert(
N == 1 &&
"Invalid number of operands!");
484 const MCExpr *Expr =
getImm();
488 void addZeroOperands(MCInst &Inst,
unsigned N)
const {
489 addImmOperands(Inst,
N);
492 void addUImm0to2Operands(MCInst &Inst,
unsigned N)
const {
493 addImmOperands(Inst,
N);
496 void addUImm1Operands(MCInst &Inst,
unsigned N)
const {
497 addImmOperands(Inst,
N);
500 void addUImm2Operands(MCInst &Inst,
unsigned N)
const {
501 addImmOperands(Inst,
N);
504 void addUImm3Operands(MCInst &Inst,
unsigned N)
const {
505 addImmOperands(Inst,
N);
508 void addUImm4Operands(MCInst &Inst,
unsigned N)
const {
509 addImmOperands(Inst,
N);
512 void addUImm6Operands(MCInst &Inst,
unsigned N)
const {
513 addImmOperands(Inst,
N);
516 void addUImm7Operands(MCInst &Inst,
unsigned N)
const {
517 addImmOperands(Inst,
N);
520 void addSImm7Operands(MCInst &Inst,
unsigned N)
const {
521 addImmOperands(Inst,
N);
524 void addExpr(MCInst &Inst,
const MCExpr *Expr)
const {
534 void addMEMrriOperands(MCInst &Inst,
unsigned N)
const {
535 assert(
N == 3 &&
"Invalid number of operands!");
539 addExpr(Inst, getMemOffset());
542 void addMEMriiOperands(MCInst &Inst,
unsigned N)
const {
543 assert(
N == 3 &&
"Invalid number of operands!");
546 addExpr(Inst, getMemIndex());
547 addExpr(Inst, getMemOffset());
550 void addMEMzriOperands(MCInst &Inst,
unsigned N)
const {
551 assert(
N == 3 &&
"Invalid number of operands!");
555 addExpr(Inst, getMemOffset());
558 void addMEMziiOperands(MCInst &Inst,
unsigned N)
const {
559 assert(
N == 3 &&
"Invalid number of operands!");
562 addExpr(Inst, getMemIndex());
563 addExpr(Inst, getMemOffset());
566 void addMEMriOperands(MCInst &Inst,
unsigned N)
const {
567 assert(
N == 2 &&
"Invalid number of operands!");
570 addExpr(Inst, getMemOffset());
573 void addMEMziOperands(MCInst &Inst,
unsigned N)
const {
574 assert(
N == 2 &&
"Invalid number of operands!");
577 addExpr(Inst, getMemOffset());
580 void addCCOpOperands(MCInst &Inst,
unsigned N)
const {
581 assert(
N == 1 &&
"Invalid number of operands!");
586 void addRDOpOperands(MCInst &Inst,
unsigned N)
const {
587 assert(
N == 1 &&
"Invalid number of operands!");
592 void addMImmOperands(MCInst &Inst,
unsigned N)
const {
593 assert(
N == 1 &&
"Invalid number of operands!");
595 assert(ConstExpr &&
"Null operands!");
596 int64_t
Value = ConstExpr->getValue();
602 static std::unique_ptr<VEOperand> CreateToken(StringRef Str, SMLoc S) {
603 auto Op = std::make_unique<VEOperand>(k_Token);
604 Op->Tok.Data = Str.data();
605 Op->Tok.Length = Str.size();
611 static std::unique_ptr<VEOperand> CreateReg(MCRegister
Reg, SMLoc S,
613 auto Op = std::make_unique<VEOperand>(k_Register);
620 static std::unique_ptr<VEOperand> CreateImm(
const MCExpr *Val, SMLoc S,
622 auto Op = std::make_unique<VEOperand>(k_Immediate);
629 static std::unique_ptr<VEOperand> CreateCCOp(
unsigned CCVal, SMLoc S,
631 auto Op = std::make_unique<VEOperand>(k_CCOp);
632 Op->CC.CCVal = CCVal;
638 static std::unique_ptr<VEOperand> CreateRDOp(
unsigned RDVal, SMLoc S,
640 auto Op = std::make_unique<VEOperand>(k_RDOp);
641 Op->RD.RDVal = RDVal;
647 static std::unique_ptr<VEOperand> CreateMImm(
const MCExpr *Val,
bool Flag,
649 auto Op = std::make_unique<VEOperand>(k_MImmOp);
657 static bool MorphToI32Reg(VEOperand &
Op) {
658 MCRegister
Reg =
Op.getReg();
659 unsigned regIdx =
Reg - VE::SX0;
666 static bool MorphToF32Reg(VEOperand &
Op) {
667 MCRegister
Reg =
Op.getReg();
668 unsigned regIdx =
Reg - VE::SX0;
675 static bool MorphToF128Reg(VEOperand &
Op) {
676 MCRegister
Reg =
Op.getReg();
677 unsigned regIdx =
Reg - VE::SX0;
678 if (regIdx % 2 || regIdx > 63)
684 static bool MorphToVM512Reg(VEOperand &
Op) {
685 MCRegister
Reg =
Op.getReg();
686 unsigned regIdx =
Reg - VE::VM0;
687 if (regIdx % 2 || regIdx > 15)
693 static bool MorphToMISCReg(VEOperand &
Op) {
697 unsigned regIdx = ConstExpr->getValue();
700 Op.Kind = k_Register;
705 static std::unique_ptr<VEOperand>
706 MorphToMEMri(MCRegister
Base, std::unique_ptr<VEOperand>
Op) {
707 const MCExpr *
Imm =
Op->getImm();
708 Op->Kind = k_MemoryRegImm;
710 Op->Mem.IndexReg = MCRegister();
711 Op->Mem.Index =
nullptr;
712 Op->Mem.Offset =
Imm;
716 static std::unique_ptr<VEOperand>
717 MorphToMEMzi(std::unique_ptr<VEOperand>
Op) {
718 const MCExpr *
Imm =
Op->getImm();
719 Op->Kind = k_MemoryZeroImm;
720 Op->Mem.Base = MCRegister();
721 Op->Mem.IndexReg = MCRegister();
722 Op->Mem.Index =
nullptr;
723 Op->Mem.Offset =
Imm;
727 static std::unique_ptr<VEOperand>
728 MorphToMEMrri(MCRegister
Base, MCRegister Index,
729 std::unique_ptr<VEOperand>
Op) {
730 const MCExpr *
Imm =
Op->getImm();
731 Op->Kind = k_MemoryRegRegImm;
734 Op->Mem.Index =
nullptr;
735 Op->Mem.Offset =
Imm;
739 static std::unique_ptr<VEOperand>
740 MorphToMEMrii(MCRegister
Base,
const MCExpr *Index,
741 std::unique_ptr<VEOperand>
Op) {
742 const MCExpr *
Imm =
Op->getImm();
743 Op->Kind = k_MemoryRegImmImm;
745 Op->Mem.IndexReg = MCRegister();
747 Op->Mem.Offset =
Imm;
751 static std::unique_ptr<VEOperand>
752 MorphToMEMzri(MCRegister Index, std::unique_ptr<VEOperand>
Op) {
753 const MCExpr *
Imm =
Op->getImm();
754 Op->Kind = k_MemoryZeroRegImm;
755 Op->Mem.Base = MCRegister();
757 Op->Mem.Index =
nullptr;
758 Op->Mem.Offset =
Imm;
762 static std::unique_ptr<VEOperand>
763 MorphToMEMzii(
const MCExpr *Index, std::unique_ptr<VEOperand>
Op) {
764 const MCExpr *
Imm =
Op->getImm();
765 Op->Kind = k_MemoryZeroImmImm;
766 Op->Mem.Base = MCRegister();
767 Op->Mem.IndexReg = MCRegister();
769 Op->Mem.Offset =
Imm;
776bool VEAsmParser::matchAndEmitInstruction(
SMLoc IDLoc,
unsigned &Opcode,
779 bool MatchingInlineAsm) {
781 unsigned MatchResult =
782 MatchInstructionImpl(
Operands, Inst, ErrorInfo, MatchingInlineAsm);
783 switch (MatchResult) {
789 case Match_MissingFeature:
791 "instruction requires a CPU feature not currently enabled");
793 case Match_InvalidOperand: {
794 SMLoc ErrorLoc = IDLoc;
795 if (ErrorInfo != ~0ULL) {
797 return Error(IDLoc,
"too few operands for instruction");
799 ErrorLoc = ((VEOperand &)*
Operands[ErrorInfo]).getStartLoc();
800 if (ErrorLoc == SMLoc())
804 return Error(ErrorLoc,
"invalid operand for instruction");
806 case Match_MnemonicFail:
807 return Error(IDLoc,
"invalid instruction mnemonic");
812bool VEAsmParser::parseRegister(MCRegister &
Reg, SMLoc &StartLoc,
814 if (!tryParseRegister(
Reg, StartLoc, EndLoc).isSuccess())
815 return Error(StartLoc,
"invalid register name");
821MCRegister VEAsmParser::parseRegisterName(MCRegister (*matchFn)(StringRef)) {
824 MCRegister RegNum = matchFn(Name);
829 RegNum = matchFn(
Name.lower());
848 Reg = VE::NoRegister;
854 if (
Reg == VE::NoRegister)
857 if (
Reg != VE::NoRegister) {
862 getLexer().UnLex(Tok);
867 bool IntegerCC,
bool OmitCC,
SMLoc NameLoc,
878 StringRef SuffixStr = Name.substr(Suffix);
880 Name = Name.slice(0, Prefix);
881 Operands->push_back(VEOperand::CreateToken(Name, NameLoc));
885 Operands->push_back(VEOperand::CreateCCOp(CondCode, CondLoc, SuffixLoc));
887 if (!SuffixStr.
empty())
888 Operands->push_back(VEOperand::CreateToken(SuffixStr, SuffixLoc));
890 Operands->push_back(VEOperand::CreateToken(Name, NameLoc));
903 Name = Name.slice(0, Prefix);
905 Operands->push_back(VEOperand::CreateToken(Name, NameLoc));
914 Operands->push_back(VEOperand::CreateToken(Name, NameLoc));
921StringRef VEAsmParser::splitMnemonic(StringRef Name, SMLoc NameLoc,
924 StringRef Mnemonic =
Name;
926 if (Name[0] ==
'b') {
931 if (
Name.size() > 1 && Name[1] ==
'r')
936 (Name[
Next + 1] ==
'd' || Name[
Next + 1] ==
's'))
939 }
else if (
Name.starts_with(
"cmov.l.") ||
Name.starts_with(
"cmov.w.") ||
940 Name.starts_with(
"cmov.d.") ||
Name.starts_with(
"cmov.s.")) {
941 bool ICC =
Name[5] ==
'l' ||
Name[5] ==
'w';
943 }
else if (
Name.starts_with(
"cvt.w.d.sx") ||
Name.starts_with(
"cvt.w.d.zx") ||
944 Name.starts_with(
"cvt.w.s.sx") ||
Name.starts_with(
"cvt.w.s.zx")) {
946 }
else if (
Name.starts_with(
"cvt.l.d")) {
948 }
else if (
Name.starts_with(
"vcvt.w.d.sx") ||
949 Name.starts_with(
"vcvt.w.d.zx") ||
950 Name.starts_with(
"vcvt.w.s.sx") ||
951 Name.starts_with(
"vcvt.w.s.zx")) {
953 }
else if (
Name.starts_with(
"vcvt.l.d")) {
955 }
else if (
Name.starts_with(
"pvcvt.w.s.lo") ||
956 Name.starts_with(
"pvcvt.w.s.up")) {
958 }
else if (
Name.starts_with(
"pvcvt.w.s")) {
960 }
else if (
Name.starts_with(
"vfmk.l.") ||
Name.starts_with(
"vfmk.w.") ||
961 Name.starts_with(
"vfmk.d.") ||
Name.starts_with(
"vfmk.s.")) {
962 bool ICC =
Name[5] ==
'l' ||
Name[5] ==
'w' ?
true :
false;
964 }
else if (
Name.starts_with(
"pvfmk.w.lo.") ||
965 Name.starts_with(
"pvfmk.w.up.") ||
966 Name.starts_with(
"pvfmk.s.lo.") ||
967 Name.starts_with(
"pvfmk.s.up.")) {
968 bool ICC =
Name[6] ==
'l' ||
Name[6] ==
'w' ?
true :
false;
971 Operands->push_back(VEOperand::CreateToken(Mnemonic, NameLoc));
994 if (!parseOperand(
Operands, Mnemonic).isSuccess()) {
996 return Error(
Loc,
"unexpected token");
1002 if (!parseOperand(
Operands, Mnemonic).isSuccess()) {
1003 SMLoc Loc = getLexer().getLoc();
1004 return Error(Loc,
"unexpected token");
1009 SMLoc Loc = getLexer().getLoc();
1010 return Error(Loc,
"unexpected token");
1016ParseStatus VEAsmParser::parseDirective(AsmToken DirectiveID) {
1024 if (IDVal ==
".word")
1025 return parseLiteralValues(4, DirectiveID.
getLoc());
1028 if (IDVal ==
".long")
1029 return parseLiteralValues(8, DirectiveID.
getLoc());
1032 if (IDVal ==
".llong")
1033 return parseLiteralValues(8, DirectiveID.
getLoc());
1043bool VEAsmParser::parseLiteralValues(
unsigned Size, SMLoc L) {
1044 auto parseOne = [&]() ->
bool {
1045 const MCExpr *
Value;
1046 if (getParser().parseExpression(
Value))
1048 getParser().getStreamer().emitValue(
Value,
Size, L);
1051 return (parseMany(parseOne));
1060const MCExpr *VEAsmParser::extractSpecifier(
const MCExpr *
E,
1062 MCContext &
Context = getParser().getContext();
1065 switch (
E->getKind()) {
1131 const MCExpr *
Sub = extractSpecifier(UE->
getSubExpr(), Variant);
1140 const MCExpr *
LHS = extractSpecifier(BE->
getLHS(), LHSVariant);
1141 const MCExpr *
RHS = extractSpecifier(BE->
getRHS(), RHSVariant);
1155 else if (LHSVariant == RHSVariant)
1169bool VEAsmParser::parseExpression(
const MCExpr *&EVal) {
1171 if (getParser().parseExpression(EVal))
1176 const MCExpr *
E = extractSpecifier(EVal, Specifier);
1185 const AsmToken &Tok = Parser.
getTok();
1197 std::unique_ptr<VEOperand>
Offset;
1198 switch (getLexer().getKind()) {
1207 if (!parseExpression(EVal))
1208 Offset = VEOperand::CreateImm(EVal, S,
E);
1221 switch (getLexer().getKind()) {
1226 Operands.push_back(VEOperand::MorphToMEMzii(
1235 const MCExpr *IndexValue =
nullptr;
1236 MCRegister IndexReg;
1238 switch (getLexer().getKind()) {
1240 if (parseRegister(IndexReg, S,
E))
1247 if (getParser().parseExpression(IndexValue,
E))
1257 switch (getLexer().getKind()) {
1264 IndexValue ? VEOperand::MorphToMEMzii(IndexValue, std::move(
Offset))
1265 : VEOperand::MorphToMEMzri(IndexReg, std::move(
Offset)));
1274 if (parseRegister(BaseReg, S,
E))
1283 ? VEOperand::MorphToMEMrii(BaseReg, IndexValue, std::move(
Offset))
1284 : VEOperand::MorphToMEMrri(BaseReg, IndexReg, std::move(
Offset)));
1291 const AsmToken &Tok = Parser.
getTok();
1304 std::unique_ptr<VEOperand>
Offset;
1305 switch (getLexer().getKind()) {
1314 if (!parseExpression(EVal))
1315 Offset = VEOperand::CreateImm(EVal, S,
E);
1322 if (parseRegister(BaseReg, S,
E))
1335 switch (getLexer().getKind()) {
1341 Operands.push_back(BaseReg != VE::NoRegister
1342 ? VEOperand::MorphToMEMri(BaseReg, std::move(
Offset))
1343 : VEOperand::MorphToMEMzi(std::move(
Offset)));
1347 if (BaseReg != VE::NoRegister)
1353 switch (getLexer().getKind()) {
1355 if (parseRegister(BaseReg, S,
E))
1361 if (parseRegister(BaseReg, S,
E))
1373 Operands.push_back(BaseReg != VE::NoRegister
1374 ? VEOperand::MorphToMEMri(BaseReg, std::move(
Offset))
1375 : VEOperand::MorphToMEMzi(std::move(
Offset)));
1384 const AsmToken Tok1 = Parser.
getTok();
1390 const AsmToken Tok2 = Parser.
getTok();
1394 getLexer().UnLex(Tok1);
1398 const AsmToken Tok3 = Parser.
getTok();
1400 getLexer().UnLex(Tok2);
1401 getLexer().UnLex(Tok1);
1406 const AsmToken &Tok4 = Parser.
getTok();
1408 if (Suffix !=
"1" && Suffix !=
"0") {
1409 getLexer().UnLex(Tok3);
1410 getLexer().UnLex(Tok2);
1411 getLexer().UnLex(Tok1);
1417 VEOperand::CreateMImm(EVal, Suffix ==
"0", Tok1.
getLoc(), EndLoc));
1422 StringRef Mnemonic) {
1424 ParseStatus Res = MatchOperandParserImpl(
Operands, Mnemonic);
1432 switch (getLexer().getKind()) {
1435 const AsmToken Tok1 = Parser.
getTok();
1440 if (!tryParseRegister(Reg1,
S1, E1).isSuccess()) {
1441 getLexer().UnLex(Tok1);
1451 if (!tryParseRegister(Reg2, S2, E2).isSuccess())
1458 Operands.push_back(VEOperand::CreateReg(Reg1,
S1, E1));
1459 Operands.push_back(VEOperand::CreateReg(Reg2, S2, E2));
1466 std::unique_ptr<VEOperand>
Op;
1467 Res = parseVEAsmOperand(
Op);
1478 std::unique_ptr<VEOperand> Op1 = VEOperand::CreateToken(
1482 std::unique_ptr<VEOperand> Op2;
1483 Res = parseVEAsmOperand(Op2);
1490 Operands.push_back(std::move(Op1));
1491 Operands.push_back(std::move(Op2));
1502ParseStatus VEAsmParser::parseVEAsmOperand(std::unique_ptr<VEOperand> &
Op) {
1509 switch (getLexer().getKind()) {
1515 if (tryParseRegister(
Reg, S,
E).isSuccess())
1516 Op = VEOperand::CreateReg(
Reg, S,
E);
1523 if (!parseExpression(EVal))
1524 Op = VEOperand::CreateImm(EVal, S,
E);
1535#define GET_REGISTER_MATCHER
1536#define GET_MATCHER_IMPLEMENTATION
1537#include "VEGenAsmMatcher.inc"
1541 VEOperand &
Op = (VEOperand &)GOp;
1550 if (
Op.isReg() && VEOperand::MorphToF32Reg(
Op))
1554 if (
Op.isReg() && VEOperand::MorphToI32Reg(
Op))
1558 if (
Op.isReg() && VEOperand::MorphToF128Reg(
Op))
1562 if (
Op.isReg() && VEOperand::MorphToVM512Reg(
Op))
1566 if (
Op.isImm() && VEOperand::MorphToMISCReg(
Op))
1570 return Match_InvalidOperand;
static MCRegister MatchRegisterName(StringRef Name)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static void applyMnemonicAliases(StringRef &Mnemonic, const FeatureBitset &Features, unsigned VariantID)
static bool isNot(const MachineRegisterInfo &MRI, const MachineInstr &MI)
static MCRegister MatchRegisterAltName(StringRef Name)
Maps from the set of all alternative registernames to a register number.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_EXTERNAL_VISIBILITY
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
static MCRegister getReg(const MCDisassembler *D, unsigned RC, unsigned RegNo)
static bool isReg(const MCInst &MI, unsigned OpNo)
static bool isUImm2(const MachineOperand &MO)
const SmallVectorImpl< MachineOperand > & Cond
Func getContext().diagnose(DiagnosticInfoUnsupported(Func
This file defines the SmallVector class.
static const MCPhysReg MISCRegs[31]
static const MCPhysReg F128Regs[32]
static const MCPhysReg F32Regs[64]
static StringRef parseCC(StringRef Name, unsigned Prefix, unsigned Suffix, bool IntegerCC, bool OmitCC, SMLoc NameLoc, OperandVector *Operands)
static const MCPhysReg VM512Regs[8]
static const MCPhysReg I32Regs[64]
static StringRef parseRD(StringRef Name, unsigned Prefix, SMLoc NameLoc, OperandVector *Operands)
LLVM_ABI LLVM_EXTERNAL_VISIBILITY void LLVMInitializeVEAsmParser()
static bool isMImm(SDValue V)
Target independent representation for an assembler token.
LLVM_ABI SMLoc getLoc() 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
LLVM_ABI SMLoc getEndLoc() const
StringRef getIdentifier() const
Get the identifier string for the current token, which should be an identifier or a string.
Base class for user error types.
Container class for subtarget features.
void printExpr(raw_ostream &, const MCExpr &) const
Generic assembler parser interface, for use by target specific assembly parsers.
const AsmToken & getTok() const
Get the current AsmToken from the stream.
virtual const AsmToken & Lex()=0
Get the next AsmToken in the stream, possibly handling file inclusion first.
const MCExpr * getLHS() const
Get the left-hand side expression of the binary operator.
const MCExpr * getRHS() const
Get the right-hand side expression of the binary operator.
Opcode getOpcode() const
Get the kind of this binary expression.
static LLVM_ABI const MCBinaryExpr * create(Opcode Op, const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx, SMLoc Loc=SMLoc())
static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Base class for the full range of assembler expressions which are needed for parsing.
@ Unary
Unary expressions.
@ Constant
Constant expressions.
@ SymbolRef
References to labels and assigned expressions.
@ Target
Target specific expression.
@ Specifier
Expression with a relocation specifier.
@ Binary
Binary expressions.
void addOperand(const MCOperand Op)
Interface to description of machine instruction set.
static MCOperand createExpr(const MCExpr *Val)
static MCOperand createReg(MCRegister Reg)
static MCOperand createImm(int64_t Val)
MCParsedAsmOperand - This abstract class represents a source-level assembly instruction operand.
Wrapper class representing physical registers. Should be passed by value.
constexpr unsigned id() const
static const MCSpecifierExpr * create(const MCExpr *Expr, Spec S, MCContext &Ctx, SMLoc Loc=SMLoc())
Streaming machine code generation interface.
virtual void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit the given Instruction into the current section.
Generic base class for all target subtargets.
const MCSymbol & getSymbol() const
uint16_t getSpecifier() const
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
MCTargetAsmParser - Generic interface to target specific assembly parsers.
Opcode getOpcode() const
Get the kind of this unary expression.
static LLVM_ABI const MCUnaryExpr * create(Opcode Op, const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())
const MCExpr * getSubExpr() const
Get the child of this unary expression.
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
Represents a location in source code.
static SMLoc getFromPointer(const char *Ptr)
constexpr const char * getPointer() const
Represent a constant reference to a string, i.e.
constexpr bool empty() const
Check if the string is empty.
constexpr const char * data() const
Get a pointer to the start of the string (which may not be null terminated).
LLVM_ABI std::string lower() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
std::variant< std::monostate, Loc::Single, Loc::Multi, Loc::MMI, Loc::EntryValue > Variant
Alias for the std::variant specialization base class of DbgVariable.
Flag
These should be considered private to the implementation of the MCInstrDesc class.
@ CE
Windows NT (Windows on ARM)
BaseReg
Stack frame base register. Bit 0 of FREInfo.Info.
This is an optimization pass for GlobalISel generic memory operations.
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr, unsigned DynamicVGPRBlockSize=0)
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
static bool isMem(const MachineInstr &MI, unsigned Op)
LLVM_ABI std::pair< StringRef, StringRef > getToken(StringRef Source, StringRef Delimiters=" \t\n\v\f\r")
getToken - This function extracts one token from source, ignoring any leading characters that appear ...
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
Target & getTheVETarget()
SmallVectorImpl< std::unique_ptr< MCParsedAsmOperand > > OperandVector
MachineInstr * getImm(const MachineOperand &MO, const MachineRegisterInfo *MRI)
static VECC::CondCode stringToVEFCondCode(StringRef S)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
@ Sub
Subtraction of integers.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
DWARFExpression::Operation Op
RoundingMode
Rounding mode.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Next
static VERD::RoundingMode stringToVERD(StringRef S)
static VECC::CondCode stringToVEICondCode(StringRef S)
RegisterMCAsmParser - Helper template for registering a target specific assembly parser,...