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