9#ifndef LLVM_LIB_TARGET_X86_ASMPARSER_X86OPERAND_H
10#define LLVM_LIB_TARGET_X86_ASMPARSER_X86OPERAND_H
111 auto PrintImmValue = [&](
const MCExpr *Val,
const char *VName) {
117 const MCSymbol &Sym = SRE->getSymbol();
119 OS << VName << SymNameStr;
135 PrintImmValue(
Imm.Val,
"Imm:");
138 OS <<
"Prefix:" <<
Pref.Prefixes;
141 OS <<
"Memory: ModeSize=" <<
Mem.ModeSize;
143 OS <<
",Size=" <<
Mem.Size;
150 OS <<
",Scale=" <<
Mem.Scale;
152 PrintImmValue(
Mem.Disp,
",Disp=");
176 return Pref.Prefixes;
198 return Mem.DefaultBaseReg;
214 return Mem.FrontendSize;
218 return Mem.MaybeDirectBranchDest;
283 if (!
isImm())
return false;
287 if (!CE)
return false;
292 if (!
isImm())
return false;
296 if (!CE)
return true;
334 return isMem() &&
Mem.BaseReg != X86::RIP &&
Mem.BaseReg != X86::EIP;
339 return Mem.IndexReg >= LowR &&
Mem.IndexReg <= HighR;
515 (X86MCRegisterClasses[X86::GR32RegClassID].contains(
getReg()) ||
521 (X86MCRegisterClasses[X86::GR16RegClassID].contains(
getReg()) ||
528 (X86MCRegisterClasses[X86::VR64RegClassID].contains(
getReg()) ||
536 X86MCRegisterClasses[X86::VK1RegClassID].contains(
getReg());
541 X86MCRegisterClasses[X86::VK2RegClassID].contains(
getReg());
546 X86MCRegisterClasses[X86::VK4RegClassID].contains(
getReg());
551 X86MCRegisterClasses[X86::VK8RegClassID].contains(
getReg());
556 X86MCRegisterClasses[X86::VK16RegClassID].contains(
getReg());
568 assert(
N == 1 &&
"Invalid number of operands!");
573 assert(
N == 1 &&
"Invalid number of operands!");
575 if (X86MCRegisterClasses[X86::GR64RegClassID].
contains(RegNo))
581 assert(
N == 1 &&
"Invalid number of operands!");
583 if (X86MCRegisterClasses[X86::GR32RegClassID].
contains(RegNo) ||
584 X86MCRegisterClasses[X86::GR64RegClassID].
contains(RegNo))
590 assert(
N == 1 &&
"Invalid number of operands!");
595 assert(
N == 1 &&
"Invalid number of operands!");
600 assert(
N == 1 &&
"Invalid number of operands!");
624 assert((
N == 5) &&
"Invalid number of operands!");
636 assert((
N == 1) &&
"Invalid number of operands!");
645 assert((
N == 2) &&
"Invalid number of operands!");
651 assert((
N == 1) &&
"Invalid number of operands!");
656 assert((
N == 2) &&
"Invalid number of operands!");
668 Res->Tok.Data = Str.data();
669 Res->Tok.Length = Str.size();
673 static std::unique_ptr<X86Operand>
678 Res->Reg.RegNo =
Reg;
686 static std::unique_ptr<X86Operand>
691 static std::unique_ptr<X86Operand>
694 Res->Pref.Prefixes = Prefixes;
702 bool GlobalRef =
true) {
705 Res->Imm.LocalRef = !GlobalRef;
708 Res->AddressOf =
true;
713 static std::unique_ptr<X86Operand>
716 void *
OpDecl =
nullptr,
unsigned FrontendSize = 0,
717 bool UseUpRegs =
false,
bool MaybeDirectBranchDest =
true) {
720 Res->Mem.Disp = Disp;
725 Res->Mem.Size =
Size;
726 Res->Mem.ModeSize = ModeSize;
727 Res->Mem.FrontendSize = FrontendSize;
728 Res->Mem.MaybeDirectBranchDest = MaybeDirectBranchDest;
732 Res->AddressOf =
false;
737 static std::unique_ptr<X86Operand>
743 unsigned FrontendSize = 0,
bool UseUpRegs =
false,
744 bool MaybeDirectBranchDest =
true) {
747 assert((SegReg || BaseReg || IndexReg || DefaultBaseReg) &&
748 "Invalid memory operand!");
751 assert(((Scale == 1 || Scale == 2 || Scale == 4 || Scale == 8)) &&
754 Res->Mem.SegReg = SegReg;
755 Res->Mem.Disp = Disp;
756 Res->Mem.BaseReg = BaseReg;
757 Res->Mem.DefaultBaseReg = DefaultBaseReg;
758 Res->Mem.IndexReg = IndexReg;
759 Res->Mem.Scale = Scale;
760 Res->Mem.Size =
Size;
761 Res->Mem.ModeSize = ModeSize;
762 Res->Mem.FrontendSize = FrontendSize;
763 Res->Mem.MaybeDirectBranchDest = MaybeDirectBranchDest;
767 Res->AddressOf =
false;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
This class is intended to be used as a base class for asm properties and features specific to the tar...
Base class for the full range of assembler expressions which are needed for parsing.
@ Constant
Constant expressions.
@ SymbolRef
References to labels and assigned expressions.
Instances of this class represent a single low-level machine instruction.
void addOperand(const MCOperand Op)
static MCOperand createExpr(const MCExpr *Val)
static MCOperand createReg(MCRegister Reg)
static MCOperand createImm(int64_t Val)
MCParsedAsmOperand()=default
Wrapper class representing physical registers. Should be passed by value.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
StringRef getName() const
getName - Get the symbol name.
Represents a location in source code.
static SMLoc getFromPointer(const char *Ptr)
Represents a range in source code.
StringRef - Represent a constant reference to a string, i.e.
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
LLVM Value Representation.
static const char * getRegisterName(MCRegister Reg)
This class implements an extremely fast bulk output stream that can only output to a stream.
bool isZMMReg(MCRegister Reg)
bool isXMMReg(MCRegister Reg)
bool isYMMReg(MCRegister Reg)
This is an optimization pass for GlobalISel generic memory operations.
bool isImmSExti64i32Value(uint64_t Value)
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
MCRegister getX86SubSuperRegister(MCRegister Reg, unsigned Size, bool High=false)
bool isImmUnsignedi4Value(uint64_t Value)
bool isImmSExti64i8Value(uint64_t Value)
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
bool isImmUnsignedi8Value(uint64_t Value)
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
bool isImmSExti16i8Value(uint64_t Value)
bool isImmSExti32i8Value(uint64_t Value)
bool MaybeDirectBranchDest
If false, then this operand must be a memory operand for an indirect branch instruction.
unsigned FrontendSize
If the memory operand is unsized and there are multiple instruction matches, prefer the one with this...
MCRegister DefaultBaseReg
bool isMemOffs64_64() const
SMLoc getStartLoc() const override
getStartLoc - Get the location of the first token of this operand.
enum llvm::X86Operand::KindTy Kind
bool isMem64_RC256X() const
void addAVX512RCOperands(MCInst &Inst, unsigned N) const
bool isImm() const override
isImm - Is this an immediate operand?
bool isMemUseUpRegs() const override
isMemUseUpRegs - Is memory operand use up regs, for example, intel MS inline asm may use ARR[baseReg ...
bool isMemOffs64_32() const
static std::unique_ptr< X86Operand > CreateImm(const MCExpr *Val, SMLoc StartLoc, SMLoc EndLoc, StringRef SymName=StringRef(), void *OpDecl=nullptr, bool GlobalRef=true)
void addMaskPairOperands(MCInst &Inst, unsigned N) const
void addExpr(MCInst &Inst, const MCExpr *Expr) const
bool isImmSExti64i32() const
X86Operand(KindTy K, SMLoc Start, SMLoc End)
MCRegister getMemSegReg() const
bool isOffsetOfLocal() const override
isOffsetOfLocal - Do we need to emit code to get the offset of the local variable,...
void addGR16orGR32orGR64Operands(MCInst &Inst, unsigned N) const
bool isMem512_GR16() const
static std::unique_ptr< X86Operand > CreatePrefix(unsigned Prefixes, SMLoc StartLoc, SMLoc EndLoc)
bool isMemOffs32_32() const
static std::unique_ptr< X86Operand > CreateDXReg(SMLoc StartLoc, SMLoc EndLoc)
bool UseUpRegs
This used for inline asm which may specify base reg and index reg for MemOp.
bool isImmSExti64i8() const
bool isMaybeDirectBranchDest() const
void addAbsMemOperands(MCInst &Inst, unsigned N) const
bool isGR32orGR64() const
void addImmOperands(MCInst &Inst, unsigned N) const
void print(raw_ostream &OS, const MCAsmInfo &) const override
print - Print a debug representation of the operand to the given stream.
void setTokenValue(StringRef Value)
bool isMem512_GR64() const
void addMemOffsOperands(MCInst &Inst, unsigned N) const
bool isImmUnsignedi8() const
void addSrcIdxOperands(MCInst &Inst, unsigned N) const
bool isMem32_RC256X() const
bool isAbsMemMode16() const
void * getOpDecl() override
bool isMemOffs32_8() const
static std::unique_ptr< X86Operand > CreateReg(MCRegister Reg, SMLoc StartLoc, SMLoc EndLoc, bool AddressOf=false, SMLoc OffsetOfLoc=SMLoc(), StringRef SymName=StringRef(), void *OpDecl=nullptr)
bool isMemOffs64_8() const
bool isImmSExti16i8() const
SMRange getLocRange() const
getLocRange - Get the range between the first and last token of this operand.
bool isMem32_RC512() const
MCRegister getMemBaseReg() const
unsigned getMemScale() const
SMLoc getEndLoc() const override
getEndLoc - Get the location of the last token of this operand.
bool isReg() const override
isReg - Is this a register operand?
bool isMem() const override
isMem - Is this a memory operand?
bool isImmUnsignedi4() const
const MCExpr * getMemDisp() const
bool isMemOffs16_8() const
unsigned getPrefix() const
bool isMem512_GR32() 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, bool UseUpRegs=false, bool MaybeDirectBranchDest=true)
Create an absolute memory operand.
bool isImmSExti32i8() const
void addGR32orGR64Operands(MCInst &Inst, unsigned N) const
bool isMem32_RC128X() const
bool isMem64_RC512() const
bool isMem64_RC128() const
bool isMemIndexReg(unsigned LowR, unsigned HighR) const
bool isMemOffs32_16() const
void addMemOperands(MCInst &Inst, unsigned N) const
void addRegOperands(MCInst &Inst, unsigned N) const
void addDstIdxOperands(MCInst &Inst, unsigned N) const
static std::unique_ptr< X86Operand > CreateMem(unsigned ModeSize, MCRegister SegReg, const MCExpr *Disp, MCRegister BaseReg, MCRegister IndexReg, unsigned Scale, SMLoc StartLoc, SMLoc EndLoc, unsigned Size=0, MCRegister DefaultBaseReg=MCRegister(), StringRef SymName=StringRef(), void *OpDecl=nullptr, unsigned FrontendSize=0, bool UseUpRegs=false, bool MaybeDirectBranchDest=true)
Create a generalized memory operand.
unsigned getMemModeSize() const
bool isMem64_RC256() const
bool isMemOffs64_16() const
bool needAddressOf() const override
needAddressOf - Do we need to emit code to get the address of the variable/label?
MCRegister getMemDefaultBaseReg() const
static std::unique_ptr< X86Operand > CreateToken(StringRef Str, SMLoc Loc)
bool isMemUnsized() const
const MCExpr * getImm() const
SMLoc getOffsetOfLoc() const override
getOffsetOfLoc - Get the location of the offset operator.
MCRegister getMemIndexReg() const
bool isMem32_RC128() const
bool isMem32_RC256() const
bool isMemOffs16_16() const
StringRef getToken() const
unsigned getMemFrontendSize() const
MCRegister getReg() const override
bool isMemOffs16_32() const
bool isMemOffs32_64() const
bool isToken() const override
isToken - Is this a token operand?
bool isMem64_RC128X() const
StringRef getSymName() override
bool isGR16orGR32orGR64() const