rename TargetAsmInfo::getASDirective -> getDataASDirective
[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     /// getDataASDirective - Return the directive that should be used to emit
309     /// data of the specified size to the specified numeric address space.
310     virtual const char *getDataASDirective(unsigned Size, unsigned AS) const {
311       assert(AS != 0 && "Don't know the directives for default addr space");
312       return NULL;
313     }
314
315     //===--- Alignment Information ----------------------------------------===//
316
317     /// AlignDirective - The directive used to emit round up to an alignment
318     /// boundary.
319     ///
320     const char *AlignDirective;           // Defaults to "\t.align\t"
321
322     /// AlignmentIsInBytes - If this is true (the default) then the asmprinter
323     /// emits ".align N" directives, where N is the number of bytes to align to.
324     /// Otherwise, it emits ".align log2(N)", e.g. 3 to align to an 8 byte
325     /// boundary.
326     bool AlignmentIsInBytes;              // Defaults to true
327
328     /// TextAlignFillValue - If non-zero, this is used to fill the executable
329     /// space created as the result of a alignment directive.
330     unsigned TextAlignFillValue;
331
332     //===--- Section Switching Directives ---------------------------------===//
333     
334     /// SwitchToSectionDirective - This is the directive used when we want to
335     /// emit a global to an arbitrary section.  The section name is emited after
336     /// this.
337     const char *SwitchToSectionDirective; // Defaults to "\t.section\t"
338     
339     /// TextSectionStartSuffix - This is printed after each start of section
340     /// directive for text sections.
341     const char *TextSectionStartSuffix;   // Defaults to "".
342
343     /// DataSectionStartSuffix - This is printed after each start of section
344     /// directive for data sections.
345     const char *DataSectionStartSuffix;   // Defaults to "".
346     
347     /// SectionEndDirectiveSuffix - If non-null, the asm printer will close each
348     /// section with the section name and this suffix printed.
349     const char *SectionEndDirectiveSuffix;// Defaults to null.
350     
351     /// ConstantPoolSection - This is the section that we SwitchToSection right
352     /// before emitting the constant pool for a function.
353     const char *ConstantPoolSection;      // Defaults to "\t.section .rodata"
354
355     /// JumpTableDataSection - This is the section that we SwitchToSection right
356     /// before emitting the jump tables for a function when the relocation model
357     /// is not PIC.
358     const char *JumpTableDataSection;     // Defaults to "\t.section .rodata"
359     
360     /// JumpTableDirective - if non-null, the directive to emit before a jump
361     /// table.
362     const char *JumpTableDirective;
363
364     /// CStringSection - If not null, this allows for special handling of
365     /// cstring constants (null terminated string that does not contain any
366     /// other null bytes) on this target. This is commonly supported as
367     /// ".cstring".
368     const char *CStringSection;           // Defaults to NULL
369     const Section *CStringSection_;
370
371     /// StaticCtorsSection - This is the directive that is emitted to switch to
372     /// a section to emit the static constructor list.
373     /// Defaults to "\t.section .ctors,\"aw\",@progbits".
374     const char *StaticCtorsSection;
375
376     /// StaticDtorsSection - This is the directive that is emitted to switch to
377     /// a section to emit the static destructor list.
378     /// Defaults to "\t.section .dtors,\"aw\",@progbits".
379     const char *StaticDtorsSection;
380
381     //===--- Global Variable Emission Directives --------------------------===//
382     
383     /// GlobalDirective - This is the directive used to declare a global entity.
384     ///
385     const char *GlobalDirective;          // Defaults to NULL.
386
387     /// ExternDirective - This is the directive used to declare external 
388     /// globals.
389     ///
390     const char *ExternDirective;          // Defaults to NULL.
391     
392     /// SetDirective - This is the name of a directive that can be used to tell
393     /// the assembler to set the value of a variable to some expression.
394     const char *SetDirective;             // Defaults to null.
395     
396     /// LCOMMDirective - This is the name of a directive (if supported) that can
397     /// be used to efficiently declare a local (internal) block of zero
398     /// initialized data in the .bss/.data section.  The syntax expected is:
399     /// @verbatim <LCOMMDirective> SYMBOLNAME LENGTHINBYTES, ALIGNMENT
400     /// @endverbatim
401     const char *LCOMMDirective;           // Defaults to null.
402     
403     const char *COMMDirective;            // Defaults to "\t.comm\t".
404
405     /// COMMDirectiveTakesAlignment - True if COMMDirective take a third
406     /// argument that specifies the alignment of the declaration.
407     bool COMMDirectiveTakesAlignment;     // Defaults to true.
408     
409     /// HasDotTypeDotSizeDirective - True if the target has .type and .size
410     /// directives, this is true for most ELF targets.
411     bool HasDotTypeDotSizeDirective;      // Defaults to true.
412
413     /// HasSingleParameterDotFile - True if the target has a single parameter
414     /// .file directive, this is true for ELF targets.
415     bool HasSingleParameterDotFile;      // Defaults to true.
416
417     /// UsedDirective - This directive, if non-null, is used to declare a global
418     /// as being used somehow that the assembler can't see.  This prevents dead
419     /// code elimination on some targets.
420     const char *UsedDirective;            // Defaults to null.
421
422     /// WeakRefDirective - This directive, if non-null, is used to declare a
423     /// global as being a weak undefined symbol.
424     const char *WeakRefDirective;         // Defaults to null.
425     
426     /// WeakDefDirective - This directive, if non-null, is used to declare a
427     /// global as being a weak defined symbol.
428     const char *WeakDefDirective;         // Defaults to null.
429     
430     /// HiddenDirective - This directive, if non-null, is used to declare a
431     /// global or function as having hidden visibility.
432     const char *HiddenDirective;          // Defaults to "\t.hidden\t".
433
434     /// ProtectedDirective - This directive, if non-null, is used to declare a
435     /// global or function as having protected visibility.
436     const char *ProtectedDirective;       // Defaults to "\t.protected\t".
437
438     //===--- Dwarf Emission Directives -----------------------------------===//
439
440     /// AbsoluteDebugSectionOffsets - True if we should emit abolute section
441     /// offsets for debug information. Defaults to false.
442     bool AbsoluteDebugSectionOffsets;
443
444     /// AbsoluteEHSectionOffsets - True if we should emit abolute section
445     /// offsets for EH information. Defaults to false.
446     bool AbsoluteEHSectionOffsets;
447
448     /// HasLEB128 - True if target asm supports leb128 directives.
449     ///
450     bool HasLEB128; // Defaults to false.
451
452     /// hasDotLocAndDotFile - True if target asm supports .loc and .file
453     /// directives for emitting debugging information.
454     ///
455     bool HasDotLocAndDotFile; // Defaults to false.
456
457     /// SupportsDebugInformation - True if target supports emission of debugging
458     /// information.
459     bool SupportsDebugInformation;
460
461     /// SupportsExceptionHandling - True if target supports
462     /// exception handling.
463     ///
464     bool SupportsExceptionHandling; // Defaults to false.
465
466     /// RequiresFrameSection - true if the Dwarf2 output needs a frame section
467     ///
468     bool DwarfRequiresFrameSection; // Defaults to true.
469
470     /// DwarfUsesInlineInfoSection - True if DwarfDebugInlineSection is used to
471     /// encode inline subroutine information.
472     bool DwarfUsesInlineInfoSection; // Defaults to false.
473
474     /// Is_EHSymbolPrivate - If set, the "_foo.eh" is made private so that it
475     /// doesn't show up in the symbol table of the object file.
476     bool Is_EHSymbolPrivate;                // Defaults to true.
477
478     /// GlobalEHDirective - This is the directive used to make exception frame
479     /// tables globally visible.
480     ///
481     const char *GlobalEHDirective;          // Defaults to NULL.
482
483     /// SupportsWeakEmptyEHFrame - True if target assembler and linker will
484     /// handle a weak_definition of constant 0 for an omitted EH frame.
485     bool SupportsWeakOmittedEHFrame;  // Defaults to true.
486
487     /// DwarfSectionOffsetDirective - Special section offset directive.
488     const char* DwarfSectionOffsetDirective; // Defaults to NULL
489     
490     /// DwarfAbbrevSection - Section directive for Dwarf abbrev.
491     ///
492     const char *DwarfAbbrevSection; // Defaults to ".debug_abbrev".
493
494     /// DwarfInfoSection - Section directive for Dwarf info.
495     ///
496     const char *DwarfInfoSection; // Defaults to ".debug_info".
497
498     /// DwarfLineSection - Section directive for Dwarf info.
499     ///
500     const char *DwarfLineSection; // Defaults to ".debug_line".
501     
502     /// DwarfFrameSection - Section directive for Dwarf info.
503     ///
504     const char *DwarfFrameSection; // Defaults to ".debug_frame".
505     
506     /// DwarfPubNamesSection - Section directive for Dwarf info.
507     ///
508     const char *DwarfPubNamesSection; // Defaults to ".debug_pubnames".
509     
510     /// DwarfPubTypesSection - Section directive for Dwarf info.
511     ///
512     const char *DwarfPubTypesSection; // Defaults to ".debug_pubtypes".
513
514     /// DwarfDebugInlineSection - Section directive for inline info.
515     ///
516     const char *DwarfDebugInlineSection; // Defaults to ".debug_inlined"
517
518     /// DwarfStrSection - Section directive for Dwarf info.
519     ///
520     const char *DwarfStrSection; // Defaults to ".debug_str".
521
522     /// DwarfLocSection - Section directive for Dwarf info.
523     ///
524     const char *DwarfLocSection; // Defaults to ".debug_loc".
525
526     /// DwarfARangesSection - Section directive for Dwarf info.
527     ///
528     const char *DwarfARangesSection; // Defaults to ".debug_aranges".
529
530     /// DwarfRangesSection - Section directive for Dwarf info.
531     ///
532     const char *DwarfRangesSection; // Defaults to ".debug_ranges".
533
534     /// DwarfMacroInfoSection - Section directive for DWARF macro info.
535     ///
536     const char *DwarfMacroInfoSection; // Defaults to ".debug_macinfo".
537     
538     /// DwarfEHFrameSection - Section directive for Exception frames.
539     ///
540     const char *DwarfEHFrameSection; // Defaults to ".eh_frame".
541     
542     /// DwarfExceptionSection - Section directive for Exception table.
543     ///
544     const char *DwarfExceptionSection; // Defaults to ".gcc_except_table".
545
546     //===--- CBE Asm Translation Table -----------------------------------===//
547
548     const char *const *AsmTransCBE; // Defaults to empty
549
550   public:
551     explicit TargetAsmInfo(const TargetMachine &TM);
552     virtual ~TargetAsmInfo();
553
554     const Section* getNamedSection(const char *Name,
555                                    unsigned Flags = SectionFlags::None,
556                                    bool Override = false) const;
557     const Section* getUnnamedSection(const char *Directive,
558                                      unsigned Flags = SectionFlags::None,
559                                      bool Override = false) const;
560
561     /// Measure the specified inline asm to determine an approximation of its
562     /// length.
563     virtual unsigned getInlineAsmLength(const char *Str) const;
564
565     /// ExpandInlineAsm - This hook allows the target to expand an inline asm
566     /// call to be explicit llvm code if it wants to.  This is useful for
567     /// turning simple inline asms into LLVM intrinsics, which gives the
568     /// compiler more information about the behavior of the code.
569     virtual bool ExpandInlineAsm(CallInst *CI) const {
570       return false;
571     }
572
573     /// emitUsedDirectiveFor - This hook allows targets to selectively decide
574     /// not to emit the UsedDirective for some symbols in llvm.used.
575     virtual bool emitUsedDirectiveFor(const GlobalValue *GV,
576                                       Mangler *Mang) const {
577       return (GV!=0);
578     }
579
580     /// PreferredEHDataFormat - This hook allows the target to select data
581     /// format used for encoding pointers in exception handling data. Reason is
582     /// 0 for data, 1 for code labels, 2 for function pointers. Global is true
583     /// if the symbol can be relocated.
584     virtual unsigned PreferredEHDataFormat(DwarfEncoding::Target Reason,
585                                            bool Global) const;
586
587     /// SectionKindForGlobal - This hook allows the target to select proper
588     /// section kind used for global emission.
589     virtual SectionKind::Kind
590     SectionKindForGlobal(const GlobalValue *GV) const;
591
592     /// RelocBehaviour - Describes how relocations should be treated when
593     /// selecting sections. Reloc::Global bit should be set if global
594     /// relocations should force object to be placed in read-write
595     /// sections. Reloc::Local bit should be set if local relocations should
596     /// force object to be placed in read-write sections.
597     virtual unsigned RelocBehaviour() const;
598
599     /// SectionFlagsForGlobal - This hook allows the target to select proper
600     /// section flags either for given global or for section.
601     virtual unsigned
602     SectionFlagsForGlobal(const GlobalValue *GV = NULL,
603                           const char* name = NULL) const;
604
605     /// SectionForGlobal - This hooks returns proper section name for given
606     /// global with all necessary flags and marks.
607     virtual const Section* SectionForGlobal(const GlobalValue *GV) const;
608
609     // Helper methods for SectionForGlobal
610     virtual std::string UniqueSectionForGlobal(const GlobalValue* GV,
611                                                SectionKind::Kind kind) const;
612
613     const std::string& getSectionFlags(unsigned Flags) const;
614     virtual std::string printSectionFlags(unsigned flags) const { return ""; }
615
616     virtual const Section* SelectSectionForGlobal(const GlobalValue *GV) const;
617
618     virtual const Section* SelectSectionForMachineConst(const Type *Ty) const;
619
620     /// getSLEB128Size - Compute the number of bytes required for a signed
621     /// leb128 value.
622
623     static unsigned getSLEB128Size(int Value);
624
625     /// getULEB128Size - Compute the number of bytes required for an unsigned
626     /// leb128 value.
627
628     static unsigned getULEB128Size(unsigned Value);
629
630     // Data directive accessors
631     //
632     const char *getData8bitsDirective(unsigned AS = 0) const {
633       return AS == 0 ? Data8bitsDirective : getDataASDirective(8, AS);
634     }
635     const char *getData16bitsDirective(unsigned AS = 0) const {
636       return AS == 0 ? Data16bitsDirective : getDataASDirective(16, AS);
637     }
638     const char *getData32bitsDirective(unsigned AS = 0) const {
639       return AS == 0 ? Data32bitsDirective : getDataASDirective(32, AS);
640     }
641     const char *getData64bitsDirective(unsigned AS = 0) const {
642       return AS == 0 ? Data64bitsDirective : getDataASDirective(64, AS);
643     }
644
645
646     // Accessors.
647     //
648     const Section *getTextSection() const {
649       return TextSection;
650     }
651     const Section *getDataSection() const {
652       return DataSection;
653     }
654     const char *getBSSSection() const {
655       return BSSSection;
656     }
657     const Section *getBSSSection_() const {
658       return BSSSection_;
659     }
660     const Section *getReadOnlySection() const {
661       return ReadOnlySection;
662     }
663     const Section *getSmallDataSection() const {
664       return SmallDataSection;
665     }
666     const Section *getSmallBSSSection() const {
667       return SmallBSSSection;
668     }
669     const Section *getSmallRODataSection() const {
670       return SmallRODataSection;
671     }
672     const Section *getTLSDataSection() const {
673       return TLSDataSection;
674     }
675     const Section *getTLSBSSSection() const {
676       return TLSBSSSection;
677     }
678     const char *getZeroFillDirective() const {
679       return ZeroFillDirective;
680     }
681     const char *getNonexecutableStackDirective() const {
682       return NonexecutableStackDirective;
683     }
684     bool needsSet() const {
685       return NeedsSet;
686     }
687     const char *getPCSymbol() const {
688       return PCSymbol;
689     }
690     char getSeparatorChar() const {
691       return SeparatorChar;
692     }
693     unsigned getCommentColumn() const {
694       return CommentColumn;
695     }
696     const char *getCommentString() const {
697       return CommentString;
698     }
699     const char *getGlobalPrefix() const {
700       return GlobalPrefix;
701     }
702     const char *getPrivateGlobalPrefix() const {
703       return PrivateGlobalPrefix;
704     }
705     const char *getLessPrivateGlobalPrefix() const {
706       return LessPrivateGlobalPrefix;
707     }
708     const char *getJumpTableSpecialLabelPrefix() const {
709       return JumpTableSpecialLabelPrefix;
710     }
711     const char *getGlobalVarAddrPrefix() const {
712       return GlobalVarAddrPrefix;
713     }
714     const char *getGlobalVarAddrSuffix() const {
715       return GlobalVarAddrSuffix;
716     }
717     const char *getFunctionAddrPrefix() const {
718       return FunctionAddrPrefix;
719     }
720     const char *getFunctionAddrSuffix() const {
721       return FunctionAddrSuffix;
722     }
723     const char *getPersonalityPrefix() const {
724       return PersonalityPrefix;
725     }
726     const char *getPersonalitySuffix() const {
727       return PersonalitySuffix;
728     }
729     bool getNeedsIndirectEncoding() const {
730       return NeedsIndirectEncoding;
731     }
732     const char *getInlineAsmStart() const {
733       return InlineAsmStart;
734     }
735     const char *getInlineAsmEnd() const {
736       return InlineAsmEnd;
737     }
738     unsigned getAssemblerDialect() const {
739       return AssemblerDialect;
740     }
741     bool doesAllowQuotesInName() const {
742       return AllowQuotesInName;
743     }
744     const char *getZeroDirective() const {
745       return ZeroDirective;
746     }
747     const char *getZeroDirectiveSuffix() const {
748       return ZeroDirectiveSuffix;
749     }
750     const char *getAsciiDirective() const {
751       return AsciiDirective;
752     }
753     const char *getAscizDirective() const {
754       return AscizDirective;
755     }
756     const char *getJumpTableDirective() const {
757       return JumpTableDirective;
758     }
759     const char *getAlignDirective() const {
760       return AlignDirective;
761     }
762     bool getAlignmentIsInBytes() const {
763       return AlignmentIsInBytes;
764     }
765     unsigned getTextAlignFillValue() const {
766       return TextAlignFillValue;
767     }
768     const char *getSwitchToSectionDirective() const {
769       return SwitchToSectionDirective;
770     }
771     const char *getTextSectionStartSuffix() const {
772       return TextSectionStartSuffix;
773     }
774     const char *getDataSectionStartSuffix() const {
775       return DataSectionStartSuffix;
776     }
777     const char *getSectionEndDirectiveSuffix() const {
778       return SectionEndDirectiveSuffix;
779     }
780     const char *getConstantPoolSection() const {
781       return ConstantPoolSection;
782     }
783     const char *getJumpTableDataSection() const {
784       return JumpTableDataSection;
785     }
786     const char *getCStringSection() const {
787       return CStringSection;
788     }
789     const Section *getCStringSection_() const {
790       return CStringSection_;
791     }
792     const char *getStaticCtorsSection() const {
793       return StaticCtorsSection;
794     }
795     const char *getStaticDtorsSection() const {
796       return StaticDtorsSection;
797     }
798     const char *getGlobalDirective() const {
799       return GlobalDirective;
800     }
801     const char *getExternDirective() const {
802       return ExternDirective;
803     }
804     const char *getSetDirective() const {
805       return SetDirective;
806     }
807     const char *getLCOMMDirective() const {
808       return LCOMMDirective;
809     }
810     const char *getCOMMDirective() const {
811       return COMMDirective;
812     }
813     bool getCOMMDirectiveTakesAlignment() const {
814       return COMMDirectiveTakesAlignment;
815     }
816     bool hasDotTypeDotSizeDirective() const {
817       return HasDotTypeDotSizeDirective;
818     }
819     bool hasSingleParameterDotFile() const {
820       return HasSingleParameterDotFile;
821     }
822     const char *getUsedDirective() const {
823       return UsedDirective;
824     }
825     const char *getWeakRefDirective() const {
826       return WeakRefDirective;
827     }
828     const char *getWeakDefDirective() const {
829       return WeakDefDirective;
830     }
831     const char *getHiddenDirective() const {
832       return HiddenDirective;
833     }
834     const char *getProtectedDirective() const {
835       return ProtectedDirective;
836     }
837     bool isAbsoluteDebugSectionOffsets() const {
838       return AbsoluteDebugSectionOffsets;
839     }
840     bool isAbsoluteEHSectionOffsets() const {
841       return AbsoluteEHSectionOffsets;
842     }
843     bool hasLEB128() const {
844       return HasLEB128;
845     }
846     bool hasDotLocAndDotFile() const {
847       return HasDotLocAndDotFile;
848     }
849     bool doesSupportDebugInformation() const {
850       return SupportsDebugInformation;
851     }
852     bool doesSupportExceptionHandling() const {
853       return SupportsExceptionHandling;
854     }
855     bool doesDwarfRequireFrameSection() const {
856       return DwarfRequiresFrameSection;
857     }
858     bool doesDwarfUsesInlineInfoSection() const {
859       return DwarfUsesInlineInfoSection;
860     }
861     bool is_EHSymbolPrivate() const {
862       return Is_EHSymbolPrivate;
863     }
864     const char *getGlobalEHDirective() const {
865       return GlobalEHDirective;
866     }
867     bool getSupportsWeakOmittedEHFrame() const {
868       return SupportsWeakOmittedEHFrame;
869     }
870     const char *getDwarfSectionOffsetDirective() const {
871       return DwarfSectionOffsetDirective;
872     }
873     const char *getDwarfAbbrevSection() const {
874       return DwarfAbbrevSection;
875     }
876     const char *getDwarfInfoSection() const {
877       return DwarfInfoSection;
878     }
879     const char *getDwarfLineSection() const {
880       return DwarfLineSection;
881     }
882     const char *getDwarfFrameSection() const {
883       return DwarfFrameSection;
884     }
885     const char *getDwarfPubNamesSection() const {
886       return DwarfPubNamesSection;
887     }
888     const char *getDwarfPubTypesSection() const {
889       return DwarfPubTypesSection;
890     }
891     const char *getDwarfDebugInlineSection() const {
892       return DwarfDebugInlineSection;
893     }
894     const char *getDwarfStrSection() const {
895       return DwarfStrSection;
896     }
897     const char *getDwarfLocSection() const {
898       return DwarfLocSection;
899     }
900     const char *getDwarfARangesSection() const {
901       return DwarfARangesSection;
902     }
903     const char *getDwarfRangesSection() const {
904       return DwarfRangesSection;
905     }
906     const char *getDwarfMacroInfoSection() const {
907       return DwarfMacroInfoSection;
908     }
909     const char *getDwarfEHFrameSection() const {
910       return DwarfEHFrameSection;
911     }
912     const char *getDwarfExceptionSection() const {
913       return DwarfExceptionSection;
914     }
915     const char *const *getAsmCBE() const {
916       return AsmTransCBE;
917     }
918   };
919 }
920
921 #endif