1 //===-- llvm/Target/TargetAsmInfo.h - Asm info ------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains a class to be used as the basis for target specific
11 // asm writers. This class primarily takes care of global printing constants,
12 // which are used in very similar ways across all targets.
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_TARGET_ASM_INFO_H
17 #define LLVM_TARGET_ASM_INFO_H
19 #include "llvm/ADT/DenseMap.h"
20 #include "llvm/ADT/StringMap.h"
21 #include "llvm/Support/DataTypes.h"
25 // DWARF encoding query type
26 namespace DwarfEncoding {
34 /// SectionKind - This is a simple POD value that classifies the properties of
35 /// a section. A global variable is classified into the deepest possible
36 /// classification, and then the target maps them onto their sections based on
37 /// what capabilities they have.
39 /// The comments below describe these as if they were an inheritance hierarchy
40 /// in order to explain the predicates below.
43 /// Text - Text section, used for functions and other executable code.
46 /// ReadOnly - Data that is never written to at program runtime by the
47 /// program or the dynamic linker. Things in the top-level readonly
48 /// SectionKind are not mergeable.
51 /// MergeableCString - This is a special section for nul-terminated
52 /// strings. The linker can unique the C strings, knowing their
53 /// semantics. Because it uniques based on the nul terminators, the
54 /// compiler can't put strings in this section that have embeded nuls
58 /// MergeableConst - These are sections for merging fixed-length
59 /// constants together. For example, this can be used to unique
60 /// constant pool entries etc.
63 /// MergeableConst4 - This is a section used by 4-byte constants,
64 /// for example, floats.
67 /// MergeableConst8 - This is a section used by 8-byte constants,
68 /// for example, doubles.
71 /// MergeableConst16 - This is a section used by 16-byte constants,
72 /// for example, vectors.
75 /// Writeable - This is the base of all segments that need to be written
76 /// to during program runtime.
78 /// ThreadLocal - This is the base of all TLS segments. All TLS
79 /// objects must be writeable, otherwise there is no reason for them to
82 /// ThreadBSS - Zero-initialized TLS data objects.
85 /// ThreadData - Initialized TLS data objects.
88 /// GlobalWriteableData - Writeable data that is global (not thread
91 /// BSS - Zero initialized writeable data.
94 /// DataRel - This is the most general form of data that is written
95 /// to by the program, it can have random relocations to arbitrary
99 /// DataRelLocal - This is writeable data that has a non-zero
100 /// initializer and has relocations in it, but all of the
101 /// relocations are known to be within the final linked image
102 /// the global is linked into.
105 /// DataNoRel - This is writeable data that has a non-zero
106 /// initializer, but whose initializer is known to have no
110 /// ReadOnlyWithRel - These are global variables that are never
111 /// written to by the program, but that have relocations, so they
112 /// must be stuck in a writeable section so that the dynamic linker
113 /// can write to them. If it chooses to, the dynamic linker can
114 /// mark the pages these globals end up on as read-only after it is
115 /// done with its relocation phase.
118 /// ReadOnlyWithRelLocal - This is data that is readonly by the
119 /// program, but must be writeable so that the dynamic linker
120 /// can perform relocations in it. This is used when we know
121 /// that all the relocations are to globals in this final
130 /// Weak - This is true if the referenced symbol is weak (i.e. linkonce,
131 /// weak, weak_odr, etc). This is orthogonal from the categorization.
135 bool isWeak() const { return Weak; }
137 bool isText() const { return K == Text; }
139 bool isReadOnly() const {
140 return K == ReadOnly || K == MergeableCString || isMergeableConst();
143 bool isMergeableCString() const { return K == MergeableCString; }
144 bool isMergeableConst() const {
145 return K == MergeableConst || K == MergeableConst4 ||
146 K == MergeableConst8 || K == MergeableConst16;
149 bool isMergeableConst4() const { return K == MergeableConst4; }
150 bool isMergeableConst8() const { return K == MergeableConst8; }
151 bool isMergeableConst16() const { return K == MergeableConst16; }
153 bool isWriteable() const {
154 return isThreadLocal() || isGlobalWriteableData();
157 bool isThreadLocal() const {
158 return K == ThreadData || K == ThreadBSS;
161 bool isThreadBSS() const { return K == ThreadBSS; }
162 bool isThreadData() const { return K == ThreadData; }
164 bool isGlobalWriteableData() const {
165 return isBSS() || isDataRel() || isReadOnlyWithRel();
168 bool isBSS() const { return K == BSS; }
170 bool isDataRel() const {
171 return K == DataRel || K == DataRelLocal || K == DataNoRel;
174 bool isDataRelLocal() const {
175 return K == DataRelLocal || K == DataNoRel;
178 bool isDataNoRel() const { return K == DataNoRel; }
180 bool isReadOnlyWithRel() const {
181 return K == ReadOnlyWithRel || K == ReadOnlyWithRelLocal;
184 bool isReadOnlyWithRelLocal() const {
185 return K == ReadOnlyWithRelLocal;
188 static SectionKind get(Kind K, bool isWeak) {
196 namespace SectionFlags {
197 const unsigned Invalid = -1U;
198 const unsigned None = 0;
199 const unsigned Code = 1 << 0; ///< Section contains code
200 const unsigned Writable = 1 << 1; ///< Section is writeable
201 const unsigned BSS = 1 << 2; ///< Section contains only zeroes
202 const unsigned Mergeable = 1 << 3; ///< Section contains mergeable data
203 const unsigned Strings = 1 << 4; ///< Section contains C-type strings
204 const unsigned TLS = 1 << 5; ///< Section contains thread-local data
205 const unsigned Debug = 1 << 6; ///< Section contains debug data
206 const unsigned Linkonce = 1 << 7; ///< Section is linkonce
207 const unsigned TypeFlags = 0xFF;
208 // Some gap for future flags
210 /// Named - True if this section should be printed with ".section <name>",
211 /// false if the section name is something like ".const".
212 const unsigned Named = 1 << 23; ///< Section is named
213 const unsigned EntitySize = 0xFF << 24; ///< Entity size for mergeable stuff
215 static inline unsigned getEntitySize(unsigned Flags) {
216 return (Flags >> 24) & 0xFF;
219 // FIXME: Why does this return a value?
220 static inline unsigned setEntitySize(unsigned Flags, unsigned Size) {
221 return (Flags & ~EntitySize) | ((Size & 0xFF) << 24);
225 static inline unsigned getEmptyKey() { return Invalid; }
226 static inline unsigned getTombstoneKey() { return Invalid - 1; }
227 static unsigned getHashValue(const unsigned &Key) { return Key; }
228 static bool isEqual(unsigned LHS, unsigned RHS) { return LHS == RHS; }
229 static bool isPod() { return true; }
232 typedef DenseMap<unsigned, std::string, KeyInfo> FlagsStringsMapType;
242 friend class TargetAsmInfo;
243 friend class StringMapEntry<Section>;
244 friend class StringMap<Section>;
248 explicit Section(unsigned F = SectionFlags::Invalid) : Flags(F) { }
252 unsigned getEntitySize() const { return (Flags >> 24) & 0xFF; }
254 const std::string &getName() const { return Name; }
255 unsigned getFlags() const { return Flags; }
257 bool hasFlag(unsigned F) const { return (Flags & F) != 0; }
260 /// TargetAsmInfo - This class is intended to be used as a base class for asm
261 /// properties and features specific to the target.
262 class TargetAsmInfo {
264 mutable StringMap<Section> Sections;
265 mutable SectionFlags::FlagsStringsMapType FlagsStrings;
267 /// TM - The current TargetMachine.
268 const TargetMachine &TM;
270 //===------------------------------------------------------------------===//
271 // Properties to be set by the target writer, used to configure asm printer.
274 /// TextSection - Section directive for standard text.
276 const Section *TextSection; // Defaults to ".text".
278 /// DataSection - Section directive for standard data.
280 const Section *DataSection; // Defaults to ".data".
282 /// BSSSection - Section directive for uninitialized data. Null if this
283 /// target doesn't support a BSS section.
285 const char *BSSSection; // Default to ".bss".
286 const Section *BSSSection_;
288 /// ReadOnlySection - This is the directive that is emitted to switch to a
289 /// read-only section for constant data (e.g. data declared const,
291 const Section *ReadOnlySection; // Defaults to NULL
293 /// TLSDataSection - Section directive for Thread Local data.
295 const Section *TLSDataSection; // Defaults to ".tdata".
297 /// TLSBSSSection - Section directive for Thread Local uninitialized data.
298 /// Null if this target doesn't support a BSS section.
300 const Section *TLSBSSSection; // Defaults to ".tbss".
302 /// ZeroFillDirective - Directive for emitting a global to the ZeroFill
303 /// section on this target. Null if this target doesn't support zerofill.
304 const char *ZeroFillDirective; // Default is null.
306 /// NonexecutableStackDirective - Directive for declaring to the
307 /// linker and beyond that the emitted code does not require stack
308 /// memory to be executable.
309 const char *NonexecutableStackDirective; // Default is null.
311 /// NeedsSet - True if target asm treats expressions in data directives
312 /// as linktime-relocatable. For assembly-time computation, we need to
313 /// use a .set. Thus:
316 /// is computed at assembly time, while
318 /// is relocated if the relative locations of x and y change at linktime.
319 /// We want both these things in different places.
320 bool NeedsSet; // Defaults to false.
322 /// MaxInstLength - This is the maximum possible length of an instruction,
323 /// which is needed to compute the size of an inline asm.
324 unsigned MaxInstLength; // Defaults to 4.
326 /// PCSymbol - The symbol used to represent the current PC. Used in PC
327 /// relative expressions.
328 const char *PCSymbol; // Defaults to "$".
330 /// SeparatorChar - This character, if specified, is used to separate
331 /// instructions from each other when on the same line. This is used to
332 /// measure inline asm instructions.
333 char SeparatorChar; // Defaults to ';'
335 /// CommentColumn - This indicates the comment num (zero-based) at
336 /// which asm comments should be printed.
337 unsigned CommentColumn; // Defaults to 60
339 /// CommentString - This indicates the comment character used by the
341 const char *CommentString; // Defaults to "#"
343 /// FirstOperandColumn - The output column where the first operand
344 /// should be printed
345 unsigned FirstOperandColumn; // Defaults to 0 (ignored)
347 /// MaxOperandLength - The maximum length of any printed asm
349 unsigned MaxOperandLength; // Defaults to 0 (ignored)
351 /// GlobalPrefix - If this is set to a non-empty string, it is prepended
352 /// onto all global symbols. This is often used for "_" or ".".
353 const char *GlobalPrefix; // Defaults to ""
355 /// PrivateGlobalPrefix - This prefix is used for globals like constant
356 /// pool entries that are completely private to the .s file and should not
357 /// have names in the .o file. This is often "." or "L".
358 const char *PrivateGlobalPrefix; // Defaults to "."
360 /// LinkerPrivateGlobalPrefix - This prefix is used for symbols that should
361 /// be passed through the assembler but be removed by the linker. This
362 /// is "l" on Darwin, currently used for some ObjC metadata.
363 const char *LinkerPrivateGlobalPrefix; // Defaults to ""
365 /// JumpTableSpecialLabelPrefix - If not null, a extra (dead) label is
366 /// emitted before jump tables with the specified prefix.
367 const char *JumpTableSpecialLabelPrefix; // Default to null.
369 /// GlobalVarAddrPrefix/Suffix - If these are nonempty, these strings
370 /// will enclose any GlobalVariable (that isn't a function)
372 const char *GlobalVarAddrPrefix; // Defaults to ""
373 const char *GlobalVarAddrSuffix; // Defaults to ""
375 /// FunctionAddrPrefix/Suffix - If these are nonempty, these strings
376 /// will enclose any GlobalVariable that points to a function.
378 const char *FunctionAddrPrefix; // Defaults to ""
379 const char *FunctionAddrSuffix; // Defaults to ""
381 /// PersonalityPrefix/Suffix - If these are nonempty, these strings will
382 /// enclose any personality function in the common frame section.
384 const char *PersonalityPrefix; // Defaults to ""
385 const char *PersonalitySuffix; // Defaults to ""
387 /// NeedsIndirectEncoding - If set, we need to set the indirect encoding bit
390 bool NeedsIndirectEncoding; // Defaults to false
392 /// InlineAsmStart/End - If these are nonempty, they contain a directive to
393 /// emit before and after an inline assembly statement.
394 const char *InlineAsmStart; // Defaults to "#APP\n"
395 const char *InlineAsmEnd; // Defaults to "#NO_APP\n"
397 /// AssemblerDialect - Which dialect of an assembler variant to use.
398 unsigned AssemblerDialect; // Defaults to 0
400 /// AllowQuotesInName - This is true if the assembler allows for complex
401 /// symbol names to be surrounded in quotes. This defaults to false.
402 bool AllowQuotesInName;
404 //===--- Data Emission Directives -------------------------------------===//
406 /// ZeroDirective - this should be set to the directive used to get some
407 /// number of zero bytes emitted to the current section. Common cases are
408 /// "\t.zero\t" and "\t.space\t". If this is set to null, the
409 /// Data*bitsDirective's will be used to emit zero bytes.
410 const char *ZeroDirective; // Defaults to "\t.zero\t"
411 const char *ZeroDirectiveSuffix; // Defaults to ""
413 /// AsciiDirective - This directive allows emission of an ascii string with
414 /// the standard C escape characters embedded into it.
415 const char *AsciiDirective; // Defaults to "\t.ascii\t"
417 /// AscizDirective - If not null, this allows for special handling of
418 /// zero terminated strings on this target. This is commonly supported as
419 /// ".asciz". If a target doesn't support this, it can be set to null.
420 const char *AscizDirective; // Defaults to "\t.asciz\t"
422 /// DataDirectives - These directives are used to output some unit of
423 /// integer data to the current section. If a data directive is set to
424 /// null, smaller data directives will be used to emit the large sizes.
425 const char *Data8bitsDirective; // Defaults to "\t.byte\t"
426 const char *Data16bitsDirective; // Defaults to "\t.short\t"
427 const char *Data32bitsDirective; // Defaults to "\t.long\t"
428 const char *Data64bitsDirective; // Defaults to "\t.quad\t"
430 /// getDataASDirective - Return the directive that should be used to emit
431 /// data of the specified size to the specified numeric address space.
432 virtual const char *getDataASDirective(unsigned Size, unsigned AS) const {
433 assert(AS != 0 && "Don't know the directives for default addr space");
437 //===--- Alignment Information ----------------------------------------===//
439 /// AlignDirective - The directive used to emit round up to an alignment
442 const char *AlignDirective; // Defaults to "\t.align\t"
444 /// AlignmentIsInBytes - If this is true (the default) then the asmprinter
445 /// emits ".align N" directives, where N is the number of bytes to align to.
446 /// Otherwise, it emits ".align log2(N)", e.g. 3 to align to an 8 byte
448 bool AlignmentIsInBytes; // Defaults to true
450 /// TextAlignFillValue - If non-zero, this is used to fill the executable
451 /// space created as the result of a alignment directive.
452 unsigned TextAlignFillValue;
454 //===--- Section Switching Directives ---------------------------------===//
456 /// SwitchToSectionDirective - This is the directive used when we want to
457 /// emit a global to an arbitrary section. The section name is emited after
459 const char *SwitchToSectionDirective; // Defaults to "\t.section\t"
461 /// TextSectionStartSuffix - This is printed after each start of section
462 /// directive for text sections.
463 const char *TextSectionStartSuffix; // Defaults to "".
465 /// DataSectionStartSuffix - This is printed after each start of section
466 /// directive for data sections.
467 const char *DataSectionStartSuffix; // Defaults to "".
469 /// SectionEndDirectiveSuffix - If non-null, the asm printer will close each
470 /// section with the section name and this suffix printed.
471 const char *SectionEndDirectiveSuffix;// Defaults to null.
473 /// ConstantPoolSection - This is the section that we SwitchToSection right
474 /// before emitting the constant pool for a function.
475 const char *ConstantPoolSection; // Defaults to "\t.section .rodata"
477 /// JumpTableDataSection - This is the section that we SwitchToSection right
478 /// before emitting the jump tables for a function when the relocation model
480 const char *JumpTableDataSection; // Defaults to "\t.section .rodata"
482 /// JumpTableDirective - if non-null, the directive to emit before a jump
484 const char *JumpTableDirective;
486 /// CStringSection - If not null, this allows for special handling of
487 /// cstring constants (null terminated string that does not contain any
488 /// other null bytes) on this target. This is commonly supported as
490 const char *CStringSection; // Defaults to NULL
491 const Section *CStringSection_;
493 /// StaticCtorsSection - This is the directive that is emitted to switch to
494 /// a section to emit the static constructor list.
495 /// Defaults to "\t.section .ctors,\"aw\",@progbits".
496 const char *StaticCtorsSection;
498 /// StaticDtorsSection - This is the directive that is emitted to switch to
499 /// a section to emit the static destructor list.
500 /// Defaults to "\t.section .dtors,\"aw\",@progbits".
501 const char *StaticDtorsSection;
503 //===--- Global Variable Emission Directives --------------------------===//
505 /// GlobalDirective - This is the directive used to declare a global entity.
507 const char *GlobalDirective; // Defaults to NULL.
509 /// ExternDirective - This is the directive used to declare external
512 const char *ExternDirective; // Defaults to NULL.
514 /// SetDirective - This is the name of a directive that can be used to tell
515 /// the assembler to set the value of a variable to some expression.
516 const char *SetDirective; // Defaults to null.
518 /// LCOMMDirective - This is the name of a directive (if supported) that can
519 /// be used to efficiently declare a local (internal) block of zero
520 /// initialized data in the .bss/.data section. The syntax expected is:
521 /// @verbatim <LCOMMDirective> SYMBOLNAME LENGTHINBYTES, ALIGNMENT
523 const char *LCOMMDirective; // Defaults to null.
525 const char *COMMDirective; // Defaults to "\t.comm\t".
527 /// COMMDirectiveTakesAlignment - True if COMMDirective take a third
528 /// argument that specifies the alignment of the declaration.
529 bool COMMDirectiveTakesAlignment; // Defaults to true.
531 /// HasDotTypeDotSizeDirective - True if the target has .type and .size
532 /// directives, this is true for most ELF targets.
533 bool HasDotTypeDotSizeDirective; // Defaults to true.
535 /// HasSingleParameterDotFile - True if the target has a single parameter
536 /// .file directive, this is true for ELF targets.
537 bool HasSingleParameterDotFile; // Defaults to true.
539 /// UsedDirective - This directive, if non-null, is used to declare a global
540 /// as being used somehow that the assembler can't see. This prevents dead
541 /// code elimination on some targets.
542 const char *UsedDirective; // Defaults to null.
544 /// WeakRefDirective - This directive, if non-null, is used to declare a
545 /// global as being a weak undefined symbol.
546 const char *WeakRefDirective; // Defaults to null.
548 /// WeakDefDirective - This directive, if non-null, is used to declare a
549 /// global as being a weak defined symbol.
550 const char *WeakDefDirective; // Defaults to null.
552 /// HiddenDirective - This directive, if non-null, is used to declare a
553 /// global or function as having hidden visibility.
554 const char *HiddenDirective; // Defaults to "\t.hidden\t".
556 /// ProtectedDirective - This directive, if non-null, is used to declare a
557 /// global or function as having protected visibility.
558 const char *ProtectedDirective; // Defaults to "\t.protected\t".
560 //===--- Dwarf Emission Directives -----------------------------------===//
562 /// AbsoluteDebugSectionOffsets - True if we should emit abolute section
563 /// offsets for debug information. Defaults to false.
564 bool AbsoluteDebugSectionOffsets;
566 /// AbsoluteEHSectionOffsets - True if we should emit abolute section
567 /// offsets for EH information. Defaults to false.
568 bool AbsoluteEHSectionOffsets;
570 /// HasLEB128 - True if target asm supports leb128 directives.
572 bool HasLEB128; // Defaults to false.
574 /// hasDotLocAndDotFile - True if target asm supports .loc and .file
575 /// directives for emitting debugging information.
577 bool HasDotLocAndDotFile; // Defaults to false.
579 /// SupportsDebugInformation - True if target supports emission of debugging
581 bool SupportsDebugInformation;
583 /// SupportsExceptionHandling - True if target supports
584 /// exception handling.
586 bool SupportsExceptionHandling; // Defaults to false.
588 /// RequiresFrameSection - true if the Dwarf2 output needs a frame section
590 bool DwarfRequiresFrameSection; // Defaults to true.
592 /// DwarfUsesInlineInfoSection - True if DwarfDebugInlineSection is used to
593 /// encode inline subroutine information.
594 bool DwarfUsesInlineInfoSection; // Defaults to false.
596 /// Is_EHSymbolPrivate - If set, the "_foo.eh" is made private so that it
597 /// doesn't show up in the symbol table of the object file.
598 bool Is_EHSymbolPrivate; // Defaults to true.
600 /// GlobalEHDirective - This is the directive used to make exception frame
601 /// tables globally visible.
603 const char *GlobalEHDirective; // Defaults to NULL.
605 /// SupportsWeakEmptyEHFrame - True if target assembler and linker will
606 /// handle a weak_definition of constant 0 for an omitted EH frame.
607 bool SupportsWeakOmittedEHFrame; // Defaults to true.
609 /// DwarfSectionOffsetDirective - Special section offset directive.
610 const char* DwarfSectionOffsetDirective; // Defaults to NULL
612 /// DwarfAbbrevSection - Section directive for Dwarf abbrev.
614 const char *DwarfAbbrevSection; // Defaults to ".debug_abbrev".
616 /// DwarfInfoSection - Section directive for Dwarf info.
618 const char *DwarfInfoSection; // Defaults to ".debug_info".
620 /// DwarfLineSection - Section directive for Dwarf info.
622 const char *DwarfLineSection; // Defaults to ".debug_line".
624 /// DwarfFrameSection - Section directive for Dwarf info.
626 const char *DwarfFrameSection; // Defaults to ".debug_frame".
628 /// DwarfPubNamesSection - Section directive for Dwarf info.
630 const char *DwarfPubNamesSection; // Defaults to ".debug_pubnames".
632 /// DwarfPubTypesSection - Section directive for Dwarf info.
634 const char *DwarfPubTypesSection; // Defaults to ".debug_pubtypes".
636 /// DwarfDebugInlineSection - Section directive for inline info.
638 const char *DwarfDebugInlineSection; // Defaults to ".debug_inlined"
640 /// DwarfStrSection - Section directive for Dwarf info.
642 const char *DwarfStrSection; // Defaults to ".debug_str".
644 /// DwarfLocSection - Section directive for Dwarf info.
646 const char *DwarfLocSection; // Defaults to ".debug_loc".
648 /// DwarfARangesSection - Section directive for Dwarf info.
650 const char *DwarfARangesSection; // Defaults to ".debug_aranges".
652 /// DwarfRangesSection - Section directive for Dwarf info.
654 const char *DwarfRangesSection; // Defaults to ".debug_ranges".
656 /// DwarfMacroInfoSection - Section directive for DWARF macro info.
658 const char *DwarfMacroInfoSection; // Defaults to ".debug_macinfo".
660 /// DwarfEHFrameSection - Section directive for Exception frames.
662 const char *DwarfEHFrameSection; // Defaults to ".eh_frame".
664 /// DwarfExceptionSection - Section directive for Exception table.
666 const char *DwarfExceptionSection; // Defaults to ".gcc_except_table".
668 //===--- CBE Asm Translation Table -----------------------------------===//
670 const char *const *AsmTransCBE; // Defaults to empty
673 explicit TargetAsmInfo(const TargetMachine &TM);
674 virtual ~TargetAsmInfo();
676 const Section* getNamedSection(const char *Name,
677 unsigned Flags = SectionFlags::None,
678 bool Override = false) const;
679 const Section* getUnnamedSection(const char *Directive,
680 unsigned Flags = SectionFlags::None,
681 bool Override = false) const;
683 /// Measure the specified inline asm to determine an approximation of its
685 virtual unsigned getInlineAsmLength(const char *Str) const;
687 /// emitUsedDirectiveFor - This hook allows targets to selectively decide
688 /// not to emit the UsedDirective for some symbols in llvm.used.
689 // FIXME: REMOVE this (rdar://7071300)
690 virtual bool emitUsedDirectiveFor(const GlobalValue *GV,
691 Mangler *Mang) const {
695 /// PreferredEHDataFormat - This hook allows the target to select data
696 /// format used for encoding pointers in exception handling data. Reason is
697 /// 0 for data, 1 for code labels, 2 for function pointers. Global is true
698 /// if the symbol can be relocated.
699 virtual unsigned PreferredEHDataFormat(DwarfEncoding::Target Reason,
703 /// getSectionForMergeableConstant - Given a Mergeable constant with the
704 /// specified size and relocation information, return a section that it
705 /// should be placed in.
706 virtual const Section *getSectionForMergeableConstant(SectionKind Kind)const;
709 /// getSectionPrefixForUniqueGlobal - Return a string that we should prepend
710 /// onto a global's name in order to get the unique section name for the
711 /// global. This is important for globals that need to be merged across
712 /// translation units.
714 getSectionPrefixForUniqueGlobal(SectionKind Kind) const {
718 /// getFlagsForNamedSection - If this target wants to be able to infer
719 /// section flags based on the name of the section specified for a global
720 /// variable, it can implement this. This is used on ELF systems so that
721 /// ".tbss" gets the TLS bit set etc.
722 virtual unsigned getFlagsForNamedSection(const char *Section) const {
726 /// SectionForGlobal - This method computes the appropriate section to emit
727 /// the specified global variable or function definition. This should not
728 /// be passed external (or available externally) globals.
729 // FIXME: MOVE TO ASMPRINTER.
730 const Section* SectionForGlobal(const GlobalValue *GV) const;
732 /// getSpecialCasedSectionGlobals - Allow the target to completely override
733 /// section assignment of a global.
734 /// FIXME: ELIMINATE this by making PIC16 implement ADDRESS with
735 /// getFlagsForNamedSection.
736 virtual const Section *
737 getSpecialCasedSectionGlobals(const GlobalValue *GV,
738 SectionKind Kind) const {
742 const std::string &getSectionFlags(unsigned Flags) const;
743 virtual std::string printSectionFlags(unsigned flags) const { return ""; }
745 // FIXME: Eliminate this.
746 virtual const Section* SelectSectionForGlobal(const GlobalValue *GV,
747 SectionKind Kind) const;
749 /// getSLEB128Size - Compute the number of bytes required for a signed
751 static unsigned getSLEB128Size(int Value);
753 /// getULEB128Size - Compute the number of bytes required for an unsigned
755 static unsigned getULEB128Size(unsigned Value);
757 // Data directive accessors.
759 const char *getData8bitsDirective(unsigned AS = 0) const {
760 return AS == 0 ? Data8bitsDirective : getDataASDirective(8, AS);
762 const char *getData16bitsDirective(unsigned AS = 0) const {
763 return AS == 0 ? Data16bitsDirective : getDataASDirective(16, AS);
765 const char *getData32bitsDirective(unsigned AS = 0) const {
766 return AS == 0 ? Data32bitsDirective : getDataASDirective(32, AS);
768 const char *getData64bitsDirective(unsigned AS = 0) const {
769 return AS == 0 ? Data64bitsDirective : getDataASDirective(64, AS);
775 const Section *getTextSection() const {
778 const Section *getDataSection() const {
781 const char *getBSSSection() const {
784 const Section *getBSSSection_() const {
787 const Section *getReadOnlySection() const {
788 return ReadOnlySection;
790 const Section *getTLSDataSection() const {
791 return TLSDataSection;
793 const Section *getTLSBSSSection() const {
794 return TLSBSSSection;
796 const char *getZeroFillDirective() const {
797 return ZeroFillDirective;
799 const char *getNonexecutableStackDirective() const {
800 return NonexecutableStackDirective;
802 bool needsSet() const {
805 const char *getPCSymbol() const {
808 char getSeparatorChar() const {
809 return SeparatorChar;
811 unsigned getCommentColumn() const {
812 return CommentColumn;
814 const char *getCommentString() const {
815 return CommentString;
817 unsigned getOperandColumn(int operand) const {
818 return FirstOperandColumn + (MaxOperandLength+1)*(operand-1);
820 const char *getGlobalPrefix() const {
823 const char *getPrivateGlobalPrefix() const {
824 return PrivateGlobalPrefix;
826 const char *getLinkerPrivateGlobalPrefix() const {
827 return LinkerPrivateGlobalPrefix;
829 const char *getJumpTableSpecialLabelPrefix() const {
830 return JumpTableSpecialLabelPrefix;
832 const char *getGlobalVarAddrPrefix() const {
833 return GlobalVarAddrPrefix;
835 const char *getGlobalVarAddrSuffix() const {
836 return GlobalVarAddrSuffix;
838 const char *getFunctionAddrPrefix() const {
839 return FunctionAddrPrefix;
841 const char *getFunctionAddrSuffix() const {
842 return FunctionAddrSuffix;
844 const char *getPersonalityPrefix() const {
845 return PersonalityPrefix;
847 const char *getPersonalitySuffix() const {
848 return PersonalitySuffix;
850 bool getNeedsIndirectEncoding() const {
851 return NeedsIndirectEncoding;
853 const char *getInlineAsmStart() const {
854 return InlineAsmStart;
856 const char *getInlineAsmEnd() const {
859 unsigned getAssemblerDialect() const {
860 return AssemblerDialect;
862 bool doesAllowQuotesInName() const {
863 return AllowQuotesInName;
865 const char *getZeroDirective() const {
866 return ZeroDirective;
868 const char *getZeroDirectiveSuffix() const {
869 return ZeroDirectiveSuffix;
871 const char *getAsciiDirective() const {
872 return AsciiDirective;
874 const char *getAscizDirective() const {
875 return AscizDirective;
877 const char *getJumpTableDirective() const {
878 return JumpTableDirective;
880 const char *getAlignDirective() const {
881 return AlignDirective;
883 bool getAlignmentIsInBytes() const {
884 return AlignmentIsInBytes;
886 unsigned getTextAlignFillValue() const {
887 return TextAlignFillValue;
889 const char *getSwitchToSectionDirective() const {
890 return SwitchToSectionDirective;
892 const char *getTextSectionStartSuffix() const {
893 return TextSectionStartSuffix;
895 const char *getDataSectionStartSuffix() const {
896 return DataSectionStartSuffix;
898 const char *getSectionEndDirectiveSuffix() const {
899 return SectionEndDirectiveSuffix;
901 const char *getConstantPoolSection() const {
902 return ConstantPoolSection;
904 const char *getJumpTableDataSection() const {
905 return JumpTableDataSection;
907 const char *getCStringSection() const {
908 return CStringSection;
910 const Section *getCStringSection_() const {
911 return CStringSection_;
913 const char *getStaticCtorsSection() const {
914 return StaticCtorsSection;
916 const char *getStaticDtorsSection() const {
917 return StaticDtorsSection;
919 const char *getGlobalDirective() const {
920 return GlobalDirective;
922 const char *getExternDirective() const {
923 return ExternDirective;
925 const char *getSetDirective() const {
928 const char *getLCOMMDirective() const {
929 return LCOMMDirective;
931 const char *getCOMMDirective() const {
932 return COMMDirective;
934 bool getCOMMDirectiveTakesAlignment() const {
935 return COMMDirectiveTakesAlignment;
937 bool hasDotTypeDotSizeDirective() const {
938 return HasDotTypeDotSizeDirective;
940 bool hasSingleParameterDotFile() const {
941 return HasSingleParameterDotFile;
943 const char *getUsedDirective() const {
944 return UsedDirective;
946 const char *getWeakRefDirective() const {
947 return WeakRefDirective;
949 const char *getWeakDefDirective() const {
950 return WeakDefDirective;
952 const char *getHiddenDirective() const {
953 return HiddenDirective;
955 const char *getProtectedDirective() const {
956 return ProtectedDirective;
958 bool isAbsoluteDebugSectionOffsets() const {
959 return AbsoluteDebugSectionOffsets;
961 bool isAbsoluteEHSectionOffsets() const {
962 return AbsoluteEHSectionOffsets;
964 bool hasLEB128() const {
967 bool hasDotLocAndDotFile() const {
968 return HasDotLocAndDotFile;
970 bool doesSupportDebugInformation() const {
971 return SupportsDebugInformation;
973 bool doesSupportExceptionHandling() const {
974 return SupportsExceptionHandling;
976 bool doesDwarfRequireFrameSection() const {
977 return DwarfRequiresFrameSection;
979 bool doesDwarfUsesInlineInfoSection() const {
980 return DwarfUsesInlineInfoSection;
982 bool is_EHSymbolPrivate() const {
983 return Is_EHSymbolPrivate;
985 const char *getGlobalEHDirective() const {
986 return GlobalEHDirective;
988 bool getSupportsWeakOmittedEHFrame() const {
989 return SupportsWeakOmittedEHFrame;
991 const char *getDwarfSectionOffsetDirective() const {
992 return DwarfSectionOffsetDirective;
994 const char *getDwarfAbbrevSection() const {
995 return DwarfAbbrevSection;
997 const char *getDwarfInfoSection() const {
998 return DwarfInfoSection;
1000 const char *getDwarfLineSection() const {
1001 return DwarfLineSection;
1003 const char *getDwarfFrameSection() const {
1004 return DwarfFrameSection;
1006 const char *getDwarfPubNamesSection() const {
1007 return DwarfPubNamesSection;
1009 const char *getDwarfPubTypesSection() const {
1010 return DwarfPubTypesSection;
1012 const char *getDwarfDebugInlineSection() const {
1013 return DwarfDebugInlineSection;
1015 const char *getDwarfStrSection() const {
1016 return DwarfStrSection;
1018 const char *getDwarfLocSection() const {
1019 return DwarfLocSection;
1021 const char *getDwarfARangesSection() const {
1022 return DwarfARangesSection;
1024 const char *getDwarfRangesSection() const {
1025 return DwarfRangesSection;
1027 const char *getDwarfMacroInfoSection() const {
1028 return DwarfMacroInfoSection;
1030 const char *getDwarfEHFrameSection() const {
1031 return DwarfEHFrameSection;
1033 const char *getDwarfExceptionSection() const {
1034 return DwarfExceptionSection;
1036 const char *const *getAsmCBE() const {