LLVM 18.0.0git
|
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. | |
bool | canGetFragmentOffset (const MCFragment *F) const |
void | invalidateFragmentsFrom (MCFragment *F) |
Invalidate the fragments starting with F because it has been resized. | |
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. | |
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. | |
Utility Functions | |
uint64_t | getSectionAddressSize (const MCSection *Sec) const |
Get the address space size of the given section, as it effects layout. | |
uint64_t | getSectionFileSize (const MCSection *Sec) const |
Get the data size of the given section, as emitted to the object file. | |
bool | getSymbolOffset (const MCSymbol &S, uint64_t &Val) const |
Get the offset of the given symbol, as computed in the current layout. | |
uint64_t | getSymbolOffset (const MCSymbol &S) const |
Variant that reports a fatal error if the offset is not computable. | |
const MCSymbol * | getBaseSymbol (const MCSymbol &Symbol) const |
If this symbol is equivalent to A + Constant, return A. | |
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 28 of file MCAsmLayout.h.
MCAsmLayout::MCAsmLayout | ( | MCAssembler & | Assembler | ) |
Definition at line 32 of file MCFragment.cpp.
bool MCAsmLayout::canGetFragmentOffset | ( | const MCFragment * | F | ) | const |
F
can be obtained via getFragmentOffset. Definition at line 51 of file MCFragment.cpp.
References llvm::MCSection::begin(), F, llvm::MCFragment::getLayoutOrder(), and I.
Referenced by AttemptToFoldSymbolOffsetDifference().
|
inline |
Get the assembler object this is a layout for.
Definition at line 50 of file MCAsmLayout.h.
Referenced by computeLabelDiff(), llvm::CodeViewContext::encodeDefRange(), llvm::MCExpr::evaluateAsAbsolute(), llvm::MCExpr::evaluateAsRelocatable(), llvm::AVRMCExpr::evaluateAsRelocatableImpl(), llvm::PPCMCExpr::evaluateAsRelocatableImpl(), llvm::MCExpr::evaluateAsValue(), llvm::MCExpr::evaluateKnownAbsolute(), getBaseSymbol(), getSectionAddressSize(), llvm::RISCVAsmBackend::handleAddSubRelocations(), layoutFragment(), llvm::RISCVAsmBackend::relaxDwarfCFA(), llvm::RISCVAsmBackend::relaxDwarfLineAddr(), and llvm::MachObjectWriter::writeObject().
If this symbol is equivalent to A + Constant, return A.
Definition at line 162 of file MCFragment.cpp.
References A, llvm::MCExpr::evaluateAsValue(), getAssembler(), llvm::MCAssembler::getContext(), llvm::MCExpr::getLoc(), llvm::MCSymbol::getName(), llvm::MCSymbolRefExpr::getSymbol(), llvm::MCSymbol::isCommon(), and llvm::MCContext::reportError().
uint64_t MCAsmLayout::getFragmentOffset | ( | const MCFragment * | F | ) | const |
Get the offset of the given fragment inside its containing section.
Definition at line 96 of file MCFragment.cpp.
Referenced by llvm::MCAssembler::computeFragmentSize(), llvm::RISCVAsmBackend::evaluateTargetFixup(), llvm::MachObjectWriter::getFragmentAddress(), getLabelOffset(), and getSectionAddressSize().
Get the address space size of the given section, as it effects layout.
This may differ from the size reported by
Definition at line 198 of file MCFragment.cpp.
References llvm::MCAssembler::computeFragmentSize(), F, getAssembler(), llvm::MCSection::getFragmentList(), and getFragmentOffset().
Referenced by llvm::MachObjectWriter::computeSectionAddresses(), llvm::MachObjectWriter::getPaddingSize(), getSectionFileSize(), llvm::MachObjectWriter::writeObject(), llvm::MachObjectWriter::writeSection(), and llvm::MCAssembler::writeSectionData().
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 204 of file MCFragment.cpp.
References getSectionAddressSize(), and llvm::MCSection::isVirtualSection().
Referenced by llvm::MachObjectWriter::writeObject(), llvm::MachObjectWriter::writeSection(), and llvm::MCAssembler::writeSectionData().
|
inline |
Definition at line 69 of file MCAsmLayout.h.
Referenced by llvm::MachObjectWriter::computeSectionAddresses(), llvm::MachObjectWriter::getPaddingSize(), and llvm::MCAssembler::layout().
|
inline |
Definition at line 70 of file MCAsmLayout.h.
Variant that reports a fatal error if the offset is not computable.
Definition at line 156 of file MCFragment.cpp.
References getSymbolOffsetImpl().
Get the offset of the given symbol, as computed in the current layout.
Definition at line 152 of file MCFragment.cpp.
References getSymbolOffsetImpl().
Referenced by AttemptToFoldSymbolOffsetDifference(), llvm::MCAssembler::computeFragmentSize(), llvm::RISCVAsmBackend::evaluateTargetFixup(), llvm::MachObjectWriter::getSymbolAddress(), and getSymbolValue().
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 70 of file MCFragment.cpp.
References F.
Referenced by llvm::MCAssembler::layout().
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 406 of file MCAssembler.cpp.
References assert(), llvm::computeBundlePadding(), llvm::MCAssembler::computeFragmentSize(), F, getAssembler(), llvm::MCAssembler::getBundleAlignSize(), llvm::MCAssembler::getRelaxAll(), llvm::MCAssembler::isBundlingEnabled(), llvm::report_fatal_error(), and llvm::MCEncodedFragment::setBundlePadding().