blob: d11f01628f5f9da5d09efbad1f5411c586a91a5b [file] [log] [blame]
Jim Laskey8e8de8f2006-09-07 22:05:02 +00001//===-- X86TargetAsmInfo.cpp - X86 asm properties ---------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Jim Laskey8e8de8f2006-09-07 22:05:02 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file contains the declarations of the X86TargetAsmInfo properties.
11//
12//===----------------------------------------------------------------------===//
13
14#include "X86TargetAsmInfo.h"
15#include "X86TargetMachine.h"
16#include "X86Subtarget.h"
Reid Spencer7aa8a452007-01-12 23:22:14 +000017#include "llvm/DerivedTypes.h"
Chris Lattner625bd052006-11-29 01:14:06 +000018#include "llvm/InlineAsm.h"
19#include "llvm/Instructions.h"
Chris Lattner3e9f1d02007-04-01 20:49:36 +000020#include "llvm/Intrinsics.h"
Chris Lattner625bd052006-11-29 01:14:06 +000021#include "llvm/Module.h"
22#include "llvm/ADT/StringExtras.h"
Anton Korobeynikovcee750f2008-02-27 23:33:50 +000023#include "llvm/Support/Dwarf.h"
24
Jim Laskey8e8de8f2006-09-07 22:05:02 +000025using namespace llvm;
Anton Korobeynikovcee750f2008-02-27 23:33:50 +000026using namespace llvm::dwarf;
Jim Laskey8e8de8f2006-09-07 22:05:02 +000027
Anton Korobeynikov84903222008-09-24 22:21:39 +000028const char *const llvm::x86_asm_table[] = {
29 "{si}", "S",
30 "{di}", "D",
31 "{ax}", "a",
32 "{cx}", "c",
33 "{memory}", "memory",
34 "{flags}", "",
35 "{dirflag}", "",
36 "{fpsr}", "",
37 "{cc}", "cc",
38 0,0};
Andrew Lenharth6c0695f2006-11-28 19:52:49 +000039
Anton Korobeynikov84903222008-09-24 22:21:39 +000040template <class BaseTAI>
41bool X86TargetAsmInfo<BaseTAI>::LowerToBSwap(CallInst *CI) const {
Chris Lattner625bd052006-11-29 01:14:06 +000042 // FIXME: this should verify that we are targetting a 486 or better. If not,
43 // we will turn this bswap into something that will be lowered to logical ops
44 // instead of emitting the bswap asm. For now, we don't support 486 or lower
45 // so don't worry about this.
Anton Korobeynikov82100452008-07-09 13:20:27 +000046
Chris Lattner625bd052006-11-29 01:14:06 +000047 // Verify this is a simple bswap.
48 if (CI->getNumOperands() != 2 ||
49 CI->getType() != CI->getOperand(1)->getType() ||
Chris Lattner42a75512007-01-15 02:27:26 +000050 !CI->getType()->isInteger())
Chris Lattner625bd052006-11-29 01:14:06 +000051 return false;
Anton Korobeynikov82100452008-07-09 13:20:27 +000052
Chris Lattner3e9f1d02007-04-01 20:49:36 +000053 const IntegerType *Ty = dyn_cast<IntegerType>(CI->getType());
54 if (!Ty || Ty->getBitWidth() % 16 != 0)
Reid Spencera54b7cb2007-01-12 07:05:14 +000055 return false;
Anton Korobeynikov82100452008-07-09 13:20:27 +000056
Chris Lattner625bd052006-11-29 01:14:06 +000057 // Okay, we can do this xform, do so now.
Chandler Carruth69940402007-08-04 01:51:18 +000058 const Type *Tys[] = { Ty };
Chris Lattner625bd052006-11-29 01:14:06 +000059 Module *M = CI->getParent()->getParent()->getParent();
Chandler Carruth69940402007-08-04 01:51:18 +000060 Constant *Int = Intrinsic::getDeclaration(M, Intrinsic::bswap, Tys, 1);
Anton Korobeynikov82100452008-07-09 13:20:27 +000061
Chris Lattner625bd052006-11-29 01:14:06 +000062 Value *Op = CI->getOperand(1);
Gabor Greif051a9502008-04-06 20:25:17 +000063 Op = CallInst::Create(Int, Op, CI->getName(), CI);
Anton Korobeynikov82100452008-07-09 13:20:27 +000064
Chris Lattner625bd052006-11-29 01:14:06 +000065 CI->replaceAllUsesWith(Op);
66 CI->eraseFromParent();
67 return true;
68}
69
Anton Korobeynikov84903222008-09-24 22:21:39 +000070template <class BaseTAI>
71bool X86TargetAsmInfo<BaseTAI>::ExpandInlineAsm(CallInst *CI) const {
Chris Lattner625bd052006-11-29 01:14:06 +000072 InlineAsm *IA = cast<InlineAsm>(CI->getCalledValue());
Chris Lattner5d521352006-11-29 01:48:01 +000073 std::vector<InlineAsm::ConstraintInfo> Constraints = IA->ParseConstraints();
Anton Korobeynikov82100452008-07-09 13:20:27 +000074
Chris Lattner625bd052006-11-29 01:14:06 +000075 std::string AsmStr = IA->getAsmString();
Anton Korobeynikov82100452008-07-09 13:20:27 +000076
Chris Lattner625bd052006-11-29 01:14:06 +000077 // TODO: should remove alternatives from the asmstring: "foo {a|b}" -> "foo a"
78 std::vector<std::string> AsmPieces;
79 SplitString(AsmStr, AsmPieces, "\n"); // ; as separator?
Anton Korobeynikov82100452008-07-09 13:20:27 +000080
Chris Lattner625bd052006-11-29 01:14:06 +000081 switch (AsmPieces.size()) {
Anton Korobeynikov82100452008-07-09 13:20:27 +000082 default: return false;
Chris Lattner625bd052006-11-29 01:14:06 +000083 case 1:
84 AsmStr = AsmPieces[0];
85 AsmPieces.clear();
86 SplitString(AsmStr, AsmPieces, " \t"); // Split with whitespace.
Anton Korobeynikov82100452008-07-09 13:20:27 +000087
Chris Lattner5d521352006-11-29 01:48:01 +000088 // bswap $0
Anton Korobeynikov82100452008-07-09 13:20:27 +000089 if (AsmPieces.size() == 2 &&
Chris Lattner625bd052006-11-29 01:14:06 +000090 AsmPieces[0] == "bswap" && AsmPieces[1] == "$0") {
91 // No need to check constraints, nothing other than the equivalent of
92 // "=r,0" would be valid here.
93 return LowerToBSwap(CI);
94 }
95 break;
Chris Lattner5d521352006-11-29 01:48:01 +000096 case 3:
Reid Spencer47857812006-12-31 05:55:36 +000097 if (CI->getType() == Type::Int64Ty && Constraints.size() >= 2 &&
Chris Lattner5d521352006-11-29 01:48:01 +000098 Constraints[0].Codes.size() == 1 && Constraints[0].Codes[0] == "A" &&
99 Constraints[1].Codes.size() == 1 && Constraints[1].Codes[0] == "0") {
100 // bswap %eax / bswap %edx / xchgl %eax, %edx -> llvm.bswap.i64
101 std::vector<std::string> Words;
102 SplitString(AsmPieces[0], Words, " \t");
103 if (Words.size() == 2 && Words[0] == "bswap" && Words[1] == "%eax") {
104 Words.clear();
105 SplitString(AsmPieces[1], Words, " \t");
106 if (Words.size() == 2 && Words[0] == "bswap" && Words[1] == "%edx") {
107 Words.clear();
108 SplitString(AsmPieces[2], Words, " \t,");
109 if (Words.size() == 3 && Words[0] == "xchgl" && Words[1] == "%eax" &&
110 Words[2] == "%edx") {
111 return LowerToBSwap(CI);
112 }
113 }
114 }
115 }
116 break;
Chris Lattner625bd052006-11-29 01:14:06 +0000117 }
118 return false;
119}
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000120
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000121X86DarwinTargetAsmInfo::X86DarwinTargetAsmInfo(const X86TargetMachine &TM):
Anton Korobeynikov84903222008-09-24 22:21:39 +0000122 X86TargetAsmInfo<DarwinTargetAsmInfo>(TM) {
Anton Korobeynikov16b7f512008-08-08 18:25:52 +0000123 const X86Subtarget* Subtarget = &DTM->getSubtarget<X86Subtarget>();
124 bool is64Bit = Subtarget->is64Bit();
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000125
126 AlignmentIsInBytes = false;
127 TextAlignFillValue = 0x90;
128 GlobalPrefix = "_";
129 if (!is64Bit)
130 Data64bitsDirective = 0; // we can't emit a 64-bit unit
131 ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
132 PrivateGlobalPrefix = "L"; // Marker for constant pool idxs
Dale Johannesenb2dfb892008-09-09 01:21:22 +0000133 LessPrivateGlobalPrefix = "l"; // Marker for some ObjC metadata
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000134 BSSSection = 0; // no BSS section.
135 ZeroFillDirective = "\t.zerofill\t"; // Uses .zerofill
Anton Korobeynikov18f6ed92008-07-19 13:15:21 +0000136 if (DTM->getRelocationModel() != Reloc::Static)
Anton Korobeynikov7705ea32008-07-09 21:54:26 +0000137 ConstantPoolSection = "\t.const_data";
138 else
139 ConstantPoolSection = "\t.const\n";
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000140 JumpTableDataSection = "\t.const\n";
141 CStringSection = "\t.cstring";
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000142 // FIXME: Why don't always use this section?
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +0000143 if (is64Bit) {
Anton Korobeynikov64818732008-09-24 22:18:54 +0000144 SixteenByteConstantSection = getUnnamedSection("\t.literal16\n",
145 SectionFlags::Mergeable);
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +0000146 }
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000147 LCOMMDirective = "\t.lcomm\t";
148 SwitchToSectionDirective = "\t.section ";
149 StringConstantPrefix = "\1LC";
Anton Korobeynikov16b7f512008-08-08 18:25:52 +0000150 // Leopard and above support aligned common symbols.
151 COMMDirectiveTakesAlignment = (Subtarget->getDarwinVers() >= 9);
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000152 HasDotTypeDotSizeDirective = false;
153 if (TM.getRelocationModel() == Reloc::Static) {
154 StaticCtorsSection = ".constructor";
155 StaticDtorsSection = ".destructor";
156 } else {
157 StaticCtorsSection = ".mod_init_func";
158 StaticDtorsSection = ".mod_term_func";
159 }
160 if (is64Bit) {
161 PersonalityPrefix = "";
162 PersonalitySuffix = "+4@GOTPCREL";
163 } else {
164 PersonalityPrefix = "L";
165 PersonalitySuffix = "$non_lazy_ptr";
166 }
167 NeedsIndirectEncoding = true;
168 InlineAsmStart = "## InlineAsm Start";
169 InlineAsmEnd = "## InlineAsm End";
170 CommentString = "##";
171 SetDirective = "\t.set";
172 PCSymbol = ".";
173 UsedDirective = "\t.no_dead_strip\t";
174 WeakDefDirective = "\t.weak_definition ";
175 WeakRefDirective = "\t.weak_reference ";
176 HiddenDirective = "\t.private_extern ";
177 ProtectedDirective = "\t.globl\t";
178
179 // In non-PIC modes, emit a special label before jump tables so that the
180 // linker can perform more accurate dead code stripping.
181 if (TM.getRelocationModel() != Reloc::PIC_) {
182 // Emit a local label that is preserved until the linker runs.
183 JumpTableSpecialLabelPrefix = "l";
184 }
185
186 SupportsDebugInformation = true;
187 NeedsSet = true;
188 DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug";
189 DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug";
190 DwarfLineSection = ".section __DWARF,__debug_line,regular,debug";
191 DwarfFrameSection = ".section __DWARF,__debug_frame,regular,debug";
192 DwarfPubNamesSection = ".section __DWARF,__debug_pubnames,regular,debug";
193 DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes,regular,debug";
194 DwarfStrSection = ".section __DWARF,__debug_str,regular,debug";
195 DwarfLocSection = ".section __DWARF,__debug_loc,regular,debug";
196 DwarfARangesSection = ".section __DWARF,__debug_aranges,regular,debug";
197 DwarfRangesSection = ".section __DWARF,__debug_ranges,regular,debug";
198 DwarfMacInfoSection = ".section __DWARF,__debug_macinfo,regular,debug";
199
200 // Exceptions handling
201 SupportsExceptionHandling = true;
202 GlobalEHDirective = "\t.globl\t";
203 SupportsWeakOmittedEHFrame = false;
204 AbsoluteEHSectionOffsets = false;
205 DwarfEHFrameSection =
206 ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support";
207 DwarfExceptionSection = ".section __DATA,__gcc_except_tab";
208}
209
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000210unsigned
211X86DarwinTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
212 bool Global) const {
213 if (Reason == DwarfEncoding::Functions && Global)
214 return (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4);
215 else if (Reason == DwarfEncoding::CodeLabels || !Global)
216 return DW_EH_PE_pcrel;
217 else
218 return DW_EH_PE_absptr;
219}
220
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000221X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const X86TargetMachine &TM):
Anton Korobeynikov84903222008-09-24 22:21:39 +0000222 X86TargetAsmInfo<ELFTargetAsmInfo>(TM) {
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +0000223
Anton Korobeynikovb20015b2008-07-09 13:25:26 +0000224 CStringSection = ".rodata.str";
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000225 PrivateGlobalPrefix = ".L";
226 WeakRefDirective = "\t.weak\t";
227 SetDirective = "\t.set\t";
228 PCSymbol = ".";
229
230 // Set up DWARF directives
231 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
232
233 // Debug Information
234 AbsoluteDebugSectionOffsets = true;
235 SupportsDebugInformation = true;
236 DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"\",@progbits";
237 DwarfInfoSection = "\t.section\t.debug_info,\"\",@progbits";
238 DwarfLineSection = "\t.section\t.debug_line,\"\",@progbits";
239 DwarfFrameSection = "\t.section\t.debug_frame,\"\",@progbits";
240 DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"\",@progbits";
241 DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"\",@progbits";
242 DwarfStrSection = "\t.section\t.debug_str,\"\",@progbits";
243 DwarfLocSection = "\t.section\t.debug_loc,\"\",@progbits";
244 DwarfARangesSection = "\t.section\t.debug_aranges,\"\",@progbits";
245 DwarfRangesSection = "\t.section\t.debug_ranges,\"\",@progbits";
246 DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"\",@progbits";
247
248 // Exceptions handling
Anton Korobeynikovc4da15a2008-09-08 21:13:08 +0000249 SupportsExceptionHandling = true;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000250 AbsoluteEHSectionOffsets = false;
251 DwarfEHFrameSection = "\t.section\t.eh_frame,\"aw\",@progbits";
252 DwarfExceptionSection = "\t.section\t.gcc_except_table,\"a\",@progbits";
253
254 // On Linux we must declare when we can use a non-executable stack.
Anton Korobeynikov18f6ed92008-07-19 13:15:21 +0000255 if (ETM->getSubtarget<X86Subtarget>().isLinux())
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000256 NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\",@progbits";
257}
258
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000259unsigned
260X86ELFTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
261 bool Global) const {
Anton Korobeynikov18f6ed92008-07-19 13:15:21 +0000262 CodeModel::Model CM = ETM->getCodeModel();
263 bool is64Bit = ETM->getSubtarget<X86Subtarget>().is64Bit();
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000264
Anton Korobeynikov18f6ed92008-07-19 13:15:21 +0000265 if (ETM->getRelocationModel() == Reloc::PIC_) {
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000266 unsigned Format = 0;
267
268 if (!is64Bit)
269 // 32 bit targets always encode pointers as 4 bytes
270 Format = DW_EH_PE_sdata4;
271 else {
272 // 64 bit targets encode pointers in 4 bytes iff:
273 // - code model is small OR
274 // - code model is medium and we're emitting externally visible symbols
275 // or any code symbols
276 if (CM == CodeModel::Small ||
277 (CM == CodeModel::Medium && (Global ||
278 Reason != DwarfEncoding::Data)))
279 Format = DW_EH_PE_sdata4;
280 else
281 Format = DW_EH_PE_sdata8;
282 }
283
284 if (Global)
285 Format |= DW_EH_PE_indirect;
286
287 return (Format | DW_EH_PE_pcrel);
288 } else {
289 if (is64Bit &&
290 (CM == CodeModel::Small ||
291 (CM == CodeModel::Medium && Reason != DwarfEncoding::Data)))
292 return DW_EH_PE_udata4;
293 else
294 return DW_EH_PE_absptr;
295 }
296}
297
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000298X86COFFTargetAsmInfo::X86COFFTargetAsmInfo(const X86TargetMachine &TM):
Anton Korobeynikov84903222008-09-24 22:21:39 +0000299 X86GenericTargetAsmInfo(TM) {
Anton Korobeynikov18f6ed92008-07-19 13:15:21 +0000300 X86TM = &TM;
301
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000302 GlobalPrefix = "_";
303 LCOMMDirective = "\t.lcomm\t";
304 COMMDirectiveTakesAlignment = false;
305 HasDotTypeDotSizeDirective = false;
306 StaticCtorsSection = "\t.section .ctors,\"aw\"";
307 StaticDtorsSection = "\t.section .dtors,\"aw\"";
308 HiddenDirective = NULL;
309 PrivateGlobalPrefix = "L"; // Prefix for private global symbols
310 WeakRefDirective = "\t.weak\t";
311 SetDirective = "\t.set\t";
312
313 // Set up DWARF directives
314 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
315 AbsoluteDebugSectionOffsets = true;
316 AbsoluteEHSectionOffsets = false;
317 SupportsDebugInformation = true;
318 DwarfSectionOffsetDirective = "\t.secrel32\t";
319 DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"dr\"";
320 DwarfInfoSection = "\t.section\t.debug_info,\"dr\"";
321 DwarfLineSection = "\t.section\t.debug_line,\"dr\"";
322 DwarfFrameSection = "\t.section\t.debug_frame,\"dr\"";
323 DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"dr\"";
324 DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"dr\"";
325 DwarfStrSection = "\t.section\t.debug_str,\"dr\"";
326 DwarfLocSection = "\t.section\t.debug_loc,\"dr\"";
327 DwarfARangesSection = "\t.section\t.debug_aranges,\"dr\"";
328 DwarfRangesSection = "\t.section\t.debug_ranges,\"dr\"";
329 DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"dr\"";
330}
331
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000332unsigned
333X86COFFTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
334 bool Global) const {
335 CodeModel::Model CM = X86TM->getCodeModel();
336 bool is64Bit = X86TM->getSubtarget<X86Subtarget>().is64Bit();
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000337
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000338 if (X86TM->getRelocationModel() == Reloc::PIC_) {
339 unsigned Format = 0;
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000340
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000341 if (!is64Bit)
342 // 32 bit targets always encode pointers as 4 bytes
343 Format = DW_EH_PE_sdata4;
344 else {
345 // 64 bit targets encode pointers in 4 bytes iff:
346 // - code model is small OR
347 // - code model is medium and we're emitting externally visible symbols
348 // or any code symbols
349 if (CM == CodeModel::Small ||
350 (CM == CodeModel::Medium && (Global ||
351 Reason != DwarfEncoding::Data)))
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000352 Format = DW_EH_PE_sdata4;
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000353 else
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000354 Format = DW_EH_PE_sdata8;
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000355 }
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000356
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000357 if (Global)
358 Format |= DW_EH_PE_indirect;
359
360 return (Format | DW_EH_PE_pcrel);
361 } else {
362 if (is64Bit &&
363 (CM == CodeModel::Small ||
364 (CM == CodeModel::Medium && Reason != DwarfEncoding::Data)))
365 return DW_EH_PE_udata4;
366 else
367 return DW_EH_PE_absptr;
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000368 }
369}
370
Anton Korobeynikovb9a02fc2008-07-09 13:21:29 +0000371std::string
372X86COFFTargetAsmInfo::UniqueSectionForGlobal(const GlobalValue* GV,
373 SectionKind::Kind kind) const {
374 switch (kind) {
375 case SectionKind::Text:
376 return ".text$linkonce" + GV->getName();
377 case SectionKind::Data:
378 case SectionKind::BSS:
379 case SectionKind::ThreadData:
380 case SectionKind::ThreadBSS:
381 return ".data$linkonce" + GV->getName();
382 case SectionKind::ROData:
383 case SectionKind::RODataMergeConst:
384 case SectionKind::RODataMergeStr:
385 return ".rdata$linkonce" + GV->getName();
Anton Korobeynikov29b03f72008-07-09 13:19:38 +0000386 default:
Anton Korobeynikovb9a02fc2008-07-09 13:21:29 +0000387 assert(0 && "Unknown section kind");
Anton Korobeynikov29b03f72008-07-09 13:19:38 +0000388 }
389}
390
Anton Korobeynikovd0c1e292008-08-16 12:57:07 +0000391std::string X86COFFTargetAsmInfo::printSectionFlags(unsigned flags) const {
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000392 std::string Flags = ",\"";
393
394 if (flags & SectionFlags::Code)
395 Flags += 'x';
396 if (flags & SectionFlags::Writeable)
397 Flags += 'w';
398
399 Flags += "\"";
400
401 return Flags;
402}
403
404X86WinTargetAsmInfo::X86WinTargetAsmInfo(const X86TargetMachine &TM):
Anton Korobeynikov84903222008-09-24 22:21:39 +0000405 X86GenericTargetAsmInfo(TM) {
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000406 GlobalPrefix = "_";
407 CommentString = ";";
408
409 PrivateGlobalPrefix = "$";
410 AlignDirective = "\talign\t";
411 ZeroDirective = "\tdb\t";
412 ZeroDirectiveSuffix = " dup(0)";
413 AsciiDirective = "\tdb\t";
414 AscizDirective = 0;
415 Data8bitsDirective = "\tdb\t";
416 Data16bitsDirective = "\tdw\t";
417 Data32bitsDirective = "\tdd\t";
418 Data64bitsDirective = "\tdq\t";
419 HasDotTypeDotSizeDirective = false;
420
Anton Korobeynikovd7ca4162008-09-24 22:15:21 +0000421 TextSection = getUnnamedSection("_text", SectionFlags::Code);
Anton Korobeynikov315690e2008-09-24 22:16:16 +0000422 DataSection = getUnnamedSection("_data", SectionFlags::Writeable);
423
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000424 JumpTableDataSection = NULL;
425 SwitchToSectionDirective = "";
426 TextSectionStartSuffix = "\tsegment 'CODE'";
427 DataSectionStartSuffix = "\tsegment 'DATA'";
428 SectionEndDirectiveSuffix = "\tends\n";
429}