Sink getSectionPrefixForUniqueGlobal down into the TAI
[oota-llvm.git] / include / llvm / Target / TargetAsmInfo.h
1 //===-- llvm/Target/TargetAsmInfo.h - Asm info ------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
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.
13 //
14 //===----------------------------------------------------------------------===//
15
16 #ifndef LLVM_TARGET_ASM_INFO_H
17 #define LLVM_TARGET_ASM_INFO_H
18
19 #include "llvm/ADT/StringMap.h"
20 #include "llvm/Support/DataTypes.h"
21 #include <string>
22
23 namespace llvm {
24   template <typename T> class SmallVectorImpl;
25   class TargetMachine;
26   class GlobalValue;
27   class Mangler;
28   
29   // DWARF encoding query type
30   namespace DwarfEncoding {
31     enum Target {
32       Data       = 0,
33       CodeLabels = 1,
34       Functions  = 2
35     };
36   }
37
38   /// SectionKind - This is a simple POD value that classifies the properties of
39   /// a section.  A global variable is classified into the deepest possible
40   /// classification, and then the target maps them onto their sections based on
41   /// what capabilities they have.
42   ///
43   /// The comments below describe these as if they were an inheritance hierarchy
44   /// in order to explain the predicates below.
45   class SectionKind {
46   public:
47     enum Kind {
48       /// Metadata - Debug info sections or other metadata.
49       Metadata,
50       
51       /// Text - Text section, used for functions and other executable code.
52       Text,
53       
54       /// ReadOnly - Data that is never written to at program runtime by the
55       /// program or the dynamic linker.  Things in the top-level readonly
56       /// SectionKind are not mergeable.
57       ReadOnly,
58
59           /// MergeableCString - This is a special section for nul-terminated
60           /// strings.  The linker can unique the C strings, knowing their
61           /// semantics.  Because it uniques based on the nul terminators, the
62           /// compiler can't put strings in this section that have embeded nuls
63           /// in them.
64           MergeableCString,
65       
66           /// MergeableConst - These are sections for merging fixed-length
67           /// constants together.  For example, this can be used to unique
68           /// constant pool entries etc.
69           MergeableConst,
70       
71               /// MergeableConst4 - This is a section used by 4-byte constants,
72               /// for example, floats.
73               MergeableConst4,
74       
75               /// MergeableConst8 - This is a section used by 8-byte constants,
76               /// for example, doubles.
77               MergeableConst8,
78
79               /// MergeableConst16 - This is a section used by 16-byte constants,
80               /// for example, vectors.
81               MergeableConst16,
82       
83       /// Writeable - This is the base of all segments that need to be written
84       /// to during program runtime.
85       
86          /// ThreadLocal - This is the base of all TLS segments.  All TLS
87          /// objects must be writeable, otherwise there is no reason for them to
88          /// be thread local!
89       
90              /// ThreadBSS - Zero-initialized TLS data objects.
91              ThreadBSS,
92       
93              /// ThreadData - Initialized TLS data objects.
94              ThreadData,
95       
96          /// GlobalWriteableData - Writeable data that is global (not thread
97          /// local).
98       
99              /// BSS - Zero initialized writeable data.
100              BSS,
101
102              /// DataRel - This is the most general form of data that is written
103              /// to by the program, it can have random relocations to arbitrary
104              /// globals.
105              DataRel,
106
107                  /// DataRelLocal - This is writeable data that has a non-zero
108                  /// initializer and has relocations in it, but all of the
109                  /// relocations are known to be within the final linked image
110                  /// the global is linked into.
111                  DataRelLocal,
112
113                      /// DataNoRel - This is writeable data that has a non-zero
114                      /// initializer, but whose initializer is known to have no
115                      /// relocations.
116                      DataNoRel,
117
118              /// ReadOnlyWithRel - These are global variables that are never
119              /// written to by the program, but that have relocations, so they
120              /// must be stuck in a writeable section so that the dynamic linker
121              /// can write to them.  If it chooses to, the dynamic linker can
122              /// mark the pages these globals end up on as read-only after it is
123              /// done with its relocation phase.
124              ReadOnlyWithRel,
125       
126                  /// ReadOnlyWithRelLocal - This is data that is readonly by the
127                  /// program, but must be writeable so that the dynamic linker
128                  /// can perform relocations in it.  This is used when we know
129                  /// that all the relocations are to globals in this final
130                  /// linked image.
131                  ReadOnlyWithRelLocal
132       
133     };
134     
135   private:
136     Kind K : 6;
137     
138     /// Weak - This is true if the referenced symbol is weak (i.e. linkonce,
139     /// weak, weak_odr, etc).  This is orthogonal from the categorization.
140     bool Weak : 1;
141     
142     /// ExplicitSection - This is true if the global had a section explicitly
143     /// specified on it.
144     bool ExplicitSection : 1;
145   public:
146     
147     // FIXME: REMOVE.
148     Kind getKind() const { return K; }
149     
150     bool isWeak() const { return Weak; }
151     bool hasExplicitSection() const { return ExplicitSection; }
152     
153     
154     bool isMetadata() const { return K == Metadata; }
155     bool isText() const { return K == Text; }
156     
157     bool isReadOnly() const {
158       return K == ReadOnly || K == MergeableCString || isMergeableConst();
159     }
160
161     bool isMergeableCString() const { return K == MergeableCString; }
162     bool isMergeableConst() const {
163       return K == MergeableConst || K == MergeableConst4 ||
164              K == MergeableConst8 || K == MergeableConst16;
165     }
166     
167     bool isMergeableConst4() const { return K == MergeableConst4; }
168     bool isMergeableConst8() const { return K == MergeableConst8; }
169     bool isMergeableConst16() const { return K == MergeableConst16; }
170     
171     bool isWriteable() const {
172       return isThreadLocal() || isGlobalWriteableData();
173     }
174     
175     bool isThreadLocal() const {
176       return K == ThreadData || K == ThreadBSS;
177     }
178     
179     bool isThreadBSS() const { return K == ThreadBSS; } 
180     bool isThreadData() const { return K == ThreadData; } 
181
182     bool isGlobalWriteableData() const {
183       return isBSS() || isDataRel() || isReadOnlyWithRel();
184     }
185     
186     bool isBSS() const { return K == BSS; }
187     
188     bool isDataRel() const {
189       return K == DataRel || K == DataRelLocal || K == DataNoRel;
190     }
191     
192     bool isDataRelLocal() const {
193       return K == DataRelLocal || K == DataNoRel;
194     }
195
196     bool isDataNoRel() const { return K == DataNoRel; }
197     
198     bool isReadOnlyWithRel() const {
199       return K == ReadOnlyWithRel || K == ReadOnlyWithRelLocal;
200     }
201
202     bool isReadOnlyWithRelLocal() const {
203       return K == ReadOnlyWithRelLocal;
204     }
205     
206     static SectionKind get(Kind K, bool isWeak = false,
207                            bool hasExplicitSection = false) {
208       SectionKind Res;
209       Res.K = K;
210       Res.Weak = isWeak;
211       Res.ExplicitSection = hasExplicitSection;
212       return Res;
213     }
214   };
215
216   class Section {
217     friend class TargetAsmInfo;
218     friend class StringMapEntry<Section>;
219     friend class StringMap<Section>;
220
221     std::string Name;
222     SectionKind Kind;
223     explicit Section() { }
224
225   public:
226     const std::string &getName() const { return Name; }
227     SectionKind getKind() const { return Kind; }
228   };
229
230   /// TargetAsmInfo - This class is intended to be used as a base class for asm
231   /// properties and features specific to the target.
232   class TargetAsmInfo {
233   private:
234     mutable StringMap<Section> Sections;
235   protected:
236     /// TM - The current TargetMachine.
237     const TargetMachine &TM;
238
239     //===------------------------------------------------------------------===//
240     // Properties to be set by the target writer, used to configure asm printer.
241     //
242
243     /// TextSection - Section directive for standard text.
244     ///
245     const Section *TextSection;           // Defaults to ".text".
246
247     /// DataSection - Section directive for standard data.
248     ///
249     const Section *DataSection;           // Defaults to ".data".
250
251     /// BSSSection - Section directive for uninitialized data.  Null if this
252     /// target doesn't support a BSS section.
253     ///
254     const char *BSSSection;               // Default to ".bss".
255     const Section *BSSSection_;
256
257     /// ReadOnlySection - This is the directive that is emitted to switch to a
258     /// read-only section for constant data (e.g. data declared const,
259     /// jump tables).
260     const Section *ReadOnlySection;       // Defaults to NULL
261
262     /// TLSDataSection - Section directive for Thread Local data.
263     ///
264     const Section *TLSDataSection;        // Defaults to ".tdata".
265
266     /// TLSBSSSection - Section directive for Thread Local uninitialized data.
267     /// Null if this target doesn't support a BSS section.
268     ///
269     const Section *TLSBSSSection;         // Defaults to ".tbss".
270
271     /// ZeroFillDirective - Directive for emitting a global to the ZeroFill
272     /// section on this target.  Null if this target doesn't support zerofill.
273     const char *ZeroFillDirective;        // Default is null.
274
275     /// NonexecutableStackDirective - Directive for declaring to the
276     /// linker and beyond that the emitted code does not require stack
277     /// memory to be executable.
278     const char *NonexecutableStackDirective; // Default is null.
279
280     /// NeedsSet - True if target asm treats expressions in data directives
281     /// as linktime-relocatable.  For assembly-time computation, we need to
282     /// use a .set.  Thus:
283     /// .set w, x-y
284     /// .long w
285     /// is computed at assembly time, while
286     /// .long x-y
287     /// is relocated if the relative locations of x and y change at linktime.
288     /// We want both these things in different places.
289     bool NeedsSet;                        // Defaults to false.
290     
291     /// MaxInstLength - This is the maximum possible length of an instruction,
292     /// which is needed to compute the size of an inline asm.
293     unsigned MaxInstLength;               // Defaults to 4.
294     
295     /// PCSymbol - The symbol used to represent the current PC.  Used in PC
296     /// relative expressions.
297     const char *PCSymbol;                 // Defaults to "$".
298
299     /// SeparatorChar - This character, if specified, is used to separate
300     /// instructions from each other when on the same line.  This is used to
301     /// measure inline asm instructions.
302     char SeparatorChar;                   // Defaults to ';'
303
304     /// CommentColumn - This indicates the comment num (zero-based) at
305     /// which asm comments should be printed.
306     unsigned CommentColumn;               // Defaults to 60
307
308     /// CommentString - This indicates the comment character used by the
309     /// assembler.
310     const char *CommentString;            // Defaults to "#"
311
312     /// FirstOperandColumn - The output column where the first operand
313     /// should be printed
314     unsigned FirstOperandColumn;          // Defaults to 0 (ignored)
315
316     /// MaxOperandLength - The maximum length of any printed asm
317     /// operand
318     unsigned MaxOperandLength;            // Defaults to 0 (ignored)
319
320     /// GlobalPrefix - If this is set to a non-empty string, it is prepended
321     /// onto all global symbols.  This is often used for "_" or ".".
322     const char *GlobalPrefix;             // Defaults to ""
323
324     /// PrivateGlobalPrefix - This prefix is used for globals like constant
325     /// pool entries that are completely private to the .s file and should not
326     /// have names in the .o file.  This is often "." or "L".
327     const char *PrivateGlobalPrefix;      // Defaults to "."
328     
329     /// LinkerPrivateGlobalPrefix - This prefix is used for symbols that should
330     /// be passed through the assembler but be removed by the linker.  This
331     /// is "l" on Darwin, currently used for some ObjC metadata.
332     const char *LinkerPrivateGlobalPrefix;      // Defaults to ""
333     
334     /// JumpTableSpecialLabelPrefix - If not null, a extra (dead) label is
335     /// emitted before jump tables with the specified prefix.
336     const char *JumpTableSpecialLabelPrefix;  // Default to null.
337     
338     /// GlobalVarAddrPrefix/Suffix - If these are nonempty, these strings
339     /// will enclose any GlobalVariable (that isn't a function)
340     ///
341     const char *GlobalVarAddrPrefix;      // Defaults to ""
342     const char *GlobalVarAddrSuffix;      // Defaults to ""
343
344     /// FunctionAddrPrefix/Suffix - If these are nonempty, these strings
345     /// will enclose any GlobalVariable that points to a function.
346     ///
347     const char *FunctionAddrPrefix;       // Defaults to ""
348     const char *FunctionAddrSuffix;       // Defaults to ""
349
350     /// PersonalityPrefix/Suffix - If these are nonempty, these strings will
351     /// enclose any personality function in the common frame section.
352     /// 
353     const char *PersonalityPrefix;        // Defaults to ""
354     const char *PersonalitySuffix;        // Defaults to ""
355
356     /// NeedsIndirectEncoding - If set, we need to set the indirect encoding bit
357     /// for EH in Dwarf.
358     /// 
359     bool NeedsIndirectEncoding;           // Defaults to false
360
361     /// InlineAsmStart/End - If these are nonempty, they contain a directive to
362     /// emit before and after an inline assembly statement.
363     const char *InlineAsmStart;           // Defaults to "#APP\n"
364     const char *InlineAsmEnd;             // Defaults to "#NO_APP\n"
365
366     /// AssemblerDialect - Which dialect of an assembler variant to use.
367     unsigned AssemblerDialect;            // Defaults to 0
368
369     /// AllowQuotesInName - This is true if the assembler allows for complex
370     /// symbol names to be surrounded in quotes.  This defaults to false.
371     bool AllowQuotesInName;
372     
373     //===--- Data Emission Directives -------------------------------------===//
374
375     /// ZeroDirective - this should be set to the directive used to get some
376     /// number of zero bytes emitted to the current section.  Common cases are
377     /// "\t.zero\t" and "\t.space\t".  If this is set to null, the
378     /// Data*bitsDirective's will be used to emit zero bytes.
379     const char *ZeroDirective;            // Defaults to "\t.zero\t"
380     const char *ZeroDirectiveSuffix;      // Defaults to ""
381
382     /// AsciiDirective - This directive allows emission of an ascii string with
383     /// the standard C escape characters embedded into it.
384     const char *AsciiDirective;           // Defaults to "\t.ascii\t"
385     
386     /// AscizDirective - If not null, this allows for special handling of
387     /// zero terminated strings on this target.  This is commonly supported as
388     /// ".asciz".  If a target doesn't support this, it can be set to null.
389     const char *AscizDirective;           // Defaults to "\t.asciz\t"
390
391     /// DataDirectives - These directives are used to output some unit of
392     /// integer data to the current section.  If a data directive is set to
393     /// null, smaller data directives will be used to emit the large sizes.
394     const char *Data8bitsDirective;       // Defaults to "\t.byte\t"
395     const char *Data16bitsDirective;      // Defaults to "\t.short\t"
396     const char *Data32bitsDirective;      // Defaults to "\t.long\t"
397     const char *Data64bitsDirective;      // Defaults to "\t.quad\t"
398
399     /// getDataASDirective - Return the directive that should be used to emit
400     /// data of the specified size to the specified numeric address space.
401     virtual const char *getDataASDirective(unsigned Size, unsigned AS) const {
402       assert(AS != 0 && "Don't know the directives for default addr space");
403       return NULL;
404     }
405
406     //===--- Alignment Information ----------------------------------------===//
407
408     /// AlignDirective - The directive used to emit round up to an alignment
409     /// boundary.
410     ///
411     const char *AlignDirective;           // Defaults to "\t.align\t"
412
413     /// AlignmentIsInBytes - If this is true (the default) then the asmprinter
414     /// emits ".align N" directives, where N is the number of bytes to align to.
415     /// Otherwise, it emits ".align log2(N)", e.g. 3 to align to an 8 byte
416     /// boundary.
417     bool AlignmentIsInBytes;              // Defaults to true
418
419     /// TextAlignFillValue - If non-zero, this is used to fill the executable
420     /// space created as the result of a alignment directive.
421     unsigned TextAlignFillValue;
422
423     //===--- Section Switching Directives ---------------------------------===//
424     
425     /// SwitchToSectionDirective - This is the directive used when we want to
426     /// emit a global to an arbitrary section.  The section name is emited after
427     /// this.
428     const char *SwitchToSectionDirective; // Defaults to "\t.section\t"
429     
430     /// TextSectionStartSuffix - This is printed after each start of section
431     /// directive for text sections.
432     const char *TextSectionStartSuffix;   // Defaults to "".
433
434     /// DataSectionStartSuffix - This is printed after each start of section
435     /// directive for data sections.
436     const char *DataSectionStartSuffix;   // Defaults to "".
437     
438     /// SectionEndDirectiveSuffix - If non-null, the asm printer will close each
439     /// section with the section name and this suffix printed.
440     const char *SectionEndDirectiveSuffix;// Defaults to null.
441     
442     /// ConstantPoolSection - This is the section that we SwitchToSection right
443     /// before emitting the constant pool for a function.
444     const char *ConstantPoolSection;      // Defaults to "\t.section .rodata"
445
446     /// JumpTableDataSection - This is the section that we SwitchToSection right
447     /// before emitting the jump tables for a function when the relocation model
448     /// is not PIC.
449     const char *JumpTableDataSection;     // Defaults to "\t.section .rodata"
450     
451     /// JumpTableDirective - if non-null, the directive to emit before a jump
452     /// table.
453     const char *JumpTableDirective;
454
455     /// CStringSection - If not null, this allows for special handling of
456     /// cstring constants (null terminated string that does not contain any
457     /// other null bytes) on this target. This is commonly supported as
458     /// ".cstring".
459     const char *CStringSection;           // Defaults to NULL
460     const Section *CStringSection_;
461
462     /// StaticCtorsSection - This is the directive that is emitted to switch to
463     /// a section to emit the static constructor list.
464     /// Defaults to "\t.section .ctors,\"aw\",@progbits".
465     const char *StaticCtorsSection;
466
467     /// StaticDtorsSection - This is the directive that is emitted to switch to
468     /// a section to emit the static destructor list.
469     /// Defaults to "\t.section .dtors,\"aw\",@progbits".
470     const char *StaticDtorsSection;
471
472     //===--- Global Variable Emission Directives --------------------------===//
473     
474     /// GlobalDirective - This is the directive used to declare a global entity.
475     ///
476     const char *GlobalDirective;          // Defaults to NULL.
477
478     /// ExternDirective - This is the directive used to declare external 
479     /// globals.
480     ///
481     const char *ExternDirective;          // Defaults to NULL.
482     
483     /// SetDirective - This is the name of a directive that can be used to tell
484     /// the assembler to set the value of a variable to some expression.
485     const char *SetDirective;             // Defaults to null.
486     
487     /// LCOMMDirective - This is the name of a directive (if supported) that can
488     /// be used to efficiently declare a local (internal) block of zero
489     /// initialized data in the .bss/.data section.  The syntax expected is:
490     /// @verbatim <LCOMMDirective> SYMBOLNAME LENGTHINBYTES, ALIGNMENT
491     /// @endverbatim
492     const char *LCOMMDirective;           // Defaults to null.
493     
494     const char *COMMDirective;            // Defaults to "\t.comm\t".
495
496     /// COMMDirectiveTakesAlignment - True if COMMDirective take a third
497     /// argument that specifies the alignment of the declaration.
498     bool COMMDirectiveTakesAlignment;     // Defaults to true.
499     
500     /// HasDotTypeDotSizeDirective - True if the target has .type and .size
501     /// directives, this is true for most ELF targets.
502     bool HasDotTypeDotSizeDirective;      // Defaults to true.
503
504     /// HasSingleParameterDotFile - True if the target has a single parameter
505     /// .file directive, this is true for ELF targets.
506     bool HasSingleParameterDotFile;      // Defaults to true.
507
508     /// UsedDirective - This directive, if non-null, is used to declare a global
509     /// as being used somehow that the assembler can't see.  This prevents dead
510     /// code elimination on some targets.
511     const char *UsedDirective;            // Defaults to null.
512
513     /// WeakRefDirective - This directive, if non-null, is used to declare a
514     /// global as being a weak undefined symbol.
515     const char *WeakRefDirective;         // Defaults to null.
516     
517     /// WeakDefDirective - This directive, if non-null, is used to declare a
518     /// global as being a weak defined symbol.
519     const char *WeakDefDirective;         // Defaults to null.
520     
521     /// HiddenDirective - This directive, if non-null, is used to declare a
522     /// global or function as having hidden visibility.
523     const char *HiddenDirective;          // Defaults to "\t.hidden\t".
524
525     /// ProtectedDirective - This directive, if non-null, is used to declare a
526     /// global or function as having protected visibility.
527     const char *ProtectedDirective;       // Defaults to "\t.protected\t".
528
529     //===--- Dwarf Emission Directives -----------------------------------===//
530
531     /// AbsoluteDebugSectionOffsets - True if we should emit abolute section
532     /// offsets for debug information. Defaults to false.
533     bool AbsoluteDebugSectionOffsets;
534
535     /// AbsoluteEHSectionOffsets - True if we should emit abolute section
536     /// offsets for EH information. Defaults to false.
537     bool AbsoluteEHSectionOffsets;
538
539     /// HasLEB128 - True if target asm supports leb128 directives.
540     ///
541     bool HasLEB128; // Defaults to false.
542
543     /// hasDotLocAndDotFile - True if target asm supports .loc and .file
544     /// directives for emitting debugging information.
545     ///
546     bool HasDotLocAndDotFile; // Defaults to false.
547
548     /// SupportsDebugInformation - True if target supports emission of debugging
549     /// information.
550     bool SupportsDebugInformation;
551
552     /// SupportsExceptionHandling - True if target supports
553     /// exception handling.
554     ///
555     bool SupportsExceptionHandling; // Defaults to false.
556
557     /// RequiresFrameSection - true if the Dwarf2 output needs a frame section
558     ///
559     bool DwarfRequiresFrameSection; // Defaults to true.
560
561     /// DwarfUsesInlineInfoSection - True if DwarfDebugInlineSection is used to
562     /// encode inline subroutine information.
563     bool DwarfUsesInlineInfoSection; // Defaults to false.
564
565     /// Is_EHSymbolPrivate - If set, the "_foo.eh" is made private so that it
566     /// doesn't show up in the symbol table of the object file.
567     bool Is_EHSymbolPrivate;                // Defaults to true.
568
569     /// GlobalEHDirective - This is the directive used to make exception frame
570     /// tables globally visible.
571     ///
572     const char *GlobalEHDirective;          // Defaults to NULL.
573
574     /// SupportsWeakEmptyEHFrame - True if target assembler and linker will
575     /// handle a weak_definition of constant 0 for an omitted EH frame.
576     bool SupportsWeakOmittedEHFrame;  // Defaults to true.
577
578     /// DwarfSectionOffsetDirective - Special section offset directive.
579     const char* DwarfSectionOffsetDirective; // Defaults to NULL
580     
581     /// DwarfAbbrevSection - Section directive for Dwarf abbrev.
582     ///
583     const char *DwarfAbbrevSection; // Defaults to ".debug_abbrev".
584
585     /// DwarfInfoSection - Section directive for Dwarf info.
586     ///
587     const char *DwarfInfoSection; // Defaults to ".debug_info".
588
589     /// DwarfLineSection - Section directive for Dwarf info.
590     ///
591     const char *DwarfLineSection; // Defaults to ".debug_line".
592     
593     /// DwarfFrameSection - Section directive for Dwarf info.
594     ///
595     const char *DwarfFrameSection; // Defaults to ".debug_frame".
596     
597     /// DwarfPubNamesSection - Section directive for Dwarf info.
598     ///
599     const char *DwarfPubNamesSection; // Defaults to ".debug_pubnames".
600     
601     /// DwarfPubTypesSection - Section directive for Dwarf info.
602     ///
603     const char *DwarfPubTypesSection; // Defaults to ".debug_pubtypes".
604
605     /// DwarfDebugInlineSection - Section directive for inline info.
606     ///
607     const char *DwarfDebugInlineSection; // Defaults to ".debug_inlined"
608
609     /// DwarfStrSection - Section directive for Dwarf info.
610     ///
611     const char *DwarfStrSection; // Defaults to ".debug_str".
612
613     /// DwarfLocSection - Section directive for Dwarf info.
614     ///
615     const char *DwarfLocSection; // Defaults to ".debug_loc".
616
617     /// DwarfARangesSection - Section directive for Dwarf info.
618     ///
619     const char *DwarfARangesSection; // Defaults to ".debug_aranges".
620
621     /// DwarfRangesSection - Section directive for Dwarf info.
622     ///
623     const char *DwarfRangesSection; // Defaults to ".debug_ranges".
624
625     /// DwarfMacroInfoSection - Section directive for DWARF macro info.
626     ///
627     const char *DwarfMacroInfoSection; // Defaults to ".debug_macinfo".
628     
629     /// DwarfEHFrameSection - Section directive for Exception frames.
630     ///
631     const char *DwarfEHFrameSection; // Defaults to ".eh_frame".
632     
633     /// DwarfExceptionSection - Section directive for Exception table.
634     ///
635     const char *DwarfExceptionSection; // Defaults to ".gcc_except_table".
636
637     //===--- CBE Asm Translation Table -----------------------------------===//
638
639     const char *const *AsmTransCBE; // Defaults to empty
640
641   public:
642     explicit TargetAsmInfo(const TargetMachine &TM);
643     virtual ~TargetAsmInfo();
644
645     const Section *getOrCreateSection(const char *Name,
646                                       bool isDirective,
647                                       SectionKind::Kind K) const;
648
649     /// Measure the specified inline asm to determine an approximation of its
650     /// length.
651     virtual unsigned getInlineAsmLength(const char *Str) const;
652
653     /// emitUsedDirectiveFor - This hook allows targets to selectively decide
654     /// not to emit the UsedDirective for some symbols in llvm.used.
655 // FIXME: REMOVE this (rdar://7071300)
656     virtual bool emitUsedDirectiveFor(const GlobalValue *GV,
657                                       Mangler *Mang) const {
658       return (GV!=0);
659     }
660
661     /// PreferredEHDataFormat - This hook allows the target to select data
662     /// format used for encoding pointers in exception handling data. Reason is
663     /// 0 for data, 1 for code labels, 2 for function pointers. Global is true
664     /// if the symbol can be relocated.
665     virtual unsigned PreferredEHDataFormat(DwarfEncoding::Target Reason,
666                                            bool Global) const;
667
668     
669     /// getSectionForMergeableConstant - Given a Mergeable constant with the
670     /// specified size and relocation information, return a section that it
671     /// should be placed in.
672     virtual const Section *getSectionForMergeableConstant(SectionKind Kind)const;
673
674     
675     /// getKindForNamedSection - If this target wants to be able to override
676     /// section flags based on the name of the section specified for a global
677     /// variable, it can implement this.  This is used on ELF systems so that
678     /// ".tbss" gets the TLS bit set etc.
679     virtual SectionKind::Kind getKindForNamedSection(const char *Section,
680                                                      SectionKind::Kind K) const{
681       return K;
682     }
683     
684     /// SectionForGlobal - This method computes the appropriate section to emit
685     /// the specified global variable or function definition.  This should not
686     /// be passed external (or available externally) globals.
687     // FIXME: MOVE TO ASMPRINTER.
688     const Section* SectionForGlobal(const GlobalValue *GV) const;
689     
690     /// getSpecialCasedSectionGlobals - Allow the target to completely override
691     /// section assignment of a global.
692     /// FIXME: ELIMINATE this by making PIC16 implement ADDRESS with
693     /// getFlagsForNamedSection.
694     virtual const Section *
695     getSpecialCasedSectionGlobals(const GlobalValue *GV,
696                                   SectionKind Kind) const {
697       return 0;
698     }
699     
700     /// getSectionFlagsAsString - Turn the flags in the specified SectionKind
701     /// into a string that can be printed to the assembly file after the
702     /// ".section foo" part of a section directive.
703     virtual void getSectionFlagsAsString(SectionKind Kind,
704                                          SmallVectorImpl<char> &Str) const {
705     }
706
707 // FIXME: Eliminate this.
708     virtual const Section* SelectSectionForGlobal(const GlobalValue *GV,
709                                                   SectionKind Kind) const;
710
711     /// getSLEB128Size - Compute the number of bytes required for a signed
712     /// leb128 value.
713     static unsigned getSLEB128Size(int Value);
714
715     /// getULEB128Size - Compute the number of bytes required for an unsigned
716     /// leb128 value.
717     static unsigned getULEB128Size(unsigned Value);
718
719     // Data directive accessors.
720     //
721     const char *getData8bitsDirective(unsigned AS = 0) const {
722       return AS == 0 ? Data8bitsDirective : getDataASDirective(8, AS);
723     }
724     const char *getData16bitsDirective(unsigned AS = 0) const {
725       return AS == 0 ? Data16bitsDirective : getDataASDirective(16, AS);
726     }
727     const char *getData32bitsDirective(unsigned AS = 0) const {
728       return AS == 0 ? Data32bitsDirective : getDataASDirective(32, AS);
729     }
730     const char *getData64bitsDirective(unsigned AS = 0) const {
731       return AS == 0 ? Data64bitsDirective : getDataASDirective(64, AS);
732     }
733
734
735     // Accessors.
736     //
737     const Section *getTextSection() const {
738       return TextSection;
739     }
740     const Section *getDataSection() const {
741       return DataSection;
742     }
743     const char *getBSSSection() const {
744       return BSSSection;
745     }
746     const Section *getBSSSection_() const {
747       return BSSSection_;
748     }
749     const Section *getReadOnlySection() const {
750       return ReadOnlySection;
751     }
752     const Section *getTLSDataSection() const {
753       return TLSDataSection;
754     }
755     const Section *getTLSBSSSection() const {
756       return TLSBSSSection;
757     }
758     const char *getZeroFillDirective() const {
759       return ZeroFillDirective;
760     }
761     const char *getNonexecutableStackDirective() const {
762       return NonexecutableStackDirective;
763     }
764     bool needsSet() const {
765       return NeedsSet;
766     }
767     const char *getPCSymbol() const {
768       return PCSymbol;
769     }
770     char getSeparatorChar() const {
771       return SeparatorChar;
772     }
773     unsigned getCommentColumn() const {
774       return CommentColumn;
775     }
776     const char *getCommentString() const {
777       return CommentString;
778     }
779     unsigned getOperandColumn(int operand) const {
780       return FirstOperandColumn + (MaxOperandLength+1)*(operand-1);
781     }
782     const char *getGlobalPrefix() const {
783       return GlobalPrefix;
784     }
785     const char *getPrivateGlobalPrefix() const {
786       return PrivateGlobalPrefix;
787     }
788     const char *getLinkerPrivateGlobalPrefix() const {
789       return LinkerPrivateGlobalPrefix;
790     }
791     const char *getJumpTableSpecialLabelPrefix() const {
792       return JumpTableSpecialLabelPrefix;
793     }
794     const char *getGlobalVarAddrPrefix() const {
795       return GlobalVarAddrPrefix;
796     }
797     const char *getGlobalVarAddrSuffix() const {
798       return GlobalVarAddrSuffix;
799     }
800     const char *getFunctionAddrPrefix() const {
801       return FunctionAddrPrefix;
802     }
803     const char *getFunctionAddrSuffix() const {
804       return FunctionAddrSuffix;
805     }
806     const char *getPersonalityPrefix() const {
807       return PersonalityPrefix;
808     }
809     const char *getPersonalitySuffix() const {
810       return PersonalitySuffix;
811     }
812     bool getNeedsIndirectEncoding() const {
813       return NeedsIndirectEncoding;
814     }
815     const char *getInlineAsmStart() const {
816       return InlineAsmStart;
817     }
818     const char *getInlineAsmEnd() const {
819       return InlineAsmEnd;
820     }
821     unsigned getAssemblerDialect() const {
822       return AssemblerDialect;
823     }
824     bool doesAllowQuotesInName() const {
825       return AllowQuotesInName;
826     }
827     const char *getZeroDirective() const {
828       return ZeroDirective;
829     }
830     const char *getZeroDirectiveSuffix() const {
831       return ZeroDirectiveSuffix;
832     }
833     const char *getAsciiDirective() const {
834       return AsciiDirective;
835     }
836     const char *getAscizDirective() const {
837       return AscizDirective;
838     }
839     const char *getJumpTableDirective() const {
840       return JumpTableDirective;
841     }
842     const char *getAlignDirective() const {
843       return AlignDirective;
844     }
845     bool getAlignmentIsInBytes() const {
846       return AlignmentIsInBytes;
847     }
848     unsigned getTextAlignFillValue() const {
849       return TextAlignFillValue;
850     }
851     const char *getSwitchToSectionDirective() const {
852       return SwitchToSectionDirective;
853     }
854     const char *getTextSectionStartSuffix() const {
855       return TextSectionStartSuffix;
856     }
857     const char *getDataSectionStartSuffix() const {
858       return DataSectionStartSuffix;
859     }
860     const char *getSectionEndDirectiveSuffix() const {
861       return SectionEndDirectiveSuffix;
862     }
863     const char *getConstantPoolSection() const {
864       return ConstantPoolSection;
865     }
866     const char *getJumpTableDataSection() const {
867       return JumpTableDataSection;
868     }
869     const char *getCStringSection() const {
870       return CStringSection;
871     }
872     const Section *getCStringSection_() const {
873       return CStringSection_;
874     }
875     const char *getStaticCtorsSection() const {
876       return StaticCtorsSection;
877     }
878     const char *getStaticDtorsSection() const {
879       return StaticDtorsSection;
880     }
881     const char *getGlobalDirective() const {
882       return GlobalDirective;
883     }
884     const char *getExternDirective() const {
885       return ExternDirective;
886     }
887     const char *getSetDirective() const {
888       return SetDirective;
889     }
890     const char *getLCOMMDirective() const {
891       return LCOMMDirective;
892     }
893     const char *getCOMMDirective() const {
894       return COMMDirective;
895     }
896     bool getCOMMDirectiveTakesAlignment() const {
897       return COMMDirectiveTakesAlignment;
898     }
899     bool hasDotTypeDotSizeDirective() const {
900       return HasDotTypeDotSizeDirective;
901     }
902     bool hasSingleParameterDotFile() const {
903       return HasSingleParameterDotFile;
904     }
905     const char *getUsedDirective() const {
906       return UsedDirective;
907     }
908     const char *getWeakRefDirective() const {
909       return WeakRefDirective;
910     }
911     const char *getWeakDefDirective() const {
912       return WeakDefDirective;
913     }
914     const char *getHiddenDirective() const {
915       return HiddenDirective;
916     }
917     const char *getProtectedDirective() const {
918       return ProtectedDirective;
919     }
920     bool isAbsoluteDebugSectionOffsets() const {
921       return AbsoluteDebugSectionOffsets;
922     }
923     bool isAbsoluteEHSectionOffsets() const {
924       return AbsoluteEHSectionOffsets;
925     }
926     bool hasLEB128() const {
927       return HasLEB128;
928     }
929     bool hasDotLocAndDotFile() const {
930       return HasDotLocAndDotFile;
931     }
932     bool doesSupportDebugInformation() const {
933       return SupportsDebugInformation;
934     }
935     bool doesSupportExceptionHandling() const {
936       return SupportsExceptionHandling;
937     }
938     bool doesDwarfRequireFrameSection() const {
939       return DwarfRequiresFrameSection;
940     }
941     bool doesDwarfUsesInlineInfoSection() const {
942       return DwarfUsesInlineInfoSection;
943     }
944     bool is_EHSymbolPrivate() const {
945       return Is_EHSymbolPrivate;
946     }
947     const char *getGlobalEHDirective() const {
948       return GlobalEHDirective;
949     }
950     bool getSupportsWeakOmittedEHFrame() const {
951       return SupportsWeakOmittedEHFrame;
952     }
953     const char *getDwarfSectionOffsetDirective() const {
954       return DwarfSectionOffsetDirective;
955     }
956     const char *getDwarfAbbrevSection() const {
957       return DwarfAbbrevSection;
958     }
959     const char *getDwarfInfoSection() const {
960       return DwarfInfoSection;
961     }
962     const char *getDwarfLineSection() const {
963       return DwarfLineSection;
964     }
965     const char *getDwarfFrameSection() const {
966       return DwarfFrameSection;
967     }
968     const char *getDwarfPubNamesSection() const {
969       return DwarfPubNamesSection;
970     }
971     const char *getDwarfPubTypesSection() const {
972       return DwarfPubTypesSection;
973     }
974     const char *getDwarfDebugInlineSection() const {
975       return DwarfDebugInlineSection;
976     }
977     const char *getDwarfStrSection() const {
978       return DwarfStrSection;
979     }
980     const char *getDwarfLocSection() const {
981       return DwarfLocSection;
982     }
983     const char *getDwarfARangesSection() const {
984       return DwarfARangesSection;
985     }
986     const char *getDwarfRangesSection() const {
987       return DwarfRangesSection;
988     }
989     const char *getDwarfMacroInfoSection() const {
990       return DwarfMacroInfoSection;
991     }
992     const char *getDwarfEHFrameSection() const {
993       return DwarfEHFrameSection;
994     }
995     const char *getDwarfExceptionSection() const {
996       return DwarfExceptionSection;
997     }
998     const char *const *getAsmCBE() const {
999       return AsmTransCBE;
1000     }
1001   };
1002 }
1003
1004 #endif