blob: 0e634c6eb9fa2f2a9e0767d646e3c8492f8e9278 [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
Dan Gohmancfbb2f02008-03-25 21:45:14 +000028static const char *const x86_asm_table[] = {
29 "{si}", "S",
Andrew Lenharth6c0695f2006-11-28 19:52:49 +000030 "{di}", "D",
31 "{ax}", "a",
32 "{cx}", "c",
Andrew Lenharth6c0695f2006-11-28 19:52:49 +000033 "{memory}", "memory",
34 "{flags}", "",
35 "{dirflag}", "",
36 "{fpsr}", "",
37 "{cc}", "cc",
38 0,0};
39
Jim Laskey8e8de8f2006-09-07 22:05:02 +000040X86TargetAsmInfo::X86TargetAsmInfo(const X86TargetMachine &TM) {
41 const X86Subtarget *Subtarget = &TM.getSubtarget<X86Subtarget>();
Anton Korobeynikovcee750f2008-02-27 23:33:50 +000042
Andrew Lenharth6c0695f2006-11-28 19:52:49 +000043 AsmTransCBE = x86_asm_table;
Anton Korobeynikov82100452008-07-09 13:20:27 +000044
Bill Wendlingcb900992007-01-16 09:29:17 +000045 AssemblerDialect = Subtarget->getAsmFlavor();
Jim Laskey8e8de8f2006-09-07 22:05:02 +000046}
Chris Lattnerafbfded2006-10-05 02:43:52 +000047
Chris Lattner625bd052006-11-29 01:14:06 +000048bool X86TargetAsmInfo::LowerToBSwap(CallInst *CI) const {
49 // FIXME: this should verify that we are targetting a 486 or better. If not,
50 // we will turn this bswap into something that will be lowered to logical ops
51 // instead of emitting the bswap asm. For now, we don't support 486 or lower
52 // so don't worry about this.
Anton Korobeynikov82100452008-07-09 13:20:27 +000053
Chris Lattner625bd052006-11-29 01:14:06 +000054 // Verify this is a simple bswap.
55 if (CI->getNumOperands() != 2 ||
56 CI->getType() != CI->getOperand(1)->getType() ||
Chris Lattner42a75512007-01-15 02:27:26 +000057 !CI->getType()->isInteger())
Chris Lattner625bd052006-11-29 01:14:06 +000058 return false;
Anton Korobeynikov82100452008-07-09 13:20:27 +000059
Chris Lattner3e9f1d02007-04-01 20:49:36 +000060 const IntegerType *Ty = dyn_cast<IntegerType>(CI->getType());
61 if (!Ty || Ty->getBitWidth() % 16 != 0)
Reid Spencera54b7cb2007-01-12 07:05:14 +000062 return false;
Anton Korobeynikov82100452008-07-09 13:20:27 +000063
Chris Lattner625bd052006-11-29 01:14:06 +000064 // Okay, we can do this xform, do so now.
Chandler Carruth69940402007-08-04 01:51:18 +000065 const Type *Tys[] = { Ty };
Chris Lattner625bd052006-11-29 01:14:06 +000066 Module *M = CI->getParent()->getParent()->getParent();
Chandler Carruth69940402007-08-04 01:51:18 +000067 Constant *Int = Intrinsic::getDeclaration(M, Intrinsic::bswap, Tys, 1);
Anton Korobeynikov82100452008-07-09 13:20:27 +000068
Chris Lattner625bd052006-11-29 01:14:06 +000069 Value *Op = CI->getOperand(1);
Gabor Greif051a9502008-04-06 20:25:17 +000070 Op = CallInst::Create(Int, Op, CI->getName(), CI);
Anton Korobeynikov82100452008-07-09 13:20:27 +000071
Chris Lattner625bd052006-11-29 01:14:06 +000072 CI->replaceAllUsesWith(Op);
73 CI->eraseFromParent();
74 return true;
75}
76
Chris Lattner625bd052006-11-29 01:14:06 +000077bool X86TargetAsmInfo::ExpandInlineAsm(CallInst *CI) const {
78 InlineAsm *IA = cast<InlineAsm>(CI->getCalledValue());
Chris Lattner5d521352006-11-29 01:48:01 +000079 std::vector<InlineAsm::ConstraintInfo> Constraints = IA->ParseConstraints();
Anton Korobeynikov82100452008-07-09 13:20:27 +000080
Chris Lattner625bd052006-11-29 01:14:06 +000081 std::string AsmStr = IA->getAsmString();
Anton Korobeynikov82100452008-07-09 13:20:27 +000082
Chris Lattner625bd052006-11-29 01:14:06 +000083 // TODO: should remove alternatives from the asmstring: "foo {a|b}" -> "foo a"
84 std::vector<std::string> AsmPieces;
85 SplitString(AsmStr, AsmPieces, "\n"); // ; as separator?
Anton Korobeynikov82100452008-07-09 13:20:27 +000086
Chris Lattner625bd052006-11-29 01:14:06 +000087 switch (AsmPieces.size()) {
Anton Korobeynikov82100452008-07-09 13:20:27 +000088 default: return false;
Chris Lattner625bd052006-11-29 01:14:06 +000089 case 1:
90 AsmStr = AsmPieces[0];
91 AsmPieces.clear();
92 SplitString(AsmStr, AsmPieces, " \t"); // Split with whitespace.
Anton Korobeynikov82100452008-07-09 13:20:27 +000093
Chris Lattner5d521352006-11-29 01:48:01 +000094 // bswap $0
Anton Korobeynikov82100452008-07-09 13:20:27 +000095 if (AsmPieces.size() == 2 &&
Chris Lattner625bd052006-11-29 01:14:06 +000096 AsmPieces[0] == "bswap" && AsmPieces[1] == "$0") {
97 // No need to check constraints, nothing other than the equivalent of
98 // "=r,0" would be valid here.
99 return LowerToBSwap(CI);
100 }
101 break;
Chris Lattner5d521352006-11-29 01:48:01 +0000102 case 3:
Reid Spencer47857812006-12-31 05:55:36 +0000103 if (CI->getType() == Type::Int64Ty && Constraints.size() >= 2 &&
Chris Lattner5d521352006-11-29 01:48:01 +0000104 Constraints[0].Codes.size() == 1 && Constraints[0].Codes[0] == "A" &&
105 Constraints[1].Codes.size() == 1 && Constraints[1].Codes[0] == "0") {
106 // bswap %eax / bswap %edx / xchgl %eax, %edx -> llvm.bswap.i64
107 std::vector<std::string> Words;
108 SplitString(AsmPieces[0], Words, " \t");
109 if (Words.size() == 2 && Words[0] == "bswap" && Words[1] == "%eax") {
110 Words.clear();
111 SplitString(AsmPieces[1], Words, " \t");
112 if (Words.size() == 2 && Words[0] == "bswap" && Words[1] == "%edx") {
113 Words.clear();
114 SplitString(AsmPieces[2], Words, " \t,");
115 if (Words.size() == 3 && Words[0] == "xchgl" && Words[1] == "%eax" &&
116 Words[2] == "%edx") {
117 return LowerToBSwap(CI);
118 }
119 }
120 }
121 }
122 break;
Chris Lattner625bd052006-11-29 01:14:06 +0000123 }
124 return false;
125}
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000126
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000127X86DarwinTargetAsmInfo::X86DarwinTargetAsmInfo(const X86TargetMachine &TM):
Anton Korobeynikov18f6ed92008-07-19 13:15:21 +0000128 X86TargetAsmInfo(TM), DarwinTargetAsmInfo(TM) {
129 bool is64Bit = DTM->getSubtarget<X86Subtarget>().is64Bit();
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000130
131 AlignmentIsInBytes = false;
132 TextAlignFillValue = 0x90;
133 GlobalPrefix = "_";
134 if (!is64Bit)
135 Data64bitsDirective = 0; // we can't emit a 64-bit unit
136 ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
137 PrivateGlobalPrefix = "L"; // Marker for constant pool idxs
138 BSSSection = 0; // no BSS section.
139 ZeroFillDirective = "\t.zerofill\t"; // Uses .zerofill
Anton Korobeynikov18f6ed92008-07-19 13:15:21 +0000140 if (DTM->getRelocationModel() != Reloc::Static)
Anton Korobeynikov7705ea32008-07-09 21:54:26 +0000141 ConstantPoolSection = "\t.const_data";
142 else
143 ConstantPoolSection = "\t.const\n";
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000144 JumpTableDataSection = "\t.const\n";
145 CStringSection = "\t.cstring";
146 FourByteConstantSection = "\t.literal4\n";
Anton Korobeynikovb126f3b2008-07-09 20:47:55 +0000147 EightByteConstantSection = "\t.literal8\n";
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000148 // FIXME: Why don't always use this section?
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +0000149 if (is64Bit) {
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000150 SixteenByteConstantSection = "\t.literal16\n";
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +0000151 }
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000152 ReadOnlySection = "\t.const\n";
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +0000153
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000154 LCOMMDirective = "\t.lcomm\t";
155 SwitchToSectionDirective = "\t.section ";
156 StringConstantPrefix = "\1LC";
157 COMMDirectiveTakesAlignment = false;
158 HasDotTypeDotSizeDirective = false;
159 if (TM.getRelocationModel() == Reloc::Static) {
160 StaticCtorsSection = ".constructor";
161 StaticDtorsSection = ".destructor";
162 } else {
163 StaticCtorsSection = ".mod_init_func";
164 StaticDtorsSection = ".mod_term_func";
165 }
166 if (is64Bit) {
167 PersonalityPrefix = "";
168 PersonalitySuffix = "+4@GOTPCREL";
169 } else {
170 PersonalityPrefix = "L";
171 PersonalitySuffix = "$non_lazy_ptr";
172 }
173 NeedsIndirectEncoding = true;
174 InlineAsmStart = "## InlineAsm Start";
175 InlineAsmEnd = "## InlineAsm End";
176 CommentString = "##";
177 SetDirective = "\t.set";
178 PCSymbol = ".";
179 UsedDirective = "\t.no_dead_strip\t";
180 WeakDefDirective = "\t.weak_definition ";
181 WeakRefDirective = "\t.weak_reference ";
182 HiddenDirective = "\t.private_extern ";
183 ProtectedDirective = "\t.globl\t";
184
185 // In non-PIC modes, emit a special label before jump tables so that the
186 // linker can perform more accurate dead code stripping.
187 if (TM.getRelocationModel() != Reloc::PIC_) {
188 // Emit a local label that is preserved until the linker runs.
189 JumpTableSpecialLabelPrefix = "l";
190 }
191
192 SupportsDebugInformation = true;
193 NeedsSet = true;
194 DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug";
195 DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug";
196 DwarfLineSection = ".section __DWARF,__debug_line,regular,debug";
197 DwarfFrameSection = ".section __DWARF,__debug_frame,regular,debug";
198 DwarfPubNamesSection = ".section __DWARF,__debug_pubnames,regular,debug";
199 DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes,regular,debug";
200 DwarfStrSection = ".section __DWARF,__debug_str,regular,debug";
201 DwarfLocSection = ".section __DWARF,__debug_loc,regular,debug";
202 DwarfARangesSection = ".section __DWARF,__debug_aranges,regular,debug";
203 DwarfRangesSection = ".section __DWARF,__debug_ranges,regular,debug";
204 DwarfMacInfoSection = ".section __DWARF,__debug_macinfo,regular,debug";
205
206 // Exceptions handling
207 SupportsExceptionHandling = true;
208 GlobalEHDirective = "\t.globl\t";
209 SupportsWeakOmittedEHFrame = false;
210 AbsoluteEHSectionOffsets = false;
211 DwarfEHFrameSection =
212 ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support";
213 DwarfExceptionSection = ".section __DATA,__gcc_except_tab";
214}
215
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000216unsigned
217X86DarwinTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
218 bool Global) const {
219 if (Reason == DwarfEncoding::Functions && Global)
220 return (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4);
221 else if (Reason == DwarfEncoding::CodeLabels || !Global)
222 return DW_EH_PE_pcrel;
223 else
224 return DW_EH_PE_absptr;
225}
226
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000227X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const X86TargetMachine &TM):
Anton Korobeynikov18f6ed92008-07-19 13:15:21 +0000228 X86TargetAsmInfo(TM), ELFTargetAsmInfo(TM) {
229 bool is64Bit = ETM->getSubtarget<X86Subtarget>().is64Bit();
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +0000230
Anton Korobeynikovb20015b2008-07-09 13:25:26 +0000231 ReadOnlySection = ".rodata";
Anton Korobeynikov2a889172008-07-09 13:25:46 +0000232 FourByteConstantSection = "\t.section\t.rodata.cst4,\"aM\",@progbits,4";
233 EightByteConstantSection = "\t.section\t.rodata.cst8,\"aM\",@progbits,8";
234 SixteenByteConstantSection = "\t.section\t.rodata.cst16,\"aM\",@progbits,16";
Anton Korobeynikovb20015b2008-07-09 13:25:26 +0000235 CStringSection = ".rodata.str";
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000236 PrivateGlobalPrefix = ".L";
237 WeakRefDirective = "\t.weak\t";
238 SetDirective = "\t.set\t";
239 PCSymbol = ".";
240
241 // Set up DWARF directives
242 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
243
244 // Debug Information
245 AbsoluteDebugSectionOffsets = true;
246 SupportsDebugInformation = true;
247 DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"\",@progbits";
248 DwarfInfoSection = "\t.section\t.debug_info,\"\",@progbits";
249 DwarfLineSection = "\t.section\t.debug_line,\"\",@progbits";
250 DwarfFrameSection = "\t.section\t.debug_frame,\"\",@progbits";
251 DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"\",@progbits";
252 DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"\",@progbits";
253 DwarfStrSection = "\t.section\t.debug_str,\"\",@progbits";
254 DwarfLocSection = "\t.section\t.debug_loc,\"\",@progbits";
255 DwarfARangesSection = "\t.section\t.debug_aranges,\"\",@progbits";
256 DwarfRangesSection = "\t.section\t.debug_ranges,\"\",@progbits";
257 DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"\",@progbits";
258
259 // Exceptions handling
260 if (!is64Bit)
261 SupportsExceptionHandling = true;
262 AbsoluteEHSectionOffsets = false;
263 DwarfEHFrameSection = "\t.section\t.eh_frame,\"aw\",@progbits";
264 DwarfExceptionSection = "\t.section\t.gcc_except_table,\"a\",@progbits";
265
266 // On Linux we must declare when we can use a non-executable stack.
Anton Korobeynikov18f6ed92008-07-19 13:15:21 +0000267 if (ETM->getSubtarget<X86Subtarget>().isLinux())
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000268 NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\",@progbits";
269}
270
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000271unsigned
272X86ELFTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
273 bool Global) const {
Anton Korobeynikov18f6ed92008-07-19 13:15:21 +0000274 CodeModel::Model CM = ETM->getCodeModel();
275 bool is64Bit = ETM->getSubtarget<X86Subtarget>().is64Bit();
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000276
Anton Korobeynikov18f6ed92008-07-19 13:15:21 +0000277 if (ETM->getRelocationModel() == Reloc::PIC_) {
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000278 unsigned Format = 0;
279
280 if (!is64Bit)
281 // 32 bit targets always encode pointers as 4 bytes
282 Format = DW_EH_PE_sdata4;
283 else {
284 // 64 bit targets encode pointers in 4 bytes iff:
285 // - code model is small OR
286 // - code model is medium and we're emitting externally visible symbols
287 // or any code symbols
288 if (CM == CodeModel::Small ||
289 (CM == CodeModel::Medium && (Global ||
290 Reason != DwarfEncoding::Data)))
291 Format = DW_EH_PE_sdata4;
292 else
293 Format = DW_EH_PE_sdata8;
294 }
295
296 if (Global)
297 Format |= DW_EH_PE_indirect;
298
299 return (Format | DW_EH_PE_pcrel);
300 } else {
301 if (is64Bit &&
302 (CM == CodeModel::Small ||
303 (CM == CodeModel::Medium && Reason != DwarfEncoding::Data)))
304 return DW_EH_PE_udata4;
305 else
306 return DW_EH_PE_absptr;
307 }
308}
309
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000310X86COFFTargetAsmInfo::X86COFFTargetAsmInfo(const X86TargetMachine &TM):
311 X86TargetAsmInfo(TM) {
Anton Korobeynikov18f6ed92008-07-19 13:15:21 +0000312 X86TM = &TM;
313
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000314 GlobalPrefix = "_";
315 LCOMMDirective = "\t.lcomm\t";
316 COMMDirectiveTakesAlignment = false;
317 HasDotTypeDotSizeDirective = false;
318 StaticCtorsSection = "\t.section .ctors,\"aw\"";
319 StaticDtorsSection = "\t.section .dtors,\"aw\"";
320 HiddenDirective = NULL;
321 PrivateGlobalPrefix = "L"; // Prefix for private global symbols
322 WeakRefDirective = "\t.weak\t";
323 SetDirective = "\t.set\t";
324
325 // Set up DWARF directives
326 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
327 AbsoluteDebugSectionOffsets = true;
328 AbsoluteEHSectionOffsets = false;
329 SupportsDebugInformation = true;
330 DwarfSectionOffsetDirective = "\t.secrel32\t";
331 DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"dr\"";
332 DwarfInfoSection = "\t.section\t.debug_info,\"dr\"";
333 DwarfLineSection = "\t.section\t.debug_line,\"dr\"";
334 DwarfFrameSection = "\t.section\t.debug_frame,\"dr\"";
335 DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"dr\"";
336 DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"dr\"";
337 DwarfStrSection = "\t.section\t.debug_str,\"dr\"";
338 DwarfLocSection = "\t.section\t.debug_loc,\"dr\"";
339 DwarfARangesSection = "\t.section\t.debug_aranges,\"dr\"";
340 DwarfRangesSection = "\t.section\t.debug_ranges,\"dr\"";
341 DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"dr\"";
342}
343
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000344unsigned
345X86COFFTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
346 bool Global) const {
347 CodeModel::Model CM = X86TM->getCodeModel();
348 bool is64Bit = X86TM->getSubtarget<X86Subtarget>().is64Bit();
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000349
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000350 if (X86TM->getRelocationModel() == Reloc::PIC_) {
351 unsigned Format = 0;
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000352
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000353 if (!is64Bit)
354 // 32 bit targets always encode pointers as 4 bytes
355 Format = DW_EH_PE_sdata4;
356 else {
357 // 64 bit targets encode pointers in 4 bytes iff:
358 // - code model is small OR
359 // - code model is medium and we're emitting externally visible symbols
360 // or any code symbols
361 if (CM == CodeModel::Small ||
362 (CM == CodeModel::Medium && (Global ||
363 Reason != DwarfEncoding::Data)))
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000364 Format = DW_EH_PE_sdata4;
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000365 else
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000366 Format = DW_EH_PE_sdata8;
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000367 }
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000368
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000369 if (Global)
370 Format |= DW_EH_PE_indirect;
371
372 return (Format | DW_EH_PE_pcrel);
373 } else {
374 if (is64Bit &&
375 (CM == CodeModel::Small ||
376 (CM == CodeModel::Medium && Reason != DwarfEncoding::Data)))
377 return DW_EH_PE_udata4;
378 else
379 return DW_EH_PE_absptr;
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000380 }
381}
382
Anton Korobeynikovb9a02fc2008-07-09 13:21:29 +0000383std::string
384X86COFFTargetAsmInfo::UniqueSectionForGlobal(const GlobalValue* GV,
385 SectionKind::Kind kind) const {
386 switch (kind) {
387 case SectionKind::Text:
388 return ".text$linkonce" + GV->getName();
389 case SectionKind::Data:
390 case SectionKind::BSS:
391 case SectionKind::ThreadData:
392 case SectionKind::ThreadBSS:
393 return ".data$linkonce" + GV->getName();
394 case SectionKind::ROData:
395 case SectionKind::RODataMergeConst:
396 case SectionKind::RODataMergeStr:
397 return ".rdata$linkonce" + GV->getName();
Anton Korobeynikov29b03f72008-07-09 13:19:38 +0000398 default:
Anton Korobeynikovb9a02fc2008-07-09 13:21:29 +0000399 assert(0 && "Unknown section kind");
Anton Korobeynikov29b03f72008-07-09 13:19:38 +0000400 }
401}
402
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000403std::string X86COFFTargetAsmInfo::PrintSectionFlags(unsigned flags) const {
404 std::string Flags = ",\"";
405
406 if (flags & SectionFlags::Code)
407 Flags += 'x';
408 if (flags & SectionFlags::Writeable)
409 Flags += 'w';
410
411 Flags += "\"";
412
413 return Flags;
414}
415
416X86WinTargetAsmInfo::X86WinTargetAsmInfo(const X86TargetMachine &TM):
417 X86TargetAsmInfo(TM) {
418 GlobalPrefix = "_";
419 CommentString = ";";
420
421 PrivateGlobalPrefix = "$";
422 AlignDirective = "\talign\t";
423 ZeroDirective = "\tdb\t";
424 ZeroDirectiveSuffix = " dup(0)";
425 AsciiDirective = "\tdb\t";
426 AscizDirective = 0;
427 Data8bitsDirective = "\tdb\t";
428 Data16bitsDirective = "\tdw\t";
429 Data32bitsDirective = "\tdd\t";
430 Data64bitsDirective = "\tdq\t";
431 HasDotTypeDotSizeDirective = false;
432
433 TextSection = "_text";
434 DataSection = "_data";
435 JumpTableDataSection = NULL;
436 SwitchToSectionDirective = "";
437 TextSectionStartSuffix = "\tsegment 'CODE'";
438 DataSectionStartSuffix = "\tsegment 'DATA'";
439 SectionEndDirectiveSuffix = "\tends\n";
440}