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