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