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