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