1 //====- X86InstrX86-64.td - Describe the X86 Instruction Set ----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the Evan Cheng and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the X86-64 instruction set, defining the instructions,
11 // and properties of the instructions which are needed for code generation,
12 // machine code emission, and analysis.
14 //===----------------------------------------------------------------------===//
16 //===----------------------------------------------------------------------===//
17 // Operand Definitions...
20 // 64-bits but only 32 bits are significant.
21 def i64i32imm : Operand<i64>;
22 // 64-bits but only 8 bits are significant.
23 def i64i8imm : Operand<i64>;
25 def lea64mem : Operand<i64> {
26 let PrintMethod = "printi64mem";
27 let MIOperandInfo = (ops GR64, i8imm, GR64, i32imm);
30 def lea64_32mem : Operand<i32> {
31 let PrintMethod = "printlea64_32mem";
32 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
35 //===----------------------------------------------------------------------===//
36 // Complex Pattern Definitions...
38 def lea64addr : ComplexPattern<i64, 4, "SelectLEAAddr",
39 [add, mul, shl, or, frameindex, X86Wrapper],
42 //===----------------------------------------------------------------------===//
43 // Instruction templates...
46 class RI<bits<8> o, Format F, dag outs, dag ins, string asm, list<dag> pattern>
47 : I<o, F, outs, ins, asm, pattern>, REX_W;
48 class RIi8 <bits<8> o, Format F, dag outs, dag ins, string asm,
50 : Ii8<o, F, outs, ins, asm, pattern>, REX_W;
51 class RIi32 <bits<8> o, Format F, dag outs, dag ins, string asm,
53 : Ii32<o, F, outs, ins, asm, pattern>, REX_W;
55 class RIi64<bits<8> o, Format f, dag outs, dag ins, string asm,
57 : X86Inst<o, f, Imm64, outs, ins, asm>, REX_W {
58 let Pattern = pattern;
62 class RSSI<bits<8> o, Format F, dag outs, dag ins, string asm,
64 : SSI<o, F, outs, ins, asm, pattern>, REX_W;
65 class RSDI<bits<8> o, Format F, dag outs, dag ins, string asm,
67 : SDI<o, F, outs, ins, asm, pattern>, REX_W;
68 class RPDI<bits<8> o, Format F, dag outs, dag ins, string asm,
70 : PDI<o, F, outs, ins, asm, pattern>, REX_W;
72 //===----------------------------------------------------------------------===//
73 // Pattern fragments...
76 def i64immSExt32 : PatLeaf<(i64 imm), [{
77 // i64immSExt32 predicate - True if the 64-bit immediate fits in a 32-bit
78 // sign extended field.
79 return (int64_t)N->getValue() == (int32_t)N->getValue();
82 def i64immZExt32 : PatLeaf<(i64 imm), [{
83 // i64immZExt32 predicate - True if the 64-bit immediate fits in a 32-bit
84 // unsignedsign extended field.
85 return (uint64_t)N->getValue() == (uint32_t)N->getValue();
88 def i64immSExt8 : PatLeaf<(i64 imm), [{
89 // i64immSExt8 predicate - True if the 64-bit immediate fits in a 8-bit
90 // sign extended field.
91 return (int64_t)N->getValue() == (int8_t)N->getValue();
94 def sextloadi64i1 : PatFrag<(ops node:$ptr), (i64 (sextloadi1 node:$ptr))>;
95 def sextloadi64i8 : PatFrag<(ops node:$ptr), (i64 (sextloadi8 node:$ptr))>;
96 def sextloadi64i16 : PatFrag<(ops node:$ptr), (i64 (sextloadi16 node:$ptr))>;
97 def sextloadi64i32 : PatFrag<(ops node:$ptr), (i64 (sextloadi32 node:$ptr))>;
99 def zextloadi64i1 : PatFrag<(ops node:$ptr), (i64 (zextloadi1 node:$ptr))>;
100 def zextloadi64i8 : PatFrag<(ops node:$ptr), (i64 (zextloadi8 node:$ptr))>;
101 def zextloadi64i16 : PatFrag<(ops node:$ptr), (i64 (zextloadi16 node:$ptr))>;
102 def zextloadi64i32 : PatFrag<(ops node:$ptr), (i64 (zextloadi32 node:$ptr))>;
104 def extloadi64i1 : PatFrag<(ops node:$ptr), (i64 (extloadi1 node:$ptr))>;
105 def extloadi64i8 : PatFrag<(ops node:$ptr), (i64 (extloadi8 node:$ptr))>;
106 def extloadi64i16 : PatFrag<(ops node:$ptr), (i64 (extloadi16 node:$ptr))>;
107 def extloadi64i32 : PatFrag<(ops node:$ptr), (i64 (extloadi32 node:$ptr))>;
109 //===----------------------------------------------------------------------===//
110 // Instruction list...
113 def IMPLICIT_DEF_GR64 : I<0, Pseudo, (outs GR64:$dst), (ins),
114 "#IMPLICIT_DEF $dst",
115 [(set GR64:$dst, (undef))]>;
117 //===----------------------------------------------------------------------===//
118 // Call Instructions...
120 let isCall = 1, noResults = 1 in
121 // All calls clobber the non-callee saved registers...
122 let Defs = [RAX, RCX, RDX, RSI, RDI, R8, R9, R10, R11,
123 FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
124 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
125 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
126 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15] in {
127 def CALL64pcrel32 : I<0xE8, RawFrm, (outs), (ins i64imm:$dst, variable_ops),
128 "call ${dst:call}", []>;
129 def CALL64r : I<0xFF, MRM2r, (outs), (ins GR64:$dst, variable_ops),
130 "call {*}$dst", [(X86call GR64:$dst)]>;
131 def CALL64m : I<0xFF, MRM2m, (outs), (ins i64mem:$dst, variable_ops),
136 let isBranch = 1, isTerminator = 1, noResults = 1, isBarrier = 1 in {
137 def JMP64r : I<0xFF, MRM4r, (outs), (ins GR64:$dst), "jmp{q} {*}$dst",
138 [(brind GR64:$dst)]>;
139 def JMP64m : I<0xFF, MRM4m, (outs), (ins i64mem:$dst), "jmp{q} {*}$dst",
140 [(brind (loadi64 addr:$dst))]>;
143 //===----------------------------------------------------------------------===//
144 // Miscellaneous Instructions...
146 def LEAVE64 : I<0xC9, RawFrm,
147 (outs), (ins), "leave", []>, Imp<[RBP,RSP],[RBP,RSP]>;
148 def POP64r : I<0x58, AddRegFrm,
149 (outs GR64:$reg), (ins), "pop{q} $reg", []>, Imp<[RSP],[RSP]>;
150 def PUSH64r : I<0x50, AddRegFrm,
151 (outs), (ins GR64:$reg), "push{q} $reg", []>, Imp<[RSP],[RSP]>;
153 def LEA64_32r : I<0x8D, MRMSrcMem,
154 (outs GR32:$dst), (ins lea64_32mem:$src),
155 "lea{l} {$src|$dst}, {$dst|$src}",
156 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In64BitMode]>;
158 def LEA64r : RI<0x8D, MRMSrcMem, (outs GR64:$dst), (ins lea64mem:$src),
159 "lea{q} {$src|$dst}, {$dst|$src}",
160 [(set GR64:$dst, lea64addr:$src)]>;
162 let isTwoAddress = 1 in
163 def BSWAP64r : RI<0xC8, AddRegFrm, (outs GR64:$dst), (ins GR64:$src),
165 [(set GR64:$dst, (bswap GR64:$src))]>, TB;
167 def XCHG64rr : RI<0x87, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2),
168 "xchg{q} {$src2|$src1}, {$src1|$src2}", []>;
169 def XCHG64mr : RI<0x87, MRMDestMem, (outs), (ins i64mem:$src1, GR64:$src2),
170 "xchg{q} {$src2|$src1}, {$src1|$src2}", []>;
171 def XCHG64rm : RI<0x87, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2),
172 "xchg{q} {$src2|$src1}, {$src1|$src2}", []>;
175 def REP_MOVSQ : RI<0xA5, RawFrm, (outs), (ins), "{rep;movsq|rep movsq}",
176 [(X86rep_movs i64)]>,
177 Imp<[RCX,RDI,RSI], [RCX,RDI,RSI]>, REP;
178 def REP_STOSQ : RI<0xAB, RawFrm, (outs), (ins), "{rep;stosq|rep stosq}",
179 [(X86rep_stos i64)]>,
180 Imp<[RAX,RCX,RDI], [RCX,RDI]>, REP;
182 //===----------------------------------------------------------------------===//
183 // Move Instructions...
186 def MOV64rr : RI<0x89, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
187 "mov{q} {$src, $dst|$dst, $src}", []>;
189 def MOV64ri : RIi64<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64imm:$src),
190 "movabs{q} {$src, $dst|$dst, $src}",
191 [(set GR64:$dst, imm:$src)]>;
192 def MOV64ri32 : RIi32<0xC7, MRM0r, (outs GR64:$dst), (ins i64i32imm:$src),
193 "mov{q} {$src, $dst|$dst, $src}",
194 [(set GR64:$dst, i64immSExt32:$src)]>;
196 def MOV64rm : RI<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
197 "mov{q} {$src, $dst|$dst, $src}",
198 [(set GR64:$dst, (load addr:$src))]>;
200 def MOV64mr : RI<0x89, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
201 "mov{q} {$src, $dst|$dst, $src}",
202 [(store GR64:$src, addr:$dst)]>;
203 def MOV64mi32 : RIi32<0xC7, MRM0m, (outs), (ins i64mem:$dst, i64i32imm:$src),
204 "mov{q} {$src, $dst|$dst, $src}",
205 [(store i64immSExt32:$src, addr:$dst)]>;
207 // Sign/Zero extenders
209 def MOVSX64rr8 : RI<0xBE, MRMSrcReg, (outs GR64:$dst), (ins GR8 :$src),
210 "movs{bq|x} {$src, $dst|$dst, $src}",
211 [(set GR64:$dst, (sext GR8:$src))]>, TB;
212 def MOVSX64rm8 : RI<0xBE, MRMSrcMem, (outs GR64:$dst), (ins i8mem :$src),
213 "movs{bq|x} {$src, $dst|$dst, $src}",
214 [(set GR64:$dst, (sextloadi64i8 addr:$src))]>, TB;
215 def MOVSX64rr16: RI<0xBF, MRMSrcReg, (outs GR64:$dst), (ins GR16:$src),
216 "movs{wq|x} {$src, $dst|$dst, $src}",
217 [(set GR64:$dst, (sext GR16:$src))]>, TB;
218 def MOVSX64rm16: RI<0xBF, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
219 "movs{wq|x} {$src, $dst|$dst, $src}",
220 [(set GR64:$dst, (sextloadi64i16 addr:$src))]>, TB;
221 def MOVSX64rr32: RI<0x63, MRMSrcReg, (outs GR64:$dst), (ins GR32:$src),
222 "movs{lq|xd} {$src, $dst|$dst, $src}",
223 [(set GR64:$dst, (sext GR32:$src))]>;
224 def MOVSX64rm32: RI<0x63, MRMSrcMem, (outs GR64:$dst), (ins i32mem:$src),
225 "movs{lq|xd} {$src, $dst|$dst, $src}",
226 [(set GR64:$dst, (sextloadi64i32 addr:$src))]>;
228 def MOVZX64rr8 : RI<0xB6, MRMSrcReg, (outs GR64:$dst), (ins GR8 :$src),
229 "movz{bq|x} {$src, $dst|$dst, $src}",
230 [(set GR64:$dst, (zext GR8:$src))]>, TB;
231 def MOVZX64rm8 : RI<0xB6, MRMSrcMem, (outs GR64:$dst), (ins i8mem :$src),
232 "movz{bq|x} {$src, $dst|$dst, $src}",
233 [(set GR64:$dst, (zextloadi64i8 addr:$src))]>, TB;
234 def MOVZX64rr16: RI<0xB7, MRMSrcReg, (outs GR64:$dst), (ins GR16:$src),
235 "movz{wq|x} {$src, $dst|$dst, $src}",
236 [(set GR64:$dst, (zext GR16:$src))]>, TB;
237 def MOVZX64rm16: RI<0xB7, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
238 "movz{wq|x} {$src, $dst|$dst, $src}",
239 [(set GR64:$dst, (zextloadi64i16 addr:$src))]>, TB;
241 def CDQE : RI<0x98, RawFrm, (outs), (ins),
242 "{cltq|cdqe}", []>, Imp<[EAX],[RAX]>; // RAX = signext(EAX)
244 def CQO : RI<0x99, RawFrm, (outs), (ins),
245 "{cqto|cqo}", []>, Imp<[RAX],[RAX,RDX]>; // RDX:RAX = signext(RAX)
247 //===----------------------------------------------------------------------===//
248 // Arithmetic Instructions...
251 let isTwoAddress = 1 in {
252 let isConvertibleToThreeAddress = 1 in {
253 let isCommutable = 1 in
254 def ADD64rr : RI<0x01, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
255 "add{q} {$src2, $dst|$dst, $src2}",
256 [(set GR64:$dst, (add GR64:$src1, GR64:$src2))]>;
258 def ADD64ri32 : RIi32<0x81, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
259 "add{q} {$src2, $dst|$dst, $src2}",
260 [(set GR64:$dst, (add GR64:$src1, i64immSExt32:$src2))]>;
261 def ADD64ri8 : RIi8<0x83, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
262 "add{q} {$src2, $dst|$dst, $src2}",
263 [(set GR64:$dst, (add GR64:$src1, i64immSExt8:$src2))]>;
264 } // isConvertibleToThreeAddress
266 def ADD64rm : RI<0x03, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
267 "add{q} {$src2, $dst|$dst, $src2}",
268 [(set GR64:$dst, (add GR64:$src1, (load addr:$src2)))]>;
271 def ADD64mr : RI<0x01, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
272 "add{q} {$src2, $dst|$dst, $src2}",
273 [(store (add (load addr:$dst), GR64:$src2), addr:$dst)]>;
274 def ADD64mi32 : RIi32<0x81, MRM0m, (outs), (ins i64mem:$dst, i64i32imm :$src2),
275 "add{q} {$src2, $dst|$dst, $src2}",
276 [(store (add (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>;
277 def ADD64mi8 : RIi8<0x83, MRM0m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
278 "add{q} {$src2, $dst|$dst, $src2}",
279 [(store (add (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
281 let isTwoAddress = 1 in {
282 let isCommutable = 1 in
283 def ADC64rr : RI<0x11, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
284 "adc{q} {$src2, $dst|$dst, $src2}",
285 [(set GR64:$dst, (adde GR64:$src1, GR64:$src2))]>;
287 def ADC64rm : RI<0x13, MRMSrcMem , (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
288 "adc{q} {$src2, $dst|$dst, $src2}",
289 [(set GR64:$dst, (adde GR64:$src1, (load addr:$src2)))]>;
291 def ADC64ri32 : RIi32<0x81, MRM2r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
292 "adc{q} {$src2, $dst|$dst, $src2}",
293 [(set GR64:$dst, (adde GR64:$src1, i64immSExt32:$src2))]>;
294 def ADC64ri8 : RIi8<0x83, MRM2r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
295 "adc{q} {$src2, $dst|$dst, $src2}",
296 [(set GR64:$dst, (adde GR64:$src1, i64immSExt8:$src2))]>;
299 def ADC64mr : RI<0x11, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
300 "adc{q} {$src2, $dst|$dst, $src2}",
301 [(store (adde (load addr:$dst), GR64:$src2), addr:$dst)]>;
302 def ADC64mi32 : RIi32<0x81, MRM2m, (outs), (ins i64mem:$dst, i64i32imm:$src2),
303 "adc{q} {$src2, $dst|$dst, $src2}",
304 [(store (adde (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
305 def ADC64mi8 : RIi8<0x83, MRM2m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
306 "adc{q} {$src2, $dst|$dst, $src2}",
307 [(store (adde (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
309 let isTwoAddress = 1 in {
310 def SUB64rr : RI<0x29, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
311 "sub{q} {$src2, $dst|$dst, $src2}",
312 [(set GR64:$dst, (sub GR64:$src1, GR64:$src2))]>;
314 def SUB64rm : RI<0x2B, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
315 "sub{q} {$src2, $dst|$dst, $src2}",
316 [(set GR64:$dst, (sub GR64:$src1, (load addr:$src2)))]>;
318 def SUB64ri32 : RIi32<0x81, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
319 "sub{q} {$src2, $dst|$dst, $src2}",
320 [(set GR64:$dst, (sub GR64:$src1, i64immSExt32:$src2))]>;
321 def SUB64ri8 : RIi8<0x83, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
322 "sub{q} {$src2, $dst|$dst, $src2}",
323 [(set GR64:$dst, (sub GR64:$src1, i64immSExt8:$src2))]>;
326 def SUB64mr : RI<0x29, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
327 "sub{q} {$src2, $dst|$dst, $src2}",
328 [(store (sub (load addr:$dst), GR64:$src2), addr:$dst)]>;
329 def SUB64mi32 : RIi32<0x81, MRM5m, (outs), (ins i64mem:$dst, i64i32imm:$src2),
330 "sub{q} {$src2, $dst|$dst, $src2}",
331 [(store (sub (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>;
332 def SUB64mi8 : RIi8<0x83, MRM5m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
333 "sub{q} {$src2, $dst|$dst, $src2}",
334 [(store (sub (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
336 let isTwoAddress = 1 in {
337 def SBB64rr : RI<0x19, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
338 "sbb{q} {$src2, $dst|$dst, $src2}",
339 [(set GR64:$dst, (sube GR64:$src1, GR64:$src2))]>;
341 def SBB64rm : RI<0x1B, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
342 "sbb{q} {$src2, $dst|$dst, $src2}",
343 [(set GR64:$dst, (sube GR64:$src1, (load addr:$src2)))]>;
345 def SBB64ri32 : RIi32<0x81, MRM3r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
346 "sbb{q} {$src2, $dst|$dst, $src2}",
347 [(set GR64:$dst, (sube GR64:$src1, i64immSExt32:$src2))]>;
348 def SBB64ri8 : RIi8<0x83, MRM3r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
349 "sbb{q} {$src2, $dst|$dst, $src2}",
350 [(set GR64:$dst, (sube GR64:$src1, i64immSExt8:$src2))]>;
353 def SBB64mr : RI<0x19, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
354 "sbb{q} {$src2, $dst|$dst, $src2}",
355 [(store (sube (load addr:$dst), GR64:$src2), addr:$dst)]>;
356 def SBB64mi32 : RIi32<0x81, MRM3m, (outs), (ins i64mem:$dst, i64i32imm:$src2),
357 "sbb{q} {$src2, $dst|$dst, $src2}",
358 [(store (sube (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>;
359 def SBB64mi8 : RIi8<0x83, MRM3m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
360 "sbb{q} {$src2, $dst|$dst, $src2}",
361 [(store (sube (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
363 // Unsigned multiplication
364 def MUL64r : RI<0xF7, MRM4r, (outs), (ins GR64:$src),
366 Imp<[RAX],[RAX,RDX]>; // RAX,RDX = RAX*GR64
367 def MUL64m : RI<0xF7, MRM4m, (outs), (ins i64mem:$src),
369 Imp<[RAX],[RAX,RDX]>; // RAX,RDX = RAX*[mem64]
371 // Signed multiplication
372 def IMUL64r : RI<0xF7, MRM5r, (outs), (ins GR64:$src),
374 Imp<[RAX],[RAX,RDX]>; // RAX,RDX = RAX*GR64
375 def IMUL64m : RI<0xF7, MRM5m, (outs), (ins i64mem:$src),
377 Imp<[RAX],[RAX,RDX]>; // RAX,RDX = RAX*[mem64]
379 let isTwoAddress = 1 in {
380 let isCommutable = 1 in
381 def IMUL64rr : RI<0xAF, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
382 "imul{q} {$src2, $dst|$dst, $src2}",
383 [(set GR64:$dst, (mul GR64:$src1, GR64:$src2))]>, TB;
385 def IMUL64rm : RI<0xAF, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
386 "imul{q} {$src2, $dst|$dst, $src2}",
387 [(set GR64:$dst, (mul GR64:$src1, (load addr:$src2)))]>, TB;
390 // Suprisingly enough, these are not two address instructions!
391 def IMUL64rri32 : RIi32<0x69, MRMSrcReg, // GR64 = GR64*I32
392 (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
393 "imul{q} {$src2, $src1, $dst|$dst, $src1, $src2}",
394 [(set GR64:$dst, (mul GR64:$src1, i64immSExt32:$src2))]>;
395 def IMUL64rri8 : RIi8<0x6B, MRMSrcReg, // GR64 = GR64*I8
396 (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
397 "imul{q} {$src2, $src1, $dst|$dst, $src1, $src2}",
398 [(set GR64:$dst, (mul GR64:$src1, i64immSExt8:$src2))]>;
399 def IMUL64rmi32 : RIi32<0x69, MRMSrcMem, // GR64 = [mem64]*I32
400 (outs GR64:$dst), (ins i64mem:$src1, i64i32imm:$src2),
401 "imul{q} {$src2, $src1, $dst|$dst, $src1, $src2}",
402 [(set GR64:$dst, (mul (load addr:$src1), i64immSExt32:$src2))]>;
403 def IMUL64rmi8 : RIi8<0x6B, MRMSrcMem, // GR64 = [mem64]*I8
404 (outs GR64:$dst), (ins i64mem:$src1, i64i8imm: $src2),
405 "imul{q} {$src2, $src1, $dst|$dst, $src1, $src2}",
406 [(set GR64:$dst, (mul (load addr:$src1), i64immSExt8:$src2))]>;
408 // Unsigned division / remainder
409 def DIV64r : RI<0xF7, MRM6r, (outs), (ins GR64:$src), // RDX:RAX/r64 = RAX,RDX
410 "div{q} $src", []>, Imp<[RAX,RDX],[RAX,RDX]>;
411 def DIV64m : RI<0xF7, MRM6m, (outs), (ins i64mem:$src), // RDX:RAX/[mem64] = RAX,RDX
412 "div{q} $src", []>, Imp<[RAX,RDX],[RAX,RDX]>;
414 // Signed division / remainder
415 def IDIV64r: RI<0xF7, MRM7r, (outs), (ins GR64:$src), // RDX:RAX/r64 = RAX,RDX
416 "idiv{q} $src", []>, Imp<[RAX,RDX],[RAX,RDX]>;
417 def IDIV64m: RI<0xF7, MRM7m, (outs), (ins i64mem:$src), // RDX:RAX/[mem64] = RAX,RDX
418 "idiv{q} $src", []>, Imp<[RAX,RDX],[RAX,RDX]>;
420 // Unary instructions
421 let CodeSize = 2 in {
422 let isTwoAddress = 1 in
423 def NEG64r : RI<0xF7, MRM3r, (outs GR64:$dst), (ins GR64:$src), "neg{q} $dst",
424 [(set GR64:$dst, (ineg GR64:$src))]>;
425 def NEG64m : RI<0xF7, MRM3m, (outs), (ins i64mem:$dst), "neg{q} $dst",
426 [(store (ineg (loadi64 addr:$dst)), addr:$dst)]>;
428 let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in
429 def INC64r : RI<0xFF, MRM0r, (outs GR64:$dst), (ins GR64:$src), "inc{q} $dst",
430 [(set GR64:$dst, (add GR64:$src, 1))]>;
431 def INC64m : RI<0xFF, MRM0m, (outs), (ins i64mem:$dst), "inc{q} $dst",
432 [(store (add (loadi64 addr:$dst), 1), addr:$dst)]>;
434 let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in
435 def DEC64r : RI<0xFF, MRM1r, (outs GR64:$dst), (ins GR64:$src), "dec{q} $dst",
436 [(set GR64:$dst, (add GR64:$src, -1))]>;
437 def DEC64m : RI<0xFF, MRM1m, (outs), (ins i64mem:$dst), "dec{q} $dst",
438 [(store (add (loadi64 addr:$dst), -1), addr:$dst)]>;
440 // In 64-bit mode, single byte INC and DEC cannot be encoded.
441 let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in {
442 // Can transform into LEA.
443 def INC64_16r : I<0xFF, MRM0r, (outs GR16:$dst), (ins GR16:$src), "inc{w} $dst",
444 [(set GR16:$dst, (add GR16:$src, 1))]>,
445 OpSize, Requires<[In64BitMode]>;
446 def INC64_32r : I<0xFF, MRM0r, (outs GR32:$dst), (ins GR32:$src), "inc{l} $dst",
447 [(set GR32:$dst, (add GR32:$src, 1))]>,
448 Requires<[In64BitMode]>;
449 def DEC64_16r : I<0xFF, MRM1r, (outs GR16:$dst), (ins GR16:$src), "dec{w} $dst",
450 [(set GR16:$dst, (add GR16:$src, -1))]>,
451 OpSize, Requires<[In64BitMode]>;
452 def DEC64_32r : I<0xFF, MRM1r, (outs GR32:$dst), (ins GR32:$src), "dec{l} $dst",
453 [(set GR32:$dst, (add GR32:$src, -1))]>,
454 Requires<[In64BitMode]>;
455 } // isConvertibleToThreeAddress
459 // Shift instructions
460 let isTwoAddress = 1 in {
461 def SHL64rCL : RI<0xD3, MRM4r, (outs GR64:$dst), (ins GR64:$src),
462 "shl{q} {%cl, $dst|$dst, %CL}",
463 [(set GR64:$dst, (shl GR64:$src, CL))]>,
465 def SHL64ri : RIi8<0xC1, MRM4r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
466 "shl{q} {$src2, $dst|$dst, $src2}",
467 [(set GR64:$dst, (shl GR64:$src1, (i8 imm:$src2)))]>;
468 def SHL64r1 : RI<0xD1, MRM4r, (outs GR64:$dst), (ins GR64:$src1),
472 def SHL64mCL : RI<0xD3, MRM4m, (outs), (ins i64mem:$dst),
473 "shl{q} {%cl, $dst|$dst, %CL}",
474 [(store (shl (loadi64 addr:$dst), CL), addr:$dst)]>,
476 def SHL64mi : RIi8<0xC1, MRM4m, (outs), (ins i64mem:$dst, i8imm:$src),
477 "shl{q} {$src, $dst|$dst, $src}",
478 [(store (shl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
479 def SHL64m1 : RI<0xD1, MRM4m, (outs), (ins i64mem:$dst),
481 [(store (shl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
483 let isTwoAddress = 1 in {
484 def SHR64rCL : RI<0xD3, MRM5r, (outs GR64:$dst), (ins GR64:$src),
485 "shr{q} {%cl, $dst|$dst, %CL}",
486 [(set GR64:$dst, (srl GR64:$src, CL))]>,
488 def SHR64ri : RIi8<0xC1, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
489 "shr{q} {$src2, $dst|$dst, $src2}",
490 [(set GR64:$dst, (srl GR64:$src1, (i8 imm:$src2)))]>;
491 def SHR64r1 : RI<0xD1, MRM5r, (outs GR64:$dst), (ins GR64:$src1),
493 [(set GR64:$dst, (srl GR64:$src1, (i8 1)))]>;
496 def SHR64mCL : RI<0xD3, MRM5m, (outs), (ins i64mem:$dst),
497 "shr{q} {%cl, $dst|$dst, %CL}",
498 [(store (srl (loadi64 addr:$dst), CL), addr:$dst)]>,
500 def SHR64mi : RIi8<0xC1, MRM5m, (outs), (ins i64mem:$dst, i8imm:$src),
501 "shr{q} {$src, $dst|$dst, $src}",
502 [(store (srl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
503 def SHR64m1 : RI<0xD1, MRM5m, (outs), (ins i64mem:$dst),
505 [(store (srl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
507 let isTwoAddress = 1 in {
508 def SAR64rCL : RI<0xD3, MRM7r, (outs GR64:$dst), (ins GR64:$src),
509 "sar{q} {%cl, $dst|$dst, %CL}",
510 [(set GR64:$dst, (sra GR64:$src, CL))]>, Imp<[CL],[]>;
511 def SAR64ri : RIi8<0xC1, MRM7r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
512 "sar{q} {$src2, $dst|$dst, $src2}",
513 [(set GR64:$dst, (sra GR64:$src1, (i8 imm:$src2)))]>;
514 def SAR64r1 : RI<0xD1, MRM7r, (outs GR64:$dst), (ins GR64:$src1),
516 [(set GR64:$dst, (sra GR64:$src1, (i8 1)))]>;
519 def SAR64mCL : RI<0xD3, MRM7m, (outs), (ins i64mem:$dst),
520 "sar{q} {%cl, $dst|$dst, %CL}",
521 [(store (sra (loadi64 addr:$dst), CL), addr:$dst)]>,
523 def SAR64mi : RIi8<0xC1, MRM7m, (outs), (ins i64mem:$dst, i8imm:$src),
524 "sar{q} {$src, $dst|$dst, $src}",
525 [(store (sra (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
526 def SAR64m1 : RI<0xD1, MRM7m, (outs), (ins i64mem:$dst),
528 [(store (sra (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
530 // Rotate instructions
531 let isTwoAddress = 1 in {
532 def ROL64rCL : RI<0xD3, MRM0r, (outs GR64:$dst), (ins GR64:$src),
533 "rol{q} {%cl, $dst|$dst, %CL}",
534 [(set GR64:$dst, (rotl GR64:$src, CL))]>, Imp<[CL],[]>;
535 def ROL64ri : RIi8<0xC1, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
536 "rol{q} {$src2, $dst|$dst, $src2}",
537 [(set GR64:$dst, (rotl GR64:$src1, (i8 imm:$src2)))]>;
538 def ROL64r1 : RI<0xD1, MRM0r, (outs GR64:$dst), (ins GR64:$src1),
540 [(set GR64:$dst, (rotl GR64:$src1, (i8 1)))]>;
543 def ROL64mCL : I<0xD3, MRM0m, (outs), (ins i64mem:$dst),
544 "rol{q} {%cl, $dst|$dst, %CL}",
545 [(store (rotl (loadi64 addr:$dst), CL), addr:$dst)]>,
547 def ROL64mi : RIi8<0xC1, MRM0m, (outs), (ins i64mem:$dst, i8imm:$src),
548 "rol{q} {$src, $dst|$dst, $src}",
549 [(store (rotl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
550 def ROL64m1 : RI<0xD1, MRM0m, (outs), (ins i64mem:$dst),
552 [(store (rotl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
554 let isTwoAddress = 1 in {
555 def ROR64rCL : RI<0xD3, MRM1r, (outs GR64:$dst), (ins GR64:$src),
556 "ror{q} {%cl, $dst|$dst, %CL}",
557 [(set GR64:$dst, (rotr GR64:$src, CL))]>, Imp<[CL],[]>;
558 def ROR64ri : RIi8<0xC1, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
559 "ror{q} {$src2, $dst|$dst, $src2}",
560 [(set GR64:$dst, (rotr GR64:$src1, (i8 imm:$src2)))]>;
561 def ROR64r1 : RI<0xD1, MRM1r, (outs GR64:$dst), (ins GR64:$src1),
563 [(set GR64:$dst, (rotr GR64:$src1, (i8 1)))]>;
566 def ROR64mCL : RI<0xD3, MRM1m, (outs), (ins i64mem:$dst),
567 "ror{q} {%cl, $dst|$dst, %CL}",
568 [(store (rotr (loadi64 addr:$dst), CL), addr:$dst)]>,
570 def ROR64mi : RIi8<0xC1, MRM1m, (outs), (ins i64mem:$dst, i8imm:$src),
571 "ror{q} {$src, $dst|$dst, $src}",
572 [(store (rotr (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
573 def ROR64m1 : RI<0xD1, MRM1m, (outs), (ins i64mem:$dst),
575 [(store (rotr (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
577 // Double shift instructions (generalizations of rotate)
578 let isTwoAddress = 1 in {
579 def SHLD64rrCL : RI<0xA5, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
580 "shld{q} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
582 def SHRD64rrCL : RI<0xAD, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
583 "shrd{q} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
586 let isCommutable = 1 in { // FIXME: Update X86InstrInfo::commuteInstruction
587 def SHLD64rri8 : RIi8<0xA4, MRMDestReg,
588 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2, i8imm:$src3),
589 "shld{q} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
591 def SHRD64rri8 : RIi8<0xAC, MRMDestReg,
592 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2, i8imm:$src3),
593 "shrd{q} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
598 // Temporary hack: there is no patterns associated with these instructions
599 // so we have to tell tblgen that these do not produce results.
600 let noResults = 1 in {
601 def SHLD64mrCL : RI<0xA5, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
602 "shld{q} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
604 def SHRD64mrCL : RI<0xAD, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
605 "shrd{q} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
607 def SHLD64mri8 : RIi8<0xA4, MRMDestMem,
608 (outs), (ins i64mem:$dst, GR64:$src2, i8imm:$src3),
609 "shld{q} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
611 def SHRD64mri8 : RIi8<0xAC, MRMDestMem,
612 (outs), (ins i64mem:$dst, GR64:$src2, i8imm:$src3),
613 "shrd{q} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
617 //===----------------------------------------------------------------------===//
618 // Logical Instructions...
621 let isTwoAddress = 1 in
622 def NOT64r : RI<0xF7, MRM2r, (outs GR64:$dst), (ins GR64:$src), "not{q} $dst",
623 [(set GR64:$dst, (not GR64:$src))]>;
624 def NOT64m : RI<0xF7, MRM2m, (outs), (ins i64mem:$dst), "not{q} $dst",
625 [(store (not (loadi64 addr:$dst)), addr:$dst)]>;
627 let isTwoAddress = 1 in {
628 let isCommutable = 1 in
629 def AND64rr : RI<0x21, MRMDestReg,
630 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
631 "and{q} {$src2, $dst|$dst, $src2}",
632 [(set GR64:$dst, (and GR64:$src1, GR64:$src2))]>;
633 def AND64rm : RI<0x23, MRMSrcMem,
634 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
635 "and{q} {$src2, $dst|$dst, $src2}",
636 [(set GR64:$dst, (and GR64:$src1, (load addr:$src2)))]>;
637 def AND64ri32 : RIi32<0x81, MRM4r,
638 (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
639 "and{q} {$src2, $dst|$dst, $src2}",
640 [(set GR64:$dst, (and GR64:$src1, i64immSExt32:$src2))]>;
641 def AND64ri8 : RIi8<0x83, MRM4r,
642 (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
643 "and{q} {$src2, $dst|$dst, $src2}",
644 [(set GR64:$dst, (and GR64:$src1, i64immSExt8:$src2))]>;
647 def AND64mr : RI<0x21, MRMDestMem,
648 (outs), (ins i64mem:$dst, GR64:$src),
649 "and{q} {$src, $dst|$dst, $src}",
650 [(store (and (load addr:$dst), GR64:$src), addr:$dst)]>;
651 def AND64mi32 : RIi32<0x81, MRM4m,
652 (outs), (ins i64mem:$dst, i64i32imm:$src),
653 "and{q} {$src, $dst|$dst, $src}",
654 [(store (and (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>;
655 def AND64mi8 : RIi8<0x83, MRM4m,
656 (outs), (ins i64mem:$dst, i64i8imm :$src),
657 "and{q} {$src, $dst|$dst, $src}",
658 [(store (and (load addr:$dst), i64immSExt8:$src), addr:$dst)]>;
660 let isTwoAddress = 1 in {
661 let isCommutable = 1 in
662 def OR64rr : RI<0x09, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
663 "or{q} {$src2, $dst|$dst, $src2}",
664 [(set GR64:$dst, (or GR64:$src1, GR64:$src2))]>;
665 def OR64rm : RI<0x0B, MRMSrcMem , (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
666 "or{q} {$src2, $dst|$dst, $src2}",
667 [(set GR64:$dst, (or GR64:$src1, (load addr:$src2)))]>;
668 def OR64ri32 : RIi32<0x81, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
669 "or{q} {$src2, $dst|$dst, $src2}",
670 [(set GR64:$dst, (or GR64:$src1, i64immSExt32:$src2))]>;
671 def OR64ri8 : RIi8<0x83, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
672 "or{q} {$src2, $dst|$dst, $src2}",
673 [(set GR64:$dst, (or GR64:$src1, i64immSExt8:$src2))]>;
676 def OR64mr : RI<0x09, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
677 "or{q} {$src, $dst|$dst, $src}",
678 [(store (or (load addr:$dst), GR64:$src), addr:$dst)]>;
679 def OR64mi32 : RIi32<0x81, MRM1m, (outs), (ins i64mem:$dst, i64i32imm:$src),
680 "or{q} {$src, $dst|$dst, $src}",
681 [(store (or (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>;
682 def OR64mi8 : RIi8<0x83, MRM1m, (outs), (ins i64mem:$dst, i64i8imm:$src),
683 "or{q} {$src, $dst|$dst, $src}",
684 [(store (or (load addr:$dst), i64immSExt8:$src), addr:$dst)]>;
686 let isTwoAddress = 1 in {
687 let isCommutable = 1 in
688 def XOR64rr : RI<0x31, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
689 "xor{q} {$src2, $dst|$dst, $src2}",
690 [(set GR64:$dst, (xor GR64:$src1, GR64:$src2))]>;
691 def XOR64rm : RI<0x33, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
692 "xor{q} {$src2, $dst|$dst, $src2}",
693 [(set GR64:$dst, (xor GR64:$src1, (load addr:$src2)))]>;
694 def XOR64ri32 : RIi32<0x81, MRM6r,
695 (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
696 "xor{q} {$src2, $dst|$dst, $src2}",
697 [(set GR64:$dst, (xor GR64:$src1, i64immSExt32:$src2))]>;
698 def XOR64ri8 : RIi8<0x83, MRM6r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
699 "xor{q} {$src2, $dst|$dst, $src2}",
700 [(set GR64:$dst, (xor GR64:$src1, i64immSExt8:$src2))]>;
703 def XOR64mr : RI<0x31, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
704 "xor{q} {$src, $dst|$dst, $src}",
705 [(store (xor (load addr:$dst), GR64:$src), addr:$dst)]>;
706 def XOR64mi32 : RIi32<0x81, MRM6m, (outs), (ins i64mem:$dst, i64i32imm:$src),
707 "xor{q} {$src, $dst|$dst, $src}",
708 [(store (xor (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>;
709 def XOR64mi8 : RIi8<0x83, MRM6m, (outs), (ins i64mem:$dst, i64i8imm :$src),
710 "xor{q} {$src, $dst|$dst, $src}",
711 [(store (xor (load addr:$dst), i64immSExt8:$src), addr:$dst)]>;
713 //===----------------------------------------------------------------------===//
714 // Comparison Instructions...
717 // Integer comparison
718 let isCommutable = 1 in
719 def TEST64rr : RI<0x85, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2),
720 "test{q} {$src2, $src1|$src1, $src2}",
721 [(X86cmp (and GR64:$src1, GR64:$src2), 0)]>;
722 def TEST64rm : RI<0x85, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2),
723 "test{q} {$src2, $src1|$src1, $src2}",
724 [(X86cmp (and GR64:$src1, (loadi64 addr:$src2)), 0)]>;
725 def TEST64ri32 : RIi32<0xF7, MRM0r, (outs), (ins GR64:$src1, i64i32imm:$src2),
726 "test{q} {$src2, $src1|$src1, $src2}",
727 [(X86cmp (and GR64:$src1, i64immSExt32:$src2), 0)]>;
728 def TEST64mi32 : RIi32<0xF7, MRM0m, (outs), (ins i64mem:$src1, i64i32imm:$src2),
729 "test{q} {$src2, $src1|$src1, $src2}",
730 [(X86cmp (and (loadi64 addr:$src1), i64immSExt32:$src2), 0)]>;
732 def CMP64rr : RI<0x39, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2),
733 "cmp{q} {$src2, $src1|$src1, $src2}",
734 [(X86cmp GR64:$src1, GR64:$src2)]>;
735 def CMP64mr : RI<0x39, MRMDestMem, (outs), (ins i64mem:$src1, GR64:$src2),
736 "cmp{q} {$src2, $src1|$src1, $src2}",
737 [(X86cmp (loadi64 addr:$src1), GR64:$src2)]>;
738 def CMP64rm : RI<0x3B, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2),
739 "cmp{q} {$src2, $src1|$src1, $src2}",
740 [(X86cmp GR64:$src1, (loadi64 addr:$src2))]>;
741 def CMP64ri32 : RIi32<0x81, MRM7r, (outs), (ins GR64:$src1, i64i32imm:$src2),
742 "cmp{q} {$src2, $src1|$src1, $src2}",
743 [(X86cmp GR64:$src1, i64immSExt32:$src2)]>;
744 def CMP64mi32 : RIi32<0x81, MRM7m, (outs), (ins i64mem:$src1, i64i32imm:$src2),
745 "cmp{q} {$src2, $src1|$src1, $src2}",
746 [(X86cmp (loadi64 addr:$src1), i64immSExt32:$src2)]>;
747 def CMP64mi8 : RIi8<0x83, MRM7m, (outs), (ins i64mem:$src1, i64i8imm:$src2),
748 "cmp{q} {$src2, $src1|$src1, $src2}",
749 [(X86cmp (loadi64 addr:$src1), i64immSExt8:$src2)]>;
750 def CMP64ri8 : RIi8<0x83, MRM7r, (outs), (ins GR64:$src1, i64i8imm:$src2),
751 "cmp{q} {$src2, $src1|$src1, $src2}",
752 [(X86cmp GR64:$src1, i64immSExt8:$src2)]>;
755 let isTwoAddress = 1 in {
756 def CMOVB64rr : RI<0x42, MRMSrcReg, // if <u, GR64 = GR64
757 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
758 "cmovb {$src2, $dst|$dst, $src2}",
759 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
761 def CMOVB64rm : RI<0x42, MRMSrcMem, // if <u, GR64 = [mem64]
762 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
763 "cmovb {$src2, $dst|$dst, $src2}",
764 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
766 def CMOVAE64rr: RI<0x43, MRMSrcReg, // if >=u, GR64 = GR64
767 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
768 "cmovae {$src2, $dst|$dst, $src2}",
769 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
771 def CMOVAE64rm: RI<0x43, MRMSrcMem, // if >=u, GR64 = [mem64]
772 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
773 "cmovae {$src2, $dst|$dst, $src2}",
774 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
776 def CMOVE64rr : RI<0x44, MRMSrcReg, // if ==, GR64 = GR64
777 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
778 "cmove {$src2, $dst|$dst, $src2}",
779 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
781 def CMOVE64rm : RI<0x44, MRMSrcMem, // if ==, GR64 = [mem64]
782 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
783 "cmove {$src2, $dst|$dst, $src2}",
784 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
786 def CMOVNE64rr: RI<0x45, MRMSrcReg, // if !=, GR64 = GR64
787 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
788 "cmovne {$src2, $dst|$dst, $src2}",
789 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
791 def CMOVNE64rm: RI<0x45, MRMSrcMem, // if !=, GR64 = [mem64]
792 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
793 "cmovne {$src2, $dst|$dst, $src2}",
794 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
796 def CMOVBE64rr: RI<0x46, MRMSrcReg, // if <=u, GR64 = GR64
797 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
798 "cmovbe {$src2, $dst|$dst, $src2}",
799 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
801 def CMOVBE64rm: RI<0x46, MRMSrcMem, // if <=u, GR64 = [mem64]
802 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
803 "cmovbe {$src2, $dst|$dst, $src2}",
804 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
806 def CMOVA64rr : RI<0x47, MRMSrcReg, // if >u, GR64 = GR64
807 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
808 "cmova {$src2, $dst|$dst, $src2}",
809 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
811 def CMOVA64rm : RI<0x47, MRMSrcMem, // if >u, GR64 = [mem64]
812 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
813 "cmova {$src2, $dst|$dst, $src2}",
814 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
816 def CMOVL64rr : RI<0x4C, MRMSrcReg, // if <s, GR64 = GR64
817 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
818 "cmovl {$src2, $dst|$dst, $src2}",
819 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
821 def CMOVL64rm : RI<0x4C, MRMSrcMem, // if <s, GR64 = [mem64]
822 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
823 "cmovl {$src2, $dst|$dst, $src2}",
824 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
826 def CMOVGE64rr: RI<0x4D, MRMSrcReg, // if >=s, GR64 = GR64
827 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
828 "cmovge {$src2, $dst|$dst, $src2}",
829 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
831 def CMOVGE64rm: RI<0x4D, MRMSrcMem, // if >=s, GR64 = [mem64]
832 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
833 "cmovge {$src2, $dst|$dst, $src2}",
834 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
836 def CMOVLE64rr: RI<0x4E, MRMSrcReg, // if <=s, GR64 = GR64
837 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
838 "cmovle {$src2, $dst|$dst, $src2}",
839 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
841 def CMOVLE64rm: RI<0x4E, MRMSrcMem, // if <=s, GR64 = [mem64]
842 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
843 "cmovle {$src2, $dst|$dst, $src2}",
844 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
846 def CMOVG64rr : RI<0x4F, MRMSrcReg, // if >s, GR64 = GR64
847 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
848 "cmovg {$src2, $dst|$dst, $src2}",
849 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
851 def CMOVG64rm : RI<0x4F, MRMSrcMem, // if >s, GR64 = [mem64]
852 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
853 "cmovg {$src2, $dst|$dst, $src2}",
854 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
856 def CMOVS64rr : RI<0x48, MRMSrcReg, // if signed, GR64 = GR64
857 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
858 "cmovs {$src2, $dst|$dst, $src2}",
859 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
861 def CMOVS64rm : RI<0x48, MRMSrcMem, // if signed, GR64 = [mem64]
862 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
863 "cmovs {$src2, $dst|$dst, $src2}",
864 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
866 def CMOVNS64rr: RI<0x49, MRMSrcReg, // if !signed, GR64 = GR64
867 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
868 "cmovns {$src2, $dst|$dst, $src2}",
869 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
871 def CMOVNS64rm: RI<0x49, MRMSrcMem, // if !signed, GR64 = [mem64]
872 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
873 "cmovns {$src2, $dst|$dst, $src2}",
874 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
876 def CMOVP64rr : RI<0x4A, MRMSrcReg, // if parity, GR64 = GR64
877 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
878 "cmovp {$src2, $dst|$dst, $src2}",
879 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
881 def CMOVP64rm : RI<0x4A, MRMSrcMem, // if parity, GR64 = [mem64]
882 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
883 "cmovp {$src2, $dst|$dst, $src2}",
884 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
886 def CMOVNP64rr : RI<0x4B, MRMSrcReg, // if !parity, GR64 = GR64
887 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
888 "cmovnp {$src2, $dst|$dst, $src2}",
889 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
891 def CMOVNP64rm : RI<0x4B, MRMSrcMem, // if !parity, GR64 = [mem64]
892 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
893 "cmovnp {$src2, $dst|$dst, $src2}",
894 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
898 //===----------------------------------------------------------------------===//
899 // Conversion Instructions...
903 def Int_CVTSD2SI64rr: RSDI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
904 "cvtsd2si{q} {$src, $dst|$dst, $src}",
905 []>; // TODO: add intrinsic
906 def Int_CVTSD2SI64rm: RSDI<0x2D, MRMSrcMem, (outs GR64:$dst), (ins f128mem:$src),
907 "cvtsd2si{q} {$src, $dst|$dst, $src}",
908 []>; // TODO: add intrinsic
909 def CVTTSD2SI64rr: RSDI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins FR64:$src),
910 "cvttsd2si{q} {$src, $dst|$dst, $src}",
911 [(set GR64:$dst, (fp_to_sint FR64:$src))]>;
912 def CVTTSD2SI64rm: RSDI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f64mem:$src),
913 "cvttsd2si{q} {$src, $dst|$dst, $src}",
914 [(set GR64:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
915 def Int_CVTTSD2SI64rr: RSDI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
916 "cvttsd2si{q} {$src, $dst|$dst, $src}",
917 []>; // TODO: add intrinsic
918 def Int_CVTTSD2SI64rm: RSDI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f128mem:$src),
919 "cvttsd2si{q} {$src, $dst|$dst, $src}",
920 []>; // TODO: add intrinsic
923 def CVTSI2SD64rr: RSDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src),
924 "cvtsi2sd{q} {$src, $dst|$dst, $src}",
925 [(set FR64:$dst, (sint_to_fp GR64:$src))]>;
926 def CVTSI2SD64rm: RSDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i64mem:$src),
927 "cvtsi2sd{q} {$src, $dst|$dst, $src}",
928 [(set FR64:$dst, (sint_to_fp (loadi64 addr:$src)))]>;
929 let isTwoAddress = 1 in {
930 def Int_CVTSI2SD64rr: RSDI<0x2A, MRMSrcReg,
931 (outs VR128:$dst), (ins VR128:$src1, GR64:$src2),
932 "cvtsi2sd{q} {$src2, $dst|$dst, $src2}",
933 []>; // TODO: add intrinsic
934 def Int_CVTSI2SD64rm: RSDI<0x2A, MRMSrcMem,
935 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
936 "cvtsi2sd{q} {$src2, $dst|$dst, $src2}",
937 []>; // TODO: add intrinsic
941 def CVTSI2SS64rr: RSSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR64:$src),
942 "cvtsi2ss{q} {$src, $dst|$dst, $src}",
943 [(set FR32:$dst, (sint_to_fp GR64:$src))]>;
944 def CVTSI2SS64rm: RSSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i64mem:$src),
945 "cvtsi2ss{q} {$src, $dst|$dst, $src}",
946 [(set FR32:$dst, (sint_to_fp (loadi64 addr:$src)))]>;
947 let isTwoAddress = 1 in {
948 def Int_CVTSI2SS64rr: RSSI<0x2A, MRMSrcReg,
949 (outs VR128:$dst), (ins VR128:$src1, GR64:$src2),
950 "cvtsi2ss{q} {$src2, $dst|$dst, $src2}",
951 []>; // TODO: add intrinsic
952 def Int_CVTSI2SS64rm: RSSI<0x2A, MRMSrcMem,
953 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
954 "cvtsi2ss{q} {$src2, $dst|$dst, $src2}",
955 []>; // TODO: add intrinsic
959 def Int_CVTSS2SI64rr: RSSI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
960 "cvtss2si{q} {$src, $dst|$dst, $src}",
961 []>; // TODO: add intrinsic
962 def Int_CVTSS2SI64rm: RSSI<0x2D, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src),
963 "cvtss2si{q} {$src, $dst|$dst, $src}",
964 []>; // TODO: add intrinsic
965 def CVTTSS2SI64rr: RSSI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins FR32:$src),
966 "cvttss2si{q} {$src, $dst|$dst, $src}",
967 [(set GR64:$dst, (fp_to_sint FR32:$src))]>;
968 def CVTTSS2SI64rm: RSSI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src),
969 "cvttss2si{q} {$src, $dst|$dst, $src}",
970 [(set GR64:$dst, (fp_to_sint (loadf32 addr:$src)))]>;
971 def Int_CVTTSS2SI64rr: RSSI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
972 "cvttss2si{q} {$src, $dst|$dst, $src}",
973 []>; // TODO: add intrinsic
974 def Int_CVTTSS2SI64rm: RSSI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src),
975 "cvttss2si{q} {$src, $dst|$dst, $src}",
976 []>; // TODO: add intrinsic
978 //===----------------------------------------------------------------------===//
979 // Alias Instructions
980 //===----------------------------------------------------------------------===//
983 // In 64-mode, each 64-bit and 32-bit registers has a low 8-bit sub-register.
984 def TRUNC_64to8 : I<0x88, MRMDestReg, (outs GR8:$dst), (ins GR64:$src),
985 "mov{b} {${src:subreg8}, $dst|$dst, ${src:subreg8}",
986 [(set GR8:$dst, (trunc GR64:$src))]>;
987 def TRUNC_32to8 : I<0x88, MRMDestReg, (outs GR8:$dst), (ins GR32:$src),
988 "mov{b} {${src:subreg8}, $dst|$dst, ${src:subreg8}",
989 [(set GR8:$dst, (trunc GR32:$src))]>,
990 Requires<[In64BitMode]>;
991 def TRUNC_16to8 : I<0x88, MRMDestReg, (outs GR8:$dst), (ins GR16:$src),
992 "mov{b} {${src:subreg8}, $dst|$dst, ${src:subreg8}}",
993 [(set GR8:$dst, (trunc GR16:$src))]>,
994 Requires<[In64BitMode]>;
996 def TRUNC_64to16 : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR64:$src),
997 "mov{w} {${src:subreg16}, $dst|$dst, ${src:subreg16}}",
998 [(set GR16:$dst, (trunc GR64:$src))]>;
1000 def TRUNC_64to32 : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR64:$src),
1001 "mov{l} {${src:subreg32}, $dst|$dst, ${src:subreg32}}",
1002 [(set GR32:$dst, (trunc GR64:$src))]>;
1005 // TODO: Remove this after proper i32 -> i64 zext support.
1006 def PsMOVZX64rr32: I<0x89, MRMDestReg, (outs GR64:$dst), (ins GR32:$src),
1007 "mov{l} {$src, ${dst:subreg32}|${dst:subreg32}, $src}",
1008 [(set GR64:$dst, (zext GR32:$src))]>;
1009 def PsMOVZX64rm32: I<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i32mem:$src),
1010 "mov{l} {$src, ${dst:subreg32}|${dst:subreg32}, $src}",
1011 [(set GR64:$dst, (zextloadi64i32 addr:$src))]>;
1014 // Alias instructions that map movr0 to xor.
1015 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
1016 // FIXME: AddedComplexity gives MOV64r0 a higher priority than MOV64ri32. Remove
1017 // when we have a better way to specify isel priority.
1018 let AddedComplexity = 1 in
1019 def MOV64r0 : RI<0x31, MRMInitReg, (outs GR64:$dst), (ins),
1020 "xor{q} $dst, $dst",
1021 [(set GR64:$dst, 0)]>;
1023 // Materialize i64 constant where top 32-bits are zero.
1024 let AddedComplexity = 1 in
1025 def MOV64ri64i32 : Ii32<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64i32imm:$src),
1026 "mov{l} {$src, ${dst:subreg32}|${dst:subreg32}, $src}",
1027 [(set GR64:$dst, i64immZExt32:$src)]>;
1029 //===----------------------------------------------------------------------===//
1030 // Non-Instruction Patterns
1031 //===----------------------------------------------------------------------===//
1033 // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
1034 def : Pat<(i64 (X86Wrapper tconstpool :$dst)),
1035 (MOV64ri tconstpool :$dst)>, Requires<[NotSmallCode]>;
1036 def : Pat<(i64 (X86Wrapper tjumptable :$dst)),
1037 (MOV64ri tjumptable :$dst)>, Requires<[NotSmallCode]>;
1038 def : Pat<(i64 (X86Wrapper tglobaladdr :$dst)),
1039 (MOV64ri tglobaladdr :$dst)>, Requires<[NotSmallCode]>;
1040 def : Pat<(i64 (X86Wrapper texternalsym:$dst)),
1041 (MOV64ri texternalsym:$dst)>, Requires<[NotSmallCode]>;
1043 def : Pat<(store (i64 (X86Wrapper tconstpool:$src)), addr:$dst),
1044 (MOV64mi32 addr:$dst, tconstpool:$src)>,
1045 Requires<[SmallCode, IsStatic]>;
1046 def : Pat<(store (i64 (X86Wrapper tjumptable:$src)), addr:$dst),
1047 (MOV64mi32 addr:$dst, tjumptable:$src)>,
1048 Requires<[SmallCode, IsStatic]>;
1049 def : Pat<(store (i64 (X86Wrapper tglobaladdr:$src)), addr:$dst),
1050 (MOV64mi32 addr:$dst, tglobaladdr:$src)>,
1051 Requires<[SmallCode, IsStatic]>;
1052 def : Pat<(store (i64 (X86Wrapper texternalsym:$src)), addr:$dst),
1053 (MOV64mi32 addr:$dst, texternalsym:$src)>,
1054 Requires<[SmallCode, IsStatic]>;
1057 // Direct PC relative function call for small code model. 32-bit displacement
1058 // sign extended to 64-bit.
1059 def : Pat<(X86call (i64 tglobaladdr:$dst)),
1060 (CALL64pcrel32 tglobaladdr:$dst)>;
1061 def : Pat<(X86call (i64 texternalsym:$dst)),
1062 (CALL64pcrel32 texternalsym:$dst)>;
1064 def : Pat<(X86tailcall (i64 tglobaladdr:$dst)),
1065 (CALL64pcrel32 tglobaladdr:$dst)>;
1066 def : Pat<(X86tailcall (i64 texternalsym:$dst)),
1067 (CALL64pcrel32 texternalsym:$dst)>;
1069 def : Pat<(X86tailcall GR64:$dst),
1070 (CALL64r GR64:$dst)>;
1072 // {s|z}extload bool -> {s|z}extload byte
1073 def : Pat<(sextloadi64i1 addr:$src), (MOVSX64rm8 addr:$src)>;
1074 def : Pat<(zextloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>;
1077 def : Pat<(extloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>;
1078 def : Pat<(extloadi64i8 addr:$src), (MOVZX64rm8 addr:$src)>;
1079 def : Pat<(extloadi64i16 addr:$src), (MOVZX64rm16 addr:$src)>;
1080 def : Pat<(extloadi64i32 addr:$src), (PsMOVZX64rm32 addr:$src)>;
1083 def : Pat<(i64 (anyext GR8 :$src)), (MOVZX64rr8 GR8 :$src)>;
1084 def : Pat<(i64 (anyext GR16:$src)), (MOVZX64rr16 GR16:$src)>;
1085 def : Pat<(i64 (anyext GR32:$src)), (PsMOVZX64rr32 GR32:$src)>;
1086 def : Pat<(i64 (anyext (loadi8 addr:$src))), (MOVZX64rm8 addr:$src)>;
1087 def : Pat<(i64 (anyext (loadi16 addr:$src))), (MOVZX64rm16 addr:$src)>;
1088 def : Pat<(i64 (anyext (loadi32 addr:$src))), (PsMOVZX64rm32 addr:$src)>;
1090 //===----------------------------------------------------------------------===//
1092 //===----------------------------------------------------------------------===//
1094 // (shl x, 1) ==> (add x, x)
1095 def : Pat<(shl GR64:$src1, (i8 1)), (ADD64rr GR64:$src1, GR64:$src1)>;
1097 // (or (x >> c) | (y << (64 - c))) ==> (shrd64 x, y, c)
1098 def : Pat<(or (srl GR64:$src1, CL:$amt),
1099 (shl GR64:$src2, (sub 64, CL:$amt))),
1100 (SHRD64rrCL GR64:$src1, GR64:$src2)>;
1102 def : Pat<(store (or (srl (loadi64 addr:$dst), CL:$amt),
1103 (shl GR64:$src2, (sub 64, CL:$amt))), addr:$dst),
1104 (SHRD64mrCL addr:$dst, GR64:$src2)>;
1106 // (or (x << c) | (y >> (64 - c))) ==> (shld64 x, y, c)
1107 def : Pat<(or (shl GR64:$src1, CL:$amt),
1108 (srl GR64:$src2, (sub 64, CL:$amt))),
1109 (SHLD64rrCL GR64:$src1, GR64:$src2)>;
1111 def : Pat<(store (or (shl (loadi64 addr:$dst), CL:$amt),
1112 (srl GR64:$src2, (sub 64, CL:$amt))), addr:$dst),
1113 (SHLD64mrCL addr:$dst, GR64:$src2)>;
1115 // X86 specific add which produces a flag.
1116 def : Pat<(addc GR64:$src1, GR64:$src2),
1117 (ADD64rr GR64:$src1, GR64:$src2)>;
1118 def : Pat<(addc GR64:$src1, (load addr:$src2)),
1119 (ADD64rm GR64:$src1, addr:$src2)>;
1120 def : Pat<(addc GR64:$src1, i64immSExt32:$src2),
1121 (ADD64ri32 GR64:$src1, imm:$src2)>;
1122 def : Pat<(addc GR64:$src1, i64immSExt8:$src2),
1123 (ADD64ri8 GR64:$src1, i64immSExt8:$src2)>;
1125 def : Pat<(subc GR64:$src1, GR64:$src2),
1126 (SUB64rr GR64:$src1, GR64:$src2)>;
1127 def : Pat<(subc GR64:$src1, (load addr:$src2)),
1128 (SUB64rm GR64:$src1, addr:$src2)>;
1129 def : Pat<(subc GR64:$src1, imm:$src2),
1130 (SUB64ri32 GR64:$src1, i64immSExt32:$src2)>;
1131 def : Pat<(subc GR64:$src1, i64immSExt8:$src2),
1132 (SUB64ri8 GR64:$src1, i64immSExt8:$src2)>;
1135 //===----------------------------------------------------------------------===//
1136 // X86-64 SSE Instructions
1137 //===----------------------------------------------------------------------===//
1139 // Move instructions...
1141 def MOV64toPQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
1142 "mov{d|q} {$src, $dst|$dst, $src}",
1144 (v2i64 (scalar_to_vector GR64:$src)))]>;
1145 def MOV64toPQIrm : RPDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
1146 "mov{d|q} {$src, $dst|$dst, $src}",
1148 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>;
1150 def MOVPQIto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins VR128:$src),
1151 "mov{d|q} {$src, $dst|$dst, $src}",
1152 [(set GR64:$dst, (vector_extract (v2i64 VR128:$src),
1154 def MOVPQIto64mr : RPDI<0x7E, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
1155 "mov{d|q} {$src, $dst|$dst, $src}",
1156 [(store (i64 (vector_extract (v2i64 VR128:$src),
1157 (iPTR 0))), addr:$dst)]>;
1159 def MOV64toSDrr : RPDI<0x6E, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src),
1160 "mov{d|q} {$src, $dst|$dst, $src}",
1161 [(set FR64:$dst, (bitconvert GR64:$src))]>;
1162 def MOV64toSDrm : RPDI<0x6E, MRMSrcMem, (outs FR64:$dst), (ins i64mem:$src),
1163 "mov{d|q} {$src, $dst|$dst, $src}",
1164 [(set FR64:$dst, (bitconvert (loadi64 addr:$src)))]>;
1166 def MOVSDto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins FR64:$src),
1167 "mov{d|q} {$src, $dst|$dst, $src}",
1168 [(set GR64:$dst, (bitconvert FR64:$src))]>;
1169 def MOVSDto64mr : RPDI<0x7E, MRMDestMem, (outs), (ins i64mem:$dst, FR64:$src),
1170 "mov{d|q} {$src, $dst|$dst, $src}",
1171 [(store (i64 (bitconvert FR64:$src)), addr:$dst)]>;