MCAsmInfo.h 27 KB

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