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) {
113 if (
auto Imm = cast<MCConstantExpr>(Val)->getValue())
116 if (
auto *SRE = dyn_cast<MCSymbolRefExpr>(Val)) {
118 if (
const char *SymNameStr =
Sym.getName().data())
119 OS << VName << SymNameStr;
135 PrintImmValue(
Imm.
Val,
"Imm:");
152 PrintImmValue(
Mem.
Disp,
",Disp=");
283 if (!
isImm())
return false;
287 if (!CE)
return false;
292 if (!
isImm())
return false;
296 if (!CE)
return true;
421 if (
auto *CE = dyn_cast<MCConstantExpr>(
getMemDisp()))
434 cast<MCConstantExpr>(
getMemDisp())->getValue() == 0;
455 cast<MCConstantExpr>(
getMemDisp())->getValue() == 0;
515 (X86MCRegisterClasses[X86::GR32RegClassID].contains(
getReg()) ||
516 X86MCRegisterClasses[X86::GR64RegClassID].contains(
getReg()));
521 (X86MCRegisterClasses[X86::GR16RegClassID].contains(
getReg()) ||
522 X86MCRegisterClasses[X86::GR32RegClassID].contains(
getReg()) ||
523 X86MCRegisterClasses[X86::GR64RegClassID].contains(
getReg()));
528 (X86MCRegisterClasses[X86::VR64RegClassID].contains(
getReg()) ||
529 X86MCRegisterClasses[X86::VR128XRegClassID].contains(
getReg()) ||
530 X86MCRegisterClasses[X86::VR256XRegClassID].contains(
getReg()) ||
531 X86MCRegisterClasses[X86::VR512RegClassID].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!");
625 X86MCRegisterClasses[X86::TILERegClassID].contains(
getReg());
629 assert(
N == 1 &&
"Invalid number of operands!");
636 Reg = X86::TMM0_TMM1;
640 Reg = X86::TMM2_TMM3;
644 Reg = X86::TMM4_TMM5;
648 Reg = X86::TMM6_TMM7;
655 assert((
N == 5) &&
"Invalid number of operands!");
667 assert((
N == 1) &&
"Invalid number of operands!");
676 assert((
N == 2) &&
"Invalid number of operands!");
682 assert((
N == 1) &&
"Invalid number of operands!");
687 assert((
N == 2) &&
"Invalid number of operands!");
698 auto Res = std::make_unique<X86Operand>(
Token, Loc,
EndLoc);
699 Res->Tok.Data = Str.data();
700 Res->Tok.Length = Str.size();
704 static std::unique_ptr<X86Operand>
709 Res->Reg.RegNo =
Reg;
717 static std::unique_ptr<X86Operand>
722 static std::unique_ptr<X86Operand>
725 Res->Pref.Prefixes = Prefixes;
733 bool GlobalRef =
true) {
736 Res->Imm.LocalRef = !GlobalRef;
739 Res->AddressOf =
true;
744 static std::unique_ptr<X86Operand>
747 void *
OpDecl =
nullptr,
unsigned FrontendSize = 0,
748 bool UseUpRegs =
false,
bool MaybeDirectBranchDest =
true) {
751 Res->Mem.Disp = Disp;
756 Res->Mem.Size =
Size;
757 Res->Mem.ModeSize = ModeSize;
758 Res->Mem.FrontendSize = FrontendSize;
759 Res->Mem.MaybeDirectBranchDest = MaybeDirectBranchDest;
763 Res->AddressOf =
false;
768 static std::unique_ptr<X86Operand>
774 unsigned FrontendSize = 0,
bool UseUpRegs =
false,
775 bool MaybeDirectBranchDest =
true) {
778 assert((SegReg || BaseReg || IndexReg || DefaultBaseReg) &&
779 "Invalid memory operand!");
782 assert(((Scale == 1 || Scale == 2 || Scale == 4 || Scale == 8)) &&
785 Res->Mem.SegReg = SegReg;
786 Res->Mem.Disp = Disp;
787 Res->Mem.BaseReg = BaseReg;
788 Res->Mem.DefaultBaseReg = DefaultBaseReg;
789 Res->Mem.IndexReg = IndexReg;
790 Res->Mem.Scale = Scale;
791 Res->Mem.Size =
Size;
792 Res->Mem.ModeSize = ModeSize;
793 Res->Mem.FrontendSize = FrontendSize;
794 Res->Mem.MaybeDirectBranchDest = MaybeDirectBranchDest;
798 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 - 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 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? 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