LLVM 20.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 , Target } |
Public Member Functions | |
MCExpr (const MCExpr &)=delete | |
MCExpr & | operator= (const MCExpr &)=delete |
Accessors | |
ExprKind | getKind () const |
SMLoc | getLoc () const |
Utility Methods | |
void | print (raw_ostream &OS, const MCAsmInfo *MAI, bool InParens=false) const |
void | dump () const |
Expression Evaluation | |
bool | evaluateAsAbsolute (int64_t &Res, const MCAssembler &Asm, const SectionAddrMap &Addrs) const |
Try to evaluate the expression to an absolute value. | |
bool | evaluateAsAbsolute (int64_t &Res) const |
bool | evaluateAsAbsolute (int64_t &Res, const MCAssembler &Asm) const |
bool | evaluateAsAbsolute (int64_t &Res, const MCAssembler *Asm) const |
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. | |
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. | |
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. | |
Protected Member Functions | |
MCExpr (ExprKind Kind, SMLoc Loc, unsigned SubclassData=0) | |
bool | evaluateAsRelocatableImpl (MCValue &Res, const MCAssembler *Asm, const MCFixup *Fixup, const SectionAddrMap *Addrs, bool InSet) const |
unsigned | getSubclassData () const |
Base class for the full range of assembler expressions which are needed for parsing.
enum llvm::MCExpr::ExprKind : uint8_t |
LLVM_DUMP_METHOD void MCExpr::dump | ( | ) | const |
Definition at line 174 of file MCExpr.cpp.
References llvm::dbgs().
bool MCExpr::evaluateAsAbsolute | ( | int64_t & | Res | ) | const |
Definition at line 546 of file MCExpr.cpp.
bool MCExpr::evaluateAsAbsolute | ( | int64_t & | Res, |
const MCAssembler & | Asm | ||
) | const |
Definition at line 557 of file MCExpr.cpp.
bool MCExpr::evaluateAsAbsolute | ( | int64_t & | Res, |
const MCAssembler & | Asm, | ||
const SectionAddrMap & | Addrs | ||
) | const |
Try to evaluate the expression to an absolute value.
Res | - The absolute value, if evaluation succeeds. |
Definition at line 550 of file MCExpr.cpp.
Referenced by targetOpKnownBitsMapHelper().
bool MCExpr::evaluateAsAbsolute | ( | int64_t & | Res, |
const MCAssembler * | Asm | ||
) | const |
Definition at line 561 of file MCExpr.cpp.
bool MCExpr::evaluateAsRelocatable | ( | MCValue & | Res, |
const MCAssembler * | Asm, | ||
const MCFixup * | Fixup | ||
) | 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. |
Fixup | - The Fixup object if available. |
Definition at line 788 of file MCExpr.cpp.
References evaluateAsRelocatableImpl(), and Fixup.
Referenced by llvm::DelayedMCExprs::assignDocNode(), llvm::PPCMCExpr::evaluateAsConstant(), llvm::RISCVMCExpr::evaluateAsConstant(), llvm::AVRMCExpr::evaluateAsConstant(), llvm::AArch64MCExpr::evaluateAsRelocatableImpl(), llvm::AArch64AuthMCExpr::evaluateAsRelocatableImpl(), llvm::AMDGPUMCExpr::evaluateAsRelocatableImpl(), llvm::AVRMCExpr::evaluateAsRelocatableImpl(), llvm::CSKYMCExpr::evaluateAsRelocatableImpl(), llvm::HexagonMCExpr::evaluateAsRelocatableImpl(), llvm::LanaiMCExpr::evaluateAsRelocatableImpl(), llvm::LoongArchMCExpr::evaluateAsRelocatableImpl(), llvm::MipsMCExpr::evaluateAsRelocatableImpl(), llvm::PPCMCExpr::evaluateAsRelocatableImpl(), llvm::RISCVMCExpr::evaluateAsRelocatableImpl(), llvm::SparcMCExpr::evaluateAsRelocatableImpl(), llvm::SystemZMCExpr::evaluateAsRelocatableImpl(), llvm::VEMCExpr::evaluateAsRelocatableImpl(), llvm::XtensaMCExpr::evaluateAsRelocatableImpl(), llvm::RISCVAsmBackend::evaluateTargetFixup(), getOffsetAndDataFragment(), llvm::RISCVMCExpr::getPCRelHiFixup(), llvm::MachObjectWriter::getSymbolAddress(), and llvm::MCAssembler::isThumbFunc().
|
protected |
-(a - b + const) ==> (b - a - const)
Definition at line 813 of file MCExpr.cpp.
References A, llvm::MCBinaryExpr::Add, llvm::MCBinaryExpr::And, llvm::MCBinaryExpr::AShr, B, Binary, canExpand(), Constant, llvm::MCSymbolRefExpr::create(), llvm::MCBinaryExpr::Div, llvm::MCBinaryExpr::EQ, evaluateAsRelocatableImpl(), evaluateSymbolicAdd(), Fixup, llvm::MCValue::get(), llvm::MCValue::getConstant(), getKind(), llvm::MCSymbolRefExpr::getKind(), llvm::MCBinaryExpr::getLHS(), llvm::MCUnaryExpr::getOpcode(), llvm::MCBinaryExpr::getOpcode(), llvm::MCValue::getRefKind(), llvm::MCBinaryExpr::getRHS(), llvm::MCUnaryExpr::getSubExpr(), llvm::MCValue::getSymA(), llvm::MCValue::getSymB(), llvm::MCSymbolRefExpr::getSymbol(), llvm::MCBinaryExpr::GT, llvm::MCBinaryExpr::GTE, llvm::MCSymbolRefExpr::hasSubsectionsViaSymbols(), llvm::MCValue::isAbsolute(), llvm::MCBinaryExpr::LAnd, LHS, llvm_unreachable, llvm::MCUnaryExpr::LNot, llvm::MCBinaryExpr::LOr, llvm::MCBinaryExpr::LShr, llvm::MCBinaryExpr::LT, llvm::MCBinaryExpr::LTE, llvm::MCUnaryExpr::Minus, llvm::MCBinaryExpr::Mod, llvm::MCBinaryExpr::Mul, llvm::MCBinaryExpr::NE, llvm::MCUnaryExpr::Not, llvm::MCBinaryExpr::Or, llvm::MCBinaryExpr::OrNot, llvm::MCUnaryExpr::Plus, RHS, llvm::MCBinaryExpr::Shl, llvm::MCBinaryExpr::Sub, Sym, SymbolRef, Target, Unary, llvm::MCSymbolRefExpr::VK_None, 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 793 of file MCExpr.cpp.
References evaluateAsRelocatableImpl().
Referenced by llvm::MCAssembler::computeFragmentSize(), 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 565 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().
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 1029 of file MCExpr.cpp.
References llvm::MCSymbol::AbsolutePseudoFragment, Binary, Constant, findAssociatedFragment(), getKind(), llvm::MCBinaryExpr::getLHS(), llvm::MCBinaryExpr::getOpcode(), llvm::MCBinaryExpr::getRHS(), llvm::MCSymbolRefExpr::getSymbol(), llvm_unreachable, llvm::MCBinaryExpr::Sub, Sym, SymbolRef, Target, and Unary.
Referenced by findAssociatedFragment(), llvm::AMDGPUMCExpr::findAssociatedFragment(), llvm::ARMMCExpr::findAssociatedFragment(), llvm::AVRMCExpr::findAssociatedFragment(), llvm::CSKYMCExpr::findAssociatedFragment(), llvm::HexagonMCExpr::findAssociatedFragment(), llvm::LanaiMCExpr::findAssociatedFragment(), llvm::LoongArchMCExpr::findAssociatedFragment(), llvm::MipsMCExpr::findAssociatedFragment(), llvm::PPCMCExpr::findAssociatedFragment(), llvm::RISCVMCExpr::findAssociatedFragment(), llvm::SparcMCExpr::findAssociatedFragment(), llvm::SystemZMCExpr::findAssociatedFragment(), llvm::VEMCExpr::findAssociatedFragment(), llvm::XtensaMCExpr::findAssociatedFragment(), and llvm::MCSymbol::getFragment().
|
inline |
Definition at line 78 of file MCExpr.h.
Referenced by evaluateAsRelocatableImpl(), EvaluateCRExpr(), findAssociatedFragment(), fixELFSymbolsInTLSFixupsImpl(), getAccessVariant(), llvm::CSKYMCCodeEmitter::getBareSymbolOpValue(), llvm::CSKYMCCodeEmitter::getBranchSymbolOpValue(), llvm::CSKYMCCodeEmitter::getCallSymbolOpValue(), llvm::CSKYMCCodeEmitter::getConstpoolSymbolOpValue(), llvm::CSKYMCCodeEmitter::getDataSymbolOpValue(), llvm::PPCMCCodeEmitter::getDispRI34PCRelEncoding(), llvm::MipsMCCodeEmitter::getExprOpValue(), hasGOTReference(), hasSecRelSymbolRef(), hasVariantSymbol(), llvm::MCOperand::isBareSymbolRef(), isEvaluated(), knownBitsMapHelper(), needsExpandMemInst(), needsPCRel(), llvm::X86Operand::print(), print(), llvm::ARMMCExpr::printImpl(), llvm::ARMInstPrinter::printOperand(), startsWithGlobalOffsetTable(), tryFoldHelper(), and llvm::MCStreamer::visitUsedExpr().
|
inline |
Definition at line 79 of file MCExpr.h.
Referenced by llvm::MCAssembler::getBaseSymbol(), llvm::MipsMCCodeEmitter::getExprOpValue(), llvm::LoongArchAsmBackend::relaxLEB128(), llvm::RISCVAsmBackend::relaxLEB128(), llvm::MCStreamer::switchSection(), and tryFoldHelper().
|
inlineprotected |
Definition at line 69 of file MCExpr.h.
Referenced by llvm::MCSymbolRefExpr::getKind(), llvm::MCUnaryExpr::getOpcode(), llvm::MCBinaryExpr::getOpcode(), llvm::MCConstantExpr::getSizeInBytes(), llvm::MCSymbolRefExpr::hasSubsectionsViaSymbols(), and llvm::MCConstantExpr::useHexFormat().
void MCExpr::print | ( | raw_ostream & | OS, |
const MCAsmInfo * | MAI, | ||
bool | InParens = false |
||
) | const |
Definition at line 40 of file MCExpr.cpp.
References llvm::MCBinaryExpr::Add, llvm::MCBinaryExpr::And, llvm::MCBinaryExpr::AShr, Binary, Constant, llvm::MCBinaryExpr::Div, llvm::MCBinaryExpr::EQ, llvm::format(), getKind(), llvm::MCSymbolRefExpr::getKind(), llvm::MCBinaryExpr::getLHS(), llvm::MCUnaryExpr::getOpcode(), llvm::MCBinaryExpr::getOpcode(), llvm::MCBinaryExpr::getRHS(), llvm::MCUnaryExpr::getSubExpr(), llvm::MCSymbolRefExpr::getSymbol(), llvm::MCSymbolRefExpr::getVariantKindName(), llvm::MCBinaryExpr::GT, llvm::MCBinaryExpr::GTE, llvm::MCBinaryExpr::LAnd, llvm_unreachable, llvm::MCUnaryExpr::LNot, llvm::MCBinaryExpr::LOr, llvm::MCBinaryExpr::LShr, llvm::MCBinaryExpr::LT, llvm::MCBinaryExpr::LTE, llvm::MCUnaryExpr::Minus, llvm::MCBinaryExpr::Mod, llvm::MCBinaryExpr::Mul, llvm::MCBinaryExpr::NE, llvm::MCUnaryExpr::Not, llvm::MCBinaryExpr::Or, llvm::MCBinaryExpr::OrNot, OS, llvm::MCUnaryExpr::Plus, print(), llvm::MCBinaryExpr::Shl, llvm::MCBinaryExpr::Sub, Sym, SymbolRef, Target, Unary, llvm::MCAsmInfo::useParensForDollarSignNames(), llvm::MCAsmInfo::useParensForSymbolVariant(), llvm::Twine::utohexstr(), llvm::MCSymbolRefExpr::VK_None, and llvm::MCBinaryExpr::Xor.
Referenced by print(), llvm::AArch64InstPrinter::printAddSubImm(), llvm::ARMInstPrinter::printAdrLabelOperand(), llvm::AMDGPU::printAMDGPUMCExpr(), llvm::AArch64InstPrinter::printAMIndexedWB(), llvm::CSKYInstPrinter::printConstpool(), llvm::CSKYInstPrinter::printDataSymbol(), llvm::AArch64MCExpr::printImpl(), llvm::AArch64AuthMCExpr::printImpl(), llvm::ARMMCExpr::printImpl(), llvm::AVRMCExpr::printImpl(), llvm::CSKYMCExpr::printImpl(), llvm::HexagonMCExpr::printImpl(), llvm::LanaiMCExpr::printImpl(), llvm::LoongArchMCExpr::printImpl(), llvm::MipsMCExpr::printImpl(), llvm::NVPTXGenericMCSymbolRefExpr::printImpl(), llvm::PPCMCExpr::printImpl(), llvm::RISCVMCExpr::printImpl(), llvm::SparcMCExpr::printImpl(), llvm::SystemZMCExpr::printImpl(), llvm::VEMCExpr::printImpl(), llvm::XtensaMCExpr::printImpl(), llvm::X86IntelInstPrinter::printMemOffset(), llvm::X86ATTInstPrinter::printMemOffset(), printMemoryImmediateOffset(), llvm::X86IntelInstPrinter::printMemReference(), llvm::X86ATTInstPrinter::printMemReference(), llvm::SparcInstPrinter::printOperand(), llvm::VEInstPrinter::printOperand(), llvm::ARMInstPrinter::printOperand(), llvm::CSKYInstPrinter::printOperand(), llvm::RISCVInstPrinter::printOperand(), printOperand(), llvm::SystemZInstPrinter::printOperand(), llvm::ARMInstPrinter::printThumbLdrLabelOperand(), llvm::PPCInstPrinter::printTLSCall(), and llvm::AArch64InstPrinter::printUImm12Offset().