34#define DEBUG_TYPE "ve-asmparser"
46#define GET_ASSEMBLER_HEADER
47#include "VEGenAsmMatcher.inc"
52 bool matchAndEmitInstruction(
SMLoc IDLoc,
unsigned &Opcode,
55 bool MatchingInlineAsm)
override;
59 SMLoc &EndLoc)
override;
65 unsigned Kind)
override;
74 ParseStatus parseVEAsmOperand(std::unique_ptr<VEOperand> &Operand);
78 bool parseExpression(
const MCExpr *&EVal);
84 bool parseLiteralValues(
unsigned Size,
SMLoc L);
91 setAvailableFeatures(ComputeAvailableFeatures(getSTI().getFeatureBits()));
98 VE::SW0, VE::SW1, VE::SW2, VE::SW3, VE::SW4, VE::SW5, VE::SW6,
99 VE::SW7, VE::SW8, VE::SW9, VE::SW10, VE::SW11, VE::SW12, VE::SW13,
100 VE::SW14, VE::SW15, VE::SW16, VE::SW17, VE::SW18, VE::SW19, VE::SW20,
101 VE::SW21, VE::SW22, VE::SW23, VE::SW24, VE::SW25, VE::SW26, VE::SW27,
102 VE::SW28, VE::SW29, VE::SW30, VE::SW31, VE::SW32, VE::SW33, VE::SW34,
103 VE::SW35, VE::SW36, VE::SW37, VE::SW38, VE::SW39, VE::SW40, VE::SW41,
104 VE::SW42, VE::SW43, VE::SW44, VE::SW45, VE::SW46, VE::SW47, VE::SW48,
105 VE::SW49, VE::SW50, VE::SW51, VE::SW52, VE::SW53, VE::SW54, VE::SW55,
106 VE::SW56, VE::SW57, VE::SW58, VE::SW59, VE::SW60, VE::SW61, VE::SW62,
110 VE::SF0, VE::SF1, VE::SF2, VE::SF3, VE::SF4, VE::SF5, VE::SF6,
111 VE::SF7, VE::SF8, VE::SF9, VE::SF10, VE::SF11, VE::SF12, VE::SF13,
112 VE::SF14, VE::SF15, VE::SF16, VE::SF17, VE::SF18, VE::SF19, VE::SF20,
113 VE::SF21, VE::SF22, VE::SF23, VE::SF24, VE::SF25, VE::SF26, VE::SF27,
114 VE::SF28, VE::SF29, VE::SF30, VE::SF31, VE::SF32, VE::SF33, VE::SF34,
115 VE::SF35, VE::SF36, VE::SF37, VE::SF38, VE::SF39, VE::SF40, VE::SF41,
116 VE::SF42, VE::SF43, VE::SF44, VE::SF45, VE::SF46, VE::SF47, VE::SF48,
117 VE::SF49, VE::SF50, VE::SF51, VE::SF52, VE::SF53, VE::SF54, VE::SF55,
118 VE::SF56, VE::SF57, VE::SF58, VE::SF59, VE::SF60, VE::SF61, VE::SF62,
122 VE::Q0, VE::Q1, VE::Q2, VE::Q3, VE::Q4, VE::Q5, VE::Q6, VE::Q7,
123 VE::Q8, VE::Q9, VE::Q10, VE::Q11, VE::Q12, VE::Q13, VE::Q14, VE::Q15,
124 VE::Q16, VE::Q17, VE::Q18, VE::Q19, VE::Q20, VE::Q21, VE::Q22, VE::Q23,
125 VE::Q24, VE::Q25, VE::Q26, VE::Q27, VE::Q28, VE::Q29, VE::Q30, VE::Q31};
128 VE::VMP4, VE::VMP5, VE::VMP6, VE::VMP7};
131 VE::USRCC, VE::PSW, VE::SAR, VE::NoRegister,
132 VE::NoRegister, VE::NoRegister, VE::NoRegister, VE::PMMR,
133 VE::PMCR0, VE::PMCR1, VE::PMCR2, VE::PMCR3,
134 VE::NoRegister, VE::NoRegister, VE::NoRegister, VE::NoRegister,
135 VE::PMC0, VE::PMC1, VE::PMC2, VE::PMC3,
136 VE::PMC4, VE::PMC5, VE::PMC6, VE::PMC7,
137 VE::PMC8, VE::PMC9, VE::PMC10, VE::PMC11,
138 VE::PMC12, VE::PMC13, VE::PMC14};
164 SMLoc StartLoc, EndLoc;
183 const MCExpr *Offset;
210 VEOperand(KindTy K) : Kind(
K) {}
212 bool isToken()
const override {
return Kind == k_Token; }
213 bool isReg()
const override {
return Kind == k_Register; }
214 bool isImm()
const override {
return Kind == k_Immediate; }
215 bool isMem()
const override {
216 return isMEMrri() || isMEMrii() || isMEMzri() || isMEMzii() || isMEMri() ||
219 bool isMEMrri()
const {
return Kind == k_MemoryRegRegImm; }
220 bool isMEMrii()
const {
return Kind == k_MemoryRegImmImm; }
221 bool isMEMzri()
const {
return Kind == k_MemoryZeroRegImm; }
222 bool isMEMzii()
const {
return Kind == k_MemoryZeroImmImm; }
223 bool isMEMri()
const {
return Kind == k_MemoryRegImm; }
224 bool isMEMzi()
const {
return Kind == k_MemoryZeroImm; }
225 bool isCCOp()
const {
return Kind == k_CCOp; }
226 bool isRDOp()
const {
return Kind == k_RDOp; }
233 int64_t
Value = ConstExpr->getValue();
244 int64_t
Value = ConstExpr->getValue();
255 int64_t
Value = ConstExpr->getValue();
266 int64_t
Value = ConstExpr->getValue();
277 int64_t
Value = ConstExpr->getValue();
288 int64_t
Value = ConstExpr->getValue();
299 int64_t
Value = ConstExpr->getValue();
310 int64_t
Value = ConstExpr->getValue();
321 int64_t
Value = ConstExpr->getValue();
327 if (Kind != k_MImmOp)
332 int64_t
Value = ConstExpr->getValue();
339 assert(Kind == k_Token &&
"Invalid access!");
340 return StringRef(Tok.Data, Tok.Length);
343 MCRegister
getReg()
const override {
344 assert((Kind == k_Register) &&
"Invalid access!");
348 const MCExpr *
getImm()
const {
349 assert((Kind == k_Immediate) &&
"Invalid access!");
353 MCRegister getMemBase()
const {
354 assert((Kind == k_MemoryRegRegImm || Kind == k_MemoryRegImmImm ||
355 Kind == k_MemoryRegImm) &&
360 MCRegister getMemIndexReg()
const {
361 assert((Kind == k_MemoryRegRegImm || Kind == k_MemoryZeroRegImm) &&
366 const MCExpr *getMemIndex()
const {
367 assert((Kind == k_MemoryRegImmImm || Kind == k_MemoryZeroImmImm) &&
372 const MCExpr *getMemOffset()
const {
373 assert((Kind == k_MemoryRegRegImm || Kind == k_MemoryRegImmImm ||
374 Kind == k_MemoryZeroImmImm || Kind == k_MemoryZeroRegImm ||
375 Kind == k_MemoryRegImm || Kind == k_MemoryZeroImm) &&
380 void setMemOffset(
const MCExpr *off) {
381 assert((Kind == k_MemoryRegRegImm || Kind == k_MemoryRegImmImm ||
382 Kind == k_MemoryZeroImmImm || Kind == k_MemoryZeroRegImm ||
383 Kind == k_MemoryRegImm || Kind == k_MemoryZeroImm) &&
388 unsigned getCCVal()
const {
389 assert((Kind == k_CCOp) &&
"Invalid access!");
393 unsigned getRDVal()
const {
394 assert((Kind == k_RDOp) &&
"Invalid access!");
398 const MCExpr *getMImmVal()
const {
399 assert((Kind == k_MImmOp) &&
"Invalid access!");
402 bool getM0Flag()
const {
403 assert((Kind == k_MImmOp) &&
"Invalid access!");
408 SMLoc getStartLoc()
const override {
return StartLoc; }
410 SMLoc getEndLoc()
const override {
return EndLoc; }
412 void print(raw_ostream &OS,
const MCAsmInfo &MAI)
const override {
415 OS <<
"Token: " <<
getToken() <<
"\n";
418 OS <<
"Reg: #" <<
getReg().
id() <<
"\n";
421 OS <<
"Imm: " <<
getImm() <<
"\n";
423 case k_MemoryRegRegImm:
424 assert(getMemOffset() !=
nullptr);
425 OS <<
"Mem: #" << getMemBase().id() <<
"+#" << getMemIndexReg().id()
430 case k_MemoryRegImmImm:
431 assert(getMemIndex() !=
nullptr && getMemOffset() !=
nullptr);
432 OS <<
"Mem: #" << getMemBase().id() <<
"+";
438 case k_MemoryZeroRegImm:
439 assert(getMemOffset() !=
nullptr);
440 OS <<
"Mem: 0+#" << getMemIndexReg().id() <<
"+";
444 case k_MemoryZeroImmImm:
445 assert(getMemIndex() !=
nullptr && getMemOffset() !=
nullptr);
453 assert(getMemOffset() !=
nullptr);
454 OS <<
"Mem: #" << getMemBase().id() <<
"+";
458 case k_MemoryZeroImm:
459 assert(getMemOffset() !=
nullptr);
465 OS <<
"CCOp: " << getCCVal() <<
"\n";
468 OS <<
"RDOp: " << getRDVal() <<
"\n";
471 OS <<
"MImm: (" << getMImmVal() << (getM0Flag() ?
")0" :
")1") <<
"\n";
476 void addRegOperands(MCInst &Inst,
unsigned N)
const {
477 assert(
N == 1 &&
"Invalid number of operands!");
481 void addImmOperands(MCInst &Inst,
unsigned N)
const {
482 assert(
N == 1 &&
"Invalid number of operands!");
483 const MCExpr *Expr =
getImm();
487 void addZeroOperands(MCInst &Inst,
unsigned N)
const {
488 addImmOperands(Inst,
N);
491 void addUImm0to2Operands(MCInst &Inst,
unsigned N)
const {
492 addImmOperands(Inst,
N);
495 void addUImm1Operands(MCInst &Inst,
unsigned N)
const {
496 addImmOperands(Inst,
N);
499 void addUImm2Operands(MCInst &Inst,
unsigned N)
const {
500 addImmOperands(Inst,
N);
503 void addUImm3Operands(MCInst &Inst,
unsigned N)
const {
504 addImmOperands(Inst,
N);
507 void addUImm4Operands(MCInst &Inst,
unsigned N)
const {
508 addImmOperands(Inst,
N);
511 void addUImm6Operands(MCInst &Inst,
unsigned N)
const {
512 addImmOperands(Inst,
N);
515 void addUImm7Operands(MCInst &Inst,
unsigned N)
const {
516 addImmOperands(Inst,
N);
519 void addSImm7Operands(MCInst &Inst,
unsigned N)
const {
520 addImmOperands(Inst,
N);
523 void addExpr(MCInst &Inst,
const MCExpr *Expr)
const {
533 void addMEMrriOperands(MCInst &Inst,
unsigned N)
const {
534 assert(
N == 3 &&
"Invalid number of operands!");
538 addExpr(Inst, getMemOffset());
541 void addMEMriiOperands(MCInst &Inst,
unsigned N)
const {
542 assert(
N == 3 &&
"Invalid number of operands!");
545 addExpr(Inst, getMemIndex());
546 addExpr(Inst, getMemOffset());
549 void addMEMzriOperands(MCInst &Inst,
unsigned N)
const {
550 assert(
N == 3 &&
"Invalid number of operands!");
554 addExpr(Inst, getMemOffset());
557 void addMEMziiOperands(MCInst &Inst,
unsigned N)
const {
558 assert(
N == 3 &&
"Invalid number of operands!");
561 addExpr(Inst, getMemIndex());
562 addExpr(Inst, getMemOffset());
565 void addMEMriOperands(MCInst &Inst,
unsigned N)
const {
566 assert(
N == 2 &&
"Invalid number of operands!");
569 addExpr(Inst, getMemOffset());
572 void addMEMziOperands(MCInst &Inst,
unsigned N)
const {
573 assert(
N == 2 &&
"Invalid number of operands!");
576 addExpr(Inst, getMemOffset());
579 void addCCOpOperands(MCInst &Inst,
unsigned N)
const {
580 assert(
N == 1 &&
"Invalid number of operands!");
585 void addRDOpOperands(MCInst &Inst,
unsigned N)
const {
586 assert(
N == 1 &&
"Invalid number of operands!");
591 void addMImmOperands(MCInst &Inst,
unsigned N)
const {
592 assert(
N == 1 &&
"Invalid number of operands!");
594 assert(ConstExpr &&
"Null operands!");
595 int64_t
Value = ConstExpr->getValue();
601 static std::unique_ptr<VEOperand> CreateToken(StringRef Str, SMLoc S) {
602 auto Op = std::make_unique<VEOperand>(k_Token);
603 Op->Tok.Data = Str.data();
604 Op->Tok.Length = Str.size();
610 static std::unique_ptr<VEOperand> CreateReg(MCRegister
Reg, SMLoc S,
612 auto Op = std::make_unique<VEOperand>(k_Register);
619 static std::unique_ptr<VEOperand> CreateImm(
const MCExpr *Val, SMLoc S,
621 auto Op = std::make_unique<VEOperand>(k_Immediate);
628 static std::unique_ptr<VEOperand> CreateCCOp(
unsigned CCVal, SMLoc S,
630 auto Op = std::make_unique<VEOperand>(k_CCOp);
631 Op->CC.CCVal = CCVal;
637 static std::unique_ptr<VEOperand> CreateRDOp(
unsigned RDVal, SMLoc S,
639 auto Op = std::make_unique<VEOperand>(k_RDOp);
640 Op->RD.RDVal = RDVal;
646 static std::unique_ptr<VEOperand> CreateMImm(
const MCExpr *Val,
bool Flag,
648 auto Op = std::make_unique<VEOperand>(k_MImmOp);
656 static bool MorphToI32Reg(VEOperand &
Op) {
657 MCRegister
Reg =
Op.getReg();
658 unsigned regIdx =
Reg - VE::SX0;
665 static bool MorphToF32Reg(VEOperand &
Op) {
666 MCRegister
Reg =
Op.getReg();
667 unsigned regIdx =
Reg - VE::SX0;
674 static bool MorphToF128Reg(VEOperand &
Op) {
675 MCRegister
Reg =
Op.getReg();
676 unsigned regIdx =
Reg - VE::SX0;
677 if (regIdx % 2 || regIdx > 63)
683 static bool MorphToVM512Reg(VEOperand &
Op) {
684 MCRegister
Reg =
Op.getReg();
685 unsigned regIdx =
Reg - VE::VM0;
686 if (regIdx % 2 || regIdx > 15)
692 static bool MorphToMISCReg(VEOperand &
Op) {
696 unsigned regIdx = ConstExpr->getValue();
697 if (regIdx > 31 ||
MISCRegs[regIdx] == VE::NoRegister)
699 Op.Kind = k_Register;
704 static std::unique_ptr<VEOperand>
705 MorphToMEMri(MCRegister
Base, std::unique_ptr<VEOperand>
Op) {
706 const MCExpr *
Imm =
Op->getImm();
707 Op->Kind = k_MemoryRegImm;
709 Op->Mem.IndexReg = MCRegister();
710 Op->Mem.Index =
nullptr;
711 Op->Mem.Offset =
Imm;
715 static std::unique_ptr<VEOperand>
716 MorphToMEMzi(std::unique_ptr<VEOperand>
Op) {
717 const MCExpr *
Imm =
Op->getImm();
718 Op->Kind = k_MemoryZeroImm;
719 Op->Mem.Base = MCRegister();
720 Op->Mem.IndexReg = MCRegister();
721 Op->Mem.Index =
nullptr;
722 Op->Mem.Offset =
Imm;
726 static std::unique_ptr<VEOperand>
727 MorphToMEMrri(MCRegister
Base, MCRegister Index,
728 std::unique_ptr<VEOperand>
Op) {
729 const MCExpr *
Imm =
Op->getImm();
730 Op->Kind = k_MemoryRegRegImm;
733 Op->Mem.Index =
nullptr;
734 Op->Mem.Offset =
Imm;
738 static std::unique_ptr<VEOperand>
739 MorphToMEMrii(MCRegister
Base,
const MCExpr *Index,
740 std::unique_ptr<VEOperand>
Op) {
741 const MCExpr *
Imm =
Op->getImm();
742 Op->Kind = k_MemoryRegImmImm;
744 Op->Mem.IndexReg = MCRegister();
746 Op->Mem.Offset =
Imm;
750 static std::unique_ptr<VEOperand>
751 MorphToMEMzri(MCRegister Index, std::unique_ptr<VEOperand>
Op) {
752 const MCExpr *
Imm =
Op->getImm();
753 Op->Kind = k_MemoryZeroRegImm;
754 Op->Mem.Base = MCRegister();
756 Op->Mem.Index =
nullptr;
757 Op->Mem.Offset =
Imm;
761 static std::unique_ptr<VEOperand>
762 MorphToMEMzii(
const MCExpr *Index, std::unique_ptr<VEOperand>
Op) {
763 const MCExpr *
Imm =
Op->getImm();
764 Op->Kind = k_MemoryZeroImmImm;
765 Op->Mem.Base = MCRegister();
766 Op->Mem.IndexReg = MCRegister();
768 Op->Mem.Offset =
Imm;
775bool VEAsmParser::matchAndEmitInstruction(
SMLoc IDLoc,
unsigned &Opcode,
778 bool MatchingInlineAsm) {
780 unsigned MatchResult =
781 MatchInstructionImpl(Operands, Inst, ErrorInfo, MatchingInlineAsm);
782 switch (MatchResult) {
788 case Match_MissingFeature:
790 "instruction requires a CPU feature not currently enabled");
792 case Match_InvalidOperand: {
793 SMLoc ErrorLoc = IDLoc;
794 if (ErrorInfo != ~0ULL) {
795 if (ErrorInfo >= Operands.
size())
796 return Error(IDLoc,
"too few operands for instruction");
798 ErrorLoc = ((VEOperand &)*Operands[ErrorInfo]).getStartLoc();
799 if (ErrorLoc == SMLoc())
803 return Error(ErrorLoc,
"invalid operand for instruction");
805 case Match_MnemonicFail:
806 return Error(IDLoc,
"invalid instruction mnemonic");
811bool VEAsmParser::parseRegister(MCRegister &
Reg, SMLoc &StartLoc,
813 if (!tryParseRegister(
Reg, StartLoc, EndLoc).isSuccess())
814 return Error(StartLoc,
"invalid register name");
820MCRegister VEAsmParser::parseRegisterName(MCRegister (*matchFn)(StringRef)) {
823 MCRegister RegNum = matchFn(Name);
828 RegNum = matchFn(
Name.lower());
847 Reg = VE::NoRegister;
853 if (
Reg == VE::NoRegister)
856 if (
Reg != VE::NoRegister) {
861 getLexer().UnLex(Tok);
866 bool IntegerCC,
bool OmitCC,
SMLoc NameLoc,
877 StringRef SuffixStr = Name.substr(Suffix);
879 Name = Name.slice(0, Prefix);
880 Operands->
push_back(VEOperand::CreateToken(Name, NameLoc));
884 Operands->
push_back(VEOperand::CreateCCOp(CondCode, CondLoc, SuffixLoc));
886 if (!SuffixStr.
empty())
887 Operands->
push_back(VEOperand::CreateToken(SuffixStr, SuffixLoc));
889 Operands->
push_back(VEOperand::CreateToken(Name, NameLoc));
902 Name = Name.slice(0, Prefix);
904 Operands->
push_back(VEOperand::CreateToken(Name, NameLoc));
913 Operands->
push_back(VEOperand::CreateToken(Name, NameLoc));
920StringRef VEAsmParser::splitMnemonic(StringRef Name, SMLoc NameLoc,
923 StringRef Mnemonic =
Name;
925 if (Name[0] ==
'b') {
930 if (
Name.size() > 1 && Name[1] ==
'r')
935 (Name[
Next + 1] ==
'd' || Name[
Next + 1] ==
's'))
937 Mnemonic =
parseCC(Name, Start,
Next, ICC,
true, NameLoc, Operands);
938 }
else if (
Name.starts_with(
"cmov.l.") ||
Name.starts_with(
"cmov.w.") ||
939 Name.starts_with(
"cmov.d.") ||
Name.starts_with(
"cmov.s.")) {
940 bool ICC =
Name[5] ==
'l' ||
Name[5] ==
'w';
941 Mnemonic =
parseCC(Name, 7,
Name.size(), ICC,
false, NameLoc, Operands);
942 }
else if (
Name.starts_with(
"cvt.w.d.sx") ||
Name.starts_with(
"cvt.w.d.zx") ||
943 Name.starts_with(
"cvt.w.s.sx") ||
Name.starts_with(
"cvt.w.s.zx")) {
944 Mnemonic =
parseRD(Name, 10, NameLoc, Operands);
945 }
else if (
Name.starts_with(
"cvt.l.d")) {
946 Mnemonic =
parseRD(Name, 7, NameLoc, Operands);
947 }
else if (
Name.starts_with(
"vcvt.w.d.sx") ||
948 Name.starts_with(
"vcvt.w.d.zx") ||
949 Name.starts_with(
"vcvt.w.s.sx") ||
950 Name.starts_with(
"vcvt.w.s.zx")) {
951 Mnemonic =
parseRD(Name, 11, NameLoc, Operands);
952 }
else if (
Name.starts_with(
"vcvt.l.d")) {
953 Mnemonic =
parseRD(Name, 8, NameLoc, Operands);
954 }
else if (
Name.starts_with(
"pvcvt.w.s.lo") ||
955 Name.starts_with(
"pvcvt.w.s.up")) {
956 Mnemonic =
parseRD(Name, 12, NameLoc, Operands);
957 }
else if (
Name.starts_with(
"pvcvt.w.s")) {
958 Mnemonic =
parseRD(Name, 9, NameLoc, Operands);
959 }
else if (
Name.starts_with(
"vfmk.l.") ||
Name.starts_with(
"vfmk.w.") ||
960 Name.starts_with(
"vfmk.d.") ||
Name.starts_with(
"vfmk.s.")) {
961 bool ICC =
Name[5] ==
'l' ||
Name[5] ==
'w' ?
true :
false;
962 Mnemonic =
parseCC(Name, 7,
Name.size(), ICC,
true, NameLoc, Operands);
963 }
else if (
Name.starts_with(
"pvfmk.w.lo.") ||
964 Name.starts_with(
"pvfmk.w.up.") ||
965 Name.starts_with(
"pvfmk.s.lo.") ||
966 Name.starts_with(
"pvfmk.s.up.")) {
967 bool ICC =
Name[6] ==
'l' ||
Name[6] ==
'w' ?
true :
false;
968 Mnemonic =
parseCC(Name, 11,
Name.size(), ICC,
true, NameLoc, Operands);
970 Operands->
push_back(VEOperand::CreateToken(Mnemonic, NameLoc));
989 StringRef Mnemonic = splitMnemonic(Name, NameLoc, &Operands);
993 if (!parseOperand(Operands, Mnemonic).isSuccess()) {
995 return Error(
Loc,
"unexpected token");
1001 if (!parseOperand(Operands, Mnemonic).isSuccess()) {
1002 SMLoc Loc = getLexer().getLoc();
1003 return Error(Loc,
"unexpected token");
1008 SMLoc Loc = getLexer().getLoc();
1009 return Error(Loc,
"unexpected token");
1015ParseStatus VEAsmParser::parseDirective(AsmToken DirectiveID) {
1023 if (IDVal ==
".word")
1024 return parseLiteralValues(4, DirectiveID.
getLoc());
1027 if (IDVal ==
".long")
1028 return parseLiteralValues(8, DirectiveID.
getLoc());
1031 if (IDVal ==
".llong")
1032 return parseLiteralValues(8, DirectiveID.
getLoc());
1042bool VEAsmParser::parseLiteralValues(
unsigned Size, SMLoc L) {
1043 auto parseOne = [&]() ->
bool {
1044 const MCExpr *
Value;
1045 if (getParser().parseExpression(
Value))
1047 getParser().getStreamer().emitValue(
Value,
Size, L);
1050 return (parseMany(parseOne));
1059const MCExpr *VEAsmParser::extractSpecifier(
const MCExpr *
E,
1061 MCContext &
Context = getParser().getContext();
1064 switch (
E->getKind()) {
1130 const MCExpr *
Sub = extractSpecifier(UE->
getSubExpr(), Variant);
1139 const MCExpr *
LHS = extractSpecifier(BE->
getLHS(), LHSVariant);
1140 const MCExpr *
RHS = extractSpecifier(BE->
getRHS(), RHSVariant);
1154 else if (LHSVariant == RHSVariant)
1168bool VEAsmParser::parseExpression(
const MCExpr *&EVal) {
1170 if (getParser().parseExpression(EVal))
1175 const MCExpr *
E = extractSpecifier(EVal, Specifier);
1182ParseStatus VEAsmParser::parseMEMOperand(
OperandVector &Operands) {
1184 const AsmToken &Tok = Parser.
getTok();
1196 std::unique_ptr<VEOperand>
Offset;
1197 switch (getLexer().getKind()) {
1206 if (!parseExpression(EVal))
1207 Offset = VEOperand::CreateImm(EVal, S,
E);
1220 switch (getLexer().getKind()) {
1225 Operands.
push_back(VEOperand::MorphToMEMzii(
1234 const MCExpr *IndexValue =
nullptr;
1235 MCRegister IndexReg;
1237 switch (getLexer().getKind()) {
1239 if (parseRegister(IndexReg, S,
E))
1246 if (getParser().parseExpression(IndexValue,
E))
1256 switch (getLexer().getKind()) {
1263 IndexValue ? VEOperand::MorphToMEMzii(IndexValue, std::move(
Offset))
1264 : VEOperand::MorphToMEMzri(IndexReg, std::move(
Offset)));
1273 if (parseRegister(BaseReg, S,
E))
1282 ? VEOperand::MorphToMEMrii(BaseReg, IndexValue, std::move(
Offset))
1283 : VEOperand::MorphToMEMrri(BaseReg, IndexReg, std::move(
Offset)));
1288ParseStatus VEAsmParser::parseMEMAsOperand(
OperandVector &Operands) {
1290 const AsmToken &Tok = Parser.
getTok();
1303 std::unique_ptr<VEOperand>
Offset;
1304 switch (getLexer().getKind()) {
1313 if (!parseExpression(EVal))
1314 Offset = VEOperand::CreateImm(EVal, S,
E);
1321 if (parseRegister(BaseReg, S,
E))
1334 switch (getLexer().getKind()) {
1340 Operands.
push_back(BaseReg != VE::NoRegister
1341 ? VEOperand::MorphToMEMri(BaseReg, std::move(
Offset))
1342 : VEOperand::MorphToMEMzi(std::move(
Offset)));
1346 if (BaseReg != VE::NoRegister)
1352 switch (getLexer().getKind()) {
1354 if (parseRegister(BaseReg, S,
E))
1360 if (parseRegister(BaseReg, S,
E))
1372 Operands.
push_back(BaseReg != VE::NoRegister
1373 ? VEOperand::MorphToMEMri(BaseReg, std::move(
Offset))
1374 : VEOperand::MorphToMEMzi(std::move(
Offset)));
1379ParseStatus VEAsmParser::parseMImmOperand(
OperandVector &Operands) {
1383 const AsmToken Tok1 = Parser.
getTok();
1389 const AsmToken Tok2 = Parser.
getTok();
1393 getLexer().UnLex(Tok1);
1397 const AsmToken Tok3 = Parser.
getTok();
1399 getLexer().UnLex(Tok2);
1400 getLexer().UnLex(Tok1);
1405 const AsmToken &Tok4 = Parser.
getTok();
1407 if (Suffix !=
"1" && Suffix !=
"0") {
1408 getLexer().UnLex(Tok3);
1409 getLexer().UnLex(Tok2);
1410 getLexer().UnLex(Tok1);
1416 VEOperand::CreateMImm(EVal, Suffix ==
"0", Tok1.
getLoc(), EndLoc));
1420ParseStatus VEAsmParser::parseOperand(
OperandVector &Operands,
1421 StringRef Mnemonic) {
1423 ParseStatus Res = MatchOperandParserImpl(Operands, Mnemonic);
1431 switch (getLexer().getKind()) {
1434 const AsmToken Tok1 = Parser.
getTok();
1439 if (!tryParseRegister(Reg1,
S1, E1).isSuccess()) {
1440 getLexer().UnLex(Tok1);
1450 if (!tryParseRegister(Reg2, S2, E2).isSuccess())
1457 Operands.
push_back(VEOperand::CreateReg(Reg1,
S1, E1));
1458 Operands.
push_back(VEOperand::CreateReg(Reg2, S2, E2));
1465 std::unique_ptr<VEOperand>
Op;
1466 Res = parseVEAsmOperand(
Op);
1477 std::unique_ptr<VEOperand> Op1 = VEOperand::CreateToken(
1481 std::unique_ptr<VEOperand> Op2;
1482 Res = parseVEAsmOperand(Op2);
1501ParseStatus VEAsmParser::parseVEAsmOperand(std::unique_ptr<VEOperand> &
Op) {
1508 switch (getLexer().getKind()) {
1514 if (tryParseRegister(
Reg, S,
E).isSuccess())
1515 Op = VEOperand::CreateReg(
Reg, S,
E);
1522 if (!parseExpression(EVal))
1523 Op = VEOperand::CreateImm(EVal, S,
E);
1534#define GET_REGISTER_MATCHER
1535#define GET_MATCHER_IMPLEMENTATION
1536#include "VEGenAsmMatcher.inc"
1540 VEOperand &
Op = (VEOperand &)GOp;
1549 if (
Op.isReg() && VEOperand::MorphToF32Reg(
Op))
1553 if (
Op.isReg() && VEOperand::MorphToI32Reg(
Op))
1557 if (
Op.isReg() && VEOperand::MorphToF128Reg(
Op))
1561 if (
Op.isReg() && VEOperand::MorphToVM512Reg(
Op))
1565 if (
Op.isImm() && VEOperand::MorphToMISCReg(
Op))
1569 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")
Analysis containing CSE Info
#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)
const SmallVectorImpl< MachineOperand > & Cond
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
void push_back(const T &Elt)
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - Check if the string is empty.
constexpr const char * data() const
data - 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)
Context & getContext() const
BaseReg
Stack frame base register. Bit 0 of FREInfo.Info.
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
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.
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...
FunctionAddr VTableAddr Next
DWARFExpression::Operation Op
RoundingMode
Rounding mode.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
static VERD::RoundingMode stringToVERD(StringRef S)
static VECC::CondCode stringToVEICondCode(StringRef S)
RegisterMCAsmParser - Helper template for registering a target specific assembly parser,...