42 static const char OpPrecedence[] = {
64 std::unique_ptr<X86AsmInstrumentation> Instrumentation;
68 SMLoc consumeToken() {
76 uint64_t &
ErrorInfo,
bool matchingInlineAsm,
77 unsigned VariantID = 0) {
80 SwitchMode(X86::Mode32Bit);
81 unsigned rv = MatchInstructionImpl(Operands, Inst, ErrorInfo,
82 matchingInlineAsm, VariantID);
84 SwitchMode(X86::Mode16Bit);
88 enum InfixCalculatorTok {
107 enum IntelOperatorKind {
115 class InfixCalculator {
116 typedef std::pair< InfixCalculatorTok, int64_t > ICToken;
120 bool isUnaryOperator(
const InfixCalculatorTok
Op) {
121 return Op == IC_NEG || Op == IC_NOT;
125 int64_t popOperand() {
126 assert (!PostfixStack.empty() &&
"Poped an empty stack!");
127 ICToken
Op = PostfixStack.pop_back_val();
128 assert ((Op.first == IC_IMM || Op.first == IC_REGISTER)
129 &&
"Expected and immediate or register!");
132 void pushOperand(InfixCalculatorTok Op, int64_t Val = 0) {
133 assert ((Op == IC_IMM || Op == IC_REGISTER) &&
134 "Unexpected operand!");
135 PostfixStack.push_back(std::make_pair(Op, Val));
138 void popOperator() { InfixOperatorStack.pop_back(); }
139 void pushOperator(InfixCalculatorTok Op) {
141 if (InfixOperatorStack.empty()) {
142 InfixOperatorStack.push_back(Op);
149 unsigned Idx = InfixOperatorStack.size() - 1;
150 InfixCalculatorTok StackOp = InfixOperatorStack[Idx];
151 if (OpPrecedence[Op] > OpPrecedence[StackOp] || StackOp == IC_LPAREN) {
152 InfixOperatorStack.push_back(Op);
158 unsigned ParenCount = 0;
161 if (InfixOperatorStack.empty())
164 Idx = InfixOperatorStack.size() - 1;
165 StackOp = InfixOperatorStack[Idx];
166 if (!(OpPrecedence[StackOp] >= OpPrecedence[Op] || ParenCount))
171 if (!ParenCount && StackOp == IC_LPAREN)
174 if (StackOp == IC_RPAREN) {
176 InfixOperatorStack.pop_back();
177 }
else if (StackOp == IC_LPAREN) {
179 InfixOperatorStack.pop_back();
181 InfixOperatorStack.pop_back();
182 PostfixStack.push_back(std::make_pair(StackOp, 0));
186 InfixOperatorStack.push_back(Op);
191 while (!InfixOperatorStack.empty()) {
192 InfixCalculatorTok StackOp = InfixOperatorStack.pop_back_val();
193 if (StackOp != IC_LPAREN && StackOp != IC_RPAREN)
194 PostfixStack.push_back(std::make_pair(StackOp, 0));
197 if (PostfixStack.empty())
201 for (
unsigned i = 0, e = PostfixStack.size(); i != e; ++i) {
202 ICToken Op = PostfixStack[i];
203 if (Op.first == IC_IMM || Op.first == IC_REGISTER) {
205 }
else if (isUnaryOperator(Op.first)) {
206 assert (OperandStack.
size() > 0 &&
"Too few operands.");
208 assert (Operand.first == IC_IMM &&
209 "Unary operation with a register!");
215 OperandStack.
push_back(std::make_pair(IC_IMM, -Operand.second));
218 OperandStack.
push_back(std::make_pair(IC_IMM, ~Operand.second));
222 assert (OperandStack.
size() > 1 &&
"Too few operands.");
231 Val = Op1.second + Op2.second;
232 OperandStack.
push_back(std::make_pair(IC_IMM, Val));
235 Val = Op1.second - Op2.second;
236 OperandStack.
push_back(std::make_pair(IC_IMM, Val));
239 assert (Op1.first == IC_IMM && Op2.first == IC_IMM &&
240 "Multiply operation with an immediate and a register!");
241 Val = Op1.second * Op2.second;
242 OperandStack.
push_back(std::make_pair(IC_IMM, Val));
245 assert (Op1.first == IC_IMM && Op2.first == IC_IMM &&
246 "Divide operation with an immediate and a register!");
247 assert (Op2.second != 0 &&
"Division by zero!");
248 Val = Op1.second / Op2.second;
249 OperandStack.
push_back(std::make_pair(IC_IMM, Val));
252 assert (Op1.first == IC_IMM && Op2.first == IC_IMM &&
253 "Modulo operation with an immediate and a register!");
254 Val = Op1.second % Op2.second;
255 OperandStack.
push_back(std::make_pair(IC_IMM, Val));
258 assert (Op1.first == IC_IMM && Op2.first == IC_IMM &&
259 "Or operation with an immediate and a register!");
260 Val = Op1.second | Op2.second;
261 OperandStack.
push_back(std::make_pair(IC_IMM, Val));
264 assert(Op1.first == IC_IMM && Op2.first == IC_IMM &&
265 "Xor operation with an immediate and a register!");
266 Val = Op1.second ^ Op2.second;
267 OperandStack.
push_back(std::make_pair(IC_IMM, Val));
270 assert (Op1.first == IC_IMM && Op2.first == IC_IMM &&
271 "And operation with an immediate and a register!");
272 Val = Op1.second & Op2.second;
273 OperandStack.
push_back(std::make_pair(IC_IMM, Val));
276 assert (Op1.first == IC_IMM && Op2.first == IC_IMM &&
277 "Left shift operation with an immediate and a register!");
278 Val = Op1.second << Op2.second;
279 OperandStack.
push_back(std::make_pair(IC_IMM, Val));
282 assert (Op1.first == IC_IMM && Op2.first == IC_IMM &&
283 "Right shift operation with an immediate and a register!");
284 Val = Op1.second >> Op2.second;
285 OperandStack.
push_back(std::make_pair(IC_IMM, Val));
290 assert (OperandStack.
size() == 1 &&
"Expected a single result.");
295 enum IntelExprState {
317 class IntelExprStateMachine {
318 IntelExprState State, PrevState;
319 unsigned BaseReg, IndexReg, TmpReg, Scale;
323 bool StopOnLBrac, AddImmPrefix;
328 IntelExprStateMachine(int64_t imm,
bool stoponlbrac,
bool addimmprefix) :
329 State(IES_PLUS), PrevState(IES_ERROR), BaseReg(0), IndexReg(0), TmpReg(0),
330 Scale(1), Imm(imm), Sym(nullptr), StopOnLBrac(stoponlbrac),
331 AddImmPrefix(addimmprefix) { Info.clear(); }
333 unsigned getBaseReg() {
return BaseReg; }
334 unsigned getIndexReg() {
return IndexReg; }
335 unsigned getScale() {
return Scale; }
337 StringRef getSymName() {
return SymName; }
338 int64_t getImm() {
return Imm + IC.execute(); }
339 bool isValidEndState() {
340 return State == IES_RBRAC || State == IES_INTEGER;
342 bool getStopOnLBrac() {
return StopOnLBrac; }
343 bool getAddImmPrefix() {
return AddImmPrefix; }
344 bool hadError() {
return State == IES_ERROR; }
351 IntelExprState CurrState = State;
360 IC.pushOperator(IC_OR);
363 PrevState = CurrState;
366 IntelExprState CurrState = State;
375 IC.pushOperator(IC_XOR);
378 PrevState = CurrState;
381 IntelExprState CurrState = State;
390 IC.pushOperator(IC_AND);
393 PrevState = CurrState;
396 IntelExprState CurrState = State;
405 IC.pushOperator(IC_LSHIFT);
408 PrevState = CurrState;
411 IntelExprState CurrState = State;
420 IC.pushOperator(IC_RSHIFT);
423 PrevState = CurrState;
426 IntelExprState CurrState = State;
435 IC.pushOperator(IC_PLUS);
436 if (CurrState == IES_REGISTER && PrevState != IES_MULTIPLY) {
442 assert (!IndexReg &&
"BaseReg/IndexReg already set!");
449 PrevState = CurrState;
452 IntelExprState CurrState = State;
475 if (CurrState == IES_REGISTER || CurrState == IES_RPAREN ||
476 CurrState == IES_INTEGER || CurrState == IES_RBRAC)
477 IC.pushOperator(IC_MINUS);
479 IC.pushOperator(IC_NEG);
480 if (CurrState == IES_REGISTER && PrevState != IES_MULTIPLY) {
486 assert (!IndexReg &&
"BaseReg/IndexReg already set!");
493 PrevState = CurrState;
496 IntelExprState CurrState = State;
515 IC.pushOperator(IC_NOT);
518 PrevState = CurrState;
520 void onRegister(
unsigned Reg) {
521 IntelExprState CurrState = State;
528 State = IES_REGISTER;
530 IC.pushOperand(IC_REGISTER);
534 if (PrevState == IES_INTEGER) {
535 assert (!IndexReg &&
"IndexReg already set!");
536 State = IES_REGISTER;
539 Scale = IC.popOperand();
540 IC.pushOperand(IC_IMM);
547 PrevState = CurrState;
560 SymName = SymRefName;
561 IC.pushOperand(IC_IMM);
566 IntelExprState CurrState = State;
584 if (PrevState == IES_REGISTER && CurrState == IES_MULTIPLY) {
586 assert (!IndexReg &&
"IndexReg already set!");
589 if(Scale != 1 && Scale != 2 && Scale != 4 && Scale != 8) {
590 ErrMsg =
"scale factor in address must be 1, 2, 4 or 8";
596 IC.pushOperand(IC_IMM, TmpInt);
600 PrevState = CurrState;
612 State = IES_MULTIPLY;
613 IC.pushOperator(IC_MULTIPLY);
626 IC.pushOperator(IC_DIVIDE);
639 IC.pushOperator(IC_MOD);
651 IC.pushOperator(IC_PLUS);
656 IntelExprState CurrState = State;
665 if (CurrState == IES_REGISTER && PrevState != IES_MULTIPLY) {
671 assert (!IndexReg &&
"BaseReg/IndexReg already set!");
678 PrevState = CurrState;
681 IntelExprState CurrState = State;
699 IC.pushOperator(IC_LPAREN);
702 PrevState = CurrState;
714 IC.pushOperator(IC_RPAREN);
721 bool MatchingInlineAsm =
false) {
723 if (MatchingInlineAsm) {
724 if (!getLexer().isAtStartOfStatement())
728 return Parser.
Error(L, Msg, Range);
736 std::unique_ptr<X86Operand> DefaultMemSIOperand(
SMLoc Loc);
737 std::unique_ptr<X86Operand> DefaultMemDIOperand(
SMLoc Loc);
738 bool IsSIReg(
unsigned Reg);
739 unsigned GetSIDIForRegClass(
unsigned RegClassID,
unsigned Reg,
bool IsSIReg);
742 std::unique_ptr<llvm::MCParsedAsmOperand> &&Src,
743 std::unique_ptr<llvm::MCParsedAsmOperand> &&Dst);
746 std::unique_ptr<X86Operand> ParseOperand();
747 std::unique_ptr<X86Operand> ParseATTOperand();
748 std::unique_ptr<X86Operand> ParseIntelOperand();
749 std::unique_ptr<X86Operand> ParseIntelOffsetOfOperator();
750 bool ParseIntelDotOperator(
const MCExpr *Disp,
const MCExpr *&NewDisp);
752 unsigned ParseIntelOperator(
unsigned OpKind);
753 std::unique_ptr<X86Operand>
754 ParseIntelSegmentOverride(
unsigned SegReg,
SMLoc Start,
unsigned Size);
755 std::unique_ptr<X86Operand> ParseRoundingModeOp(
SMLoc Start,
SMLoc End);
756 bool ParseIntelNamedOperator(
StringRef Name, IntelExprStateMachine &SM);
757 bool ParseIntelExpression(IntelExprStateMachine &SM,
SMLoc &
End);
758 std::unique_ptr<X86Operand>
759 ParseIntelBracExpression(
unsigned SegReg,
SMLoc Start, int64_t ImmDisp,
760 bool isSymbol,
unsigned Size);
763 bool IsUnevaluatedOperand,
SMLoc &
End);
765 std::unique_ptr<X86Operand> ParseMemOperand(
unsigned SegReg,
SMLoc StartLoc);
767 std::unique_ptr<X86Operand>
768 CreateMemForInlineAsm(
unsigned SegReg,
const MCExpr *Disp,
unsigned BaseReg,
769 unsigned IndexReg,
unsigned Scale,
SMLoc Start,
772 bool AllowBetterSizeMatch =
false);
774 bool parseDirectiveEven(
SMLoc L);
775 bool ParseDirectiveWord(
unsigned Size,
SMLoc L);
784 bool MatchAndEmitInstruction(
SMLoc IDLoc,
unsigned &Opcode,
787 bool MatchingInlineAsm)
override;
792 bool ErrorMissingFeature(
SMLoc IDLoc, uint64_t ErrorInfo,
793 bool MatchingInlineAsm);
795 bool MatchAndEmitATTInstruction(
SMLoc IDLoc,
unsigned &Opcode,
798 bool MatchingInlineAsm);
800 bool MatchAndEmitIntelInstruction(
SMLoc IDLoc,
unsigned &Opcode,
803 bool MatchingInlineAsm);
805 bool OmitRegisterFromClobberLists(
unsigned RegNo)
override;
813 bool ParseZ(std::unique_ptr<X86Operand> &
Z,
const SMLoc &StartLoc);
815 bool is64BitMode()
const {
817 return getSTI().getFeatureBits()[X86::Mode64Bit];
819 bool is32BitMode()
const {
821 return getSTI().getFeatureBits()[X86::Mode32Bit];
823 bool is16BitMode()
const {
825 return getSTI().getFeatureBits()[X86::Mode16Bit];
827 void SwitchMode(
unsigned mode) {
829 FeatureBitset AllModes({X86::Mode64Bit, X86::Mode32Bit, X86::Mode16Bit});
831 unsigned FB = ComputeAvailableFeatures(
833 setAvailableFeatures(FB);
838 unsigned getPointerWidth() {
839 if (is16BitMode())
return 16;
840 if (is32BitMode())
return 32;
841 if (is64BitMode())
return 64;
845 bool isParsingIntelSyntax() {
846 return getParser().getAssemblerDialect();
852 #define GET_ASSEMBLER_HEADER
853 #include "X86GenAsmMatcher.inc"
865 setAvailableFeatures(ComputeAvailableFeatures(getSTI().getFeatureBits()));
866 Instrumentation.reset(
870 bool ParseRegister(
unsigned &RegNo,
SMLoc &StartLoc,
SMLoc &EndLoc)
override;
872 void SetFrameRegister(
unsigned RegNo)
override;
877 bool ParseDirective(
AsmToken DirectiveID)
override;
894 if ((BaseReg == X86::RIP && IndexReg != 0) || (IndexReg == X86::RIP)) {
895 ErrMsg =
"invalid base+index expression";
898 if (BaseReg != 0 && IndexReg != 0) {
899 if (X86MCRegisterClasses[X86::GR64RegClassID].
contains(BaseReg) &&
900 (X86MCRegisterClasses[X86::GR16RegClassID].
contains(IndexReg) ||
901 X86MCRegisterClasses[X86::GR32RegClassID].
contains(IndexReg)) &&
902 IndexReg != X86::RIZ) {
903 ErrMsg =
"base register is 64-bit, but index register is not";
906 if (X86MCRegisterClasses[X86::GR32RegClassID].
contains(BaseReg) &&
907 (X86MCRegisterClasses[X86::GR16RegClassID].
contains(IndexReg) ||
908 X86MCRegisterClasses[X86::GR64RegClassID].
contains(IndexReg)) &&
909 IndexReg != X86::EIZ){
910 ErrMsg =
"base register is 32-bit, but index register is not";
913 if (X86MCRegisterClasses[X86::GR16RegClassID].
contains(BaseReg)) {
914 if (X86MCRegisterClasses[X86::GR32RegClassID].
contains(IndexReg) ||
915 X86MCRegisterClasses[X86::GR64RegClassID].
contains(IndexReg)) {
916 ErrMsg =
"base register is 16-bit, but index register is not";
919 if (((BaseReg == X86::BX || BaseReg == X86::BP) &&
920 IndexReg != X86::SI && IndexReg != X86::DI) ||
921 ((BaseReg == X86::SI || BaseReg == X86::DI) &&
922 IndexReg != X86::BX && IndexReg != X86::BP)) {
923 ErrMsg =
"invalid 16-bit base/index register combination";
931 bool X86AsmParser::ParseRegister(
unsigned &RegNo,
936 StartLoc = PercentTok.
getLoc();
947 if (isParsingIntelSyntax())
return true;
948 return Error(StartLoc,
"invalid register name",
960 if (isParsingInlineAsm() && isParsingIntelSyntax() && RegNo == X86::EFLAGS)
963 if (!is64BitMode()) {
969 if (RegNo == X86::RIZ ||
970 X86MCRegisterClasses[X86::GR64RegClassID].
contains(RegNo) ||
973 return Error(StartLoc,
"register %"
974 + Tok.
getString() +
" is only available in 64-bit mode",
976 }
else if (!getSTI().getFeatureBits()[X86::FeatureAVX512]) {
978 return Error(StartLoc,
"register %"
979 + Tok.
getString() +
" is only available with AVX512",
996 return Error(IntTok.
getLoc(),
"expected stack index");
998 case 0: RegNo = X86::ST0;
break;
999 case 1: RegNo = X86::ST1;
break;
1000 case 2: RegNo = X86::ST2;
break;
1001 case 3: RegNo = X86::ST3;
break;
1002 case 4: RegNo = X86::ST4;
break;
1003 case 5: RegNo = X86::ST5;
break;
1004 case 6: RegNo = X86::ST6;
break;
1005 case 7: RegNo = X86::ST7;
break;
1006 default:
return Error(IntTok.
getLoc(),
"invalid stack index");
1024 case '0': RegNo = X86::DR0;
break;
1025 case '1': RegNo = X86::DR1;
break;
1026 case '2': RegNo = X86::DR2;
break;
1027 case '3': RegNo = X86::DR3;
break;
1028 case '4': RegNo = X86::DR4;
break;
1029 case '5': RegNo = X86::DR5;
break;
1030 case '6': RegNo = X86::DR6;
break;
1031 case '7': RegNo = X86::DR7;
break;
1042 if (isParsingIntelSyntax())
return true;
1043 return Error(StartLoc,
"invalid register name",
1051 void X86AsmParser::SetFrameRegister(
unsigned RegNo) {
1052 Instrumentation->SetInitialFrameRegister(RegNo);
1055 std::unique_ptr<X86Operand> X86AsmParser::DefaultMemSIOperand(
SMLoc Loc) {
1056 bool Parse32 = is32BitMode() || Code16GCC;
1057 unsigned Basereg = is64BitMode() ? X86::RSI : (Parse32 ? X86::ESI : X86::SI);
1064 std::unique_ptr<X86Operand> X86AsmParser::DefaultMemDIOperand(
SMLoc Loc) {
1065 bool Parse32 = is32BitMode() || Code16GCC;
1066 unsigned Basereg = is64BitMode() ? X86::RDI : (Parse32 ? X86::EDI : X86::DI);
1073 bool X86AsmParser::IsSIReg(
unsigned Reg) {
1087 unsigned X86AsmParser::GetSIDIForRegClass(
unsigned RegClassID,
unsigned Reg,
1089 switch (RegClassID) {
1091 case X86::GR64RegClassID:
1092 return IsSIReg ? X86::RSI : X86::RDI;
1093 case X86::GR32RegClassID:
1094 return IsSIReg ? X86::ESI : X86::EDI;
1095 case X86::GR16RegClassID:
1096 return IsSIReg ? X86::SI : X86::DI;
1100 void X86AsmParser::AddDefaultSrcDestOperands(
1101 OperandVector& Operands, std::unique_ptr<llvm::MCParsedAsmOperand> &&Src,
1102 std::unique_ptr<llvm::MCParsedAsmOperand> &&Dst) {
1103 if (isParsingIntelSyntax()) {
1113 bool X86AsmParser::VerifyAndAdjustOperands(
OperandVector &OrigOperands,
1116 if (OrigOperands.
size() > 1) {
1119 "Operand size mismatch");
1123 int RegClassID = -1;
1124 for (
unsigned int i = 0; i < FinalOperands.
size(); ++i) {
1128 if (FinalOp.
isReg() &&
1133 if (FinalOp.
isMem()) {
1135 if (!OrigOp.
isMem())
1144 if (RegClassID != -1 &&
1145 !X86MCRegisterClasses[RegClassID].
contains(OrigReg)) {
1147 "mismatching source and destination index registers");
1150 if (X86MCRegisterClasses[X86::GR64RegClassID].
contains(OrigReg))
1151 RegClassID = X86::GR64RegClassID;
1152 else if (X86MCRegisterClasses[X86::GR32RegClassID].
contains(OrigReg))
1153 RegClassID = X86::GR32RegClassID;
1154 else if (X86MCRegisterClasses[X86::GR16RegClassID].
contains(OrigReg))
1155 RegClassID = X86::GR16RegClassID;
1161 bool IsSI = IsSIReg(FinalReg);
1162 FinalReg = GetSIDIForRegClass(RegClassID, FinalReg, IsSI);
1164 if (FinalReg != OrigReg) {
1165 std::string RegName = IsSI ?
"ES:(R|E)SI" :
"ES:(R|E)DI";
1166 Warnings.push_back(std::make_pair(
1168 "memory operand is only for determining the size, " + RegName +
1169 " will be used for the location"));
1180 for (
auto &WarningMsg : Warnings) {
1181 Warning(WarningMsg.first, WarningMsg.second);
1185 for (
unsigned int i = 0; i < FinalOperands.
size(); ++i)
1189 for (
unsigned int i = 0; i < FinalOperands.
size(); ++i)
1190 OrigOperands.
push_back(std::move(FinalOperands[i]));
1195 std::unique_ptr<X86Operand> X86AsmParser::ParseOperand() {
1196 if (isParsingIntelSyntax())
1197 return ParseIntelOperand();
1198 return ParseATTOperand();
1204 .Cases(
"BYTE",
"byte", 8)
1205 .
Cases(
"WORD",
"word", 16)
1206 .
Cases(
"DWORD",
"dword", 32)
1207 .
Cases(
"FWORD",
"fword", 48)
1208 .
Cases(
"QWORD",
"qword", 64)
1209 .
Cases(
"MMWORD",
"mmword", 64)
1210 .
Cases(
"XWORD",
"xword", 80)
1211 .
Cases(
"TBYTE",
"tbyte", 80)
1212 .
Cases(
"XMMWORD",
"xmmword", 128)
1213 .
Cases(
"YMMWORD",
"ymmword", 256)
1214 .
Cases(
"ZMMWORD",
"zmmword", 512)
1215 .
Cases(
"OPAQUE",
"opaque", -1U)
1220 std::unique_ptr<X86Operand> X86AsmParser::CreateMemForInlineAsm(
1221 unsigned SegReg,
const MCExpr *Disp,
unsigned BaseReg,
unsigned IndexReg,
1229 Size = getPointerWidth();
1237 Identifier, Info.
OpDecl);
1244 unsigned FrontendSize = 0;
1247 isa<MCSymbolRefExpr>(BinOp ? BinOp->
getLHS() : Disp);
1248 if (IsSymRef && !Size && Info.
Type)
1249 FrontendSize = Info.
Type * 8;
1254 BaseReg = BaseReg ? BaseReg : 1;
1256 IndexReg, Scale, Start, End, Size, Identifier,
1257 Info.
OpDecl, FrontendSize);
1263 int64_t FinalImmDisp,
SMLoc &BracLoc,
1273 if (ImmDisp != FinalImmDisp) {
1279 if (AR.Loc.getPointer() > BracLoc.
getPointer())
1282 assert (!Found &&
"ImmDisp already rewritten.");
1284 AR.Len = BracLoc.
getPointer() - AR.Loc.getPointer();
1285 AR.Val = FinalImmDisp;
1290 assert (Found &&
"Unable to rewrite ImmDisp.");
1303 if (AR.Loc.getPointer() < StartInBrac.
getPointer())
1308 const char *SymLocPtr = SymName.
data();
1310 if (
unsigned Len = SymLocPtr - StartInBrac.
getPointer()) {
1311 assert(Len > 0 &&
"Expected a non-negative length.");
1312 AsmRewrites.emplace_back(
AOK_Skip, StartInBrac, Len);
1315 if (
unsigned Len = End.
getPointer() - (SymLocPtr + SymName.
size())) {
1317 assert(Len > 0 &&
"Expected a non-negative length.");
1318 AsmRewrites.emplace_back(
AOK_Skip, Loc, Len);
1325 bool X86AsmParser::ParseIntelNamedOperator(
StringRef Name, IntelExprStateMachine &SM) {
1348 bool X86AsmParser::ParseIntelExpression(IntelExprStateMachine &SM,
SMLoc &End) {
1355 bool UpdateLocLex =
true;
1370 if (SM.isValidEndState()) {
1374 return Error(Tok.
getLoc(),
"unknown token in expression");
1387 UpdateLocLex =
false;
1389 SM.onRegister(TmpReg);
1390 }
else if (ParseIntelNamedOperator(Identifier, SM)) {
1391 UpdateLocLex =
true;
1392 }
else if (!isParsingInlineAsm()) {
1393 if (getParser().parsePrimaryExpr(Val, End))
1394 return Error(Tok.
getLoc(),
"Unexpected identifier!");
1395 SM.onIdentifierExpr(Val, Identifier);
1396 }
else if (
unsigned OpKind = IdentifyIntelOperator(Identifier)) {
1397 if (OpKind == IOK_OFFSET)
1398 return Error(IdentLoc,
"Dealing OFFSET operator as part of"
1399 "a compound immediate expression is yet to be supported");
1400 int64_t Val = ParseIntelOperator(OpKind);
1404 if (SM.onInteger(Val, ErrMsg))
1405 return Error(IdentLoc, ErrMsg);
1411 if (ParseIntelIdentifier(Val, Identifier, Info,
1414 SM.onIdentifierExpr(Val, Identifier);
1420 if (isParsingInlineAsm() && SM.getAddImmPrefix())
1423 SMLoc Loc = getTok().getLoc();
1424 int64_t
IntVal = getTok().getIntVal();
1425 End = consumeToken();
1426 UpdateLocLex =
false;
1429 if (IDVal ==
"f" || IDVal ==
"b") {
1431 getContext().getDirectionalLocalSymbol(IntVal, IDVal ==
"b");
1436 return Error(Loc,
"invalid reference to undefined symbol");
1438 SM.onIdentifierExpr(Val, Identifier);
1439 End = consumeToken();
1441 if (SM.onInteger(IntVal, ErrMsg))
1442 return Error(Loc, ErrMsg);
1445 if (SM.onInteger(IntVal, ErrMsg))
1446 return Error(Loc, ErrMsg);
1459 SM.onLShift();
break;
1461 SM.onRShift();
break;
1468 return Error(Tok.
getLoc(),
"unknown token in expression");
1470 if (!Done && UpdateLocLex)
1471 End = consumeToken();
1478 std::unique_ptr<X86Operand>
1479 X86AsmParser::ParseIntelBracExpression(
unsigned SegReg,
SMLoc Start,
1480 int64_t ImmDisp,
bool isSymbol,
1486 return ErrorOperand(BracLoc,
"Expected '[' token!");
1493 IntelExprStateMachine SM(ImmDisp,
false,
true);
1494 if (ParseIntelExpression(SM, End))
1497 const MCExpr *Disp =
nullptr;
1498 if (
const MCExpr *Sym = SM.getSym()) {
1501 if (isParsingInlineAsm())
1503 ImmDisp, SM.getImm(), BracLoc, StartInBrac,
1507 if (SM.getImm() || !Disp) {
1523 if (ParseIntelDotOperator(Disp, NewDisp))
1533 Error(Start,
"cannot use more than one symbol in memory operand");
1536 if (SM.getBaseReg()) {
1537 Error(Start,
"cannot use base register with variable reference");
1540 if (SM.getIndexReg()) {
1541 Error(Start,
"cannot use index register with variable reference");
1546 int BaseReg = SM.getBaseReg();
1547 int IndexReg = SM.getIndexReg();
1548 int Scale = SM.getScale();
1549 if (!isParsingInlineAsm()) {
1551 if (!BaseReg && !IndexReg) {
1559 Error(StartInBrac, ErrMsg);
1563 IndexReg, Scale, Start, End, Size);
1567 return CreateMemForInlineAsm(SegReg, Disp, BaseReg, IndexReg, Scale, Start,
1568 End, Size, SM.getSymName(), Info,
1569 isParsingInlineAsm());
1573 bool X86AsmParser::ParseIntelIdentifier(
const MCExpr *&Val,
1576 bool IsUnevaluatedOperand,
SMLoc &End) {
1578 assert(isParsingInlineAsm() &&
"Expected to be parsing inline assembly.");
1583 SemaCallback->LookupInlineAsmIdentifier(LineBuf, Info, IsUnevaluatedOperand);
1595 Identifier = LineBuf;
1600 "frontend claimed part of a token?");
1606 SemaCallback->LookupInlineAsmLabel(Identifier, getSourceManager(),
1608 assert(InternalName.
size() &&
"We should have an internal name here.");
1610 InstInfo->AsmRewrites->emplace_back(
AOK_Label, Loc, Identifier.
size(),
1615 MCSymbol *Sym = getContext().getOrCreateSymbol(Identifier);
1622 std::unique_ptr<X86Operand>
1623 X86AsmParser::ParseIntelSegmentOverride(
unsigned SegReg,
SMLoc Start,
1626 assert(SegReg != 0 &&
"Tried to parse a segment override without a segment!");
1629 return ErrorOperand(Tok.
getLoc(),
"Expected ':' token!");
1632 int64_t ImmDisp = 0;
1637 if (isParsingInlineAsm())
1652 return ParseIntelBracExpression(SegReg, Start, ImmDisp,
false, Size);
1656 if (!isParsingInlineAsm()) {
1657 if (getParser().parsePrimaryExpr(Val, End))
1658 return ErrorOperand(Tok.
getLoc(),
"unknown token in expression");
1665 if (ParseIntelIdentifier(Val, Identifier, Info,
1668 return CreateMemForInlineAsm(0, Val, 0,0,
1669 1, Start, End, Size, Identifier, Info);
1673 std::unique_ptr<X86Operand>
1674 X86AsmParser::ParseRoundingModeOp(
SMLoc Start,
SMLoc End) {
1678 const SMLoc consumedToken = consumeToken();
1687 return ErrorOperand(Tok.
getLoc(),
"Invalid rounding mode.");
1690 return ErrorOperand(Tok.
getLoc(),
"Expected - at this point");
1694 return ErrorOperand(Tok.
getLoc(),
"Expected } at this point");
1696 const MCExpr *RndModeOp =
1703 return ErrorOperand(Tok.
getLoc(),
"Expected } at this point");
1707 return ErrorOperand(Tok.
getLoc(),
"unknown token in expression");
1711 bool X86AsmParser::ParseIntelDotOperator(
const MCExpr *Disp,
1712 const MCExpr *&NewDisp) {
1715 int64_t OrigDispVal, DotDispVal;
1718 if (
const MCConstantExpr *OrigDisp = dyn_cast<MCConstantExpr>(Disp))
1719 OrigDispVal = OrigDisp->getValue();
1721 return Error(Tok.
getLoc(),
"Non-constant offsets are not supported!");
1725 if (DotDispStr.startswith(
"."))
1731 DotDispStr.getAsInteger(10, DotDisp);
1735 std::pair<StringRef, StringRef> BaseMember = DotDispStr.split(
'.');
1736 if (SemaCallback->LookupInlineAsmField(BaseMember.first, BaseMember.second,
1738 return Error(Tok.
getLoc(),
"Unable to lookup field reference!");
1739 DotDispVal = DotDisp;
1741 return Error(Tok.
getLoc(),
"Unexpected token type!");
1745 unsigned Len = DotDispStr.size();
1746 InstInfo->AsmRewrites->emplace_back(
AOK_DotOperator, Loc, Len, DotDispVal);
1755 std::unique_ptr<X86Operand> X86AsmParser::ParseIntelOffsetOfOperator() {
1765 if (ParseIntelIdentifier(Val, Identifier, Info,
1770 InstInfo->AsmRewrites->emplace_back(
AOK_Skip, OffsetOfLoc, 7);
1775 bool Parse32 = is32BitMode() || Code16GCC;
1776 unsigned RegNo = is64BitMode() ? X86::RBX : (Parse32 ? X86::EBX : X86::BX);
1779 OffsetOfLoc, Identifier, Info.
OpDecl);
1784 unsigned X86AsmParser::IdentifyIntelOperator(
StringRef Name) {
1786 .Cases(
"TYPE",
"type",IOK_TYPE)
1787 .
Cases(
"SIZE",
"size",IOK_SIZE)
1788 .
Cases(
"LENGTH",
"length",IOK_LENGTH)
1789 .
Cases(
"OFFSET",
"offset",IOK_OFFSET)
1799 unsigned X86AsmParser::ParseIntelOperator(
unsigned OpKind) {
1805 const MCExpr *Val =
nullptr;
1809 if (ParseIntelIdentifier(Val, Identifier, Info,
1814 Error(Start,
"unable to lookup expression");
1821 case IOK_LENGTH: CVal = Info.
Length;
break;
1822 case IOK_SIZE: CVal = Info.
Size;
break;
1823 case IOK_TYPE: CVal = Info.
Type;
break;
1829 InstInfo->AsmRewrites->emplace_back(
AOK_Imm, TypeLoc, Len, CVal);
1834 std::unique_ptr<X86Operand> X86AsmParser::ParseIntelOperand() {
1842 if (isParsingInlineAsm())
1843 if (IdentifyIntelOperator(Tok.
getString()) == IOK_OFFSET)
1844 return ParseIntelOffsetOfOperator();
1846 bool PtrInOperand =
false;
1851 return ErrorOperand(Tok.
getLoc(),
"Expected 'PTR' or 'ptr' token!");
1853 PtrInOperand =
true;
1859 if (getSTI().getFeatureBits()[X86::FeatureAVX512] &&
1861 return ParseRoundingModeOp(Start, End);
1866 !ParseRegister(RegNo, Start, End)) {
1871 if (RegNo == X86::RIP)
1872 return ErrorOperand(Start,
"rip can only be used as a base register");
1875 return ErrorOperand(Start,
"expected memory operand after "
1876 "'ptr', found register operand instead");
1880 return ParseIntelSegmentOverride(RegNo, Start, Size);
1887 return ParseIntelBracExpression(0, Start, 0,
false,
1891 IntelExprStateMachine SM(0,
true,
1893 if (ParseIntelExpression(SM, End))
1897 int64_t Imm = SM.getImm();
1899 SM.getSym()->evaluateAsAbsolute(Imm);
1909 InstInfo->AsmRewrites->emplace_back(
AOK_Imm, Start, Len, Imm);
1918 if (isParsingInlineAsm())
1919 return CreateMemForInlineAsm(0, SM.getSym(), 0,
1922 SM.getSymName(), SM.getIdentifierInfo());
1933 return ErrorOperand(Start,
"expected a positive immediate displacement "
1934 "before bracketed expr.");
1936 return ParseIntelBracExpression(0, Start, Imm, isSymbol, Size);
1939 std::unique_ptr<X86Operand> X86AsmParser::ParseATTOperand() {
1941 switch (getLexer().getKind()) {
1949 if (ParseRegister(RegNo, Start, End))
return nullptr;
1950 if (RegNo == X86::EIZ || RegNo == X86::RIZ) {
1951 Error(Start,
"%eiz and %riz can only be used as index registers",
1955 if (RegNo == X86::RIP) {
1956 Error(Start,
"%rip can only be used as a base register",
1966 if (!X86MCRegisterClasses[X86::SEGMENT_REGRegClassID].
contains(RegNo))
1967 return ErrorOperand(Start,
"invalid segment register");
1970 return ParseMemOperand(RegNo, Start);
1977 if (getParser().parseExpression(Val, End))
1983 if (getSTI().getFeatureBits()[X86::FeatureAVX512])
1984 return ParseRoundingModeOp(Start, End);
1985 return ErrorOperand(Start,
"Unexpected '{' in expression");
1992 bool X86AsmParser::ParseZ(std::unique_ptr<X86Operand> &Z,
1993 const SMLoc &StartLoc) {
1999 (getLexer().getTok().getIdentifier() ==
"z")))
2004 return Error(getLexer().getLoc(),
"Expected } at this point");
2012 bool X86AsmParser::HandleAVX512Operand(
OperandVector &Operands,
2015 if(getSTI().getFeatureBits()[X86::FeatureAVX512]) {
2018 const SMLoc consumedToken = consumeToken();
2022 if (getLexer().getTok().getIntVal() != 1)
2023 return TokError(
"Expected 1to<NUM> at this point");
2026 !getLexer().getTok().getIdentifier().
startswith(
"to"))
2027 return TokError(
"Expected 1to<NUM> at this point");
2029 const char *BroadcastPrimitive =
2031 .Case(
"to2",
"{1to2}")
2032 .
Case(
"to4",
"{1to4}")
2033 .
Case(
"to8",
"{1to8}")
2034 .
Case(
"to16",
"{1to16}")
2036 if (!BroadcastPrimitive)
2037 return TokError(
"Invalid memory broadcast primitive.");
2040 return TokError(
"Expected } at this point");
2051 std::unique_ptr<X86Operand> Z;
2052 if (ParseZ(Z, consumedToken))
2058 const SMLoc StartLoc = Z ? consumeToken() : consumedToken;
2061 if (std::unique_ptr<X86Operand> Op = ParseOperand()) {
2063 return Error(getLexer().getLoc(),
"Expected } at this point");
2068 return Error(getLexer().getLoc(),
2069 "Expected an op-mask register at this point");
2074 if (ParseZ(Z, consumeToken()) || !Z)
2092 std::unique_ptr<X86Operand> X86AsmParser::ParseMemOperand(
unsigned SegReg,
2103 if (getParser().parseExpression(Disp, ExprEnd))
return nullptr;
2130 if (getParser().parseParenExpression(Disp, ExprEnd))
2151 unsigned BaseReg = 0, IndexReg = 0, Scale = 1;
2152 SMLoc IndexLoc, BaseLoc;
2155 SMLoc StartLoc, EndLoc;
2157 if (ParseRegister(BaseReg, StartLoc, EndLoc))
return nullptr;
2158 if (BaseReg == X86::EIZ || BaseReg == X86::RIZ) {
2159 Error(StartLoc,
"eiz and riz can only be used as index registers",
2177 if (ParseRegister(IndexReg, L, L))
2179 if (BaseReg == X86::RIP) {
2180 Error(IndexLoc,
"%rip as base register can not have an index register");
2183 if (IndexReg == X86::RIP) {
2184 Error(IndexLoc,
"%rip is not allowed as an index register");
2193 "expected comma in scale expression");
2202 if (getParser().parseAbsoluteExpression(ScaleVal)){
2203 Error(Loc,
"expected scale expression");
2208 if (X86MCRegisterClasses[X86::GR16RegClassID].
contains(BaseReg) &&
2210 Error(Loc,
"scale factor in 16-bit address must be 1");
2213 if (ScaleVal != 1 && ScaleVal != 2 && ScaleVal != 4 &&
2215 Error(Loc,
"scale factor in address must be 1, 2, 4 or 8");
2227 if (getParser().parseAbsoluteExpression(Value))
2231 Warning(Loc,
"scale factor without index register is ignored");
2247 if (X86MCRegisterClasses[X86::GR16RegClassID].
contains(BaseReg) &&
2248 (is64BitMode() || (BaseReg != X86::BX && BaseReg != X86::BP &&
2249 BaseReg != X86::SI && BaseReg != X86::DI)) &&
2250 BaseReg != X86::DX) {
2251 Error(BaseLoc,
"invalid 16-bit base register");
2255 X86MCRegisterClasses[X86::GR16RegClassID].
contains(IndexReg)) {
2256 Error(IndexLoc,
"16-bit memory operand may not include only index register");
2262 Error(BaseLoc, ErrMsg);
2266 if (SegReg || BaseReg || IndexReg)
2268 IndexReg, Scale, MemStart, MemEnd);
2278 if (Name ==
"jmp" && isParsingIntelSyntax() && isParsingInlineAsm()) {
2280 if (NextTok ==
"short") {
2287 InstInfo->AsmRewrites->emplace_back(
AOK_Skip, NameEndLoc,
2288 NextTok.
size() + 1);
2294 PatchedName !=
"setb" && PatchedName !=
"setnb")
2295 PatchedName = PatchedName.
substr(0, Name.
size()-1);
2301 bool IsVCMP = PatchedName[0] ==
'v';
2302 unsigned CCIdx = IsVCMP ? 4 : 3;
2304 PatchedName.
slice(CCIdx, PatchedName.
size() - 2))
2306 .
Case(
"eq_oq", 0x00)
2308 .
Case(
"lt_os", 0x01)
2310 .
Case(
"le_os", 0x02)
2311 .
Case(
"unord", 0x03)
2312 .
Case(
"unord_q", 0x03)
2314 .
Case(
"neq_uq", 0x04)
2316 .
Case(
"nlt_us", 0x05)
2318 .
Case(
"nle_us", 0x06)
2320 .
Case(
"ord_q", 0x07)
2322 .
Case(
"eq_uq", 0x08)
2324 .
Case(
"nge_us", 0x09)
2326 .
Case(
"ngt_us", 0x0A)
2327 .
Case(
"false", 0x0B)
2328 .
Case(
"false_oq", 0x0B)
2329 .
Case(
"neq_oq", 0x0C)
2331 .
Case(
"ge_os", 0x0D)
2333 .
Case(
"gt_os", 0x0E)
2335 .
Case(
"true_uq", 0x0F)
2336 .
Case(
"eq_os", 0x10)
2337 .
Case(
"lt_oq", 0x11)
2338 .
Case(
"le_oq", 0x12)
2339 .
Case(
"unord_s", 0x13)
2340 .
Case(
"neq_us", 0x14)
2341 .
Case(
"nlt_uq", 0x15)
2342 .
Case(
"nle_uq", 0x16)
2343 .
Case(
"ord_s", 0x17)
2344 .
Case(
"eq_us", 0x18)
2345 .
Case(
"nge_uq", 0x19)
2346 .
Case(
"ngt_uq", 0x1A)
2347 .
Case(
"false_os", 0x1B)
2348 .
Case(
"neq_os", 0x1C)
2349 .
Case(
"ge_oq", 0x1D)
2350 .
Case(
"gt_oq", 0x1E)
2351 .
Case(
"true_us", 0x1F)
2353 if (ComparisonCode != ~0U && (IsVCMP || ComparisonCode < 8)) {
2359 getParser().getContext());
2362 PatchedName = PatchedName.
substr(PatchedName.
size() - 2);
2370 unsigned CCIdx = PatchedName.
drop_back().
back() ==
'u' ? 2 : 1;
2372 PatchedName.
slice(5, PatchedName.
size() - CCIdx))
2382 if (ComparisonCode != ~0U && (ComparisonCode != 0 || CCIdx == 2)) {
2386 getParser().getContext());
2389 PatchedName = PatchedName.
substr(PatchedName.
size() - CCIdx);
2397 unsigned CCIdx = PatchedName.
drop_back().
back() ==
'u' ? 2 : 1;
2399 PatchedName.
slice(5, PatchedName.
size() - CCIdx))
2409 if (ComparisonCode != ~0U) {
2413 getParser().getContext());
2416 PatchedName = PatchedName.
substr(PatchedName.
size() - CCIdx);
2424 Name ==
"lock" || Name ==
"rep" ||
2425 Name ==
"repe" || Name ==
"repz" ||
2426 Name ==
"repne" || Name ==
"repnz" ||
2427 Name ==
"rex64" || Name ==
"data16" || Name ==
"data32";
2429 bool CurlyAsEndOfStatement =
false;
2442 if (std::unique_ptr<X86Operand> Op = ParseOperand()) {
2444 if (HandleAVX512Operand(Operands, *Operands.
back()))
2458 CurlyAsEndOfStatement =
2459 isParsingIntelSyntax() && isParsingInlineAsm() &&
2462 return TokError(
"unexpected token in argument list");
2469 else if (CurlyAsEndOfStatement)
2472 getLexer().getTok().getLoc(), 0);
2478 Name ==
"fsub" || Name ==
"fdiv" || Name ==
"fsubr" || Name ==
"fdivr";
2479 if (IsFp && Operands.
size() == 1) {
2481 .Case(
"fsub",
"fsubp")
2482 .
Case(
"fdiv",
"fdivp")
2483 .
Case(
"fsubr",
"fsubrp")
2484 .
Case(
"fdivr",
"fdivrp");
2485 static_cast<X86Operand &
>(*Operands[0]).setTokenValue(Repl);
2490 if ((Name ==
"mov" || Name ==
"movw" || Name ==
"movl") &&
2491 (Operands.
size() == 3)) {
2496 X86MCRegisterClasses[X86::SEGMENT_REGRegClassID].contains(
2498 (X86MCRegisterClasses[X86::GR16RegClassID].
contains(Op1.
getReg()) ||
2499 X86MCRegisterClasses[X86::GR32RegClassID].
contains(Op1.
getReg()))) {
2501 if (Name !=
"mov" && Name[3] == (is16BitMode() ?
'l' :
'w')) {
2502 Name = is16BitMode() ?
"movw" :
"movl";
2515 if ((Name ==
"outb" || Name ==
"outsb" || Name ==
"outw" || Name ==
"outsw" ||
2516 Name ==
"outl" || Name ==
"outsl" || Name ==
"out" || Name ==
"outs") &&
2517 Operands.
size() == 3) {
2520 isa<MCConstantExpr>(Op.
Mem.
Disp) &&
2521 cast<MCConstantExpr>(Op.
Mem.
Disp)->getValue() == 0 &&
2528 if ((Name ==
"inb" || Name ==
"insb" || Name ==
"inw" || Name ==
"insw" ||
2529 Name ==
"inl" || Name ==
"insl" || Name ==
"in" || Name ==
"ins") &&
2530 Operands.
size() == 3) {
2533 isa<MCConstantExpr>(Op.
Mem.
Disp) &&
2534 cast<MCConstantExpr>(Op.
Mem.
Disp)->getValue() == 0 &&
2542 bool HadVerifyError =
false;
2546 (Operands.
size() == 1 || Operands.
size() == 3) &&
2547 (Name ==
"insb" || Name ==
"insw" || Name ==
"insl" || Name ==
"insd" ||
2550 AddDefaultSrcDestOperands(TmpOperands,
2552 DefaultMemDIOperand(NameLoc));
2553 HadVerifyError = VerifyAndAdjustOperands(Operands, TmpOperands);
2558 (Operands.
size() == 1 || Operands.
size() == 3) &&
2559 (Name ==
"outsb" || Name ==
"outsw" || Name ==
"outsl" ||
2560 Name ==
"outsd" || Name ==
"outs")) {
2561 AddDefaultSrcDestOperands(TmpOperands, DefaultMemSIOperand(NameLoc),
2563 HadVerifyError = VerifyAndAdjustOperands(Operands, TmpOperands);
2570 (Operands.
size() == 1 || Operands.
size() == 2) &&
2571 (Name ==
"lods" || Name ==
"lodsb" || Name ==
"lodsw" ||
2572 Name ==
"lodsl" || Name ==
"lodsd" || Name ==
"lodsq")) {
2573 TmpOperands.
push_back(DefaultMemSIOperand(NameLoc));
2574 HadVerifyError = VerifyAndAdjustOperands(Operands, TmpOperands);
2581 (Operands.
size() == 1 || Operands.
size() == 2) &&
2582 (Name ==
"stos" || Name ==
"stosb" || Name ==
"stosw" ||
2583 Name ==
"stosl" || Name ==
"stosd" || Name ==
"stosq")) {
2584 TmpOperands.
push_back(DefaultMemDIOperand(NameLoc));
2585 HadVerifyError = VerifyAndAdjustOperands(Operands, TmpOperands);
2592 (Operands.
size() == 1 || Operands.
size() == 2) &&
2593 (Name ==
"scas" || Name ==
"scasb" || Name ==
"scasw" ||
2594 Name ==
"scasl" || Name ==
"scasd" || Name ==
"scasq")) {
2595 TmpOperands.
push_back(DefaultMemDIOperand(NameLoc));
2596 HadVerifyError = VerifyAndAdjustOperands(Operands, TmpOperands);
2601 (Operands.
size() == 1 || Operands.
size() == 3) &&
2602 (Name ==
"cmps" || Name ==
"cmpsb" || Name ==
"cmpsw" ||
2603 Name ==
"cmpsl" || Name ==
"cmpsd" || Name ==
"cmpsq")) {
2604 AddDefaultSrcDestOperands(TmpOperands, DefaultMemDIOperand(NameLoc),
2605 DefaultMemSIOperand(NameLoc));
2606 HadVerifyError = VerifyAndAdjustOperands(Operands, TmpOperands);
2611 (Name ==
"movs" || Name ==
"movsb" || Name ==
"movsw" ||
2612 Name ==
"movsl" || Name ==
"movsd" || Name ==
"movsq")) ||
2614 (Name ==
"smov" || Name ==
"smovb" || Name ==
"smovw" ||
2615 Name ==
"smovl" || Name ==
"smovd" || Name ==
"smovq"))) &&
2616 (Operands.
size() == 1 || Operands.
size() == 3)) {
2617 if (Name ==
"movsd" && Operands.
size() == 1 && !isParsingIntelSyntax())
2619 AddDefaultSrcDestOperands(TmpOperands, DefaultMemSIOperand(NameLoc),
2620 DefaultMemDIOperand(NameLoc));
2621 HadVerifyError = VerifyAndAdjustOperands(Operands, TmpOperands);
2625 if (HadVerifyError) {
2626 return HadVerifyError;
2635 Operands.
size() == 3) {
2636 if (isParsingIntelSyntax()) {
2639 if (Op1.
isImm() && isa<MCConstantExpr>(Op1.
getImm()) &&
2640 cast<MCConstantExpr>(Op1.
getImm())->getValue() == 1)
2644 if (Op1.
isImm() && isa<MCConstantExpr>(Op1.
getImm()) &&
2645 cast<MCConstantExpr>(Op1.
getImm())->getValue() == 1)
2652 if (Name ==
"int" && Operands.
size() == 2) {
2655 if (
auto *CE = dyn_cast<MCConstantExpr>(Op1.
getImm()))
2656 if (
CE->getValue() == 3) {
2658 static_cast<X86Operand &
>(*Operands[0]).setTokenValue(
"int3");
2663 if ((Name ==
"xlat" || Name ==
"xlatb") && Operands.
size() == 2) {
2666 Warning(Op1.
getStartLoc(),
"memory operand is only for determining the "
2667 "size, (R|E)BX will be used for the location");
2669 static_cast<X86Operand &
>(*Operands[0]).setTokenValue(
"xlatb");
2684 Instrumentation->InstrumentAndEmitInstruction(Inst, Operands, getContext(),
2688 bool X86AsmParser::MatchAndEmitInstruction(
SMLoc IDLoc,
unsigned &Opcode,
2691 bool MatchingInlineAsm) {
2692 if (isParsingIntelSyntax())
2693 return MatchAndEmitIntelInstruction(IDLoc, Opcode, Operands, Out, ErrorInfo,
2695 return MatchAndEmitATTInstruction(IDLoc, Opcode, Operands, Out, ErrorInfo,
2701 bool MatchingInlineAsm) {
2706 .Case(
"finit",
"fninit")
2707 .
Case(
"fsave",
"fnsave")
2708 .
Case(
"fstcw",
"fnstcw")
2709 .
Case(
"fstcww",
"fnstcw")
2710 .
Case(
"fstenv",
"fnstenv")
2711 .
Case(
"fstsw",
"fnstsw")
2712 .
Case(
"fstsww",
"fnstsw")
2713 .
Case(
"fclex",
"fnclex")
2719 if (!MatchingInlineAsm)
2720 EmitInstruction(Inst, Operands, Out);
2725 bool X86AsmParser::ErrorMissingFeature(
SMLoc IDLoc, uint64_t ErrorInfo,
2726 bool MatchingInlineAsm) {
2727 assert(ErrorInfo &&
"Unknown missing feature!");
2730 OS <<
"instruction requires:";
2732 for (
unsigned i = 0; i < (
sizeof(ErrorInfo)*8-1); ++i) {
2733 if (ErrorInfo & Mask)
2737 return Error(IDLoc, OS.str(),
SMRange(), MatchingInlineAsm);
2740 bool X86AsmParser::MatchAndEmitATTInstruction(
SMLoc IDLoc,
unsigned &Opcode,
2743 uint64_t &ErrorInfo,
2744 bool MatchingInlineAsm) {
2745 assert(!Operands.
empty() &&
"Unexpect empty operand list!");
2747 assert(Op.isToken() &&
"Leading operand should always be a mnemonic!");
2751 MatchFPUWaitAlias(IDLoc, Op, Operands, Out, MatchingInlineAsm);
2753 bool WasOriginallyInvalidOperand =
false;
2757 switch (MatchInstruction(Operands, Inst, ErrorInfo, MatchingInlineAsm,
2758 isParsingIntelSyntax())) {
2764 if (!MatchingInlineAsm)
2765 while (processInstruction(Inst, Operands))
2769 if (!MatchingInlineAsm)
2770 EmitInstruction(Inst, Operands, Out);
2773 case Match_MissingFeature:
2774 return ErrorMissingFeature(IDLoc, ErrorInfo, MatchingInlineAsm);
2775 case Match_InvalidOperand:
2776 WasOriginallyInvalidOperand =
true;
2778 case Match_MnemonicFail:
2792 Op.setTokenValue(Tmp);
2800 const char *Suffixes = Base[0] !=
'f' ?
"bwlq" :
"slt\0";
2803 uint64_t ErrorInfoIgnore;
2804 uint64_t ErrorInfoMissingFeature = 0;
2808 Tmp.
back() = Suffixes[
I];
2809 Match[
I] = MatchInstruction(Operands, Inst, ErrorInfoIgnore,
2810 MatchingInlineAsm, isParsingIntelSyntax());
2812 if (Match[
I] == Match_MissingFeature)
2813 ErrorInfoMissingFeature = ErrorInfoIgnore;
2817 Op.setTokenValue(Base);
2822 unsigned NumSuccessfulMatches =
2824 if (NumSuccessfulMatches == 1) {
2826 if (!MatchingInlineAsm)
2827 EmitInstruction(Inst, Operands, Out);
2836 if (NumSuccessfulMatches > 1) {
2838 unsigned NumMatches = 0;
2840 if (Match[
I] == Match_Success)
2841 MatchChars[NumMatches++] = Suffixes[
I];
2845 OS <<
"ambiguous instructions require an explicit suffix (could be ";
2846 for (
unsigned i = 0; i != NumMatches; ++i) {
2849 if (i + 1 == NumMatches)
2851 OS <<
"'" << Base << MatchChars[i] <<
"'";
2854 Error(IDLoc, OS.str(), EmptyRange, MatchingInlineAsm);
2863 if (!WasOriginallyInvalidOperand) {
2864 return Error(IDLoc,
"invalid instruction mnemonic '" + Base +
"'",
2865 Op.getLocRange(), MatchingInlineAsm);
2869 if (ErrorInfo != ~0ULL) {
2870 if (ErrorInfo >= Operands.
size())
2871 return Error(IDLoc,
"too few operands for instruction", EmptyRange,
2878 OperandRange, MatchingInlineAsm);
2882 return Error(IDLoc,
"invalid operand for instruction", EmptyRange,
2889 Match_MissingFeature) == 1) {
2890 ErrorInfo = ErrorInfoMissingFeature;
2891 return ErrorMissingFeature(IDLoc, ErrorInfoMissingFeature,
2898 Match_InvalidOperand) == 1) {
2899 return Error(IDLoc,
"invalid operand for instruction", EmptyRange,
2904 Error(IDLoc,
"unknown use of instruction mnemonic without a size suffix",
2905 EmptyRange, MatchingInlineAsm);
2909 bool X86AsmParser::MatchAndEmitIntelInstruction(
SMLoc IDLoc,
unsigned &Opcode,
2912 uint64_t &ErrorInfo,
2913 bool MatchingInlineAsm) {
2914 assert(!Operands.
empty() &&
"Unexpect empty operand list!");
2916 assert(Op.isToken() &&
"Leading operand should always be a mnemonic!");
2922 MatchFPUWaitAlias(IDLoc, Op, Operands, Out, MatchingInlineAsm);
2928 for (
const auto &Op : Operands) {
2931 UnsizedMemOp = X86Op;
2941 static const char *
const PtrSizedInstrs[] = {
"call",
"jmp",
"push"};
2942 for (
const char *Instr : PtrSizedInstrs) {
2943 if (Mnemonic == Instr) {
2944 UnsizedMemOp->
Mem.
Size = getPointerWidth();
2951 uint64_t ErrorInfoMissingFeature = 0;
2955 if (Mnemonic ==
"push" && Operands.size() == 2) {
2956 auto *X86Op =
static_cast<X86Operand *
>(Operands[1].get());
2957 if (X86Op->
isImm()) {
2960 unsigned Size = getPointerWidth();
2965 Tmp += (is64BitMode())
2967 : (is32BitMode()) ?
"l" : (is16BitMode()) ?
"w" :
" ";
2968 Op.setTokenValue(Tmp);
2970 Match.
push_back(MatchInstruction(Operands, Inst, ErrorInfo,
2973 Op.setTokenValue(Base);
2982 static const unsigned MopSizes[] = {8, 16, 32, 64, 80, 128, 256, 512};
2983 for (
unsigned Size : MopSizes) {
2985 uint64_t ErrorInfoIgnore;
2987 unsigned M = MatchInstruction(Operands, Inst, ErrorInfoIgnore,
2988 MatchingInlineAsm, isParsingIntelSyntax());
2993 if (Match.
back() == Match_MissingFeature)
2994 ErrorInfoMissingFeature = ErrorInfoIgnore;
3004 if (Match.
empty()) {
3006 Operands, Inst, ErrorInfo, MatchingInlineAsm, isParsingIntelSyntax()));
3008 if (Match.
back() == Match_MissingFeature)
3009 ErrorInfoMissingFeature = ErrorInfo;
3017 if (Match.
back() == Match_MnemonicFail) {
3018 return Error(IDLoc,
"invalid instruction mnemonic '" + Mnemonic +
"'",
3019 Op.getLocRange(), MatchingInlineAsm);
3022 unsigned NumSuccessfulMatches =
3027 if (UnsizedMemOp && NumSuccessfulMatches > 1 &&
3030 unsigned M = MatchInstruction(
3031 Operands, Inst, ErrorInfo, MatchingInlineAsm, isParsingIntelSyntax());
3032 if (M == Match_Success)
3033 NumSuccessfulMatches = 1;
3037 InstInfo->AsmRewrites->emplace_back(
3045 if (NumSuccessfulMatches == 1) {
3049 if (!MatchingInlineAsm)
3050 while (processInstruction(Inst, Operands))
3053 if (!MatchingInlineAsm)
3054 EmitInstruction(Inst, Operands, Out);
3057 }
else if (NumSuccessfulMatches > 1) {
3059 "multiple matches only possible with unsized memory operands");
3061 "ambiguous operand size for instruction '" + Mnemonic +
"\'",
3068 Match_MissingFeature) == 1) {
3069 ErrorInfo = ErrorInfoMissingFeature;
3070 return ErrorMissingFeature(IDLoc, ErrorInfoMissingFeature,
3077 Match_InvalidOperand) == 1) {
3078 return Error(IDLoc,
"invalid operand for instruction", EmptyRange,
3083 return Error(IDLoc,
"unknown instruction mnemonic", EmptyRange,
3087 bool X86AsmParser::OmitRegisterFromClobberLists(
unsigned RegNo) {
3088 return X86MCRegisterClasses[X86::SEGMENT_REGRegClassID].contains(RegNo);
3091 bool X86AsmParser::ParseDirective(
AsmToken DirectiveID) {
3094 if (IDVal ==
".word")
3095 return ParseDirectiveWord(2, DirectiveID.
getLoc());
3097 return ParseDirectiveCode(IDVal, DirectiveID.
getLoc());
3099 getParser().setParsingInlineAsm(
false);
3104 return Error(DirectiveID.
getLoc(),
"'.att_syntax noprefix' is not "
3105 "supported: registers must have a "
3106 "'%' prefix in .att_syntax");
3108 getParser().setAssemblerDialect(0);
3110 }
else if (IDVal.
startswith(
".intel_syntax")) {
3111 getParser().setAssemblerDialect(1);
3112 getParser().setParsingInlineAsm(
true);
3117 return Error(DirectiveID.
getLoc(),
"'.intel_syntax prefix' is not "
3118 "supported: registers must not have "
3119 "a '%' prefix in .intel_syntax");
3122 }
else if (IDVal ==
".even")
3123 return parseDirectiveEven(DirectiveID.
getLoc());
3129 bool X86AsmParser::parseDirectiveEven(
SMLoc L) {
3131 TokError(
"unexpected token in directive");
3136 getStreamer().InitSections(
false);
3137 Section = getStreamer().getCurrentSectionOnly();
3140 getStreamer().EmitCodeAlignment(2, 0);
3142 getStreamer().EmitValueToAlignment(2, 0, 1, 0);
3147 bool X86AsmParser::ParseDirectiveWord(
unsigned Size,
SMLoc L) {
3152 SMLoc ExprLoc = getLexer().getLoc();
3153 if (getParser().parseExpression(Value))
3156 if (
const auto *MCE = dyn_cast<MCConstantExpr>(Value)) {
3157 assert(Size <= 8 &&
"Invalid size");
3158 uint64_t IntValue = MCE->getValue();
3159 if (!
isUIntN(8 * Size, IntValue) && !
isIntN(8 * Size, IntValue))
3160 return Error(ExprLoc,
"literal value out of range for directive");
3161 getStreamer().EmitIntValue(IntValue, Size);
3163 getStreamer().EmitValue(Value, Size, ExprLoc);
3171 Error(L,
"unexpected token in directive");
3184 bool X86AsmParser::ParseDirectiveCode(
StringRef IDVal,
SMLoc L) {
3187 if (IDVal ==
".code16") {
3189 if (!is16BitMode()) {
3190 SwitchMode(X86::Mode16Bit);
3191 getParser().getStreamer().EmitAssemblerFlag(
MCAF_Code16);
3193 }
else if (IDVal ==
".code16gcc") {
3197 if (!is16BitMode()) {
3198 SwitchMode(X86::Mode16Bit);
3199 getParser().getStreamer().EmitAssemblerFlag(
MCAF_Code16);
3201 }
else if (IDVal ==
".code32") {
3203 if (!is32BitMode()) {
3204 SwitchMode(X86::Mode32Bit);
3205 getParser().getStreamer().EmitAssemblerFlag(
MCAF_Code32);
3207 }
else if (IDVal ==
".code64") {
3209 if (!is64BitMode()) {
3210 SwitchMode(X86::Mode64Bit);
3211 getParser().getStreamer().EmitAssemblerFlag(
MCAF_Code64);
3214 Error(L,
"unknown directive " + IDVal);
3227 #define GET_REGISTER_MATCHER
3228 #define GET_MATCHER_IMPLEMENTATION
3229 #define GET_SUBTARGET_FEATURE_NAME
3230 #include "X86GenAsmMatcher.inc"
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
StringRef getToken() const
static const char * getSubtargetFeatureName(uint64_t Val)
Represents a range in source code.
Instances of this class represent a uniqued identifier for a section in the current translation unit...
void push_back(const T &Elt)
const_iterator end(StringRef path)
Get end iterator over path.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool endswith(StringRef Suffix) const
Check if this string ends with the given Suffix.
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
uint64_t getZExtValue() const
Get zero extended value.
bool isX86_64NonExtLowByteReg(unsigned reg)
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
const char * getPointer() const
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
TokenKind getKind() const
SmallVectorImpl< AsmRewrite > * AsmRewrites
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.
MCTargetAsmParser - Generic interface to target specific assembly parsers.
LLVM_NODISCARD bool equals_lower(StringRef RHS) const
equals_lower - Check for string equality, ignoring case.
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
A raw_ostream that writes to an SmallVector or SmallString.
unsigned getMemFrontendSize() const
static std::unique_ptr< X86Operand > CreateMem(unsigned ModeSize, const MCExpr *Disp, SMLoc StartLoc, SMLoc EndLoc, unsigned Size=0, StringRef SymName=StringRef(), void *OpDecl=nullptr, unsigned FrontendSize=0)
Create an absolute memory operand.
LLVM_NODISCARD char back() const
back - Get the last character in the string.
return AArch64::GPR64RegClass contains(Reg)
static ModuleSymbolTable::Symbol getSym(DataRefImpl &Symb)
static bool CheckBaseRegAndIndexReg(unsigned BaseReg, unsigned IndexReg, StringRef &ErrMsg)
}
amode Optimize addressing mode
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
void LLVMInitializeX86AsmParser()
SMLoc getEndLoc() const override
getEndLoc - Get the location of the last token of this operand.
bool isImm() const override
isImm - Is this an immediate operand?
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.
LLVM_ATTRIBUTE_ALWAYS_INLINE R Default(const T &Value) const
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool equals(StringRef RHS) const
equals - Check for string equality, this is more efficient than compare() when the relative ordering ...
Reg
All possible values of the reg field in the ModR/M byte.
Target independent representation for an assembler token.
static unsigned getIntelMemOperandSize(StringRef OpStr)
getIntelMemOperandSize - Return intel memory operand size.
Windows NT (Windows on ARM)
const MCExpr * getImm() const
zlib-gnu style compression
MCParsedAsmOperand - This abstract class represents a source-level assembly instruction operand...
static std::unique_ptr< X86Operand > CreateImm(const MCExpr *Val, SMLoc StartLoc, SMLoc EndLoc)
LLVM_NODISCARD bool empty() const
static bool startswith(StringRef Magic, const char(&S)[N])
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & Case(const char(&S)[N], const T &Value)
unsigned getReg() const override
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
.code16 (X86) / .code 16 (ARM)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
auto count(R &&Range, const E &Element) -> typename std::iterator_traits< decltype(std::begin(Range))>::difference_type
Wrapper function around std::count to count the number of times an element Element occurs in the give...
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
int64_t getIntVal() const
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.
Instances of this class represent a single low-level machine instruction.
virtual void eatToEndOfStatement()=0
Skip to the end of the current statement, for error recovery.
bool isX86_64ExtendedReg(unsigned RegNo)
isX86_64ExtendedReg - Is the MachineOperand a x86-64 extended (r8 or higher) register? e.g.
FeatureBitset ToggleFeature(uint64_t FB)
ToggleFeature - Toggle a feature and returns the re-computed feature bits.
Function Alias Analysis false
const MCExpr * getLHS() const
Get the left-hand side expression of the binary operator.
virtual MCContext & getContext()=0
A switch()-like statement whose cases are string literals.
Streaming machine code generation interface.
X86Operand - Instances of this class represent a parsed X86 machine instruction.
Container class for subtarget features.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t find(char C, size_t From=0) const
Search for the first character C in the string.
SMRange getLocRange() const
getLocRange - Get the range between the first and last token of this operand.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
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")
static const unsigned End
bool Error(SMLoc L, const Twine &Msg, SMRange Range=None)
Return an error at the location L, with the message Msg.
virtual bool UseCodeAlign() const =0
Return true if a .align directive should use "optimized nops" to fill instead of 0s.
bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE int compare(StringRef RHS) const
compare - Compare two strings; the result is -1, 0, or 1 if this string is lexicographically less tha...
iterator erase(const_iterator CI)
Binary assembler expressions.
SMLoc getStartLoc() const override
getStartLoc - Get the location of the first token of this operand.
unsigned getX86SubSuperRegisterOrZero(unsigned, unsigned, bool High=false)
Returns the sub or super register of a specific X86 register.
X86AsmInstrumentation * CreateX86AsmInstrumentation(const MCTargetOptions &MCOptions, const MCContext &Ctx, const MCSubtargetInfo *&STI)
static bool is32ExtendedReg(unsigned RegNo)
is32ExtendedReg - Is the MemoryOperand a 32 extended (zmm16 or higher) registers? e...
void setOpcode(unsigned Op)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
constexpr size_t array_lengthof(T(&)[N])
Find the length of an array.
static void RewriteIntelBracExpression(SmallVectorImpl< AsmRewrite > &AsmRewrites, StringRef SymName, int64_t ImmDisp, int64_t FinalImmDisp, SMLoc &BracLoc, SMLoc &StartInBrac, SMLoc &End)
LLVM_NODISCARD std::string upper() const
Convert the given ASCII string to uppercase.
LLVM_NODISCARD T pop_back_val()
const FeatureBitset & getFeatureBits() const
getFeatureBits - Return the feature bits.
bool is(TokenKind K) const
bool isMemUnsized() const
unsigned getOpcode() const
Class for arbitrary precision integers.
Base class for user error types.
static std::unique_ptr< X86Operand > CreateToken(StringRef Str, SMLoc Loc)
.code32 (X86) / .code 32 (ARM)
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
static SMLoc getFromPointer(const char *Ptr)
llvm_unreachable("Unknown RegBank!")
static std::unique_ptr< X86Operand > CreateReg(unsigned RegNo, SMLoc StartLoc, SMLoc EndLoc, bool AddressOf=false, SMLoc OffsetOfLoc=SMLoc(), StringRef SymName=StringRef(), void *OpDecl=nullptr)
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & Cases(const char(&S0)[N0], const char(&S1)[N1], const T &Value)
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.
void emplace_back(ArgTypes &&...Args)
StringRef getName() const
getName - Get the symbol name.
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
MCSubtargetInfo - Generic base class for all target subtargets.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Target & getTheX86_32Target()
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
static unsigned MatchRegisterName(StringRef Name)
Maps from the set of all register names to a register number.
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.
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).
bool isReg() const override
isReg - Is this a register operand?
StringRef - Represent a constant reference to a string, i.e.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef drop_back(size_t N=1) const
Return a StringRef equal to 'this' but with the last N elements dropped.
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml","ocaml 3.10-compatible collector")
Represents a location in source code.
bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
Target & getTheX86_64Target()
LLVM_NODISCARD std::string lower() const
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx)
bool isMem() const override
isMem - Is this a memory operand?
bool isUndefined(bool SetUsed=true) const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).