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