Go to the documentation of this file.
9 #ifndef LLVM_LIB_TARGET_X86_ASMPARSER_X86OPERAND_H
10 #define LLVM_LIB_TARGET_X86_ASMPARSER_X86OPERAND_H
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 << SymNameStr;
125 PrintImmValue(
Imm.
Val,
"Imm:");
142 PrintImmValue(
Mem.
Disp,
",Disp=");
269 if (!
isImm())
return false;
273 if (!CE)
return false;
278 if (!
isImm())
return false;
282 if (!CE)
return true;
385 cast<MCConstantExpr>(
getMemDisp())->getValue() == 0;
405 cast<MCConstantExpr>(
getMemDisp())->getValue() == 0;
465 (X86MCRegisterClasses[X86::GR32RegClassID].contains(
getReg()) ||
466 X86MCRegisterClasses[X86::GR64RegClassID].contains(
getReg()));
471 (X86MCRegisterClasses[X86::GR16RegClassID].contains(
getReg()) ||
472 X86MCRegisterClasses[X86::GR32RegClassID].contains(
getReg()) ||
473 X86MCRegisterClasses[X86::GR64RegClassID].contains(
getReg()));
478 (X86MCRegisterClasses[X86::VR64RegClassID].contains(
getReg()) ||
479 X86MCRegisterClasses[X86::VR128XRegClassID].contains(
getReg()) ||
480 X86MCRegisterClasses[X86::VR256XRegClassID].contains(
getReg()) ||
481 X86MCRegisterClasses[X86::VR512RegClassID].contains(
getReg()));
486 X86MCRegisterClasses[X86::VK1RegClassID].contains(
getReg());
491 X86MCRegisterClasses[X86::VK2RegClassID].contains(
getReg());
496 X86MCRegisterClasses[X86::VK4RegClassID].contains(
getReg());
501 X86MCRegisterClasses[X86::VK8RegClassID].contains(
getReg());
506 X86MCRegisterClasses[X86::VK16RegClassID].contains(
getReg());
518 assert(
N == 1 &&
"Invalid number of operands!");
523 assert(
N == 1 &&
"Invalid number of operands!");
525 if (X86MCRegisterClasses[X86::GR64RegClassID].
contains(RegNo))
531 assert(
N == 1 &&
"Invalid number of operands!");
533 if (X86MCRegisterClasses[X86::GR32RegClassID].
contains(RegNo) ||
534 X86MCRegisterClasses[X86::GR64RegClassID].
contains(RegNo))
540 assert(
N == 1 &&
"Invalid number of operands!");
545 assert(
N == 1 &&
"Invalid number of operands!");
550 assert(
N == 1 &&
"Invalid number of operands!");
574 assert((
N == 5) &&
"Invalid number of operands!");
586 assert((
N == 1) &&
"Invalid number of operands!");
595 assert((
N == 2) &&
"Invalid number of operands!");
601 assert((
N == 1) &&
"Invalid number of operands!");
606 assert((
N == 2) &&
"Invalid number of operands!");
617 auto Res = std::make_unique<X86Operand>(
Token, Loc,
EndLoc);
618 Res->Tok.Data = Str.
data();
619 Res->Tok.Length = Str.
size();
623 static std::unique_ptr<X86Operand>
628 Res->Reg.RegNo = RegNo;
636 static std::unique_ptr<X86Operand>
641 static std::unique_ptr<X86Operand>
644 Res->Pref.Prefixes = Prefixes;
652 bool GlobalRef =
true) {
655 Res->Imm.LocalRef = !GlobalRef;
658 Res->AddressOf =
true;
663 static std::unique_ptr<X86Operand>
666 void *
OpDecl =
nullptr,
unsigned FrontendSize = 0) {
669 Res->Mem.Disp = Disp;
670 Res->Mem.BaseReg = 0;
671 Res->Mem.DefaultBaseReg = 0;
672 Res->Mem.IndexReg = 0;
674 Res->Mem.Size =
Size;
675 Res->Mem.ModeSize = ModeSize;
676 Res->Mem.FrontendSize = FrontendSize;
679 Res->AddressOf =
false;
684 static std::unique_ptr<X86Operand>
686 unsigned BaseReg,
unsigned IndexReg,
unsigned Scale,
SMLoc StartLoc,
688 unsigned DefaultBaseReg = X86::NoRegister,
690 unsigned FrontendSize = 0) {
693 assert((SegReg || BaseReg || IndexReg || DefaultBaseReg) &&
694 "Invalid memory operand!");
697 assert(((Scale == 1 || Scale == 2 || Scale == 4 || Scale == 8)) &&
700 Res->Mem.SegReg = SegReg;
701 Res->Mem.Disp = Disp;
702 Res->Mem.BaseReg = BaseReg;
703 Res->Mem.DefaultBaseReg = DefaultBaseReg;
704 Res->Mem.IndexReg = IndexReg;
705 Res->Mem.Scale = Scale;
706 Res->Mem.Size =
Size;
707 Res->Mem.ModeSize = ModeSize;
708 Res->Mem.FrontendSize = FrontendSize;
711 Res->AddressOf =
false;
718 #endif // LLVM_LIB_TARGET_X86_ASMPARSER_X86OPERAND_H
void addAVX512RCOperands(MCInst &Inst, unsigned N) const
SMLoc getEndLoc() const override
getEndLoc - Get the location of the last token of this operand.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
unsigned getMemScale() const
static MCOperand createExpr(const MCExpr *Val)
MCParsedAsmOperand - This abstract class represents a source-level assembly instruction operand.
bool isMem128_RC256X() const
bool isMemIndexReg(unsigned LowR, unsigned HighR) const
static MCOperand createImm(int64_t Val)
void addImmOperands(MCInst &Inst, unsigned N) const
bool isMem256_RC128X() const
bool isImmUnsignedi4Value(uint64_t Value)
return AArch64::GPR64RegClass contains(Reg)
bool isMem256_RC256X() const
bool isImmSExti32i8Value(uint64_t Value)
bool isImmSExti32i8() const
unsigned getMemIndexReg() const
bool isMem() const override
isMem - Is this a memory operand?
unsigned getPrefix() const
Instances of this class represent a single low-level machine instruction.
bool isMemOffs32_8() const
bool isReg() const override
isReg - Is this a register operand?
bool isMem256_RC128() const
bool isImmSExti64i32() const
bool isMem256_RC512() const
static std::unique_ptr< X86Operand > CreatePrefix(unsigned Prefixes, SMLoc StartLoc, SMLoc EndLoc)
bool isMemOffs64_16() const
void addMaskPairOperands(MCInst &Inst, unsigned N) const
void addAbsMemOperands(MCInst &Inst, unsigned N) const
Represents a location in source code.
void addMemOffsOperands(MCInst &Inst, unsigned N) const
bool isMem64_RC128X() const
void addDstIdxOperands(MCInst &Inst, unsigned N) const
enum llvm::X86Operand::KindTy Kind
bool isImmSExti64i8Value(uint64_t Value)
This class implements an extremely fast bulk output stream that can only output to a stream.
bool isImm() const override
isImm - Is this an immediate operand?
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.
StringRef getName() const
getName - Get the symbol name.
bool isImmUnsignedi8Value(uint64_t Value)
bool isImmSExti16i8() const
void addGR16orGR32orGR64Operands(MCInst &Inst, unsigned N) const
SMRange getLocRange() const
getLocRange - Get the range between the first and last token of this operand.
void addOperand(const MCOperand Op)
bool isGR16orGR32orGR64() const
bool isMemOffs64_32() const
bool isMem128_RC128() const
bool isImmSExti64i8() const
bool isImmSExti16i8Value(uint64_t Value)
void * getOpDecl() override
unsigned getMemDefaultBaseReg() const
const MCExpr * getMemDisp() const
bool isMemOffs64_64() const
X86Operand - Instances of this class represent a parsed X86 machine instruction.
MCRegister getX86SubSuperRegister(MCRegister, unsigned, bool High=false)
Returns the sub or super register of a specific X86 register.
static std::unique_ptr< X86Operand > CreateImm(const MCExpr *Val, SMLoc StartLoc, SMLoc EndLoc, StringRef SymName=StringRef(), void *OpDecl=nullptr, bool GlobalRef=true)
bool isMemOffs16_16() const
void addSrcIdxOperands(MCInst &Inst, unsigned N) const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static std::unique_ptr< X86Operand > CreateDXReg(SMLoc StartLoc, SMLoc EndLoc)
bool isImmUnsignedi8() const
bool isMem128_RC128X() const
bool isGR32orGR64() const
static const char * getRegisterName(unsigned RegNo)
const MCExpr * getImm() const
void addExpr(MCInst &Inst, const MCExpr *Expr) const
bool isMem512_RC512() const
This class provides various memory handling functions that manipulate MemoryBlock instances.
StringRef - Represent a constant reference to a string, i.e.
static MCOperand createReg(unsigned Reg)
void addRegOperands(MCInst &Inst, unsigned N) const
Wrapper class representing virtual and physical registers.
bool isMem64_RC128() const
unsigned getReg() const override
bool isMem256_RC256() const
void addMemOperands(MCInst &Inst, unsigned N) const
X86Operand(KindTy K, SMLoc Start, SMLoc End)
SMLoc getStartLoc() const override
getStartLoc - Get the location of the first token of this operand.
const char * getPointer() const
unsigned getMemModeSize() const
bool isMemOffs64_8() const
unsigned FrontendSize
If the memory operand is unsized and there are multiple instruction matches, prefer the one with this...
void addGR32orGR64Operands(MCInst &Inst, unsigned N) const
bool isMemOffs16_8() const
static std::unique_ptr< X86Operand > CreateToken(StringRef Str, SMLoc Loc)
StringRef getToken() const
unsigned getMemBaseReg() const
unsigned getMemFrontendSize() const
void print(raw_ostream &OS) const override
print - Print a debug representation of the operand to the given stream.
@ SymbolRef
References to labels and assigned expressions.
Represents a range in source code.
bool needAddressOf() const override
needAddressOf - Do we need to emit code to get the address of the variable/label? Only valid when par...
@ Constant
Constant expressions.
static std::unique_ptr< X86Operand > CreateReg(unsigned RegNo, SMLoc StartLoc, SMLoc EndLoc, bool AddressOf=false, SMLoc OffsetOfLoc=SMLoc(), StringRef SymName=StringRef(), void *OpDecl=nullptr)
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, unsigned DefaultBaseReg=X86::NoRegister, StringRef SymName=StringRef(), void *OpDecl=nullptr, unsigned FrontendSize=0)
Create a generalized memory operand.
const LLVM_NODISCARD char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
bool isMemOffs32_16() const
static SMLoc getFromPointer(const char *Ptr)
bool isImmSExti64i32Value(uint64_t Value)
bool isMem512_RC256X() const
StringRef getSymName() override
bool isMemUnsized() const
SMLoc getOffsetOfLoc() const override
getOffsetOfLoc - Get the location of the offset operator.
LLVM_NODISCARD size_t size() const
size - Get the string size.
bool isMem128_RC256() const
bool isMemOffs16_32() const
LLVM Value Representation.
unsigned getMemSegReg() const
bool isImmUnsignedi4() const
Base class for the full range of assembler expressions which are needed for parsing.
bool isMemOffs32_64() const
bool isMemOffs32_32() const
bool isToken() const override
isToken - Is this a token operand?
void setTokenValue(StringRef Value)
Wrapper class representing physical registers. Should be passed by value.
bool isOffsetOfLocal() const override
isOffsetOfLocal - Do we need to emit code to get the offset of the local variable,...