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 // Forward declaration.
27 /// TargetAsmInfo - This class is intended to be used as a base class for asm
28 /// properties and features specific to the target.
32 //===------------------------------------------------------------------===//
33 // Properties to be set by the target writer, used to configure asm printer.
36 /// TextSection - Section directive for standard text.
38 const char *TextSection; // Defaults to ".text".
40 /// DataSection - Section directive for standard data.
42 const char *DataSection; // Defaults to ".data".
44 /// AddressSize - Size of addresses used in file.
46 unsigned AddressSize; // Defaults to 4.
48 /// NeedsSet - True if target asm can't compute addresses on data
50 bool NeedsSet; // Defaults to false.
52 /// CommentString - This indicates the comment character used by the
54 const char *CommentString; // Defaults to "#"
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 ""
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 "."
65 /// GlobalVarAddrPrefix/Suffix - If these are nonempty, these strings
66 /// will enclose any GlobalVariable (that isn't a function)
68 const char *GlobalVarAddrPrefix; // Defaults to ""
69 const char *GlobalVarAddrSuffix; // Defaults to ""
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.
78 const char *FunctionAddrPrefix; // Defaults to ""
79 const char *FunctionAddrSuffix; // Defaults to ""
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"
86 //===--- Data Emission Directives -------------------------------------===//
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 ""
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"
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"
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 const char *JumpTableDirective; // if used, the jump table reloc flag
113 //===--- Alignment Information ----------------------------------------===//
115 /// AlignDirective - The directive used to emit round up to an alignment
118 const char *AlignDirective; // Defaults to "\t.align\t"
120 /// AlignmentIsInBytes - If this is true (the default) then the asmprinter
121 /// emits ".align N" directives, where N is the number of bytes to align to.
122 /// Otherwise, it emits ".align log2(N)", e.g. 3 to align to an 8 byte
124 bool AlignmentIsInBytes; // Defaults to true
126 //===--- Section Switching Directives ---------------------------------===//
128 /// SwitchToSectionDirective - This is the directive used when we want to
129 /// emit a global to an arbitrary section. The section name is emited after
131 const char *SwitchToSectionDirective; // Defaults to "\t.section\t"
133 /// TextSectionStartSuffix - This is printed after each start of section
134 /// directive for text sections.
135 const char *TextSectionStartSuffix; // Defaults to "".
137 /// DataSectionStartSuffix - This is printed after each start of section
138 /// directive for data sections.
139 const char *DataSectionStartSuffix; // Defaults to "".
141 /// SectionEndDirectiveSuffix - If non-null, the asm printer will close each
142 /// section with the section name and this suffix printed.
143 const char *SectionEndDirectiveSuffix;// Defaults to null.
145 /// ConstantPoolSection - This is the section that we SwitchToSection right
146 /// before emitting the constant pool for a function.
147 const char *ConstantPoolSection; // Defaults to "\t.section .rodata\n"
149 /// JumpTableDataSection - This is the section that we SwitchToSection right
150 /// before emitting the jump tables for a function when the relocation model
152 const char *JumpTableDataSection; // Defaults to "\t.section .rodata\n"
154 /// JumpTableTextSection - This is the section that we SwitchToSection right
155 /// before emitting the jump tables for a function when the relocation model
157 const char *JumpTableTextSection; // Defaults to "\t.text\n"
159 /// StaticCtorsSection - This is the directive that is emitted to switch to
160 /// a section to emit the static constructor list.
161 /// Defaults to "\t.section .ctors,\"aw\",@progbits".
162 const char *StaticCtorsSection;
164 /// StaticDtorsSection - This is the directive that is emitted to switch to
165 /// a section to emit the static destructor list.
166 /// Defaults to "\t.section .dtors,\"aw\",@progbits".
167 const char *StaticDtorsSection;
169 /// FourByteConstantSection, EightByteConstantSection,
170 /// SixteenByteConstantSection - These are special sections where we place
171 /// 4-, 8-, and 16- byte constant literals.
172 const char *FourByteConstantSection;
173 const char *EightByteConstantSection;
174 const char *SixteenByteConstantSection;
176 //===--- Global Variable Emission Directives --------------------------===//
178 /// SetDirective - This is the name of a directive that can be used to tell
179 /// the assembler to set the value of a variable to some expression.
180 const char *SetDirective; // Defaults to null.
182 /// LCOMMDirective - This is the name of a directive (if supported) that can
183 /// be used to efficiently declare a local (internal) block of zero
184 /// initialized data in the .bss/.data section. The syntax expected is:
185 /// \literal <LCOMMDirective> SYMBOLNAME LENGTHINBYTES, ALIGNMENT
187 const char *LCOMMDirective; // Defaults to null.
189 const char *COMMDirective; // Defaults to "\t.comm\t".
191 /// COMMDirectiveTakesAlignment - True if COMMDirective take a third
192 /// argument that specifies the alignment of the declaration.
193 bool COMMDirectiveTakesAlignment; // Defaults to true.
195 /// HasDotTypeDotSizeDirective - True if the target has .type and .size
196 /// directives, this is true for most ELF targets.
197 bool HasDotTypeDotSizeDirective; // Defaults to true.
199 //===--- Dwarf Emission Directives -----------------------------------===//
201 /// HasLEB128 - True if target asm supports leb128 directives.
203 bool HasLEB128; // Defaults to false.
205 /// hasDotLoc - True if target asm supports .loc directives.
207 bool HasDotLoc; // Defaults to false.
209 /// HasDotFile - True if target asm supports .file directives.
211 bool HasDotFile; // Defaults to false.
213 /// DwarfAbbrevSection - Section directive for Dwarf abbrev.
215 const char *DwarfAbbrevSection; // Defaults to ".debug_abbrev".
217 /// DwarfInfoSection - Section directive for Dwarf info.
219 const char *DwarfInfoSection; // Defaults to ".debug_info".
221 /// DwarfLineSection - Section directive for Dwarf info.
223 const char *DwarfLineSection; // Defaults to ".debug_line".
225 /// DwarfFrameSection - Section directive for Dwarf info.
227 const char *DwarfFrameSection; // Defaults to ".debug_frame".
229 /// DwarfPubNamesSection - Section directive for Dwarf info.
231 const char *DwarfPubNamesSection; // Defaults to ".debug_pubnames".
233 /// DwarfPubTypesSection - Section directive for Dwarf info.
235 const char *DwarfPubTypesSection; // Defaults to ".debug_pubtypes".
237 /// DwarfStrSection - Section directive for Dwarf info.
239 const char *DwarfStrSection; // Defaults to ".debug_str".
241 /// DwarfLocSection - Section directive for Dwarf info.
243 const char *DwarfLocSection; // Defaults to ".debug_loc".
245 /// DwarfARangesSection - Section directive for Dwarf info.
247 const char *DwarfARangesSection; // Defaults to ".debug_aranges".
249 /// DwarfRangesSection - Section directive for Dwarf info.
251 const char *DwarfRangesSection; // Defaults to ".debug_ranges".
253 /// DwarfMacInfoSection - Section directive for Dwarf info.
255 const char *DwarfMacInfoSection; // Defaults to ".debug_macinfo".
264 const char *getTextSection() const {
267 const char *getDataSection() const {
270 unsigned getAddressSize() const {
273 bool needsSet() const {
276 const char *getCommentString() const {
277 return CommentString;
279 const char *getGlobalPrefix() const {
282 const char *getPrivateGlobalPrefix() const {
283 return PrivateGlobalPrefix;
285 const char *getGlobalVarAddrPrefix() const {
286 return GlobalVarAddrPrefix;
288 const char *getGlobalVarAddrSuffix() const {
289 return GlobalVarAddrSuffix;
291 const char *getFunctionAddrPrefix() const {
292 return FunctionAddrPrefix;
294 const char *getFunctionAddrSuffix() const {
295 return FunctionAddrSuffix;
297 const char *getInlineAsmStart() const {
298 return InlineAsmStart;
300 const char *getInlineAsmEnd() const {
303 const char *getZeroDirective() const {
304 return ZeroDirective;
306 const char *getZeroDirectiveSuffix() const {
307 return ZeroDirectiveSuffix;
309 const char *getAsciiDirective() const {
310 return AsciiDirective;
312 const char *getAscizDirective() const {
313 return AscizDirective;
315 const char *getData8bitsDirective() const {
316 return Data8bitsDirective;
318 const char *getData16bitsDirective() const {
319 return Data16bitsDirective;
321 const char *getData32bitsDirective() const {
322 return Data32bitsDirective;
324 const char *getData64bitsDirective() const {
325 return Data64bitsDirective;
327 const char *getJumpTableDirective() const {
328 return JumpTableDirective;
330 const char *getAlignDirective() const {
331 return AlignDirective;
333 bool getAlignmentIsInBytes() const {
334 return AlignmentIsInBytes;
336 const char *getSwitchToSectionDirective() const {
337 return SwitchToSectionDirective;
339 const char *getTextSectionStartSuffix() const {
340 return TextSectionStartSuffix;
342 const char *getDataSectionStartSuffix() const {
343 return DataSectionStartSuffix;
345 const char *getSectionEndDirectiveSuffix() const {
346 return SectionEndDirectiveSuffix;
348 const char *getConstantPoolSection() const {
349 return ConstantPoolSection;
351 const char *getJumpTableDataSection() const {
352 return JumpTableDataSection;
354 const char *getJumpTableTextSection() const {
355 return JumpTableTextSection;
357 const char *getStaticCtorsSection() const {
358 return StaticCtorsSection;
360 const char *getStaticDtorsSection() const {
361 return StaticDtorsSection;
363 const char *getFourByteConstantSection() const {
364 return FourByteConstantSection;
366 const char *getEightByteConstantSection() const {
367 return EightByteConstantSection;
369 const char *getSixteenByteConstantSection() const {
370 return SixteenByteConstantSection;
372 const char *getSetDirective() const {
375 const char *getLCOMMDirective() const {
376 return LCOMMDirective;
378 const char *getCOMMDirective() const {
379 return COMMDirective;
381 bool getCOMMDirectiveTakesAlignment() const {
382 return COMMDirectiveTakesAlignment;
384 bool hasDotTypeDotSizeDirective() const {
385 return HasDotTypeDotSizeDirective;
387 bool hasLEB128() const {
390 bool hasDotLoc() const {
393 bool hasDotFile() const {
396 const char *getDwarfAbbrevSection() const {
397 return DwarfAbbrevSection;
399 const char *getDwarfInfoSection() const {
400 return DwarfInfoSection;
402 const char *getDwarfLineSection() const {
403 return DwarfLineSection;
405 const char *getDwarfFrameSection() const {
406 return DwarfFrameSection;
408 const char *getDwarfPubNamesSection() const {
409 return DwarfPubNamesSection;
411 const char *getDwarfPubTypesSection() const {
412 return DwarfPubTypesSection;
414 const char *getDwarfStrSection() const {
415 return DwarfStrSection;
417 const char *getDwarfLocSection() const {
418 return DwarfLocSection;
420 const char *getDwarfARangesSection() const {
421 return DwarfARangesSection;
423 const char *getDwarfRangesSection() const {
424 return DwarfRangesSection;
426 const char *getDwarfMacInfoSection() const {
427 return DwarfMacInfoSection;