LLVM 22.0.0git
|
Base class for the full range of assembler expressions which are needed for parsing. More...
#include "llvm/MC/MCExpr.h"
Public Types | |
enum | ExprKind : uint8_t { Binary , Constant , SymbolRef , Unary , Specifier , Target } |
Public Member Functions | |
MCExpr (const MCExpr &)=delete | |
MCExpr & | operator= (const MCExpr &)=delete |
Accessors | |
ExprKind | getKind () const |
SMLoc | getLoc () const |
Utility Methods | |
LLVM_ABI void | dump () const |
Expression Evaluation | |
LLVM_ABI bool | evaluateAsAbsolute (int64_t &Res) const |
Try to evaluate the expression to an absolute value. | |
LLVM_ABI bool | evaluateAsAbsolute (int64_t &Res, const MCAssembler &Asm) const |
LLVM_ABI bool | evaluateAsAbsolute (int64_t &Res, const MCAssembler *Asm) const |
LLVM_ABI bool | evaluateKnownAbsolute (int64_t &Res, const MCAssembler &Asm) const |
Aggressive variant of evaluateAsRelocatable when relocations are unavailable (e.g. | |
LLVM_ABI bool | evaluateAsRelocatable (MCValue &Res, const MCAssembler *Asm) const |
Try to evaluate the expression to a relocatable value, i.e. | |
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. | |
LLVM_ABI MCFragment * | findAssociatedFragment () const |
Find the "associated section" for this expression, which is currently defined as the absolute section for constants, or otherwise the section associated with the first defined symbol in the expression. |
Static Public Member Functions | |
static LLVM_ABI bool | evaluateSymbolicAdd (const MCAssembler *, bool, const MCValue &, const MCValue &, MCValue &) |
Protected Types | |
using | Spec = uint16_t |
Protected Member Functions | |
MCExpr (ExprKind Kind, SMLoc Loc, unsigned SubclassData=0) | |
LLVM_ABI bool | evaluateAsRelocatableImpl (MCValue &Res, const MCAssembler *Asm, bool InSet) const |
unsigned | getSubclassData () const |
Friends | |
class | MCAsmInfo |
class | MCFragment |
class | MCOperand |
Base class for the full range of assembler expressions which are needed for parsing.
|
protected |
enum llvm::MCExpr::ExprKind : uint8_t |
Enumerator | |
---|---|
Binary | Binary expressions. |
Constant | Constant expressions. |
SymbolRef | References to labels and assigned expressions. |
Unary | Unary expressions. |
Specifier | Expression with a relocation specifier. |
Target | Target specific expression. |
|
inlineexplicitprotected |
Definition at line 67 of file MCExpr.h.
References assert().
Referenced by llvm::MCBinaryExpr::classof(), llvm::MCConstantExpr::classof(), llvm::MCSpecifierExpr::classof(), llvm::MCSymbolRefExpr::classof(), llvm::MCTargetExpr::classof(), llvm::MCUnaryExpr::classof(), llvm::MCBinaryExpr::create(), llvm::MCSpecifierExpr::create(), llvm::MCUnaryExpr::create(), llvm::MCBinaryExpr::createAdd(), llvm::MCBinaryExpr::createAnd(), llvm::MCBinaryExpr::createAShr(), llvm::MCBinaryExpr::createDiv(), llvm::MCBinaryExpr::createEQ(), llvm::MCBinaryExpr::createGT(), llvm::MCBinaryExpr::createGTE(), llvm::MCBinaryExpr::createLAnd(), llvm::MCUnaryExpr::createLNot(), llvm::MCBinaryExpr::createLOr(), llvm::MCBinaryExpr::createLShr(), llvm::MCBinaryExpr::createLT(), llvm::MCBinaryExpr::createLTE(), llvm::MCUnaryExpr::createMinus(), llvm::MCBinaryExpr::createMod(), llvm::MCBinaryExpr::createMul(), llvm::MCBinaryExpr::createNE(), llvm::MCUnaryExpr::createNot(), llvm::MCBinaryExpr::createOr(), llvm::MCUnaryExpr::createPlus(), llvm::MCBinaryExpr::createShl(), llvm::MCBinaryExpr::createSub(), llvm::MCBinaryExpr::createXor(), llvm::MCBinaryExpr::getLHS(), llvm::MCBinaryExpr::getRHS(), llvm::MCSpecifierExpr::getSubExpr(), llvm::MCUnaryExpr::getSubExpr(), llvm::MCTargetExpr::isEqualTo(), MCExpr(), llvm::MCSpecifierExpr::MCSpecifierExpr(), llvm::MCTargetExpr::MCTargetExpr(), and operator=().
LLVM_DUMP_METHOD void MCExpr::dump | ( | ) | const |
Definition at line 193 of file MCExpr.cpp.
References llvm::dbgs(), and LLVM_DUMP_METHOD.
bool MCExpr::evaluateAsAbsolute | ( | int64_t & | Res | ) | const |
Try to evaluate the expression to an absolute value.
Res | - The absolute value, if evaluation succeeds. |
Definition at line 238 of file MCExpr.cpp.
Referenced by printImpl(), and targetOpKnownBitsMapHelper().
bool MCExpr::evaluateAsAbsolute | ( | int64_t & | Res, |
const MCAssembler & | Asm ) const |
Definition at line 242 of file MCExpr.cpp.
bool MCExpr::evaluateAsAbsolute | ( | int64_t & | Res, |
const MCAssembler * | Asm ) const |
Definition at line 246 of file MCExpr.cpp.
bool MCExpr::evaluateAsRelocatable | ( | MCValue & | Res, |
const MCAssembler * | Asm ) const |
Try to evaluate the expression to a relocatable value, i.e.
an expression of the fixed form (a - b + constant).
Res | - The relocatable value, if evaluation succeeds. |
Asm | - The assembler object to use for evaluating values. |
Definition at line 450 of file MCExpr.cpp.
References evaluateAsRelocatableImpl().
Referenced by llvm::DelayedMCExprs::assignDocNode(), evaluate(), evaluate(), llvm::AVRMCExpr::evaluateAsConstant(), llvm::PPC::evaluateAsConstant(), evaluateAsRelocatable(), llvm::AMDGPUMCExpr::evaluateAsRelocatableImpl(), llvm::SystemZMCAsmInfoGOFF::evaluateAsRelocatableImpl(), llvm::VEELFMCAsmInfo::evaluateAsRelocatableImpl(), llvm::RISCVAsmBackend::evaluateFixup(), getPCRelHiFixup(), llvm::MachObjectWriter::getSymbolAddress(), llvm::MCAssembler::isThumbFunc(), and llvm::DelayedMCExprs::resolveDelayedExpressions().
|
protected |
-(a - b + const) ==> (b - a - const)
Definition at line 457 of file MCExpr.cpp.
References _, A(), llvm::MCBinaryExpr::Add, llvm::MCBinaryExpr::And, llvm::MCBinaryExpr::AShr, B(), Binary, llvm::cast(), Constant, llvm::MCConstantExpr::create(), llvm::MCBinaryExpr::Div, llvm::dyn_cast(), llvm::MCBinaryExpr::EQ, evaluateAsRelocatableImpl(), evaluateSymbolicAdd(), llvm::MCValue::get(), llvm::MCValue::getAddSym(), llvm::MCValue::getConstant(), getKind(), llvm::MCSymbolRefExpr::getKind(), llvm::MCBinaryExpr::getLHS(), getLoc(), llvm::MCSymbol::getName(), llvm::MCBinaryExpr::getOpcode(), llvm::MCUnaryExpr::getOpcode(), llvm::MCBinaryExpr::getRHS(), llvm::MCValue::getSpecifier(), llvm::MCUnaryExpr::getSubExpr(), llvm::MCValue::getSubSym(), llvm::MCSymbolRefExpr::getSymbol(), llvm::MCSymbol::getVariableValue(), llvm::MCBinaryExpr::GT, llvm::MCBinaryExpr::GTE, llvm::MCValue::isAbsolute(), llvm::MCSymbol::isResolving(), llvm::MCSymbol::isVariable(), llvm::MCSymbol::isWeakExternal(), llvm::MCBinaryExpr::LAnd, llvm_unreachable, llvm::MCUnaryExpr::LNot, llvm::MCBinaryExpr::LOr, llvm::MCBinaryExpr::LShr, llvm::MCBinaryExpr::LT, llvm::MCBinaryExpr::LTE, llvm::make_scope_exit(), llvm::MCUnaryExpr::Minus, llvm::MCBinaryExpr::Mod, llvm::MCBinaryExpr::Mul, llvm::MCBinaryExpr::NE, llvm::MCUnaryExpr::Not, llvm::MCBinaryExpr::Or, llvm::MCBinaryExpr::OrNot, llvm::MCUnaryExpr::Plus, llvm::MCSymbol::setIsResolving(), llvm::MCSymbol::setVariableValue(), llvm::MCBinaryExpr::Shl, Specifier, llvm::MCBinaryExpr::Sub, std::swap(), SymbolRef, Target, Unary, and llvm::MCBinaryExpr::Xor.
Referenced by evaluateAsRelocatable(), evaluateAsRelocatableImpl(), and evaluateAsValue().
bool MCExpr::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.
This is a more aggressive variant of evaluateAsRelocatable. The intended use is for when relocations are not available, like the .size directive.
Definition at line 453 of file MCExpr.cpp.
References evaluateAsRelocatableImpl().
Referenced by llvm::MCAssembler::getBaseSymbol(), and getSymbolOffsetImpl().
bool MCExpr::evaluateKnownAbsolute | ( | int64_t & | Res, |
const MCAssembler & | Asm ) const |
Aggressive variant of evaluateAsRelocatable when relocations are unavailable (e.g.
.fill). Expects callers to handle errors when true is returned.
Definition at line 250 of file MCExpr.cpp.
Referenced by computeLabelDiff(), llvm::LoongArchAsmBackend::relaxDwarfCFA(), llvm::RISCVAsmBackend::relaxDwarfCFA(), llvm::LoongArchAsmBackend::relaxDwarfLineAddr(), llvm::RISCVAsmBackend::relaxDwarfLineAddr(), llvm::LoongArchAsmBackend::relaxLEB128(), and llvm::RISCVAsmBackend::relaxLEB128().
|
static |
Definition at line 407 of file MCExpr.cpp.
References A(), attemptToFoldSymbolOffsetDifference(), B(), and llvm::MCValue::get().
Referenced by evaluateAsRelocatableImpl().
MCFragment * MCExpr::findAssociatedFragment | ( | ) | const |
Find the "associated section" for this expression, which is currently defined as the absolute section for constants, or otherwise the section associated with the first defined symbol in the expression.
Definition at line 692 of file MCExpr.cpp.
References llvm::MCSymbol::AbsolutePseudoFragment, Binary, llvm::cast(), Constant, F, findAssociatedFragment(), llvm::MCSymbol::Fragment, llvm::MCSymbol::getFragment(), getKind(), llvm::MCBinaryExpr::getLHS(), llvm::MCBinaryExpr::getOpcode(), llvm::MCBinaryExpr::getRHS(), llvm::MCSymbol::isResolving(), llvm_unreachable, MCFragment, llvm::MCSymbol::setIsResolving(), Specifier, llvm::MCBinaryExpr::Sub, SymbolRef, Target, and Unary.
Referenced by llvm::AMDGPUMCExpr::findAssociatedFragment(), findAssociatedFragment(), and llvm::MCSymbol::getFragment().
|
inline |
Definition at line 85 of file MCExpr.h.
Referenced by evaluateAsRelocatableImpl(), findAssociatedFragment(), llvm::PPCMCCodeEmitter::getDispRI34PCRelEncoding(), llvm::MipsMCCodeEmitter::getExprOpValue(), hasGOTReference(), hasSecRelSymbolRef(), hasVariantSymbol(), llvm::MCOperand::isBareSymbolRef(), isEvaluated(), knownBitsMapHelper(), needsExpandMemInst(), needsPCRel(), llvm::X86Operand::print(), llvm::ARMInstPrinter::printOperand(), startsWithGlobalOffsetTable(), tryFoldHelper(), and llvm::MCStreamer::visitUsedExpr().
|
inline |
Definition at line 86 of file MCExpr.h.
Referenced by llvm::MCAsmParser::applySpecifier(), evaluateAsRelocatableImpl(), llvm::MCAssembler::getBaseSymbol(), llvm::MipsMCCodeEmitter::getExprOpValue(), llvm::MCStreamer::switchSection(), and tryFoldHelper().
|
inlineprotected |
Definition at line 76 of file MCExpr.h.
Referenced by llvm::MCSymbolRefExpr::getKind(), llvm::MCBinaryExpr::getOpcode(), llvm::MCUnaryExpr::getOpcode(), llvm::MCConstantExpr::getSizeInBytes(), llvm::MCSpecifierExpr::getSpecifier(), llvm::MCSymbolRefExpr::getSpecifier(), and llvm::MCConstantExpr::useHexFormat().
|
friend |
Definition at line 37 of file MCExpr.h.
References MCAsmInfo.
Referenced by MCAsmInfo, and llvm::MCTargetExpr::printImpl().
|
friend |
Definition at line 38 of file MCExpr.h.
References MCFragment.
Referenced by findAssociatedFragment(), llvm::MCTargetExpr::findAssociatedFragment(), and MCFragment.
|
friend |