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