10 #ifndef LLVM_LIB_TARGET_X86_ASMPARSER_X86OPERAND_H
11 #define LLVM_LIB_TARGET_X86_ASMPARSER_X86OPERAND_H
88 assert(
Kind ==
Token &&
"Invalid access!");
92 assert(
Kind ==
Token &&
"Invalid access!");
194 if (!
isImm())
return false;
196 if (!CE)
return false;
294 cast<MCConstantExpr>(
getMemDisp())->getValue() == 0;
314 cast<MCConstantExpr>(
getMemDisp())->getValue() == 0;
372 (X86MCRegisterClasses[X86::GR32RegClassID].contains(
getReg()) ||
373 X86MCRegisterClasses[X86::GR64RegClassID].contains(
getReg()));
385 assert(N == 1 &&
"Invalid number of operands!");
400 case X86::R8:
return X86::R8D;
401 case X86::R9:
return X86::R9D;
402 case X86::R10:
return X86::R10D;
403 case X86::R11:
return X86::R11D;
404 case X86::R12:
return X86::R12D;
405 case X86::R13:
return X86::R13D;
406 case X86::R14:
return X86::R14D;
407 case X86::R15:
return X86::R15D;
408 case X86::RIP:
return X86::EIP;
413 assert(N == 1 &&
"Invalid number of operands!");
414 unsigned RegNo =
getReg();
415 if (X86MCRegisterClasses[X86::GR64RegClassID].
contains(RegNo))
420 assert(N == 1 &&
"Invalid number of operands!");
424 assert(N == 1 &&
"Invalid number of operands!");
429 assert((N == 5) &&
"Invalid number of operands!");
438 assert((N == 1) &&
"Invalid number of operands!");
447 assert((N == 2) &&
"Invalid number of operands!");
452 assert((N == 1) &&
"Invalid number of operands!");
457 assert((N == 2) &&
"Invalid number of operands!");
468 auto Res = llvm::make_unique<X86Operand>(
Token, Loc,
EndLoc);
469 Res->Tok.Data = Str.
data();
470 Res->Tok.Length = Str.
size();
474 static std::unique_ptr<X86Operand>
479 Res->Reg.RegNo = RegNo;
495 static std::unique_ptr<X86Operand>
501 Res->Mem.Disp = Disp;
502 Res->Mem.BaseReg = 0;
503 Res->Mem.IndexReg = 0;
505 Res->Mem.Size = Size;
506 Res->Mem.ModeSize = ModeSize;
509 Res->AddressOf =
false;
514 static std::unique_ptr<X86Operand>
516 unsigned BaseReg,
unsigned IndexReg,
unsigned Scale,
SMLoc StartLoc,
521 assert((SegReg || BaseReg || IndexReg) &&
"Invalid memory operand!");
524 assert(((Scale == 1 || Scale == 2 || Scale == 4 || Scale == 8)) &&
527 Res->Mem.SegReg = SegReg;
528 Res->Mem.Disp = Disp;
529 Res->Mem.BaseReg = BaseReg;
530 Res->Mem.IndexReg = IndexReg;
531 Res->Mem.Scale = Scale;
532 Res->Mem.Size = Size;
533 Res->Mem.ModeSize = ModeSize;
536 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
size_t size() const
size - Get the string size.
SMLoc getOffsetOfLoc() const override
getOffsetOfLoc - Get the location of the offset operator.
bool isMemOffs64_32() const
bool isImmUnsignedi8Value(uint64_t Value)
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
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
unsigned getMemScale() const
bool isImmSExti64i32() 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.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool isImm() const override
isImm - Is this an immediate operand?
Base class for the full range of assembler expressions which are needed for parsing.
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
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)
StringRef getSymName() override
bool isImmSExti64i32Value(uint64_t Value)
unsigned getReg() const override
bool isMemOffs16_16() const
bool isMemOffs64_8() const
const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
bool isImmSExti16i8Value(uint64_t Value)
bool isMemOffs32_8() const
const MCExpr * getMemDisp() const
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 isImmUnsignedi8() const
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?
SMLoc getStartLoc() const override
getStartLoc - Get the location of the first token of this operand.
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 isOffsetOf() const override
isOffsetOf - Do we need to emit code to get the offset of the variable, rather then the value of the ...
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.
LLVM_ATTRIBUTE_UNUSED_RESULT std::enable_if< !is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
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 isGR32orGR64() const
void addAbsMemOperands(MCInst &Inst, unsigned N) const
LLVM Value Representation.
bool isImmSExti32i8Value(uint64_t Value)
This class implements an extremely fast bulk output stream that can only output to a stream...
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...