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