LLVM  4.0.0
Public Types | Protected Member Functions | List of all members
llvm::MCExpr Class Reference

Base class for the full range of assembler expressions which are needed for parsing. More...

#include <MCExpr.h>

Inheritance diagram for llvm::MCExpr:
[legend]

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...
 
MCFragmentfindAssociatedFragment () 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
 

Detailed Description

Base class for the full range of assembler expressions which are needed for parsing.

Definition at line 34 of file MCExpr.h.

Member Enumeration Documentation

Enumerator
Binary 

Binary expressions.

Constant 

Constant expressions.

SymbolRef 

References to labels and assigned expressions.

Unary 

Unary expressions.

Target 

Target specific expression.

Definition at line 36 of file MCExpr.h.

Constructor & Destructor Documentation

llvm::MCExpr::MCExpr ( ExprKind  Kind)
inlineexplicitprotected

Definition at line 59 of file MCExpr.h.

Member Function Documentation

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.

Parameters
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.
Returns
- True on success.

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).

Parameters
Res- The relocatable value, if evaluation succeeds.
Layout- The assembler layout object to use for evaluating values.
Fixup- The Fixup object if available.
Returns
- True on success.

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().

bool MCExpr::evaluateAsRelocatableImpl ( MCValue Res,
const MCAssembler Asm,
const MCAsmLayout Layout,
const MCFixup Fixup,
const SectionAddrMap Addrs,
bool  InSet 
) const
protected
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
ExprKind llvm::MCExpr::getKind ( ) const
inline
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().


The documentation for this class was generated from the following files: