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 // Generated object files can use all ELF features supported by GNU ld of 410 // this binutils version and later. INT_MAX means all features can be used, 411 // regardless of GNU ld support. The default value is referenced by 412 // clang/Driver/Options.td. 413 std::pair<int, int> BinutilsVersion = {2, 26}; 414 415 /// Should we use the integrated assembler? 416 /// The integrated assembler should be enabled by default (by the 417 /// constructors) when failing to parse a valid piece of assembly (inline 418 /// or otherwise) is considered a bug. It may then be overridden after 419 /// construction (see LLVMTargetMachine::initAsmInfo()). 420 bool UseIntegratedAssembler; 421 422 /// Preserve Comments in assembly 423 bool PreserveAsmComments; 424 425 /// Compress DWARF debug sections. Defaults to no compression. 426 DebugCompressionType CompressDebugSections = DebugCompressionType::None; 427 428 /// True if the integrated assembler should interpret 'a >> b' constant 429 /// expressions as logical rather than arithmetic. 430 bool UseLogicalShr = true; 431 432 // If true, emit GOTPCRELX/REX_GOTPCRELX instead of GOTPCREL, on 433 // X86_64 ELF. 434 bool RelaxELFRelocations = true; 435 436 // If true, then the lexer and expression parser will support %neg(), 437 // %hi(), and similar unary operators. 438 bool HasMipsExpressions = false; 439 440 // If true, emit function descriptor symbol on AIX. 441 bool NeedsFunctionDescriptors = false; 442 443 public: 444 explicit MCAsmInfo(); 445 virtual ~MCAsmInfo(); 446 447 /// Get the code pointer size in bytes. 448 unsigned getCodePointerSize() const { return CodePointerSize; } 449 450 /// Get the callee-saved register stack slot 451 /// size in bytes. 452 unsigned getCalleeSaveStackSlotSize() const { 453 return CalleeSaveStackSlotSize; 454 } 455 456 /// True if the target is little endian. 457 bool isLittleEndian() const { return IsLittleEndian; } 458 459 /// True if target stack grow up. 460 bool isStackGrowthDirectionUp() const { return StackGrowsUp; } 461 462 bool hasSubsectionsViaSymbols() const { return HasSubsectionsViaSymbols; } 463 464 // Data directive accessors. 465 466 const char *getData8bitsDirective() const { return Data8bitsDirective; } 467 const char *getData16bitsDirective() const { return Data16bitsDirective; } 468 const char *getData32bitsDirective() const { return Data32bitsDirective; } 469 const char *getData64bitsDirective() const { return Data64bitsDirective; } 470 bool supportsSignedData() const { return SupportsSignedData; } 471 const char *getGPRel64Directive() const { return GPRel64Directive; } 472 const char *getGPRel32Directive() const { return GPRel32Directive; } 473 const char *getDTPRel64Directive() const { return DTPRel64Directive; } 474 const char *getDTPRel32Directive() const { return DTPRel32Directive; } 475 const char *getTPRel64Directive() const { return TPRel64Directive; } 476 const char *getTPRel32Directive() const { return TPRel32Directive; } 477 478 /// Targets can implement this method to specify a section to switch to if the 479 /// translation unit doesn't have any trampolines that require an executable 480 /// stack. 481 virtual MCSection *getNonexecutableStackSection(MCContext &Ctx) const { 482 return nullptr; 483 } 484 485 /// True if the section is atomized using the symbols in it. 486 /// This is false if the section is not atomized at all (most ELF sections) or 487 /// if it is atomized based on its contents (MachO' __TEXT,__cstring for 488 /// example). 489 virtual bool isSectionAtomizableBySymbols(const MCSection &Section) const; 490 491 virtual const MCExpr *getExprForPersonalitySymbol(const MCSymbol *Sym, 492 unsigned Encoding, 493 MCStreamer &Streamer) const; 494 495 virtual const MCExpr *getExprForFDESymbol(const MCSymbol *Sym, 496 unsigned Encoding, 497 MCStreamer &Streamer) const; 498 499 /// Return true if C is an acceptable character inside a symbol name. 500 virtual bool isAcceptableChar(char C) const; 501 502 /// Return true if the identifier \p Name does not need quotes to be 503 /// syntactically correct. 504 virtual bool isValidUnquotedName(StringRef Name) const; 505 506 /// Return true if the .section directive should be omitted when 507 /// emitting \p SectionName. For example: 508 /// 509 /// shouldOmitSectionDirective(".text") 510 /// 511 /// returns false => .section .text,#alloc,#execinstr 512 /// returns true => .text 513 virtual bool shouldOmitSectionDirective(StringRef SectionName) const; 514 515 bool usesSunStyleELFSectionSwitchSyntax() const { 516 return SunStyleELFSectionSwitchSyntax; 517 } 518 519 bool usesELFSectionDirectiveForBSS() const { 520 return UsesELFSectionDirectiveForBSS; 521 } 522 523 bool needsDwarfSectionOffsetDirective() const { 524 return NeedsDwarfSectionOffsetDirective; 525 } 526 527 // Accessors. 528 529 bool hasMachoZeroFillDirective() const { return HasMachoZeroFillDirective; } 530 bool hasMachoTBSSDirective() const { return HasMachoTBSSDirective; } 531 bool hasCOFFAssociativeComdats() const { return HasCOFFAssociativeComdats; } 532 bool hasCOFFComdatConstants() const { return HasCOFFComdatConstants; } 533 bool hasVisibilityOnlyWithLinkage() const { 534 return HasVisibilityOnlyWithLinkage; 535 } 536 537 /// Returns the maximum possible encoded instruction size in bytes. If \p STI 538 /// is null, this should be the maximum size for any subtarget. 539 virtual unsigned getMaxInstLength(const MCSubtargetInfo *STI = nullptr) const { 540 return MaxInstLength; 541 } 542 543 unsigned getMinInstAlignment() const { return MinInstAlignment; } 544 bool getDollarIsPC() const { return DollarIsPC; } 545 const char *getSeparatorString() const { return SeparatorString; } 546 547 /// This indicates the column (zero-based) at which asm comments should be 548 /// printed. 549 unsigned getCommentColumn() const { return 40; } 550 551 StringRef getCommentString() const { return CommentString; } 552 const char *getLabelSuffix() const { return LabelSuffix; } 553 554 bool useAssignmentForEHBegin() const { return UseAssignmentForEHBegin; } 555 bool needsLocalForSize() const { return NeedsLocalForSize; } 556 StringRef getPrivateGlobalPrefix() const { return PrivateGlobalPrefix; } 557 StringRef getPrivateLabelPrefix() const { return PrivateLabelPrefix; } 558 559 bool hasLinkerPrivateGlobalPrefix() const { 560 return !LinkerPrivateGlobalPrefix.empty(); 561 } 562 563 StringRef getLinkerPrivateGlobalPrefix() const { 564 if (hasLinkerPrivateGlobalPrefix()) 565 return LinkerPrivateGlobalPrefix; 566 return getPrivateGlobalPrefix(); 567 } 568 569 const char *getInlineAsmStart() const { return InlineAsmStart; } 570 const char *getInlineAsmEnd() const { return InlineAsmEnd; } 571 const char *getCode16Directive() const { return Code16Directive; } 572 const char *getCode32Directive() const { return Code32Directive; } 573 const char *getCode64Directive() const { return Code64Directive; } 574 unsigned getAssemblerDialect() const { return AssemblerDialect; } 575 bool doesAllowAtInName() const { return AllowAtInName; } 576 bool doesAllowSymbolAtNameStart() const { return AllowSymbolAtNameStart; } 577 bool supportsNameQuoting() const { return SupportsQuotedNames; } 578 579 bool doesSupportDataRegionDirectives() const { 580 return UseDataRegionDirectives; 581 } 582 583 bool useDotAlignForAlignment() const { 584 return UseDotAlignForAlignment; 585 } 586 587 bool hasLEB128Directives() const { return HasLEB128Directives; } 588 589 const char *getZeroDirective() const { return ZeroDirective; } 590 bool doesZeroDirectiveSupportNonZeroValue() const { 591 return ZeroDirectiveSupportsNonZeroValue; 592 } 593 const char *getAsciiDirective() const { return AsciiDirective; } 594 const char *getAscizDirective() const { return AscizDirective; } 595 const char *getByteListDirective() const { return ByteListDirective; } 596 AsmCharLiteralSyntax characterLiteralSyntax() const { 597 return CharacterLiteralSyntax; 598 } 599 bool getAlignmentIsInBytes() const { return AlignmentIsInBytes; } 600 unsigned getTextAlignFillValue() const { return TextAlignFillValue; } 601 const char *getGlobalDirective() const { return GlobalDirective; } 602 603 bool doesSetDirectiveSuppressReloc() const { 604 return SetDirectiveSuppressesReloc; 605 } 606 607 bool hasAggressiveSymbolFolding() const { return HasAggressiveSymbolFolding; } 608 609 bool getCOMMDirectiveAlignmentIsInBytes() const { 610 return COMMDirectiveAlignmentIsInBytes; 611 } 612 613 LCOMM::LCOMMType getLCOMMDirectiveAlignmentType() const { 614 return LCOMMDirectiveAlignmentType; 615 } 616 617 bool hasFunctionAlignment() const { return HasFunctionAlignment; } 618 bool hasDotTypeDotSizeDirective() const { return HasDotTypeDotSizeDirective; } 619 bool hasSingleParameterDotFile() const { return HasSingleParameterDotFile; } 620 bool hasIdentDirective() const { return HasIdentDirective; } 621 bool hasNoDeadStrip() const { return HasNoDeadStrip; } 622 bool hasAltEntry() const { return HasAltEntry; } 623 const char *getWeakDirective() const { return WeakDirective; } 624 const char *getWeakRefDirective() const { return WeakRefDirective; } 625 bool hasWeakDefDirective() const { return HasWeakDefDirective; } 626 627 bool hasWeakDefCanBeHiddenDirective() const { 628 return HasWeakDefCanBeHiddenDirective; 629 } 630 631 bool avoidWeakIfComdat() const { return AvoidWeakIfComdat; } 632 633 MCSymbolAttr getHiddenVisibilityAttr() const { return HiddenVisibilityAttr; } 634 635 MCSymbolAttr getHiddenDeclarationVisibilityAttr() const { 636 return HiddenDeclarationVisibilityAttr; 637 } 638 639 MCSymbolAttr getProtectedVisibilityAttr() const { 640 return ProtectedVisibilityAttr; 641 } 642 643 bool doesSupportDebugInformation() const { return SupportsDebugInformation; } 644 645 ExceptionHandling getExceptionHandlingType() const { return ExceptionsType; } 646 WinEH::EncodingType getWinEHEncodingType() const { return WinEHEncodingType; } 647 648 void setExceptionsType(ExceptionHandling EH) { 649 ExceptionsType = EH; 650 } 651 652 /// Returns true if the exception handling method for the platform uses call 653 /// frame information to unwind. 654 bool usesCFIForEH() const { 655 return (ExceptionsType == ExceptionHandling::DwarfCFI || 656 ExceptionsType == ExceptionHandling::ARM || usesWindowsCFI()); 657 } 658 659 bool usesWindowsCFI() const { 660 return ExceptionsType == ExceptionHandling::WinEH && 661 (WinEHEncodingType != WinEH::EncodingType::Invalid && 662 WinEHEncodingType != WinEH::EncodingType::X86); 663 } 664 665 bool doesDwarfUseRelocationsAcrossSections() const { 666 return DwarfUsesRelocationsAcrossSections; 667 } 668 669 bool doDwarfFDESymbolsUseAbsDiff() const { return DwarfFDESymbolsUseAbsDiff; } 670 bool useDwarfRegNumForCFI() const { return DwarfRegNumForCFI; } 671 bool useParensForSymbolVariant() const { return UseParensForSymbolVariant; } 672 bool supportsExtendedDwarfLocDirective() const { 673 return SupportsExtendedDwarfLocDirective; 674 } 675 676 void addInitialFrameState(const MCCFIInstruction &Inst); 677 678 const std::vector<MCCFIInstruction> &getInitialFrameState() const { 679 return InitialFrameState; 680 } 681 682 void setBinutilsVersion(std::pair<int, int> Value) { 683 BinutilsVersion = Value; 684 } 685 686 /// Return true if assembly (inline or otherwise) should be parsed. 687 bool useIntegratedAssembler() const { return UseIntegratedAssembler; } 688 689 bool binutilsIsAtLeast(int Major, int Minor) const { 690 return BinutilsVersion >= std::make_pair(Major, Minor); 691 } 692 693 /// Set whether assembly (inline or otherwise) should be parsed. 694 virtual void setUseIntegratedAssembler(bool Value) { 695 UseIntegratedAssembler = Value; 696 } 697 698 /// Return true if assembly (inline or otherwise) should be parsed. 699 bool preserveAsmComments() const { return PreserveAsmComments; } 700 701 /// Set whether assembly (inline or otherwise) should be parsed. 702 virtual void setPreserveAsmComments(bool Value) { 703 PreserveAsmComments = Value; 704 } 705 706 DebugCompressionType compressDebugSections() const { 707 return CompressDebugSections; 708 } 709 710 void setCompressDebugSections(DebugCompressionType CompressDebugSections) { 711 this->CompressDebugSections = CompressDebugSections; 712 } 713 714 bool shouldUseLogicalShr() const { return UseLogicalShr; } 715 716 bool canRelaxRelocations() const { return RelaxELFRelocations; } 717 void setRelaxELFRelocations(bool V) { RelaxELFRelocations = V; } 718 bool hasMipsExpressions() const { return HasMipsExpressions; } 719 bool needsFunctionDescriptors() const { return NeedsFunctionDescriptors; } 720 }; 721 722 } // end namespace llvm 723 724 #endif // LLVM_MC_MCASMINFO_H 725