10 #ifndef LLVM_LIB_TARGET_X86_ASMPARSER_X86OPERAND_H 11 #define LLVM_LIB_TARGET_X86_ASMPARSER_X86OPERAND_H 81 : Kind(K), StartLoc(Start), EndLoc(End) {}
101 auto PrintImmValue = [&](
const MCExpr *Val,
const char *VName) {
103 if (
auto Imm = cast<MCConstantExpr>(Val)->getValue())
106 if (
auto *SRE = dyn_cast<MCSymbolRefExpr>(Val)) {
107 const MCSymbol &Sym = SRE->getSymbol();
109 OS << VName << SymName;
125 PrintImmValue(
Imm.
Val,
"Imm:");
142 PrintImmValue(
Mem.
Disp,
",Disp=");
265 if (!
isImm())
return false;
269 if (!CE)
return true;
371 cast<MCConstantExpr>(
getMemDisp())->getValue() == 0;
391 cast<MCConstantExpr>(
getMemDisp())->getValue() == 0;
451 (X86MCRegisterClasses[X86::GR32RegClassID].contains(
getReg()) ||
452 X86MCRegisterClasses[X86::GR64RegClassID].contains(
getReg()));
464 assert(N == 1 &&
"Invalid number of operands!");
469 assert(N == 1 &&
"Invalid number of operands!");
470 unsigned RegNo =
getReg();
471 if (X86MCRegisterClasses[X86::GR64RegClassID].
contains(RegNo))
477 assert(N == 1 &&
"Invalid number of operands!");
482 assert(N == 1 &&
"Invalid number of operands!");
487 assert((N == 5) &&
"Invalid number of operands!");
496 assert((N == 1) &&
"Invalid number of operands!");
505 assert((N == 2) &&
"Invalid number of operands!");
511 assert((N == 1) &&
"Invalid number of operands!");
516 assert((N == 2) &&
"Invalid number of operands!");
527 auto Res = llvm::make_unique<X86Operand>(
Token, Loc,
EndLoc);
528 Res->Tok.Data = Str.
data();
529 Res->Tok.Length = Str.
size();
533 static std::unique_ptr<X86Operand>
535 bool AddressOf =
false,
SMLoc OffsetOfLoc =
SMLoc(),
538 Res->Reg.RegNo = RegNo;
546 static std::unique_ptr<X86Operand>
551 static std::unique_ptr<X86Operand>
554 Res->Pref.Prefixes = Prefixes;
566 static std::unique_ptr<X86Operand>
569 void *OpDecl =
nullptr,
unsigned FrontendSize = 0) {
572 Res->Mem.Disp = Disp;
573 Res->Mem.BaseReg = 0;
574 Res->Mem.IndexReg = 0;
576 Res->Mem.Size =
Size;
577 Res->Mem.ModeSize = ModeSize;
578 Res->Mem.FrontendSize = FrontendSize;
581 Res->AddressOf =
false;
586 static std::unique_ptr<X86Operand>
588 unsigned BaseReg,
unsigned IndexReg,
unsigned Scale,
SMLoc StartLoc,
590 void *OpDecl =
nullptr,
unsigned FrontendSize = 0) {
593 assert((SegReg || BaseReg || IndexReg) &&
"Invalid memory operand!");
596 assert(((Scale == 1 || Scale == 2 || Scale == 4 || Scale == 8)) &&
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;
609 Res->AddressOf =
false;
616 #endif // LLVM_LIB_TARGET_X86_ASMPARSER_X86OPERAND_H
Represents a range in source code.
bool isMem64_RC128X() const
bool isGR32orGR64() const
unsigned getMemFrontendSize() const
bool isMem256_RC256() const
This class represents lattice values for constants.
SMLoc getOffsetOfLoc() const override
getOffsetOfLoc - Get the location of the offset operator.
SMRange getLocRange() const
getLocRange - Get the range between the first and last token of this operand.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
bool isMemOffs16_32() const
bool isImmUnsignedi8Value(uint64_t Value)
bool isMemOffs32_8() const
static MCOperand createExpr(const MCExpr *Val)
This class provides various memory handling functions that manipulate MemoryBlock instances...
unsigned getMemModeSize() const
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
bool isImmSExti64i8() 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.
bool isMem64_RC128() const
bool isMemOffs64_8() const
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).
return AArch64::GPR64RegClass contains(Reg)
StringRef getToken() const
unsigned FrontendSize
If the memory operand is unsized and there are multiple instruction matches, prefer the one with this...
void addSrcIdxOperands(MCInst &Inst, unsigned N) const
static MCOperand createReg(unsigned Reg)
bool isImmSExti64i8Value(uint64_t Value)
unsigned getPrefix() const
bool isMemUnsized() const
SMLoc getEndLoc() const override
getEndLoc - Get the location of the last token of this operand.
bool isMemOffs64_64() const
void addRegOperands(MCInst &Inst, unsigned N) const
bool isImm() const override
isImm - Is this an immediate operand?
bool isMem128_RC256() const
bool isMem128_RC256X() const
Base class for the full range of assembler expressions which are needed for parsing.
bool isImmSExti16i8() const
bool isMem512_RC512() const
bool isMem256_RC128() 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)
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.
StringRef getSymName() override
bool isImmSExti64i32Value(uint64_t Value)
unsigned getReg() const override
bool isImmSExti16i8Value(uint64_t Value)
bool isMemOffs32_64() const
bool isImmUnsignedi8() const
void addMemOffsOperands(MCInst &Inst, unsigned N) const
bool isMem256_RC256X() const
Instances of this class represent a single low-level machine instruction.
void addAbsMemOperands(MCInst &Inst, unsigned N) const
const char * getPointer() const
X86Operand - Instances of this class represent a parsed X86 machine instruction.
void addGR32orGR64Operands(MCInst &Inst, unsigned N) const
bool isMem256_RC512() const
void addAVX512RCOperands(MCInst &Inst, unsigned N) const
unsigned getMemBaseReg() const
const MCExpr * getImm() const
bool isImmSExti64i32() const
bool isMemOffs64_16() const
static std::unique_ptr< X86Operand > CreateDXReg(SMLoc StartLoc, SMLoc EndLoc)
bool isMem128_RC128() const
static const char * getRegisterName(unsigned RegNo)
bool isMem512_RC256X() const
void setTokenValue(StringRef Value)
void addExpr(MCInst &Inst, const MCExpr *Expr) const
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.
bool isMemOffs64_32() const
bool isMemOffs32_32() const
void * getOpDecl() override
unsigned getMemScale() const
bool isMem128_RC128X() const
void addImmOperands(MCInst &Inst, unsigned N) const
bool isMem256_RC128X() 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 ...
unsigned getX86SubSuperRegister(unsigned, unsigned, bool High=false)
Returns the sub or super register of a specific X86 register.
bool isMemOffs16_16() const
void print(raw_ostream &OS) const override
print - Print a debug representation of the operand to the given stream.
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)
unsigned getMemIndexReg() const
X86Operand(KindTy K, SMLoc Start, SMLoc End)
bool isImmSExti32i8() 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)
References to labels and assigned expressions.
bool isMemOffs32_16() const
StringRef getName() const
getName - Get the symbol name.
static std::unique_ptr< X86Operand > CreatePrefix(unsigned Prefixes, SMLoc StartLoc, SMLoc EndLoc)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void addMemOperands(MCInst &Inst, unsigned N) const
LLVM Value Representation.
const MCExpr * getMemDisp() const
bool isImmSExti32i8Value(uint64_t Value)
This class implements an extremely fast bulk output stream that can only output to a stream...
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.
enum llvm::X86Operand::KindTy Kind
unsigned getMemSegReg() const
Represents a location in source code.
void addDstIdxOperands(MCInst &Inst, unsigned N) const
bool isMemOffs16_8() const
bool isMemIndexReg(unsigned LowR, unsigned HighR) const
static MCOperand createImm(int64_t Val)
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...