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