LLVM  7.0.0svn
Public Types | Public Member Functions | 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 "llvm/MC/MCExpr.h"

Inheritance diagram for llvm::MCExpr:
Inheritance graph

Public Types

enum  ExprKind {
  Binary, Constant, SymbolRef, Unary,

Public Member Functions

 MCExpr (const MCExpr &)=delete
MCExproperator= (const MCExpr &)=delete
ExprKind getKind () const
SMLoc getLoc () 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, SMLoc Loc)
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 36 of file MCExpr.h.

Member Enumeration Documentation

◆ ExprKind


Binary expressions.


Constant expressions.


References to labels and assigned expressions.


Unary expressions.


Target specific expression.

Definition at line 38 of file MCExpr.h.

Constructor & Destructor Documentation

◆ MCExpr() [1/2]

llvm::MCExpr::MCExpr ( ExprKind  Kind,
SMLoc  Loc 

Definition at line 59 of file MCExpr.h.

References llvm::HexStyle::Asm, evaluateAsRelocatableImpl(), Fixup, and operator=().

◆ MCExpr() [2/2]

llvm::MCExpr::MCExpr ( const MCExpr )

Member Function Documentation

◆ dump()

LLVM_DUMP_METHOD void MCExpr::dump ( ) const

Definition at line 140 of file MCExpr.cpp.

Referenced by getLoc().

◆ evaluateAsAbsolute() [1/4]

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

Definition at line 433 of file MCExpr.cpp.

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

◆ evaluateAsAbsolute() [2/4]

bool MCExpr::evaluateAsAbsolute ( int64_t &  Res) const

Definition at line 424 of file MCExpr.cpp.

◆ evaluateAsAbsolute() [3/4]

bool MCExpr::evaluateAsAbsolute ( int64_t &  Res,
const MCAssembler Asm 
) const

Definition at line 439 of file MCExpr.cpp.

◆ evaluateAsAbsolute() [4/4]

bool MCExpr::evaluateAsAbsolute ( int64_t &  Res,
const MCAsmLayout Layout 
) const

Definition at line 428 of file MCExpr.cpp.

◆ evaluateAsRelocatable()

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

◆ evaluateAsRelocatableImpl()

bool MCExpr::evaluateAsRelocatableImpl ( MCValue Res,
const MCAssembler Asm,
const MCAsmLayout Layout,
const MCFixup Fixup,
const SectionAddrMap Addrs,
bool  InSet 
) const

◆ 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 614 of file MCExpr.cpp.

References llvm::MCAsmLayout::getAssembler().

Referenced by llvm::MCAssembler::computeFragmentSize(), llvm::MCAsmLayout::getBaseSymbol(), getLoc(), and getSymbolOffsetImpl().

◆ evaluateKnownAbsolute()

bool MCExpr::evaluateKnownAbsolute ( int64_t &  Res,
const MCAsmLayout Layout 
) const

Definition at line 443 of file MCExpr.cpp.

Referenced by computeLabelDiff(), llvm::MCAssembler::Finish(), getLoc(), and mergeTypeForSet().

◆ findAssociatedFragment()

MCFragment * MCExpr::findAssociatedFragment ( ) const

◆ getKind()

ExprKind llvm::MCExpr::getKind ( ) const

◆ getLoc()

SMLoc llvm::MCExpr::getLoc ( ) const

◆ operator=()

MCExpr& llvm::MCExpr::operator= ( const MCExpr )

Referenced by MCExpr().

◆ print()

void MCExpr::print ( raw_ostream OS,
const MCAsmInfo MAI,
bool  InParens = false 
) const

Definition at line 40 of file MCExpr.cpp.

References llvm::MCBinaryExpr::Add, llvm::MCBinaryExpr::And, llvm::MCBinaryExpr::AShr, Binary, Constant, llvm::MCBinaryExpr::Div, llvm::StringRef::empty(), llvm::MCBinaryExpr::EQ, 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 createPPCMCAsmInfo(), llvm::AMDGPUAsmPrinter::EmitInstruction(), llvm::MCTargetStreamer::emitValue(), GetAEABIUnwindPersonalityName(), getLoc(), getOpenCLAlignment(), getPlatformName(), llvm::operator<<(), print(), llvm::AArch64InstPrinter::printAddSubImm(), llvm::ARMInstPrinter::printAdrLabelOperand(), llvm::AArch64InstPrinter::printAdrpLabel(), llvm::AArch64InstPrinter::printAlignedLabel(), llvm::AArch64InstPrinter::printAMIndexedWB(), PrintCFIEscape(), llvm::LanaiInstPrinter::printHi16AndImmOperand(), llvm::LanaiInstPrinter::printHi16ImmOperand(), llvm::HexagonMCExpr::printImpl(), llvm::LanaiMCExpr::printImpl(), llvm::Nios2MCExpr::printImpl(), llvm::RISCVMCExpr::printImpl(), llvm::ARMMCExpr::printImpl(), llvm::MipsMCExpr::printImpl(), llvm::PPCMCExpr::printImpl(), llvm::SparcMCExpr::printImpl(), llvm::AArch64MCExpr::printImpl(), llvm::AArch64InstPrinter::printInst(), llvm::MipsInstPrinter::printInst(), llvm::R600InstPrinter::printLiteral(), 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::RISCVInstPrinter::printOperand(), llvm::X86IntelInstPrinter::printOperand(), llvm::NVPTXInstPrinter::printOperand(), llvm::SystemZInstPrinter::printOperand(), llvm::WebAssemblyInstPrinter::printOperand(), llvm::X86ATTInstPrinter::printOperand(), llvm::Nios2InstPrinter::printOperand(), llvm::SparcInstPrinter::printOperand(), llvm::PPCInstPrinter::printOperand(), llvm::AArch64InstPrinter::printOperand(), llvm::R600InstPrinter::printOperand(), llvm::X86IntelInstPrinter::printPCRelImm(), llvm::X86ATTInstPrinter::printPCRelImm(), llvm::MSP430InstPrinter::printPCRelImmOperand(), PrintQuotedString(), llvm::AMDGPUInstPrinter::printRegOperand(), printSImmOperand(), llvm::MSP430InstPrinter::printSrcMemOperand(), llvm::MCSectionWasm::PrintSwitchToSection(), llvm::MCSectionELF::PrintSwitchToSection(), llvm::ARMInstPrinter::printThumbLdrLabelOperand(), llvm::X86IntelInstPrinter::printU8Imm(), and llvm::AArch64InstPrinter::printUImm12Offset().

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