blob: 89d952a5b0523962446c9b02f4a9b18c26af12c7 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//====- X86InstrX86-64.td - Describe the X86 Instruction Set ----*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
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.
7//
8//===----------------------------------------------------------------------===//
9//
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.
13//
14//===----------------------------------------------------------------------===//
15
16//===----------------------------------------------------------------------===//
17// Operand Definitions...
18//
19
20// 64-bits but only 32 bits are significant.
21def i64i32imm : Operand<i64>;
22// 64-bits but only 8 bits are significant.
23def i64i8imm : Operand<i64>;
24
25def lea64mem : Operand<i64> {
26 let PrintMethod = "printi64mem";
27 let MIOperandInfo = (ops GR64, i8imm, GR64, i32imm);
28}
29
30def lea64_32mem : Operand<i32> {
31 let PrintMethod = "printlea64_32mem";
32 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
33}
34
35//===----------------------------------------------------------------------===//
36// Complex Pattern Definitions...
37//
38def lea64addr : ComplexPattern<i64, 4, "SelectLEAAddr",
39 [add, mul, shl, or, frameindex, X86Wrapper],
40 []>;
41
42//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +000043// Pattern fragments...
44//
45
46def 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();
50}]>;
51
52def 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();
56}]>;
57
58def 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();
62}]>;
63
64def sextloadi64i1 : PatFrag<(ops node:$ptr), (i64 (sextloadi1 node:$ptr))>;
65def sextloadi64i8 : PatFrag<(ops node:$ptr), (i64 (sextloadi8 node:$ptr))>;
66def sextloadi64i16 : PatFrag<(ops node:$ptr), (i64 (sextloadi16 node:$ptr))>;
67def sextloadi64i32 : PatFrag<(ops node:$ptr), (i64 (sextloadi32 node:$ptr))>;
68
69def zextloadi64i1 : PatFrag<(ops node:$ptr), (i64 (zextloadi1 node:$ptr))>;
70def zextloadi64i8 : PatFrag<(ops node:$ptr), (i64 (zextloadi8 node:$ptr))>;
71def zextloadi64i16 : PatFrag<(ops node:$ptr), (i64 (zextloadi16 node:$ptr))>;
72def zextloadi64i32 : PatFrag<(ops node:$ptr), (i64 (zextloadi32 node:$ptr))>;
73
74def extloadi64i1 : PatFrag<(ops node:$ptr), (i64 (extloadi1 node:$ptr))>;
75def extloadi64i8 : PatFrag<(ops node:$ptr), (i64 (extloadi8 node:$ptr))>;
76def extloadi64i16 : PatFrag<(ops node:$ptr), (i64 (extloadi16 node:$ptr))>;
77def extloadi64i32 : PatFrag<(ops node:$ptr), (i64 (extloadi32 node:$ptr))>;
78
79//===----------------------------------------------------------------------===//
80// Instruction list...
81//
82
Evan Chengb783fa32007-07-19 01:14:50 +000083def IMPLICIT_DEF_GR64 : I<0, Pseudo, (outs GR64:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000084 "#IMPLICIT_DEF $dst",
85 [(set GR64:$dst, (undef))]>;
86
87//===----------------------------------------------------------------------===//
88// Call Instructions...
89//
Evan Cheng37e7c752007-07-21 00:34:19 +000090let isCall = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +000091 // 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] in {
Evan Chengb783fa32007-07-19 01:14:50 +000097 def CALL64pcrel32 : I<0xE8, RawFrm, (outs), (ins i64imm:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +000098 "call\t${dst:call}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +000099 def CALL64r : I<0xFF, MRM2r, (outs), (ins GR64:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000100 "call\t{*}$dst", [(X86call GR64:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000101 def CALL64m : I<0xFF, MRM2m, (outs), (ins i64mem:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000102 "call\t{*}$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000103 }
104
105// Branches
Evan Cheng37e7c752007-07-21 00:34:19 +0000106let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000107 def JMP64r : I<0xFF, MRM4r, (outs), (ins GR64:$dst), "jmp{q}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000108 [(brind GR64:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000109 def JMP64m : I<0xFF, MRM4m, (outs), (ins i64mem:$dst), "jmp{q}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000110 [(brind (loadi64 addr:$dst))]>;
111}
112
113//===----------------------------------------------------------------------===//
114// Miscellaneous Instructions...
115//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000116let Defs = [RBP,RSP], Uses = [RBP,RSP] in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000117def LEAVE64 : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000118 (outs), (ins), "leave", []>;
119let Defs = [RSP], Uses = [RSP] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000120def POP64r : I<0x58, AddRegFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000121 (outs GR64:$reg), (ins), "pop{q}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000122def PUSH64r : I<0x50, AddRegFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000123 (outs), (ins GR64:$reg), "push{q}\t$reg", []>;
124}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000125
126def LEA64_32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000127 (outs GR32:$dst), (ins lea64_32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000128 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000129 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In64BitMode]>;
130
Evan Chengb783fa32007-07-19 01:14:50 +0000131def LEA64r : RI<0x8D, MRMSrcMem, (outs GR64:$dst), (ins lea64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000132 "lea{q}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000133 [(set GR64:$dst, lea64addr:$src)]>;
134
135let isTwoAddress = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000136def BSWAP64r : RI<0xC8, AddRegFrm, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000137 "bswap{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000138 [(set GR64:$dst, (bswap GR64:$src))]>, TB;
139// Exchange
Evan Chengb783fa32007-07-19 01:14:50 +0000140def XCHG64rr : RI<0x87, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000141 "xchg{q}\t{$src2|$src1}, {$src1|$src2}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000142def XCHG64mr : RI<0x87, MRMDestMem, (outs), (ins i64mem:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000143 "xchg{q}\t{$src2|$src1}, {$src1|$src2}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000144def XCHG64rm : RI<0x87, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000145 "xchg{q}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000146
147// Repeat string ops
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000148let Defs = [RCX,RDI,RSI], Uses = [RCX,RDI,RSI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000149def REP_MOVSQ : RI<0xA5, RawFrm, (outs), (ins), "{rep;movsq|rep movsq}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000150 [(X86rep_movs i64)]>, REP;
151let Defs = [RCX,RDI], Uses = [RAX,RCX,RDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000152def REP_STOSQ : RI<0xAB, RawFrm, (outs), (ins), "{rep;stosq|rep stosq}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000153 [(X86rep_stos i64)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000154
155//===----------------------------------------------------------------------===//
156// Move Instructions...
157//
158
Evan Chengb783fa32007-07-19 01:14:50 +0000159def MOV64rr : RI<0x89, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000160 "mov{q}\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000161
Dan Gohman8aef09b2007-09-07 21:32:51 +0000162let isReMaterializable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000163def MOV64ri : RIi64<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000164 "movabs{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000165 [(set GR64:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000166def MOV64ri32 : RIi32<0xC7, MRM0r, (outs GR64:$dst), (ins i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000167 "mov{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000168 [(set GR64:$dst, i64immSExt32:$src)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +0000169}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000170
Evan Cheng4e84e452007-08-30 05:49:43 +0000171let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000172def MOV64rm : RI<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000173 "mov{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000174 [(set GR64:$dst, (load addr:$src))]>;
175
Evan Chengb783fa32007-07-19 01:14:50 +0000176def MOV64mr : RI<0x89, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000177 "mov{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000178 [(store GR64:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000179def MOV64mi32 : RIi32<0xC7, MRM0m, (outs), (ins i64mem:$dst, i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000180 "mov{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000181 [(store i64immSExt32:$src, addr:$dst)]>;
182
183// Sign/Zero extenders
184
Evan Chengb783fa32007-07-19 01:14:50 +0000185def MOVSX64rr8 : RI<0xBE, MRMSrcReg, (outs GR64:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000186 "movs{bq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000187 [(set GR64:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000188def MOVSX64rm8 : RI<0xBE, MRMSrcMem, (outs GR64:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000189 "movs{bq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000190 [(set GR64:$dst, (sextloadi64i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000191def MOVSX64rr16: RI<0xBF, MRMSrcReg, (outs GR64:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000192 "movs{wq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000193 [(set GR64:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000194def MOVSX64rm16: RI<0xBF, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000195 "movs{wq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000196 [(set GR64:$dst, (sextloadi64i16 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000197def MOVSX64rr32: RI<0x63, MRMSrcReg, (outs GR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000198 "movs{lq|xd}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000199 [(set GR64:$dst, (sext GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000200def MOVSX64rm32: RI<0x63, MRMSrcMem, (outs GR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000201 "movs{lq|xd}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000202 [(set GR64:$dst, (sextloadi64i32 addr:$src))]>;
203
Evan Chengb783fa32007-07-19 01:14:50 +0000204def MOVZX64rr8 : RI<0xB6, MRMSrcReg, (outs GR64:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000205 "movz{bq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000206 [(set GR64:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000207def MOVZX64rm8 : RI<0xB6, MRMSrcMem, (outs GR64:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000208 "movz{bq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000209 [(set GR64:$dst, (zextloadi64i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000210def MOVZX64rr16: RI<0xB7, MRMSrcReg, (outs GR64:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000211 "movz{wq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000212 [(set GR64:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000213def MOVZX64rm16: RI<0xB7, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000214 "movz{wq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000215 [(set GR64:$dst, (zextloadi64i16 addr:$src))]>, TB;
216
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000217let Defs = [RAX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000218def CDQE : RI<0x98, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000219 "{cltq|cdqe}", []>; // RAX = signext(EAX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000220
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000221let Defs = [RAX,RDX], Uses = [RAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000222def CQO : RI<0x99, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000223 "{cqto|cqo}", []>; // RDX:RAX = signext(RAX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000224
225//===----------------------------------------------------------------------===//
226// Arithmetic Instructions...
227//
228
Evan Cheng55687072007-09-14 21:48:26 +0000229let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000230let isTwoAddress = 1 in {
231let isConvertibleToThreeAddress = 1 in {
232let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000233def ADD64rr : RI<0x01, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000234 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000235 [(set GR64:$dst, (add GR64:$src1, GR64:$src2))]>;
236
Evan Chengb783fa32007-07-19 01:14:50 +0000237def ADD64ri32 : RIi32<0x81, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000238 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000239 [(set GR64:$dst, (add GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000240def ADD64ri8 : RIi8<0x83, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000241 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000242 [(set GR64:$dst, (add GR64:$src1, i64immSExt8:$src2))]>;
243} // isConvertibleToThreeAddress
244
Evan Chengb783fa32007-07-19 01:14:50 +0000245def ADD64rm : RI<0x03, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000246 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000247 [(set GR64:$dst, (add GR64:$src1, (load addr:$src2)))]>;
248} // isTwoAddress
249
Evan Chengb783fa32007-07-19 01:14:50 +0000250def ADD64mr : RI<0x01, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000251 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000252 [(store (add (load addr:$dst), GR64:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000253def ADD64mi32 : RIi32<0x81, MRM0m, (outs), (ins i64mem:$dst, i64i32imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000254 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000255 [(store (add (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000256def ADD64mi8 : RIi8<0x83, MRM0m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000257 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000258 [(store (add (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
259
260let isTwoAddress = 1 in {
261let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000262def ADC64rr : RI<0x11, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000263 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000264 [(set GR64:$dst, (adde GR64:$src1, GR64:$src2))]>;
265
Evan Chengb783fa32007-07-19 01:14:50 +0000266def ADC64rm : RI<0x13, MRMSrcMem , (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000267 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000268 [(set GR64:$dst, (adde GR64:$src1, (load addr:$src2)))]>;
269
Evan Chengb783fa32007-07-19 01:14:50 +0000270def ADC64ri32 : RIi32<0x81, MRM2r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000271 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000272 [(set GR64:$dst, (adde GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000273def ADC64ri8 : RIi8<0x83, MRM2r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000274 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000275 [(set GR64:$dst, (adde GR64:$src1, i64immSExt8:$src2))]>;
276} // isTwoAddress
277
Evan Chengb783fa32007-07-19 01:14:50 +0000278def ADC64mr : RI<0x11, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000279 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000280 [(store (adde (load addr:$dst), GR64:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000281def ADC64mi32 : RIi32<0x81, MRM2m, (outs), (ins i64mem:$dst, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000282 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000283 [(store (adde (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000284def ADC64mi8 : RIi8<0x83, MRM2m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000285 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000286 [(store (adde (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
287
288let isTwoAddress = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000289def SUB64rr : RI<0x29, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000290 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000291 [(set GR64:$dst, (sub GR64:$src1, GR64:$src2))]>;
292
Evan Chengb783fa32007-07-19 01:14:50 +0000293def SUB64rm : RI<0x2B, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000294 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000295 [(set GR64:$dst, (sub GR64:$src1, (load addr:$src2)))]>;
296
Evan Chengb783fa32007-07-19 01:14:50 +0000297def SUB64ri32 : RIi32<0x81, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000298 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000299 [(set GR64:$dst, (sub GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000300def SUB64ri8 : RIi8<0x83, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000301 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000302 [(set GR64:$dst, (sub GR64:$src1, i64immSExt8:$src2))]>;
303} // isTwoAddress
304
Evan Chengb783fa32007-07-19 01:14:50 +0000305def SUB64mr : RI<0x29, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000306 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000307 [(store (sub (load addr:$dst), GR64:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000308def SUB64mi32 : RIi32<0x81, MRM5m, (outs), (ins i64mem:$dst, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000309 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000310 [(store (sub (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000311def SUB64mi8 : RIi8<0x83, MRM5m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000312 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000313 [(store (sub (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
314
315let isTwoAddress = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000316def SBB64rr : RI<0x19, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000317 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000318 [(set GR64:$dst, (sube GR64:$src1, GR64:$src2))]>;
319
Evan Chengb783fa32007-07-19 01:14:50 +0000320def SBB64rm : RI<0x1B, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000321 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000322 [(set GR64:$dst, (sube GR64:$src1, (load addr:$src2)))]>;
323
Evan Chengb783fa32007-07-19 01:14:50 +0000324def SBB64ri32 : RIi32<0x81, MRM3r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000325 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000326 [(set GR64:$dst, (sube GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000327def SBB64ri8 : RIi8<0x83, MRM3r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000328 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000329 [(set GR64:$dst, (sube GR64:$src1, i64immSExt8:$src2))]>;
330} // isTwoAddress
331
Evan Chengb783fa32007-07-19 01:14:50 +0000332def SBB64mr : RI<0x19, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000333 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000334 [(store (sube (load addr:$dst), GR64:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000335def SBB64mi32 : RIi32<0x81, MRM3m, (outs), (ins i64mem:$dst, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000336 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000337 [(store (sube (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000338def SBB64mi8 : RIi8<0x83, MRM3m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000339 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000340 [(store (sube (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000341} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000342
343// Unsigned multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000344let Defs = [RAX,RDX,EFLAGS], Uses = [RAX] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000345def MUL64r : RI<0xF7, MRM4r, (outs), (ins GR64:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000346 "mul{q}\t$src", []>; // RAX,RDX = RAX*GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000347def MUL64m : RI<0xF7, MRM4m, (outs), (ins i64mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000348 "mul{q}\t$src", []>; // RAX,RDX = RAX*[mem64]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000349
350// Signed multiplication
Evan Chengb783fa32007-07-19 01:14:50 +0000351def IMUL64r : RI<0xF7, MRM5r, (outs), (ins GR64:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000352 "imul{q}\t$src", []>; // RAX,RDX = RAX*GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000353def IMUL64m : RI<0xF7, MRM5m, (outs), (ins i64mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000354 "imul{q}\t$src", []>; // RAX,RDX = RAX*[mem64]
355}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000356
Evan Cheng55687072007-09-14 21:48:26 +0000357let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000358let isTwoAddress = 1 in {
359let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000360def IMUL64rr : RI<0xAF, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000361 "imul{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000362 [(set GR64:$dst, (mul GR64:$src1, GR64:$src2))]>, TB;
363
Evan Chengb783fa32007-07-19 01:14:50 +0000364def IMUL64rm : RI<0xAF, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000365 "imul{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000366 [(set GR64:$dst, (mul GR64:$src1, (load addr:$src2)))]>, TB;
367} // isTwoAddress
368
369// Suprisingly enough, these are not two address instructions!
370def IMUL64rri32 : RIi32<0x69, MRMSrcReg, // GR64 = GR64*I32
Evan Chengb783fa32007-07-19 01:14:50 +0000371 (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000372 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000373 [(set GR64:$dst, (mul GR64:$src1, i64immSExt32:$src2))]>;
374def IMUL64rri8 : RIi8<0x6B, MRMSrcReg, // GR64 = GR64*I8
Evan Chengb783fa32007-07-19 01:14:50 +0000375 (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000376 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000377 [(set GR64:$dst, (mul GR64:$src1, i64immSExt8:$src2))]>;
378def IMUL64rmi32 : RIi32<0x69, MRMSrcMem, // GR64 = [mem64]*I32
Evan Chengb783fa32007-07-19 01:14:50 +0000379 (outs GR64:$dst), (ins i64mem:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000380 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000381 [(set GR64:$dst, (mul (load addr:$src1), i64immSExt32:$src2))]>;
382def IMUL64rmi8 : RIi8<0x6B, MRMSrcMem, // GR64 = [mem64]*I8
Evan Chengb783fa32007-07-19 01:14:50 +0000383 (outs GR64:$dst), (ins i64mem:$src1, i64i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000384 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000385 [(set GR64:$dst, (mul (load addr:$src1), i64immSExt8:$src2))]>;
Evan Cheng55687072007-09-14 21:48:26 +0000386} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000387
388// Unsigned division / remainder
Evan Cheng55687072007-09-14 21:48:26 +0000389let Defs = [RAX,RDX,EFLAGS], Uses = [RAX,RDX] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000390def DIV64r : RI<0xF7, MRM6r, (outs), (ins GR64:$src), // RDX:RAX/r64 = RAX,RDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000391 "div{q}\t$src", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000392def DIV64m : RI<0xF7, MRM6m, (outs), (ins i64mem:$src), // RDX:RAX/[mem64] = RAX,RDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000393 "div{q}\t$src", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000394
395// Signed division / remainder
Evan Chengb783fa32007-07-19 01:14:50 +0000396def IDIV64r: RI<0xF7, MRM7r, (outs), (ins GR64:$src), // RDX:RAX/r64 = RAX,RDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000397 "idiv{q}\t$src", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000398def IDIV64m: RI<0xF7, MRM7m, (outs), (ins i64mem:$src), // RDX:RAX/[mem64] = RAX,RDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000399 "idiv{q}\t$src", []>;
400}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000401
402// Unary instructions
Evan Cheng55687072007-09-14 21:48:26 +0000403let Defs = [EFLAGS], CodeSize = 2 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000404let isTwoAddress = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000405def NEG64r : RI<0xF7, MRM3r, (outs GR64:$dst), (ins GR64:$src), "neg{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000406 [(set GR64:$dst, (ineg GR64:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000407def NEG64m : RI<0xF7, MRM3m, (outs), (ins i64mem:$dst), "neg{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000408 [(store (ineg (loadi64 addr:$dst)), addr:$dst)]>;
409
410let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000411def INC64r : RI<0xFF, MRM0r, (outs GR64:$dst), (ins GR64:$src), "inc{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000412 [(set GR64:$dst, (add GR64:$src, 1))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000413def INC64m : RI<0xFF, MRM0m, (outs), (ins i64mem:$dst), "inc{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000414 [(store (add (loadi64 addr:$dst), 1), addr:$dst)]>;
415
416let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000417def DEC64r : RI<0xFF, MRM1r, (outs GR64:$dst), (ins GR64:$src), "dec{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000418 [(set GR64:$dst, (add GR64:$src, -1))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000419def DEC64m : RI<0xFF, MRM1m, (outs), (ins i64mem:$dst), "dec{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000420 [(store (add (loadi64 addr:$dst), -1), addr:$dst)]>;
421
422// In 64-bit mode, single byte INC and DEC cannot be encoded.
423let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in {
424// Can transform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +0000425def INC64_16r : I<0xFF, MRM0r, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000426 [(set GR16:$dst, (add GR16:$src, 1))]>,
427 OpSize, Requires<[In64BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000428def INC64_32r : I<0xFF, MRM0r, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000429 [(set GR32:$dst, (add GR32:$src, 1))]>,
430 Requires<[In64BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000431def DEC64_16r : I<0xFF, MRM1r, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000432 [(set GR16:$dst, (add GR16:$src, -1))]>,
433 OpSize, Requires<[In64BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000434def DEC64_32r : I<0xFF, MRM1r, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000435 [(set GR32:$dst, (add GR32:$src, -1))]>,
436 Requires<[In64BitMode]>;
437} // isConvertibleToThreeAddress
Evan Cheng55687072007-09-14 21:48:26 +0000438} // Defs = [EFLAGS], CodeSize
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000439
440
Evan Cheng55687072007-09-14 21:48:26 +0000441let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000442// Shift instructions
443let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000444let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000445def SHL64rCL : RI<0xD3, MRM4r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000446 "shl{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000447 [(set GR64:$dst, (shl GR64:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000448def SHL64ri : RIi8<0xC1, MRM4r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000449 "shl{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000450 [(set GR64:$dst, (shl GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000451def SHL64r1 : RI<0xD1, MRM4r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000452 "shl{q}\t$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000453} // isTwoAddress
454
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000455let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000456def SHL64mCL : RI<0xD3, MRM4m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000457 "shl{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000458 [(store (shl (loadi64 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000459def SHL64mi : RIi8<0xC1, MRM4m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000460 "shl{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000461 [(store (shl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000462def SHL64m1 : RI<0xD1, MRM4m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000463 "shl{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000464 [(store (shl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
465
466let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000467let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000468def SHR64rCL : RI<0xD3, MRM5r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000469 "shr{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000470 [(set GR64:$dst, (srl GR64:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000471def SHR64ri : RIi8<0xC1, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000472 "shr{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000473 [(set GR64:$dst, (srl GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000474def SHR64r1 : RI<0xD1, MRM5r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000475 "shr{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000476 [(set GR64:$dst, (srl GR64:$src1, (i8 1)))]>;
477} // isTwoAddress
478
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000479let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000480def SHR64mCL : RI<0xD3, MRM5m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000481 "shr{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000482 [(store (srl (loadi64 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000483def SHR64mi : RIi8<0xC1, MRM5m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000484 "shr{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000485 [(store (srl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000486def SHR64m1 : RI<0xD1, MRM5m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000487 "shr{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000488 [(store (srl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
489
490let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000491let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000492def SAR64rCL : RI<0xD3, MRM7r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000493 "sar{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000494 [(set GR64:$dst, (sra GR64:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000495def SAR64ri : RIi8<0xC1, MRM7r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000496 "sar{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000497 [(set GR64:$dst, (sra GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000498def SAR64r1 : RI<0xD1, MRM7r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000499 "sar{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000500 [(set GR64:$dst, (sra GR64:$src1, (i8 1)))]>;
501} // isTwoAddress
502
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000503let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000504def SAR64mCL : RI<0xD3, MRM7m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000505 "sar{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000506 [(store (sra (loadi64 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000507def SAR64mi : RIi8<0xC1, MRM7m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000508 "sar{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000509 [(store (sra (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000510def SAR64m1 : RI<0xD1, MRM7m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000511 "sar{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000512 [(store (sra (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
513
514// Rotate instructions
515let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000516let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000517def ROL64rCL : RI<0xD3, MRM0r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000518 "rol{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000519 [(set GR64:$dst, (rotl GR64:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000520def ROL64ri : RIi8<0xC1, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000521 "rol{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000522 [(set GR64:$dst, (rotl GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000523def ROL64r1 : RI<0xD1, MRM0r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000524 "rol{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000525 [(set GR64:$dst, (rotl GR64:$src1, (i8 1)))]>;
526} // isTwoAddress
527
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000528let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000529def ROL64mCL : I<0xD3, MRM0m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000530 "rol{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000531 [(store (rotl (loadi64 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000532def ROL64mi : RIi8<0xC1, MRM0m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000533 "rol{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000534 [(store (rotl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000535def ROL64m1 : RI<0xD1, MRM0m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000536 "rol{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000537 [(store (rotl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
538
539let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000540let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000541def ROR64rCL : RI<0xD3, MRM1r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000542 "ror{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000543 [(set GR64:$dst, (rotr GR64:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000544def ROR64ri : RIi8<0xC1, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000545 "ror{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000546 [(set GR64:$dst, (rotr GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000547def ROR64r1 : RI<0xD1, MRM1r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000548 "ror{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000549 [(set GR64:$dst, (rotr GR64:$src1, (i8 1)))]>;
550} // isTwoAddress
551
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000552let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000553def ROR64mCL : RI<0xD3, MRM1m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000554 "ror{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000555 [(store (rotr (loadi64 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000556def ROR64mi : RIi8<0xC1, MRM1m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000557 "ror{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000558 [(store (rotr (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000559def ROR64m1 : RI<0xD1, MRM1m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000560 "ror{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000561 [(store (rotr (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
562
563// Double shift instructions (generalizations of rotate)
564let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000565let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000566def SHLD64rrCL : RI<0xA5, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000567 "shld{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
568 [(set GR64:$dst, (X86shld GR64:$src1, GR64:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000569def SHRD64rrCL : RI<0xAD, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000570 "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
571 [(set GR64:$dst, (X86shrd GR64:$src1, GR64:$src2, CL))]>, TB;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000572}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000573
574let isCommutable = 1 in { // FIXME: Update X86InstrInfo::commuteInstruction
575def SHLD64rri8 : RIi8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000576 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2, i8imm:$src3),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000577 "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
578 [(set GR64:$dst, (X86shld GR64:$src1, GR64:$src2,
579 (i8 imm:$src3)))]>,
580 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000581def SHRD64rri8 : RIi8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000582 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2, i8imm:$src3),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000583 "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
584 [(set GR64:$dst, (X86shrd GR64:$src1, GR64:$src2,
585 (i8 imm:$src3)))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000586 TB;
587} // isCommutable
588} // isTwoAddress
589
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000590let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000591def SHLD64mrCL : RI<0xA5, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000592 "shld{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
593 [(store (X86shld (loadi64 addr:$dst), GR64:$src2, CL),
594 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000595def SHRD64mrCL : RI<0xAD, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000596 "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
597 [(store (X86shrd (loadi64 addr:$dst), GR64:$src2, CL),
598 addr:$dst)]>, TB;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000599}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000600def SHLD64mri8 : RIi8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000601 (outs), (ins i64mem:$dst, GR64:$src2, i8imm:$src3),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000602 "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
603 [(store (X86shld (loadi64 addr:$dst), GR64:$src2,
604 (i8 imm:$src3)), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000605 TB;
606def SHRD64mri8 : RIi8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000607 (outs), (ins i64mem:$dst, GR64:$src2, i8imm:$src3),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000608 "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
609 [(store (X86shrd (loadi64 addr:$dst), GR64:$src2,
610 (i8 imm:$src3)), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000611 TB;
Evan Cheng55687072007-09-14 21:48:26 +0000612} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000613
614//===----------------------------------------------------------------------===//
615// Logical Instructions...
616//
617
618let isTwoAddress = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000619def NOT64r : RI<0xF7, MRM2r, (outs GR64:$dst), (ins GR64:$src), "not{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000620 [(set GR64:$dst, (not GR64:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000621def NOT64m : RI<0xF7, MRM2m, (outs), (ins i64mem:$dst), "not{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000622 [(store (not (loadi64 addr:$dst)), addr:$dst)]>;
623
Evan Cheng55687072007-09-14 21:48:26 +0000624let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000625let isTwoAddress = 1 in {
626let isCommutable = 1 in
627def AND64rr : RI<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000628 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000629 "and{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000630 [(set GR64:$dst, (and GR64:$src1, GR64:$src2))]>;
631def AND64rm : RI<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000632 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000633 "and{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000634 [(set GR64:$dst, (and GR64:$src1, (load addr:$src2)))]>;
635def AND64ri32 : RIi32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +0000636 (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000637 "and{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000638 [(set GR64:$dst, (and GR64:$src1, i64immSExt32:$src2))]>;
639def AND64ri8 : RIi8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +0000640 (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000641 "and{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000642 [(set GR64:$dst, (and GR64:$src1, i64immSExt8:$src2))]>;
643} // isTwoAddress
644
645def AND64mr : RI<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000646 (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000647 "and{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000648 [(store (and (load addr:$dst), GR64:$src), addr:$dst)]>;
649def AND64mi32 : RIi32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +0000650 (outs), (ins i64mem:$dst, i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000651 "and{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000652 [(store (and (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>;
653def AND64mi8 : RIi8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +0000654 (outs), (ins i64mem:$dst, i64i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000655 "and{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000656 [(store (and (load addr:$dst), i64immSExt8:$src), addr:$dst)]>;
657
658let isTwoAddress = 1 in {
659let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000660def OR64rr : RI<0x09, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000661 "or{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000662 [(set GR64:$dst, (or GR64:$src1, GR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000663def OR64rm : RI<0x0B, MRMSrcMem , (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000664 "or{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000665 [(set GR64:$dst, (or GR64:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000666def OR64ri32 : RIi32<0x81, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000667 "or{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000668 [(set GR64:$dst, (or GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000669def OR64ri8 : RIi8<0x83, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000670 "or{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000671 [(set GR64:$dst, (or GR64:$src1, i64immSExt8:$src2))]>;
672} // isTwoAddress
673
Evan Chengb783fa32007-07-19 01:14:50 +0000674def OR64mr : RI<0x09, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000675 "or{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000676 [(store (or (load addr:$dst), GR64:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000677def OR64mi32 : RIi32<0x81, MRM1m, (outs), (ins i64mem:$dst, i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000678 "or{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000679 [(store (or (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000680def OR64mi8 : RIi8<0x83, MRM1m, (outs), (ins i64mem:$dst, i64i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000681 "or{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000682 [(store (or (load addr:$dst), i64immSExt8:$src), addr:$dst)]>;
683
684let isTwoAddress = 1 in {
685let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000686def XOR64rr : RI<0x31, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000687 "xor{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000688 [(set GR64:$dst, (xor GR64:$src1, GR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000689def XOR64rm : RI<0x33, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000690 "xor{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000691 [(set GR64:$dst, (xor GR64:$src1, (load addr:$src2)))]>;
692def XOR64ri32 : RIi32<0x81, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +0000693 (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000694 "xor{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000695 [(set GR64:$dst, (xor GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000696def XOR64ri8 : RIi8<0x83, MRM6r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000697 "xor{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000698 [(set GR64:$dst, (xor GR64:$src1, i64immSExt8:$src2))]>;
699} // isTwoAddress
700
Evan Chengb783fa32007-07-19 01:14:50 +0000701def XOR64mr : RI<0x31, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000702 "xor{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000703 [(store (xor (load addr:$dst), GR64:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000704def XOR64mi32 : RIi32<0x81, MRM6m, (outs), (ins i64mem:$dst, i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000705 "xor{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000706 [(store (xor (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000707def XOR64mi8 : RIi8<0x83, MRM6m, (outs), (ins i64mem:$dst, i64i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000708 "xor{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000709 [(store (xor (load addr:$dst), i64immSExt8:$src), addr:$dst)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000710} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000711
712//===----------------------------------------------------------------------===//
713// Comparison Instructions...
714//
715
716// Integer comparison
Evan Cheng55687072007-09-14 21:48:26 +0000717let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000718let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000719def TEST64rr : RI<0x85, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000720 "test{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000721 [(X86cmp (and GR64:$src1, GR64:$src2), 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000722def TEST64rm : RI<0x85, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000723 "test{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000724 [(X86cmp (and GR64:$src1, (loadi64 addr:$src2)), 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000725def TEST64ri32 : RIi32<0xF7, MRM0r, (outs), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000726 "test{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000727 [(X86cmp (and GR64:$src1, i64immSExt32:$src2), 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000728def TEST64mi32 : RIi32<0xF7, MRM0m, (outs), (ins i64mem:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000729 "test{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000730 [(X86cmp (and (loadi64 addr:$src1), i64immSExt32:$src2), 0)]>;
731
Evan Chengb783fa32007-07-19 01:14:50 +0000732def CMP64rr : RI<0x39, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000733 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000734 [(X86cmp GR64:$src1, GR64:$src2)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000735def CMP64mr : RI<0x39, MRMDestMem, (outs), (ins i64mem:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000736 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000737 [(X86cmp (loadi64 addr:$src1), GR64:$src2)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000738def CMP64rm : RI<0x3B, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000739 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000740 [(X86cmp GR64:$src1, (loadi64 addr:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000741def CMP64ri32 : RIi32<0x81, MRM7r, (outs), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000742 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000743 [(X86cmp GR64:$src1, i64immSExt32:$src2)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000744def CMP64mi32 : RIi32<0x81, MRM7m, (outs), (ins i64mem:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000745 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000746 [(X86cmp (loadi64 addr:$src1), i64immSExt32:$src2)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000747def CMP64mi8 : RIi8<0x83, MRM7m, (outs), (ins i64mem:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000748 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000749 [(X86cmp (loadi64 addr:$src1), i64immSExt8:$src2)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000750def CMP64ri8 : RIi8<0x83, MRM7r, (outs), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000751 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000752 [(X86cmp GR64:$src1, i64immSExt8:$src2)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000753} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000754
755// Conditional moves
756let isTwoAddress = 1 in {
757def CMOVB64rr : RI<0x42, MRMSrcReg, // if <u, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000758 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000759 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000760 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
761 X86_COND_B))]>, TB;
762def CMOVB64rm : RI<0x42, MRMSrcMem, // if <u, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000763 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000764 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000765 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
766 X86_COND_B))]>, TB;
767def CMOVAE64rr: RI<0x43, MRMSrcReg, // if >=u, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000768 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000769 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000770 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
771 X86_COND_AE))]>, TB;
772def CMOVAE64rm: RI<0x43, MRMSrcMem, // if >=u, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000773 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000774 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000775 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
776 X86_COND_AE))]>, TB;
777def CMOVE64rr : RI<0x44, MRMSrcReg, // if ==, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000778 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000779 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000780 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
781 X86_COND_E))]>, TB;
782def CMOVE64rm : RI<0x44, MRMSrcMem, // if ==, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000783 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000784 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000785 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
786 X86_COND_E))]>, TB;
787def CMOVNE64rr: RI<0x45, MRMSrcReg, // if !=, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000788 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000789 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000790 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
791 X86_COND_NE))]>, TB;
792def CMOVNE64rm: RI<0x45, MRMSrcMem, // if !=, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000793 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000794 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000795 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
796 X86_COND_NE))]>, TB;
797def CMOVBE64rr: RI<0x46, MRMSrcReg, // if <=u, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000798 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000799 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000800 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
801 X86_COND_BE))]>, TB;
802def CMOVBE64rm: RI<0x46, MRMSrcMem, // if <=u, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000803 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000804 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000805 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
806 X86_COND_BE))]>, TB;
807def CMOVA64rr : RI<0x47, MRMSrcReg, // if >u, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000808 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000809 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000810 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
811 X86_COND_A))]>, TB;
812def CMOVA64rm : RI<0x47, MRMSrcMem, // if >u, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000813 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000814 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000815 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
816 X86_COND_A))]>, TB;
817def CMOVL64rr : RI<0x4C, MRMSrcReg, // if <s, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000818 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000819 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000820 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
821 X86_COND_L))]>, TB;
822def CMOVL64rm : RI<0x4C, MRMSrcMem, // if <s, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000823 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000824 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000825 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
826 X86_COND_L))]>, TB;
827def CMOVGE64rr: RI<0x4D, MRMSrcReg, // if >=s, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000828 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000829 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000830 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
831 X86_COND_GE))]>, TB;
832def CMOVGE64rm: RI<0x4D, MRMSrcMem, // if >=s, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000833 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000834 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000835 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
836 X86_COND_GE))]>, TB;
837def CMOVLE64rr: RI<0x4E, MRMSrcReg, // if <=s, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000838 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000839 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000840 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
841 X86_COND_LE))]>, TB;
842def CMOVLE64rm: RI<0x4E, MRMSrcMem, // if <=s, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000843 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000844 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000845 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
846 X86_COND_LE))]>, TB;
847def CMOVG64rr : RI<0x4F, MRMSrcReg, // if >s, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000848 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000849 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000850 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
851 X86_COND_G))]>, TB;
852def CMOVG64rm : RI<0x4F, MRMSrcMem, // if >s, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000853 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000854 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000855 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
856 X86_COND_G))]>, TB;
857def CMOVS64rr : RI<0x48, MRMSrcReg, // if signed, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000858 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000859 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000860 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
861 X86_COND_S))]>, TB;
862def CMOVS64rm : RI<0x48, MRMSrcMem, // if signed, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000863 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000864 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000865 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
866 X86_COND_S))]>, TB;
867def CMOVNS64rr: RI<0x49, MRMSrcReg, // if !signed, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000868 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000869 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000870 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
871 X86_COND_NS))]>, TB;
872def CMOVNS64rm: RI<0x49, MRMSrcMem, // if !signed, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000873 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000874 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000875 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
876 X86_COND_NS))]>, TB;
877def CMOVP64rr : RI<0x4A, MRMSrcReg, // if parity, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000878 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000879 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000880 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
881 X86_COND_P))]>, TB;
882def CMOVP64rm : RI<0x4A, MRMSrcMem, // if parity, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000883 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000884 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000885 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
886 X86_COND_P))]>, TB;
887def CMOVNP64rr : RI<0x4B, MRMSrcReg, // if !parity, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000888 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000889 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000890 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
891 X86_COND_NP))]>, TB;
892def CMOVNP64rm : RI<0x4B, MRMSrcMem, // if !parity, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000893 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000894 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000895 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
896 X86_COND_NP))]>, TB;
897} // isTwoAddress
898
899//===----------------------------------------------------------------------===//
900// Conversion Instructions...
901//
902
903// f64 -> signed i64
Evan Chengb783fa32007-07-19 01:14:50 +0000904def Int_CVTSD2SI64rr: RSDI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000905 "cvtsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +0000906 [(set GR64:$dst,
907 (int_x86_sse2_cvtsd2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000908def Int_CVTSD2SI64rm: RSDI<0x2D, MRMSrcMem, (outs GR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000909 "cvtsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +0000910 [(set GR64:$dst, (int_x86_sse2_cvtsd2si64
911 (load addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000912def CVTTSD2SI64rr: RSDI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000913 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000914 [(set GR64:$dst, (fp_to_sint FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000915def CVTTSD2SI64rm: RSDI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000916 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000917 [(set GR64:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000918def Int_CVTTSD2SI64rr: RSDI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000919 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +0000920 [(set GR64:$dst,
921 (int_x86_sse2_cvttsd2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000922def Int_CVTTSD2SI64rm: RSDI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000923 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +0000924 [(set GR64:$dst,
925 (int_x86_sse2_cvttsd2si64
926 (load addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000927
928// Signed i64 -> f64
Evan Chengb783fa32007-07-19 01:14:50 +0000929def CVTSI2SD64rr: RSDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000930 "cvtsi2sd{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000931 [(set FR64:$dst, (sint_to_fp GR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000932def CVTSI2SD64rm: RSDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000933 "cvtsi2sd{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000934 [(set FR64:$dst, (sint_to_fp (loadi64 addr:$src)))]>;
935let isTwoAddress = 1 in {
936def Int_CVTSI2SD64rr: RSDI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000937 (outs VR128:$dst), (ins VR128:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000938 "cvtsi2sd{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendling6227d462007-07-23 03:07:27 +0000939 [(set VR128:$dst,
940 (int_x86_sse2_cvtsi642sd VR128:$src1,
941 GR64:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000942def Int_CVTSI2SD64rm: RSDI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000943 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000944 "cvtsi2sd{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendling6227d462007-07-23 03:07:27 +0000945 [(set VR128:$dst,
946 (int_x86_sse2_cvtsi642sd VR128:$src1,
947 (loadi64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000948} // isTwoAddress
949
950// Signed i64 -> f32
Evan Chengb783fa32007-07-19 01:14:50 +0000951def CVTSI2SS64rr: RSSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000952 "cvtsi2ss{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000953 [(set FR32:$dst, (sint_to_fp GR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000954def CVTSI2SS64rm: RSSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000955 "cvtsi2ss{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000956 [(set FR32:$dst, (sint_to_fp (loadi64 addr:$src)))]>;
957let isTwoAddress = 1 in {
958def Int_CVTSI2SS64rr: RSSI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000959 (outs VR128:$dst), (ins VR128:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000960 "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000961 []>; // TODO: add intrinsic
962def Int_CVTSI2SS64rm: RSSI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000963 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000964 "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000965 []>; // TODO: add intrinsic
966} // isTwoAddress
967
968// f32 -> signed i64
Evan Chengb783fa32007-07-19 01:14:50 +0000969def Int_CVTSS2SI64rr: RSSI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000970 "cvtss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +0000971 [(set GR64:$dst,
972 (int_x86_sse_cvtss2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000973def Int_CVTSS2SI64rm: RSSI<0x2D, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000974 "cvtss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +0000975 [(set GR64:$dst, (int_x86_sse_cvtss2si64
976 (load addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000977def CVTTSS2SI64rr: RSSI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000978 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000979 [(set GR64:$dst, (fp_to_sint FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000980def CVTTSS2SI64rm: RSSI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000981 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000982 [(set GR64:$dst, (fp_to_sint (loadf32 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000983def Int_CVTTSS2SI64rr: RSSI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000984 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +0000985 [(set GR64:$dst,
986 (int_x86_sse_cvttss2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000987def Int_CVTTSS2SI64rm: RSSI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000988 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +0000989 [(set GR64:$dst,
990 (int_x86_sse_cvttss2si64 (load addr:$src)))]>;
991
992let isTwoAddress = 1 in {
993 def Int_CVTSI642SSrr : RSSI<0x2A, MRMSrcReg,
994 (outs VR128:$dst), (ins VR128:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000995 "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendling6227d462007-07-23 03:07:27 +0000996 [(set VR128:$dst,
997 (int_x86_sse_cvtsi642ss VR128:$src1,
998 GR64:$src2))]>;
999 def Int_CVTSI642SSrm : RSSI<0x2A, MRMSrcMem,
1000 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001001 "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendling6227d462007-07-23 03:07:27 +00001002 [(set VR128:$dst,
1003 (int_x86_sse_cvtsi642ss VR128:$src1,
1004 (loadi64 addr:$src2)))]>;
1005}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001006
1007//===----------------------------------------------------------------------===//
1008// Alias Instructions
1009//===----------------------------------------------------------------------===//
1010
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001011// Zero-extension
1012// TODO: Remove this after proper i32 -> i64 zext support.
Evan Chengb783fa32007-07-19 01:14:50 +00001013def PsMOVZX64rr32: I<0x89, MRMDestReg, (outs GR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001014 "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001015 [(set GR64:$dst, (zext GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001016def PsMOVZX64rm32: I<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001017 "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001018 [(set GR64:$dst, (zextloadi64i32 addr:$src))]>;
1019
1020
1021// Alias instructions that map movr0 to xor.
1022// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
1023// FIXME: AddedComplexity gives MOV64r0 a higher priority than MOV64ri32. Remove
1024// when we have a better way to specify isel priority.
Evan Cheng55687072007-09-14 21:48:26 +00001025let Defs = [EFLAGS], AddedComplexity = 1, isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001026def MOV64r0 : RI<0x31, MRMInitReg, (outs GR64:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00001027 "xor{q}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001028 [(set GR64:$dst, 0)]>;
1029
1030// Materialize i64 constant where top 32-bits are zero.
Dan Gohman8aef09b2007-09-07 21:32:51 +00001031let AddedComplexity = 1, isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001032def MOV64ri64i32 : Ii32<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001033 "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001034 [(set GR64:$dst, i64immZExt32:$src)]>;
1035
1036//===----------------------------------------------------------------------===//
1037// Non-Instruction Patterns
1038//===----------------------------------------------------------------------===//
1039
1040// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
1041def : Pat<(i64 (X86Wrapper tconstpool :$dst)),
1042 (MOV64ri tconstpool :$dst)>, Requires<[NotSmallCode]>;
1043def : Pat<(i64 (X86Wrapper tjumptable :$dst)),
1044 (MOV64ri tjumptable :$dst)>, Requires<[NotSmallCode]>;
1045def : Pat<(i64 (X86Wrapper tglobaladdr :$dst)),
1046 (MOV64ri tglobaladdr :$dst)>, Requires<[NotSmallCode]>;
1047def : Pat<(i64 (X86Wrapper texternalsym:$dst)),
1048 (MOV64ri texternalsym:$dst)>, Requires<[NotSmallCode]>;
1049
1050def : Pat<(store (i64 (X86Wrapper tconstpool:$src)), addr:$dst),
1051 (MOV64mi32 addr:$dst, tconstpool:$src)>,
Evan Cheng415e2e92007-08-01 23:46:10 +00001052 Requires<[SmallCode, HasLow4G, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001053def : Pat<(store (i64 (X86Wrapper tjumptable:$src)), addr:$dst),
1054 (MOV64mi32 addr:$dst, tjumptable:$src)>,
Evan Cheng415e2e92007-08-01 23:46:10 +00001055 Requires<[SmallCode, HasLow4G, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001056def : Pat<(store (i64 (X86Wrapper tglobaladdr:$src)), addr:$dst),
1057 (MOV64mi32 addr:$dst, tglobaladdr:$src)>,
Evan Cheng415e2e92007-08-01 23:46:10 +00001058 Requires<[SmallCode, HasLow4G, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001059def : Pat<(store (i64 (X86Wrapper texternalsym:$src)), addr:$dst),
1060 (MOV64mi32 addr:$dst, texternalsym:$src)>,
Evan Cheng415e2e92007-08-01 23:46:10 +00001061 Requires<[SmallCode, HasLow4G, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001062
1063// Calls
1064// Direct PC relative function call for small code model. 32-bit displacement
1065// sign extended to 64-bit.
1066def : Pat<(X86call (i64 tglobaladdr:$dst)),
1067 (CALL64pcrel32 tglobaladdr:$dst)>;
1068def : Pat<(X86call (i64 texternalsym:$dst)),
1069 (CALL64pcrel32 texternalsym:$dst)>;
1070
1071def : Pat<(X86tailcall (i64 tglobaladdr:$dst)),
1072 (CALL64pcrel32 tglobaladdr:$dst)>;
1073def : Pat<(X86tailcall (i64 texternalsym:$dst)),
1074 (CALL64pcrel32 texternalsym:$dst)>;
1075
1076def : Pat<(X86tailcall GR64:$dst),
1077 (CALL64r GR64:$dst)>;
1078
Dan Gohmanec596042007-09-17 14:35:24 +00001079// Comparisons.
1080
1081// TEST R,R is smaller than CMP R,0
1082def : Pat<(X86cmp GR64:$src1, 0),
1083 (TEST64rr GR64:$src1, GR64:$src1)>;
1084
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001085// {s|z}extload bool -> {s|z}extload byte
1086def : Pat<(sextloadi64i1 addr:$src), (MOVSX64rm8 addr:$src)>;
1087def : Pat<(zextloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>;
1088
1089// extload
1090def : Pat<(extloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>;
1091def : Pat<(extloadi64i8 addr:$src), (MOVZX64rm8 addr:$src)>;
1092def : Pat<(extloadi64i16 addr:$src), (MOVZX64rm16 addr:$src)>;
1093def : Pat<(extloadi64i32 addr:$src), (PsMOVZX64rm32 addr:$src)>;
1094
1095// anyext -> zext
1096def : Pat<(i64 (anyext GR8 :$src)), (MOVZX64rr8 GR8 :$src)>;
1097def : Pat<(i64 (anyext GR16:$src)), (MOVZX64rr16 GR16:$src)>;
1098def : Pat<(i64 (anyext GR32:$src)), (PsMOVZX64rr32 GR32:$src)>;
1099def : Pat<(i64 (anyext (loadi8 addr:$src))), (MOVZX64rm8 addr:$src)>;
1100def : Pat<(i64 (anyext (loadi16 addr:$src))), (MOVZX64rm16 addr:$src)>;
1101def : Pat<(i64 (anyext (loadi32 addr:$src))), (PsMOVZX64rm32 addr:$src)>;
1102
1103//===----------------------------------------------------------------------===//
1104// Some peepholes
1105//===----------------------------------------------------------------------===//
1106
1107// (shl x, 1) ==> (add x, x)
1108def : Pat<(shl GR64:$src1, (i8 1)), (ADD64rr GR64:$src1, GR64:$src1)>;
1109
1110// (or (x >> c) | (y << (64 - c))) ==> (shrd64 x, y, c)
1111def : Pat<(or (srl GR64:$src1, CL:$amt),
1112 (shl GR64:$src2, (sub 64, CL:$amt))),
1113 (SHRD64rrCL GR64:$src1, GR64:$src2)>;
1114
1115def : Pat<(store (or (srl (loadi64 addr:$dst), CL:$amt),
1116 (shl GR64:$src2, (sub 64, CL:$amt))), addr:$dst),
1117 (SHRD64mrCL addr:$dst, GR64:$src2)>;
1118
1119// (or (x << c) | (y >> (64 - c))) ==> (shld64 x, y, c)
1120def : Pat<(or (shl GR64:$src1, CL:$amt),
1121 (srl GR64:$src2, (sub 64, CL:$amt))),
1122 (SHLD64rrCL GR64:$src1, GR64:$src2)>;
1123
1124def : Pat<(store (or (shl (loadi64 addr:$dst), CL:$amt),
1125 (srl GR64:$src2, (sub 64, CL:$amt))), addr:$dst),
1126 (SHLD64mrCL addr:$dst, GR64:$src2)>;
1127
1128// X86 specific add which produces a flag.
1129def : Pat<(addc GR64:$src1, GR64:$src2),
1130 (ADD64rr GR64:$src1, GR64:$src2)>;
1131def : Pat<(addc GR64:$src1, (load addr:$src2)),
1132 (ADD64rm GR64:$src1, addr:$src2)>;
1133def : Pat<(addc GR64:$src1, i64immSExt32:$src2),
1134 (ADD64ri32 GR64:$src1, imm:$src2)>;
1135def : Pat<(addc GR64:$src1, i64immSExt8:$src2),
1136 (ADD64ri8 GR64:$src1, i64immSExt8:$src2)>;
1137
1138def : Pat<(subc GR64:$src1, GR64:$src2),
1139 (SUB64rr GR64:$src1, GR64:$src2)>;
1140def : Pat<(subc GR64:$src1, (load addr:$src2)),
1141 (SUB64rm GR64:$src1, addr:$src2)>;
1142def : Pat<(subc GR64:$src1, imm:$src2),
1143 (SUB64ri32 GR64:$src1, i64immSExt32:$src2)>;
1144def : Pat<(subc GR64:$src1, i64immSExt8:$src2),
1145 (SUB64ri8 GR64:$src1, i64immSExt8:$src2)>;
1146
1147
1148//===----------------------------------------------------------------------===//
1149// X86-64 SSE Instructions
1150//===----------------------------------------------------------------------===//
1151
1152// Move instructions...
1153
Evan Chengb783fa32007-07-19 01:14:50 +00001154def MOV64toPQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001155 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001156 [(set VR128:$dst,
1157 (v2i64 (scalar_to_vector GR64:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001158def MOV64toPQIrm : RPDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001159 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001160 [(set VR128:$dst,
1161 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>;
1162
Evan Chengb783fa32007-07-19 01:14:50 +00001163def MOVPQIto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001164 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001165 [(set GR64:$dst, (vector_extract (v2i64 VR128:$src),
1166 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001167def MOVPQIto64mr : RPDI<0x7E, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001168 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001169 [(store (i64 (vector_extract (v2i64 VR128:$src),
1170 (iPTR 0))), addr:$dst)]>;
1171
Evan Chengb783fa32007-07-19 01:14:50 +00001172def MOV64toSDrr : RPDI<0x6E, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001173 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001174 [(set FR64:$dst, (bitconvert GR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001175def MOV64toSDrm : RPDI<0x6E, MRMSrcMem, (outs FR64:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001176 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001177 [(set FR64:$dst, (bitconvert (loadi64 addr:$src)))]>;
1178
Evan Chengb783fa32007-07-19 01:14:50 +00001179def MOVSDto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001180 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001181 [(set GR64:$dst, (bitconvert FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001182def MOVSDto64mr : RPDI<0x7E, MRMDestMem, (outs), (ins i64mem:$dst, FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001183 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001184 [(store (i64 (bitconvert FR64:$src)), addr:$dst)]>;