9#ifndef LLVM_LIB_TARGET_X86_ASMPARSER_X86OPERAND_H
10#define LLVM_LIB_TARGET_X86_ASMPARSER_X86OPERAND_H
112 auto PrintImmValue = [&](
const MCExpr *Val,
const char *VName) {
114 if (
auto Imm = cast<MCConstantExpr>(Val)->getValue())
117 if (
auto *SRE = dyn_cast<MCSymbolRefExpr>(Val)) {
119 if (
const char *SymNameStr =
Sym.getName().data())
120 OS << VName << SymNameStr;
136 PrintImmValue(
Imm.
Val,
"Imm:");
153 PrintImmValue(
Mem.
Disp,
",Disp=");
284 if (!
isImm())
return false;
288 if (!CE)
return false;
293 if (!
isImm())
return false;
297 if (!CE)
return true;
429 cast<MCConstantExpr>(
getMemDisp())->getValue() == 0;
450 cast<MCConstantExpr>(
getMemDisp())->getValue() == 0;
510 (X86MCRegisterClasses[X86::GR32RegClassID].contains(
getReg()) ||
511 X86MCRegisterClasses[X86::GR64RegClassID].contains(
getReg()));
516 (X86MCRegisterClasses[X86::GR16RegClassID].contains(
getReg()) ||
517 X86MCRegisterClasses[X86::GR32RegClassID].contains(
getReg()) ||
518 X86MCRegisterClasses[X86::GR64RegClassID].contains(
getReg()));
523 (X86MCRegisterClasses[X86::VR64RegClassID].contains(
getReg()) ||
524 X86MCRegisterClasses[X86::VR128XRegClassID].contains(
getReg()) ||
525 X86MCRegisterClasses[X86::VR256XRegClassID].contains(
getReg()) ||
526 X86MCRegisterClasses[X86::VR512RegClassID].contains(
getReg()));
531 X86MCRegisterClasses[X86::VK1RegClassID].contains(
getReg());
536 X86MCRegisterClasses[X86::VK2RegClassID].contains(
getReg());
541 X86MCRegisterClasses[X86::VK4RegClassID].contains(
getReg());
546 X86MCRegisterClasses[X86::VK8RegClassID].contains(
getReg());
551 X86MCRegisterClasses[X86::VK16RegClassID].contains(
getReg());
563 assert(
N == 1 &&
"Invalid number of operands!");
568 assert(
N == 1 &&
"Invalid number of operands!");
570 if (X86MCRegisterClasses[X86::GR64RegClassID].
contains(RegNo))
576 assert(
N == 1 &&
"Invalid number of operands!");
578 if (X86MCRegisterClasses[X86::GR32RegClassID].
contains(RegNo) ||
579 X86MCRegisterClasses[X86::GR64RegClassID].
contains(RegNo))
585 assert(
N == 1 &&
"Invalid number of operands!");
590 assert(
N == 1 &&
"Invalid number of operands!");
595 assert(
N == 1 &&
"Invalid number of operands!");
620 X86MCRegisterClasses[X86::TILERegClassID].contains(
getReg());
624 assert(
N == 1 &&
"Invalid number of operands!");
631 Reg = X86::TMM0_TMM1;
635 Reg = X86::TMM2_TMM3;
639 Reg = X86::TMM4_TMM5;
643 Reg = X86::TMM6_TMM7;
650 assert((
N == 5) &&
"Invalid number of operands!");
662 assert((
N == 1) &&
"Invalid number of operands!");
671 assert((
N == 2) &&
"Invalid number of operands!");
677 assert((
N == 1) &&
"Invalid number of operands!");
682 assert((
N == 2) &&
"Invalid number of operands!");
693 auto Res = std::make_unique<X86Operand>(
Token, Loc,
EndLoc);
694 Res->Tok.Data = Str.data();
695 Res->Tok.Length = Str.size();
699 static std::unique_ptr<X86Operand>
704 Res->Reg.RegNo =
Reg;
712 static std::unique_ptr<X86Operand>
717 static std::unique_ptr<X86Operand>
720 Res->Pref.Prefixes = Prefixes;
728 bool GlobalRef =
true) {
731 Res->Imm.LocalRef = !GlobalRef;
734 Res->AddressOf =
true;
739 static std::unique_ptr<X86Operand>
742 void *
OpDecl =
nullptr,
unsigned FrontendSize = 0,
743 bool UseUpRegs =
false,
bool MaybeDirectBranchDest =
true) {
746 Res->Mem.Disp = Disp;
751 Res->Mem.Size =
Size;
752 Res->Mem.ModeSize = ModeSize;
753 Res->Mem.FrontendSize = FrontendSize;
754 Res->Mem.MaybeDirectBranchDest = MaybeDirectBranchDest;
758 Res->AddressOf =
false;
763 static std::unique_ptr<X86Operand>
769 unsigned FrontendSize = 0,
bool UseUpRegs =
false,
770 bool MaybeDirectBranchDest =
true) {
773 assert((SegReg || BaseReg || IndexReg || DefaultBaseReg) &&
774 "Invalid memory operand!");
777 assert(((Scale == 1 || Scale == 2 || Scale == 4 || Scale == 8)) &&
780 Res->Mem.SegReg = SegReg;
781 Res->Mem.Disp = Disp;
782 Res->Mem.BaseReg = BaseReg;
783 Res->Mem.DefaultBaseReg = DefaultBaseReg;
784 Res->Mem.IndexReg = IndexReg;
785 Res->Mem.Scale = Scale;
786 Res->Mem.Size =
Size;
787 Res->Mem.ModeSize = ModeSize;
788 Res->Mem.FrontendSize = FrontendSize;
789 Res->Mem.MaybeDirectBranchDest = MaybeDirectBranchDest;
793 Res->AddressOf =
false;
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
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 - This abstract class represents a source-level assembly instruction operand.
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 ...
Wrapper class representing virtual and physical registers.
Represents a location in source code.
static SMLoc getFromPointer(const char *Ptr)
constexpr const char * getPointer() const
Represents a range in source code.
StringRef - Represent a constant reference to a string, i.e.
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.
This class provides various memory handling functions that manipulate MemoryBlock instances.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
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)
MCRegister getX86SubSuperRegister(MCRegister Reg, unsigned Size, bool High=false)
bool isImmUnsignedi4Value(uint64_t Value)
bool isImmSExti64i8Value(uint64_t Value)
bool isImmUnsignedi8Value(uint64_t Value)
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
X86Operand - Instances of this class represent a parsed X86 machine instruction.
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 addTILEPairOperands(MCInst &Inst, unsigned N) const
void addAbsMemOperands(MCInst &Inst, unsigned N) const
bool isGR32orGR64() const
void addImmOperands(MCInst &Inst, unsigned N) const
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
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
void print(raw_ostream &OS) const override
print - Print a debug representation of the operand to the given stream.
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? Only valid when par...
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