#include "llvm/MC/MCAssembler.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCCodeEmitter.h"
#include "llvm/MC/MCCodeView.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCDwarf.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCFixup.h"
#include "llvm/MC/MCFixupKindInfo.h"
#include "llvm/MC/MCFragment.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCObjectWriter.h"
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCValue.h"
#include "llvm/Support/Alignment.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/EndianStream.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/LEB128.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>
#include <cstdint>
#include <tuple>
#include <utility>
usingnamespacellvm;
namespace llvm {
class MCSubtargetInfo;
}
#define DEBUG_TYPE …
namespace {
stats
}
MCAssembler::MCAssembler(MCContext &Context,
std::unique_ptr<MCAsmBackend> Backend,
std::unique_ptr<MCCodeEmitter> Emitter,
std::unique_ptr<MCObjectWriter> Writer)
: … { … }
void MCAssembler::reset() { … }
bool MCAssembler::registerSection(MCSection &Section) { … }
bool MCAssembler::isThumbFunc(const MCSymbol *Symbol) const { … }
bool MCAssembler::evaluateFixup(const MCFixup &Fixup, const MCFragment *DF,
MCValue &Target, const MCSubtargetInfo *STI,
uint64_t &Value, bool &WasForced) const { … }
uint64_t MCAssembler::computeFragmentSize(const MCFragment &F) const { … }
static uint64_t computeBundlePadding(unsigned BundleSize,
const MCEncodedFragment *F,
uint64_t FOffset, uint64_t FSize) { … }
void MCAssembler::layoutBundle(MCFragment *Prev, MCFragment *F) const { … }
void MCAssembler::ensureValid(MCSection &Sec) const { … }
uint64_t MCAssembler::getFragmentOffset(const MCFragment &F) const { … }
static bool getLabelOffset(const MCAssembler &Asm, const MCSymbol &S,
bool ReportError, uint64_t &Val) { … }
static bool getSymbolOffsetImpl(const MCAssembler &Asm, const MCSymbol &S,
bool ReportError, uint64_t &Val) { … }
bool MCAssembler::getSymbolOffset(const MCSymbol &S, uint64_t &Val) const { … }
uint64_t MCAssembler::getSymbolOffset(const MCSymbol &S) const { … }
const MCSymbol *MCAssembler::getBaseSymbol(const MCSymbol &Symbol) const { … }
uint64_t MCAssembler::getSectionAddressSize(const MCSection &Sec) const { … }
uint64_t MCAssembler::getSectionFileSize(const MCSection &Sec) const { … }
bool MCAssembler::registerSymbol(const MCSymbol &Symbol) { … }
void MCAssembler::writeFragmentPadding(raw_ostream &OS,
const MCEncodedFragment &EF,
uint64_t FSize) const { … }
static void writeFragment(raw_ostream &OS, const MCAssembler &Asm,
const MCFragment &F) { … }
void MCAssembler::writeSectionData(raw_ostream &OS,
const MCSection *Sec) const { … }
std::tuple<MCValue, uint64_t, bool>
MCAssembler::handleFixup(MCFragment &F, const MCFixup &Fixup,
const MCSubtargetInfo *STI) { … }
void MCAssembler::layout() { … }
void MCAssembler::Finish() { … }
bool MCAssembler::fixupNeedsRelaxation(const MCFixup &Fixup,
const MCRelaxableFragment *DF) const { … }
bool MCAssembler::fragmentNeedsRelaxation(const MCRelaxableFragment *F) const { … }
bool MCAssembler::relaxInstruction(MCRelaxableFragment &F) { … }
bool MCAssembler::relaxLEB(MCLEBFragment &LF) { … }
static bool mayCrossBoundary(uint64_t StartAddr, uint64_t Size,
Align BoundaryAlignment) { … }
static bool isAgainstBoundary(uint64_t StartAddr, uint64_t Size,
Align BoundaryAlignment) { … }
static bool needPadding(uint64_t StartAddr, uint64_t Size,
Align BoundaryAlignment) { … }
bool MCAssembler::relaxBoundaryAlign(MCBoundaryAlignFragment &BF) { … }
bool MCAssembler::relaxDwarfLineAddr(MCDwarfLineAddrFragment &DF) { … }
bool MCAssembler::relaxDwarfCallFrameFragment(MCDwarfCallFrameFragment &DF) { … }
bool MCAssembler::relaxCVInlineLineTable(MCCVInlineLineTableFragment &F) { … }
bool MCAssembler::relaxCVDefRange(MCCVDefRangeFragment &F) { … }
bool MCAssembler::relaxPseudoProbeAddr(MCPseudoProbeAddrFragment &PF) { … }
bool MCAssembler::relaxFragment(MCFragment &F) { … }
bool MCAssembler::layoutOnce() { … }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void MCAssembler::dump() const{
raw_ostream &OS = errs();
OS << "<MCAssembler\n";
OS << " Sections:[\n ";
bool First = true;
for (const MCSection &Sec : *this) {
if (First)
First = false;
else
OS << ",\n ";
Sec.dump();
}
OS << "],\n";
OS << " Symbols:[";
First = true;
for (const MCSymbol &Sym : symbols()) {
if (First)
First = false;
else
OS << ",\n ";
OS << "(";
Sym.dump();
OS << ", Index:" << Sym.getIndex() << ", ";
OS << ")";
}
OS << "]>\n";
}
#endif