LLVM  8.0.1
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
[legend]

Public Types

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

Public Member Functions

 MCExpr (const MCExpr &)=delete
 
MCExproperator= (const MCExpr &)=delete
 
Accessors
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 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

Enumerator
Binary 

Binary expressions.

Constant 

Constant expressions.

SymbolRef 

References to labels and assigned expressions.

Unary 

Unary expressions.

Target 

Target specific expression.

Definition at line 38 of file MCExpr.h.

Constructor & Destructor Documentation

◆ MCExpr() [1/2]

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

Definition at line 59 of file MCExpr.h.

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

◆ MCExpr() [2/2]

llvm::MCExpr::MCExpr ( const MCExpr )
delete

Member Function Documentation

◆ dump()

LLVM_DUMP_METHOD void MCExpr::dump ( ) const

Definition at line 145 of file MCExpr.cpp.

Referenced by getLoc().

◆ evaluateAsAbsolute() [1/5]

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

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

◆ evaluateAsAbsolute() [2/5]

bool MCExpr::evaluateAsAbsolute ( int64_t &  Res) const

Definition at line 447 of file MCExpr.cpp.

◆ evaluateAsAbsolute() [3/5]

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

Definition at line 462 of file MCExpr.cpp.

◆ evaluateAsAbsolute() [4/5]

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

Definition at line 466 of file MCExpr.cpp.

◆ evaluateAsAbsolute() [5/5]

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

Definition at line 451 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
protected

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

References llvm::MCAsmLayout::getAssembler().

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

◆ evaluateKnownAbsolute()

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

Definition at line 470 of file MCExpr.cpp.

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

◆ findAssociatedFragment()

MCFragment * MCExpr::findAssociatedFragment ( ) const

◆ getKind()

ExprKind llvm::MCExpr::getKind ( ) const
inline

◆ getLoc()

SMLoc llvm::MCExpr::getLoc ( ) const
inline

◆ operator=()

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

Referenced by MCExpr().

◆ print()

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

Definition at line 42 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, 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 createPPCMCAsmInfo(), 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::ARMMCExpr::printImpl(), llvm::RISCVMCExpr::printImpl(), llvm::MipsMCExpr::printImpl(), llvm::PPCMCExpr::printImpl(), llvm::SparcMCExpr::printImpl(), llvm::AArch64MCExpr::printImpl(), llvm::MSP430InstPrinter::printInst(), 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::RISCVInstPrinter::printOperand(), llvm::X86IntelInstPrinter::printOperand(), llvm::NVPTXInstPrinter::printOperand(), llvm::SystemZInstPrinter::printOperand(), llvm::X86ATTInstPrinter::printOperand(), llvm::SparcInstPrinter::printOperand(), llvm::WebAssemblyInstPrinter::printOperand(), llvm::PPCInstPrinter::printOperand(), llvm::AArch64InstPrinter::printOperand(), llvm::R600InstPrinter::printOperand(), llvm::X86InstPrinterCommon::printPCRelImm(), PrintQuotedString(), llvm::AMDGPUInstPrinter::printRegOperand(), printSImmOperand(), 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: