LLVM
8.0.1
|
Base class for the full range of assembler expressions which are needed for parsing. More...
#include "llvm/MC/MCExpr.h"
Public Types | |
enum | ExprKind { 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 MCAsmLayout &Layout, const SectionAddrMap &Addrs) const |
Try to evaluate the expression to an absolute value. More... | |
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 | evaluateAsAbsolute (int64_t &Res, const MCAsmLayout &Layout) const |
bool | evaluateKnownAbsolute (int64_t &Res, const MCAsmLayout &Layout) const |
bool | evaluateAsRelocatable (MCValue &Res, const MCAsmLayout *Layout, const MCFixup *Fixup) const |
Try to evaluate the expression to a relocatable value, i.e. More... | |
bool | evaluateAsValue (MCValue &Res, const MCAsmLayout &Layout) const |
Try to evaluate the expression to the form (a - b + constant) where neither a nor b are variables. More... | |
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. More... | |
Protected Member Functions | |
MCExpr (ExprKind Kind, SMLoc Loc) | |
bool | evaluateAsRelocatableImpl (MCValue &Res, const MCAssembler *Asm, const MCAsmLayout *Layout, const MCFixup *Fixup, const SectionAddrMap *Addrs, bool InSet) const |
Base class for the full range of assembler expressions which are needed for parsing.
Definition at line 59 of file MCExpr.h.
References llvm::HexStyle::Asm, evaluateAsRelocatableImpl(), Fixup, and operator=().
LLVM_DUMP_METHOD void MCExpr::dump | ( | ) | const |
Definition at line 145 of file MCExpr.cpp.
Referenced by getLoc().
bool MCExpr::evaluateAsAbsolute | ( | int64_t & | Res, |
const MCAsmLayout & | Layout, | ||
const SectionAddrMap & | Addrs | ||
) | const |
Try to evaluate the expression to an absolute value.
Res | - The absolute value, if evaluation succeeds. |
Layout | - The assembler layout object to use for evaluating symbol values. If not given, then only non-symbolic expressions will be evaluated. |
Definition at line 456 of file MCExpr.cpp.
Referenced by llvm::AArch64InstPrinter::printAlignedLabel(), and llvm::ARMInstPrinter::printOperand().
bool MCExpr::evaluateAsAbsolute | ( | int64_t & | Res | ) | const |
Definition at line 447 of file MCExpr.cpp.
bool MCExpr::evaluateAsAbsolute | ( | int64_t & | Res, |
const MCAssembler & | Asm | ||
) | const |
Definition at line 462 of file MCExpr.cpp.
bool MCExpr::evaluateAsAbsolute | ( | int64_t & | Res, |
const MCAssembler * | Asm | ||
) | const |
Definition at line 466 of file MCExpr.cpp.
bool MCExpr::evaluateAsAbsolute | ( | int64_t & | Res, |
const MCAsmLayout & | Layout | ||
) | const |
Definition at line 451 of file MCExpr.cpp.
bool MCExpr::evaluateAsRelocatable | ( | MCValue & | Res, |
const MCAsmLayout * | Layout, | ||
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. |
Layout | - The assembler layout object to use for evaluating values. |
Fixup | - The Fixup object if available. |
Definition at line 647 of file MCExpr.cpp.
References llvm::MCAsmLayout::getAssembler().
Referenced by canGoAfterDWARF(), llvm::CodeViewContext::encodeDefRange(), llvm::RISCVMCExpr::evaluateAsConstant(), llvm::PPCMCExpr::evaluateAsConstant(), llvm::HexagonMCExpr::evaluateAsRelocatableImpl(), llvm::LanaiMCExpr::evaluateAsRelocatableImpl(), llvm::RISCVMCExpr::evaluateAsRelocatableImpl(), llvm::MipsMCExpr::evaluateAsRelocatableImpl(), llvm::PPCMCExpr::evaluateAsRelocatableImpl(), llvm::SparcMCExpr::evaluateAsRelocatableImpl(), llvm::AArch64MCExpr::evaluateAsRelocatableImpl(), llvm::MCAssembler::getAtom(), getLoc(), llvm::RISCVMCExpr::getPCRelHiFixup(), llvm::MachObjectWriter::getSymbolAddress(), incrementLoc(), isOperator(), isShiftedUIntAtAnyPosition(), and llvm::MCAssembler::isThumbFunc().
|
protected |
-(a - b + const) ==> (b - a - const)
Definition at line 674 of file MCExpr.cpp.
References llvm::MCBinaryExpr::Add, llvm::MCBinaryExpr::And, llvm::MCBinaryExpr::AShr, B, canExpand(), llvm::MCBinaryExpr::Div, llvm::MCBinaryExpr::EQ, evaluateAsRelocatableImpl(), EvaluateSymbolicAdd(), llvm::MCValue::get(), llvm::MCValue::getConstant(), llvm::MCSymbolRefExpr::getKind(), llvm::MCBinaryExpr::getLHS(), llvm::MCUnaryExpr::getOpcode(), llvm::MCBinaryExpr::getOpcode(), 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::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::MCUnaryExpr::Plus, llvm::MCBinaryExpr::Shl, llvm::MCBinaryExpr::Sub, llvm::MCSymbolRefExpr::VK_None, and llvm::MCBinaryExpr::Xor.
Referenced by evaluateAsRelocatableImpl(), MCExpr(), and llvm::MCTargetExpr::MCTargetExpr().
bool MCExpr::evaluateAsValue | ( | MCValue & | Res, |
const MCAsmLayout & | Layout | ||
) | 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 655 of file MCExpr.cpp.
References llvm::MCAsmLayout::getAssembler().
Referenced by llvm::MCAssembler::computeFragmentSize(), llvm::MCAsmLayout::getBaseSymbol(), getLoc(), llvm::RISCVMCExpr::getPCRelHiFixup(), and getSymbolOffsetImpl().
bool MCExpr::evaluateKnownAbsolute | ( | int64_t & | Res, |
const MCAsmLayout & | Layout | ||
) | const |
Definition at line 470 of file MCExpr.cpp.
Referenced by llvm::MCAssembler::Finish(), getLoc(), and mergeTypeForSet().
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 867 of file MCExpr.cpp.
References llvm::MCSymbol::AbsolutePseudoFragment, findAssociatedFragment(), llvm::MCSymbol::getFragment(), llvm::MCBinaryExpr::getLHS(), llvm::MCBinaryExpr::getOpcode(), llvm::MCBinaryExpr::getRHS(), llvm::MCSymbolRefExpr::getSymbol(), llvm_unreachable, and llvm::MCBinaryExpr::Sub.
Referenced by llvm::HexagonMCExpr::findAssociatedFragment(), llvm::LanaiMCExpr::findAssociatedFragment(), llvm::AVRMCExpr::findAssociatedFragment(), llvm::ARMMCExpr::findAssociatedFragment(), llvm::RISCVMCExpr::findAssociatedFragment(), llvm::MipsMCExpr::findAssociatedFragment(), llvm::PPCMCExpr::findAssociatedFragment(), llvm::SparcMCExpr::findAssociatedFragment(), findAssociatedFragment(), llvm::MCSymbol::getFragment(), getLoc(), llvm::RISCVMCExpr::getPCRelHiFixup(), llvm::MCTargetExpr::inlineAssignedExpr(), and llvm::RISCVAsmBackend::shouldForceRelocation().
|
inline |
Definition at line 73 of file MCExpr.h.
Referenced by addNegOperand(), llvm::HexagonMCExpr::classof(), llvm::LanaiMCExpr::classof(), llvm::AVRMCExpr::classof(), llvm::X86MCExpr::classof(), llvm::ARMMCExpr::classof(), llvm::RISCVMCExpr::classof(), llvm::MipsMCExpr::classof(), llvm::NVPTXFloatMCExpr::classof(), llvm::PPCMCExpr::classof(), llvm::SparcMCExpr::classof(), llvm::NVPTXGenericMCSymbolRefExpr::classof(), llvm::MCConstantExpr::classof(), llvm::AArch64MCExpr::classof(), llvm::MCSymbolRefExpr::classof(), llvm::MCUnaryExpr::classof(), llvm::MCBinaryExpr::classof(), llvm::MCTargetExpr::classof(), ConvertDoubleToBytes(), countMCSymbolRefExpr(), llvm::MipsTargetELFStreamer::emitAssignment(), llvm::MCELFStreamer::EmitIdent(), llvm::MCObjectStreamer::EmitRelocDirective(), EvaluateCRExpr(), fixELFSymbolsInTLSFixupsImpl(), getAccessVariant(), llvm::MipsMCCodeEmitter::getExprOpValue(), HasConditionalBranch(), hasGOTReference(), HasSecRelSymbolRef(), llvm::MCOperand::isBareSymbolRef(), isOperator(), isPCRel(), IsSmallMemAccess(), llvm::MCParserUtils::isSymbolUsedInExpression(), needsPCRel(), print(), llvm::X86Operand::print(), llvm::ARMMCExpr::printImpl(), RefineErrorLoc(), StartsWithGlobalOffsetTable(), and llvm::MCStreamer::visitUsedExpr().
|
inline |
Definition at line 74 of file MCExpr.h.
References dump(), evaluateAsRelocatable(), evaluateAsValue(), evaluateKnownAbsolute(), findAssociatedFragment(), and print().
Referenced by llvm::MCELFStreamer::EmitIdent(), and llvm::MCAsmLayout::getBaseSymbol().
void MCExpr::print | ( | raw_ostream & | OS, |
const MCAsmInfo * | MAI, | ||
bool | InParens = false |
||
) | const |
Definition at line 42 of file MCExpr.cpp.
References llvm::MCBinaryExpr::Add, llvm::MCBinaryExpr::And, llvm::MCBinaryExpr::AShr, Binary, Constant, llvm::MCBinaryExpr::Div, llvm::StringRef::empty(), llvm::MCBinaryExpr::EQ, getKind(), llvm::MCSymbolRefExpr::getKind(), llvm::MCBinaryExpr::getLHS(), llvm::MCSymbol::getName(), llvm::MCUnaryExpr::getOpcode(), llvm::MCBinaryExpr::getOpcode(), llvm::MCBinaryExpr::getRHS(), llvm::MCUnaryExpr::getSubExpr(), llvm::MCSymbolRefExpr::getSymbol(), llvm::MCBinaryExpr::GT, llvm::MCUnaryExpr::LNot, llvm::MCUnaryExpr::Minus, llvm::MCUnaryExpr::Not, llvm::MCUnaryExpr::Plus, print(), llvm::MCSymbol::print(), llvm::MCSymbolRefExpr::printVariantKind(), SymbolRef, Target, Unary, and llvm::MCSymbolRefExpr::VK_None.
Referenced by createPPCMCAsmInfo(), llvm::MCTargetStreamer::emitValue(), GetAEABIUnwindPersonalityName(), getLoc(), getOpenCLAlignment(), getPlatformName(), llvm::operator<<(), print(), llvm::AArch64InstPrinter::printAddSubImm(), llvm::ARMInstPrinter::printAdrLabelOperand(), llvm::AArch64InstPrinter::printAdrpLabel(), llvm::AArch64InstPrinter::printAlignedLabel(), llvm::AArch64InstPrinter::printAMIndexedWB(), PrintCFIEscape(), llvm::LanaiInstPrinter::printHi16AndImmOperand(), llvm::LanaiInstPrinter::printHi16ImmOperand(), llvm::HexagonMCExpr::printImpl(), llvm::LanaiMCExpr::printImpl(), llvm::ARMMCExpr::printImpl(), llvm::RISCVMCExpr::printImpl(), llvm::MipsMCExpr::printImpl(), llvm::PPCMCExpr::printImpl(), llvm::SparcMCExpr::printImpl(), llvm::AArch64MCExpr::printImpl(), llvm::MSP430InstPrinter::printInst(), llvm::AArch64InstPrinter::printInst(), llvm::MipsInstPrinter::printInst(), llvm::R600InstPrinter::printLiteral(), llvm::LanaiInstPrinter::printLo16AndImmOperand(), llvm::LanaiInstPrinter::printMemImmOperand(), llvm::X86IntelInstPrinter::printMemOffset(), llvm::X86ATTInstPrinter::printMemOffset(), printMemoryImmediateOffset(), llvm::X86IntelInstPrinter::printMemReference(), llvm::X86ATTInstPrinter::printMemReference(), llvm::LanaiInstPrinter::printOperand(), llvm::RISCVInstPrinter::printOperand(), llvm::X86IntelInstPrinter::printOperand(), llvm::NVPTXInstPrinter::printOperand(), llvm::SystemZInstPrinter::printOperand(), llvm::X86ATTInstPrinter::printOperand(), llvm::SparcInstPrinter::printOperand(), llvm::WebAssemblyInstPrinter::printOperand(), llvm::PPCInstPrinter::printOperand(), llvm::AArch64InstPrinter::printOperand(), llvm::R600InstPrinter::printOperand(), llvm::X86InstPrinterCommon::printPCRelImm(), PrintQuotedString(), llvm::AMDGPUInstPrinter::printRegOperand(), printSImmOperand(), llvm::MCSectionWasm::PrintSwitchToSection(), llvm::MCSectionELF::PrintSwitchToSection(), llvm::ARMInstPrinter::printThumbLdrLabelOperand(), llvm::X86IntelInstPrinter::printU8Imm(), and llvm::AArch64InstPrinter::printUImm12Offset().