* Split immSExt8 to i16SExt8 and i32SExt8 for i16 and i32 immediate operands.
[oota-llvm.git] / lib / Target / X86 / X86InstrInfo.td
1 //===- X86InstrInfo.td - Describe the X86 Instruction Set -------*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source 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 // *mem - Operand definitions for the funky X86 addressing mode operands.
17 //
18 class X86MemOperand<ValueType Ty, string printMethod> : Operand<Ty> {
19   let PrintMethod = printMethod;
20   let NumMIOperands = 4;
21   let MIOperandInfo = (ops R32, i8imm, R32, i32imm);
22 }
23
24 def i8mem   : X86MemOperand<i32, "printi8mem">;
25 def i16mem  : X86MemOperand<i32, "printi16mem">;
26 def i32mem  : X86MemOperand<i32, "printi32mem">;
27 def i64mem  : X86MemOperand<i32, "printi64mem">;
28 def f32mem  : X86MemOperand<i32, "printf32mem">;
29 def f64mem  : X86MemOperand<i32, "printf64mem">;
30 def f80mem  : X86MemOperand<i32, "printf80mem">;
31
32 def SSECC : Operand<i8> {
33   let PrintMethod = "printSSECC";
34 }
35
36 // A couple of more descriptive operand definitions.
37 // 16-bits but only 8 bits are significant.
38 def i16i8imm  : Operand<i16>;
39 // 32-bits but only 8 bits are significant.
40 def i32i8imm  : Operand<i32>;
41
42 // PCRelative calls need special operand formatting.
43 let PrintMethod = "printCallOperand" in
44   def calltarget : Operand<i32>;
45
46 // Branch targets have OtherVT type.
47 def brtarget : Operand<OtherVT>;
48
49 // Define X86 specific addressing mode.
50 def addr    : ComplexPattern<i32, 4, "SelectAddr", []>;
51 def leaaddr : ComplexPattern<i32, 4, "SelectLEAAddr", [add]>;
52
53 // Format specifies the encoding used by the instruction.  This is part of the
54 // ad-hoc solution used to emit machine instruction encodings by our machine
55 // code emitter.
56 class Format<bits<5> val> {
57   bits<5> Value = val;
58 }
59
60 def Pseudo     : Format<0>; def RawFrm     : Format<1>;
61 def AddRegFrm  : Format<2>; def MRMDestReg : Format<3>;
62 def MRMDestMem : Format<4>; def MRMSrcReg  : Format<5>;
63 def MRMSrcMem  : Format<6>;
64 def MRM0r  : Format<16>; def MRM1r  : Format<17>; def MRM2r  : Format<18>;
65 def MRM3r  : Format<19>; def MRM4r  : Format<20>; def MRM5r  : Format<21>;
66 def MRM6r  : Format<22>; def MRM7r  : Format<23>;
67 def MRM0m  : Format<24>; def MRM1m  : Format<25>; def MRM2m  : Format<26>;
68 def MRM3m  : Format<27>; def MRM4m  : Format<28>; def MRM5m  : Format<29>;
69 def MRM6m  : Format<30>; def MRM7m  : Format<31>;
70
71 // ImmType - This specifies the immediate type used by an instruction. This is
72 // part of the ad-hoc solution used to emit machine instruction encodings by our
73 // machine code emitter.
74 class ImmType<bits<2> val> {
75   bits<2> Value = val;
76 }
77 def NoImm  : ImmType<0>;
78 def Imm8   : ImmType<1>;
79 def Imm16  : ImmType<2>;
80 def Imm32  : ImmType<3>;
81
82 // FPFormat - This specifies what form this FP instruction has.  This is used by
83 // the Floating-Point stackifier pass.
84 class FPFormat<bits<3> val> {
85   bits<3> Value = val;
86 }
87 def NotFP      : FPFormat<0>;
88 def ZeroArgFP  : FPFormat<1>;
89 def OneArgFP   : FPFormat<2>;
90 def OneArgFPRW : FPFormat<3>;
91 def TwoArgFP   : FPFormat<4>;
92 def CompareFP  : FPFormat<5>;
93 def CondMovFP  : FPFormat<6>;
94 def SpecialFP  : FPFormat<7>;
95
96
97 class X86Inst<bits<8> opcod, Format f, ImmType i, dag ops, string AsmStr>
98   : Instruction {
99   let Namespace = "X86";
100
101   bits<8> Opcode = opcod;
102   Format Form = f;
103   bits<5> FormBits = Form.Value;
104   ImmType ImmT = i;
105   bits<2> ImmTypeBits = ImmT.Value;
106
107   dag OperandList = ops;
108   string AsmString = AsmStr;
109
110   //
111   // Attributes specific to X86 instructions...
112   //
113   bit hasOpSizePrefix = 0; // Does this inst have a 0x66 prefix?
114
115   bits<4> Prefix = 0;       // Which prefix byte does this inst have?
116   FPFormat FPForm;          // What flavor of FP instruction is this?
117   bits<3> FPFormBits = 0;
118 }
119
120 class Imp<list<Register> uses, list<Register> defs> {
121   list<Register> Uses = uses;
122   list<Register> Defs = defs;
123 }
124
125
126 // Prefix byte classes which are used to indicate to the ad-hoc machine code
127 // emitter that various prefix bytes are required.
128 class OpSize { bit hasOpSizePrefix = 1; }
129 class TB     { bits<4> Prefix = 1; }
130 class REP    { bits<4> Prefix = 2; }
131 class D8     { bits<4> Prefix = 3; }
132 class D9     { bits<4> Prefix = 4; }
133 class DA     { bits<4> Prefix = 5; }
134 class DB     { bits<4> Prefix = 6; }
135 class DC     { bits<4> Prefix = 7; }
136 class DD     { bits<4> Prefix = 8; }
137 class DE     { bits<4> Prefix = 9; }
138 class DF     { bits<4> Prefix = 10; }
139 class XD     { bits<4> Prefix = 11; }
140 class XS     { bits<4> Prefix = 12; }
141
142
143 //===----------------------------------------------------------------------===//
144 // Pattern fragments...
145 //
146 def i16SExt8  : PatLeaf<(i16 imm), [{
147   // i16SExt8 predicate - True if the 16-bit immediate fits in a 8-bit
148   // sign extended field.
149   return (int)N->getValue() == (signed char)N->getValue();
150 }]>;
151
152 def i32SExt8  : PatLeaf<(i32 imm), [{
153   // i32SExt8 predicate - True if the 32-bit immediate fits in a 8-bit
154   // sign extended field.
155   return (int)N->getValue() == (signed char)N->getValue();
156 }]>;
157
158 def i16ZExt8  : PatLeaf<(i16 imm), [{
159   // i16ZExt8 predicate - True if the 16-bit immediate fits in a 8-bit zero
160   // extended field.
161   return (unsigned)N->getValue() == (unsigned char)N->getValue();
162 }]>;
163
164 //===----------------------------------------------------------------------===//
165 // Instruction templates...
166
167 class I<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
168   : X86Inst<o, f, NoImm, ops, asm> {
169   let Pattern = pattern;
170 }
171 class Ii8 <bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
172   : X86Inst<o, f, Imm8 , ops, asm> {
173   let Pattern = pattern;
174 }
175 class Ii16<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
176   : X86Inst<o, f, Imm16, ops, asm> {
177   let Pattern = pattern;
178 }
179 class Ii32<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
180   : X86Inst<o, f, Imm32, ops, asm> {
181   let Pattern = pattern;
182 }
183
184 //===----------------------------------------------------------------------===//
185 // Instruction list...
186 //
187
188 def PHI : I<0, Pseudo, (ops variable_ops), "PHINODE", []>;        // PHI node.
189 def NOOP : I<0x90, RawFrm, (ops), "nop", []>; // nop
190
191 def ADJCALLSTACKDOWN : I<0, Pseudo, (ops i32imm:$amt), "#ADJCALLSTACKDOWN", []>;
192 def ADJCALLSTACKUP   : I<0, Pseudo, (ops i32imm:$amt1, i32imm:$amt2),
193                          "#ADJCALLSTACKUP", []>;
194 def IMPLICIT_USE     : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_USE", []>;
195 def IMPLICIT_DEF     : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_DEF", []>;
196 let isTerminator = 1 in
197   let Defs = [FP0, FP1, FP2, FP3, FP4, FP5, FP6] in
198     def FP_REG_KILL  : I<0, Pseudo, (ops), "#FP_REG_KILL", []>;
199
200 //===----------------------------------------------------------------------===//
201 //  Control Flow Instructions...
202 //
203
204 // Return instructions.
205 let isTerminator = 1, isReturn = 1, isBarrier = 1 in
206   def RET : I<0xC3, RawFrm, (ops), "ret", [(ret)]>;
207 let isTerminator = 1, isReturn = 1, isBarrier = 1 in
208   def RETI : Ii16<0xC2, RawFrm, (ops i16imm:$amt), "ret $amt", []>;
209
210 // All branches are RawFrm, Void, Branch, and Terminators
211 let isBranch = 1, isTerminator = 1 in
212   class IBr<bits<8> opcode, dag ops, string asm, list<dag> pattern> :
213         I<opcode, RawFrm, ops, asm, pattern>;
214
215 let isBarrier = 1 in
216   def JMP : IBr<0xE9, (ops brtarget:$dst), "jmp $dst", [(br bb:$dst)]>;
217 def JB  : IBr<0x82, (ops brtarget:$dst), "jb $dst",
218               []>, TB;
219 def JAE : IBr<0x83, (ops brtarget:$dst), "jae $dst", []>, TB;
220 def JE  : IBr<0x84, (ops brtarget:$dst), "je $dst", []>, TB;
221 def JNE : IBr<0x85, (ops brtarget:$dst), "jne $dst", []>, TB;
222 def JBE : IBr<0x86, (ops brtarget:$dst), "jbe $dst", []>, TB;
223 def JA  : IBr<0x87, (ops brtarget:$dst), "ja $dst", []>, TB;
224 def JS  : IBr<0x88, (ops brtarget:$dst), "js $dst", []>, TB;
225 def JNS : IBr<0x89, (ops brtarget:$dst), "jns $dst", []>, TB;
226 def JP  : IBr<0x8A, (ops brtarget:$dst), "jp $dst", []>, TB;
227 def JNP : IBr<0x8B, (ops brtarget:$dst), "jnp $dst", []>, TB;
228 def JL  : IBr<0x8C, (ops brtarget:$dst), "jl $dst", []>, TB;
229 def JGE : IBr<0x8D, (ops brtarget:$dst), "jge $dst", []>, TB;
230 def JLE : IBr<0x8E, (ops brtarget:$dst), "jle $dst", []>, TB;
231 def JG  : IBr<0x8F, (ops brtarget:$dst), "jg $dst", []>, TB;
232
233 //===----------------------------------------------------------------------===//
234 //  Call Instructions...
235 //
236 let isCall = 1 in
237   // All calls clobber the non-callee saved registers...
238   let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
239               XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7] in {
240     def CALLpcrel32 : I<0xE8, RawFrm, (ops calltarget:$dst), "call $dst", []>;
241     def CALL32r     : I<0xFF, MRM2r, (ops R32:$dst), "call {*}$dst", []>;
242     def CALL32m     : I<0xFF, MRM2m, (ops i32mem:$dst), "call {*}$dst", []>;
243   }
244
245 // Tail call stuff.
246 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
247   def TAILJMPd : IBr<0xE9, (ops calltarget:$dst), "jmp $dst  # TAIL CALL", []>;
248 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
249   def TAILJMPr : I<0xFF, MRM4r, (ops R32:$dst), "jmp {*}$dst  # TAIL CALL", []>;
250 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
251   def TAILJMPm : I<0xFF, MRM4m, (ops i32mem:$dst),
252                    "jmp {*}$dst  # TAIL CALL", []>;
253
254 // ADJSTACKPTRri - This is a standard ADD32ri instruction, identical in every
255 // way, except that it is marked as being a terminator.  This causes the epilog
256 // inserter to insert reloads of callee saved registers BEFORE this.  We need
257 // this until we have a more accurate way of tracking where the stack pointer is
258 // within a function.
259 let isTerminator = 1, isTwoAddress = 1 in
260   def ADJSTACKPTRri : Ii32<0x81, MRM0r, (ops R32:$dst, R32:$src1, i32imm:$src2),
261                            "add{l} {$src2, $dst|$dst, $src2}", []>;
262
263 //===----------------------------------------------------------------------===//
264 //  Miscellaneous Instructions...
265 //
266 def LEAVE    : I<0xC9, RawFrm,
267                  (ops), "leave", []>, Imp<[EBP,ESP],[EBP,ESP]>;
268 def POP32r   : I<0x58, AddRegFrm,
269                  (ops R32:$reg), "pop{l} $reg", []>, Imp<[ESP],[ESP]>;
270
271 let isTwoAddress = 1 in                               // R32 = bswap R32
272   def BSWAP32r : I<0xC8, AddRegFrm,
273                    (ops R32:$dst, R32:$src), "bswap{l} $dst", []>, TB;
274
275 def XCHG8rr  : I<0x86, MRMDestReg,                    // xchg R8, R8
276                  (ops R8:$src1, R8:$src2),
277                  "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
278 def XCHG16rr : I<0x87, MRMDestReg,                    // xchg R16, R16
279                  (ops R16:$src1, R16:$src2),
280                  "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
281 def XCHG32rr : I<0x87, MRMDestReg,                    // xchg R32, R32
282                  (ops R32:$src1, R32:$src2),
283                  "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
284
285 def XCHG8mr  : I<0x86, MRMDestMem,
286                  (ops i8mem:$src1, R8:$src2),
287                  "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
288 def XCHG16mr : I<0x87, MRMDestMem,
289                  (ops i16mem:$src1, R16:$src2),
290                  "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
291 def XCHG32mr : I<0x87, MRMDestMem,
292                  (ops i32mem:$src1, R32:$src2),
293                  "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
294 def XCHG8rm  : I<0x86, MRMSrcMem,
295                  (ops R8:$src1, i8mem:$src2),
296                  "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
297 def XCHG16rm : I<0x87, MRMSrcMem,
298                  (ops R16:$src1, i16mem:$src2),
299                  "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
300 def XCHG32rm : I<0x87, MRMSrcMem,
301                  (ops R32:$src1, i32mem:$src2),
302                  "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
303
304 def LEA16r   : I<0x8D, MRMSrcMem,
305                  (ops R16:$dst, i32mem:$src),
306                  "lea{w} {$src|$dst}, {$dst|$src}", []>, OpSize;
307 def LEA32r   : I<0x8D, MRMSrcMem,
308                  (ops R32:$dst, i32mem:$src),
309                  "lea{l} {$src|$dst}, {$dst|$src}",
310                  [(set R32:$dst, leaaddr:$src)]>;
311
312
313 def REP_MOVSB : I<0xA4, RawFrm, (ops), "{rep;movsb|rep movsb}", []>,
314                 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
315 def REP_MOVSW : I<0xA5, RawFrm, (ops), "{rep;movsw|rep movsw}", []>,
316                 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP, OpSize;
317 def REP_MOVSD : I<0xA5, RawFrm, (ops), "{rep;movsd|rep movsd}", []>,
318                 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
319
320 def REP_STOSB : I<0xAA, RawFrm, (ops), "{rep;stosb|rep stosb}", []>,
321                 Imp<[AL,ECX,EDI], [ECX,EDI]>, REP;
322 def REP_STOSW : I<0xAB, RawFrm, (ops), "{rep;stosw|rep stosw}", []>,
323                 Imp<[AX,ECX,EDI], [ECX,EDI]>, REP, OpSize;
324 def REP_STOSD : I<0xAB, RawFrm, (ops), "{rep;stosl|rep stosd}", []>,
325                 Imp<[EAX,ECX,EDI], [ECX,EDI]>, REP;
326
327
328 //===----------------------------------------------------------------------===//
329 //  Input/Output Instructions...
330 //
331 def IN8rr  : I<0xEC, RawFrm, (ops),
332                "in{b} {%dx, %al|%AL, %DX}", []>,  Imp<[DX], [AL]>;
333 def IN16rr : I<0xED, RawFrm, (ops),
334                "in{w} {%dx, %ax|%AX, %DX}", []>,  Imp<[DX], [AX]>, OpSize;
335 def IN32rr : I<0xED, RawFrm, (ops),
336                "in{l} {%dx, %eax|%EAX, %DX}", []>, Imp<[DX],[EAX]>;
337
338 def IN8ri  : Ii8<0xE4, RawFrm, (ops i8imm:$port),
339                   "in{b} {$port, %al|%AL, $port}", []>,  Imp<[], [AL]>;
340 def IN16ri : Ii8<0xE5, RawFrm, (ops i8imm:$port),
341                   "in{w} {$port, %ax|%AX, $port}", []>,  Imp<[], [AX]>, OpSize;
342 def IN32ri : Ii8<0xE5, RawFrm, (ops i8imm:$port),
343                   "in{l} {$port, %eax|%EAX, $port}", []>, Imp<[],[EAX]>;
344
345 def OUT8rr  : I<0xEE, RawFrm, (ops),
346                 "out{b} {%al, %dx|%DX, %AL}",
347                 [(writeport AL, DX)]>,  Imp<[DX,  AL], []>;
348 def OUT16rr : I<0xEF, RawFrm, (ops),
349                 "out{w} {%ax, %dx|%DX, %AX}",
350                 [(writeport AX, DX)]>,  Imp<[DX,  AX], []>, OpSize;
351 def OUT32rr : I<0xEF, RawFrm, (ops),
352                 "out{l} {%eax, %dx|%DX, %EAX}",
353                 [(writeport EAX, DX)]>, Imp<[DX, EAX], []>;
354
355 def OUT8ir  : Ii8<0xE6, RawFrm, (ops i16i8imm:$port),
356                    "out{b} {%al, $port|$port, %AL}",
357                    [(writeport AL, (i16 i16ZExt8:$port))]>,
358                    Imp<[AL], []>;
359 def OUT16ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
360                    "out{w} {%ax, $port|$port, %AX}",
361                    [(writeport AX, (i16 i16ZExt8:$port))]>,
362                    Imp<[AX], []>, OpSize;
363 def OUT32ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
364                    "out{l} {%eax, $port|$port, %EAX}",
365                    [(writeport EAX, (i16 i16ZExt8:$port))]>,
366                    Imp<[EAX], []>;
367
368 //===----------------------------------------------------------------------===//
369 //  Move Instructions...
370 //
371 def MOV8rr  : I<0x88, MRMDestReg, (ops R8 :$dst, R8 :$src),
372                 "mov{b} {$src, $dst|$dst, $src}", []>;
373 def MOV16rr : I<0x89, MRMDestReg, (ops R16:$dst, R16:$src),
374                 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
375 def MOV32rr : I<0x89, MRMDestReg, (ops R32:$dst, R32:$src),
376                 "mov{l} {$src, $dst|$dst, $src}", []>;
377 def MOV8ri  : Ii8 <0xB0, AddRegFrm, (ops R8 :$dst, i8imm :$src),
378                    "mov{b} {$src, $dst|$dst, $src}",
379                    [(set R8:$dst, imm:$src)]>;
380 def MOV16ri : Ii16<0xB8, AddRegFrm, (ops R16:$dst, i16imm:$src),
381                    "mov{w} {$src, $dst|$dst, $src}",
382                    [(set R16:$dst, imm:$src)]>, OpSize;
383 def MOV32ri : Ii32<0xB8, AddRegFrm, (ops R32:$dst, i32imm:$src),
384                    "mov{l} {$src, $dst|$dst, $src}",
385                    [(set R32:$dst, imm:$src)]>;
386 def MOV8mi  : Ii8 <0xC6, MRM0m, (ops i8mem :$dst, i8imm :$src),
387                    "mov{b} {$src, $dst|$dst, $src}",
388                    [(store (i8 imm:$src), addr:$dst)]>;
389 def MOV16mi : Ii16<0xC7, MRM0m, (ops i16mem:$dst, i16imm:$src),
390                    "mov{w} {$src, $dst|$dst, $src}",
391                    [(store (i16 imm:$src), addr:$dst)]>, OpSize;
392 def MOV32mi : Ii32<0xC7, MRM0m, (ops i32mem:$dst, i32imm:$src),
393                    "mov{l} {$src, $dst|$dst, $src}",
394                    [(store (i32 imm:$src), addr:$dst)]>;
395
396 def MOV8rm  : I<0x8A, MRMSrcMem, (ops R8 :$dst, i8mem :$src),
397                 "mov{b} {$src, $dst|$dst, $src}",
398                 [(set R8:$dst, (load addr:$src))]>;
399 def MOV16rm : I<0x8B, MRMSrcMem, (ops R16:$dst, i16mem:$src),
400                 "mov{w} {$src, $dst|$dst, $src}",
401                 [(set R16:$dst, (load addr:$src))]>, OpSize;
402 def MOV32rm : I<0x8B, MRMSrcMem, (ops R32:$dst, i32mem:$src),
403                 "mov{l} {$src, $dst|$dst, $src}",
404                 [(set R32:$dst, (load addr:$src))]>;
405
406 def MOV8mr  : I<0x88, MRMDestMem, (ops i8mem :$dst, R8 :$src),
407                 "mov{b} {$src, $dst|$dst, $src}",
408                 [(store R8:$src, addr:$dst)]>;
409 def MOV16mr : I<0x89, MRMDestMem, (ops i16mem:$dst, R16:$src),
410                 "mov{w} {$src, $dst|$dst, $src}",
411                 [(store R16:$src, addr:$dst)]>, OpSize;
412 def MOV32mr : I<0x89, MRMDestMem, (ops i32mem:$dst, R32:$src),
413                 "mov{l} {$src, $dst|$dst, $src}",
414                 [(store R32:$src, addr:$dst)]>;
415                 
416 //===----------------------------------------------------------------------===//
417 //  Fixed-Register Multiplication and Division Instructions...
418 //
419
420 // Extra precision multiplication
421 def MUL8r  : I<0xF6, MRM4r, (ops R8:$src), "mul{b} $src", []>,
422              Imp<[AL],[AX]>;               // AL,AH = AL*R8
423 def MUL16r : I<0xF7, MRM4r, (ops R16:$src), "mul{w} $src", []>,
424              Imp<[AX],[AX,DX]>, OpSize;    // AX,DX = AX*R16
425 def MUL32r : I<0xF7, MRM4r, (ops R32:$src), "mul{l} $src", []>,
426              Imp<[EAX],[EAX,EDX]>;         // EAX,EDX = EAX*R32
427 def MUL8m  : I<0xF6, MRM4m, (ops i8mem :$src),
428                "mul{b} $src", []>, Imp<[AL],[AX]>;          // AL,AH = AL*[mem8]
429 def MUL16m : I<0xF7, MRM4m, (ops i16mem:$src),
430                "mul{w} $src", []>, Imp<[AX],[AX,DX]>,
431                OpSize; // AX,DX = AX*[mem16]
432 def MUL32m : I<0xF7, MRM4m, (ops i32mem:$src),
433                "mul{l} $src", []>, Imp<[EAX],[EAX,EDX]>;// EAX,EDX = EAX*[mem32]
434
435 def IMUL8r  : I<0xF6, MRM5r, (ops R8:$src), "imul{b} $src", []>,
436               Imp<[AL],[AX]>;               // AL,AH = AL*R8
437 def IMUL16r : I<0xF7, MRM5r, (ops R16:$src), "imul{w} $src", []>,
438               Imp<[AX],[AX,DX]>, OpSize;    // AX,DX = AX*R16
439 def IMUL32r : I<0xF7, MRM5r, (ops R32:$src), "imul{l} $src", []>,
440               Imp<[EAX],[EAX,EDX]>;         // EAX,EDX = EAX*R32
441 def IMUL8m  : I<0xF6, MRM5m, (ops i8mem :$src),
442                 "imul{b} $src", []>, Imp<[AL],[AX]>;        // AL,AH = AL*[mem8]
443 def IMUL16m : I<0xF7, MRM5m, (ops i16mem:$src),
444                 "imul{w} $src", []>, Imp<[AX],[AX,DX]>,
445                 OpSize; // AX,DX = AX*[mem16]
446 def IMUL32m : I<0xF7, MRM5m, (ops i32mem:$src),
447                 "imul{l} $src", []>,
448                 Imp<[EAX],[EAX,EDX]>;  // EAX,EDX = EAX*[mem32]
449
450 // unsigned division/remainder
451 def DIV8r  : I<0xF6, MRM6r, (ops R8:$src),          // AX/r8 = AL,AH
452                "div{b} $src", []>, Imp<[AX],[AX]>;
453 def DIV16r : I<0xF7, MRM6r, (ops R16:$src),         // DX:AX/r16 = AX,DX
454                "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
455 def DIV32r : I<0xF7, MRM6r, (ops R32:$src),         // EDX:EAX/r32 = EAX,EDX
456                "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
457 def DIV8m  : I<0xF6, MRM6m, (ops i8mem:$src),       // AX/[mem8] = AL,AH
458                "div{b} $src", []>, Imp<[AX],[AX]>;
459 def DIV16m : I<0xF7, MRM6m, (ops i16mem:$src),      // DX:AX/[mem16] = AX,DX
460                "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
461 def DIV32m : I<0xF7, MRM6m, (ops i32mem:$src),      // EDX:EAX/[mem32] = EAX,EDX
462                "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
463
464 // Signed division/remainder.
465 def IDIV8r : I<0xF6, MRM7r, (ops R8:$src),          // AX/r8 = AL,AH
466                "idiv{b} $src", []>, Imp<[AX],[AX]>;
467 def IDIV16r: I<0xF7, MRM7r, (ops R16:$src),         // DX:AX/r16 = AX,DX
468                "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
469 def IDIV32r: I<0xF7, MRM7r, (ops R32:$src),         // EDX:EAX/r32 = EAX,EDX
470                "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
471 def IDIV8m : I<0xF6, MRM7m, (ops i8mem:$src),      // AX/[mem8] = AL,AH
472                "idiv{b} $src", []>, Imp<[AX],[AX]>;
473 def IDIV16m: I<0xF7, MRM7m, (ops i16mem:$src),     // DX:AX/[mem16] = AX,DX
474                "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
475 def IDIV32m: I<0xF7, MRM7m, (ops i32mem:$src),     // EDX:EAX/[mem32] = EAX,EDX
476                "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
477
478 // Sign-extenders for division.
479 def CBW : I<0x98, RawFrm, (ops),
480             "{cbtw|cbw}", []>, Imp<[AL],[AH]>;   // AX = signext(AL)
481 def CWD : I<0x99, RawFrm, (ops),
482             "{cwtd|cwd}", []>, Imp<[AX],[DX]>;   // DX:AX = signext(AX)
483 def CDQ : I<0x99, RawFrm, (ops),
484             "{cltd|cdq}", []>, Imp<[EAX],[EDX]>; // EDX:EAX = signext(EAX)
485           
486
487 //===----------------------------------------------------------------------===//
488 //  Two address Instructions...
489 //
490 let isTwoAddress = 1 in {
491
492 // Conditional moves
493 def CMOVB16rr : I<0x42, MRMSrcReg,       // if <u, R16 = R16
494                   (ops R16:$dst, R16:$src1, R16:$src2),
495                   "cmovb {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
496 def CMOVB16rm : I<0x42, MRMSrcMem,       // if <u, R16 = [mem16]
497                   (ops R16:$dst, R16:$src1, i16mem:$src2),
498                   "cmovb {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
499 def CMOVB32rr : I<0x42, MRMSrcReg,       // if <u, R32 = R32
500                   (ops R32:$dst, R32:$src1, R32:$src2),
501                   "cmovb {$src2, $dst|$dst, $src2}", []>, TB;
502 def CMOVB32rm : I<0x42, MRMSrcMem,       // if <u, R32 = [mem32]
503                   (ops R32:$dst, R32:$src1, i32mem:$src2),
504                   "cmovb {$src2, $dst|$dst, $src2}", []>, TB;
505
506 def CMOVAE16rr: I<0x43, MRMSrcReg,       // if >=u, R16 = R16
507                   (ops R16:$dst, R16:$src1, R16:$src2),
508                   "cmovae {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
509 def CMOVAE16rm: I<0x43, MRMSrcMem,       // if >=u, R16 = [mem16]
510                   (ops R16:$dst, R16:$src1, i16mem:$src2),
511                   "cmovae {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
512 def CMOVAE32rr: I<0x43, MRMSrcReg,       // if >=u, R32 = R32
513                   (ops R32:$dst, R32:$src1, R32:$src2),
514                   "cmovae {$src2, $dst|$dst, $src2}", []>, TB;
515 def CMOVAE32rm: I<0x43, MRMSrcMem,       // if >=u, R32 = [mem32]
516                   (ops R32:$dst, R32:$src1, i32mem:$src2),
517                   "cmovae {$src2, $dst|$dst, $src2}", []>, TB;
518
519 def CMOVE16rr : I<0x44, MRMSrcReg,       // if ==, R16 = R16
520                   (ops R16:$dst, R16:$src1, R16:$src2),
521                   "cmove {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
522 def CMOVE16rm : I<0x44, MRMSrcMem,       // if ==, R16 = [mem16]
523                   (ops R16:$dst, R16:$src1, i16mem:$src2),
524                   "cmove {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
525 def CMOVE32rr : I<0x44, MRMSrcReg,       // if ==, R32 = R32
526                   (ops R32:$dst, R32:$src1, R32:$src2),
527                   "cmove {$src2, $dst|$dst, $src2}", []>, TB;
528 def CMOVE32rm : I<0x44, MRMSrcMem,       // if ==, R32 = [mem32]
529                   (ops R32:$dst, R32:$src1, i32mem:$src2),
530                   "cmove {$src2, $dst|$dst, $src2}", []>, TB;
531
532 def CMOVNE16rr: I<0x45, MRMSrcReg,       // if !=, R16 = R16
533                   (ops R16:$dst, R16:$src1, R16:$src2),
534                   "cmovne {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
535 def CMOVNE16rm: I<0x45, MRMSrcMem,       // if !=, R16 = [mem16]
536                   (ops R16:$dst, R16:$src1, i16mem:$src2),
537                   "cmovne {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
538 def CMOVNE32rr: I<0x45, MRMSrcReg,       // if !=, R32 = R32
539                   (ops R32:$dst, R32:$src1, R32:$src2),
540                   "cmovne {$src2, $dst|$dst, $src2}", []>, TB;
541 def CMOVNE32rm: I<0x45, MRMSrcMem,       // if !=, R32 = [mem32]
542                   (ops R32:$dst, R32:$src1, i32mem:$src2),
543                   "cmovne {$src2, $dst|$dst, $src2}", []>, TB;
544
545 def CMOVBE16rr: I<0x46, MRMSrcReg,       // if <=u, R16 = R16
546                   (ops R16:$dst, R16:$src1, R16:$src2),
547                   "cmovbe {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
548 def CMOVBE16rm: I<0x46, MRMSrcMem,       // if <=u, R16 = [mem16]
549                   (ops R16:$dst, R16:$src1, i16mem:$src2),
550                   "cmovbe {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
551 def CMOVBE32rr: I<0x46, MRMSrcReg,       // if <=u, R32 = R32
552                   (ops R32:$dst, R32:$src1, R32:$src2),
553                   "cmovbe {$src2, $dst|$dst, $src2}", []>, TB;
554 def CMOVBE32rm: I<0x46, MRMSrcMem,       // if <=u, R32 = [mem32]
555                   (ops R32:$dst, R32:$src1, i32mem:$src2),
556                   "cmovbe {$src2, $dst|$dst, $src2}", []>, TB;
557
558 def CMOVA16rr : I<0x47, MRMSrcReg,       // if >u, R16 = R16
559                   (ops R16:$dst, R16:$src1, R16:$src2),
560                   "cmova {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
561 def CMOVA16rm : I<0x47, MRMSrcMem,       // if >u, R16 = [mem16]
562                   (ops R16:$dst, R16:$src1, i16mem:$src2),
563                   "cmova {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
564 def CMOVA32rr : I<0x47, MRMSrcReg,       // if >u, R32 = R32
565                   (ops R32:$dst, R32:$src1, R32:$src2),
566                   "cmova {$src2, $dst|$dst, $src2}", []>, TB;
567 def CMOVA32rm : I<0x47, MRMSrcMem,       // if >u, R32 = [mem32]
568                   (ops R32:$dst, R32:$src1, i32mem:$src2),
569                   "cmova {$src2, $dst|$dst, $src2}", []>, TB;
570
571 def CMOVS16rr : I<0x48, MRMSrcReg,       // if signed, R16 = R16
572                   (ops R16:$dst, R16:$src1, R16:$src2),
573                   "cmovs {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
574 def CMOVS16rm : I<0x48, MRMSrcMem,       // if signed, R16 = [mem16]
575                   (ops R16:$dst, R16:$src1, i16mem:$src2),
576                   "cmovs {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
577 def CMOVS32rr : I<0x48, MRMSrcReg,       // if signed, R32 = R32
578                   (ops R32:$dst, R32:$src1, R32:$src2),
579                   "cmovs {$src2, $dst|$dst, $src2}", []>, TB;
580 def CMOVS32rm : I<0x48, MRMSrcMem,       // if signed, R32 = [mem32]
581                   (ops R32:$dst, R32:$src1, i32mem:$src2),
582                   "cmovs {$src2, $dst|$dst, $src2}", []>, TB;
583
584 def CMOVNS16rr: I<0x49, MRMSrcReg,       // if !signed, R16 = R16
585                   (ops R16:$dst, R16:$src1, R16:$src2),
586                   "cmovns {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
587 def CMOVNS16rm: I<0x49, MRMSrcMem,       // if !signed, R16 = [mem16]
588                   (ops R16:$dst, R16:$src1, i16mem:$src2),
589                   "cmovns {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
590 def CMOVNS32rr: I<0x49, MRMSrcReg,       // if !signed, R32 = R32
591                   (ops R32:$dst, R32:$src1, R32:$src2),
592                   "cmovns {$src2, $dst|$dst, $src2}", []>, TB;
593 def CMOVNS32rm: I<0x49, MRMSrcMem,       // if !signed, R32 = [mem32]
594                   (ops R32:$dst, R32:$src1, i32mem:$src2),
595                   "cmovns {$src2, $dst|$dst, $src2}", []>, TB;
596
597 def CMOVP16rr : I<0x4A, MRMSrcReg,       // if parity, R16 = R16
598                   (ops R16:$dst, R16:$src1, R16:$src2),
599                   "cmovp {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
600 def CMOVP16rm : I<0x4A, MRMSrcMem,       // if parity, R16 = [mem16]
601                   (ops R16:$dst, R16:$src1, i16mem:$src2),
602                   "cmovp {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
603 def CMOVP32rr : I<0x4A, MRMSrcReg,       // if parity, R32 = R32
604                   (ops R32:$dst, R32:$src1, R32:$src2),
605                   "cmovp {$src2, $dst|$dst, $src2}", []>, TB;
606 def CMOVP32rm : I<0x4A, MRMSrcMem,       // if parity, R32 = [mem32]
607                   (ops R32:$dst, R32:$src1, i32mem:$src2),
608                   "cmovp {$src2, $dst|$dst, $src2}", []>, TB;
609
610  
611 def CMOVNP16rr : I<0x4B, MRMSrcReg,       // if !parity, R16 = R16
612                   (ops R16:$dst, R16:$src1, R16:$src2),
613                   "cmovnp {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
614 def CMOVNP16rm : I<0x4B, MRMSrcMem,       // if !parity, R16 = [mem16]
615                   (ops R16:$dst, R16:$src1, i16mem:$src2),
616                   "cmovnp {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
617 def CMOVNP32rr : I<0x4B, MRMSrcReg,       // if !parity, R32 = R32
618                   (ops R32:$dst, R32:$src1, R32:$src2),
619                   "cmovnp {$src2, $dst|$dst, $src2}", []>, TB;
620 def CMOVNP32rm : I<0x4B, MRMSrcMem,       // if !parity, R32 = [mem32]
621                   (ops R32:$dst, R32:$src1, i32mem:$src2),
622                   "cmovnp {$src2, $dst|$dst, $src2}", []>, TB;
623
624
625 def CMOVL16rr : I<0x4C, MRMSrcReg,       // if <s, R16 = R16
626                   (ops R16:$dst, R16:$src1, R16:$src2),
627                   "cmovl {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
628 def CMOVL16rm : I<0x4C, MRMSrcMem,       // if <s, R16 = [mem16]
629                   (ops R16:$dst, R16:$src1, i16mem:$src2),
630                   "cmovl {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
631 def CMOVL32rr : I<0x4C, MRMSrcReg,       // if <s, R32 = R32
632                   (ops R32:$dst, R32:$src1, R32:$src2),
633                   "cmovl {$src2, $dst|$dst, $src2}", []>, TB;
634 def CMOVL32rm : I<0x4C, MRMSrcMem,       // if <s, R32 = [mem32]
635                   (ops R32:$dst, R32:$src1, i32mem:$src2),
636                   "cmovl {$src2, $dst|$dst, $src2}", []>, TB;
637
638 def CMOVGE16rr: I<0x4D, MRMSrcReg,       // if >=s, R16 = R16
639                   (ops R16:$dst, R16:$src1, R16:$src2),
640                   "cmovge {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
641 def CMOVGE16rm: I<0x4D, MRMSrcMem,       // if >=s, R16 = [mem16]
642                   (ops R16:$dst, R16:$src1, i16mem:$src2),
643                   "cmovge {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
644 def CMOVGE32rr: I<0x4D, MRMSrcReg,       // if >=s, R32 = R32
645                   (ops R32:$dst, R32:$src1, R32:$src2),
646                   "cmovge {$src2, $dst|$dst, $src2}", []>, TB;
647 def CMOVGE32rm: I<0x4D, MRMSrcMem,       // if >=s, R32 = [mem32]
648                   (ops R32:$dst, R32:$src1, i32mem:$src2),
649                   "cmovge {$src2, $dst|$dst, $src2}", []>, TB;
650
651 def CMOVLE16rr: I<0x4E, MRMSrcReg,       // if <=s, R16 = R16
652                   (ops R16:$dst, R16:$src1, R16:$src2),
653                   "cmovle {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
654 def CMOVLE16rm: I<0x4E, MRMSrcMem,       // if <=s, R16 = [mem16]
655                   (ops R16:$dst, R16:$src1, i16mem:$src2),
656                   "cmovle {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
657 def CMOVLE32rr: I<0x4E, MRMSrcReg,       // if <=s, R32 = R32
658                   (ops R32:$dst, R32:$src1, R32:$src2),
659                   "cmovle {$src2, $dst|$dst, $src2}", []>, TB;
660 def CMOVLE32rm: I<0x4E, MRMSrcMem,       // if <=s, R32 = [mem32]
661                   (ops R32:$dst, R32:$src1, i32mem:$src2),
662                   "cmovle {$src2, $dst|$dst, $src2}", []>, TB;
663
664 def CMOVG16rr : I<0x4F, MRMSrcReg,       // if >s, R16 = R16
665                   (ops R16:$dst, R16:$src1, R16:$src2),
666                   "cmovg {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
667 def CMOVG16rm : I<0x4F, MRMSrcMem,       // if >s, R16 = [mem16]
668                   (ops R16:$dst, R16:$src1, i16mem:$src2),
669                   "cmovg {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
670 def CMOVG32rr : I<0x4F, MRMSrcReg,       // if >s, R32 = R32
671                   (ops R32:$dst, R32:$src1, R32:$src2),
672                   "cmovg {$src2, $dst|$dst, $src2}", []>, TB;
673 def CMOVG32rm : I<0x4F, MRMSrcMem,       // if >s, R32 = [mem32]
674                   (ops R32:$dst, R32:$src1, i32mem:$src2),
675                   "cmovg {$src2, $dst|$dst, $src2}", []>, TB;
676
677 // unary instructions
678 def NEG8r  : I<0xF6, MRM3r, (ops R8 :$dst, R8 :$src), "neg{b} $dst",
679                [(set R8:$dst, (ineg R8:$src))]>;
680 def NEG16r : I<0xF7, MRM3r, (ops R16:$dst, R16:$src), "neg{w} $dst",
681                [(set R16:$dst, (ineg R16:$src))]>, OpSize;
682 def NEG32r : I<0xF7, MRM3r, (ops R32:$dst, R32:$src), "neg{l} $dst",
683                [(set R32:$dst, (ineg R32:$src))]>;
684 let isTwoAddress = 0 in {
685   def NEG8m  : I<0xF6, MRM3m, (ops i8mem :$dst), "neg{b} $dst", []>;
686   def NEG16m : I<0xF7, MRM3m, (ops i16mem:$dst), "neg{w} $dst", []>, OpSize;
687   def NEG32m : I<0xF7, MRM3m, (ops i32mem:$dst), "neg{l} $dst", []>;
688 }
689
690 def NOT8r  : I<0xF6, MRM2r, (ops R8 :$dst, R8 :$src), "not{b} $dst",
691                [(set R8:$dst, (not R8:$src))]>;
692 def NOT16r : I<0xF7, MRM2r, (ops R16:$dst, R16:$src), "not{w} $dst",
693                [(set R16:$dst, (not R16:$src))]>, OpSize;
694 def NOT32r : I<0xF7, MRM2r, (ops R32:$dst, R32:$src), "not{l} $dst",
695                [(set R32:$dst, (not R32:$src))]>;
696 let isTwoAddress = 0 in {
697   def NOT8m  : I<0xF6, MRM2m, (ops i8mem :$dst), "not{b} $dst", []>;
698   def NOT16m : I<0xF7, MRM2m, (ops i16mem:$dst), "not{w} $dst", []>, OpSize;
699   def NOT32m : I<0xF7, MRM2m, (ops i32mem:$dst), "not{l} $dst", []>;
700 }
701
702 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
703 def INC8r  : I<0xFE, MRM0r, (ops R8 :$dst, R8 :$src), "inc{b} $dst",
704                [(set R8:$dst, (add R8:$src, 1))]>;
705 let isConvertibleToThreeAddress = 1 in {   // Can transform into LEA.
706 def INC16r : I<0xFF, MRM0r, (ops R16:$dst, R16:$src), "inc{w} $dst",
707                [(set R16:$dst, (add R16:$src, 1))]>, OpSize;
708 def INC32r : I<0xFF, MRM0r, (ops R32:$dst, R32:$src), "inc{l} $dst",
709                [(set R32:$dst, (add R32:$src, 1))]>;
710 }
711 let isTwoAddress = 0 in {
712   def INC8m  : I<0xFE, MRM0m, (ops i8mem :$dst), "inc{b} $dst", []>;
713   def INC16m : I<0xFF, MRM0m, (ops i16mem:$dst), "inc{w} $dst", []>, OpSize;
714   def INC32m : I<0xFF, MRM0m, (ops i32mem:$dst), "inc{l} $dst", []>;
715 }
716
717 def DEC8r  : I<0xFE, MRM1r, (ops R8 :$dst, R8 :$src), "dec{b} $dst",
718                [(set R8:$dst, (add R8:$src, -1))]>;
719 let isConvertibleToThreeAddress = 1 in {   // Can transform into LEA.
720 def DEC16r : I<0xFF, MRM1r, (ops R16:$dst, R16:$src), "dec{w} $dst",
721                [(set R16:$dst, (add R16:$src, -1))]>, OpSize;
722 def DEC32r : I<0xFF, MRM1r, (ops R32:$dst, R32:$src), "dec{l} $dst",
723                [(set R32:$dst, (add R32:$src, -1))]>;
724 }
725
726 let isTwoAddress = 0 in {
727   def DEC8m  : I<0xFE, MRM1m, (ops i8mem :$dst), "dec{b} $dst", []>;
728   def DEC16m : I<0xFF, MRM1m, (ops i16mem:$dst), "dec{w} $dst", []>, OpSize;
729   def DEC32m : I<0xFF, MRM1m, (ops i32mem:$dst), "dec{l} $dst", []>;
730 }
731
732 // Logical operators...
733 let isCommutable = 1 in {   // X = AND Y, Z   --> X = AND Z, Y
734 def AND8rr   : I<0x20, MRMDestReg,
735                 (ops R8 :$dst, R8 :$src1, R8 :$src2),
736                 "and{b} {$src2, $dst|$dst, $src2}",
737                 [(set R8:$dst, (and R8:$src1, R8:$src2))]>;
738 def AND16rr  : I<0x21, MRMDestReg,
739                  (ops R16:$dst, R16:$src1, R16:$src2),
740                  "and{w} {$src2, $dst|$dst, $src2}",
741                  [(set R16:$dst, (and R16:$src1, R16:$src2))]>, OpSize;
742 def AND32rr  : I<0x21, MRMDestReg, 
743                  (ops R32:$dst, R32:$src1, R32:$src2),
744                  "and{l} {$src2, $dst|$dst, $src2}",
745                  [(set R32:$dst, (and R32:$src1, R32:$src2))]>;
746 }
747
748 def AND8rm   : I<0x22, MRMSrcMem, 
749                  (ops R8 :$dst, R8 :$src1, i8mem :$src2),
750                  "and{b} {$src2, $dst|$dst, $src2}",[]>;
751 def AND16rm  : I<0x23, MRMSrcMem, 
752                  (ops R16:$dst, R16:$src1, i16mem:$src2),
753                  "and{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
754 def AND32rm  : I<0x23, MRMSrcMem,
755                  (ops R32:$dst, R32:$src1, i32mem:$src2),
756                  "and{l} {$src2, $dst|$dst, $src2}", []>;
757
758 def AND8ri   : Ii8<0x80, MRM4r, 
759                    (ops R8 :$dst, R8 :$src1, i8imm :$src2),
760                    "and{b} {$src2, $dst|$dst, $src2}",
761                    [(set R8:$dst, (and R8:$src1, imm:$src2))]>;
762 def AND16ri  : Ii16<0x81, MRM4r, 
763                     (ops R16:$dst, R16:$src1, i16imm:$src2),
764                     "and{w} {$src2, $dst|$dst, $src2}",
765                     [(set R16:$dst, (and R16:$src1, imm:$src2))]>, OpSize;
766 def AND32ri  : Ii32<0x81, MRM4r, 
767                     (ops R32:$dst, R32:$src1, i32imm:$src2),
768                     "and{l} {$src2, $dst|$dst, $src2}",
769                     [(set R32:$dst, (and R32:$src1, imm:$src2))]>;
770 def AND16ri8 : Ii8<0x83, MRM4r, 
771                    (ops R16:$dst, R16:$src1, i16i8imm:$src2),
772                    "and{w} {$src2, $dst|$dst, $src2}",
773                    [(set R16:$dst, (and R16:$src1, i16SExt8:$src2))]>, OpSize;
774 def AND32ri8 : Ii8<0x83, MRM4r, 
775                    (ops R32:$dst, R32:$src1, i32i8imm:$src2),
776                    "and{l} {$src2, $dst|$dst, $src2}",
777                    [(set R32:$dst, (and R32:$src1, i32SExt8:$src2))]>;
778
779 let isTwoAddress = 0 in {
780   def AND8mr   : I<0x20, MRMDestMem,
781                    (ops i8mem :$dst, R8 :$src),
782                    "and{b} {$src, $dst|$dst, $src}", []>;
783   def AND16mr  : I<0x21, MRMDestMem,
784                    (ops i16mem:$dst, R16:$src),
785                    "and{w} {$src, $dst|$dst, $src}", []>, OpSize;
786   def AND32mr  : I<0x21, MRMDestMem,
787                    (ops i32mem:$dst, R32:$src),
788                    "and{l} {$src, $dst|$dst, $src}", []>;
789   def AND8mi   : Ii8<0x80, MRM4m,
790                      (ops i8mem :$dst, i8imm :$src),
791                      "and{b} {$src, $dst|$dst, $src}", []>;
792   def AND16mi  : Ii16<0x81, MRM4m,
793                       (ops i16mem:$dst, i16imm:$src),
794                       "and{w} {$src, $dst|$dst, $src}", []>, OpSize;
795   def AND32mi  : Ii32<0x81, MRM4m,
796                       (ops i32mem:$dst, i32imm:$src),
797                       "and{l} {$src, $dst|$dst, $src}", []>;
798   def AND16mi8 : Ii8<0x83, MRM4m,
799                      (ops i16mem:$dst, i8imm :$src),
800                      "and{w} {$src, $dst|$dst, $src}", []>, OpSize;
801   def AND32mi8 : Ii8<0x83, MRM4m,
802                      (ops i32mem:$dst, i8imm :$src),
803                      "and{l} {$src, $dst|$dst, $src}", []>;
804 }
805
806
807 let isCommutable = 1 in {   // X = OR Y, Z   --> X = OR Z, Y
808 def OR8rr    : I<0x08, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2),
809                  "or{b} {$src2, $dst|$dst, $src2}",
810                  [(set R8:$dst, (or R8:$src1, R8:$src2))]>;
811 def OR16rr   : I<0x09, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
812                  "or{w} {$src2, $dst|$dst, $src2}",
813                  [(set R16:$dst, (or R16:$src1, R16:$src2))]>, OpSize;
814 def OR32rr   : I<0x09, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
815                  "or{l} {$src2, $dst|$dst, $src2}",
816                  [(set R32:$dst, (or R32:$src1, R32:$src2))]>;
817 }
818 def OR8rm    : I<0x0A, MRMSrcMem , (ops R8 :$dst, R8 :$src1, i8mem :$src2),
819                  "or{b} {$src2, $dst|$dst, $src2}", []>;
820 def OR16rm   : I<0x0B, MRMSrcMem , (ops R16:$dst, R16:$src1, i16mem:$src2),
821                  "or{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
822 def OR32rm   : I<0x0B, MRMSrcMem , (ops R32:$dst, R32:$src1, i32mem:$src2),
823                  "or{l} {$src2, $dst|$dst, $src2}", []>;
824
825 def OR8ri    : Ii8 <0x80, MRM1r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
826                     "or{b} {$src2, $dst|$dst, $src2}",
827                     [(set R8:$dst, (or R8:$src1, imm:$src2))]>;
828 def OR16ri   : Ii16<0x81, MRM1r, (ops R16:$dst, R16:$src1, i16imm:$src2),
829                     "or{w} {$src2, $dst|$dst, $src2}", 
830                     [(set R16:$dst, (or R16:$src1, imm:$src2))]>, OpSize;
831 def OR32ri   : Ii32<0x81, MRM1r, (ops R32:$dst, R32:$src1, i32imm:$src2),
832                     "or{l} {$src2, $dst|$dst, $src2}",
833                     [(set R32:$dst, (or R32:$src1, imm:$src2))]>;
834
835 def OR16ri8  : Ii8<0x83, MRM1r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
836                    "or{w} {$src2, $dst|$dst, $src2}",
837                    [(set R16:$dst, (or R16:$src1, i16SExt8:$src2))]>, OpSize;
838 def OR32ri8  : Ii8<0x83, MRM1r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
839                    "or{l} {$src2, $dst|$dst, $src2}",
840                    [(set R32:$dst, (or R32:$src1, i32SExt8:$src2))]>;
841 let isTwoAddress = 0 in {
842   def OR8mr  : I<0x08, MRMDestMem, (ops i8mem:$dst, R8:$src),
843                  "or{b} {$src, $dst|$dst, $src}", []>;
844   def OR16mr : I<0x09, MRMDestMem, (ops i16mem:$dst, R16:$src),
845                  "or{w} {$src, $dst|$dst, $src}", []>, OpSize;
846   def OR32mr : I<0x09, MRMDestMem, (ops i32mem:$dst, R32:$src),
847                  "or{l} {$src, $dst|$dst, $src}", []>;
848   def OR8mi    : Ii8<0x80, MRM1m, (ops i8mem :$dst, i8imm:$src),
849                  "or{b} {$src, $dst|$dst, $src}", []>;
850   def OR16mi   : Ii16<0x81, MRM1m, (ops i16mem:$dst, i16imm:$src),
851                  "or{w} {$src, $dst|$dst, $src}", []>, OpSize;
852   def OR32mi   : Ii32<0x81, MRM1m, (ops i32mem:$dst, i32imm:$src),
853                  "or{l} {$src, $dst|$dst, $src}", []>;
854   def OR16mi8  : Ii8<0x83, MRM1m, (ops i16mem:$dst, i8imm:$src),
855                  "or{w} {$src, $dst|$dst, $src}", []>, OpSize;
856   def OR32mi8  : Ii8<0x83, MRM1m, (ops i32mem:$dst, i8imm:$src),
857                  "or{l} {$src, $dst|$dst, $src}", []>;
858 }
859
860
861 let isCommutable = 1 in {   // X = XOR Y, Z   --> X = XOR Z, Y
862 def XOR8rr   : I<0x30, MRMDestReg,
863                  (ops R8 :$dst, R8 :$src1, R8 :$src2),
864                  "xor{b} {$src2, $dst|$dst, $src2}",
865                  [(set R8:$dst, (xor R8:$src1, R8:$src2))]>;
866 def XOR16rr  : I<0x31, MRMDestReg, 
867                  (ops R16:$dst, R16:$src1, R16:$src2), 
868                  "xor{w} {$src2, $dst|$dst, $src2}",
869                  [(set R16:$dst, (xor R16:$src1, R16:$src2))]>, OpSize;
870 def XOR32rr  : I<0x31, MRMDestReg, 
871                  (ops R32:$dst, R32:$src1, R32:$src2), 
872                  "xor{l} {$src2, $dst|$dst, $src2}",
873                  [(set R32:$dst, (xor R32:$src1, R32:$src2))]>;
874 }
875
876 def XOR8rm   : I<0x32, MRMSrcMem , 
877                  (ops R8 :$dst, R8:$src1, i8mem :$src2), 
878                  "xor{b} {$src2, $dst|$dst, $src2}", []>;
879 def XOR16rm  : I<0x33, MRMSrcMem , 
880                  (ops R16:$dst, R8:$src1, i16mem:$src2), 
881                  "xor{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
882 def XOR32rm  : I<0x33, MRMSrcMem , 
883                  (ops R32:$dst, R8:$src1, i32mem:$src2), 
884                  "xor{l} {$src2, $dst|$dst, $src2}", []>;
885
886 def XOR8ri   : Ii8<0x80, MRM6r, 
887                    (ops R8:$dst, R8:$src1, i8imm:$src2), 
888                    "xor{b} {$src2, $dst|$dst, $src2}",
889                    [(set R8:$dst, (xor R8:$src1, imm:$src2))]>;
890 def XOR16ri  : Ii16<0x81, MRM6r, 
891                     (ops R16:$dst, R16:$src1, i16imm:$src2), 
892                     "xor{w} {$src2, $dst|$dst, $src2}",
893                     [(set R16:$dst, (xor R16:$src1, imm:$src2))]>, OpSize;
894 def XOR32ri  : Ii32<0x81, MRM6r, 
895                     (ops R32:$dst, R32:$src1, i32imm:$src2), 
896                     "xor{l} {$src2, $dst|$dst, $src2}",
897                     [(set R32:$dst, (xor R32:$src1, imm:$src2))]>;
898 def XOR16ri8 : Ii8<0x83, MRM6r, 
899                    (ops R16:$dst, R16:$src1, i16i8imm:$src2),
900                    "xor{w} {$src2, $dst|$dst, $src2}",
901                    [(set R16:$dst, (xor R16:$src1, i16SExt8:$src2))]>, OpSize;
902 def XOR32ri8 : Ii8<0x83, MRM6r, 
903                    (ops R32:$dst, R32:$src1, i32i8imm:$src2),
904                    "xor{l} {$src2, $dst|$dst, $src2}",
905                    [(set R32:$dst, (xor R32:$src1, i32SExt8:$src2))]>;
906 let isTwoAddress = 0 in {
907   def XOR8mr   : I<0x30, MRMDestMem,
908                    (ops i8mem :$dst, R8 :$src),
909                    "xor{b} {$src, $dst|$dst, $src}", []>;
910   def XOR16mr  : I<0x31, MRMDestMem,
911                    (ops i16mem:$dst, R16:$src),
912                    "xor{w} {$src, $dst|$dst, $src}", []>, OpSize;
913   def XOR32mr  : I<0x31, MRMDestMem,
914                    (ops i32mem:$dst, R32:$src),
915                    "xor{l} {$src, $dst|$dst, $src}", []>;
916   def XOR8mi   : Ii8<0x80, MRM6m,
917                      (ops i8mem :$dst, i8imm :$src),
918                      "xor{b} {$src, $dst|$dst, $src}", []>;
919   def XOR16mi  : Ii16<0x81, MRM6m,
920                       (ops i16mem:$dst, i16imm:$src),
921                       "xor{w} {$src, $dst|$dst, $src}", []>, OpSize;
922   def XOR32mi  : Ii32<0x81, MRM6m,
923                       (ops i32mem:$dst, i32imm:$src),
924                       "xor{l} {$src, $dst|$dst, $src}", []>;
925   def XOR16mi8 : Ii8<0x83, MRM6m,
926                      (ops i16mem:$dst, i8imm :$src),
927                      "xor{w} {$src, $dst|$dst, $src}", []>, OpSize;
928   def XOR32mi8 : Ii8<0x83, MRM6m,
929                      (ops i32mem:$dst, i8imm :$src),
930                      "xor{l} {$src, $dst|$dst, $src}", []>;
931 }
932
933 // Shift instructions
934 // FIXME: provide shorter instructions when imm8 == 1
935 def SHL8rCL  : I<0xD2, MRM4r, (ops R8 :$dst, R8 :$src),
936                  "shl{b} {%cl, $dst|$dst, %CL}",
937                  [(set R8:$dst, (shl R8:$src, CL))]>, Imp<[CL],[]>;
938 def SHL16rCL : I<0xD3, MRM4r, (ops R16:$dst, R16:$src),
939                  "shl{w} {%cl, $dst|$dst, %CL}",
940                  [(set R16:$dst, (shl R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
941 def SHL32rCL : I<0xD3, MRM4r, (ops R32:$dst, R32:$src),
942                  "shl{l} {%cl, $dst|$dst, %CL}",
943                  [(set R32:$dst, (shl R32:$src, CL))]>, Imp<[CL],[]>;
944
945 def SHL8ri   : Ii8<0xC0, MRM4r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
946                    "shl{b} {$src2, $dst|$dst, $src2}",
947                    [(set R8:$dst, (shl R8:$src1, (i8 imm:$src2)))]>;
948 let isConvertibleToThreeAddress = 1 in {   // Can transform into LEA.
949 def SHL16ri  : Ii8<0xC1, MRM4r, (ops R16:$dst, R16:$src1, i8imm:$src2),
950                    "shl{w} {$src2, $dst|$dst, $src2}",
951                    [(set R16:$dst, (shl R16:$src1, (i8 imm:$src2)))]>, OpSize;
952 def SHL32ri  : Ii8<0xC1, MRM4r, (ops R32:$dst, R32:$src1, i8imm:$src2),
953                    "shl{l} {$src2, $dst|$dst, $src2}",
954                    [(set R32:$dst, (shl R32:$src1, (i8 imm:$src2)))]>;
955 }
956
957 let isTwoAddress = 0 in {
958   def SHL8mCL  : I<0xD2, MRM4m, (ops i8mem :$dst),
959                    "shl{b} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
960   def SHL16mCL : I<0xD3, MRM4m, (ops i16mem:$dst),
961                    "shl{w} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>, OpSize;
962   def SHL32mCL : I<0xD3, MRM4m, (ops i32mem:$dst),
963                    "shl{l} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
964   def SHL8mi   : Ii8<0xC0, MRM4m, (ops i8mem :$dst, i8imm:$src),
965                      "shl{b} {$src, $dst|$dst, $src}", []>;
966   def SHL16mi  : Ii8<0xC1, MRM4m, (ops i16mem:$dst, i8imm:$src),
967                      "shl{w} {$src, $dst|$dst, $src}", []>, OpSize;
968   def SHL32mi  : Ii8<0xC1, MRM4m, (ops i32mem:$dst, i8imm:$src),
969                      "shl{l} {$src, $dst|$dst, $src}", []>;
970 }
971
972 def SHR8rCL  : I<0xD2, MRM5r, (ops R8 :$dst, R8 :$src),
973                  "shr{b} {%cl, $dst|$dst, %CL}",
974                  [(set R8:$dst, (srl R8:$src, CL))]>, Imp<[CL],[]>;
975 def SHR16rCL : I<0xD3, MRM5r, (ops R16:$dst, R16:$src),
976                  "shr{w} {%cl, $dst|$dst, %CL}",
977                  [(set R16:$dst, (srl R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
978 def SHR32rCL : I<0xD3, MRM5r, (ops R32:$dst, R32:$src),
979                  "shr{l} {%cl, $dst|$dst, %CL}",
980                  [(set R32:$dst, (srl R32:$src, CL))]>, Imp<[CL],[]>;
981
982 def SHR8ri   : Ii8<0xC0, MRM5r, (ops R8:$dst, R8:$src1, i8imm:$src2),
983                    "shr{b} {$src2, $dst|$dst, $src2}",
984                    [(set R8:$dst, (srl R8:$src1, (i8 imm:$src2)))]>;
985 def SHR16ri  : Ii8<0xC1, MRM5r, (ops R16:$dst, R16:$src1, i8imm:$src2),
986                    "shr{w} {$src2, $dst|$dst, $src2}",
987                    [(set R16:$dst, (srl R16:$src1, (i8 imm:$src2)))]>, OpSize;
988 def SHR32ri  : Ii8<0xC1, MRM5r, (ops R32:$dst, R32:$src1, i8imm:$src2),
989                    "shr{l} {$src2, $dst|$dst, $src2}",
990                    [(set R32:$dst, (srl R32:$src1, (i8 imm:$src2)))]>;
991
992 let isTwoAddress = 0 in {
993   def SHR8mCL  : I<0xD2, MRM5m, (ops i8mem :$dst),
994                    "shr{b} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
995   def SHR16mCL : I<0xD3, MRM5m, (ops i16mem:$dst),
996                    "shr{w} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>, OpSize;
997   def SHR32mCL : I<0xD3, MRM5m, (ops i32mem:$dst),
998                    "shr{l} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
999   def SHR8mi   : Ii8<0xC0, MRM5m, (ops i8mem :$dst, i8imm:$src),
1000                      "shr{b} {$src, $dst|$dst, $src}", []>;
1001   def SHR16mi  : Ii8<0xC1, MRM5m, (ops i16mem:$dst, i8imm:$src),
1002                      "shr{w} {$src, $dst|$dst, $src}", []>, OpSize;
1003   def SHR32mi  : Ii8<0xC1, MRM5m, (ops i32mem:$dst, i8imm:$src),
1004                      "shr{l} {$src, $dst|$dst, $src}", []>;
1005 }
1006
1007 def SAR8rCL  : I<0xD2, MRM7r, (ops R8 :$dst, R8 :$src),
1008                  "sar{b} {%cl, $dst|$dst, %CL}",
1009                  [(set R8:$dst, (sra R8:$src, CL))]>, Imp<[CL],[]>;
1010 def SAR16rCL : I<0xD3, MRM7r, (ops R16:$dst, R16:$src),
1011                  "sar{w} {%cl, $dst|$dst, %CL}",
1012                  [(set R16:$dst, (sra R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1013 def SAR32rCL : I<0xD3, MRM7r, (ops R32:$dst, R32:$src),
1014                  "sar{l} {%cl, $dst|$dst, %CL}",
1015                  [(set R32:$dst, (sra R32:$src, CL))]>, Imp<[CL],[]>;
1016
1017 def SAR8ri   : Ii8<0xC0, MRM7r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
1018                    "sar{b} {$src2, $dst|$dst, $src2}",
1019                    [(set R8:$dst, (sra R8:$src1, (i8 imm:$src2)))]>;
1020 def SAR16ri  : Ii8<0xC1, MRM7r, (ops R16:$dst, R16:$src1, i8imm:$src2),
1021                    "sar{w} {$src2, $dst|$dst, $src2}",
1022                    [(set R16:$dst, (sra R16:$src1, (i8 imm:$src2)))]>,
1023                    OpSize;
1024 def SAR32ri  : Ii8<0xC1, MRM7r, (ops R32:$dst, R32:$src1, i8imm:$src2),
1025                    "sar{l} {$src2, $dst|$dst, $src2}",
1026                    [(set R32:$dst, (sra R32:$src1, (i8 imm:$src2)))]>;
1027 let isTwoAddress = 0 in {
1028   def SAR8mCL  : I<0xD2, MRM7m, (ops i8mem :$dst),
1029                    "sar{b} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
1030   def SAR16mCL : I<0xD3, MRM7m, (ops i16mem:$dst),
1031                    "sar{w} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>, OpSize;
1032   def SAR32mCL : I<0xD3, MRM7m, (ops i32mem:$dst), 
1033                    "sar{l} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
1034   def SAR8mi   : Ii8<0xC0, MRM7m, (ops i8mem :$dst, i8imm:$src),
1035                      "sar{b} {$src, $dst|$dst, $src}", []>;
1036   def SAR16mi  : Ii8<0xC1, MRM7m, (ops i16mem:$dst, i8imm:$src),
1037                      "sar{w} {$src, $dst|$dst, $src}", []>, OpSize;
1038   def SAR32mi  : Ii8<0xC1, MRM7m, (ops i32mem:$dst, i8imm:$src),
1039                      "sar{l} {$src, $dst|$dst, $src}", []>;
1040 }
1041
1042 // Rotate instructions
1043 // FIXME: provide shorter instructions when imm8 == 1
1044 def ROL8rCL  : I<0xD2, MRM0r, (ops R8 :$dst, R8 :$src),
1045                  "rol{b} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
1046 def ROL16rCL : I<0xD3, MRM0r, (ops R16:$dst, R16:$src),
1047                  "rol{w} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>, OpSize;
1048 def ROL32rCL : I<0xD3, MRM0r, (ops R32:$dst, R32:$src),
1049                  "rol{l} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
1050
1051 def ROL8ri   : Ii8<0xC0, MRM0r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
1052                    "rol{b} {$src2, $dst|$dst, $src2}", []>;
1053 def ROL16ri  : Ii8<0xC1, MRM0r, (ops R16:$dst, R16:$src1, i8imm:$src2),
1054                    "rol{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
1055 def ROL32ri  : Ii8<0xC1, MRM0r, (ops R32:$dst, R32:$src1, i8imm:$src2),
1056                    "rol{l} {$src2, $dst|$dst, $src2}", []>;
1057
1058 let isTwoAddress = 0 in {
1059   def ROL8mCL  : I<0xD2, MRM0m, (ops i8mem :$dst),
1060                    "rol{b} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
1061   def ROL16mCL : I<0xD3, MRM0m, (ops i16mem:$dst),
1062                    "rol{w} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>, OpSize;
1063   def ROL32mCL : I<0xD3, MRM0m, (ops i32mem:$dst),
1064                    "rol{l} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
1065   def ROL8mi   : Ii8<0xC0, MRM0m, (ops i8mem :$dst, i8imm:$src),
1066                      "rol{b} {$src, $dst|$dst, $src}", []>;
1067   def ROL16mi  : Ii8<0xC1, MRM0m, (ops i16mem:$dst, i8imm:$src),
1068                      "rol{w} {$src, $dst|$dst, $src}", []>, OpSize;
1069   def ROL32mi  : Ii8<0xC1, MRM0m, (ops i32mem:$dst, i8imm:$src),
1070                      "rol{l} {$src, $dst|$dst, $src}", []>;
1071 }
1072
1073 def ROR8rCL  : I<0xD2, MRM1r, (ops R8 :$dst, R8 :$src),
1074                  "ror{b} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
1075 def ROR16rCL : I<0xD3, MRM1r, (ops R16:$dst, R16:$src),
1076                  "ror{w} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>, OpSize;
1077 def ROR32rCL : I<0xD3, MRM1r, (ops R32:$dst, R32:$src),
1078                  "ror{l} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
1079
1080 def ROR8ri   : Ii8<0xC0, MRM1r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
1081                    "ror{b} {$src2, $dst|$dst, $src2}", []>;
1082 def ROR16ri  : Ii8<0xC1, MRM1r, (ops R16:$dst, R16:$src1, i8imm:$src2),
1083                    "ror{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
1084 def ROR32ri  : Ii8<0xC1, MRM1r, (ops R32:$dst, R32:$src1, i8imm:$src2),
1085                    "ror{l} {$src2, $dst|$dst, $src2}", []>;
1086 let isTwoAddress = 0 in {
1087   def ROR8mCL  : I<0xD2, MRM1m, (ops i8mem :$dst),
1088                    "ror{b} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
1089   def ROR16mCL : I<0xD3, MRM1m, (ops i16mem:$dst),
1090                    "ror{w} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>, OpSize;
1091   def ROR32mCL : I<0xD3, MRM1m, (ops i32mem:$dst), 
1092                    "ror{l} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
1093   def ROR8mi   : Ii8<0xC0, MRM1m, (ops i8mem :$dst, i8imm:$src),
1094                      "ror{b} {$src, $dst|$dst, $src}", []>;
1095   def ROR16mi  : Ii8<0xC1, MRM1m, (ops i16mem:$dst, i8imm:$src),
1096                      "ror{w} {$src, $dst|$dst, $src}", []>, OpSize;
1097   def ROR32mi  : Ii8<0xC1, MRM1m, (ops i32mem:$dst, i8imm:$src),
1098                      "ror{l} {$src, $dst|$dst, $src}", []>;
1099 }
1100
1101
1102
1103 // Double shift instructions (generalizations of rotate)
1104
1105 def SHLD32rrCL : I<0xA5, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1106                    "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
1107                    Imp<[CL],[]>, TB;
1108 def SHRD32rrCL : I<0xAD, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1109                    "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
1110                    Imp<[CL],[]>, TB;
1111 def SHLD16rrCL : I<0xA5, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
1112                    "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
1113                    Imp<[CL],[]>, TB, OpSize;
1114 def SHRD16rrCL : I<0xAD, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
1115                    "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
1116                    Imp<[CL],[]>, TB, OpSize;
1117
1118 let isCommutable = 1 in {  // These instructions commute to each other.
1119 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
1120                      (ops R32:$dst, R32:$src1, R32:$src2, i8imm:$src3),
1121                      "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}", []>, TB;
1122 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
1123                      (ops R32:$dst, R32:$src1, R32:$src2, i8imm:$src3),
1124                      "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}", []>, TB;
1125 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
1126                      (ops R16:$dst, R16:$src1, R16:$src2, i8imm:$src3),
1127                      "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
1128                      TB, OpSize;
1129 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
1130                      (ops R16:$dst, R16:$src1, R16:$src2, i8imm:$src3),
1131                      "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
1132                      TB, OpSize;
1133 }
1134
1135 let isTwoAddress = 0 in {
1136   def SHLD32mrCL : I<0xA5, MRMDestMem, (ops i32mem:$dst, R32:$src2),
1137                      "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
1138                      Imp<[CL],[]>, TB;
1139   def SHRD32mrCL : I<0xAD, MRMDestMem, (ops i32mem:$dst, R32:$src2),
1140                     "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
1141                     Imp<[CL],[]>, TB;
1142   def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
1143                       (ops i32mem:$dst, R32:$src2, i8imm:$src3),
1144                       "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
1145                       TB;
1146   def SHRD32mri8 : Ii8<0xAC, MRMDestMem, 
1147                        (ops i32mem:$dst, R32:$src2, i8imm:$src3),
1148                        "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
1149                        TB;
1150
1151   def SHLD16mrCL : I<0xA5, MRMDestMem, (ops i16mem:$dst, R16:$src2),
1152                      "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
1153                      Imp<[CL],[]>, TB, OpSize;
1154   def SHRD16mrCL : I<0xAD, MRMDestMem, (ops i16mem:$dst, R16:$src2),
1155                     "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
1156                     Imp<[CL],[]>, TB, OpSize;
1157   def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
1158                       (ops i16mem:$dst, R16:$src2, i8imm:$src3),
1159                       "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
1160                       TB, OpSize;
1161   def SHRD16mri8 : Ii8<0xAC, MRMDestMem, 
1162                        (ops i16mem:$dst, R16:$src2, i8imm:$src3),
1163                        "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
1164                        TB, OpSize;
1165 }
1166
1167
1168 // Arithmetic.
1169 let isCommutable = 1 in {   // X = ADD Y, Z   --> X = ADD Z, Y
1170 def ADD8rr   : I<0x00, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2),
1171                  "add{b} {$src2, $dst|$dst, $src2}",
1172                  [(set R8:$dst, (add R8:$src1, R8:$src2))]>;
1173 let isConvertibleToThreeAddress = 1 in {   // Can transform into LEA.
1174 def ADD16rr  : I<0x01, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
1175                  "add{w} {$src2, $dst|$dst, $src2}",
1176                  [(set R16:$dst, (add R16:$src1, R16:$src2))]>, OpSize;
1177 def ADD32rr  : I<0x01, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1178                  "add{l} {$src2, $dst|$dst, $src2}",
1179                  [(set R32:$dst, (add R32:$src1, R32:$src2))]>;
1180 } // end isConvertibleToThreeAddress
1181 } // end isCommutable
1182 def ADD8rm   : I<0x02, MRMSrcMem, (ops R8 :$dst, R8 :$src1, i8mem :$src2),
1183                  "add{b} {$src2, $dst|$dst, $src2}",
1184                  [(set R8:$dst, (add R8:$src1, (load addr:$src2)))]>;
1185 def ADD16rm  : I<0x03, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
1186                  "add{w} {$src2, $dst|$dst, $src2}",
1187                  [(set R16:$dst, (add R16:$src1, (load addr:$src2)))]>, OpSize;
1188 def ADD32rm  : I<0x03, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
1189                  "add{l} {$src2, $dst|$dst, $src2}",
1190                  [(set R32:$dst, (add R32:$src1, (load addr:$src2)))]>;
1191
1192 def ADD8ri   : Ii8<0x80, MRM0r, (ops R8:$dst, R8:$src1, i8imm:$src2),
1193                    "add{b} {$src2, $dst|$dst, $src2}",
1194                    [(set R8:$dst, (add R8:$src1, imm:$src2))]>;
1195
1196 let isConvertibleToThreeAddress = 1 in {   // Can transform into LEA.
1197 def ADD16ri  : Ii16<0x81, MRM0r, (ops R16:$dst, R16:$src1, i16imm:$src2),
1198                     "add{w} {$src2, $dst|$dst, $src2}",
1199                     [(set R16:$dst, (add R16:$src1, imm:$src2))]>, OpSize;
1200 def ADD32ri  : Ii32<0x81, MRM0r, (ops R32:$dst, R32:$src1, i32imm:$src2),
1201                     "add{l} {$src2, $dst|$dst, $src2}",
1202                     [(set R32:$dst, (add R32:$src1, imm:$src2))]>;
1203 }
1204
1205 // FIXME: move ADD16ri8 above ADD16ri to optimize for space.
1206 def ADD16ri8 : Ii8<0x83, MRM0r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1207                    "add{w} {$src2, $dst|$dst, $src2}",
1208                    [(set R16:$dst, (add R16:$src1, i16SExt8:$src2))]>, OpSize;
1209 def ADD32ri8 : Ii8<0x83, MRM0r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1210                    "add{l} {$src2, $dst|$dst, $src2}",
1211                    [(set R32:$dst, (add R32:$src1, i32SExt8:$src2))]>;
1212
1213 let isTwoAddress = 0 in {
1214   def ADD8mr   : I<0x00, MRMDestMem, (ops i8mem :$dst, R8 :$src2),
1215                    "add{b} {$src2, $dst|$dst, $src2}",
1216                    [(store (add (load addr:$dst), R8:$src2), addr:$dst)]>;
1217   def ADD16mr  : I<0x01, MRMDestMem, (ops i16mem:$dst, R16:$src2),
1218                    "add{w} {$src2, $dst|$dst, $src2}",
1219                    [(store (add (load addr:$dst), R16:$src2), addr:$dst)]>, OpSize;
1220   def ADD32mr  : I<0x01, MRMDestMem, (ops i32mem:$dst, R32:$src2),
1221                    "add{l} {$src2, $dst|$dst, $src2}",
1222                    [(store (add (load addr:$dst), R32:$src2), addr:$dst)]>;
1223   def ADD8mi   : Ii8<0x80, MRM0m, (ops i8mem :$dst, i8imm :$src2),
1224                      "add{b} {$src2, $dst|$dst, $src2}",
1225                    [(store (add (load addr:$dst), (i8 imm:$src2)), addr:$dst)]>;
1226   def ADD16mi  : Ii16<0x81, MRM0m, (ops i16mem:$dst, i16imm:$src2),
1227                       "add{w} {$src2, $dst|$dst, $src2}",
1228                    [(store (add (load addr:$dst), (i16 imm:$src2)), addr:$dst)]>, OpSize;
1229   def ADD32mi  : Ii32<0x81, MRM0m, (ops i32mem:$dst, i32imm:$src2),
1230                       "add{l} {$src2, $dst|$dst, $src2}",
1231                    [(store (add (load addr:$dst), (i32 imm:$src2)), addr:$dst)]>;
1232   def ADD16mi8 : Ii8<0x83, MRM0m, (ops i16mem:$dst, i16i8imm :$src2),
1233                      "add{w} {$src2, $dst|$dst, $src2}",
1234                    [(store (add (load addr:$dst), i16SExt8:$src2), addr:$dst)]>, OpSize;
1235   def ADD32mi8 : Ii8<0x83, MRM0m, (ops i32mem:$dst, i32i8imm :$src2),
1236                      "add{l} {$src2, $dst|$dst, $src2}",
1237                    [(store (add (load addr:$dst), i32SExt8:$src2), addr:$dst)]>;
1238 }
1239
1240 let isCommutable = 1 in {  // X = ADC Y, Z --> X = ADC Z, Y
1241 def ADC32rr  : I<0x11, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1242                  "adc{l} {$src2, $dst|$dst, $src2}", []>;
1243 }
1244 def ADC32rm  : I<0x13, MRMSrcMem , (ops R32:$dst, R32:$src1, i32mem:$src2),
1245                  "adc{l} {$src2, $dst|$dst, $src2}", []>;
1246 def ADC32ri  : Ii32<0x81, MRM2r, (ops R32:$dst, R32:$src1, i32imm:$src2),
1247                     "adc{l} {$src2, $dst|$dst, $src2}", []>;
1248 def ADC32ri8 : Ii8<0x83, MRM2r, (ops R32:$dst, R32:$src1, i8imm:$src2),
1249                    "adc{l} {$src2, $dst|$dst, $src2}", []>;
1250
1251 let isTwoAddress = 0 in {
1252   def ADC32mr  : I<0x11, MRMDestMem, (ops i32mem:$dst, R32:$src2),
1253                    "adc{l} {$src2, $dst|$dst, $src2}", []>;
1254   def ADC32mi  : Ii32<0x81, MRM2m, (ops i32mem:$dst, i32imm:$src2),
1255                       "adc{l} {$src2, $dst|$dst, $src2}", []>;
1256   def ADC32mi8 : Ii8<0x83, MRM2m, (ops i32mem:$dst, i8imm :$src2),
1257                      "adc{l} {$src2, $dst|$dst, $src2}", []>;
1258 }
1259
1260 def SUB8rr   : I<0x28, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2),
1261                  "sub{b} {$src2, $dst|$dst, $src2}",
1262                  [(set R8:$dst, (sub R8:$src1, R8:$src2))]>;
1263 def SUB16rr  : I<0x29, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
1264                  "sub{w} {$src2, $dst|$dst, $src2}",
1265                  [(set R16:$dst, (sub R16:$src1, R16:$src2))]>, OpSize;
1266 def SUB32rr  : I<0x29, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1267                  "sub{l} {$src2, $dst|$dst, $src2}",
1268                  [(set R32:$dst, (sub R32:$src1, R32:$src2))]>;
1269 def SUB8rm   : I<0x2A, MRMSrcMem, (ops R8 :$dst, R8 :$src1, i8mem :$src2),
1270                  "sub{b} {$src2, $dst|$dst, $src2}",
1271                  [(set R8:$dst, (sub R8:$src1, (load addr:$src2)))]>;
1272 def SUB16rm  : I<0x2B, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
1273                  "sub{w} {$src2, $dst|$dst, $src2}",
1274                  [(set R16:$dst, (sub R16:$src1, (load addr:$src2)))]>, OpSize;
1275 def SUB32rm  : I<0x2B, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
1276                  "sub{l} {$src2, $dst|$dst, $src2}",
1277                  [(set R32:$dst, (sub R32:$src1, (load addr:$src2)))]>;
1278
1279 def SUB8ri   : Ii8 <0x80, MRM5r, (ops R8:$dst, R8:$src1, i8imm:$src2),
1280                     "sub{b} {$src2, $dst|$dst, $src2}",
1281                     [(set R8:$dst, (sub R8:$src1, imm:$src2))]>;
1282 def SUB16ri  : Ii16<0x81, MRM5r, (ops R16:$dst, R16:$src1, i16imm:$src2),
1283                     "sub{w} {$src2, $dst|$dst, $src2}",
1284                     [(set R16:$dst, (sub R16:$src1, imm:$src2))]>, OpSize;
1285 def SUB32ri  : Ii32<0x81, MRM5r, (ops R32:$dst, R32:$src1, i32imm:$src2),
1286                     "sub{l} {$src2, $dst|$dst, $src2}",
1287                     [(set R32:$dst, (sub R32:$src1, imm:$src2))]>;
1288 def SUB16ri8 : Ii8<0x83, MRM5r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1289                    "sub{w} {$src2, $dst|$dst, $src2}",
1290                    [(set R16:$dst, (sub R16:$src1, i16SExt8:$src2))]>, OpSize;
1291 def SUB32ri8 : Ii8<0x83, MRM5r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1292                    "sub{l} {$src2, $dst|$dst, $src2}",
1293                    [(set R32:$dst, (sub R32:$src1, i32SExt8:$src2))]>;
1294 let isTwoAddress = 0 in {
1295   def SUB8mr   : I<0x28, MRMDestMem, (ops i8mem :$dst, R8 :$src2),
1296                    "sub{b} {$src2, $dst|$dst, $src2}",
1297                    [(store (sub (load addr:$dst), R8:$src2), addr:$dst)]>;
1298   def SUB16mr  : I<0x29, MRMDestMem, (ops i16mem:$dst, R16:$src2),
1299                    "sub{w} {$src2, $dst|$dst, $src2}",
1300                    [(store (sub (load addr:$dst), R16:$src2), addr:$dst)]>, OpSize;
1301   def SUB32mr  : I<0x29, MRMDestMem, (ops i32mem:$dst, R32:$src2), 
1302                    "sub{l} {$src2, $dst|$dst, $src2}",
1303                    [(store (sub (load addr:$dst), R32:$src2), addr:$dst)]>;
1304   def SUB8mi   : Ii8<0x80, MRM5m, (ops i8mem :$dst, i8imm:$src2), 
1305                      "sub{b} {$src2, $dst|$dst, $src2}",
1306                    [(store (sub (load addr:$dst), (i8 imm:$src2)), addr:$dst)]>;
1307   def SUB16mi  : Ii16<0x81, MRM5m, (ops i16mem:$dst, i16imm:$src2), 
1308                       "sub{w} {$src2, $dst|$dst, $src2}",
1309                    [(store (sub (load addr:$dst), (i16 imm:$src2)), addr:$dst)]>, OpSize;
1310   def SUB32mi  : Ii32<0x81, MRM5m, (ops i32mem:$dst, i32imm:$src2), 
1311                       "sub{l} {$src2, $dst|$dst, $src2}",
1312                    [(store (sub (load addr:$dst), (i32 imm:$src2)), addr:$dst)]>;
1313   def SUB16mi8 : Ii8<0x83, MRM5m, (ops i16mem:$dst, i16i8imm :$src2), 
1314                      "sub{w} {$src2, $dst|$dst, $src2}",
1315                    [(store (sub (load addr:$dst), i16SExt8:$src2), addr:$dst)]>, OpSize;
1316   def SUB32mi8 : Ii8<0x83, MRM5m, (ops i32mem:$dst, i32i8imm :$src2), 
1317                      "sub{l} {$src2, $dst|$dst, $src2}",
1318                    [(store (sub (load addr:$dst), i32SExt8:$src2), addr:$dst)]>;
1319 }
1320
1321 def SBB32rr    : I<0x19, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1322                   "sbb{l} {$src2, $dst|$dst, $src2}", []>;
1323
1324 let isTwoAddress = 0 in {
1325   def SBB32mr  : I<0x19, MRMDestMem, (ops i32mem:$dst, R32:$src2), 
1326                    "sbb{l} {$src2, $dst|$dst, $src2}", []>;
1327   def SBB8mi  : Ii32<0x80, MRM3m, (ops i8mem:$dst, i8imm:$src2), 
1328                       "sbb{b} {$src2, $dst|$dst, $src2}", []>;
1329   def SBB16mi  : Ii32<0x81, MRM3m, (ops i16mem:$dst, i16imm:$src2), 
1330                       "sbb{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
1331   def SBB32mi  : Ii32<0x81, MRM3m, (ops i32mem:$dst, i32imm:$src2), 
1332                       "sbb{l} {$src2, $dst|$dst, $src2}", []>;
1333   def SBB16mi8 : Ii8<0x83, MRM3m, (ops i16mem:$dst, i8imm :$src2), 
1334                      "sbb{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
1335   def SBB32mi8 : Ii8<0x83, MRM3m, (ops i32mem:$dst, i8imm :$src2), 
1336                      "sbb{l} {$src2, $dst|$dst, $src2}", []>;
1337 }
1338 def SBB8ri   : Ii8<0x80, MRM3r, (ops R8:$dst, R8:$src1, i8imm:$src2),
1339                     "sbb{b} {$src2, $dst|$dst, $src2}", []>;
1340 def SBB16ri  : Ii16<0x81, MRM3r, (ops R16:$dst, R16:$src1, i16imm:$src2),
1341                     "sbb{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
1342
1343 def SBB32rm  : I<0x1B, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
1344                     "sbb{l} {$src2, $dst|$dst, $src2}", []>;
1345 def SBB32ri  : Ii32<0x81, MRM3r, (ops R32:$dst, R32:$src1, i32imm:$src2),
1346                     "sbb{l} {$src2, $dst|$dst, $src2}", []>;
1347
1348 def SBB16ri8 : Ii8<0x83, MRM3r, (ops R16:$dst, R16:$src1, i8imm:$src2),
1349                    "sbb{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
1350 def SBB32ri8 : Ii8<0x83, MRM3r, (ops R32:$dst, R32:$src1, i8imm:$src2),
1351                    "sbb{l} {$src2, $dst|$dst, $src2}", []>;
1352
1353 let isCommutable = 1 in {  // X = IMUL Y, Z --> X = IMUL Z, Y
1354 def IMUL16rr : I<0xAF, MRMSrcReg, (ops R16:$dst, R16:$src1, R16:$src2),
1355                  "imul{w} {$src2, $dst|$dst, $src2}",
1356                  [(set R16:$dst, (mul R16:$src1, R16:$src2))]>, TB, OpSize;
1357 def IMUL32rr : I<0xAF, MRMSrcReg, (ops R32:$dst, R32:$src1, R32:$src2),
1358                  "imul{l} {$src2, $dst|$dst, $src2}",
1359                  [(set R32:$dst, (mul R32:$src1, R32:$src2))]>, TB;
1360 }
1361 def IMUL16rm : I<0xAF, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
1362                  "imul{w} {$src2, $dst|$dst, $src2}",
1363                  [(set R16:$dst, (mul R16:$src1, (load addr:$src2)))]>, TB, OpSize;
1364 def IMUL32rm : I<0xAF, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
1365                  "imul{l} {$src2, $dst|$dst, $src2}",
1366                  [(set R32:$dst, (mul R32:$src1, (load addr:$src2)))]>, TB;
1367
1368 } // end Two Address instructions
1369
1370 // Suprisingly enough, these are not two address instructions!
1371 def IMUL16rri  : Ii16<0x69, MRMSrcReg,                      // R16 = R16*I16
1372                       (ops R16:$dst, R16:$src1, i16imm:$src2),
1373                       "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
1374                       [(set R16:$dst, (mul R16:$src1, imm:$src2))]>, OpSize;
1375 def IMUL32rri  : Ii32<0x69, MRMSrcReg,                      // R32 = R32*I32
1376                       (ops R32:$dst, R32:$src1, i32imm:$src2),
1377                       "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
1378                       [(set R32:$dst, (mul R32:$src1, imm:$src2))]>;
1379 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg,                       // R16 = R16*I8
1380                      (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1381                      "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
1382                       [(set R16:$dst, (mul R16:$src1, i16SExt8:$src2))]>, OpSize;
1383 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg,                       // R32 = R32*I8
1384                      (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1385                      "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
1386                      [(set R32:$dst, (mul R32:$src1, i32SExt8:$src2))]>;
1387
1388 def IMUL16rmi  : Ii16<0x69, MRMSrcMem,                      // R16 = [mem16]*I16
1389                       (ops R16:$dst, i16mem:$src1, i16imm:$src2),
1390                       "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
1391                       [(set R16:$dst, (mul (load addr:$src1), imm:$src2))]>,
1392                       OpSize;
1393 def IMUL32rmi  : Ii32<0x69, MRMSrcMem,                      // R32 = [mem32]*I32
1394                       (ops R32:$dst, i32mem:$src1, i32imm:$src2),
1395                       "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
1396                       [(set R32:$dst, (mul (load addr:$src1), imm:$src2))]>;
1397 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem,                       // R16 = [mem16]*I8
1398                      (ops R16:$dst, i16mem:$src1, i16i8imm :$src2),
1399                      "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
1400                      [(set R16:$dst, (mul (load addr:$src1), i16SExt8:$src2))]>, OpSize;
1401 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem,                       // R32 = [mem32]*I8
1402                      (ops R32:$dst, i32mem:$src1, i32i8imm: $src2),
1403                      "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
1404                      [(set R32:$dst, (mul (load addr:$src1), i32SExt8:$src2))]>;
1405
1406 //===----------------------------------------------------------------------===//
1407 // Test instructions are just like AND, except they don't generate a result.
1408 //
1409 let isCommutable = 1 in {   // TEST X, Y   --> TEST Y, X
1410 def TEST8rr  : I<0x84, MRMDestReg, (ops R8:$src1, R8:$src2),
1411                  "test{b} {$src2, $src1|$src1, $src2}", []>;
1412 def TEST16rr : I<0x85, MRMDestReg, (ops R16:$src1, R16:$src2),
1413                  "test{w} {$src2, $src1|$src1, $src2}", []>, OpSize;
1414 def TEST32rr : I<0x85, MRMDestReg, (ops R32:$src1, R32:$src2),
1415                  "test{l} {$src2, $src1|$src1, $src2}", []>;
1416 }
1417 def TEST8mr  : I<0x84, MRMDestMem, (ops i8mem :$src1, R8 :$src2),
1418                  "test{b} {$src2, $src1|$src1, $src2}", []>;
1419 def TEST16mr : I<0x85, MRMDestMem, (ops i16mem:$src1, R16:$src2),
1420                  "test{w} {$src2, $src1|$src1, $src2}", []>, OpSize;
1421 def TEST32mr : I<0x85, MRMDestMem, (ops i32mem:$src1, R32:$src2),
1422                  "test{l} {$src2, $src1|$src1, $src2}", []>;
1423 def TEST8rm  : I<0x84, MRMSrcMem, (ops R8 :$src1, i8mem :$src2),
1424                  "test{b} {$src2, $src1|$src1, $src2}", []>;
1425 def TEST16rm : I<0x85, MRMSrcMem, (ops R16:$src1, i16mem:$src2),
1426                  "test{w} {$src2, $src1|$src1, $src2}", []>, OpSize;
1427 def TEST32rm : I<0x85, MRMSrcMem, (ops R32:$src1, i32mem:$src2),
1428                  "test{l} {$src2, $src1|$src1, $src2}", []>;
1429
1430 def TEST8ri  : Ii8 <0xF6, MRM0r,                     // flags = R8  & imm8
1431                     (ops R8:$src1, i8imm:$src2),
1432                     "test{b} {$src2, $src1|$src1, $src2}", []>;
1433 def TEST16ri : Ii16<0xF7, MRM0r,                     // flags = R16 & imm16
1434                     (ops R16:$src1, i16imm:$src2),
1435                     "test{w} {$src2, $src1|$src1, $src2}", []>, OpSize;
1436 def TEST32ri : Ii32<0xF7, MRM0r,                     // flags = R32 & imm32
1437                     (ops R32:$src1, i32imm:$src2),
1438                     "test{l} {$src2, $src1|$src1, $src2}", []>;
1439 def TEST8mi  : Ii8 <0xF6, MRM0m,                     // flags = [mem8]  & imm8
1440                     (ops i32mem:$src1, i8imm:$src2),
1441                     "test{b} {$src2, $src1|$src1, $src2}", []>;
1442 def TEST16mi : Ii16<0xF7, MRM0m,                     // flags = [mem16] & imm16
1443                     (ops i16mem:$src1, i16imm:$src2),
1444                     "test{w} {$src2, $src1|$src1, $src2}", []>, OpSize;
1445 def TEST32mi : Ii32<0xF7, MRM0m,                     // flags = [mem32] & imm32
1446                     (ops i32mem:$src1, i32imm:$src2),
1447                     "test{l} {$src2, $src1|$src1, $src2}", []>;
1448
1449
1450
1451 // Condition code ops, incl. set if equal/not equal/...
1452 def SAHF     : I<0x9E, RawFrm, (ops), "sahf", []>, Imp<[AH],[]>;  // flags = AH
1453 def LAHF     : I<0x9F, RawFrm, (ops), "lahf", []>, Imp<[],[AH]>;  // AH = flags
1454
1455 def SETBr    : I<0x92, MRM0r,
1456                  (ops R8   :$dst), "setb $dst", []>, TB;    // R8 = <  unsign
1457 def SETBm    : I<0x92, MRM0m,
1458                  (ops i8mem:$dst), "setb $dst", []>, TB;    // [mem8] = <  unsign
1459 def SETAEr   : I<0x93, MRM0r, 
1460                  (ops R8   :$dst), "setae $dst", []>, TB;   // R8 = >= unsign
1461 def SETAEm   : I<0x93, MRM0m, 
1462                  (ops i8mem:$dst), "setae $dst", []>, TB;   // [mem8] = >= unsign
1463 def SETEr    : I<0x94, MRM0r, 
1464                  (ops R8   :$dst), "sete $dst", []>, TB;    // R8 = ==
1465 def SETEm    : I<0x94, MRM0m, 
1466                  (ops i8mem:$dst), "sete $dst", []>, TB;    // [mem8] = ==
1467 def SETNEr   : I<0x95, MRM0r, 
1468                  (ops R8   :$dst), "setne $dst", []>, TB;   // R8 = !=
1469 def SETNEm   : I<0x95, MRM0m, 
1470                  (ops i8mem:$dst), "setne $dst", []>, TB;   // [mem8] = !=
1471 def SETBEr   : I<0x96, MRM0r, 
1472                  (ops R8   :$dst), "setbe $dst", []>, TB;   // R8 = <= unsign
1473 def SETBEm   : I<0x96, MRM0m, 
1474                  (ops i8mem:$dst), "setbe $dst", []>, TB;   // [mem8] = <= unsign
1475 def SETAr    : I<0x97, MRM0r, 
1476                  (ops R8   :$dst), "seta $dst", []>, TB;    // R8 = >  signed
1477 def SETAm    : I<0x97, MRM0m, 
1478                  (ops i8mem:$dst), "seta $dst", []>, TB;    // [mem8] = >  signed
1479 def SETSr    : I<0x98, MRM0r, 
1480                  (ops R8   :$dst), "sets $dst", []>, TB;    // R8 = <sign bit>
1481 def SETSm    : I<0x98, MRM0m, 
1482                  (ops i8mem:$dst), "sets $dst", []>, TB;    // [mem8] = <sign bit>
1483 def SETNSr   : I<0x99, MRM0r, 
1484                  (ops R8   :$dst), "setns $dst", []>, TB;   // R8 = !<sign bit>
1485 def SETNSm   : I<0x99, MRM0m, 
1486                  (ops i8mem:$dst), "setns $dst", []>, TB;   // [mem8] = !<sign bit>
1487 def SETPr    : I<0x9A, MRM0r, 
1488                  (ops R8   :$dst), "setp $dst", []>, TB;    // R8 = parity
1489 def SETPm    : I<0x9A, MRM0m, 
1490                  (ops i8mem:$dst), "setp $dst", []>, TB;    // [mem8] = parity
1491 def SETNPr   : I<0x9B, MRM0r, 
1492                  (ops R8   :$dst), "setnp $dst", []>, TB;   // R8 = not parity
1493 def SETNPm   : I<0x9B, MRM0m, 
1494                  (ops i8mem:$dst), "setnp $dst", []>, TB;   // [mem8] = not parity
1495 def SETLr    : I<0x9C, MRM0r, 
1496                  (ops R8   :$dst), "setl $dst", []>, TB;    // R8 = <  signed
1497 def SETLm    : I<0x9C, MRM0m, 
1498                  (ops i8mem:$dst), "setl $dst", []>, TB;    // [mem8] = <  signed
1499 def SETGEr   : I<0x9D, MRM0r, 
1500                  (ops R8   :$dst), "setge $dst", []>, TB;   // R8 = >= signed
1501 def SETGEm   : I<0x9D, MRM0m, 
1502                  (ops i8mem:$dst), "setge $dst", []>, TB;   // [mem8] = >= signed
1503 def SETLEr   : I<0x9E, MRM0r, 
1504                  (ops R8   :$dst), "setle $dst", []>, TB;   // R8 = <= signed
1505 def SETLEm   : I<0x9E, MRM0m, 
1506                  (ops i8mem:$dst), "setle $dst", []>, TB;   // [mem8] = <= signed
1507 def SETGr    : I<0x9F, MRM0r, 
1508                  (ops R8   :$dst), "setg $dst", []>, TB;    // R8 = <  signed
1509 def SETGm    : I<0x9F, MRM0m, 
1510                  (ops i8mem:$dst), "setg $dst", []>, TB;    // [mem8] = <  signed
1511
1512 // Integer comparisons
1513 def CMP8rr  : I<0x38, MRMDestReg,
1514                 (ops R8 :$src1, R8 :$src2),
1515                 "cmp{b} {$src2, $src1|$src1, $src2}", []>;
1516 def CMP16rr : I<0x39, MRMDestReg,
1517                 (ops R16:$src1, R16:$src2),
1518                 "cmp{w} {$src2, $src1|$src1, $src2}", []>, OpSize;
1519 def CMP32rr : I<0x39, MRMDestReg,
1520                 (ops R32:$src1, R32:$src2),
1521                 "cmp{l} {$src2, $src1|$src1, $src2}", []>;
1522 def CMP8mr  : I<0x38, MRMDestMem,
1523                 (ops i8mem :$src1, R8 :$src2),
1524                 "cmp{b} {$src2, $src1|$src1, $src2}", []>;
1525 def CMP16mr : I<0x39, MRMDestMem,
1526                 (ops i16mem:$src1, R16:$src2),
1527                 "cmp{w} {$src2, $src1|$src1, $src2}", []>, OpSize;
1528 def CMP32mr : I<0x39, MRMDestMem,
1529                 (ops i32mem:$src1, R32:$src2),
1530                 "cmp{l} {$src2, $src1|$src1, $src2}", []>;
1531 def CMP8rm  : I<0x3A, MRMSrcMem,
1532                 (ops R8 :$src1, i8mem :$src2),
1533                 "cmp{b} {$src2, $src1|$src1, $src2}", []>;
1534 def CMP16rm : I<0x3B, MRMSrcMem,
1535                 (ops R16:$src1, i16mem:$src2),
1536                 "cmp{w} {$src2, $src1|$src1, $src2}", []>, OpSize;
1537 def CMP32rm : I<0x3B, MRMSrcMem,
1538                 (ops R32:$src1, i32mem:$src2),
1539                 "cmp{l} {$src2, $src1|$src1, $src2}", []>;
1540 def CMP8ri  : Ii8<0x80, MRM7r,
1541                   (ops R16:$src1, i8imm:$src2),
1542                   "cmp{b} {$src2, $src1|$src1, $src2}", []>;
1543 def CMP16ri : Ii16<0x81, MRM7r,
1544                    (ops R16:$src1, i16imm:$src2),
1545                    "cmp{w} {$src2, $src1|$src1, $src2}", []>, OpSize;
1546 def CMP32ri : Ii32<0x81, MRM7r,
1547                    (ops R32:$src1, i32imm:$src2),
1548                    "cmp{l} {$src2, $src1|$src1, $src2}", []>;
1549 def CMP8mi  : Ii8 <0x80, MRM7m,
1550                    (ops i8mem :$src1, i8imm :$src2),
1551                    "cmp{b} {$src2, $src1|$src1, $src2}", []>;
1552 def CMP16mi : Ii16<0x81, MRM7m,
1553                    (ops i16mem:$src1, i16imm:$src2),
1554                    "cmp{w} {$src2, $src1|$src1, $src2}", []>, OpSize;
1555 def CMP32mi : Ii32<0x81, MRM7m,
1556                    (ops i32mem:$src1, i32imm:$src2),
1557                    "cmp{l} {$src2, $src1|$src1, $src2}", []>;
1558
1559 // Sign/Zero extenders
1560 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (ops R16:$dst, R8 :$src),
1561                    "movs{bw|x} {$src, $dst|$dst, $src}",
1562                    [(set R16:$dst, (sext R8:$src))]>, TB, OpSize;
1563 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (ops R16:$dst, i8mem :$src),
1564                    "movs{bw|x} {$src, $dst|$dst, $src}", []>, TB, OpSize;
1565 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (ops R32:$dst, R8 :$src),
1566                    "movs{bl|x} {$src, $dst|$dst, $src}",
1567                    [(set R32:$dst, (sext R8:$src))]>, TB;
1568 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (ops R32:$dst, i8mem :$src),
1569                    "movs{bl|x} {$src, $dst|$dst, $src}", []>, TB;
1570 def MOVSX32rr16: I<0xBF, MRMSrcReg, (ops R32:$dst, R16:$src),
1571                    "movs{wl|x} {$src, $dst|$dst, $src}",
1572                    [(set R32:$dst, (sext R16:$src))]>, TB;
1573 def MOVSX32rm16: I<0xBF, MRMSrcMem, (ops R32:$dst, i16mem:$src),
1574                    "movs{wl|x} {$src, $dst|$dst, $src}", []>, TB;
1575
1576 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (ops R16:$dst, R8 :$src),
1577                    "movz{bw|x} {$src, $dst|$dst, $src}",
1578                    [(set R16:$dst, (zext R8:$src))]>, TB, OpSize;
1579 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (ops R16:$dst, i8mem :$src),
1580                    "movz{bw|x} {$src, $dst|$dst, $src}", []>, TB, OpSize;
1581 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (ops R32:$dst, R8 :$src),
1582                    "movz{bl|x} {$src, $dst|$dst, $src}",
1583                    [(set R32:$dst, (zext R8:$src))]>, TB;
1584 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (ops R32:$dst, i8mem :$src),
1585                    "movz{bl|x} {$src, $dst|$dst, $src}", []>, TB;
1586 def MOVZX32rr16: I<0xB7, MRMSrcReg, (ops R32:$dst, R16:$src),
1587                    "movz{wl|x} {$src, $dst|$dst, $src}",
1588                    [(set R32:$dst, (zext R16:$src))]>, TB;
1589 def MOVZX32rm16: I<0xB7, MRMSrcMem, (ops R32:$dst, i16mem:$src),
1590                    "movz{wl|x} {$src, $dst|$dst, $src}", []>, TB;
1591
1592 //===----------------------------------------------------------------------===//
1593 // XMM Floating point support (requires SSE2)
1594 //===----------------------------------------------------------------------===//
1595
1596 def MOVSSrr : I<0x10, MRMSrcReg, (ops V4F4:$dst, V4F4:$src),
1597                 "movss {$src, $dst|$dst, $src}", []>, XS;
1598 def MOVSSrm : I<0x10, MRMSrcMem, (ops V4F4:$dst, f32mem:$src),
1599                 "movss {$src, $dst|$dst, $src}", []>, XS;
1600 def MOVSSmr : I<0x11, MRMDestMem, (ops f32mem:$dst, V4F4:$src),
1601                 "movss {$src, $dst|$dst, $src}", []>, XS;
1602 def MOVSDrr : I<0x10, MRMSrcReg, (ops V2F8:$dst, V2F8:$src),
1603                 "movsd {$src, $dst|$dst, $src}", []>, XD;
1604 def MOVSDrm : I<0x10, MRMSrcMem, (ops V2F8:$dst, f64mem:$src),
1605                 "movsd {$src, $dst|$dst, $src}", []>, XD;
1606 def MOVSDmr : I<0x11, MRMDestMem, (ops f64mem:$dst, V2F8:$src),
1607                 "movsd {$src, $dst|$dst, $src}", []>, XD;
1608
1609 def CVTTSD2SIrr: I<0x2C, MRMSrcReg, (ops R32:$dst, V2F8:$src),
1610                 "cvttsd2si {$src, $dst|$dst, $src}",
1611                 [(set R32:$dst, (fp_to_sint V2F8:$src))]>, XD;
1612 def CVTTSD2SIrm: I<0x2C, MRMSrcMem, (ops R32:$dst, f64mem:$src),
1613                 "cvttsd2si {$src, $dst|$dst, $src}", []>, XD;
1614 def CVTTSS2SIrr: I<0x2C, MRMSrcReg, (ops R32:$dst, V4F4:$src),
1615                 "cvttss2si {$src, $dst|$dst, $src}",
1616                 [(set R32:$dst, (fp_to_sint V4F4:$src))]>, XS;
1617 def CVTTSS2SIrm: I<0x2C, MRMSrcMem, (ops R32:$dst, f32mem:$src),
1618                 "cvttss2si {$src, $dst|$dst, $src}", []>, XS;
1619 def CVTSD2SSrr: I<0x5A, MRMSrcReg, (ops V4F4:$dst, V2F8:$src),
1620                 "cvtsd2ss {$src, $dst|$dst, $src}",
1621                 [(set V4F4:$dst, (fround V2F8:$src))]>, XS;
1622 def CVTSD2SSrm: I<0x5A, MRMSrcMem, (ops V4F4:$dst, f64mem:$src), 
1623                 "cvtsd2ss {$src, $dst|$dst, $src}", []>, XS;
1624 def CVTSS2SDrr: I<0x5A, MRMSrcReg, (ops V2F8:$dst, V4F4:$src),
1625                 "cvtss2sd {$src, $dst|$dst, $src}",
1626                 [(set V2F8:$dst, (fextend V4F4:$src))]>, XD;
1627 def CVTSS2SDrm: I<0x5A, MRMSrcMem, (ops V2F8:$dst, f32mem:$src),
1628                 "cvtss2sd {$src, $dst|$dst, $src}", []>, XD;
1629 def CVTSI2SSrr: I<0x2A, MRMSrcReg, (ops V4F4:$dst, R32:$src),
1630                 "cvtsi2ss {$src, $dst|$dst, $src}",
1631                 [(set V4F4:$dst, (sint_to_fp R32:$src))]>, XS;
1632 def CVTSI2SSrm: I<0x2A, MRMSrcMem, (ops V4F4:$dst, i32mem:$src),
1633                 "cvtsi2ss {$src, $dst|$dst, $src}", []>, XS;
1634 def CVTSI2SDrr: I<0x2A, MRMSrcReg, (ops V2F8:$dst, R32:$src),
1635                 "cvtsi2sd {$src, $dst|$dst, $src}",
1636                 [(set V2F8:$dst, (sint_to_fp R32:$src))]>, XD;
1637 def CVTSI2SDrm: I<0x2A, MRMSrcMem, (ops V2F8:$dst, i32mem:$src),
1638                 "cvtsi2sd {$src, $dst|$dst, $src}", []>, XD;
1639
1640 def SQRTSSrm : I<0x51, MRMSrcMem, (ops V4F4:$dst, f32mem:$src),
1641                 "sqrtss {$src, $dst|$dst, $src}", []>, XS;
1642 def SQRTSSrr : I<0x51, MRMSrcReg, (ops V4F4:$dst, V4F4:$src),
1643                 "sqrtss {$src, $dst|$dst, $src}",
1644                 [(set V4F4:$dst, (fsqrt V4F4:$src))]>, XS;
1645 def SQRTSDrm : I<0x51, MRMSrcMem, (ops V2F8:$dst, f64mem:$src),
1646                 "sqrtsd {$src, $dst|$dst, $src}", []>, XD;
1647 def SQRTSDrr : I<0x51, MRMSrcReg, (ops V2F8:$dst, V2F8:$src),
1648                 "sqrtsd {$src, $dst|$dst, $src}",
1649                 [(set V2F8:$dst, (fsqrt V2F8:$src))]>, XD;
1650
1651 def UCOMISDrr: I<0x2E, MRMSrcReg, (ops V2F8:$dst, V2F8:$src),
1652                 "ucomisd {$src, $dst|$dst, $src}", []>, TB, OpSize;
1653 def UCOMISDrm: I<0x2E, MRMSrcMem, (ops V2F8:$dst, f64mem:$src),
1654                 "ucomisd {$src, $dst|$dst, $src}", []>, TB, OpSize;
1655 def UCOMISSrr: I<0x2E, MRMSrcReg, (ops V4F4:$dst, V4F4:$src),
1656                 "ucomiss {$src, $dst|$dst, $src}", []>, TB;
1657 def UCOMISSrm: I<0x2E, MRMSrcMem, (ops V4F4:$dst, f32mem:$src),
1658                 "ucomiss {$src, $dst|$dst, $src}", []>, TB;
1659
1660 // Pseudo-instructions that map fld0 to xorps/xorpd for sse.
1661 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
1662 def FLD0SS : I<0x57, MRMSrcReg, (ops V4F4:$dst),
1663                 "xorps $dst, $dst", []>, TB;
1664 def FLD0SD : I<0x57, MRMSrcReg, (ops V2F8:$dst),
1665                 "xorpd $dst, $dst", []>, TB, OpSize;
1666
1667 let isTwoAddress = 1 in {
1668 let isCommutable = 1 in {
1669 def ADDSSrr : I<0x58, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
1670                 "addss {$src2, $dst|$dst, $src2}",
1671                 [(set V4F4:$dst, (fadd V4F4:$src1, V4F4:$src2))]>, XS;
1672 def ADDSDrr : I<0x58, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
1673                 "addsd {$src2, $dst|$dst, $src2}",
1674                 [(set V2F8:$dst, (fadd V2F8:$src1, V2F8:$src2))]>, XD;
1675 def ANDPSrr : I<0x54, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
1676                 "andps {$src2, $dst|$dst, $src2}", []>, TB;
1677 def ANDPDrr : I<0x54, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
1678                 "andpd {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
1679 def MULSSrr : I<0x59, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
1680                 "mulss {$src2, $dst|$dst, $src2}",
1681                 [(set V4F4:$dst, (fmul V4F4:$src1, V4F4:$src2))]>, XS;
1682 def MULSDrr : I<0x59, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
1683                 "mulsd {$src2, $dst|$dst, $src2}",
1684                 [(set V2F8:$dst, (fmul V2F8:$src1, V2F8:$src2))]>, XD;
1685 def ORPSrr : I<0x56, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
1686                 "orps {$src2, $dst|$dst, $src2}", []>, TB;
1687 def ORPDrr : I<0x56, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
1688                 "orpd {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
1689 def XORPSrr : I<0x57, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
1690                 "xorps {$src2, $dst|$dst, $src2}", []>, TB;
1691 def XORPDrr : I<0x57, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
1692                 "xorpd {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
1693 }
1694 def ANDNPSrr : I<0x55, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
1695                 "andnps {$src2, $dst|$dst, $src2}", []>, TB;
1696 def ANDNPDrr : I<0x55, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
1697                 "andnpd {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
1698 def ADDSSrm : I<0x58, MRMSrcMem, (ops V4F4:$dst, V4F4:$src1, f32mem:$src2),
1699                 "addss {$src2, $dst|$dst, $src2}", []>, XS;
1700 def ADDSDrm : I<0x58, MRMSrcMem, (ops V2F8:$dst, V2F8:$src1, f64mem:$src2),
1701                 "addsd {$src2, $dst|$dst, $src2}", []>, XD;
1702 def MULSSrm : I<0x59, MRMSrcMem, (ops V4F4:$dst, V4F4:$src1, f32mem:$src2),
1703                 "mulss {$src2, $dst|$dst, $src2}", []>, XS;
1704 def MULSDrm : I<0x59, MRMSrcMem, (ops V2F8:$dst, V2F8:$src1, f64mem:$src2),
1705                 "mulsd {$src2, $dst|$dst, $src2}", []>, XD;
1706
1707 def DIVSSrm : I<0x5E, MRMSrcMem, (ops V4F4:$dst, V4F4:$src1, f32mem:$src2),
1708                 "divss {$src2, $dst|$dst, $src2}", []>, XS;
1709 def DIVSSrr : I<0x5E, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
1710                 "divss {$src2, $dst|$dst, $src2}",
1711                 [(set V4F4:$dst, (fdiv V4F4:$src1, V4F4:$src2))]>, XS;
1712 def DIVSDrm : I<0x5E, MRMSrcMem, (ops V2F8:$dst, V2F8:$src1, f64mem:$src2),
1713                 "divsd {$src2, $dst|$dst, $src2}", []>, XD;
1714 def DIVSDrr : I<0x5E, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
1715                 "divsd {$src2, $dst|$dst, $src2}",
1716                 [(set V2F8:$dst, (fdiv V2F8:$src1, V2F8:$src2))]>, XD;
1717
1718 def SUBSSrm : I<0x5C, MRMSrcMem, (ops V4F4:$dst, V4F4:$src1, f32mem:$src2),
1719                 "subss {$src2, $dst|$dst, $src2}", []>, XS;
1720 def SUBSSrr : I<0x5C, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
1721                 "subss {$src2, $dst|$dst, $src2}",
1722                 [(set V4F4:$dst, (fsub V4F4:$src1, V4F4:$src2))]>, XS;
1723 def SUBSDrm : I<0x5C, MRMSrcMem, (ops V2F8:$dst, V2F8:$src1, f64mem:$src2),
1724                 "subsd {$src2, $dst|$dst, $src2}", []>, XD;
1725 def SUBSDrr : I<0x5C, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
1726                 "subsd {$src2, $dst|$dst, $src2}",
1727                 [(set V2F8:$dst, (fsub V2F8:$src1, V2F8:$src2))]>, XD;
1728
1729 def CMPSSrr : I<0xC2, MRMSrcReg, 
1730                 (ops V4F4:$dst, V4F4:$src1, V4F4:$src, SSECC:$cc),
1731                 "cmp${cc}ss {$src, $dst|$dst, $src}", []>, XS;
1732 def CMPSSrm : I<0xC2, MRMSrcMem, 
1733                 (ops V4F4:$dst, V4F4:$src1, f32mem:$src, SSECC:$cc),
1734                 "cmp${cc}ss {$src, $dst|$dst, $src}", []>, XS;
1735 def CMPSDrr : I<0xC2, MRMSrcReg, 
1736                 (ops V2F8:$dst, V2F8:$src1, V2F8:$src, SSECC:$cc),
1737                 "cmp${cc}sd {$src, $dst|$dst, $src}", []>, XD;
1738 def CMPSDrm : I<0xC2, MRMSrcMem, 
1739                 (ops V2F8:$dst, V2F8:$src1, f64mem:$src, SSECC:$cc),
1740                 "cmp${cc}sd {$src, $dst|$dst, $src}", []>, XD;
1741 }
1742
1743 //===----------------------------------------------------------------------===//
1744 // Miscellaneous Instructions
1745 //===----------------------------------------------------------------------===//
1746
1747 def RDTSC : I<0x31, RawFrm, (ops), "rdtsc", []>, TB, Imp<[],[EAX,EDX]>;
1748
1749
1750 //===----------------------------------------------------------------------===//
1751 // Stack-based Floating point support
1752 //===----------------------------------------------------------------------===//
1753
1754 // FIXME: These need to indicate mod/ref sets for FP regs... & FP 'TOP'
1755
1756 // Floating point instruction template
1757 class FPI<bits<8> o, Format F, FPFormat fp, dag ops, string asm>
1758   : X86Inst<o, F, NoImm, ops, asm> {
1759   let FPForm = fp; let FPFormBits = FPForm.Value;
1760 }
1761
1762 // Pseudo instructions for floating point.  We use these pseudo instructions
1763 // because they can be expanded by the fp spackifier into one of many different
1764 // forms of instructions for doing these operations.  Until the stackifier runs,
1765 // we prefer to be abstract.
1766 def FpMOV : FPI<0, Pseudo, SpecialFP,
1767                 (ops RFP:$dst, RFP:$src), "">;   // f1 = fmov f2
1768 def FpADD : FPI<0, Pseudo, TwoArgFP ,
1769                 (ops RFP:$dst, RFP:$src1, RFP:$src2), "">; // f1 = fadd f2, f3
1770 def FpSUB : FPI<0, Pseudo, TwoArgFP ,
1771                 (ops RFP:$dst, RFP:$src1, RFP:$src2), "">;    // f1 = fsub f2, f3
1772 def FpMUL : FPI<0, Pseudo, TwoArgFP ,
1773                 (ops RFP:$dst, RFP:$src1, RFP:$src2), "">;    // f1 = fmul f2, f3
1774 def FpDIV : FPI<0, Pseudo, TwoArgFP ,
1775                 (ops RFP:$dst, RFP:$src1, RFP:$src2), "">;    // f1 = fdiv f2, f3
1776
1777 def FpGETRESULT : FPI<0, Pseudo, SpecialFP, (ops RFP:$dst), "">,
1778                   Imp<[ST0], []>;  // FPR = ST(0)
1779
1780 def FpSETRESULT : FPI<0, Pseudo, SpecialFP, (ops RFP:$src), "">,
1781                   Imp<[], [ST0]>;  // ST(0) = FPR
1782
1783 // FADD reg, mem: Before stackification, these are represented by:
1784 // R1 = FADD* R2, [mem]
1785 def FADD32m  : FPI<0xD8, MRM0m, OneArgFPRW,    // ST(0) = ST(0) + [mem32real]
1786                    (ops f32mem:$src, variable_ops),
1787                    "fadd{s} $src">;
1788 def FADD64m  : FPI<0xDC, MRM0m, OneArgFPRW,    // ST(0) = ST(0) + [mem64real]
1789                    (ops f64mem:$src, variable_ops),
1790                    "fadd{l} $src">;
1791 //def FIADD16m : FPI<0xDE, MRM0m, OneArgFPRW>;    // ST(0) = ST(0) + [mem16int]
1792 //def FIADD32m : FPI<0xDA, MRM0m, OneArgFPRW>;    // ST(0) = ST(0) + [mem32int]
1793
1794 // FMUL reg, mem: Before stackification, these are represented by:
1795 // R1 = FMUL* R2, [mem]
1796 def FMUL32m  : FPI<0xD8, MRM1m, OneArgFPRW,    // ST(0) = ST(0) * [mem32real]
1797                    (ops f32mem:$src, variable_ops),
1798                    "fmul{s} $src">;
1799 def FMUL64m  : FPI<0xDC, MRM1m, OneArgFPRW,    // ST(0) = ST(0) * [mem64real]
1800                    (ops f64mem:$src, variable_ops),
1801                    "fmul{l} $src">;
1802 // ST(0) = ST(0) * [mem16int]
1803 //def FIMUL16m : FPI16m<"fimul", 0xDE, MRM1m, OneArgFPRW>;
1804 // ST(0) = ST(0) * [mem32int]
1805 //def FIMUL32m : FPI32m<"fimul", 0xDA, MRM1m, OneArgFPRW>;
1806
1807 // FSUB reg, mem: Before stackification, these are represented by:
1808 // R1 = FSUB* R2, [mem]
1809 def FSUB32m  : FPI<0xD8, MRM4m, OneArgFPRW,    // ST(0) = ST(0) - [mem32real]
1810                    (ops f32mem:$src, variable_ops),
1811                    "fsub{s} $src">;
1812 def FSUB64m  : FPI<0xDC, MRM4m, OneArgFPRW,    // ST(0) = ST(0) - [mem64real]
1813                    (ops f64mem:$src, variable_ops),
1814                    "fsub{l} $src">;
1815 // ST(0) = ST(0) - [mem16int]
1816 //def FISUB16m : FPI16m<"fisub", 0xDE, MRM4m, OneArgFPRW>;
1817 // ST(0) = ST(0) - [mem32int]
1818 //def FISUB32m : FPI32m<"fisub", 0xDA, MRM4m, OneArgFPRW>;
1819
1820 // FSUBR reg, mem: Before stackification, these are represented by:
1821 // R1 = FSUBR* R2, [mem]
1822
1823 // Note that the order of operands does not reflect the operation being
1824 // performed.
1825 def FSUBR32m  : FPI<0xD8, MRM5m, OneArgFPRW,  // ST(0) = [mem32real] - ST(0)
1826                     (ops f32mem:$src, variable_ops),
1827                     "fsubr{s} $src">;
1828 def FSUBR64m  : FPI<0xDC, MRM5m, OneArgFPRW,  // ST(0) = [mem64real] - ST(0)
1829                     (ops f64mem:$src, variable_ops),
1830                     "fsubr{l} $src">;
1831 // ST(0) = [mem16int] - ST(0)
1832 //def FISUBR16m : FPI16m<"fisubr", 0xDE, MRM5m, OneArgFPRW>;
1833 // ST(0) = [mem32int] - ST(0)
1834 //def FISUBR32m : FPI32m<"fisubr", 0xDA, MRM5m, OneArgFPRW>;
1835
1836 // FDIV reg, mem: Before stackification, these are represented by:
1837 // R1 = FDIV* R2, [mem]
1838 def FDIV32m  : FPI<0xD8, MRM6m, OneArgFPRW,    // ST(0) = ST(0) / [mem32real]
1839                    (ops f32mem:$src, variable_ops),
1840                    "fdiv{s} $src">;
1841 def FDIV64m  : FPI<0xDC, MRM6m, OneArgFPRW,    // ST(0) = ST(0) / [mem64real]
1842                    (ops f64mem:$src, variable_ops),
1843                    "fdiv{l} $src">;
1844 // ST(0) = ST(0) / [mem16int]
1845 //def FIDIV16m : FPI16m<"fidiv", 0xDE, MRM6m, OneArgFPRW>;
1846 // ST(0) = ST(0) / [mem32int]
1847 //def FIDIV32m : FPI32m<"fidiv", 0xDA, MRM6m, OneArgFPRW>;
1848
1849 // FDIVR reg, mem: Before stackification, these are represented by:
1850 // R1 = FDIVR* R2, [mem]
1851 // Note that the order of operands does not reflect the operation being
1852 // performed.
1853 def FDIVR32m  : FPI<0xD8, MRM7m, OneArgFPRW,  // ST(0) = [mem32real] / ST(0)
1854                     (ops f32mem:$src, variable_ops),
1855                     "fdivr{s} $src">;
1856 def FDIVR64m  : FPI<0xDC, MRM7m, OneArgFPRW,  // ST(0) = [mem64real] / ST(0)
1857                     (ops f64mem:$src, variable_ops),
1858                     "fdivr{l} $src">;
1859 // ST(0) = [mem16int] / ST(0)
1860 //def FIDIVR16m : FPI16m<"fidivr", 0xDE, MRM7m, OneArgFPRW>;
1861 // ST(0) = [mem32int] / ST(0)
1862 //def FIDIVR32m : FPI32m<"fidivr", 0xDA, MRM7m, OneArgFPRW>;
1863
1864
1865 // Floating point cmovs...
1866 let isTwoAddress = 1, Uses = [ST0], Defs = [ST0] in {
1867   def FCMOVB  : FPI<0xC0, AddRegFrm, CondMovFP,
1868                     (ops RST:$op, variable_ops),
1869                     "fcmovb {$op, %ST(0)|%ST(0), $op}">, DA;
1870   def FCMOVBE : FPI<0xD0, AddRegFrm, CondMovFP,
1871                     (ops RST:$op, variable_ops),
1872                     "fcmovbe {$op, %ST(0)|%ST(0), $op}">, DA;
1873   def FCMOVE  : FPI<0xC8, AddRegFrm, CondMovFP,
1874                     (ops RST:$op, variable_ops),
1875                     "fcmove {$op, %ST(0)|%ST(0), $op}">, DA;
1876   def FCMOVP  : FPI<0xD8, AddRegFrm, CondMovFP,
1877                     (ops RST:$op, variable_ops),
1878                     "fcmovu  {$op, %ST(0)|%ST(0), $op}">, DA;
1879   def FCMOVAE : FPI<0xC0, AddRegFrm, CondMovFP,
1880                     (ops RST:$op, variable_ops),
1881                     "fcmovae {$op, %ST(0)|%ST(0), $op}">, DB;
1882   def FCMOVA  : FPI<0xD0, AddRegFrm, CondMovFP,
1883                     (ops RST:$op, variable_ops),
1884                     "fcmova {$op, %ST(0)|%ST(0), $op}">, DB;
1885   def FCMOVNE : FPI<0xC8, AddRegFrm, CondMovFP,
1886                     (ops RST:$op, variable_ops),
1887                     "fcmovne {$op, %ST(0)|%ST(0), $op}">, DB;
1888   def FCMOVNP : FPI<0xD8, AddRegFrm, CondMovFP,
1889                     (ops RST:$op, variable_ops),
1890                     "fcmovnu {$op, %ST(0)|%ST(0), $op}">, DB;
1891 }
1892
1893 // Floating point loads & stores...
1894 // FIXME: these are all marked variable_ops because they have an implicit 
1895 // destination.  Instructions like FILD* that are generated by the instruction
1896 //  selector (not the fp stackifier) need more accurate operand accounting.
1897 def FLDrr   : FPI<0xC0, AddRegFrm, NotFP,
1898                   (ops RST:$src, variable_ops),
1899                   "fld $src">, D9;
1900 def FLD32m  : FPI<0xD9, MRM0m, ZeroArgFP,
1901                   (ops f32mem:$src, variable_ops),
1902                   "fld{s} $src">;
1903 def FLD64m  : FPI<0xDD, MRM0m, ZeroArgFP,
1904                   (ops f64mem:$src, variable_ops),
1905                   "fld{l} $src">;
1906 def FLD80m  : FPI<0xDB, MRM5m, ZeroArgFP,
1907                   (ops f80mem:$src, variable_ops),
1908                   "fld{t} $src">;
1909 def FILD16m : FPI<0xDF, MRM0m, ZeroArgFP,
1910                   (ops i16mem:$src, variable_ops),
1911                   "fild{s} $src">;
1912 def FILD32m : FPI<0xDB, MRM0m, ZeroArgFP,
1913                   (ops i32mem:$src, variable_ops),
1914                   "fild{l} $src">;
1915 def FILD64m : FPI<0xDF, MRM5m, ZeroArgFP,
1916                   (ops i64mem:$src, variable_ops),
1917                   "fild{ll} $src">;
1918
1919 def FSTrr    : FPI<0xD0, AddRegFrm, NotFP,
1920                    (ops RST:$op, variable_ops),
1921                    "fst $op">, DD;
1922 def FSTPrr   : FPI<0xD8, AddRegFrm, NotFP,
1923                    (ops RST:$op, variable_ops),
1924                    "fstp $op">, DD;
1925 def FST32m   : FPI<0xD9, MRM2m, OneArgFP,
1926                    (ops f32mem:$op, variable_ops),
1927                    "fst{s} $op">;
1928 def FST64m   : FPI<0xDD, MRM2m, OneArgFP,
1929                    (ops f64mem:$op, variable_ops),
1930                    "fst{l} $op">;
1931 def FSTP32m  : FPI<0xD9, MRM3m, OneArgFP,
1932                    (ops f32mem:$op, variable_ops),
1933                    "fstp{s} $op">;
1934 def FSTP64m  : FPI<0xDD, MRM3m, OneArgFP,
1935                    (ops f64mem:$op, variable_ops),
1936                    "fstp{l} $op">;
1937 def FSTP80m  : FPI<0xDB, MRM7m, OneArgFP,
1938                    (ops f80mem:$op, variable_ops),
1939                    "fstp{t} $op">;
1940
1941 def FIST16m  : FPI<0xDF, MRM2m , OneArgFP,
1942                    (ops i16mem:$op, variable_ops),
1943                    "fist{s} $op">;
1944 def FIST32m  : FPI<0xDB, MRM2m , OneArgFP,
1945                    (ops i32mem:$op, variable_ops),
1946                    "fist{l} $op">;
1947 def FISTP16m : FPI<0xDF, MRM3m , NotFP   ,
1948                    (ops i16mem:$op, variable_ops),
1949                    "fistp{s} $op">;
1950 def FISTP32m : FPI<0xDB, MRM3m , NotFP   ,
1951                    (ops i32mem:$op, variable_ops),
1952                    "fistp{l} $op">;
1953 def FISTP64m : FPI<0xDF, MRM7m , OneArgFP,
1954                    (ops i64mem:$op, variable_ops),
1955                    "fistp{ll} $op">;
1956
1957 def FXCH     : FPI<0xC8, AddRegFrm, NotFP,
1958                    (ops RST:$op), "fxch $op">, D9;      // fxch ST(i), ST(0)
1959
1960 // Floating point constant loads...
1961 def FLD0 : FPI<0xEE, RawFrm, ZeroArgFP, (ops variable_ops), "fldz">, D9;
1962 def FLD1 : FPI<0xE8, RawFrm, ZeroArgFP, (ops variable_ops), "fld1">, D9;
1963
1964
1965 // Unary operations...
1966 def FCHS  : FPI<0xE0, RawFrm, OneArgFPRW,   // f1 = fchs f2
1967                 (ops variable_ops),
1968                 "fchs">, D9;
1969 def FABS  : FPI<0xE1, RawFrm, OneArgFPRW,   // f1 = fabs f2
1970                 (ops variable_ops),
1971                 "fabs">, D9;
1972 def FSQRT : FPI<0xFA, RawFrm, OneArgFPRW,   // fsqrt ST(0)
1973                 (ops variable_ops),
1974                 "fsqrt">, D9;
1975 def FSIN  : FPI<0xFE, RawFrm, OneArgFPRW,   // fsin  ST(0)
1976                 (ops variable_ops),
1977                 "fsin">, D9;
1978 def FCOS  : FPI<0xFF, RawFrm, OneArgFPRW,   // fcos  ST(0)
1979                 (ops variable_ops),
1980                 "fcos">, D9;
1981 def FTST  : FPI<0xE4, RawFrm, OneArgFP  ,   // ftst ST(0)
1982                 (ops variable_ops),
1983                 "ftst">, D9;
1984
1985 // Binary arithmetic operations...
1986 class FPST0rInst<bits<8> o, dag ops, string asm>
1987   : I<o, AddRegFrm, ops, asm, []>, D8 {
1988   list<Register> Uses = [ST0];
1989   list<Register> Defs = [ST0];
1990 }
1991 class FPrST0Inst<bits<8> o, dag ops, string asm>
1992   : I<o, AddRegFrm, ops, asm, []>, DC {
1993   list<Register> Uses = [ST0];
1994 }
1995 class FPrST0PInst<bits<8> o, dag ops, string asm>
1996   : I<o, AddRegFrm, ops, asm, []>, DE {
1997   list<Register> Uses = [ST0];
1998 }
1999
2000 def FADDST0r   : FPST0rInst <0xC0, (ops RST:$op),
2001                              "fadd $op">;
2002 def FADDrST0   : FPrST0Inst <0xC0, (ops RST:$op),
2003                              "fadd {%ST(0), $op|$op, %ST(0)}">;
2004 def FADDPrST0  : FPrST0PInst<0xC0, (ops RST:$op),
2005                              "faddp $op">;
2006
2007 // NOTE: GAS and apparently all other AT&T style assemblers have a broken notion
2008 // of some of the 'reverse' forms of the fsub and fdiv instructions.  As such,
2009 // we have to put some 'r's in and take them out of weird places.
2010 def FSUBRST0r  : FPST0rInst <0xE8, (ops RST:$op),
2011                              "fsubr $op">;
2012 def FSUBrST0   : FPrST0Inst <0xE8, (ops RST:$op),
2013                              "fsub{r} {%ST(0), $op|$op, %ST(0)}">;
2014 def FSUBPrST0  : FPrST0PInst<0xE8, (ops RST:$op),
2015                              "fsub{r}p $op">;
2016
2017 def FSUBST0r   : FPST0rInst <0xE0, (ops RST:$op),
2018                              "fsub $op">;
2019 def FSUBRrST0  : FPrST0Inst <0xE0, (ops RST:$op),
2020                              "fsub{|r} {%ST(0), $op|$op, %ST(0)}">;
2021 def FSUBRPrST0 : FPrST0PInst<0xE0, (ops RST:$op),
2022                              "fsub{|r}p $op">;
2023
2024 def FMULST0r   : FPST0rInst <0xC8, (ops RST:$op),
2025                              "fmul $op">;
2026 def FMULrST0   : FPrST0Inst <0xC8, (ops RST:$op),
2027                              "fmul {%ST(0), $op|$op, %ST(0)}">;
2028 def FMULPrST0  : FPrST0PInst<0xC8, (ops RST:$op),
2029                              "fmulp $op">;
2030
2031 def FDIVRST0r  : FPST0rInst <0xF8, (ops RST:$op),
2032                              "fdivr $op">;
2033 def FDIVrST0   : FPrST0Inst <0xF8, (ops RST:$op),
2034                              "fdiv{r} {%ST(0), $op|$op, %ST(0)}">;
2035 def FDIVPrST0  : FPrST0PInst<0xF8, (ops RST:$op),
2036                              "fdiv{r}p $op">;
2037
2038 def FDIVST0r   : FPST0rInst <0xF0, (ops RST:$op),  // ST(0) = ST(0) / ST(i)
2039                              "fdiv $op">;
2040 def FDIVRrST0  : FPrST0Inst <0xF0, (ops RST:$op),  // ST(i) = ST(0) / ST(i)
2041                              "fdiv{|r} {%ST(0), $op|$op, %ST(0)}">;
2042 def FDIVRPrST0 : FPrST0PInst<0xF0, (ops RST:$op),  // ST(i) = ST(0) / ST(i), pop
2043                              "fdiv{|r}p $op">;
2044
2045 // Floating point compares
2046 def FUCOMr    : FPI<0xE0, AddRegFrm, CompareFP,   // FPSW = cmp ST(0) with ST(i)
2047                     (ops RST:$reg, variable_ops),
2048                     "fucom $reg">, DD, Imp<[ST0],[]>;
2049 def FUCOMPr   : I<0xE8, AddRegFrm,           // FPSW = cmp ST(0) with ST(i), pop
2050                   (ops RST:$reg, variable_ops),
2051                   "fucomp $reg", []>, DD, Imp<[ST0],[]>;
2052 def FUCOMPPr  : I<0xE9, RawFrm,                // cmp ST(0) with ST(1), pop, pop
2053                   (ops variable_ops),
2054                   "fucompp", []>, DA, Imp<[ST0],[]>;
2055
2056 def FUCOMIr  : FPI<0xE8, AddRegFrm, CompareFP,  // CC = cmp ST(0) with ST(i)
2057                    (ops RST:$reg, variable_ops),
2058                    "fucomi {$reg, %ST(0)|%ST(0), $reg}">, DB, Imp<[ST0],[]>;
2059 def FUCOMIPr : I<0xE8, AddRegFrm,              // CC = cmp ST(0) with ST(i), pop
2060                  (ops RST:$reg, variable_ops),
2061                  "fucomip {$reg, %ST(0)|%ST(0), $reg}", []>, DF, Imp<[ST0],[]>;
2062
2063
2064 // Floating point flag ops
2065 def FNSTSW8r  : I<0xE0, RawFrm,                  // AX = fp flags
2066                   (ops), "fnstsw", []>, DF, Imp<[],[AX]>;
2067
2068 def FNSTCW16m : I<0xD9, MRM7m,                   // [mem16] = X87 control world
2069                   (ops i16mem:$dst), "fnstcw $dst", []>;
2070 def FLDCW16m  : I<0xD9, MRM5m,                   // X87 control world = [mem16]
2071                   (ops i16mem:$dst), "fldcw $dst", []>;