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