LLVM  3.7.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) 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...
 
MCSectionfindAssociatedSection () 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 33 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 35 of file MCExpr.h.

Constructor & Destructor Documentation

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

Definition at line 58 of file MCExpr.h.

Member Function Documentation

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

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

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 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
ExprKind llvm::MCExpr::getKind ( ) const
inline
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().


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