Go to the documentation of this file.
50 #define DEBUG_TYPE "assembler"
55 STATISTIC(EmittedFragments,
"Number of emitted assembler fragments - total");
57 "Number of emitted assembler fragments - relaxable");
59 "Number of emitted assembler fragments - data");
60 STATISTIC(EmittedCompactEncodedInstFragments,
61 "Number of emitted assembler fragments - compact encoded inst");
63 "Number of emitted assembler fragments - align");
65 "Number of emitted assembler fragments - fill");
66 STATISTIC(EmittedNopsFragments,
"Number of emitted assembler fragments - nops");
67 STATISTIC(EmittedOrgFragments,
"Number of emitted assembler fragments - org");
68 STATISTIC(evaluateFixup,
"Number of evaluated fixups");
69 STATISTIC(FragmentLayouts,
"Number of fragment layouts");
70 STATISTIC(ObjectBytes,
"Number of emitted object file bytes");
71 STATISTIC(RelaxationSteps,
"Number of assembler layout and relaxation steps");
72 STATISTIC(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())
162 ThumbFuncs.insert(
Symbol);
168 if (!
Symbol.isTemporary())
171 if (
Symbol.isUsedInReloc())
183 if (!
S.isInSection())
188 if (!
getContext().getAsmInfo()->isSectionAtomizableBySymbols(
189 *
S.getFragment()->getParent()))
193 return S.getFragment()->getAtom();
196 bool MCAssembler::evaluateFixup(
const MCAsmLayout &Layout,
199 bool &WasForced)
const {
200 ++stats::evaluateFixup;
219 "unsupported subtraction of qualified symbol");
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;
285 if (IsResolved &&
getBackend().shouldForceRelocation(*
this, Fixup,
Target)) {
296 switch (
F.getKind()) {
298 return cast<MCDataFragment>(
F).getContents().size();
300 return cast<MCRelaxableFragment>(
F).getContents().size();
302 return cast<MCCompactEncodedInstFragment>(
F).getContents().size();
304 auto &FF = cast<MCFillFragment>(
F);
305 int64_t NumValues = 0;
306 if (!FF.getNumValues().evaluateAsAbsolute(NumValues, Layout)) {
308 "expected assembly-time absolute expression");
311 int64_t Size = NumValues * FF.getValueSize();
320 return cast<MCNopsFragment>(
F).getNumBytes();
323 return cast<MCLEBFragment>(
F).getContents().size();
326 return cast<MCBoundaryAlignFragment>(
F).getSize();
339 getBackend().shouldInsertExtraNopBytesForCodeAlign(AF, Size))
345 while (Size %
getBackend().getMinimumNopSize())
358 "expected assembly-time absolute expression");
363 int64_t TargetLocation =
Value.getConstant();
370 TargetLocation += Val;
372 int64_t Size = TargetLocation - FragmentOffset;
373 if (Size < 0 || Size >= 0x40000000) {
375 OF.
getLoc(),
"invalid .org offset '" +
Twine(TargetLocation) +
376 "' (at offset '" +
Twine(FragmentOffset) +
"')");
383 return cast<MCDwarfLineAddrFragment>(
F).getContents().size();
385 return cast<MCDwarfCallFrameFragment>(
F).getContents().size();
387 return cast<MCCVInlineLineTableFragment>(
F).getContents().size();
389 return cast<MCCVDefRangeFragment>(
F).getContents().size();
391 return cast<MCPseudoProbeAddrFragment>(
F).getContents().size();
403 assert(!isFragmentValid(
F) &&
"Attempt to recompute a valid fragment!");
406 assert((!Prev || isFragmentValid(Prev)) &&
407 "Attempt to compute fragment before its predecessor!");
409 assert(!
F->IsBeingLaidOut &&
"Already being laid out!");
410 F->IsBeingLaidOut =
true;
412 ++stats::FragmentLayouts;
419 F->IsBeingLaidOut =
false;
420 LastValidFragment[
F->getParent()] =
F;
450 assert(isa<MCEncodedFragment>(
F) &&
451 "Only MCEncodedFragment implementations have instructions");
460 if (RequiredBundlePadding > UINT8_MAX)
463 EF->Offset += RequiredBundlePadding;
468 bool New = !
Symbol.isRegistered();
472 Symbol.setIsRegistered(
true);
473 Symbols.push_back(&
Symbol);
483 if (BundlePadding > 0) {
485 "Writing bundle padding with disabled bundling");
487 "Writing bundle padding for a fragment without instructions");
489 unsigned TotalLength = BundlePadding +
static_cast<unsigned>(FSize);
501 if (!
getBackend().writeNopData(OS, DistanceToBoundary, STI))
503 Twine(DistanceToBoundary) +
" bytes");
504 BundlePadding -= DistanceToBoundary;
506 if (!
getBackend().writeNopData(OS, BundlePadding, STI))
508 Twine(BundlePadding) +
" bytes");
516 uint64_t FragmentSize =
Asm.computeFragmentSize(Layout,
F);
521 Asm.writeFragmentPadding(OS, *EF, FragmentSize);
528 ++stats::EmittedFragments;
530 switch (
F.getKind()) {
532 ++stats::EmittedAlignFragments;
544 "' is not a divisor of padding size '" +
545 Twine(FragmentSize) +
"'");
554 Twine(Count) +
" bytes");
562 case 1: OS << char(AF.
getValue());
break;
564 support::endian::write<uint16_t>(OS, AF.
getValue(), Endian);
567 support::endian::write<uint32_t>(OS, AF.
getValue(), Endian);
570 support::endian::write<uint64_t>(OS, AF.
getValue(), Endian);
578 ++stats::EmittedDataFragments;
579 OS << cast<MCDataFragment>(
F).getContents();
583 ++stats::EmittedRelaxableFragments;
584 OS << cast<MCRelaxableFragment>(
F).getContents();
588 ++stats::EmittedCompactEncodedInstFragments;
589 OS << cast<MCCompactEncodedInstFragment>(
F).getContents();
593 ++stats::EmittedFillFragments;
597 const unsigned MaxChunkSize = 16;
598 char Data[MaxChunkSize];
599 assert(0 < VSize && VSize <= MaxChunkSize &&
"Illegal fragment fill size");
602 for (
unsigned I = 0;
I != VSize; ++
I) {
606 for (
unsigned I = VSize;
I < MaxChunkSize; ++
I)
610 const unsigned NumPerChunk = MaxChunkSize / VSize;
612 const unsigned ChunkSize = VSize * NumPerChunk;
616 for (
uint64_t I = 0,
E = FragmentSize / ChunkSize;
I !=
E; ++
I)
620 unsigned TrailingCount = FragmentSize % ChunkSize;
627 ++stats::EmittedNopsFragments;
632 int64_t MaximumNopLength =
635 assert(NumBytes > 0 &&
"Expected positive NOPs fragment size");
636 assert(ControlledNopLength >= 0 &&
"Expected non-negative NOP size");
638 if (ControlledNopLength > MaximumNopLength) {
639 Asm.getContext().reportError(NF.
getLoc(),
640 "illegal NOP size " +
642 ". (expected within [0, " +
646 ControlledNopLength = MaximumNopLength;
650 if (!ControlledNopLength)
651 ControlledNopLength = MaximumNopLength;
656 assert(NumBytesToEmit &&
"try to emit empty NOP instruction");
657 if (!
Asm.getBackend().writeNopData(OS, NumBytesToEmit,
660 Twine(NumBytesToEmit) +
" bytes");
663 NumBytes -= NumBytesToEmit;
678 Twine(FragmentSize) +
" bytes");
689 ++stats::EmittedOrgFragments;
709 const auto &OF = cast<MCCVInlineLineTableFragment>(
F);
710 OS << OF.getContents();
714 const auto &DRF = cast<MCCVDefRangeFragment>(
F);
715 OS << DRF.getContents();
728 "The stream should advance by fragment size");
741 switch (
F.getKind()) {
748 if (
DF.fixup_begin() !=
DF.fixup_end())
750 " section '" + Sec->getName() +
751 "' cannot have fixups");
752 for (
unsigned i = 0,
e =
DF.getContents().size();
i !=
e; ++
i)
753 if (
DF.getContents()[
i]) {
755 Sec->getVirtualSectionKind() +
756 " section '" + Sec->getName() +
757 "' cannot have non-zero initializers");
765 assert((cast<MCAlignFragment>(
F).getValueSize() == 0 ||
766 cast<MCAlignFragment>(
F).getValue() == 0) &&
767 "Invalid align in virtual section!");
770 assert((cast<MCFillFragment>(
F).getValue() == 0) &&
771 "Invalid fill in virtual section!");
791 std::tuple<MCValue, uint64_t, bool>
798 bool IsResolved = evaluateFixup(Layout, Fixup, &
F,
Target, FixedValue,
806 return std::make_tuple(
Target, FixedValue, IsResolved);
812 errs() <<
"assembler backend - pre-layout\n--\n";
816 unsigned SectionIndex = 0;
831 unsigned FragmentIndex = 0;
833 Frag.setLayoutOrder(FragmentIndex++);
837 while (layoutOnce(Layout)) {
848 errs() <<
"assembler backend - post-relaxation\n--\n";
852 finishLayout(Layout);
855 errs() <<
"assembler backend - final-layout\n--\n";
870 switch (Frag.getKind()) {
884 Contents =
DF.getContents();
885 STI =
DF.getSubtargetInfo();
886 assert(!
DF.hasInstructions() || STI !=
nullptr);
906 Contents =
DF.getContents();
912 Contents =
DF.getContents();
926 std::tie(
Target, FixedValue, IsResolved) =
927 handleFixup(Layout, Frag,
Fixup);
944 bool MCAssembler::fixupNeedsRelaxation(
const MCFixup &Fixup,
951 bool Resolved = evaluateFixup(Layout, Fixup,
DF,
Target,
Value, WasForced);
966 if (!
getBackend().mayNeedRelaxation(
F->getInst(), *
F->getSubtargetInfo()))
969 for (
const MCFixup &Fixup :
F->getFixups())
970 if (fixupNeedsRelaxation(Fixup,
F, Layout))
976 bool MCAssembler::relaxInstruction(
MCAsmLayout &Layout,
979 "Expected CodeEmitter defined for relaxInstruction");
980 if (!fragmentNeedsRelaxation(&
F, Layout))
983 ++stats::RelaxedInstructions;
1004 F.getContents() =
Code;
1037 Align BoundaryAlignment) {
1038 uint64_t EndAddr = StartAddr + Size;
1039 return (StartAddr >>
Log2(BoundaryAlignment)) !=
1040 ((EndAddr - 1) >>
Log2(BoundaryAlignment));
1050 Align BoundaryAlignment) {
1051 uint64_t EndAddr = StartAddr + Size;
1052 return (EndAddr & (BoundaryAlignment.
value() - 1)) == 0;
1062 Align BoundaryAlignment) {
1067 bool MCAssembler::relaxBoundaryAlign(
MCAsmLayout &Layout,
1077 F =
F->getPrevNode())
1091 bool MCAssembler::relaxDwarfLineAddr(
MCAsmLayout &Layout,
1095 if (
getBackend().relaxDwarfLineAddr(
DF, Layout, WasRelaxed))
1101 bool Abs =
DF.getAddrDelta().evaluateKnownAbsolute(AddrDelta, Layout);
1102 assert(Abs &&
"We created a line delta with an invalid expression");
1105 LineDelta =
DF.getLineDelta();
1109 DF.getFixups().clear();
1113 return OldSize !=
Data.size();
1116 bool MCAssembler::relaxDwarfCallFrameFragment(
MCAsmLayout &Layout,
1119 if (
getBackend().relaxDwarfCFA(
DF, Layout, WasRelaxed))
1125 bool Abs =
DF.getAddrDelta().evaluateKnownAbsolute(AddrDelta, Layout);
1126 assert(Abs &&
"We created call frame with an invalid expression");
1131 DF.getFixups().clear();
1134 return OldSize !=
Data.size();
1137 bool MCAssembler::relaxCVInlineLineTable(
MCAsmLayout &Layout,
1139 unsigned OldSize =
F.getContents().size();
1141 return OldSize !=
F.getContents().size();
1144 bool MCAssembler::relaxCVDefRange(
MCAsmLayout &Layout,
1146 unsigned OldSize =
F.getContents().size();
1148 return OldSize !=
F.getContents().size();
1151 bool MCAssembler::relaxPseudoProbeAddr(
MCAsmLayout &Layout,
1156 assert(Abs &&
"We created a pseudo probe with an invalid expression");
1165 return OldSize !=
Data.size();
1169 switch(
F.getKind()) {
1174 "Did not expect a MCRelaxableFragment in RelaxAll mode");
1175 return relaxInstruction(Layout, cast<MCRelaxableFragment>(
F));
1177 return relaxDwarfLineAddr(Layout, cast<MCDwarfLineAddrFragment>(
F));
1179 return relaxDwarfCallFrameFragment(Layout,
1180 cast<MCDwarfCallFrameFragment>(
F));
1182 return relaxLEB(Layout, cast<MCLEBFragment>(
F));
1184 return relaxBoundaryAlign(Layout, cast<MCBoundaryAlignFragment>(
F));
1186 return relaxCVInlineLineTable(Layout, cast<MCCVInlineLineTableFragment>(
F));
1188 return relaxCVDefRange(Layout, cast<MCCVDefRangeFragment>(
F));
1190 return relaxPseudoProbeAddr(Layout, cast<MCPseudoProbeAddrFragment>(
F));
1204 bool RelaxedFrag = relaxFragment(Layout, Frag);
1205 if (RelaxedFrag && !FirstRelaxedFragment)
1206 FirstRelaxedFragment = &Frag;
1208 if (FirstRelaxedFragment) {
1215 bool MCAssembler::layoutOnce(
MCAsmLayout &Layout) {
1216 ++stats::RelaxationSteps;
1218 bool WasRelaxed =
false;
1220 while (layoutSectionOnce(Layout, Sec))
1227 void MCAssembler::finishLayout(
MCAsmLayout &Layout) {
1238 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1242 OS <<
"<MCAssembler\n";
1243 OS <<
" Sections:[\n ";
1245 if (
it !=
begin()) OS <<
",\n ";
1255 OS <<
", Index:" <<
it->getIndex() <<
", ";
MCAsmBackend & getBackend() const
static void writeFragment(raw_ostream &OS, const MCAssembler &Asm, const MCAsmLayout &Layout, const MCFragment &F)
Write the fragment F to the output file.
uint64_t tell() const
tell - Return the current offset with the file.
const MCSubtargetInfo * getSubtargetInfo() const
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
This is an optimization pass for GlobalISel generic memory operations.
void Finish()
Finish - Do final processing and write the object to the output stream.
A relaxable fragment holds on to its MCInst, since it may need to be relaxed during the assembler lay...
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Align getAlignment() const
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.
into xmm2 addss xmm2 xmm1 xmm3 addss xmm3 movaps xmm0 unpcklps xmm0 ret seems silly when it could just be one addps Expand libm rounding functions main should enable SSE DAZ mode and other fast SSE modes Think about doing i64 math in SSE regs on x86 This testcase should have no SSE instructions in it
virtual const MCFixupKindInfo & getFixupKindInfo(MCFixupKind Kind) const
Get information on a fixup kind.
Fragment representing the binary annotations produced by the .cv_inline_linetable directive.
void registerSymbol(const MCSymbol &Symbol, bool *Created=nullptr)
CodeViewContext & getCVContext()
Context object for machine code objects.
void setSize(uint64_t Value)
Target - Wrapper for Target specific information.
@ FKF_Constant
This fixup kind should be resolved if defined.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
bool isUndefined(bool SetUsed=true) const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
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...
bool isDefined() const
isDefined - Check if this symbol is defined (i.e., it has an address).
void reset()
Reuse an assembler instance.
static bool mayCrossBoundary(uint64_t StartAddr, uint64_t Size, Align BoundaryAlignment)
Check if the branch crosses the boundary.
static void EncodeAdvanceLoc(MCContext &Context, uint64_t AddrDelta, raw_ostream &OS)
MCSection * getParent() const
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...
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
Instances of this class represent a single low-level machine instruction.
SmallVectorImpl< MCFixup > & getFixups()
@ FKF_IsAlignedDownTo32Bits
Should this fixup kind force a 4-byte aligned effective PC value?
void writeSectionData(raw_ostream &OS, const MCSection *Section, const MCAsmLayout &Layout) const
Emit the section contents to OS.
bool alignToBundleEnd() const
Should this fragment be placed at the end of an aligned bundle?
MCSection::FragmentListType & getFragmentList()
bool isThumbFunc(const MCSymbol *Func) const
Check whether a given symbol has been flagged with .thumb_func.
bool evaluateAsRelocatable(MCValue &Res, const MCAsmLayout *Layout, const MCFixup *Fixup) const
Try to evaluate the expression to a relocatable value, i.e.
virtual void finishLayout(MCAssembler const &Asm, MCAsmLayout &Layout) const
Give backend an opportunity to finish layout after relaxation.
unsigned getMaxBytesToEmit() const
Align getAlignment() const
symbol_iterator symbol_begin()
#define DEBUG_WITH_TYPE(TYPE, X)
DEBUG_WITH_TYPE macro - This macro should be used by passes to emit debug information.
Represents a location in source code.
void invalidateFragmentsFrom(MCFragment *F)
Invalidate the fragments starting with F because it has been resized.
@ Ref
The access may reference the value stored in memory.
unsigned encodeSLEB128(int64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a SLEB128 value to an output stream.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
MCContext & getContext() const
void encodeDefRange(MCAsmLayout &Layout, MCCVDefRangeFragment &F)
SmallString< 8 > & getContents()
unsigned Log2(Align A)
Returns the log2 of the alignment.
Represents a symbol table index fragment.
void setLayoutOrder(unsigned Value)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
raw_ostream & write(unsigned char C)
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
STATISTIC(NumFunctions, "Total number of functions")
This class implements an extremely fast bulk output stream that can only output to a stream.
void layoutFragment(MCFragment *Fragment)
Perform layout for a single fragment, assuming that the previous fragment has already been laid out c...
Represents a version number in the form major[.minor[.subminor[.build]]].
bool evaluateKnownAbsolute(int64_t &Res, const MCAsmLayout &Layout) const
virtual void recordRelocation(MCAssembler &Asm, const MCAsmLayout &Layout, const MCFragment *Fragment, const MCFixup &Fixup, MCValue Target, uint64_t &FixedValue)=0
Record a relocation entry.
MCCodeEmitter * getEmitterPtr() const
virtual void reset()
lifetime management
const MCSymbolRefExpr * getSymA() const
This struct is a compact representation of a valid (non-zero power of two) alignment.
bool hasInstructions() const
Does this fragment have instructions emitted into it? By default this is false, but specific fragment...
unsigned Flags
Flags describing additional information on this fixup kind.
static RegisterPass< DebugifyFunctionPass > DF("debugify-function", "Attach debug info to a function")
uint32_t getIndex() const
Get the (implementation defined) index.
static void Encode(MCContext &Context, MCDwarfLineTableParams Params, int64_t LineDelta, uint64_t AddrDelta, raw_ostream &OS)
Utility function to encode a Dwarf pair of LineDelta and AddrDeltas.
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.
MCObjectWriter * getWriterPtr() const
Interface implemented by fragments that contain encoded instructions and/or data.
MCCodeEmitter & getEmitter() const
unsigned getValueSize() const
void encodeInlineLineTable(MCAsmLayout &Layout, MCCVInlineLineTableFragment &F)
Encodes the binary annotations once we have a layout.
void setBundlePadding(uint8_t N)
Set the padding size for this fragment.
@ FKF_IsPCRel
Is this fixup kind PCrelative? This is used by the assembler backend to evaluate fixup values in a ta...
symbol_iterator symbol_end()
unsigned getBundleAlignSize() const
const MCFragment * getLastFragment() const
bool isSymbolLinkerVisible(const MCSymbol &SD) const
Check whether a particular symbol is visible to the linker and is required in the symbol table,...
MCAssembler(MCContext &Context, std::unique_ptr< MCAsmBackend > Backend, std::unique_ptr< MCCodeEmitter > Emitter, std::unique_ptr< MCObjectWriter > Writer)
Construct a new assembler instance.
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 ...
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...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
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...
void reportError(SMLoc L, const Twine &Msg)
@ FK_Data_1
A one-byte fixup.
const MCExpr & getAddrDelta() const
Represent a reference to a symbol from inside an expression.
@ FKF_IsTarget
Should this fixup be evaluated in a target dependent manner?
uint64_t getValue() const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Expected< ExpressionValue > min(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
PowerPC TLS Dynamic Call Fixup
StringRef - Represent a constant reference to a string, i.e.
virtual bool isVirtualSection() const =0
Check whether this section is "virtual", that is has no actual object file contents.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const MCExpr & getValue() const
virtual void relaxInstruction(MCInst &Inst, const MCSubtargetInfo &STI) const
Relax the instruction in the given fragment to the next wider instruction.
Instances of this class represent a uniqued identifier for a section in the current translation unit.
const MCSymbol * getSymbol()
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
uint64_t getFragmentOffset(const MCFragment *F) const
Get the offset of the given fragment inside its containing section.
void layout(MCAsmLayout &Layout)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static bool needPadding(uint64_t StartAddr, uint64_t Size, Align BoundaryAlignment)
Check if the branch needs padding.
virtual void reset()
Lifetime management.
virtual bool useCodeAlign() const =0
Return true if a .align directive should use "optimized nops" to fill instead of 0s.
virtual void reset()
lifetime management
virtual bool evaluateTargetFixup(const MCAssembler &Asm, const MCAsmLayout &Layout, const MCFixup &Fixup, const MCFragment *DF, const MCValue &Target, uint64_t &Value, bool &WasForced)
Encapsulates the layout of an assembly file at a particular point in time.
static bool isAgainstBoundary(uint64_t StartAddr, uint64_t Size, Align BoundaryAlignment)
Check if the branch is against the boundary.
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...
uint64_t value() const
This is a hole in the type system and should not be abused.
MCLOHContainer & getLOHContainer()
const MCSubtargetInfo * getSubtargetInfo() const
Retrieve the MCSubTargetInfo in effect when the instruction was encoded.
int64_t getNumBytes() const
uint32_t getRefKind() const
bool getSymbolOffset(const MCSymbol &S, uint64_t &Val) const
Get the offset of the given symbol, as computed in the current layout.
uint8_t getBundlePadding() const
Get the padding size that must be inserted before this fragment.
virtual uint64_t writeObject(MCAssembler &Asm, const MCAsmLayout &Layout)=0
Write the object file and returns the number of bytes written.
const MCSubtargetInfo * getSubtargetInfo() const
bool registerSection(MCSection &Section)
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,...
const MCSubtargetInfo * getSubtargetInfo() const
std::string to_string(const T &Value)
A raw_ostream that writes to an SmallVector or SmallString.
unsigned encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a ULEB128 value to an output stream.
void writeFragmentPadding(raw_ostream &OS, const MCEncodedFragment &F, uint64_t FSize) const
Write the necessary bundle padding to OS.
uint8_t getValueSize() const
MCAssembler & getAssembler() const
Get the assembler object this is a layout for.
This represents an "assembler immediate".
MCAsmBackend * getBackendPtr() const
An iterator type that allows iterating over the pointees via some other iterator.
uint64_t getSectionAddressSize(const MCSection *Sec) const
Get the address space size of the given section, as it effects layout.
MCDwarfLineTableParams getDWARFLinetableParams() const
The same transformation can work with an even modulo with the addition of a and shrink the compare RHS by the same amount Unless the target supports that transformation probably isn t worthwhile The transformation can also easily be made to work with non zero equality for n
Fragment for data and encoded instructions.
bool isBundlingEnabled() const
Generic base class for all target subtargets.
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Fragment representing the .cv_def_range directive.
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...
LLVM Value Representation.
const MCExpr & getOffset() const
Base class for the full range of assembler expressions which are needed for parsing.
const MCSymbolRefExpr * getSymB() const
SmallVectorImpl< char > & getContents()
int64_t getControlledNopLength() const
virtual void encodeInstruction(const MCInst &Inst, raw_ostream &OS, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const =0
EncodeInstruction - Encode the given Inst to bytes on the output stream OS.
void setOrdinal(unsigned Value)
Represents required padding such that a particular other set of fragments does not cross a particular...
MCObjectWriter & getWriter() const