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 mergable.
51 /// MergableCString - 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 /// MergableConst - These are sections for merging fixed-length
59 /// constants together. For example, this can be used to unique
60 /// constant pool entries etc.
63 /// MergableConst4 - This is a section used by 4-byte constants,
64 /// for example, floats.
67 /// MergableConst8 - This is a section used by 8-byte constants,
68 /// for example, doubles.
71 /// MergableConst16 - This is a section used by 16-byte constants,
72 /// for example, vectors.
75 /// Writable - 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 writable, otherwise there is no reason for them to
82 /// ThreadBSS - Zero-initialized TLS data objects.
85 /// ThreadData - Initialized TLS data objects.
88 /// GlobalWritableData - Writable data that is global (not thread
91 /// BSS - Zero initialized writable 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 writable 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 writable 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 writable 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 writable 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
125 } K : 8; // This is private.
127 bool isText() const {
131 bool isReadOnly() const {
132 return K == ReadOnly || K == MergableCString || isMergableConst();
135 bool isMergableCString() const { return K == MergableCString; }
136 bool isMergableConst() const {
137 return K == MergableConst || K == MergableConst4 ||
138 K == MergableConst8 || K == MergableConst16;
141 bool isMergableConst4() const { return K == MergableConst4; }
142 bool isMergableConst8() const { return K == MergableConst8; }
143 bool isMergableConst16() const { return K == MergableConst16; }
145 bool isWritable() const {
146 return isThreadLocal() || isGlobalWritableData();
149 bool isThreadLocal() const {
150 return K == ThreadData || K == ThreadBSS;
153 bool isThreadBSS() const { return K == ThreadBSS; }
154 bool isThreadData() const { return K == ThreadData; }
156 bool isGlobalWritableData() const {
157 return isBSS() || isDataRel() || isReadOnlyWithRel();
160 bool isBSS() const { return K == BSS; }
162 bool isDataRel() const {
163 return K == DataRel || K == DataRelLocal || K == DataNoRel;
166 bool isDataRelLocal() const {
167 return K == DataRelLocal || K == DataNoRel;
170 bool isDataNoRel() const { return K == DataNoRel; }
172 bool isReadOnlyWithRel() const {
173 return K == ReadOnlyWithRel || K == ReadOnlyWithRelLocal;
176 bool isReadOnlyWithRelLocal() const {
177 return K == ReadOnlyWithRelLocal;
180 static SectionKind get(Kind K) {
181 SectionKind Res = { K };
186 namespace SectionFlags {
187 const unsigned Invalid = -1U;
188 const unsigned None = 0;
189 const unsigned Code = 1 << 0; ///< Section contains code
190 const unsigned Writable = 1 << 1; ///< Section is writable
191 const unsigned BSS = 1 << 2; ///< Section contains only zeroes
192 const unsigned Mergeable = 1 << 3; ///< Section contains mergeable data
193 const unsigned Strings = 1 << 4; ///< Section contains C-type strings
194 const unsigned TLS = 1 << 5; ///< Section contains thread-local data
195 const unsigned Debug = 1 << 6; ///< Section contains debug data
196 const unsigned Linkonce = 1 << 7; ///< Section is linkonce
197 const unsigned TypeFlags = 0xFF;
198 // Some gap for future flags
200 /// Named - True if this section should be printed with ".section <name>",
201 /// false if the section name is something like ".const".
202 const unsigned Named = 1 << 23; ///< Section is named
203 const unsigned EntitySize = 0xFF << 24; ///< Entity size for mergeable stuff
205 static inline unsigned getEntitySize(unsigned Flags) {
206 return (Flags >> 24) & 0xFF;
209 // FIXME: Why does this return a value?
210 static inline unsigned setEntitySize(unsigned Flags, unsigned Size) {
211 return (Flags & ~EntitySize) | ((Size & 0xFF) << 24);
215 static inline unsigned getEmptyKey() { return Invalid; }
216 static inline unsigned getTombstoneKey() { return Invalid - 1; }
217 static unsigned getHashValue(const unsigned &Key) { return Key; }
218 static bool isEqual(unsigned LHS, unsigned RHS) { return LHS == RHS; }
219 static bool isPod() { return true; }
222 typedef DenseMap<unsigned, std::string, KeyInfo> FlagsStringsMapType;
232 friend class TargetAsmInfo;
233 friend class StringMapEntry<Section>;
234 friend class StringMap<Section>;
238 explicit Section(unsigned F = SectionFlags::Invalid) : Flags(F) { }
242 unsigned getEntitySize() const { return (Flags >> 24) & 0xFF; }
244 const std::string &getName() const { return Name; }
245 unsigned getFlags() const { return Flags; }
247 bool hasFlag(unsigned F) const { return (Flags & F) != 0; }
250 /// TargetAsmInfo - This class is intended to be used as a base class for asm
251 /// properties and features specific to the target.
252 class TargetAsmInfo {
254 mutable StringMap<Section> Sections;
255 mutable SectionFlags::FlagsStringsMapType FlagsStrings;
257 /// TM - The current TargetMachine.
258 const TargetMachine &TM;
260 //===------------------------------------------------------------------===//
261 // Properties to be set by the target writer, used to configure asm printer.
264 /// TextSection - Section directive for standard text.
266 const Section *TextSection; // Defaults to ".text".
268 /// DataSection - Section directive for standard data.
270 const Section *DataSection; // Defaults to ".data".
272 /// BSSSection - Section directive for uninitialized data. Null if this
273 /// target doesn't support a BSS section.
275 const char *BSSSection; // Default to ".bss".
276 const Section *BSSSection_;
278 /// ReadOnlySection - This is the directive that is emitted to switch to a
279 /// read-only section for constant data (e.g. data declared const,
281 const Section *ReadOnlySection; // Defaults to NULL
283 /// TLSDataSection - Section directive for Thread Local data.
285 const Section *TLSDataSection; // Defaults to ".tdata".
287 /// TLSBSSSection - Section directive for Thread Local uninitialized data.
288 /// Null if this target doesn't support a BSS section.
290 const Section *TLSBSSSection; // Defaults to ".tbss".
292 /// ZeroFillDirective - Directive for emitting a global to the ZeroFill
293 /// section on this target. Null if this target doesn't support zerofill.
294 const char *ZeroFillDirective; // Default is null.
296 /// NonexecutableStackDirective - Directive for declaring to the
297 /// linker and beyond that the emitted code does not require stack
298 /// memory to be executable.
299 const char *NonexecutableStackDirective; // Default is null.
301 /// NeedsSet - True if target asm treats expressions in data directives
302 /// as linktime-relocatable. For assembly-time computation, we need to
303 /// use a .set. Thus:
306 /// is computed at assembly time, while
308 /// is relocated if the relative locations of x and y change at linktime.
309 /// We want both these things in different places.
310 bool NeedsSet; // Defaults to false.
312 /// MaxInstLength - This is the maximum possible length of an instruction,
313 /// which is needed to compute the size of an inline asm.
314 unsigned MaxInstLength; // Defaults to 4.
316 /// PCSymbol - The symbol used to represent the current PC. Used in PC
317 /// relative expressions.
318 const char *PCSymbol; // Defaults to "$".
320 /// SeparatorChar - This character, if specified, is used to separate
321 /// instructions from each other when on the same line. This is used to
322 /// measure inline asm instructions.
323 char SeparatorChar; // Defaults to ';'
325 /// CommentColumn - This indicates the comment num (zero-based) at
326 /// which asm comments should be printed.
327 unsigned CommentColumn; // Defaults to 60
329 /// CommentString - This indicates the comment character used by the
331 const char *CommentString; // Defaults to "#"
333 /// FirstOperandColumn - The output column where the first operand
334 /// should be printed
335 unsigned FirstOperandColumn; // Defaults to 0 (ignored)
337 /// MaxOperandLength - The maximum length of any printed asm
339 unsigned MaxOperandLength; // Defaults to 0 (ignored)
341 /// GlobalPrefix - If this is set to a non-empty string, it is prepended
342 /// onto all global symbols. This is often used for "_" or ".".
343 const char *GlobalPrefix; // Defaults to ""
345 /// PrivateGlobalPrefix - This prefix is used for globals like constant
346 /// pool entries that are completely private to the .s file and should not
347 /// have names in the .o file. This is often "." or "L".
348 const char *PrivateGlobalPrefix; // Defaults to "."
350 /// LinkerPrivateGlobalPrefix - This prefix is used for symbols that should
351 /// be passed through the assembler but be removed by the linker. This
352 /// is "l" on Darwin, currently used for some ObjC metadata.
353 const char *LinkerPrivateGlobalPrefix; // Defaults to ""
355 /// JumpTableSpecialLabelPrefix - If not null, a extra (dead) label is
356 /// emitted before jump tables with the specified prefix.
357 const char *JumpTableSpecialLabelPrefix; // Default to null.
359 /// GlobalVarAddrPrefix/Suffix - If these are nonempty, these strings
360 /// will enclose any GlobalVariable (that isn't a function)
362 const char *GlobalVarAddrPrefix; // Defaults to ""
363 const char *GlobalVarAddrSuffix; // Defaults to ""
365 /// FunctionAddrPrefix/Suffix - If these are nonempty, these strings
366 /// will enclose any GlobalVariable that points to a function.
368 const char *FunctionAddrPrefix; // Defaults to ""
369 const char *FunctionAddrSuffix; // Defaults to ""
371 /// PersonalityPrefix/Suffix - If these are nonempty, these strings will
372 /// enclose any personality function in the common frame section.
374 const char *PersonalityPrefix; // Defaults to ""
375 const char *PersonalitySuffix; // Defaults to ""
377 /// NeedsIndirectEncoding - If set, we need to set the indirect encoding bit
380 bool NeedsIndirectEncoding; // Defaults to false
382 /// InlineAsmStart/End - If these are nonempty, they contain a directive to
383 /// emit before and after an inline assembly statement.
384 const char *InlineAsmStart; // Defaults to "#APP\n"
385 const char *InlineAsmEnd; // Defaults to "#NO_APP\n"
387 /// AssemblerDialect - Which dialect of an assembler variant to use.
388 unsigned AssemblerDialect; // Defaults to 0
390 /// AllowQuotesInName - This is true if the assembler allows for complex
391 /// symbol names to be surrounded in quotes. This defaults to false.
392 bool AllowQuotesInName;
394 //===--- Data Emission Directives -------------------------------------===//
396 /// ZeroDirective - this should be set to the directive used to get some
397 /// number of zero bytes emitted to the current section. Common cases are
398 /// "\t.zero\t" and "\t.space\t". If this is set to null, the
399 /// Data*bitsDirective's will be used to emit zero bytes.
400 const char *ZeroDirective; // Defaults to "\t.zero\t"
401 const char *ZeroDirectiveSuffix; // Defaults to ""
403 /// AsciiDirective - This directive allows emission of an ascii string with
404 /// the standard C escape characters embedded into it.
405 const char *AsciiDirective; // Defaults to "\t.ascii\t"
407 /// AscizDirective - If not null, this allows for special handling of
408 /// zero terminated strings on this target. This is commonly supported as
409 /// ".asciz". If a target doesn't support this, it can be set to null.
410 const char *AscizDirective; // Defaults to "\t.asciz\t"
412 /// DataDirectives - These directives are used to output some unit of
413 /// integer data to the current section. If a data directive is set to
414 /// null, smaller data directives will be used to emit the large sizes.
415 const char *Data8bitsDirective; // Defaults to "\t.byte\t"
416 const char *Data16bitsDirective; // Defaults to "\t.short\t"
417 const char *Data32bitsDirective; // Defaults to "\t.long\t"
418 const char *Data64bitsDirective; // Defaults to "\t.quad\t"
420 /// getDataASDirective - Return the directive that should be used to emit
421 /// data of the specified size to the specified numeric address space.
422 virtual const char *getDataASDirective(unsigned Size, unsigned AS) const {
423 assert(AS != 0 && "Don't know the directives for default addr space");
427 //===--- Alignment Information ----------------------------------------===//
429 /// AlignDirective - The directive used to emit round up to an alignment
432 const char *AlignDirective; // Defaults to "\t.align\t"
434 /// AlignmentIsInBytes - If this is true (the default) then the asmprinter
435 /// emits ".align N" directives, where N is the number of bytes to align to.
436 /// Otherwise, it emits ".align log2(N)", e.g. 3 to align to an 8 byte
438 bool AlignmentIsInBytes; // Defaults to true
440 /// TextAlignFillValue - If non-zero, this is used to fill the executable
441 /// space created as the result of a alignment directive.
442 unsigned TextAlignFillValue;
444 //===--- Section Switching Directives ---------------------------------===//
446 /// SwitchToSectionDirective - This is the directive used when we want to
447 /// emit a global to an arbitrary section. The section name is emited after
449 const char *SwitchToSectionDirective; // Defaults to "\t.section\t"
451 /// TextSectionStartSuffix - This is printed after each start of section
452 /// directive for text sections.
453 const char *TextSectionStartSuffix; // Defaults to "".
455 /// DataSectionStartSuffix - This is printed after each start of section
456 /// directive for data sections.
457 const char *DataSectionStartSuffix; // Defaults to "".
459 /// SectionEndDirectiveSuffix - If non-null, the asm printer will close each
460 /// section with the section name and this suffix printed.
461 const char *SectionEndDirectiveSuffix;// Defaults to null.
463 /// ConstantPoolSection - This is the section that we SwitchToSection right
464 /// before emitting the constant pool for a function.
465 const char *ConstantPoolSection; // Defaults to "\t.section .rodata"
467 /// JumpTableDataSection - This is the section that we SwitchToSection right
468 /// before emitting the jump tables for a function when the relocation model
470 const char *JumpTableDataSection; // Defaults to "\t.section .rodata"
472 /// JumpTableDirective - if non-null, the directive to emit before a jump
474 const char *JumpTableDirective;
476 /// CStringSection - If not null, this allows for special handling of
477 /// cstring constants (null terminated string that does not contain any
478 /// other null bytes) on this target. This is commonly supported as
480 const char *CStringSection; // Defaults to NULL
481 const Section *CStringSection_;
483 /// StaticCtorsSection - This is the directive that is emitted to switch to
484 /// a section to emit the static constructor list.
485 /// Defaults to "\t.section .ctors,\"aw\",@progbits".
486 const char *StaticCtorsSection;
488 /// StaticDtorsSection - This is the directive that is emitted to switch to
489 /// a section to emit the static destructor list.
490 /// Defaults to "\t.section .dtors,\"aw\",@progbits".
491 const char *StaticDtorsSection;
493 //===--- Global Variable Emission Directives --------------------------===//
495 /// GlobalDirective - This is the directive used to declare a global entity.
497 const char *GlobalDirective; // Defaults to NULL.
499 /// ExternDirective - This is the directive used to declare external
502 const char *ExternDirective; // Defaults to NULL.
504 /// SetDirective - This is the name of a directive that can be used to tell
505 /// the assembler to set the value of a variable to some expression.
506 const char *SetDirective; // Defaults to null.
508 /// LCOMMDirective - This is the name of a directive (if supported) that can
509 /// be used to efficiently declare a local (internal) block of zero
510 /// initialized data in the .bss/.data section. The syntax expected is:
511 /// @verbatim <LCOMMDirective> SYMBOLNAME LENGTHINBYTES, ALIGNMENT
513 const char *LCOMMDirective; // Defaults to null.
515 const char *COMMDirective; // Defaults to "\t.comm\t".
517 /// COMMDirectiveTakesAlignment - True if COMMDirective take a third
518 /// argument that specifies the alignment of the declaration.
519 bool COMMDirectiveTakesAlignment; // Defaults to true.
521 /// HasDotTypeDotSizeDirective - True if the target has .type and .size
522 /// directives, this is true for most ELF targets.
523 bool HasDotTypeDotSizeDirective; // Defaults to true.
525 /// HasSingleParameterDotFile - True if the target has a single parameter
526 /// .file directive, this is true for ELF targets.
527 bool HasSingleParameterDotFile; // Defaults to true.
529 /// UsedDirective - This directive, if non-null, is used to declare a global
530 /// as being used somehow that the assembler can't see. This prevents dead
531 /// code elimination on some targets.
532 const char *UsedDirective; // Defaults to null.
534 /// WeakRefDirective - This directive, if non-null, is used to declare a
535 /// global as being a weak undefined symbol.
536 const char *WeakRefDirective; // Defaults to null.
538 /// WeakDefDirective - This directive, if non-null, is used to declare a
539 /// global as being a weak defined symbol.
540 const char *WeakDefDirective; // Defaults to null.
542 /// HiddenDirective - This directive, if non-null, is used to declare a
543 /// global or function as having hidden visibility.
544 const char *HiddenDirective; // Defaults to "\t.hidden\t".
546 /// ProtectedDirective - This directive, if non-null, is used to declare a
547 /// global or function as having protected visibility.
548 const char *ProtectedDirective; // Defaults to "\t.protected\t".
550 //===--- Dwarf Emission Directives -----------------------------------===//
552 /// AbsoluteDebugSectionOffsets - True if we should emit abolute section
553 /// offsets for debug information. Defaults to false.
554 bool AbsoluteDebugSectionOffsets;
556 /// AbsoluteEHSectionOffsets - True if we should emit abolute section
557 /// offsets for EH information. Defaults to false.
558 bool AbsoluteEHSectionOffsets;
560 /// HasLEB128 - True if target asm supports leb128 directives.
562 bool HasLEB128; // Defaults to false.
564 /// hasDotLocAndDotFile - True if target asm supports .loc and .file
565 /// directives for emitting debugging information.
567 bool HasDotLocAndDotFile; // Defaults to false.
569 /// SupportsDebugInformation - True if target supports emission of debugging
571 bool SupportsDebugInformation;
573 /// SupportsExceptionHandling - True if target supports
574 /// exception handling.
576 bool SupportsExceptionHandling; // Defaults to false.
578 /// RequiresFrameSection - true if the Dwarf2 output needs a frame section
580 bool DwarfRequiresFrameSection; // Defaults to true.
582 /// DwarfUsesInlineInfoSection - True if DwarfDebugInlineSection is used to
583 /// encode inline subroutine information.
584 bool DwarfUsesInlineInfoSection; // Defaults to false.
586 /// Is_EHSymbolPrivate - If set, the "_foo.eh" is made private so that it
587 /// doesn't show up in the symbol table of the object file.
588 bool Is_EHSymbolPrivate; // Defaults to true.
590 /// GlobalEHDirective - This is the directive used to make exception frame
591 /// tables globally visible.
593 const char *GlobalEHDirective; // Defaults to NULL.
595 /// SupportsWeakEmptyEHFrame - True if target assembler and linker will
596 /// handle a weak_definition of constant 0 for an omitted EH frame.
597 bool SupportsWeakOmittedEHFrame; // Defaults to true.
599 /// DwarfSectionOffsetDirective - Special section offset directive.
600 const char* DwarfSectionOffsetDirective; // Defaults to NULL
602 /// DwarfAbbrevSection - Section directive for Dwarf abbrev.
604 const char *DwarfAbbrevSection; // Defaults to ".debug_abbrev".
606 /// DwarfInfoSection - Section directive for Dwarf info.
608 const char *DwarfInfoSection; // Defaults to ".debug_info".
610 /// DwarfLineSection - Section directive for Dwarf info.
612 const char *DwarfLineSection; // Defaults to ".debug_line".
614 /// DwarfFrameSection - Section directive for Dwarf info.
616 const char *DwarfFrameSection; // Defaults to ".debug_frame".
618 /// DwarfPubNamesSection - Section directive for Dwarf info.
620 const char *DwarfPubNamesSection; // Defaults to ".debug_pubnames".
622 /// DwarfPubTypesSection - Section directive for Dwarf info.
624 const char *DwarfPubTypesSection; // Defaults to ".debug_pubtypes".
626 /// DwarfDebugInlineSection - Section directive for inline info.
628 const char *DwarfDebugInlineSection; // Defaults to ".debug_inlined"
630 /// DwarfStrSection - Section directive for Dwarf info.
632 const char *DwarfStrSection; // Defaults to ".debug_str".
634 /// DwarfLocSection - Section directive for Dwarf info.
636 const char *DwarfLocSection; // Defaults to ".debug_loc".
638 /// DwarfARangesSection - Section directive for Dwarf info.
640 const char *DwarfARangesSection; // Defaults to ".debug_aranges".
642 /// DwarfRangesSection - Section directive for Dwarf info.
644 const char *DwarfRangesSection; // Defaults to ".debug_ranges".
646 /// DwarfMacroInfoSection - Section directive for DWARF macro info.
648 const char *DwarfMacroInfoSection; // Defaults to ".debug_macinfo".
650 /// DwarfEHFrameSection - Section directive for Exception frames.
652 const char *DwarfEHFrameSection; // Defaults to ".eh_frame".
654 /// DwarfExceptionSection - Section directive for Exception table.
656 const char *DwarfExceptionSection; // Defaults to ".gcc_except_table".
658 //===--- CBE Asm Translation Table -----------------------------------===//
660 const char *const *AsmTransCBE; // Defaults to empty
663 explicit TargetAsmInfo(const TargetMachine &TM);
664 virtual ~TargetAsmInfo();
666 const Section* getNamedSection(const char *Name,
667 unsigned Flags = SectionFlags::None,
668 bool Override = false) const;
669 const Section* getUnnamedSection(const char *Directive,
670 unsigned Flags = SectionFlags::None,
671 bool Override = false) const;
673 /// Measure the specified inline asm to determine an approximation of its
675 virtual unsigned getInlineAsmLength(const char *Str) const;
677 /// emitUsedDirectiveFor - This hook allows targets to selectively decide
678 /// not to emit the UsedDirective for some symbols in llvm.used.
679 // FIXME: REMOVE this (rdar://7071300)
680 virtual bool emitUsedDirectiveFor(const GlobalValue *GV,
681 Mangler *Mang) const {
685 /// PreferredEHDataFormat - This hook allows the target to select data
686 /// format used for encoding pointers in exception handling data. Reason is
687 /// 0 for data, 1 for code labels, 2 for function pointers. Global is true
688 /// if the symbol can be relocated.
689 virtual unsigned PreferredEHDataFormat(DwarfEncoding::Target Reason,
693 /// getSectionForMergableConstant - Given a mergable constant with the
694 /// specified size and relocation information, return a section that it
695 /// should be placed in.
696 virtual const Section *getSectionForMergableConstant(SectionKind Kind)const;
699 /// getSectionPrefixForUniqueGlobal - Return a string that we should prepend
700 /// onto a global's name in order to get the unique section name for the
701 /// global. This is important for globals that need to be merged across
702 /// translation units.
704 getSectionPrefixForUniqueGlobal(SectionKind Kind) const {
708 /// getFlagsForNamedSection - If this target wants to be able to infer
709 /// section flags based on the name of the section specified for a global
710 /// variable, it can implement this. This is used on ELF systems so that
711 /// ".tbss" gets the TLS bit set etc.
712 virtual unsigned getFlagsForNamedSection(const char *Section) const {
716 /// SectionForGlobal - This method computes the appropriate section to emit
717 /// the specified global variable or function definition. This should not
718 /// be passed external (or available externally) globals.
719 // FIXME: MOVE TO ASMPRINTER.
720 const Section* SectionForGlobal(const GlobalValue *GV) const;
722 /// getSpecialCasedSectionGlobals - Allow the target to completely override
723 /// section assignment of a global.
724 /// FIXME: ELIMINATE this by making PIC16 implement ADDRESS with
725 /// getFlagsForNamedSection.
726 virtual const Section *
727 getSpecialCasedSectionGlobals(const GlobalValue *GV,
728 SectionKind Kind) const {
732 const std::string &getSectionFlags(unsigned Flags) const;
733 virtual std::string printSectionFlags(unsigned flags) const { return ""; }
735 // FIXME: Eliminate this.
736 virtual const Section* SelectSectionForGlobal(const GlobalValue *GV,
737 SectionKind Kind) const;
739 /// getSLEB128Size - Compute the number of bytes required for a signed
741 static unsigned getSLEB128Size(int Value);
743 /// getULEB128Size - Compute the number of bytes required for an unsigned
745 static unsigned getULEB128Size(unsigned Value);
747 // Data directive accessors.
749 const char *getData8bitsDirective(unsigned AS = 0) const {
750 return AS == 0 ? Data8bitsDirective : getDataASDirective(8, AS);
752 const char *getData16bitsDirective(unsigned AS = 0) const {
753 return AS == 0 ? Data16bitsDirective : getDataASDirective(16, AS);
755 const char *getData32bitsDirective(unsigned AS = 0) const {
756 return AS == 0 ? Data32bitsDirective : getDataASDirective(32, AS);
758 const char *getData64bitsDirective(unsigned AS = 0) const {
759 return AS == 0 ? Data64bitsDirective : getDataASDirective(64, AS);
765 const Section *getTextSection() const {
768 const Section *getDataSection() const {
771 const char *getBSSSection() const {
774 const Section *getBSSSection_() const {
777 const Section *getReadOnlySection() const {
778 return ReadOnlySection;
780 const Section *getTLSDataSection() const {
781 return TLSDataSection;
783 const Section *getTLSBSSSection() const {
784 return TLSBSSSection;
786 const char *getZeroFillDirective() const {
787 return ZeroFillDirective;
789 const char *getNonexecutableStackDirective() const {
790 return NonexecutableStackDirective;
792 bool needsSet() const {
795 const char *getPCSymbol() const {
798 char getSeparatorChar() const {
799 return SeparatorChar;
801 unsigned getCommentColumn() const {
802 return CommentColumn;
804 const char *getCommentString() const {
805 return CommentString;
807 unsigned getOperandColumn(int operand) const {
808 return FirstOperandColumn + (MaxOperandLength+1)*(operand-1);
810 const char *getGlobalPrefix() const {
813 const char *getPrivateGlobalPrefix() const {
814 return PrivateGlobalPrefix;
816 const char *getLinkerPrivateGlobalPrefix() const {
817 return LinkerPrivateGlobalPrefix;
819 const char *getJumpTableSpecialLabelPrefix() const {
820 return JumpTableSpecialLabelPrefix;
822 const char *getGlobalVarAddrPrefix() const {
823 return GlobalVarAddrPrefix;
825 const char *getGlobalVarAddrSuffix() const {
826 return GlobalVarAddrSuffix;
828 const char *getFunctionAddrPrefix() const {
829 return FunctionAddrPrefix;
831 const char *getFunctionAddrSuffix() const {
832 return FunctionAddrSuffix;
834 const char *getPersonalityPrefix() const {
835 return PersonalityPrefix;
837 const char *getPersonalitySuffix() const {
838 return PersonalitySuffix;
840 bool getNeedsIndirectEncoding() const {
841 return NeedsIndirectEncoding;
843 const char *getInlineAsmStart() const {
844 return InlineAsmStart;
846 const char *getInlineAsmEnd() const {
849 unsigned getAssemblerDialect() const {
850 return AssemblerDialect;
852 bool doesAllowQuotesInName() const {
853 return AllowQuotesInName;
855 const char *getZeroDirective() const {
856 return ZeroDirective;
858 const char *getZeroDirectiveSuffix() const {
859 return ZeroDirectiveSuffix;
861 const char *getAsciiDirective() const {
862 return AsciiDirective;
864 const char *getAscizDirective() const {
865 return AscizDirective;
867 const char *getJumpTableDirective() const {
868 return JumpTableDirective;
870 const char *getAlignDirective() const {
871 return AlignDirective;
873 bool getAlignmentIsInBytes() const {
874 return AlignmentIsInBytes;
876 unsigned getTextAlignFillValue() const {
877 return TextAlignFillValue;
879 const char *getSwitchToSectionDirective() const {
880 return SwitchToSectionDirective;
882 const char *getTextSectionStartSuffix() const {
883 return TextSectionStartSuffix;
885 const char *getDataSectionStartSuffix() const {
886 return DataSectionStartSuffix;
888 const char *getSectionEndDirectiveSuffix() const {
889 return SectionEndDirectiveSuffix;
891 const char *getConstantPoolSection() const {
892 return ConstantPoolSection;
894 const char *getJumpTableDataSection() const {
895 return JumpTableDataSection;
897 const char *getCStringSection() const {
898 return CStringSection;
900 const Section *getCStringSection_() const {
901 return CStringSection_;
903 const char *getStaticCtorsSection() const {
904 return StaticCtorsSection;
906 const char *getStaticDtorsSection() const {
907 return StaticDtorsSection;
909 const char *getGlobalDirective() const {
910 return GlobalDirective;
912 const char *getExternDirective() const {
913 return ExternDirective;
915 const char *getSetDirective() const {
918 const char *getLCOMMDirective() const {
919 return LCOMMDirective;
921 const char *getCOMMDirective() const {
922 return COMMDirective;
924 bool getCOMMDirectiveTakesAlignment() const {
925 return COMMDirectiveTakesAlignment;
927 bool hasDotTypeDotSizeDirective() const {
928 return HasDotTypeDotSizeDirective;
930 bool hasSingleParameterDotFile() const {
931 return HasSingleParameterDotFile;
933 const char *getUsedDirective() const {
934 return UsedDirective;
936 const char *getWeakRefDirective() const {
937 return WeakRefDirective;
939 const char *getWeakDefDirective() const {
940 return WeakDefDirective;
942 const char *getHiddenDirective() const {
943 return HiddenDirective;
945 const char *getProtectedDirective() const {
946 return ProtectedDirective;
948 bool isAbsoluteDebugSectionOffsets() const {
949 return AbsoluteDebugSectionOffsets;
951 bool isAbsoluteEHSectionOffsets() const {
952 return AbsoluteEHSectionOffsets;
954 bool hasLEB128() const {
957 bool hasDotLocAndDotFile() const {
958 return HasDotLocAndDotFile;
960 bool doesSupportDebugInformation() const {
961 return SupportsDebugInformation;
963 bool doesSupportExceptionHandling() const {
964 return SupportsExceptionHandling;
966 bool doesDwarfRequireFrameSection() const {
967 return DwarfRequiresFrameSection;
969 bool doesDwarfUsesInlineInfoSection() const {
970 return DwarfUsesInlineInfoSection;
972 bool is_EHSymbolPrivate() const {
973 return Is_EHSymbolPrivate;
975 const char *getGlobalEHDirective() const {
976 return GlobalEHDirective;
978 bool getSupportsWeakOmittedEHFrame() const {
979 return SupportsWeakOmittedEHFrame;
981 const char *getDwarfSectionOffsetDirective() const {
982 return DwarfSectionOffsetDirective;
984 const char *getDwarfAbbrevSection() const {
985 return DwarfAbbrevSection;
987 const char *getDwarfInfoSection() const {
988 return DwarfInfoSection;
990 const char *getDwarfLineSection() const {
991 return DwarfLineSection;
993 const char *getDwarfFrameSection() const {
994 return DwarfFrameSection;
996 const char *getDwarfPubNamesSection() const {
997 return DwarfPubNamesSection;
999 const char *getDwarfPubTypesSection() const {
1000 return DwarfPubTypesSection;
1002 const char *getDwarfDebugInlineSection() const {
1003 return DwarfDebugInlineSection;
1005 const char *getDwarfStrSection() const {
1006 return DwarfStrSection;
1008 const char *getDwarfLocSection() const {
1009 return DwarfLocSection;
1011 const char *getDwarfARangesSection() const {
1012 return DwarfARangesSection;
1014 const char *getDwarfRangesSection() const {
1015 return DwarfRangesSection;
1017 const char *getDwarfMacroInfoSection() const {
1018 return DwarfMacroInfoSection;
1020 const char *getDwarfEHFrameSection() const {
1021 return DwarfEHFrameSection;
1023 const char *getDwarfExceptionSection() const {
1024 return DwarfExceptionSection;
1026 const char *const *getAsmCBE() const {