1 //===-- llvm/MC/MCAsmInfo.h - Asm info --------------------------*- 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 contains a class to be used as the basis for target specific
10 // asm writers.  This class primarily takes care of global printing constants,
11 // which are used in very similar ways across all targets.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_MC_MCASMINFO_H
16 #define LLVM_MC_MCASMINFO_H
17 
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/MC/MCDirectives.h"
20 #include "llvm/MC/MCTargetOptions.h"
21 #include <vector>
22 
23 namespace llvm {
24 
25 class MCContext;
26 class MCCFIInstruction;
27 class MCExpr;
28 class MCSection;
29 class MCStreamer;
30 class MCSubtargetInfo;
31 class MCSymbol;
32 
33 namespace WinEH {
34 
35 enum class EncodingType {
36   Invalid, /// Invalid
37   Alpha,   /// Windows Alpha
38   Alpha64, /// Windows AXP64
39   ARM,     /// Windows NT (Windows on ARM)
40   CE,      /// Windows CE ARM, PowerPC, SH3, SH4
41   Itanium, /// Windows x64, Windows Itanium (IA-64)
42   X86,     /// Windows x86, uses no CFI, just EH tables
43   MIPS = Alpha,
44 };
45 
46 } // end namespace WinEH
47 
48 namespace LCOMM {
49 
50 enum LCOMMType { NoAlignment, ByteAlignment, Log2Alignment };
51 
52 } // end namespace LCOMM
53 
54 /// This class is intended to be used as a base class for asm
55 /// properties and features specific to the target.
56 class MCAsmInfo {
57 protected:
58   //===------------------------------------------------------------------===//
59   // Properties to be set by the target writer, used to configure asm printer.
60   //
61 
62   /// Code pointer size in bytes.  Default is 4.
63   unsigned CodePointerSize = 4;
64 
65   /// Size of the stack slot reserved for callee-saved registers, in bytes.
66   /// Default is same as pointer size.
67   unsigned CalleeSaveStackSlotSize = 4;
68 
69   /// True if target is little endian.  Default is true.
70   bool IsLittleEndian = true;
71 
72   /// True if target stack grow up.  Default is false.
73   bool StackGrowsUp = false;
74 
75   /// True if this target has the MachO .subsections_via_symbols directive.
76   /// Default is false.
77   bool HasSubsectionsViaSymbols = false;
78 
79   /// True if this is a MachO target that supports the macho-specific .zerofill
80   /// directive for emitting BSS Symbols.  Default is false.
81   bool HasMachoZeroFillDirective = false;
82 
83   /// True if this is a MachO target that supports the macho-specific .tbss
84   /// directive for emitting thread local BSS Symbols.  Default is false.
85   bool HasMachoTBSSDirective = false;
86 
87   /// True if this is a non-GNU COFF target. The COFF port of the GNU linker
88   /// doesn't handle associative comdats in the way that we would like to use
89   /// them.
90   bool HasCOFFAssociativeComdats = false;
91 
92   /// True if this is a non-GNU COFF target. For GNU targets, we don't generate
93   /// constants into comdat sections.
94   bool HasCOFFComdatConstants = false;
95 
96   /// True if this is an XCOFF target that supports visibility attributes as
97   /// part of .global, .weak, .extern, and .comm. Default is false.
98   bool HasVisibilityOnlyWithLinkage = false;
99 
100   /// This is the maximum possible length of an instruction, which is needed to
101   /// compute the size of an inline asm.  Defaults to 4.
102   unsigned MaxInstLength = 4;
103 
104   /// Every possible instruction length is a multiple of this value.  Factored
105   /// out in .debug_frame and .debug_line.  Defaults to 1.
106   unsigned MinInstAlignment = 1;
107 
108   /// The '$' token, when not referencing an identifier or constant, refers to
109   /// the current PC.  Defaults to false.
110   bool DollarIsPC = false;
111 
112   /// This string, if specified, is used to separate instructions from each
113   /// other when on the same line.  Defaults to ';'
114   const char *SeparatorString;
115 
116   /// This indicates the comment character used by the assembler.  Defaults to
117   /// "#"
118   StringRef CommentString;
119 
120   /// This is appended to emitted labels.  Defaults to ":"
121   const char *LabelSuffix;
122 
123   // Print the EH begin symbol with an assignment. Defaults to false.
124   bool UseAssignmentForEHBegin = false;
125 
126   // Do we need to create a local symbol for .size?
127   bool NeedsLocalForSize = false;
128 
129   /// This prefix is used for globals like constant pool entries that are
130   /// completely private to the .s file and should not have names in the .o
131   /// file.  Defaults to "L"
132   StringRef PrivateGlobalPrefix;
133 
134   /// This prefix is used for labels for basic blocks. Defaults to the same as
135   /// PrivateGlobalPrefix.
136   StringRef PrivateLabelPrefix;
137 
138   /// This prefix is used for symbols that should be passed through the
139   /// assembler but be removed by the linker.  This is 'l' on Darwin, currently
140   /// used for some ObjC metadata.  The default of "" meast that for this system
141   /// a plain private symbol should be used.  Defaults to "".
142   StringRef LinkerPrivateGlobalPrefix;
143 
144   /// If these are nonempty, they contain a directive to emit before and after
145   /// an inline assembly statement.  Defaults to "#APP\n", "#NO_APP\n"
146   const char *InlineAsmStart;
147   const char *InlineAsmEnd;
148 
149   /// These are assembly directives that tells the assembler to interpret the
150   /// following instructions differently.  Defaults to ".code16", ".code32",
151   /// ".code64".
152   const char *Code16Directive;
153   const char *Code32Directive;
154   const char *Code64Directive;
155 
156   /// Which dialect of an assembler variant to use.  Defaults to 0
157   unsigned AssemblerDialect = 0;
158 
159   /// This is true if the assembler allows @ characters in symbol names.
160   /// Defaults to false.
161   bool AllowAtInName = false;
162 
163   /// This is true if the assembler allows $ @ ? characters at the start of
164   /// symbol names. Defaults to false.
165   bool AllowSymbolAtNameStart = false;
166 
167   /// If this is true, symbol names with invalid characters will be printed in
168   /// quotes.
169   bool SupportsQuotedNames = true;
170 
171   /// This is true if data region markers should be printed as
172   /// ".data_region/.end_data_region" directives. If false, use "$d/$a" labels
173   /// instead.
174   bool UseDataRegionDirectives = false;
175 
176   /// True if .align is to be used for alignment. Only power-of-two
177   /// alignment is supported.
178   bool UseDotAlignForAlignment = false;
179 
180   //===--- Data Emission Directives -------------------------------------===//
181 
182   /// This should be set to the directive used to get some number of zero (and
183   /// non-zero if supported by the directive) bytes emitted to the current
184   /// section. Common cases are "\t.zero\t" and "\t.space\t". Defaults to
185   /// "\t.zero\t"
186   const char *ZeroDirective;
187 
188   /// This should be set to true if the zero directive supports a value to emit
189   /// other than zero. If this is set to false, the Data*bitsDirective's will be
190   /// used to emit these bytes. Defaults to true.
191   bool ZeroDirectiveSupportsNonZeroValue = true;
192 
193   /// This directive allows emission of an ascii string with the standard C
194   /// escape characters embedded into it.  If a target doesn't support this, it
195   /// can be set to null. Defaults to "\t.ascii\t"
196   const char *AsciiDirective;
197 
198   /// If not null, this allows for special handling of zero terminated strings
199   /// on this target.  This is commonly supported as ".asciz".  If a target
200   /// doesn't support this, it can be set to null.  Defaults to "\t.asciz\t"
201   const char *AscizDirective;
202 
203   /// These directives are used to output some unit of integer data to the
204   /// current section.  If a data directive is set to null, smaller data
205   /// directives will be used to emit the large sizes.  Defaults to "\t.byte\t",
206   /// "\t.short\t", "\t.long\t", "\t.quad\t"
207   const char *Data8bitsDirective;
208   const char *Data16bitsDirective;
209   const char *Data32bitsDirective;
210   const char *Data64bitsDirective;
211 
212   /// If non-null, a directive that is used to emit a word which should be
213   /// relocated as a 64-bit GP-relative offset, e.g. .gpdword on Mips.  Defaults
214   /// to nullptr.
215   const char *GPRel64Directive = nullptr;
216 
217   /// If non-null, a directive that is used to emit a word which should be
218   /// relocated as a 32-bit GP-relative offset, e.g. .gpword on Mips or .gprel32
219   /// on Alpha.  Defaults to nullptr.
220   const char *GPRel32Directive = nullptr;
221 
222   /// If non-null, directives that are used to emit a word/dword which should
223   /// be relocated as a 32/64-bit DTP/TP-relative offset, e.g. .dtprelword/
224   /// .dtpreldword/.tprelword/.tpreldword on Mips.
225   const char *DTPRel32Directive = nullptr;
226   const char *DTPRel64Directive = nullptr;
227   const char *TPRel32Directive = nullptr;
228   const char *TPRel64Directive = nullptr;
229 
230   /// This is true if this target uses "Sun Style" syntax for section switching
231   /// ("#alloc,#write" etc) instead of the normal ELF syntax (,"a,w") in
232   /// .section directives.  Defaults to false.
233   bool SunStyleELFSectionSwitchSyntax = false;
234 
235   /// This is true if this target uses ELF '.section' directive before the
236   /// '.bss' one. It's used for PPC/Linux which doesn't support the '.bss'
237   /// directive only.  Defaults to false.
238   bool UsesELFSectionDirectiveForBSS = false;
239 
240   bool NeedsDwarfSectionOffsetDirective = false;
241 
242   //===--- Alignment Information ----------------------------------------===//
243 
244   /// If this is true (the default) then the asmprinter emits ".align N"
245   /// directives, where N is the number of bytes to align to.  Otherwise, it
246   /// emits ".align log2(N)", e.g. 3 to align to an 8 byte boundary.  Defaults
247   /// to true.
248   bool AlignmentIsInBytes = true;
249 
250   /// If non-zero, this is used to fill the executable space created as the
251   /// result of a alignment directive.  Defaults to 0
252   unsigned TextAlignFillValue = 0;
253 
254   //===--- Global Variable Emission Directives --------------------------===//
255 
256   /// This is the directive used to declare a global entity. Defaults to
257   /// ".globl".
258   const char *GlobalDirective;
259 
260   /// True if the expression
261   ///   .long f - g
262   /// uses a relocation but it can be suppressed by writing
263   ///   a = f - g
264   ///   .long a
265   bool SetDirectiveSuppressesReloc = false;
266 
267   /// False if the assembler requires that we use
268   /// \code
269   ///   Lc = a - b
270   ///   .long Lc
271   /// \endcode
272   //
273   /// instead of
274   //
275   /// \code
276   ///   .long a - b
277   /// \endcode
278   ///
279   ///  Defaults to true.
280   bool HasAggressiveSymbolFolding = true;
281 
282   /// True is .comm's and .lcomms optional alignment is to be specified in bytes
283   /// instead of log2(n).  Defaults to true.
284   bool COMMDirectiveAlignmentIsInBytes = true;
285 
286   /// Describes if the .lcomm directive for the target supports an alignment
287   /// argument and how it is interpreted.  Defaults to NoAlignment.
288   LCOMM::LCOMMType LCOMMDirectiveAlignmentType = LCOMM::NoAlignment;
289 
290   // True if the target allows .align directives on functions. This is true for
291   // most targets, so defaults to true.
292   bool HasFunctionAlignment = true;
293 
294   /// True if the target has .type and .size directives, this is true for most
295   /// ELF targets.  Defaults to true.
296   bool HasDotTypeDotSizeDirective = true;
297 
298   /// True if the target has a single parameter .file directive, this is true
299   /// for ELF targets.  Defaults to true.
300   bool HasSingleParameterDotFile = true;
301 
302   /// True if the target has a .ident directive, this is true for ELF targets.
303   /// Defaults to false.
304   bool HasIdentDirective = false;
305 
306   /// True if this target supports the MachO .no_dead_strip directive.  Defaults
307   /// to false.
308   bool HasNoDeadStrip = false;
309 
310   /// True if this target supports the MachO .alt_entry directive.  Defaults to
311   /// false.
312   bool HasAltEntry = false;
313 
314   /// Used to declare a global as being a weak symbol. Defaults to ".weak".
315   const char *WeakDirective;
316 
317   /// This directive, if non-null, is used to declare a global as being a weak
318   /// undefined symbol.  Defaults to nullptr.
319   const char *WeakRefDirective = nullptr;
320 
321   /// True if we have a directive to declare a global as being a weak defined
322   /// symbol.  Defaults to false.
323   bool HasWeakDefDirective = false;
324 
325   /// True if we have a directive to declare a global as being a weak defined
326   /// symbol that can be hidden (unexported).  Defaults to false.
327   bool HasWeakDefCanBeHiddenDirective = false;
328 
329   /// True if we should mark symbols as global instead of weak, for
330   /// weak*/linkonce*, if the symbol has a comdat.
331   /// Defaults to false.
332   bool AvoidWeakIfComdat = false;
333 
334   /// This attribute, if not MCSA_Invalid, is used to declare a symbol as having
335   /// hidden visibility.  Defaults to MCSA_Hidden.
336   MCSymbolAttr HiddenVisibilityAttr = MCSA_Hidden;
337 
338   /// This attribute, if not MCSA_Invalid, is used to declare an undefined
339   /// symbol as having hidden visibility. Defaults to MCSA_Hidden.
340   MCSymbolAttr HiddenDeclarationVisibilityAttr = MCSA_Hidden;
341 
342   /// This attribute, if not MCSA_Invalid, is used to declare a symbol as having
343   /// protected visibility.  Defaults to MCSA_Protected
344   MCSymbolAttr ProtectedVisibilityAttr = MCSA_Protected;
345 
346   //===--- Dwarf Emission Directives -----------------------------------===//
347 
348   /// True if target supports emission of debugging information.  Defaults to
349   /// false.
350   bool SupportsDebugInformation = false;
351 
352   /// Exception handling format for the target.  Defaults to None.
353   ExceptionHandling ExceptionsType = ExceptionHandling::None;
354 
355   /// Windows exception handling data (.pdata) encoding.  Defaults to Invalid.
356   WinEH::EncodingType WinEHEncodingType = WinEH::EncodingType::Invalid;
357 
358   /// True if Dwarf2 output generally uses relocations for references to other
359   /// .debug_* sections.
360   bool DwarfUsesRelocationsAcrossSections = true;
361 
362   /// True if DWARF FDE symbol reference relocations should be replaced by an
363   /// absolute difference.
364   bool DwarfFDESymbolsUseAbsDiff = false;
365 
366   /// True if dwarf register numbers are printed instead of symbolic register
367   /// names in .cfi_* directives.  Defaults to false.
368   bool DwarfRegNumForCFI = false;
369 
370   /// True if target uses parens to indicate the symbol variant instead of @.
371   /// For example, foo(plt) instead of foo@plt.  Defaults to false.
372   bool UseParensForSymbolVariant = false;
373 
374   /// True if the target supports flags in ".loc" directive, false if only
375   /// location is allowed.
376   bool SupportsExtendedDwarfLocDirective = true;
377 
378   //===--- Prologue State ----------------------------------------------===//
379 
380   std::vector<MCCFIInstruction> InitialFrameState;
381 
382   //===--- Integrated Assembler Information ----------------------------===//
383 
384   /// Should we use the integrated assembler?
385   /// The integrated assembler should be enabled by default (by the
386   /// constructors) when failing to parse a valid piece of assembly (inline
387   /// or otherwise) is considered a bug. It may then be overridden after
388   /// construction (see LLVMTargetMachine::initAsmInfo()).
389   bool UseIntegratedAssembler;
390 
391   /// Preserve Comments in assembly
392   bool PreserveAsmComments;
393 
394   /// Compress DWARF debug sections. Defaults to no compression.
395   DebugCompressionType CompressDebugSections = DebugCompressionType::None;
396 
397   /// True if the integrated assembler should interpret 'a >> b' constant
398   /// expressions as logical rather than arithmetic.
399   bool UseLogicalShr = true;
400 
401   // If true, emit GOTPCRELX/REX_GOTPCRELX instead of GOTPCREL, on
402   // X86_64 ELF.
403   bool RelaxELFRelocations = true;
404 
405   // If true, then the lexer and expression parser will support %neg(),
406   // %hi(), and similar unary operators.
407   bool HasMipsExpressions = false;
408 
409   // If true, emit function descriptor symbol on AIX.
410   bool NeedsFunctionDescriptors = false;
411 
412 public:
413   explicit MCAsmInfo();
414   virtual ~MCAsmInfo();
415 
416   /// Get the code pointer size in bytes.
getCodePointerSize()417   unsigned getCodePointerSize() const { return CodePointerSize; }
418 
419   /// Get the callee-saved register stack slot
420   /// size in bytes.
getCalleeSaveStackSlotSize()421   unsigned getCalleeSaveStackSlotSize() const {
422     return CalleeSaveStackSlotSize;
423   }
424 
425   /// True if the target is little endian.
isLittleEndian()426   bool isLittleEndian() const { return IsLittleEndian; }
427 
428   /// True if target stack grow up.
isStackGrowthDirectionUp()429   bool isStackGrowthDirectionUp() const { return StackGrowsUp; }
430 
hasSubsectionsViaSymbols()431   bool hasSubsectionsViaSymbols() const { return HasSubsectionsViaSymbols; }
432 
433   // Data directive accessors.
434 
getData8bitsDirective()435   const char *getData8bitsDirective() const { return Data8bitsDirective; }
getData16bitsDirective()436   const char *getData16bitsDirective() const { return Data16bitsDirective; }
getData32bitsDirective()437   const char *getData32bitsDirective() const { return Data32bitsDirective; }
getData64bitsDirective()438   const char *getData64bitsDirective() const { return Data64bitsDirective; }
getGPRel64Directive()439   const char *getGPRel64Directive() const { return GPRel64Directive; }
getGPRel32Directive()440   const char *getGPRel32Directive() const { return GPRel32Directive; }
getDTPRel64Directive()441   const char *getDTPRel64Directive() const { return DTPRel64Directive; }
getDTPRel32Directive()442   const char *getDTPRel32Directive() const { return DTPRel32Directive; }
getTPRel64Directive()443   const char *getTPRel64Directive() const { return TPRel64Directive; }
getTPRel32Directive()444   const char *getTPRel32Directive() const { return TPRel32Directive; }
445 
446   /// Targets can implement this method to specify a section to switch to if the
447   /// translation unit doesn't have any trampolines that require an executable
448   /// stack.
getNonexecutableStackSection(MCContext & Ctx)449   virtual MCSection *getNonexecutableStackSection(MCContext &Ctx) const {
450     return nullptr;
451   }
452 
453   /// True if the section is atomized using the symbols in it.
454   /// This is false if the section is not atomized at all (most ELF sections) or
455   /// if it is atomized based on its contents (MachO' __TEXT,__cstring for
456   /// example).
457   virtual bool isSectionAtomizableBySymbols(const MCSection &Section) const;
458 
459   virtual const MCExpr *getExprForPersonalitySymbol(const MCSymbol *Sym,
460                                                     unsigned Encoding,
461                                                     MCStreamer &Streamer) const;
462 
463   virtual const MCExpr *getExprForFDESymbol(const MCSymbol *Sym,
464                                             unsigned Encoding,
465                                             MCStreamer &Streamer) const;
466 
467   /// Return true if C is an acceptable character inside a symbol name.
468   virtual bool isAcceptableChar(char C) const;
469 
470   /// Return true if the identifier \p Name does not need quotes to be
471   /// syntactically correct.
472   virtual bool isValidUnquotedName(StringRef Name) const;
473 
474   /// Return true if the .section directive should be omitted when
475   /// emitting \p SectionName.  For example:
476   ///
477   /// shouldOmitSectionDirective(".text")
478   ///
479   /// returns false => .section .text,#alloc,#execinstr
480   /// returns true  => .text
481   virtual bool shouldOmitSectionDirective(StringRef SectionName) const;
482 
usesSunStyleELFSectionSwitchSyntax()483   bool usesSunStyleELFSectionSwitchSyntax() const {
484     return SunStyleELFSectionSwitchSyntax;
485   }
486 
usesELFSectionDirectiveForBSS()487   bool usesELFSectionDirectiveForBSS() const {
488     return UsesELFSectionDirectiveForBSS;
489   }
490 
needsDwarfSectionOffsetDirective()491   bool needsDwarfSectionOffsetDirective() const {
492     return NeedsDwarfSectionOffsetDirective;
493   }
494 
495   // Accessors.
496 
hasMachoZeroFillDirective()497   bool hasMachoZeroFillDirective() const { return HasMachoZeroFillDirective; }
hasMachoTBSSDirective()498   bool hasMachoTBSSDirective() const { return HasMachoTBSSDirective; }
hasCOFFAssociativeComdats()499   bool hasCOFFAssociativeComdats() const { return HasCOFFAssociativeComdats; }
hasCOFFComdatConstants()500   bool hasCOFFComdatConstants() const { return HasCOFFComdatConstants; }
hasVisibilityOnlyWithLinkage()501   bool hasVisibilityOnlyWithLinkage() const {
502     return HasVisibilityOnlyWithLinkage;
503   }
504 
505   /// Returns the maximum possible encoded instruction size in bytes. If \p STI
506   /// is null, this should be the maximum size for any subtarget.
507   virtual unsigned getMaxInstLength(const MCSubtargetInfo *STI = nullptr) const {
508     return MaxInstLength;
509   }
510 
getMinInstAlignment()511   unsigned getMinInstAlignment() const { return MinInstAlignment; }
getDollarIsPC()512   bool getDollarIsPC() const { return DollarIsPC; }
getSeparatorString()513   const char *getSeparatorString() const { return SeparatorString; }
514 
515   /// This indicates the column (zero-based) at which asm comments should be
516   /// printed.
getCommentColumn()517   unsigned getCommentColumn() const { return 40; }
518 
getCommentString()519   StringRef getCommentString() const { return CommentString; }
getLabelSuffix()520   const char *getLabelSuffix() const { return LabelSuffix; }
521 
useAssignmentForEHBegin()522   bool useAssignmentForEHBegin() const { return UseAssignmentForEHBegin; }
needsLocalForSize()523   bool needsLocalForSize() const { return NeedsLocalForSize; }
getPrivateGlobalPrefix()524   StringRef getPrivateGlobalPrefix() const { return PrivateGlobalPrefix; }
getPrivateLabelPrefix()525   StringRef getPrivateLabelPrefix() const { return PrivateLabelPrefix; }
526 
hasLinkerPrivateGlobalPrefix()527   bool hasLinkerPrivateGlobalPrefix() const {
528     return !LinkerPrivateGlobalPrefix.empty();
529   }
530 
getLinkerPrivateGlobalPrefix()531   StringRef getLinkerPrivateGlobalPrefix() const {
532     if (hasLinkerPrivateGlobalPrefix())
533       return LinkerPrivateGlobalPrefix;
534     return getPrivateGlobalPrefix();
535   }
536 
getInlineAsmStart()537   const char *getInlineAsmStart() const { return InlineAsmStart; }
getInlineAsmEnd()538   const char *getInlineAsmEnd() const { return InlineAsmEnd; }
getCode16Directive()539   const char *getCode16Directive() const { return Code16Directive; }
getCode32Directive()540   const char *getCode32Directive() const { return Code32Directive; }
getCode64Directive()541   const char *getCode64Directive() const { return Code64Directive; }
getAssemblerDialect()542   unsigned getAssemblerDialect() const { return AssemblerDialect; }
doesAllowAtInName()543   bool doesAllowAtInName() const { return AllowAtInName; }
doesAllowSymbolAtNameStart()544   bool doesAllowSymbolAtNameStart() const { return AllowSymbolAtNameStart; }
supportsNameQuoting()545   bool supportsNameQuoting() const { return SupportsQuotedNames; }
546 
doesSupportDataRegionDirectives()547   bool doesSupportDataRegionDirectives() const {
548     return UseDataRegionDirectives;
549   }
550 
useDotAlignForAlignment()551   bool useDotAlignForAlignment() const {
552     return UseDotAlignForAlignment;
553   }
554 
getZeroDirective()555   const char *getZeroDirective() const { return ZeroDirective; }
doesZeroDirectiveSupportNonZeroValue()556   bool doesZeroDirectiveSupportNonZeroValue() const {
557     return ZeroDirectiveSupportsNonZeroValue;
558   }
getAsciiDirective()559   const char *getAsciiDirective() const { return AsciiDirective; }
getAscizDirective()560   const char *getAscizDirective() const { return AscizDirective; }
getAlignmentIsInBytes()561   bool getAlignmentIsInBytes() const { return AlignmentIsInBytes; }
getTextAlignFillValue()562   unsigned getTextAlignFillValue() const { return TextAlignFillValue; }
getGlobalDirective()563   const char *getGlobalDirective() const { return GlobalDirective; }
564 
doesSetDirectiveSuppressReloc()565   bool doesSetDirectiveSuppressReloc() const {
566     return SetDirectiveSuppressesReloc;
567   }
568 
hasAggressiveSymbolFolding()569   bool hasAggressiveSymbolFolding() const { return HasAggressiveSymbolFolding; }
570 
getCOMMDirectiveAlignmentIsInBytes()571   bool getCOMMDirectiveAlignmentIsInBytes() const {
572     return COMMDirectiveAlignmentIsInBytes;
573   }
574 
getLCOMMDirectiveAlignmentType()575   LCOMM::LCOMMType getLCOMMDirectiveAlignmentType() const {
576     return LCOMMDirectiveAlignmentType;
577   }
578 
hasFunctionAlignment()579   bool hasFunctionAlignment() const { return HasFunctionAlignment; }
hasDotTypeDotSizeDirective()580   bool hasDotTypeDotSizeDirective() const { return HasDotTypeDotSizeDirective; }
hasSingleParameterDotFile()581   bool hasSingleParameterDotFile() const { return HasSingleParameterDotFile; }
hasIdentDirective()582   bool hasIdentDirective() const { return HasIdentDirective; }
hasNoDeadStrip()583   bool hasNoDeadStrip() const { return HasNoDeadStrip; }
hasAltEntry()584   bool hasAltEntry() const { return HasAltEntry; }
getWeakDirective()585   const char *getWeakDirective() const { return WeakDirective; }
getWeakRefDirective()586   const char *getWeakRefDirective() const { return WeakRefDirective; }
hasWeakDefDirective()587   bool hasWeakDefDirective() const { return HasWeakDefDirective; }
588 
hasWeakDefCanBeHiddenDirective()589   bool hasWeakDefCanBeHiddenDirective() const {
590     return HasWeakDefCanBeHiddenDirective;
591   }
592 
avoidWeakIfComdat()593   bool avoidWeakIfComdat() const { return AvoidWeakIfComdat; }
594 
getHiddenVisibilityAttr()595   MCSymbolAttr getHiddenVisibilityAttr() const { return HiddenVisibilityAttr; }
596 
getHiddenDeclarationVisibilityAttr()597   MCSymbolAttr getHiddenDeclarationVisibilityAttr() const {
598     return HiddenDeclarationVisibilityAttr;
599   }
600 
getProtectedVisibilityAttr()601   MCSymbolAttr getProtectedVisibilityAttr() const {
602     return ProtectedVisibilityAttr;
603   }
604 
doesSupportDebugInformation()605   bool doesSupportDebugInformation() const { return SupportsDebugInformation; }
606 
doesSupportExceptionHandling()607   bool doesSupportExceptionHandling() const {
608     return ExceptionsType != ExceptionHandling::None;
609   }
610 
getExceptionHandlingType()611   ExceptionHandling getExceptionHandlingType() const { return ExceptionsType; }
getWinEHEncodingType()612   WinEH::EncodingType getWinEHEncodingType() const { return WinEHEncodingType; }
613 
setExceptionsType(ExceptionHandling EH)614   void setExceptionsType(ExceptionHandling EH) {
615     ExceptionsType = EH;
616   }
617 
618   /// Returns true if the exception handling method for the platform uses call
619   /// frame information to unwind.
usesCFIForEH()620   bool usesCFIForEH() const {
621     return (ExceptionsType == ExceptionHandling::DwarfCFI ||
622             ExceptionsType == ExceptionHandling::ARM || usesWindowsCFI());
623   }
624 
usesWindowsCFI()625   bool usesWindowsCFI() const {
626     return ExceptionsType == ExceptionHandling::WinEH &&
627            (WinEHEncodingType != WinEH::EncodingType::Invalid &&
628             WinEHEncodingType != WinEH::EncodingType::X86);
629   }
630 
doesDwarfUseRelocationsAcrossSections()631   bool doesDwarfUseRelocationsAcrossSections() const {
632     return DwarfUsesRelocationsAcrossSections;
633   }
634 
doDwarfFDESymbolsUseAbsDiff()635   bool doDwarfFDESymbolsUseAbsDiff() const { return DwarfFDESymbolsUseAbsDiff; }
useDwarfRegNumForCFI()636   bool useDwarfRegNumForCFI() const { return DwarfRegNumForCFI; }
useParensForSymbolVariant()637   bool useParensForSymbolVariant() const { return UseParensForSymbolVariant; }
supportsExtendedDwarfLocDirective()638   bool supportsExtendedDwarfLocDirective() const {
639     return SupportsExtendedDwarfLocDirective;
640   }
641 
642   void addInitialFrameState(const MCCFIInstruction &Inst);
643 
getInitialFrameState()644   const std::vector<MCCFIInstruction> &getInitialFrameState() const {
645     return InitialFrameState;
646   }
647 
648   /// Return true if assembly (inline or otherwise) should be parsed.
useIntegratedAssembler()649   bool useIntegratedAssembler() const { return UseIntegratedAssembler; }
650 
651   /// Set whether assembly (inline or otherwise) should be parsed.
setUseIntegratedAssembler(bool Value)652   virtual void setUseIntegratedAssembler(bool Value) {
653     UseIntegratedAssembler = Value;
654   }
655 
656   /// Return true if assembly (inline or otherwise) should be parsed.
preserveAsmComments()657   bool preserveAsmComments() const { return PreserveAsmComments; }
658 
659   /// Set whether assembly (inline or otherwise) should be parsed.
setPreserveAsmComments(bool Value)660   virtual void setPreserveAsmComments(bool Value) {
661     PreserveAsmComments = Value;
662   }
663 
compressDebugSections()664   DebugCompressionType compressDebugSections() const {
665     return CompressDebugSections;
666   }
667 
setCompressDebugSections(DebugCompressionType CompressDebugSections)668   void setCompressDebugSections(DebugCompressionType CompressDebugSections) {
669     this->CompressDebugSections = CompressDebugSections;
670   }
671 
shouldUseLogicalShr()672   bool shouldUseLogicalShr() const { return UseLogicalShr; }
673 
canRelaxRelocations()674   bool canRelaxRelocations() const { return RelaxELFRelocations; }
setRelaxELFRelocations(bool V)675   void setRelaxELFRelocations(bool V) { RelaxELFRelocations = V; }
hasMipsExpressions()676   bool hasMipsExpressions() const { return HasMipsExpressions; }
needsFunctionDescriptors()677   bool needsFunctionDescriptors() const { return NeedsFunctionDescriptors; }
678 };
679 
680 } // end namespace llvm
681 
682 #endif // LLVM_MC_MCASMINFO_H
683