LLVM 24.0.0git
MCSection.h
Go to the documentation of this file.
1//===- MCSection.h - Machine Code Sections ----------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file declares the MCSection class.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_MC_MCSECTION_H
14#define LLVM_MC_MCSECTION_H
15
16#include "llvm/ADT/ArrayRef.h"
17#include "llvm/ADT/DenseMap.h"
20#include "llvm/MC/MCFixup.h"
21#include "llvm/MC/MCInst.h"
22#include "llvm/MC/SectionKind.h"
25#include <cassert>
26#include <utility>
27
28namespace llvm {
29
30class MCAssembler;
31class MCContext;
32class MCExpr;
33class MCFragment;
35class MCSymbol;
36class MCSection;
37class MCSubtargetInfo;
38
39// Represents a contiguous piece of code or data within a section. Its size is
40// determined by MCAssembler::layout. All subclasses must have trivial
41// destructors.
43 friend class MCAssembler;
44 friend class MCStreamer;
45 friend class MCObjectStreamer;
46 friend class MCSection;
47
48public:
66
67private:
68 // The next fragment within the section.
69 MCFragment *Next = nullptr;
70
71 /// The data for the section this fragment is in.
72 MCSection *Parent = nullptr;
73
74 /// The offset of this fragment in its section.
75 uint64_t Offset = 0;
76
77 /// The layout order of this fragment.
78 unsigned LayoutOrder = 0;
79
80 FragmentType Kind;
81
82 //== Used by certain fragment types for better packing.
83
84 // The number of fixups for the optional variable-size tail must be small.
85 uint8_t VarFixupSize = 0;
86
87 bool LinkerRelaxable : 1;
88
89 /// FT_Data, FT_Relaxable
90 bool HasInstructions : 1;
91 /// FT_Relaxable, x86-specific
92 bool AllowAutoPadding : 1;
93
94 // Track content and fixups for the fixed-size part as fragments are
95 // appended to the section. The content is stored as trailing data of the
96 // MCFragment. The content remains immutable, except when modified by
97 // applyFixup.
98 uint32_t FixedSize = 0;
99 uint32_t FixupStart = 0;
100 uint32_t FixupEnd = 0;
101
102 // Track content and fixups for the optional variable-size tail part,
103 // typically modified during relaxation.
104 uint32_t VarContentStart = 0;
105 uint32_t VarContentEnd = 0;
106 uint32_t VarFixupStart = 0;
107
108protected:
109 const MCSubtargetInfo *STI = nullptr;
110
111private:
112 // Optional variable-size tail used by various fragment types.
113 union Tail {
114 struct {
115 uint32_t Opcode;
116 uint32_t Flags;
117 uint32_t OperandStart;
118 uint32_t OperandSize;
119 } relax;
120 struct {
121 // The alignment to ensure, in bytes.
122 Align Alignment;
123 // The size of the integer (in bytes) of \p Value.
124 uint8_t FillLen;
125 // If true, fill with target-specific nop instructions.
126 bool EmitNops;
127 // The maximum number of bytes to emit; if the alignment
128 // cannot be satisfied in this width then this fragment is ignored.
129 unsigned MaxBytesToEmit;
130 // Value to use for filling padding bytes.
131 int64_t Fill;
132 } align;
133 struct {
134 // Symbol denoting the end of the region; always non-null.
135 const MCSymbol *End;
136 // The preferred (maximum) alignment.
137 Align PreferredAlign;
138 // The alignment computed during relaxation.
139 Align ComputedAlign;
140 // If true, fill padding with target NOPs via writeNopData; the STI field
141 // holds the subtarget info needed. If false, fill with Fill byte.
142 bool EmitNops;
143 // Fill byte used when !EmitNops.
144 uint8_t Fill;
145 } prefalign;
146 struct {
147 // True if this is a sleb128, false if uleb128.
148 bool IsSigned;
149 // The value this fragment should contain.
150 const MCExpr *Value;
151 } leb;
152 // Used by .debug_frame and .debug_line to encode an address difference.
153 struct {
154 // The address difference between two labels.
155 const MCExpr *AddrDelta;
156 // The value of the difference between the two line numbers between two
157 // .loc dwarf directives.
158 int64_t LineDelta;
159 } dwarf;
160 struct {
161 // This FRE describes unwind info at AddrDelta from function start.
162 const MCExpr *AddrDelta;
163 // Fragment that records how many bytes of AddrDelta to emit.
164 MCFragment *FDEFragment;
165 } sframe;
166 } u{};
167
168public:
169 LLVM_ABI MCFragment(FragmentType Kind = MCFragment::FT_Data,
170 bool HasInstructions = false);
171 MCFragment(const MCFragment &) = delete;
172 MCFragment &operator=(const MCFragment &) = delete;
173
174 MCFragment *getNext() const { return Next; }
175
176 FragmentType getKind() const { return Kind; }
177
178 MCSection *getParent() const { return Parent; }
179 void setParent(MCSection *Value) { Parent = Value; }
180
181 LLVM_ABI const MCSymbol *getAtom() const;
182
183 unsigned getLayoutOrder() const { return LayoutOrder; }
184 void setLayoutOrder(unsigned Value) { LayoutOrder = Value; }
185
186 /// Does this fragment have instructions emitted into it? By default
187 /// this is false, but specific fragment types may set it to true.
188 bool hasInstructions() const { return HasInstructions; }
189
190 LLVM_ABI void dump() const;
191
192 /// Retrieve the MCSubTargetInfo in effect when the instruction was encoded.
193 /// Guaranteed to be non-null if hasInstructions() == true
194 const MCSubtargetInfo *getSubtargetInfo() const { return STI; }
195
196 /// Record that the fragment contains instructions with the MCSubtargetInfo in
197 /// effect when the instruction was encoded.
199 HasInstructions = true;
200 this->STI = &STI;
201 }
202
203 bool isLinkerRelaxable() const { return LinkerRelaxable; }
204 void setLinkerRelaxable() { LinkerRelaxable = true; }
205
206 bool getAllowAutoPadding() const { return AllowAutoPadding; }
207 void setAllowAutoPadding(bool V) { AllowAutoPadding = V; }
208
209 //== Content-related functions manage parent's storage using ContentStart and
210 // ContentSize.
211
214
219
220 size_t getFixedSize() const { return FixedSize; }
221 size_t getVarSize() const { return VarContentEnd - VarContentStart; }
222 size_t getSize() const {
223 return FixedSize + (VarContentEnd - VarContentStart);
224 }
225
226 //== Fixup-related functions manage parent's storage using FixupStart and
227 // FixupSize.
228 void clearFixups() { FixupEnd = FixupStart; }
229 LLVM_ABI void addFixup(MCFixup Fixup);
230 // Insert .reloc fixups according to the ordering rules for .reloc
231 // relocations (see MCAssembler::layout()).
237
238 // Source fixup offsets are relative to the variable part's start.
239 // Stored fixup offsets are relative to the fixed part's start.
244
245 //== FT_Relaxable functions
246 unsigned getOpcode() const {
247 assert(Kind == FT_Relaxable);
248 return u.relax.Opcode;
249 }
251 MCInst getInst() const;
252 void setInst(const MCInst &Inst);
253
254 //== FT_Align functions
255 void makeAlign(Align Alignment, int64_t Fill, uint8_t FillLen,
256 unsigned MaxBytesToEmit) {
257 Kind = FT_Align;
258 u.align.EmitNops = false;
259 u.align.Alignment = Alignment;
260 u.align.Fill = Fill;
261 u.align.FillLen = FillLen;
262 u.align.MaxBytesToEmit = MaxBytesToEmit;
263 }
264
266 assert(Kind == FT_Align);
267 return u.align.Alignment;
268 }
269 int64_t getAlignFill() const {
270 assert(Kind == FT_Align);
271 return u.align.Fill;
272 }
274 assert(Kind == FT_Align);
275 return u.align.FillLen;
276 }
277 unsigned getAlignMaxBytesToEmit() const {
278 assert(Kind == FT_Align);
279 return u.align.MaxBytesToEmit;
280 }
281 bool hasAlignEmitNops() const {
282 assert(Kind == FT_Align);
283 return u.align.EmitNops;
284 }
285
286 //== FT_PrefAlign functions
287 // Initialize an FT_PrefAlign fragment. The region starts at this fragment and
288 // ends at \p End. ComputedAlign is set during relaxation:
289 // body_size < PrefAlign => ComputedAlign = std::bit_ceil(body_size)
290 // body_size >= PrefAlign => ComputedAlign = PrefAlign
291 void makePrefAlign(Align PrefAlign, const MCSymbol &End, bool EmitNops,
292 uint8_t Fill) {
293 Kind = FT_PrefAlign;
294 u.prefalign.End = &End;
295 u.prefalign.PreferredAlign = PrefAlign;
296 u.prefalign.ComputedAlign = Align();
297 u.prefalign.EmitNops = EmitNops;
298 u.prefalign.Fill = Fill;
299 }
300 const MCSymbol &getPrefAlignEnd() const {
301 assert(Kind == FT_PrefAlign);
302 return *u.prefalign.End;
303 }
305 assert(Kind == FT_PrefAlign);
306 return u.prefalign.PreferredAlign;
307 }
309 assert(Kind == FT_PrefAlign);
310 return u.prefalign.ComputedAlign;
311 }
313 assert(Kind == FT_PrefAlign);
314 u.prefalign.ComputedAlign = A;
315 }
316 bool getPrefAlignEmitNops() const {
317 assert(Kind == FT_PrefAlign);
318 return u.prefalign.EmitNops;
319 }
321 assert(Kind == FT_PrefAlign);
322 return u.prefalign.Fill;
323 }
324
325 //== FT_LEB functions
326 void makeLEB(bool IsSigned, const MCExpr *Value) {
327 assert(Kind == FT_Data);
328 Kind = MCFragment::FT_LEB;
329 u.leb.IsSigned = IsSigned;
330 u.leb.Value = Value;
331 }
332 const MCExpr &getLEBValue() const {
333 assert(Kind == FT_LEB);
334 return *u.leb.Value;
335 }
336 void setLEBValue(const MCExpr *Expr) {
337 assert(Kind == FT_LEB);
338 u.leb.Value = Expr;
339 }
340 bool isLEBSigned() const {
341 assert(Kind == FT_LEB);
342 return u.leb.IsSigned;
343 }
344
345 //== FT_DwarfFrame functions
346 const MCExpr &getDwarfAddrDelta() const {
347 assert(Kind == FT_Dwarf || Kind == FT_DwarfFrame);
348 return *u.dwarf.AddrDelta;
349 }
351 assert(Kind == FT_Dwarf || Kind == FT_DwarfFrame);
352 u.dwarf.AddrDelta = E;
353 }
354 int64_t getDwarfLineDelta() const {
355 assert(Kind == FT_Dwarf);
356 return u.dwarf.LineDelta;
357 }
358 void setDwarfLineDelta(int64_t LineDelta) {
359 assert(Kind == FT_Dwarf);
360 u.dwarf.LineDelta = LineDelta;
361 }
362
363 //== FT_SFrame functions
364 const MCExpr &getSFrameAddrDelta() const {
365 assert(Kind == FT_SFrame);
366 return *u.sframe.AddrDelta;
367 }
369 assert(Kind == FT_SFrame);
370 u.sframe.AddrDelta = E;
371 }
373 assert(Kind == FT_SFrame);
374 return u.sframe.FDEFragment;
375 }
377 assert(Kind == FT_SFrame);
378 u.sframe.FDEFragment = F;
379 }
380};
381
382// MCFragment subclasses do not use the fixed-size part or variable-size tail of
383// MCFragment. Instead, they encode content in a specialized way.
384
386 uint8_t ValueSize;
387 /// Value to use for filling bytes.
388 uint64_t Value;
389 /// The number of bytes to insert.
390 const MCExpr &NumValues;
391
392 /// Source location of the directive that this fragment was created for.
393 SMLoc Loc;
394
395public:
396 MCFillFragment(uint64_t Value, uint8_t VSize, const MCExpr &NumValues,
397 SMLoc Loc)
398 : MCFragment(FT_Fill), ValueSize(VSize), Value(Value),
399 NumValues(NumValues), Loc(Loc) {}
400
401 uint64_t getValue() const { return Value; }
402 uint8_t getValueSize() const { return ValueSize; }
403 const MCExpr &getNumValues() const { return NumValues; }
404
405 SMLoc getLoc() const { return Loc; }
406
407 static bool classof(const MCFragment *F) {
408 return F->getKind() == MCFragment::FT_Fill;
409 }
410};
411
413 /// The number of bytes to insert.
414 int64_t Size;
415 /// Maximum number of bytes allowed in each NOP instruction.
416 int64_t ControlledNopLength;
417
418 /// Source location of the directive that this fragment was created for.
419 SMLoc Loc;
420
421public:
422 MCNopsFragment(int64_t NumBytes, int64_t ControlledNopLength, SMLoc L,
423 const MCSubtargetInfo &STI)
424 : MCFragment(FT_Nops), Size(NumBytes),
425 ControlledNopLength(ControlledNopLength), Loc(L) {
426 this->STI = &STI;
427 }
428
429 int64_t getNumBytes() const { return Size; }
430 int64_t getControlledNopLength() const { return ControlledNopLength; }
431
432 SMLoc getLoc() const { return Loc; }
433
434 static bool classof(const MCFragment *F) {
435 return F->getKind() == MCFragment::FT_Nops;
436 }
437};
438
439class MCOrgFragment : public MCFragment {
440 /// Value to use for filling bytes.
441 int8_t Value;
442
443 /// The offset this fragment should start at.
444 const MCExpr *Offset;
445
446 /// Source location of the directive that this fragment was created for.
447 SMLoc Loc;
448
449public:
450 MCOrgFragment(const MCExpr &Offset, int8_t Value, SMLoc Loc)
451 : MCFragment(FT_Org), Value(Value), Offset(&Offset), Loc(Loc) {}
452
453 const MCExpr &getOffset() const { return *Offset; }
454 uint8_t getValue() const { return Value; }
455
456 SMLoc getLoc() const { return Loc; }
457
458 static bool classof(const MCFragment *F) {
459 return F->getKind() == MCFragment::FT_Org;
460 }
461};
462
463/// Represents a symbol table index fragment.
465 const MCSymbol *Sym;
466
467public:
469
470 const MCSymbol *getSymbol() const { return Sym; }
471
472 static bool classof(const MCFragment *F) {
473 return F->getKind() == MCFragment::FT_SymbolId;
474 }
475};
476
477/// Fragment representing the binary annotations produced by the
478/// .cv_inline_linetable directive.
480 unsigned SiteFuncId;
481 unsigned StartFileId;
482 unsigned StartLineNum;
483 const MCSymbol *FnStartSym;
484 const MCSymbol *FnEndSym;
485
486 /// CodeViewContext has the real knowledge about this format, so let it access
487 /// our members.
488 friend class CodeViewContext;
489
490public:
491 MCCVInlineLineTableFragment(unsigned SiteFuncId, unsigned StartFileId,
492 unsigned StartLineNum, const MCSymbol *FnStartSym,
493 const MCSymbol *FnEndSym)
494 : MCFragment(FT_CVInlineLines), SiteFuncId(SiteFuncId),
495 StartFileId(StartFileId), StartLineNum(StartLineNum),
496 FnStartSym(FnStartSym), FnEndSym(FnEndSym) {}
497
498 const MCSymbol *getFnStartSym() const { return FnStartSym; }
499 const MCSymbol *getFnEndSym() const { return FnEndSym; }
500
501 static bool classof(const MCFragment *F) {
502 return F->getKind() == MCFragment::FT_CVInlineLines;
503 }
504};
505
506/// Fragment representing the .cv_def_range directive.
509 StringRef FixedSizePortion;
510
511 /// CodeViewContext has the real knowledge about this format, so let it access
512 /// our members.
513 friend class CodeViewContext;
514
515public:
517 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
518 StringRef FixedSizePortion)
519 : MCFragment(FT_CVDefRange), Ranges(Ranges.begin(), Ranges.end()),
520 FixedSizePortion(FixedSizePortion) {}
521
525
526 StringRef getFixedSizePortion() const { return FixedSizePortion; }
527
528 static bool classof(const MCFragment *F) {
529 return F->getKind() == MCFragment::FT_CVDefRange;
530 }
531};
532
533/// Represents required padding such that a particular other set of fragments
534/// does not cross a particular power-of-two boundary. The other fragments must
535/// follow this one within the same section.
537 /// The alignment requirement of the branch to be aligned.
538 Align AlignBoundary;
539 /// The last fragment in the set of fragments to be aligned.
540 const MCFragment *LastFragment = nullptr;
541 /// The size of the fragment. The size is lazily set during relaxation, and
542 /// is not meaningful before that.
543 uint64_t Size = 0;
544
545 /// If true, align the last instruction in the fragment to the end of the
546 /// fragment.
547 bool AlignToEnd = false;
548
549public:
551 : MCFragment(FT_BoundaryAlign), AlignBoundary(AlignBoundary) {
552 this->STI = &STI;
553 }
554
555 uint64_t getSize() const { return Size; }
556 void setSize(uint64_t Value) { Size = Value; }
557
558 Align getAlignment() const { return AlignBoundary; }
559 void setAlignment(Align Value) { AlignBoundary = Value; }
560
561 bool isAlignToEnd() const { return AlignToEnd; }
562 void setAlignToEnd(bool Value) { AlignToEnd = Value; }
563
564 const MCFragment *getLastFragment() const { return LastFragment; }
566 assert(!F || getParent() == F->getParent());
567 LastFragment = F;
568 }
569
570 static bool classof(const MCFragment *F) {
571 return F->getKind() == MCFragment::FT_BoundaryAlign;
572 }
573};
574
575/// Instances of this class represent a uniqued identifier for a section in the
576/// current translation unit. The MCContext class uniques and creates these.
578public:
581 friend class MCFragment;
582 static constexpr unsigned NonUniqueID = ~0U;
583
584 struct iterator {
585 MCFragment *F = nullptr;
586 iterator() = default;
587 explicit iterator(MCFragment *F) : F(F) {}
588 MCFragment &operator*() const { return *F; }
589 bool operator==(const iterator &O) const { return F == O.F; }
590 bool operator!=(const iterator &O) const { return F != O.F; }
591 iterator &operator++();
592 };
593
594 struct FragList {
595 MCFragment *Head = nullptr;
596 MCFragment *Tail = nullptr;
597 };
598
599private:
600 // At parse time, this holds the fragment list of the current subsection. At
601 // layout time, this holds the concatenated fragment lists of all subsections.
602 // Null until the first fragment is added to this section.
603 FragList *CurFragList = nullptr;
604 // In many object file formats, this denotes the section symbol. In Mach-O,
605 // this denotes an optional temporary label at the section start.
606 MCSymbol *Begin;
607 MCSymbol *End = nullptr;
608 /// The alignment requirement of this section.
609 Align Alignment;
610 /// The section index in the assemblers section list.
611 unsigned Ordinal = 0;
612 // If not -1u, the first linker-relaxable fragment's order within the
613 // subsection. When present, the offset between two locations crossing this
614 // fragment may not be fully resolved.
615 unsigned FirstLinkerRelaxable = -1u;
616
617 /// Whether this section has had instructions emitted into it.
618 bool HasInstructions : 1;
619
620 bool IsRegistered : 1;
621
622 bool IsText : 1;
623 bool IsBss : 1;
624
625 MCFragment DummyFragment;
626
627 // Mapping from subsection number to fragment list. At layout time, the
628 // subsection 0 list is replaced with concatenated fragments from all
629 // subsections.
631
632 // Content and fixup storage for fragments
633 SmallVector<char, 0> ContentStorage;
634 SmallVector<MCFixup, 0> FixupStorage;
635 SmallVector<MCOperand, 0> MCOperandStorage;
636
637protected:
638 // TODO Make Name private when possible.
640
641 MCSection(StringRef Name, bool IsText, bool IsBss, MCSymbol *Begin);
642
643public:
644 MCSection(const MCSection &) = delete;
645 MCSection &operator=(const MCSection &) = delete;
646
647 StringRef getName() const { return Name; }
648 bool isText() const { return IsText; }
649
650 MCSymbol *getBeginSymbol() { return Begin; }
651 const MCSymbol *getBeginSymbol() const {
652 return const_cast<MCSection *>(this)->getBeginSymbol();
653 }
655 assert(!Begin);
656 Begin = Sym;
657 }
658 MCSymbol *getEndSymbol(MCContext &Ctx);
659 bool hasEnded() const;
660
661 Align getAlign() const { return Alignment; }
662 void setAlignment(Align Value) { Alignment = Value; }
663
664 /// Makes sure that Alignment is at least MinAlignment.
665 void ensureMinAlignment(Align MinAlignment) {
666 if (Alignment < MinAlignment)
667 Alignment = MinAlignment;
668 }
669
670 unsigned getOrdinal() const { return Ordinal; }
671 void setOrdinal(unsigned Value) { Ordinal = Value; }
672
673 bool hasInstructions() const { return HasInstructions; }
674 void setHasInstructions(bool Value) { HasInstructions = Value; }
675
676 bool isRegistered() const { return IsRegistered; }
677 void setIsRegistered(bool Value) { IsRegistered = Value; }
678
679 unsigned firstLinkerRelaxable() const { return FirstLinkerRelaxable; }
680 bool isLinkerRelaxable() const { return FirstLinkerRelaxable != -1u; }
681 void setFirstLinkerRelaxable(unsigned Order) { FirstLinkerRelaxable = Order; }
682
683 MCFragment &getDummyFragment() { return DummyFragment; }
684
685 FragList *curFragList() const { return CurFragList; }
686
687 // Return the highest subsection number in use. Subsections is sorted, so
688 // this is also the last subsection in layout order. After layout, all
689 // subsections are merged into subsection 0.
690 unsigned getLastSubsection() const {
691 return Subsections.empty() ? 0 : Subsections.back().first;
692 }
693 iterator begin() const { return iterator(CurFragList->Head); }
694 iterator end() const { return {}; }
695
697 *FragToSyms = nullptr) const;
698
699 /// Check whether this section is "virtual", that is has no actual object
700 /// file contents.
701 bool isBssSection() const { return IsBss; }
702};
703
705 return {reinterpret_cast<char *>(this + 1), FixedSize};
706}
708 return {reinterpret_cast<const char *>(this + 1), FixedSize};
709}
710
712 return MutableArrayRef(getParent()->ContentStorage)
713 .slice(VarContentStart, VarContentEnd - VarContentStart);
714}
716 return ArrayRef(getParent()->ContentStorage)
717 .slice(VarContentStart, VarContentEnd - VarContentStart);
718}
719
720//== Fixup-related functions manage parent's storage using FixupStart and
721// FixupSize.
723 return MutableArrayRef(getParent()->FixupStorage)
724 .slice(FixupStart, FixupEnd - FixupStart);
725}
727 return ArrayRef(getParent()->FixupStorage)
728 .slice(FixupStart, FixupEnd - FixupStart);
729}
730
732 return MutableArrayRef(getParent()->FixupStorage)
733 .slice(VarFixupStart, VarFixupSize);
734}
736 return ArrayRef(getParent()->FixupStorage).slice(VarFixupStart, VarFixupSize);
737}
738
739//== FT_Relaxable functions
741 assert(Kind == FT_Relaxable);
742 return MutableArrayRef(getParent()->MCOperandStorage)
743 .slice(u.relax.OperandStart, u.relax.OperandSize);
744}
746 assert(Kind == FT_Relaxable);
747 MCInst Inst;
748 Inst.setOpcode(u.relax.Opcode);
749 Inst.setFlags(u.relax.Flags);
750 Inst.setOperands(ArrayRef(getParent()->MCOperandStorage)
751 .slice(u.relax.OperandStart, u.relax.OperandSize));
752 return Inst;
753}
754inline void MCFragment::setInst(const MCInst &Inst) {
755 assert(Kind == FT_Relaxable);
756 u.relax.Opcode = Inst.getOpcode();
757 u.relax.Flags = Inst.getFlags();
758 auto &S = getParent()->MCOperandStorage;
759 if (Inst.getNumOperands() > u.relax.OperandSize) {
760 u.relax.OperandStart = S.size();
761 S.resize_for_overwrite(S.size() + Inst.getNumOperands());
762 }
763 u.relax.OperandSize = Inst.getNumOperands();
764 llvm::copy(Inst, S.begin() + u.relax.OperandStart);
765}
766
768 F = F->Next;
769 return *this;
770}
771
772} // end namespace llvm
773
774#endif // LLVM_MC_MCSECTION_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
uint64_t uint64_t
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_ABI
Definition Compiler.h:211
static uint64_t align(uint64_t Size)
This file defines the DenseMap class.
#define F(x, y, z)
Definition MD5.cpp:54
This file defines the SmallString class.
This file defines the SmallVector class.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
Definition ArrayRef.h:185
void setAlignToEnd(bool Value)
Definition MCSection.h:562
MCBoundaryAlignFragment(Align AlignBoundary, const MCSubtargetInfo &STI)
Definition MCSection.h:550
void setAlignment(Align Value)
Definition MCSection.h:559
void setSize(uint64_t Value)
Definition MCSection.h:556
const MCFragment * getLastFragment() const
Definition MCSection.h:564
static bool classof(const MCFragment *F)
Definition MCSection.h:570
void setLastFragment(const MCFragment *F)
Definition MCSection.h:565
MCCVDefRangeFragment(ArrayRef< std::pair< const MCSymbol *, const MCSymbol * > > Ranges, StringRef FixedSizePortion)
Definition MCSection.h:516
ArrayRef< std::pair< const MCSymbol *, const MCSymbol * > > getRanges() const
Definition MCSection.h:522
static bool classof(const MCFragment *F)
Definition MCSection.h:528
StringRef getFixedSizePortion() const
Definition MCSection.h:526
friend class CodeViewContext
CodeViewContext has the real knowledge about this format, so let it access our members.
Definition MCSection.h:513
static bool classof(const MCFragment *F)
Definition MCSection.h:501
MCCVInlineLineTableFragment(unsigned SiteFuncId, unsigned StartFileId, unsigned StartLineNum, const MCSymbol *FnStartSym, const MCSymbol *FnEndSym)
Definition MCSection.h:491
const MCSymbol * getFnStartSym() const
Definition MCSection.h:498
friend class CodeViewContext
CodeViewContext has the real knowledge about this format, so let it access our members.
Definition MCSection.h:488
const MCSymbol * getFnEndSym() const
Definition MCSection.h:499
Context object for machine code objects.
Definition MCContext.h:84
Base class for the full range of assembler expressions which are needed for parsing.
Definition MCExpr.h:31
MCFillFragment(uint64_t Value, uint8_t VSize, const MCExpr &NumValues, SMLoc Loc)
Definition MCSection.h:396
SMLoc getLoc() const
Definition MCSection.h:405
uint8_t getValueSize() const
Definition MCSection.h:402
uint64_t getValue() const
Definition MCSection.h:401
static bool classof(const MCFragment *F)
Definition MCSection.h:407
const MCExpr & getNumValues() const
Definition MCSection.h:403
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition MCFixup.h:65
LLVM_ABI void moveFixupsToEnd()
Definition MCSection.cpp:73
const MCExpr & getDwarfAddrDelta() const
Definition MCSection.h:346
MutableArrayRef< char > getContents()
Definition MCSection.h:704
MCFragment * getSFrameFDE() const
Definition MCSection.h:372
bool getAllowAutoPadding() const
Definition MCSection.h:206
Align getPrefAlignPreferred() const
Definition MCSection.h:304
FragmentType getKind() const
Definition MCSection.h:176
bool isLinkerRelaxable() const
Definition MCSection.h:203
void setAllowAutoPadding(bool V)
Definition MCSection.h:207
unsigned getLayoutOrder() const
Definition MCSection.h:183
LLVM_ABI void insertRelocFixups(ArrayRef< MCFixup > Fixups)
Definition MCSection.cpp:93
LLVM_ABI MCFragment(FragmentType Kind=MCFragment::FT_Data, bool HasInstructions=false)
bool hasAlignEmitNops() const
Definition MCSection.h:281
friend class MCObjectStreamer
Definition MCSection.h:45
void setSFrameAddrDelta(const MCExpr *E)
Definition MCSection.h:368
void setParent(MCSection *Value)
Definition MCSection.h:179
MCInst getInst() const
Definition MCSection.h:745
LLVM_ABI const MCSymbol * getAtom() const
LLVM_ABI void appendFixups(ArrayRef< MCFixup > Fixups)
Definition MCSection.cpp:85
void setDwarfLineDelta(int64_t LineDelta)
Definition MCSection.h:358
unsigned getAlignMaxBytesToEmit() const
Definition MCSection.h:277
int64_t getDwarfLineDelta() const
Definition MCSection.h:354
bool isLEBSigned() const
Definition MCSection.h:340
bool getPrefAlignEmitNops() const
Definition MCSection.h:316
unsigned getOpcode() const
Definition MCSection.h:246
MutableArrayRef< MCFixup > getFixups()
Definition MCSection.h:722
friend class MCSection
Definition MCSection.h:46
void setLayoutOrder(unsigned Value)
Definition MCSection.h:184
void setSFrameFDE(MCFragment *F)
Definition MCSection.h:376
const MCExpr & getLEBValue() const
Definition MCSection.h:332
void makePrefAlign(Align PrefAlign, const MCSymbol &End, bool EmitNops, uint8_t Fill)
Definition MCSection.h:291
LLVM_ABI void dump() const
friend class MCAssembler
Definition MCSection.h:43
size_t getSize() const
Definition MCSection.h:222
uint8_t getPrefAlignFill() const
Definition MCSection.h:320
MCSection * getParent() const
Definition MCSection.h:178
void makeAlign(Align Alignment, int64_t Fill, uint8_t FillLen, unsigned MaxBytesToEmit)
Definition MCSection.h:255
LLVM_ABI void setVarFixups(ArrayRef< MCFixup > Fixups)
MCFragment * getNext() const
Definition MCSection.h:174
const MCSubtargetInfo * STI
Definition MCSection.h:109
MCFragment(const MCFragment &)=delete
Align getPrefAlignComputed() const
Definition MCSection.h:308
void clearVarFixups()
Definition MCSection.h:241
ArrayRef< MCOperand > getOperands() const
Definition MCSection.h:740
LLVM_ABI void addFixup(MCFixup Fixup)
Definition MCSection.cpp:71
void setLinkerRelaxable()
Definition MCSection.h:204
Align getAlignment() const
Definition MCSection.h:265
size_t getFixedSize() const
Definition MCSection.h:220
friend class MCStreamer
Definition MCSection.h:44
int64_t getAlignFill() const
Definition MCSection.h:269
MCFragment & operator=(const MCFragment &)=delete
void makeLEB(bool IsSigned, const MCExpr *Value)
Definition MCSection.h:326
bool hasInstructions() const
Does this fragment have instructions emitted into it?
Definition MCSection.h:188
void setPrefAlignComputed(Align A)
Definition MCSection.h:312
uint8_t getAlignFillLen() const
Definition MCSection.h:273
void setDwarfAddrDelta(const MCExpr *E)
Definition MCSection.h:350
void setLEBValue(const MCExpr *Expr)
Definition MCSection.h:336
size_t getVarSize() const
Definition MCSection.h:221
const MCSymbol & getPrefAlignEnd() const
Definition MCSection.h:300
LLVM_ABI void setVarContents(ArrayRef< char > Contents)
Definition MCSection.cpp:61
MutableArrayRef< char > getVarContents()
Definition MCSection.h:711
const MCSubtargetInfo * getSubtargetInfo() const
Retrieve the MCSubTargetInfo in effect when the instruction was encoded.
Definition MCSection.h:194
void setHasInstructions(const MCSubtargetInfo &STI)
Record that the fragment contains instructions with the MCSubtargetInfo in effect when the instructio...
Definition MCSection.h:198
const MCExpr & getSFrameAddrDelta() const
Definition MCSection.h:364
MutableArrayRef< MCFixup > getVarFixups()
Definition MCSection.h:731
void setInst(const MCInst &Inst)
Definition MCSection.h:754
void clearVarContents()
Definition MCSection.h:216
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:187
unsigned getNumOperands() const
Definition MCInst.h:211
unsigned getFlags() const
Definition MCInst.h:204
unsigned getOpcode() const
Definition MCInst.h:201
void setFlags(unsigned F)
Definition MCInst.h:203
void setOperands(ArrayRef< MCOperand > Ops)
Definition MCInst.h:215
iterator begin()
Definition MCInst.h:226
void setOpcode(unsigned Op)
Definition MCInst.h:200
int64_t getControlledNopLength() const
Definition MCSection.h:430
int64_t getNumBytes() const
Definition MCSection.h:429
MCNopsFragment(int64_t NumBytes, int64_t ControlledNopLength, SMLoc L, const MCSubtargetInfo &STI)
Definition MCSection.h:422
static bool classof(const MCFragment *F)
Definition MCSection.h:434
SMLoc getLoc() const
Definition MCSection.h:432
Streaming object file generation interface.
SMLoc getLoc() const
Definition MCSection.h:456
static bool classof(const MCFragment *F)
Definition MCSection.h:458
uint8_t getValue() const
Definition MCSection.h:454
const MCExpr & getOffset() const
Definition MCSection.h:453
MCOrgFragment(const MCExpr &Offset, int8_t Value, SMLoc Loc)
Definition MCSection.h:450
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition MCSection.h:577
void setAlignment(Align Value)
Definition MCSection.h:662
unsigned getOrdinal() const
Definition MCSection.h:670
friend MCObjectStreamer
Definition MCSection.h:580
void ensureMinAlignment(Align MinAlignment)
Makes sure that Alignment is at least MinAlignment.
Definition MCSection.h:665
bool isBssSection() const
Check whether this section is "virtual", that is has no actual object file contents.
Definition MCSection.h:701
Align getAlign() const
Definition MCSection.h:661
unsigned getLastSubsection() const
Definition MCSection.h:690
bool isLinkerRelaxable() const
Definition MCSection.h:680
static constexpr unsigned NonUniqueID
Definition MCSection.h:582
const MCSymbol * getBeginSymbol() const
Definition MCSection.h:651
bool hasInstructions() const
Definition MCSection.h:673
bool isRegistered() const
Definition MCSection.h:676
void setHasInstructions(bool Value)
Definition MCSection.h:674
void setBeginSymbol(MCSymbol *Sym)
Definition MCSection.h:654
MCSection(const MCSection &)=delete
friend MCAssembler
Definition MCSection.h:579
void setOrdinal(unsigned Value)
Definition MCSection.h:671
bool isText() const
Definition MCSection.h:648
StringRef Name
Definition MCSection.h:639
iterator end() const
Definition MCSection.h:694
MCSection & operator=(const MCSection &)=delete
StringRef getName() const
Definition MCSection.h:647
friend class MCFragment
Definition MCSection.h:581
MCFragment & getDummyFragment()
Definition MCSection.h:683
unsigned firstLinkerRelaxable() const
Definition MCSection.h:679
FragList * curFragList() const
Definition MCSection.h:685
MCSymbol * getBeginSymbol()
Definition MCSection.h:650
iterator begin() const
Definition MCSection.h:693
MCSection(StringRef Name, bool IsText, bool IsBss, MCSymbol *Begin)
Definition MCSection.cpp:21
void setIsRegistered(bool Value)
Definition MCSection.h:677
void setFirstLinkerRelaxable(unsigned Order)
Definition MCSection.h:681
Generic base class for all target subtargets.
const MCSymbol * getSymbol() const
Definition MCSection.h:470
MCSymbolIdFragment(const MCSymbol *Sym)
Definition MCSection.h:468
static bool classof(const MCFragment *F)
Definition MCSection.h:472
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
Represent a mutable reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:294
MutableArrayRef< T > slice(size_t N, size_t M) const
Chop off the first N elements of the array, and keep M elements in the array.
Definition ArrayRef.h:372
Represents a location in source code.
Definition SMLoc.h:22
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
LLVM Value Representation.
Definition Value.h:75
Calculates the starting offsets for various sections within the .debug_names section.
Definition Dwarf.h:35
This is an optimization pass for GlobalISel generic memory operations.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
@ Offset
Definition DWP.cpp:577
MutableArrayRef(T &OneElt) -> MutableArrayRef< T >
ArrayRef(const T &OneElt) -> ArrayRef< T >
OutputIt copy(R &&Range, OutputIt Out)
Definition STLExtras.h:1901
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Next
Definition InstrProf.h:147
@ End
Run the machine verifier once, at the end of the pipeline.
Definition CodeGen.h:320
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
MCFragment & operator*() const
Definition MCSection.h:588
bool operator==(const iterator &O) const
Definition MCSection.h:589
bool operator!=(const iterator &O) const
Definition MCSection.h:590
iterator(MCFragment *F)
Definition MCSection.h:587