1 //===-- llvm/Target/TargetAsmInfo.h - Asm info ------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
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.
8 //===----------------------------------------------------------------------===//
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.
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_TARGET_ASM_INFO_H
17 #define LLVM_TARGET_ASM_INFO_H
19 #include "llvm/CodeGen/MachineFunctionPass.h"
20 #include "llvm/Support/DataTypes.h"
24 /// TargetAsmInfo - This class is intended to be used as a base class for asm
25 /// properties and features specific to the target.
29 //===------------------------------------------------------------------===//
30 // Properties to be set by the target writer, used to configure asm printer.
33 /// TextSection - Section directive for standard text.
35 const char *TextSection; // Defaults to ".text".
37 /// DataSection - Section directive for standard data.
39 const char *DataSection; // Defaults to ".data".
41 /// AddressSize - Size of addresses used in file.
43 unsigned AddressSize; // Defaults to 4.
45 /// NeedsSet - True if target asm can't compute addresses on data
47 bool NeedsSet; // Defaults to false.
49 /// CommentString - This indicates the comment character used by the
51 const char *CommentString; // Defaults to "#"
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 ""
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 "."
62 /// GlobalVarAddrPrefix/Suffix - If these are nonempty, these strings
63 /// will enclose any GlobalVariable (that isn't a function)
65 const char *GlobalVarAddrPrefix; // Defaults to ""
66 const char *GlobalVarAddrSuffix; // Defaults to ""
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.
75 const char *FunctionAddrPrefix; // Defaults to ""
76 const char *FunctionAddrSuffix; // Defaults to ""
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"
83 //===--- Data Emission Directives -------------------------------------===//
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 ""
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"
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"
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"
109 //===--- Alignment Information ----------------------------------------===//
111 /// AlignDirective - The directive used to emit round up to an alignment
114 const char *AlignDirective; // Defaults to "\t.align\t"
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
120 bool AlignmentIsInBytes; // Defaults to true
122 //===--- Section Switching Directives ---------------------------------===//
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
127 const char *SwitchToSectionDirective; // Defaults to "\t.section\t"
129 /// TextSectionStartSuffix - This is printed after each start of section
130 /// directive for text sections.
131 const char *TextSectionStartSuffix; // Defaults to "".
133 /// DataSectionStartSuffix - This is printed after each start of section
134 /// directive for data sections.
135 const char *DataSectionStartSuffix; // Defaults to "".
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.
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"
145 /// JumpTableDataSection - This is the section that we SwitchToSection right
146 /// before emitting the jump tables for a function when the relocation model
148 const char *JumpTableDataSection; // Defaults to "\t.section .rodata\n"
150 /// JumpTableTextSection - This is the section that we SwitchToSection right
151 /// before emitting the jump tables for a function when the relocation model
153 const char *JumpTableTextSection; // Defaults to "\t.text\n"
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;
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;
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;
172 //===--- Global Variable Emission Directives --------------------------===//
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.
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
183 const char *LCOMMDirective; // Defaults to null.
185 const char *COMMDirective; // Defaults to "\t.comm\t".
187 /// COMMDirectiveTakesAlignment - True if COMMDirective take a third
188 /// argument that specifies the alignment of the declaration.
189 bool COMMDirectiveTakesAlignment; // Defaults to true.
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.
195 //===--- Dwarf Emission Directives -----------------------------------===//
197 /// HasLEB128 - True if target asm supports leb128 directives.
199 bool HasLEB128; // Defaults to false.
201 /// hasDotLoc - True if target asm supports .loc directives.
203 bool HasDotLoc; // Defaults to false.
205 /// HasDotFile - True if target asm supports .file directives.
207 bool HasDotFile; // Defaults to false.
209 /// DwarfAbbrevSection - Section directive for Dwarf abbrev.
211 const char *DwarfAbbrevSection; // Defaults to ".debug_abbrev".
213 /// DwarfInfoSection - Section directive for Dwarf info.
215 const char *DwarfInfoSection; // Defaults to ".debug_info".
217 /// DwarfLineSection - Section directive for Dwarf info.
219 const char *DwarfLineSection; // Defaults to ".debug_line".
221 /// DwarfFrameSection - Section directive for Dwarf info.
223 const char *DwarfFrameSection; // Defaults to ".debug_frame".
225 /// DwarfPubNamesSection - Section directive for Dwarf info.
227 const char *DwarfPubNamesSection; // Defaults to ".debug_pubnames".
229 /// DwarfPubTypesSection - Section directive for Dwarf info.
231 const char *DwarfPubTypesSection; // Defaults to ".debug_pubtypes".
233 /// DwarfStrSection - Section directive for Dwarf info.
235 const char *DwarfStrSection; // Defaults to ".debug_str".
237 /// DwarfLocSection - Section directive for Dwarf info.
239 const char *DwarfLocSection; // Defaults to ".debug_loc".
241 /// DwarfARangesSection - Section directive for Dwarf info.
243 const char *DwarfARangesSection; // Defaults to ".debug_aranges".
245 /// DwarfRangesSection - Section directive for Dwarf info.
247 const char *DwarfRangesSection; // Defaults to ".debug_ranges".
249 /// DwarfMacInfoSection - Section directive for Dwarf info.
251 const char *DwarfMacInfoSection; // Defaults to ".debug_macinfo".
260 const char *getTextSection() const {
263 const char *getDataSection() const {
266 unsigned getAddressSize() const {
269 bool getNeedsSet() const {
272 const char *getCommentString() const {
273 return CommentString;
275 const char *getGlobalPrefix() const {
278 const char *getPrivateGlobalPrefix() const {
279 return PrivateGlobalPrefix;
281 const char *getGlobalVarAddrPrefix() const {
282 return GlobalVarAddrPrefix;
284 const char *getGlobalVarAddrSuffix() const {
285 return GlobalVarAddrSuffix;
287 const char *getFunctionAddrPrefix() const {
288 return FunctionAddrPrefix;
290 const char *getFunctionAddrSuffix() const {
291 return FunctionAddrSuffix;
293 const char *getInlineAsmStart() const {
294 return InlineAsmStart;
296 const char *getInlineAsmEnd() const {
299 const char *getZeroDirective() const {
300 return ZeroDirective;
302 const char *getZeroDirectiveSuffix() const {
303 return ZeroDirectiveSuffix;
305 const char *getAsciiDirective() const {
306 return AsciiDirective;
308 const char *getAscizDirective() const {
309 return AscizDirective;
311 const char *getData8bitsDirective() const {
312 return Data8bitsDirective;
314 const char *getData16bitsDirective() const {
315 return Data16bitsDirective;
317 const char *getData32bitsDirective() const {
318 return Data32bitsDirective;
320 const char *getData64bitsDirective() const {
321 return Data64bitsDirective;
323 const char *getAlignDirective() const {
324 return AlignDirective;
326 bool getAlignmentIsInBytes() const {
327 return AlignmentIsInBytes;
329 const char *getSwitchToSectionDirective() const {
330 return SwitchToSectionDirective;
332 const char *getTextSectionStartSuffix() const {
333 return TextSectionStartSuffix;
335 const char *getDataSectionStartSuffix() const {
336 return DataSectionStartSuffix;
338 const char *getSectionEndDirectiveSuffix() const {
339 return SectionEndDirectiveSuffix;
341 const char *getConstantPoolSection() const {
342 return ConstantPoolSection;
344 const char *getJumpTableDataSection() const {
345 return JumpTableDataSection;
347 const char *getJumpTableTextSection() const {
348 return JumpTableTextSection;
350 const char *getStaticCtorsSection() const {
351 return StaticCtorsSection;
353 const char *getStaticDtorsSection() const {
354 return StaticDtorsSection;
356 const char *getFourByteConstantSection() const {
357 return FourByteConstantSection;
359 const char *getEightByteConstantSection() const {
360 return EightByteConstantSection;
362 const char *getSixteenByteConstantSection() const {
363 return SixteenByteConstantSection;
365 const char *getSetDirective() const {
368 const char *getLCOMMDirective() const {
369 return LCOMMDirective;
371 const char *getCOMMDirective() const {
372 return COMMDirective;
374 bool getCOMMDirectiveTakesAlignment() const {
375 return COMMDirectiveTakesAlignment;
377 bool hasDotTypeDotSizeDirective() const {
378 return HasDotTypeDotSizeDirective;
380 bool hasLEB128() const {
383 bool hasDotLoc() const {
386 bool hasDotFile() const {
389 const char *getDwarfAbbrevSection() const {
390 return DwarfAbbrevSection;
392 const char *getDwarfInfoSection() const {
393 return DwarfInfoSection;
395 const char *getDwarfLineSection() const {
396 return DwarfLineSection;
398 const char *getDwarfFrameSection() const {
399 return DwarfFrameSection;
401 const char *getDwarfPubNamesSection() const {
402 return DwarfPubNamesSection;
404 const char *getDwarfPubTypesSection() const {
405 return DwarfPubTypesSection;
407 const char *getDwarfStrSection() const {
408 return DwarfStrSection;
410 const char *getDwarfLocSection() const {
411 return DwarfLocSection;
413 const char *getDwarfARangesSection() const {
414 return DwarfARangesSection;
416 const char *getDwarfRangesSection() const {
417 return DwarfRangesSection;
419 const char *getDwarfMacInfoSection() const {
420 return DwarfMacInfoSection;