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 // Pattern fragments...
46 def i64immSExt32 : PatLeaf<(i64 imm), [{
47 // i64immSExt32 predicate - True if the 64-bit immediate fits in a 32-bit
48 // sign extended field.
49 return (int64_t)N->getValue() == (int32_t)N->getValue();
52 def i64immZExt32 : PatLeaf<(i64 imm), [{
53 // i64immZExt32 predicate - True if the 64-bit immediate fits in a 32-bit
54 // unsignedsign extended field.
55 return (uint64_t)N->getValue() == (uint32_t)N->getValue();
58 def i64immSExt8 : PatLeaf<(i64 imm), [{
59 // i64immSExt8 predicate - True if the 64-bit immediate fits in a 8-bit
60 // sign extended field.
61 return (int64_t)N->getValue() == (int8_t)N->getValue();
64 def sextloadi64i1 : PatFrag<(ops node:$ptr), (i64 (sextloadi1 node:$ptr))>;
65 def sextloadi64i8 : PatFrag<(ops node:$ptr), (i64 (sextloadi8 node:$ptr))>;
66 def sextloadi64i16 : PatFrag<(ops node:$ptr), (i64 (sextloadi16 node:$ptr))>;
67 def sextloadi64i32 : PatFrag<(ops node:$ptr), (i64 (sextloadi32 node:$ptr))>;
69 def zextloadi64i1 : PatFrag<(ops node:$ptr), (i64 (zextloadi1 node:$ptr))>;
70 def zextloadi64i8 : PatFrag<(ops node:$ptr), (i64 (zextloadi8 node:$ptr))>;
71 def zextloadi64i16 : PatFrag<(ops node:$ptr), (i64 (zextloadi16 node:$ptr))>;
72 def zextloadi64i32 : PatFrag<(ops node:$ptr), (i64 (zextloadi32 node:$ptr))>;
74 def extloadi64i1 : PatFrag<(ops node:$ptr), (i64 (extloadi1 node:$ptr))>;
75 def extloadi64i8 : PatFrag<(ops node:$ptr), (i64 (extloadi8 node:$ptr))>;
76 def extloadi64i16 : PatFrag<(ops node:$ptr), (i64 (extloadi16 node:$ptr))>;
77 def extloadi64i32 : PatFrag<(ops node:$ptr), (i64 (extloadi32 node:$ptr))>;
79 //===----------------------------------------------------------------------===//
80 // Instruction list...
83 def IMPLICIT_DEF_GR64 : I<0, Pseudo, (outs GR64:$dst), (ins),
85 [(set GR64:$dst, (undef))]>;
87 //===----------------------------------------------------------------------===//
88 // Call Instructions...
91 // All calls clobber the non-callee saved registers...
92 let Defs = [RAX, RCX, RDX, RSI, RDI, R8, R9, R10, R11,
93 FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
94 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
95 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
96 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS] in {
97 def CALL64pcrel32 : I<0xE8, RawFrm, (outs), (ins i64imm:$dst, variable_ops),
98 "call\t${dst:call}", []>;
99 def CALL64r : I<0xFF, MRM2r, (outs), (ins GR64:$dst, variable_ops),
100 "call\t{*}$dst", [(X86call GR64:$dst)]>;
101 def CALL64m : I<0xFF, MRM2m, (outs), (ins i64mem:$dst, variable_ops),
102 "call\t{*}$dst", []>;
106 let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
107 def JMP64r : I<0xFF, MRM4r, (outs), (ins GR64:$dst), "jmp{q}\t{*}$dst",
108 [(brind GR64:$dst)]>;
109 def JMP64m : I<0xFF, MRM4m, (outs), (ins i64mem:$dst), "jmp{q}\t{*}$dst",
110 [(brind (loadi64 addr:$dst))]>;
113 //===----------------------------------------------------------------------===//
114 // Miscellaneous Instructions...
116 let Defs = [RBP,RSP], Uses = [RBP,RSP] in
117 def LEAVE64 : I<0xC9, RawFrm,
118 (outs), (ins), "leave", []>;
119 let Defs = [RSP], Uses = [RSP] in {
120 def POP64r : I<0x58, AddRegFrm,
121 (outs GR64:$reg), (ins), "pop{q}\t$reg", []>;
122 def PUSH64r : I<0x50, AddRegFrm,
123 (outs), (ins GR64:$reg), "push{q}\t$reg", []>;
126 let Defs = [RSP, EFLAGS], Uses = [RSP] in
127 def POPFQ : I<0x9D, RawFrm, (outs), (ins), "popf", []>, REX_W;
128 let Defs = [RSP], Uses = [RSP, EFLAGS] in
129 def PUSHFQ : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
131 def LEA64_32r : I<0x8D, MRMSrcMem,
132 (outs GR32:$dst), (ins lea64_32mem:$src),
133 "lea{l}\t{$src|$dst}, {$dst|$src}",
134 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In64BitMode]>;
136 def LEA64r : RI<0x8D, MRMSrcMem, (outs GR64:$dst), (ins lea64mem:$src),
137 "lea{q}\t{$src|$dst}, {$dst|$src}",
138 [(set GR64:$dst, lea64addr:$src)]>;
140 let isTwoAddress = 1 in
141 def BSWAP64r : RI<0xC8, AddRegFrm, (outs GR64:$dst), (ins GR64:$src),
143 [(set GR64:$dst, (bswap GR64:$src))]>, TB;
145 def XCHG64rr : RI<0x87, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2),
146 "xchg{q}\t{$src2|$src1}, {$src1|$src2}", []>;
147 def XCHG64mr : RI<0x87, MRMDestMem, (outs), (ins i64mem:$src1, GR64:$src2),
148 "xchg{q}\t{$src2|$src1}, {$src1|$src2}", []>;
149 def XCHG64rm : RI<0x87, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2),
150 "xchg{q}\t{$src2|$src1}, {$src1|$src2}", []>;
153 let Defs = [RCX,RDI,RSI], Uses = [RCX,RDI,RSI] in
154 def REP_MOVSQ : RI<0xA5, RawFrm, (outs), (ins), "{rep;movsq|rep movsq}",
155 [(X86rep_movs i64)]>, REP;
156 let Defs = [RCX,RDI], Uses = [RAX,RCX,RDI] in
157 def REP_STOSQ : RI<0xAB, RawFrm, (outs), (ins), "{rep;stosq|rep stosq}",
158 [(X86rep_stos i64)]>, REP;
160 //===----------------------------------------------------------------------===//
161 // Move Instructions...
164 def MOV64rr : RI<0x89, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
165 "mov{q}\t{$src, $dst|$dst, $src}", []>;
167 let isReMaterializable = 1 in {
168 def MOV64ri : RIi64<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64imm:$src),
169 "movabs{q}\t{$src, $dst|$dst, $src}",
170 [(set GR64:$dst, imm:$src)]>;
171 def MOV64ri32 : RIi32<0xC7, MRM0r, (outs GR64:$dst), (ins i64i32imm:$src),
172 "mov{q}\t{$src, $dst|$dst, $src}",
173 [(set GR64:$dst, i64immSExt32:$src)]>;
177 def MOV64rm : RI<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
178 "mov{q}\t{$src, $dst|$dst, $src}",
179 [(set GR64:$dst, (load addr:$src))]>;
181 def MOV64mr : RI<0x89, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
182 "mov{q}\t{$src, $dst|$dst, $src}",
183 [(store GR64:$src, addr:$dst)]>;
184 def MOV64mi32 : RIi32<0xC7, MRM0m, (outs), (ins i64mem:$dst, i64i32imm:$src),
185 "mov{q}\t{$src, $dst|$dst, $src}",
186 [(store i64immSExt32:$src, addr:$dst)]>;
188 // Sign/Zero extenders
190 def MOVSX64rr8 : RI<0xBE, MRMSrcReg, (outs GR64:$dst), (ins GR8 :$src),
191 "movs{bq|x}\t{$src, $dst|$dst, $src}",
192 [(set GR64:$dst, (sext GR8:$src))]>, TB;
193 def MOVSX64rm8 : RI<0xBE, MRMSrcMem, (outs GR64:$dst), (ins i8mem :$src),
194 "movs{bq|x}\t{$src, $dst|$dst, $src}",
195 [(set GR64:$dst, (sextloadi64i8 addr:$src))]>, TB;
196 def MOVSX64rr16: RI<0xBF, MRMSrcReg, (outs GR64:$dst), (ins GR16:$src),
197 "movs{wq|x}\t{$src, $dst|$dst, $src}",
198 [(set GR64:$dst, (sext GR16:$src))]>, TB;
199 def MOVSX64rm16: RI<0xBF, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
200 "movs{wq|x}\t{$src, $dst|$dst, $src}",
201 [(set GR64:$dst, (sextloadi64i16 addr:$src))]>, TB;
202 def MOVSX64rr32: RI<0x63, MRMSrcReg, (outs GR64:$dst), (ins GR32:$src),
203 "movs{lq|xd}\t{$src, $dst|$dst, $src}",
204 [(set GR64:$dst, (sext GR32:$src))]>;
205 def MOVSX64rm32: RI<0x63, MRMSrcMem, (outs GR64:$dst), (ins i32mem:$src),
206 "movs{lq|xd}\t{$src, $dst|$dst, $src}",
207 [(set GR64:$dst, (sextloadi64i32 addr:$src))]>;
209 def MOVZX64rr8 : RI<0xB6, MRMSrcReg, (outs GR64:$dst), (ins GR8 :$src),
210 "movz{bq|x}\t{$src, $dst|$dst, $src}",
211 [(set GR64:$dst, (zext GR8:$src))]>, TB;
212 def MOVZX64rm8 : RI<0xB6, MRMSrcMem, (outs GR64:$dst), (ins i8mem :$src),
213 "movz{bq|x}\t{$src, $dst|$dst, $src}",
214 [(set GR64:$dst, (zextloadi64i8 addr:$src))]>, TB;
215 def MOVZX64rr16: RI<0xB7, MRMSrcReg, (outs GR64:$dst), (ins GR16:$src),
216 "movz{wq|x}\t{$src, $dst|$dst, $src}",
217 [(set GR64:$dst, (zext GR16:$src))]>, TB;
218 def MOVZX64rm16: RI<0xB7, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
219 "movz{wq|x}\t{$src, $dst|$dst, $src}",
220 [(set GR64:$dst, (zextloadi64i16 addr:$src))]>, TB;
222 let Defs = [RAX], Uses = [EAX] in
223 def CDQE : RI<0x98, RawFrm, (outs), (ins),
224 "{cltq|cdqe}", []>; // RAX = signext(EAX)
226 let Defs = [RAX,RDX], Uses = [RAX] in
227 def CQO : RI<0x99, RawFrm, (outs), (ins),
228 "{cqto|cqo}", []>; // RDX:RAX = signext(RAX)
230 //===----------------------------------------------------------------------===//
231 // Arithmetic Instructions...
234 let Defs = [EFLAGS] in {
235 let isTwoAddress = 1 in {
236 let isConvertibleToThreeAddress = 1 in {
237 let isCommutable = 1 in
238 def ADD64rr : RI<0x01, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
239 "add{q}\t{$src2, $dst|$dst, $src2}",
240 [(set GR64:$dst, (add GR64:$src1, GR64:$src2))]>;
242 def ADD64ri32 : RIi32<0x81, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
243 "add{q}\t{$src2, $dst|$dst, $src2}",
244 [(set GR64:$dst, (add GR64:$src1, i64immSExt32:$src2))]>;
245 def ADD64ri8 : RIi8<0x83, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
246 "add{q}\t{$src2, $dst|$dst, $src2}",
247 [(set GR64:$dst, (add GR64:$src1, i64immSExt8:$src2))]>;
248 } // isConvertibleToThreeAddress
250 def ADD64rm : RI<0x03, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
251 "add{q}\t{$src2, $dst|$dst, $src2}",
252 [(set GR64:$dst, (add GR64:$src1, (load addr:$src2)))]>;
255 def ADD64mr : RI<0x01, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
256 "add{q}\t{$src2, $dst|$dst, $src2}",
257 [(store (add (load addr:$dst), GR64:$src2), addr:$dst)]>;
258 def ADD64mi32 : RIi32<0x81, MRM0m, (outs), (ins i64mem:$dst, i64i32imm :$src2),
259 "add{q}\t{$src2, $dst|$dst, $src2}",
260 [(store (add (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>;
261 def ADD64mi8 : RIi8<0x83, MRM0m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
262 "add{q}\t{$src2, $dst|$dst, $src2}",
263 [(store (add (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
265 let Uses = [EFLAGS] in {
266 let isTwoAddress = 1 in {
267 let isCommutable = 1 in
268 def ADC64rr : RI<0x11, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
269 "adc{q}\t{$src2, $dst|$dst, $src2}",
270 [(set GR64:$dst, (adde GR64:$src1, GR64:$src2))]>;
272 def ADC64rm : RI<0x13, MRMSrcMem , (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
273 "adc{q}\t{$src2, $dst|$dst, $src2}",
274 [(set GR64:$dst, (adde GR64:$src1, (load addr:$src2)))]>;
276 def ADC64ri32 : RIi32<0x81, MRM2r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
277 "adc{q}\t{$src2, $dst|$dst, $src2}",
278 [(set GR64:$dst, (adde GR64:$src1, i64immSExt32:$src2))]>;
279 def ADC64ri8 : RIi8<0x83, MRM2r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
280 "adc{q}\t{$src2, $dst|$dst, $src2}",
281 [(set GR64:$dst, (adde GR64:$src1, i64immSExt8:$src2))]>;
284 def ADC64mr : RI<0x11, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
285 "adc{q}\t{$src2, $dst|$dst, $src2}",
286 [(store (adde (load addr:$dst), GR64:$src2), addr:$dst)]>;
287 def ADC64mi32 : RIi32<0x81, MRM2m, (outs), (ins i64mem:$dst, i64i32imm:$src2),
288 "adc{q}\t{$src2, $dst|$dst, $src2}",
289 [(store (adde (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
290 def ADC64mi8 : RIi8<0x83, MRM2m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
291 "adc{q}\t{$src2, $dst|$dst, $src2}",
292 [(store (adde (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
295 let isTwoAddress = 1 in {
296 def SUB64rr : RI<0x29, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
297 "sub{q}\t{$src2, $dst|$dst, $src2}",
298 [(set GR64:$dst, (sub GR64:$src1, GR64:$src2))]>;
300 def SUB64rm : RI<0x2B, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
301 "sub{q}\t{$src2, $dst|$dst, $src2}",
302 [(set GR64:$dst, (sub GR64:$src1, (load addr:$src2)))]>;
304 def SUB64ri32 : RIi32<0x81, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
305 "sub{q}\t{$src2, $dst|$dst, $src2}",
306 [(set GR64:$dst, (sub GR64:$src1, i64immSExt32:$src2))]>;
307 def SUB64ri8 : RIi8<0x83, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
308 "sub{q}\t{$src2, $dst|$dst, $src2}",
309 [(set GR64:$dst, (sub GR64:$src1, i64immSExt8:$src2))]>;
312 def SUB64mr : RI<0x29, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
313 "sub{q}\t{$src2, $dst|$dst, $src2}",
314 [(store (sub (load addr:$dst), GR64:$src2), addr:$dst)]>;
315 def SUB64mi32 : RIi32<0x81, MRM5m, (outs), (ins i64mem:$dst, i64i32imm:$src2),
316 "sub{q}\t{$src2, $dst|$dst, $src2}",
317 [(store (sub (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>;
318 def SUB64mi8 : RIi8<0x83, MRM5m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
319 "sub{q}\t{$src2, $dst|$dst, $src2}",
320 [(store (sub (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
322 let Uses = [EFLAGS] in {
323 let isTwoAddress = 1 in {
324 def SBB64rr : RI<0x19, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
325 "sbb{q}\t{$src2, $dst|$dst, $src2}",
326 [(set GR64:$dst, (sube GR64:$src1, GR64:$src2))]>;
328 def SBB64rm : RI<0x1B, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
329 "sbb{q}\t{$src2, $dst|$dst, $src2}",
330 [(set GR64:$dst, (sube GR64:$src1, (load addr:$src2)))]>;
332 def SBB64ri32 : RIi32<0x81, MRM3r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
333 "sbb{q}\t{$src2, $dst|$dst, $src2}",
334 [(set GR64:$dst, (sube GR64:$src1, i64immSExt32:$src2))]>;
335 def SBB64ri8 : RIi8<0x83, MRM3r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
336 "sbb{q}\t{$src2, $dst|$dst, $src2}",
337 [(set GR64:$dst, (sube GR64:$src1, i64immSExt8:$src2))]>;
340 def SBB64mr : RI<0x19, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
341 "sbb{q}\t{$src2, $dst|$dst, $src2}",
342 [(store (sube (load addr:$dst), GR64:$src2), addr:$dst)]>;
343 def SBB64mi32 : RIi32<0x81, MRM3m, (outs), (ins i64mem:$dst, i64i32imm:$src2),
344 "sbb{q}\t{$src2, $dst|$dst, $src2}",
345 [(store (sube (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>;
346 def SBB64mi8 : RIi8<0x83, MRM3m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
347 "sbb{q}\t{$src2, $dst|$dst, $src2}",
348 [(store (sube (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
352 // Unsigned multiplication
353 let Defs = [RAX,RDX,EFLAGS], Uses = [RAX] in {
354 def MUL64r : RI<0xF7, MRM4r, (outs), (ins GR64:$src),
355 "mul{q}\t$src", []>; // RAX,RDX = RAX*GR64
356 def MUL64m : RI<0xF7, MRM4m, (outs), (ins i64mem:$src),
357 "mul{q}\t$src", []>; // RAX,RDX = RAX*[mem64]
359 // Signed multiplication
360 def IMUL64r : RI<0xF7, MRM5r, (outs), (ins GR64:$src),
361 "imul{q}\t$src", []>; // RAX,RDX = RAX*GR64
362 def IMUL64m : RI<0xF7, MRM5m, (outs), (ins i64mem:$src),
363 "imul{q}\t$src", []>; // RAX,RDX = RAX*[mem64]
366 let Defs = [EFLAGS] in {
367 let isTwoAddress = 1 in {
368 let isCommutable = 1 in
369 def IMUL64rr : RI<0xAF, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
370 "imul{q}\t{$src2, $dst|$dst, $src2}",
371 [(set GR64:$dst, (mul GR64:$src1, GR64:$src2))]>, TB;
373 def IMUL64rm : RI<0xAF, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
374 "imul{q}\t{$src2, $dst|$dst, $src2}",
375 [(set GR64:$dst, (mul GR64:$src1, (load addr:$src2)))]>, TB;
378 // Suprisingly enough, these are not two address instructions!
379 def IMUL64rri32 : RIi32<0x69, MRMSrcReg, // GR64 = GR64*I32
380 (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
381 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
382 [(set GR64:$dst, (mul GR64:$src1, i64immSExt32:$src2))]>;
383 def IMUL64rri8 : RIi8<0x6B, MRMSrcReg, // GR64 = GR64*I8
384 (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
385 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
386 [(set GR64:$dst, (mul GR64:$src1, i64immSExt8:$src2))]>;
387 def IMUL64rmi32 : RIi32<0x69, MRMSrcMem, // GR64 = [mem64]*I32
388 (outs GR64:$dst), (ins i64mem:$src1, i64i32imm:$src2),
389 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
390 [(set GR64:$dst, (mul (load addr:$src1), i64immSExt32:$src2))]>;
391 def IMUL64rmi8 : RIi8<0x6B, MRMSrcMem, // GR64 = [mem64]*I8
392 (outs GR64:$dst), (ins i64mem:$src1, i64i8imm: $src2),
393 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
394 [(set GR64:$dst, (mul (load addr:$src1), i64immSExt8:$src2))]>;
397 // Unsigned division / remainder
398 let Defs = [RAX,RDX,EFLAGS], Uses = [RAX,RDX] in {
399 def DIV64r : RI<0xF7, MRM6r, (outs), (ins GR64:$src), // RDX:RAX/r64 = RAX,RDX
401 def DIV64m : RI<0xF7, MRM6m, (outs), (ins i64mem:$src), // RDX:RAX/[mem64] = RAX,RDX
404 // Signed division / remainder
405 def IDIV64r: RI<0xF7, MRM7r, (outs), (ins GR64:$src), // RDX:RAX/r64 = RAX,RDX
406 "idiv{q}\t$src", []>;
407 def IDIV64m: RI<0xF7, MRM7m, (outs), (ins i64mem:$src), // RDX:RAX/[mem64] = RAX,RDX
408 "idiv{q}\t$src", []>;
411 // Unary instructions
412 let Defs = [EFLAGS], CodeSize = 2 in {
413 let isTwoAddress = 1 in
414 def NEG64r : RI<0xF7, MRM3r, (outs GR64:$dst), (ins GR64:$src), "neg{q}\t$dst",
415 [(set GR64:$dst, (ineg GR64:$src))]>;
416 def NEG64m : RI<0xF7, MRM3m, (outs), (ins i64mem:$dst), "neg{q}\t$dst",
417 [(store (ineg (loadi64 addr:$dst)), addr:$dst)]>;
419 let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in
420 def INC64r : RI<0xFF, MRM0r, (outs GR64:$dst), (ins GR64:$src), "inc{q}\t$dst",
421 [(set GR64:$dst, (add GR64:$src, 1))]>;
422 def INC64m : RI<0xFF, MRM0m, (outs), (ins i64mem:$dst), "inc{q}\t$dst",
423 [(store (add (loadi64 addr:$dst), 1), addr:$dst)]>;
425 let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in
426 def DEC64r : RI<0xFF, MRM1r, (outs GR64:$dst), (ins GR64:$src), "dec{q}\t$dst",
427 [(set GR64:$dst, (add GR64:$src, -1))]>;
428 def DEC64m : RI<0xFF, MRM1m, (outs), (ins i64mem:$dst), "dec{q}\t$dst",
429 [(store (add (loadi64 addr:$dst), -1), addr:$dst)]>;
431 // In 64-bit mode, single byte INC and DEC cannot be encoded.
432 let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in {
433 // Can transform into LEA.
434 def INC64_16r : I<0xFF, MRM0r, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
435 [(set GR16:$dst, (add GR16:$src, 1))]>,
436 OpSize, Requires<[In64BitMode]>;
437 def INC64_32r : I<0xFF, MRM0r, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
438 [(set GR32:$dst, (add GR32:$src, 1))]>,
439 Requires<[In64BitMode]>;
440 def DEC64_16r : I<0xFF, MRM1r, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
441 [(set GR16:$dst, (add GR16:$src, -1))]>,
442 OpSize, Requires<[In64BitMode]>;
443 def DEC64_32r : I<0xFF, MRM1r, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
444 [(set GR32:$dst, (add GR32:$src, -1))]>,
445 Requires<[In64BitMode]>;
446 } // isConvertibleToThreeAddress
447 } // Defs = [EFLAGS], CodeSize
450 let Defs = [EFLAGS] in {
451 // Shift instructions
452 let isTwoAddress = 1 in {
454 def SHL64rCL : RI<0xD3, MRM4r, (outs GR64:$dst), (ins GR64:$src),
455 "shl{q}\t{%cl, $dst|$dst, %CL}",
456 [(set GR64:$dst, (shl GR64:$src, CL))]>;
457 let isConvertibleToThreeAddress = 1 in // Can transform into LEA.
458 def SHL64ri : RIi8<0xC1, MRM4r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
459 "shl{q}\t{$src2, $dst|$dst, $src2}",
460 [(set GR64:$dst, (shl GR64:$src1, (i8 imm:$src2)))]>;
461 def SHL64r1 : RI<0xD1, MRM4r, (outs GR64:$dst), (ins GR64:$src1),
466 def SHL64mCL : RI<0xD3, MRM4m, (outs), (ins i64mem:$dst),
467 "shl{q}\t{%cl, $dst|$dst, %CL}",
468 [(store (shl (loadi64 addr:$dst), CL), addr:$dst)]>;
469 def SHL64mi : RIi8<0xC1, MRM4m, (outs), (ins i64mem:$dst, i8imm:$src),
470 "shl{q}\t{$src, $dst|$dst, $src}",
471 [(store (shl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
472 def SHL64m1 : RI<0xD1, MRM4m, (outs), (ins i64mem:$dst),
474 [(store (shl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
476 let isTwoAddress = 1 in {
478 def SHR64rCL : RI<0xD3, MRM5r, (outs GR64:$dst), (ins GR64:$src),
479 "shr{q}\t{%cl, $dst|$dst, %CL}",
480 [(set GR64:$dst, (srl GR64:$src, CL))]>;
481 def SHR64ri : RIi8<0xC1, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
482 "shr{q}\t{$src2, $dst|$dst, $src2}",
483 [(set GR64:$dst, (srl GR64:$src1, (i8 imm:$src2)))]>;
484 def SHR64r1 : RI<0xD1, MRM5r, (outs GR64:$dst), (ins GR64:$src1),
486 [(set GR64:$dst, (srl GR64:$src1, (i8 1)))]>;
490 def SHR64mCL : RI<0xD3, MRM5m, (outs), (ins i64mem:$dst),
491 "shr{q}\t{%cl, $dst|$dst, %CL}",
492 [(store (srl (loadi64 addr:$dst), CL), addr:$dst)]>;
493 def SHR64mi : RIi8<0xC1, MRM5m, (outs), (ins i64mem:$dst, i8imm:$src),
494 "shr{q}\t{$src, $dst|$dst, $src}",
495 [(store (srl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
496 def SHR64m1 : RI<0xD1, MRM5m, (outs), (ins i64mem:$dst),
498 [(store (srl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
500 let isTwoAddress = 1 in {
502 def SAR64rCL : RI<0xD3, MRM7r, (outs GR64:$dst), (ins GR64:$src),
503 "sar{q}\t{%cl, $dst|$dst, %CL}",
504 [(set GR64:$dst, (sra GR64:$src, CL))]>;
505 def SAR64ri : RIi8<0xC1, MRM7r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
506 "sar{q}\t{$src2, $dst|$dst, $src2}",
507 [(set GR64:$dst, (sra GR64:$src1, (i8 imm:$src2)))]>;
508 def SAR64r1 : RI<0xD1, MRM7r, (outs GR64:$dst), (ins GR64:$src1),
510 [(set GR64:$dst, (sra GR64:$src1, (i8 1)))]>;
514 def SAR64mCL : RI<0xD3, MRM7m, (outs), (ins i64mem:$dst),
515 "sar{q}\t{%cl, $dst|$dst, %CL}",
516 [(store (sra (loadi64 addr:$dst), CL), addr:$dst)]>;
517 def SAR64mi : RIi8<0xC1, MRM7m, (outs), (ins i64mem:$dst, i8imm:$src),
518 "sar{q}\t{$src, $dst|$dst, $src}",
519 [(store (sra (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
520 def SAR64m1 : RI<0xD1, MRM7m, (outs), (ins i64mem:$dst),
522 [(store (sra (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
524 // Rotate instructions
525 let isTwoAddress = 1 in {
527 def ROL64rCL : RI<0xD3, MRM0r, (outs GR64:$dst), (ins GR64:$src),
528 "rol{q}\t{%cl, $dst|$dst, %CL}",
529 [(set GR64:$dst, (rotl GR64:$src, CL))]>;
530 def ROL64ri : RIi8<0xC1, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
531 "rol{q}\t{$src2, $dst|$dst, $src2}",
532 [(set GR64:$dst, (rotl GR64:$src1, (i8 imm:$src2)))]>;
533 def ROL64r1 : RI<0xD1, MRM0r, (outs GR64:$dst), (ins GR64:$src1),
535 [(set GR64:$dst, (rotl GR64:$src1, (i8 1)))]>;
539 def ROL64mCL : I<0xD3, MRM0m, (outs), (ins i64mem:$dst),
540 "rol{q}\t{%cl, $dst|$dst, %CL}",
541 [(store (rotl (loadi64 addr:$dst), CL), addr:$dst)]>;
542 def ROL64mi : RIi8<0xC1, MRM0m, (outs), (ins i64mem:$dst, i8imm:$src),
543 "rol{q}\t{$src, $dst|$dst, $src}",
544 [(store (rotl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
545 def ROL64m1 : RI<0xD1, MRM0m, (outs), (ins i64mem:$dst),
547 [(store (rotl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
549 let isTwoAddress = 1 in {
551 def ROR64rCL : RI<0xD3, MRM1r, (outs GR64:$dst), (ins GR64:$src),
552 "ror{q}\t{%cl, $dst|$dst, %CL}",
553 [(set GR64:$dst, (rotr GR64:$src, CL))]>;
554 def ROR64ri : RIi8<0xC1, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
555 "ror{q}\t{$src2, $dst|$dst, $src2}",
556 [(set GR64:$dst, (rotr GR64:$src1, (i8 imm:$src2)))]>;
557 def ROR64r1 : RI<0xD1, MRM1r, (outs GR64:$dst), (ins GR64:$src1),
559 [(set GR64:$dst, (rotr GR64:$src1, (i8 1)))]>;
563 def ROR64mCL : RI<0xD3, MRM1m, (outs), (ins i64mem:$dst),
564 "ror{q}\t{%cl, $dst|$dst, %CL}",
565 [(store (rotr (loadi64 addr:$dst), CL), addr:$dst)]>;
566 def ROR64mi : RIi8<0xC1, MRM1m, (outs), (ins i64mem:$dst, i8imm:$src),
567 "ror{q}\t{$src, $dst|$dst, $src}",
568 [(store (rotr (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
569 def ROR64m1 : RI<0xD1, MRM1m, (outs), (ins i64mem:$dst),
571 [(store (rotr (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
573 // Double shift instructions (generalizations of rotate)
574 let isTwoAddress = 1 in {
576 def SHLD64rrCL : RI<0xA5, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
577 "shld{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
578 [(set GR64:$dst, (X86shld GR64:$src1, GR64:$src2, CL))]>, TB;
579 def SHRD64rrCL : RI<0xAD, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
580 "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
581 [(set GR64:$dst, (X86shrd GR64:$src1, GR64:$src2, CL))]>, TB;
584 let isCommutable = 1 in { // FIXME: Update X86InstrInfo::commuteInstruction
585 def SHLD64rri8 : RIi8<0xA4, MRMDestReg,
586 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2, i8imm:$src3),
587 "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
588 [(set GR64:$dst, (X86shld GR64:$src1, GR64:$src2,
591 def SHRD64rri8 : RIi8<0xAC, MRMDestReg,
592 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2, i8imm:$src3),
593 "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
594 [(set GR64:$dst, (X86shrd GR64:$src1, GR64:$src2,
601 def SHLD64mrCL : RI<0xA5, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
602 "shld{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
603 [(store (X86shld (loadi64 addr:$dst), GR64:$src2, CL),
605 def SHRD64mrCL : RI<0xAD, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
606 "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
607 [(store (X86shrd (loadi64 addr:$dst), GR64:$src2, CL),
610 def SHLD64mri8 : RIi8<0xA4, MRMDestMem,
611 (outs), (ins i64mem:$dst, GR64:$src2, i8imm:$src3),
612 "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
613 [(store (X86shld (loadi64 addr:$dst), GR64:$src2,
614 (i8 imm:$src3)), addr:$dst)]>,
616 def SHRD64mri8 : RIi8<0xAC, MRMDestMem,
617 (outs), (ins i64mem:$dst, GR64:$src2, i8imm:$src3),
618 "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
619 [(store (X86shrd (loadi64 addr:$dst), GR64:$src2,
620 (i8 imm:$src3)), addr:$dst)]>,
624 //===----------------------------------------------------------------------===//
625 // Logical Instructions...
628 let isTwoAddress = 1 in
629 def NOT64r : RI<0xF7, MRM2r, (outs GR64:$dst), (ins GR64:$src), "not{q}\t$dst",
630 [(set GR64:$dst, (not GR64:$src))]>;
631 def NOT64m : RI<0xF7, MRM2m, (outs), (ins i64mem:$dst), "not{q}\t$dst",
632 [(store (not (loadi64 addr:$dst)), addr:$dst)]>;
634 let Defs = [EFLAGS] in {
635 let isTwoAddress = 1 in {
636 let isCommutable = 1 in
637 def AND64rr : RI<0x21, MRMDestReg,
638 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
639 "and{q}\t{$src2, $dst|$dst, $src2}",
640 [(set GR64:$dst, (and GR64:$src1, GR64:$src2))]>;
641 def AND64rm : RI<0x23, MRMSrcMem,
642 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
643 "and{q}\t{$src2, $dst|$dst, $src2}",
644 [(set GR64:$dst, (and GR64:$src1, (load addr:$src2)))]>;
645 def AND64ri32 : RIi32<0x81, MRM4r,
646 (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
647 "and{q}\t{$src2, $dst|$dst, $src2}",
648 [(set GR64:$dst, (and GR64:$src1, i64immSExt32:$src2))]>;
649 def AND64ri8 : RIi8<0x83, MRM4r,
650 (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
651 "and{q}\t{$src2, $dst|$dst, $src2}",
652 [(set GR64:$dst, (and GR64:$src1, i64immSExt8:$src2))]>;
655 def AND64mr : RI<0x21, MRMDestMem,
656 (outs), (ins i64mem:$dst, GR64:$src),
657 "and{q}\t{$src, $dst|$dst, $src}",
658 [(store (and (load addr:$dst), GR64:$src), addr:$dst)]>;
659 def AND64mi32 : RIi32<0x81, MRM4m,
660 (outs), (ins i64mem:$dst, i64i32imm:$src),
661 "and{q}\t{$src, $dst|$dst, $src}",
662 [(store (and (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>;
663 def AND64mi8 : RIi8<0x83, MRM4m,
664 (outs), (ins i64mem:$dst, i64i8imm :$src),
665 "and{q}\t{$src, $dst|$dst, $src}",
666 [(store (and (load addr:$dst), i64immSExt8:$src), addr:$dst)]>;
668 let isTwoAddress = 1 in {
669 let isCommutable = 1 in
670 def OR64rr : RI<0x09, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
671 "or{q}\t{$src2, $dst|$dst, $src2}",
672 [(set GR64:$dst, (or GR64:$src1, GR64:$src2))]>;
673 def OR64rm : RI<0x0B, MRMSrcMem , (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
674 "or{q}\t{$src2, $dst|$dst, $src2}",
675 [(set GR64:$dst, (or GR64:$src1, (load addr:$src2)))]>;
676 def OR64ri32 : RIi32<0x81, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
677 "or{q}\t{$src2, $dst|$dst, $src2}",
678 [(set GR64:$dst, (or GR64:$src1, i64immSExt32:$src2))]>;
679 def OR64ri8 : RIi8<0x83, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
680 "or{q}\t{$src2, $dst|$dst, $src2}",
681 [(set GR64:$dst, (or GR64:$src1, i64immSExt8:$src2))]>;
684 def OR64mr : RI<0x09, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
685 "or{q}\t{$src, $dst|$dst, $src}",
686 [(store (or (load addr:$dst), GR64:$src), addr:$dst)]>;
687 def OR64mi32 : RIi32<0x81, MRM1m, (outs), (ins i64mem:$dst, i64i32imm:$src),
688 "or{q}\t{$src, $dst|$dst, $src}",
689 [(store (or (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>;
690 def OR64mi8 : RIi8<0x83, MRM1m, (outs), (ins i64mem:$dst, i64i8imm:$src),
691 "or{q}\t{$src, $dst|$dst, $src}",
692 [(store (or (load addr:$dst), i64immSExt8:$src), addr:$dst)]>;
694 let isTwoAddress = 1 in {
695 let isCommutable = 1 in
696 def XOR64rr : RI<0x31, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
697 "xor{q}\t{$src2, $dst|$dst, $src2}",
698 [(set GR64:$dst, (xor GR64:$src1, GR64:$src2))]>;
699 def XOR64rm : RI<0x33, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
700 "xor{q}\t{$src2, $dst|$dst, $src2}",
701 [(set GR64:$dst, (xor GR64:$src1, (load addr:$src2)))]>;
702 def XOR64ri32 : RIi32<0x81, MRM6r,
703 (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
704 "xor{q}\t{$src2, $dst|$dst, $src2}",
705 [(set GR64:$dst, (xor GR64:$src1, i64immSExt32:$src2))]>;
706 def XOR64ri8 : RIi8<0x83, MRM6r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
707 "xor{q}\t{$src2, $dst|$dst, $src2}",
708 [(set GR64:$dst, (xor GR64:$src1, i64immSExt8:$src2))]>;
711 def XOR64mr : RI<0x31, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
712 "xor{q}\t{$src, $dst|$dst, $src}",
713 [(store (xor (load addr:$dst), GR64:$src), addr:$dst)]>;
714 def XOR64mi32 : RIi32<0x81, MRM6m, (outs), (ins i64mem:$dst, i64i32imm:$src),
715 "xor{q}\t{$src, $dst|$dst, $src}",
716 [(store (xor (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>;
717 def XOR64mi8 : RIi8<0x83, MRM6m, (outs), (ins i64mem:$dst, i64i8imm :$src),
718 "xor{q}\t{$src, $dst|$dst, $src}",
719 [(store (xor (load addr:$dst), i64immSExt8:$src), addr:$dst)]>;
722 //===----------------------------------------------------------------------===//
723 // Comparison Instructions...
726 // Integer comparison
727 let Defs = [EFLAGS] in {
728 let isCommutable = 1 in
729 def TEST64rr : RI<0x85, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2),
730 "test{q}\t{$src2, $src1|$src1, $src2}",
731 [(X86cmp (and GR64:$src1, GR64:$src2), 0),
733 def TEST64rm : RI<0x85, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2),
734 "test{q}\t{$src2, $src1|$src1, $src2}",
735 [(X86cmp (and GR64:$src1, (loadi64 addr:$src2)), 0),
737 def TEST64ri32 : RIi32<0xF7, MRM0r, (outs),
738 (ins GR64:$src1, i64i32imm:$src2),
739 "test{q}\t{$src2, $src1|$src1, $src2}",
740 [(X86cmp (and GR64:$src1, i64immSExt32:$src2), 0),
742 def TEST64mi32 : RIi32<0xF7, MRM0m, (outs),
743 (ins i64mem:$src1, i64i32imm:$src2),
744 "test{q}\t{$src2, $src1|$src1, $src2}",
745 [(X86cmp (and (loadi64 addr:$src1), i64immSExt32:$src2), 0),
748 def CMP64rr : RI<0x39, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2),
749 "cmp{q}\t{$src2, $src1|$src1, $src2}",
750 [(X86cmp GR64:$src1, GR64:$src2),
752 def CMP64mr : RI<0x39, MRMDestMem, (outs), (ins i64mem:$src1, GR64:$src2),
753 "cmp{q}\t{$src2, $src1|$src1, $src2}",
754 [(X86cmp (loadi64 addr:$src1), GR64:$src2),
756 def CMP64rm : RI<0x3B, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2),
757 "cmp{q}\t{$src2, $src1|$src1, $src2}",
758 [(X86cmp GR64:$src1, (loadi64 addr:$src2)),
760 def CMP64ri32 : RIi32<0x81, MRM7r, (outs), (ins GR64:$src1, i64i32imm:$src2),
761 "cmp{q}\t{$src2, $src1|$src1, $src2}",
762 [(X86cmp GR64:$src1, i64immSExt32:$src2),
764 def CMP64mi32 : RIi32<0x81, MRM7m, (outs),
765 (ins i64mem:$src1, i64i32imm:$src2),
766 "cmp{q}\t{$src2, $src1|$src1, $src2}",
767 [(X86cmp (loadi64 addr:$src1), i64immSExt32:$src2),
769 def CMP64mi8 : RIi8<0x83, MRM7m, (outs), (ins i64mem:$src1, i64i8imm:$src2),
770 "cmp{q}\t{$src2, $src1|$src1, $src2}",
771 [(X86cmp (loadi64 addr:$src1), i64immSExt8:$src2),
773 def CMP64ri8 : RIi8<0x83, MRM7r, (outs), (ins GR64:$src1, i64i8imm:$src2),
774 "cmp{q}\t{$src2, $src1|$src1, $src2}",
775 [(X86cmp GR64:$src1, i64immSExt8:$src2),
780 let Uses = [EFLAGS], isTwoAddress = 1 in {
781 let isCommutable = 1 in {
782 def CMOVB64rr : RI<0x42, MRMSrcReg, // if <u, GR64 = GR64
783 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
784 "cmovb\t{$src2, $dst|$dst, $src2}",
785 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
786 X86_COND_B, EFLAGS))]>, TB;
787 def CMOVAE64rr: RI<0x43, MRMSrcReg, // if >=u, GR64 = GR64
788 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
789 "cmovae\t{$src2, $dst|$dst, $src2}",
790 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
791 X86_COND_AE, EFLAGS))]>, TB;
792 def CMOVE64rr : RI<0x44, MRMSrcReg, // if ==, GR64 = GR64
793 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
794 "cmove\t{$src2, $dst|$dst, $src2}",
795 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
796 X86_COND_E, EFLAGS))]>, TB;
797 def CMOVNE64rr: RI<0x45, MRMSrcReg, // if !=, GR64 = GR64
798 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
799 "cmovne\t{$src2, $dst|$dst, $src2}",
800 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
801 X86_COND_NE, EFLAGS))]>, TB;
802 def CMOVBE64rr: RI<0x46, MRMSrcReg, // if <=u, GR64 = GR64
803 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
804 "cmovbe\t{$src2, $dst|$dst, $src2}",
805 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
806 X86_COND_BE, EFLAGS))]>, TB;
807 def CMOVA64rr : RI<0x47, MRMSrcReg, // if >u, GR64 = GR64
808 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
809 "cmova\t{$src2, $dst|$dst, $src2}",
810 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
811 X86_COND_A, EFLAGS))]>, TB;
812 def CMOVL64rr : RI<0x4C, MRMSrcReg, // if <s, GR64 = GR64
813 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
814 "cmovl\t{$src2, $dst|$dst, $src2}",
815 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
816 X86_COND_L, EFLAGS))]>, TB;
817 def CMOVGE64rr: RI<0x4D, MRMSrcReg, // if >=s, GR64 = GR64
818 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
819 "cmovge\t{$src2, $dst|$dst, $src2}",
820 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
821 X86_COND_GE, EFLAGS))]>, TB;
822 def CMOVLE64rr: RI<0x4E, MRMSrcReg, // if <=s, GR64 = GR64
823 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
824 "cmovle\t{$src2, $dst|$dst, $src2}",
825 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
826 X86_COND_LE, EFLAGS))]>, TB;
827 def CMOVG64rr : RI<0x4F, MRMSrcReg, // if >s, GR64 = GR64
828 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
829 "cmovg\t{$src2, $dst|$dst, $src2}",
830 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
831 X86_COND_G, EFLAGS))]>, TB;
832 def CMOVS64rr : RI<0x48, MRMSrcReg, // if signed, GR64 = GR64
833 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
834 "cmovs\t{$src2, $dst|$dst, $src2}",
835 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
836 X86_COND_S, EFLAGS))]>, TB;
837 def CMOVNS64rr: RI<0x49, MRMSrcReg, // if !signed, GR64 = GR64
838 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
839 "cmovns\t{$src2, $dst|$dst, $src2}",
840 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
841 X86_COND_NS, EFLAGS))]>, TB;
842 def CMOVP64rr : RI<0x4A, MRMSrcReg, // if parity, GR64 = GR64
843 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
844 "cmovp\t{$src2, $dst|$dst, $src2}",
845 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
846 X86_COND_P, EFLAGS))]>, TB;
847 def CMOVNP64rr : RI<0x4B, MRMSrcReg, // if !parity, GR64 = GR64
848 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
849 "cmovnp\t{$src2, $dst|$dst, $src2}",
850 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
851 X86_COND_NP, EFLAGS))]>, TB;
852 } // isCommutable = 1
854 def CMOVB64rm : RI<0x42, MRMSrcMem, // if <u, GR64 = [mem64]
855 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
856 "cmovb\t{$src2, $dst|$dst, $src2}",
857 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
858 X86_COND_B, EFLAGS))]>, TB;
859 def CMOVAE64rm: RI<0x43, MRMSrcMem, // if >=u, GR64 = [mem64]
860 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
861 "cmovae\t{$src2, $dst|$dst, $src2}",
862 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
863 X86_COND_AE, EFLAGS))]>, TB;
864 def CMOVE64rm : RI<0x44, MRMSrcMem, // if ==, GR64 = [mem64]
865 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
866 "cmove\t{$src2, $dst|$dst, $src2}",
867 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
868 X86_COND_E, EFLAGS))]>, TB;
869 def CMOVNE64rm: RI<0x45, MRMSrcMem, // if !=, GR64 = [mem64]
870 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
871 "cmovne\t{$src2, $dst|$dst, $src2}",
872 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
873 X86_COND_NE, EFLAGS))]>, TB;
874 def CMOVBE64rm: RI<0x46, MRMSrcMem, // if <=u, GR64 = [mem64]
875 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
876 "cmovbe\t{$src2, $dst|$dst, $src2}",
877 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
878 X86_COND_BE, EFLAGS))]>, TB;
879 def CMOVA64rm : RI<0x47, MRMSrcMem, // if >u, GR64 = [mem64]
880 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
881 "cmova\t{$src2, $dst|$dst, $src2}",
882 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
883 X86_COND_A, EFLAGS))]>, TB;
884 def CMOVL64rm : RI<0x4C, MRMSrcMem, // if <s, GR64 = [mem64]
885 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
886 "cmovl\t{$src2, $dst|$dst, $src2}",
887 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
888 X86_COND_L, EFLAGS))]>, TB;
889 def CMOVGE64rm: RI<0x4D, MRMSrcMem, // if >=s, GR64 = [mem64]
890 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
891 "cmovge\t{$src2, $dst|$dst, $src2}",
892 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
893 X86_COND_GE, EFLAGS))]>, TB;
894 def CMOVLE64rm: RI<0x4E, MRMSrcMem, // if <=s, GR64 = [mem64]
895 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
896 "cmovle\t{$src2, $dst|$dst, $src2}",
897 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
898 X86_COND_LE, EFLAGS))]>, TB;
899 def CMOVG64rm : RI<0x4F, MRMSrcMem, // if >s, GR64 = [mem64]
900 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
901 "cmovg\t{$src2, $dst|$dst, $src2}",
902 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
903 X86_COND_G, EFLAGS))]>, TB;
904 def CMOVS64rm : RI<0x48, MRMSrcMem, // if signed, GR64 = [mem64]
905 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
906 "cmovs\t{$src2, $dst|$dst, $src2}",
907 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
908 X86_COND_S, EFLAGS))]>, TB;
909 def CMOVNS64rm: RI<0x49, MRMSrcMem, // if !signed, GR64 = [mem64]
910 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
911 "cmovns\t{$src2, $dst|$dst, $src2}",
912 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
913 X86_COND_NS, EFLAGS))]>, TB;
914 def CMOVP64rm : RI<0x4A, MRMSrcMem, // if parity, GR64 = [mem64]
915 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
916 "cmovp\t{$src2, $dst|$dst, $src2}",
917 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
918 X86_COND_P, EFLAGS))]>, TB;
919 def CMOVNP64rm : RI<0x4B, MRMSrcMem, // if !parity, GR64 = [mem64]
920 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
921 "cmovnp\t{$src2, $dst|$dst, $src2}",
922 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
923 X86_COND_NP, EFLAGS))]>, TB;
926 //===----------------------------------------------------------------------===//
927 // Conversion Instructions...
931 def Int_CVTSD2SI64rr: RSDI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
932 "cvtsd2si{q}\t{$src, $dst|$dst, $src}",
934 (int_x86_sse2_cvtsd2si64 VR128:$src))]>;
935 def Int_CVTSD2SI64rm: RSDI<0x2D, MRMSrcMem, (outs GR64:$dst), (ins f128mem:$src),
936 "cvtsd2si{q}\t{$src, $dst|$dst, $src}",
937 [(set GR64:$dst, (int_x86_sse2_cvtsd2si64
938 (load addr:$src)))]>;
939 def CVTTSD2SI64rr: RSDI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins FR64:$src),
940 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
941 [(set GR64:$dst, (fp_to_sint FR64:$src))]>;
942 def CVTTSD2SI64rm: RSDI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f64mem:$src),
943 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
944 [(set GR64:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
945 def Int_CVTTSD2SI64rr: RSDI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
946 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
948 (int_x86_sse2_cvttsd2si64 VR128:$src))]>;
949 def Int_CVTTSD2SI64rm: RSDI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f128mem:$src),
950 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
952 (int_x86_sse2_cvttsd2si64
953 (load addr:$src)))]>;
956 def CVTSI2SD64rr: RSDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src),
957 "cvtsi2sd{q}\t{$src, $dst|$dst, $src}",
958 [(set FR64:$dst, (sint_to_fp GR64:$src))]>;
959 def CVTSI2SD64rm: RSDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i64mem:$src),
960 "cvtsi2sd{q}\t{$src, $dst|$dst, $src}",
961 [(set FR64:$dst, (sint_to_fp (loadi64 addr:$src)))]>;
962 let isTwoAddress = 1 in {
963 def Int_CVTSI2SD64rr: RSDI<0x2A, MRMSrcReg,
964 (outs VR128:$dst), (ins VR128:$src1, GR64:$src2),
965 "cvtsi2sd{q}\t{$src2, $dst|$dst, $src2}",
967 (int_x86_sse2_cvtsi642sd VR128:$src1,
969 def Int_CVTSI2SD64rm: RSDI<0x2A, MRMSrcMem,
970 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
971 "cvtsi2sd{q}\t{$src2, $dst|$dst, $src2}",
973 (int_x86_sse2_cvtsi642sd VR128:$src1,
974 (loadi64 addr:$src2)))]>;
978 def CVTSI2SS64rr: RSSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR64:$src),
979 "cvtsi2ss{q}\t{$src, $dst|$dst, $src}",
980 [(set FR32:$dst, (sint_to_fp GR64:$src))]>;
981 def CVTSI2SS64rm: RSSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i64mem:$src),
982 "cvtsi2ss{q}\t{$src, $dst|$dst, $src}",
983 [(set FR32:$dst, (sint_to_fp (loadi64 addr:$src)))]>;
984 let isTwoAddress = 1 in {
985 def Int_CVTSI2SS64rr: RSSI<0x2A, MRMSrcReg,
986 (outs VR128:$dst), (ins VR128:$src1, GR64:$src2),
987 "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}",
988 []>; // TODO: add intrinsic
989 def Int_CVTSI2SS64rm: RSSI<0x2A, MRMSrcMem,
990 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
991 "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}",
992 []>; // TODO: add intrinsic
996 def Int_CVTSS2SI64rr: RSSI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
997 "cvtss2si{q}\t{$src, $dst|$dst, $src}",
999 (int_x86_sse_cvtss2si64 VR128:$src))]>;
1000 def Int_CVTSS2SI64rm: RSSI<0x2D, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src),
1001 "cvtss2si{q}\t{$src, $dst|$dst, $src}",
1002 [(set GR64:$dst, (int_x86_sse_cvtss2si64
1003 (load addr:$src)))]>;
1004 def CVTTSS2SI64rr: RSSI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins FR32:$src),
1005 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
1006 [(set GR64:$dst, (fp_to_sint FR32:$src))]>;
1007 def CVTTSS2SI64rm: RSSI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src),
1008 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
1009 [(set GR64:$dst, (fp_to_sint (loadf32 addr:$src)))]>;
1010 def Int_CVTTSS2SI64rr: RSSI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
1011 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
1013 (int_x86_sse_cvttss2si64 VR128:$src))]>;
1014 def Int_CVTTSS2SI64rm: RSSI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src),
1015 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
1017 (int_x86_sse_cvttss2si64 (load addr:$src)))]>;
1019 let isTwoAddress = 1 in {
1020 def Int_CVTSI642SSrr : RSSI<0x2A, MRMSrcReg,
1021 (outs VR128:$dst), (ins VR128:$src1, GR64:$src2),
1022 "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}",
1024 (int_x86_sse_cvtsi642ss VR128:$src1,
1026 def Int_CVTSI642SSrm : RSSI<0x2A, MRMSrcMem,
1027 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
1028 "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}",
1030 (int_x86_sse_cvtsi642ss VR128:$src1,
1031 (loadi64 addr:$src2)))]>;
1034 //===----------------------------------------------------------------------===//
1035 // Alias Instructions
1036 //===----------------------------------------------------------------------===//
1039 // TODO: Remove this after proper i32 -> i64 zext support.
1040 def PsMOVZX64rr32: I<0x89, MRMDestReg, (outs GR64:$dst), (ins GR32:$src),
1041 "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
1042 [(set GR64:$dst, (zext GR32:$src))]>;
1043 def PsMOVZX64rm32: I<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i32mem:$src),
1044 "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
1045 [(set GR64:$dst, (zextloadi64i32 addr:$src))]>;
1048 // Alias instructions that map movr0 to xor. Use xorl instead of xorq; it's
1049 // equivalent due to implicit zero-extending, and it sometimes has a smaller
1051 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
1052 // FIXME: AddedComplexity gives MOV64r0 a higher priority than MOV64ri32. Remove
1053 // when we have a better way to specify isel priority.
1054 let Defs = [EFLAGS], AddedComplexity = 1, isReMaterializable = 1 in
1055 def MOV64r0 : RI<0x31, MRMInitReg, (outs GR64:$dst), (ins),
1056 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
1057 [(set GR64:$dst, 0)]>;
1059 // Materialize i64 constant where top 32-bits are zero.
1060 let AddedComplexity = 1, isReMaterializable = 1 in
1061 def MOV64ri64i32 : Ii32<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64i32imm:$src),
1062 "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
1063 [(set GR64:$dst, i64immZExt32:$src)]>;
1065 //===----------------------------------------------------------------------===//
1066 // Non-Instruction Patterns
1067 //===----------------------------------------------------------------------===//
1069 // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
1070 def : Pat<(i64 (X86Wrapper tconstpool :$dst)),
1071 (MOV64ri tconstpool :$dst)>, Requires<[NotSmallCode]>;
1072 def : Pat<(i64 (X86Wrapper tjumptable :$dst)),
1073 (MOV64ri tjumptable :$dst)>, Requires<[NotSmallCode]>;
1074 def : Pat<(i64 (X86Wrapper tglobaladdr :$dst)),
1075 (MOV64ri tglobaladdr :$dst)>, Requires<[NotSmallCode]>;
1076 def : Pat<(i64 (X86Wrapper texternalsym:$dst)),
1077 (MOV64ri texternalsym:$dst)>, Requires<[NotSmallCode]>;
1079 def : Pat<(store (i64 (X86Wrapper tconstpool:$src)), addr:$dst),
1080 (MOV64mi32 addr:$dst, tconstpool:$src)>,
1081 Requires<[SmallCode, HasLow4G, IsStatic]>;
1082 def : Pat<(store (i64 (X86Wrapper tjumptable:$src)), addr:$dst),
1083 (MOV64mi32 addr:$dst, tjumptable:$src)>,
1084 Requires<[SmallCode, HasLow4G, IsStatic]>;
1085 def : Pat<(store (i64 (X86Wrapper tglobaladdr:$src)), addr:$dst),
1086 (MOV64mi32 addr:$dst, tglobaladdr:$src)>,
1087 Requires<[SmallCode, HasLow4G, IsStatic]>;
1088 def : Pat<(store (i64 (X86Wrapper texternalsym:$src)), addr:$dst),
1089 (MOV64mi32 addr:$dst, texternalsym:$src)>,
1090 Requires<[SmallCode, HasLow4G, IsStatic]>;
1093 // Direct PC relative function call for small code model. 32-bit displacement
1094 // sign extended to 64-bit.
1095 def : Pat<(X86call (i64 tglobaladdr:$dst)),
1096 (CALL64pcrel32 tglobaladdr:$dst)>;
1097 def : Pat<(X86call (i64 texternalsym:$dst)),
1098 (CALL64pcrel32 texternalsym:$dst)>;
1100 def : Pat<(X86tailcall (i64 tglobaladdr:$dst)),
1101 (CALL64pcrel32 tglobaladdr:$dst)>;
1102 def : Pat<(X86tailcall (i64 texternalsym:$dst)),
1103 (CALL64pcrel32 texternalsym:$dst)>;
1105 def : Pat<(X86tailcall GR64:$dst),
1106 (CALL64r GR64:$dst)>;
1110 // TEST R,R is smaller than CMP R,0
1111 def : Pat<(parallel (X86cmp GR64:$src1, 0), (implicit EFLAGS)),
1112 (TEST64rr GR64:$src1, GR64:$src1)>;
1114 // {s|z}extload bool -> {s|z}extload byte
1115 def : Pat<(sextloadi64i1 addr:$src), (MOVSX64rm8 addr:$src)>;
1116 def : Pat<(zextloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>;
1119 def : Pat<(extloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>;
1120 def : Pat<(extloadi64i8 addr:$src), (MOVZX64rm8 addr:$src)>;
1121 def : Pat<(extloadi64i16 addr:$src), (MOVZX64rm16 addr:$src)>;
1122 def : Pat<(extloadi64i32 addr:$src), (PsMOVZX64rm32 addr:$src)>;
1125 def : Pat<(i64 (anyext GR8 :$src)), (MOVZX64rr8 GR8 :$src)>;
1126 def : Pat<(i64 (anyext GR16:$src)), (MOVZX64rr16 GR16:$src)>;
1127 def : Pat<(i64 (anyext GR32:$src)), (PsMOVZX64rr32 GR32:$src)>;
1128 def : Pat<(i64 (anyext (loadi8 addr:$src))), (MOVZX64rm8 addr:$src)>;
1129 def : Pat<(i64 (anyext (loadi16 addr:$src))), (MOVZX64rm16 addr:$src)>;
1130 def : Pat<(i64 (anyext (loadi32 addr:$src))), (PsMOVZX64rm32 addr:$src)>;
1132 //===----------------------------------------------------------------------===//
1134 //===----------------------------------------------------------------------===//
1136 // (shl x, 1) ==> (add x, x)
1137 def : Pat<(shl GR64:$src1, (i8 1)), (ADD64rr GR64:$src1, GR64:$src1)>;
1139 // (or (x >> c) | (y << (64 - c))) ==> (shrd64 x, y, c)
1140 def : Pat<(or (srl GR64:$src1, CL:$amt),
1141 (shl GR64:$src2, (sub 64, CL:$amt))),
1142 (SHRD64rrCL GR64:$src1, GR64:$src2)>;
1144 def : Pat<(store (or (srl (loadi64 addr:$dst), CL:$amt),
1145 (shl GR64:$src2, (sub 64, CL:$amt))), addr:$dst),
1146 (SHRD64mrCL addr:$dst, GR64:$src2)>;
1148 // (or (x << c) | (y >> (64 - c))) ==> (shld64 x, y, c)
1149 def : Pat<(or (shl GR64:$src1, CL:$amt),
1150 (srl GR64:$src2, (sub 64, CL:$amt))),
1151 (SHLD64rrCL GR64:$src1, GR64:$src2)>;
1153 def : Pat<(store (or (shl (loadi64 addr:$dst), CL:$amt),
1154 (srl GR64:$src2, (sub 64, CL:$amt))), addr:$dst),
1155 (SHLD64mrCL addr:$dst, GR64:$src2)>;
1157 // X86 specific add which produces a flag.
1158 def : Pat<(addc GR64:$src1, GR64:$src2),
1159 (ADD64rr GR64:$src1, GR64:$src2)>;
1160 def : Pat<(addc GR64:$src1, (load addr:$src2)),
1161 (ADD64rm GR64:$src1, addr:$src2)>;
1162 def : Pat<(addc GR64:$src1, i64immSExt32:$src2),
1163 (ADD64ri32 GR64:$src1, imm:$src2)>;
1164 def : Pat<(addc GR64:$src1, i64immSExt8:$src2),
1165 (ADD64ri8 GR64:$src1, i64immSExt8:$src2)>;
1167 def : Pat<(subc GR64:$src1, GR64:$src2),
1168 (SUB64rr GR64:$src1, GR64:$src2)>;
1169 def : Pat<(subc GR64:$src1, (load addr:$src2)),
1170 (SUB64rm GR64:$src1, addr:$src2)>;
1171 def : Pat<(subc GR64:$src1, imm:$src2),
1172 (SUB64ri32 GR64:$src1, i64immSExt32:$src2)>;
1173 def : Pat<(subc GR64:$src1, i64immSExt8:$src2),
1174 (SUB64ri8 GR64:$src1, i64immSExt8:$src2)>;
1177 //===----------------------------------------------------------------------===//
1178 // X86-64 SSE Instructions
1179 //===----------------------------------------------------------------------===//
1181 // Move instructions...
1183 def MOV64toPQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
1184 "mov{d|q}\t{$src, $dst|$dst, $src}",
1186 (v2i64 (scalar_to_vector GR64:$src)))]>;
1187 def MOV64toPQIrm : RPDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
1188 "mov{d|q}\t{$src, $dst|$dst, $src}",
1190 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>;
1192 def MOVPQIto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins VR128:$src),
1193 "mov{d|q}\t{$src, $dst|$dst, $src}",
1194 [(set GR64:$dst, (vector_extract (v2i64 VR128:$src),
1196 def MOVPQIto64mr : RPDI<0x7E, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
1197 "mov{d|q}\t{$src, $dst|$dst, $src}",
1198 [(store (i64 (vector_extract (v2i64 VR128:$src),
1199 (iPTR 0))), addr:$dst)]>;
1201 def MOV64toSDrr : RPDI<0x6E, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src),
1202 "mov{d|q}\t{$src, $dst|$dst, $src}",
1203 [(set FR64:$dst, (bitconvert GR64:$src))]>;
1204 def MOV64toSDrm : RPDI<0x6E, MRMSrcMem, (outs FR64:$dst), (ins i64mem:$src),
1205 "mov{d|q}\t{$src, $dst|$dst, $src}",
1206 [(set FR64:$dst, (bitconvert (loadi64 addr:$src)))]>;
1208 def MOVSDto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins FR64:$src),
1209 "mov{d|q}\t{$src, $dst|$dst, $src}",
1210 [(set GR64:$dst, (bitconvert FR64:$src))]>;
1211 def MOVSDto64mr : RPDI<0x7E, MRMDestMem, (outs), (ins i64mem:$dst, FR64:$src),
1212 "mov{d|q}\t{$src, $dst|$dst, $src}",
1213 [(store (i64 (bitconvert FR64:$src)), addr:$dst)]>;