10 #ifndef LLVM_LIB_TARGET_X86_ASMPARSER_X86OPERAND_H
11 #define LLVM_LIB_TARGET_X86_ASMPARSER_X86OPERAND_H
194 if (!
isImm())
return false;
198 if (!CE)
return true;
297 cast<MCConstantExpr>(
getMemDisp())->getValue() == 0;
317 cast<MCConstantExpr>(
getMemDisp())->getValue() == 0;
375 (X86MCRegisterClasses[X86::GR32RegClassID].contains(
getReg()) ||
376 X86MCRegisterClasses[X86::GR64RegClassID].contains(
getReg()));
388 assert(N == 1 &&
"Invalid number of operands!");
403 case X86::R8:
return X86::R8D;
404 case X86::R9:
return X86::R9D;
405 case X86::R10:
return X86::R10D;
406 case X86::R11:
return X86::R11D;
407 case X86::R12:
return X86::R12D;
408 case X86::R13:
return X86::R13D;
409 case X86::R14:
return X86::R14D;
410 case X86::R15:
return X86::R15D;
411 case X86::RIP:
return X86::EIP;
416 assert(N == 1 &&
"Invalid number of operands!");
417 unsigned RegNo =
getReg();
418 if (X86MCRegisterClasses[X86::GR64RegClassID].
contains(RegNo))
423 assert(N == 1 &&
"Invalid number of operands!");
427 assert(N == 1 &&
"Invalid number of operands!");
432 assert((N == 5) &&
"Invalid number of operands!");
441 assert((N == 1) &&
"Invalid number of operands!");
450 assert((N == 2) &&
"Invalid number of operands!");
455 assert((N == 1) &&
"Invalid number of operands!");
460 assert((N == 2) &&
"Invalid number of operands!");
471 auto Res = llvm::make_unique<X86Operand>(
Token, Loc,
EndLoc);
472 Res->Tok.Data = Str.
data();
473 Res->Tok.Length = Str.
size();
477 static std::unique_ptr<X86Operand>
482 Res->Reg.RegNo = RegNo;
498 static std::unique_ptr<X86Operand>
504 Res->Mem.Disp = Disp;
505 Res->Mem.BaseReg = 0;
506 Res->Mem.IndexReg = 0;
508 Res->Mem.Size = Size;
509 Res->Mem.ModeSize = ModeSize;
512 Res->AddressOf =
false;
517 static std::unique_ptr<X86Operand>
519 unsigned BaseReg,
unsigned IndexReg,
unsigned Scale,
SMLoc StartLoc,
524 assert((SegReg || BaseReg || IndexReg) &&
"Invalid memory operand!");
527 assert(((Scale == 1 || Scale == 2 || Scale == 4 || Scale == 8)) &&
530 Res->Mem.SegReg = SegReg;
531 Res->Mem.Disp = Disp;
532 Res->Mem.BaseReg = BaseReg;
533 Res->Mem.IndexReg = IndexReg;
534 Res->Mem.Scale = Scale;
535 Res->Mem.Size = Size;
536 Res->Mem.ModeSize = ModeSize;
539 Res->AddressOf =
false;
void addImmOperands(MCInst &Inst, unsigned N) const
StringRef getToken() const
bool isMemOffs64_16() const
Represents a range in source code.
const char * getPointer() const
SMLoc getOffsetOfLoc() const override
getOffsetOfLoc - Get the location of the offset operator.
bool isMem128_RC128X() const
bool isMemOffs64_32() const
bool isImmUnsignedi8Value(uint64_t Value)
bool isMem512_RC512() const
void addAVX512RCOperands(MCInst &Inst, unsigned N) const
static MCOperand createExpr(const MCExpr *Val)
This class provides various memory handling functions that manipulate MemoryBlock instances...
bool isMemOffs16_32() const
bool isMem256_RC256() const
unsigned getMemModeSize() 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)
Create an absolute memory operand.
bool isMemOffs64_64() const
bool isMem256_RC128X() const
unsigned getMemScale() const
return AArch64::GPR64RegClass contains(Reg)
bool isImmSExti64i32() const
bool isMem512_RC256X() const
static MCOperand createReg(unsigned Reg)
bool isImmSExti64i8Value(uint64_t Value)
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?
Base class for the full range of assembler expressions which are needed for parsing.
const MCExpr * getImm() const
void addMemOffsOperands(MCInst &Inst, unsigned N) const
MCParsedAsmOperand - This abstract class represents a source-level assembly instruction operand...
static std::unique_ptr< X86Operand > CreateImm(const MCExpr *Val, SMLoc StartLoc, SMLoc EndLoc)
bool isMem128_RC256X() const
StringRef getSymName() override
bool isImmSExti64i32Value(uint64_t Value)
unsigned getReg() const override
bool isMemOffs16_16() const
bool isMemOffs64_8() const
bool isImmSExti16i8Value(uint64_t Value)
bool isMemOffs32_8() const
const MCExpr * getMemDisp() const
bool isMem64_RC128() const
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
Instances of this class represent a single low-level machine instruction.
bool isImmSExti32i8() const
X86Operand - Instances of this class represent a parsed X86 machine instruction.
SMRange getLocRange() const
getLocRange - Get the range between the first and last token of this operand.
bool isMem128_RC256() const
bool isImmUnsignedi8() const
static const unsigned End
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)
Create a generalized memory operand.
void setTokenValue(StringRef Value)
bool isToken() const override
isToken - Is this a token operand?
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
SMLoc getStartLoc() const override
getStartLoc - Get the location of the first token of this operand.
bool isMem64_RC128X() const
unsigned getMemSegReg() const
void addGR32orGR64Operands(MCInst &Inst, unsigned N) const
bool isMemOffs32_16() const
void * getOpDecl() override
bool isMemOffs32_64() const
void addRegOperands(MCInst &Inst, unsigned N) const
bool isMem128_RC128() const
bool isOffsetOf() const override
isOffsetOf - Do we need to emit code to get the offset of the variable, rather then the value of the ...
bool isMem256_RC256X() const
bool isMemUnsized() const
bool isMemOffs16_8() const
static unsigned getGR32FromGR64(unsigned RegNo)
bool isImmSExti16i8() const
void print(raw_ostream &OS) const override
print - Print a debug representation of the operand to the given stream.
unsigned getMemBaseReg() const
static std::unique_ptr< X86Operand > CreateToken(StringRef Str, SMLoc Loc)
static SMLoc getFromPointer(const char *Ptr)
static std::unique_ptr< X86Operand > CreateReg(unsigned RegNo, SMLoc StartLoc, SMLoc EndLoc, bool AddressOf=false, SMLoc OffsetOfLoc=SMLoc(), StringRef SymName=StringRef(), void *OpDecl=nullptr)
bool isImmSExti64i8() const
X86Operand(KindTy K, SMLoc Start, SMLoc End)
bool isMemIndexReg(unsigned LowR, unsigned HighR) const
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
bool isMem256_RC128() const
bool isGR32orGR64() const
void addAbsMemOperands(MCInst &Inst, unsigned N) const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
bool isImmSExti32i8Value(uint64_t Value)
This class implements an extremely fast bulk output stream that can only output to a stream...
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
void addMemOperands(MCInst &Inst, unsigned N) const
bool isReg() const override
isReg - Is this a register operand?
void addOperand(const MCOperand &Op)
StringRef - Represent a constant reference to a string, i.e.
void addSrcIdxOperands(MCInst &Inst, unsigned N) const
enum llvm::X86Operand::KindTy Kind
void addExpr(MCInst &Inst, const MCExpr *Expr) const
Represents a location in source code.
bool isMemOffs32_32() const
static MCOperand createImm(int64_t Val)
void addDstIdxOperands(MCInst &Inst, unsigned N) const
unsigned getMemIndexReg() const
bool isMem() const override
isMem - Is this a memory operand?
bool needAddressOf() const override
needAddressOf - Do we need to emit code to get the address of the variable/label? Only valid when par...