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