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