|
LLVM
3.7.0
|
Base class for the full range of assembler expressions which are needed for parsing. More...
#include <MCExpr.h>
Public Types | |
| enum | ExprKind { Binary, Constant, SymbolRef, Unary, Target } |
Public Member Functions | |
Accessors | |
| ExprKind | getKind () const |
Utility Methods | |
| void | print (raw_ostream &OS, const MCAsmInfo *MAI) 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 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... | |
| MCSection * | findAssociatedSection () 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) | |
| 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.
|
inlineexplicitprotected |
| void MCExpr::dump | ( | ) | const |
Definition at line 132 of file MCExpr.cpp.
| 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 418 of file MCExpr.cpp.
Referenced by llvm::AArch64InstPrinter::printAlignedLabel(), and llvm::ARMInstPrinter::printOperand().
| bool MCExpr::evaluateAsAbsolute | ( | int64_t & | Res | ) | const |
Definition at line 409 of file MCExpr.cpp.
| bool MCExpr::evaluateAsAbsolute | ( | int64_t & | Res, |
| const MCAssembler & | Asm | ||
| ) | const |
Definition at line 424 of file MCExpr.cpp.
| bool MCExpr::evaluateAsAbsolute | ( | int64_t & | Res, |
| const MCAsmLayout & | Layout | ||
| ) | const |
Definition at line 413 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 595 of file MCExpr.cpp.
References evaluateAsRelocatableImpl(), and llvm::MCAsmLayout::getAssembler().
Referenced by llvm::PPCMCExpr::evaluateAsConstant(), llvm::MipsMCExpr::evaluateAsRelocatableImpl(), llvm::PPCMCExpr::evaluateAsRelocatableImpl(), llvm::SparcMCExpr::evaluateAsRelocatableImpl(), llvm::AArch64MCExpr::evaluateAsRelocatableImpl(), llvm::MachObjectWriter::getSymbolAddress(), and getSymbolOffsetImpl().
|
protected |
-(a - b + const) ==> (b - a - const)
Definition at line 624 of file MCExpr.cpp.
References llvm::MCBinaryExpr::Add, llvm::MCBinaryExpr::And, llvm::MCBinaryExpr::AShr, canExpand(), llvm::MCBinaryExpr::Div, llvm::MCBinaryExpr::EQ, evaluateAsRelocatableImpl(), EvaluateSymbolicAdd(), llvm::MCValue::get(), getKind(), 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, Unary, llvm::MCSymbolRefExpr::VK_None, and llvm::MCBinaryExpr::Xor.
Referenced by evaluateAsRelocatable(), evaluateAsRelocatableImpl(), and evaluateAsValue().
| 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 603 of file MCExpr.cpp.
References evaluateAsRelocatableImpl(), and llvm::MCAsmLayout::getAssembler().
Referenced by llvm::MCAsmLayout::getBaseSymbol().
| bool MCExpr::evaluateKnownAbsolute | ( | int64_t & | Res, |
| const MCAsmLayout & | Layout | ||
| ) | const |
Definition at line 428 of file MCExpr.cpp.
| MCSection * MCExpr::findAssociatedSection | ( | ) | 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 768 of file MCExpr.cpp.
References llvm::MCSymbol::AbsolutePseudoSection, findAssociatedSection(), getKind(), llvm::MCBinaryExpr::getLHS(), llvm::MCBinaryExpr::getOpcode(), llvm::MCBinaryExpr::getRHS(), llvm::MCSymbol::getSection(), llvm::MCSymbolRefExpr::getSymbol(), llvm_unreachable, llvm::MCBinaryExpr::Sub, and Unary.
Referenced by llvm::MipsMCExpr::findAssociatedSection(), llvm::ARMMCExpr::findAssociatedSection(), llvm::PPCMCExpr::findAssociatedSection(), llvm::SparcMCExpr::findAssociatedSection(), and findAssociatedSection().
|
inline |
Definition at line 69 of file MCExpr.h.
Referenced by llvm::MipsMCExpr::classof(), llvm::ARMMCExpr::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(), llvm::MipsTargetELFStreamer::emitAssignment(), evaluateAsRelocatableImpl(), EvaluateCRExpr(), findAssociatedSection(), fixELFSymbolsInTLSFixupsImpl(), getAccessVariant(), hasGOTReference(), HasSecRelSymbolRef(), llvm::MCParserUtils::isSymbolUsedInExpression(), print(), llvm::ARMMCExpr::printImpl(), StartsWithGlobalOffsetTable(), and llvm::MCStreamer::visitUsedExpr().
| void MCExpr::print | ( | raw_ostream & | OS, |
| const MCAsmInfo * | MAI | ||
| ) | const |
Definition at line 33 of file MCExpr.cpp.
References llvm::MCBinaryExpr::Add, llvm::MCBinaryExpr::And, llvm::MCBinaryExpr::AShr, Binary, Constant, llvm::MCBinaryExpr::Div, 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 llvm::operator<<(), print(), llvm::AArch64InstPrinter::printAddSubImm(), llvm::ARMInstPrinter::printAdrLabelOperand(), llvm::AArch64InstPrinter::printAdrpLabel(), llvm::AArch64InstPrinter::printAlignedLabel(), llvm::AArch64InstPrinter::printAMIndexedWB(), llvm::HexagonInstPrinter::printImmOperand(), llvm::MipsMCExpr::printImpl(), llvm::ARMMCExpr::printImpl(), llvm::PPCMCExpr::printImpl(), llvm::SparcMCExpr::printImpl(), llvm::NVPTXGenericMCSymbolRefExpr::printImpl(), llvm::AArch64MCExpr::printImpl(), llvm::AArch64InstPrinter::printInst(), llvm::X86IntelInstPrinter::printMemOffset(), llvm::X86ATTInstPrinter::printMemOffset(), llvm::X86IntelInstPrinter::printMemReference(), llvm::X86ATTInstPrinter::printMemReference(), llvm::MSP430InstPrinter::printOperand(), llvm::X86IntelInstPrinter::printOperand(), llvm::SystemZInstPrinter::printOperand(), llvm::NVPTXInstPrinter::printOperand(), llvm::X86ATTInstPrinter::printOperand(), llvm::PPCInstPrinter::printOperand(), llvm::SparcInstPrinter::printOperand(), llvm::HexagonInstPrinter::printOperand(), llvm::AArch64InstPrinter::printOperand(), llvm::X86IntelInstPrinter::printPCRelImm(), llvm::X86ATTInstPrinter::printPCRelImm(), llvm::MSP430InstPrinter::printPCRelImmOperand(), llvm::MSP430InstPrinter::printSrcMemOperand(), llvm::MCSectionELF::PrintSwitchToSection(), llvm::ARMInstPrinter::printThumbLdrLabelOperand(), and llvm::AArch64InstPrinter::printUImm12Offset().
1.8.6