LLVM 20.0.0git
|
#include "llvm/MC/MCAssembler.h"
Public Types | |
using | SectionListType = SmallVector< MCSection *, 0 > |
using | const_iterator = pointee_iterator< SectionListType::const_iterator > |
Friends | |
class | MCObjectWriter |
Definition at line 53 of file MCAssembler.h.
Definition at line 57 of file MCAssembler.h.
using llvm::MCAssembler::SectionListType = SmallVector<MCSection *, 0> |
Definition at line 56 of file MCAssembler.h.
MCAssembler::MCAssembler | ( | MCContext & | Context, |
std::unique_ptr< MCAsmBackend > | Backend, | ||
std::unique_ptr< MCCodeEmitter > | Emitter, | ||
std::unique_ptr< MCObjectWriter > | Writer | ||
) |
Construct a new assembler instance.
Definition at line 80 of file MCAssembler.cpp.
|
delete |
|
inline |
Definition at line 218 of file MCAssembler.h.
References llvm::SmallVectorTemplateCommon< T, typename >::begin().
uint64_t MCAssembler::computeFragmentSize | ( | const MCFragment & | F | ) | const |
Compute the effective fragment size.
Definition at line 240 of file MCAssembler.cpp.
References A, assert(), llvm::MCExpr::evaluateAsValue(), F, llvm::MCFragment::FT_Align, llvm::MCFragment::FT_BoundaryAlign, llvm::MCFragment::FT_CVDefRange, llvm::MCFragment::FT_CVInlineLines, llvm::MCFragment::FT_Data, llvm::MCFragment::FT_Dummy, llvm::MCFragment::FT_Dwarf, llvm::MCFragment::FT_DwarfFrame, llvm::MCFragment::FT_Fill, llvm::MCFragment::FT_LEB, llvm::MCFragment::FT_Nops, llvm::MCFragment::FT_Org, llvm::MCFragment::FT_PseudoProbe, llvm::MCFragment::FT_Relaxable, llvm::MCFragment::FT_SymbolId, llvm::MCAlignFragment::getAlignment(), getBackend(), getBackendPtr(), getContext(), getFragmentOffset(), llvm::MCOrgFragment::getLoc(), llvm::MCAlignFragment::getMaxBytesToEmit(), llvm::MCOrgFragment::getOffset(), llvm::MCFragment::getParent(), getSymbolOffset(), llvm::MCAlignFragment::hasEmitNops(), llvm_unreachable, llvm::Offset, llvm::offsetToAlignment(), llvm::MCContext::reportError(), Size, llvm::MCSection::useCodeAlign(), and llvm::Align::value().
Referenced by ensureValid(), getSectionAddressSize(), and layoutBundle().
LLVM_DUMP_METHOD void MCAssembler::dump | ( | ) | const |
Definition at line 1305 of file MCAssembler.cpp.
References llvm::MCSection::dump(), llvm::errs(), llvm::First, OS, Sym, and symbols().
Referenced by layout().
|
inline |
Definition at line 219 of file MCAssembler.h.
References llvm::SmallVectorTemplateCommon< T, typename >::end().
void MCAssembler::ensureValid | ( | MCSection & | Sec | ) | const |
Definition at line 424 of file MCAssembler.cpp.
References computeFragmentSize(), F, llvm::MCSection::hasLayout(), isBundlingEnabled(), layoutBundle(), llvm::Offset, and llvm::MCSection::setHasLayout().
Referenced by getFragmentOffset().
void MCAssembler::Finish | ( | ) |
Finish - Do final processing and write the object to the output stream.
Writer
is used for custom object writer (as the MCJIT does), if not specified it is automatically created from backend.
Definition at line 1029 of file MCAssembler.cpp.
References getWriter(), layout(), and llvm::MCObjectWriter::writeObject().
Referenced by llvm::MCObjectStreamer::finishImpl().
|
inline |
Definition at line 188 of file MCAssembler.h.
Referenced by computeFragmentSize(), llvm::MCELFStreamer::emitAssemblerFlag(), llvm::MCWasmStreamer::emitAssemblerFlag(), llvm::MCWinCOFFStreamer::emitAssemblerFlag(), llvm::X86_MC::emitInstruction(), llvm::MCObjectStreamer::emitRelocDirective(), llvm::MCXCOFFStreamer::emitXCOFFRefDirective(), layout(), llvm::LoongArchTargetELFStreamer::LoongArchTargetELFStreamer(), llvm::RISCVTargetELFStreamer::RISCVTargetELFStreamer(), and writeFragmentPadding().
|
inline |
Definition at line 184 of file MCAssembler.h.
Referenced by computeFragmentSize(), layout(), reset(), writeFragmentPadding(), and writeSectionData().
Definition at line 506 of file MCAssembler.cpp.
References A, assert(), llvm::MCExpr::evaluateAsValue(), getContext(), llvm::MCExpr::getLoc(), llvm::MCSymbol::getName(), llvm::MCSymbolRefExpr::getSymbol(), llvm::MCSymbol::isCommon(), and llvm::MCContext::reportError().
|
inline |
Definition at line 210 of file MCAssembler.h.
Referenced by llvm::MCELFStreamer::emitBundleAlignMode(), layoutBundle(), setSectionAlignmentForBundling(), and writeFragmentPadding().
|
inline |
Definition at line 182 of file MCAssembler.h.
Referenced by computeFragmentSize(), llvm::MCELFStreamer::emitCommonSymbol(), llvm::MipsTargetELFStreamer::emitDirectiveCpLoad(), llvm::MipsTargetELFStreamer::emitDirectiveCpsetup(), llvm::MipsTargetELFStreamer::emitDirectiveEnd(), llvm::MipsTargetELFStreamer::emitFrame(), llvm::MCELFStreamer::emitIdent(), llvm::MipsTargetELFStreamer::emitMipsAbiFlags(), llvm::MipsTargetELFStreamer::finish(), getBaseSymbol(), llvm::HexagonMCELFStreamer::HexagonMCEmitCommonSymbol(), layout(), llvm::MipsTargetELFStreamer::MipsTargetELFStreamer(), and writeSectionData().
|
inline |
Definition at line 194 of file MCAssembler.h.
Referenced by llvm::MCObjectStreamer::emitDwarfAdvanceLineAddr().
|
inline |
Definition at line 190 of file MCAssembler.h.
References Emitter.
Referenced by llvm::MCXCOFFStreamer::emitInstToData(), llvm::MCWinCOFFStreamer::emitInstToData(), and llvm::MCObjectStreamer::emitInstToFragment().
|
inline |
Definition at line 186 of file MCAssembler.h.
References Emitter.
Referenced by llvm::PPCELFStreamer::emitInstruction(), llvm::PPCXCOFFStreamer::emitInstruction(), reset(), and llvm::AMDGPUAsmPrinter::runOnMachineFunction().
uint64_t MCAssembler::getFragmentOffset | ( | const MCFragment & | F | ) | const |
Definition at line 441 of file MCAssembler.cpp.
References ensureValid(), and F.
Referenced by computeFragmentSize(), and getSectionAddressSize().
|
inline |
Definition at line 205 of file MCAssembler.h.
Definition at line 543 of file MCAssembler.cpp.
References assert(), computeFragmentSize(), llvm::MCSection::curFragList(), F, getFragmentOffset(), and llvm::MCSection::FragList::Tail.
Referenced by getSectionFileSize(), and writeSectionData().
Definition at line 550 of file MCAssembler.cpp.
References getSectionAddressSize(), and llvm::MCSection::isVirtualSection().
Referenced by writeSectionData().
Definition at line 500 of file MCAssembler.cpp.
References getSymbolOffsetImpl().
Definition at line 496 of file MCAssembler.cpp.
References getSymbolOffsetImpl().
Referenced by computeFragmentSize().
|
inline |
Definition at line 192 of file MCAssembler.h.
Referenced by llvm::MCObjectStreamer::emitAddrsig(), llvm::MCObjectStreamer::emitAddrsigSym(), llvm::MCObjectStreamer::emitFileDirective(), Finish(), llvm::MCELFStreamer::getWriter(), llvm::MCWinCOFFStreamer::getWriter(), and layout().
|
inline |
Definition at line 204 of file MCAssembler.h.
|
inline |
Definition at line 208 of file MCAssembler.h.
Referenced by canReuseDataFragment(), ensureValid(), setSectionAlignmentForBundling(), and writeFragmentPadding().
Check whether a given symbol has been flagged with .thumb_func.
Definition at line 112 of file MCAssembler.cpp.
References llvm::MCExpr::evaluateAsRelocatable(), isThumbFunc(), llvm::Ref, Sym, and llvm::MCSymbolRefExpr::VK_None.
Referenced by isThumbFunc().
void MCAssembler::layout | ( | ) |
Definition at line 893 of file MCAssembler.cpp.
References _, llvm::MCAsmBackend::applyFixup(), assert(), DEBUG_WITH_TYPE, DF, dump(), llvm::errs(), llvm::MCObjectWriter::executePostLayoutBinding(), llvm::MCAsmBackend::finishLayout(), Fixup, llvm::MCFragment::FT_Align, llvm::MCFragment::FT_CVDefRange, llvm::MCFragment::FT_Data, llvm::MCFragment::FT_Dwarf, llvm::MCFragment::FT_DwarfFrame, llvm::MCFragment::FT_LEB, llvm::MCFragment::FT_PseudoProbe, llvm::MCFragment::FT_Relaxable, getBackend(), getBackendPtr(), llvm::MCEncodedFragmentWithFixups< ContentsSize, FixupsSize >::getContents(), getContext(), llvm::MCEncodedFragmentWithFixups< ContentsSize, FixupsSize >::getFixups(), llvm::MCEncodedFragment::getSubtargetInfo(), getWriter(), llvm::MCAlignFragment::hasEmitNops(), llvm::MCFragment::hasInstructions(), llvm::List, llvm::MCSection::setHasLayout(), llvm::MCSection::setOrdinal(), llvm::MCAsmBackend::shouldInsertFixupForCodeAlign(), and llvm::CallingConv::Tail.
Referenced by Finish().
void MCAssembler::layoutBundle | ( | MCFragment * | Prev, |
MCFragment * | F | ||
) | const |
Definition at line 383 of file MCAssembler.cpp.
References assert(), computeBundlePadding(), computeFragmentSize(), DF, F, getBundleAlignSize(), llvm::report_fatal_error(), and llvm::MCEncodedFragment::setBundlePadding().
Referenced by ensureValid().
|
delete |
Definition at line 103 of file MCAssembler.cpp.
References assert(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().
Referenced by llvm::MCObjectStreamer::changeSectionImpl().
Definition at line 557 of file MCAssembler.cpp.
Referenced by llvm::MCWinCOFFStreamer::changeSection(), llvm::MipsELFStreamer::createPendingLabelRelocs(), llvm::MCObjectStreamer::emitAssignment(), llvm::MCWinCOFFStreamer::emitCOFFSafeSEH(), llvm::MCWinCOFFStreamer::emitCOFFSymbolIndex(), llvm::MCWinCOFFStreamer::emitCOFFSymbolStorageClass(), llvm::MCWinCOFFStreamer::emitCOFFSymbolType(), llvm::MCELFStreamer::emitCommonSymbol(), llvm::MCWinCOFFStreamer::emitCommonSymbol(), llvm::MCXCOFFStreamer::emitCommonSymbol(), llvm::MipsTargetELFStreamer::emitDirectiveCpLoad(), llvm::RISCVTargetELFStreamer::emitDirectiveVariantCC(), llvm::MipsTargetELFStreamer::emitLabel(), llvm::MCObjectStreamer::emitLabel(), llvm::MCObjectStreamer::emitLabelAtPos(), llvm::MCELFStreamer::emitLocalCommonSymbol(), llvm::MCELFStreamer::emitSymbolAttribute(), llvm::MCWasmStreamer::emitSymbolAttribute(), llvm::MCWinCOFFStreamer::emitSymbolAttribute(), llvm::MCXCOFFStreamer::emitSymbolAttribute(), llvm::MCELFStreamer::emitWeakReference(), llvm::MCWasmStreamer::emitWeakReference(), llvm::MCWinCOFFStreamer::emitWeakReference(), llvm::HexagonMCELFStreamer::HexagonMCEmitCommonSymbol(), and llvm::HexagonMCELFStreamer::HexagonMCEmitLocalCommonSymbol().
void MCAssembler::reset | ( | ) |
Reuse an assembler instance.
Definition at line 87 of file MCAssembler.cpp.
References llvm::SmallVectorImpl< T >::clear(), getBackendPtr(), getEmitterPtr(), llvm::MCAsmBackend::reset(), and llvm::MCCodeEmitter::reset().
|
inline |
Definition at line 212 of file MCAssembler.h.
References assert(), and Size.
Referenced by llvm::MCELFStreamer::emitBundleAlignMode().
Flag a function symbol as the target of a .thumb_func directive.
Definition at line 176 of file MCAssembler.h.
References llvm::SmallPtrSetImpl< PtrType >::insert().
|
inline |
Definition at line 206 of file MCAssembler.h.
|
inline |
Definition at line 223 of file MCAssembler.h.
References llvm::make_pointee_range().
Referenced by dump().
void MCAssembler::writeFragmentPadding | ( | raw_ostream & | OS, |
const MCEncodedFragment & | F, | ||
uint64_t | FSize | ||
) | const |
Write the necessary bundle padding to OS
.
Expects a fragment F
containing instructions and its size FSize
.
Definition at line 566 of file MCAssembler.cpp.
References llvm::MCEncodedFragment::alignToBundleEnd(), assert(), getBackend(), getBackendPtr(), getBundleAlignSize(), llvm::MCEncodedFragment::getBundlePadding(), llvm::MCEncodedFragment::getSubtargetInfo(), llvm::MCFragment::hasInstructions(), isBundlingEnabled(), OS, and llvm::report_fatal_error().
void MCAssembler::writeSectionData | ( | raw_ostream & | OS, |
const MCSection * | Section | ||
) | const |
Emit the section contents to OS
.
Definition at line 815 of file MCAssembler.cpp.
References assert(), DF, F, llvm::MCFragment::FT_Align, llvm::MCFragment::FT_Data, llvm::MCFragment::FT_Fill, llvm::MCFragment::FT_Org, getBackendPtr(), getContext(), getSectionAddressSize(), getSectionFileSize(), llvm::MCSection::isVirtualSection(), llvm_unreachable, OS, llvm::MCContext::reportError(), llvm::raw_ostream::tell(), and writeFragment().
|
friend |
Definition at line 55 of file MCAssembler.h.