blob: 4dfb214ec71fc7ffcf8bf6e5959c74d3e70a20f3 [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 Korobeynikov32b952a2008-09-25 21:00:33 +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 Korobeynikov4468b7a2008-07-09 13:20:48 +000040X86DarwinTargetAsmInfo::X86DarwinTargetAsmInfo(const X86TargetMachine &TM):
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000041 X86TargetAsmInfo<DarwinTargetAsmInfo>(TM) {
Dan Gohman8f092252008-11-03 18:22:42 +000042 const X86Subtarget* Subtarget = &TM.getSubtarget<X86Subtarget>();
Anton Korobeynikov16b7f512008-08-08 18:25:52 +000043 bool is64Bit = Subtarget->is64Bit();
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000044
45 AlignmentIsInBytes = false;
46 TextAlignFillValue = 0x90;
47 GlobalPrefix = "_";
48 if (!is64Bit)
49 Data64bitsDirective = 0; // we can't emit a 64-bit unit
50 ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
51 PrivateGlobalPrefix = "L"; // Marker for constant pool idxs
Dale Johannesenb2dfb892008-09-09 01:21:22 +000052 LessPrivateGlobalPrefix = "l"; // Marker for some ObjC metadata
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000053 BSSSection = 0; // no BSS section.
54 ZeroFillDirective = "\t.zerofill\t"; // Uses .zerofill
Dan Gohman8f092252008-11-03 18:22:42 +000055 if (TM.getRelocationModel() != Reloc::Static)
Anton Korobeynikov7705ea32008-07-09 21:54:26 +000056 ConstantPoolSection = "\t.const_data";
57 else
58 ConstantPoolSection = "\t.const\n";
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000059 JumpTableDataSection = "\t.const\n";
60 CStringSection = "\t.cstring";
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000061 // FIXME: Why don't always use this section?
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +000062 if (is64Bit) {
Anton Korobeynikov64818732008-09-24 22:18:54 +000063 SixteenByteConstantSection = getUnnamedSection("\t.literal16\n",
64 SectionFlags::Mergeable);
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +000065 }
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000066 LCOMMDirective = "\t.lcomm\t";
67 SwitchToSectionDirective = "\t.section ";
68 StringConstantPrefix = "\1LC";
Anton Korobeynikov16b7f512008-08-08 18:25:52 +000069 // Leopard and above support aligned common symbols.
70 COMMDirectiveTakesAlignment = (Subtarget->getDarwinVers() >= 9);
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000071 HasDotTypeDotSizeDirective = false;
Rafael Espindola952b8392008-12-03 11:01:37 +000072 HasSingleParameterDotFile = false;
Bill Wendlingd4121be2008-12-24 05:25:49 +000073 FDEEncodingRequiresSData4 = false;
Bill Wendling722f5f12008-12-24 08:05:17 +000074 NonLocalEHFrameLabel = true;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000075 if (TM.getRelocationModel() == Reloc::Static) {
76 StaticCtorsSection = ".constructor";
77 StaticDtorsSection = ".destructor";
78 } else {
79 StaticCtorsSection = ".mod_init_func";
80 StaticDtorsSection = ".mod_term_func";
81 }
82 if (is64Bit) {
83 PersonalityPrefix = "";
84 PersonalitySuffix = "+4@GOTPCREL";
85 } else {
86 PersonalityPrefix = "L";
87 PersonalitySuffix = "$non_lazy_ptr";
88 }
89 NeedsIndirectEncoding = true;
90 InlineAsmStart = "## InlineAsm Start";
91 InlineAsmEnd = "## InlineAsm End";
92 CommentString = "##";
93 SetDirective = "\t.set";
94 PCSymbol = ".";
95 UsedDirective = "\t.no_dead_strip\t";
96 WeakDefDirective = "\t.weak_definition ";
97 WeakRefDirective = "\t.weak_reference ";
98 HiddenDirective = "\t.private_extern ";
99 ProtectedDirective = "\t.globl\t";
100
101 // In non-PIC modes, emit a special label before jump tables so that the
102 // linker can perform more accurate dead code stripping.
103 if (TM.getRelocationModel() != Reloc::PIC_) {
104 // Emit a local label that is preserved until the linker runs.
105 JumpTableSpecialLabelPrefix = "l";
106 }
107
108 SupportsDebugInformation = true;
109 NeedsSet = true;
110 DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug";
111 DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug";
112 DwarfLineSection = ".section __DWARF,__debug_line,regular,debug";
113 DwarfFrameSection = ".section __DWARF,__debug_frame,regular,debug";
114 DwarfPubNamesSection = ".section __DWARF,__debug_pubnames,regular,debug";
115 DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes,regular,debug";
116 DwarfStrSection = ".section __DWARF,__debug_str,regular,debug";
117 DwarfLocSection = ".section __DWARF,__debug_loc,regular,debug";
118 DwarfARangesSection = ".section __DWARF,__debug_aranges,regular,debug";
119 DwarfRangesSection = ".section __DWARF,__debug_ranges,regular,debug";
120 DwarfMacInfoSection = ".section __DWARF,__debug_macinfo,regular,debug";
121
122 // Exceptions handling
123 SupportsExceptionHandling = true;
124 GlobalEHDirective = "\t.globl\t";
125 SupportsWeakOmittedEHFrame = false;
126 AbsoluteEHSectionOffsets = false;
127 DwarfEHFrameSection =
128 ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support";
129 DwarfExceptionSection = ".section __DATA,__gcc_except_tab";
130}
131
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000132unsigned
133X86DarwinTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
134 bool Global) const {
135 if (Reason == DwarfEncoding::Functions && Global)
136 return (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4);
137 else if (Reason == DwarfEncoding::CodeLabels || !Global)
138 return DW_EH_PE_pcrel;
139 else
140 return DW_EH_PE_absptr;
141}
142
Rafael Espindola2f6fea92008-12-19 10:55:56 +0000143const char *
144X86DarwinTargetAsmInfo::getEHGlobalPrefix() const
145{
146 const X86Subtarget* Subtarget = &TM.getSubtarget<X86Subtarget>();
147 if (Subtarget->getDarwinVers() > 9)
148 return PrivateGlobalPrefix;
149 else
150 return "";
151}
152
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000153X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const X86TargetMachine &TM):
Anton Korobeynikov32b952a2008-09-25 21:00:33 +0000154 X86TargetAsmInfo<ELFTargetAsmInfo>(TM) {
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +0000155
Anton Korobeynikovb20015b2008-07-09 13:25:26 +0000156 CStringSection = ".rodata.str";
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000157 PrivateGlobalPrefix = ".L";
158 WeakRefDirective = "\t.weak\t";
159 SetDirective = "\t.set\t";
160 PCSymbol = ".";
161
162 // Set up DWARF directives
163 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
164
165 // Debug Information
166 AbsoluteDebugSectionOffsets = true;
167 SupportsDebugInformation = true;
168 DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"\",@progbits";
169 DwarfInfoSection = "\t.section\t.debug_info,\"\",@progbits";
170 DwarfLineSection = "\t.section\t.debug_line,\"\",@progbits";
171 DwarfFrameSection = "\t.section\t.debug_frame,\"\",@progbits";
172 DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"\",@progbits";
173 DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"\",@progbits";
174 DwarfStrSection = "\t.section\t.debug_str,\"\",@progbits";
175 DwarfLocSection = "\t.section\t.debug_loc,\"\",@progbits";
176 DwarfARangesSection = "\t.section\t.debug_aranges,\"\",@progbits";
177 DwarfRangesSection = "\t.section\t.debug_ranges,\"\",@progbits";
178 DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"\",@progbits";
179
180 // Exceptions handling
Anton Korobeynikovc4da15a2008-09-08 21:13:08 +0000181 SupportsExceptionHandling = true;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000182 AbsoluteEHSectionOffsets = false;
183 DwarfEHFrameSection = "\t.section\t.eh_frame,\"aw\",@progbits";
184 DwarfExceptionSection = "\t.section\t.gcc_except_table,\"a\",@progbits";
185
186 // On Linux we must declare when we can use a non-executable stack.
Dan Gohman8f092252008-11-03 18:22:42 +0000187 if (TM.getSubtarget<X86Subtarget>().isLinux())
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000188 NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\",@progbits";
189}
190
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000191unsigned
192X86ELFTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
193 bool Global) const {
Dan Gohman8f092252008-11-03 18:22:42 +0000194 CodeModel::Model CM = TM.getCodeModel();
195 bool is64Bit = TM.getSubtarget<X86Subtarget>().is64Bit();
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000196
Dan Gohman8f092252008-11-03 18:22:42 +0000197 if (TM.getRelocationModel() == Reloc::PIC_) {
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000198 unsigned Format = 0;
199
200 if (!is64Bit)
201 // 32 bit targets always encode pointers as 4 bytes
202 Format = DW_EH_PE_sdata4;
203 else {
204 // 64 bit targets encode pointers in 4 bytes iff:
205 // - code model is small OR
206 // - code model is medium and we're emitting externally visible symbols
207 // or any code symbols
208 if (CM == CodeModel::Small ||
209 (CM == CodeModel::Medium && (Global ||
210 Reason != DwarfEncoding::Data)))
211 Format = DW_EH_PE_sdata4;
212 else
213 Format = DW_EH_PE_sdata8;
214 }
215
216 if (Global)
217 Format |= DW_EH_PE_indirect;
218
219 return (Format | DW_EH_PE_pcrel);
220 } else {
221 if (is64Bit &&
222 (CM == CodeModel::Small ||
223 (CM == CodeModel::Medium && Reason != DwarfEncoding::Data)))
224 return DW_EH_PE_udata4;
225 else
226 return DW_EH_PE_absptr;
227 }
228}
229
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000230X86COFFTargetAsmInfo::X86COFFTargetAsmInfo(const X86TargetMachine &TM):
Anton Korobeynikov32b952a2008-09-25 21:00:33 +0000231 X86GenericTargetAsmInfo(TM) {
Anton Korobeynikov18f6ed92008-07-19 13:15:21 +0000232
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000233 GlobalPrefix = "_";
234 LCOMMDirective = "\t.lcomm\t";
235 COMMDirectiveTakesAlignment = false;
236 HasDotTypeDotSizeDirective = false;
Rafael Espindola952b8392008-12-03 11:01:37 +0000237 HasSingleParameterDotFile = false;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000238 StaticCtorsSection = "\t.section .ctors,\"aw\"";
239 StaticDtorsSection = "\t.section .dtors,\"aw\"";
240 HiddenDirective = NULL;
241 PrivateGlobalPrefix = "L"; // Prefix for private global symbols
242 WeakRefDirective = "\t.weak\t";
243 SetDirective = "\t.set\t";
244
245 // Set up DWARF directives
246 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
247 AbsoluteDebugSectionOffsets = true;
248 AbsoluteEHSectionOffsets = false;
249 SupportsDebugInformation = true;
250 DwarfSectionOffsetDirective = "\t.secrel32\t";
251 DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"dr\"";
252 DwarfInfoSection = "\t.section\t.debug_info,\"dr\"";
253 DwarfLineSection = "\t.section\t.debug_line,\"dr\"";
254 DwarfFrameSection = "\t.section\t.debug_frame,\"dr\"";
255 DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"dr\"";
256 DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"dr\"";
257 DwarfStrSection = "\t.section\t.debug_str,\"dr\"";
258 DwarfLocSection = "\t.section\t.debug_loc,\"dr\"";
259 DwarfARangesSection = "\t.section\t.debug_aranges,\"dr\"";
260 DwarfRangesSection = "\t.section\t.debug_ranges,\"dr\"";
261 DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"dr\"";
262}
263
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000264unsigned
265X86COFFTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
266 bool Global) const {
Dan Gohman8f092252008-11-03 18:22:42 +0000267 CodeModel::Model CM = TM.getCodeModel();
268 bool is64Bit = TM.getSubtarget<X86Subtarget>().is64Bit();
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000269
Dan Gohman8f092252008-11-03 18:22:42 +0000270 if (TM.getRelocationModel() == Reloc::PIC_) {
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000271 unsigned Format = 0;
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000272
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000273 if (!is64Bit)
274 // 32 bit targets always encode pointers as 4 bytes
275 Format = DW_EH_PE_sdata4;
276 else {
277 // 64 bit targets encode pointers in 4 bytes iff:
278 // - code model is small OR
279 // - code model is medium and we're emitting externally visible symbols
280 // or any code symbols
281 if (CM == CodeModel::Small ||
282 (CM == CodeModel::Medium && (Global ||
283 Reason != DwarfEncoding::Data)))
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000284 Format = DW_EH_PE_sdata4;
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000285 else
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000286 Format = DW_EH_PE_sdata8;
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000287 }
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000288
Anton Korobeynikovb9e58ef2008-07-09 13:21:08 +0000289 if (Global)
290 Format |= DW_EH_PE_indirect;
291
292 return (Format | DW_EH_PE_pcrel);
293 } else {
294 if (is64Bit &&
295 (CM == CodeModel::Small ||
296 (CM == CodeModel::Medium && Reason != DwarfEncoding::Data)))
297 return DW_EH_PE_udata4;
298 else
299 return DW_EH_PE_absptr;
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000300 }
301}
302
Anton Korobeynikovb9a02fc2008-07-09 13:21:29 +0000303std::string
304X86COFFTargetAsmInfo::UniqueSectionForGlobal(const GlobalValue* GV,
305 SectionKind::Kind kind) const {
306 switch (kind) {
307 case SectionKind::Text:
308 return ".text$linkonce" + GV->getName();
309 case SectionKind::Data:
310 case SectionKind::BSS:
311 case SectionKind::ThreadData:
312 case SectionKind::ThreadBSS:
313 return ".data$linkonce" + GV->getName();
314 case SectionKind::ROData:
315 case SectionKind::RODataMergeConst:
316 case SectionKind::RODataMergeStr:
317 return ".rdata$linkonce" + GV->getName();
Anton Korobeynikov29b03f72008-07-09 13:19:38 +0000318 default:
Anton Korobeynikovb9a02fc2008-07-09 13:21:29 +0000319 assert(0 && "Unknown section kind");
Anton Korobeynikov29b03f72008-07-09 13:19:38 +0000320 }
321}
322
Anton Korobeynikovd0c1e292008-08-16 12:57:07 +0000323std::string X86COFFTargetAsmInfo::printSectionFlags(unsigned flags) const {
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000324 std::string Flags = ",\"";
325
326 if (flags & SectionFlags::Code)
327 Flags += 'x';
328 if (flags & SectionFlags::Writeable)
329 Flags += 'w';
330
331 Flags += "\"";
332
333 return Flags;
334}
335
336X86WinTargetAsmInfo::X86WinTargetAsmInfo(const X86TargetMachine &TM):
Anton Korobeynikov32b952a2008-09-25 21:00:33 +0000337 X86GenericTargetAsmInfo(TM) {
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000338 GlobalPrefix = "_";
339 CommentString = ";";
340
341 PrivateGlobalPrefix = "$";
342 AlignDirective = "\talign\t";
343 ZeroDirective = "\tdb\t";
344 ZeroDirectiveSuffix = " dup(0)";
345 AsciiDirective = "\tdb\t";
346 AscizDirective = 0;
347 Data8bitsDirective = "\tdb\t";
348 Data16bitsDirective = "\tdw\t";
349 Data32bitsDirective = "\tdd\t";
350 Data64bitsDirective = "\tdq\t";
351 HasDotTypeDotSizeDirective = false;
Rafael Espindola952b8392008-12-03 11:01:37 +0000352 HasSingleParameterDotFile = false;
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000353
Anton Korobeynikovd7ca4162008-09-24 22:15:21 +0000354 TextSection = getUnnamedSection("_text", SectionFlags::Code);
Anton Korobeynikov315690e2008-09-24 22:16:16 +0000355 DataSection = getUnnamedSection("_data", SectionFlags::Writeable);
356
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000357 JumpTableDataSection = NULL;
358 SwitchToSectionDirective = "";
359 TextSectionStartSuffix = "\tsegment 'CODE'";
360 DataSectionStartSuffix = "\tsegment 'DATA'";
361 SectionEndDirectiveSuffix = "\tends\n";
362}
Anton Korobeynikov6381a132008-10-05 08:53:29 +0000363
364template <class BaseTAI>
365bool X86TargetAsmInfo<BaseTAI>::LowerToBSwap(CallInst *CI) const {
366 // FIXME: this should verify that we are targetting a 486 or better. If not,
367 // we will turn this bswap into something that will be lowered to logical ops
368 // instead of emitting the bswap asm. For now, we don't support 486 or lower
369 // so don't worry about this.
370
371 // Verify this is a simple bswap.
372 if (CI->getNumOperands() != 2 ||
373 CI->getType() != CI->getOperand(1)->getType() ||
374 !CI->getType()->isInteger())
375 return false;
376
377 const IntegerType *Ty = dyn_cast<IntegerType>(CI->getType());
378 if (!Ty || Ty->getBitWidth() % 16 != 0)
379 return false;
380
381 // Okay, we can do this xform, do so now.
382 const Type *Tys[] = { Ty };
383 Module *M = CI->getParent()->getParent()->getParent();
384 Constant *Int = Intrinsic::getDeclaration(M, Intrinsic::bswap, Tys, 1);
385
386 Value *Op = CI->getOperand(1);
387 Op = CallInst::Create(Int, Op, CI->getName(), CI);
388
389 CI->replaceAllUsesWith(Op);
390 CI->eraseFromParent();
391 return true;
392}
393
394template <class BaseTAI>
395bool X86TargetAsmInfo<BaseTAI>::ExpandInlineAsm(CallInst *CI) const {
396 InlineAsm *IA = cast<InlineAsm>(CI->getCalledValue());
397 std::vector<InlineAsm::ConstraintInfo> Constraints = IA->ParseConstraints();
398
399 std::string AsmStr = IA->getAsmString();
400
401 // TODO: should remove alternatives from the asmstring: "foo {a|b}" -> "foo a"
402 std::vector<std::string> AsmPieces;
403 SplitString(AsmStr, AsmPieces, "\n"); // ; as separator?
404
405 switch (AsmPieces.size()) {
406 default: return false;
407 case 1:
408 AsmStr = AsmPieces[0];
409 AsmPieces.clear();
410 SplitString(AsmStr, AsmPieces, " \t"); // Split with whitespace.
411
412 // bswap $0
413 if (AsmPieces.size() == 2 &&
414 AsmPieces[0] == "bswap" && AsmPieces[1] == "$0") {
415 // No need to check constraints, nothing other than the equivalent of
416 // "=r,0" would be valid here.
417 return LowerToBSwap(CI);
418 }
419 break;
420 case 3:
421 if (CI->getType() == Type::Int64Ty && Constraints.size() >= 2 &&
422 Constraints[0].Codes.size() == 1 && Constraints[0].Codes[0] == "A" &&
423 Constraints[1].Codes.size() == 1 && Constraints[1].Codes[0] == "0") {
424 // bswap %eax / bswap %edx / xchgl %eax, %edx -> llvm.bswap.i64
425 std::vector<std::string> Words;
426 SplitString(AsmPieces[0], Words, " \t");
427 if (Words.size() == 2 && Words[0] == "bswap" && Words[1] == "%eax") {
428 Words.clear();
429 SplitString(AsmPieces[1], Words, " \t");
430 if (Words.size() == 2 && Words[0] == "bswap" && Words[1] == "%edx") {
431 Words.clear();
432 SplitString(AsmPieces[2], Words, " \t,");
433 if (Words.size() == 3 && Words[0] == "xchgl" && Words[1] == "%eax" &&
434 Words[2] == "%edx") {
435 return LowerToBSwap(CI);
436 }
437 }
438 }
439 }
440 break;
441 }
442 return false;
443}
444
445// Instantiate default implementation.
446TEMPLATE_INSTANTIATION(class X86TargetAsmInfo<TargetAsmInfo>);