LLVM 22.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;
35class MCObjectStreamer;
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:
66 };
67
68private:
69 // The next fragment within the section.
70 MCFragment *Next = nullptr;
71
72 /// The data for the section this fragment is in.
73 MCSection *Parent = nullptr;
74
75 /// The offset of this fragment in its section.
76 uint64_t Offset = 0;
77
78 /// The layout order of this fragment.
79 unsigned LayoutOrder = 0;
80
81 FragmentType Kind;
82
83 //== Used by certain fragment types for better packing.
84
85 // The number of fixups for the optional variable-size tail must be small.
86 uint8_t VarFixupSize = 0;
87
88 bool LinkerRelaxable : 1;
89
90 /// FT_Data, FT_Relaxable
91 bool HasInstructions : 1;
92 /// FT_Relaxable, x86-specific
93 bool AllowAutoPadding : 1;
94
95 // Track content and fixups for the fixed-size part as fragments are
96 // appended to the section. The content is stored as trailing data of the
97 // MCFragment. The content remains immutable, except when modified by
98 // applyFixup.
99 uint32_t FixedSize = 0;
100 uint32_t FixupStart = 0;
101 uint32_t FixupEnd = 0;
102
103 // Track content and fixups for the optional variable-size tail part,
104 // typically modified during relaxation.
105 uint32_t VarContentStart = 0;
106 uint32_t VarContentEnd = 0;
107 uint32_t VarFixupStart = 0;
108
109 const MCSubtargetInfo *STI = nullptr;
110
111 // Optional variable-size tail used by various fragment types.
112 union Tail {
113 struct {
114 uint32_t Opcode;
115 uint32_t Flags;
116 uint32_t OperandStart;
117 uint32_t OperandSize;
118 } relax;
119 struct {
120 // The alignment to ensure, in bytes.
121 Align Alignment;
122 // The size of the integer (in bytes) of \p Value.
123 uint8_t FillLen;
124 // If true, fill with target-specific nop instructions.
125 bool EmitNops;
126 // The maximum number of bytes to emit; if the alignment
127 // cannot be satisfied in this width then this fragment is ignored.
128 unsigned MaxBytesToEmit;
129 // Value to use for filling padding bytes.
130 int64_t Fill;
131 } align;
132 struct {
133 // True if this is a sleb128, false if uleb128.
134 bool IsSigned;
135 // The value this fragment should contain.
136 const MCExpr *Value;
137 } leb;
138 // Used by .debug_frame and .debug_line to encode an address difference.
139 struct {
140 // The address difference between two labels.
141 const MCExpr *AddrDelta;
142 // The value of the difference between the two line numbers between two
143 // .loc dwarf directives.
144 int64_t LineDelta;
145 } dwarf;
146 } u{};
147
148public:
150 bool HasInstructions = false);
151 MCFragment(const MCFragment &) = delete;
152 MCFragment &operator=(const MCFragment &) = delete;
153
154 MCFragment *getNext() const { return Next; }
155
156 FragmentType getKind() const { return Kind; }
157
158 MCSection *getParent() const { return Parent; }
159 void setParent(MCSection *Value) { Parent = Value; }
160
161 LLVM_ABI const MCSymbol *getAtom() const;
162
163 unsigned getLayoutOrder() const { return LayoutOrder; }
164 void setLayoutOrder(unsigned Value) { LayoutOrder = Value; }
165
166 /// Does this fragment have instructions emitted into it? By default
167 /// this is false, but specific fragment types may set it to true.
168 bool hasInstructions() const { return HasInstructions; }
169
170 LLVM_ABI void dump() const;
171
172 /// Retrieve the MCSubTargetInfo in effect when the instruction was encoded.
173 /// Guaranteed to be non-null if hasInstructions() == true
174 const MCSubtargetInfo *getSubtargetInfo() const { return STI; }
175
176 /// Record that the fragment contains instructions with the MCSubtargetInfo in
177 /// effect when the instruction was encoded.
179 HasInstructions = true;
180 this->STI = &STI;
181 }
182
183 bool isLinkerRelaxable() const { return LinkerRelaxable; }
184 void setLinkerRelaxable() { LinkerRelaxable = true; }
185
186 bool getAllowAutoPadding() const { return AllowAutoPadding; }
187 void setAllowAutoPadding(bool V) { AllowAutoPadding = V; }
188
189 //== Content-related functions manage parent's storage using ContentStart and
190 // ContentSize.
191
194
199
200 size_t getFixedSize() const { return FixedSize; }
201 size_t getVarSize() const { return VarContentEnd - VarContentStart; }
202 size_t getSize() const {
203 return FixedSize + (VarContentEnd - VarContentStart);
204 }
205
206 //== Fixup-related functions manage parent's storage using FixupStart and
207 // FixupSize.
208 void clearFixups() { FixupEnd = FixupStart; }
213
214 // Source fixup offsets are relative to the variable part's start.
215 // Stored fixup offsets are relative to the fixed part's start.
220
221 //== FT_Relaxable functions
222 unsigned getOpcode() const {
223 assert(Kind == FT_Relaxable);
224 return u.relax.Opcode;
225 }
227 MCInst getInst() const;
228 void setInst(const MCInst &Inst);
229
230 //== FT_Align functions
231 void makeAlign(Align Alignment, int64_t Fill, uint8_t FillLen,
232 unsigned MaxBytesToEmit) {
233 Kind = FT_Align;
234 u.align.EmitNops = false;
235 u.align.Alignment = Alignment;
236 u.align.Fill = Fill;
237 u.align.FillLen = FillLen;
238 u.align.MaxBytesToEmit = MaxBytesToEmit;
239 }
240
242 assert(Kind == FT_Align);
243 return u.align.Alignment;
244 }
245 int64_t getAlignFill() const {
246 assert(Kind == FT_Align);
247 return u.align.Fill;
248 }
250 assert(Kind == FT_Align);
251 return u.align.FillLen;
252 }
253 unsigned getAlignMaxBytesToEmit() const {
254 assert(Kind == FT_Align);
255 return u.align.MaxBytesToEmit;
256 }
257 bool hasAlignEmitNops() const {
258 assert(Kind == FT_Align);
259 return u.align.EmitNops;
260 }
261
262 //== FT_LEB functions
263 void makeLEB(bool IsSigned, const MCExpr *Value) {
264 assert(Kind == FT_Data);
265 Kind = MCFragment::FT_LEB;
266 u.leb.IsSigned = IsSigned;
267 u.leb.Value = Value;
268 }
269 const MCExpr &getLEBValue() const {
270 assert(Kind == FT_LEB);
271 return *u.leb.Value;
272 }
273 void setLEBValue(const MCExpr *Expr) {
274 assert(Kind == FT_LEB);
275 u.leb.Value = Expr;
276 }
277 bool isLEBSigned() const {
278 assert(Kind == FT_LEB);
279 return u.leb.IsSigned;
280 }
281
282 //== FT_DwarfFrame functions
283 const MCExpr &getDwarfAddrDelta() const {
284 assert(Kind == FT_Dwarf || Kind == FT_DwarfFrame);
285 return *u.dwarf.AddrDelta;
286 }
288 assert(Kind == FT_Dwarf || Kind == FT_DwarfFrame);
289 u.dwarf.AddrDelta = E;
290 }
291 int64_t getDwarfLineDelta() const {
292 assert(Kind == FT_Dwarf);
293 return u.dwarf.LineDelta;
294 }
295 void setDwarfLineDelta(int64_t LineDelta) {
296 assert(Kind == FT_Dwarf);
297 u.dwarf.LineDelta = LineDelta;
298 }
299};
300
301// MCFragment subclasses do not use the fixed-size part or variable-size tail of
302// MCFragment. Instead, they encode content in a specialized way.
303
305 uint8_t ValueSize;
306 /// Value to use for filling bytes.
308 /// The number of bytes to insert.
309 const MCExpr &NumValues;
310
311 /// Source location of the directive that this fragment was created for.
312 SMLoc Loc;
313
314public:
315 MCFillFragment(uint64_t Value, uint8_t VSize, const MCExpr &NumValues,
316 SMLoc Loc)
317 : MCFragment(FT_Fill), ValueSize(VSize), Value(Value),
318 NumValues(NumValues), Loc(Loc) {}
319
320 uint64_t getValue() const { return Value; }
321 uint8_t getValueSize() const { return ValueSize; }
322 const MCExpr &getNumValues() const { return NumValues; }
323
324 SMLoc getLoc() const { return Loc; }
325
326 static bool classof(const MCFragment *F) {
327 return F->getKind() == MCFragment::FT_Fill;
328 }
329};
330
332 /// The number of bytes to insert.
333 int64_t Size;
334 /// Maximum number of bytes allowed in each NOP instruction.
335 int64_t ControlledNopLength;
336
337 /// Source location of the directive that this fragment was created for.
338 SMLoc Loc;
339
340 /// When emitting Nops some subtargets have specific nop encodings.
341 const MCSubtargetInfo &STI;
342
343public:
344 MCNopsFragment(int64_t NumBytes, int64_t ControlledNopLength, SMLoc L,
345 const MCSubtargetInfo &STI)
346 : MCFragment(FT_Nops), Size(NumBytes),
347 ControlledNopLength(ControlledNopLength), Loc(L), STI(STI) {}
348
349 int64_t getNumBytes() const { return Size; }
350 int64_t getControlledNopLength() const { return ControlledNopLength; }
351
352 SMLoc getLoc() const { return Loc; }
353
354 const MCSubtargetInfo *getSubtargetInfo() const { return &STI; }
355
356 static bool classof(const MCFragment *F) {
357 return F->getKind() == MCFragment::FT_Nops;
358 }
359};
360
361class MCOrgFragment : public MCFragment {
362 /// Value to use for filling bytes.
363 int8_t Value;
364
365 /// The offset this fragment should start at.
366 const MCExpr *Offset;
367
368 /// Source location of the directive that this fragment was created for.
369 SMLoc Loc;
370
371public:
372 MCOrgFragment(const MCExpr &Offset, int8_t Value, SMLoc Loc)
373 : MCFragment(FT_Org), Value(Value), Offset(&Offset), Loc(Loc) {}
374
375 const MCExpr &getOffset() const { return *Offset; }
376 uint8_t getValue() const { return Value; }
377
378 SMLoc getLoc() const { return Loc; }
379
380 static bool classof(const MCFragment *F) {
381 return F->getKind() == MCFragment::FT_Org;
382 }
383};
384
385/// Represents a symbol table index fragment.
387 const MCSymbol *Sym;
388
389public:
391
392 const MCSymbol *getSymbol() { return Sym; }
393 const MCSymbol *getSymbol() const { return Sym; }
394
395 static bool classof(const MCFragment *F) {
396 return F->getKind() == MCFragment::FT_SymbolId;
397 }
398};
399
400/// Fragment representing the binary annotations produced by the
401/// .cv_inline_linetable directive.
403 unsigned SiteFuncId;
404 unsigned StartFileId;
405 unsigned StartLineNum;
406 const MCSymbol *FnStartSym;
407 const MCSymbol *FnEndSym;
408
409 /// CodeViewContext has the real knowledge about this format, so let it access
410 /// our members.
411 friend class CodeViewContext;
412
413public:
414 MCCVInlineLineTableFragment(unsigned SiteFuncId, unsigned StartFileId,
415 unsigned StartLineNum, const MCSymbol *FnStartSym,
416 const MCSymbol *FnEndSym)
417 : MCFragment(FT_CVInlineLines), SiteFuncId(SiteFuncId),
418 StartFileId(StartFileId), StartLineNum(StartLineNum),
419 FnStartSym(FnStartSym), FnEndSym(FnEndSym) {}
420
421 const MCSymbol *getFnStartSym() const { return FnStartSym; }
422 const MCSymbol *getFnEndSym() const { return FnEndSym; }
423
424 static bool classof(const MCFragment *F) {
425 return F->getKind() == MCFragment::FT_CVInlineLines;
426 }
427};
428
429/// Fragment representing the .cv_def_range directive.
432 StringRef FixedSizePortion;
433
434 /// CodeViewContext has the real knowledge about this format, so let it access
435 /// our members.
436 friend class CodeViewContext;
437
438public:
440 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
441 StringRef FixedSizePortion)
442 : MCFragment(FT_CVDefRange), Ranges(Ranges.begin(), Ranges.end()),
443 FixedSizePortion(FixedSizePortion) {}
444
446 return Ranges;
447 }
448
449 StringRef getFixedSizePortion() const { return FixedSizePortion; }
450
451 static bool classof(const MCFragment *F) {
452 return F->getKind() == MCFragment::FT_CVDefRange;
453 }
454};
455
456/// Represents required padding such that a particular other set of fragments
457/// does not cross a particular power-of-two boundary. The other fragments must
458/// follow this one within the same section.
460 /// The alignment requirement of the branch to be aligned.
461 Align AlignBoundary;
462 /// The last fragment in the set of fragments to be aligned.
463 const MCFragment *LastFragment = nullptr;
464 /// The size of the fragment. The size is lazily set during relaxation, and
465 /// is not meaningful before that.
466 uint64_t Size = 0;
467
468 /// When emitting Nops some subtargets have specific nop encodings.
469 const MCSubtargetInfo &STI;
470
471public:
473 : MCFragment(FT_BoundaryAlign), AlignBoundary(AlignBoundary), STI(STI) {}
474
475 uint64_t getSize() const { return Size; }
476 void setSize(uint64_t Value) { Size = Value; }
477
478 Align getAlignment() const { return AlignBoundary; }
479 void setAlignment(Align Value) { AlignBoundary = Value; }
480
481 const MCFragment *getLastFragment() const { return LastFragment; }
483 assert(!F || getParent() == F->getParent());
484 LastFragment = F;
485 }
486
487 const MCSubtargetInfo *getSubtargetInfo() const { return &STI; }
488
489 static bool classof(const MCFragment *F) {
490 return F->getKind() == MCFragment::FT_BoundaryAlign;
491 }
492};
493
494/// Instances of this class represent a uniqued identifier for a section in the
495/// current translation unit. The MCContext class uniques and creates these.
497public:
500 friend class MCFragment;
501 static constexpr unsigned NonUniqueID = ~0U;
502
503 struct iterator {
504 MCFragment *F = nullptr;
505 iterator() = default;
506 explicit iterator(MCFragment *F) : F(F) {}
507 MCFragment &operator*() const { return *F; }
508 bool operator==(const iterator &O) const { return F == O.F; }
509 bool operator!=(const iterator &O) const { return F != O.F; }
510 iterator &operator++();
511 };
512
513 struct FragList {
514 MCFragment *Head = nullptr;
515 MCFragment *Tail = nullptr;
516 };
517
518private:
519 // At parse time, this holds the fragment list of the current subsection. At
520 // layout time, this holds the concatenated fragment lists of all subsections.
521 FragList *CurFragList;
522 // In many object file formats, this denotes the section symbol. In Mach-O,
523 // this denotes an optional temporary label at the section start.
524 MCSymbol *Begin;
525 MCSymbol *End = nullptr;
526 /// The alignment requirement of this section.
527 Align Alignment;
528 /// The section index in the assemblers section list.
529 unsigned Ordinal = 0;
530 // If not -1u, the first linker-relaxable fragment's order within the
531 // subsection. When present, the offset between two locations crossing this
532 // fragment may not be fully resolved.
533 unsigned FirstLinkerRelaxable = -1u;
534
535 /// Whether this section has had instructions emitted into it.
536 bool HasInstructions : 1;
537
538 bool IsRegistered : 1;
539
540 bool IsText : 1;
541 bool IsBss : 1;
542
543 MCFragment DummyFragment;
544
545 // Mapping from subsection number to fragment list. At layout time, the
546 // subsection 0 list is replaced with concatenated fragments from all
547 // subsections.
549
550 // Content and fixup storage for fragments
551 SmallVector<char, 0> ContentStorage;
552 SmallVector<MCFixup, 0> FixupStorage;
553 SmallVector<MCOperand, 0> MCOperandStorage;
554
555protected:
556 // TODO Make Name private when possible.
558
559 MCSection(StringRef Name, bool IsText, bool IsBss, MCSymbol *Begin);
560
561public:
562 MCSection(const MCSection &) = delete;
563 MCSection &operator=(const MCSection &) = delete;
564
565 StringRef getName() const { return Name; }
566 bool isText() const { return IsText; }
567
568 MCSymbol *getBeginSymbol() { return Begin; }
569 const MCSymbol *getBeginSymbol() const {
570 return const_cast<MCSection *>(this)->getBeginSymbol();
571 }
573 assert(!Begin);
574 Begin = Sym;
575 }
576 MCSymbol *getEndSymbol(MCContext &Ctx);
577 bool hasEnded() const;
578
579 Align getAlign() const { return Alignment; }
580 void setAlignment(Align Value) { Alignment = Value; }
581
582 /// Makes sure that Alignment is at least MinAlignment.
583 void ensureMinAlignment(Align MinAlignment) {
584 if (Alignment < MinAlignment)
585 Alignment = MinAlignment;
586 }
587
588 unsigned getOrdinal() const { return Ordinal; }
589 void setOrdinal(unsigned Value) { Ordinal = Value; }
590
591 bool hasInstructions() const { return HasInstructions; }
592 void setHasInstructions(bool Value) { HasInstructions = Value; }
593
594 bool isRegistered() const { return IsRegistered; }
595 void setIsRegistered(bool Value) { IsRegistered = Value; }
596
597 unsigned firstLinkerRelaxable() const { return FirstLinkerRelaxable; }
598 bool isLinkerRelaxable() const { return FirstLinkerRelaxable != -1u; }
599 void setFirstLinkerRelaxable(unsigned Order) { FirstLinkerRelaxable = Order; }
600
601 MCFragment &getDummyFragment() { return DummyFragment; }
602
603 FragList *curFragList() const { return CurFragList; }
604 iterator begin() const { return iterator(CurFragList->Head); }
605 iterator end() const { return {}; }
606
608 *FragToSyms = nullptr) const;
609
610 /// Check whether this section is "virtual", that is has no actual object
611 /// file contents.
612 bool isBssSection() const { return IsBss; }
613};
614
616 return {reinterpret_cast<char *>(this + 1), FixedSize};
617}
619 return {reinterpret_cast<const char *>(this + 1), FixedSize};
620}
621
623 return MutableArrayRef(getParent()->ContentStorage)
624 .slice(VarContentStart, VarContentEnd - VarContentStart);
625}
627 return ArrayRef(getParent()->ContentStorage)
628 .slice(VarContentStart, VarContentEnd - VarContentStart);
629}
630
631//== Fixup-related functions manage parent's storage using FixupStart and
632// FixupSize.
634 return MutableArrayRef(getParent()->FixupStorage)
635 .slice(FixupStart, FixupEnd - FixupStart);
636}
638 return ArrayRef(getParent()->FixupStorage)
639 .slice(FixupStart, FixupEnd - FixupStart);
640}
641
643 return MutableArrayRef(getParent()->FixupStorage)
644 .slice(VarFixupStart, VarFixupSize);
645}
647 return ArrayRef(getParent()->FixupStorage).slice(VarFixupStart, VarFixupSize);
648}
649
650//== FT_Relaxable functions
652 assert(Kind == FT_Relaxable);
653 return MutableArrayRef(getParent()->MCOperandStorage)
654 .slice(u.relax.OperandStart, u.relax.OperandSize);
655}
657 assert(Kind == FT_Relaxable);
658 MCInst Inst;
659 Inst.setOpcode(u.relax.Opcode);
660 Inst.setFlags(u.relax.Flags);
661 Inst.setOperands(ArrayRef(getParent()->MCOperandStorage)
662 .slice(u.relax.OperandStart, u.relax.OperandSize));
663 return Inst;
664}
665inline void MCFragment::setInst(const MCInst &Inst) {
666 assert(Kind == FT_Relaxable);
667 u.relax.Opcode = Inst.getOpcode();
668 u.relax.Flags = Inst.getFlags();
669 auto &S = getParent()->MCOperandStorage;
670 if (Inst.getNumOperands() > u.relax.OperandSize) {
671 u.relax.OperandStart = S.size();
672 S.resize_for_overwrite(S.size() + Inst.getNumOperands());
673 }
674 u.relax.OperandSize = Inst.getNumOperands();
675 llvm::copy(Inst, S.begin() + u.relax.OperandStart);
676}
677
679 F = F->Next;
680 return *this;
681}
682
683} // end namespace llvm
684
685#endif // LLVM_MC_MCSECTION_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_ABI
Definition: Compiler.h:213
This file defines the DenseMap class.
std::string Name
bool End
Definition: ELF_riscv.cpp:480
uint64_t Offset
Definition: ELF_riscv.cpp:478
Symbol * Sym
Definition: ELF_riscv.cpp:479
#define F(x, y, z)
Definition: MD5.cpp:55
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:41
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:191
Holds state from .cv_file and .cv_loc directives for later emission.
Definition: MCCodeView.h:144
Represents required padding such that a particular other set of fragments does not cross a particular...
Definition: MCSection.h:459
MCBoundaryAlignFragment(Align AlignBoundary, const MCSubtargetInfo &STI)
Definition: MCSection.h:472
uint64_t getSize() const
Definition: MCSection.h:475
void setAlignment(Align Value)
Definition: MCSection.h:479
void setSize(uint64_t Value)
Definition: MCSection.h:476
const MCFragment * getLastFragment() const
Definition: MCSection.h:481
const MCSubtargetInfo * getSubtargetInfo() const
Definition: MCSection.h:487
static bool classof(const MCFragment *F)
Definition: MCSection.h:489
void setLastFragment(const MCFragment *F)
Definition: MCSection.h:482
Fragment representing the .cv_def_range directive.
Definition: MCSection.h:430
MCCVDefRangeFragment(ArrayRef< std::pair< const MCSymbol *, const MCSymbol * > > Ranges, StringRef FixedSizePortion)
Definition: MCSection.h:439
ArrayRef< std::pair< const MCSymbol *, const MCSymbol * > > getRanges() const
Definition: MCSection.h:445
static bool classof(const MCFragment *F)
Definition: MCSection.h:451
StringRef getFixedSizePortion() const
Definition: MCSection.h:449
Fragment representing the binary annotations produced by the .cv_inline_linetable directive.
Definition: MCSection.h:402
static bool classof(const MCFragment *F)
Definition: MCSection.h:424
MCCVInlineLineTableFragment(unsigned SiteFuncId, unsigned StartFileId, unsigned StartLineNum, const MCSymbol *FnStartSym, const MCSymbol *FnEndSym)
Definition: MCSection.h:414
const MCSymbol * getFnStartSym() const
Definition: MCSection.h:421
const MCSymbol * getFnEndSym() const
Definition: MCSection.h:422
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:315
SMLoc getLoc() const
Definition: MCSection.h:324
uint8_t getValueSize() const
Definition: MCSection.h:321
uint64_t getValue() const
Definition: MCSection.h:320
static bool classof(const MCFragment *F)
Definition: MCSection.h:326
const MCExpr & getNumValues() const
Definition: MCSection.h:322
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:283
MutableArrayRef< char > getContents()
Definition: MCSection.h:615
bool getAllowAutoPadding() const
Definition: MCSection.h:186
FragmentType getKind() const
Definition: MCSection.h:156
bool isLinkerRelaxable() const
Definition: MCSection.h:183
void setAllowAutoPadding(bool V)
Definition: MCSection.h:187
unsigned getLayoutOrder() const
Definition: MCSection.h:163
LLVM_ABI MCFragment(FragmentType Kind=MCFragment::FT_Data, bool HasInstructions=false)
Definition: MCFragment.cpp:30
bool hasAlignEmitNops() const
Definition: MCSection.h:257
void setParent(MCSection *Value)
Definition: MCSection.h:159
MCInst getInst() const
Definition: MCSection.h:656
LLVM_ABI const MCSymbol * getAtom() const
Definition: MCFragment.cpp:37
LLVM_ABI void appendFixups(ArrayRef< MCFixup > Fixups)
Definition: MCSection.cpp:73
void setDwarfLineDelta(int64_t LineDelta)
Definition: MCSection.h:295
unsigned getAlignMaxBytesToEmit() const
Definition: MCSection.h:253
int64_t getDwarfLineDelta() const
Definition: MCSection.h:291
bool isLEBSigned() const
Definition: MCSection.h:277
unsigned getOpcode() const
Definition: MCSection.h:222
MutableArrayRef< MCFixup > getFixups()
Definition: MCSection.h:633
void setLayoutOrder(unsigned Value)
Definition: MCSection.h:164
const MCExpr & getLEBValue() const
Definition: MCSection.h:269
LLVM_ABI void dump() const
Definition: MCFragment.cpp:42
size_t getSize() const
Definition: MCSection.h:202
void clearFixups()
Definition: MCSection.h:208
MCSection * getParent() const
Definition: MCSection.h:158
void makeAlign(Align Alignment, int64_t Fill, uint8_t FillLen, unsigned MaxBytesToEmit)
Definition: MCSection.h:231
LLVM_ABI void setVarFixups(ArrayRef< MCFixup > Fixups)
Definition: MCSection.cpp:87
MCFragment * getNext() const
Definition: MCSection.h:154
MCFragment(const MCFragment &)=delete
void clearVarFixups()
Definition: MCSection.h:217
ArrayRef< MCOperand > getOperands() const
Definition: MCSection.h:651
LLVM_ABI void addFixup(MCFixup Fixup)
Definition: MCSection.cpp:71
void setLinkerRelaxable()
Definition: MCSection.h:184
Align getAlignment() const
Definition: MCSection.h:241
size_t getFixedSize() const
Definition: MCSection.h:200
int64_t getAlignFill() const
Definition: MCSection.h:245
MCFragment & operator=(const MCFragment &)=delete
void makeLEB(bool IsSigned, const MCExpr *Value)
Definition: MCSection.h:263
bool hasInstructions() const
Does this fragment have instructions emitted into it? By default this is false, but specific fragment...
Definition: MCSection.h:168
uint8_t getAlignFillLen() const
Definition: MCSection.h:249
void setDwarfAddrDelta(const MCExpr *E)
Definition: MCSection.h:287
void setLEBValue(const MCExpr *Expr)
Definition: MCSection.h:273
size_t getVarSize() const
Definition: MCSection.h:201
LLVM_ABI void setVarContents(ArrayRef< char > Contents)
Definition: MCSection.cpp:61
MutableArrayRef< char > getVarContents()
Definition: MCSection.h:622
const MCSubtargetInfo * getSubtargetInfo() const
Retrieve the MCSubTargetInfo in effect when the instruction was encoded.
Definition: MCSection.h:174
void setHasInstructions(const MCSubtargetInfo &STI)
Record that the fragment contains instructions with the MCSubtargetInfo in effect when the instructio...
Definition: MCSection.h:178
MutableArrayRef< MCFixup > getVarFixups()
Definition: MCSection.h:642
void setInst(const MCInst &Inst)
Definition: MCSection.h:665
void clearVarContents()
Definition: MCSection.h:196
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:350
int64_t getNumBytes() const
Definition: MCSection.h:349
MCNopsFragment(int64_t NumBytes, int64_t ControlledNopLength, SMLoc L, const MCSubtargetInfo &STI)
Definition: MCSection.h:344
static bool classof(const MCFragment *F)
Definition: MCSection.h:356
const MCSubtargetInfo * getSubtargetInfo() const
Definition: MCSection.h:354
SMLoc getLoc() const
Definition: MCSection.h:352
Streaming object file generation interface.
SMLoc getLoc() const
Definition: MCSection.h:378
static bool classof(const MCFragment *F)
Definition: MCSection.h:380
uint8_t getValue() const
Definition: MCSection.h:376
const MCExpr & getOffset() const
Definition: MCSection.h:375
MCOrgFragment(const MCExpr &Offset, int8_t Value, SMLoc Loc)
Definition: MCSection.h:372
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:496
void setAlignment(Align Value)
Definition: MCSection.h:580
unsigned getOrdinal() const
Definition: MCSection.h:588
friend MCObjectStreamer
Definition: MCSection.h:499
void ensureMinAlignment(Align MinAlignment)
Makes sure that Alignment is at least MinAlignment.
Definition: MCSection.h:583
bool isBssSection() const
Check whether this section is "virtual", that is has no actual object file contents.
Definition: MCSection.h:612
Align getAlign() const
Definition: MCSection.h:579
bool isLinkerRelaxable() const
Definition: MCSection.h:598
const MCSymbol * getBeginSymbol() const
Definition: MCSection.h:569
bool hasInstructions() const
Definition: MCSection.h:591
bool isRegistered() const
Definition: MCSection.h:594
void setHasInstructions(bool Value)
Definition: MCSection.h:592
void setBeginSymbol(MCSymbol *Sym)
Definition: MCSection.h:572
MCSection(const MCSection &)=delete
friend MCAssembler
Definition: MCSection.h:498
void setOrdinal(unsigned Value)
Definition: MCSection.h:589
bool isText() const
Definition: MCSection.h:566
StringRef Name
Definition: MCSection.h:557
iterator end() const
Definition: MCSection.h:605
MCSection & operator=(const MCSection &)=delete
StringRef getName() const
Definition: MCSection.h:565
MCFragment & getDummyFragment()
Definition: MCSection.h:601
unsigned firstLinkerRelaxable() const
Definition: MCSection.h:597
FragList * curFragList() const
Definition: MCSection.h:603
MCSymbol * getBeginSymbol()
Definition: MCSection.h:568
iterator begin() const
Definition: MCSection.h:604
void setIsRegistered(bool Value)
Definition: MCSection.h:595
void setFirstLinkerRelaxable(unsigned Order)
Definition: MCSection.h:599
Streaming machine code generation interface.
Definition: MCStreamer.h:220
Generic base class for all target subtargets.
Represents a symbol table index fragment.
Definition: MCSection.h:386
const MCSymbol * getSymbol() const
Definition: MCSection.h:393
MCSymbolIdFragment(const MCSymbol *Sym)
Definition: MCSection.h:390
static bool classof(const MCFragment *F)
Definition: MCSection.h:395
const MCSymbol * getSymbol()
Definition: MCSection.h:392
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:303
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:381
Represents a location in source code.
Definition: SMLoc.h:23
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1197
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
LLVM Value Representation.
Definition: Value.h:75
@ Tail
Attemps to make calls as fast as possible while guaranteeing that tail call optimization can always b...
Definition: CallingConv.h:76
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
OutputIt copy(R &&Range, OutputIt Out)
Definition: STLExtras.h:1854
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:507
bool operator==(const iterator &O) const
Definition: MCSection.h:508
bool operator!=(const iterator &O) const
Definition: MCSection.h:509
iterator(MCFragment *F)
Definition: MCSection.h:506
iterator & operator++()
Definition: MCSection.h:678