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