Separate target specifc asm properties from asm printers.
[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
24   /// TargetAsmInfo - This class is intended to be used as a base class for asm
25   /// properties and features specific to the target.
26   class TargetAsmInfo {
27   
28   protected:
29     //===------------------------------------------------------------------===//
30     // Properties to be set by the target writer, used to configure asm printer.
31     // 
32     
33     /// TextSection - Section directive for standard text.
34     ///
35     const char *TextSection;              // Defaults to ".text".
36     
37     /// DataSection - Section directive for standard data.
38     ///
39     const char *DataSection;              // Defaults to ".data".
40     
41     /// AddressSize - Size of addresses used in file.
42     ///
43     unsigned AddressSize;                 // Defaults to 4.
44
45     /// NeedsSet - True if target asm can't compute addresses on data
46     /// directives.
47     bool NeedsSet;                        // Defaults to false.
48
49     /// CommentString - This indicates the comment character used by the
50     /// assembler.
51     const char *CommentString;            // Defaults to "#"
52
53     /// GlobalPrefix - If this is set to a non-empty string, it is prepended
54     /// onto all global symbols.  This is often used for "_" or ".".
55     const char *GlobalPrefix;             // Defaults to ""
56
57     /// PrivateGlobalPrefix - This prefix is used for globals like constant
58     /// pool entries that are completely private to the .o file and should not
59     /// have names in the .o file.  This is often "." or "L".
60     const char *PrivateGlobalPrefix;      // Defaults to "."
61     
62     /// GlobalVarAddrPrefix/Suffix - If these are nonempty, these strings
63     /// will enclose any GlobalVariable (that isn't a function)
64     ///
65     const char *GlobalVarAddrPrefix;      // Defaults to ""
66     const char *GlobalVarAddrSuffix;      // Defaults to ""
67
68     /// FunctionAddrPrefix/Suffix - If these are nonempty, these strings
69     /// will enclose any GlobalVariable that points to a function.
70     /// For example, this is used by the IA64 backend to materialize
71     /// function descriptors, by decorating the ".data8" object with the
72     /// \literal @fptr( ) \endliteral
73     /// link-relocation operator.
74     ///
75     const char *FunctionAddrPrefix;       // Defaults to ""
76     const char *FunctionAddrSuffix;       // Defaults to ""
77
78     /// InlineAsmStart/End - If these are nonempty, they contain a directive to
79     /// emit before and after an inline assembly statement.
80     const char *InlineAsmStart;           // Defaults to "#APP\n"
81     const char *InlineAsmEnd;             // Defaults to "#NO_APP\n"
82     
83     //===--- Data Emission Directives -------------------------------------===//
84
85     /// ZeroDirective - this should be set to the directive used to get some
86     /// number of zero bytes emitted to the current section.  Common cases are
87     /// "\t.zero\t" and "\t.space\t".  If this is set to null, the
88     /// Data*bitsDirective's will be used to emit zero bytes.
89     const char *ZeroDirective;            // Defaults to "\t.zero\t"
90     const char *ZeroDirectiveSuffix;      // Defaults to ""
91
92     /// AsciiDirective - This directive allows emission of an ascii string with
93     /// the standard C escape characters embedded into it.
94     const char *AsciiDirective;           // Defaults to "\t.ascii\t"
95     
96     /// AscizDirective - If not null, this allows for special handling of
97     /// zero terminated strings on this target.  This is commonly supported as
98     /// ".asciz".  If a target doesn't support this, it can be set to null.
99     const char *AscizDirective;           // Defaults to "\t.asciz\t"
100
101     /// DataDirectives - These directives are used to output some unit of
102     /// integer data to the current section.  If a data directive is set to
103     /// null, smaller data directives will be used to emit the large sizes.
104     const char *Data8bitsDirective;       // Defaults to "\t.byte\t"
105     const char *Data16bitsDirective;      // Defaults to "\t.short\t"
106     const char *Data32bitsDirective;      // Defaults to "\t.long\t"
107     const char *Data64bitsDirective;      // Defaults to "\t.quad\t"
108
109     //===--- Alignment Information ----------------------------------------===//
110
111     /// AlignDirective - The directive used to emit round up to an alignment
112     /// boundary.
113     ///
114     const char *AlignDirective;           // Defaults to "\t.align\t"
115
116     /// AlignmentIsInBytes - If this is true (the default) then the asmprinter
117     /// emits ".align N" directives, where N is the number of bytes to align to.
118     /// Otherwise, it emits ".align log2(N)", e.g. 3 to align to an 8 byte
119     /// boundary.
120     bool AlignmentIsInBytes;              // Defaults to true
121     
122     //===--- Section Switching Directives ---------------------------------===//
123     
124     /// SwitchToSectionDirective - This is the directive used when we want to
125     /// emit a global to an arbitrary section.  The section name is emited after
126     /// this.
127     const char *SwitchToSectionDirective; // Defaults to "\t.section\t"
128     
129     /// TextSectionStartSuffix - This is printed after each start of section
130     /// directive for text sections.
131     const char *TextSectionStartSuffix;   // Defaults to "".
132
133     /// DataSectionStartSuffix - This is printed after each start of section
134     /// directive for data sections.
135     const char *DataSectionStartSuffix;   // Defaults to "".
136     
137     /// SectionEndDirectiveSuffix - If non-null, the asm printer will close each
138     /// section with the section name and this suffix printed.
139     const char *SectionEndDirectiveSuffix;// Defaults to null.
140     
141     /// ConstantPoolSection - This is the section that we SwitchToSection right
142     /// before emitting the constant pool for a function.
143     const char *ConstantPoolSection;      // Defaults to "\t.section .rodata\n"
144
145     /// JumpTableDataSection - This is the section that we SwitchToSection right
146     /// before emitting the jump tables for a function when the relocation model
147     /// is not PIC.
148     const char *JumpTableDataSection;     // Defaults to "\t.section .rodata\n"
149     
150     /// JumpTableTextSection - This is the section that we SwitchToSection right
151     /// before emitting the jump tables for a function when the relocation model
152     /// is PIC.
153     const char *JumpTableTextSection;     // Defaults to "\t.text\n"
154     
155     /// StaticCtorsSection - This is the directive that is emitted to switch to
156     /// a section to emit the static constructor list.
157     /// Defaults to "\t.section .ctors,\"aw\",@progbits".
158     const char *StaticCtorsSection;
159
160     /// StaticDtorsSection - This is the directive that is emitted to switch to
161     /// a section to emit the static destructor list.
162     /// Defaults to "\t.section .dtors,\"aw\",@progbits".
163     const char *StaticDtorsSection;
164
165     /// FourByteConstantSection, EightByteConstantSection,
166     /// SixteenByteConstantSection - These are special sections where we place
167     /// 4-, 8-, and 16- byte constant literals.
168     const char *FourByteConstantSection;
169     const char *EightByteConstantSection;
170     const char *SixteenByteConstantSection;
171     
172     //===--- Global Variable Emission Directives --------------------------===//
173     
174     /// SetDirective - This is the name of a directive that can be used to tell
175     /// the assembler to set the value of a variable to some expression.
176     const char *SetDirective;             // Defaults to null.
177     
178     /// LCOMMDirective - This is the name of a directive (if supported) that can
179     /// be used to efficiently declare a local (internal) block of zero
180     /// initialized data in the .bss/.data section.  The syntax expected is:
181     /// \literal <LCOMMDirective> SYMBOLNAME LENGTHINBYTES, ALIGNMENT
182     /// \endliteral
183     const char *LCOMMDirective;           // Defaults to null.
184     
185     const char *COMMDirective;            // Defaults to "\t.comm\t".
186
187     /// COMMDirectiveTakesAlignment - True if COMMDirective take a third
188     /// argument that specifies the alignment of the declaration.
189     bool COMMDirectiveTakesAlignment;     // Defaults to true.
190     
191     /// HasDotTypeDotSizeDirective - True if the target has .type and .size
192     /// directives, this is true for most ELF targets.
193     bool HasDotTypeDotSizeDirective;      // Defaults to true.
194     
195     //===--- Dwarf Emission Directives -----------------------------------===//
196
197     /// HasLEB128 - True if target asm supports leb128 directives.
198     ///
199     bool HasLEB128; // Defaults to false.
200     
201     /// hasDotLoc - True if target asm supports .loc directives.
202     ///
203     bool HasDotLoc; // Defaults to false.
204     
205     /// HasDotFile - True if target asm supports .file directives.
206     ///
207     bool HasDotFile; // Defaults to false.
208     
209     /// DwarfAbbrevSection - Section directive for Dwarf abbrev.
210     ///
211     const char *DwarfAbbrevSection; // Defaults to ".debug_abbrev".
212
213     /// DwarfInfoSection - Section directive for Dwarf info.
214     ///
215     const char *DwarfInfoSection; // Defaults to ".debug_info".
216
217     /// DwarfLineSection - Section directive for Dwarf info.
218     ///
219     const char *DwarfLineSection; // Defaults to ".debug_line".
220     
221     /// DwarfFrameSection - Section directive for Dwarf info.
222     ///
223     const char *DwarfFrameSection; // Defaults to ".debug_frame".
224     
225     /// DwarfPubNamesSection - Section directive for Dwarf info.
226     ///
227     const char *DwarfPubNamesSection; // Defaults to ".debug_pubnames".
228     
229     /// DwarfPubTypesSection - Section directive for Dwarf info.
230     ///
231     const char *DwarfPubTypesSection; // Defaults to ".debug_pubtypes".
232     
233     /// DwarfStrSection - Section directive for Dwarf info.
234     ///
235     const char *DwarfStrSection; // Defaults to ".debug_str".
236
237     /// DwarfLocSection - Section directive for Dwarf info.
238     ///
239     const char *DwarfLocSection; // Defaults to ".debug_loc".
240
241     /// DwarfARangesSection - Section directive for Dwarf info.
242     ///
243     const char *DwarfARangesSection; // Defaults to ".debug_aranges".
244
245     /// DwarfRangesSection - Section directive for Dwarf info.
246     ///
247     const char *DwarfRangesSection; // Defaults to ".debug_ranges".
248
249     /// DwarfMacInfoSection - Section directive for Dwarf info.
250     ///
251     const char *DwarfMacInfoSection; // Defaults to ".debug_macinfo".
252
253
254   public:
255     TargetAsmInfo();
256         
257     //
258     // Accessors.
259     //
260     const char *getTextSection() const {
261       return TextSection;
262     }
263     const char *getDataSection() const {
264       return DataSection;
265     }
266     unsigned getAddressSize() const {
267       return AddressSize;
268     }
269     bool getNeedsSet() const {
270       return NeedsSet;
271     }
272     const char *getCommentString() const {
273       return CommentString;
274     }
275     const char *getGlobalPrefix() const {
276       return GlobalPrefix;
277     }
278     const char *getPrivateGlobalPrefix() const {
279       return PrivateGlobalPrefix;
280     }
281     const char *getGlobalVarAddrPrefix() const {
282       return GlobalVarAddrPrefix;
283     }
284     const char *getGlobalVarAddrSuffix() const {
285       return GlobalVarAddrSuffix;
286     }
287     const char *getFunctionAddrPrefix() const {
288       return FunctionAddrPrefix;
289     }
290     const char *getFunctionAddrSuffix() const {
291       return FunctionAddrSuffix;
292     }
293     const char *getInlineAsmStart() const {
294       return InlineAsmStart;
295     }
296     const char *getInlineAsmEnd() const {
297       return InlineAsmEnd;
298     }
299     const char *getZeroDirective() const {
300       return ZeroDirective;
301     }
302     const char *getZeroDirectiveSuffix() const {
303       return ZeroDirectiveSuffix;
304     }
305     const char *getAsciiDirective() const {
306       return AsciiDirective;
307     }
308     const char *getAscizDirective() const {
309       return AscizDirective;
310     }
311     const char *getData8bitsDirective() const {
312       return Data8bitsDirective;
313     }
314     const char *getData16bitsDirective() const {
315       return Data16bitsDirective;
316     }
317     const char *getData32bitsDirective() const {
318       return Data32bitsDirective;
319     }
320     const char *getData64bitsDirective() const {
321       return Data64bitsDirective;
322     }
323     const char *getAlignDirective() const {
324       return AlignDirective;
325     }
326     bool getAlignmentIsInBytes() const {
327       return AlignmentIsInBytes;
328     }
329     const char *getSwitchToSectionDirective() const {
330       return SwitchToSectionDirective;
331     }
332     const char *getTextSectionStartSuffix() const {
333       return TextSectionStartSuffix;
334     }
335     const char *getDataSectionStartSuffix() const {
336       return DataSectionStartSuffix;
337     }
338     const char *getSectionEndDirectiveSuffix() const {
339       return SectionEndDirectiveSuffix;
340     }
341     const char *getConstantPoolSection() const {
342       return ConstantPoolSection;
343     }
344     const char *getJumpTableDataSection() const {
345       return JumpTableDataSection;
346     }
347     const char *getJumpTableTextSection() const {
348       return JumpTableTextSection;
349     }
350     const char *getStaticCtorsSection() const {
351       return StaticCtorsSection;
352     }
353     const char *getStaticDtorsSection() const {
354       return StaticDtorsSection;
355     }
356     const char *getFourByteConstantSection() const {
357       return FourByteConstantSection;
358     }
359     const char *getEightByteConstantSection() const {
360       return EightByteConstantSection;
361     }
362     const char *getSixteenByteConstantSection() const {
363       return SixteenByteConstantSection;
364     }
365     const char *getSetDirective() const {
366       return SetDirective;
367     }
368     const char *getLCOMMDirective() const {
369       return LCOMMDirective;
370     }
371     const char *getCOMMDirective() const {
372       return COMMDirective;
373     }
374     bool getCOMMDirectiveTakesAlignment() const {
375       return COMMDirectiveTakesAlignment;
376     }
377     bool hasDotTypeDotSizeDirective() const {
378       return HasDotTypeDotSizeDirective;
379     }
380     bool hasLEB128() const {
381       return HasLEB128;
382     }
383     bool hasDotLoc() const {
384       return HasDotLoc;
385     }
386     bool hasDotFile() const {
387       return HasDotFile;
388     }
389     const char *getDwarfAbbrevSection() const {
390       return DwarfAbbrevSection;
391     }
392     const char *getDwarfInfoSection() const {
393       return DwarfInfoSection;
394     }
395     const char *getDwarfLineSection() const {
396       return DwarfLineSection;
397     }
398     const char *getDwarfFrameSection() const {
399       return DwarfFrameSection;
400     }
401     const char *getDwarfPubNamesSection() const {
402       return DwarfPubNamesSection;
403     }
404     const char *getDwarfPubTypesSection() const {
405       return DwarfPubTypesSection;
406     }
407     const char *getDwarfStrSection() const {
408       return DwarfStrSection;
409     }
410     const char *getDwarfLocSection() const {
411       return DwarfLocSection;
412     }
413     const char *getDwarfARangesSection() const {
414       return DwarfARangesSection;
415     }
416     const char *getDwarfRangesSection() const {
417       return DwarfRangesSection;
418     }
419     const char *getDwarfMacInfoSection() const {
420       return DwarfMacInfoSection;
421     }
422   };
423   
424 }
425
426 #endif
427