9#ifndef LLVM_MC_MCEXPR_H
10#define LLVM_MC_MCEXPR_H
45 static const unsigned NumSubclassDataBits = 24;
48 "ExprKind and SubclassData together should take up one word");
52 unsigned SubclassData : NumSubclassDataBits;
55 bool evaluateAsAbsolute(int64_t &Res,
const MCAssembler *Asm,
60 : Kind(Kind), SubclassData(SubclassData), Loc(Loc) {
61 assert(SubclassData < (1 << NumSubclassDataBits) &&
62 "Subclass data too large");
86 bool InParens =
false)
const;
101 bool evaluateAsAbsolute(int64_t &Res,
const MCAssembler &Asm,
103 bool evaluateAsAbsolute(int64_t &Res)
const;
104 bool evaluateAsAbsolute(int64_t &Res,
const MCAssembler &Asm)
const;
105 bool evaluateAsAbsolute(int64_t &Res,
const MCAssembler *Asm)
const;
139 E.print(
OS,
nullptr);
148 static const unsigned SizeInBytesBits = 8;
149 static const unsigned SizeInBytesMask = (1 << SizeInBytesBits) - 1;
150 static const unsigned PrintInHexBit = 1 << SizeInBytesBits;
152 static unsigned encodeSubclassData(
bool PrintInHex,
unsigned SizeInBytes) {
153 assert(SizeInBytes <=
sizeof(int64_t) &&
"Excessive size");
154 return SizeInBytes | (PrintInHex ? PrintInHexBit : 0);
159 encodeSubclassData(PrintInHex, SizeInBytes)),
Value(
Value) {}
166 bool PrintInHex =
false,
167 unsigned SizeInBytes = 0);
379 static const unsigned VariantKindBits = 16;
380 static const unsigned VariantKindMask = (1 << VariantKindBits) - 1;
383 static const unsigned HasSubsectionsViaSymbolsBit = 1 << VariantKindBits;
385 static unsigned encodeSubclassData(
VariantKind Kind,
386 bool HasSubsectionsViaSymbols) {
387 return (
unsigned)Kind |
388 (HasSubsectionsViaSymbols ? HasSubsectionsViaSymbolsBit : 0);
391 explicit MCSymbolRefExpr(
const MCSymbol *Symbol,
VariantKind Kind,
392 const MCAsmInfo *MAI, SMLoc Loc = SMLoc());
457 MCContext &Ctx, SMLoc Loc = SMLoc());
534 const MCExpr *RHS, MCContext &Ctx,
535 SMLoc Loc = SMLoc());
658 virtual void anchor();
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines the DenseMap class.
PowerPC TLS Dynamic Call Fixup
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class represents an Operation in the Expression.
This class is intended to be used as a base class for asm properties and features specific to the tar...
Binary assembler expressions.
const MCExpr * getLHS() const
Get the left-hand side expression of the binary operator.
static const MCBinaryExpr * createEQ(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static const MCBinaryExpr * createLShr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static const MCBinaryExpr * createLAnd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
const MCExpr * getRHS() const
Get the right-hand side expression of the binary operator.
static const MCBinaryExpr * createXor(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static const MCBinaryExpr * createAnd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static bool classof(const MCExpr *E)
static const MCBinaryExpr * createLT(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Opcode getOpcode() const
Get the kind of this binary expression.
static const MCBinaryExpr * createOr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static const MCBinaryExpr * createMod(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static const MCBinaryExpr * createLOr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static const MCBinaryExpr * createNE(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static const MCBinaryExpr * createGTE(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static const MCBinaryExpr * createMul(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static const MCBinaryExpr * createLTE(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static const MCBinaryExpr * createAShr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static const MCBinaryExpr * createGT(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static const MCBinaryExpr * createDiv(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static const MCBinaryExpr * create(Opcode Op, const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx, SMLoc Loc=SMLoc())
static const MCBinaryExpr * createShl(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
@ AShr
Arithmetic shift right.
@ LShr
Logical shift right.
@ GTE
Signed greater than or equal comparison (result is either 0 or some target-specific non-zero value).
@ GT
Signed greater than comparison (result is either 0 or some target-specific non-zero value)
@ Xor
Bitwise exclusive or.
@ LT
Signed less than comparison (result is either 0 or some target-specific non-zero value).
@ LTE
Signed less than or equal comparison (result is either 0 or some target-specific non-zero value).
@ NE
Inequality comparison.
static bool classof(const MCExpr *E)
bool useHexFormat() const
unsigned getSizeInBytes() const
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Context object for machine code objects.
Base class for the full range of assembler expressions which are needed for parsing.
bool evaluateAsValue(MCValue &Res, const MCAssembler &Asm) const
Try to evaluate the expression to the form (a - b + constant) where neither a nor b are variables.
MCExpr & operator=(const MCExpr &)=delete
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm, const MCFixup *Fixup, const SectionAddrMap *Addrs, bool InSet) const
MCExpr(ExprKind Kind, SMLoc Loc, unsigned SubclassData=0)
@ Unary
Unary expressions.
@ Constant
Constant expressions.
@ SymbolRef
References to labels and assigned expressions.
@ Target
Target specific expression.
@ Binary
Binary expressions.
MCExpr(const MCExpr &)=delete
bool evaluateKnownAbsolute(int64_t &Res, const MCAssembler &Asm) const
Aggressive variant of evaluateAsRelocatable when relocations are unavailable (e.g.
bool evaluateAsRelocatable(MCValue &Res, const MCAssembler *Asm, const MCFixup *Fixup) const
Try to evaluate the expression to a relocatable value, i.e.
unsigned getSubclassData() const
bool isSymbolUsedInExpression(const MCSymbol *Sym) const
Returns whether the given symbol is used anywhere in the expression or subexpressions.
void print(raw_ostream &OS, const MCAsmInfo *MAI, bool InParens=false) const
MCFragment * findAssociatedFragment() const
Find the "associated section" for this expression, which is currently defined as the absolute section...
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Streaming machine code generation interface.
Represent a reference to a symbol from inside an expression.
const MCSymbol & getSymbol() const
static bool classof(const MCExpr *E)
static StringRef getVariantKindName(VariantKind Kind)
static VariantKind getVariantKindForName(StringRef Name)
@ VK_AMDGPU_GOTPCREL32_LO
@ VK_AMDGPU_GOTPCREL32_HI
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
VariantKind getKind() const
bool hasSubsectionsViaSymbols() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
This is an extension point for target-specific MCExpr subclasses to implement.
static bool classof(const MCExpr *E)
virtual void visitUsedExpr(MCStreamer &Streamer) const =0
virtual void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const =0
virtual bool isSymbolUsedInExpression(const MCSymbol *Sym) const
virtual void fixELFSymbolsInTLSFixups(MCAssembler &) const =0
virtual MCFragment * findAssociatedFragment() const =0
virtual bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm, const MCFixup *Fixup) const =0
virtual bool isEqualTo(const MCExpr *x) const
virtual bool inlineAssignedExpr() const
virtual ~MCTargetExpr()=default
Unary assembler expressions.
Opcode getOpcode() const
Get the kind of this unary expression.
static bool classof(const MCExpr *E)
static const MCUnaryExpr * create(Opcode Op, const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())
static const MCUnaryExpr * createLNot(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())
const MCExpr * getSubExpr() const
Get the child of this unary expression.
static const MCUnaryExpr * createPlus(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())
static const MCUnaryExpr * createNot(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())
static const MCUnaryExpr * createMinus(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())
This represents an "assembler immediate".
Represents a location in source code.
StringRef - Represent a constant reference to a string, i.e.
Target - Wrapper for Target specific information.
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
DWARFExpression::Operation Op
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)