40 static bool inRange(
const MCExpr *Expr, int64_t MinValue, int64_t MaxValue) {
41 if (
auto *CE = dyn_cast<MCConstantExpr>(Expr)) {
42 int64_t
Value = CE->getValue();
43 return Value >= MinValue && Value <= MaxValue;
87 SMLoc StartLoc, EndLoc;
116 unsigned MemKind : 4;
117 unsigned RegKind : 4;
144 else if (
auto *CE = dyn_cast<MCConstantExpr>(Expr))
151 SystemZOperand(OperandKind kind,
SMLoc startLoc,
SMLoc endLoc)
152 :
Kind(kind), StartLoc(startLoc), EndLoc(endLoc) {}
155 static std::unique_ptr<SystemZOperand> createInvalid(
SMLoc StartLoc,
157 return make_unique<SystemZOperand>(KindInvalid, StartLoc, EndLoc);
160 static std::unique_ptr<SystemZOperand> createToken(
StringRef Str,
SMLoc Loc) {
161 auto Op = make_unique<SystemZOperand>(KindToken, Loc, Loc);
162 Op->Token.Data = Str.
data();
163 Op->Token.Length = Str.
size();
167 static std::unique_ptr<SystemZOperand>
169 auto Op = make_unique<SystemZOperand>(KindReg, StartLoc, EndLoc);
175 static std::unique_ptr<SystemZOperand>
177 auto Op = make_unique<SystemZOperand>(KindImm, StartLoc, EndLoc);
182 static std::unique_ptr<SystemZOperand>
184 const MCExpr *Disp,
unsigned Index,
const MCExpr *LengthImm,
185 unsigned LengthReg,
SMLoc StartLoc,
SMLoc EndLoc) {
186 auto Op = make_unique<SystemZOperand>(KindMem, StartLoc, EndLoc);
187 Op->Mem.MemKind = MemKind;
188 Op->Mem.RegKind = RegKind;
190 Op->Mem.Index = Index;
192 if (MemKind == BDLMem)
193 Op->Mem.Length.Imm = LengthImm;
194 if (MemKind == BDRMem)
195 Op->Mem.Length.Reg = LengthReg;
199 static std::unique_ptr<SystemZOperand>
202 auto Op = make_unique<SystemZOperand>(KindImmTLS, StartLoc, EndLoc);
203 Op->ImmTLS.Imm = Imm;
204 Op->ImmTLS.Sym = Sym;
209 bool isToken()
const override {
210 return Kind == KindToken;
214 return StringRef(Token.Data, Token.Length);
218 bool isReg()
const override {
219 return Kind == KindReg;
222 return Kind == KindReg &&
Reg.Kind == RegKind;
224 unsigned getReg()
const override {
230 bool isImm()
const override {
231 return Kind == KindImm;
233 bool isImm(int64_t MinValue, int64_t MaxValue)
const {
234 return Kind == KindImm &&
inRange(Imm, MinValue, MaxValue);
236 const MCExpr *getImm()
const {
237 assert(
Kind == KindImm &&
"Not an immediate");
242 bool isImmTLS()
const {
243 return Kind == KindImmTLS;
247 bool isMem()
const override {
248 return Kind == KindMem;
251 return (
Kind == KindMem &&
252 (Mem.MemKind == MemKind ||
255 (Mem.MemKind == BDMem && MemKind == BDXMem)));
258 return isMem(MemKind) && Mem.RegKind == RegKind;
261 return isMem(MemKind, RegKind) &&
inRange(Mem.Disp, 0, 0xfff);
264 return isMem(MemKind, RegKind) &&
inRange(Mem.Disp, -524288, 524287);
267 return isMemDisp12(BDLMem, RegKind) &&
inRange(Mem.Length.Imm, 1, 0x10);
270 return isMemDisp12(BDLMem, RegKind) &&
inRange(Mem.Length.Imm, 1, 0x100);
274 SMLoc getStartLoc()
const override {
return StartLoc; }
275 SMLoc getEndLoc()
const override {
return EndLoc; }
284 void addRegOperands(
MCInst &Inst,
unsigned N)
const {
285 assert(N == 1 &&
"Invalid number of operands");
288 void addImmOperands(
MCInst &Inst,
unsigned N)
const {
289 assert(N == 1 &&
"Invalid number of operands");
290 addExpr(Inst, getImm());
292 void addBDAddrOperands(
MCInst &Inst,
unsigned N)
const {
293 assert(N == 2 &&
"Invalid number of operands");
296 addExpr(Inst, Mem.Disp);
298 void addBDXAddrOperands(
MCInst &Inst,
unsigned N)
const {
299 assert(N == 3 &&
"Invalid number of operands");
302 addExpr(Inst, Mem.Disp);
305 void addBDLAddrOperands(
MCInst &Inst,
unsigned N)
const {
306 assert(N == 3 &&
"Invalid number of operands");
309 addExpr(Inst, Mem.Disp);
310 addExpr(Inst, Mem.Length.Imm);
312 void addBDRAddrOperands(
MCInst &Inst,
unsigned N)
const {
313 assert(N == 3 &&
"Invalid number of operands");
316 addExpr(Inst, Mem.Disp);
319 void addBDVAddrOperands(
MCInst &Inst,
unsigned N)
const {
320 assert(N == 3 &&
"Invalid number of operands");
323 addExpr(Inst, Mem.Disp);
326 void addImmTLSOperands(
MCInst &Inst,
unsigned N)
const {
327 assert(N == 2 &&
"Invalid number of operands");
328 assert(
Kind == KindImmTLS &&
"Invalid operand type");
329 addExpr(Inst, ImmTLS.Imm);
331 addExpr(Inst, ImmTLS.Sym);
335 bool isGR32()
const {
return isReg(GR32Reg); }
336 bool isGRH32()
const {
return isReg(GRH32Reg); }
337 bool isGRX32()
const {
return false; }
338 bool isGR64()
const {
return isReg(GR64Reg); }
339 bool isGR128()
const {
return isReg(GR128Reg); }
340 bool isADDR32()
const {
return isReg(ADDR32Reg); }
341 bool isADDR64()
const {
return isReg(ADDR64Reg); }
342 bool isADDR128()
const {
return false; }
343 bool isFP32()
const {
return isReg(FP32Reg); }
344 bool isFP64()
const {
return isReg(FP64Reg); }
345 bool isFP128()
const {
return isReg(FP128Reg); }
346 bool isVR32()
const {
return isReg(VR32Reg); }
347 bool isVR64()
const {
return isReg(VR64Reg); }
348 bool isVF128()
const {
return false; }
349 bool isVR128()
const {
return isReg(VR128Reg); }
350 bool isAR32()
const {
return isReg(AR32Reg); }
351 bool isCR64()
const {
return isReg(CR64Reg); }
352 bool isAnyReg()
const {
return (
isReg() || isImm(0, 15)); }
353 bool isBDAddr32Disp12()
const {
return isMemDisp12(BDMem, ADDR32Reg); }
354 bool isBDAddr32Disp20()
const {
return isMemDisp20(BDMem, ADDR32Reg); }
355 bool isBDAddr64Disp12()
const {
return isMemDisp12(BDMem, ADDR64Reg); }
356 bool isBDAddr64Disp20()
const {
return isMemDisp20(BDMem, ADDR64Reg); }
357 bool isBDXAddr64Disp12()
const {
return isMemDisp12(BDXMem, ADDR64Reg); }
358 bool isBDXAddr64Disp20()
const {
return isMemDisp20(BDXMem, ADDR64Reg); }
359 bool isBDLAddr64Disp12Len4()
const {
return isMemDisp12Len4(ADDR64Reg); }
360 bool isBDLAddr64Disp12Len8()
const {
return isMemDisp12Len8(ADDR64Reg); }
361 bool isBDRAddr64Disp12()
const {
return isMemDisp12(BDRMem, ADDR64Reg); }
362 bool isBDVAddr64Disp12()
const {
return isMemDisp12(BDVMem, ADDR64Reg); }
363 bool isU1Imm()
const {
return isImm(0, 1); }
364 bool isU2Imm()
const {
return isImm(0, 3); }
365 bool isU3Imm()
const {
return isImm(0, 7); }
366 bool isU4Imm()
const {
return isImm(0, 15); }
367 bool isU6Imm()
const {
return isImm(0, 63); }
368 bool isU8Imm()
const {
return isImm(0, 255); }
369 bool isS8Imm()
const {
return isImm(-128, 127); }
370 bool isU12Imm()
const {
return isImm(0, 4095); }
371 bool isU16Imm()
const {
return isImm(0, 65535); }
372 bool isS16Imm()
const {
return isImm(-32768, 32767); }
373 bool isU32Imm()
const {
return isImm(0, (1LL << 32) - 1); }
374 bool isS32Imm()
const {
return isImm(-(1LL << 31), (1LL << 31) - 1); }
375 bool isU48Imm()
const {
return isImm(0, (1LL << 48) - 1); }
379 #define GET_ASSEMBLER_HEADER
380 #include "SystemZGenAsmMatcher.inc"
394 SMLoc StartLoc, EndLoc;
399 bool parseRegister(
Register &
Reg, RegisterGroup Group,
const unsigned *
Regs,
400 bool IsAddress =
false);
403 RegisterGroup Group,
const unsigned *
Regs,
408 bool parseAddress(
bool &HaveReg1,
Register &Reg1,
413 bool ParseDirectiveInsn(
SMLoc L);
420 int64_t MaxVal,
bool AllowTLS);
435 setAvailableFeatures(ComputeAvailableFeatures(getSTI().getFeatureBits()));
439 bool ParseDirective(
AsmToken DirectiveID)
override;
440 bool ParseRegister(
unsigned &RegNo,
SMLoc &StartLoc,
SMLoc &EndLoc)
override;
443 bool MatchAndEmitInstruction(
SMLoc IDLoc,
unsigned &Opcode,
446 bool MatchingInlineAsm)
override;
501 return parseAnyRegister(Operands);
522 return parsePCRel(Operands, -(1LL << 12), (1LL << 12) - 1,
false);
525 return parsePCRel(Operands, -(1LL << 16), (1LL << 16) - 1,
false);
528 return parsePCRel(Operands, -(1LL << 24), (1LL << 24) - 1,
false);
531 return parsePCRel(Operands, -(1LL << 32), (1LL << 32) - 1,
false);
534 return parsePCRel(Operands, -(1LL << 16), (1LL << 16) - 1,
true);
537 return parsePCRel(Operands, -(1LL << 32), (1LL << 32) - 1,
true);
543 #define GET_REGISTER_MATCHER
544 #define GET_SUBTARGET_FEATURE_NAME
545 #define GET_MATCHER_IMPLEMENTATION
546 #include "SystemZGenAsmMatcher.inc"
554 MatchClassKind OperandKinds[5];
573 {
"e", SystemZ::InsnE, 1,
575 {
"ri", SystemZ::InsnRI, 3,
576 { MCK_U32Imm, MCK_AnyReg, MCK_S16Imm } },
577 {
"rie", SystemZ::InsnRIE, 4,
578 { MCK_U48Imm, MCK_AnyReg, MCK_AnyReg, MCK_PCRel16 } },
579 {
"ril", SystemZ::InsnRIL, 3,
580 { MCK_U48Imm, MCK_AnyReg, MCK_PCRel32 } },
581 {
"rilu", SystemZ::InsnRILU, 3,
582 { MCK_U48Imm, MCK_AnyReg, MCK_U32Imm } },
583 {
"ris", SystemZ::InsnRIS, 5,
584 { MCK_U48Imm, MCK_AnyReg, MCK_S8Imm, MCK_U4Imm, MCK_BDAddr64Disp12 } },
585 {
"rr", SystemZ::InsnRR, 3,
586 { MCK_U16Imm, MCK_AnyReg, MCK_AnyReg } },
587 {
"rre", SystemZ::InsnRRE, 3,
588 { MCK_U32Imm, MCK_AnyReg, MCK_AnyReg } },
589 {
"rrf", SystemZ::InsnRRF, 5,
590 { MCK_U32Imm, MCK_AnyReg, MCK_AnyReg, MCK_AnyReg, MCK_U4Imm } },
591 {
"rrs", SystemZ::InsnRRS, 5,
592 { MCK_U48Imm, MCK_AnyReg, MCK_AnyReg, MCK_U4Imm, MCK_BDAddr64Disp12 } },
593 {
"rs", SystemZ::InsnRS, 4,
594 { MCK_U32Imm, MCK_AnyReg, MCK_AnyReg, MCK_BDAddr64Disp12 } },
595 {
"rse", SystemZ::InsnRSE, 4,
596 { MCK_U48Imm, MCK_AnyReg, MCK_AnyReg, MCK_BDAddr64Disp12 } },
597 {
"rsi", SystemZ::InsnRSI, 4,
598 { MCK_U48Imm, MCK_AnyReg, MCK_AnyReg, MCK_PCRel16 } },
599 {
"rsy", SystemZ::InsnRSY, 4,
600 { MCK_U48Imm, MCK_AnyReg, MCK_AnyReg, MCK_BDAddr64Disp20 } },
601 {
"rx", SystemZ::InsnRX, 3,
602 { MCK_U32Imm, MCK_AnyReg, MCK_BDXAddr64Disp12 } },
603 {
"rxe", SystemZ::InsnRXE, 3,
604 { MCK_U48Imm, MCK_AnyReg, MCK_BDXAddr64Disp12 } },
605 {
"rxf", SystemZ::InsnRXF, 4,
606 { MCK_U48Imm, MCK_AnyReg, MCK_AnyReg, MCK_BDXAddr64Disp12 } },
607 {
"rxy", SystemZ::InsnRXY, 3,
608 { MCK_U48Imm, MCK_AnyReg, MCK_BDXAddr64Disp20 } },
609 {
"s", SystemZ::InsnS, 2,
610 { MCK_U32Imm, MCK_BDAddr64Disp12 } },
611 {
"si", SystemZ::InsnSI, 3,
612 { MCK_U32Imm, MCK_BDAddr64Disp12, MCK_S8Imm } },
613 {
"sil", SystemZ::InsnSIL, 3,
614 { MCK_U48Imm, MCK_BDAddr64Disp12, MCK_U16Imm } },
615 {
"siy", SystemZ::InsnSIY, 3,
616 { MCK_U48Imm, MCK_BDAddr64Disp20, MCK_U8Imm } },
617 {
"ss", SystemZ::InsnSS, 4,
618 { MCK_U48Imm, MCK_BDXAddr64Disp12, MCK_BDAddr64Disp12, MCK_AnyReg } },
619 {
"sse", SystemZ::InsnSSE, 3,
620 { MCK_U48Imm, MCK_BDAddr64Disp12, MCK_BDAddr64Disp12 } },
621 {
"ssf", SystemZ::InsnSSF, 4,
622 { MCK_U48Imm, MCK_BDAddr64Disp12, MCK_BDAddr64Disp12, MCK_AnyReg } }
625 void SystemZOperand::print(
raw_ostream &OS)
const {
630 bool SystemZAsmParser::parseRegister(
Register &
Reg) {
631 Reg.StartLoc = Parser.getTok().getLoc();
635 return Error(Parser.getTok().getLoc(),
"register expected");
640 return Error(Reg.StartLoc,
"invalid register");
645 return Error(Reg.StartLoc,
"invalid register");
650 return Error(Reg.StartLoc,
"invalid register");
653 if (Prefix ==
'r' && Reg.Num < 16)
655 else if (Prefix ==
'f' && Reg.Num < 16)
657 else if (Prefix ==
'v' && Reg.Num < 32)
659 else if (Prefix ==
'a' && Reg.Num < 16)
661 else if (Prefix ==
'c' && Reg.Num < 16)
664 return Error(Reg.StartLoc,
"invalid register");
666 Reg.EndLoc = Parser.getTok().getLoc();
677 bool SystemZAsmParser::parseRegister(
Register &Reg, RegisterGroup Group,
678 const unsigned *
Regs,
bool IsAddress) {
679 if (parseRegister(Reg))
681 if (Reg.Group != Group && !(Reg.Group == RegFP && Group == RegV))
682 return Error(Reg.StartLoc,
"invalid operand for instruction");
683 if (Regs && Regs[Reg.Num] == 0)
684 return Error(Reg.StartLoc,
"invalid register pair");
685 if (Reg.Num == 0 && IsAddress)
686 return Error(Reg.StartLoc,
"%r0 used in an address");
688 Reg.Num = Regs[Reg.Num];
694 SystemZAsmParser::parseRegister(
OperandVector &Operands, RegisterGroup Group,
700 bool IsAddress = (Kind == ADDR32Reg || Kind == ADDR64Reg);
701 if (parseRegister(Reg, Group, Regs, IsAddress))
704 Operands.
push_back(SystemZOperand::createReg(Kind, Reg.Num,
705 Reg.StartLoc, Reg.EndLoc));
711 SystemZAsmParser::parseAnyRegister(
OperandVector &Operands) {
715 SMLoc StartLoc = Parser.getTok().getLoc();
716 if (Parser.parseExpression(Register))
719 if (
auto *CE = dyn_cast<MCConstantExpr>(Register)) {
720 int64_t
Value =
CE->getValue();
722 Error(StartLoc,
"invalid register");
730 Operands.
push_back(SystemZOperand::createImm(Register, StartLoc, EndLoc));
734 if (parseRegister(Reg))
740 if (Reg.Group == RegGR) {
744 else if (Reg.Group == RegFP) {
748 else if (Reg.Group == RegV) {
752 else if (Reg.Group == RegAR) {
756 else if (Reg.Group == RegCR) {
764 Operands.
push_back(SystemZOperand::createReg(Kind, RegNo,
765 Reg.StartLoc, Reg.EndLoc));
771 bool SystemZAsmParser::parseAddress(
bool &HaveReg1, Register &Reg1,
772 bool &HaveReg2, Register &Reg2,
776 if (getParser().parseExpression(Disp))
789 if (parseRegister(Reg1))
793 if (getParser().parseExpression(Length))
801 if (parseRegister(Reg2))
807 return Error(Parser.getTok().getLoc(),
"unexpected token in address");
815 SystemZAsmParser::parseAddressRegister(Register &Reg) {
816 if (Reg.Group == RegV) {
817 Error(Reg.StartLoc,
"invalid use of vector addressing");
819 }
else if (Reg.Group != RegGR) {
820 Error(Reg.StartLoc,
"invalid address register");
822 }
else if (Reg.Num == 0) {
823 Error(Reg.StartLoc,
"%r0 used in an address");
834 SMLoc StartLoc = Parser.getTok().getLoc();
835 unsigned Base = 0, Index = 0, LengthReg = 0;
837 bool HaveReg1, HaveReg2;
840 if (parseAddress(HaveReg1, Reg1, HaveReg2, Reg2, Disp, Length))
847 if (parseAddressRegister(Reg1))
849 Base = Regs[Reg1.Num];
853 Error(StartLoc,
"invalid use of length addressing");
857 Error(StartLoc,
"invalid use of indexed addressing");
864 if (parseAddressRegister(Reg1))
869 Index = Regs[Reg1.Num];
871 Base = Regs[Reg1.Num];
875 if (parseAddressRegister(Reg2))
877 Base = Regs[Reg2.Num];
881 Error(StartLoc,
"invalid use of length addressing");
888 if (parseAddressRegister(Reg2))
890 Base = Regs[Reg2.Num];
893 if (HaveReg1 && HaveReg2) {
894 Error(StartLoc,
"invalid use of indexed addressing");
899 Error(StartLoc,
"missing length in address");
905 if (!HaveReg1 || Reg1.Group != RegGR) {
906 Error(StartLoc,
"invalid operand for instruction");
912 if (parseAddressRegister(Reg2))
914 Base = Regs[Reg2.Num];
918 Error(StartLoc,
"invalid use of length addressing");
924 if (!HaveReg1 || Reg1.Group != RegV) {
925 Error(StartLoc,
"vector index required in address");
931 if (parseAddressRegister(Reg2))
933 Base = Regs[Reg2.Num];
937 Error(StartLoc,
"invalid use of length addressing");
945 Operands.
push_back(SystemZOperand::createMem(MemKind, RegKind, Base, Disp,
946 Index, Length, LengthReg,
951 bool SystemZAsmParser::ParseDirective(
AsmToken DirectiveID) {
954 if (IDVal ==
".insn")
955 return ParseDirectiveInsn(DirectiveID.
getLoc());
962 bool SystemZAsmParser::ParseDirectiveInsn(
SMLoc L) {
969 return Error(ErrorLoc,
"expected instruction format");
979 if (EntryRange.first == EntryRange.second)
980 return Error(ErrorLoc,
"unrecognized format");
995 return Error(StartLoc,
"unexpected token in directive");
1000 if (Kind == MCK_AnyReg)
1001 ResTy = parseAnyReg(Operands);
1002 else if (Kind == MCK_BDXAddr64Disp12 || Kind == MCK_BDXAddr64Disp20)
1003 ResTy = parseBDXAddr64(Operands);
1004 else if (Kind == MCK_BDAddr64Disp12 || Kind == MCK_BDAddr64Disp20)
1005 ResTy = parseBDAddr64(Operands);
1006 else if (Kind == MCK_PCRel32)
1007 ResTy = parsePCRel32(Operands);
1008 else if (Kind == MCK_PCRel16)
1009 ResTy = parsePCRel16(Operands);
1017 return Error(StartLoc,
"unexpected token in directive");
1022 Operands.
push_back(SystemZOperand::createImm(Expr, StartLoc, EndLoc));
1033 for (
size_t i = 0; i < Operands.
size(); i++) {
1038 unsigned Res = validateOperandClass(Operand, Kind);
1039 if (Res != Match_Success)
1043 SystemZOperand &ZOperand =
static_cast<SystemZOperand &
>(Operand);
1044 if (ZOperand.isReg())
1045 ZOperand.addRegOperands(Inst, 1);
1046 else if (ZOperand.isMem(BDMem))
1047 ZOperand.addBDAddrOperands(Inst, 2);
1048 else if (ZOperand.isMem(BDXMem))
1049 ZOperand.addBDXAddrOperands(Inst, 3);
1050 else if (ZOperand.isImm())
1051 ZOperand.addImmOperands(Inst, 1);
1062 bool SystemZAsmParser::ParseRegister(
unsigned &RegNo,
SMLoc &StartLoc,
1065 if (parseRegister(Reg))
1067 if (Reg.Group == RegGR)
1069 else if (Reg.Group == RegFP)
1071 else if (Reg.Group == RegV)
1073 else if (Reg.Group == RegAR)
1075 else if (Reg.Group == RegCR)
1077 StartLoc = Reg.StartLoc;
1078 EndLoc = Reg.EndLoc;
1085 Operands.
push_back(SystemZOperand::createToken(Name, NameLoc));
1090 if (parseOperand(Operands, Name)) {
1097 if (parseOperand(Operands, Name)) {
1102 SMLoc Loc = getLexer().getLoc();
1103 return Error(Loc,
"unexpected token in argument list");
1112 bool SystemZAsmParser::parseOperand(
OperandVector &Operands,
1119 uint64_t AvailableFeatures = getAvailableFeatures();
1120 setAvailableFeatures(~(uint64_t)0);
1122 setAvailableFeatures(AvailableFeatures);
1138 if (parseRegister(Reg))
1140 Operands.
push_back(SystemZOperand::createInvalid(Reg.StartLoc, Reg.EndLoc));
1148 Register Reg1, Reg2;
1149 bool HaveReg1, HaveReg2;
1152 if (parseAddress(HaveReg1, Reg1, HaveReg2, Reg2, Expr, Length))
1156 if (HaveReg1 && Reg1.Group != RegGR && Reg1.Group != RegV
1157 && parseAddressRegister(Reg1))
1159 if (HaveReg2 && parseAddressRegister(Reg2))
1164 if (HaveReg1 || HaveReg2 || Length)
1165 Operands.
push_back(SystemZOperand::createInvalid(StartLoc, EndLoc));
1167 Operands.
push_back(SystemZOperand::createImm(Expr, StartLoc, EndLoc));
1173 bool SystemZAsmParser::MatchAndEmitInstruction(
SMLoc IDLoc,
unsigned &
Opcode,
1177 bool MatchingInlineAsm) {
1179 unsigned MatchResult;
1181 MatchResult = MatchInstructionImpl(Operands, Inst, ErrorInfo,
1183 switch (MatchResult) {
1189 case Match_MissingFeature: {
1190 assert(ErrorInfo &&
"Unknown missing feature!");
1193 std::string Msg =
"instruction requires:";
1195 for (
unsigned I = 0;
I <
sizeof(ErrorInfo) * 8 - 1; ++
I) {
1196 if (ErrorInfo & Mask) {
1202 return Error(IDLoc, Msg);
1205 case Match_InvalidOperand: {
1206 SMLoc ErrorLoc = IDLoc;
1207 if (ErrorInfo != ~0ULL) {
1208 if (ErrorInfo >= Operands.
size())
1209 return Error(IDLoc,
"too few operands for instruction");
1211 ErrorLoc = ((SystemZOperand &)*Operands[ErrorInfo]).getStartLoc();
1212 if (ErrorLoc ==
SMLoc())
1215 return Error(ErrorLoc,
"invalid operand for instruction");
1218 case Match_MnemonicFail: {
1219 uint64_t FBS = ComputeAvailableFeatures(getSTI().getFeatureBits());
1221 ((SystemZOperand &)*Operands[0]).
getToken(), FBS);
1222 return Error(IDLoc,
"invalid instruction" + Suggestion,
1223 ((SystemZOperand &)*Operands[0]).getLocRange());
1231 SystemZAsmParser::parsePCRel(
OperandVector &Operands, int64_t MinVal,
1232 int64_t MaxVal,
bool AllowTLS) {
1237 if (getParser().parseExpression(Expr))
1242 if (
auto *CE = dyn_cast<MCConstantExpr>(Expr)) {
1243 int64_t Value =
CE->getValue();
1245 Error(StartLoc,
"offset out of range");
1256 const MCExpr *Sym =
nullptr;
1267 if (Name ==
"tls_gdcall")
1269 else if (Name ==
"tls_ldcall")
1298 Operands.
push_back(SystemZOperand::createImmTLS(Expr, Sym,
1301 Operands.
push_back(SystemZOperand::createImm(Expr, StartLoc, EndLoc));
static bool isReg(const MCInst &MI, unsigned OpNo)
std::enable_if< std::numeric_limits< T >::is_signed, bool >::type getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
Represents a range in source code.
void push_back(const T &Elt)
const_iterator end(StringRef path)
Get end iterator over path.
const unsigned GR32Regs[16]
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
const char * getPointer() const
const unsigned FP128Regs[16]
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Generic assembler parser interface, for use by target specific assembly parsers.
virtual void Initialize(MCAsmParser &Parser)
Initialize the extension for parsing using the given Parser.
static MCOperand createExpr(const MCExpr *Val)
MCTargetAsmParser - Generic interface to target specific assembly parsers.
MatchClassKind OperandKinds[5]
StringRef getString() const
Get the string for the current token, this includes all characters (for example, the quotes on string...
virtual const AsmToken & Lex()=0
Get the next AsmToken in the stream, possibly handling file inclusion first.
bool isNot(TokenKind K) const
const unsigned FP32Regs[16]
static struct InsnMatchEntry InsnMatchTable[]
virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI, bool PrintSchedInfo=false)
Emit the given Instruction into the current section.
const unsigned VR64Regs[32]
static MCOperand createReg(unsigned Reg)
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 ...
const unsigned AR32Regs[16]
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Base class for the full range of assembler expressions which are needed for parsing.
Reg
All possible values of the reg field in the ModR/M byte.
Target independent representation for an assembler token.
Windows NT (Windows on ARM)
const unsigned GRH32Regs[16]
static bool isMem(const MachineInstr &MI, unsigned Op)
MCParsedAsmOperand - This abstract class represents a source-level assembly instruction operand...
virtual bool parseExpression(const MCExpr *&Res, SMLoc &EndLoc)=0
Parse an arbitrary expression.
Context object for machine code objects.
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
const AsmToken & getTok() const
Get the current AsmToken from the stream.
const unsigned CR64Regs[16]
Instances of this class represent a single low-level machine instruction.
virtual void addAliasForDirective(StringRef Directive, StringRef Alias)=0
Streaming machine code generation interface.
MCSymbol * createTempSymbol(bool CanBeUnnamed=true)
Create and return a new assembler temporary symbol with a unique but unspecified name.
static bool inRange(const MCExpr *Expr, int64_t MinValue, int64_t MaxValue)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Interface to description of machine instruction set.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
virtual MCStreamer & getStreamer()=0
Return the output streamer for the assembler.
void LLVMInitializeSystemZAsmParser()
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
const unsigned FP64Regs[16]
virtual SMLoc getStartLoc() const =0
getStartLoc - Get the location of the first token of this operand.
Promote Memory to Register
const unsigned GR128Regs[16]
bool is(TokenKind K) const
std::string SystemZMnemonicSpellCheck(StringRef S, uint64_t FBS)
const unsigned GR64Regs[16]
static unsigned getReg(const void *D, unsigned RC, unsigned RegNo)
Base class for user error types.
static SMLoc getFromPointer(const char *Ptr)
llvm_unreachable("Unknown RegBank!")
Target & getTheSystemZTarget()
StringRef getIdentifier() const
Get the identifier string for the current token, which should be an identifier or a string...
RegisterMCAsmParser - Helper template for registering a target specific assembly parser, for use in the target machine initialization function.
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
MCSubtargetInfo - Generic base class for all target subtargets.
const unsigned VR32Regs[32]
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
virtual void EmitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
This class implements an extremely fast bulk output stream that can only output to a stream...
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
void addOperand(const MCOperand &Op)
StringRef - Represent a constant reference to a string, i.e.
virtual bool parseIdentifier(StringRef &Res)=0
Parse an identifier or string (as a quoted identifier) and set Res to the identifier contents...
Represents a location in source code.
static const char * getSubtargetFeatureName(uint64_t Val)
static MCOperand createImm(int64_t Val)
const unsigned VR128Regs[32]