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;
73 ParseStatus parseVEAsmOperand(std::unique_ptr<VEOperand> &Operand);
77 bool parseExpression(
const MCExpr *&EVal);
83 bool parseLiteralValues(
unsigned Size,
SMLoc L);
90 setAvailableFeatures(ComputeAvailableFeatures(getSTI().getFeatureBits()));
97 VE::USRCC, VE::PSW, VE::SAR, VE::NoRegister,
98 VE::NoRegister, VE::NoRegister, VE::NoRegister, VE::PMMR,
99 VE::PMCR0, VE::PMCR1, VE::PMCR2, VE::PMCR3,
100 VE::NoRegister, VE::NoRegister, VE::NoRegister, VE::NoRegister,
101 VE::PMC0, VE::PMC1, VE::PMC2, VE::PMC3,
102 VE::PMC4, VE::PMC5, VE::PMC6, VE::PMC7,
103 VE::PMC8, VE::PMC9, VE::PMC10, VE::PMC11,
104 VE::PMC12, VE::PMC13, VE::PMC14};
130 SMLoc StartLoc, EndLoc;
149 const MCExpr *Offset;
176 VEOperand(KindTy K) : Kind(
K) {}
178 bool isToken()
const override {
return Kind == k_Token; }
179 bool isReg()
const override {
return Kind == k_Register; }
180 bool isImm()
const override {
return Kind == k_Immediate; }
181 bool isMem()
const override {
182 return isMEMrri() || isMEMrii() || isMEMzri() || isMEMzii() || isMEMri() ||
185 bool isMEMrri()
const {
return Kind == k_MemoryRegRegImm; }
186 bool isMEMrii()
const {
return Kind == k_MemoryRegImmImm; }
187 bool isMEMzri()
const {
return Kind == k_MemoryZeroRegImm; }
188 bool isMEMzii()
const {
return Kind == k_MemoryZeroImmImm; }
189 bool isMEMri()
const {
return Kind == k_MemoryRegImm; }
190 bool isMEMzi()
const {
return Kind == k_MemoryZeroImm; }
191 bool isCCOp()
const {
return Kind == k_CCOp; }
192 bool isRDOp()
const {
return Kind == k_RDOp; }
199 int64_t
Value = ConstExpr->getValue();
204 bool isUImm0to2()
const {
210 int64_t
Value = ConstExpr->getValue();
215 bool isUImm1()
const {
221 int64_t
Value = ConstExpr->getValue();
232 int64_t
Value = ConstExpr->getValue();
237 bool isUImm3()
const {
243 int64_t
Value = ConstExpr->getValue();
248 bool isUImm4()
const {
254 int64_t
Value = ConstExpr->getValue();
259 bool isUImm6()
const {
265 int64_t
Value = ConstExpr->getValue();
270 bool isUImm7()
const {
276 int64_t
Value = ConstExpr->getValue();
281 bool isSImm7()
const {
287 int64_t
Value = ConstExpr->getValue();
293 if (Kind != k_MImmOp)
298 int64_t
Value = ConstExpr->getValue();
305 assert(Kind == k_Token &&
"Invalid access!");
306 return StringRef(Tok.Data, Tok.Length);
309 MCRegister
getReg()
const override {
310 assert((Kind == k_Register) &&
"Invalid access!");
314 const MCExpr *
getImm()
const {
315 assert((Kind == k_Immediate) &&
"Invalid access!");
319 MCRegister getMemBase()
const {
320 assert((Kind == k_MemoryRegRegImm || Kind == k_MemoryRegImmImm ||
321 Kind == k_MemoryRegImm) &&
326 MCRegister getMemIndexReg()
const {
327 assert((Kind == k_MemoryRegRegImm || Kind == k_MemoryZeroRegImm) &&
332 const MCExpr *getMemIndex()
const {
333 assert((Kind == k_MemoryRegImmImm || Kind == k_MemoryZeroImmImm) &&
338 const MCExpr *getMemOffset()
const {
339 assert((Kind == k_MemoryRegRegImm || Kind == k_MemoryRegImmImm ||
340 Kind == k_MemoryZeroImmImm || Kind == k_MemoryZeroRegImm ||
341 Kind == k_MemoryRegImm || Kind == k_MemoryZeroImm) &&
346 void setMemOffset(
const MCExpr *off) {
347 assert((Kind == k_MemoryRegRegImm || Kind == k_MemoryRegImmImm ||
348 Kind == k_MemoryZeroImmImm || Kind == k_MemoryZeroRegImm ||
349 Kind == k_MemoryRegImm || Kind == k_MemoryZeroImm) &&
354 unsigned getCCVal()
const {
355 assert((Kind == k_CCOp) &&
"Invalid access!");
359 unsigned getRDVal()
const {
360 assert((Kind == k_RDOp) &&
"Invalid access!");
364 const MCExpr *getMImmVal()
const {
365 assert((Kind == k_MImmOp) &&
"Invalid access!");
368 bool getM0Flag()
const {
369 assert((Kind == k_MImmOp) &&
"Invalid access!");
374 SMLoc getStartLoc()
const override {
return StartLoc; }
376 SMLoc getEndLoc()
const override {
return EndLoc; }
378 void print(raw_ostream &OS,
const MCAsmInfo &MAI)
const override {
381 OS <<
"Token: " <<
getToken() <<
"\n";
384 OS <<
"Reg: #" <<
getReg().
id() <<
"\n";
387 OS <<
"Imm: " <<
getImm() <<
"\n";
389 case k_MemoryRegRegImm:
390 assert(getMemOffset() !=
nullptr);
391 OS <<
"Mem: #" << getMemBase().id() <<
"+#" << getMemIndexReg().id()
396 case k_MemoryRegImmImm:
397 assert(getMemIndex() !=
nullptr && getMemOffset() !=
nullptr);
398 OS <<
"Mem: #" << getMemBase().id() <<
"+";
404 case k_MemoryZeroRegImm:
405 assert(getMemOffset() !=
nullptr);
406 OS <<
"Mem: 0+#" << getMemIndexReg().id() <<
"+";
410 case k_MemoryZeroImmImm:
411 assert(getMemIndex() !=
nullptr && getMemOffset() !=
nullptr);
419 assert(getMemOffset() !=
nullptr);
420 OS <<
"Mem: #" << getMemBase().id() <<
"+";
424 case k_MemoryZeroImm:
425 assert(getMemOffset() !=
nullptr);
431 OS <<
"CCOp: " << getCCVal() <<
"\n";
434 OS <<
"RDOp: " << getRDVal() <<
"\n";
437 OS <<
"MImm: (" << getMImmVal() << (getM0Flag() ?
")0" :
")1") <<
"\n";
442 void addRegOperands(MCInst &Inst,
unsigned N)
const {
443 assert(
N == 1 &&
"Invalid number of operands!");
447 void addMISCRegOperands(MCInst &Inst,
unsigned N)
const {
448 assert(
N == 1 &&
"Invalid number of operands!");
449 MCRegister
R = isImm() ? getMISCReg() :
getReg();
450 assert(R &&
"Invalid MISC register operand!");
454 void addImmOperands(MCInst &Inst,
unsigned N)
const {
455 assert(
N == 1 &&
"Invalid number of operands!");
456 const MCExpr *Expr =
getImm();
460 void addZeroOperands(MCInst &Inst,
unsigned N)
const {
461 addImmOperands(Inst,
N);
464 void addUImm0to2Operands(MCInst &Inst,
unsigned N)
const {
465 addImmOperands(Inst,
N);
468 void addUImm1Operands(MCInst &Inst,
unsigned N)
const {
469 addImmOperands(Inst,
N);
472 void addUImm2Operands(MCInst &Inst,
unsigned N)
const {
473 addImmOperands(Inst,
N);
476 void addUImm3Operands(MCInst &Inst,
unsigned N)
const {
477 addImmOperands(Inst,
N);
480 void addUImm4Operands(MCInst &Inst,
unsigned N)
const {
481 addImmOperands(Inst,
N);
484 void addUImm6Operands(MCInst &Inst,
unsigned N)
const {
485 addImmOperands(Inst,
N);
488 void addUImm7Operands(MCInst &Inst,
unsigned N)
const {
489 addImmOperands(Inst,
N);
492 void addSImm7Operands(MCInst &Inst,
unsigned N)
const {
493 addImmOperands(Inst,
N);
496 void addExpr(MCInst &Inst,
const MCExpr *Expr)
const {
506 void addMEMrriOperands(MCInst &Inst,
unsigned N)
const {
507 assert(
N == 3 &&
"Invalid number of operands!");
511 addExpr(Inst, getMemOffset());
514 void addMEMriiOperands(MCInst &Inst,
unsigned N)
const {
515 assert(
N == 3 &&
"Invalid number of operands!");
518 addExpr(Inst, getMemIndex());
519 addExpr(Inst, getMemOffset());
522 void addMEMzriOperands(MCInst &Inst,
unsigned N)
const {
523 assert(
N == 3 &&
"Invalid number of operands!");
527 addExpr(Inst, getMemOffset());
530 void addMEMziiOperands(MCInst &Inst,
unsigned N)
const {
531 assert(
N == 3 &&
"Invalid number of operands!");
534 addExpr(Inst, getMemIndex());
535 addExpr(Inst, getMemOffset());
538 void addMEMriOperands(MCInst &Inst,
unsigned N)
const {
539 assert(
N == 2 &&
"Invalid number of operands!");
542 addExpr(Inst, getMemOffset());
545 void addMEMziOperands(MCInst &Inst,
unsigned N)
const {
546 assert(
N == 2 &&
"Invalid number of operands!");
549 addExpr(Inst, getMemOffset());
552 void addCCOpOperands(MCInst &Inst,
unsigned N)
const {
553 assert(
N == 1 &&
"Invalid number of operands!");
558 void addRDOpOperands(MCInst &Inst,
unsigned N)
const {
559 assert(
N == 1 &&
"Invalid number of operands!");
564 void addMImmOperands(MCInst &Inst,
unsigned N)
const {
565 assert(
N == 1 &&
"Invalid number of operands!");
567 assert(ConstExpr &&
"Null operands!");
568 int64_t
Value = ConstExpr->getValue();
574 static std::unique_ptr<VEOperand> CreateToken(StringRef Str, SMLoc S) {
575 auto Op = std::make_unique<VEOperand>(k_Token);
576 Op->Tok.Data = Str.data();
577 Op->Tok.Length = Str.size();
583 static std::unique_ptr<VEOperand> CreateReg(MCRegister
Reg, SMLoc S,
585 auto Op = std::make_unique<VEOperand>(k_Register);
592 static std::unique_ptr<VEOperand> CreateImm(
const MCExpr *Val, SMLoc S,
594 auto Op = std::make_unique<VEOperand>(k_Immediate);
601 static std::unique_ptr<VEOperand> CreateCCOp(
unsigned CCVal, SMLoc S,
603 auto Op = std::make_unique<VEOperand>(k_CCOp);
604 Op->CC.CCVal = CCVal;
610 static std::unique_ptr<VEOperand> CreateRDOp(
unsigned RDVal, SMLoc S,
612 auto Op = std::make_unique<VEOperand>(k_RDOp);
613 Op->RD.RDVal = RDVal;
619 static std::unique_ptr<VEOperand> CreateMImm(
const MCExpr *Val,
bool Flag,
621 auto Op = std::make_unique<VEOperand>(k_MImmOp);
629 MCRegister getMISCReg()
const {
633 return VE::NoRegister;
634 uint64_t regIdx = ConstExpr->getValue();
636 return VE::NoRegister;
640 static std::unique_ptr<VEOperand>
641 MorphToMEMri(MCRegister
Base, std::unique_ptr<VEOperand>
Op) {
642 const MCExpr *
Imm =
Op->getImm();
643 Op->Kind = k_MemoryRegImm;
645 Op->Mem.IndexReg = MCRegister();
646 Op->Mem.Index =
nullptr;
647 Op->Mem.Offset =
Imm;
651 static std::unique_ptr<VEOperand>
652 MorphToMEMzi(std::unique_ptr<VEOperand>
Op) {
653 const MCExpr *
Imm =
Op->getImm();
654 Op->Kind = k_MemoryZeroImm;
655 Op->Mem.Base = MCRegister();
656 Op->Mem.IndexReg = MCRegister();
657 Op->Mem.Index =
nullptr;
658 Op->Mem.Offset =
Imm;
662 static std::unique_ptr<VEOperand>
663 MorphToMEMrri(MCRegister
Base, MCRegister Index,
664 std::unique_ptr<VEOperand>
Op) {
665 const MCExpr *
Imm =
Op->getImm();
666 Op->Kind = k_MemoryRegRegImm;
669 Op->Mem.Index =
nullptr;
670 Op->Mem.Offset =
Imm;
674 static std::unique_ptr<VEOperand>
675 MorphToMEMrii(MCRegister
Base,
const MCExpr *Index,
676 std::unique_ptr<VEOperand>
Op) {
677 const MCExpr *
Imm =
Op->getImm();
678 Op->Kind = k_MemoryRegImmImm;
680 Op->Mem.IndexReg = MCRegister();
682 Op->Mem.Offset =
Imm;
686 static std::unique_ptr<VEOperand>
687 MorphToMEMzri(MCRegister Index, std::unique_ptr<VEOperand>
Op) {
688 const MCExpr *
Imm =
Op->getImm();
689 Op->Kind = k_MemoryZeroRegImm;
690 Op->Mem.Base = MCRegister();
692 Op->Mem.Index =
nullptr;
693 Op->Mem.Offset =
Imm;
697 static std::unique_ptr<VEOperand>
698 MorphToMEMzii(
const MCExpr *Index, std::unique_ptr<VEOperand>
Op) {
699 const MCExpr *
Imm =
Op->getImm();
700 Op->Kind = k_MemoryZeroImmImm;
701 Op->Mem.Base = MCRegister();
702 Op->Mem.IndexReg = MCRegister();
704 Op->Mem.Offset =
Imm;
711bool VEAsmParser::matchAndEmitInstruction(
SMLoc IDLoc,
unsigned &Opcode,
714 bool MatchingInlineAsm) {
716 unsigned MatchResult =
717 MatchInstructionImpl(
Operands, Inst, ErrorInfo, MatchingInlineAsm);
718 switch (MatchResult) {
721 Out.emitInstruction(Inst, getSTI());
724 case Match_MissingFeature:
726 "instruction requires a CPU feature not currently enabled");
728 case Match_InvalidOperand: {
729 SMLoc ErrorLoc = IDLoc;
730 if (ErrorInfo != ~0ULL) {
732 return Error(IDLoc,
"too few operands for instruction");
734 ErrorLoc = ((VEOperand &)*
Operands[ErrorInfo]).getStartLoc();
735 if (ErrorLoc == SMLoc())
739 return Error(ErrorLoc,
"invalid operand for instruction");
741 case Match_MnemonicFail:
742 return Error(IDLoc,
"invalid instruction mnemonic");
747bool VEAsmParser::parseRegister(MCRegister &
Reg, SMLoc &StartLoc,
749 if (!tryParseRegister(
Reg, StartLoc, EndLoc).isSuccess())
750 return Error(StartLoc,
"invalid register name");
756MCRegister VEAsmParser::parseRegisterName(MCRegister (*matchFn)(StringRef)) {
759 MCRegister RegNum = matchFn(Name);
764 RegNum = matchFn(
Name.lower());
783 Reg = VE::NoRegister;
789 if (
Reg == VE::NoRegister)
792 if (
Reg != VE::NoRegister) {
797 getLexer().UnLex(Tok);
802 bool IntegerCC,
bool OmitCC,
SMLoc NameLoc,
813 StringRef SuffixStr = Name.substr(Suffix);
815 Name = Name.slice(0, Prefix);
816 Operands->push_back(VEOperand::CreateToken(Name, NameLoc));
820 Operands->push_back(VEOperand::CreateCCOp(CondCode, CondLoc, SuffixLoc));
822 if (!SuffixStr.
empty())
823 Operands->push_back(VEOperand::CreateToken(SuffixStr, SuffixLoc));
825 Operands->push_back(VEOperand::CreateToken(Name, NameLoc));
838 Name = Name.slice(0, Prefix);
840 Operands->push_back(VEOperand::CreateToken(Name, NameLoc));
849 Operands->push_back(VEOperand::CreateToken(Name, NameLoc));
856StringRef VEAsmParser::splitMnemonic(StringRef Name, SMLoc NameLoc,
859 StringRef Mnemonic =
Name;
861 if (Name[0] ==
'b') {
866 if (
Name.size() > 1 && Name[1] ==
'r')
871 (Name[
Next + 1] ==
'd' || Name[
Next + 1] ==
's'))
874 }
else if (
Name.starts_with(
"cmov.l.") ||
Name.starts_with(
"cmov.w.") ||
875 Name.starts_with(
"cmov.d.") ||
Name.starts_with(
"cmov.s.")) {
876 bool ICC =
Name[5] ==
'l' ||
Name[5] ==
'w';
878 }
else if (
Name.starts_with(
"cvt.w.d.sx") ||
Name.starts_with(
"cvt.w.d.zx") ||
879 Name.starts_with(
"cvt.w.s.sx") ||
Name.starts_with(
"cvt.w.s.zx")) {
881 }
else if (
Name.starts_with(
"cvt.l.d")) {
883 }
else if (
Name.starts_with(
"vcvt.w.d.sx") ||
884 Name.starts_with(
"vcvt.w.d.zx") ||
885 Name.starts_with(
"vcvt.w.s.sx") ||
886 Name.starts_with(
"vcvt.w.s.zx")) {
888 }
else if (
Name.starts_with(
"vcvt.l.d")) {
890 }
else if (
Name.starts_with(
"pvcvt.w.s.lo") ||
891 Name.starts_with(
"pvcvt.w.s.up")) {
893 }
else if (
Name.starts_with(
"pvcvt.w.s")) {
895 }
else if (
Name.starts_with(
"vfmk.l.") ||
Name.starts_with(
"vfmk.w.") ||
896 Name.starts_with(
"vfmk.d.") ||
Name.starts_with(
"vfmk.s.")) {
897 bool ICC =
Name[5] ==
'l' ||
Name[5] ==
'w' ?
true :
false;
899 }
else if (
Name.starts_with(
"pvfmk.w.lo.") ||
900 Name.starts_with(
"pvfmk.w.up.") ||
901 Name.starts_with(
"pvfmk.s.lo.") ||
902 Name.starts_with(
"pvfmk.s.up.")) {
903 bool ICC =
Name[6] ==
'l' ||
Name[6] ==
'w' ?
true :
false;
906 Operands->push_back(VEOperand::CreateToken(Mnemonic, NameLoc));
929 if (!parseOperand(
Operands, Mnemonic).isSuccess()) {
931 return Error(
Loc,
"unexpected token");
937 if (!parseOperand(
Operands, Mnemonic).isSuccess()) {
938 SMLoc Loc = getLexer().getLoc();
939 return Error(Loc,
"unexpected token");
944 SMLoc Loc = getLexer().getLoc();
945 return Error(Loc,
"unexpected token");
951ParseStatus VEAsmParser::parseDirective(AsmToken DirectiveID) {
959 if (IDVal ==
".word")
960 return parseLiteralValues(4, DirectiveID.
getLoc());
963 if (IDVal ==
".long")
964 return parseLiteralValues(8, DirectiveID.
getLoc());
967 if (IDVal ==
".llong")
968 return parseLiteralValues(8, DirectiveID.
getLoc());
978bool VEAsmParser::parseLiteralValues(
unsigned Size, SMLoc L) {
979 auto parseOne = [&]() ->
bool {
981 if (getParser().parseExpression(
Value))
983 getParser().getStreamer().emitValue(
Value,
Size, L);
986 return (parseMany(parseOne));
995const MCExpr *VEAsmParser::extractSpecifier(
const MCExpr *
E,
997 MCContext &
Context = getParser().getContext();
1000 switch (
E->getKind()) {
1066 const MCExpr *
Sub = extractSpecifier(UE->
getSubExpr(), Variant);
1075 const MCExpr *
LHS = extractSpecifier(BE->
getLHS(), LHSVariant);
1076 const MCExpr *
RHS = extractSpecifier(BE->
getRHS(), RHSVariant);
1090 else if (LHSVariant == RHSVariant)
1104bool VEAsmParser::parseExpression(
const MCExpr *&EVal) {
1106 if (getParser().parseExpression(EVal))
1111 const MCExpr *
E = extractSpecifier(EVal, Specifier);
1120 const AsmToken &Tok = Parser.
getTok();
1132 std::unique_ptr<VEOperand>
Offset;
1133 switch (getLexer().getKind()) {
1142 if (!parseExpression(EVal))
1143 Offset = VEOperand::CreateImm(EVal, S,
E);
1156 switch (getLexer().getKind()) {
1161 Operands.push_back(VEOperand::MorphToMEMzii(
1170 const MCExpr *IndexValue =
nullptr;
1171 MCRegister IndexReg;
1173 switch (getLexer().getKind()) {
1175 if (parseRegister(IndexReg, S,
E))
1182 if (getParser().parseExpression(IndexValue,
E))
1192 switch (getLexer().getKind()) {
1199 IndexValue ? VEOperand::MorphToMEMzii(IndexValue, std::move(
Offset))
1200 : VEOperand::MorphToMEMzri(IndexReg, std::move(
Offset)));
1209 if (parseRegister(BaseReg, S,
E))
1218 ? VEOperand::MorphToMEMrii(BaseReg, IndexValue, std::move(
Offset))
1219 : VEOperand::MorphToMEMrri(BaseReg, IndexReg, std::move(
Offset)));
1226 const AsmToken &Tok = Parser.
getTok();
1239 std::unique_ptr<VEOperand>
Offset;
1240 switch (getLexer().getKind()) {
1249 if (!parseExpression(EVal))
1250 Offset = VEOperand::CreateImm(EVal, S,
E);
1257 if (parseRegister(BaseReg, S,
E))
1270 switch (getLexer().getKind()) {
1276 Operands.push_back(BaseReg != VE::NoRegister
1277 ? VEOperand::MorphToMEMri(BaseReg, std::move(
Offset))
1278 : VEOperand::MorphToMEMzi(std::move(
Offset)));
1282 if (BaseReg != VE::NoRegister)
1288 switch (getLexer().getKind()) {
1290 if (parseRegister(BaseReg, S,
E))
1296 if (parseRegister(BaseReg, S,
E))
1308 Operands.push_back(BaseReg != VE::NoRegister
1309 ? VEOperand::MorphToMEMri(BaseReg, std::move(
Offset))
1310 : VEOperand::MorphToMEMzi(std::move(
Offset)));
1319 const AsmToken Tok1 = Parser.
getTok();
1325 const AsmToken Tok2 = Parser.
getTok();
1329 getLexer().UnLex(Tok1);
1333 const AsmToken Tok3 = Parser.
getTok();
1335 getLexer().UnLex(Tok2);
1336 getLexer().UnLex(Tok1);
1341 const AsmToken &Tok4 = Parser.
getTok();
1343 if (Suffix !=
"1" && Suffix !=
"0") {
1344 getLexer().UnLex(Tok3);
1345 getLexer().UnLex(Tok2);
1346 getLexer().UnLex(Tok1);
1352 VEOperand::CreateMImm(EVal, Suffix ==
"0", Tok1.
getLoc(), EndLoc));
1357 StringRef Mnemonic) {
1359 ParseStatus Res = MatchOperandParserImpl(
Operands, Mnemonic);
1367 switch (getLexer().getKind()) {
1370 const AsmToken Tok1 = Parser.
getTok();
1375 if (!tryParseRegister(Reg1,
S1, E1).isSuccess()) {
1376 getLexer().UnLex(Tok1);
1386 if (!tryParseRegister(Reg2, S2, E2).isSuccess())
1393 Operands.push_back(VEOperand::CreateReg(Reg1,
S1, E1));
1394 Operands.push_back(VEOperand::CreateReg(Reg2, S2, E2));
1401 std::unique_ptr<VEOperand>
Op;
1402 Res = parseVEAsmOperand(
Op);
1413 std::unique_ptr<VEOperand> Op1 = VEOperand::CreateToken(
1417 std::unique_ptr<VEOperand> Op2;
1418 Res = parseVEAsmOperand(Op2);
1425 Operands.push_back(std::move(Op1));
1426 Operands.push_back(std::move(Op2));
1437ParseStatus VEAsmParser::parseVEAsmOperand(std::unique_ptr<VEOperand> &
Op) {
1444 switch (getLexer().getKind()) {
1450 if (tryParseRegister(
Reg, S,
E).isSuccess())
1451 Op = VEOperand::CreateReg(
Reg, S,
E);
1458 if (!parseExpression(EVal))
1459 Op = VEOperand::CreateImm(EVal, S,
E);
1470#define GET_REGISTER_MATCHER
1471#define GET_MATCHER_IMPLEMENTATION
1472#include "VEGenAsmMatcher.inc"
1476 const VEOperand &
Op =
static_cast<const VEOperand &
>(GOp);
1478 if (Kind == MCK_MISC &&
Op.isImm() &&
Op.getMISCReg())
1480 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)
SmallVector< MachineOperand, 4 > Cond
static MCRegister getReg(const MCDisassembler *D, unsigned RC, unsigned RegNo)
static bool isReg(const MCInst &MI, unsigned OpNo)
static bool isUImm2(const MachineOperand &MO)
Func getContext().diagnose(DiagnosticInfoUnsupported(Func
This file defines the SmallVector class.
static const MCPhysReg MISCRegs[31]
static StringRef parseCC(StringRef Name, unsigned Prefix, unsigned Suffix, bool IntegerCC, bool OmitCC, SMLoc NameLoc, OperandVector *Operands)
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 and target specific virtual registers.
constexpr unsigned id() const
static const MCSpecifierExpr * create(const MCExpr *Expr, Spec S, MCContext &Ctx, SMLoc Loc=SMLoc())
Streaming machine code generation interface.
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,...