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