1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | #ifndef LLVM_MC_MCASMINFO_H |
17 | #define LLVM_MC_MCASMINFO_H |
18 | |
19 | #include "llvm/MC/MCDirectives.h" |
20 | #include "llvm/MC/MCDwarf.h" |
21 | #include <cassert> |
22 | #include <vector> |
23 | |
24 | namespace llvm { |
25 | class MCExpr; |
26 | class MCSection; |
27 | class MCStreamer; |
28 | class MCSymbol; |
29 | class MCContext; |
30 | |
31 | namespace WinEH { |
32 | enum class EncodingType { |
33 | Invalid, |
34 | Alpha, |
35 | Alpha64, |
36 | ARM, |
37 | CE, |
38 | Itanium, |
39 | X86, |
40 | MIPS = Alpha, |
41 | }; |
42 | } |
43 | |
44 | enum class ExceptionHandling { |
45 | None, |
46 | DwarfCFI, |
47 | SjLj, |
48 | ARM, |
49 | WinEH, |
50 | }; |
51 | |
52 | namespace LCOMM { |
53 | enum LCOMMType { NoAlignment, ByteAlignment, Log2Alignment }; |
54 | } |
55 | |
56 | enum class DebugCompressionType { |
57 | DCT_None, |
58 | DCT_Zlib, |
59 | DCT_ZlibGnu |
60 | }; |
61 | |
62 | |
63 | |
64 | class MCAsmInfo { |
| Excessive padding in 'class llvm::MCAsmInfo' (32 padding bytes, where 0 is optimal). Consider reordering the fields or adding explicit padding members |
65 | protected: |
66 | |
67 | |
68 | |
69 | |
70 | |
71 | unsigned PointerSize; |
72 | |
73 | |
74 | |
75 | unsigned CalleeSaveStackSlotSize; |
76 | |
77 | |
78 | bool IsLittleEndian; |
79 | |
80 | |
81 | bool StackGrowsUp; |
82 | |
83 | |
84 | |
85 | bool HasSubsectionsViaSymbols; |
86 | |
87 | |
88 | |
89 | bool HasMachoZeroFillDirective; |
90 | |
91 | |
92 | |
93 | bool HasMachoTBSSDirective; |
94 | |
95 | |
96 | |
97 | |
98 | |
99 | bool HasStaticCtorDtorReferenceInStaticMode; |
100 | |
101 | |
102 | |
103 | unsigned MaxInstLength; |
104 | |
105 | |
106 | |
107 | unsigned MinInstAlignment; |
108 | |
109 | |
110 | |
111 | bool DollarIsPC; |
112 | |
113 | |
114 | |
115 | const char *SeparatorString; |
116 | |
117 | |
118 | |
119 | const char *CommentString; |
120 | |
121 | |
122 | const char *LabelSuffix; |
123 | |
124 | |
125 | bool UseAssignmentForEHBegin; |
126 | |
127 | |
128 | bool NeedsLocalForSize; |
129 | |
130 | |
131 | |
132 | |
133 | const char *PrivateGlobalPrefix; |
134 | |
135 | |
136 | |
137 | const char *PrivateLabelPrefix; |
138 | |
139 | |
140 | |
141 | |
142 | |
143 | const char *LinkerPrivateGlobalPrefix; |
144 | |
145 | |
146 | |
147 | const char *InlineAsmStart; |
148 | const char *InlineAsmEnd; |
149 | |
150 | |
151 | |
152 | |
153 | const char *Code16Directive; |
154 | const char *Code32Directive; |
155 | const char *Code64Directive; |
156 | |
157 | |
158 | unsigned AssemblerDialect; |
159 | |
160 | |
161 | |
162 | bool AllowAtInName; |
163 | |
164 | |
165 | |
166 | bool SupportsQuotedNames; |
167 | |
168 | |
169 | |
170 | |
171 | bool UseDataRegionDirectives; |
172 | |
173 | |
174 | |
175 | |
176 | |
177 | |
178 | |
179 | const char *ZeroDirective; |
180 | |
181 | |
182 | |
183 | const char *AsciiDirective; |
184 | |
185 | |
186 | |
187 | |
188 | const char *AscizDirective; |
189 | |
190 | |
191 | |
192 | |
193 | |
194 | const char *Data8bitsDirective; |
195 | const char *Data16bitsDirective; |
196 | const char *Data32bitsDirective; |
197 | const char *Data64bitsDirective; |
198 | |
199 | |
200 | |
201 | |
202 | const char *GPRel64Directive; |
203 | |
204 | |
205 | |
206 | |
207 | const char *GPRel32Directive; |
208 | |
209 | |
210 | |
211 | |
212 | bool SunStyleELFSectionSwitchSyntax; |
213 | |
214 | |
215 | |
216 | |
217 | bool UsesELFSectionDirectiveForBSS; |
218 | |
219 | bool NeedsDwarfSectionOffsetDirective; |
220 | |
221 | |
222 | |
223 | |
224 | |
225 | |
226 | |
227 | bool AlignmentIsInBytes; |
228 | |
229 | |
230 | |
231 | unsigned TextAlignFillValue; |
232 | |
233 | |
234 | |
235 | |
236 | |
237 | const char *GlobalDirective; |
238 | |
239 | |
240 | |
241 | |
242 | |
243 | |
244 | bool SetDirectiveSuppressesReloc; |
245 | |
246 | |
247 | |
248 | |
249 | |
250 | |
251 | |
252 | |
253 | |
254 | |
255 | |
256 | |
257 | |
258 | |
259 | bool HasAggressiveSymbolFolding; |
260 | |
261 | |
262 | |
263 | bool COMMDirectiveAlignmentIsInBytes; |
264 | |
265 | |
266 | |
267 | LCOMM::LCOMMType LCOMMDirectiveAlignmentType; |
268 | |
269 | |
270 | |
271 | bool HasFunctionAlignment; |
272 | |
273 | |
274 | |
275 | bool HasDotTypeDotSizeDirective; |
276 | |
277 | |
278 | |
279 | bool HasSingleParameterDotFile; |
280 | |
281 | |
282 | |
283 | bool HasIdentDirective; |
284 | |
285 | |
286 | |
287 | bool HasNoDeadStrip; |
288 | |
289 | |
290 | |
291 | bool HasAltEntry; |
292 | |
293 | |
294 | const char *WeakDirective; |
295 | |
296 | |
297 | |
298 | const char *WeakRefDirective; |
299 | |
300 | |
301 | |
302 | bool HasWeakDefDirective; |
303 | |
304 | |
305 | |
306 | bool HasWeakDefCanBeHiddenDirective; |
307 | |
308 | |
309 | |
310 | bool HasLinkOnceDirective; |
311 | |
312 | |
313 | |
314 | MCSymbolAttr HiddenVisibilityAttr; |
315 | |
316 | |
317 | |
318 | MCSymbolAttr HiddenDeclarationVisibilityAttr; |
319 | |
320 | |
321 | |
322 | MCSymbolAttr ProtectedVisibilityAttr; |
323 | |
324 | |
325 | |
326 | |
327 | |
328 | bool SupportsDebugInformation; |
329 | |
330 | |
331 | ExceptionHandling ExceptionsType; |
332 | |
333 | |
334 | WinEH::EncodingType WinEHEncodingType; |
335 | |
336 | |
337 | |
338 | bool DwarfUsesRelocationsAcrossSections; |
339 | |
340 | |
341 | |
342 | bool DwarfFDESymbolsUseAbsDiff; |
343 | |
344 | |
345 | |
346 | bool DwarfRegNumForCFI; |
347 | |
348 | |
349 | |
350 | bool UseParensForSymbolVariant; |
351 | |
352 | |
353 | |
354 | std::vector<MCCFIInstruction> InitialFrameState; |
355 | |
356 | |
357 | |
358 | |
359 | |
360 | |
361 | |
362 | |
363 | bool UseIntegratedAssembler; |
364 | |
365 | |
366 | DebugCompressionType CompressDebugSections; |
367 | |
368 | |
369 | |
370 | bool UseLogicalShr; |
371 | |
372 | |
373 | |
374 | bool RelaxELFRelocations = false; |
375 | |
376 | public: |
377 | explicit MCAsmInfo(); |
378 | virtual ~MCAsmInfo(); |
379 | |
380 | |
381 | unsigned getPointerSize() const { return PointerSize; } |
382 | |
383 | |
384 | |
385 | unsigned getCalleeSaveStackSlotSize() const { |
386 | return CalleeSaveStackSlotSize; |
387 | } |
388 | |
389 | |
390 | bool isLittleEndian() const { return IsLittleEndian; } |
391 | |
392 | |
393 | bool isStackGrowthDirectionUp() const { return StackGrowsUp; } |
394 | |
395 | bool hasSubsectionsViaSymbols() const { return HasSubsectionsViaSymbols; } |
396 | |
397 | |
398 | |
399 | const char *getData8bitsDirective() const { return Data8bitsDirective; } |
400 | const char *getData16bitsDirective() const { return Data16bitsDirective; } |
401 | const char *getData32bitsDirective() const { return Data32bitsDirective; } |
402 | const char *getData64bitsDirective() const { return Data64bitsDirective; } |
403 | const char *getGPRel64Directive() const { return GPRel64Directive; } |
404 | const char *getGPRel32Directive() const { return GPRel32Directive; } |
405 | |
406 | |
407 | |
408 | |
409 | virtual MCSection *getNonexecutableStackSection(MCContext &Ctx) const { |
410 | return nullptr; |
411 | } |
412 | |
413 | |
414 | |
415 | |
416 | |
417 | virtual bool isSectionAtomizableBySymbols(const MCSection &Section) const; |
418 | |
419 | virtual const MCExpr *getExprForPersonalitySymbol(const MCSymbol *Sym, |
420 | unsigned Encoding, |
421 | MCStreamer &Streamer) const; |
422 | |
423 | virtual const MCExpr *getExprForFDESymbol(const MCSymbol *Sym, |
424 | unsigned Encoding, |
425 | MCStreamer &Streamer) const; |
426 | |
427 | |
428 | |
429 | virtual bool isValidUnquotedName(StringRef Name) const; |
430 | |
431 | |
432 | |
433 | |
434 | |
435 | |
436 | |
437 | |
438 | virtual bool shouldOmitSectionDirective(StringRef SectionName) const; |
439 | |
440 | bool usesSunStyleELFSectionSwitchSyntax() const { |
441 | return SunStyleELFSectionSwitchSyntax; |
442 | } |
443 | |
444 | bool usesELFSectionDirectiveForBSS() const { |
445 | return UsesELFSectionDirectiveForBSS; |
446 | } |
447 | |
448 | bool needsDwarfSectionOffsetDirective() const { |
449 | return NeedsDwarfSectionOffsetDirective; |
450 | } |
451 | |
452 | |
453 | |
454 | bool hasMachoZeroFillDirective() const { return HasMachoZeroFillDirective; } |
455 | bool hasMachoTBSSDirective() const { return HasMachoTBSSDirective; } |
456 | bool hasStaticCtorDtorReferenceInStaticMode() const { |
457 | return HasStaticCtorDtorReferenceInStaticMode; |
458 | } |
459 | unsigned getMaxInstLength() const { return MaxInstLength; } |
460 | unsigned getMinInstAlignment() const { return MinInstAlignment; } |
461 | bool getDollarIsPC() const { return DollarIsPC; } |
462 | const char *getSeparatorString() const { return SeparatorString; } |
463 | |
464 | |
465 | |
466 | unsigned getCommentColumn() const { return 40; } |
467 | |
468 | const char *getCommentString() const { return CommentString; } |
469 | const char *getLabelSuffix() const { return LabelSuffix; } |
470 | |
471 | bool useAssignmentForEHBegin() const { return UseAssignmentForEHBegin; } |
472 | bool needsLocalForSize() const { return NeedsLocalForSize; } |
473 | const char *getPrivateGlobalPrefix() const { return PrivateGlobalPrefix; } |
474 | const char *getPrivateLabelPrefix() const { return PrivateLabelPrefix; } |
475 | bool hasLinkerPrivateGlobalPrefix() const { |
476 | return LinkerPrivateGlobalPrefix[0] != '\0'; |
477 | } |
478 | const char *getLinkerPrivateGlobalPrefix() const { |
479 | if (hasLinkerPrivateGlobalPrefix()) |
480 | return LinkerPrivateGlobalPrefix; |
481 | return getPrivateGlobalPrefix(); |
482 | } |
483 | const char *getInlineAsmStart() const { return InlineAsmStart; } |
484 | const char *getInlineAsmEnd() const { return InlineAsmEnd; } |
485 | const char *getCode16Directive() const { return Code16Directive; } |
486 | const char *getCode32Directive() const { return Code32Directive; } |
487 | const char *getCode64Directive() const { return Code64Directive; } |
488 | unsigned getAssemblerDialect() const { return AssemblerDialect; } |
489 | bool doesAllowAtInName() const { return AllowAtInName; } |
490 | bool supportsNameQuoting() const { return SupportsQuotedNames; } |
491 | bool doesSupportDataRegionDirectives() const { |
492 | return UseDataRegionDirectives; |
493 | } |
494 | const char *getZeroDirective() const { return ZeroDirective; } |
495 | const char *getAsciiDirective() const { return AsciiDirective; } |
496 | const char *getAscizDirective() const { return AscizDirective; } |
497 | bool getAlignmentIsInBytes() const { return AlignmentIsInBytes; } |
498 | unsigned getTextAlignFillValue() const { return TextAlignFillValue; } |
499 | const char *getGlobalDirective() const { return GlobalDirective; } |
500 | bool doesSetDirectiveSuppressesReloc() const { |
501 | return SetDirectiveSuppressesReloc; |
502 | } |
503 | bool hasAggressiveSymbolFolding() const { return HasAggressiveSymbolFolding; } |
504 | bool getCOMMDirectiveAlignmentIsInBytes() const { |
505 | return COMMDirectiveAlignmentIsInBytes; |
506 | } |
507 | LCOMM::LCOMMType getLCOMMDirectiveAlignmentType() const { |
508 | return LCOMMDirectiveAlignmentType; |
509 | } |
510 | bool hasFunctionAlignment() const { return HasFunctionAlignment; } |
511 | bool hasDotTypeDotSizeDirective() const { return HasDotTypeDotSizeDirective; } |
512 | bool hasSingleParameterDotFile() const { return HasSingleParameterDotFile; } |
513 | bool hasIdentDirective() const { return HasIdentDirective; } |
514 | bool hasNoDeadStrip() const { return HasNoDeadStrip; } |
515 | bool hasAltEntry() const { return HasAltEntry; } |
516 | const char *getWeakDirective() const { return WeakDirective; } |
517 | const char *getWeakRefDirective() const { return WeakRefDirective; } |
518 | bool hasWeakDefDirective() const { return HasWeakDefDirective; } |
519 | bool hasWeakDefCanBeHiddenDirective() const { |
520 | return HasWeakDefCanBeHiddenDirective; |
521 | } |
522 | bool hasLinkOnceDirective() const { return HasLinkOnceDirective; } |
523 | |
524 | MCSymbolAttr getHiddenVisibilityAttr() const { return HiddenVisibilityAttr; } |
525 | MCSymbolAttr getHiddenDeclarationVisibilityAttr() const { |
526 | return HiddenDeclarationVisibilityAttr; |
527 | } |
528 | MCSymbolAttr getProtectedVisibilityAttr() const { |
529 | return ProtectedVisibilityAttr; |
530 | } |
531 | bool doesSupportDebugInformation() const { return SupportsDebugInformation; } |
532 | bool doesSupportExceptionHandling() const { |
533 | return ExceptionsType != ExceptionHandling::None; |
534 | } |
535 | ExceptionHandling getExceptionHandlingType() const { return ExceptionsType; } |
536 | WinEH::EncodingType getWinEHEncodingType() const { return WinEHEncodingType; } |
537 | |
538 | |
539 | |
540 | bool usesCFIForEH() const { |
541 | return (ExceptionsType == ExceptionHandling::DwarfCFI || |
542 | ExceptionsType == ExceptionHandling::ARM || usesWindowsCFI()); |
543 | } |
544 | |
545 | bool usesWindowsCFI() const { |
546 | return ExceptionsType == ExceptionHandling::WinEH && |
547 | (WinEHEncodingType != WinEH::EncodingType::Invalid && |
548 | WinEHEncodingType != WinEH::EncodingType::X86); |
549 | } |
550 | |
551 | bool doesDwarfUseRelocationsAcrossSections() const { |
552 | return DwarfUsesRelocationsAcrossSections; |
553 | } |
554 | bool doDwarfFDESymbolsUseAbsDiff() const { return DwarfFDESymbolsUseAbsDiff; } |
555 | bool useDwarfRegNumForCFI() const { return DwarfRegNumForCFI; } |
556 | bool useParensForSymbolVariant() const { return UseParensForSymbolVariant; } |
557 | |
558 | void addInitialFrameState(const MCCFIInstruction &Inst) { |
559 | InitialFrameState.push_back(Inst); |
560 | } |
561 | |
562 | const std::vector<MCCFIInstruction> &getInitialFrameState() const { |
563 | return InitialFrameState; |
564 | } |
565 | |
566 | |
567 | bool useIntegratedAssembler() const { return UseIntegratedAssembler; } |
568 | |
569 | |
570 | virtual void setUseIntegratedAssembler(bool Value) { |
571 | UseIntegratedAssembler = Value; |
572 | } |
573 | |
574 | DebugCompressionType compressDebugSections() const { |
575 | return CompressDebugSections; |
576 | } |
577 | |
578 | void setCompressDebugSections(DebugCompressionType CompressDebugSections) { |
579 | this->CompressDebugSections = CompressDebugSections; |
580 | } |
581 | |
582 | bool shouldUseLogicalShr() const { return UseLogicalShr; } |
583 | |
584 | bool canRelaxRelocations() const { return RelaxELFRelocations; } |
585 | void setRelaxELFRelocations(bool V) { RelaxELFRelocations = V; } |
586 | }; |
587 | } |
588 | |
589 | #endif |