xref: /llvm-project/llvm/include/llvm/MC/MCAsmInfo.h (revision 319b89197348b7cad1215e235bdc7b5ec8f9b72c)
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 public:
58   /// Assembly character literal syntax types.
59   enum AsmCharLiteralSyntax {
60     ACLS_Unknown, /// Unknown; character literals not used by LLVM for this
61                   /// target.
62     ACLS_SingleQuotePrefix, /// The desired character is prefixed by a single
63                             /// quote, e.g., `'A`.
64   };
65 
66 protected:
67   //===------------------------------------------------------------------===//
68   // Properties to be set by the target writer, used to configure asm printer.
69   //
70 
71   /// Code pointer size in bytes.  Default is 4.
72   unsigned CodePointerSize = 4;
73 
74   /// Size of the stack slot reserved for callee-saved registers, in bytes.
75   /// Default is same as pointer size.
76   unsigned CalleeSaveStackSlotSize = 4;
77 
78   /// True if target is little endian.  Default is true.
79   bool IsLittleEndian = true;
80 
81   /// True if target stack grow up.  Default is false.
82   bool StackGrowsUp = false;
83 
84   /// True if this target has the MachO .subsections_via_symbols directive.
85   /// Default is false.
86   bool HasSubsectionsViaSymbols = false;
87 
88   /// True if this is a non-GNU COFF target. The COFF port of the GNU linker
89   /// doesn't handle associative comdats in the way that we would like to use
90   /// them.
91   bool HasCOFFAssociativeComdats = false;
92 
93   /// True if this is a non-GNU COFF target. For GNU targets, we don't generate
94   /// constants into comdat sections.
95   bool HasCOFFComdatConstants = false;
96 
97   bool IsAIX = false;
98 
99   // True if using the HLASM dialect on z/OS.
100   bool IsHLASM = false;
101 
102   /// This is the maximum possible length of an instruction, which is needed to
103   /// compute the size of an inline asm.  Defaults to 4.
104   unsigned MaxInstLength = 4;
105 
106   /// Every possible instruction length is a multiple of this value.  Factored
107   /// out in .debug_frame and .debug_line.  Defaults to 1.
108   unsigned MinInstAlignment = 1;
109 
110   /// The '$' token, when not referencing an identifier or constant, refers to
111   /// the current PC.  Defaults to false.
112   bool DollarIsPC = false;
113 
114   /// This string, if specified, is used to separate instructions from each
115   /// other when on the same line.  Defaults to ';'
116   const char *SeparatorString;
117 
118   /// This indicates the comment string used by the assembler.  Defaults to
119   /// "#"
120   StringRef CommentString;
121 
122   /// This indicates whether to allow additional "comment strings" to be lexed
123   /// as a comment. Setting this attribute to true, will ensure that C-style
124   /// line comments (// ..), C-style block comments (/* .. */), and "#" are
125   /// all treated as comments in addition to the string specified by the
126   /// CommentString attribute.
127   /// Default is true.
128   bool AllowAdditionalComments = true;
129 
130   /// This is appended to emitted labels.  Defaults to ":"
131   const char *LabelSuffix;
132 
133   // Print the EH begin symbol with an assignment. Defaults to false.
134   bool UseAssignmentForEHBegin = false;
135 
136   // Do we need to create a local symbol for .size?
137   bool NeedsLocalForSize = false;
138 
139   /// This prefix is used for globals like constant pool entries that are
140   /// completely private to the .s file and should not have names in the .o
141   /// file.  Defaults to "L"
142   StringRef PrivateGlobalPrefix;
143 
144   /// This prefix is used for labels for basic blocks. Defaults to the same as
145   /// PrivateGlobalPrefix.
146   StringRef PrivateLabelPrefix;
147 
148   /// This prefix is used for symbols that should be passed through the
149   /// assembler but be removed by the linker.  This is 'l' on Darwin, currently
150   /// used for some ObjC metadata.  The default of "" meast that for this system
151   /// a plain private symbol should be used.  Defaults to "".
152   StringRef LinkerPrivateGlobalPrefix;
153 
154   /// If these are nonempty, they contain a directive to emit before and after
155   /// an inline assembly statement.  Defaults to "#APP\n", "#NO_APP\n"
156   const char *InlineAsmStart;
157   const char *InlineAsmEnd;
158 
159   /// These are assembly directives that tells the assembler to interpret the
160   /// following instructions differently.  Defaults to ".code16", ".code32",
161   /// ".code64".
162   const char *Code16Directive;
163   const char *Code32Directive;
164   const char *Code64Directive;
165 
166   /// Which dialect of an assembler variant to use.  Defaults to 0
167   unsigned AssemblerDialect = 0;
168 
169   /// This is true if the assembler allows @ characters in symbol names.
170   /// Defaults to false.
171   bool AllowAtInName = false;
172 
173   /// This is true if the assembler allows the "?" character at the start of
174   /// of a string to be lexed as an AsmToken::Identifier.
175   /// If the AsmLexer determines that the string can be lexed as a possible
176   /// comment, setting this option will have no effect, and the string will
177   /// still be lexed as a comment.
178   bool AllowQuestionAtStartOfIdentifier = false;
179 
180   /// This is true if the assembler allows the "$" character at the start of
181   /// of a string to be lexed as an AsmToken::Identifier.
182   /// If the AsmLexer determines that the string can be lexed as a possible
183   /// comment, setting this option will have no effect, and the string will
184   /// still be lexed as a comment.
185   bool AllowDollarAtStartOfIdentifier = false;
186 
187   /// This is true if the assembler allows the "@" character at the start of
188   /// a string to be lexed as an AsmToken::Identifier.
189   /// If the AsmLexer determines that the string can be lexed as a possible
190   /// comment, setting this option will have no effect, and the string will
191   /// still be lexed as a comment.
192   bool AllowAtAtStartOfIdentifier = false;
193 
194   /// If this is true, symbol names with invalid characters will be printed in
195   /// quotes.
196   bool SupportsQuotedNames = true;
197 
198   /// This is true if data region markers should be printed as
199   /// ".data_region/.end_data_region" directives. If false, use "$d/$a" labels
200   /// instead.
201   bool UseDataRegionDirectives = false;
202 
203   /// True if the target supports LEB128 directives.
204   bool HasLEB128Directives = true;
205 
206   /// True if full register names are printed.
207   bool PPCUseFullRegisterNames = false;
208 
209   //===--- Data Emission Directives -------------------------------------===//
210 
211   /// This should be set to the directive used to get some number of zero (and
212   /// non-zero if supported by the directive) bytes emitted to the current
213   /// section. Common cases are "\t.zero\t" and "\t.space\t". Defaults to
214   /// "\t.zero\t"
215   const char *ZeroDirective;
216 
217   /// This directive allows emission of an ascii string with the standard C
218   /// escape characters embedded into it.  If a target doesn't support this, it
219   /// can be set to null. Defaults to "\t.ascii\t"
220   const char *AsciiDirective;
221 
222   /// If not null, this allows for special handling of zero terminated strings
223   /// on this target.  This is commonly supported as ".asciz".  If a target
224   /// doesn't support this, it can be set to null.  Defaults to "\t.asciz\t"
225   const char *AscizDirective;
226 
227   /// Form used for character literals in the assembly syntax.  Useful for
228   /// producing strings as byte lists.  If a target does not use or support
229   /// this, it shall be set to ACLS_Unknown.  Defaults to ACLS_Unknown.
230   AsmCharLiteralSyntax CharacterLiteralSyntax = ACLS_Unknown;
231 
232   /// These directives are used to output some unit of integer data to the
233   /// current section.  If a data directive is set to null, smaller data
234   /// directives will be used to emit the large sizes.  Defaults to "\t.byte\t",
235   /// "\t.short\t", "\t.long\t", "\t.quad\t"
236   const char *Data8bitsDirective;
237   const char *Data16bitsDirective;
238   const char *Data32bitsDirective;
239   const char *Data64bitsDirective;
240 
241   /// True if data directives support signed values
242   bool SupportsSignedData = true;
243 
244   /// If non-null, a directive that is used to emit a word which should be
245   /// relocated as a 64-bit GP-relative offset, e.g. .gpdword on Mips.  Defaults
246   /// to nullptr.
247   const char *GPRel64Directive = nullptr;
248 
249   /// If non-null, a directive that is used to emit a word which should be
250   /// relocated as a 32-bit GP-relative offset, e.g. .gpword on Mips or .gprel32
251   /// on Alpha.  Defaults to nullptr.
252   const char *GPRel32Directive = nullptr;
253 
254   /// If non-null, directives that are used to emit a word/dword which should
255   /// be relocated as a 32/64-bit DTP/TP-relative offset, e.g. .dtprelword/
256   /// .dtpreldword/.tprelword/.tpreldword on Mips.
257   const char *DTPRel32Directive = nullptr;
258   const char *DTPRel64Directive = nullptr;
259   const char *TPRel32Directive = nullptr;
260   const char *TPRel64Directive = nullptr;
261 
262   /// This is true if this target uses "Sun Style" syntax for section switching
263   /// ("#alloc,#write" etc) instead of the normal ELF syntax (,"a,w") in
264   /// .section directives.  Defaults to false.
265   bool SunStyleELFSectionSwitchSyntax = false;
266 
267   /// This is true if this target uses ELF '.section' directive before the
268   /// '.bss' one. It's used for PPC/Linux which doesn't support the '.bss'
269   /// directive only.  Defaults to false.
270   bool UsesELFSectionDirectiveForBSS = false;
271 
272   bool NeedsDwarfSectionOffsetDirective = false;
273 
274   //===--- Alignment Information ----------------------------------------===//
275 
276   /// If this is true (the default) then the asmprinter emits ".align N"
277   /// directives, where N is the number of bytes to align to.  Otherwise, it
278   /// emits ".align log2(N)", e.g. 3 to align to an 8 byte boundary.  Defaults
279   /// to true.
280   bool AlignmentIsInBytes = true;
281 
282   /// If non-zero, this is used to fill the executable space created as the
283   /// result of a alignment directive.  Defaults to 0
284   unsigned TextAlignFillValue = 0;
285 
286   //===--- Global Variable Emission Directives --------------------------===//
287 
288   /// This is the directive used to declare a global entity. Defaults to
289   /// ".globl".
290   const char *GlobalDirective;
291 
292   /// True if the expression
293   ///   .long f - g
294   /// uses a relocation but it can be suppressed by writing
295   ///   a = f - g
296   ///   .long a
297   bool SetDirectiveSuppressesReloc = false;
298 
299   /// True is .comm's and .lcomms optional alignment is to be specified in bytes
300   /// instead of log2(n).  Defaults to true.
301   bool COMMDirectiveAlignmentIsInBytes = true;
302 
303   /// Describes if the .lcomm directive for the target supports an alignment
304   /// argument and how it is interpreted.  Defaults to NoAlignment.
305   LCOMM::LCOMMType LCOMMDirectiveAlignmentType = LCOMM::NoAlignment;
306 
307   // True if the target allows .align directives on functions. This is true for
308   // most targets, so defaults to true.
309   bool HasFunctionAlignment = true;
310 
311   /// True if the target has .type and .size directives, this is true for most
312   /// ELF targets.  Defaults to true.
313   bool HasDotTypeDotSizeDirective = true;
314 
315   /// True if the target has a single parameter .file directive, this is true
316   /// for ELF targets.  Defaults to true.
317   bool HasSingleParameterDotFile = true;
318 
319   /// True if the target has a .ident directive, this is true for ELF targets.
320   /// Defaults to false.
321   bool HasIdentDirective = false;
322 
323   /// True if this target supports the MachO .no_dead_strip directive.  Defaults
324   /// to false.
325   bool HasNoDeadStrip = false;
326 
327   /// Used to declare a global as being a weak symbol. Defaults to ".weak".
328   const char *WeakDirective;
329 
330   /// This directive, if non-null, is used to declare a global as being a weak
331   /// undefined symbol.  Defaults to nullptr.
332   const char *WeakRefDirective = nullptr;
333 
334   /// True if we have a directive to declare a global as being a weak defined
335   /// symbol that can be hidden (unexported).  Defaults to false.
336   bool HasWeakDefCanBeHiddenDirective = false;
337 
338   /// True if we should mark symbols as global instead of weak, for
339   /// weak*/linkonce*, if the symbol has a comdat.
340   /// Defaults to false.
341   bool AvoidWeakIfComdat = false;
342 
343   /// This attribute, if not MCSA_Invalid, is used to declare a symbol as having
344   /// hidden visibility.  Defaults to MCSA_Hidden.
345   MCSymbolAttr HiddenVisibilityAttr = MCSA_Hidden;
346 
347   /// This attribute, if not MCSA_Invalid, is used to declare a symbol as having
348   /// exported visibility.  Defaults to MCSA_Exported.
349   MCSymbolAttr ExportedVisibilityAttr = MCSA_Exported;
350 
351   /// This attribute, if not MCSA_Invalid, is used to declare an undefined
352   /// symbol as having hidden visibility. Defaults to MCSA_Hidden.
353   MCSymbolAttr HiddenDeclarationVisibilityAttr = MCSA_Hidden;
354 
355   /// This attribute, if not MCSA_Invalid, is used to declare a symbol as having
356   /// protected visibility.  Defaults to MCSA_Protected
357   MCSymbolAttr ProtectedVisibilityAttr = MCSA_Protected;
358 
359   MCSymbolAttr MemtagAttr = MCSA_Memtag;
360 
361   //===--- Dwarf Emission Directives -----------------------------------===//
362 
363   /// True if target supports emission of debugging information.  Defaults to
364   /// false.
365   bool SupportsDebugInformation = false;
366 
367   /// Exception handling format for the target.  Defaults to None.
368   ExceptionHandling ExceptionsType = ExceptionHandling::None;
369 
370   /// True if target uses CFI unwind information for other purposes than EH
371   /// (debugging / sanitizers) when `ExceptionsType == ExceptionHandling::None`.
372   bool UsesCFIWithoutEH = false;
373 
374   /// Windows exception handling data (.pdata) encoding.  Defaults to Invalid.
375   WinEH::EncodingType WinEHEncodingType = WinEH::EncodingType::Invalid;
376 
377   /// True if Dwarf2 output generally uses relocations for references to other
378   /// .debug_* sections.
379   bool DwarfUsesRelocationsAcrossSections = true;
380 
381   /// True if DWARF FDE symbol reference relocations should be replaced by an
382   /// absolute difference.
383   bool DwarfFDESymbolsUseAbsDiff = false;
384 
385   /// True if DWARF `.file directory' directive syntax is used by
386   /// default.
387   bool EnableDwarfFileDirectoryDefault = true;
388 
389   /// True if dwarf register numbers are printed instead of symbolic register
390   /// names in .cfi_* directives.  Defaults to false.
391   bool DwarfRegNumForCFI = false;
392 
393   /// True if target uses parens to indicate the symbol variant instead of @.
394   /// For example, foo(plt) instead of foo@plt.  Defaults to false.
395   bool UseParensForSymbolVariant = false;
396 
397   /// True if the target uses parens for symbol names starting with
398   /// '$' character to distinguish them from absolute names.
399   bool UseParensForDollarSignNames = true;
400 
401   /// True if the target supports flags in ".loc" directive, false if only
402   /// location is allowed.
403   bool SupportsExtendedDwarfLocDirective = true;
404 
405   //===--- Prologue State ----------------------------------------------===//
406 
407   std::vector<MCCFIInstruction> InitialFrameState;
408 
409   //===--- Integrated Assembler Information ----------------------------===//
410 
411   // Generated object files can use all ELF features supported by GNU ld of
412   // this binutils version and later. INT_MAX means all features can be used,
413   // regardless of GNU ld support. The default value is referenced by
414   // clang/Driver/Options.td.
415   std::pair<int, int> BinutilsVersion = {2, 26};
416 
417   /// Should we use the integrated assembler?
418   /// The integrated assembler should be enabled by default (by the
419   /// constructors) when failing to parse a valid piece of assembly (inline
420   /// or otherwise) is considered a bug. It may then be overridden after
421   /// construction (see CodeGenTargetMachineImpl::initAsmInfo()).
422   bool UseIntegratedAssembler;
423 
424   /// Use AsmParser to parse inlineAsm when UseIntegratedAssembler is not set.
425   bool ParseInlineAsmUsingAsmParser;
426 
427   /// Preserve Comments in assembly
428   bool PreserveAsmComments;
429 
430   /// The column (zero-based) at which asm comments should be printed.
431   unsigned CommentColumn = 40;
432 
433   /// True if the integrated assembler should interpret 'a >> b' constant
434   /// expressions as logical rather than arithmetic.
435   bool UseLogicalShr = true;
436 
437   // If true, then the lexer and expression parser will support %neg(),
438   // %hi(), and similar unary operators.
439   bool HasMipsExpressions = false;
440 
441   // If true, use Motorola-style integers in Assembly (ex. $0ac).
442   bool UseMotorolaIntegers = false;
443 
444 public:
445   explicit MCAsmInfo();
446   virtual ~MCAsmInfo();
447 
448   /// Get the code pointer size in bytes.
449   unsigned getCodePointerSize() const { return CodePointerSize; }
450 
451   /// Get the callee-saved register stack slot
452   /// size in bytes.
453   unsigned getCalleeSaveStackSlotSize() const {
454     return CalleeSaveStackSlotSize;
455   }
456 
457   /// True if the target is little endian.
458   bool isLittleEndian() const { return IsLittleEndian; }
459 
460   /// True if target stack grow up.
461   bool isStackGrowthDirectionUp() const { return StackGrowsUp; }
462 
463   bool hasSubsectionsViaSymbols() const { return HasSubsectionsViaSymbols; }
464 
465   // Data directive accessors.
466 
467   const char *getData8bitsDirective() const { return Data8bitsDirective; }
468   const char *getData16bitsDirective() const { return Data16bitsDirective; }
469   const char *getData32bitsDirective() const { return Data32bitsDirective; }
470   const char *getData64bitsDirective() const { return Data64bitsDirective; }
471   bool supportsSignedData() const { return SupportsSignedData; }
472   const char *getGPRel64Directive() const { return GPRel64Directive; }
473   const char *getGPRel32Directive() const { return GPRel32Directive; }
474   const char *getDTPRel64Directive() const { return DTPRel64Directive; }
475   const char *getDTPRel32Directive() const { return DTPRel32Directive; }
476   const char *getTPRel64Directive() const { return TPRel64Directive; }
477   const char *getTPRel32Directive() const { return TPRel32Directive; }
478 
479   /// Targets can implement this method to specify a section to switch to if the
480   /// translation unit doesn't have any trampolines that require an executable
481   /// stack.
482   virtual MCSection *getNonexecutableStackSection(MCContext &Ctx) const {
483     return nullptr;
484   }
485 
486   virtual const MCExpr *getExprForPersonalitySymbol(const MCSymbol *Sym,
487                                                     unsigned Encoding,
488                                                     MCStreamer &Streamer) const;
489 
490   virtual const MCExpr *getExprForFDESymbol(const MCSymbol *Sym,
491                                             unsigned Encoding,
492                                             MCStreamer &Streamer) const;
493 
494   /// Return true if C is an acceptable character inside a symbol name.
495   virtual bool isAcceptableChar(char C) const;
496 
497   /// Return true if the identifier \p Name does not need quotes to be
498   /// syntactically correct.
499   virtual bool isValidUnquotedName(StringRef Name) const;
500 
501   /// Return true if the .section directive should be omitted when
502   /// emitting \p SectionName.  For example:
503   ///
504   /// shouldOmitSectionDirective(".text")
505   ///
506   /// returns false => .section .text,#alloc,#execinstr
507   /// returns true  => .text
508   virtual bool shouldOmitSectionDirective(StringRef SectionName) const;
509 
510   bool usesSunStyleELFSectionSwitchSyntax() const {
511     return SunStyleELFSectionSwitchSyntax;
512   }
513 
514   bool usesELFSectionDirectiveForBSS() const {
515     return UsesELFSectionDirectiveForBSS;
516   }
517 
518   bool needsDwarfSectionOffsetDirective() const {
519     return NeedsDwarfSectionOffsetDirective;
520   }
521 
522   // Accessors.
523 
524   bool isAIX() const { return IsAIX; }
525   bool isHLASM() const { return IsHLASM; }
526   bool isMachO() const { return HasSubsectionsViaSymbols; }
527   bool hasCOFFAssociativeComdats() const { return HasCOFFAssociativeComdats; }
528   bool hasCOFFComdatConstants() const { return HasCOFFComdatConstants; }
529 
530   /// Returns the maximum possible encoded instruction size in bytes. If \p STI
531   /// is null, this should be the maximum size for any subtarget.
532   virtual unsigned getMaxInstLength(const MCSubtargetInfo *STI = nullptr) const {
533     return MaxInstLength;
534   }
535 
536   unsigned getMinInstAlignment() const { return MinInstAlignment; }
537   bool getDollarIsPC() const { return DollarIsPC; }
538   const char *getSeparatorString() const { return SeparatorString; }
539 
540   unsigned getCommentColumn() const { return CommentColumn; }
541   void setCommentColumn(unsigned Col) { CommentColumn = Col; }
542 
543   StringRef getCommentString() const { return CommentString; }
544   bool shouldAllowAdditionalComments() const { return AllowAdditionalComments; }
545   const char *getLabelSuffix() const { return LabelSuffix; }
546 
547   bool useAssignmentForEHBegin() const { return UseAssignmentForEHBegin; }
548   bool needsLocalForSize() const { return NeedsLocalForSize; }
549   StringRef getPrivateGlobalPrefix() const { return PrivateGlobalPrefix; }
550   StringRef getPrivateLabelPrefix() const { return PrivateLabelPrefix; }
551 
552   bool hasLinkerPrivateGlobalPrefix() const {
553     return !LinkerPrivateGlobalPrefix.empty();
554   }
555 
556   StringRef getLinkerPrivateGlobalPrefix() const {
557     if (hasLinkerPrivateGlobalPrefix())
558       return LinkerPrivateGlobalPrefix;
559     return getPrivateGlobalPrefix();
560   }
561 
562   const char *getInlineAsmStart() const { return InlineAsmStart; }
563   const char *getInlineAsmEnd() const { return InlineAsmEnd; }
564   const char *getCode16Directive() const { return Code16Directive; }
565   const char *getCode32Directive() const { return Code32Directive; }
566   const char *getCode64Directive() const { return Code64Directive; }
567   unsigned getAssemblerDialect() const { return AssemblerDialect; }
568   bool doesAllowAtInName() const { return AllowAtInName; }
569   void setAllowAtInName(bool V) { AllowAtInName = V; }
570   bool doesAllowQuestionAtStartOfIdentifier() const {
571     return AllowQuestionAtStartOfIdentifier;
572   }
573   bool doesAllowAtAtStartOfIdentifier() const {
574     return AllowAtAtStartOfIdentifier;
575   }
576   bool doesAllowDollarAtStartOfIdentifier() const {
577     return AllowDollarAtStartOfIdentifier;
578   }
579   bool supportsNameQuoting() const { return SupportsQuotedNames; }
580 
581   bool doesSupportDataRegionDirectives() const {
582     return UseDataRegionDirectives;
583   }
584 
585   bool hasLEB128Directives() const { return HasLEB128Directives; }
586 
587   bool useFullRegisterNames() const { return PPCUseFullRegisterNames; }
588   void setFullRegisterNames(bool V) { PPCUseFullRegisterNames = V; }
589 
590   const char *getZeroDirective() const { return ZeroDirective; }
591   const char *getAsciiDirective() const { return AsciiDirective; }
592   const char *getAscizDirective() const { return AscizDirective; }
593   AsmCharLiteralSyntax characterLiteralSyntax() const {
594     return CharacterLiteralSyntax;
595   }
596   bool getAlignmentIsInBytes() const { return AlignmentIsInBytes; }
597   unsigned getTextAlignFillValue() const { return TextAlignFillValue; }
598   const char *getGlobalDirective() const { return GlobalDirective; }
599 
600   bool doesSetDirectiveSuppressReloc() const {
601     return SetDirectiveSuppressesReloc;
602   }
603 
604   bool getCOMMDirectiveAlignmentIsInBytes() const {
605     return COMMDirectiveAlignmentIsInBytes;
606   }
607 
608   LCOMM::LCOMMType getLCOMMDirectiveAlignmentType() const {
609     return LCOMMDirectiveAlignmentType;
610   }
611 
612   bool hasFunctionAlignment() const { return HasFunctionAlignment; }
613   bool hasDotTypeDotSizeDirective() const { return HasDotTypeDotSizeDirective; }
614   bool hasSingleParameterDotFile() const { return HasSingleParameterDotFile; }
615   bool hasIdentDirective() const { return HasIdentDirective; }
616   bool hasNoDeadStrip() const { return HasNoDeadStrip; }
617   const char *getWeakDirective() const { return WeakDirective; }
618   const char *getWeakRefDirective() const { return WeakRefDirective; }
619 
620   bool hasWeakDefCanBeHiddenDirective() const {
621     return HasWeakDefCanBeHiddenDirective;
622   }
623 
624   bool avoidWeakIfComdat() const { return AvoidWeakIfComdat; }
625 
626   MCSymbolAttr getHiddenVisibilityAttr() const { return HiddenVisibilityAttr; }
627 
628   MCSymbolAttr getExportedVisibilityAttr() const { return ExportedVisibilityAttr; }
629 
630   MCSymbolAttr getHiddenDeclarationVisibilityAttr() const {
631     return HiddenDeclarationVisibilityAttr;
632   }
633 
634   MCSymbolAttr getProtectedVisibilityAttr() const {
635     return ProtectedVisibilityAttr;
636   }
637 
638   MCSymbolAttr getMemtagAttr() const { return MemtagAttr; }
639 
640   bool doesSupportDebugInformation() const { return SupportsDebugInformation; }
641 
642   ExceptionHandling getExceptionHandlingType() const { return ExceptionsType; }
643   WinEH::EncodingType getWinEHEncodingType() const { return WinEHEncodingType; }
644 
645   void setExceptionsType(ExceptionHandling EH) {
646     ExceptionsType = EH;
647   }
648 
649   bool usesCFIWithoutEH() const {
650     return ExceptionsType == ExceptionHandling::None && UsesCFIWithoutEH;
651   }
652 
653   /// Returns true if the exception handling method for the platform uses call
654   /// frame information to unwind.
655   bool usesCFIForEH() const {
656     return (ExceptionsType == ExceptionHandling::DwarfCFI ||
657             ExceptionsType == ExceptionHandling::ARM ||
658             ExceptionsType == ExceptionHandling::ZOS || usesWindowsCFI());
659   }
660 
661   bool usesWindowsCFI() const {
662     return ExceptionsType == ExceptionHandling::WinEH &&
663            (WinEHEncodingType != WinEH::EncodingType::Invalid &&
664             WinEHEncodingType != WinEH::EncodingType::X86);
665   }
666 
667   bool doesDwarfUseRelocationsAcrossSections() const {
668     return DwarfUsesRelocationsAcrossSections;
669   }
670 
671   bool doDwarfFDESymbolsUseAbsDiff() const { return DwarfFDESymbolsUseAbsDiff; }
672   bool useDwarfRegNumForCFI() const { return DwarfRegNumForCFI; }
673   bool useParensForSymbolVariant() const { return UseParensForSymbolVariant; }
674   bool useParensForDollarSignNames() const {
675     return UseParensForDollarSignNames;
676   }
677   bool supportsExtendedDwarfLocDirective() const {
678     return SupportsExtendedDwarfLocDirective;
679   }
680 
681   bool usesDwarfFileAndLocDirectives() const { return !IsAIX; }
682 
683   bool enableDwarfFileDirectoryDefault() const {
684     return EnableDwarfFileDirectoryDefault;
685   }
686 
687   void addInitialFrameState(const MCCFIInstruction &Inst);
688 
689   const std::vector<MCCFIInstruction> &getInitialFrameState() const {
690     return InitialFrameState;
691   }
692 
693   void setBinutilsVersion(std::pair<int, int> Value) {
694     BinutilsVersion = Value;
695   }
696 
697   /// Return true if assembly (inline or otherwise) should be parsed.
698   bool useIntegratedAssembler() const { return UseIntegratedAssembler; }
699 
700   /// Return true if target want to use AsmParser to parse inlineasm.
701   bool parseInlineAsmUsingAsmParser() const {
702     return ParseInlineAsmUsingAsmParser;
703   }
704 
705   bool binutilsIsAtLeast(int Major, int Minor) const {
706     return BinutilsVersion >= std::make_pair(Major, Minor);
707   }
708 
709   /// Set whether assembly (inline or otherwise) should be parsed.
710   virtual void setUseIntegratedAssembler(bool Value) {
711     UseIntegratedAssembler = Value;
712   }
713 
714   /// Set whether target want to use AsmParser to parse inlineasm.
715   virtual void setParseInlineAsmUsingAsmParser(bool Value) {
716     ParseInlineAsmUsingAsmParser = Value;
717   }
718 
719   /// Return true if assembly (inline or otherwise) should be parsed.
720   bool preserveAsmComments() const { return PreserveAsmComments; }
721 
722   /// Set whether assembly (inline or otherwise) should be parsed.
723   virtual void setPreserveAsmComments(bool Value) {
724     PreserveAsmComments = Value;
725   }
726 
727 
728   bool shouldUseLogicalShr() const { return UseLogicalShr; }
729 
730   bool hasMipsExpressions() const { return HasMipsExpressions; }
731   bool shouldUseMotorolaIntegers() const { return UseMotorolaIntegers; }
732 };
733 
734 } // end namespace llvm
735 
736 #endif // LLVM_MC_MCASMINFO_H
737