|
LLVM
4.0.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, 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 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) | |
| 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 |
| LLVM_DUMP_METHOD 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 408 of file MCExpr.cpp.
Referenced by llvm::AArch64InstPrinter::printAlignedLabel(), and llvm::ARMInstPrinter::printOperand().
| bool MCExpr::evaluateAsAbsolute | ( | int64_t & | Res | ) | const |
Definition at line 399 of file MCExpr.cpp.
| bool MCExpr::evaluateAsAbsolute | ( | int64_t & | Res, |
| const MCAssembler & | Asm | ||
| ) | const |
Definition at line 414 of file MCExpr.cpp.
| bool MCExpr::evaluateAsAbsolute | ( | int64_t & | Res, |
| const MCAsmLayout & | Layout | ||
| ) | const |
Definition at line 403 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 581 of file MCExpr.cpp.
References evaluateAsRelocatableImpl(), and llvm::MCAsmLayout::getAssembler().
Referenced by llvm::CodeViewContext::encodeDefRange(), llvm::AVRMCExpr::evaluateAsConstant(), llvm::PPCMCExpr::evaluateAsConstant(), llvm::HexagonMCExpr::evaluateAsRelocatableImpl(), llvm::LanaiMCExpr::evaluateAsRelocatableImpl(), llvm::AVRMCExpr::evaluateAsRelocatableImpl(), llvm::MipsMCExpr::evaluateAsRelocatableImpl(), llvm::PPCMCExpr::evaluateAsRelocatableImpl(), llvm::SparcMCExpr::evaluateAsRelocatableImpl(), llvm::AArch64MCExpr::evaluateAsRelocatableImpl(), and llvm::MachObjectWriter::getSymbolAddress().
|
protected |
-(a - b + const) ==> (b - a - const)
Definition at line 608 of file MCExpr.cpp.
References A, llvm::MCBinaryExpr::Add, llvm::MCBinaryExpr::And, llvm::MCBinaryExpr::AShr, B, 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 589 of file MCExpr.cpp.
References evaluateAsRelocatableImpl(), and llvm::MCAsmLayout::getAssembler().
Referenced by llvm::MCAssembler::computeFragmentSize(), llvm::MCAsmLayout::getBaseSymbol(), and getSymbolOffsetImpl().
| bool MCExpr::evaluateKnownAbsolute | ( | int64_t & | Res, |
| const MCAsmLayout & | Layout | ||
| ) | const |
Definition at line 418 of file MCExpr.cpp.
Referenced by computeLabelDiff().
| 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 765 of file MCExpr.cpp.
References llvm::MCSymbol::AbsolutePseudoFragment, findAssociatedFragment(), llvm::MCSymbol::getFragment(), getKind(), llvm::MCBinaryExpr::getLHS(), llvm::MCBinaryExpr::getOpcode(), llvm::MCBinaryExpr::getRHS(), llvm::MCSymbolRefExpr::getSymbol(), llvm_unreachable, llvm::MCBinaryExpr::Sub, and Unary.
Referenced by llvm::LanaiMCExpr::findAssociatedFragment(), llvm::AVRMCExpr::findAssociatedFragment(), llvm::ARMMCExpr::findAssociatedFragment(), llvm::MipsMCExpr::findAssociatedFragment(), llvm::PPCMCExpr::findAssociatedFragment(), llvm::SparcMCExpr::findAssociatedFragment(), findAssociatedFragment(), and llvm::MCSymbol::getFragment().
|
inline |
Definition at line 70 of file MCExpr.h.
Referenced by llvm::HexagonMCExpr::classof(), llvm::LanaiMCExpr::classof(), llvm::AVRMCExpr::classof(), llvm::ARMMCExpr::classof(), llvm::NVPTXFloatMCExpr::classof(), llvm::MipsMCExpr::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(), findAssociatedFragment(), 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, | ||
| bool | InParens = false |
||
| ) | 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(), llvm::StringRef::size(), SymbolRef, Target, Unary, and llvm::MCSymbolRefExpr::VK_None.
Referenced by llvm::AMDGPUAsmPrinter::EmitInstruction(), llvm::operator<<(), print(), llvm::AArch64InstPrinter::printAddSubImm(), llvm::ARMInstPrinter::printAdrLabelOperand(), llvm::AArch64InstPrinter::printAdrpLabel(), llvm::AArch64InstPrinter::printAlignedLabel(), llvm::AArch64InstPrinter::printAMIndexedWB(), llvm::LanaiInstPrinter::printHi16AndImmOperand(), llvm::LanaiInstPrinter::printHi16ImmOperand(), llvm::HexagonMCExpr::printImpl(), llvm::LanaiMCExpr::printImpl(), llvm::AVRMCExpr::printImpl(), llvm::ARMMCExpr::printImpl(), llvm::MipsMCExpr::printImpl(), llvm::PPCMCExpr::printImpl(), llvm::SparcMCExpr::printImpl(), llvm::NVPTXGenericMCSymbolRefExpr::printImpl(), llvm::AArch64MCExpr::printImpl(), llvm::AArch64InstPrinter::printInst(), llvm::LanaiInstPrinter::printLo16AndImmOperand(), llvm::LanaiInstPrinter::printMemImmOperand(), llvm::X86IntelInstPrinter::printMemOffset(), llvm::X86ATTInstPrinter::printMemOffset(), printMemoryImmediateOffset(), llvm::X86IntelInstPrinter::printMemReference(), llvm::X86ATTInstPrinter::printMemReference(), llvm::LanaiInstPrinter::printOperand(), llvm::MSP430InstPrinter::printOperand(), llvm::X86IntelInstPrinter::printOperand(), llvm::SystemZInstPrinter::printOperand(), llvm::NVPTXInstPrinter::printOperand(), llvm::WebAssemblyInstPrinter::printOperand(), llvm::X86ATTInstPrinter::printOperand(), llvm::SparcInstPrinter::printOperand(), llvm::PPCInstPrinter::printOperand(), llvm::AArch64InstPrinter::printOperand(), llvm::X86IntelInstPrinter::printPCRelImm(), llvm::X86ATTInstPrinter::printPCRelImm(), llvm::MSP430InstPrinter::printPCRelImmOperand(), llvm::MSP430InstPrinter::printSrcMemOperand(), llvm::MCSectionELF::PrintSwitchToSection(), llvm::ARMInstPrinter::printThumbLdrLabelOperand(), llvm::X86IntelInstPrinter::printU8Imm(), and llvm::AArch64InstPrinter::printUImm12Offset().
1.8.6