LLVM  5.0.0
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 
13 #include "X86AsmParserCommon.h"
14 #include "llvm/ADT/STLExtras.h"
15 #include "llvm/ADT/StringRef.h"
16 #include "llvm/MC/MCExpr.h"
17 #include "llvm/MC/MCInst.h"
19 #include "llvm/MC/MCRegisterInfo.h"
20 #include "llvm/Support/Casting.h"
22 #include "llvm/Support/SMLoc.h"
23 #include <cassert>
24 #include <memory>
25 
26 namespace llvm {
27 
28 /// X86Operand - Instances of this class represent a parsed X86 machine
29 /// instruction.
30 struct X86Operand : public MCParsedAsmOperand {
31  enum KindTy {
36  } Kind;
37 
41  void *OpDecl;
42  bool AddressOf;
43 
44  struct TokOp {
45  const char *Data;
46  unsigned Length;
47  };
48 
49  struct RegOp {
50  unsigned RegNo;
51  };
52 
53  struct ImmOp {
54  const MCExpr *Val;
55  };
56 
57  struct MemOp {
58  unsigned SegReg;
59  const MCExpr *Disp;
60  unsigned BaseReg;
61  unsigned IndexReg;
62  unsigned Scale;
63  unsigned Size;
64  unsigned ModeSize;
65 
66  /// If the memory operand is unsized and there are multiple instruction
67  /// matches, prefer the one with this size.
68  unsigned FrontendSize;
69  };
70 
71  union {
72  struct TokOp Tok;
73  struct RegOp Reg;
74  struct ImmOp Imm;
75  struct MemOp Mem;
76  };
77 
79  : Kind(K), StartLoc(Start), EndLoc(End) {}
80 
81  StringRef getSymName() override { return SymName; }
82  void *getOpDecl() override { return OpDecl; }
83 
84  /// getStartLoc - Get the location of the first token of this operand.
85  SMLoc getStartLoc() const override { return StartLoc; }
86 
87  /// getEndLoc - Get the location of the last token of this operand.
88  SMLoc getEndLoc() const override { return EndLoc; }
89 
90  /// getLocRange - Get the range between the first and last token of this
91  /// operand.
92  SMRange getLocRange() const { return SMRange(StartLoc, EndLoc); }
93 
94  /// getOffsetOfLoc - Get the location of the offset operator.
95  SMLoc getOffsetOfLoc() const override { return OffsetOfLoc; }
96 
97  void print(raw_ostream &OS) const override {}
98 
99  StringRef getToken() const {
100  assert(Kind == Token && "Invalid access!");
101  return StringRef(Tok.Data, Tok.Length);
102  }
104  assert(Kind == Token && "Invalid access!");
105  Tok.Data = Value.data();
106  Tok.Length = Value.size();
107  }
108 
109  unsigned getReg() const override {
110  assert(Kind == Register && "Invalid access!");
111  return Reg.RegNo;
112  }
113 
114  const MCExpr *getImm() const {
115  assert(Kind == Immediate && "Invalid access!");
116  return Imm.Val;
117  }
118 
119  const MCExpr *getMemDisp() const {
120  assert(Kind == Memory && "Invalid access!");
121  return Mem.Disp;
122  }
123  unsigned getMemSegReg() const {
124  assert(Kind == Memory && "Invalid access!");
125  return Mem.SegReg;
126  }
127  unsigned getMemBaseReg() const {
128  assert(Kind == Memory && "Invalid access!");
129  return Mem.BaseReg;
130  }
131  unsigned getMemIndexReg() const {
132  assert(Kind == Memory && "Invalid access!");
133  return Mem.IndexReg;
134  }
135  unsigned getMemScale() const {
136  assert(Kind == Memory && "Invalid access!");
137  return Mem.Scale;
138  }
139  unsigned getMemModeSize() const {
140  assert(Kind == Memory && "Invalid access!");
141  return Mem.ModeSize;
142  }
143  unsigned getMemFrontendSize() const {
144  assert(Kind == Memory && "Invalid access!");
145  return Mem.FrontendSize;
146  }
147 
148  bool isToken() const override {return Kind == Token; }
149 
150  bool isImm() const override { return Kind == Immediate; }
151 
152  bool isImmSExti16i8() const {
153  if (!isImm())
154  return false;
155 
156  // If this isn't a constant expr, just assume it fits and let relaxation
157  // handle it.
159  if (!CE)
160  return true;
161 
162  // Otherwise, check the value is in a range that makes sense for this
163  // extension.
164  return isImmSExti16i8Value(CE->getValue());
165  }
166  bool isImmSExti32i8() const {
167  if (!isImm())
168  return false;
169 
170  // If this isn't a constant expr, just assume it fits and let relaxation
171  // handle it.
173  if (!CE)
174  return true;
175 
176  // Otherwise, check the value is in a range that makes sense for this
177  // extension.
178  return isImmSExti32i8Value(CE->getValue());
179  }
180  bool isImmSExti64i8() const {
181  if (!isImm())
182  return false;
183 
184  // If this isn't a constant expr, just assume it fits and let relaxation
185  // handle it.
187  if (!CE)
188  return true;
189 
190  // Otherwise, check the value is in a range that makes sense for this
191  // extension.
192  return isImmSExti64i8Value(CE->getValue());
193  }
194  bool isImmSExti64i32() const {
195  if (!isImm())
196  return false;
197 
198  // If this isn't a constant expr, just assume it fits and let relaxation
199  // handle it.
201  if (!CE)
202  return true;
203 
204  // Otherwise, check the value is in a range that makes sense for this
205  // extension.
206  return isImmSExti64i32Value(CE->getValue());
207  }
208 
209  bool isImmUnsignedi8() const {
210  if (!isImm()) return false;
211  // If this isn't a constant expr, just assume it fits and let relaxation
212  // handle it.
214  if (!CE) return true;
215  return isImmUnsignedi8Value(CE->getValue());
216  }
217 
218  bool isOffsetOf() const override {
219  return OffsetOfLoc.getPointer();
220  }
221 
222  bool needAddressOf() const override {
223  return AddressOf;
224  }
225 
226  bool isMem() const override { return Kind == Memory; }
227  bool isMemUnsized() const {
228  return Kind == Memory && Mem.Size == 0;
229  }
230  bool isMem8() const {
231  return Kind == Memory && (!Mem.Size || Mem.Size == 8);
232  }
233  bool isMem16() const {
234  return Kind == Memory && (!Mem.Size || Mem.Size == 16);
235  }
236  bool isMem32() const {
237  return Kind == Memory && (!Mem.Size || Mem.Size == 32);
238  }
239  bool isMem64() const {
240  return Kind == Memory && (!Mem.Size || Mem.Size == 64);
241  }
242  bool isMem80() const {
243  return Kind == Memory && (!Mem.Size || Mem.Size == 80);
244  }
245  bool isMem128() const {
246  return Kind == Memory && (!Mem.Size || Mem.Size == 128);
247  }
248  bool isMem256() const {
249  return Kind == Memory && (!Mem.Size || Mem.Size == 256);
250  }
251  bool isMem512() const {
252  return Kind == Memory && (!Mem.Size || Mem.Size == 512);
253  }
254  bool isMemIndexReg(unsigned LowR, unsigned HighR) const {
255  assert(Kind == Memory && "Invalid access!");
256  return Mem.IndexReg >= LowR && Mem.IndexReg <= HighR;
257  }
258 
259  bool isMem64_RC128() const {
260  return isMem64() && isMemIndexReg(X86::XMM0, X86::XMM15);
261  }
262  bool isMem128_RC128() const {
263  return isMem128() && isMemIndexReg(X86::XMM0, X86::XMM15);
264  }
265  bool isMem128_RC256() const {
266  return isMem128() && isMemIndexReg(X86::YMM0, X86::YMM15);
267  }
268  bool isMem256_RC128() const {
269  return isMem256() && isMemIndexReg(X86::XMM0, X86::XMM15);
270  }
271  bool isMem256_RC256() const {
272  return isMem256() && isMemIndexReg(X86::YMM0, X86::YMM15);
273  }
274 
275  bool isMem64_RC128X() const {
276  return isMem64() && isMemIndexReg(X86::XMM0, X86::XMM31);
277  }
278  bool isMem128_RC128X() const {
279  return isMem128() && isMemIndexReg(X86::XMM0, X86::XMM31);
280  }
281  bool isMem128_RC256X() const {
282  return isMem128() && isMemIndexReg(X86::YMM0, X86::YMM31);
283  }
284  bool isMem256_RC128X() const {
285  return isMem256() && isMemIndexReg(X86::XMM0, X86::XMM31);
286  }
287  bool isMem256_RC256X() const {
288  return isMem256() && isMemIndexReg(X86::YMM0, X86::YMM31);
289  }
290  bool isMem256_RC512() const {
291  return isMem256() && isMemIndexReg(X86::ZMM0, X86::ZMM31);
292  }
293  bool isMem512_RC256X() const {
294  return isMem512() && isMemIndexReg(X86::YMM0, X86::YMM31);
295  }
296  bool isMem512_RC512() const {
297  return isMem512() && isMemIndexReg(X86::ZMM0, X86::ZMM31);
298  }
299 
300  bool isAbsMem() const {
301  return Kind == Memory && !getMemSegReg() && !getMemBaseReg() &&
302  !getMemIndexReg() && getMemScale() == 1;
303  }
304  bool isAVX512RC() const{
305  return isImm();
306  }
307 
308  bool isAbsMem16() const {
309  return isAbsMem() && Mem.ModeSize == 16;
310  }
311 
312  bool isSrcIdx() const {
313  return !getMemIndexReg() && getMemScale() == 1 &&
314  (getMemBaseReg() == X86::RSI || getMemBaseReg() == X86::ESI ||
315  getMemBaseReg() == X86::SI) && isa<MCConstantExpr>(getMemDisp()) &&
316  cast<MCConstantExpr>(getMemDisp())->getValue() == 0;
317  }
318  bool isSrcIdx8() const {
319  return isMem8() && isSrcIdx();
320  }
321  bool isSrcIdx16() const {
322  return isMem16() && isSrcIdx();
323  }
324  bool isSrcIdx32() const {
325  return isMem32() && isSrcIdx();
326  }
327  bool isSrcIdx64() const {
328  return isMem64() && isSrcIdx();
329  }
330 
331  bool isDstIdx() const {
332  return !getMemIndexReg() && getMemScale() == 1 &&
333  (getMemSegReg() == 0 || getMemSegReg() == X86::ES) &&
334  (getMemBaseReg() == X86::RDI || getMemBaseReg() == X86::EDI ||
335  getMemBaseReg() == X86::DI) && isa<MCConstantExpr>(getMemDisp()) &&
336  cast<MCConstantExpr>(getMemDisp())->getValue() == 0;
337  }
338  bool isDstIdx8() const {
339  return isMem8() && isDstIdx();
340  }
341  bool isDstIdx16() const {
342  return isMem16() && isDstIdx();
343  }
344  bool isDstIdx32() const {
345  return isMem32() && isDstIdx();
346  }
347  bool isDstIdx64() const {
348  return isMem64() && isDstIdx();
349  }
350 
351  bool isMemOffs() const {
352  return Kind == Memory && !getMemBaseReg() && !getMemIndexReg() &&
353  getMemScale() == 1;
354  }
355 
356  bool isMemOffs16_8() const {
357  return isMemOffs() && Mem.ModeSize == 16 && (!Mem.Size || Mem.Size == 8);
358  }
359  bool isMemOffs16_16() const {
360  return isMemOffs() && Mem.ModeSize == 16 && (!Mem.Size || Mem.Size == 16);
361  }
362  bool isMemOffs16_32() const {
363  return isMemOffs() && Mem.ModeSize == 16 && (!Mem.Size || Mem.Size == 32);
364  }
365  bool isMemOffs32_8() const {
366  return isMemOffs() && Mem.ModeSize == 32 && (!Mem.Size || Mem.Size == 8);
367  }
368  bool isMemOffs32_16() const {
369  return isMemOffs() && Mem.ModeSize == 32 && (!Mem.Size || Mem.Size == 16);
370  }
371  bool isMemOffs32_32() const {
372  return isMemOffs() && Mem.ModeSize == 32 && (!Mem.Size || Mem.Size == 32);
373  }
374  bool isMemOffs32_64() const {
375  return isMemOffs() && Mem.ModeSize == 32 && (!Mem.Size || Mem.Size == 64);
376  }
377  bool isMemOffs64_8() const {
378  return isMemOffs() && Mem.ModeSize == 64 && (!Mem.Size || Mem.Size == 8);
379  }
380  bool isMemOffs64_16() const {
381  return isMemOffs() && Mem.ModeSize == 64 && (!Mem.Size || Mem.Size == 16);
382  }
383  bool isMemOffs64_32() const {
384  return isMemOffs() && Mem.ModeSize == 64 && (!Mem.Size || Mem.Size == 32);
385  }
386  bool isMemOffs64_64() const {
387  return isMemOffs() && Mem.ModeSize == 64 && (!Mem.Size || Mem.Size == 64);
388  }
389 
390  bool isReg() const override { return Kind == Register; }
391 
392  bool isGR32orGR64() const {
393  return Kind == Register &&
394  (X86MCRegisterClasses[X86::GR32RegClassID].contains(getReg()) ||
395  X86MCRegisterClasses[X86::GR64RegClassID].contains(getReg()));
396  }
397 
398  void addExpr(MCInst &Inst, const MCExpr *Expr) const {
399  // Add as immediates when possible.
400  if (const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(Expr))
401  Inst.addOperand(MCOperand::createImm(CE->getValue()));
402  else
403  Inst.addOperand(MCOperand::createExpr(Expr));
404  }
405 
406  void addRegOperands(MCInst &Inst, unsigned N) const {
407  assert(N == 1 && "Invalid number of operands!");
409  }
410 
411  static unsigned getGR32FromGR64(unsigned RegNo) {
412  switch (RegNo) {
413  default: llvm_unreachable("Unexpected register");
414  case X86::RAX: return X86::EAX;
415  case X86::RCX: return X86::ECX;
416  case X86::RDX: return X86::EDX;
417  case X86::RBX: return X86::EBX;
418  case X86::RBP: return X86::EBP;
419  case X86::RSP: return X86::ESP;
420  case X86::RSI: return X86::ESI;
421  case X86::RDI: return X86::EDI;
422  case X86::R8: return X86::R8D;
423  case X86::R9: return X86::R9D;
424  case X86::R10: return X86::R10D;
425  case X86::R11: return X86::R11D;
426  case X86::R12: return X86::R12D;
427  case X86::R13: return X86::R13D;
428  case X86::R14: return X86::R14D;
429  case X86::R15: return X86::R15D;
430  case X86::RIP: return X86::EIP;
431  }
432  }
433 
434  void addGR32orGR64Operands(MCInst &Inst, unsigned N) const {
435  assert(N == 1 && "Invalid number of operands!");
436  unsigned RegNo = getReg();
437  if (X86MCRegisterClasses[X86::GR64RegClassID].contains(RegNo))
438  RegNo = getGR32FromGR64(RegNo);
439  Inst.addOperand(MCOperand::createReg(RegNo));
440  }
441 
442  void addAVX512RCOperands(MCInst &Inst, unsigned N) const {
443  assert(N == 1 && "Invalid number of operands!");
444  addExpr(Inst, getImm());
445  }
446 
447  void addImmOperands(MCInst &Inst, unsigned N) const {
448  assert(N == 1 && "Invalid number of operands!");
449  addExpr(Inst, getImm());
450  }
451 
452  void addMemOperands(MCInst &Inst, unsigned N) const {
453  assert((N == 5) && "Invalid number of operands!");
457  addExpr(Inst, getMemDisp());
459  }
460 
461  void addAbsMemOperands(MCInst &Inst, unsigned N) const {
462  assert((N == 1) && "Invalid number of operands!");
463  // Add as immediates when possible.
464  if (const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(getMemDisp()))
465  Inst.addOperand(MCOperand::createImm(CE->getValue()));
466  else
468  }
469 
470  void addSrcIdxOperands(MCInst &Inst, unsigned N) const {
471  assert((N == 2) && "Invalid number of operands!");
474  }
475 
476  void addDstIdxOperands(MCInst &Inst, unsigned N) const {
477  assert((N == 1) && "Invalid number of operands!");
479  }
480 
481  void addMemOffsOperands(MCInst &Inst, unsigned N) const {
482  assert((N == 2) && "Invalid number of operands!");
483  // Add as immediates when possible.
484  if (const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(getMemDisp()))
485  Inst.addOperand(MCOperand::createImm(CE->getValue()));
486  else
489  }
490 
491  static std::unique_ptr<X86Operand> CreateToken(StringRef Str, SMLoc Loc) {
493  auto Res = llvm::make_unique<X86Operand>(Token, Loc, EndLoc);
494  Res->Tok.Data = Str.data();
495  Res->Tok.Length = Str.size();
496  return Res;
497  }
498 
499  static std::unique_ptr<X86Operand>
500  CreateReg(unsigned RegNo, SMLoc StartLoc, SMLoc EndLoc,
501  bool AddressOf = false, SMLoc OffsetOfLoc = SMLoc(),
502  StringRef SymName = StringRef(), void *OpDecl = nullptr) {
503  auto Res = llvm::make_unique<X86Operand>(Register, StartLoc, EndLoc);
504  Res->Reg.RegNo = RegNo;
505  Res->AddressOf = AddressOf;
506  Res->OffsetOfLoc = OffsetOfLoc;
507  Res->SymName = SymName;
508  Res->OpDecl = OpDecl;
509  return Res;
510  }
511 
512  static std::unique_ptr<X86Operand> CreateImm(const MCExpr *Val,
513  SMLoc StartLoc, SMLoc EndLoc) {
514  auto Res = llvm::make_unique<X86Operand>(Immediate, StartLoc, EndLoc);
515  Res->Imm.Val = Val;
516  return Res;
517  }
518 
519  /// Create an absolute memory operand.
520  static std::unique_ptr<X86Operand>
521  CreateMem(unsigned ModeSize, const MCExpr *Disp, SMLoc StartLoc, SMLoc EndLoc,
522  unsigned Size = 0, StringRef SymName = StringRef(),
523  void *OpDecl = nullptr, unsigned FrontendSize = 0) {
524  auto Res = llvm::make_unique<X86Operand>(Memory, StartLoc, EndLoc);
525  Res->Mem.SegReg = 0;
526  Res->Mem.Disp = Disp;
527  Res->Mem.BaseReg = 0;
528  Res->Mem.IndexReg = 0;
529  Res->Mem.Scale = 1;
530  Res->Mem.Size = Size;
531  Res->Mem.ModeSize = ModeSize;
532  Res->Mem.FrontendSize = FrontendSize;
533  Res->SymName = SymName;
534  Res->OpDecl = OpDecl;
535  Res->AddressOf = false;
536  return Res;
537  }
538 
539  /// Create a generalized memory operand.
540  static std::unique_ptr<X86Operand>
541  CreateMem(unsigned ModeSize, unsigned SegReg, const MCExpr *Disp,
542  unsigned BaseReg, unsigned IndexReg, unsigned Scale, SMLoc StartLoc,
543  SMLoc EndLoc, unsigned Size = 0, StringRef SymName = StringRef(),
544  void *OpDecl = nullptr, unsigned FrontendSize = 0) {
545  // We should never just have a displacement, that should be parsed as an
546  // absolute memory operand.
547  assert((SegReg || BaseReg || IndexReg) && "Invalid memory operand!");
548 
549  // The scale should always be one of {1,2,4,8}.
550  assert(((Scale == 1 || Scale == 2 || Scale == 4 || Scale == 8)) &&
551  "Invalid scale!");
552  auto Res = llvm::make_unique<X86Operand>(Memory, StartLoc, EndLoc);
553  Res->Mem.SegReg = SegReg;
554  Res->Mem.Disp = Disp;
555  Res->Mem.BaseReg = BaseReg;
556  Res->Mem.IndexReg = IndexReg;
557  Res->Mem.Scale = Scale;
558  Res->Mem.Size = Size;
559  Res->Mem.ModeSize = ModeSize;
560  Res->Mem.FrontendSize = FrontendSize;
561  Res->SymName = SymName;
562  Res->OpDecl = OpDecl;
563  Res->AddressOf = false;
564  return Res;
565  }
566 };
567 
568 } // end namespace llvm
569 
570 #endif // LLVM_LIB_TARGET_X86_ASMPARSER_X86OPERAND_H
void addImmOperands(MCInst &Inst, unsigned N) const
Definition: X86Operand.h:447
StringRef getToken() const
Definition: X86Operand.h:99
bool isMemOffs64_16() const
Definition: X86Operand.h:380
Represents a range in source code.
Definition: SMLoc.h:49
const MCExpr * Val
Definition: X86Operand.h:54
const char * getPointer() const
Definition: SMLoc.h:35
bool isDstIdx8() const
Definition: X86Operand.h:338
SMLoc getOffsetOfLoc() const override
getOffsetOfLoc - Get the location of the offset operator.
Definition: X86Operand.h:95
bool isMem128_RC128X() const
Definition: X86Operand.h:278
bool isMemOffs64_32() const
Definition: X86Operand.h:383
bool isImmUnsignedi8Value(uint64_t Value)
bool isMem512_RC512() const
Definition: X86Operand.h:296
void addAVX512RCOperands(MCInst &Inst, unsigned N) const
Definition: X86Operand.h:442
static MCOperand createExpr(const MCExpr *Val)
Definition: MCInst.h:137
bool isDstIdx32() const
Definition: X86Operand.h:344
This class provides various memory handling functions that manipulate MemoryBlock instances...
Definition: Memory.h:46
struct ImmOp Imm
Definition: X86Operand.h:74
bool isMemOffs16_32() const
Definition: X86Operand.h:362
bool isMem256_RC256() const
Definition: X86Operand.h:271
bool isSrcIdx32() const
Definition: X86Operand.h:324
unsigned getMemModeSize() const
Definition: X86Operand.h:139
bool isMem256_RC512() const
Definition: X86Operand.h:290
bool isAVX512RC() const
Definition: X86Operand.h:304
unsigned getMemFrontendSize() const
Definition: X86Operand.h:143
bool isMem128() const
Definition: X86Operand.h:245
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:521
bool isMemOffs64_64() const
Definition: X86Operand.h:386
bool isMem256_RC128X() const
Definition: X86Operand.h:284
unsigned getMemScale() const
Definition: X86Operand.h:135
return AArch64::GPR64RegClass contains(Reg)
bool isImmSExti64i32() const
Definition: X86Operand.h:194
bool isSrcIdx16() const
Definition: X86Operand.h:321
bool isMem16() const
Definition: X86Operand.h:233
unsigned FrontendSize
If the memory operand is unsized and there are multiple instruction matches, prefer the one with this...
Definition: X86Operand.h:68
bool isMem512_RC256X() const
Definition: X86Operand.h:293
static MCOperand createReg(unsigned Reg)
Definition: MCInst.h:116
bool isImmSExti64i8Value(uint64_t Value)
SMLoc getEndLoc() const override
getEndLoc - Get the location of the last token of this operand.
Definition: X86Operand.h:88
bool isMem8() const
Definition: X86Operand.h:230
bool isImm() const override
isImm - Is this an immediate operand?
Definition: X86Operand.h:150
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:36
const MCExpr * getImm() const
Definition: X86Operand.h:114
void addMemOffsOperands(MCInst &Inst, unsigned N) const
Definition: X86Operand.h:481
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:512
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:541
bool isMem128_RC256X() const
Definition: X86Operand.h:281
StringRef getSymName() override
Definition: X86Operand.h:81
bool isImmSExti64i32Value(uint64_t Value)
unsigned getReg() const override
Definition: X86Operand.h:109
bool isMemOffs16_16() const
Definition: X86Operand.h:359
bool isMemOffs64_8() const
Definition: X86Operand.h:377
bool isMem80() const
Definition: X86Operand.h:242
bool isImmSExti16i8Value(uint64_t Value)
bool isMemOffs32_8() const
Definition: X86Operand.h:365
bool isDstIdx64() const
Definition: X86Operand.h:347
const MCExpr * getMemDisp() const
Definition: X86Operand.h:119
bool isMem64_RC128() const
Definition: X86Operand.h:259
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
Definition: StringRef.h:138
bool isAbsMem() const
Definition: X86Operand.h:300
bool isMem64() const
Definition: X86Operand.h:239
bool isMem256() const
Definition: X86Operand.h:248
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:159
struct TokOp Tok
Definition: X86Operand.h:72
bool isMem32() const
Definition: X86Operand.h:236
bool isImmSExti32i8() const
Definition: X86Operand.h:166
X86Operand - Instances of this class represent a parsed X86 machine instruction.
Definition: X86Operand.h:30
SMRange getLocRange() const
getLocRange - Get the range between the first and last token of this operand.
Definition: X86Operand.h:92
int64_t getValue() const
Definition: MCExpr.h:151
bool isMem128_RC256() const
Definition: X86Operand.h:265
bool isImmUnsignedi8() const
Definition: X86Operand.h:209
static const unsigned End
void setTokenValue(StringRef Value)
Definition: X86Operand.h:103
bool isToken() const override
isToken - Is this a token operand?
Definition: X86Operand.h:148
SMLoc getStartLoc() const override
getStartLoc - Get the location of the first token of this operand.
Definition: X86Operand.h:85
bool isMem64_RC128X() const
Definition: X86Operand.h:275
unsigned getMemSegReg() const
Definition: X86Operand.h:123
void addGR32orGR64Operands(MCInst &Inst, unsigned N) const
Definition: X86Operand.h:434
StringRef SymName
Definition: X86Operand.h:40
bool isMemOffs32_16() const
Definition: X86Operand.h:368
void * getOpDecl() override
Definition: X86Operand.h:82
bool isMemOffs32_64() const
Definition: X86Operand.h:374
void addRegOperands(MCInst &Inst, unsigned N) const
Definition: X86Operand.h:406
struct MemOp Mem
Definition: X86Operand.h:75
bool isMem128_RC128() const
Definition: X86Operand.h:262
const size_t N
bool isSrcIdx64() const
Definition: X86Operand.h:327
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:218
bool isMem256_RC256X() const
Definition: X86Operand.h:287
bool isMemUnsized() const
Definition: X86Operand.h:227
bool isMemOffs16_8() const
Definition: X86Operand.h:356
static unsigned getGR32FromGR64(unsigned RegNo)
Definition: X86Operand.h:411
bool isImmSExti16i8() const
Definition: X86Operand.h:152
void print(raw_ostream &OS) const override
print - Print a debug representation of the operand to the given stream.
Definition: X86Operand.h:97
unsigned getMemBaseReg() const
Definition: X86Operand.h:127
static std::unique_ptr< X86Operand > CreateToken(StringRef Str, SMLoc Loc)
Definition: X86Operand.h:491
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
static SMLoc getFromPointer(const char *Ptr)
Definition: SMLoc.h:37
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)
Definition: X86Operand.h:500
struct RegOp Reg
Definition: X86Operand.h:73
bool isImmSExti64i8() const
Definition: X86Operand.h:180
X86Operand(KindTy K, SMLoc Start, SMLoc End)
Definition: X86Operand.h:78
bool isDstIdx16() const
Definition: X86Operand.h:341
bool isMemIndexReg(unsigned LowR, unsigned HighR) const
Definition: X86Operand.h:254
bool isDstIdx() const
Definition: X86Operand.h:331
bool isMem512() const
Definition: X86Operand.h:251
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
bool isMem256_RC128() const
Definition: X86Operand.h:268
bool isSrcIdx8() const
Definition: X86Operand.h:318
bool isGR32orGR64() const
Definition: X86Operand.h:392
void addAbsMemOperands(MCInst &Inst, unsigned N) const
Definition: X86Operand.h:461
bool isMemOffs() const
Definition: X86Operand.h:351
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
Definition: Value.h:73
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:44
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
void addMemOperands(MCInst &Inst, unsigned N) const
Definition: X86Operand.h:452
bool isReg() const override
isReg - Is this a register operand?
Definition: X86Operand.h:390
bool isAbsMem16() const
Definition: X86Operand.h:308
void addOperand(const MCOperand &Op)
Definition: MCInst.h:177
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
void addSrcIdxOperands(MCInst &Inst, unsigned N) const
Definition: X86Operand.h:470
const MCExpr * Disp
Definition: X86Operand.h:59
enum llvm::X86Operand::KindTy Kind
void addExpr(MCInst &Inst, const MCExpr *Expr) const
Definition: X86Operand.h:398
bool isSrcIdx() const
Definition: X86Operand.h:312
Represents a location in source code.
Definition: SMLoc.h:24
bool isMemOffs32_32() const
Definition: X86Operand.h:371
static MCOperand createImm(int64_t Val)
Definition: MCInst.h:123
void addDstIdxOperands(MCInst &Inst, unsigned N) const
Definition: X86Operand.h:476
unsigned getMemIndexReg() const
Definition: X86Operand.h:131
bool isMem() const override
isMem - Is this a memory operand?
Definition: X86Operand.h:226
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:222