blob: a8930b8f224a1d1a60045ee3a683e2ff3ae66529 [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 Korobeynikov742fd192008-09-24 22:22:54 +000040TEMPLATE_INSTANTIATION(class X86TargetAsmInfo<TargetAsmInfo>);
41
Anton Korobeynikov84903222008-09-24 22:21:39 +000042template <class BaseTAI>
43bool X86TargetAsmInfo<BaseTAI>::LowerToBSwap(CallInst *CI) const {
Chris Lattner625bd052006-11-29 01:14:06 +000044 // FIXME: this should verify that we are targetting a 486 or better. If not,
45 // we will turn this bswap into something that will be lowered to logical ops
46 // instead of emitting the bswap asm. For now, we don't support 486 or lower
47 // so don't worry about this.
Anton Korobeynikov82100452008-07-09 13:20:27 +000048
Chris Lattner625bd052006-11-29 01:14:06 +000049 // Verify this is a simple bswap.
50 if (CI->getNumOperands() != 2 ||
51 CI->getType() != CI->getOperand(1)->getType() ||
Chris Lattner42a75512007-01-15 02:27:26 +000052 !CI->getType()->isInteger())
Chris Lattner625bd052006-11-29 01:14:06 +000053 return false;
Anton Korobeynikov82100452008-07-09 13:20:27 +000054
Chris Lattner3e9f1d02007-04-01 20:49:36 +000055 const IntegerType *Ty = dyn_cast<IntegerType>(CI->getType());
56 if (!Ty || Ty->getBitWidth() % 16 != 0)
Reid Spencera54b7cb2007-01-12 07:05:14 +000057 return false;
Anton Korobeynikov82100452008-07-09 13:20:27 +000058
Chris Lattner625bd052006-11-29 01:14:06 +000059 // Okay, we can do this xform, do so now.
Chandler Carruth69940402007-08-04 01:51:18 +000060 const Type *Tys[] = { Ty };
Chris Lattner625bd052006-11-29 01:14:06 +000061 Module *M = CI->getParent()->getParent()->getParent();
Chandler Carruth69940402007-08-04 01:51:18 +000062 Constant *Int = Intrinsic::getDeclaration(M, Intrinsic::bswap, Tys, 1);
Anton Korobeynikov82100452008-07-09 13:20:27 +000063
Chris Lattner625bd052006-11-29 01:14:06 +000064 Value *Op = CI->getOperand(1);
Gabor Greif051a9502008-04-06 20:25:17 +000065 Op = CallInst::Create(Int, Op, CI->getName(), CI);
Anton Korobeynikov82100452008-07-09 13:20:27 +000066
Chris Lattner625bd052006-11-29 01:14:06 +000067 CI->replaceAllUsesWith(Op);
68 CI->eraseFromParent();
69 return true;
70}
71
Anton Korobeynikov84903222008-09-24 22:21:39 +000072template <class BaseTAI>
73bool X86TargetAsmInfo<BaseTAI>::ExpandInlineAsm(CallInst *CI) const {
Chris Lattner625bd052006-11-29 01:14:06 +000074 InlineAsm *IA = cast<InlineAsm>(CI->getCalledValue());
Chris Lattner5d521352006-11-29 01:48:01 +000075 std::vector<InlineAsm::ConstraintInfo> Constraints = IA->ParseConstraints();
Anton Korobeynikov82100452008-07-09 13:20:27 +000076
Chris Lattner625bd052006-11-29 01:14:06 +000077 std::string AsmStr = IA->getAsmString();
Anton Korobeynikov82100452008-07-09 13:20:27 +000078
Chris Lattner625bd052006-11-29 01:14:06 +000079 // TODO: should remove alternatives from the asmstring: "foo {a|b}" -> "foo a"
80 std::vector<std::string> AsmPieces;
81 SplitString(AsmStr, AsmPieces, "\n"); // ; as separator?
Anton Korobeynikov82100452008-07-09 13:20:27 +000082
Chris Lattner625bd052006-11-29 01:14:06 +000083 switch (AsmPieces.size()) {
Anton Korobeynikov82100452008-07-09 13:20:27 +000084 default: return false;
Chris Lattner625bd052006-11-29 01:14:06 +000085 case 1:
86 AsmStr = AsmPieces[0];
87 AsmPieces.clear();
88 SplitString(AsmStr, AsmPieces, " \t"); // Split with whitespace.
Anton Korobeynikov82100452008-07-09 13:20:27 +000089
Chris Lattner5d521352006-11-29 01:48:01 +000090 // bswap $0
Anton Korobeynikov82100452008-07-09 13:20:27 +000091 if (AsmPieces.size() == 2 &&
Chris Lattner625bd052006-11-29 01:14:06 +000092 AsmPieces[0] == "bswap" && AsmPieces[1] == "$0") {
93 // No need to check constraints, nothing other than the equivalent of
94 // "=r,0" would be valid here.
95 return LowerToBSwap(CI);
96 }
97 break;
Chris Lattner5d521352006-11-29 01:48:01 +000098 case 3:
Reid Spencer47857812006-12-31 05:55:36 +000099 if (CI->getType() == Type::Int64Ty && Constraints.size() >= 2 &&
Chris Lattner5d521352006-11-29 01:48:01 +0000100 Constraints[0].Codes.size() == 1 && Constraints[0].Codes[0] == "A" &&
101 Constraints[1].Codes.size() == 1 && Constraints[1].Codes[0] == "0") {
102 // bswap %eax / bswap %edx / xchgl %eax, %edx -> llvm.bswap.i64
103 std::vector<std::string> Words;
104 SplitString(AsmPieces[0], Words, " \t");
105 if (Words.size() == 2 && Words[0] == "bswap" && Words[1] == "%eax") {
106 Words.clear();
107 SplitString(AsmPieces[1], Words, " \t");
108 if (Words.size() == 2 && Words[0] == "bswap" && Words[1] == "%edx") {
109 Words.clear();
110 SplitString(AsmPieces[2], Words, " \t,");
111 if (Words.size() == 3 && Words[0] == "xchgl" && Words[1] == "%eax" &&
112 Words[2] == "%edx") {
113 return LowerToBSwap(CI);
114 }
115 }
116 }
117 }
118 break;
Chris Lattner625bd052006-11-29 01:14:06 +0000119 }
120 return false;
121}
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000122
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000123X86DarwinTargetAsmInfo::X86DarwinTargetAsmInfo(const X86TargetMachine &TM):
Anton Korobeynikov84903222008-09-24 22:21:39 +0000124 X86TargetAsmInfo<DarwinTargetAsmInfo>(TM) {
Anton Korobeynikov16b7f512008-08-08 18:25:52 +0000125 const X86Subtarget* Subtarget = &DTM->getSubtarget<X86Subtarget>();
126 bool is64Bit = Subtarget->is64Bit();
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000127
128 AlignmentIsInBytes = false;
129 TextAlignFillValue = 0x90;
130 GlobalPrefix = "_";
131 if (!is64Bit)
132 Data64bitsDirective = 0; // we can't emit a 64-bit unit
133 ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
134 PrivateGlobalPrefix = "L"; // Marker for constant pool idxs
Dale Johannesenb2dfb892008-09-09 01:21:22 +0000135 LessPrivateGlobalPrefix = "l"; // Marker for some ObjC metadata
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000136 BSSSection = 0; // no BSS section.
137 ZeroFillDirective = "\t.zerofill\t"; // Uses .zerofill
Anton Korobeynikov18f6ed92008-07-19 13:15:21 +0000138 if (DTM->getRelocationModel() != Reloc::Static)
Anton Korobeynikov7705ea32008-07-09 21:54:26 +0000139 ConstantPoolSection = "\t.const_data";
140 else
141 ConstantPoolSection = "\t.const\n";
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000142 JumpTableDataSection = "\t.const\n";
143 CStringSection = "\t.cstring";
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000144 // FIXME: Why don't always use this section?
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +0000145 if (is64Bit) {
Anton Korobeynikov64818732008-09-24 22:18:54 +0000146 SixteenByteConstantSection = getUnnamedSection("\t.literal16\n",
147 SectionFlags::Mergeable);
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +0000148 }
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000149 LCOMMDirective = "\t.lcomm\t";
150 SwitchToSectionDirective = "\t.section ";
151 StringConstantPrefix = "\1LC";
Anton Korobeynikov16b7f512008-08-08 18:25:52 +0000152 // Leopard and above support aligned common symbols.
153 COMMDirectiveTakesAlignment = (Subtarget->getDarwinVers() >= 9);
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000154 HasDotTypeDotSizeDirective = false;
155 if (TM.getRelocationModel() == Reloc::Static) {
156 StaticCtorsSection = ".constructor";
157 StaticDtorsSection = ".destructor";
158 } else {
159 StaticCtorsSection = ".mod_init_func";
160 StaticDtorsSection = ".mod_term_func";
161 }
162 if (is64Bit) {
163 PersonalityPrefix = "";
164 PersonalitySuffix = "+4@GOTPCREL";
165 } else {
166 PersonalityPrefix = "L";
167 PersonalitySuffix = "$non_lazy_ptr";
168 }
169 NeedsIndirectEncoding = true;
170 InlineAsmStart = "## InlineAsm Start";
171 InlineAsmEnd = "## InlineAsm End";
172 CommentString = "##";
173 SetDirective = "\t.set";
174 PCSymbol = ".";
175 UsedDirective = "\t.no_dead_strip\t";
176 WeakDefDirective = "\t.weak_definition ";
177 WeakRefDirective = "\t.weak_reference ";
178 HiddenDirective = "\t.private_extern ";
179 ProtectedDirective = "\t.globl\t";
180
181 // In non-PIC modes, emit a special label before jump tables so that the
182 // linker can perform more accurate dead code stripping.
183 if (TM.getRelocationModel() != Reloc::PIC_) {
184 // Emit a local label that is preserved until the linker runs.
185 JumpTableSpecialLabelPrefix = "l";
186 }
187
188 SupportsDebugInformation = true;
189 NeedsSet = true;
190 DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug";
191 DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug";
192 DwarfLineSection = ".section __DWARF,__debug_line,regular,debug";
193 DwarfFrameSection = ".section __DWARF,__debug_frame,regular,debug";
194 DwarfPubNamesSection = ".section __DWARF,__debug_pubnames,regular,debug";
195 DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes,regular,debug";
196 DwarfStrSection = ".section __DWARF,__debug_str,regular,debug";
197 DwarfLocSection = ".section __DWARF,__debug_loc,regular,debug";
198 DwarfARangesSection = ".section __DWARF,__debug_aranges,regular,debug";
199 DwarfRangesSection = ".section __DWARF,__debug_ranges,regular,debug";
200 DwarfMacInfoSection = ".section __DWARF,__debug_macinfo,regular,debug";
201
202 // Exceptions handling
203 SupportsExceptionHandling = true;
204 GlobalEHDirective = "\t.globl\t";
205 SupportsWeakOmittedEHFrame = false;
206 AbsoluteEHSectionOffsets = false;
207 DwarfEHFrameSection =
208 ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support";
209 DwarfExceptionSection = ".section __DATA,__gcc_except_tab";
210}
211
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000212unsigned
213X86DarwinTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
214 bool Global) const {
215 if (Reason == DwarfEncoding::Functions && Global)
216 return (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4);
217 else if (Reason == DwarfEncoding::CodeLabels || !Global)
218 return DW_EH_PE_pcrel;
219 else
220 return DW_EH_PE_absptr;
221}
222
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000223X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const X86TargetMachine &TM):
Anton Korobeynikov84903222008-09-24 22:21:39 +0000224 X86TargetAsmInfo<ELFTargetAsmInfo>(TM) {
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +0000225
Anton Korobeynikovb20015b2008-07-09 13:25:26 +0000226 CStringSection = ".rodata.str";
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000227 PrivateGlobalPrefix = ".L";
228 WeakRefDirective = "\t.weak\t";
229 SetDirective = "\t.set\t";
230 PCSymbol = ".";
231
232 // Set up DWARF directives
233 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
234
235 // Debug Information
236 AbsoluteDebugSectionOffsets = true;
237 SupportsDebugInformation = true;
238 DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"\",@progbits";
239 DwarfInfoSection = "\t.section\t.debug_info,\"\",@progbits";
240 DwarfLineSection = "\t.section\t.debug_line,\"\",@progbits";
241 DwarfFrameSection = "\t.section\t.debug_frame,\"\",@progbits";
242 DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"\",@progbits";
243 DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"\",@progbits";
244 DwarfStrSection = "\t.section\t.debug_str,\"\",@progbits";
245 DwarfLocSection = "\t.section\t.debug_loc,\"\",@progbits";
246 DwarfARangesSection = "\t.section\t.debug_aranges,\"\",@progbits";
247 DwarfRangesSection = "\t.section\t.debug_ranges,\"\",@progbits";
248 DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"\",@progbits";
249
250 // Exceptions handling
Anton Korobeynikovc4da15a2008-09-08 21:13:08 +0000251 SupportsExceptionHandling = true;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000252 AbsoluteEHSectionOffsets = false;
253 DwarfEHFrameSection = "\t.section\t.eh_frame,\"aw\",@progbits";
254 DwarfExceptionSection = "\t.section\t.gcc_except_table,\"a\",@progbits";
255
256 // On Linux we must declare when we can use a non-executable stack.
Anton Korobeynikov18f6ed92008-07-19 13:15:21 +0000257 if (ETM->getSubtarget<X86Subtarget>().isLinux())
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000258 NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\",@progbits";
259}
260
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000261unsigned
262X86ELFTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
263 bool Global) const {
Anton Korobeynikov18f6ed92008-07-19 13:15:21 +0000264 CodeModel::Model CM = ETM->getCodeModel();
265 bool is64Bit = ETM->getSubtarget<X86Subtarget>().is64Bit();
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000266
Anton Korobeynikov18f6ed92008-07-19 13:15:21 +0000267 if (ETM->getRelocationModel() == Reloc::PIC_) {
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000268 unsigned Format = 0;
269
270 if (!is64Bit)
271 // 32 bit targets always encode pointers as 4 bytes
272 Format = DW_EH_PE_sdata4;
273 else {
274 // 64 bit targets encode pointers in 4 bytes iff:
275 // - code model is small OR
276 // - code model is medium and we're emitting externally visible symbols
277 // or any code symbols
278 if (CM == CodeModel::Small ||
279 (CM == CodeModel::Medium && (Global ||
280 Reason != DwarfEncoding::Data)))
281 Format = DW_EH_PE_sdata4;
282 else
283 Format = DW_EH_PE_sdata8;
284 }
285
286 if (Global)
287 Format |= DW_EH_PE_indirect;
288
289 return (Format | DW_EH_PE_pcrel);
290 } else {
291 if (is64Bit &&
292 (CM == CodeModel::Small ||
293 (CM == CodeModel::Medium && Reason != DwarfEncoding::Data)))
294 return DW_EH_PE_udata4;
295 else
296 return DW_EH_PE_absptr;
297 }
298}
299
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000300X86COFFTargetAsmInfo::X86COFFTargetAsmInfo(const X86TargetMachine &TM):
Anton Korobeynikov84903222008-09-24 22:21:39 +0000301 X86GenericTargetAsmInfo(TM) {
Anton Korobeynikov18f6ed92008-07-19 13:15:21 +0000302 X86TM = &TM;
303
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000304 GlobalPrefix = "_";
305 LCOMMDirective = "\t.lcomm\t";
306 COMMDirectiveTakesAlignment = false;
307 HasDotTypeDotSizeDirective = false;
308 StaticCtorsSection = "\t.section .ctors,\"aw\"";
309 StaticDtorsSection = "\t.section .dtors,\"aw\"";
310 HiddenDirective = NULL;
311 PrivateGlobalPrefix = "L"; // Prefix for private global symbols
312 WeakRefDirective = "\t.weak\t";
313 SetDirective = "\t.set\t";
314
315 // Set up DWARF directives
316 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
317 AbsoluteDebugSectionOffsets = true;
318 AbsoluteEHSectionOffsets = false;
319 SupportsDebugInformation = true;
320 DwarfSectionOffsetDirective = "\t.secrel32\t";
321 DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"dr\"";
322 DwarfInfoSection = "\t.section\t.debug_info,\"dr\"";
323 DwarfLineSection = "\t.section\t.debug_line,\"dr\"";
324 DwarfFrameSection = "\t.section\t.debug_frame,\"dr\"";
325 DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"dr\"";
326 DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"dr\"";
327 DwarfStrSection = "\t.section\t.debug_str,\"dr\"";
328 DwarfLocSection = "\t.section\t.debug_loc,\"dr\"";
329 DwarfARangesSection = "\t.section\t.debug_aranges,\"dr\"";
330 DwarfRangesSection = "\t.section\t.debug_ranges,\"dr\"";
331 DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"dr\"";
332}
333
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000334unsigned
335X86COFFTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
336 bool Global) const {
337 CodeModel::Model CM = X86TM->getCodeModel();
338 bool is64Bit = X86TM->getSubtarget<X86Subtarget>().is64Bit();
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000339
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000340 if (X86TM->getRelocationModel() == Reloc::PIC_) {
341 unsigned Format = 0;
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000342
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000343 if (!is64Bit)
344 // 32 bit targets always encode pointers as 4 bytes
345 Format = DW_EH_PE_sdata4;
346 else {
347 // 64 bit targets encode pointers in 4 bytes iff:
348 // - code model is small OR
349 // - code model is medium and we're emitting externally visible symbols
350 // or any code symbols
351 if (CM == CodeModel::Small ||
352 (CM == CodeModel::Medium && (Global ||
353 Reason != DwarfEncoding::Data)))
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000354 Format = DW_EH_PE_sdata4;
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000355 else
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000356 Format = DW_EH_PE_sdata8;
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000357 }
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000358
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000359 if (Global)
360 Format |= DW_EH_PE_indirect;
361
362 return (Format | DW_EH_PE_pcrel);
363 } else {
364 if (is64Bit &&
365 (CM == CodeModel::Small ||
366 (CM == CodeModel::Medium && Reason != DwarfEncoding::Data)))
367 return DW_EH_PE_udata4;
368 else
369 return DW_EH_PE_absptr;
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000370 }
371}
372
Anton Korobeynikovb9a02fc2008-07-09 13:21:29 +0000373std::string
374X86COFFTargetAsmInfo::UniqueSectionForGlobal(const GlobalValue* GV,
375 SectionKind::Kind kind) const {
376 switch (kind) {
377 case SectionKind::Text:
378 return ".text$linkonce" + GV->getName();
379 case SectionKind::Data:
380 case SectionKind::BSS:
381 case SectionKind::ThreadData:
382 case SectionKind::ThreadBSS:
383 return ".data$linkonce" + GV->getName();
384 case SectionKind::ROData:
385 case SectionKind::RODataMergeConst:
386 case SectionKind::RODataMergeStr:
387 return ".rdata$linkonce" + GV->getName();
Anton Korobeynikov29b03f72008-07-09 13:19:38 +0000388 default:
Anton Korobeynikovb9a02fc2008-07-09 13:21:29 +0000389 assert(0 && "Unknown section kind");
Anton Korobeynikov29b03f72008-07-09 13:19:38 +0000390 }
391}
392
Anton Korobeynikovd0c1e292008-08-16 12:57:07 +0000393std::string X86COFFTargetAsmInfo::printSectionFlags(unsigned flags) const {
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000394 std::string Flags = ",\"";
395
396 if (flags & SectionFlags::Code)
397 Flags += 'x';
398 if (flags & SectionFlags::Writeable)
399 Flags += 'w';
400
401 Flags += "\"";
402
403 return Flags;
404}
405
406X86WinTargetAsmInfo::X86WinTargetAsmInfo(const X86TargetMachine &TM):
Anton Korobeynikov84903222008-09-24 22:21:39 +0000407 X86GenericTargetAsmInfo(TM) {
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000408 GlobalPrefix = "_";
409 CommentString = ";";
410
411 PrivateGlobalPrefix = "$";
412 AlignDirective = "\talign\t";
413 ZeroDirective = "\tdb\t";
414 ZeroDirectiveSuffix = " dup(0)";
415 AsciiDirective = "\tdb\t";
416 AscizDirective = 0;
417 Data8bitsDirective = "\tdb\t";
418 Data16bitsDirective = "\tdw\t";
419 Data32bitsDirective = "\tdd\t";
420 Data64bitsDirective = "\tdq\t";
421 HasDotTypeDotSizeDirective = false;
422
Anton Korobeynikovd7ca4162008-09-24 22:15:21 +0000423 TextSection = getUnnamedSection("_text", SectionFlags::Code);
Anton Korobeynikov315690e2008-09-24 22:16:16 +0000424 DataSection = getUnnamedSection("_data", SectionFlags::Writeable);
425
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000426 JumpTableDataSection = NULL;
427 SwitchToSectionDirective = "";
428 TextSectionStartSuffix = "\tsegment 'CODE'";
429 DataSectionStartSuffix = "\tsegment 'DATA'";
430 SectionEndDirectiveSuffix = "\tends\n";
431}