LLVM  8.0.1
X86Operand.h
Go to the documentation of this file.
1 //===- X86Operand.h - Parsed X86 machine instruction ------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_LIB_TARGET_X86_ASMPARSER_X86OPERAND_H
11 #define LLVM_LIB_TARGET_X86_ASMPARSER_X86OPERAND_H
12 
15 #include "X86AsmParserCommon.h"
16 #include "llvm/ADT/STLExtras.h"
17 #include "llvm/ADT/StringRef.h"
18 #include "llvm/MC/MCExpr.h"
19 #include "llvm/MC/MCInst.h"
21 #include "llvm/MC/MCRegisterInfo.h"
22 #include "llvm/Support/Casting.h"
24 #include "llvm/Support/SMLoc.h"
25 #include <cassert>
26 #include <memory>
27 
28 namespace llvm {
29 
30 /// X86Operand - Instances of this class represent a parsed X86 machine
31 /// instruction.
32 struct X86Operand final : public MCParsedAsmOperand {
34 
38  void *OpDecl;
39  bool AddressOf;
40 
41  struct TokOp {
42  const char *Data;
43  unsigned Length;
44  };
45 
46  struct RegOp {
47  unsigned RegNo;
48  };
49 
50  struct PrefOp {
51  unsigned Prefixes;
52  };
53 
54  struct ImmOp {
55  const MCExpr *Val;
56  };
57 
58  struct MemOp {
59  unsigned SegReg;
60  const MCExpr *Disp;
61  unsigned BaseReg;
62  unsigned IndexReg;
63  unsigned Scale;
64  unsigned Size;
65  unsigned ModeSize;
66 
67  /// If the memory operand is unsized and there are multiple instruction
68  /// matches, prefer the one with this size.
69  unsigned FrontendSize;
70  };
71 
72  union {
73  struct TokOp Tok;
74  struct RegOp Reg;
75  struct ImmOp Imm;
76  struct MemOp Mem;
77  struct PrefOp Pref;
78  };
79 
80  X86Operand(KindTy K, SMLoc Start, SMLoc End)
81  : Kind(K), StartLoc(Start), EndLoc(End) {}
82 
83  StringRef getSymName() override { return SymName; }
84  void *getOpDecl() override { return OpDecl; }
85 
86  /// getStartLoc - Get the location of the first token of this operand.
87  SMLoc getStartLoc() const override { return StartLoc; }
88 
89  /// getEndLoc - Get the location of the last token of this operand.
90  SMLoc getEndLoc() const override { return EndLoc; }
91 
92  /// getLocRange - Get the range between the first and last token of this
93  /// operand.
94  SMRange getLocRange() const { return SMRange(StartLoc, EndLoc); }
95 
96  /// getOffsetOfLoc - Get the location of the offset operator.
97  SMLoc getOffsetOfLoc() const override { return OffsetOfLoc; }
98 
99  void print(raw_ostream &OS) const override {
100 
101  auto PrintImmValue = [&](const MCExpr *Val, const char *VName) {
102  if (Val->getKind() == MCExpr::Constant) {
103  if (auto Imm = cast<MCConstantExpr>(Val)->getValue())
104  OS << VName << Imm;
105  } else if (Val->getKind() == MCExpr::SymbolRef) {
106  if (auto *SRE = dyn_cast<MCSymbolRefExpr>(Val)) {
107  const MCSymbol &Sym = SRE->getSymbol();
108  if (auto SymName = Sym.getName().data())
109  OS << VName << SymName;
110  }
111  }
112  };
113 
114  switch (Kind) {
115  case Token:
116  OS << Tok.Data;
117  break;
118  case Register:
120  break;
121  case DXRegister:
122  OS << "DXReg";
123  break;
124  case Immediate:
125  PrintImmValue(Imm.Val, "Imm:");
126  break;
127  case Prefix:
128  OS << "Prefix:" << Pref.Prefixes;
129  break;
130  case Memory:
131  OS << "Memory: ModeSize=" << Mem.ModeSize;
132  if (Mem.Size)
133  OS << ",Size=" << Mem.Size;
134  if (Mem.BaseReg)
135  OS << ",BaseReg=" << X86IntelInstPrinter::getRegisterName(Mem.BaseReg);
136  if (Mem.IndexReg)
137  OS << ",IndexReg="
139  if (Mem.Scale)
140  OS << ",Scale=" << Mem.Scale;
141  if (Mem.Disp)
142  PrintImmValue(Mem.Disp, ",Disp=");
143  if (Mem.SegReg)
144  OS << ",SegReg=" << X86IntelInstPrinter::getRegisterName(Mem.SegReg);
145  break;
146  }
147  }
148 
149  StringRef getToken() const {
150  assert(Kind == Token && "Invalid access!");
151  return StringRef(Tok.Data, Tok.Length);
152  }
154  assert(Kind == Token && "Invalid access!");
155  Tok.Data = Value.data();
156  Tok.Length = Value.size();
157  }
158 
159  unsigned getReg() const override {
160  assert(Kind == Register && "Invalid access!");
161  return Reg.RegNo;
162  }
163 
164  unsigned getPrefix() const {
165  assert(Kind == Prefix && "Invalid access!");
166  return Pref.Prefixes;
167  }
168 
169  const MCExpr *getImm() const {
170  assert(Kind == Immediate && "Invalid access!");
171  return Imm.Val;
172  }
173 
174  const MCExpr *getMemDisp() const {
175  assert(Kind == Memory && "Invalid access!");
176  return Mem.Disp;
177  }
178  unsigned getMemSegReg() const {
179  assert(Kind == Memory && "Invalid access!");
180  return Mem.SegReg;
181  }
182  unsigned getMemBaseReg() const {
183  assert(Kind == Memory && "Invalid access!");
184  return Mem.BaseReg;
185  }
186  unsigned getMemIndexReg() const {
187  assert(Kind == Memory && "Invalid access!");
188  return Mem.IndexReg;
189  }
190  unsigned getMemScale() const {
191  assert(Kind == Memory && "Invalid access!");
192  return Mem.Scale;
193  }
194  unsigned getMemModeSize() const {
195  assert(Kind == Memory && "Invalid access!");
196  return Mem.ModeSize;
197  }
198  unsigned getMemFrontendSize() const {
199  assert(Kind == Memory && "Invalid access!");
200  return Mem.FrontendSize;
201  }
202 
203  bool isToken() const override {return Kind == Token; }
204 
205  bool isImm() const override { return Kind == Immediate; }
206 
207  bool isImmSExti16i8() const {
208  if (!isImm())
209  return false;
210 
211  // If this isn't a constant expr, just assume it fits and let relaxation
212  // handle it.
214  if (!CE)
215  return true;
216 
217  // Otherwise, check the value is in a range that makes sense for this
218  // extension.
219  return isImmSExti16i8Value(CE->getValue());
220  }
221  bool isImmSExti32i8() const {
222  if (!isImm())
223  return false;
224 
225  // If this isn't a constant expr, just assume it fits and let relaxation
226  // handle it.
228  if (!CE)
229  return true;
230 
231  // Otherwise, check the value is in a range that makes sense for this
232  // extension.
233  return isImmSExti32i8Value(CE->getValue());
234  }
235  bool isImmSExti64i8() const {
236  if (!isImm())
237  return false;
238 
239  // If this isn't a constant expr, just assume it fits and let relaxation
240  // handle it.
242  if (!CE)
243  return true;
244 
245  // Otherwise, check the value is in a range that makes sense for this
246  // extension.
247  return isImmSExti64i8Value(CE->getValue());
248  }
249  bool isImmSExti64i32() const {
250  if (!isImm())
251  return false;
252 
253  // If this isn't a constant expr, just assume it fits and let relaxation
254  // handle it.
256  if (!CE)
257  return true;
258 
259  // Otherwise, check the value is in a range that makes sense for this
260  // extension.
261  return isImmSExti64i32Value(CE->getValue());
262  }
263 
264  bool isImmUnsignedi8() const {
265  if (!isImm()) return false;
266  // If this isn't a constant expr, just assume it fits and let relaxation
267  // handle it.
269  if (!CE) return true;
270  return isImmUnsignedi8Value(CE->getValue());
271  }
272 
273  bool isOffsetOf() const override {
274  return OffsetOfLoc.getPointer();
275  }
276 
277  bool needAddressOf() const override {
278  return AddressOf;
279  }
280 
281  bool isMem() const override { return Kind == Memory; }
282  bool isMemUnsized() const {
283  return Kind == Memory && Mem.Size == 0;
284  }
285  bool isMem8() const {
286  return Kind == Memory && (!Mem.Size || Mem.Size == 8);
287  }
288  bool isMem16() const {
289  return Kind == Memory && (!Mem.Size || Mem.Size == 16);
290  }
291  bool isMem32() const {
292  return Kind == Memory && (!Mem.Size || Mem.Size == 32);
293  }
294  bool isMem64() const {
295  return Kind == Memory && (!Mem.Size || Mem.Size == 64);
296  }
297  bool isMem80() const {
298  return Kind == Memory && (!Mem.Size || Mem.Size == 80);
299  }
300  bool isMem128() const {
301  return Kind == Memory && (!Mem.Size || Mem.Size == 128);
302  }
303  bool isMem256() const {
304  return Kind == Memory && (!Mem.Size || Mem.Size == 256);
305  }
306  bool isMem512() const {
307  return Kind == Memory && (!Mem.Size || Mem.Size == 512);
308  }
309  bool isMemIndexReg(unsigned LowR, unsigned HighR) const {
310  assert(Kind == Memory && "Invalid access!");
311  return Mem.IndexReg >= LowR && Mem.IndexReg <= HighR;
312  }
313 
314  bool isMem64_RC128() const {
315  return isMem64() && isMemIndexReg(X86::XMM0, X86::XMM15);
316  }
317  bool isMem128_RC128() const {
318  return isMem128() && isMemIndexReg(X86::XMM0, X86::XMM15);
319  }
320  bool isMem128_RC256() const {
321  return isMem128() && isMemIndexReg(X86::YMM0, X86::YMM15);
322  }
323  bool isMem256_RC128() const {
324  return isMem256() && isMemIndexReg(X86::XMM0, X86::XMM15);
325  }
326  bool isMem256_RC256() const {
327  return isMem256() && isMemIndexReg(X86::YMM0, X86::YMM15);
328  }
329 
330  bool isMem64_RC128X() const {
331  return isMem64() && isMemIndexReg(X86::XMM0, X86::XMM31);
332  }
333  bool isMem128_RC128X() const {
334  return isMem128() && isMemIndexReg(X86::XMM0, X86::XMM31);
335  }
336  bool isMem128_RC256X() const {
337  return isMem128() && isMemIndexReg(X86::YMM0, X86::YMM31);
338  }
339  bool isMem256_RC128X() const {
340  return isMem256() && isMemIndexReg(X86::XMM0, X86::XMM31);
341  }
342  bool isMem256_RC256X() const {
343  return isMem256() && isMemIndexReg(X86::YMM0, X86::YMM31);
344  }
345  bool isMem256_RC512() const {
346  return isMem256() && isMemIndexReg(X86::ZMM0, X86::ZMM31);
347  }
348  bool isMem512_RC256X() const {
349  return isMem512() && isMemIndexReg(X86::YMM0, X86::YMM31);
350  }
351  bool isMem512_RC512() const {
352  return isMem512() && isMemIndexReg(X86::ZMM0, X86::ZMM31);
353  }
354 
355  bool isAbsMem() const {
356  return Kind == Memory && !getMemSegReg() && !getMemBaseReg() &&
357  !getMemIndexReg() && getMemScale() == 1;
358  }
359  bool isAVX512RC() const{
360  return isImm();
361  }
362 
363  bool isAbsMem16() const {
364  return isAbsMem() && Mem.ModeSize == 16;
365  }
366 
367  bool isSrcIdx() const {
368  return !getMemIndexReg() && getMemScale() == 1 &&
369  (getMemBaseReg() == X86::RSI || getMemBaseReg() == X86::ESI ||
370  getMemBaseReg() == X86::SI) && isa<MCConstantExpr>(getMemDisp()) &&
371  cast<MCConstantExpr>(getMemDisp())->getValue() == 0;
372  }
373  bool isSrcIdx8() const {
374  return isMem8() && isSrcIdx();
375  }
376  bool isSrcIdx16() const {
377  return isMem16() && isSrcIdx();
378  }
379  bool isSrcIdx32() const {
380  return isMem32() && isSrcIdx();
381  }
382  bool isSrcIdx64() const {
383  return isMem64() && isSrcIdx();
384  }
385 
386  bool isDstIdx() const {
387  return !getMemIndexReg() && getMemScale() == 1 &&
388  (getMemSegReg() == 0 || getMemSegReg() == X86::ES) &&
389  (getMemBaseReg() == X86::RDI || getMemBaseReg() == X86::EDI ||
390  getMemBaseReg() == X86::DI) && isa<MCConstantExpr>(getMemDisp()) &&
391  cast<MCConstantExpr>(getMemDisp())->getValue() == 0;
392  }
393  bool isDstIdx8() const {
394  return isMem8() && isDstIdx();
395  }
396  bool isDstIdx16() const {
397  return isMem16() && isDstIdx();
398  }
399  bool isDstIdx32() const {
400  return isMem32() && isDstIdx();
401  }
402  bool isDstIdx64() const {
403  return isMem64() && isDstIdx();
404  }
405 
406  bool isMemOffs() const {
407  return Kind == Memory && !getMemBaseReg() && !getMemIndexReg() &&
408  getMemScale() == 1;
409  }
410 
411  bool isMemOffs16_8() const {
412  return isMemOffs() && Mem.ModeSize == 16 && (!Mem.Size || Mem.Size == 8);
413  }
414  bool isMemOffs16_16() const {
415  return isMemOffs() && Mem.ModeSize == 16 && (!Mem.Size || Mem.Size == 16);
416  }
417  bool isMemOffs16_32() const {
418  return isMemOffs() && Mem.ModeSize == 16 && (!Mem.Size || Mem.Size == 32);
419  }
420  bool isMemOffs32_8() const {
421  return isMemOffs() && Mem.ModeSize == 32 && (!Mem.Size || Mem.Size == 8);
422  }
423  bool isMemOffs32_16() const {
424  return isMemOffs() && Mem.ModeSize == 32 && (!Mem.Size || Mem.Size == 16);
425  }
426  bool isMemOffs32_32() const {
427  return isMemOffs() && Mem.ModeSize == 32 && (!Mem.Size || Mem.Size == 32);
428  }
429  bool isMemOffs32_64() const {
430  return isMemOffs() && Mem.ModeSize == 32 && (!Mem.Size || Mem.Size == 64);
431  }
432  bool isMemOffs64_8() const {
433  return isMemOffs() && Mem.ModeSize == 64 && (!Mem.Size || Mem.Size == 8);
434  }
435  bool isMemOffs64_16() const {
436  return isMemOffs() && Mem.ModeSize == 64 && (!Mem.Size || Mem.Size == 16);
437  }
438  bool isMemOffs64_32() const {
439  return isMemOffs() && Mem.ModeSize == 64 && (!Mem.Size || Mem.Size == 32);
440  }
441  bool isMemOffs64_64() const {
442  return isMemOffs() && Mem.ModeSize == 64 && (!Mem.Size || Mem.Size == 64);
443  }
444 
445  bool isPrefix() const { return Kind == Prefix; }
446  bool isReg() const override { return Kind == Register; }
447  bool isDXReg() const { return Kind == DXRegister; }
448 
449  bool isGR32orGR64() const {
450  return Kind == Register &&
451  (X86MCRegisterClasses[X86::GR32RegClassID].contains(getReg()) ||
452  X86MCRegisterClasses[X86::GR64RegClassID].contains(getReg()));
453  }
454 
455  void addExpr(MCInst &Inst, const MCExpr *Expr) const {
456  // Add as immediates when possible.
457  if (const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(Expr))
458  Inst.addOperand(MCOperand::createImm(CE->getValue()));
459  else
460  Inst.addOperand(MCOperand::createExpr(Expr));
461  }
462 
463  void addRegOperands(MCInst &Inst, unsigned N) const {
464  assert(N == 1 && "Invalid number of operands!");
466  }
467 
468  void addGR32orGR64Operands(MCInst &Inst, unsigned N) const {
469  assert(N == 1 && "Invalid number of operands!");
470  unsigned RegNo = getReg();
471  if (X86MCRegisterClasses[X86::GR64RegClassID].contains(RegNo))
472  RegNo = getX86SubSuperRegister(RegNo, 32);
473  Inst.addOperand(MCOperand::createReg(RegNo));
474  }
475 
476  void addAVX512RCOperands(MCInst &Inst, unsigned N) const {
477  assert(N == 1 && "Invalid number of operands!");
478  addExpr(Inst, getImm());
479  }
480 
481  void addImmOperands(MCInst &Inst, unsigned N) const {
482  assert(N == 1 && "Invalid number of operands!");
483  addExpr(Inst, getImm());
484  }
485 
486  void addMemOperands(MCInst &Inst, unsigned N) const {
487  assert((N == 5) && "Invalid number of operands!");
491  addExpr(Inst, getMemDisp());
493  }
494 
495  void addAbsMemOperands(MCInst &Inst, unsigned N) const {
496  assert((N == 1) && "Invalid number of operands!");
497  // Add as immediates when possible.
498  if (const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(getMemDisp()))
499  Inst.addOperand(MCOperand::createImm(CE->getValue()));
500  else
502  }
503 
504  void addSrcIdxOperands(MCInst &Inst, unsigned N) const {
505  assert((N == 2) && "Invalid number of operands!");
508  }
509 
510  void addDstIdxOperands(MCInst &Inst, unsigned N) const {
511  assert((N == 1) && "Invalid number of operands!");
513  }
514 
515  void addMemOffsOperands(MCInst &Inst, unsigned N) const {
516  assert((N == 2) && "Invalid number of operands!");
517  // Add as immediates when possible.
518  if (const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(getMemDisp()))
519  Inst.addOperand(MCOperand::createImm(CE->getValue()));
520  else
523  }
524 
525  static std::unique_ptr<X86Operand> CreateToken(StringRef Str, SMLoc Loc) {
526  SMLoc EndLoc = SMLoc::getFromPointer(Loc.getPointer() + Str.size());
527  auto Res = llvm::make_unique<X86Operand>(Token, Loc, EndLoc);
528  Res->Tok.Data = Str.data();
529  Res->Tok.Length = Str.size();
530  return Res;
531  }
532 
533  static std::unique_ptr<X86Operand>
534  CreateReg(unsigned RegNo, SMLoc StartLoc, SMLoc EndLoc,
535  bool AddressOf = false, SMLoc OffsetOfLoc = SMLoc(),
536  StringRef SymName = StringRef(), void *OpDecl = nullptr) {
537  auto Res = llvm::make_unique<X86Operand>(Register, StartLoc, EndLoc);
538  Res->Reg.RegNo = RegNo;
539  Res->AddressOf = AddressOf;
540  Res->OffsetOfLoc = OffsetOfLoc;
541  Res->SymName = SymName;
542  Res->OpDecl = OpDecl;
543  return Res;
544  }
545 
546  static std::unique_ptr<X86Operand>
547  CreateDXReg(SMLoc StartLoc, SMLoc EndLoc) {
548  return llvm::make_unique<X86Operand>(DXRegister, StartLoc, EndLoc);
549  }
550 
551  static std::unique_ptr<X86Operand>
552  CreatePrefix(unsigned Prefixes, SMLoc StartLoc, SMLoc EndLoc) {
553  auto Res = llvm::make_unique<X86Operand>(Prefix, StartLoc, EndLoc);
554  Res->Pref.Prefixes = Prefixes;
555  return Res;
556  }
557 
558  static std::unique_ptr<X86Operand> CreateImm(const MCExpr *Val,
559  SMLoc StartLoc, SMLoc EndLoc) {
560  auto Res = llvm::make_unique<X86Operand>(Immediate, StartLoc, EndLoc);
561  Res->Imm.Val = Val;
562  return Res;
563  }
564 
565  /// Create an absolute memory operand.
566  static std::unique_ptr<X86Operand>
567  CreateMem(unsigned ModeSize, const MCExpr *Disp, SMLoc StartLoc, SMLoc EndLoc,
568  unsigned Size = 0, StringRef SymName = StringRef(),
569  void *OpDecl = nullptr, unsigned FrontendSize = 0) {
570  auto Res = llvm::make_unique<X86Operand>(Memory, StartLoc, EndLoc);
571  Res->Mem.SegReg = 0;
572  Res->Mem.Disp = Disp;
573  Res->Mem.BaseReg = 0;
574  Res->Mem.IndexReg = 0;
575  Res->Mem.Scale = 1;
576  Res->Mem.Size = Size;
577  Res->Mem.ModeSize = ModeSize;
578  Res->Mem.FrontendSize = FrontendSize;
579  Res->SymName = SymName;
580  Res->OpDecl = OpDecl;
581  Res->AddressOf = false;
582  return Res;
583  }
584 
585  /// Create a generalized memory operand.
586  static std::unique_ptr<X86Operand>
587  CreateMem(unsigned ModeSize, unsigned SegReg, const MCExpr *Disp,
588  unsigned BaseReg, unsigned IndexReg, unsigned Scale, SMLoc StartLoc,
589  SMLoc EndLoc, unsigned Size = 0, StringRef SymName = StringRef(),
590  void *OpDecl = nullptr, unsigned FrontendSize = 0) {
591  // We should never just have a displacement, that should be parsed as an
592  // absolute memory operand.
593  assert((SegReg || BaseReg || IndexReg) && "Invalid memory operand!");
594 
595  // The scale should always be one of {1,2,4,8}.
596  assert(((Scale == 1 || Scale == 2 || Scale == 4 || Scale == 8)) &&
597  "Invalid scale!");
598  auto Res = llvm::make_unique<X86Operand>(Memory, StartLoc, EndLoc);
599  Res->Mem.SegReg = SegReg;
600  Res->Mem.Disp = Disp;
601  Res->Mem.BaseReg = BaseReg;
602  Res->Mem.IndexReg = IndexReg;
603  Res->Mem.Scale = Scale;
604  Res->Mem.Size = Size;
605  Res->Mem.ModeSize = ModeSize;
606  Res->Mem.FrontendSize = FrontendSize;
607  Res->SymName = SymName;
608  Res->OpDecl = OpDecl;
609  Res->AddressOf = false;
610  return Res;
611  }
612 };
613 
614 } // end namespace llvm
615 
616 #endif // LLVM_LIB_TARGET_X86_ASMPARSER_X86OPERAND_H
bool isDstIdx32() const
Definition: X86Operand.h:399
Represents a range in source code.
Definition: SMLoc.h:49
bool isMem64_RC128X() const
Definition: X86Operand.h:330
bool isGR32orGR64() const
Definition: X86Operand.h:449
unsigned getMemFrontendSize() const
Definition: X86Operand.h:198
bool isMem256_RC256() const
Definition: X86Operand.h:326
const MCExpr * Val
Definition: X86Operand.h:55
This class represents lattice values for constants.
Definition: AllocatorList.h:24
SMLoc getOffsetOfLoc() const override
getOffsetOfLoc - Get the location of the offset operator.
Definition: X86Operand.h:97
SMRange getLocRange() const
getLocRange - Get the range between the first and last token of this operand.
Definition: X86Operand.h:94
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:42
bool isMemOffs16_32() const
Definition: X86Operand.h:417
bool isImmUnsignedi8Value(uint64_t Value)
bool isMemOffs32_8() const
Definition: X86Operand.h:420
static MCOperand createExpr(const MCExpr *Val)
Definition: MCInst.h:137
This class provides various memory handling functions that manipulate MemoryBlock instances...
Definition: Memory.h:46
unsigned getMemModeSize() const
Definition: X86Operand.h:194
struct ImmOp Imm
Definition: X86Operand.h:75
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
Definition: StringRef.h:138
bool isSrcIdx32() const
Definition: X86Operand.h:379
bool isSrcIdx8() const
Definition: X86Operand.h:373
bool isImmSExti64i8() const
Definition: X86Operand.h:235
bool isAbsMem16() const
Definition: X86Operand.h:363
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.
Definition: X86Operand.h:567
bool isMem64_RC128() const
Definition: X86Operand.h:314
bool isMemOffs64_8() const
Definition: X86Operand.h:432
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).
Definition: StringRef.h:128
bool isMem80() const
Definition: X86Operand.h:297
bool isDstIdx8() const
Definition: X86Operand.h:393
return AArch64::GPR64RegClass contains(Reg)
StringRef getToken() const
Definition: X86Operand.h:149
bool isSrcIdx16() const
Definition: X86Operand.h:376
unsigned FrontendSize
If the memory operand is unsized and there are multiple instruction matches, prefer the one with this...
Definition: X86Operand.h:69
void addSrcIdxOperands(MCInst &Inst, unsigned N) const
Definition: X86Operand.h:504
static MCOperand createReg(unsigned Reg)
Definition: MCInst.h:116
bool isImmSExti64i8Value(uint64_t Value)
unsigned getPrefix() const
Definition: X86Operand.h:164
bool isMemUnsized() const
Definition: X86Operand.h:282
SMLoc getEndLoc() const override
getEndLoc - Get the location of the last token of this operand.
Definition: X86Operand.h:90
bool isMemOffs64_64() const
Definition: X86Operand.h:441
void addRegOperands(MCInst &Inst, unsigned N) const
Definition: X86Operand.h:463
bool isImm() const override
isImm - Is this an immediate operand?
Definition: X86Operand.h:205
bool isMem128_RC256() const
Definition: X86Operand.h:320
bool isMem128_RC256X() const
Definition: X86Operand.h:336
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:36
bool isImmSExti16i8() const
Definition: X86Operand.h:207
bool isMem512_RC512() const
Definition: X86Operand.h:351
bool isMem8() const
Definition: X86Operand.h:285
bool isMem256_RC128() const
Definition: X86Operand.h:323
MCParsedAsmOperand - This abstract class represents a source-level assembly instruction operand...
static std::unique_ptr< X86Operand > CreateImm(const MCExpr *Val, SMLoc StartLoc, SMLoc EndLoc)
Definition: X86Operand.h:558
static std::unique_ptr< X86Operand > CreateMem(unsigned ModeSize, unsigned SegReg, const MCExpr *Disp, unsigned BaseReg, unsigned IndexReg, unsigned Scale, SMLoc StartLoc, SMLoc EndLoc, unsigned Size=0, StringRef SymName=StringRef(), void *OpDecl=nullptr, unsigned FrontendSize=0)
Create a generalized memory operand.
Definition: X86Operand.h:587
StringRef getSymName() override
Definition: X86Operand.h:83
bool isImmSExti64i32Value(uint64_t Value)
unsigned getReg() const override
Definition: X86Operand.h:159
bool isImmSExti16i8Value(uint64_t Value)
bool isMemOffs32_64() const
Definition: X86Operand.h:429
bool isAVX512RC() const
Definition: X86Operand.h:359
bool isImmUnsignedi8() const
Definition: X86Operand.h:264
void addMemOffsOperands(MCInst &Inst, unsigned N) const
Definition: X86Operand.h:515
bool isMem256_RC256X() const
Definition: X86Operand.h:342
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:161
bool isMem512() const
Definition: X86Operand.h:306
bool isSrcIdx() const
Definition: X86Operand.h:367
bool isPrefix() const
Definition: X86Operand.h:445
void addAbsMemOperands(MCInst &Inst, unsigned N) const
Definition: X86Operand.h:495
struct TokOp Tok
Definition: X86Operand.h:73
const char * getPointer() const
Definition: SMLoc.h:35
int64_t getValue() const
Definition: MCExpr.h:152
bool isMem256() const
Definition: X86Operand.h:303
X86Operand - Instances of this class represent a parsed X86 machine instruction.
Definition: X86Operand.h:32
void addGR32orGR64Operands(MCInst &Inst, unsigned N) const
Definition: X86Operand.h:468
bool isMem256_RC512() const
Definition: X86Operand.h:345
bool isDstIdx16() const
Definition: X86Operand.h:396
void addAVX512RCOperands(MCInst &Inst, unsigned N) const
Definition: X86Operand.h:476
unsigned getMemBaseReg() const
Definition: X86Operand.h:182
const MCExpr * getImm() const
Definition: X86Operand.h:169
bool isImmSExti64i32() const
Definition: X86Operand.h:249
bool isMemOffs64_16() const
Definition: X86Operand.h:435
static std::unique_ptr< X86Operand > CreateDXReg(SMLoc StartLoc, SMLoc EndLoc)
Definition: X86Operand.h:547
bool isMem128_RC128() const
Definition: X86Operand.h:317
static const char * getRegisterName(unsigned RegNo)
bool isMem512_RC256X() const
Definition: X86Operand.h:348
void setTokenValue(StringRef Value)
Definition: X86Operand.h:153
void addExpr(MCInst &Inst, const MCExpr *Expr) const
Definition: X86Operand.h:455
bool isToken() const override
isToken - Is this a token operand?
Definition: X86Operand.h:203
SMLoc getStartLoc() const override
getStartLoc - Get the location of the first token of this operand.
Definition: X86Operand.h:87
bool isMem32() const
Definition: X86Operand.h:291
bool isMemOffs64_32() const
Definition: X86Operand.h:438
StringRef SymName
Definition: X86Operand.h:37
bool isMemOffs32_32() const
Definition: X86Operand.h:426
void * getOpDecl() override
Definition: X86Operand.h:84
unsigned getMemScale() const
Definition: X86Operand.h:190
ExprKind getKind() const
Definition: MCExpr.h:73
bool isDstIdx() const
Definition: X86Operand.h:386
struct MemOp Mem
Definition: X86Operand.h:76
bool isMem128_RC128X() const
Definition: X86Operand.h:333
void addImmOperands(MCInst &Inst, unsigned N) const
Definition: X86Operand.h:481
bool isMem256_RC128X() const
Definition: X86Operand.h:339
bool isOffsetOf() const override
isOffsetOf - Do we need to emit code to get the offset of the variable, rather then the value of the ...
Definition: X86Operand.h:273
unsigned getX86SubSuperRegister(unsigned, unsigned, bool High=false)
Returns the sub or super register of a specific X86 register.
bool isMemOffs16_16() const
Definition: X86Operand.h:414
void print(raw_ostream &OS) const override
print - Print a debug representation of the operand to the given stream.
Definition: X86Operand.h:99
static std::unique_ptr< X86Operand > CreateToken(StringRef Str, SMLoc Loc)
Definition: X86Operand.h:525
static SMLoc getFromPointer(const char *Ptr)
Definition: SMLoc.h:37
static std::unique_ptr< X86Operand > CreateReg(unsigned RegNo, SMLoc StartLoc, SMLoc EndLoc, bool AddressOf=false, SMLoc OffsetOfLoc=SMLoc(), StringRef SymName=StringRef(), void *OpDecl=nullptr)
Definition: X86Operand.h:534
bool isMemOffs() const
Definition: X86Operand.h:406
struct RegOp Reg
Definition: X86Operand.h:74
bool isSrcIdx64() const
Definition: X86Operand.h:382
unsigned getMemIndexReg() const
Definition: X86Operand.h:186
bool isDstIdx64() const
Definition: X86Operand.h:402
X86Operand(KindTy K, SMLoc Start, SMLoc End)
Definition: X86Operand.h:80
bool isAbsMem() const
Definition: X86Operand.h:355
#define N
bool isImmSExti32i8() const
Definition: X86Operand.h:221
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Definition: Casting.h:323
References to labels and assigned expressions.
Definition: MCExpr.h:41
bool isMemOffs32_16() const
Definition: X86Operand.h:423
uint32_t Size
Definition: Profile.cpp:47
bool isMem64() const
Definition: X86Operand.h:294
bool isMem16() const
Definition: X86Operand.h:288
StringRef getName() const
getName - Get the symbol name.
Definition: MCSymbol.h:203
bool isDXReg() const
Definition: X86Operand.h:447
static std::unique_ptr< X86Operand > CreatePrefix(unsigned Prefixes, SMLoc StartLoc, SMLoc EndLoc)
Definition: X86Operand.h:552
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void addMemOperands(MCInst &Inst, unsigned N) const
Definition: X86Operand.h:486
LLVM Value Representation.
Definition: Value.h:73
const MCExpr * getMemDisp() const
Definition: X86Operand.h:174
struct PrefOp Pref
Definition: X86Operand.h:77
Constant expressions.
Definition: MCExpr.h:40
bool isImmSExti32i8Value(uint64_t Value)
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46
bool isReg() const override
isReg - Is this a register operand?
Definition: X86Operand.h:446
void addOperand(const MCOperand &Op)
Definition: MCInst.h:186
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
const MCExpr * Disp
Definition: X86Operand.h:60
bool isMem128() const
Definition: X86Operand.h:300
enum llvm::X86Operand::KindTy Kind
unsigned getMemSegReg() const
Definition: X86Operand.h:178
Represents a location in source code.
Definition: SMLoc.h:24
void addDstIdxOperands(MCInst &Inst, unsigned N) const
Definition: X86Operand.h:510
bool isMemOffs16_8() const
Definition: X86Operand.h:411
bool isMemIndexReg(unsigned LowR, unsigned HighR) const
Definition: X86Operand.h:309
static MCOperand createImm(int64_t Val)
Definition: MCInst.h:123
bool isMem() const override
isMem - Is this a memory operand?
Definition: X86Operand.h:281
bool needAddressOf() const override
needAddressOf - Do we need to emit code to get the address of the variable/label? Only valid when par...
Definition: X86Operand.h:277