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