LLVM: include/llvm/MC/MCSection.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef LLVM_MC_MCSECTION_H
14#define LLVM_MC_MCSECTION_H
15
25#include
26#include
27
28namespace llvm {
29
41
42
43
44
50
51public:
68
69private:
70
72
73
75
76
78
79
80 unsigned LayoutOrder = 0;
81
82 FragmentType Kind;
83
84
85
86
88
89 bool LinkerRelaxable : 1;
90
91
92 bool HasInstructions : 1;
93
94 bool AllowAutoPadding : 1;
95
96
97
98
99
103
104
105
106 uint32_t VarContentStart = 0;
109
110protected:
112
113private:
114
115 union Tail {
116 struct {
121 } relax;
122 struct {
123
125
127
128 bool EmitNops;
129
130
131 unsigned MaxBytesToEmit;
132
133 int64_t Fill;
134 } align;
135 struct {
136
137 bool IsSigned;
138
140 } leb;
141
142 struct {
143
144 const MCExpr *AddrDelta;
145
146
147 int64_t LineDelta;
149 struct {
150
151 const MCExpr *AddrDelta;
152
155 } u{};
156
157public:
159 bool HasInstructions = false);
162
164
166
169
171
174
175
176
178
180
181
182
184
185
186
188 HasInstructions = true;
189 this->STI = &STI;
190 }
191
194
197
198
199
200
203
208
210 size_t getVarSize() const { return VarContentEnd - VarContentStart; }
212 return FixedSize + (VarContentEnd - VarContentStart);
213 }
214
215
216
222
223
224
229
230
233 return u.relax.Opcode;
234 }
238
239
241 unsigned MaxBytesToEmit) {
243 u.align.EmitNops = false;
244 u.align.Alignment = Alignment;
245 u.align.Fill = Fill;
246 u.align.FillLen = FillLen;
247 u.align.MaxBytesToEmit = MaxBytesToEmit;
248 }
249
252 return u.align.Alignment;
253 }
256 return u.align.Fill;
257 }
260 return u.align.FillLen;
261 }
264 return u.align.MaxBytesToEmit;
265 }
268 return u.align.EmitNops;
269 }
270
271
275 u.leb.IsSigned = IsSigned;
276 u.leb.Value = Value;
277 }
280 return *u.leb.Value;
281 }
284 u.leb.Value = Expr;
285 }
288 return u.leb.IsSigned;
289 }
290
291
294 return *u.dwarf.AddrDelta;
295 }
298 u.dwarf.AddrDelta = E;
299 }
302 return u.dwarf.LineDelta;
303 }
306 u.dwarf.LineDelta = LineDelta;
307 }
308
309
312 return *u.sframe.AddrDelta;
313 }
316 u.sframe.AddrDelta = E;
317 }
320 return u.sframe.FDEFragment;
321 }
324 u.sframe.FDEFragment = F;
325 }
326};
327
328
329
330
333
335
336 const MCExpr &NumValues;
337
338
340
341public:
345 NumValues(NumValues), Loc(Loc) {}
346
350
352
356};
357
359
360 int64_t Size;
361
362 int64_t ControlledNopLength;
363
364
366
367public:
371 ControlledNopLength(ControlledNopLength), Loc(L) {
372 this->STI = &STI;
373 }
374
377
379
383};
384
386
387 int8_t Value;
388
389
390 const MCExpr *Offset;
391
392
394
395public:
398
401
403
407};
408
409
412
413public:
415
418
422};
423
424
425
427 unsigned SiteFuncId;
428 unsigned StartFileId;
429 unsigned StartLineNum;
432
433
434
436
437public:
439 unsigned StartLineNum, const MCSymbol *FnStartSym,
442 StartFileId(StartFileId), StartLineNum(StartLineNum),
443 FnStartSym(FnStartSym), FnEndSym(FnEndSym) {}
444
447
451};
452
453
457
458
459
461
462public:
464 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
467 FixedSizePortion(FixedSizePortion) {}
468
472
474
478};
479
480
481
482
484
485 Align AlignBoundary;
486
487 const MCFragment *LastFragment = nullptr;
488
489
491
492public:
495 this->STI = &STI;
496 }
497
500
503
507 LastFragment = F;
508 }
509
513};
514
515
516
518public:
523
533
538
539private:
540
541
543
544
547
549
550 unsigned Ordinal = 0;
551
552
553
554 unsigned FirstLinkerRelaxable = -1u;
555
556
557 bool HasInstructions : 1;
558
559 bool IsRegistered : 1;
560
561 bool IsText : 1;
562 bool IsBss : 1;
563
565
566
567
568
570
571
575
576protected:
577
579
581
582public:
585
587 bool isText() const { return IsText; }
588
598 bool hasEnded() const;
599
602
603
605 if (Alignment < MinAlignment)
606 Alignment = MinAlignment;
607 }
608
611
614
617
621
623
627
629 *FragToSyms = nullptr) const;
630
631
632
634};
635
637 return {reinterpret_cast<char *>(this + 1), FixedSize};
638}
640 return {reinterpret_cast<const char *>(this + 1), FixedSize};
641}
642
645 .slice(VarContentStart, VarContentEnd - VarContentStart);
646}
649 .slice(VarContentStart, VarContentEnd - VarContentStart);
650}
651
652
653
656 .slice(FixupStart, FixupEnd - FixupStart);
657}
660 .slice(FixupStart, FixupEnd - FixupStart);
661}
662
665 .slice(VarFixupStart, VarFixupSize);
666}
670
671
675 .slice(u.relax.OperandStart, u.relax.OperandSize);
676}
681 Inst.setFlags(u.relax.Flags);
683 .slice(u.relax.OperandStart, u.relax.OperandSize));
684 return Inst;
685}
688 u.relax.Opcode = Inst.getOpcode();
689 u.relax.Flags = Inst.getFlags();
690 auto &S = getParent()->MCOperandStorage;
692 u.relax.OperandStart = S.size();
693 S.resize_for_overwrite(S.size() + Inst.getNumOperands());
694 }
697}
698
701 return *this;
702}
703
704}
705
706#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines the DenseMap class.
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),...
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.
This class is intended to be used as a base class for asm properties and features specific to the tar...
MCBoundaryAlignFragment(Align AlignBoundary, const MCSubtargetInfo &STI)
Definition MCSection.h:493
uint64_t getSize() const
Definition MCSection.h:498
void setAlignment(Align Value)
Definition MCSection.h:502
void setSize(uint64_t Value)
Definition MCSection.h:499
const MCFragment * getLastFragment() const
Definition MCSection.h:504
static bool classof(const MCFragment *F)
Definition MCSection.h:510
Align getAlignment() const
Definition MCSection.h:501
void setLastFragment(const MCFragment *F)
Definition MCSection.h:505
MCCVDefRangeFragment(ArrayRef< std::pair< const MCSymbol *, const MCSymbol * > > Ranges, StringRef FixedSizePortion)
Definition MCSection.h:463
ArrayRef< std::pair< const MCSymbol *, const MCSymbol * > > getRanges() const
Definition MCSection.h:469
static bool classof(const MCFragment *F)
Definition MCSection.h:475
StringRef getFixedSizePortion() const
Definition MCSection.h:473
friend class CodeViewContext
CodeViewContext has the real knowledge about this format, so let it access our members.
Definition MCSection.h:460
static bool classof(const MCFragment *F)
Definition MCSection.h:448
MCCVInlineLineTableFragment(unsigned SiteFuncId, unsigned StartFileId, unsigned StartLineNum, const MCSymbol *FnStartSym, const MCSymbol *FnEndSym)
Definition MCSection.h:438
const MCSymbol * getFnStartSym() const
Definition MCSection.h:445
friend class CodeViewContext
CodeViewContext has the real knowledge about this format, so let it access our members.
Definition MCSection.h:435
const MCSymbol * getFnEndSym() const
Definition MCSection.h:446
Context object for machine code objects.
Base class for the full range of assembler expressions which are needed for parsing.
MCFillFragment(uint64_t Value, uint8_t VSize, const MCExpr &NumValues, SMLoc Loc)
Definition MCSection.h:342
SMLoc getLoc() const
Definition MCSection.h:351
uint8_t getValueSize() const
Definition MCSection.h:348
uint64_t getValue() const
Definition MCSection.h:347
static bool classof(const MCFragment *F)
Definition MCSection.h:353
const MCExpr & getNumValues() const
Definition MCSection.h:349
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition MCSection.h:45
const MCExpr & getDwarfAddrDelta() const
Definition MCSection.h:292
MutableArrayRef< char > getContents()
Definition MCSection.h:636
MCFragment * getSFrameFDE() const
Definition MCSection.h:318
bool getAllowAutoPadding() const
Definition MCSection.h:195
FragmentType getKind() const
Definition MCSection.h:165
bool isLinkerRelaxable() const
Definition MCSection.h:192
void setAllowAutoPadding(bool V)
Definition MCSection.h:196
unsigned getLayoutOrder() const
Definition MCSection.h:172
LLVM_ABI MCFragment(FragmentType Kind=MCFragment::FT_Data, bool HasInstructions=false)
bool hasAlignEmitNops() const
Definition MCSection.h:266
friend class MCObjectStreamer
Definition MCSection.h:48
void setSFrameAddrDelta(const MCExpr *E)
Definition MCSection.h:314
void setParent(MCSection *Value)
Definition MCSection.h:168
MCInst getInst() const
Definition MCSection.h:677
LLVM_ABI const MCSymbol * getAtom() const
LLVM_ABI void appendFixups(ArrayRef< MCFixup > Fixups)
void setDwarfLineDelta(int64_t LineDelta)
Definition MCSection.h:304
unsigned getAlignMaxBytesToEmit() const
Definition MCSection.h:262
int64_t getDwarfLineDelta() const
Definition MCSection.h:300
bool isLEBSigned() const
Definition MCSection.h:286
unsigned getOpcode() const
Definition MCSection.h:231
MutableArrayRef< MCFixup > getFixups()
Definition MCSection.h:654
friend class MCSection
Definition MCSection.h:49
void setLayoutOrder(unsigned Value)
Definition MCSection.h:173
void setSFrameFDE(MCFragment *F)
Definition MCSection.h:322
const MCExpr & getLEBValue() const
Definition MCSection.h:278
LLVM_ABI void dump() const
friend class MCAssembler
Definition MCSection.h:46
size_t getSize() const
Definition MCSection.h:211
void clearFixups()
Definition MCSection.h:217
MCSection * getParent() const
Definition MCSection.h:167
void makeAlign(Align Alignment, int64_t Fill, uint8_t FillLen, unsigned MaxBytesToEmit)
Definition MCSection.h:240
LLVM_ABI void setVarFixups(ArrayRef< MCFixup > Fixups)
MCFragment * getNext() const
Definition MCSection.h:163
const MCSubtargetInfo * STI
Definition MCSection.h:111
MCFragment(const MCFragment &)=delete
void clearVarFixups()
Definition MCSection.h:226
ArrayRef< MCOperand > getOperands() const
Definition MCSection.h:672
LLVM_ABI void addFixup(MCFixup Fixup)
void setLinkerRelaxable()
Definition MCSection.h:193
Align getAlignment() const
Definition MCSection.h:250
size_t getFixedSize() const
Definition MCSection.h:209
friend class MCStreamer
Definition MCSection.h:47
int64_t getAlignFill() const
Definition MCSection.h:254
MCFragment & operator=(const MCFragment &)=delete
void makeLEB(bool IsSigned, const MCExpr *Value)
Definition MCSection.h:272
bool hasInstructions() const
Does this fragment have instructions emitted into it?
Definition MCSection.h:177
uint8_t getAlignFillLen() const
Definition MCSection.h:258
void setDwarfAddrDelta(const MCExpr *E)
Definition MCSection.h:296
void setLEBValue(const MCExpr *Expr)
Definition MCSection.h:282
size_t getVarSize() const
Definition MCSection.h:210
LLVM_ABI void setVarContents(ArrayRef< char > Contents)
MutableArrayRef< char > getVarContents()
Definition MCSection.h:643
FragmentType
Definition MCSection.h:52
@ FT_Dwarf
Definition MCSection.h:60
@ FT_Fill
Definition MCSection.h:56
@ FT_Align
Definition MCSection.h:55
@ FT_DwarfFrame
Definition MCSection.h:61
@ FT_Data
Definition MCSection.h:53
@ FT_SymbolId
Definition MCSection.h:64
@ FT_SFrame
Definition MCSection.h:62
@ FT_CVInlineLines
Definition MCSection.h:65
@ FT_BoundaryAlign
Definition MCSection.h:63
@ FT_CVDefRange
Definition MCSection.h:66
@ FT_Relaxable
Definition MCSection.h:54
@ FT_Org
Definition MCSection.h:59
@ FT_LEB
Definition MCSection.h:57
@ FT_Nops
Definition MCSection.h:58
const MCSubtargetInfo * getSubtargetInfo() const
Retrieve the MCSubTargetInfo in effect when the instruction was encoded.
Definition MCSection.h:183
void setHasInstructions(const MCSubtargetInfo &STI)
Record that the fragment contains instructions with the MCSubtargetInfo in effect when the instructio...
Definition MCSection.h:187
const MCExpr & getSFrameAddrDelta() const
Definition MCSection.h:310
MutableArrayRef< MCFixup > getVarFixups()
Definition MCSection.h:663
void setInst(const MCInst &Inst)
Definition MCSection.h:686
void clearVarContents()
Definition MCSection.h:205
Instances of this class represent a single low-level machine instruction.
unsigned getNumOperands() const
unsigned getFlags() const
unsigned getOpcode() const
void setFlags(unsigned F)
void setOperands(ArrayRef< MCOperand > Ops)
void setOpcode(unsigned Op)
int64_t getControlledNopLength() const
Definition MCSection.h:376
int64_t getNumBytes() const
Definition MCSection.h:375
MCNopsFragment(int64_t NumBytes, int64_t ControlledNopLength, SMLoc L, const MCSubtargetInfo &STI)
Definition MCSection.h:368
static bool classof(const MCFragment *F)
Definition MCSection.h:380
SMLoc getLoc() const
Definition MCSection.h:378
Streaming object file generation interface.
SMLoc getLoc() const
Definition MCSection.h:402
static bool classof(const MCFragment *F)
Definition MCSection.h:404
uint8_t getValue() const
Definition MCSection.h:400
const MCExpr & getOffset() const
Definition MCSection.h:399
MCOrgFragment(const MCExpr &Offset, int8_t Value, SMLoc Loc)
Definition MCSection.h:396
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition MCSection.h:517
void setAlignment(Align Value)
Definition MCSection.h:601
unsigned getOrdinal() const
Definition MCSection.h:609
friend MCObjectStreamer
Definition MCSection.h:520
void ensureMinAlignment(Align MinAlignment)
Makes sure that Alignment is at least MinAlignment.
Definition MCSection.h:604
bool isBssSection() const
Check whether this section is "virtual", that is has no actual object file contents.
Definition MCSection.h:633
Align getAlign() const
Definition MCSection.h:600
bool isLinkerRelaxable() const
Definition MCSection.h:619
static constexpr unsigned NonUniqueID
Definition MCSection.h:522
const MCSymbol * getBeginSymbol() const
Definition MCSection.h:590
bool hasInstructions() const
Definition MCSection.h:612
bool isRegistered() const
Definition MCSection.h:615
void setHasInstructions(bool Value)
Definition MCSection.h:613
void setBeginSymbol(MCSymbol *Sym)
Definition MCSection.h:593
MCSection(const MCSection &)=delete
friend MCAssembler
Definition MCSection.h:519
void setOrdinal(unsigned Value)
Definition MCSection.h:610
bool isText() const
Definition MCSection.h:587
StringRef Name
Definition MCSection.h:578
iterator end() const
Definition MCSection.h:626
MCSection & operator=(const MCSection &)=delete
StringRef getName() const
Definition MCSection.h:586
friend class MCFragment
Definition MCSection.h:521
MCFragment & getDummyFragment()
Definition MCSection.h:622
unsigned firstLinkerRelaxable() const
Definition MCSection.h:618
FragList * curFragList() const
Definition MCSection.h:624
MCSymbol * getBeginSymbol()
Definition MCSection.h:589
iterator begin() const
Definition MCSection.h:625
MCSection(StringRef Name, bool IsText, bool IsBss, MCSymbol *Begin)
void setIsRegistered(bool Value)
Definition MCSection.h:616
void setFirstLinkerRelaxable(unsigned Order)
Definition MCSection.h:620
Generic base class for all target subtargets.
const MCSymbol * getSymbol() const
Definition MCSection.h:417
MCSymbolIdFragment(const MCSymbol *Sym)
Definition MCSection.h:414
static bool classof(const MCFragment *F)
Definition MCSection.h:419
const MCSymbol * getSymbol()
Definition MCSection.h:416
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
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.
Represents a location in source code.
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.
Triple - Helper class for working with autoconf configuration names.
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream.
Calculates the starting offsets for various sections within the .debug_names section.
This is an optimization pass for GlobalISel generic memory operations.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
MutableArrayRef(T &OneElt) -> MutableArrayRef< T >
FunctionAddr VTableAddr Next
ArrayRef(const T &OneElt) -> ArrayRef< T >
OutputIt copy(R &&Range, OutputIt Out)
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition MCSection.h:534
MCFragment * Head
Definition MCSection.h:535
MCFragment * Tail
Definition MCSection.h:536
Definition MCSection.h:524
MCFragment & operator*() const
Definition MCSection.h:528
bool operator==(const iterator &O) const
Definition MCSection.h:529
bool operator!=(const iterator &O) const
Definition MCSection.h:530
iterator(MCFragment *F)
Definition MCSection.h:527
MCFragment * F
Definition MCSection.h:525
iterator & operator++()
Definition MCSection.h:699