9#ifndef LLVM_MC_MCEXPR_H
10#define LLVM_MC_MCEXPR_H
50 static const unsigned NumSubclassDataBits = 24;
53 "ExprKind and SubclassData together should take up one word");
57 unsigned SubclassData : NumSubclassDataBits;
61 int SurroundingPrec = 0)
const;
62 bool evaluateAsAbsolute(int64_t &Res,
const MCAssembler *Asm,
68 : Kind(Kind), SubclassData(SubclassData), Loc(Loc) {
69 assert(SubclassData < (1 << NumSubclassDataBits) &&
70 "Subclass data too large");
102 LLVM_ABI bool evaluateAsAbsolute(int64_t &Res)
const;
146 static const unsigned SizeInBytesBits = 8;
147 static const unsigned SizeInBytesMask = (1 << SizeInBytesBits) - 1;
148 static const unsigned PrintInHexBit = 1 << SizeInBytesBits;
150 static unsigned encodeSubclassData(
bool PrintInHex,
unsigned SizeInBytes) {
151 assert(SizeInBytes <=
sizeof(int64_t) &&
"Excessive size");
152 return SizeInBytes | (PrintInHex ? PrintInHexBit : 0);
157 encodeSubclassData(PrintInHex, SizeInBytes)),
Value(
Value) {}
164 bool PrintInHex =
false,
165 unsigned SizeInBytes = 0);
263 create(
Opcode Op,
const MCExpr *Expr, MCContext &Ctx, SMLoc Loc = SMLoc());
340 const MCExpr *RHS, MCContext &Ctx,
341 SMLoc Loc = SMLoc());
466 virtual void anchor();
485 return E->getKind() == MCExpr::Target;
500 :
MCExpr(Specifier, Loc, S), Expr(Expr) {}
512 return E->getKind() == MCExpr::Specifier;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines the DenseMap class.
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)
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx, SMLoc Loc=SMLoc())
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 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 LLVM_ABI 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 LLVM_ABI 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.
LLVM_ABI 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
LLVM_ABI bool evaluateAsRelocatable(MCValue &Res, const MCAssembler *Asm) const
Try to evaluate the expression to a relocatable value, i.e.
MCExpr(ExprKind Kind, SMLoc Loc, unsigned SubclassData=0)
@ Unary
Unary expressions.
@ Constant
Constant expressions.
@ SymbolRef
References to labels and assigned expressions.
@ Specifier
Expression with a relocation specifier.
@ Binary
Binary expressions.
MCExpr(const MCExpr &)=delete
static LLVM_ABI bool evaluateSymbolicAdd(const MCAssembler *, bool, const MCValue &, const MCValue &, MCValue &)
LLVM_ABI bool evaluateKnownAbsolute(int64_t &Res, const MCAssembler &Asm) const
Aggressive variant of evaluateAsRelocatable when relocations are unavailable (e.g.
unsigned getSubclassData() const
LLVM_ABI MCFragment * findAssociatedFragment() const
Find the "associated section" for this expression, which is currently defined as the absolute section...
LLVM_ABI bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm, bool InSet) const
LLVM_ABI void dump() const
Instances of this class represent operands of the MCInst class.
Extension point for target-specific MCExpr subclasses with a relocation specifier,...
const MCExpr * getSubExpr() const
static bool classof(const MCExpr *E)
MCSpecifierExpr(const MCExpr *Expr, Spec S, SMLoc Loc=SMLoc())
Spec getSpecifier() const
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)
uint16_t getSpecifier() const
VariantKind getKind() const
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
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 MCFragment * findAssociatedFragment() const =0
virtual bool isEqualTo(const MCExpr *x) const
virtual bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm) const =0
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 LLVM_ABI 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())
Represents a location in source code.
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