LLVM API Documentation

Public Types | Public Member Functions | Protected Member Functions
llvm::MCExpr Class Reference

#include <MCExpr.h>

Inheritance diagram for llvm::MCExpr:
Inheritance graph
[legend]

List of all members.

Public Types

enum  ExprKind {
  Binary, Constant, SymbolRef, Unary,
  Target
}

Public Member Functions

void print (raw_ostream &OS) const
void dump () const
bool EvaluateAsAbsolute (int64_t &Res, const MCAsmLayout &Layout, const SectionAddrMap &Addrs) const
bool EvaluateAsAbsolute (int64_t &Res) const
bool EvaluateAsAbsolute (int64_t &Res, const MCAssembler &Asm) const
bool EvaluateAsAbsolute (int64_t &Res, const MCAsmLayout &Layout) const
int64_t evaluateKnownAbsolute (const MCAsmLayout &Layout) const
bool EvaluateAsRelocatable (MCValue &Res, const MCAsmLayout *Layout, const MCFixup *Fixup) const
bool EvaluateAsValue (MCValue &Res, const MCAsmLayout *Layout, const MCFixup *Fixup) const
 Try to evaluate the expression to the form (a - b + constant) where neither a nor b are variables.
const MCSectionFindAssociatedSection () const
Accessors
ExprKind getKind () const

Protected Member Functions

 MCExpr (ExprKind _Kind)
bool EvaluateAsRelocatableImpl (MCValue &Res, const MCAssembler *Asm, const MCAsmLayout *Layout, const MCFixup *Fixup, const SectionAddrMap *Addrs, bool InSet, bool ForceVarExpansion) const

Detailed Description

MCExpr - 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) [inline, explicit, protected]

Definition at line 59 of file MCExpr.h.


Member Function Documentation

void MCExpr::dump ( ) const

Definition at line 129 of file MCExpr.cpp.

bool MCExpr::EvaluateAsAbsolute ( int64_t &  Res,
const MCAsmLayout Layout,
const SectionAddrMap Addrs 
) const

EvaluateAsAbsolute - 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 460 of file MCExpr.cpp.

Referenced by llvm::AArch64InstPrinter::printAlignedLabel(), and llvm::ARMInstPrinter::printOperand().

bool MCExpr::EvaluateAsAbsolute ( int64_t &  Res) const

Definition at line 451 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 455 of file MCExpr.cpp.

bool MCExpr::EvaluateAsRelocatable ( MCValue Res,
const MCAsmLayout Layout,
const MCFixup Fixup 
) const

EvaluateAsRelocatable - 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 648 of file MCExpr.cpp.

References EvaluateAsRelocatableImpl(), and llvm::MCAsmLayout::getAssembler().

Referenced by evaluate(), llvm::PPCMCExpr::EvaluateAsConstant(), llvm::MipsMCExpr::EvaluateAsRelocatableImpl(), llvm::PPCMCExpr::EvaluateAsRelocatableImpl(), llvm::SparcMCExpr::EvaluateAsRelocatableImpl(), llvm::AArch64MCExpr::EvaluateAsRelocatableImpl(), llvm::MachObjectWriter::getSymbolAddress(), and llvm::MachObjectWriter::markAbsoluteVariableSymbols().

bool MCExpr::EvaluateAsRelocatableImpl ( MCValue Res,
const MCAssembler Asm,
const MCAsmLayout Layout,
const MCFixup Fixup,
const SectionAddrMap Addrs,
bool  InSet,
bool  ForceVarExpansion 
) const [protected]
bool MCExpr::EvaluateAsValue ( MCValue Res,
const MCAsmLayout Layout,
const MCFixup Fixup 
) 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 symbol value in the symbol table.

Definition at line 656 of file MCExpr.cpp.

References EvaluateAsRelocatableImpl(), and llvm::MCAsmLayout::getAssembler().

Referenced by evaluate(), llvm::MCAsmLayout::getBaseSymbol(), and getSymbolOffsetImpl().

int64_t MCExpr::evaluateKnownAbsolute ( const MCAsmLayout Layout) const

Definition at line 470 of file MCExpr.cpp.

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

Reimplemented in llvm::MCTargetExpr, llvm::AArch64MCExpr, llvm::SparcMCExpr, llvm::PPCMCExpr, llvm::NVPTXFloatMCExpr, llvm::ARMMCExpr, and llvm::MipsMCExpr.

Definition at line 816 of file MCExpr.cpp.

References FindAssociatedSection(), getKind(), llvm::MCBinaryExpr::getLHS(), llvm::MCBinaryExpr::getRHS(), llvm::MCSymbol::getSection(), llvm::MCSymbolRefExpr::getSymbol(), llvm_unreachable, and Unary.

Referenced by llvm::MipsMCExpr::FindAssociatedSection(), FindAssociatedSection(), and llvm::MCSymbol::setVariableValue().

ExprKind llvm::MCExpr::getKind ( ) const [inline]
void MCExpr::print ( raw_ostream OS) const

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