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