50#define DEBUG_TYPE "assembler"
55STATISTIC(EmittedFragments,
"Number of emitted assembler fragments - total");
57 "Number of emitted assembler fragments - relaxable");
59 "Number of emitted assembler fragments - data");
60STATISTIC(EmittedCompactEncodedInstFragments,
61 "Number of emitted assembler fragments - compact encoded inst");
63 "Number of emitted assembler fragments - align");
65 "Number of emitted assembler fragments - fill");
66STATISTIC(EmittedNopsFragments,
"Number of emitted assembler fragments - nops");
67STATISTIC(EmittedOrgFragments,
"Number of emitted assembler fragments - org");
68STATISTIC(evaluateFixup,
"Number of evaluated fixups");
69STATISTIC(FragmentLayouts,
"Number of fragment layouts");
70STATISTIC(ObjectBytes,
"Number of emitted object file bytes");
71STATISTIC(RelaxationSteps,
"Number of assembler layout and relaxation steps");
72STATISTIC(RelaxedInstructions,
"Number of relaxed instructions");
85 std::unique_ptr<MCAsmBackend> Backend,
86 std::unique_ptr<MCCodeEmitter>
Emitter,
87 std::unique_ptr<MCObjectWriter> Writer)
90 BundleAlignSize(0), RelaxAll(
false), SubsectionsViaSymbols(
false),
91 IncrementalLinkerCompatible(
false), ELFHeaderEFlags(0) {
92 VersionInfo.Major = 0;
93 DarwinTargetVariantVersionInfo.Major = 0;
101 IndirectSymbols.clear();
103 LinkerOptions.clear();
108 SubsectionsViaSymbols =
false;
109 IncrementalLinkerCompatible =
false;
111 LOHContainer.
reset();
112 VersionInfo.Major = 0;
114 DarwinTargetVariantVersionInfo.Major = 0;
115 DarwinTargetVariantVersionInfo.SDKVersion =
VersionTuple();
128 if (Section.isRegistered())
130 Sections.push_back(&Section);
131 Section.setIsRegistered(
true);
136 if (ThumbFuncs.count(Symbol))
139 if (!Symbol->isVariable())
142 const MCExpr *Expr = Symbol->getVariableValue();
162 ThumbFuncs.insert(Symbol);
168 if (!Symbol.isTemporary())
171 if (Symbol.isUsedInReloc())
188 if (!
getContext().getAsmInfo()->isSectionAtomizableBySymbols(
199 bool &WasForced)
const {
200 ++stats::evaluateFixup;
219 "unsupported subtraction of qualified symbol");
230 STI,
Value, WasForced);
236 bool IsResolved =
false;
240 }
else if (!
Target.getSymA()) {
249 Writer->isSymbolRefDifferenceFullyResolvedImpl(
250 *
this, SA, *
DF,
false,
true);
254 IsResolved =
Target.isAbsolute();
272 assert((ShouldAlignPC ? IsPCRel :
true) &&
273 "FKF_IsAlignedDownTo32Bits is only allowed on PC-relative fixups!");
280 if (ShouldAlignPC)
Offset &= ~0x3;
293 if (!IsResolved &&
Target.getSymA() &&
Target.getSymB() &&
304 switch (
F.getKind()) {
306 return cast<MCDataFragment>(
F).getContents().size();
308 return cast<MCRelaxableFragment>(
F).getContents().size();
310 return cast<MCCompactEncodedInstFragment>(
F).getContents().size();
312 auto &FF = cast<MCFillFragment>(
F);
313 int64_t NumValues = 0;
314 if (!FF.getNumValues().evaluateKnownAbsolute(NumValues, Layout)) {
316 "expected assembly-time absolute expression");
319 int64_t
Size = NumValues * FF.getValueSize();
328 return cast<MCNopsFragment>(
F).getNumBytes();
331 return cast<MCLEBFragment>(
F).getContents().size();
334 return cast<MCBoundaryAlignFragment>(
F).getSize();
366 "expected assembly-time absolute expression");
371 int64_t TargetLocation =
Value.getConstant();
378 TargetLocation += Val;
380 int64_t
Size = TargetLocation - FragmentOffset;
381 if (Size < 0 || Size >= 0x40000000) {
383 OF.
getLoc(),
"invalid .org offset '" +
Twine(TargetLocation) +
384 "' (at offset '" +
Twine(FragmentOffset) +
"')");
391 return cast<MCDwarfLineAddrFragment>(
F).getContents().size();
393 return cast<MCDwarfCallFrameFragment>(
F).getContents().size();
395 return cast<MCCVInlineLineTableFragment>(
F).getContents().size();
397 return cast<MCCVDefRangeFragment>(
F).getContents().size();
399 return cast<MCPseudoProbeAddrFragment>(
F).getContents().size();
411 assert(!isFragmentValid(
F) &&
"Attempt to recompute a valid fragment!");
414 assert((!Prev || isFragmentValid(Prev)) &&
415 "Attempt to compute fragment before its predecessor!");
417 assert(!
F->IsBeingLaidOut &&
"Already being laid out!");
418 F->IsBeingLaidOut =
true;
420 ++stats::FragmentLayouts;
427 F->IsBeingLaidOut =
false;
428 LastValidFragment[
F->getParent()] =
F;
458 assert(isa<MCEncodedFragment>(
F) &&
459 "Only MCEncodedFragment implementations have instructions");
468 if (RequiredBundlePadding > UINT8_MAX)
471 EF->Offset += RequiredBundlePadding;
476 bool Changed = !Symbol.isRegistered();
478 Symbol.setIsRegistered(
true);
479 Symbols.push_back(&Symbol);
490 if (BundlePadding > 0) {
492 "Writing bundle padding with disabled bundling");
494 "Writing bundle padding for a fragment without instructions");
496 unsigned TotalLength = BundlePadding +
static_cast<unsigned>(FSize);
508 if (!
getBackend().writeNopData(
OS, DistanceToBoundary, STI))
510 Twine(DistanceToBoundary) +
" bytes");
511 BundlePadding -= DistanceToBoundary;
515 Twine(BundlePadding) +
" bytes");
523 uint64_t FragmentSize = Asm.computeFragmentSize(Layout,
F);
528 Asm.writeFragmentPadding(
OS, *EF, FragmentSize);
535 ++stats::EmittedFragments;
537 switch (
F.getKind()) {
539 ++stats::EmittedAlignFragments;
551 "' is not a divisor of padding size '" +
552 Twine(FragmentSize) +
"'");
561 Twine(Count) +
" bytes");
566 for (
uint64_t i = 0; i != Count; ++i) {
585 ++stats::EmittedDataFragments;
586 OS << cast<MCDataFragment>(
F).getContents();
590 ++stats::EmittedRelaxableFragments;
591 OS << cast<MCRelaxableFragment>(
F).getContents();
595 ++stats::EmittedCompactEncodedInstFragments;
596 OS << cast<MCCompactEncodedInstFragment>(
F).getContents();
600 ++stats::EmittedFillFragments;
604 const unsigned MaxChunkSize = 16;
605 char Data[MaxChunkSize];
606 assert(0 < VSize && VSize <= MaxChunkSize &&
"Illegal fragment fill size");
609 for (
unsigned I = 0;
I != VSize; ++
I) {
611 Data[
I] = uint8_t(V >> (index * 8));
613 for (
unsigned I = VSize;
I < MaxChunkSize; ++
I)
617 const unsigned NumPerChunk = MaxChunkSize / VSize;
619 const unsigned ChunkSize = VSize * NumPerChunk;
623 for (
uint64_t I = 0,
E = FragmentSize / ChunkSize;
I !=
E; ++
I)
627 unsigned TrailingCount = FragmentSize % ChunkSize;
634 ++stats::EmittedNopsFragments;
639 int64_t MaximumNopLength =
642 assert(NumBytes > 0 &&
"Expected positive NOPs fragment size");
643 assert(ControlledNopLength >= 0 &&
"Expected non-negative NOP size");
645 if (ControlledNopLength > MaximumNopLength) {
646 Asm.getContext().reportError(NF.
getLoc(),
647 "illegal NOP size " +
648 std::to_string(ControlledNopLength) +
649 ". (expected within [0, " +
650 std::to_string(MaximumNopLength) +
"])");
653 ControlledNopLength = MaximumNopLength;
657 if (!ControlledNopLength)
658 ControlledNopLength = MaximumNopLength;
662 (
uint64_t)std::min(NumBytes, ControlledNopLength);
663 assert(NumBytesToEmit &&
"try to emit empty NOP instruction");
664 if (!Asm.getBackend().writeNopData(
OS, NumBytesToEmit,
667 Twine(NumBytesToEmit) +
" bytes");
670 NumBytes -= NumBytesToEmit;
685 Twine(FragmentSize) +
" bytes");
696 ++stats::EmittedOrgFragments;
699 for (
uint64_t i = 0, e = FragmentSize; i != e; ++i)
716 const auto &OF = cast<MCCVInlineLineTableFragment>(
F);
717 OS << OF.getContents();
721 const auto &DRF = cast<MCCVDefRangeFragment>(
F);
722 OS << DRF.getContents();
735 "The stream should advance by fragment size");
748 switch (
F.getKind()) {
755 if (
DF.fixup_begin() !=
DF.fixup_end())
757 " section '" + Sec->getName() +
758 "' cannot have fixups");
759 for (
unsigned i = 0, e =
DF.getContents().size(); i != e; ++i)
760 if (
DF.getContents()[i]) {
762 Sec->getVirtualSectionKind() +
763 " section '" + Sec->getName() +
764 "' cannot have non-zero initializers");
772 assert((cast<MCAlignFragment>(
F).getValueSize() == 0 ||
773 cast<MCAlignFragment>(
F).getValue() == 0) &&
774 "Invalid align in virtual section!");
777 assert((cast<MCFillFragment>(
F).getValue() == 0) &&
778 "Invalid fill in virtual section!");
798std::tuple<MCValue, uint64_t, bool>
806 evaluateFixup(Layout,
Fixup, &
F,
Target, STI, FixedValue, WasForced);
813 return std::make_tuple(
Target, FixedValue, IsResolved);
819 errs() <<
"assembler backend - pre-layout\n--\n";
823 unsigned SectionIndex = 0;
834 for (
unsigned i = 0, e = Layout.
getSectionOrder().size(); i != e; ++i) {
838 unsigned FragmentIndex = 0;
840 Frag.setLayoutOrder(FragmentIndex++);
844 while (layoutOnce(Layout)) {
855 errs() <<
"assembler backend - post-relaxation\n--\n";
859 finishLayout(Layout);
862 errs() <<
"assembler backend - final-layout\n--\n";
877 switch (Frag.getKind()) {
890 Fixups =
DF.getFixups();
891 Contents =
DF.getContents();
892 STI =
DF.getSubtargetInfo();
893 assert(!
DF.hasInstructions() || STI !=
nullptr);
912 Fixups =
DF.getFixups();
913 Contents =
DF.getContents();
918 Fixups =
DF.getFixups();
919 Contents =
DF.getContents();
923 auto &LF = cast<MCLEBFragment>(Frag);
924 Fixups = LF.getFixups();
925 Contents = LF.getContents();
939 std::tie(
Target, FixedValue, IsResolved) =
940 handleFixup(Layout, Frag,
Fixup, STI);
957bool MCAssembler::fixupNeedsRelaxation(
const MCFixup &
Fixup,
965 DF->getSubtargetInfo(),
Value, WasForced);
980 if (!
getBackend().mayNeedRelaxation(
F->getInst(), *
F->getSubtargetInfo()))
984 if (fixupNeedsRelaxation(
Fixup,
F, Layout))
990bool MCAssembler::relaxInstruction(
MCAsmLayout &Layout,
993 "Expected CodeEmitter defined for relaxInstruction");
994 if (!fragmentNeedsRelaxation(&
F, Layout))
997 ++stats::RelaxedInstructions;
1009 F.getFixups().clear();
1010 F.getContents().clear();
1012 *
F.getSubtargetInfo());
1017 const unsigned OldSize =
static_cast<unsigned>(LF.
getContents().
size());
1018 unsigned PadTo = OldSize;
1029 bool Relaxed, UseZeroPad;
1034 "leb128 expression is not absolute");
1062 Align BoundaryAlignment) {
1064 return (StartAddr >>
Log2(BoundaryAlignment)) !=
1065 ((EndAddr - 1) >>
Log2(BoundaryAlignment));
1075 Align BoundaryAlignment) {
1077 return (EndAddr & (BoundaryAlignment.
value() - 1)) == 0;
1087 Align BoundaryAlignment) {
1092bool MCAssembler::relaxBoundaryAlign(
MCAsmLayout &Layout,
1102 F =
F->getPrevNode())
1116bool MCAssembler::relaxDwarfLineAddr(
MCAsmLayout &Layout,
1120 if (
getBackend().relaxDwarfLineAddr(
DF, Layout, WasRelaxed))
1126 bool Abs =
DF.getAddrDelta().evaluateKnownAbsolute(AddrDelta, Layout);
1127 assert(Abs &&
"We created a line delta with an invalid expression");
1130 LineDelta =
DF.getLineDelta();
1133 DF.getFixups().clear();
1137 return OldSize !=
Data.size();
1140bool MCAssembler::relaxDwarfCallFrameFragment(
MCAsmLayout &Layout,
1143 if (
getBackend().relaxDwarfCFA(
DF, Layout, WasRelaxed))
1148 bool Abs =
DF.getAddrDelta().evaluateAsAbsolute(
Value, Layout);
1151 "invalid CFI advance_loc expression");
1159 DF.getFixups().clear();
1162 return OldSize !=
Data.size();
1165bool MCAssembler::relaxCVInlineLineTable(
MCAsmLayout &Layout,
1167 unsigned OldSize =
F.getContents().size();
1169 return OldSize !=
F.getContents().size();
1172bool MCAssembler::relaxCVDefRange(
MCAsmLayout &Layout,
1174 unsigned OldSize =
F.getContents().size();
1176 return OldSize !=
F.getContents().size();
1179bool MCAssembler::relaxPseudoProbeAddr(
MCAsmLayout &Layout,
1184 assert(Abs &&
"We created a pseudo probe with an invalid expression");
1193 return OldSize !=
Data.size();
1197 switch(
F.getKind()) {
1202 "Did not expect a MCRelaxableFragment in RelaxAll mode");
1203 return relaxInstruction(Layout, cast<MCRelaxableFragment>(
F));
1205 return relaxDwarfLineAddr(Layout, cast<MCDwarfLineAddrFragment>(
F));
1207 return relaxDwarfCallFrameFragment(Layout,
1208 cast<MCDwarfCallFrameFragment>(
F));
1210 return relaxLEB(Layout, cast<MCLEBFragment>(
F));
1212 return relaxBoundaryAlign(Layout, cast<MCBoundaryAlignFragment>(
F));
1214 return relaxCVInlineLineTable(Layout, cast<MCCVInlineLineTableFragment>(
F));
1216 return relaxCVDefRange(Layout, cast<MCCVDefRangeFragment>(
F));
1218 return relaxPseudoProbeAddr(Layout, cast<MCPseudoProbeAddrFragment>(
F));
1232 bool RelaxedFrag = relaxFragment(Layout, Frag);
1233 if (RelaxedFrag && !FirstRelaxedFragment)
1234 FirstRelaxedFragment = &Frag;
1236 if (FirstRelaxedFragment) {
1243bool MCAssembler::layoutOnce(
MCAsmLayout &Layout) {
1244 ++stats::RelaxationSteps;
1246 bool WasRelaxed =
false;
1248 while (layoutSectionOnce(Layout, Sec))
1255void MCAssembler::finishLayout(
MCAsmLayout &Layout) {
1258 for (
unsigned int i = 0, n = Layout.
getSectionOrder().size(); i != n; ++i) {
1266#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1270 OS <<
"<MCAssembler\n";
1271 OS <<
" Sections:[\n ";
1273 if (it !=
begin())
OS <<
",\n ";
1283 OS <<
", Index:" << it->getIndex() <<
", ";
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
dxil DXContainer Global Emitter
#define DEBUG_WITH_TYPE(TYPE, X)
DEBUG_WITH_TYPE macro - This macro should be used by passes to emit debug information.
static RegisterPass< DebugifyFunctionPass > DF("debugify-function", "Attach debug info to a function")
static void writeFragment(raw_ostream &OS, const MCAssembler &Asm, const MCAsmLayout &Layout, const MCFragment &F)
Write the fragment F to the output file.
static bool needPadding(uint64_t StartAddr, uint64_t Size, Align BoundaryAlignment)
Check if the branch needs padding.
static bool mayCrossBoundary(uint64_t StartAddr, uint64_t Size, Align BoundaryAlignment)
Check if the branch crosses the boundary.
static bool isAgainstBoundary(uint64_t StartAddr, uint64_t Size, Align BoundaryAlignment)
Check if the branch is against the boundary.
PowerPC TLS Dynamic Call Fixup
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallString class.
This file defines the SmallVector class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
void encodeInlineLineTable(MCAsmLayout &Layout, MCCVInlineLineTableFragment &F)
Encodes the binary annotations once we have a layout.
void encodeDefRange(MCAsmLayout &Layout, MCCVDefRangeFragment &F)
Align getAlignment() const
unsigned getMaxBytesToEmit() const
unsigned getValueSize() const
const MCSubtargetInfo * getSubtargetInfo() const
virtual bool fixupNeedsRelaxationAdvanced(const MCFixup &Fixup, bool Resolved, uint64_t Value, const MCRelaxableFragment *DF, const MCAsmLayout &Layout, const bool WasForced) const
Target specific predicate for whether a given fixup requires the associated instruction to be relaxed...
virtual bool shouldInsertFixupForCodeAlign(MCAssembler &Asm, const MCAsmLayout &Layout, MCAlignFragment &AF)
Hook which indicates if the target requires a fixup to be generated when handling an align directive ...
virtual void relaxInstruction(MCInst &Inst, const MCSubtargetInfo &STI) const
Relax the instruction in the given fragment to the next wider instruction.
virtual void finishLayout(MCAssembler const &Asm, MCAsmLayout &Layout) const
Give backend an opportunity to finish layout after relaxation.
virtual bool evaluateTargetFixup(const MCAssembler &Asm, const MCAsmLayout &Layout, const MCFixup &Fixup, const MCFragment *DF, const MCValue &Target, const MCSubtargetInfo *STI, uint64_t &Value, bool &WasForced)
virtual void reset()
lifetime management
virtual std::pair< bool, bool > relaxLEB128(MCLEBFragment &LF, MCAsmLayout &Layout, int64_t &Value) const
virtual const MCFixupKindInfo & getFixupKindInfo(MCFixupKind Kind) const
Get information on a fixup kind.
virtual void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, const MCValue &Target, MutableArrayRef< char > Data, uint64_t Value, bool IsResolved, const MCSubtargetInfo *STI) const =0
Apply the Value for given Fixup into the provided data fragment, at the offset specified by the fixup...
Encapsulates the layout of an assembly file at a particular point in time.
void invalidateFragmentsFrom(MCFragment *F)
Invalidate the fragments starting with F because it has been resized.
uint64_t getSectionAddressSize(const MCSection *Sec) const
Get the address space size of the given section, as it effects layout.
llvm::SmallVectorImpl< MCSection * > & getSectionOrder()
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.
void layoutFragment(MCFragment *Fragment)
Perform layout for a single fragment, assuming that the previous fragment has already been laid out c...
uint64_t getFragmentOffset(const MCFragment *F) const
Get the offset of the given fragment inside its containing section.
MCAssembler & getAssembler() const
Get the assembler object this is a layout for.
MCContext & getContext() const
void Finish()
Finish - Do final processing and write the object to the output stream.
void writeSectionData(raw_ostream &OS, const MCSection *Section, const MCAsmLayout &Layout) const
Emit the section contents to OS.
unsigned getBundleAlignSize() const
bool isBundlingEnabled() const
symbol_iterator symbol_begin()
bool getSubsectionsViaSymbols() const
void layout(MCAsmLayout &Layout)
MCObjectWriter * getWriterPtr() const
MCObjectWriter & getWriter() const
uint64_t computeFragmentSize(const MCAsmLayout &Layout, const MCFragment &F) const
Compute the effective fragment size assuming it is laid out at the given SectionAddress and FragmentO...
MCCodeEmitter * getEmitterPtr() const
MCCodeEmitter & getEmitter() const
MCAssembler(MCContext &Context, std::unique_ptr< MCAsmBackend > Backend, std::unique_ptr< MCCodeEmitter > Emitter, std::unique_ptr< MCObjectWriter > Writer)
Construct a new assembler instance.
bool isThumbFunc(const MCSymbol *Func) const
Check whether a given symbol has been flagged with .thumb_func.
MCAsmBackend & getBackend() const
bool registerSection(MCSection &Section)
const MCSymbol * getAtom(const MCSymbol &S) const
Find the symbol which defines the atom containing the given symbol, or null if there is no such symbo...
MCAsmBackend * getBackendPtr() const
bool isSymbolLinkerVisible(const MCSymbol &SD) const
Check whether a particular symbol is visible to the linker and is required in the symbol table,...
MCLOHContainer & getLOHContainer()
symbol_iterator symbol_end()
void reset()
Reuse an assembler instance.
bool registerSymbol(const MCSymbol &Symbol)
MCDwarfLineTableParams getDWARFLinetableParams() const
void writeFragmentPadding(raw_ostream &OS, const MCEncodedFragment &F, uint64_t FSize) const
Write the necessary bundle padding to OS.
Represents required padding such that a particular other set of fragments does not cross a particular...
void setSize(uint64_t Value)
const MCFragment * getLastFragment() const
const MCSubtargetInfo * getSubtargetInfo() const
Align getAlignment() const
Fragment representing the .cv_def_range directive.
Fragment representing the binary annotations produced by the .cv_inline_linetable directive.
virtual void encodeInstruction(const MCInst &Inst, SmallVectorImpl< char > &CB, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const =0
Encode the given Inst to bytes and append to CB.
virtual void reset()
Lifetime management.
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Context object for machine code objects.
CodeViewContext & getCVContext()
void reportError(SMLoc L, const Twine &Msg)
Fragment for data and encoded instructions.
static void encodeAdvanceLoc(MCContext &Context, uint64_t AddrDelta, SmallVectorImpl< char > &OS)
static void encode(MCContext &Context, MCDwarfLineTableParams Params, int64_t LineDelta, uint64_t AddrDelta, SmallVectorImpl< char > &OS)
Utility function to encode a Dwarf pair of LineDelta and AddrDeltas.
SmallVectorImpl< char > & getContents()
SmallVectorImpl< MCFixup > & getFixups()
Interface implemented by fragments that contain encoded instructions and/or data.
const MCSubtargetInfo * getSubtargetInfo() const
Retrieve the MCSubTargetInfo in effect when the instruction was encoded.
void setBundlePadding(uint8_t N)
Set the padding size for this fragment.
uint8_t getBundlePadding() const
Get the padding size that must be inserted before this fragment.
bool alignToBundleEnd() const
Should this fragment be placed at the end of an aligned bundle?
Base class for the full range of assembler expressions which are needed for parsing.
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.
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.
uint8_t getValueSize() const
uint64_t getValue() const
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
const MCSymbol * getAtom() const
MCSection * getParent() const
bool hasInstructions() const
Does this fragment have instructions emitted into it? By default this is false, but specific fragment...
Instances of this class represent a single low-level machine instruction.
const MCExpr & getValue() const
void setValue(const MCExpr *Expr)
int64_t getControlledNopLength() const
int64_t getNumBytes() const
const MCSubtargetInfo * getSubtargetInfo() const
virtual uint64_t writeObject(MCAssembler &Asm, const MCAsmLayout &Layout)=0
Write the object file and returns the number of bytes written.
virtual void executePostLayoutBinding(MCAssembler &Asm, const MCAsmLayout &Layout)=0
Perform any late binding of symbols (for example, to assign symbol indices for use when generating re...
virtual void reset()
lifetime management
virtual void recordRelocation(MCAssembler &Asm, const MCAsmLayout &Layout, const MCFragment *Fragment, const MCFixup &Fixup, MCValue Target, uint64_t &FixedValue)=0
Record a relocation entry.
const MCExpr & getOffset() const
const MCExpr & getAddrDelta() const
A relaxable fragment holds on to its MCInst, since it may need to be relaxed during the assembler lay...
Instances of this class represent a uniqued identifier for a section in the current translation unit.
void setLayoutOrder(unsigned Value)
MCSection::FragmentListType & getFragmentList()
virtual bool isVirtualSection() const =0
Check whether this section is "virtual", that is has no actual object file contents.
void setOrdinal(unsigned Value)
virtual bool useCodeAlign() const =0
Return true if a .align directive should use "optimized nops" to fill instead of 0s.
Generic base class for all target subtargets.
Represents a symbol table index fragment.
const MCSymbol * getSymbol()
Represent a reference to a symbol from inside an expression.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
bool isInSection() const
isInSection - Check if this symbol is defined in some section (i.e., it is defined but not absolute).
bool isUndefined(bool SetUsed=true) const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
uint32_t getIndex() const
Get the (implementation defined) index.
MCFragment * getFragment(bool SetUsed=true) const
This represents an "assembler immediate".
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Represents a location in source code.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
StringRef - Represent a constant reference to a string, i.e.
Target - Wrapper for Target specific information.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM Value Representation.
Represents a version number in the form major[.minor[.subminor[.build]]].
This class implements an extremely fast bulk output stream that can only output to a stream.
uint64_t tell() const
tell - Return the current offset with the file.
raw_ostream & write(unsigned char C)
A raw_ostream that writes to an SmallVector or SmallString.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
@ FK_Data_1
A one-byte fixup.
uint64_t computeBundlePadding(const MCAssembler &Assembler, const MCEncodedFragment *F, uint64_t FOffset, uint64_t FSize)
Compute the amount of padding required before the fragment F to obey bundling restrictions,...
uint64_t offsetToAlignment(uint64_t Value, Align Alignment)
Returns the offset to the next integer (mod 2**64) that is greater than or equal to Value and is a mu...
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
@ Ref
The access may reference the value stored in memory.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
unsigned encodeSLEB128(int64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a SLEB128 value to an output stream.
unsigned encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a ULEB128 value to an output stream.
unsigned Log2(Align A)
Returns the log2 of the alignment.
Implement std::hash so that hash_code can be used in STL containers.
This struct is a compact representation of a valid (non-zero power of two) alignment.
uint64_t value() const
This is a hole in the type system and should not be abused.
@ FKF_IsTarget
Should this fixup be evaluated in a target dependent manner?
@ FKF_IsAlignedDownTo32Bits
Should this fixup kind force a 4-byte aligned effective PC value?
@ FKF_Constant
This fixup kind should be resolved if defined.
@ FKF_IsPCRel
Is this fixup kind PCrelative? This is used by the assembler backend to evaluate fixup values in a ta...
unsigned Flags
Flags describing additional information on this fixup kind.
An iterator type that allows iterating over the pointees via some other iterator.