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;
437 cast<MCConstantExpr>(
getMemDisp())->getValue() == 0;
458 cast<MCConstantExpr>(
getMemDisp())->getValue() == 0;
518 (X86MCRegisterClasses[X86::GR32RegClassID].contains(
getReg()) ||
519 X86MCRegisterClasses[X86::GR64RegClassID].contains(
getReg()));
524 (X86MCRegisterClasses[X86::GR16RegClassID].contains(
getReg()) ||
525 X86MCRegisterClasses[X86::GR32RegClassID].contains(
getReg()) ||
526 X86MCRegisterClasses[X86::GR64RegClassID].contains(
getReg()));
531 (X86MCRegisterClasses[X86::VR64RegClassID].contains(
getReg()) ||
532 X86MCRegisterClasses[X86::VR128XRegClassID].contains(
getReg()) ||
533 X86MCRegisterClasses[X86::VR256XRegClassID].contains(
getReg()) ||
534 X86MCRegisterClasses[X86::VR512RegClassID].contains(
getReg()));
539 X86MCRegisterClasses[X86::VK1RegClassID].contains(
getReg());
544 X86MCRegisterClasses[X86::VK2RegClassID].contains(
getReg());
549 X86MCRegisterClasses[X86::VK4RegClassID].contains(
getReg());
554 X86MCRegisterClasses[X86::VK8RegClassID].contains(
getReg());
559 X86MCRegisterClasses[X86::VK16RegClassID].contains(
getReg());
571 assert(
N == 1 &&
"Invalid number of operands!");
576 assert(
N == 1 &&
"Invalid number of operands!");
578 if (X86MCRegisterClasses[X86::GR64RegClassID].
contains(RegNo))
584 assert(
N == 1 &&
"Invalid number of operands!");
586 if (X86MCRegisterClasses[X86::GR32RegClassID].
contains(RegNo) ||
587 X86MCRegisterClasses[X86::GR64RegClassID].
contains(RegNo))
593 assert(
N == 1 &&
"Invalid number of operands!");
598 assert(
N == 1 &&
"Invalid number of operands!");
603 assert(
N == 1 &&
"Invalid number of operands!");
628 X86MCRegisterClasses[X86::TILERegClassID].contains(
getReg());
632 assert(
N == 1 &&
"Invalid number of operands!");
639 Reg = X86::TMM0_TMM1;
643 Reg = X86::TMM2_TMM3;
647 Reg = X86::TMM4_TMM5;
651 Reg = X86::TMM6_TMM7;
658 assert((
N == 5) &&
"Invalid number of operands!");
670 assert((
N == 1) &&
"Invalid number of operands!");
679 assert((
N == 2) &&
"Invalid number of operands!");
685 assert((
N == 1) &&
"Invalid number of operands!");
690 assert((
N == 2) &&
"Invalid number of operands!");
701 auto Res = std::make_unique<X86Operand>(
Token, Loc,
EndLoc);
702 Res->Tok.Data = Str.data();
703 Res->Tok.Length = Str.size();
707 static std::unique_ptr<X86Operand>
712 Res->Reg.RegNo =
Reg;
720 static std::unique_ptr<X86Operand>
725 static std::unique_ptr<X86Operand>
728 Res->Pref.Prefixes = Prefixes;
736 bool GlobalRef =
true) {
739 Res->Imm.LocalRef = !GlobalRef;
742 Res->AddressOf =
true;
747 static std::unique_ptr<X86Operand>
750 void *
OpDecl =
nullptr,
unsigned FrontendSize = 0,
751 bool UseUpRegs =
false,
bool MaybeDirectBranchDest =
true) {
754 Res->Mem.Disp = Disp;
759 Res->Mem.Size =
Size;
760 Res->Mem.ModeSize = ModeSize;
761 Res->Mem.FrontendSize = FrontendSize;
762 Res->Mem.MaybeDirectBranchDest = MaybeDirectBranchDest;
766 Res->AddressOf =
false;
771 static std::unique_ptr<X86Operand>
777 unsigned FrontendSize = 0,
bool UseUpRegs =
false,
778 bool MaybeDirectBranchDest =
true) {
781 assert((SegReg || BaseReg || IndexReg || DefaultBaseReg) &&
782 "Invalid memory operand!");
785 assert(((Scale == 1 || Scale == 2 || Scale == 4 || Scale == 8)) &&
788 Res->Mem.SegReg = SegReg;
789 Res->Mem.Disp = Disp;
790 Res->Mem.BaseReg = BaseReg;
791 Res->Mem.DefaultBaseReg = DefaultBaseReg;
792 Res->Mem.IndexReg = IndexReg;
793 Res->Mem.Scale = Scale;
794 Res->Mem.Size =
Size;
795 Res->Mem.ModeSize = ModeSize;
796 Res->Mem.FrontendSize = FrontendSize;
797 Res->Mem.MaybeDirectBranchDest = MaybeDirectBranchDest;
801 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
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 isMem256_RC128() 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
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 isMem128_RC256() const
bool isMem256_RC256() const
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 isMem256_RC128X() 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
bool isMem256_RC256X() const
void addGR32orGR64Operands(MCInst &Inst, unsigned N) const
bool isMem128_RC256X() 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 isMem128_RC128() 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...
bool isMem128_RC128X() const
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 isMem256_RC512() const
bool isMemOffs16_16() const
StringRef getToken() const
unsigned getMemFrontendSize() const
bool isMem512_RC512() const
MCRegister getReg() const override
bool isMemOffs16_32() const
bool isMemOffs32_64() const
bool isMem512_RC256X() const
bool isToken() const override
isToken - Is this a token operand?
bool isMem64_RC128X() const
StringRef getSymName() override
bool isGR16orGR32orGR64() const