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; }
233 // Insert .reloc fixups according to the ordering rules for .reloc
234 // relocations (see MCAssembler::layout()).
240
241 // Source fixup offsets are relative to the variable part's start.
242 // Stored fixup offsets are relative to the fixed part's start.
247
248 //== FT_Relaxable functions
249 unsigned getOpcode() const {
250 assert(Kind == FT_Relaxable);
251 return u.relax.Opcode;
252 }
254 MCInst getInst() const;
255 void setInst(const MCInst &Inst);
256
257 //== FT_Align functions
258 void makeAlign(Align Alignment, int64_t Fill, uint8_t FillLen,
259 unsigned MaxBytesToEmit) {
260 Kind = FT_Align;
261 u.align.EmitNops = false;
262 u.align.Alignment = Alignment;
263 u.align.Fill = Fill;
264 u.align.FillLen = FillLen;
265 u.align.MaxBytesToEmit = MaxBytesToEmit;
266 }
267
269 assert(Kind == FT_Align);
270 return u.align.Alignment;
271 }
272 int64_t getAlignFill() const {
273 assert(Kind == FT_Align);
274 return u.align.Fill;
275 }
277 assert(Kind == FT_Align);
278 return u.align.FillLen;
279 }
280 unsigned getAlignMaxBytesToEmit() const {
281 assert(Kind == FT_Align);
282 return u.align.MaxBytesToEmit;
283 }
284 bool hasAlignEmitNops() const {
285 assert(Kind == FT_Align);
286 return u.align.EmitNops;
287 }
288
289 //== FT_PrefAlign functions
290 // Initialize an FT_PrefAlign fragment. The region starts at this fragment and
291 // ends at \p End. ComputedAlign is set during relaxation:
292 // body_size < PrefAlign => ComputedAlign = std::bit_ceil(body_size)
293 // body_size >= PrefAlign => ComputedAlign = PrefAlign
294 void makePrefAlign(Align PrefAlign, const MCSymbol &End, bool EmitNops,
295 uint8_t Fill) {
296 Kind = FT_PrefAlign;
297 u.prefalign.End = &End;
298 u.prefalign.PreferredAlign = PrefAlign;
299 u.prefalign.ComputedAlign = Align();
300 u.prefalign.EmitNops = EmitNops;
301 u.prefalign.Fill = Fill;
302 }
303 const MCSymbol &getPrefAlignEnd() const {
304 assert(Kind == FT_PrefAlign);
305 return *u.prefalign.End;
306 }
308 assert(Kind == FT_PrefAlign);
309 return u.prefalign.PreferredAlign;
310 }
312 assert(Kind == FT_PrefAlign);
313 return u.prefalign.ComputedAlign;
314 }
316 assert(Kind == FT_PrefAlign);
317 u.prefalign.ComputedAlign = A;
318 }
319 bool getPrefAlignEmitNops() const {
320 assert(Kind == FT_PrefAlign);
321 return u.prefalign.EmitNops;
322 }
324 assert(Kind == FT_PrefAlign);
325 return u.prefalign.Fill;
326 }
327
328 //== FT_LEB functions
329 void makeLEB(bool IsSigned, const MCExpr *Value) {
330 assert(Kind == FT_Data);
331 Kind = MCFragment::FT_LEB;
332 u.leb.IsSigned = IsSigned;
333 u.leb.Value = Value;
334 }
335 const MCExpr &getLEBValue() const {
336 assert(Kind == FT_LEB);
337 return *u.leb.Value;
338 }
339 void setLEBValue(const MCExpr *Expr) {
340 assert(Kind == FT_LEB);
341 u.leb.Value = Expr;
342 }
343 bool isLEBSigned() const {
344 assert(Kind == FT_LEB);
345 return u.leb.IsSigned;
346 }
347
348 //== FT_DwarfFrame functions
349 const MCExpr &getDwarfAddrDelta() const {
350 assert(Kind == FT_Dwarf || Kind == FT_DwarfFrame);
351 return *u.dwarf.AddrDelta;
352 }
354 assert(Kind == FT_Dwarf || Kind == FT_DwarfFrame);
355 u.dwarf.AddrDelta = E;
356 }
357 int64_t getDwarfLineDelta() const {
358 assert(Kind == FT_Dwarf);
359 return u.dwarf.LineDelta;
360 }
361 void setDwarfLineDelta(int64_t LineDelta) {
362 assert(Kind == FT_Dwarf);
363 u.dwarf.LineDelta = LineDelta;
364 }
365
366 //== FT_SFrame functions
367 const MCExpr &getSFrameAddrDelta() const {
368 assert(Kind == FT_SFrame);
369 return *u.sframe.AddrDelta;
370 }
372 assert(Kind == FT_SFrame);
373 u.sframe.AddrDelta = E;
374 }
376 assert(Kind == FT_SFrame);
377 return u.sframe.FDEFragment;
378 }
380 assert(Kind == FT_SFrame);
381 u.sframe.FDEFragment = F;
382 }
383};
384
385// MCFragment subclasses do not use the fixed-size part or variable-size tail of
386// MCFragment. Instead, they encode content in a specialized way.
387
389 uint8_t ValueSize;
390 /// Value to use for filling bytes.
391 uint64_t Value;
392 /// The number of bytes to insert.
393 const MCExpr &NumValues;
394
395 /// Source location of the directive that this fragment was created for.
396 SMLoc Loc;
397
398public:
399 MCFillFragment(uint64_t Value, uint8_t VSize, const MCExpr &NumValues,
400 SMLoc Loc)
401 : MCFragment(FT_Fill), ValueSize(VSize), Value(Value),
402 NumValues(NumValues), Loc(Loc) {}
403
404 uint64_t getValue() const { return Value; }
405 uint8_t getValueSize() const { return ValueSize; }
406 const MCExpr &getNumValues() const { return NumValues; }
407
408 SMLoc getLoc() const { return Loc; }
409
410 static bool classof(const MCFragment *F) {
411 return F->getKind() == MCFragment::FT_Fill;
412 }
413};
414
416 /// The number of bytes to insert.
417 int64_t Size;
418 /// Maximum number of bytes allowed in each NOP instruction.
419 int64_t ControlledNopLength;
420
421 /// Source location of the directive that this fragment was created for.
422 SMLoc Loc;
423
424public:
425 MCNopsFragment(int64_t NumBytes, int64_t ControlledNopLength, SMLoc L,
426 const MCSubtargetInfo &STI)
427 : MCFragment(FT_Nops), Size(NumBytes),
428 ControlledNopLength(ControlledNopLength), Loc(L) {
429 this->STI = &STI;
430 }
431
432 int64_t getNumBytes() const { return Size; }
433 int64_t getControlledNopLength() const { return ControlledNopLength; }
434
435 SMLoc getLoc() const { return Loc; }
436
437 static bool classof(const MCFragment *F) {
438 return F->getKind() == MCFragment::FT_Nops;
439 }
440};
441
442class MCOrgFragment : public MCFragment {
443 /// Value to use for filling bytes.
444 int8_t Value;
445
446 /// The offset this fragment should start at.
447 const MCExpr *Offset;
448
449 /// Source location of the directive that this fragment was created for.
450 SMLoc Loc;
451
452public:
453 MCOrgFragment(const MCExpr &Offset, int8_t Value, SMLoc Loc)
454 : MCFragment(FT_Org), Value(Value), Offset(&Offset), Loc(Loc) {}
455
456 const MCExpr &getOffset() const { return *Offset; }
457 uint8_t getValue() const { return Value; }
458
459 SMLoc getLoc() const { return Loc; }
460
461 static bool classof(const MCFragment *F) {
462 return F->getKind() == MCFragment::FT_Org;
463 }
464};
465
466/// Represents a symbol table index fragment.
468 const MCSymbol *Sym;
469
470public:
472
473 const MCSymbol *getSymbol() const { return Sym; }
474
475 static bool classof(const MCFragment *F) {
476 return F->getKind() == MCFragment::FT_SymbolId;
477 }
478};
479
480/// Fragment representing the binary annotations produced by the
481/// .cv_inline_linetable directive.
483 unsigned SiteFuncId;
484 unsigned StartFileId;
485 unsigned StartLineNum;
486 const MCSymbol *FnStartSym;
487 const MCSymbol *FnEndSym;
488
489 /// CodeViewContext has the real knowledge about this format, so let it access
490 /// our members.
491 friend class CodeViewContext;
492
493public:
494 MCCVInlineLineTableFragment(unsigned SiteFuncId, unsigned StartFileId,
495 unsigned StartLineNum, const MCSymbol *FnStartSym,
496 const MCSymbol *FnEndSym)
497 : MCFragment(FT_CVInlineLines), SiteFuncId(SiteFuncId),
498 StartFileId(StartFileId), StartLineNum(StartLineNum),
499 FnStartSym(FnStartSym), FnEndSym(FnEndSym) {}
500
501 const MCSymbol *getFnStartSym() const { return FnStartSym; }
502 const MCSymbol *getFnEndSym() const { return FnEndSym; }
503
504 static bool classof(const MCFragment *F) {
505 return F->getKind() == MCFragment::FT_CVInlineLines;
506 }
507};
508
509/// Fragment representing the .cv_def_range directive.
512 StringRef FixedSizePortion;
513
514 /// CodeViewContext has the real knowledge about this format, so let it access
515 /// our members.
516 friend class CodeViewContext;
517
518public:
520 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
521 StringRef FixedSizePortion)
522 : MCFragment(FT_CVDefRange), Ranges(Ranges.begin(), Ranges.end()),
523 FixedSizePortion(FixedSizePortion) {}
524
528
529 StringRef getFixedSizePortion() const { return FixedSizePortion; }
530
531 static bool classof(const MCFragment *F) {
532 return F->getKind() == MCFragment::FT_CVDefRange;
533 }
534};
535
536/// Represents required padding such that a particular other set of fragments
537/// does not cross a particular power-of-two boundary. The other fragments must
538/// follow this one within the same section.
540 /// The alignment requirement of the branch to be aligned.
541 Align AlignBoundary;
542 /// The last fragment in the set of fragments to be aligned.
543 const MCFragment *LastFragment = nullptr;
544 /// The size of the fragment. The size is lazily set during relaxation, and
545 /// is not meaningful before that.
546 uint64_t Size = 0;
547
548public:
550 : MCFragment(FT_BoundaryAlign), AlignBoundary(AlignBoundary) {
551 this->STI = &STI;
552 }
553
554 uint64_t getSize() const { return Size; }
555 void setSize(uint64_t Value) { Size = Value; }
556
557 Align getAlignment() const { return AlignBoundary; }
558 void setAlignment(Align Value) { AlignBoundary = Value; }
559
560 const MCFragment *getLastFragment() const { return LastFragment; }
562 assert(!F || getParent() == F->getParent());
563 LastFragment = F;
564 }
565
566 static bool classof(const MCFragment *F) {
567 return F->getKind() == MCFragment::FT_BoundaryAlign;
568 }
569};
570
571/// Instances of this class represent a uniqued identifier for a section in the
572/// current translation unit. The MCContext class uniques and creates these.
574public:
577 friend class MCFragment;
578 static constexpr unsigned NonUniqueID = ~0U;
579
580 struct iterator {
581 MCFragment *F = nullptr;
582 iterator() = default;
583 explicit iterator(MCFragment *F) : F(F) {}
584 MCFragment &operator*() const { return *F; }
585 bool operator==(const iterator &O) const { return F == O.F; }
586 bool operator!=(const iterator &O) const { return F != O.F; }
587 iterator &operator++();
588 };
589
590 struct FragList {
591 MCFragment *Head = nullptr;
592 MCFragment *Tail = nullptr;
593 };
594
595private:
596 // At parse time, this holds the fragment list of the current subsection. At
597 // layout time, this holds the concatenated fragment lists of all subsections.
598 // Null until the first fragment is added to this section.
599 FragList *CurFragList = nullptr;
600 // In many object file formats, this denotes the section symbol. In Mach-O,
601 // this denotes an optional temporary label at the section start.
602 MCSymbol *Begin;
603 MCSymbol *End = nullptr;
604 /// The alignment requirement of this section.
605 Align Alignment;
606 /// The section index in the assemblers section list.
607 unsigned Ordinal = 0;
608 // If not -1u, the first linker-relaxable fragment's order within the
609 // subsection. When present, the offset between two locations crossing this
610 // fragment may not be fully resolved.
611 unsigned FirstLinkerRelaxable = -1u;
612
613 /// Whether this section has had instructions emitted into it.
614 bool HasInstructions : 1;
615
616 bool IsRegistered : 1;
617
618 bool IsText : 1;
619 bool IsBss : 1;
620
621 MCFragment DummyFragment;
622
623 // Mapping from subsection number to fragment list. At layout time, the
624 // subsection 0 list is replaced with concatenated fragments from all
625 // subsections.
627
628 // Content and fixup storage for fragments
629 SmallVector<char, 0> ContentStorage;
630 SmallVector<MCFixup, 0> FixupStorage;
631 SmallVector<MCOperand, 0> MCOperandStorage;
632
633protected:
634 // TODO Make Name private when possible.
636
637 MCSection(StringRef Name, bool IsText, bool IsBss, MCSymbol *Begin);
638
639public:
640 MCSection(const MCSection &) = delete;
641 MCSection &operator=(const MCSection &) = delete;
642
643 StringRef getName() const { return Name; }
644 bool isText() const { return IsText; }
645
646 MCSymbol *getBeginSymbol() { return Begin; }
647 const MCSymbol *getBeginSymbol() const {
648 return const_cast<MCSection *>(this)->getBeginSymbol();
649 }
651 assert(!Begin);
652 Begin = Sym;
653 }
654 MCSymbol *getEndSymbol(MCContext &Ctx);
655 bool hasEnded() const;
656
657 Align getAlign() const { return Alignment; }
658 void setAlignment(Align Value) { Alignment = Value; }
659
660 /// Makes sure that Alignment is at least MinAlignment.
661 void ensureMinAlignment(Align MinAlignment) {
662 if (Alignment < MinAlignment)
663 Alignment = MinAlignment;
664 }
665
666 unsigned getOrdinal() const { return Ordinal; }
667 void setOrdinal(unsigned Value) { Ordinal = Value; }
668
669 bool hasInstructions() const { return HasInstructions; }
670 void setHasInstructions(bool Value) { HasInstructions = Value; }
671
672 bool isRegistered() const { return IsRegistered; }
673 void setIsRegistered(bool Value) { IsRegistered = Value; }
674
675 unsigned firstLinkerRelaxable() const { return FirstLinkerRelaxable; }
676 bool isLinkerRelaxable() const { return FirstLinkerRelaxable != -1u; }
677 void setFirstLinkerRelaxable(unsigned Order) { FirstLinkerRelaxable = Order; }
678
679 MCFragment &getDummyFragment() { return DummyFragment; }
680
681 FragList *curFragList() const { return CurFragList; }
682 iterator begin() const { return iterator(CurFragList->Head); }
683 iterator end() const { return {}; }
684
686 *FragToSyms = nullptr) const;
687
688 /// Check whether this section is "virtual", that is has no actual object
689 /// file contents.
690 bool isBssSection() const { return IsBss; }
691};
692
694 return {reinterpret_cast<char *>(this + 1), FixedSize};
695}
697 return {reinterpret_cast<const char *>(this + 1), FixedSize};
698}
699
701 return MutableArrayRef(getParent()->ContentStorage)
702 .slice(VarContentStart, VarContentEnd - VarContentStart);
703}
705 return ArrayRef(getParent()->ContentStorage)
706 .slice(VarContentStart, VarContentEnd - VarContentStart);
707}
708
709//== Fixup-related functions manage parent's storage using FixupStart and
710// FixupSize.
712 return MutableArrayRef(getParent()->FixupStorage)
713 .slice(FixupStart, FixupEnd - FixupStart);
714}
716 return ArrayRef(getParent()->FixupStorage)
717 .slice(FixupStart, FixupEnd - FixupStart);
718}
719
721 return MutableArrayRef(getParent()->FixupStorage)
722 .slice(VarFixupStart, VarFixupSize);
723}
725 return ArrayRef(getParent()->FixupStorage).slice(VarFixupStart, VarFixupSize);
726}
727
728//== FT_Relaxable functions
730 assert(Kind == FT_Relaxable);
731 return MutableArrayRef(getParent()->MCOperandStorage)
732 .slice(u.relax.OperandStart, u.relax.OperandSize);
733}
735 assert(Kind == FT_Relaxable);
736 MCInst Inst;
737 Inst.setOpcode(u.relax.Opcode);
738 Inst.setFlags(u.relax.Flags);
739 Inst.setOperands(ArrayRef(getParent()->MCOperandStorage)
740 .slice(u.relax.OperandStart, u.relax.OperandSize));
741 return Inst;
742}
743inline void MCFragment::setInst(const MCInst &Inst) {
744 assert(Kind == FT_Relaxable);
745 u.relax.Opcode = Inst.getOpcode();
746 u.relax.Flags = Inst.getFlags();
747 auto &S = getParent()->MCOperandStorage;
748 if (Inst.getNumOperands() > u.relax.OperandSize) {
749 u.relax.OperandStart = S.size();
750 S.resize_for_overwrite(S.size() + Inst.getNumOperands());
751 }
752 u.relax.OperandSize = Inst.getNumOperands();
753 llvm::copy(Inst, S.begin() + u.relax.OperandStart);
754}
755
757 F = F->Next;
758 return *this;
759}
760
761} // end namespace llvm
762
763#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:549
void setAlignment(Align Value)
Definition MCSection.h:558
void setSize(uint64_t Value)
Definition MCSection.h:555
const MCFragment * getLastFragment() const
Definition MCSection.h:560
static bool classof(const MCFragment *F)
Definition MCSection.h:566
void setLastFragment(const MCFragment *F)
Definition MCSection.h:561
MCCVDefRangeFragment(ArrayRef< std::pair< const MCSymbol *, const MCSymbol * > > Ranges, StringRef FixedSizePortion)
Definition MCSection.h:519
ArrayRef< std::pair< const MCSymbol *, const MCSymbol * > > getRanges() const
Definition MCSection.h:525
static bool classof(const MCFragment *F)
Definition MCSection.h:531
StringRef getFixedSizePortion() const
Definition MCSection.h:529
friend class CodeViewContext
CodeViewContext has the real knowledge about this format, so let it access our members.
Definition MCSection.h:516
static bool classof(const MCFragment *F)
Definition MCSection.h:504
MCCVInlineLineTableFragment(unsigned SiteFuncId, unsigned StartFileId, unsigned StartLineNum, const MCSymbol *FnStartSym, const MCSymbol *FnEndSym)
Definition MCSection.h:494
const MCSymbol * getFnStartSym() const
Definition MCSection.h:501
friend class CodeViewContext
CodeViewContext has the real knowledge about this format, so let it access our members.
Definition MCSection.h:491
const MCSymbol * getFnEndSym() const
Definition MCSection.h:502
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:399
SMLoc getLoc() const
Definition MCSection.h:408
uint8_t getValueSize() const
Definition MCSection.h:405
uint64_t getValue() const
Definition MCSection.h:404
static bool classof(const MCFragment *F)
Definition MCSection.h:410
const MCExpr & getNumValues() const
Definition MCSection.h:406
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition MCFixup.h:61
LLVM_ABI void moveFixupsToEnd()
Definition MCSection.cpp:73
const MCExpr & getDwarfAddrDelta() const
Definition MCSection.h:349
MutableArrayRef< char > getContents()
Definition MCSection.h:693
MCFragment * getSFrameFDE() const
Definition MCSection.h:375
bool getAllowAutoPadding() const
Definition MCSection.h:209
Align getPrefAlignPreferred() const
Definition MCSection.h:307
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 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:284
friend class MCObjectStreamer
Definition MCSection.h:48
void setSFrameAddrDelta(const MCExpr *E)
Definition MCSection.h:371
void setParent(MCSection *Value)
Definition MCSection.h:182
MCInst getInst() const
Definition MCSection.h:734
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:361
unsigned getAlignMaxBytesToEmit() const
Definition MCSection.h:280
int64_t getDwarfLineDelta() const
Definition MCSection.h:357
bool isLEBSigned() const
Definition MCSection.h:343
bool getPrefAlignEmitNops() const
Definition MCSection.h:319
unsigned getOpcode() const
Definition MCSection.h:249
MutableArrayRef< MCFixup > getFixups()
Definition MCSection.h:711
friend class MCSection
Definition MCSection.h:49
void setLayoutOrder(unsigned Value)
Definition MCSection.h:187
void setSFrameFDE(MCFragment *F)
Definition MCSection.h:379
const MCExpr & getLEBValue() const
Definition MCSection.h:335
void makePrefAlign(Align PrefAlign, const MCSymbol &End, bool EmitNops, uint8_t Fill)
Definition MCSection.h:294
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:323
MCSection * getParent() const
Definition MCSection.h:181
void makeAlign(Align Alignment, int64_t Fill, uint8_t FillLen, unsigned MaxBytesToEmit)
Definition MCSection.h:258
LLVM_ABI void setVarFixups(ArrayRef< MCFixup > Fixups)
MCFragment * getNext() const
Definition MCSection.h:177
const MCSubtargetInfo * STI
Definition MCSection.h:112
MCFragment(const MCFragment &)=delete
Align getPrefAlignComputed() const
Definition MCSection.h:311
void clearVarFixups()
Definition MCSection.h:244
ArrayRef< MCOperand > getOperands() const
Definition MCSection.h:729
LLVM_ABI void addFixup(MCFixup Fixup)
Definition MCSection.cpp:71
void setLinkerRelaxable()
Definition MCSection.h:207
Align getAlignment() const
Definition MCSection.h:268
size_t getFixedSize() const
Definition MCSection.h:223
friend class MCStreamer
Definition MCSection.h:47
int64_t getAlignFill() const
Definition MCSection.h:272
MCFragment & operator=(const MCFragment &)=delete
void makeLEB(bool IsSigned, const MCExpr *Value)
Definition MCSection.h:329
bool hasInstructions() const
Does this fragment have instructions emitted into it?
Definition MCSection.h:191
void setPrefAlignComputed(Align A)
Definition MCSection.h:315
uint8_t getAlignFillLen() const
Definition MCSection.h:276
void setDwarfAddrDelta(const MCExpr *E)
Definition MCSection.h:353
void setLEBValue(const MCExpr *Expr)
Definition MCSection.h:339
size_t getVarSize() const
Definition MCSection.h:224
const MCSymbol & getPrefAlignEnd() const
Definition MCSection.h:303
LLVM_ABI void setVarContents(ArrayRef< char > Contents)
Definition MCSection.cpp:61
MutableArrayRef< char > getVarContents()
Definition MCSection.h:700
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:367
MutableArrayRef< MCFixup > getVarFixups()
Definition MCSection.h:720
void setInst(const MCInst &Inst)
Definition MCSection.h:743
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:433
int64_t getNumBytes() const
Definition MCSection.h:432
MCNopsFragment(int64_t NumBytes, int64_t ControlledNopLength, SMLoc L, const MCSubtargetInfo &STI)
Definition MCSection.h:425
static bool classof(const MCFragment *F)
Definition MCSection.h:437
SMLoc getLoc() const
Definition MCSection.h:435
Streaming object file generation interface.
SMLoc getLoc() const
Definition MCSection.h:459
static bool classof(const MCFragment *F)
Definition MCSection.h:461
uint8_t getValue() const
Definition MCSection.h:457
const MCExpr & getOffset() const
Definition MCSection.h:456
MCOrgFragment(const MCExpr &Offset, int8_t Value, SMLoc Loc)
Definition MCSection.h:453
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition MCSection.h:573
void setAlignment(Align Value)
Definition MCSection.h:658
unsigned getOrdinal() const
Definition MCSection.h:666
friend MCObjectStreamer
Definition MCSection.h:576
void ensureMinAlignment(Align MinAlignment)
Makes sure that Alignment is at least MinAlignment.
Definition MCSection.h:661
bool isBssSection() const
Check whether this section is "virtual", that is has no actual object file contents.
Definition MCSection.h:690
Align getAlign() const
Definition MCSection.h:657
bool isLinkerRelaxable() const
Definition MCSection.h:676
static constexpr unsigned NonUniqueID
Definition MCSection.h:578
const MCSymbol * getBeginSymbol() const
Definition MCSection.h:647
bool hasInstructions() const
Definition MCSection.h:669
bool isRegistered() const
Definition MCSection.h:672
void setHasInstructions(bool Value)
Definition MCSection.h:670
void setBeginSymbol(MCSymbol *Sym)
Definition MCSection.h:650
MCSection(const MCSection &)=delete
friend MCAssembler
Definition MCSection.h:575
void setOrdinal(unsigned Value)
Definition MCSection.h:667
bool isText() const
Definition MCSection.h:644
StringRef Name
Definition MCSection.h:635
iterator end() const
Definition MCSection.h:683
MCSection & operator=(const MCSection &)=delete
StringRef getName() const
Definition MCSection.h:643
friend class MCFragment
Definition MCSection.h:577
MCFragment & getDummyFragment()
Definition MCSection.h:679
unsigned firstLinkerRelaxable() const
Definition MCSection.h:675
FragList * curFragList() const
Definition MCSection.h:681
MCSymbol * getBeginSymbol()
Definition MCSection.h:646
iterator begin() const
Definition MCSection.h:682
MCSection(StringRef Name, bool IsText, bool IsBss, MCSymbol *Begin)
Definition MCSection.cpp:21
void setIsRegistered(bool Value)
Definition MCSection.h:673
void setFirstLinkerRelaxable(unsigned Order)
Definition MCSection.h:677
Generic base class for all target subtargets.
const MCSymbol * getSymbol() const
Definition MCSection.h:473
MCSymbolIdFragment(const MCSymbol *Sym)
Definition MCSection.h:471
static bool classof(const MCFragment *F)
Definition MCSection.h:475
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:557
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:1884
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:584
bool operator==(const iterator &O) const
Definition MCSection.h:585
bool operator!=(const iterator &O) const
Definition MCSection.h:586
iterator(MCFragment *F)
Definition MCSection.h:583