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