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