LLVM
8.0.1
|
Encapsulates the layout of an assembly file at a particular point in time. More...
#include "llvm/MC/MCAsmLayout.h"
Public Member Functions | |
MCAsmLayout (MCAssembler &Assembler) | |
MCAssembler & | getAssembler () const |
Get the assembler object this is a layout for. More... | |
void | invalidateFragmentsFrom (MCFragment *F) |
Invalidate the fragments starting with F because it has been resized. More... | |
void | layoutFragment (MCFragment *Fragment) |
Perform layout for a single fragment, assuming that the previous fragment has already been laid out correctly, and the parent section has been initialized. More... | |
Section Access (in layout order) | |
llvm::SmallVectorImpl< MCSection * > & | getSectionOrder () |
const llvm::SmallVectorImpl< MCSection * > & | getSectionOrder () const |
Fragment Layout Data | |
uint64_t | getFragmentOffset (const MCFragment *F) const |
Get the offset of the given fragment inside its containing section. More... | |
Utility Functions | |
uint64_t | getSectionAddressSize (const MCSection *Sec) const |
Get the address space size of the given section, as it effects layout. More... | |
uint64_t | getSectionFileSize (const MCSection *Sec) const |
Get the data size of the given section, as emitted to the object file. More... | |
bool | getSymbolOffset (const MCSymbol &S, uint64_t &Val) const |
Get the offset of the given symbol, as computed in the current layout. More... | |
uint64_t | getSymbolOffset (const MCSymbol &S) const |
Variant that reports a fatal error if the offset is not computable. More... | |
const MCSymbol * | getBaseSymbol (const MCSymbol &Symbol) const |
If this symbol is equivalent to A + Constant, return A. More... | |
Encapsulates the layout of an assembly file at a particular point in time.
Assembly may require computing multiple layouts for a particular assembly file as part of the relaxation process. This class encapsulates the layout at a single point in time in such a way that it is always possible to efficiently compute the exact address of any symbol in the assembly file, even during the relaxation process.
Definition at line 29 of file MCAsmLayout.h.
MCAsmLayout::MCAsmLayout | ( | MCAssembler & | Assembler | ) |
Definition at line 33 of file MCFragment.cpp.
References assert(), F(), llvm::MCFragment::getLayoutOrder(), and llvm::MCFragment::getParent().
|
inline |
Get the assembler object this is a layout for.
Definition at line 51 of file MCAsmLayout.h.
References invalidateFragmentsFrom(), and layoutFragment().
Referenced by llvm::CodeViewContext::encodeDefRange(), llvm::MCExpr::evaluateAsRelocatable(), llvm::AVRMCExpr::evaluateAsRelocatableImpl(), llvm::PPCMCExpr::evaluateAsRelocatableImpl(), llvm::MCExpr::evaluateAsValue(), llvm::MCAssembler::Finish(), getBaseSymbol(), getSectionAddressSize(), and llvm::MachObjectWriter::writeObject().
If this symbol is equivalent to A + Constant, return A.
Definition at line 140 of file MCFragment.cpp.
References llvm::HexStyle::Asm, llvm::MCExpr::evaluateAsValue(), getAssembler(), llvm::MCAssembler::getContext(), llvm::MCExpr::getLoc(), llvm::MCSymbol::getName(), llvm::MCValue::getSymA(), llvm::MCValue::getSymB(), llvm::MCSymbolRefExpr::getSymbol(), llvm::MCSymbol::getVariableValue(), llvm::MCSymbol::isCommon(), llvm::MCSymbol::isVariable(), and llvm::MCContext::reportError().
Referenced by getSectionOrder(), getSymbolValue(), isWeak(), and mergeTypeForSet().
uint64_t MCAsmLayout::getFragmentOffset | ( | const MCFragment * | F | ) | const |
Get the offset of the given fragment inside its containing section.
Definition at line 78 of file MCFragment.cpp.
References assert().
Referenced by canUseLocalRelocation(), llvm::MCAssembler::computeFragmentSize(), encodeBase64StringEntry(), llvm::MCAssembler::Finish(), getARMFixupKindMachOInfo(), llvm::MCAssembler::getAtom(), getFixupKindLog2Size(), getFixupOffset(), llvm::MachObjectWriter::getFragmentAddress(), getLabelOffset(), llvm::MCCodePaddingPolicy::getNextFragmentOffset(), getSectionAddressSize(), getSectionOrder(), and isWeak().
Get the address space size of the given section, as it effects layout.
This may differ from the size reported by
Definition at line 176 of file MCFragment.cpp.
References llvm::MCAssembler::computeFragmentSize(), getAssembler(), llvm::MCSection::getFragmentList(), and getFragmentOffset().
Referenced by llvm::MachObjectWriter::computeSectionAddresses(), llvm::MCCodePaddingPolicy::getNextFragmentOffset(), llvm::MachObjectWriter::getPaddingSize(), getSectionFileSize(), getSectionOrder(), isAssociative(), isWeak(), llvm::MachObjectWriter::writeObject(), and llvm::MachObjectWriter::writeSection().
Get the data size of the given section, as emitted to the object file.
This may include additional padding, or be 0 for virtual sections.
Definition at line 182 of file MCFragment.cpp.
References getSectionAddressSize(), and llvm::MCSection::isVirtualSection().
Referenced by getSectionOrder(), llvm::MachObjectWriter::writeObject(), llvm::MachObjectWriter::writeSection(), and llvm::MCAssembler::writeSectionData().
|
inline |
Definition at line 66 of file MCAsmLayout.h.
Referenced by llvm::MachObjectWriter::computeSectionAddresses(), llvm::MCAssembler::Finish(), llvm::MachObjectWriter::getPaddingSize(), and llvm::MCAssembler::layout().
|
inline |
Definition at line 67 of file MCAsmLayout.h.
References getBaseSymbol(), getFragmentOffset(), getSectionAddressSize(), getSectionFileSize(), getSymbolOffset(), and llvm::ARMBuildAttrs::Symbol.
Get the offset of the given symbol, as computed in the current layout.
Definition at line 130 of file MCFragment.cpp.
References getSymbolOffsetImpl().
Referenced by canUseLocalRelocation(), llvm::MCAssembler::computeFragmentSize(), encodeBase64StringEntry(), getARMFixupKindMachOInfo(), llvm::MCAssembler::getAtom(), getFixupKindLog2Size(), getFixupOffset(), getSectionOrder(), llvm::MachObjectWriter::getSymbolAddress(), getSymbolValue(), isInSymtab(), and isWeak().
Variant that reports a fatal error if the offset is not computable.
Definition at line 134 of file MCFragment.cpp.
References getSymbolOffsetImpl().
void MCAsmLayout::invalidateFragmentsFrom | ( | MCFragment * | F | ) |
Invalidate the fragments starting with F because it has been resized.
The fragment's size should have already been updated, but its bundle padding will be recomputed.
Definition at line 52 of file MCFragment.cpp.
References assert(), llvm::MCFragment::getParent(), llvm::ilist_node_with_parent< NodeTy, ParentTy, Options >::getPrevNode(), I, and layoutFragment().
Referenced by llvm::MCAssembler::Finish(), getAssembler(), and llvm::MCCodePadder::relaxFragment().
void MCAsmLayout::layoutFragment | ( | MCFragment * | Fragment | ) |
Perform layout for a single fragment, assuming that the previous fragment has already been laid out correctly, and the parent section has been initialized.
Definition at line 381 of file MCAssembler.cpp.
References assert(), llvm::computeBundlePadding(), F(), llvm::MCFragment::getParent(), llvm::ilist_node_with_parent< NodeTy, ParentTy, Options >::getPrevNode(), llvm::MCFragment::hasInstructions(), llvm::report_fatal_error(), and llvm::MCEncodedFragment::setBundlePadding().
Referenced by getAssembler(), and invalidateFragmentsFrom().