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