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