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