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