1198090Srdivacky//===-- llvm/MC/MCAsmInfo.h - Asm info --------------------------*- C++ -*-===// 2198090Srdivacky// 3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4353358Sdim// See https://llvm.org/LICENSE.txt for license information. 5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6198090Srdivacky// 7198090Srdivacky//===----------------------------------------------------------------------===// 8198090Srdivacky// 9198090Srdivacky// This file contains a class to be used as the basis for target specific 10198090Srdivacky// asm writers. This class primarily takes care of global printing constants, 11198090Srdivacky// which are used in very similar ways across all targets. 12198090Srdivacky// 13198090Srdivacky//===----------------------------------------------------------------------===// 14198090Srdivacky 15249423Sdim#ifndef LLVM_MC_MCASMINFO_H 16249423Sdim#define LLVM_MC_MCASMINFO_H 17198090Srdivacky 18321369Sdim#include "llvm/ADT/StringRef.h" 19249423Sdim#include "llvm/MC/MCDirectives.h" 20314564Sdim#include "llvm/MC/MCTargetOptions.h" 21226633Sdim#include <vector> 22198090Srdivacky 23198090Srdivackynamespace llvm { 24321369Sdim 25321369Sdimclass MCContext; 26353358Sdimclass MCCFIInstruction; 27276479Sdimclass MCExpr; 28276479Sdimclass MCSection; 29276479Sdimclass MCStreamer; 30353358Sdimclass MCSubtargetInfo; 31276479Sdimclass MCSymbol; 32218893Sdim 33276479Sdimnamespace WinEH { 34321369Sdim 35276479Sdimenum class EncodingType { 36280031Sdim Invalid, /// Invalid 37280031Sdim Alpha, /// Windows Alpha 38280031Sdim Alpha64, /// Windows AXP64 39280031Sdim ARM, /// Windows NT (Windows on ARM) 40280031Sdim CE, /// Windows CE ARM, PowerPC, SH3, SH4 41280031Sdim Itanium, /// Windows x64, Windows Itanium (IA-64) 42288943Sdim X86, /// Windows x86, uses no CFI, just EH tables 43280031Sdim MIPS = Alpha, 44276479Sdim}; 45198090Srdivacky 46321369Sdim} // end namespace WinEH 47321369Sdim 48276479Sdimnamespace LCOMM { 49321369Sdim 50276479Sdimenum LCOMMType { NoAlignment, ByteAlignment, Log2Alignment }; 51234353Sdim 52321369Sdim} // end namespace LCOMM 53309124Sdim 54276479Sdim/// This class is intended to be used as a base class for asm 55276479Sdim/// properties and features specific to the target. 56276479Sdimclass MCAsmInfo { 57276479Sdimprotected: 58276479Sdim //===------------------------------------------------------------------===// 59276479Sdim // Properties to be set by the target writer, used to configure asm printer. 60276479Sdim // 61198090Srdivacky 62321369Sdim /// Code pointer size in bytes. Default is 4. 63321369Sdim unsigned CodePointerSize = 4; 64249423Sdim 65276479Sdim /// Size of the stack slot reserved for callee-saved registers, in bytes. 66276479Sdim /// Default is same as pointer size. 67321369Sdim unsigned CalleeSaveStackSlotSize = 4; 68224145Sdim 69276479Sdim /// True if target is little endian. Default is true. 70321369Sdim bool IsLittleEndian = true; 71224145Sdim 72276479Sdim /// True if target stack grow up. Default is false. 73321369Sdim bool StackGrowsUp = false; 74218893Sdim 75276479Sdim /// True if this target has the MachO .subsections_via_symbols directive. 76276479Sdim /// Default is false. 77321369Sdim bool HasSubsectionsViaSymbols = false; 78218893Sdim 79276479Sdim /// True if this is a MachO target that supports the macho-specific .zerofill 80276479Sdim /// directive for emitting BSS Symbols. Default is false. 81321369Sdim bool HasMachoZeroFillDirective = false; 82218893Sdim 83276479Sdim /// True if this is a MachO target that supports the macho-specific .tbss 84276479Sdim /// directive for emitting thread local BSS Symbols. Default is false. 85321369Sdim bool HasMachoTBSSDirective = false; 86218893Sdim 87341825Sdim /// True if this is a non-GNU COFF target. The COFF port of the GNU linker 88341825Sdim /// doesn't handle associative comdats in the way that we would like to use 89341825Sdim /// them. 90341825Sdim bool HasCOFFAssociativeComdats = false; 91341825Sdim 92341825Sdim /// True if this is a non-GNU COFF target. For GNU targets, we don't generate 93341825Sdim /// constants into comdat sections. 94341825Sdim bool HasCOFFComdatConstants = false; 95341825Sdim 96276479Sdim /// This is the maximum possible length of an instruction, which is needed to 97276479Sdim /// compute the size of an inline asm. Defaults to 4. 98321369Sdim unsigned MaxInstLength = 4; 99198090Srdivacky 100276479Sdim /// Every possible instruction length is a multiple of this value. Factored 101276479Sdim /// out in .debug_frame and .debug_line. Defaults to 1. 102321369Sdim unsigned MinInstAlignment = 1; 103261991Sdim 104276479Sdim /// The '$' token, when not referencing an identifier or constant, refers to 105276479Sdim /// the current PC. Defaults to false. 106321369Sdim bool DollarIsPC = false; 107198090Srdivacky 108276479Sdim /// This string, if specified, is used to separate instructions from each 109276479Sdim /// other when on the same line. Defaults to ';' 110276479Sdim const char *SeparatorString; 111198090Srdivacky 112276479Sdim /// This indicates the comment character used by the assembler. Defaults to 113276479Sdim /// "#" 114314564Sdim StringRef CommentString; 115198090Srdivacky 116276479Sdim /// This is appended to emitted labels. Defaults to ":" 117276479Sdim const char *LabelSuffix; 118218893Sdim 119276479Sdim // Print the EH begin symbol with an assignment. Defaults to false. 120321369Sdim bool UseAssignmentForEHBegin = false; 121249423Sdim 122288943Sdim // Do we need to create a local symbol for .size? 123321369Sdim bool NeedsLocalForSize = false; 124288943Sdim 125276479Sdim /// This prefix is used for globals like constant pool entries that are 126276479Sdim /// completely private to the .s file and should not have names in the .o 127276479Sdim /// file. Defaults to "L" 128314564Sdim StringRef PrivateGlobalPrefix; 129198090Srdivacky 130280031Sdim /// This prefix is used for labels for basic blocks. Defaults to the same as 131280031Sdim /// PrivateGlobalPrefix. 132314564Sdim StringRef PrivateLabelPrefix; 133280031Sdim 134276479Sdim /// This prefix is used for symbols that should be passed through the 135276479Sdim /// assembler but be removed by the linker. This is 'l' on Darwin, currently 136276479Sdim /// used for some ObjC metadata. The default of "" meast that for this system 137276479Sdim /// a plain private symbol should be used. Defaults to "". 138314564Sdim StringRef LinkerPrivateGlobalPrefix; 139218893Sdim 140276479Sdim /// If these are nonempty, they contain a directive to emit before and after 141276479Sdim /// an inline assembly statement. Defaults to "#APP\n", "#NO_APP\n" 142276479Sdim const char *InlineAsmStart; 143276479Sdim const char *InlineAsmEnd; 144218893Sdim 145276479Sdim /// These are assembly directives that tells the assembler to interpret the 146276479Sdim /// following instructions differently. Defaults to ".code16", ".code32", 147276479Sdim /// ".code64". 148276479Sdim const char *Code16Directive; 149276479Sdim const char *Code32Directive; 150276479Sdim const char *Code64Directive; 151198090Srdivacky 152276479Sdim /// Which dialect of an assembler variant to use. Defaults to 0 153321369Sdim unsigned AssemblerDialect = 0; 154226633Sdim 155276479Sdim /// This is true if the assembler allows @ characters in symbol names. 156276479Sdim /// Defaults to false. 157321369Sdim bool AllowAtInName = false; 158198090Srdivacky 159288943Sdim /// If this is true, symbol names with invalid characters will be printed in 160288943Sdim /// quotes. 161321369Sdim bool SupportsQuotedNames = true; 162288943Sdim 163276479Sdim /// This is true if data region markers should be printed as 164276479Sdim /// ".data_region/.end_data_region" directives. If false, use "$d/$a" labels 165276479Sdim /// instead. 166321369Sdim bool UseDataRegionDirectives = false; 167198090Srdivacky 168360784Sdim /// True if .align is to be used for alignment. Only power-of-two 169360784Sdim /// alignment is supported. 170360784Sdim bool UseDotAlignForAlignment = false; 171360784Sdim 172276479Sdim //===--- Data Emission Directives -------------------------------------===// 173239462Sdim 174276479Sdim /// This should be set to the directive used to get some number of zero bytes 175276479Sdim /// emitted to the current section. Common cases are "\t.zero\t" and 176276479Sdim /// "\t.space\t". If this is set to null, the Data*bitsDirective's will be 177276479Sdim /// used to emit zero bytes. Defaults to "\t.zero\t" 178276479Sdim const char *ZeroDirective; 179198090Srdivacky 180276479Sdim /// This directive allows emission of an ascii string with the standard C 181327952Sdim /// escape characters embedded into it. If a target doesn't support this, it 182327952Sdim /// can be set to null. Defaults to "\t.ascii\t" 183276479Sdim const char *AsciiDirective; 184198090Srdivacky 185276479Sdim /// If not null, this allows for special handling of zero terminated strings 186276479Sdim /// on this target. This is commonly supported as ".asciz". If a target 187276479Sdim /// doesn't support this, it can be set to null. Defaults to "\t.asciz\t" 188276479Sdim const char *AscizDirective; 189218893Sdim 190276479Sdim /// These directives are used to output some unit of integer data to the 191276479Sdim /// current section. If a data directive is set to null, smaller data 192276479Sdim /// directives will be used to emit the large sizes. Defaults to "\t.byte\t", 193276479Sdim /// "\t.short\t", "\t.long\t", "\t.quad\t" 194276479Sdim const char *Data8bitsDirective; 195276479Sdim const char *Data16bitsDirective; 196276479Sdim const char *Data32bitsDirective; 197276479Sdim const char *Data64bitsDirective; 198198090Srdivacky 199276479Sdim /// If non-null, a directive that is used to emit a word which should be 200276479Sdim /// relocated as a 64-bit GP-relative offset, e.g. .gpdword on Mips. Defaults 201321369Sdim /// to nullptr. 202321369Sdim const char *GPRel64Directive = nullptr; 203198090Srdivacky 204276479Sdim /// If non-null, a directive that is used to emit a word which should be 205276479Sdim /// relocated as a 32-bit GP-relative offset, e.g. .gpword on Mips or .gprel32 206321369Sdim /// on Alpha. Defaults to nullptr. 207321369Sdim const char *GPRel32Directive = nullptr; 208234353Sdim 209314564Sdim /// If non-null, directives that are used to emit a word/dword which should 210314564Sdim /// be relocated as a 32/64-bit DTP/TP-relative offset, e.g. .dtprelword/ 211314564Sdim /// .dtpreldword/.tprelword/.tpreldword on Mips. 212314564Sdim const char *DTPRel32Directive = nullptr; 213314564Sdim const char *DTPRel64Directive = nullptr; 214314564Sdim const char *TPRel32Directive = nullptr; 215314564Sdim const char *TPRel64Directive = nullptr; 216314564Sdim 217276479Sdim /// This is true if this target uses "Sun Style" syntax for section switching 218276479Sdim /// ("#alloc,#write" etc) instead of the normal ELF syntax (,"a,w") in 219276479Sdim /// .section directives. Defaults to false. 220321369Sdim bool SunStyleELFSectionSwitchSyntax = false; 221218893Sdim 222276479Sdim /// This is true if this target uses ELF '.section' directive before the 223276479Sdim /// '.bss' one. It's used for PPC/Linux which doesn't support the '.bss' 224276479Sdim /// directive only. Defaults to false. 225321369Sdim bool UsesELFSectionDirectiveForBSS = false; 226198090Srdivacky 227321369Sdim bool NeedsDwarfSectionOffsetDirective = false; 228218893Sdim 229276479Sdim //===--- Alignment Information ----------------------------------------===// 230218893Sdim 231276479Sdim /// If this is true (the default) then the asmprinter emits ".align N" 232276479Sdim /// directives, where N is the number of bytes to align to. Otherwise, it 233276479Sdim /// emits ".align log2(N)", e.g. 3 to align to an 8 byte boundary. Defaults 234276479Sdim /// to true. 235321369Sdim bool AlignmentIsInBytes = true; 236251662Sdim 237276479Sdim /// If non-zero, this is used to fill the executable space created as the 238276479Sdim /// result of a alignment directive. Defaults to 0 239321369Sdim unsigned TextAlignFillValue = 0; 240198090Srdivacky 241276479Sdim //===--- Global Variable Emission Directives --------------------------===// 242198090Srdivacky 243280031Sdim /// This is the directive used to declare a global entity. Defaults to 244280031Sdim /// ".globl". 245276479Sdim const char *GlobalDirective; 246198090Srdivacky 247280031Sdim /// True if the expression 248280031Sdim /// .long f - g 249288943Sdim /// uses a relocation but it can be suppressed by writing 250280031Sdim /// a = f - g 251280031Sdim /// .long a 252321369Sdim bool SetDirectiveSuppressesReloc = false; 253198090Srdivacky 254276479Sdim /// False if the assembler requires that we use 255276479Sdim /// \code 256276479Sdim /// Lc = a - b 257276479Sdim /// .long Lc 258276479Sdim /// \endcode 259276479Sdim // 260276479Sdim /// instead of 261276479Sdim // 262276479Sdim /// \code 263276479Sdim /// .long a - b 264276479Sdim /// \endcode 265276479Sdim /// 266276479Sdim /// Defaults to true. 267321369Sdim bool HasAggressiveSymbolFolding = true; 268218893Sdim 269276479Sdim /// True is .comm's and .lcomms optional alignment is to be specified in bytes 270276479Sdim /// instead of log2(n). Defaults to true. 271321369Sdim bool COMMDirectiveAlignmentIsInBytes = true; 272198090Srdivacky 273276479Sdim /// Describes if the .lcomm directive for the target supports an alignment 274276479Sdim /// argument and how it is interpreted. Defaults to NoAlignment. 275321369Sdim LCOMM::LCOMMType LCOMMDirectiveAlignmentType = LCOMM::NoAlignment; 276218893Sdim 277288943Sdim // True if the target allows .align directives on functions. This is true for 278288943Sdim // most targets, so defaults to true. 279321369Sdim bool HasFunctionAlignment = true; 280288943Sdim 281276479Sdim /// True if the target has .type and .size directives, this is true for most 282276479Sdim /// ELF targets. Defaults to true. 283321369Sdim bool HasDotTypeDotSizeDirective = true; 284218893Sdim 285276479Sdim /// True if the target has a single parameter .file directive, this is true 286276479Sdim /// for ELF targets. Defaults to true. 287321369Sdim bool HasSingleParameterDotFile = true; 288218893Sdim 289276479Sdim /// True if the target has a .ident directive, this is true for ELF targets. 290276479Sdim /// Defaults to false. 291321369Sdim bool HasIdentDirective = false; 292243830Sdim 293276479Sdim /// True if this target supports the MachO .no_dead_strip directive. Defaults 294276479Sdim /// to false. 295321369Sdim bool HasNoDeadStrip = false; 296198090Srdivacky 297309124Sdim /// True if this target supports the MachO .alt_entry directive. Defaults to 298309124Sdim /// false. 299321369Sdim bool HasAltEntry = false; 300309124Sdim 301280031Sdim /// Used to declare a global as being a weak symbol. Defaults to ".weak". 302280031Sdim const char *WeakDirective; 303280031Sdim 304276479Sdim /// This directive, if non-null, is used to declare a global as being a weak 305321369Sdim /// undefined symbol. Defaults to nullptr. 306321369Sdim const char *WeakRefDirective = nullptr; 307198090Srdivacky 308276479Sdim /// True if we have a directive to declare a global as being a weak defined 309276479Sdim /// symbol. Defaults to false. 310321369Sdim bool HasWeakDefDirective = false; 311261991Sdim 312276479Sdim /// True if we have a directive to declare a global as being a weak defined 313276479Sdim /// symbol that can be hidden (unexported). Defaults to false. 314321369Sdim bool HasWeakDefCanBeHiddenDirective = false; 315198090Srdivacky 316276479Sdim /// True if we have a .linkonce directive. This is used on cygwin/mingw. 317276479Sdim /// Defaults to false. 318321369Sdim bool HasLinkOnceDirective = false; 319218893Sdim 320360784Sdim /// True if we have a .lglobl directive, which is used to emit the information 321360784Sdim /// of a static symbol into the symbol table. Defaults to false. 322360784Sdim bool HasDotLGloblDirective = false; 323360784Sdim 324276479Sdim /// This attribute, if not MCSA_Invalid, is used to declare a symbol as having 325276479Sdim /// hidden visibility. Defaults to MCSA_Hidden. 326321369Sdim MCSymbolAttr HiddenVisibilityAttr = MCSA_Hidden; 327202878Srdivacky 328276479Sdim /// This attribute, if not MCSA_Invalid, is used to declare an undefined 329276479Sdim /// symbol as having hidden visibility. Defaults to MCSA_Hidden. 330321369Sdim MCSymbolAttr HiddenDeclarationVisibilityAttr = MCSA_Hidden; 331218893Sdim 332276479Sdim /// This attribute, if not MCSA_Invalid, is used to declare a symbol as having 333276479Sdim /// protected visibility. Defaults to MCSA_Protected 334321369Sdim MCSymbolAttr ProtectedVisibilityAttr = MCSA_Protected; 335265925Sdim 336360784Sdim // This attribute is used to indicate symbols such as commons on AIX may have 337360784Sdim // a storage mapping class embedded in the name. 338360784Sdim bool SymbolsHaveSMC = false; 339360784Sdim 340276479Sdim //===--- Dwarf Emission Directives -----------------------------------===// 341198090Srdivacky 342276479Sdim /// True if target supports emission of debugging information. Defaults to 343276479Sdim /// false. 344321369Sdim bool SupportsDebugInformation = false; 345219077Sdim 346276479Sdim /// Exception handling format for the target. Defaults to None. 347321369Sdim ExceptionHandling ExceptionsType = ExceptionHandling::None; 348198090Srdivacky 349276479Sdim /// Windows exception handling data (.pdata) encoding. Defaults to Invalid. 350321369Sdim WinEH::EncodingType WinEHEncodingType = WinEH::EncodingType::Invalid; 351198090Srdivacky 352276479Sdim /// True if Dwarf2 output generally uses relocations for references to other 353276479Sdim /// .debug_* sections. 354321369Sdim bool DwarfUsesRelocationsAcrossSections = true; 355198090Srdivacky 356276479Sdim /// True if DWARF FDE symbol reference relocations should be replaced by an 357276479Sdim /// absolute difference. 358321369Sdim bool DwarfFDESymbolsUseAbsDiff = false; 359198090Srdivacky 360276479Sdim /// True if dwarf register numbers are printed instead of symbolic register 361276479Sdim /// names in .cfi_* directives. Defaults to false. 362321369Sdim bool DwarfRegNumForCFI = false; 363198090Srdivacky 364276479Sdim /// True if target uses parens to indicate the symbol variant instead of @. 365276479Sdim /// For example, foo(plt) instead of foo@plt. Defaults to false. 366321369Sdim bool UseParensForSymbolVariant = false; 367212904Sdim 368341825Sdim /// True if the target supports flags in ".loc" directive, false if only 369341825Sdim /// location is allowed. 370341825Sdim bool SupportsExtendedDwarfLocDirective = true; 371341825Sdim 372276479Sdim //===--- Prologue State ----------------------------------------------===// 373265925Sdim 374276479Sdim std::vector<MCCFIInstruction> InitialFrameState; 375224145Sdim 376288943Sdim //===--- Integrated Assembler Information ----------------------------===// 377226633Sdim 378276479Sdim /// Should we use the integrated assembler? 379276479Sdim /// The integrated assembler should be enabled by default (by the 380276479Sdim /// constructors) when failing to parse a valid piece of assembly (inline 381276479Sdim /// or otherwise) is considered a bug. It may then be overridden after 382276479Sdim /// construction (see LLVMTargetMachine::initAsmInfo()). 383276479Sdim bool UseIntegratedAssembler; 384226633Sdim 385309124Sdim /// Preserve Comments in assembly 386309124Sdim bool PreserveAsmComments; 387198090Srdivacky 388309124Sdim /// Compress DWARF debug sections. Defaults to no compression. 389321369Sdim DebugCompressionType CompressDebugSections = DebugCompressionType::None; 390309124Sdim 391288943Sdim /// True if the integrated assembler should interpret 'a >> b' constant 392288943Sdim /// expressions as logical rather than arithmetic. 393321369Sdim bool UseLogicalShr = true; 394288943Sdim 395309124Sdim // If true, emit GOTPCRELX/REX_GOTPCRELX instead of GOTPCREL, on 396309124Sdim // X86_64 ELF. 397309124Sdim bool RelaxELFRelocations = true; 398309124Sdim 399314564Sdim // If true, then the lexer and expression parser will support %neg(), 400314564Sdim // %hi(), and similar unary operators. 401314564Sdim bool HasMipsExpressions = false; 402314564Sdim 403360784Sdim // If true, emit function descriptor symbol on AIX. 404360784Sdim bool NeedsFunctionDescriptors = false; 405360784Sdim 406276479Sdimpublic: 407276479Sdim explicit MCAsmInfo(); 408276479Sdim virtual ~MCAsmInfo(); 409198090Srdivacky 410321369Sdim /// Get the code pointer size in bytes. 411321369Sdim unsigned getCodePointerSize() const { return CodePointerSize; } 412224145Sdim 413276479Sdim /// Get the callee-saved register stack slot 414276479Sdim /// size in bytes. 415276479Sdim unsigned getCalleeSaveStackSlotSize() const { 416276479Sdim return CalleeSaveStackSlotSize; 417276479Sdim } 418249423Sdim 419276479Sdim /// True if the target is little endian. 420276479Sdim bool isLittleEndian() const { return IsLittleEndian; } 421224145Sdim 422276479Sdim /// True if target stack grow up. 423276479Sdim bool isStackGrowthDirectionUp() const { return StackGrowsUp; } 424224145Sdim 425276479Sdim bool hasSubsectionsViaSymbols() const { return HasSubsectionsViaSymbols; } 426218893Sdim 427276479Sdim // Data directive accessors. 428198090Srdivacky 429276479Sdim const char *getData8bitsDirective() const { return Data8bitsDirective; } 430276479Sdim const char *getData16bitsDirective() const { return Data16bitsDirective; } 431276479Sdim const char *getData32bitsDirective() const { return Data32bitsDirective; } 432276479Sdim const char *getData64bitsDirective() const { return Data64bitsDirective; } 433276479Sdim const char *getGPRel64Directive() const { return GPRel64Directive; } 434276479Sdim const char *getGPRel32Directive() const { return GPRel32Directive; } 435314564Sdim const char *getDTPRel64Directive() const { return DTPRel64Directive; } 436314564Sdim const char *getDTPRel32Directive() const { return DTPRel32Directive; } 437314564Sdim const char *getTPRel64Directive() const { return TPRel64Directive; } 438314564Sdim const char *getTPRel32Directive() const { return TPRel32Directive; } 439218893Sdim 440276479Sdim /// Targets can implement this method to specify a section to switch to if the 441276479Sdim /// translation unit doesn't have any trampolines that require an executable 442276479Sdim /// stack. 443288943Sdim virtual MCSection *getNonexecutableStackSection(MCContext &Ctx) const { 444276479Sdim return nullptr; 445276479Sdim } 446221345Sdim 447341825Sdim /// True if the section is atomized using the symbols in it. 448280031Sdim /// This is false if the section is not atomized at all (most ELF sections) or 449280031Sdim /// if it is atomized based on its contents (MachO' __TEXT,__cstring for 450280031Sdim /// example). 451280031Sdim virtual bool isSectionAtomizableBySymbols(const MCSection &Section) const; 452280031Sdim 453276479Sdim virtual const MCExpr *getExprForPersonalitySymbol(const MCSymbol *Sym, 454276479Sdim unsigned Encoding, 455276479Sdim MCStreamer &Streamer) const; 456221345Sdim 457276479Sdim virtual const MCExpr *getExprForFDESymbol(const MCSymbol *Sym, 458276479Sdim unsigned Encoding, 459276479Sdim MCStreamer &Streamer) const; 460218893Sdim 461360784Sdim /// Return true if C is an acceptable character inside a symbol name. 462360784Sdim virtual bool isAcceptableChar(char C) const; 463360784Sdim 464288943Sdim /// Return true if the identifier \p Name does not need quotes to be 465288943Sdim /// syntactically correct. 466288943Sdim virtual bool isValidUnquotedName(StringRef Name) const; 467288943Sdim 468296417Sdim /// Return true if the .section directive should be omitted when 469296417Sdim /// emitting \p SectionName. For example: 470296417Sdim /// 471296417Sdim /// shouldOmitSectionDirective(".text") 472296417Sdim /// 473296417Sdim /// returns false => .section .text,#alloc,#execinstr 474296417Sdim /// returns true => .text 475296417Sdim virtual bool shouldOmitSectionDirective(StringRef SectionName) const; 476296417Sdim 477276479Sdim bool usesSunStyleELFSectionSwitchSyntax() const { 478276479Sdim return SunStyleELFSectionSwitchSyntax; 479276479Sdim } 480198090Srdivacky 481276479Sdim bool usesELFSectionDirectiveForBSS() const { 482276479Sdim return UsesELFSectionDirectiveForBSS; 483276479Sdim } 484218893Sdim 485276479Sdim bool needsDwarfSectionOffsetDirective() const { 486276479Sdim return NeedsDwarfSectionOffsetDirective; 487276479Sdim } 488251662Sdim 489276479Sdim // Accessors. 490249423Sdim 491276479Sdim bool hasMachoZeroFillDirective() const { return HasMachoZeroFillDirective; } 492276479Sdim bool hasMachoTBSSDirective() const { return HasMachoTBSSDirective; } 493341825Sdim bool hasCOFFAssociativeComdats() const { return HasCOFFAssociativeComdats; } 494341825Sdim bool hasCOFFComdatConstants() const { return HasCOFFComdatConstants; } 495353358Sdim 496353358Sdim /// Returns the maximum possible encoded instruction size in bytes. If \p STI 497353358Sdim /// is null, this should be the maximum size for any subtarget. 498353358Sdim virtual unsigned getMaxInstLength(const MCSubtargetInfo *STI = nullptr) const { 499353358Sdim return MaxInstLength; 500353358Sdim } 501353358Sdim 502276479Sdim unsigned getMinInstAlignment() const { return MinInstAlignment; } 503276479Sdim bool getDollarIsPC() const { return DollarIsPC; } 504276479Sdim const char *getSeparatorString() const { return SeparatorString; } 505249423Sdim 506276479Sdim /// This indicates the column (zero-based) at which asm comments should be 507276479Sdim /// printed. 508276479Sdim unsigned getCommentColumn() const { return 40; } 509276479Sdim 510314564Sdim StringRef getCommentString() const { return CommentString; } 511276479Sdim const char *getLabelSuffix() const { return LabelSuffix; } 512276479Sdim 513276479Sdim bool useAssignmentForEHBegin() const { return UseAssignmentForEHBegin; } 514288943Sdim bool needsLocalForSize() const { return NeedsLocalForSize; } 515314564Sdim StringRef getPrivateGlobalPrefix() const { return PrivateGlobalPrefix; } 516314564Sdim StringRef getPrivateLabelPrefix() const { return PrivateLabelPrefix; } 517321369Sdim 518276479Sdim bool hasLinkerPrivateGlobalPrefix() const { 519353358Sdim return !LinkerPrivateGlobalPrefix.empty(); 520276479Sdim } 521321369Sdim 522314564Sdim StringRef getLinkerPrivateGlobalPrefix() const { 523276479Sdim if (hasLinkerPrivateGlobalPrefix()) 524198090Srdivacky return LinkerPrivateGlobalPrefix; 525276479Sdim return getPrivateGlobalPrefix(); 526276479Sdim } 527321369Sdim 528276479Sdim const char *getInlineAsmStart() const { return InlineAsmStart; } 529276479Sdim const char *getInlineAsmEnd() const { return InlineAsmEnd; } 530276479Sdim const char *getCode16Directive() const { return Code16Directive; } 531276479Sdim const char *getCode32Directive() const { return Code32Directive; } 532276479Sdim const char *getCode64Directive() const { return Code64Directive; } 533276479Sdim unsigned getAssemblerDialect() const { return AssemblerDialect; } 534276479Sdim bool doesAllowAtInName() const { return AllowAtInName; } 535288943Sdim bool supportsNameQuoting() const { return SupportsQuotedNames; } 536321369Sdim 537276479Sdim bool doesSupportDataRegionDirectives() const { 538276479Sdim return UseDataRegionDirectives; 539276479Sdim } 540321369Sdim 541360784Sdim bool useDotAlignForAlignment() const { 542360784Sdim return UseDotAlignForAlignment; 543360784Sdim } 544360784Sdim 545276479Sdim const char *getZeroDirective() const { return ZeroDirective; } 546276479Sdim const char *getAsciiDirective() const { return AsciiDirective; } 547276479Sdim const char *getAscizDirective() const { return AscizDirective; } 548276479Sdim bool getAlignmentIsInBytes() const { return AlignmentIsInBytes; } 549276479Sdim unsigned getTextAlignFillValue() const { return TextAlignFillValue; } 550276479Sdim const char *getGlobalDirective() const { return GlobalDirective; } 551321369Sdim 552309124Sdim bool doesSetDirectiveSuppressReloc() const { 553280031Sdim return SetDirectiveSuppressesReloc; 554280031Sdim } 555321369Sdim 556276479Sdim bool hasAggressiveSymbolFolding() const { return HasAggressiveSymbolFolding; } 557321369Sdim 558276479Sdim bool getCOMMDirectiveAlignmentIsInBytes() const { 559276479Sdim return COMMDirectiveAlignmentIsInBytes; 560276479Sdim } 561321369Sdim 562276479Sdim LCOMM::LCOMMType getLCOMMDirectiveAlignmentType() const { 563276479Sdim return LCOMMDirectiveAlignmentType; 564276479Sdim } 565321369Sdim 566288943Sdim bool hasFunctionAlignment() const { return HasFunctionAlignment; } 567276479Sdim bool hasDotTypeDotSizeDirective() const { return HasDotTypeDotSizeDirective; } 568276479Sdim bool hasSingleParameterDotFile() const { return HasSingleParameterDotFile; } 569276479Sdim bool hasIdentDirective() const { return HasIdentDirective; } 570276479Sdim bool hasNoDeadStrip() const { return HasNoDeadStrip; } 571309124Sdim bool hasAltEntry() const { return HasAltEntry; } 572280031Sdim const char *getWeakDirective() const { return WeakDirective; } 573276479Sdim const char *getWeakRefDirective() const { return WeakRefDirective; } 574276479Sdim bool hasWeakDefDirective() const { return HasWeakDefDirective; } 575321369Sdim 576276479Sdim bool hasWeakDefCanBeHiddenDirective() const { 577276479Sdim return HasWeakDefCanBeHiddenDirective; 578276479Sdim } 579321369Sdim 580276479Sdim bool hasLinkOnceDirective() const { return HasLinkOnceDirective; } 581218893Sdim 582360784Sdim bool hasDotLGloblDirective() const { return HasDotLGloblDirective; } 583360784Sdim 584276479Sdim MCSymbolAttr getHiddenVisibilityAttr() const { return HiddenVisibilityAttr; } 585321369Sdim 586276479Sdim MCSymbolAttr getHiddenDeclarationVisibilityAttr() const { 587276479Sdim return HiddenDeclarationVisibilityAttr; 588276479Sdim } 589321369Sdim 590276479Sdim MCSymbolAttr getProtectedVisibilityAttr() const { 591276479Sdim return ProtectedVisibilityAttr; 592276479Sdim } 593321369Sdim 594360784Sdim bool getSymbolsHaveSMC() const { return SymbolsHaveSMC; } 595360784Sdim 596276479Sdim bool doesSupportDebugInformation() const { return SupportsDebugInformation; } 597321369Sdim 598276479Sdim bool doesSupportExceptionHandling() const { 599276479Sdim return ExceptionsType != ExceptionHandling::None; 600276479Sdim } 601321369Sdim 602276479Sdim ExceptionHandling getExceptionHandlingType() const { return ExceptionsType; } 603276479Sdim WinEH::EncodingType getWinEHEncodingType() const { return WinEHEncodingType; } 604280031Sdim 605309124Sdim void setExceptionsType(ExceptionHandling EH) { 606309124Sdim ExceptionsType = EH; 607309124Sdim } 608309124Sdim 609288943Sdim /// Returns true if the exception handling method for the platform uses call 610288943Sdim /// frame information to unwind. 611288943Sdim bool usesCFIForEH() const { 612276479Sdim return (ExceptionsType == ExceptionHandling::DwarfCFI || 613288943Sdim ExceptionsType == ExceptionHandling::ARM || usesWindowsCFI()); 614276479Sdim } 615280031Sdim 616280031Sdim bool usesWindowsCFI() const { 617288943Sdim return ExceptionsType == ExceptionHandling::WinEH && 618288943Sdim (WinEHEncodingType != WinEH::EncodingType::Invalid && 619288943Sdim WinEHEncodingType != WinEH::EncodingType::X86); 620280031Sdim } 621280031Sdim 622276479Sdim bool doesDwarfUseRelocationsAcrossSections() const { 623276479Sdim return DwarfUsesRelocationsAcrossSections; 624276479Sdim } 625321369Sdim 626276479Sdim bool doDwarfFDESymbolsUseAbsDiff() const { return DwarfFDESymbolsUseAbsDiff; } 627276479Sdim bool useDwarfRegNumForCFI() const { return DwarfRegNumForCFI; } 628276479Sdim bool useParensForSymbolVariant() const { return UseParensForSymbolVariant; } 629341825Sdim bool supportsExtendedDwarfLocDirective() const { 630341825Sdim return SupportsExtendedDwarfLocDirective; 631341825Sdim } 632226633Sdim 633353358Sdim void addInitialFrameState(const MCCFIInstruction &Inst); 634261991Sdim 635276479Sdim const std::vector<MCCFIInstruction> &getInitialFrameState() const { 636276479Sdim return InitialFrameState; 637276479Sdim } 638276479Sdim 639276479Sdim /// Return true if assembly (inline or otherwise) should be parsed. 640276479Sdim bool useIntegratedAssembler() const { return UseIntegratedAssembler; } 641276479Sdim 642276479Sdim /// Set whether assembly (inline or otherwise) should be parsed. 643276479Sdim virtual void setUseIntegratedAssembler(bool Value) { 644276479Sdim UseIntegratedAssembler = Value; 645276479Sdim } 646276479Sdim 647309124Sdim /// Return true if assembly (inline or otherwise) should be parsed. 648309124Sdim bool preserveAsmComments() const { return PreserveAsmComments; } 649276479Sdim 650309124Sdim /// Set whether assembly (inline or otherwise) should be parsed. 651309124Sdim virtual void setPreserveAsmComments(bool Value) { 652309124Sdim PreserveAsmComments = Value; 653309124Sdim } 654309124Sdim 655309124Sdim DebugCompressionType compressDebugSections() const { 656309124Sdim return CompressDebugSections; 657309124Sdim } 658309124Sdim 659309124Sdim void setCompressDebugSections(DebugCompressionType CompressDebugSections) { 660276479Sdim this->CompressDebugSections = CompressDebugSections; 661276479Sdim } 662288943Sdim 663288943Sdim bool shouldUseLogicalShr() const { return UseLogicalShr; } 664309124Sdim 665309124Sdim bool canRelaxRelocations() const { return RelaxELFRelocations; } 666309124Sdim void setRelaxELFRelocations(bool V) { RelaxELFRelocations = V; } 667314564Sdim bool hasMipsExpressions() const { return HasMipsExpressions; } 668360784Sdim bool needsFunctionDescriptors() const { return NeedsFunctionDescriptors; } 669276479Sdim}; 670198090Srdivacky 671321369Sdim} // end namespace llvm 672321369Sdim 673321369Sdim#endif // LLVM_MC_MCASMINFO_H 674