9 #ifndef LLVM_LIB_TARGET_X86_ASMPARSER_X86OPERAND_H 10 #define LLVM_LIB_TARGET_X86_ASMPARSER_X86OPERAND_H 82 : Kind(K), StartLoc(Start), EndLoc(End), CallOperand(
false) {}
102 auto PrintImmValue = [&](
const MCExpr *Val,
const char *VName) {
104 if (
auto Imm = cast<MCConstantExpr>(Val)->getValue())
107 if (
auto *SRE = dyn_cast<MCSymbolRefExpr>(Val)) {
108 const MCSymbol &Sym = SRE->getSymbol();
110 OS << VName << SymNameStr;
126 PrintImmValue(
Imm.
Val,
"Imm:");
143 PrintImmValue(
Mem.
Disp,
",Disp=");
266 if (!
isImm())
return false;
270 if (!CE)
return false;
275 if (!
isImm())
return false;
279 if (!CE)
return true;
377 cast<MCConstantExpr>(
getMemDisp())->getValue() == 0;
397 cast<MCConstantExpr>(
getMemDisp())->getValue() == 0;
457 (X86MCRegisterClasses[X86::GR32RegClassID].contains(
getReg()) ||
458 X86MCRegisterClasses[X86::GR64RegClassID].contains(
getReg()));
463 X86MCRegisterClasses[X86::VK1RegClassID].contains(
getReg());
468 X86MCRegisterClasses[X86::VK2RegClassID].contains(
getReg());
473 X86MCRegisterClasses[X86::VK4RegClassID].contains(
getReg());
478 X86MCRegisterClasses[X86::VK8RegClassID].contains(
getReg());
483 X86MCRegisterClasses[X86::VK16RegClassID].contains(
getReg());
495 assert(N == 1 &&
"Invalid number of operands!");
500 assert(N == 1 &&
"Invalid number of operands!");
502 if (X86MCRegisterClasses[X86::GR64RegClassID].
contains(RegNo))
508 assert(N == 1 &&
"Invalid number of operands!");
513 assert(N == 1 &&
"Invalid number of operands!");
518 assert(N == 1 &&
"Invalid number of operands!");
542 assert((N == 5) &&
"Invalid number of operands!");
551 assert((N == 1) &&
"Invalid number of operands!");
560 assert((N == 2) &&
"Invalid number of operands!");
566 assert((N == 1) &&
"Invalid number of operands!");
571 assert((N == 2) &&
"Invalid number of operands!");
582 auto Res = std::make_unique<X86Operand>(
Token, Loc,
EndLoc);
583 Res->Tok.Data = Str.
data();
584 Res->Tok.Length = Str.
size();
588 static std::unique_ptr<X86Operand>
590 bool AddressOf =
false,
SMLoc OffsetOfLoc =
SMLoc(),
593 Res->Reg.RegNo = RegNo;
601 static std::unique_ptr<X86Operand>
606 static std::unique_ptr<X86Operand>
609 Res->Pref.Prefixes = Prefixes;
616 void *OpDecl =
nullptr,
617 bool GlobalRef =
true) {
620 Res->Imm.LocalRef = !GlobalRef;
623 Res->AddressOf =
true;
628 static std::unique_ptr<X86Operand>
631 void *OpDecl =
nullptr,
unsigned FrontendSize = 0) {
634 Res->Mem.Disp = Disp;
635 Res->Mem.BaseReg = 0;
636 Res->Mem.IndexReg = 0;
638 Res->Mem.Size =
Size;
639 Res->Mem.ModeSize = ModeSize;
640 Res->Mem.FrontendSize = FrontendSize;
643 Res->AddressOf =
false;
648 static std::unique_ptr<X86Operand>
650 unsigned BaseReg,
unsigned IndexReg,
unsigned Scale,
SMLoc StartLoc,
652 void *OpDecl =
nullptr,
unsigned FrontendSize = 0) {
655 assert((SegReg || BaseReg || IndexReg) &&
"Invalid memory operand!");
658 assert(((Scale == 1 || Scale == 2 || Scale == 4 || Scale == 8)) &&
661 Res->Mem.SegReg = SegReg;
662 Res->Mem.Disp = Disp;
663 Res->Mem.BaseReg = BaseReg;
664 Res->Mem.IndexReg = IndexReg;
665 Res->Mem.Scale = Scale;
666 Res->Mem.Size =
Size;
667 Res->Mem.ModeSize = ModeSize;
668 Res->Mem.FrontendSize = FrontendSize;
671 Res->AddressOf =
false;
678 #endif // LLVM_LIB_TARGET_X86_ASMPARSER_X86OPERAND_H
Represents a range in source code.
bool isMem64_RC128X() const
bool isGR32orGR64() const
unsigned getMemFrontendSize() const
Wrapper class representing physical registers. Should be passed by value.
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
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.
MCRegister getX86SubSuperRegister(MCRegister, unsigned, bool High=false)
Returns the sub or super register of a specific X86 register.
bool isMem64_RC128() const
bool isMemOffs64_8() const
return AArch64::GPR64RegClass contains(Reg)
StringRef getToken() const
void addMaskPairOperands(MCInst &Inst, unsigned N) 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
bool isImmUnsignedi4Value(uint64_t Value)
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 > 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.
bool isOffsetOfLocal() const override
isOffsetOfLocal - Do we need to emit code to get the offset of the local variable, rather than its value? Only valid when parsing MS-style inline assembly.
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
LLVM_NODISCARD size_t size() const
size - Get the string size.
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 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 > CreateImm(const MCExpr *Val, SMLoc StartLoc, SMLoc EndLoc, StringRef SymName=StringRef(), void *OpDecl=nullptr, bool GlobalRef=true)
static std::unique_ptr< X86Operand > CreatePrefix(unsigned Prefixes, SMLoc StartLoc, SMLoc EndLoc)
LLVM_NODISCARD const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
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 isImmUnsignedi4() 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.
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)
Wrapper class representing virtual and physical registers.
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...