Fix couple of bugs connected with eh info:
[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 was developed by James M. Laskey and is distributed under
6 // the University of Illinois Open Source 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/CodeGen/MachineFunctionPass.h"
20 #include "llvm/Support/DataTypes.h"
21
22 namespace llvm {
23   class TargetMachine;
24   class CallInst;
25
26   /// TargetAsmInfo - This class is intended to be used as a base class for asm
27   /// properties and features specific to the target.
28   class TargetAsmInfo {
29   protected:
30     //===------------------------------------------------------------------===//
31     // Properties to be set by the target writer, used to configure asm printer.
32     //
33     
34     /// TextSection - Section directive for standard text.
35     ///
36     const char *TextSection;              // Defaults to ".text".
37     
38     /// DataSection - Section directive for standard data.
39     ///
40     const char *DataSection;              // Defaults to ".data".
41
42     /// BSSSection - Section directive for uninitialized data.  Null if this
43     /// target doesn't support a BSS section.
44     ///
45     const char *BSSSection;               // Default to ".bss".
46
47     /// TLSDataSection - Section directive for Thread Local data.
48     ///
49     const char *TLSDataSection;// Defaults to ".section .tdata,"awT",@progbits".
50
51     /// TLSBSSSection - Section directive for Thread Local uninitialized data.
52     /// Null if this target doesn't support a BSS section.
53     ///
54     const char *TLSBSSSection;// Default to ".section .tbss,"awT",@nobits".
55     /// ZeroFillDirective - Directive for emitting a global to the ZeroFill
56     /// section on this target.  Null if this target doesn't support zerofill.
57     const char *ZeroFillDirective;        // Default is null.
58     
59     /// AddressSize - Size of addresses used in file.
60     ///
61     unsigned AddressSize;                 // Defaults to 4.
62     
63     /// NeedsSet - True if target asm can't compute addresses on data
64     /// directives.
65     bool NeedsSet;                        // Defaults to false.
66     
67     /// MaxInstLength - This is the maximum possible length of an instruction,
68     /// which is needed to compute the size of an inline asm.
69     unsigned MaxInstLength;               // Defaults to 4.
70     
71     /// PCSymbol - The symbol used to represent the current PC.  Used in PC
72     /// relative expressions.
73     const char *PCSymbol;                 // Defaults to "$".
74
75     /// SeparatorChar - This character, if specified, is used to separate
76     /// instructions from each other when on the same line.  This is used to
77     /// measure inline asm instructions.
78     char SeparatorChar;                   // Defaults to ';'
79
80     /// CommentString - This indicates the comment character used by the
81     /// assembler.
82     const char *CommentString;            // Defaults to "#"
83
84     /// GlobalPrefix - If this is set to a non-empty string, it is prepended
85     /// onto all global symbols.  This is often used for "_" or ".".
86     const char *GlobalPrefix;             // Defaults to ""
87
88     /// PrivateGlobalPrefix - This prefix is used for globals like constant
89     /// pool entries that are completely private to the .o file and should not
90     /// have names in the .o file.  This is often "." or "L".
91     const char *PrivateGlobalPrefix;      // Defaults to "."
92     
93     /// JumpTableSpecialLabelPrefix - If not null, a extra (dead) label is
94     /// emitted before jump tables with the specified prefix.
95     const char *JumpTableSpecialLabelPrefix;  // Default to null.
96     
97     /// GlobalVarAddrPrefix/Suffix - If these are nonempty, these strings
98     /// will enclose any GlobalVariable (that isn't a function)
99     ///
100     const char *GlobalVarAddrPrefix;      // Defaults to ""
101     const char *GlobalVarAddrSuffix;      // Defaults to ""
102
103     /// FunctionAddrPrefix/Suffix - If these are nonempty, these strings
104     /// will enclose any GlobalVariable that points to a function.
105     /// For example, this is used by the IA64 backend to materialize
106     /// function descriptors, by decorating the ".data8" object with the
107     /// \literal @fptr( ) \endliteral
108     /// link-relocation operator.
109     ///
110     const char *FunctionAddrPrefix;       // Defaults to ""
111     const char *FunctionAddrSuffix;       // Defaults to ""
112
113     /// InlineAsmStart/End - If these are nonempty, they contain a directive to
114     /// emit before and after an inline assembly statement.
115     const char *InlineAsmStart;           // Defaults to "#APP\n"
116     const char *InlineAsmEnd;             // Defaults to "#NO_APP\n"
117
118     /// AssemblerDialect - Which dialect of an assembler variant to use.
119     unsigned AssemblerDialect;            // Defaults to 0
120
121     //===--- Data Emission Directives -------------------------------------===//
122
123     /// ZeroDirective - this should be set to the directive used to get some
124     /// number of zero bytes emitted to the current section.  Common cases are
125     /// "\t.zero\t" and "\t.space\t".  If this is set to null, the
126     /// Data*bitsDirective's will be used to emit zero bytes.
127     const char *ZeroDirective;            // Defaults to "\t.zero\t"
128     const char *ZeroDirectiveSuffix;      // Defaults to ""
129
130     /// AsciiDirective - This directive allows emission of an ascii string with
131     /// the standard C escape characters embedded into it.
132     const char *AsciiDirective;           // Defaults to "\t.ascii\t"
133     
134     /// AscizDirective - If not null, this allows for special handling of
135     /// zero terminated strings on this target.  This is commonly supported as
136     /// ".asciz".  If a target doesn't support this, it can be set to null.
137     const char *AscizDirective;           // Defaults to "\t.asciz\t"
138
139     /// DataDirectives - These directives are used to output some unit of
140     /// integer data to the current section.  If a data directive is set to
141     /// null, smaller data directives will be used to emit the large sizes.
142     const char *Data8bitsDirective;       // Defaults to "\t.byte\t"
143     const char *Data16bitsDirective;      // Defaults to "\t.short\t"
144     const char *Data32bitsDirective;      // Defaults to "\t.long\t"
145     const char *Data64bitsDirective;      // Defaults to "\t.quad\t"
146
147     //===--- Alignment Information ----------------------------------------===//
148
149     /// AlignDirective - The directive used to emit round up to an alignment
150     /// boundary.
151     ///
152     const char *AlignDirective;           // Defaults to "\t.align\t"
153
154     /// AlignmentIsInBytes - If this is true (the default) then the asmprinter
155     /// emits ".align N" directives, where N is the number of bytes to align to.
156     /// Otherwise, it emits ".align log2(N)", e.g. 3 to align to an 8 byte
157     /// boundary.
158     bool AlignmentIsInBytes;              // Defaults to true
159
160     //===--- Section Switching Directives ---------------------------------===//
161     
162     /// SwitchToSectionDirective - This is the directive used when we want to
163     /// emit a global to an arbitrary section.  The section name is emited after
164     /// this.
165     const char *SwitchToSectionDirective; // Defaults to "\t.section\t"
166     
167     /// TextSectionStartSuffix - This is printed after each start of section
168     /// directive for text sections.
169     const char *TextSectionStartSuffix;   // Defaults to "".
170
171     /// DataSectionStartSuffix - This is printed after each start of section
172     /// directive for data sections.
173     const char *DataSectionStartSuffix;   // Defaults to "".
174     
175     /// SectionEndDirectiveSuffix - If non-null, the asm printer will close each
176     /// section with the section name and this suffix printed.
177     const char *SectionEndDirectiveSuffix;// Defaults to null.
178     
179     /// ConstantPoolSection - This is the section that we SwitchToSection right
180     /// before emitting the constant pool for a function.
181     const char *ConstantPoolSection;      // Defaults to "\t.section .rodata\n"
182
183     /// JumpTableDataSection - This is the section that we SwitchToSection right
184     /// before emitting the jump tables for a function when the relocation model
185     /// is not PIC.
186     const char *JumpTableDataSection;     // Defaults to "\t.section .rodata\n"
187     
188     /// JumpTableDirective - if non-null, the directive to emit before a jump
189     /// table.
190     const char *JumpTableDirective;
191
192     /// CStringSection - If not null, this allows for special handling of
193     /// cstring constants (\0 terminated string that does not contain any
194     /// other null bytes) on this target. This is commonly supported as
195     /// ".cstring".
196     const char *CStringSection;           // Defaults to NULL
197
198     /// StaticCtorsSection - This is the directive that is emitted to switch to
199     /// a section to emit the static constructor list.
200     /// Defaults to "\t.section .ctors,\"aw\",@progbits".
201     const char *StaticCtorsSection;
202
203     /// StaticDtorsSection - This is the directive that is emitted to switch to
204     /// a section to emit the static destructor list.
205     /// Defaults to "\t.section .dtors,\"aw\",@progbits".
206     const char *StaticDtorsSection;
207
208     /// FourByteConstantSection, EightByteConstantSection,
209     /// SixteenByteConstantSection - These are special sections where we place
210     /// 4-, 8-, and 16- byte constant literals.
211     const char *FourByteConstantSection;
212     const char *EightByteConstantSection;
213     const char *SixteenByteConstantSection;
214
215     /// ReadOnlySection - This is the directive that is emitted to switch to a
216     /// read-only section for constant data (e.g. data declared const,
217     /// jump tables).
218     const char *ReadOnlySection;          // Defaults to NULL
219
220     //===--- Global Variable Emission Directives --------------------------===//
221     
222     /// GlobalDirective - This is the directive used to declare a global entity.
223     ///
224     const char *GlobalDirective;          // Defaults to NULL.
225     
226     /// SetDirective - This is the name of a directive that can be used to tell
227     /// the assembler to set the value of a variable to some expression.
228     const char *SetDirective;             // Defaults to null.
229     
230     /// LCOMMDirective - This is the name of a directive (if supported) that can
231     /// be used to efficiently declare a local (internal) block of zero
232     /// initialized data in the .bss/.data section.  The syntax expected is:
233     /// \literal <LCOMMDirective> SYMBOLNAME LENGTHINBYTES, ALIGNMENT
234     /// \endliteral
235     const char *LCOMMDirective;           // Defaults to null.
236     
237     const char *COMMDirective;            // Defaults to "\t.comm\t".
238
239     /// COMMDirectiveTakesAlignment - True if COMMDirective take a third
240     /// argument that specifies the alignment of the declaration.
241     bool COMMDirectiveTakesAlignment;     // Defaults to true.
242     
243     /// HasDotTypeDotSizeDirective - True if the target has .type and .size
244     /// directives, this is true for most ELF targets.
245     bool HasDotTypeDotSizeDirective;      // Defaults to true.
246     
247     /// UsedDirective - This directive, if non-null, is used to declare a global
248     /// as being used somehow that the assembler can't see.  This prevents dead
249     /// code elimination on some targets.
250     const char *UsedDirective;            // Defaults to null.
251
252     /// WeakRefDirective - This directive, if non-null, is used to declare a
253     /// global as being a weak undefined symbol.
254     const char *WeakRefDirective;         // Defaults to null.
255     
256     /// HiddenDirective - This directive, if non-null, is used to declare a
257     /// global or function as having hidden visibility.
258     const char *HiddenDirective;          // Defaults to "\t.hidden\t".
259
260     /// ProtectedDirective - This directive, if non-null, is used to declare a
261     /// global or function as having protected visibility.
262     const char *ProtectedDirective;       // Defaults to "\t.protected\t".
263
264     //===--- Dwarf Emission Directives -----------------------------------===//
265
266     /// AbsoluteDebugSectionOffsets - True if we should emit abolute section
267     /// offsets for debug information. Defaults to false.
268     bool AbsoluteDebugSectionOffsets;
269
270     /// AbsoluteEHSectionOffsets - True if we should emit abolute section
271     /// offsets for EH information. Defaults to false.
272     bool AbsoluteEHSectionOffsets;
273
274     /// HasLEB128 - True if target asm supports leb128 directives.
275     ///
276     bool HasLEB128; // Defaults to false.
277     
278     /// hasDotLoc - True if target asm supports .loc directives.
279     ///
280     bool HasDotLoc; // Defaults to false.
281     
282     /// HasDotFile - True if target asm supports .file directives.
283     ///
284     bool HasDotFile; // Defaults to false.
285     
286     /// SupportsExceptionHandling - True if target supports exception handling.
287     ///
288     bool SupportsExceptionHandling; // Defaults to false.
289     
290     /// RequiresFrameSection - true if the Dwarf2 output needs a frame section
291     ///
292     bool DwarfRequiresFrameSection; // Defaults to true.
293
294     /// DwarfSectionOffsetDirective - Special section offset directive.
295     const char* DwarfSectionOffsetDirective; // Defaults to NULL
296     
297     /// DwarfAbbrevSection - Section directive for Dwarf abbrev.
298     ///
299     const char *DwarfAbbrevSection; // Defaults to ".debug_abbrev".
300
301     /// DwarfInfoSection - Section directive for Dwarf info.
302     ///
303     const char *DwarfInfoSection; // Defaults to ".debug_info".
304
305     /// DwarfLineSection - Section directive for Dwarf info.
306     ///
307     const char *DwarfLineSection; // Defaults to ".debug_line".
308     
309     /// DwarfFrameSection - Section directive for Dwarf info.
310     ///
311     const char *DwarfFrameSection; // Defaults to ".debug_frame".
312     
313     /// DwarfPubNamesSection - Section directive for Dwarf info.
314     ///
315     const char *DwarfPubNamesSection; // Defaults to ".debug_pubnames".
316     
317     /// DwarfPubTypesSection - Section directive for Dwarf info.
318     ///
319     const char *DwarfPubTypesSection; // Defaults to ".debug_pubtypes".
320     
321     /// DwarfStrSection - Section directive for Dwarf info.
322     ///
323     const char *DwarfStrSection; // Defaults to ".debug_str".
324
325     /// DwarfLocSection - Section directive for Dwarf info.
326     ///
327     const char *DwarfLocSection; // Defaults to ".debug_loc".
328
329     /// DwarfARangesSection - Section directive for Dwarf info.
330     ///
331     const char *DwarfARangesSection; // Defaults to ".debug_aranges".
332
333     /// DwarfRangesSection - Section directive for Dwarf info.
334     ///
335     const char *DwarfRangesSection; // Defaults to ".debug_ranges".
336
337     /// DwarfMacInfoSection - Section directive for Dwarf info.
338     ///
339     const char *DwarfMacInfoSection; // Defaults to ".debug_macinfo".
340     
341     /// DwarfEHFrameSection - Section directive for Exception frames.
342     ///
343     const char *DwarfEHFrameSection; // Defaults to ".eh_frame".
344     
345     /// DwarfExceptionSection - Section directive for Exception table.
346     ///
347     const char *DwarfExceptionSection; // Defaults to ".gcc_except_table".
348      
349
350     //===--- CBE Asm Translation Table -----------------------------------===//
351
352     const char** AsmTransCBE; // Defaults to empty
353
354   public:
355     TargetAsmInfo();
356     virtual ~TargetAsmInfo();
357
358     /// Measure the specified inline asm to determine an approximation of its
359     /// length.
360     virtual unsigned getInlineAsmLength(const char *Str) const;
361
362     /// ExpandInlineAsm - This hook allows the target to expand an inline asm
363     /// call to be explicit llvm code if it wants to.  This is useful for
364     /// turning simple inline asms into LLVM intrinsics, which gives the
365     /// compiler more information about the behavior of the code.
366     virtual bool ExpandInlineAsm(CallInst *CI) const {
367       return false;
368     }
369     
370     // Accessors.
371     //
372     const char *getTextSection() const {
373       return TextSection;
374     }
375     const char *getDataSection() const {
376       return DataSection;
377     }
378     const char *getBSSSection() const {
379       return BSSSection;
380     }
381     const char *getTLSDataSection() const {
382       return TLSDataSection;
383     }
384     const char *getTLSBSSSection() const {
385       return TLSBSSSection;
386     }
387     const char *getZeroFillDirective() const {
388       return ZeroFillDirective;
389     }
390     unsigned getAddressSize() const {
391       return AddressSize;
392     }
393     bool needsSet() const {
394       return NeedsSet;
395     }
396     const char *getPCSymbol() const {
397       return PCSymbol;
398     }
399     char getSeparatorChar() const {
400       return SeparatorChar;
401     }
402     const char *getCommentString() const {
403       return CommentString;
404     }
405     const char *getGlobalPrefix() const {
406       return GlobalPrefix;
407     }
408     const char *getPrivateGlobalPrefix() const {
409       return PrivateGlobalPrefix;
410     }
411     const char *getJumpTableSpecialLabelPrefix() const {
412       return JumpTableSpecialLabelPrefix;
413     }
414     const char *getGlobalVarAddrPrefix() const {
415       return GlobalVarAddrPrefix;
416     }
417     const char *getGlobalVarAddrSuffix() const {
418       return GlobalVarAddrSuffix;
419     }
420     const char *getFunctionAddrPrefix() const {
421       return FunctionAddrPrefix;
422     }
423     const char *getFunctionAddrSuffix() const {
424       return FunctionAddrSuffix;
425     }
426     const char *getInlineAsmStart() const {
427       return InlineAsmStart;
428     }
429     const char *getInlineAsmEnd() const {
430       return InlineAsmEnd;
431     }
432     unsigned getAssemblerDialect() const {
433       return AssemblerDialect;
434     }
435     const char *getZeroDirective() const {
436       return ZeroDirective;
437     }
438     const char *getZeroDirectiveSuffix() const {
439       return ZeroDirectiveSuffix;
440     }
441     const char *getAsciiDirective() const {
442       return AsciiDirective;
443     }
444     const char *getAscizDirective() const {
445       return AscizDirective;
446     }
447     const char *getData8bitsDirective() const {
448       return Data8bitsDirective;
449     }
450     const char *getData16bitsDirective() const {
451       return Data16bitsDirective;
452     }
453     const char *getData32bitsDirective() const {
454       return Data32bitsDirective;
455     }
456     const char *getData64bitsDirective() const {
457       return Data64bitsDirective;
458     }
459     const char *getJumpTableDirective() const {
460       return JumpTableDirective;
461     }
462     const char *getAlignDirective() const {
463       return AlignDirective;
464     }
465     bool getAlignmentIsInBytes() const {
466       return AlignmentIsInBytes;
467     }
468     const char *getSwitchToSectionDirective() const {
469       return SwitchToSectionDirective;
470     }
471     const char *getTextSectionStartSuffix() const {
472       return TextSectionStartSuffix;
473     }
474     const char *getDataSectionStartSuffix() const {
475       return DataSectionStartSuffix;
476     }
477     const char *getSectionEndDirectiveSuffix() const {
478       return SectionEndDirectiveSuffix;
479     }
480     const char *getConstantPoolSection() const {
481       return ConstantPoolSection;
482     }
483     const char *getJumpTableDataSection() const {
484       return JumpTableDataSection;
485     }
486     const char *getCStringSection() const {
487       return CStringSection;
488     }
489     const char *getStaticCtorsSection() const {
490       return StaticCtorsSection;
491     }
492     const char *getStaticDtorsSection() const {
493       return StaticDtorsSection;
494     }
495     const char *getFourByteConstantSection() const {
496       return FourByteConstantSection;
497     }
498     const char *getEightByteConstantSection() const {
499       return EightByteConstantSection;
500     }
501     const char *getSixteenByteConstantSection() const {
502       return SixteenByteConstantSection;
503     }
504     const char *getReadOnlySection() const {
505       return ReadOnlySection;
506     }
507     const char *getGlobalDirective() const {
508       return GlobalDirective;
509     }
510     const char *getSetDirective() const {
511       return SetDirective;
512     }
513     const char *getLCOMMDirective() const {
514       return LCOMMDirective;
515     }
516     const char *getCOMMDirective() const {
517       return COMMDirective;
518     }
519     bool getCOMMDirectiveTakesAlignment() const {
520       return COMMDirectiveTakesAlignment;
521     }
522     bool hasDotTypeDotSizeDirective() const {
523       return HasDotTypeDotSizeDirective;
524     }
525     const char *getUsedDirective() const {
526       return UsedDirective;
527     }
528     const char *getWeakRefDirective() const {
529       return WeakRefDirective;
530     }
531     const char *getHiddenDirective() const {
532       return HiddenDirective;
533     }
534     const char *getProtectedDirective() const {
535       return ProtectedDirective;
536     }
537     bool isAbsoluteDebugSectionOffsets() const {
538       return AbsoluteDebugSectionOffsets;
539     }
540     bool isAbsoluteEHSectionOffsets() const {
541       return AbsoluteEHSectionOffsets;
542     }
543     bool hasLEB128() const {
544       return HasLEB128;
545     }
546     bool hasDotLoc() const {
547       return HasDotLoc;
548     }
549     bool hasDotFile() const {
550       return HasDotFile;
551     }
552     bool getSupportsExceptionHandling() const {
553       return SupportsExceptionHandling;
554     }
555     bool getDwarfRequiresFrameSection() const {
556       return DwarfRequiresFrameSection;
557     }
558     const char *getDwarfSectionOffsetDirective() const {
559       return DwarfSectionOffsetDirective;
560     }    
561     const char *getDwarfAbbrevSection() const {
562       return DwarfAbbrevSection;
563     }
564     const char *getDwarfInfoSection() const {
565       return DwarfInfoSection;
566     }
567     const char *getDwarfLineSection() const {
568       return DwarfLineSection;
569     }
570     const char *getDwarfFrameSection() const {
571       return DwarfFrameSection;
572     }
573     const char *getDwarfPubNamesSection() const {
574       return DwarfPubNamesSection;
575     }
576     const char *getDwarfPubTypesSection() const {
577       return DwarfPubTypesSection;
578     }
579     const char *getDwarfStrSection() const {
580       return DwarfStrSection;
581     }
582     const char *getDwarfLocSection() const {
583       return DwarfLocSection;
584     }
585     const char *getDwarfARangesSection() const {
586       return DwarfARangesSection;
587     }
588     const char *getDwarfRangesSection() const {
589       return DwarfRangesSection;
590     }
591     const char *getDwarfMacInfoSection() const {
592       return DwarfMacInfoSection;
593     }
594     const char *getDwarfEHFrameSection() const {
595       return DwarfEHFrameSection;
596     }
597     const char *getDwarfExceptionSection() const {
598       return DwarfExceptionSection;
599     }
600     const char** getAsmCBE() const {
601       return AsmTransCBE;
602     }
603   };
604 }
605
606 #endif
607