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