Added a new register class for segment registers
[oota-llvm.git] / lib / Target / X86 / X86InstrInfo.td
1 //===- X86InstrInfo.td - Describe the X86 Instruction Set --*- tablegen -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // This file describes the X86 instruction set, defining the instructions, and
11 // properties of the instructions which are needed for code generation, machine
12 // code emission, and analysis.
13 //
14 //===----------------------------------------------------------------------===//
15
16 //===----------------------------------------------------------------------===//
17 // X86 specific DAG Nodes.
18 //
19
20 def SDTIntShiftDOp: SDTypeProfile<1, 3,
21                                   [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
22                                    SDTCisInt<0>, SDTCisInt<3>]>;
23
24 def SDTX86CmpTest : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
25
26 def SDTX86Cmov    : SDTypeProfile<1, 4,
27                                   [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
28                                    SDTCisVT<3, i8>, SDTCisVT<4, i32>]>;
29
30 // Unary and binary operator instructions that set EFLAGS as a side-effect.
31 def SDTUnaryArithWithFlags  : SDTypeProfile<1, 1,
32                                             [SDTCisInt<0>]>;
33 def SDTBinaryArithWithFlags : SDTypeProfile<1, 2,
34                                             [SDTCisSameAs<0, 1>,
35                                              SDTCisSameAs<0, 2>,
36                                              SDTCisInt<0>]>;
37 def SDTX86BrCond  : SDTypeProfile<0, 3,
38                                   [SDTCisVT<0, OtherVT>,
39                                    SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
40
41 def SDTX86SetCC   : SDTypeProfile<1, 2,
42                                   [SDTCisVT<0, i8>,
43                                    SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
44
45 def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>, 
46                                      SDTCisVT<2, i8>]>;
47 def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
48
49 def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
50                                 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
51 def SDTX86Ret     : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
52
53 def SDT_X86CallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>]>;
54 def SDT_X86CallSeqEnd   : SDCallSeqEnd<[SDTCisVT<0, i32>,
55                                         SDTCisVT<1, i32>]>;
56
57 def SDT_X86Call   : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
58
59 def SDT_X86VASTART_SAVE_XMM_REGS : SDTypeProfile<0, -1, [SDTCisVT<0, i8>,
60                                                          SDTCisVT<1, iPTR>,
61                                                          SDTCisVT<2, iPTR>]>;
62
63 def SDTX86RepStr  : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
64
65 def SDTX86RdTsc   : SDTypeProfile<0, 0, []>;
66
67 def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
68
69 def SDT_X86TLSADDR : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
70
71 def SDT_X86SegmentBaseAddress : SDTypeProfile<1, 1, [SDTCisPtrTy<0>]>;
72
73 def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
74
75 def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
76
77 def X86bsf     : SDNode<"X86ISD::BSF",      SDTIntUnaryOp>;
78 def X86bsr     : SDNode<"X86ISD::BSR",      SDTIntUnaryOp>;
79 def X86shld    : SDNode<"X86ISD::SHLD",     SDTIntShiftDOp>;
80 def X86shrd    : SDNode<"X86ISD::SHRD",     SDTIntShiftDOp>;
81
82 def X86cmp     : SDNode<"X86ISD::CMP" ,     SDTX86CmpTest>;
83
84 def X86bt      : SDNode<"X86ISD::BT",       SDTX86CmpTest>;
85
86 def X86cmov    : SDNode<"X86ISD::CMOV",     SDTX86Cmov>;
87 def X86brcond  : SDNode<"X86ISD::BRCOND",   SDTX86BrCond,
88                         [SDNPHasChain]>;
89 def X86setcc   : SDNode<"X86ISD::SETCC",    SDTX86SetCC>;
90
91 def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
92                         [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
93                          SDNPMayLoad]>;
94 def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
95                         [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
96                          SDNPMayLoad]>;
97 def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
98                         [SDNPHasChain, SDNPMayStore, 
99                          SDNPMayLoad, SDNPMemOperand]>;
100 def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
101                         [SDNPHasChain, SDNPMayStore, 
102                          SDNPMayLoad, SDNPMemOperand]>;
103 def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
104                         [SDNPHasChain, SDNPMayStore, 
105                          SDNPMayLoad, SDNPMemOperand]>;
106 def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
107                         [SDNPHasChain, SDNPMayStore, 
108                          SDNPMayLoad, SDNPMemOperand]>;
109 def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
110                         [SDNPHasChain, SDNPMayStore, 
111                          SDNPMayLoad, SDNPMemOperand]>;
112 def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
113                         [SDNPHasChain, SDNPMayStore, 
114                          SDNPMayLoad, SDNPMemOperand]>;
115 def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
116                         [SDNPHasChain, SDNPMayStore, 
117                          SDNPMayLoad, SDNPMemOperand]>;
118 def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
119                         [SDNPHasChain, SDNPOptInFlag]>;
120
121 def X86vastart_save_xmm_regs :
122                  SDNode<"X86ISD::VASTART_SAVE_XMM_REGS",
123                         SDT_X86VASTART_SAVE_XMM_REGS,
124                         [SDNPHasChain]>;
125
126 def X86callseq_start :
127                  SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
128                         [SDNPHasChain, SDNPOutFlag]>;
129 def X86callseq_end :
130                  SDNode<"ISD::CALLSEQ_END",   SDT_X86CallSeqEnd,
131                         [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;       
132
133 def X86call    : SDNode<"X86ISD::CALL",     SDT_X86Call,
134                         [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
135
136 def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
137                         [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
138 def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
139                         [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
140                          SDNPMayLoad]>;
141
142 def X86rdtsc   : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
143                         [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
144
145 def X86Wrapper    : SDNode<"X86ISD::Wrapper",     SDTX86Wrapper>;
146 def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP",  SDTX86Wrapper>;
147
148 def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
149                         [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
150 def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
151                                  SDT_X86SegmentBaseAddress, []>;
152
153 def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
154                         [SDNPHasChain]>;
155
156 def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET, 
157                         [SDNPHasChain,  SDNPOptInFlag]>;
158
159 def X86add_flag  : SDNode<"X86ISD::ADD",  SDTBinaryArithWithFlags>;
160 def X86sub_flag  : SDNode<"X86ISD::SUB",  SDTBinaryArithWithFlags>;
161 def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags>;
162 def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags>;
163 def X86inc_flag  : SDNode<"X86ISD::INC",  SDTUnaryArithWithFlags>;
164 def X86dec_flag  : SDNode<"X86ISD::DEC",  SDTUnaryArithWithFlags>;
165
166 def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
167
168 //===----------------------------------------------------------------------===//
169 // X86 Operand Definitions.
170 //
171
172 def i32imm_pcrel : Operand<i32> {
173   let PrintMethod = "print_pcrel_imm";
174 }
175
176 // A version of ptr_rc which excludes SP, ESP, and RSP. This is used for
177 // the index operand of an address, to conform to x86 encoding restrictions.
178 def ptr_rc_nosp : PointerLikeRegClass<1>;
179
180 // *mem - Operand definitions for the funky X86 addressing mode operands.
181 //
182 def X86MemAsmOperand : AsmOperandClass {
183   let Name = "Mem";
184   let SuperClass = ?;
185 }
186 class X86MemOperand<string printMethod> : Operand<iPTR> {
187   let PrintMethod = printMethod;
188   let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
189   let ParserMatchClass = X86MemAsmOperand;
190 }
191
192 def opaque32mem : X86MemOperand<"printopaquemem">;
193 def opaque48mem : X86MemOperand<"printopaquemem">;
194 def opaque80mem : X86MemOperand<"printopaquemem">;
195
196 def i8mem   : X86MemOperand<"printi8mem">;
197 def i16mem  : X86MemOperand<"printi16mem">;
198 def i32mem  : X86MemOperand<"printi32mem">;
199 def i64mem  : X86MemOperand<"printi64mem">;
200 def i128mem : X86MemOperand<"printi128mem">;
201 def i256mem : X86MemOperand<"printi256mem">;
202 def f32mem  : X86MemOperand<"printf32mem">;
203 def f64mem  : X86MemOperand<"printf64mem">;
204 def f80mem  : X86MemOperand<"printf80mem">;
205 def f128mem : X86MemOperand<"printf128mem">;
206 def f256mem : X86MemOperand<"printf256mem">;
207
208 // A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
209 // plain GR64, so that it doesn't potentially require a REX prefix.
210 def i8mem_NOREX : Operand<i64> {
211   let PrintMethod = "printi8mem";
212   let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX_NOSP, i32imm, i8imm);
213   let ParserMatchClass = X86MemAsmOperand;
214 }
215
216 def lea32mem : Operand<i32> {
217   let PrintMethod = "printlea32mem";
218   let MIOperandInfo = (ops GR32, i8imm, GR32_NOSP, i32imm);
219   let ParserMatchClass = X86MemAsmOperand;
220 }
221
222 def SSECC : Operand<i8> {
223   let PrintMethod = "printSSECC";
224 }
225
226 def piclabel: Operand<i32> {
227   let PrintMethod = "printPICLabel";
228 }
229
230 def ImmSExt8AsmOperand : AsmOperandClass {
231   let Name = "ImmSExt8";
232   let SuperClass = ImmAsmOperand;
233 }
234
235 // A couple of more descriptive operand definitions.
236 // 16-bits but only 8 bits are significant.
237 def i16i8imm  : Operand<i16> {
238   let ParserMatchClass = ImmSExt8AsmOperand;
239 }
240 // 32-bits but only 8 bits are significant.
241 def i32i8imm  : Operand<i32> {
242   let ParserMatchClass = ImmSExt8AsmOperand;
243 }
244
245 // Branch targets have OtherVT type and print as pc-relative values.
246 def brtarget : Operand<OtherVT> {
247   let PrintMethod = "print_pcrel_imm";
248 }
249
250 def brtarget8 : Operand<OtherVT> {
251   let PrintMethod = "print_pcrel_imm";
252 }
253
254 //===----------------------------------------------------------------------===//
255 // X86 Complex Pattern Definitions.
256 //
257
258 // Define X86 specific addressing mode.
259 def addr      : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
260 def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
261                                [add, sub, mul, X86mul_imm, shl, or, frameindex],
262                                []>;
263 def tls32addr : ComplexPattern<i32, 4, "SelectTLSADDRAddr",
264                                [tglobaltlsaddr], []>;
265
266 //===----------------------------------------------------------------------===//
267 // X86 Instruction Predicate Definitions.
268 def HasMMX       : Predicate<"Subtarget->hasMMX()">;
269 def HasSSE1      : Predicate<"Subtarget->hasSSE1()">;
270 def HasSSE2      : Predicate<"Subtarget->hasSSE2()">;
271 def HasSSE3      : Predicate<"Subtarget->hasSSE3()">;
272 def HasSSSE3     : Predicate<"Subtarget->hasSSSE3()">;
273 def HasSSE41     : Predicate<"Subtarget->hasSSE41()">;
274 def HasSSE42     : Predicate<"Subtarget->hasSSE42()">;
275 def HasSSE4A     : Predicate<"Subtarget->hasSSE4A()">;
276 def HasAVX       : Predicate<"Subtarget->hasAVX()">;
277 def HasFMA3      : Predicate<"Subtarget->hasFMA3()">;
278 def HasFMA4      : Predicate<"Subtarget->hasFMA4()">;
279 def FPStackf32   : Predicate<"!Subtarget->hasSSE1()">;
280 def FPStackf64   : Predicate<"!Subtarget->hasSSE2()">;
281 def In32BitMode  : Predicate<"!Subtarget->is64Bit()">;
282 def In64BitMode  : Predicate<"Subtarget->is64Bit()">;
283 def IsWin64      : Predicate<"Subtarget->isTargetWin64()">;
284 def NotWin64     : Predicate<"!Subtarget->isTargetWin64()">;
285 def SmallCode    : Predicate<"TM.getCodeModel() == CodeModel::Small">;
286 def KernelCode   : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
287 def FarData      : Predicate<"TM.getCodeModel() != CodeModel::Small &&"
288                              "TM.getCodeModel() != CodeModel::Kernel">;
289 def NearData     : Predicate<"TM.getCodeModel() == CodeModel::Small ||"
290                              "TM.getCodeModel() == CodeModel::Kernel">;
291 def IsStatic     : Predicate<"TM.getRelocationModel() == Reloc::Static">;
292 def OptForSpeed  : Predicate<"!OptForSize">;
293 def FastBTMem    : Predicate<"!Subtarget->isBTMemSlow()">;
294 def CallImmAddr  : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
295
296 //===----------------------------------------------------------------------===//
297 // X86 Instruction Format Definitions.
298 //
299
300 include "X86InstrFormats.td"
301
302 //===----------------------------------------------------------------------===//
303 // Pattern fragments...
304 //
305
306 // X86 specific condition code. These correspond to CondCode in
307 // X86InstrInfo.h. They must be kept in synch.
308 def X86_COND_A   : PatLeaf<(i8 0)>;  // alt. COND_NBE
309 def X86_COND_AE  : PatLeaf<(i8 1)>;  // alt. COND_NC
310 def X86_COND_B   : PatLeaf<(i8 2)>;  // alt. COND_C
311 def X86_COND_BE  : PatLeaf<(i8 3)>;  // alt. COND_NA
312 def X86_COND_E   : PatLeaf<(i8 4)>;  // alt. COND_Z
313 def X86_COND_G   : PatLeaf<(i8 5)>;  // alt. COND_NLE
314 def X86_COND_GE  : PatLeaf<(i8 6)>;  // alt. COND_NL
315 def X86_COND_L   : PatLeaf<(i8 7)>;  // alt. COND_NGE
316 def X86_COND_LE  : PatLeaf<(i8 8)>;  // alt. COND_NG
317 def X86_COND_NE  : PatLeaf<(i8 9)>;  // alt. COND_NZ
318 def X86_COND_NO  : PatLeaf<(i8 10)>;
319 def X86_COND_NP  : PatLeaf<(i8 11)>; // alt. COND_PO
320 def X86_COND_NS  : PatLeaf<(i8 12)>;
321 def X86_COND_O   : PatLeaf<(i8 13)>;
322 def X86_COND_P   : PatLeaf<(i8 14)>; // alt. COND_PE
323 def X86_COND_S   : PatLeaf<(i8 15)>;
324
325 def i16immSExt8  : PatLeaf<(i16 imm), [{
326   // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
327   // sign extended field.
328   return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
329 }]>;
330
331 def i32immSExt8  : PatLeaf<(i32 imm), [{
332   // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
333   // sign extended field.
334   return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
335 }]>;
336
337 // Helper fragments for loads.
338 // It's always safe to treat a anyext i16 load as a i32 load if the i16 is
339 // known to be 32-bit aligned or better. Ditto for i8 to i16.
340 def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
341   LoadSDNode *LD = cast<LoadSDNode>(N);
342   if (const Value *Src = LD->getSrcValue())
343     if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
344       if (PT->getAddressSpace() > 255)
345         return false;
346   ISD::LoadExtType ExtType = LD->getExtensionType();
347   if (ExtType == ISD::NON_EXTLOAD)
348     return true;
349   if (ExtType == ISD::EXTLOAD)
350     return LD->getAlignment() >= 2 && !LD->isVolatile();
351   return false;
352 }]>;
353
354 def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
355   LoadSDNode *LD = cast<LoadSDNode>(N);
356   if (const Value *Src = LD->getSrcValue())
357     if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
358       if (PT->getAddressSpace() > 255)
359         return false;
360   ISD::LoadExtType ExtType = LD->getExtensionType();
361   if (ExtType == ISD::EXTLOAD)
362     return LD->getAlignment() >= 2 && !LD->isVolatile();
363   return false;
364 }]>;
365
366 def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
367   LoadSDNode *LD = cast<LoadSDNode>(N);
368   if (const Value *Src = LD->getSrcValue())
369     if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
370       if (PT->getAddressSpace() > 255)
371         return false;
372   ISD::LoadExtType ExtType = LD->getExtensionType();
373   if (ExtType == ISD::NON_EXTLOAD)
374     return true;
375   if (ExtType == ISD::EXTLOAD)
376     return LD->getAlignment() >= 4 && !LD->isVolatile();
377   return false;
378 }]>;
379
380 def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
381   LoadSDNode *LD = cast<LoadSDNode>(N);
382   if (const Value *Src = LD->getSrcValue())
383     if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
384       if (PT->getAddressSpace() > 255)
385         return false;
386   if (LD->isVolatile())
387     return false;
388   ISD::LoadExtType ExtType = LD->getExtensionType();
389   if (ExtType == ISD::NON_EXTLOAD)
390     return true;
391   if (ExtType == ISD::EXTLOAD)
392     return LD->getAlignment() >= 4;
393   return false;
394 }]>;
395
396 def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
397   if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
398     if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
399       return PT->getAddressSpace() == 256;
400   return false;
401 }]>;
402
403 def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
404   if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
405     if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
406       return PT->getAddressSpace() == 257;
407   return false;
408 }]>;
409
410 def loadi8  : PatFrag<(ops node:$ptr), (i8  (load node:$ptr)), [{
411   if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
412     if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
413       if (PT->getAddressSpace() > 255)
414         return false;
415   return true;
416 }]>;
417 def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr)), [{
418   if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
419     if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
420       if (PT->getAddressSpace() > 255)
421         return false;
422   return true;
423 }]>;
424
425 def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr)), [{
426   if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
427     if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
428       if (PT->getAddressSpace() > 255)
429         return false;
430   return true;
431 }]>;
432 def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr)), [{
433   if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
434     if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
435       if (PT->getAddressSpace() > 255)
436         return false;
437   return true;
438 }]>;
439 def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr)), [{
440   if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
441     if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
442       if (PT->getAddressSpace() > 255)
443         return false;
444   return true;
445 }]>;
446
447 def sextloadi16i8  : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
448 def sextloadi32i8  : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
449 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
450
451 def zextloadi8i1   : PatFrag<(ops node:$ptr), (i8  (zextloadi1 node:$ptr))>;
452 def zextloadi16i1  : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
453 def zextloadi32i1  : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
454 def zextloadi16i8  : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
455 def zextloadi32i8  : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
456 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
457
458 def extloadi8i1    : PatFrag<(ops node:$ptr), (i8  (extloadi1 node:$ptr))>;
459 def extloadi16i1   : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
460 def extloadi32i1   : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
461 def extloadi16i8   : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
462 def extloadi32i8   : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
463 def extloadi32i16  : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
464
465
466 // An 'and' node with a single use.
467 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
468   return N->hasOneUse();
469 }]>;
470 // An 'srl' node with a single use.
471 def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
472   return N->hasOneUse();
473 }]>;
474 // An 'trunc' node with a single use.
475 def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
476   return N->hasOneUse();
477 }]>;
478
479 // 'shld' and 'shrd' instruction patterns. Note that even though these have
480 // the srl and shl in their patterns, the C++ code must still check for them,
481 // because predicates are tested before children nodes are explored.
482
483 def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
484                    (or (srl node:$src1, node:$amt1),
485                        (shl node:$src2, node:$amt2)), [{
486   assert(N->getOpcode() == ISD::OR);
487   return N->getOperand(0).getOpcode() == ISD::SRL &&
488          N->getOperand(1).getOpcode() == ISD::SHL &&
489          isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
490          isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
491          N->getOperand(0).getConstantOperandVal(1) ==
492          N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
493 }]>;
494
495 def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
496                    (or (shl node:$src1, node:$amt1),
497                        (srl node:$src2, node:$amt2)), [{
498   assert(N->getOpcode() == ISD::OR);
499   return N->getOperand(0).getOpcode() == ISD::SHL &&
500          N->getOperand(1).getOpcode() == ISD::SRL &&
501          isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
502          isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
503          N->getOperand(0).getConstantOperandVal(1) ==
504          N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
505 }]>;
506
507 //===----------------------------------------------------------------------===//
508 // Instruction list...
509 //
510
511 // ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
512 // a stack adjustment and the codegen must know that they may modify the stack
513 // pointer before prolog-epilog rewriting occurs.
514 // Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
515 // sub / add which can clobber EFLAGS.
516 let Defs = [ESP, EFLAGS], Uses = [ESP] in {
517 def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
518                            "#ADJCALLSTACKDOWN",
519                            [(X86callseq_start timm:$amt)]>,
520                           Requires<[In32BitMode]>;
521 def ADJCALLSTACKUP32   : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
522                            "#ADJCALLSTACKUP",
523                            [(X86callseq_end timm:$amt1, timm:$amt2)]>,
524                           Requires<[In32BitMode]>;
525 }
526
527 // x86-64 va_start lowering magic.
528 let usesCustomDAGSchedInserter = 1 in
529 def VASTART_SAVE_XMM_REGS : I<0, Pseudo,
530                               (outs),
531                               (ins GR8:$al,
532                                    i64imm:$regsavefi, i64imm:$offset,
533                                    variable_ops),
534                               "#VASTART_SAVE_XMM_REGS $al, $regsavefi, $offset",
535                               [(X86vastart_save_xmm_regs GR8:$al,
536                                                          imm:$regsavefi,
537                                                          imm:$offset)]>;
538
539 // Nop
540 let neverHasSideEffects = 1 in {
541   def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
542   def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
543                 "nopl\t$zero", []>, TB;
544 }
545
546 // Trap
547 def INT3 : I<0xcc, RawFrm, (outs), (ins), "int 3", []>;
548 def INT : I<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap", []>;
549
550 // PIC base
551 let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
552   def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
553                       "call\t$label\n\t"
554                       "pop{l}\t$reg", []>;
555
556 //===----------------------------------------------------------------------===//
557 //  Control Flow Instructions...
558 //
559
560 // Return instructions.
561 let isTerminator = 1, isReturn = 1, isBarrier = 1,
562     hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
563   def RET    : I   <0xC3, RawFrm, (outs), (ins variable_ops),
564                     "ret",
565                     [(X86retflag 0)]>;
566   def RETI   : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
567                     "ret\t$amt",
568                     [(X86retflag timm:$amt)]>;
569 }
570
571 // All branches are RawFrm, Void, Branch, and Terminators
572 let isBranch = 1, isTerminator = 1 in
573   class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
574         I<opcode, RawFrm, (outs), ins, asm, pattern>;
575
576 let isBranch = 1, isBarrier = 1 in {
577   def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
578   def JMP8 : IBr<0xEB, (ins brtarget8:$dst), "jmp\t$dst", []>;
579 }
580
581 // Indirect branches
582 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
583   def JMP32r     : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
584                      [(brind GR32:$dst)]>;
585   def JMP32m     : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
586                      [(brind (loadi32 addr:$dst))]>;
587                      
588   def FARJMP16i  : Iseg16<0xEA, RawFrm, (outs), 
589                           (ins i16imm:$seg, i16imm:$off),
590                           "ljmp{w}\t$seg, $off", []>, OpSize;
591   def FARJMP32i  : Iseg32<0xEA, RawFrm, (outs),
592                           (ins i16imm:$seg, i32imm:$off),
593                           "ljmp{l}\t$seg, $off", []>;                     
594
595   def FARJMP16m  : I<0xFF, MRM5m, (outs), (ins opaque32mem:$dst), 
596                      "ljmp{w}\t{*}$dst", []>, OpSize;
597   def FARJMP32m  : I<0xFF, MRM5m, (outs), (ins opaque48mem:$dst),
598                      "ljmp{l}\t{*}$dst", []>;
599 }
600
601 // Conditional branches
602 let Uses = [EFLAGS] in {
603 // Short conditional jumps
604 def JO8   : IBr<0x70, (ins brtarget8:$dst), "jo\t$dst", []>;
605 def JNO8  : IBr<0x71, (ins brtarget8:$dst), "jno\t$dst", []>;
606 def JB8   : IBr<0x72, (ins brtarget8:$dst), "jb\t$dst", []>;
607 def JAE8  : IBr<0x73, (ins brtarget8:$dst), "jae\t$dst", []>;
608 def JE8   : IBr<0x74, (ins brtarget8:$dst), "je\t$dst", []>;
609 def JNE8  : IBr<0x75, (ins brtarget8:$dst), "jne\t$dst", []>;
610 def JBE8  : IBr<0x76, (ins brtarget8:$dst), "jbe\t$dst", []>;
611 def JA8   : IBr<0x77, (ins brtarget8:$dst), "ja\t$dst", []>;
612 def JS8   : IBr<0x78, (ins brtarget8:$dst), "js\t$dst", []>;
613 def JNS8  : IBr<0x79, (ins brtarget8:$dst), "jns\t$dst", []>;
614 def JP8   : IBr<0x7A, (ins brtarget8:$dst), "jp\t$dst", []>;
615 def JNP8  : IBr<0x7B, (ins brtarget8:$dst), "jnp\t$dst", []>;
616 def JL8   : IBr<0x7C, (ins brtarget8:$dst), "jl\t$dst", []>;
617 def JGE8  : IBr<0x7D, (ins brtarget8:$dst), "jge\t$dst", []>;
618 def JLE8  : IBr<0x7E, (ins brtarget8:$dst), "jle\t$dst", []>;
619 def JG8   : IBr<0x7F, (ins brtarget8:$dst), "jg\t$dst", []>;
620
621 def JCXZ8 : IBr<0xE3, (ins brtarget8:$dst), "jcxz\t$dst", []>;
622
623 def JE  : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
624               [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
625 def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
626               [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
627 def JL  : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
628               [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
629 def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
630               [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
631 def JG  : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
632               [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
633 def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
634               [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
635
636 def JB  : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
637               [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
638 def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
639               [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
640 def JA  : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
641               [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
642 def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
643               [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
644
645 def JS  : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
646               [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
647 def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
648               [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
649 def JP  : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
650               [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
651 def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
652               [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
653 def JO  : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
654               [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
655 def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
656               [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
657 } // Uses = [EFLAGS]
658
659 //===----------------------------------------------------------------------===//
660 //  Call Instructions...
661 //
662 let isCall = 1 in
663   // All calls clobber the non-callee saved registers. ESP is marked as
664   // a use to prevent stack-pointer assignments that appear immediately
665   // before calls from potentially appearing dead. Uses for argument
666   // registers are added manually.
667   let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
668               MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
669               XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
670               XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
671       Uses = [ESP] in {
672     def CALLpcrel32 : Ii32<0xE8, RawFrm,
673                            (outs), (ins i32imm_pcrel:$dst,variable_ops),
674                            "call\t$dst", []>;
675     def CALL32r     : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
676                         "call\t{*}$dst", [(X86call GR32:$dst)]>;
677     def CALL32m     : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
678                         "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
679   
680     def FARCALL16i  : Iseg16<0x9A, RawFrm, (outs), 
681                              (ins i16imm:$seg, i16imm:$off),
682                              "lcall{w}\t$seg, $off", []>, OpSize;
683     def FARCALL32i  : Iseg32<0x9A, RawFrm, (outs),
684                              (ins i16imm:$seg, i32imm:$off),
685                              "lcall{l}\t$seg, $off", []>;
686                              
687     def FARCALL16m  : I<0xFF, MRM3m, (outs), (ins opaque32mem:$dst),
688                         "lcall{w}\t{*}$dst", []>, OpSize;
689     def FARCALL32m  : I<0xFF, MRM3m, (outs), (ins opaque48mem:$dst),
690                         "lcall{l}\t{*}$dst", []>;
691   }
692
693 // Tail call stuff.
694
695 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
696 def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
697                  "#TC_RETURN $dst $offset",
698                  []>;
699
700 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
701 def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
702                  "#TC_RETURN $dst $offset",
703                  []>;
704
705 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
706
707   def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst  # TAILCALL",
708                  []>;
709 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
710   def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst  # TAILCALL",
711                  []>;     
712 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
713   def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
714                    "jmp\t{*}$dst  # TAILCALL", []>;
715
716 //===----------------------------------------------------------------------===//
717 //  Miscellaneous Instructions...
718 //
719 let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
720 def LEAVE    : I<0xC9, RawFrm,
721                  (outs), (ins), "leave", []>;
722
723 let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
724 let mayLoad = 1 in {
725 def POP16r  : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
726   OpSize;
727 def POP32r  : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
728 def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
729   OpSize;
730 def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
731   OpSize;
732 def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
733 def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
734 }
735
736 let mayStore = 1 in {
737 def PUSH16r  : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
738   OpSize;
739 def PUSH32r  : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
740 def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
741   OpSize;
742 def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
743   OpSize;
744 def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
745 def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
746 }
747 }
748
749 let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
750 def PUSH32i8   : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm), 
751                      "push{l}\t$imm", []>;
752 def PUSH32i16  : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm), 
753                       "push{l}\t$imm", []>;
754 def PUSH32i32  : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm), 
755                       "push{l}\t$imm", []>;
756 }
757
758 let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
759 def POPFD    : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
760 let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
761 def PUSHFD   : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
762
763 let isTwoAddress = 1 in                               // GR32 = bswap GR32
764   def BSWAP32r : I<0xC8, AddRegFrm,
765                    (outs GR32:$dst), (ins GR32:$src),
766                    "bswap{l}\t$dst", 
767                    [(set GR32:$dst, (bswap GR32:$src))]>, TB;
768
769
770 // Bit scan instructions.
771 let Defs = [EFLAGS] in {
772 def BSF16rr  : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
773                  "bsf{w}\t{$src, $dst|$dst, $src}",
774                  [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
775 def BSF16rm  : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
776                  "bsf{w}\t{$src, $dst|$dst, $src}",
777                  [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
778                   (implicit EFLAGS)]>, TB;
779 def BSF32rr  : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
780                  "bsf{l}\t{$src, $dst|$dst, $src}",
781                  [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
782 def BSF32rm  : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
783                  "bsf{l}\t{$src, $dst|$dst, $src}",
784                  [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
785                   (implicit EFLAGS)]>, TB;
786
787 def BSR16rr  : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
788                  "bsr{w}\t{$src, $dst|$dst, $src}",
789                  [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
790 def BSR16rm  : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
791                  "bsr{w}\t{$src, $dst|$dst, $src}",
792                  [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
793                   (implicit EFLAGS)]>, TB;
794 def BSR32rr  : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
795                  "bsr{l}\t{$src, $dst|$dst, $src}",
796                  [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
797 def BSR32rm  : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
798                  "bsr{l}\t{$src, $dst|$dst, $src}",
799                  [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
800                   (implicit EFLAGS)]>, TB;
801 } // Defs = [EFLAGS]
802
803 let neverHasSideEffects = 1 in
804 def LEA16r   : I<0x8D, MRMSrcMem,
805                  (outs GR16:$dst), (ins i32mem:$src),
806                  "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
807 let isReMaterializable = 1 in
808 def LEA32r   : I<0x8D, MRMSrcMem,
809                  (outs GR32:$dst), (ins lea32mem:$src),
810                  "lea{l}\t{$src|$dst}, {$dst|$src}",
811                  [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
812
813 let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
814 def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
815                   [(X86rep_movs i8)]>, REP;
816 def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
817                   [(X86rep_movs i16)]>, REP, OpSize;
818 def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
819                   [(X86rep_movs i32)]>, REP;
820 }
821
822 let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
823 def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
824                   [(X86rep_stos i8)]>, REP;
825 let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
826 def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
827                   [(X86rep_stos i16)]>, REP, OpSize;
828 let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
829 def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
830                   [(X86rep_stos i32)]>, REP;
831
832 def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
833 def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
834 def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
835
836 def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
837 def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
838 def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
839
840 let Defs = [RAX, RDX] in
841 def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
842             TB;
843
844 let isBarrier = 1, hasCtrlDep = 1 in {
845 def TRAP    : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
846 }
847
848 def SYSCALL  : I<0x05, RawFrm,
849                  (outs), (ins), "syscall", []>, TB;
850 def SYSRET   : I<0x07, RawFrm,
851                  (outs), (ins), "sysret", []>, TB;
852 def SYSENTER : I<0x34, RawFrm,
853                  (outs), (ins), "sysenter", []>, TB;
854 def SYSEXIT  : I<0x35, RawFrm,
855                  (outs), (ins), "sysexit", []>, TB;
856
857 def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
858
859
860 //===----------------------------------------------------------------------===//
861 //  Input/Output Instructions...
862 //
863 let Defs = [AL], Uses = [DX] in
864 def IN8rr  : I<0xEC, RawFrm, (outs), (ins),
865                "in{b}\t{%dx, %al|%AL, %DX}", []>;
866 let Defs = [AX], Uses = [DX] in
867 def IN16rr : I<0xED, RawFrm, (outs), (ins),
868                "in{w}\t{%dx, %ax|%AX, %DX}", []>,  OpSize;
869 let Defs = [EAX], Uses = [DX] in
870 def IN32rr : I<0xED, RawFrm, (outs), (ins),
871                "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
872
873 let Defs = [AL] in
874 def IN8ri  : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
875                   "in{b}\t{$port, %al|%AL, $port}", []>;
876 let Defs = [AX] in
877 def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
878                   "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
879 let Defs = [EAX] in
880 def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
881                   "in{l}\t{$port, %eax|%EAX, $port}", []>;
882
883 let Uses = [DX, AL] in
884 def OUT8rr  : I<0xEE, RawFrm, (outs), (ins),
885                 "out{b}\t{%al, %dx|%DX, %AL}", []>;
886 let Uses = [DX, AX] in
887 def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
888                 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
889 let Uses = [DX, EAX] in
890 def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
891                 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
892
893 let Uses = [AL] in
894 def OUT8ir  : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
895                    "out{b}\t{%al, $port|$port, %AL}", []>;
896 let Uses = [AX] in
897 def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
898                    "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
899 let Uses = [EAX] in
900 def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
901                    "out{l}\t{%eax, $port|$port, %EAX}", []>;
902
903 //===----------------------------------------------------------------------===//
904 //  Move Instructions...
905 //
906 let neverHasSideEffects = 1 in {
907 def MOV8rr  : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
908                 "mov{b}\t{$src, $dst|$dst, $src}", []>;
909 def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
910                 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
911 def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
912                 "mov{l}\t{$src, $dst|$dst, $src}", []>;
913 }
914 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
915 def MOV8ri  : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
916                    "mov{b}\t{$src, $dst|$dst, $src}",
917                    [(set GR8:$dst, imm:$src)]>;
918 def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
919                    "mov{w}\t{$src, $dst|$dst, $src}",
920                    [(set GR16:$dst, imm:$src)]>, OpSize;
921 def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
922                    "mov{l}\t{$src, $dst|$dst, $src}",
923                    [(set GR32:$dst, imm:$src)]>;
924 }
925 def MOV8mi  : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
926                    "mov{b}\t{$src, $dst|$dst, $src}",
927                    [(store (i8 imm:$src), addr:$dst)]>;
928 def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
929                    "mov{w}\t{$src, $dst|$dst, $src}",
930                    [(store (i16 imm:$src), addr:$dst)]>, OpSize;
931 def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
932                    "mov{l}\t{$src, $dst|$dst, $src}",
933                    [(store (i32 imm:$src), addr:$dst)]>;
934
935 def MOV8o8a : Ii8 <0xA0, RawFrm, (outs), (ins i8imm:$src),
936                    "mov{b}\t{$src, %al|%al, $src}", []>;
937 def MOV16o16a : Ii16 <0xA1, RawFrm, (outs), (ins i16imm:$src),
938                       "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
939 def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins i32imm:$src),
940                       "mov{l}\t{$src, %eax|%eax, $src}", []>;
941
942 def MOV8ao8 : Ii8 <0xA2, RawFrm, (outs i8imm:$dst), (ins),
943                    "mov{b}\t{%al, $dst|$dst, %al}", []>;
944 def MOV16ao16 : Ii16 <0xA3, RawFrm, (outs i16imm:$dst), (ins),
945                       "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize;
946 def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs i32imm:$dst), (ins),
947                       "mov{l}\t{%eax, $dst|$dst, %eax}", []>;
948
949 // Moves to and from segment registers
950 def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
951                 "mov{w}\t{$src, $dst|$dst, $src}", []>;
952 def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src),
953                 "mov{w}\t{$src, $dst|$dst, $src}", []>;
954 def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
955                 "mov{w}\t{$src, $dst|$dst, $src}", []>;
956 def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
957                 "mov{w}\t{$src, $dst|$dst, $src}", []>;
958
959 let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
960 def MOV8rm  : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
961                 "mov{b}\t{$src, $dst|$dst, $src}",
962                 [(set GR8:$dst, (loadi8 addr:$src))]>;
963 def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
964                 "mov{w}\t{$src, $dst|$dst, $src}",
965                 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
966 def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
967                 "mov{l}\t{$src, $dst|$dst, $src}",
968                 [(set GR32:$dst, (loadi32 addr:$src))]>;
969 }
970
971 def MOV8mr  : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
972                 "mov{b}\t{$src, $dst|$dst, $src}",
973                 [(store GR8:$src, addr:$dst)]>;
974 def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
975                 "mov{w}\t{$src, $dst|$dst, $src}",
976                 [(store GR16:$src, addr:$dst)]>, OpSize;
977 def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
978                 "mov{l}\t{$src, $dst|$dst, $src}",
979                 [(store GR32:$src, addr:$dst)]>;
980
981 // Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
982 // that they can be used for copying and storing h registers, which can't be
983 // encoded when a REX prefix is present.
984 let neverHasSideEffects = 1 in
985 def MOV8rr_NOREX : I<0x88, MRMDestReg,
986                      (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
987                      "mov{b}\t{$src, $dst|$dst, $src}  # NOREX", []>;
988 let mayStore = 1 in
989 def MOV8mr_NOREX : I<0x88, MRMDestMem,
990                      (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
991                      "mov{b}\t{$src, $dst|$dst, $src}  # NOREX", []>;
992 let mayLoad = 1,
993     canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
994 def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
995                      (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
996                      "mov{b}\t{$src, $dst|$dst, $src}  # NOREX", []>;
997
998 //===----------------------------------------------------------------------===//
999 //  Fixed-Register Multiplication and Division Instructions...
1000 //
1001
1002 // Extra precision multiplication
1003 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
1004 def MUL8r  : I<0xF6, MRM4r, (outs),  (ins GR8:$src), "mul{b}\t$src",
1005                // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1006                // This probably ought to be moved to a def : Pat<> if the
1007                // syntax can be accepted.
1008                [(set AL, (mul AL, GR8:$src)),
1009                 (implicit EFLAGS)]>;     // AL,AH = AL*GR8
1010
1011 let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
1012 def MUL16r : I<0xF7, MRM4r, (outs),  (ins GR16:$src),
1013                "mul{w}\t$src", 
1014                []>, OpSize;    // AX,DX = AX*GR16
1015
1016 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
1017 def MUL32r : I<0xF7, MRM4r, (outs),  (ins GR32:$src),
1018                "mul{l}\t$src",
1019                []>; // EAX,EDX = EAX*GR32
1020
1021 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
1022 def MUL8m  : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
1023                "mul{b}\t$src",
1024                // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1025                // This probably ought to be moved to a def : Pat<> if the
1026                // syntax can be accepted.
1027                [(set AL, (mul AL, (loadi8 addr:$src))),
1028                 (implicit EFLAGS)]>;   // AL,AH = AL*[mem8]
1029
1030 let mayLoad = 1, neverHasSideEffects = 1 in {
1031 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1032 def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
1033                "mul{w}\t$src",
1034                []>, OpSize; // AX,DX = AX*[mem16]
1035
1036 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
1037 def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
1038               "mul{l}\t$src",
1039               []>;          // EAX,EDX = EAX*[mem32]
1040 }
1041
1042 let neverHasSideEffects = 1 in {
1043 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
1044 def IMUL8r  : I<0xF6, MRM5r, (outs),  (ins GR8:$src), "imul{b}\t$src", []>;
1045               // AL,AH = AL*GR8
1046 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1047 def IMUL16r : I<0xF7, MRM5r, (outs),  (ins GR16:$src), "imul{w}\t$src", []>,
1048               OpSize;    // AX,DX = AX*GR16
1049 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
1050 def IMUL32r : I<0xF7, MRM5r, (outs),  (ins GR32:$src), "imul{l}\t$src", []>;
1051               // EAX,EDX = EAX*GR32
1052 let mayLoad = 1 in {
1053 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
1054 def IMUL8m  : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
1055                 "imul{b}\t$src", []>;    // AL,AH = AL*[mem8]
1056 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1057 def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
1058                 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
1059 let Defs = [EAX,EDX], Uses = [EAX] in
1060 def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
1061                 "imul{l}\t$src", []>;  // EAX,EDX = EAX*[mem32]
1062 }
1063 } // neverHasSideEffects
1064
1065 // unsigned division/remainder
1066 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
1067 def DIV8r  : I<0xF6, MRM6r, (outs),  (ins GR8:$src),          // AX/r8 = AL,AH
1068                "div{b}\t$src", []>;
1069 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1070 def DIV16r : I<0xF7, MRM6r, (outs),  (ins GR16:$src),         // DX:AX/r16 = AX,DX
1071                "div{w}\t$src", []>, OpSize;
1072 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1073 def DIV32r : I<0xF7, MRM6r, (outs),  (ins GR32:$src),         // EDX:EAX/r32 = EAX,EDX
1074                "div{l}\t$src", []>;
1075 let mayLoad = 1 in {
1076 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
1077 def DIV8m  : I<0xF6, MRM6m, (outs), (ins i8mem:$src),       // AX/[mem8] = AL,AH
1078                "div{b}\t$src", []>;
1079 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1080 def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src),      // DX:AX/[mem16] = AX,DX
1081                "div{w}\t$src", []>, OpSize;
1082 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1083 def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src),      // EDX:EAX/[mem32] = EAX,EDX
1084                "div{l}\t$src", []>;
1085 }
1086
1087 // Signed division/remainder.
1088 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
1089 def IDIV8r : I<0xF6, MRM7r, (outs),  (ins GR8:$src),          // AX/r8 = AL,AH
1090                "idiv{b}\t$src", []>;
1091 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1092 def IDIV16r: I<0xF7, MRM7r, (outs),  (ins GR16:$src),         // DX:AX/r16 = AX,DX
1093                "idiv{w}\t$src", []>, OpSize;
1094 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1095 def IDIV32r: I<0xF7, MRM7r, (outs),  (ins GR32:$src),         // EDX:EAX/r32 = EAX,EDX
1096                "idiv{l}\t$src", []>;
1097 let mayLoad = 1, mayLoad = 1 in {
1098 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
1099 def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src),      // AX/[mem8] = AL,AH
1100                "idiv{b}\t$src", []>;
1101 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1102 def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src),     // DX:AX/[mem16] = AX,DX
1103                "idiv{w}\t$src", []>, OpSize;
1104 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1105 def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src),     // EDX:EAX/[mem32] = EAX,EDX
1106                "idiv{l}\t$src", []>;
1107 }
1108
1109 //===----------------------------------------------------------------------===//
1110 //  Two address Instructions.
1111 //
1112 let isTwoAddress = 1 in {
1113
1114 // Conditional moves
1115 let Uses = [EFLAGS] in {
1116
1117 // X86 doesn't have 8-bit conditional moves. Use a customDAGSchedInserter to
1118 // emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1119 // however that requires promoting the operands, and can induce additional
1120 // i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1121 // clobber EFLAGS, because if one of the operands is zero, the expansion
1122 // could involve an xor.
1123 let usesCustomDAGSchedInserter = 1, isTwoAddress = 0, Defs = [EFLAGS] in
1124 def CMOV_GR8 : I<0, Pseudo,
1125                  (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1126                  "#CMOV_GR8 PSEUDO!",
1127                  [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1128                                           imm:$cond, EFLAGS))]>;
1129
1130 let isCommutable = 1 in {
1131 def CMOVB16rr : I<0x42, MRMSrcReg,       // if <u, GR16 = GR16
1132                   (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1133                   "cmovb\t{$src2, $dst|$dst, $src2}",
1134                   [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1135                                    X86_COND_B, EFLAGS))]>,
1136                   TB, OpSize;
1137 def CMOVB32rr : I<0x42, MRMSrcReg,       // if <u, GR32 = GR32
1138                   (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1139                   "cmovb\t{$src2, $dst|$dst, $src2}",
1140                   [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1141                                    X86_COND_B, EFLAGS))]>,
1142                    TB;
1143 def CMOVAE16rr: I<0x43, MRMSrcReg,       // if >=u, GR16 = GR16
1144                   (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1145                   "cmovae\t{$src2, $dst|$dst, $src2}",
1146                   [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1147                                    X86_COND_AE, EFLAGS))]>,
1148                    TB, OpSize;
1149 def CMOVAE32rr: I<0x43, MRMSrcReg,       // if >=u, GR32 = GR32
1150                   (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1151                   "cmovae\t{$src2, $dst|$dst, $src2}",
1152                   [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1153                                    X86_COND_AE, EFLAGS))]>,
1154                    TB;
1155 def CMOVE16rr : I<0x44, MRMSrcReg,       // if ==, GR16 = GR16
1156                   (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1157                   "cmove\t{$src2, $dst|$dst, $src2}",
1158                   [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1159                                    X86_COND_E, EFLAGS))]>,
1160                    TB, OpSize;
1161 def CMOVE32rr : I<0x44, MRMSrcReg,       // if ==, GR32 = GR32
1162                   (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1163                   "cmove\t{$src2, $dst|$dst, $src2}",
1164                   [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1165                                    X86_COND_E, EFLAGS))]>,
1166                    TB;
1167 def CMOVNE16rr: I<0x45, MRMSrcReg,       // if !=, GR16 = GR16
1168                   (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1169                   "cmovne\t{$src2, $dst|$dst, $src2}",
1170                   [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1171                                    X86_COND_NE, EFLAGS))]>,
1172                    TB, OpSize;
1173 def CMOVNE32rr: I<0x45, MRMSrcReg,       // if !=, GR32 = GR32
1174                   (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1175                   "cmovne\t{$src2, $dst|$dst, $src2}",
1176                   [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1177                                    X86_COND_NE, EFLAGS))]>,
1178                    TB;
1179 def CMOVBE16rr: I<0x46, MRMSrcReg,       // if <=u, GR16 = GR16
1180                   (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1181                   "cmovbe\t{$src2, $dst|$dst, $src2}",
1182                   [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1183                                    X86_COND_BE, EFLAGS))]>,
1184                    TB, OpSize;
1185 def CMOVBE32rr: I<0x46, MRMSrcReg,       // if <=u, GR32 = GR32
1186                   (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1187                   "cmovbe\t{$src2, $dst|$dst, $src2}",
1188                   [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1189                                    X86_COND_BE, EFLAGS))]>,
1190                    TB;
1191 def CMOVA16rr : I<0x47, MRMSrcReg,       // if >u, GR16 = GR16
1192                   (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1193                   "cmova\t{$src2, $dst|$dst, $src2}",
1194                   [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1195                                    X86_COND_A, EFLAGS))]>,
1196                    TB, OpSize;
1197 def CMOVA32rr : I<0x47, MRMSrcReg,       // if >u, GR32 = GR32
1198                   (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1199                   "cmova\t{$src2, $dst|$dst, $src2}",
1200                   [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1201                                    X86_COND_A, EFLAGS))]>,
1202                    TB;
1203 def CMOVL16rr : I<0x4C, MRMSrcReg,       // if <s, GR16 = GR16
1204                   (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1205                   "cmovl\t{$src2, $dst|$dst, $src2}",
1206                   [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1207                                    X86_COND_L, EFLAGS))]>,
1208                    TB, OpSize;
1209 def CMOVL32rr : I<0x4C, MRMSrcReg,       // if <s, GR32 = GR32
1210                   (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1211                   "cmovl\t{$src2, $dst|$dst, $src2}",
1212                   [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1213                                    X86_COND_L, EFLAGS))]>,
1214                    TB;
1215 def CMOVGE16rr: I<0x4D, MRMSrcReg,       // if >=s, GR16 = GR16
1216                   (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1217                   "cmovge\t{$src2, $dst|$dst, $src2}",
1218                   [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1219                                    X86_COND_GE, EFLAGS))]>,
1220                    TB, OpSize;
1221 def CMOVGE32rr: I<0x4D, MRMSrcReg,       // if >=s, GR32 = GR32
1222                   (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1223                   "cmovge\t{$src2, $dst|$dst, $src2}",
1224                   [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1225                                    X86_COND_GE, EFLAGS))]>,
1226                    TB;
1227 def CMOVLE16rr: I<0x4E, MRMSrcReg,       // if <=s, GR16 = GR16
1228                   (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1229                   "cmovle\t{$src2, $dst|$dst, $src2}",
1230                   [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1231                                    X86_COND_LE, EFLAGS))]>,
1232                    TB, OpSize;
1233 def CMOVLE32rr: I<0x4E, MRMSrcReg,       // if <=s, GR32 = GR32
1234                   (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1235                   "cmovle\t{$src2, $dst|$dst, $src2}",
1236                   [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1237                                    X86_COND_LE, EFLAGS))]>,
1238                    TB;
1239 def CMOVG16rr : I<0x4F, MRMSrcReg,       // if >s, GR16 = GR16
1240                   (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1241                   "cmovg\t{$src2, $dst|$dst, $src2}",
1242                   [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1243                                    X86_COND_G, EFLAGS))]>,
1244                    TB, OpSize;
1245 def CMOVG32rr : I<0x4F, MRMSrcReg,       // if >s, GR32 = GR32
1246                   (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1247                   "cmovg\t{$src2, $dst|$dst, $src2}",
1248                   [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1249                                    X86_COND_G, EFLAGS))]>,
1250                    TB;
1251 def CMOVS16rr : I<0x48, MRMSrcReg,       // if signed, GR16 = GR16
1252                   (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1253                   "cmovs\t{$src2, $dst|$dst, $src2}",
1254                   [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1255                                    X86_COND_S, EFLAGS))]>,
1256                   TB, OpSize;
1257 def CMOVS32rr : I<0x48, MRMSrcReg,       // if signed, GR32 = GR32
1258                   (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1259                   "cmovs\t{$src2, $dst|$dst, $src2}",
1260                   [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1261                                    X86_COND_S, EFLAGS))]>,
1262                   TB;
1263 def CMOVNS16rr: I<0x49, MRMSrcReg,       // if !signed, GR16 = GR16
1264                   (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1265                   "cmovns\t{$src2, $dst|$dst, $src2}",
1266                   [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1267                                    X86_COND_NS, EFLAGS))]>,
1268                   TB, OpSize;
1269 def CMOVNS32rr: I<0x49, MRMSrcReg,       // if !signed, GR32 = GR32
1270                   (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1271                   "cmovns\t{$src2, $dst|$dst, $src2}",
1272                   [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1273                                    X86_COND_NS, EFLAGS))]>,
1274                   TB;
1275 def CMOVP16rr : I<0x4A, MRMSrcReg,       // if parity, GR16 = GR16
1276                   (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1277                   "cmovp\t{$src2, $dst|$dst, $src2}",
1278                   [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1279                                    X86_COND_P, EFLAGS))]>,
1280                   TB, OpSize;
1281 def CMOVP32rr : I<0x4A, MRMSrcReg,       // if parity, GR32 = GR32
1282                   (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1283                   "cmovp\t{$src2, $dst|$dst, $src2}",
1284                   [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1285                                    X86_COND_P, EFLAGS))]>,
1286                   TB;
1287 def CMOVNP16rr : I<0x4B, MRMSrcReg,       // if !parity, GR16 = GR16
1288                   (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1289                   "cmovnp\t{$src2, $dst|$dst, $src2}",
1290                    [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1291                                     X86_COND_NP, EFLAGS))]>,
1292                   TB, OpSize;
1293 def CMOVNP32rr : I<0x4B, MRMSrcReg,       // if !parity, GR32 = GR32
1294                   (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1295                   "cmovnp\t{$src2, $dst|$dst, $src2}",
1296                    [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1297                                     X86_COND_NP, EFLAGS))]>,
1298                   TB;
1299 def CMOVO16rr : I<0x40, MRMSrcReg,       // if overflow, GR16 = GR16
1300                   (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1301                   "cmovo\t{$src2, $dst|$dst, $src2}",
1302                   [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1303                                    X86_COND_O, EFLAGS))]>,
1304                   TB, OpSize;
1305 def CMOVO32rr : I<0x40, MRMSrcReg,       // if overflow, GR32 = GR32
1306                   (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1307                   "cmovo\t{$src2, $dst|$dst, $src2}",
1308                   [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1309                                    X86_COND_O, EFLAGS))]>,
1310                   TB;
1311 def CMOVNO16rr : I<0x41, MRMSrcReg,       // if !overflow, GR16 = GR16
1312                   (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1313                   "cmovno\t{$src2, $dst|$dst, $src2}",
1314                    [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1315                                     X86_COND_NO, EFLAGS))]>,
1316                   TB, OpSize;
1317 def CMOVNO32rr : I<0x41, MRMSrcReg,       // if !overflow, GR32 = GR32
1318                   (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1319                   "cmovno\t{$src2, $dst|$dst, $src2}",
1320                    [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1321                                     X86_COND_NO, EFLAGS))]>,
1322                   TB;
1323 } // isCommutable = 1
1324
1325 def CMOVB16rm : I<0x42, MRMSrcMem,       // if <u, GR16 = [mem16]
1326                   (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1327                   "cmovb\t{$src2, $dst|$dst, $src2}",
1328                   [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1329                                    X86_COND_B, EFLAGS))]>,
1330                   TB, OpSize;
1331 def CMOVB32rm : I<0x42, MRMSrcMem,       // if <u, GR32 = [mem32]
1332                   (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1333                   "cmovb\t{$src2, $dst|$dst, $src2}",
1334                   [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1335                                    X86_COND_B, EFLAGS))]>,
1336                    TB;
1337 def CMOVAE16rm: I<0x43, MRMSrcMem,       // if >=u, GR16 = [mem16]
1338                   (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1339                   "cmovae\t{$src2, $dst|$dst, $src2}",
1340                   [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1341                                    X86_COND_AE, EFLAGS))]>,
1342                    TB, OpSize;
1343 def CMOVAE32rm: I<0x43, MRMSrcMem,       // if >=u, GR32 = [mem32]
1344                   (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1345                   "cmovae\t{$src2, $dst|$dst, $src2}",
1346                   [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1347                                    X86_COND_AE, EFLAGS))]>,
1348                    TB;
1349 def CMOVE16rm : I<0x44, MRMSrcMem,       // if ==, GR16 = [mem16]
1350                   (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1351                   "cmove\t{$src2, $dst|$dst, $src2}",
1352                   [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1353                                    X86_COND_E, EFLAGS))]>,
1354                    TB, OpSize;
1355 def CMOVE32rm : I<0x44, MRMSrcMem,       // if ==, GR32 = [mem32]
1356                   (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1357                   "cmove\t{$src2, $dst|$dst, $src2}",
1358                   [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1359                                    X86_COND_E, EFLAGS))]>,
1360                    TB;
1361 def CMOVNE16rm: I<0x45, MRMSrcMem,       // if !=, GR16 = [mem16]
1362                   (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1363                   "cmovne\t{$src2, $dst|$dst, $src2}",
1364                   [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1365                                    X86_COND_NE, EFLAGS))]>,
1366                    TB, OpSize;
1367 def CMOVNE32rm: I<0x45, MRMSrcMem,       // if !=, GR32 = [mem32]
1368                   (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1369                   "cmovne\t{$src2, $dst|$dst, $src2}",
1370                   [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1371                                    X86_COND_NE, EFLAGS))]>,
1372                    TB;
1373 def CMOVBE16rm: I<0x46, MRMSrcMem,       // if <=u, GR16 = [mem16]
1374                   (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1375                   "cmovbe\t{$src2, $dst|$dst, $src2}",
1376                   [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1377                                    X86_COND_BE, EFLAGS))]>,
1378                    TB, OpSize;
1379 def CMOVBE32rm: I<0x46, MRMSrcMem,       // if <=u, GR32 = [mem32]
1380                   (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1381                   "cmovbe\t{$src2, $dst|$dst, $src2}",
1382                   [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1383                                    X86_COND_BE, EFLAGS))]>,
1384                    TB;
1385 def CMOVA16rm : I<0x47, MRMSrcMem,       // if >u, GR16 = [mem16]
1386                   (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1387                   "cmova\t{$src2, $dst|$dst, $src2}",
1388                   [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1389                                    X86_COND_A, EFLAGS))]>,
1390                    TB, OpSize;
1391 def CMOVA32rm : I<0x47, MRMSrcMem,       // if >u, GR32 = [mem32]
1392                   (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1393                   "cmova\t{$src2, $dst|$dst, $src2}",
1394                   [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1395                                    X86_COND_A, EFLAGS))]>,
1396                    TB;
1397 def CMOVL16rm : I<0x4C, MRMSrcMem,       // if <s, GR16 = [mem16]
1398                   (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1399                   "cmovl\t{$src2, $dst|$dst, $src2}",
1400                   [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1401                                    X86_COND_L, EFLAGS))]>,
1402                    TB, OpSize;
1403 def CMOVL32rm : I<0x4C, MRMSrcMem,       // if <s, GR32 = [mem32]
1404                   (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1405                   "cmovl\t{$src2, $dst|$dst, $src2}",
1406                   [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1407                                    X86_COND_L, EFLAGS))]>,
1408                    TB;
1409 def CMOVGE16rm: I<0x4D, MRMSrcMem,       // if >=s, GR16 = [mem16]
1410                   (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1411                   "cmovge\t{$src2, $dst|$dst, $src2}",
1412                   [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1413                                    X86_COND_GE, EFLAGS))]>,
1414                    TB, OpSize;
1415 def CMOVGE32rm: I<0x4D, MRMSrcMem,       // if >=s, GR32 = [mem32]
1416                   (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1417                   "cmovge\t{$src2, $dst|$dst, $src2}",
1418                   [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1419                                    X86_COND_GE, EFLAGS))]>,
1420                    TB;
1421 def CMOVLE16rm: I<0x4E, MRMSrcMem,       // if <=s, GR16 = [mem16]
1422                   (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1423                   "cmovle\t{$src2, $dst|$dst, $src2}",
1424                   [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1425                                    X86_COND_LE, EFLAGS))]>,
1426                    TB, OpSize;
1427 def CMOVLE32rm: I<0x4E, MRMSrcMem,       // if <=s, GR32 = [mem32]
1428                   (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1429                   "cmovle\t{$src2, $dst|$dst, $src2}",
1430                   [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1431                                    X86_COND_LE, EFLAGS))]>,
1432                    TB;
1433 def CMOVG16rm : I<0x4F, MRMSrcMem,       // if >s, GR16 = [mem16]
1434                   (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1435                   "cmovg\t{$src2, $dst|$dst, $src2}",
1436                   [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1437                                    X86_COND_G, EFLAGS))]>,
1438                    TB, OpSize;
1439 def CMOVG32rm : I<0x4F, MRMSrcMem,       // if >s, GR32 = [mem32]
1440                   (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1441                   "cmovg\t{$src2, $dst|$dst, $src2}",
1442                   [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1443                                    X86_COND_G, EFLAGS))]>,
1444                    TB;
1445 def CMOVS16rm : I<0x48, MRMSrcMem,       // if signed, GR16 = [mem16]
1446                   (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1447                   "cmovs\t{$src2, $dst|$dst, $src2}",
1448                   [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1449                                    X86_COND_S, EFLAGS))]>,
1450                   TB, OpSize;
1451 def CMOVS32rm : I<0x48, MRMSrcMem,       // if signed, GR32 = [mem32]
1452                   (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1453                   "cmovs\t{$src2, $dst|$dst, $src2}",
1454                   [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1455                                    X86_COND_S, EFLAGS))]>,
1456                   TB;
1457 def CMOVNS16rm: I<0x49, MRMSrcMem,       // if !signed, GR16 = [mem16]
1458                   (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1459                   "cmovns\t{$src2, $dst|$dst, $src2}",
1460                   [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1461                                    X86_COND_NS, EFLAGS))]>,
1462                   TB, OpSize;
1463 def CMOVNS32rm: I<0x49, MRMSrcMem,       // if !signed, GR32 = [mem32]
1464                   (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1465                   "cmovns\t{$src2, $dst|$dst, $src2}",
1466                   [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1467                                    X86_COND_NS, EFLAGS))]>,
1468                   TB;
1469 def CMOVP16rm : I<0x4A, MRMSrcMem,       // if parity, GR16 = [mem16]
1470                   (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1471                   "cmovp\t{$src2, $dst|$dst, $src2}",
1472                   [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1473                                    X86_COND_P, EFLAGS))]>,
1474                   TB, OpSize;
1475 def CMOVP32rm : I<0x4A, MRMSrcMem,       // if parity, GR32 = [mem32]
1476                   (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1477                   "cmovp\t{$src2, $dst|$dst, $src2}",
1478                   [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1479                                    X86_COND_P, EFLAGS))]>,
1480                   TB;
1481 def CMOVNP16rm : I<0x4B, MRMSrcMem,       // if !parity, GR16 = [mem16]
1482                   (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1483                   "cmovnp\t{$src2, $dst|$dst, $src2}",
1484                    [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1485                                     X86_COND_NP, EFLAGS))]>,
1486                   TB, OpSize;
1487 def CMOVNP32rm : I<0x4B, MRMSrcMem,       // if !parity, GR32 = [mem32]
1488                   (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1489                   "cmovnp\t{$src2, $dst|$dst, $src2}",
1490                    [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1491                                     X86_COND_NP, EFLAGS))]>,
1492                   TB;
1493 def CMOVO16rm : I<0x40, MRMSrcMem,       // if overflow, GR16 = [mem16]
1494                   (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1495                   "cmovo\t{$src2, $dst|$dst, $src2}",
1496                   [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1497                                    X86_COND_O, EFLAGS))]>,
1498                   TB, OpSize;
1499 def CMOVO32rm : I<0x40, MRMSrcMem,       // if overflow, GR32 = [mem32]
1500                   (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1501                   "cmovo\t{$src2, $dst|$dst, $src2}",
1502                   [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1503                                    X86_COND_O, EFLAGS))]>,
1504                   TB;
1505 def CMOVNO16rm : I<0x41, MRMSrcMem,       // if !overflow, GR16 = [mem16]
1506                   (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1507                   "cmovno\t{$src2, $dst|$dst, $src2}",
1508                    [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1509                                     X86_COND_NO, EFLAGS))]>,
1510                   TB, OpSize;
1511 def CMOVNO32rm : I<0x41, MRMSrcMem,       // if !overflow, GR32 = [mem32]
1512                   (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1513                   "cmovno\t{$src2, $dst|$dst, $src2}",
1514                    [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1515                                     X86_COND_NO, EFLAGS))]>,
1516                   TB;
1517 } // Uses = [EFLAGS]
1518
1519
1520 // unary instructions
1521 let CodeSize = 2 in {
1522 let Defs = [EFLAGS] in {
1523 def NEG8r  : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
1524                [(set GR8:$dst, (ineg GR8:$src)),
1525                 (implicit EFLAGS)]>;
1526 def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
1527                [(set GR16:$dst, (ineg GR16:$src)),
1528                 (implicit EFLAGS)]>, OpSize;
1529 def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
1530                [(set GR32:$dst, (ineg GR32:$src)),
1531                 (implicit EFLAGS)]>;
1532 let isTwoAddress = 0 in {
1533   def NEG8m  : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
1534                  [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1535                   (implicit EFLAGS)]>;
1536   def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
1537                  [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1538                   (implicit EFLAGS)]>, OpSize;
1539   def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
1540                  [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1541                   (implicit EFLAGS)]>;
1542 }
1543 } // Defs = [EFLAGS]
1544
1545 // Match xor -1 to not. Favors these over a move imm + xor to save code size.
1546 let AddedComplexity = 15 in {
1547 def NOT8r  : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
1548                [(set GR8:$dst, (not GR8:$src))]>;
1549 def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
1550                [(set GR16:$dst, (not GR16:$src))]>, OpSize;
1551 def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
1552                [(set GR32:$dst, (not GR32:$src))]>;
1553 }
1554 let isTwoAddress = 0 in {
1555   def NOT8m  : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
1556                  [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1557   def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
1558                  [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1559   def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
1560                  [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1561 }
1562 } // CodeSize
1563
1564 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1565 let Defs = [EFLAGS] in {
1566 let CodeSize = 2 in
1567 def INC8r  : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
1568                [(set GR8:$dst, (add GR8:$src, 1)),
1569                 (implicit EFLAGS)]>;
1570 let isConvertibleToThreeAddress = 1, CodeSize = 1 in {  // Can xform into LEA.
1571 def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
1572                [(set GR16:$dst, (add GR16:$src, 1)),
1573                 (implicit EFLAGS)]>,
1574              OpSize, Requires<[In32BitMode]>;
1575 def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
1576                [(set GR32:$dst, (add GR32:$src, 1)),
1577                 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
1578 }
1579 let isTwoAddress = 0, CodeSize = 2 in {
1580   def INC8m  : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
1581                [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1582                 (implicit EFLAGS)]>;
1583   def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
1584                [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1585                 (implicit EFLAGS)]>,
1586                OpSize, Requires<[In32BitMode]>;
1587   def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
1588                [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1589                 (implicit EFLAGS)]>,
1590                Requires<[In32BitMode]>;
1591 }
1592
1593 let CodeSize = 2 in
1594 def DEC8r  : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
1595                [(set GR8:$dst, (add GR8:$src, -1)),
1596                 (implicit EFLAGS)]>;
1597 let isConvertibleToThreeAddress = 1, CodeSize = 1 in {   // Can xform into LEA.
1598 def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
1599                [(set GR16:$dst, (add GR16:$src, -1)),
1600                 (implicit EFLAGS)]>,
1601              OpSize, Requires<[In32BitMode]>;
1602 def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
1603                [(set GR32:$dst, (add GR32:$src, -1)),
1604                 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
1605 }
1606
1607 let isTwoAddress = 0, CodeSize = 2 in {
1608   def DEC8m  : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
1609                [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1610                 (implicit EFLAGS)]>;
1611   def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
1612                [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1613                 (implicit EFLAGS)]>,
1614                OpSize, Requires<[In32BitMode]>;
1615   def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
1616                [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1617                 (implicit EFLAGS)]>,
1618                Requires<[In32BitMode]>;
1619 }
1620 } // Defs = [EFLAGS]
1621
1622 // Logical operators...
1623 let Defs = [EFLAGS] in {
1624 let isCommutable = 1 in {   // X = AND Y, Z   --> X = AND Z, Y
1625 def AND8rr   : I<0x20, MRMDestReg,
1626                 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1627                 "and{b}\t{$src2, $dst|$dst, $src2}",
1628                 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1629                  (implicit EFLAGS)]>;
1630 def AND16rr  : I<0x21, MRMDestReg,
1631                  (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1632                  "and{w}\t{$src2, $dst|$dst, $src2}",
1633                  [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1634                   (implicit EFLAGS)]>, OpSize;
1635 def AND32rr  : I<0x21, MRMDestReg, 
1636                  (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1637                  "and{l}\t{$src2, $dst|$dst, $src2}",
1638                  [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1639                   (implicit EFLAGS)]>;
1640 }
1641
1642 def AND8rm   : I<0x22, MRMSrcMem, 
1643                  (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1644                  "and{b}\t{$src2, $dst|$dst, $src2}",
1645                 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
1646                  (implicit EFLAGS)]>;
1647 def AND16rm  : I<0x23, MRMSrcMem, 
1648                  (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1649                  "and{w}\t{$src2, $dst|$dst, $src2}",
1650                 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
1651                  (implicit EFLAGS)]>, OpSize;
1652 def AND32rm  : I<0x23, MRMSrcMem,
1653                  (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1654                  "and{l}\t{$src2, $dst|$dst, $src2}",
1655                 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
1656                  (implicit EFLAGS)]>;
1657
1658 def AND8ri   : Ii8<0x80, MRM4r, 
1659                    (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
1660                    "and{b}\t{$src2, $dst|$dst, $src2}",
1661                    [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1662                     (implicit EFLAGS)]>;
1663 def AND16ri  : Ii16<0x81, MRM4r, 
1664                     (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1665                     "and{w}\t{$src2, $dst|$dst, $src2}",
1666                     [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1667                      (implicit EFLAGS)]>, OpSize;
1668 def AND32ri  : Ii32<0x81, MRM4r, 
1669                     (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1670                     "and{l}\t{$src2, $dst|$dst, $src2}",
1671                     [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1672                      (implicit EFLAGS)]>;
1673 def AND16ri8 : Ii8<0x83, MRM4r, 
1674                    (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1675                    "and{w}\t{$src2, $dst|$dst, $src2}",
1676                    [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1677                     (implicit EFLAGS)]>,
1678                    OpSize;
1679 def AND32ri8 : Ii8<0x83, MRM4r, 
1680                    (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1681                    "and{l}\t{$src2, $dst|$dst, $src2}",
1682                    [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1683                     (implicit EFLAGS)]>;
1684
1685 let isTwoAddress = 0 in {
1686   def AND8mr   : I<0x20, MRMDestMem,
1687                    (outs), (ins i8mem :$dst, GR8 :$src),
1688                    "and{b}\t{$src, $dst|$dst, $src}",
1689                    [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1690                     (implicit EFLAGS)]>;
1691   def AND16mr  : I<0x21, MRMDestMem,
1692                    (outs), (ins i16mem:$dst, GR16:$src),
1693                    "and{w}\t{$src, $dst|$dst, $src}",
1694                    [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1695                     (implicit EFLAGS)]>,
1696                    OpSize;
1697   def AND32mr  : I<0x21, MRMDestMem,
1698                    (outs), (ins i32mem:$dst, GR32:$src),
1699                    "and{l}\t{$src, $dst|$dst, $src}",
1700                    [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1701                     (implicit EFLAGS)]>;
1702   def AND8mi   : Ii8<0x80, MRM4m,
1703                      (outs), (ins i8mem :$dst, i8imm :$src),
1704                      "and{b}\t{$src, $dst|$dst, $src}",
1705                       [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1706                        (implicit EFLAGS)]>;
1707   def AND16mi  : Ii16<0x81, MRM4m,
1708                       (outs), (ins i16mem:$dst, i16imm:$src),
1709                       "and{w}\t{$src, $dst|$dst, $src}",
1710                       [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1711                        (implicit EFLAGS)]>,
1712                       OpSize;
1713   def AND32mi  : Ii32<0x81, MRM4m,
1714                       (outs), (ins i32mem:$dst, i32imm:$src),
1715                       "and{l}\t{$src, $dst|$dst, $src}",
1716                       [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1717                        (implicit EFLAGS)]>;
1718   def AND16mi8 : Ii8<0x83, MRM4m,
1719                      (outs), (ins i16mem:$dst, i16i8imm :$src),
1720                      "and{w}\t{$src, $dst|$dst, $src}",
1721                 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1722                  (implicit EFLAGS)]>,
1723                      OpSize;
1724   def AND32mi8 : Ii8<0x83, MRM4m,
1725                      (outs), (ins i32mem:$dst, i32i8imm :$src),
1726                      "and{l}\t{$src, $dst|$dst, $src}",
1727                 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1728                  (implicit EFLAGS)]>;
1729
1730   def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1731                    "and{b}\t{$src, %al|%al, $src}", []>;
1732   def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1733                       "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1734   def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1735                       "and{l}\t{$src, %eax|%eax, $src}", []>;
1736
1737 }
1738
1739
1740 let isCommutable = 1 in {   // X = OR Y, Z   --> X = OR Z, Y
1741 def OR8rr    : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1742                  "or{b}\t{$src2, $dst|$dst, $src2}",
1743                  [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1744                   (implicit EFLAGS)]>;
1745 def OR16rr   : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1746                  "or{w}\t{$src2, $dst|$dst, $src2}",
1747                  [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1748                   (implicit EFLAGS)]>, OpSize;
1749 def OR32rr   : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1750                  "or{l}\t{$src2, $dst|$dst, $src2}",
1751                  [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1752                   (implicit EFLAGS)]>;
1753 }
1754 def OR8rm    : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1755                  "or{b}\t{$src2, $dst|$dst, $src2}",
1756                 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1757                  (implicit EFLAGS)]>;
1758 def OR16rm   : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1759                  "or{w}\t{$src2, $dst|$dst, $src2}",
1760                 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1761                  (implicit EFLAGS)]>, OpSize;
1762 def OR32rm   : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1763                  "or{l}\t{$src2, $dst|$dst, $src2}",
1764                 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1765                  (implicit EFLAGS)]>;
1766
1767 def OR8ri    : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1768                     "or{b}\t{$src2, $dst|$dst, $src2}",
1769                     [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1770                      (implicit EFLAGS)]>;
1771 def OR16ri   : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1772                     "or{w}\t{$src2, $dst|$dst, $src2}", 
1773                     [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1774                      (implicit EFLAGS)]>, OpSize;
1775 def OR32ri   : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1776                     "or{l}\t{$src2, $dst|$dst, $src2}",
1777                     [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1778                      (implicit EFLAGS)]>;
1779
1780 def OR16ri8  : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1781                    "or{w}\t{$src2, $dst|$dst, $src2}",
1782                    [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1783                     (implicit EFLAGS)]>, OpSize;
1784 def OR32ri8  : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1785                    "or{l}\t{$src2, $dst|$dst, $src2}",
1786                    [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1787                     (implicit EFLAGS)]>;
1788 let isTwoAddress = 0 in {
1789   def OR8mr  : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
1790                  "or{b}\t{$src, $dst|$dst, $src}",
1791                  [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1792                   (implicit EFLAGS)]>;
1793   def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
1794                  "or{w}\t{$src, $dst|$dst, $src}",
1795                  [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1796                   (implicit EFLAGS)]>, OpSize;
1797   def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1798                  "or{l}\t{$src, $dst|$dst, $src}",
1799                  [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1800                   (implicit EFLAGS)]>;
1801   def OR8mi    : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1802                  "or{b}\t{$src, $dst|$dst, $src}",
1803                  [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1804                   (implicit EFLAGS)]>;
1805   def OR16mi   : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
1806                  "or{w}\t{$src, $dst|$dst, $src}",
1807                  [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1808                   (implicit EFLAGS)]>,
1809                  OpSize;
1810   def OR32mi   : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
1811                  "or{l}\t{$src, $dst|$dst, $src}",
1812                  [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1813                   (implicit EFLAGS)]>;
1814   def OR16mi8  : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
1815                  "or{w}\t{$src, $dst|$dst, $src}",
1816                  [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1817                   (implicit EFLAGS)]>,
1818                      OpSize;
1819   def OR32mi8  : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
1820                  "or{l}\t{$src, $dst|$dst, $src}",
1821                  [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1822                   (implicit EFLAGS)]>;
1823                   
1824   def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
1825                    "or{b}\t{$src, %al|%al, $src}", []>;
1826   def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
1827                       "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1828   def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
1829                       "or{l}\t{$src, %eax|%eax, $src}", []>;
1830 } // isTwoAddress = 0
1831
1832
1833 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1834   def XOR8rr   : I<0x30, MRMDestReg,
1835                    (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1836                    "xor{b}\t{$src2, $dst|$dst, $src2}",
1837                    [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1838                     (implicit EFLAGS)]>;
1839   def XOR16rr  : I<0x31, MRMDestReg, 
1840                    (outs GR16:$dst), (ins GR16:$src1, GR16:$src2), 
1841                    "xor{w}\t{$src2, $dst|$dst, $src2}",
1842                    [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1843                     (implicit EFLAGS)]>, OpSize;
1844   def XOR32rr  : I<0x31, MRMDestReg, 
1845                    (outs GR32:$dst), (ins GR32:$src1, GR32:$src2), 
1846                    "xor{l}\t{$src2, $dst|$dst, $src2}",
1847                    [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1848                     (implicit EFLAGS)]>;
1849 } // isCommutable = 1
1850
1851 def XOR8rm   : I<0x32, MRMSrcMem , 
1852                  (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2), 
1853                  "xor{b}\t{$src2, $dst|$dst, $src2}",
1854                  [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1855                   (implicit EFLAGS)]>;
1856 def XOR16rm  : I<0x33, MRMSrcMem , 
1857                  (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2), 
1858                  "xor{w}\t{$src2, $dst|$dst, $src2}",
1859                  [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1860                   (implicit EFLAGS)]>,
1861                  OpSize;
1862 def XOR32rm  : I<0x33, MRMSrcMem , 
1863                  (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2), 
1864                  "xor{l}\t{$src2, $dst|$dst, $src2}",
1865                  [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1866                   (implicit EFLAGS)]>;
1867
1868 def XOR8ri   : Ii8<0x80, MRM6r, 
1869                    (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2), 
1870                    "xor{b}\t{$src2, $dst|$dst, $src2}",
1871                    [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1872                     (implicit EFLAGS)]>;
1873 def XOR16ri  : Ii16<0x81, MRM6r, 
1874                     (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2), 
1875                     "xor{w}\t{$src2, $dst|$dst, $src2}",
1876                     [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1877                      (implicit EFLAGS)]>, OpSize;
1878 def XOR32ri  : Ii32<0x81, MRM6r, 
1879                     (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2), 
1880                     "xor{l}\t{$src2, $dst|$dst, $src2}",
1881                     [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1882                      (implicit EFLAGS)]>;
1883 def XOR16ri8 : Ii8<0x83, MRM6r, 
1884                    (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1885                    "xor{w}\t{$src2, $dst|$dst, $src2}",
1886                    [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1887                     (implicit EFLAGS)]>,
1888                    OpSize;
1889 def XOR32ri8 : Ii8<0x83, MRM6r, 
1890                    (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1891                    "xor{l}\t{$src2, $dst|$dst, $src2}",
1892                    [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1893                     (implicit EFLAGS)]>;
1894
1895 let isTwoAddress = 0 in {
1896   def XOR8mr   : I<0x30, MRMDestMem,
1897                    (outs), (ins i8mem :$dst, GR8 :$src),
1898                    "xor{b}\t{$src, $dst|$dst, $src}",
1899                    [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1900                     (implicit EFLAGS)]>;
1901   def XOR16mr  : I<0x31, MRMDestMem,
1902                    (outs), (ins i16mem:$dst, GR16:$src),
1903                    "xor{w}\t{$src, $dst|$dst, $src}",
1904                    [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1905                     (implicit EFLAGS)]>,
1906                    OpSize;
1907   def XOR32mr  : I<0x31, MRMDestMem,
1908                    (outs), (ins i32mem:$dst, GR32:$src),
1909                    "xor{l}\t{$src, $dst|$dst, $src}",
1910                    [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1911                     (implicit EFLAGS)]>;
1912   def XOR8mi   : Ii8<0x80, MRM6m,
1913                      (outs), (ins i8mem :$dst, i8imm :$src),
1914                      "xor{b}\t{$src, $dst|$dst, $src}",
1915                     [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1916                      (implicit EFLAGS)]>;
1917   def XOR16mi  : Ii16<0x81, MRM6m,
1918                       (outs), (ins i16mem:$dst, i16imm:$src),
1919                       "xor{w}\t{$src, $dst|$dst, $src}",
1920                    [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1921                     (implicit EFLAGS)]>,
1922                       OpSize;
1923   def XOR32mi  : Ii32<0x81, MRM6m,
1924                       (outs), (ins i32mem:$dst, i32imm:$src),
1925                       "xor{l}\t{$src, $dst|$dst, $src}",
1926                    [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1927                     (implicit EFLAGS)]>;
1928   def XOR16mi8 : Ii8<0x83, MRM6m,
1929                      (outs), (ins i16mem:$dst, i16i8imm :$src),
1930                      "xor{w}\t{$src, $dst|$dst, $src}",
1931                  [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1932                   (implicit EFLAGS)]>,
1933                      OpSize;
1934   def XOR32mi8 : Ii8<0x83, MRM6m,
1935                      (outs), (ins i32mem:$dst, i32i8imm :$src),
1936                      "xor{l}\t{$src, $dst|$dst, $src}",
1937                  [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1938                   (implicit EFLAGS)]>;
1939                   
1940   def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
1941                    "xor{b}\t{$src, %al|%al, $src}", []>;
1942   def XOR16i16 : Ii16 <0x35, RawFrm, (outs), (ins i16imm:$src),
1943                         "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1944   def XOR32i32 : Ii32 <0x35, RawFrm, (outs), (ins i32imm:$src),
1945                         "xor{l}\t{$src, %eax|%eax, $src}", []>;
1946 } // isTwoAddress = 0
1947 } // Defs = [EFLAGS]
1948
1949 // Shift instructions
1950 let Defs = [EFLAGS] in {
1951 let Uses = [CL] in {
1952 def SHL8rCL  : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
1953                  "shl{b}\t{%cl, $dst|$dst, CL}",
1954                  [(set GR8:$dst, (shl GR8:$src, CL))]>;
1955 def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
1956                  "shl{w}\t{%cl, $dst|$dst, CL}",
1957                  [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
1958 def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
1959                  "shl{l}\t{%cl, $dst|$dst, CL}",
1960                  [(set GR32:$dst, (shl GR32:$src, CL))]>;
1961 } // Uses = [CL]
1962
1963 def SHL8ri   : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1964                    "shl{b}\t{$src2, $dst|$dst, $src2}",
1965                    [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1966 let isConvertibleToThreeAddress = 1 in {   // Can transform into LEA.
1967 def SHL16ri  : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1968                    "shl{w}\t{$src2, $dst|$dst, $src2}",
1969                    [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1970 def SHL32ri  : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1971                    "shl{l}\t{$src2, $dst|$dst, $src2}",
1972                    [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
1973 // NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1974 // cheaper.
1975 } // isConvertibleToThreeAddress = 1
1976
1977 let isTwoAddress = 0 in {
1978   let Uses = [CL] in {
1979   def SHL8mCL  : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
1980                    "shl{b}\t{%cl, $dst|$dst, CL}",
1981                    [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
1982   def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
1983                    "shl{w}\t{%cl, $dst|$dst, CL}",
1984                    [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1985   def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
1986                    "shl{l}\t{%cl, $dst|$dst, CL}",
1987                    [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1988   }
1989   def SHL8mi   : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
1990                      "shl{b}\t{$src, $dst|$dst, $src}",
1991                   [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1992   def SHL16mi  : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
1993                      "shl{w}\t{$src, $dst|$dst, $src}",
1994                  [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1995                      OpSize;
1996   def SHL32mi  : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
1997                      "shl{l}\t{$src, $dst|$dst, $src}",
1998                  [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1999
2000   // Shift by 1
2001   def SHL8m1   : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
2002                    "shl{b}\t$dst",
2003                   [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2004   def SHL16m1  : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
2005                    "shl{w}\t$dst",
2006                  [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2007                      OpSize;
2008   def SHL32m1  : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
2009                    "shl{l}\t$dst",
2010                  [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2011 }
2012
2013 let Uses = [CL] in {
2014 def SHR8rCL  : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
2015                  "shr{b}\t{%cl, $dst|$dst, CL}",
2016                  [(set GR8:$dst, (srl GR8:$src, CL))]>;
2017 def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
2018                  "shr{w}\t{%cl, $dst|$dst, CL}",
2019                  [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
2020 def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
2021                  "shr{l}\t{%cl, $dst|$dst, CL}",
2022                  [(set GR32:$dst, (srl GR32:$src, CL))]>;
2023 }
2024
2025 def SHR8ri   : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2026                    "shr{b}\t{$src2, $dst|$dst, $src2}",
2027                    [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
2028 def SHR16ri  : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2029                    "shr{w}\t{$src2, $dst|$dst, $src2}",
2030                    [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2031 def SHR32ri  : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2032                    "shr{l}\t{$src2, $dst|$dst, $src2}",
2033                    [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
2034
2035 // Shift by 1
2036 def SHR8r1   : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
2037                  "shr{b}\t$dst",
2038                  [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
2039 def SHR16r1  : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
2040                  "shr{w}\t$dst",
2041                  [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
2042 def SHR32r1  : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
2043                  "shr{l}\t$dst",
2044                  [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
2045
2046 let isTwoAddress = 0 in {
2047   let Uses = [CL] in {
2048   def SHR8mCL  : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
2049                    "shr{b}\t{%cl, $dst|$dst, CL}",
2050                    [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
2051   def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
2052                    "shr{w}\t{%cl, $dst|$dst, CL}",
2053                    [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
2054                    OpSize;
2055   def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
2056                    "shr{l}\t{%cl, $dst|$dst, CL}",
2057                    [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
2058   }
2059   def SHR8mi   : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
2060                      "shr{b}\t{$src, $dst|$dst, $src}",
2061                   [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2062   def SHR16mi  : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
2063                      "shr{w}\t{$src, $dst|$dst, $src}",
2064                  [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2065                      OpSize;
2066   def SHR32mi  : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
2067                      "shr{l}\t{$src, $dst|$dst, $src}",
2068                  [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2069
2070   // Shift by 1
2071   def SHR8m1   : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
2072                    "shr{b}\t$dst",
2073                   [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2074   def SHR16m1  : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
2075                    "shr{w}\t$dst",
2076                  [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
2077   def SHR32m1  : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
2078                    "shr{l}\t$dst",
2079                  [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2080 }
2081
2082 let Uses = [CL] in {
2083 def SAR8rCL  : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
2084                  "sar{b}\t{%cl, $dst|$dst, CL}",
2085                  [(set GR8:$dst, (sra GR8:$src, CL))]>;
2086 def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
2087                  "sar{w}\t{%cl, $dst|$dst, CL}",
2088                  [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
2089 def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
2090                  "sar{l}\t{%cl, $dst|$dst, CL}",
2091                  [(set GR32:$dst, (sra GR32:$src, CL))]>;
2092 }
2093
2094 def SAR8ri   : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2095                    "sar{b}\t{$src2, $dst|$dst, $src2}",
2096                    [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
2097 def SAR16ri  : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2098                    "sar{w}\t{$src2, $dst|$dst, $src2}",
2099                    [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
2100                    OpSize;
2101 def SAR32ri  : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2102                    "sar{l}\t{$src2, $dst|$dst, $src2}",
2103                    [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
2104
2105 // Shift by 1
2106 def SAR8r1   : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
2107                  "sar{b}\t$dst",
2108                  [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
2109 def SAR16r1  : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
2110                  "sar{w}\t$dst",
2111                  [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
2112 def SAR32r1  : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
2113                  "sar{l}\t$dst",
2114                  [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2115
2116 let isTwoAddress = 0 in {
2117   let Uses = [CL] in {
2118   def SAR8mCL  : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
2119                    "sar{b}\t{%cl, $dst|$dst, CL}",
2120                    [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
2121   def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
2122                    "sar{w}\t{%cl, $dst|$dst, CL}",
2123                    [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2124   def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst), 
2125                    "sar{l}\t{%cl, $dst|$dst, CL}",
2126                    [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2127   }
2128   def SAR8mi   : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
2129                      "sar{b}\t{$src, $dst|$dst, $src}",
2130                   [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2131   def SAR16mi  : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
2132                      "sar{w}\t{$src, $dst|$dst, $src}",
2133                  [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2134                      OpSize;
2135   def SAR32mi  : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
2136                      "sar{l}\t{$src, $dst|$dst, $src}",
2137                  [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2138
2139   // Shift by 1
2140   def SAR8m1   : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
2141                    "sar{b}\t$dst",
2142                   [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2143   def SAR16m1  : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
2144                    "sar{w}\t$dst",
2145                  [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2146                      OpSize;
2147   def SAR32m1  : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
2148                    "sar{l}\t$dst",
2149                  [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2150 }
2151
2152 // Rotate instructions
2153 // FIXME: provide shorter instructions when imm8 == 1
2154 let Uses = [CL] in {
2155 def ROL8rCL  : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
2156                  "rol{b}\t{%cl, $dst|$dst, CL}",
2157                  [(set GR8:$dst, (rotl GR8:$src, CL))]>;
2158 def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
2159                  "rol{w}\t{%cl, $dst|$dst, CL}",
2160                  [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
2161 def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
2162                  "rol{l}\t{%cl, $dst|$dst, CL}",
2163                  [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2164 }
2165
2166 def ROL8ri   : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2167                    "rol{b}\t{$src2, $dst|$dst, $src2}",
2168                    [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
2169 def ROL16ri  : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2170                    "rol{w}\t{$src2, $dst|$dst, $src2}",
2171                    [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2172 def ROL32ri  : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2173                    "rol{l}\t{$src2, $dst|$dst, $src2}",
2174                    [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2175
2176 // Rotate by 1
2177 def ROL8r1   : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
2178                  "rol{b}\t$dst",
2179                  [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
2180 def ROL16r1  : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
2181                  "rol{w}\t$dst",
2182                  [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
2183 def ROL32r1  : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
2184                  "rol{l}\t$dst",
2185                  [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2186
2187 let isTwoAddress = 0 in {
2188   let Uses = [CL] in {
2189   def ROL8mCL  : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
2190                    "rol{b}\t{%cl, $dst|$dst, CL}",
2191                    [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
2192   def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
2193                    "rol{w}\t{%cl, $dst|$dst, CL}",
2194                    [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2195   def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
2196                    "rol{l}\t{%cl, $dst|$dst, CL}",
2197                    [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2198   }
2199   def ROL8mi   : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
2200                      "rol{b}\t{$src, $dst|$dst, $src}",
2201                  [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2202   def ROL16mi  : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
2203                      "rol{w}\t{$src, $dst|$dst, $src}",
2204                 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2205                      OpSize;
2206   def ROL32mi  : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
2207                      "rol{l}\t{$src, $dst|$dst, $src}",
2208                 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2209
2210   // Rotate by 1
2211   def ROL8m1   : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
2212                    "rol{b}\t$dst",
2213                  [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2214   def ROL16m1  : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
2215                    "rol{w}\t$dst",
2216                 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2217                      OpSize;
2218   def ROL32m1  : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
2219                    "rol{l}\t$dst",
2220                 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2221 }
2222
2223 let Uses = [CL] in {
2224 def ROR8rCL  : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
2225                  "ror{b}\t{%cl, $dst|$dst, CL}",
2226                  [(set GR8:$dst, (rotr GR8:$src, CL))]>;
2227 def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
2228                  "ror{w}\t{%cl, $dst|$dst, CL}",
2229                  [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
2230 def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
2231                  "ror{l}\t{%cl, $dst|$dst, CL}",
2232                  [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2233 }
2234
2235 def ROR8ri   : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2236                    "ror{b}\t{$src2, $dst|$dst, $src2}",
2237                    [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
2238 def ROR16ri  : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2239                    "ror{w}\t{$src2, $dst|$dst, $src2}",
2240                    [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2241 def ROR32ri  : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2242                    "ror{l}\t{$src2, $dst|$dst, $src2}",
2243                    [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2244
2245 // Rotate by 1
2246 def ROR8r1   : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
2247                  "ror{b}\t$dst",
2248                  [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
2249 def ROR16r1  : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
2250                  "ror{w}\t$dst",
2251                  [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
2252 def ROR32r1  : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
2253                  "ror{l}\t$dst",
2254                  [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2255
2256 let isTwoAddress = 0 in {
2257   let Uses = [CL] in {
2258   def ROR8mCL  : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
2259                    "ror{b}\t{%cl, $dst|$dst, CL}",
2260                    [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
2261   def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
2262                    "ror{w}\t{%cl, $dst|$dst, CL}",
2263                    [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2264   def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst), 
2265                    "ror{l}\t{%cl, $dst|$dst, CL}",
2266                    [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2267   }
2268   def ROR8mi   : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
2269                      "ror{b}\t{$src, $dst|$dst, $src}",
2270                  [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2271   def ROR16mi  : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
2272                      "ror{w}\t{$src, $dst|$dst, $src}",
2273                 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2274                      OpSize;
2275   def ROR32mi  : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
2276                      "ror{l}\t{$src, $dst|$dst, $src}",
2277                 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2278
2279   // Rotate by 1
2280   def ROR8m1   : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
2281                    "ror{b}\t$dst",
2282                  [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2283   def ROR16m1  : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
2284                    "ror{w}\t$dst",
2285                 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2286                      OpSize;
2287   def ROR32m1  : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
2288                    "ror{l}\t$dst",
2289                 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2290 }
2291
2292
2293
2294 // Double shift instructions (generalizations of rotate)
2295 let Uses = [CL] in {
2296 def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2297                    "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2298                    [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
2299 def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2300                    "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2301                    [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
2302 def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2303                    "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2304                    [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
2305                    TB, OpSize;
2306 def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2307                    "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2308                    [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
2309                    TB, OpSize;
2310 }
2311
2312 let isCommutable = 1 in {  // These instructions commute to each other.
2313 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
2314                      (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2315                      "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2316                      [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2317                                       (i8 imm:$src3)))]>,
2318                  TB;
2319 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
2320                      (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2321                      "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2322                      [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2323                                       (i8 imm:$src3)))]>,
2324                  TB;
2325 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
2326                      (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2327                      "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2328                      [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2329                                       (i8 imm:$src3)))]>,
2330                      TB, OpSize;
2331 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
2332                      (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2333                      "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2334                      [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2335                                       (i8 imm:$src3)))]>,
2336                      TB, OpSize;
2337 }
2338
2339 let isTwoAddress = 0 in {
2340   let Uses = [CL] in {
2341   def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2342                      "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2343                      [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
2344                        addr:$dst)]>, TB;
2345   def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2346                     "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2347                     [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
2348                       addr:$dst)]>, TB;
2349   }
2350   def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
2351                       (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2352                       "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2353                       [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2354                                         (i8 imm:$src3)), addr:$dst)]>,
2355                       TB;
2356   def SHRD32mri8 : Ii8<0xAC, MRMDestMem, 
2357                        (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2358                        "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2359                        [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2360                                          (i8 imm:$src3)), addr:$dst)]>,
2361                        TB;
2362
2363   let Uses = [CL] in {
2364   def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2365                      "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2366                      [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
2367                        addr:$dst)]>, TB, OpSize;
2368   def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2369                     "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2370                     [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
2371                       addr:$dst)]>, TB, OpSize;
2372   }
2373   def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
2374                       (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2375                       "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2376                       [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2377                                         (i8 imm:$src3)), addr:$dst)]>,
2378                       TB, OpSize;
2379   def SHRD16mri8 : Ii8<0xAC, MRMDestMem, 
2380                        (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2381                        "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2382                       [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2383                                         (i8 imm:$src3)), addr:$dst)]>,
2384                        TB, OpSize;
2385 }
2386 } // Defs = [EFLAGS]
2387
2388
2389 // Arithmetic.
2390 let Defs = [EFLAGS] in {
2391 let isCommutable = 1 in {   // X = ADD Y, Z   --> X = ADD Z, Y
2392 // Register-Register Addition
2393 def ADD8rr    : I<0x00, MRMDestReg, (outs GR8 :$dst),
2394                                     (ins GR8 :$src1, GR8 :$src2),
2395                   "add{b}\t{$src2, $dst|$dst, $src2}",
2396                   [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
2397                    (implicit EFLAGS)]>;
2398
2399 let isConvertibleToThreeAddress = 1 in {   // Can transform into LEA.
2400 // Register-Register Addition
2401 def ADD16rr  : I<0x01, MRMDestReg, (outs GR16:$dst),
2402                                    (ins GR16:$src1, GR16:$src2),
2403                  "add{w}\t{$src2, $dst|$dst, $src2}",
2404                  [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2405                   (implicit EFLAGS)]>, OpSize;
2406 def ADD32rr  : I<0x01, MRMDestReg, (outs GR32:$dst),
2407                                    (ins GR32:$src1, GR32:$src2),
2408                  "add{l}\t{$src2, $dst|$dst, $src2}",
2409                  [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2410                   (implicit EFLAGS)]>;
2411 } // end isConvertibleToThreeAddress
2412 } // end isCommutable
2413
2414 // Register-Memory Addition
2415 def ADD8rm   : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2416                                   (ins GR8 :$src1, i8mem :$src2),
2417                  "add{b}\t{$src2, $dst|$dst, $src2}",
2418                  [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2419                   (implicit EFLAGS)]>;
2420 def ADD16rm  : I<0x03, MRMSrcMem, (outs GR16:$dst),
2421                                   (ins GR16:$src1, i16mem:$src2),
2422                  "add{w}\t{$src2, $dst|$dst, $src2}",
2423                  [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2424                   (implicit EFLAGS)]>, OpSize;
2425 def ADD32rm  : I<0x03, MRMSrcMem, (outs GR32:$dst),
2426                                   (ins GR32:$src1, i32mem:$src2),
2427                  "add{l}\t{$src2, $dst|$dst, $src2}",
2428                  [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2429                   (implicit EFLAGS)]>;
2430
2431 // Register-Integer Addition
2432 def ADD8ri    : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2433                     "add{b}\t{$src2, $dst|$dst, $src2}",
2434                     [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2435                      (implicit EFLAGS)]>;
2436
2437 let isConvertibleToThreeAddress = 1 in {   // Can transform into LEA.
2438 // Register-Integer Addition
2439 def ADD16ri  : Ii16<0x81, MRM0r, (outs GR16:$dst),
2440                                  (ins GR16:$src1, i16imm:$src2),
2441                     "add{w}\t{$src2, $dst|$dst, $src2}",
2442                     [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2443                      (implicit EFLAGS)]>, OpSize;
2444 def ADD32ri  : Ii32<0x81, MRM0r, (outs GR32:$dst),
2445                                  (ins GR32:$src1, i32imm:$src2),
2446                     "add{l}\t{$src2, $dst|$dst, $src2}",
2447                     [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2448                      (implicit EFLAGS)]>;
2449 def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2450                                 (ins GR16:$src1, i16i8imm:$src2),
2451                    "add{w}\t{$src2, $dst|$dst, $src2}",
2452                    [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2453                     (implicit EFLAGS)]>, OpSize;
2454 def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2455                                 (ins GR32:$src1, i32i8imm:$src2),
2456                    "add{l}\t{$src2, $dst|$dst, $src2}",
2457                    [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2458                     (implicit EFLAGS)]>;
2459 }
2460
2461 let isTwoAddress = 0 in {
2462   // Memory-Register Addition
2463   def ADD8mr   : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2464                    "add{b}\t{$src2, $dst|$dst, $src2}",
2465                    [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2466                     (implicit EFLAGS)]>;
2467   def ADD16mr  : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2468                    "add{w}\t{$src2, $dst|$dst, $src2}",
2469                    [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2470                     (implicit EFLAGS)]>, OpSize;
2471   def ADD32mr  : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2472                    "add{l}\t{$src2, $dst|$dst, $src2}",
2473                    [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2474                     (implicit EFLAGS)]>;
2475   def ADD8mi   : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
2476                      "add{b}\t{$src2, $dst|$dst, $src2}",
2477                    [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2478                     (implicit EFLAGS)]>;
2479   def ADD16mi  : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
2480                       "add{w}\t{$src2, $dst|$dst, $src2}",
2481                   [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2482                    (implicit EFLAGS)]>, OpSize;
2483   def ADD32mi  : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
2484                       "add{l}\t{$src2, $dst|$dst, $src2}",
2485                       [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2486                        (implicit EFLAGS)]>;
2487   def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2488                      "add{w}\t{$src2, $dst|$dst, $src2}",
2489                      [(store (add (load addr:$dst), i16immSExt8:$src2),
2490                                   addr:$dst),
2491                       (implicit EFLAGS)]>, OpSize;
2492   def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2493                      "add{l}\t{$src2, $dst|$dst, $src2}",
2494                   [(store (add (load addr:$dst), i32immSExt8:$src2),
2495                                addr:$dst),
2496                    (implicit EFLAGS)]>;
2497
2498   // addition to rAX
2499   def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
2500                    "add{b}\t{$src, %al|%al, $src}", []>;
2501   def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
2502                       "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2503   def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
2504                       "add{l}\t{$src, %eax|%eax, $src}", []>;
2505 }
2506
2507 let Uses = [EFLAGS] in {
2508 let isCommutable = 1 in {  // X = ADC Y, Z --> X = ADC Z, Y
2509 def ADC8rr   : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2510                  "adc{b}\t{$src2, $dst|$dst, $src2}",
2511                  [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
2512 def ADC16rr  : I<0x11, MRMDestReg, (outs GR16:$dst),
2513                                    (ins GR16:$src1, GR16:$src2),
2514                  "adc{w}\t{$src2, $dst|$dst, $src2}",
2515                  [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
2516 def ADC32rr  : I<0x11, MRMDestReg, (outs GR32:$dst),
2517                                    (ins GR32:$src1, GR32:$src2),
2518                  "adc{l}\t{$src2, $dst|$dst, $src2}",
2519                  [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
2520 }
2521 def ADC8rm   : I<0x12, MRMSrcMem , (outs GR8:$dst), 
2522                                    (ins GR8:$src1, i8mem:$src2),
2523                  "adc{b}\t{$src2, $dst|$dst, $src2}",
2524                  [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
2525 def ADC16rm  : I<0x13, MRMSrcMem , (outs GR16:$dst),
2526                                    (ins GR16:$src1, i16mem:$src2),
2527                  "adc{w}\t{$src2, $dst|$dst, $src2}",
2528                  [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
2529                  OpSize;
2530 def ADC32rm  : I<0x13, MRMSrcMem , (outs GR32:$dst),
2531                                    (ins GR32:$src1, i32mem:$src2),
2532                  "adc{l}\t{$src2, $dst|$dst, $src2}",
2533                  [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2534 def ADC8ri   : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2535                     "adc{b}\t{$src2, $dst|$dst, $src2}",
2536                  [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
2537 def ADC16ri  : Ii16<0x81, MRM2r, (outs GR16:$dst),
2538                                  (ins GR16:$src1, i16imm:$src2),
2539                     "adc{w}\t{$src2, $dst|$dst, $src2}",
2540                  [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
2541 def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2542                                 (ins GR16:$src1, i16i8imm:$src2),
2543                    "adc{w}\t{$src2, $dst|$dst, $src2}",
2544                  [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2545                  OpSize;
2546 def ADC32ri  : Ii32<0x81, MRM2r, (outs GR32:$dst),
2547                                  (ins GR32:$src1, i32imm:$src2),
2548                     "adc{l}\t{$src2, $dst|$dst, $src2}",
2549                  [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
2550 def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2551                                 (ins GR32:$src1, i32i8imm:$src2),
2552                    "adc{l}\t{$src2, $dst|$dst, $src2}",
2553                  [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
2554
2555 let isTwoAddress = 0 in {
2556   def ADC8mr   : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2557                    "adc{b}\t{$src2, $dst|$dst, $src2}",
2558                    [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2559   def ADC16mr  : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2560                    "adc{w}\t{$src2, $dst|$dst, $src2}",
2561                    [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2562                    OpSize;
2563   def ADC32mr  : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2564                    "adc{l}\t{$src2, $dst|$dst, $src2}",
2565                    [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2566   def ADC8mi   : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
2567                       "adc{b}\t{$src2, $dst|$dst, $src2}",
2568                   [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2569   def ADC16mi  : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
2570                       "adc{w}\t{$src2, $dst|$dst, $src2}",
2571                   [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2572                   OpSize;
2573   def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2574                      "adc{w}\t{$src2, $dst|$dst, $src2}",
2575                [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2576                OpSize;
2577   def ADC32mi  : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
2578                       "adc{l}\t{$src2, $dst|$dst, $src2}",
2579                   [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2580   def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2581                      "adc{l}\t{$src2, $dst|$dst, $src2}",
2582                [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2583
2584   def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2585                    "adc{b}\t{$src, %al|%al, $src}", []>;
2586   def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
2587                       "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2588   def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
2589                       "adc{l}\t{$src, %eax|%eax, $src}", []>;
2590 }
2591 } // Uses = [EFLAGS]
2592
2593 // Register-Register Subtraction
2594 def SUB8rr  : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2595                 "sub{b}\t{$src2, $dst|$dst, $src2}",
2596                 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2597                  (implicit EFLAGS)]>;
2598 def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2599                 "sub{w}\t{$src2, $dst|$dst, $src2}",
2600                 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2601                  (implicit EFLAGS)]>, OpSize;
2602 def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2603                 "sub{l}\t{$src2, $dst|$dst, $src2}",
2604                 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2605                  (implicit EFLAGS)]>;
2606
2607 // Register-Memory Subtraction
2608 def SUB8rm  : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2609                                  (ins GR8 :$src1, i8mem :$src2),
2610                 "sub{b}\t{$src2, $dst|$dst, $src2}",
2611                 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2612                  (implicit EFLAGS)]>;
2613 def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2614                                  (ins GR16:$src1, i16mem:$src2),
2615                 "sub{w}\t{$src2, $dst|$dst, $src2}",
2616                 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2617                  (implicit EFLAGS)]>, OpSize;
2618 def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2619                                  (ins GR32:$src1, i32mem:$src2),
2620                 "sub{l}\t{$src2, $dst|$dst, $src2}",
2621                 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2622                  (implicit EFLAGS)]>;
2623
2624 // Register-Integer Subtraction
2625 def SUB8ri   : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2626                                  (ins GR8:$src1, i8imm:$src2),
2627                     "sub{b}\t{$src2, $dst|$dst, $src2}",
2628                     [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2629                      (implicit EFLAGS)]>;
2630 def SUB16ri  : Ii16<0x81, MRM5r, (outs GR16:$dst),
2631                                  (ins GR16:$src1, i16imm:$src2),
2632                     "sub{w}\t{$src2, $dst|$dst, $src2}",
2633                     [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2634                      (implicit EFLAGS)]>, OpSize;
2635 def SUB32ri  : Ii32<0x81, MRM5r, (outs GR32:$dst),
2636                                  (ins GR32:$src1, i32imm:$src2),
2637                     "sub{l}\t{$src2, $dst|$dst, $src2}",
2638                     [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2639                      (implicit EFLAGS)]>;
2640 def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2641                                 (ins GR16:$src1, i16i8imm:$src2),
2642                    "sub{w}\t{$src2, $dst|$dst, $src2}",
2643                    [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2644                     (implicit EFLAGS)]>, OpSize;
2645 def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2646                                 (ins GR32:$src1, i32i8imm:$src2),
2647                    "sub{l}\t{$src2, $dst|$dst, $src2}",
2648                    [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2649                     (implicit EFLAGS)]>;
2650
2651 let isTwoAddress = 0 in {
2652   // Memory-Register Subtraction
2653   def SUB8mr   : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
2654                    "sub{b}\t{$src2, $dst|$dst, $src2}",
2655                    [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2656                     (implicit EFLAGS)]>;
2657   def SUB16mr  : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2658                    "sub{w}\t{$src2, $dst|$dst, $src2}",
2659                    [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2660                     (implicit EFLAGS)]>, OpSize;
2661   def SUB32mr  : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2), 
2662                    "sub{l}\t{$src2, $dst|$dst, $src2}",
2663                    [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2664                     (implicit EFLAGS)]>;
2665
2666   // Memory-Integer Subtraction
2667   def SUB8mi   : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2), 
2668                      "sub{b}\t{$src2, $dst|$dst, $src2}",
2669                      [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2670                       (implicit EFLAGS)]>;
2671   def SUB16mi  : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2), 
2672                       "sub{w}\t{$src2, $dst|$dst, $src2}",
2673                       [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2674                        (implicit EFLAGS)]>, OpSize;
2675   def SUB32mi  : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2), 
2676                       "sub{l}\t{$src2, $dst|$dst, $src2}",
2677                       [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2678                        (implicit EFLAGS)]>;
2679   def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2), 
2680                      "sub{w}\t{$src2, $dst|$dst, $src2}",
2681                      [(store (sub (load addr:$dst), i16immSExt8:$src2),
2682                              addr:$dst),
2683                       (implicit EFLAGS)]>, OpSize;
2684   def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2685                      "sub{l}\t{$src2, $dst|$dst, $src2}",
2686                      [(store (sub (load addr:$dst), i32immSExt8:$src2),
2687                              addr:$dst),
2688                       (implicit EFLAGS)]>;
2689                       
2690   def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
2691                    "sub{b}\t{$src, %al|%al, $src}", []>;
2692   def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
2693                       "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2694   def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
2695                       "sub{l}\t{$src, %eax|%eax, $src}", []>;
2696 }
2697
2698 let Uses = [EFLAGS] in {
2699 def SBB8rr     : I<0x18, MRMDestReg, (outs GR8:$dst),
2700                                      (ins GR8:$src1, GR8:$src2),
2701                   "sbb{b}\t{$src2, $dst|$dst, $src2}",
2702                  [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
2703 def SBB16rr    : I<0x19, MRMDestReg, (outs GR16:$dst),
2704                                      (ins GR16:$src1, GR16:$src2),
2705                   "sbb{w}\t{$src2, $dst|$dst, $src2}",
2706                  [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
2707 def SBB32rr    : I<0x19, MRMDestReg, (outs GR32:$dst),
2708                                       (ins GR32:$src1, GR32:$src2),
2709                   "sbb{l}\t{$src2, $dst|$dst, $src2}",
2710                  [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
2711
2712 let isTwoAddress = 0 in {
2713   def SBB8mr   : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2), 
2714                    "sbb{b}\t{$src2, $dst|$dst, $src2}",
2715                    [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
2716   def SBB16mr  : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2), 
2717                    "sbb{w}\t{$src2, $dst|$dst, $src2}",
2718                    [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
2719                    OpSize;
2720   def SBB32mr  : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2), 
2721                    "sbb{l}\t{$src2, $dst|$dst, $src2}",
2722                    [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
2723   def SBB8mi  : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2), 
2724                       "sbb{b}\t{$src2, $dst|$dst, $src2}",
2725                    [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2726   def SBB16mi  : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2), 
2727                       "sbb{w}\t{$src2, $dst|$dst, $src2}",
2728                   [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2729                   OpSize;
2730   def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2), 
2731                      "sbb{w}\t{$src2, $dst|$dst, $src2}",
2732                [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2733                OpSize;
2734   def SBB32mi  : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2), 
2735                       "sbb{l}\t{$src2, $dst|$dst, $src2}",
2736                   [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2737   def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2), 
2738                      "sbb{l}\t{$src2, $dst|$dst, $src2}",
2739                [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2740                
2741   def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
2742                    "sbb{b}\t{$src, %al|%al, $src}", []>;
2743   def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
2744                       "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2745   def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
2746                       "sbb{l}\t{$src, %eax|%eax, $src}", []>;
2747 }
2748 def SBB8rm   : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2749                     "sbb{b}\t{$src2, $dst|$dst, $src2}",
2750                     [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
2751 def SBB16rm  : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2752                                   (ins GR16:$src1, i16mem:$src2),
2753                     "sbb{w}\t{$src2, $dst|$dst, $src2}",
2754                     [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
2755                     OpSize;
2756 def SBB32rm  : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2757                                   (ins GR32:$src1, i32mem:$src2),
2758                     "sbb{l}\t{$src2, $dst|$dst, $src2}",
2759                     [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
2760 def SBB8ri   : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2761                     "sbb{b}\t{$src2, $dst|$dst, $src2}",
2762                     [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
2763 def SBB16ri  : Ii16<0x81, MRM3r, (outs GR16:$dst),
2764                                  (ins GR16:$src1, i16imm:$src2),
2765                     "sbb{w}\t{$src2, $dst|$dst, $src2}",
2766                     [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
2767 def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2768                                 (ins GR16:$src1, i16i8imm:$src2),
2769                    "sbb{w}\t{$src2, $dst|$dst, $src2}",
2770                    [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
2771                    OpSize;
2772 def SBB32ri  : Ii32<0x81, MRM3r, (outs GR32:$dst), 
2773                                  (ins GR32:$src1, i32imm:$src2),
2774                     "sbb{l}\t{$src2, $dst|$dst, $src2}",
2775                     [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
2776 def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2777                                 (ins GR32:$src1, i32i8imm:$src2),
2778                    "sbb{l}\t{$src2, $dst|$dst, $src2}",
2779                    [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
2780 } // Uses = [EFLAGS]
2781 } // Defs = [EFLAGS]
2782
2783 let Defs = [EFLAGS] in {
2784 let isCommutable = 1 in {  // X = IMUL Y, Z --> X = IMUL Z, Y
2785 // Register-Register Signed Integer Multiply
2786 def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2787                  "imul{w}\t{$src2, $dst|$dst, $src2}",
2788                  [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2789                   (implicit EFLAGS)]>, TB, OpSize;
2790 def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2791                  "imul{l}\t{$src2, $dst|$dst, $src2}",
2792                  [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2793                   (implicit EFLAGS)]>, TB;
2794 }
2795
2796 // Register-Memory Signed Integer Multiply
2797 def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2798                                   (ins GR16:$src1, i16mem:$src2),
2799                  "imul{w}\t{$src2, $dst|$dst, $src2}",
2800                  [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2801                   (implicit EFLAGS)]>, TB, OpSize;
2802 def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2803                  "imul{l}\t{$src2, $dst|$dst, $src2}",
2804                  [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2805                   (implicit EFLAGS)]>, TB;
2806 } // Defs = [EFLAGS]
2807 } // end Two Address instructions
2808
2809 // Suprisingly enough, these are not two address instructions!
2810 let Defs = [EFLAGS] in {
2811 // Register-Integer Signed Integer Multiply
2812 def IMUL16rri  : Ii16<0x69, MRMSrcReg,                      // GR16 = GR16*I16
2813                       (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2814                       "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2815                       [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2816                        (implicit EFLAGS)]>, OpSize;
2817 def IMUL32rri  : Ii32<0x69, MRMSrcReg,                      // GR32 = GR32*I32
2818                       (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2819                       "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2820                       [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2821                        (implicit EFLAGS)]>;
2822 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg,                       // GR16 = GR16*I8
2823                      (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2824                      "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2825                      [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2826                       (implicit EFLAGS)]>, OpSize;
2827 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg,                       // GR32 = GR32*I8
2828                      (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2829                      "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2830                      [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2831                       (implicit EFLAGS)]>;
2832
2833 // Memory-Integer Signed Integer Multiply
2834 def IMUL16rmi  : Ii16<0x69, MRMSrcMem,                      // GR16 = [mem16]*I16
2835                       (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
2836                       "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2837                       [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2838                        (implicit EFLAGS)]>, OpSize;
2839 def IMUL32rmi  : Ii32<0x69, MRMSrcMem,                      // GR32 = [mem32]*I32
2840                       (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
2841                       "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2842                       [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2843                        (implicit EFLAGS)]>;
2844 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem,                       // GR16 = [mem16]*I8
2845                      (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
2846                      "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2847                      [(set GR16:$dst, (mul (load addr:$src1),
2848                                        i16immSExt8:$src2)),
2849                       (implicit EFLAGS)]>, OpSize;
2850 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem,                       // GR32 = [mem32]*I8
2851                      (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
2852                      "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2853                      [(set GR32:$dst, (mul (load addr:$src1),
2854                                            i32immSExt8:$src2)),
2855                       (implicit EFLAGS)]>;
2856 } // Defs = [EFLAGS]
2857
2858 //===----------------------------------------------------------------------===//
2859 // Test instructions are just like AND, except they don't generate a result.
2860 //
2861 let Defs = [EFLAGS] in {
2862 let isCommutable = 1 in {   // TEST X, Y   --> TEST Y, X
2863 def TEST8rr  : I<0x84, MRMDestReg, (outs),  (ins GR8:$src1, GR8:$src2),
2864                      "test{b}\t{$src2, $src1|$src1, $src2}",
2865                      [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
2866                       (implicit EFLAGS)]>;
2867 def TEST16rr : I<0x85, MRMDestReg, (outs),  (ins GR16:$src1, GR16:$src2),
2868                      "test{w}\t{$src2, $src1|$src1, $src2}",
2869                      [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
2870                       (implicit EFLAGS)]>,
2871                  OpSize;
2872 def TEST32rr : I<0x85, MRMDestReg, (outs),  (ins GR32:$src1, GR32:$src2),
2873                      "test{l}\t{$src2, $src1|$src1, $src2}",
2874                      [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
2875                       (implicit EFLAGS)]>;
2876 }
2877
2878 def TEST8i8  : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
2879                    "test{b}\t{$src, %al|%al, $src}", []>;
2880 def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
2881                      "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2882 def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
2883                      "test{l}\t{$src, %eax|%eax, $src}", []>;
2884
2885 def TEST8rm  : I<0x84, MRMSrcMem, (outs),  (ins GR8 :$src1, i8mem :$src2),
2886                      "test{b}\t{$src2, $src1|$src1, $src2}",
2887                      [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2888                       (implicit EFLAGS)]>;
2889 def TEST16rm : I<0x85, MRMSrcMem, (outs),  (ins GR16:$src1, i16mem:$src2),
2890                      "test{w}\t{$src2, $src1|$src1, $src2}",
2891                      [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2892                       (implicit EFLAGS)]>, OpSize;
2893 def TEST32rm : I<0x85, MRMSrcMem, (outs),  (ins GR32:$src1, i32mem:$src2),
2894                      "test{l}\t{$src2, $src1|$src1, $src2}",
2895                      [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2896                       (implicit EFLAGS)]>;
2897
2898 def TEST8ri  : Ii8 <0xF6, MRM0r,                     // flags = GR8  & imm8
2899                     (outs),  (ins GR8:$src1, i8imm:$src2),
2900                     "test{b}\t{$src2, $src1|$src1, $src2}",
2901                     [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
2902                      (implicit EFLAGS)]>;
2903 def TEST16ri : Ii16<0xF7, MRM0r,                     // flags = GR16 & imm16
2904                     (outs),  (ins GR16:$src1, i16imm:$src2),
2905                     "test{w}\t{$src2, $src1|$src1, $src2}",
2906                     [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
2907                      (implicit EFLAGS)]>, OpSize;
2908 def TEST32ri : Ii32<0xF7, MRM0r,                     // flags = GR32 & imm32
2909                     (outs),  (ins GR32:$src1, i32imm:$src2),
2910                     "test{l}\t{$src2, $src1|$src1, $src2}",
2911                     [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
2912                      (implicit EFLAGS)]>;
2913
2914 def TEST8mi  : Ii8 <0xF6, MRM0m,                   // flags = [mem8]  & imm8
2915                     (outs), (ins i8mem:$src1, i8imm:$src2),
2916                     "test{b}\t{$src2, $src1|$src1, $src2}",
2917                     [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2918                      (implicit EFLAGS)]>;
2919 def TEST16mi : Ii16<0xF7, MRM0m,                   // flags = [mem16] & imm16
2920                     (outs), (ins i16mem:$src1, i16imm:$src2),
2921                     "test{w}\t{$src2, $src1|$src1, $src2}",
2922                     [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2923                      (implicit EFLAGS)]>, OpSize;
2924 def TEST32mi : Ii32<0xF7, MRM0m,                   // flags = [mem32] & imm32
2925                     (outs), (ins i32mem:$src1, i32imm:$src2),
2926                     "test{l}\t{$src2, $src1|$src1, $src2}",
2927                     [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
2928                      (implicit EFLAGS)]>;
2929 } // Defs = [EFLAGS]
2930
2931
2932 // Condition code ops, incl. set if equal/not equal/...
2933 let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
2934 def SAHF     : I<0x9E, RawFrm, (outs),  (ins), "sahf", []>;  // flags = AH
2935 let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
2936 def LAHF     : I<0x9F, RawFrm, (outs),  (ins), "lahf", []>;  // AH = flags
2937
2938 let Uses = [EFLAGS] in {
2939 def SETEr    : I<0x94, MRM0r, 
2940                  (outs GR8   :$dst), (ins),
2941                  "sete\t$dst",
2942                  [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
2943                TB;                        // GR8 = ==
2944 def SETEm    : I<0x94, MRM0m, 
2945                  (outs), (ins i8mem:$dst),
2946                  "sete\t$dst",
2947                  [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
2948                TB;                        // [mem8] = ==
2949
2950 def SETNEr   : I<0x95, MRM0r, 
2951                  (outs GR8   :$dst), (ins),
2952                  "setne\t$dst",
2953                  [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
2954                TB;                        // GR8 = !=
2955 def SETNEm   : I<0x95, MRM0m, 
2956                  (outs), (ins i8mem:$dst),
2957                  "setne\t$dst",
2958                  [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
2959                TB;                        // [mem8] = !=
2960
2961 def SETLr    : I<0x9C, MRM0r, 
2962                  (outs GR8   :$dst), (ins),
2963                  "setl\t$dst",
2964                  [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
2965                TB;                        // GR8 = <  signed
2966 def SETLm    : I<0x9C, MRM0m, 
2967                  (outs), (ins i8mem:$dst),
2968                  "setl\t$dst",
2969                  [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
2970                TB;                        // [mem8] = <  signed
2971
2972 def SETGEr   : I<0x9D, MRM0r, 
2973                  (outs GR8   :$dst), (ins),
2974                  "setge\t$dst",
2975                  [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
2976                TB;                        // GR8 = >= signed
2977 def SETGEm   : I<0x9D, MRM0m, 
2978                  (outs), (ins i8mem:$dst),
2979                  "setge\t$dst",
2980                  [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
2981                TB;                        // [mem8] = >= signed
2982
2983 def SETLEr   : I<0x9E, MRM0r, 
2984                  (outs GR8   :$dst), (ins),
2985                  "setle\t$dst",
2986                  [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
2987                TB;                        // GR8 = <= signed
2988 def SETLEm   : I<0x9E, MRM0m, 
2989                  (outs), (ins i8mem:$dst),
2990                  "setle\t$dst",
2991                  [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
2992                TB;                        // [mem8] = <= signed
2993
2994 def SETGr    : I<0x9F, MRM0r, 
2995                  (outs GR8   :$dst), (ins),
2996                  "setg\t$dst",
2997                  [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
2998                TB;                        // GR8 = >  signed
2999 def SETGm    : I<0x9F, MRM0m, 
3000                  (outs), (ins i8mem:$dst),
3001                  "setg\t$dst",
3002                  [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
3003                TB;                        // [mem8] = >  signed
3004
3005 def SETBr    : I<0x92, MRM0r,
3006                  (outs GR8   :$dst), (ins),
3007                  "setb\t$dst",
3008                  [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
3009                TB;                        // GR8 = <  unsign
3010 def SETBm    : I<0x92, MRM0m,
3011                  (outs), (ins i8mem:$dst),
3012                  "setb\t$dst",
3013                  [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
3014                TB;                        // [mem8] = <  unsign
3015
3016 def SETAEr   : I<0x93, MRM0r, 
3017                  (outs GR8   :$dst), (ins),
3018                  "setae\t$dst",
3019                  [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
3020                TB;                        // GR8 = >= unsign
3021 def SETAEm   : I<0x93, MRM0m, 
3022                  (outs), (ins i8mem:$dst),
3023                  "setae\t$dst",
3024                  [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
3025                TB;                        // [mem8] = >= unsign
3026
3027 def SETBEr   : I<0x96, MRM0r, 
3028                  (outs GR8   :$dst), (ins),
3029                  "setbe\t$dst",
3030                  [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
3031                TB;                        // GR8 = <= unsign
3032 def SETBEm   : I<0x96, MRM0m, 
3033                  (outs), (ins i8mem:$dst),
3034                  "setbe\t$dst",
3035                  [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
3036                TB;                        // [mem8] = <= unsign
3037
3038 def SETAr    : I<0x97, MRM0r, 
3039                  (outs GR8   :$dst), (ins),
3040                  "seta\t$dst",
3041                  [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
3042                TB;                        // GR8 = >  signed
3043 def SETAm    : I<0x97, MRM0m, 
3044                  (outs), (ins i8mem:$dst),
3045                  "seta\t$dst",
3046                  [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
3047                TB;                        // [mem8] = >  signed
3048
3049 def SETSr    : I<0x98, MRM0r, 
3050                  (outs GR8   :$dst), (ins),
3051                  "sets\t$dst",
3052                  [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
3053                TB;                        // GR8 = <sign bit>
3054 def SETSm    : I<0x98, MRM0m, 
3055                  (outs), (ins i8mem:$dst),
3056                  "sets\t$dst",
3057                  [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
3058                TB;                        // [mem8] = <sign bit>
3059 def SETNSr   : I<0x99, MRM0r, 
3060                  (outs GR8   :$dst), (ins),
3061                  "setns\t$dst",
3062                  [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
3063                TB;                        // GR8 = !<sign bit>
3064 def SETNSm   : I<0x99, MRM0m, 
3065                  (outs), (ins i8mem:$dst),
3066                  "setns\t$dst",
3067                  [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
3068                TB;                        // [mem8] = !<sign bit>
3069
3070 def SETPr    : I<0x9A, MRM0r, 
3071                  (outs GR8   :$dst), (ins),
3072                  "setp\t$dst",
3073                  [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
3074                TB;                        // GR8 = parity
3075 def SETPm    : I<0x9A, MRM0m, 
3076                  (outs), (ins i8mem:$dst),
3077                  "setp\t$dst",
3078                  [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
3079                TB;                        // [mem8] = parity
3080 def SETNPr   : I<0x9B, MRM0r, 
3081                  (outs GR8   :$dst), (ins),
3082                  "setnp\t$dst",
3083                  [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
3084                TB;                        // GR8 = not parity
3085 def SETNPm   : I<0x9B, MRM0m, 
3086                  (outs), (ins i8mem:$dst),
3087                  "setnp\t$dst",
3088                  [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
3089                TB;                        // [mem8] = not parity
3090
3091 def SETOr    : I<0x90, MRM0r, 
3092                  (outs GR8   :$dst), (ins),
3093                  "seto\t$dst",
3094                  [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
3095                TB;                        // GR8 = overflow
3096 def SETOm    : I<0x90, MRM0m, 
3097                  (outs), (ins i8mem:$dst),
3098                  "seto\t$dst",
3099                  [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
3100                TB;                        // [mem8] = overflow
3101 def SETNOr   : I<0x91, MRM0r, 
3102                  (outs GR8   :$dst), (ins),
3103                  "setno\t$dst",
3104                  [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3105                TB;                        // GR8 = not overflow
3106 def SETNOm   : I<0x91, MRM0m, 
3107                  (outs), (ins i8mem:$dst),
3108                  "setno\t$dst",
3109                  [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3110                TB;                        // [mem8] = not overflow
3111 } // Uses = [EFLAGS]
3112
3113
3114 // Integer comparisons
3115 let Defs = [EFLAGS] in {
3116 def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3117                  "cmp{b}\t{$src, %al|%al, $src}", []>;
3118 def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3119                     "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3120 def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3121                     "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3122
3123 def CMP8rr  : I<0x38, MRMDestReg,
3124                 (outs), (ins GR8 :$src1, GR8 :$src2),
3125                 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3126                 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
3127 def CMP16rr : I<0x39, MRMDestReg,
3128                 (outs), (ins GR16:$src1, GR16:$src2),
3129                 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3130                 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
3131 def CMP32rr : I<0x39, MRMDestReg,
3132                 (outs), (ins GR32:$src1, GR32:$src2),
3133                 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3134                 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
3135 def CMP8mr  : I<0x38, MRMDestMem,
3136                 (outs), (ins i8mem :$src1, GR8 :$src2),
3137                 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3138                 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
3139                  (implicit EFLAGS)]>;
3140 def CMP16mr : I<0x39, MRMDestMem,
3141                 (outs), (ins i16mem:$src1, GR16:$src2),
3142                 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3143                 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
3144                  (implicit EFLAGS)]>, OpSize;
3145 def CMP32mr : I<0x39, MRMDestMem,
3146                 (outs), (ins i32mem:$src1, GR32:$src2),
3147                 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3148                 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
3149                  (implicit EFLAGS)]>;
3150 def CMP8rm  : I<0x3A, MRMSrcMem,
3151                 (outs), (ins GR8 :$src1, i8mem :$src2),
3152                 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3153                 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
3154                  (implicit EFLAGS)]>;
3155 def CMP16rm : I<0x3B, MRMSrcMem,
3156                 (outs), (ins GR16:$src1, i16mem:$src2),
3157                 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3158                 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
3159                  (implicit EFLAGS)]>, OpSize;
3160 def CMP32rm : I<0x3B, MRMSrcMem,
3161                 (outs), (ins GR32:$src1, i32mem:$src2),
3162                 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3163                 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
3164                  (implicit EFLAGS)]>;
3165 def CMP8ri  : Ii8<0x80, MRM7r,
3166                   (outs), (ins GR8:$src1, i8imm:$src2),
3167                   "cmp{b}\t{$src2, $src1|$src1, $src2}",
3168                   [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
3169 def CMP16ri : Ii16<0x81, MRM7r,
3170                    (outs), (ins GR16:$src1, i16imm:$src2),
3171                    "cmp{w}\t{$src2, $src1|$src1, $src2}",
3172                    [(X86cmp GR16:$src1, imm:$src2),
3173                     (implicit EFLAGS)]>, OpSize;
3174 def CMP32ri : Ii32<0x81, MRM7r,
3175                    (outs), (ins GR32:$src1, i32imm:$src2),
3176                    "cmp{l}\t{$src2, $src1|$src1, $src2}",
3177                    [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
3178 def CMP8mi  : Ii8 <0x80, MRM7m,
3179                    (outs), (ins i8mem :$src1, i8imm :$src2),
3180                    "cmp{b}\t{$src2, $src1|$src1, $src2}",
3181                    [(X86cmp (loadi8 addr:$src1), imm:$src2),
3182                     (implicit EFLAGS)]>;
3183 def CMP16mi : Ii16<0x81, MRM7m,
3184                    (outs), (ins i16mem:$src1, i16imm:$src2),
3185                    "cmp{w}\t{$src2, $src1|$src1, $src2}",
3186                    [(X86cmp (loadi16 addr:$src1), imm:$src2),
3187                     (implicit EFLAGS)]>, OpSize;
3188 def CMP32mi : Ii32<0x81, MRM7m,
3189                    (outs), (ins i32mem:$src1, i32imm:$src2),
3190                    "cmp{l}\t{$src2, $src1|$src1, $src2}",
3191                    [(X86cmp (loadi32 addr:$src1), imm:$src2),
3192                     (implicit EFLAGS)]>;
3193 def CMP16ri8 : Ii8<0x83, MRM7r,
3194                    (outs), (ins GR16:$src1, i16i8imm:$src2),
3195                    "cmp{w}\t{$src2, $src1|$src1, $src2}",
3196                    [(X86cmp GR16:$src1, i16immSExt8:$src2),
3197                     (implicit EFLAGS)]>, OpSize;
3198 def CMP16mi8 : Ii8<0x83, MRM7m,
3199                    (outs), (ins i16mem:$src1, i16i8imm:$src2),
3200                    "cmp{w}\t{$src2, $src1|$src1, $src2}",
3201                    [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
3202                     (implicit EFLAGS)]>, OpSize;
3203 def CMP32mi8 : Ii8<0x83, MRM7m,
3204                    (outs), (ins i32mem:$src1, i32i8imm:$src2),
3205                    "cmp{l}\t{$src2, $src1|$src1, $src2}",
3206                    [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
3207                     (implicit EFLAGS)]>;
3208 def CMP32ri8 : Ii8<0x83, MRM7r,
3209                    (outs), (ins GR32:$src1, i32i8imm:$src2),
3210                    "cmp{l}\t{$src2, $src1|$src1, $src2}",
3211                    [(X86cmp GR32:$src1, i32immSExt8:$src2),
3212                     (implicit EFLAGS)]>;
3213 } // Defs = [EFLAGS]
3214
3215 // Bit tests.
3216 // TODO: BTC, BTR, and BTS
3217 let Defs = [EFLAGS] in {
3218 def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3219                "bt{w}\t{$src2, $src1|$src1, $src2}",
3220                [(X86bt GR16:$src1, GR16:$src2),
3221                 (implicit EFLAGS)]>, OpSize, TB;
3222 def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3223                "bt{l}\t{$src2, $src1|$src1, $src2}",
3224                [(X86bt GR32:$src1, GR32:$src2),
3225                 (implicit EFLAGS)]>, TB;
3226
3227 // Unlike with the register+register form, the memory+register form of the
3228 // bt instruction does not ignore the high bits of the index. From ISel's
3229 // perspective, this is pretty bizarre. Disable these instructions for now.
3230 //def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3231 //               "bt{w}\t{$src2, $src1|$src1, $src2}",
3232 //               [(X86bt (loadi16 addr:$src1), GR16:$src2),
3233 //                (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
3234 //def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3235 //               "bt{l}\t{$src2, $src1|$src1, $src2}",
3236 //               [(X86bt (loadi32 addr:$src1), GR32:$src2),
3237 //                (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
3238
3239 def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3240                 "bt{w}\t{$src2, $src1|$src1, $src2}",
3241                 [(X86bt GR16:$src1, i16immSExt8:$src2),
3242                  (implicit EFLAGS)]>, OpSize, TB;
3243 def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3244                 "bt{l}\t{$src2, $src1|$src1, $src2}",
3245                 [(X86bt GR32:$src1, i32immSExt8:$src2),
3246                  (implicit EFLAGS)]>, TB;
3247 // Note that these instructions don't need FastBTMem because that
3248 // only applies when the other operand is in a register. When it's
3249 // an immediate, bt is still fast.
3250 def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3251                 "bt{w}\t{$src2, $src1|$src1, $src2}",
3252                 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3253                  (implicit EFLAGS)]>, OpSize, TB;
3254 def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3255                 "bt{l}\t{$src2, $src1|$src1, $src2}",
3256                 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3257                  (implicit EFLAGS)]>, TB;
3258 } // Defs = [EFLAGS]
3259
3260 // Sign/Zero extenders
3261 // Use movsbl intead of movsbw; we don't care about the high 16 bits
3262 // of the register here. This has a smaller encoding and avoids a
3263 // partial-register update.
3264 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3265                    "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3266                    [(set GR16:$dst, (sext GR8:$src))]>, TB;
3267 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3268                    "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3269                    [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
3270 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3271                    "movs{bl|x}\t{$src, $dst|$dst, $src}",
3272                    [(set GR32:$dst, (sext GR8:$src))]>, TB;
3273 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3274                    "movs{bl|x}\t{$src, $dst|$dst, $src}",
3275                    [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
3276 def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3277                    "movs{wl|x}\t{$src, $dst|$dst, $src}",
3278                    [(set GR32:$dst, (sext GR16:$src))]>, TB;
3279 def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3280                    "movs{wl|x}\t{$src, $dst|$dst, $src}",
3281                    [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3282
3283 // Use movzbl intead of movzbw; we don't care about the high 16 bits
3284 // of the register here. This has a smaller encoding and avoids a
3285 // partial-register update.
3286 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3287                    "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3288                    [(set GR16:$dst, (zext GR8:$src))]>, TB;
3289 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3290                    "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3291                    [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
3292 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3293                    "movz{bl|x}\t{$src, $dst|$dst, $src}",
3294                    [(set GR32:$dst, (zext GR8:$src))]>, TB;
3295 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3296                    "movz{bl|x}\t{$src, $dst|$dst, $src}",
3297                    [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
3298 def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3299                    "movz{wl|x}\t{$src, $dst|$dst, $src}",
3300                    [(set GR32:$dst, (zext GR16:$src))]>, TB;
3301 def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3302                    "movz{wl|x}\t{$src, $dst|$dst, $src}",
3303                    [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3304
3305 // These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3306 // except that they use GR32_NOREX for the output operand register class
3307 // instead of GR32. This allows them to operate on h registers on x86-64.
3308 def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3309                          (outs GR32_NOREX:$dst), (ins GR8:$src),
3310                          "movz{bl|x}\t{$src, $dst|$dst, $src}  # NOREX",
3311                          []>, TB;
3312 let mayLoad = 1 in
3313 def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3314                          (outs GR32_NOREX:$dst), (ins i8mem:$src),
3315                          "movz{bl|x}\t{$src, $dst|$dst, $src}  # NOREX",
3316                          []>, TB;
3317
3318 let neverHasSideEffects = 1 in {
3319   let Defs = [AX], Uses = [AL] in
3320   def CBW : I<0x98, RawFrm, (outs), (ins),
3321               "{cbtw|cbw}", []>, OpSize;   // AX = signext(AL)
3322   let Defs = [EAX], Uses = [AX] in
3323   def CWDE : I<0x98, RawFrm, (outs), (ins),
3324               "{cwtl|cwde}", []>;   // EAX = signext(AX)
3325
3326   let Defs = [AX,DX], Uses = [AX] in
3327   def CWD : I<0x99, RawFrm, (outs), (ins),
3328               "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3329   let Defs = [EAX,EDX], Uses = [EAX] in
3330   def CDQ : I<0x99, RawFrm, (outs), (ins),
3331               "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3332 }
3333
3334 //===----------------------------------------------------------------------===//
3335 // Alias Instructions
3336 //===----------------------------------------------------------------------===//
3337
3338 // Alias instructions that map movr0 to xor.
3339 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
3340 let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3341     isCodeGenOnly = 1 in {
3342 def MOV8r0   : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
3343                  "xor{b}\t$dst, $dst",
3344                  [(set GR8:$dst, 0)]>;
3345 // Use xorl instead of xorw since we don't care about the high 16 bits,
3346 // it's smaller, and it avoids a partial-register update.
3347 def MOV16r0  : I<0x31, MRMInitReg,  (outs GR16:$dst), (ins),
3348                  "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
3349                  [(set GR16:$dst, 0)]>;
3350 def MOV32r0  : I<0x31, MRMInitReg,  (outs GR32:$dst), (ins),
3351                  "xor{l}\t$dst, $dst",
3352                  [(set GR32:$dst, 0)]>;
3353 }
3354
3355 //===----------------------------------------------------------------------===//
3356 // Thread Local Storage Instructions
3357 //
3358
3359 // All calls clobber the non-callee saved registers. ESP is marked as
3360 // a use to prevent stack-pointer assignments that appear immediately
3361 // before calls from potentially appearing dead.
3362 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3363             MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3364             XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3365             XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
3366     Uses = [ESP] in
3367 def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3368                   "leal\t$sym, %eax; "
3369                   "call\t___tls_get_addr@PLT",
3370                   [(X86tlsaddr tls32addr:$sym)]>,
3371                   Requires<[In32BitMode]>;
3372
3373 let AddedComplexity = 5, isCodeGenOnly = 1 in
3374 def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3375                    "movl\t%gs:$src, $dst",
3376                    [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3377
3378 let AddedComplexity = 5, isCodeGenOnly = 1 in
3379 def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3380                    "movl\t%fs:$src, $dst",
3381                    [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3382
3383 //===----------------------------------------------------------------------===//
3384 // DWARF Pseudo Instructions
3385 //
3386
3387 def DWARF_LOC   : I<0, Pseudo, (outs),
3388                     (ins i32imm:$line, i32imm:$col, i32imm:$file),
3389                     ".loc\t$file $line $col",
3390                     [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3391                       (i32 imm:$file))]>;
3392
3393 //===----------------------------------------------------------------------===//
3394 // EH Pseudo Instructions
3395 //
3396 let isTerminator = 1, isReturn = 1, isBarrier = 1,
3397     hasCtrlDep = 1, isCodeGenOnly = 1 in {
3398 def EH_RETURN   : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
3399                     "ret\t#eh_return, addr: $addr",
3400                     [(X86ehret GR32:$addr)]>;
3401
3402 }
3403
3404 //===----------------------------------------------------------------------===//
3405 // Atomic support
3406 //
3407
3408 // Atomic swap. These are just normal xchg instructions. But since a memory
3409 // operand is referenced, the atomicity is ensured.
3410 let Constraints = "$val = $dst" in {
3411 def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3412                "xchg{l}\t{$val, $ptr|$ptr, $val}", 
3413                [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3414 def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3415                "xchg{w}\t{$val, $ptr|$ptr, $val}", 
3416                [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>, 
3417                 OpSize;
3418 def XCHG8rm  : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3419                "xchg{b}\t{$val, $ptr|$ptr, $val}", 
3420                [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3421 }
3422
3423 // Atomic compare and swap.
3424 let Defs = [EAX, EFLAGS], Uses = [EAX] in {
3425 def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
3426                "lock\n\t"
3427                "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
3428                [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
3429 }
3430 let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
3431 def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
3432                "lock\n\t"
3433                "cmpxchg8b\t$ptr",
3434                [(X86cas8 addr:$ptr)]>, TB, LOCK;
3435 }
3436
3437 let Defs = [AX, EFLAGS], Uses = [AX] in {
3438 def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
3439                "lock\n\t"
3440                "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
3441                [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
3442 }
3443 let Defs = [AL, EFLAGS], Uses = [AL] in {
3444 def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
3445                "lock\n\t"
3446                "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
3447                [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
3448 }
3449
3450 // Atomic exchange and add
3451 let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3452 def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3453                "lock\n\t"
3454                "xadd{l}\t{$val, $ptr|$ptr, $val}",
3455                [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
3456                 TB, LOCK;
3457 def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3458                "lock\n\t"
3459                "xadd{w}\t{$val, $ptr|$ptr, $val}",
3460                [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
3461                 TB, OpSize, LOCK;
3462 def LXADD8  : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3463                "lock\n\t"
3464                "xadd{b}\t{$val, $ptr|$ptr, $val}",
3465                [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
3466                 TB, LOCK;
3467 }
3468
3469 // Optimized codegen when the non-memory output is not used.
3470 // FIXME: Use normal add / sub instructions and add lock prefix dynamically.
3471 def LOCK_ADD8mr  : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3472                     "lock\n\t"
3473                     "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3474 def LOCK_ADD16mr  : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3475                     "lock\n\t"
3476                     "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3477 def LOCK_ADD32mr  : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3478                     "lock\n\t"
3479                     "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3480 def LOCK_ADD8mi   : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3481                     "lock\n\t"
3482                     "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3483 def LOCK_ADD16mi  : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3484                     "lock\n\t"
3485                      "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3486 def LOCK_ADD32mi  : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3487                     "lock\n\t"
3488                     "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3489 def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3490                     "lock\n\t"
3491                     "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3492 def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3493                     "lock\n\t"
3494                     "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3495
3496 def LOCK_INC8m  : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3497                     "lock\n\t"
3498                     "inc{b}\t$dst", []>, LOCK;
3499 def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3500                     "lock\n\t"
3501                     "inc{w}\t$dst", []>, OpSize, LOCK;
3502 def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3503                     "lock\n\t"
3504                     "inc{l}\t$dst", []>, LOCK;
3505
3506 def LOCK_SUB8mr   : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3507                     "lock\n\t"
3508                     "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3509 def LOCK_SUB16mr  : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3510                     "lock\n\t"
3511                     "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3512 def LOCK_SUB32mr  : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2), 
3513                     "lock\n\t"
3514                     "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3515 def LOCK_SUB8mi   : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2), 
3516                     "lock\n\t"
3517                     "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3518 def LOCK_SUB16mi  : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2), 
3519                     "lock\n\t"
3520                     "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3521 def LOCK_SUB32mi  : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2), 
3522                     "lock\n\t"
3523                      "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3524 def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2), 
3525                     "lock\n\t"
3526                      "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3527 def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3528                     "lock\n\t"
3529                      "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3530
3531 def LOCK_DEC8m  : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3532                     "lock\n\t"
3533                     "dec{b}\t$dst", []>, LOCK;
3534 def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3535                     "lock\n\t"
3536                     "dec{w}\t$dst", []>, OpSize, LOCK;
3537 def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3538                     "lock\n\t"
3539                     "dec{l}\t$dst", []>, LOCK;
3540
3541 // Atomic exchange, and, or, xor
3542 let Constraints = "$val = $dst", Defs = [EFLAGS],
3543                   usesCustomDAGSchedInserter = 1 in {
3544 def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3545                "#ATOMAND32 PSEUDO!", 
3546                [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
3547 def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3548                "#ATOMOR32 PSEUDO!", 
3549                [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
3550 def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3551                "#ATOMXOR32 PSEUDO!", 
3552                [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
3553 def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3554                "#ATOMNAND32 PSEUDO!", 
3555                [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
3556 def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3557                "#ATOMMIN32 PSEUDO!", 
3558                [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
3559 def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3560                "#ATOMMAX32 PSEUDO!", 
3561                [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
3562 def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3563                "#ATOMUMIN32 PSEUDO!", 
3564                [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
3565 def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3566                "#ATOMUMAX32 PSEUDO!", 
3567                [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
3568
3569 def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3570                "#ATOMAND16 PSEUDO!", 
3571                [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
3572 def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3573                "#ATOMOR16 PSEUDO!", 
3574                [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
3575 def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3576                "#ATOMXOR16 PSEUDO!", 
3577                [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
3578 def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3579                "#ATOMNAND16 PSEUDO!", 
3580                [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
3581 def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3582                "#ATOMMIN16 PSEUDO!", 
3583                [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
3584 def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3585                "#ATOMMAX16 PSEUDO!", 
3586                [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
3587 def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3588                "#ATOMUMIN16 PSEUDO!", 
3589                [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
3590 def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3591                "#ATOMUMAX16 PSEUDO!", 
3592                [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
3593
3594 def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3595                "#ATOMAND8 PSEUDO!", 
3596                [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
3597 def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3598                "#ATOMOR8 PSEUDO!", 
3599                [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
3600 def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3601                "#ATOMXOR8 PSEUDO!", 
3602                [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
3603 def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3604                "#ATOMNAND8 PSEUDO!", 
3605                [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
3606 }
3607
3608 let Constraints = "$val1 = $dst1, $val2 = $dst2", 
3609                   Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3610                   Uses = [EAX, EBX, ECX, EDX],
3611                   mayLoad = 1, mayStore = 1,
3612                   usesCustomDAGSchedInserter = 1 in {
3613 def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3614                                (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3615                "#ATOMAND6432 PSEUDO!", []>;
3616 def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3617                                (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3618                "#ATOMOR6432 PSEUDO!", []>;
3619 def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3620                                (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3621                "#ATOMXOR6432 PSEUDO!", []>;
3622 def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3623                                (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3624                "#ATOMNAND6432 PSEUDO!", []>;
3625 def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3626                                (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3627                "#ATOMADD6432 PSEUDO!", []>;
3628 def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3629                                (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3630                "#ATOMSUB6432 PSEUDO!", []>;
3631 def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3632                                (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3633                "#ATOMSWAP6432 PSEUDO!", []>;
3634 }
3635
3636 //===----------------------------------------------------------------------===//
3637 // Non-Instruction Patterns
3638 //===----------------------------------------------------------------------===//
3639
3640 // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
3641 def : Pat<(i32 (X86Wrapper tconstpool  :$dst)), (MOV32ri tconstpool  :$dst)>;
3642 def : Pat<(i32 (X86Wrapper tjumptable  :$dst)), (MOV32ri tjumptable  :$dst)>;
3643 def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
3644 def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3645 def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3646
3647 def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3648           (ADD32ri GR32:$src1, tconstpool:$src2)>;
3649 def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3650           (ADD32ri GR32:$src1, tjumptable:$src2)>;
3651 def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3652           (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3653 def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3654           (ADD32ri GR32:$src1, texternalsym:$src2)>;
3655
3656 def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3657           (MOV32mi addr:$dst, tglobaladdr:$src)>;
3658 def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3659           (MOV32mi addr:$dst, texternalsym:$src)>;
3660
3661 // Calls
3662 // tailcall stuff
3663 def : Pat<(X86tcret GR32:$dst, imm:$off),
3664           (TCRETURNri GR32:$dst, imm:$off)>;
3665
3666 def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3667           (TCRETURNdi texternalsym:$dst, imm:$off)>;
3668
3669 def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3670           (TCRETURNdi texternalsym:$dst, imm:$off)>;
3671
3672 // Normal calls, with various flavors of addresses.
3673 def : Pat<(X86call (i32 tglobaladdr:$dst)),
3674           (CALLpcrel32 tglobaladdr:$dst)>;
3675 def : Pat<(X86call (i32 texternalsym:$dst)),
3676           (CALLpcrel32 texternalsym:$dst)>;
3677 def : Pat<(X86call (i32 imm:$dst)),
3678           (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
3679
3680 // X86 specific add which produces a flag.
3681 def : Pat<(addc GR32:$src1, GR32:$src2),
3682           (ADD32rr GR32:$src1, GR32:$src2)>;
3683 def : Pat<(addc GR32:$src1, (load addr:$src2)),
3684           (ADD32rm GR32:$src1, addr:$src2)>;
3685 def : Pat<(addc GR32:$src1, imm:$src2),
3686           (ADD32ri GR32:$src1, imm:$src2)>;
3687 def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3688           (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3689
3690 def : Pat<(subc GR32:$src1, GR32:$src2),
3691           (SUB32rr GR32:$src1, GR32:$src2)>;
3692 def : Pat<(subc GR32:$src1, (load addr:$src2)),
3693           (SUB32rm GR32:$src1, addr:$src2)>;
3694 def : Pat<(subc GR32:$src1, imm:$src2),
3695           (SUB32ri GR32:$src1, imm:$src2)>;
3696 def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3697           (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3698
3699 // Comparisons.
3700
3701 // TEST R,R is smaller than CMP R,0
3702 def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
3703           (TEST8rr GR8:$src1, GR8:$src1)>;
3704 def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
3705           (TEST16rr GR16:$src1, GR16:$src1)>;
3706 def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
3707           (TEST32rr GR32:$src1, GR32:$src1)>;
3708
3709 // Conditional moves with folded loads with operands swapped and conditions
3710 // inverted.
3711 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3712           (CMOVAE16rm GR16:$src2, addr:$src1)>;
3713 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3714           (CMOVAE32rm GR32:$src2, addr:$src1)>;
3715 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3716           (CMOVB16rm GR16:$src2, addr:$src1)>;
3717 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3718           (CMOVB32rm GR32:$src2, addr:$src1)>;
3719 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3720           (CMOVNE16rm GR16:$src2, addr:$src1)>;
3721 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3722           (CMOVNE32rm GR32:$src2, addr:$src1)>;
3723 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3724           (CMOVE16rm GR16:$src2, addr:$src1)>;
3725 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3726           (CMOVE32rm GR32:$src2, addr:$src1)>;
3727 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3728           (CMOVA16rm GR16:$src2, addr:$src1)>;
3729 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3730           (CMOVA32rm GR32:$src2, addr:$src1)>;
3731 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3732           (CMOVBE16rm GR16:$src2, addr:$src1)>;
3733 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3734           (CMOVBE32rm GR32:$src2, addr:$src1)>;
3735 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3736           (CMOVGE16rm GR16:$src2, addr:$src1)>;
3737 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3738           (CMOVGE32rm GR32:$src2, addr:$src1)>;
3739 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3740           (CMOVL16rm GR16:$src2, addr:$src1)>;
3741 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3742           (CMOVL32rm GR32:$src2, addr:$src1)>;
3743 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3744           (CMOVG16rm GR16:$src2, addr:$src1)>;
3745 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3746           (CMOVG32rm GR32:$src2, addr:$src1)>;
3747 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3748           (CMOVLE16rm GR16:$src2, addr:$src1)>;
3749 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3750           (CMOVLE32rm GR32:$src2, addr:$src1)>;
3751 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3752           (CMOVNP16rm GR16:$src2, addr:$src1)>;
3753 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3754           (CMOVNP32rm GR32:$src2, addr:$src1)>;
3755 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3756           (CMOVP16rm GR16:$src2, addr:$src1)>;
3757 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3758           (CMOVP32rm GR32:$src2, addr:$src1)>;
3759 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3760           (CMOVNS16rm GR16:$src2, addr:$src1)>;
3761 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3762           (CMOVNS32rm GR32:$src2, addr:$src1)>;
3763 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3764           (CMOVS16rm GR16:$src2, addr:$src1)>;
3765 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3766           (CMOVS32rm GR32:$src2, addr:$src1)>;
3767 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3768           (CMOVNO16rm GR16:$src2, addr:$src1)>;
3769 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3770           (CMOVNO32rm GR32:$src2, addr:$src1)>;
3771 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3772           (CMOVO16rm GR16:$src2, addr:$src1)>;
3773 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3774           (CMOVO32rm GR32:$src2, addr:$src1)>;
3775
3776 // zextload bool -> zextload byte
3777 def : Pat<(zextloadi8i1  addr:$src), (MOV8rm     addr:$src)>;
3778 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3779 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3780
3781 // extload bool -> extload byte
3782 def : Pat<(extloadi8i1 addr:$src),   (MOV8rm      addr:$src)>;
3783 def : Pat<(extloadi16i1 addr:$src),  (MOVZX16rm8  addr:$src)>;
3784 def : Pat<(extloadi32i1 addr:$src),  (MOVZX32rm8  addr:$src)>;
3785 def : Pat<(extloadi16i8 addr:$src),  (MOVZX16rm8  addr:$src)>;
3786 def : Pat<(extloadi32i8 addr:$src),  (MOVZX32rm8  addr:$src)>;
3787 def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3788
3789 // anyext. Define these to do an explicit zero-extend to
3790 // avoid partial-register updates.
3791 def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8  GR8 :$src)>;
3792 def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8  GR8 :$src)>;
3793 def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
3794
3795 // (and (i32 load), 255) -> (zextload i8)
3796 def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3797           (MOVZX32rm8 addr:$src)>;
3798 def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3799           (MOVZX32rm16 addr:$src)>;
3800
3801 //===----------------------------------------------------------------------===//
3802 // Some peepholes
3803 //===----------------------------------------------------------------------===//
3804
3805 // Odd encoding trick: -128 fits into an 8-bit immediate field while
3806 // +128 doesn't, so in this special case use a sub instead of an add.
3807 def : Pat<(add GR16:$src1, 128),
3808           (SUB16ri8 GR16:$src1, -128)>;
3809 def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3810           (SUB16mi8 addr:$dst, -128)>;
3811 def : Pat<(add GR32:$src1, 128),
3812           (SUB32ri8 GR32:$src1, -128)>;
3813 def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3814           (SUB32mi8 addr:$dst, -128)>;
3815
3816 // r & (2^16-1) ==> movz
3817 def : Pat<(and GR32:$src1, 0xffff),
3818           (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
3819 // r & (2^8-1) ==> movz
3820 def : Pat<(and GR32:$src1, 0xff),
3821           (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_ABCD),
3822                                       x86_subreg_8bit))>,
3823       Requires<[In32BitMode]>;
3824 // r & (2^8-1) ==> movz
3825 def : Pat<(and GR16:$src1, 0xff),
3826           (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_ABCD),
3827                                       x86_subreg_8bit))>,
3828       Requires<[In32BitMode]>;
3829
3830 // sext_inreg patterns
3831 def : Pat<(sext_inreg GR32:$src, i16),
3832           (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
3833 def : Pat<(sext_inreg GR32:$src, i8),
3834           (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3835                                       x86_subreg_8bit))>,
3836       Requires<[In32BitMode]>;
3837 def : Pat<(sext_inreg GR16:$src, i8),
3838           (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3839                                       x86_subreg_8bit))>,
3840       Requires<[In32BitMode]>;
3841
3842 // trunc patterns
3843 def : Pat<(i16 (trunc GR32:$src)),
3844           (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
3845 def : Pat<(i8 (trunc GR32:$src)),
3846           (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3847                           x86_subreg_8bit)>,
3848       Requires<[In32BitMode]>;
3849 def : Pat<(i8 (trunc GR16:$src)),
3850           (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3851                           x86_subreg_8bit)>,
3852       Requires<[In32BitMode]>;
3853
3854 // h-register tricks
3855 def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
3856           (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3857                           x86_subreg_8bit_hi)>,
3858       Requires<[In32BitMode]>;
3859 def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
3860           (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3861                           x86_subreg_8bit_hi)>,
3862       Requires<[In32BitMode]>;
3863 def : Pat<(srl_su GR16:$src, (i8 8)),
3864           (EXTRACT_SUBREG
3865             (MOVZX32rr8
3866               (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3867                               x86_subreg_8bit_hi)),
3868             x86_subreg_16bit)>,
3869       Requires<[In32BitMode]>;
3870 def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
3871           (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3872                                       x86_subreg_8bit_hi))>,
3873       Requires<[In32BitMode]>;
3874 def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
3875           (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3876                                       x86_subreg_8bit_hi))>,
3877       Requires<[In32BitMode]>;
3878 def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
3879           (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3880                                       x86_subreg_8bit_hi))>,
3881       Requires<[In32BitMode]>;
3882
3883 // (shl x, 1) ==> (add x, x)
3884 def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr  GR8 :$src1, GR8 :$src1)>;
3885 def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3886 def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3887
3888 // (shl x (and y, 31)) ==> (shl x, y)
3889 def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3890           (SHL8rCL GR8:$src1)>;
3891 def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3892           (SHL16rCL GR16:$src1)>;
3893 def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3894           (SHL32rCL GR32:$src1)>;
3895 def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3896           (SHL8mCL addr:$dst)>;
3897 def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3898           (SHL16mCL addr:$dst)>;
3899 def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3900           (SHL32mCL addr:$dst)>;
3901
3902 def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3903           (SHR8rCL GR8:$src1)>;
3904 def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3905           (SHR16rCL GR16:$src1)>;
3906 def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3907           (SHR32rCL GR32:$src1)>;
3908 def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3909           (SHR8mCL addr:$dst)>;
3910 def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3911           (SHR16mCL addr:$dst)>;
3912 def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3913           (SHR32mCL addr:$dst)>;
3914
3915 def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3916           (SAR8rCL GR8:$src1)>;
3917 def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3918           (SAR16rCL GR16:$src1)>;
3919 def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3920           (SAR32rCL GR32:$src1)>;
3921 def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3922           (SAR8mCL addr:$dst)>;
3923 def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3924           (SAR16mCL addr:$dst)>;
3925 def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3926           (SAR32mCL addr:$dst)>;
3927
3928 // (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3929 def : Pat<(or (srl GR32:$src1, CL:$amt),
3930               (shl GR32:$src2, (sub 32, CL:$amt))),
3931           (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3932
3933 def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3934                      (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3935           (SHRD32mrCL addr:$dst, GR32:$src2)>;
3936
3937 def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3938               (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3939           (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3940
3941 def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3942                      (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3943                  addr:$dst),
3944           (SHRD32mrCL addr:$dst, GR32:$src2)>;
3945
3946 def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3947           (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3948
3949 def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3950                        GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3951           (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3952
3953 // (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3954 def : Pat<(or (shl GR32:$src1, CL:$amt),
3955               (srl GR32:$src2, (sub 32, CL:$amt))),
3956           (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3957
3958 def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3959                      (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3960           (SHLD32mrCL addr:$dst, GR32:$src2)>;
3961
3962 def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3963               (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3964           (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3965
3966 def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3967                      (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3968                  addr:$dst),
3969           (SHLD32mrCL addr:$dst, GR32:$src2)>;
3970
3971 def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3972           (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3973
3974 def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3975                        GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3976           (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3977
3978 // (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3979 def : Pat<(or (srl GR16:$src1, CL:$amt),
3980               (shl GR16:$src2, (sub 16, CL:$amt))),
3981           (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3982
3983 def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3984                      (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3985           (SHRD16mrCL addr:$dst, GR16:$src2)>;
3986
3987 def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3988               (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3989           (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3990
3991 def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3992                      (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3993                  addr:$dst),
3994           (SHRD16mrCL addr:$dst, GR16:$src2)>;
3995
3996 def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3997           (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3998
3999 def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
4000                        GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4001           (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4002
4003 // (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
4004 def : Pat<(or (shl GR16:$src1, CL:$amt),
4005               (srl GR16:$src2, (sub 16, CL:$amt))),
4006           (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4007
4008 def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
4009                      (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4010           (SHLD16mrCL addr:$dst, GR16:$src2)>;
4011
4012 def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
4013               (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4014           (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4015
4016 def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4017                      (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4018                  addr:$dst),
4019           (SHLD16mrCL addr:$dst, GR16:$src2)>;
4020
4021 def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4022           (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4023
4024 def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
4025                        GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4026           (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4027
4028 //===----------------------------------------------------------------------===//
4029 // EFLAGS-defining Patterns
4030 //===----------------------------------------------------------------------===//
4031
4032 // Register-Register Addition with EFLAGS result
4033 def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
4034                     (implicit EFLAGS)),
4035           (ADD8rr GR8:$src1, GR8:$src2)>;
4036 def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
4037                     (implicit EFLAGS)),
4038           (ADD16rr GR16:$src1, GR16:$src2)>;
4039 def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
4040                     (implicit EFLAGS)),
4041           (ADD32rr GR32:$src1, GR32:$src2)>;
4042
4043 // Register-Memory Addition with EFLAGS result
4044 def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
4045                     (implicit EFLAGS)),
4046           (ADD8rm GR8:$src1, addr:$src2)>;
4047 def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
4048                     (implicit EFLAGS)),
4049           (ADD16rm GR16:$src1, addr:$src2)>;
4050 def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
4051                     (implicit EFLAGS)),
4052           (ADD32rm GR32:$src1, addr:$src2)>;
4053
4054 // Register-Integer Addition with EFLAGS result
4055 def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
4056                     (implicit EFLAGS)),
4057           (ADD8ri GR8:$src1, imm:$src2)>;
4058 def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
4059                     (implicit EFLAGS)),
4060           (ADD16ri GR16:$src1, imm:$src2)>;
4061 def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
4062                     (implicit EFLAGS)),
4063           (ADD32ri GR32:$src1, imm:$src2)>;
4064 def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
4065                     (implicit EFLAGS)),
4066           (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
4067 def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
4068                     (implicit EFLAGS)),
4069           (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4070
4071 // Memory-Register Addition with EFLAGS result
4072 def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
4073                            addr:$dst),
4074                     (implicit EFLAGS)),
4075           (ADD8mr addr:$dst, GR8:$src2)>;
4076 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
4077                            addr:$dst),
4078                     (implicit EFLAGS)),
4079           (ADD16mr addr:$dst, GR16:$src2)>;
4080 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
4081                            addr:$dst),
4082                     (implicit EFLAGS)),
4083           (ADD32mr addr:$dst, GR32:$src2)>;
4084
4085 // Memory-Integer Addition with EFLAGS result
4086 def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
4087                            addr:$dst),
4088                     (implicit EFLAGS)),
4089           (ADD8mi addr:$dst, imm:$src2)>;
4090 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
4091                            addr:$dst),
4092                     (implicit EFLAGS)),
4093           (ADD16mi addr:$dst, imm:$src2)>;
4094 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
4095                            addr:$dst),
4096                     (implicit EFLAGS)),
4097           (ADD32mi addr:$dst, imm:$src2)>;
4098 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
4099                            addr:$dst),
4100                     (implicit EFLAGS)),
4101           (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
4102 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
4103                            addr:$dst),
4104                     (implicit EFLAGS)),
4105           (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
4106
4107 // Register-Register Subtraction with EFLAGS result
4108 def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
4109                     (implicit EFLAGS)),
4110           (SUB8rr GR8:$src1, GR8:$src2)>;
4111 def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
4112                     (implicit EFLAGS)),
4113           (SUB16rr GR16:$src1, GR16:$src2)>;
4114 def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
4115                     (implicit EFLAGS)),
4116           (SUB32rr GR32:$src1, GR32:$src2)>;
4117
4118 // Register-Memory Subtraction with EFLAGS result
4119 def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
4120                     (implicit EFLAGS)),
4121           (SUB8rm GR8:$src1, addr:$src2)>;
4122 def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
4123                     (implicit EFLAGS)),
4124           (SUB16rm GR16:$src1, addr:$src2)>;
4125 def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
4126                     (implicit EFLAGS)),
4127           (SUB32rm GR32:$src1, addr:$src2)>;
4128
4129 // Register-Integer Subtraction with EFLAGS result
4130 def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
4131                     (implicit EFLAGS)),
4132           (SUB8ri GR8:$src1, imm:$src2)>;
4133 def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
4134                     (implicit EFLAGS)),
4135           (SUB16ri GR16:$src1, imm:$src2)>;
4136 def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
4137                     (implicit EFLAGS)),
4138           (SUB32ri GR32:$src1, imm:$src2)>;
4139 def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
4140                     (implicit EFLAGS)),
4141           (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
4142 def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
4143                     (implicit EFLAGS)),
4144           (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4145
4146 // Memory-Register Subtraction with EFLAGS result
4147 def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
4148                            addr:$dst),
4149                     (implicit EFLAGS)),
4150           (SUB8mr addr:$dst, GR8:$src2)>;
4151 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
4152                            addr:$dst),
4153                     (implicit EFLAGS)),
4154           (SUB16mr addr:$dst, GR16:$src2)>;
4155 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
4156                            addr:$dst),
4157                     (implicit EFLAGS)),
4158           (SUB32mr addr:$dst, GR32:$src2)>;
4159
4160 // Memory-Integer Subtraction with EFLAGS result
4161 def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
4162                            addr:$dst),
4163                     (implicit EFLAGS)),
4164           (SUB8mi addr:$dst, imm:$src2)>;
4165 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
4166                            addr:$dst),
4167                     (implicit EFLAGS)),
4168           (SUB16mi addr:$dst, imm:$src2)>;
4169 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
4170                            addr:$dst),
4171                     (implicit EFLAGS)),
4172           (SUB32mi addr:$dst, imm:$src2)>;
4173 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
4174                            addr:$dst),
4175                     (implicit EFLAGS)),
4176           (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
4177 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
4178                            addr:$dst),
4179                     (implicit EFLAGS)),
4180           (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
4181
4182
4183 // Register-Register Signed Integer Multiply with EFLAGS result
4184 def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
4185                     (implicit EFLAGS)),
4186           (IMUL16rr GR16:$src1, GR16:$src2)>;
4187 def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
4188                     (implicit EFLAGS)),
4189           (IMUL32rr GR32:$src1, GR32:$src2)>;
4190
4191 // Register-Memory Signed Integer Multiply with EFLAGS result
4192 def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
4193                     (implicit EFLAGS)),
4194           (IMUL16rm GR16:$src1, addr:$src2)>;
4195 def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
4196                     (implicit EFLAGS)),
4197           (IMUL32rm GR32:$src1, addr:$src2)>;
4198
4199 // Register-Integer Signed Integer Multiply with EFLAGS result
4200 def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
4201                     (implicit EFLAGS)),
4202           (IMUL16rri GR16:$src1, imm:$src2)>;
4203 def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
4204                     (implicit EFLAGS)),
4205           (IMUL32rri GR32:$src1, imm:$src2)>;
4206 def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
4207                     (implicit EFLAGS)),
4208           (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
4209 def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
4210                     (implicit EFLAGS)),
4211           (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4212
4213 // Memory-Integer Signed Integer Multiply with EFLAGS result
4214 def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
4215                     (implicit EFLAGS)),
4216           (IMUL16rmi addr:$src1, imm:$src2)>;
4217 def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
4218                     (implicit EFLAGS)),
4219           (IMUL32rmi addr:$src1, imm:$src2)>;
4220 def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
4221                     (implicit EFLAGS)),
4222           (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
4223 def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
4224                     (implicit EFLAGS)),
4225           (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4226
4227 // Optimize multiply by 2 with EFLAGS result.
4228 let AddedComplexity = 2 in {
4229 def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
4230                     (implicit EFLAGS)),
4231           (ADD16rr GR16:$src1, GR16:$src1)>;
4232
4233 def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
4234                     (implicit EFLAGS)),
4235           (ADD32rr GR32:$src1, GR32:$src1)>;
4236 }
4237
4238 // INC and DEC with EFLAGS result. Note that these do not set CF.
4239 def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
4240           (INC8r GR8:$src)>;
4241 def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
4242                     (implicit EFLAGS)),
4243           (INC8m addr:$dst)>;
4244 def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
4245           (DEC8r GR8:$src)>;
4246 def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
4247                     (implicit EFLAGS)),
4248           (DEC8m addr:$dst)>;
4249
4250 def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
4251           (INC16r GR16:$src)>, Requires<[In32BitMode]>;
4252 def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
4253                     (implicit EFLAGS)),
4254           (INC16m addr:$dst)>, Requires<[In32BitMode]>;
4255 def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
4256           (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
4257 def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
4258                     (implicit EFLAGS)),
4259           (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
4260
4261 def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
4262           (INC32r GR32:$src)>, Requires<[In32BitMode]>;
4263 def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
4264                     (implicit EFLAGS)),
4265           (INC32m addr:$dst)>, Requires<[In32BitMode]>;
4266 def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
4267           (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
4268 def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
4269                     (implicit EFLAGS)),
4270           (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
4271
4272 // -disable-16bit support.
4273 def : Pat<(truncstorei16 (i32 imm:$src), addr:$dst),
4274           (MOV16mi addr:$dst, imm:$src)>;
4275 def : Pat<(truncstorei16 GR32:$src, addr:$dst),
4276           (MOV16mr addr:$dst, (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
4277 def : Pat<(i32 (sextloadi16 addr:$dst)),
4278           (MOVSX32rm16 addr:$dst)>;
4279 def : Pat<(i32 (zextloadi16 addr:$dst)),
4280           (MOVZX32rm16 addr:$dst)>;
4281 def : Pat<(i32 (extloadi16 addr:$dst)),
4282           (MOVZX32rm16 addr:$dst)>;
4283
4284 //===----------------------------------------------------------------------===//
4285 // Floating Point Stack Support
4286 //===----------------------------------------------------------------------===//
4287
4288 include "X86InstrFPStack.td"
4289
4290 //===----------------------------------------------------------------------===//
4291 // X86-64 Support
4292 //===----------------------------------------------------------------------===//
4293
4294 include "X86Instr64bit.td"
4295
4296 //===----------------------------------------------------------------------===//
4297 // XMM Floating point support (requires SSE / SSE2)
4298 //===----------------------------------------------------------------------===//
4299
4300 include "X86InstrSSE.td"
4301
4302 //===----------------------------------------------------------------------===//
4303 // MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
4304 //===----------------------------------------------------------------------===//
4305
4306 include "X86InstrMMX.td"