Now that RelocBehaviour() is never overloaded, it doesn't need to be
[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     /// SectionFlagsForGlobal - This hook allows the target to select proper
605     /// section flags either for given global or for section.
606 // FIXME: Eliminate this.
607     virtual unsigned
608     SectionFlagsForGlobal(const GlobalValue *GV = NULL,
609                           const char* name = NULL) const;
610
611     /// SectionForGlobal - This hooks returns proper section name for given
612     /// global with all necessary flags and marks.
613 // FIXME: Eliminate this.
614     virtual const Section* SectionForGlobal(const GlobalValue *GV) const;
615
616     // Helper methods for SectionForGlobal
617 // FIXME: Eliminate this.
618     virtual std::string UniqueSectionForGlobal(const GlobalValue* GV,
619                                                SectionKind::Kind kind) const;
620
621     const std::string &getSectionFlags(unsigned Flags) const;
622     virtual std::string printSectionFlags(unsigned flags) const { return ""; }
623
624 // FIXME: Eliminate this.
625     virtual const Section* SelectSectionForGlobal(const GlobalValue *GV) const;
626     virtual const Section* SelectSectionForMachineConst(const Type *Ty) const;
627
628     /// getSLEB128Size - Compute the number of bytes required for a signed
629     /// leb128 value.
630     static unsigned getSLEB128Size(int Value);
631
632     /// getULEB128Size - Compute the number of bytes required for an unsigned
633     /// leb128 value.
634     static unsigned getULEB128Size(unsigned Value);
635
636     // Data directive accessors.
637     //
638     const char *getData8bitsDirective(unsigned AS = 0) const {
639       return AS == 0 ? Data8bitsDirective : getDataASDirective(8, AS);
640     }
641     const char *getData16bitsDirective(unsigned AS = 0) const {
642       return AS == 0 ? Data16bitsDirective : getDataASDirective(16, AS);
643     }
644     const char *getData32bitsDirective(unsigned AS = 0) const {
645       return AS == 0 ? Data32bitsDirective : getDataASDirective(32, AS);
646     }
647     const char *getData64bitsDirective(unsigned AS = 0) const {
648       return AS == 0 ? Data64bitsDirective : getDataASDirective(64, AS);
649     }
650
651
652     // Accessors.
653     //
654     const Section *getTextSection() const {
655       return TextSection;
656     }
657     const Section *getDataSection() const {
658       return DataSection;
659     }
660     const char *getBSSSection() const {
661       return BSSSection;
662     }
663     const Section *getBSSSection_() const {
664       return BSSSection_;
665     }
666     const Section *getReadOnlySection() const {
667       return ReadOnlySection;
668     }
669     const Section *getSmallDataSection() const {
670       return SmallDataSection;
671     }
672     const Section *getSmallBSSSection() const {
673       return SmallBSSSection;
674     }
675     const Section *getSmallRODataSection() const {
676       return SmallRODataSection;
677     }
678     const Section *getTLSDataSection() const {
679       return TLSDataSection;
680     }
681     const Section *getTLSBSSSection() const {
682       return TLSBSSSection;
683     }
684     const char *getZeroFillDirective() const {
685       return ZeroFillDirective;
686     }
687     const char *getNonexecutableStackDirective() const {
688       return NonexecutableStackDirective;
689     }
690     bool needsSet() const {
691       return NeedsSet;
692     }
693     const char *getPCSymbol() const {
694       return PCSymbol;
695     }
696     char getSeparatorChar() const {
697       return SeparatorChar;
698     }
699     unsigned getCommentColumn() const {
700       return CommentColumn;
701     }
702     const char *getCommentString() const {
703       return CommentString;
704     }
705     unsigned getOperandColumn(int operand) const {
706       return FirstOperandColumn + (MaxOperandLength+1)*(operand-1);
707     }
708     const char *getGlobalPrefix() const {
709       return GlobalPrefix;
710     }
711     const char *getPrivateGlobalPrefix() const {
712       return PrivateGlobalPrefix;
713     }
714     const char *getLinkerPrivateGlobalPrefix() const {
715       return LinkerPrivateGlobalPrefix;
716     }
717     const char *getJumpTableSpecialLabelPrefix() const {
718       return JumpTableSpecialLabelPrefix;
719     }
720     const char *getGlobalVarAddrPrefix() const {
721       return GlobalVarAddrPrefix;
722     }
723     const char *getGlobalVarAddrSuffix() const {
724       return GlobalVarAddrSuffix;
725     }
726     const char *getFunctionAddrPrefix() const {
727       return FunctionAddrPrefix;
728     }
729     const char *getFunctionAddrSuffix() const {
730       return FunctionAddrSuffix;
731     }
732     const char *getPersonalityPrefix() const {
733       return PersonalityPrefix;
734     }
735     const char *getPersonalitySuffix() const {
736       return PersonalitySuffix;
737     }
738     bool getNeedsIndirectEncoding() const {
739       return NeedsIndirectEncoding;
740     }
741     const char *getInlineAsmStart() const {
742       return InlineAsmStart;
743     }
744     const char *getInlineAsmEnd() const {
745       return InlineAsmEnd;
746     }
747     unsigned getAssemblerDialect() const {
748       return AssemblerDialect;
749     }
750     bool doesAllowQuotesInName() const {
751       return AllowQuotesInName;
752     }
753     const char *getZeroDirective() const {
754       return ZeroDirective;
755     }
756     const char *getZeroDirectiveSuffix() const {
757       return ZeroDirectiveSuffix;
758     }
759     const char *getAsciiDirective() const {
760       return AsciiDirective;
761     }
762     const char *getAscizDirective() const {
763       return AscizDirective;
764     }
765     const char *getJumpTableDirective() const {
766       return JumpTableDirective;
767     }
768     const char *getAlignDirective() const {
769       return AlignDirective;
770     }
771     bool getAlignmentIsInBytes() const {
772       return AlignmentIsInBytes;
773     }
774     unsigned getTextAlignFillValue() const {
775       return TextAlignFillValue;
776     }
777     const char *getSwitchToSectionDirective() const {
778       return SwitchToSectionDirective;
779     }
780     const char *getTextSectionStartSuffix() const {
781       return TextSectionStartSuffix;
782     }
783     const char *getDataSectionStartSuffix() const {
784       return DataSectionStartSuffix;
785     }
786     const char *getSectionEndDirectiveSuffix() const {
787       return SectionEndDirectiveSuffix;
788     }
789     const char *getConstantPoolSection() const {
790       return ConstantPoolSection;
791     }
792     const char *getJumpTableDataSection() const {
793       return JumpTableDataSection;
794     }
795     const char *getCStringSection() const {
796       return CStringSection;
797     }
798     const Section *getCStringSection_() const {
799       return CStringSection_;
800     }
801     const char *getStaticCtorsSection() const {
802       return StaticCtorsSection;
803     }
804     const char *getStaticDtorsSection() const {
805       return StaticDtorsSection;
806     }
807     const char *getGlobalDirective() const {
808       return GlobalDirective;
809     }
810     const char *getExternDirective() const {
811       return ExternDirective;
812     }
813     const char *getSetDirective() const {
814       return SetDirective;
815     }
816     const char *getLCOMMDirective() const {
817       return LCOMMDirective;
818     }
819     const char *getCOMMDirective() const {
820       return COMMDirective;
821     }
822     bool getCOMMDirectiveTakesAlignment() const {
823       return COMMDirectiveTakesAlignment;
824     }
825     bool hasDotTypeDotSizeDirective() const {
826       return HasDotTypeDotSizeDirective;
827     }
828     bool hasSingleParameterDotFile() const {
829       return HasSingleParameterDotFile;
830     }
831     const char *getUsedDirective() const {
832       return UsedDirective;
833     }
834     const char *getWeakRefDirective() const {
835       return WeakRefDirective;
836     }
837     const char *getWeakDefDirective() const {
838       return WeakDefDirective;
839     }
840     const char *getHiddenDirective() const {
841       return HiddenDirective;
842     }
843     const char *getProtectedDirective() const {
844       return ProtectedDirective;
845     }
846     bool isAbsoluteDebugSectionOffsets() const {
847       return AbsoluteDebugSectionOffsets;
848     }
849     bool isAbsoluteEHSectionOffsets() const {
850       return AbsoluteEHSectionOffsets;
851     }
852     bool hasLEB128() const {
853       return HasLEB128;
854     }
855     bool hasDotLocAndDotFile() const {
856       return HasDotLocAndDotFile;
857     }
858     bool doesSupportDebugInformation() const {
859       return SupportsDebugInformation;
860     }
861     bool doesSupportExceptionHandling() const {
862       return SupportsExceptionHandling;
863     }
864     bool doesDwarfRequireFrameSection() const {
865       return DwarfRequiresFrameSection;
866     }
867     bool doesDwarfUsesInlineInfoSection() const {
868       return DwarfUsesInlineInfoSection;
869     }
870     bool is_EHSymbolPrivate() const {
871       return Is_EHSymbolPrivate;
872     }
873     const char *getGlobalEHDirective() const {
874       return GlobalEHDirective;
875     }
876     bool getSupportsWeakOmittedEHFrame() const {
877       return SupportsWeakOmittedEHFrame;
878     }
879     const char *getDwarfSectionOffsetDirective() const {
880       return DwarfSectionOffsetDirective;
881     }
882     const char *getDwarfAbbrevSection() const {
883       return DwarfAbbrevSection;
884     }
885     const char *getDwarfInfoSection() const {
886       return DwarfInfoSection;
887     }
888     const char *getDwarfLineSection() const {
889       return DwarfLineSection;
890     }
891     const char *getDwarfFrameSection() const {
892       return DwarfFrameSection;
893     }
894     const char *getDwarfPubNamesSection() const {
895       return DwarfPubNamesSection;
896     }
897     const char *getDwarfPubTypesSection() const {
898       return DwarfPubTypesSection;
899     }
900     const char *getDwarfDebugInlineSection() const {
901       return DwarfDebugInlineSection;
902     }
903     const char *getDwarfStrSection() const {
904       return DwarfStrSection;
905     }
906     const char *getDwarfLocSection() const {
907       return DwarfLocSection;
908     }
909     const char *getDwarfARangesSection() const {
910       return DwarfARangesSection;
911     }
912     const char *getDwarfRangesSection() const {
913       return DwarfRangesSection;
914     }
915     const char *getDwarfMacroInfoSection() const {
916       return DwarfMacroInfoSection;
917     }
918     const char *getDwarfEHFrameSection() const {
919       return DwarfEHFrameSection;
920     }
921     const char *getDwarfExceptionSection() const {
922       return DwarfExceptionSection;
923     }
924     const char *const *getAsmCBE() const {
925       return AsmTransCBE;
926     }
927   };
928 }
929
930 #endif