blob: 2739b665e8a092ef09d26bbb305bec07d84c3c2a [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//
116def LEAVE64 : I<0xC9, RawFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000117 (outs), (ins), "leave", []>, Imp<[RBP,RSP],[RBP,RSP]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000118def POP64r : I<0x58, AddRegFrm,
Dan Gohman91888f02007-07-31 20:11:57 +0000119 (outs GR64:$reg), (ins), "pop{q}\t$reg", []>, Imp<[RSP],[RSP]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000120def PUSH64r : I<0x50, AddRegFrm,
Dan Gohman91888f02007-07-31 20:11:57 +0000121 (outs), (ins GR64:$reg), "push{q}\t$reg", []>, Imp<[RSP],[RSP]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000122
123def LEA64_32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000124 (outs GR32:$dst), (ins lea64_32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000125 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000126 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In64BitMode]>;
127
Evan Chengb783fa32007-07-19 01:14:50 +0000128def LEA64r : RI<0x8D, MRMSrcMem, (outs GR64:$dst), (ins lea64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000129 "lea{q}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000130 [(set GR64:$dst, lea64addr:$src)]>;
131
132let isTwoAddress = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000133def BSWAP64r : RI<0xC8, AddRegFrm, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000134 "bswap{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000135 [(set GR64:$dst, (bswap GR64:$src))]>, TB;
136// Exchange
Evan Chengb783fa32007-07-19 01:14:50 +0000137def XCHG64rr : RI<0x87, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000138 "xchg{q}\t{$src2|$src1}, {$src1|$src2}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000139def XCHG64mr : RI<0x87, MRMDestMem, (outs), (ins i64mem:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000140 "xchg{q}\t{$src2|$src1}, {$src1|$src2}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000141def XCHG64rm : RI<0x87, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000142 "xchg{q}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000143
144// Repeat string ops
Evan Chengb783fa32007-07-19 01:14:50 +0000145def REP_MOVSQ : RI<0xA5, RawFrm, (outs), (ins), "{rep;movsq|rep movsq}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000146 [(X86rep_movs i64)]>,
147 Imp<[RCX,RDI,RSI], [RCX,RDI,RSI]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000148def REP_STOSQ : RI<0xAB, RawFrm, (outs), (ins), "{rep;stosq|rep stosq}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000149 [(X86rep_stos i64)]>,
150 Imp<[RAX,RCX,RDI], [RCX,RDI]>, REP;
151
152//===----------------------------------------------------------------------===//
153// Move Instructions...
154//
155
Evan Chengb783fa32007-07-19 01:14:50 +0000156def MOV64rr : RI<0x89, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000157 "mov{q}\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000158
Evan Chengb783fa32007-07-19 01:14:50 +0000159def MOV64ri : RIi64<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000160 "movabs{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000161 [(set GR64:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000162def MOV64ri32 : RIi32<0xC7, MRM0r, (outs GR64:$dst), (ins i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000163 "mov{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000164 [(set GR64:$dst, i64immSExt32:$src)]>;
165
Evan Cheng4e84e452007-08-30 05:49:43 +0000166let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000167def MOV64rm : RI<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000168 "mov{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000169 [(set GR64:$dst, (load addr:$src))]>;
170
Evan Chengb783fa32007-07-19 01:14:50 +0000171def MOV64mr : RI<0x89, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000172 "mov{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000173 [(store GR64:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000174def MOV64mi32 : RIi32<0xC7, MRM0m, (outs), (ins i64mem:$dst, i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000175 "mov{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000176 [(store i64immSExt32:$src, addr:$dst)]>;
177
178// Sign/Zero extenders
179
Evan Chengb783fa32007-07-19 01:14:50 +0000180def MOVSX64rr8 : RI<0xBE, MRMSrcReg, (outs GR64:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000181 "movs{bq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000182 [(set GR64:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000183def MOVSX64rm8 : RI<0xBE, MRMSrcMem, (outs GR64:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000184 "movs{bq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000185 [(set GR64:$dst, (sextloadi64i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000186def MOVSX64rr16: RI<0xBF, MRMSrcReg, (outs GR64:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000187 "movs{wq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000188 [(set GR64:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000189def MOVSX64rm16: RI<0xBF, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000190 "movs{wq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000191 [(set GR64:$dst, (sextloadi64i16 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000192def MOVSX64rr32: RI<0x63, MRMSrcReg, (outs GR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000193 "movs{lq|xd}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000194 [(set GR64:$dst, (sext GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000195def MOVSX64rm32: RI<0x63, MRMSrcMem, (outs GR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000196 "movs{lq|xd}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000197 [(set GR64:$dst, (sextloadi64i32 addr:$src))]>;
198
Evan Chengb783fa32007-07-19 01:14:50 +0000199def MOVZX64rr8 : RI<0xB6, MRMSrcReg, (outs GR64:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000200 "movz{bq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000201 [(set GR64:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000202def MOVZX64rm8 : RI<0xB6, MRMSrcMem, (outs GR64:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000203 "movz{bq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000204 [(set GR64:$dst, (zextloadi64i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000205def MOVZX64rr16: RI<0xB7, MRMSrcReg, (outs GR64:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000206 "movz{wq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000207 [(set GR64:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000208def MOVZX64rm16: RI<0xB7, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000209 "movz{wq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000210 [(set GR64:$dst, (zextloadi64i16 addr:$src))]>, TB;
211
Evan Chengb783fa32007-07-19 01:14:50 +0000212def CDQE : RI<0x98, RawFrm, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000213 "{cltq|cdqe}", []>, Imp<[EAX],[RAX]>; // RAX = signext(EAX)
214
Evan Chengb783fa32007-07-19 01:14:50 +0000215def CQO : RI<0x99, RawFrm, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000216 "{cqto|cqo}", []>, Imp<[RAX],[RAX,RDX]>; // RDX:RAX = signext(RAX)
217
218//===----------------------------------------------------------------------===//
219// Arithmetic Instructions...
220//
221
222let isTwoAddress = 1 in {
223let isConvertibleToThreeAddress = 1 in {
224let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000225def ADD64rr : RI<0x01, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000226 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000227 [(set GR64:$dst, (add GR64:$src1, GR64:$src2))]>;
228
Evan Chengb783fa32007-07-19 01:14:50 +0000229def ADD64ri32 : RIi32<0x81, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000230 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000231 [(set GR64:$dst, (add GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000232def ADD64ri8 : RIi8<0x83, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000233 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000234 [(set GR64:$dst, (add GR64:$src1, i64immSExt8:$src2))]>;
235} // isConvertibleToThreeAddress
236
Evan Chengb783fa32007-07-19 01:14:50 +0000237def ADD64rm : RI<0x03, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$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, (load addr:$src2)))]>;
240} // isTwoAddress
241
Evan Chengb783fa32007-07-19 01:14:50 +0000242def ADD64mr : RI<0x01, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000243 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000244 [(store (add (load addr:$dst), GR64:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000245def ADD64mi32 : RIi32<0x81, MRM0m, (outs), (ins i64mem:$dst, i64i32imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000246 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000247 [(store (add (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000248def ADD64mi8 : RIi8<0x83, MRM0m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000249 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000250 [(store (add (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
251
252let isTwoAddress = 1 in {
253let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000254def ADC64rr : RI<0x11, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000255 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000256 [(set GR64:$dst, (adde GR64:$src1, GR64:$src2))]>;
257
Evan Chengb783fa32007-07-19 01:14:50 +0000258def ADC64rm : RI<0x13, MRMSrcMem , (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000259 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000260 [(set GR64:$dst, (adde GR64:$src1, (load addr:$src2)))]>;
261
Evan Chengb783fa32007-07-19 01:14:50 +0000262def ADC64ri32 : RIi32<0x81, MRM2r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$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, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000265def ADC64ri8 : RIi8<0x83, MRM2r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000266 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000267 [(set GR64:$dst, (adde GR64:$src1, i64immSExt8:$src2))]>;
268} // isTwoAddress
269
Evan Chengb783fa32007-07-19 01:14:50 +0000270def ADC64mr : RI<0x11, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000271 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000272 [(store (adde (load addr:$dst), GR64:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000273def ADC64mi32 : RIi32<0x81, MRM2m, (outs), (ins i64mem:$dst, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000274 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000275 [(store (adde (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000276def ADC64mi8 : RIi8<0x83, MRM2m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000277 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000278 [(store (adde (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
279
280let isTwoAddress = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000281def SUB64rr : RI<0x29, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000282 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000283 [(set GR64:$dst, (sub GR64:$src1, GR64:$src2))]>;
284
Evan Chengb783fa32007-07-19 01:14:50 +0000285def SUB64rm : RI<0x2B, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000286 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000287 [(set GR64:$dst, (sub GR64:$src1, (load addr:$src2)))]>;
288
Evan Chengb783fa32007-07-19 01:14:50 +0000289def SUB64ri32 : RIi32<0x81, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$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, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000292def SUB64ri8 : RIi8<0x83, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000293 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000294 [(set GR64:$dst, (sub GR64:$src1, i64immSExt8:$src2))]>;
295} // isTwoAddress
296
Evan Chengb783fa32007-07-19 01:14:50 +0000297def SUB64mr : RI<0x29, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000298 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000299 [(store (sub (load addr:$dst), GR64:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000300def SUB64mi32 : RIi32<0x81, MRM5m, (outs), (ins i64mem:$dst, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000301 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000302 [(store (sub (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000303def SUB64mi8 : RIi8<0x83, MRM5m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000304 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000305 [(store (sub (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
306
307let isTwoAddress = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000308def SBB64rr : RI<0x19, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000309 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000310 [(set GR64:$dst, (sube GR64:$src1, GR64:$src2))]>;
311
Evan Chengb783fa32007-07-19 01:14:50 +0000312def SBB64rm : RI<0x1B, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000313 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000314 [(set GR64:$dst, (sube GR64:$src1, (load addr:$src2)))]>;
315
Evan Chengb783fa32007-07-19 01:14:50 +0000316def SBB64ri32 : RIi32<0x81, MRM3r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$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, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000319def SBB64ri8 : RIi8<0x83, MRM3r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000320 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000321 [(set GR64:$dst, (sube GR64:$src1, i64immSExt8:$src2))]>;
322} // isTwoAddress
323
Evan Chengb783fa32007-07-19 01:14:50 +0000324def SBB64mr : RI<0x19, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000325 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000326 [(store (sube (load addr:$dst), GR64:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000327def SBB64mi32 : RIi32<0x81, MRM3m, (outs), (ins i64mem:$dst, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000328 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000329 [(store (sube (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000330def SBB64mi8 : RIi8<0x83, MRM3m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000331 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000332 [(store (sube (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
333
334// Unsigned multiplication
Evan Chengb783fa32007-07-19 01:14:50 +0000335def MUL64r : RI<0xF7, MRM4r, (outs), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000336 "mul{q}\t$src", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000337 Imp<[RAX],[RAX,RDX]>; // RAX,RDX = RAX*GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000338def MUL64m : RI<0xF7, MRM4m, (outs), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000339 "mul{q}\t$src", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000340 Imp<[RAX],[RAX,RDX]>; // RAX,RDX = RAX*[mem64]
341
342// Signed multiplication
Evan Chengb783fa32007-07-19 01:14:50 +0000343def IMUL64r : RI<0xF7, MRM5r, (outs), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000344 "imul{q}\t$src", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000345 Imp<[RAX],[RAX,RDX]>; // RAX,RDX = RAX*GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000346def IMUL64m : RI<0xF7, MRM5m, (outs), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000347 "imul{q}\t$src", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000348 Imp<[RAX],[RAX,RDX]>; // RAX,RDX = RAX*[mem64]
349
350let isTwoAddress = 1 in {
351let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000352def IMUL64rr : RI<0xAF, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000353 "imul{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000354 [(set GR64:$dst, (mul GR64:$src1, GR64:$src2))]>, TB;
355
Evan Chengb783fa32007-07-19 01:14:50 +0000356def IMUL64rm : RI<0xAF, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000357 "imul{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000358 [(set GR64:$dst, (mul GR64:$src1, (load addr:$src2)))]>, TB;
359} // isTwoAddress
360
361// Suprisingly enough, these are not two address instructions!
362def IMUL64rri32 : RIi32<0x69, MRMSrcReg, // GR64 = GR64*I32
Evan Chengb783fa32007-07-19 01:14:50 +0000363 (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000364 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000365 [(set GR64:$dst, (mul GR64:$src1, i64immSExt32:$src2))]>;
366def IMUL64rri8 : RIi8<0x6B, MRMSrcReg, // GR64 = GR64*I8
Evan Chengb783fa32007-07-19 01:14:50 +0000367 (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000368 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000369 [(set GR64:$dst, (mul GR64:$src1, i64immSExt8:$src2))]>;
370def IMUL64rmi32 : RIi32<0x69, MRMSrcMem, // GR64 = [mem64]*I32
Evan Chengb783fa32007-07-19 01:14:50 +0000371 (outs GR64:$dst), (ins i64mem:$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 (load addr:$src1), i64immSExt32:$src2))]>;
374def IMUL64rmi8 : RIi8<0x6B, MRMSrcMem, // GR64 = [mem64]*I8
Evan Chengb783fa32007-07-19 01:14:50 +0000375 (outs GR64:$dst), (ins i64mem:$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 (load addr:$src1), i64immSExt8:$src2))]>;
378
379// Unsigned division / remainder
Evan Chengb783fa32007-07-19 01:14:50 +0000380def DIV64r : RI<0xF7, MRM6r, (outs), (ins GR64:$src), // RDX:RAX/r64 = RAX,RDX
Dan Gohman91888f02007-07-31 20:11:57 +0000381 "div{q}\t$src", []>, Imp<[RAX,RDX],[RAX,RDX]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000382def DIV64m : RI<0xF7, MRM6m, (outs), (ins i64mem:$src), // RDX:RAX/[mem64] = RAX,RDX
Dan Gohman91888f02007-07-31 20:11:57 +0000383 "div{q}\t$src", []>, Imp<[RAX,RDX],[RAX,RDX]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000384
385// Signed division / remainder
Evan Chengb783fa32007-07-19 01:14:50 +0000386def IDIV64r: RI<0xF7, MRM7r, (outs), (ins GR64:$src), // RDX:RAX/r64 = RAX,RDX
Dan Gohman91888f02007-07-31 20:11:57 +0000387 "idiv{q}\t$src", []>, Imp<[RAX,RDX],[RAX,RDX]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000388def IDIV64m: RI<0xF7, MRM7m, (outs), (ins i64mem:$src), // RDX:RAX/[mem64] = RAX,RDX
Dan Gohman91888f02007-07-31 20:11:57 +0000389 "idiv{q}\t$src", []>, Imp<[RAX,RDX],[RAX,RDX]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000390
391// Unary instructions
392let CodeSize = 2 in {
393let isTwoAddress = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000394def NEG64r : RI<0xF7, MRM3r, (outs GR64:$dst), (ins GR64:$src), "neg{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000395 [(set GR64:$dst, (ineg GR64:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000396def NEG64m : RI<0xF7, MRM3m, (outs), (ins i64mem:$dst), "neg{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000397 [(store (ineg (loadi64 addr:$dst)), addr:$dst)]>;
398
399let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000400def INC64r : RI<0xFF, MRM0r, (outs GR64:$dst), (ins GR64:$src), "inc{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000401 [(set GR64:$dst, (add GR64:$src, 1))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000402def INC64m : RI<0xFF, MRM0m, (outs), (ins i64mem:$dst), "inc{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000403 [(store (add (loadi64 addr:$dst), 1), addr:$dst)]>;
404
405let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000406def DEC64r : RI<0xFF, MRM1r, (outs GR64:$dst), (ins GR64:$src), "dec{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000407 [(set GR64:$dst, (add GR64:$src, -1))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000408def DEC64m : RI<0xFF, MRM1m, (outs), (ins i64mem:$dst), "dec{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000409 [(store (add (loadi64 addr:$dst), -1), addr:$dst)]>;
410
411// In 64-bit mode, single byte INC and DEC cannot be encoded.
412let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in {
413// Can transform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +0000414def INC64_16r : I<0xFF, MRM0r, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000415 [(set GR16:$dst, (add GR16:$src, 1))]>,
416 OpSize, Requires<[In64BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000417def INC64_32r : I<0xFF, MRM0r, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000418 [(set GR32:$dst, (add GR32:$src, 1))]>,
419 Requires<[In64BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000420def DEC64_16r : I<0xFF, MRM1r, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000421 [(set GR16:$dst, (add GR16:$src, -1))]>,
422 OpSize, Requires<[In64BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000423def DEC64_32r : I<0xFF, MRM1r, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000424 [(set GR32:$dst, (add GR32:$src, -1))]>,
425 Requires<[In64BitMode]>;
426} // isConvertibleToThreeAddress
427} // CodeSize
428
429
430// Shift instructions
431let isTwoAddress = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000432def SHL64rCL : RI<0xD3, MRM4r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000433 "shl{q}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000434 [(set GR64:$dst, (shl GR64:$src, CL))]>,
435 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000436def SHL64ri : RIi8<0xC1, MRM4r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000437 "shl{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000438 [(set GR64:$dst, (shl GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000439def SHL64r1 : RI<0xD1, MRM4r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000440 "shl{q}\t$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000441} // isTwoAddress
442
Evan Chengb783fa32007-07-19 01:14:50 +0000443def SHL64mCL : RI<0xD3, MRM4m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000444 "shl{q}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000445 [(store (shl (loadi64 addr:$dst), CL), addr:$dst)]>,
446 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000447def SHL64mi : RIi8<0xC1, MRM4m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000448 "shl{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000449 [(store (shl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000450def SHL64m1 : RI<0xD1, MRM4m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000451 "shl{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000452 [(store (shl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
453
454let isTwoAddress = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000455def SHR64rCL : RI<0xD3, MRM5r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000456 "shr{q}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000457 [(set GR64:$dst, (srl GR64:$src, CL))]>,
458 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000459def SHR64ri : RIi8<0xC1, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000460 "shr{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000461 [(set GR64:$dst, (srl GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000462def SHR64r1 : RI<0xD1, MRM5r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000463 "shr{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000464 [(set GR64:$dst, (srl GR64:$src1, (i8 1)))]>;
465} // isTwoAddress
466
Evan Chengb783fa32007-07-19 01:14:50 +0000467def SHR64mCL : RI<0xD3, MRM5m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000468 "shr{q}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000469 [(store (srl (loadi64 addr:$dst), CL), addr:$dst)]>,
470 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000471def SHR64mi : RIi8<0xC1, MRM5m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000472 "shr{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000473 [(store (srl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000474def SHR64m1 : RI<0xD1, MRM5m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000475 "shr{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000476 [(store (srl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
477
478let isTwoAddress = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000479def SAR64rCL : RI<0xD3, MRM7r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000480 "sar{q}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000481 [(set GR64:$dst, (sra GR64:$src, CL))]>, Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000482def SAR64ri : RIi8<0xC1, MRM7r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000483 "sar{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000484 [(set GR64:$dst, (sra GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000485def SAR64r1 : RI<0xD1, MRM7r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000486 "sar{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000487 [(set GR64:$dst, (sra GR64:$src1, (i8 1)))]>;
488} // isTwoAddress
489
Evan Chengb783fa32007-07-19 01:14:50 +0000490def SAR64mCL : RI<0xD3, MRM7m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000491 "sar{q}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000492 [(store (sra (loadi64 addr:$dst), CL), addr:$dst)]>,
493 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000494def SAR64mi : RIi8<0xC1, MRM7m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000495 "sar{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000496 [(store (sra (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000497def SAR64m1 : RI<0xD1, MRM7m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000498 "sar{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000499 [(store (sra (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
500
501// Rotate instructions
502let isTwoAddress = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000503def ROL64rCL : RI<0xD3, MRM0r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000504 "rol{q}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000505 [(set GR64:$dst, (rotl GR64:$src, CL))]>, Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000506def ROL64ri : RIi8<0xC1, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000507 "rol{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000508 [(set GR64:$dst, (rotl GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000509def ROL64r1 : RI<0xD1, MRM0r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000510 "rol{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000511 [(set GR64:$dst, (rotl GR64:$src1, (i8 1)))]>;
512} // isTwoAddress
513
Evan Chengb783fa32007-07-19 01:14:50 +0000514def ROL64mCL : I<0xD3, MRM0m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000515 "rol{q}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000516 [(store (rotl (loadi64 addr:$dst), CL), addr:$dst)]>,
517 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000518def ROL64mi : RIi8<0xC1, MRM0m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000519 "rol{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000520 [(store (rotl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000521def ROL64m1 : RI<0xD1, MRM0m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000522 "rol{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000523 [(store (rotl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
524
525let isTwoAddress = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000526def ROR64rCL : RI<0xD3, MRM1r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000527 "ror{q}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000528 [(set GR64:$dst, (rotr GR64:$src, CL))]>, Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000529def ROR64ri : RIi8<0xC1, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000530 "ror{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000531 [(set GR64:$dst, (rotr GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000532def ROR64r1 : RI<0xD1, MRM1r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000533 "ror{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000534 [(set GR64:$dst, (rotr GR64:$src1, (i8 1)))]>;
535} // isTwoAddress
536
Evan Chengb783fa32007-07-19 01:14:50 +0000537def ROR64mCL : RI<0xD3, MRM1m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000538 "ror{q}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000539 [(store (rotr (loadi64 addr:$dst), CL), addr:$dst)]>,
540 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000541def ROR64mi : RIi8<0xC1, MRM1m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000542 "ror{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000543 [(store (rotr (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000544def ROR64m1 : RI<0xD1, MRM1m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000545 "ror{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000546 [(store (rotr (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
547
548// Double shift instructions (generalizations of rotate)
549let isTwoAddress = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000550def SHLD64rrCL : RI<0xA5, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000551 "shld{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000552 Imp<[CL],[]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000553def SHRD64rrCL : RI<0xAD, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000554 "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000555 Imp<[CL],[]>, TB;
556
557let isCommutable = 1 in { // FIXME: Update X86InstrInfo::commuteInstruction
558def SHLD64rri8 : RIi8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000559 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000560 "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000561 TB;
562def SHRD64rri8 : RIi8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000563 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000564 "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000565 TB;
566} // isCommutable
567} // isTwoAddress
568
569// Temporary hack: there is no patterns associated with these instructions
570// so we have to tell tblgen that these do not produce results.
Evan Chengb783fa32007-07-19 01:14:50 +0000571def SHLD64mrCL : RI<0xA5, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000572 "shld{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000573 Imp<[CL],[]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000574def SHRD64mrCL : RI<0xAD, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000575 "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000576 Imp<[CL],[]>, TB;
577def SHLD64mri8 : RIi8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000578 (outs), (ins i64mem:$dst, GR64:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000579 "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000580 TB;
581def SHRD64mri8 : RIi8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000582 (outs), (ins i64mem:$dst, GR64:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000583 "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000584 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000585
586//===----------------------------------------------------------------------===//
587// Logical Instructions...
588//
589
590let isTwoAddress = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000591def NOT64r : RI<0xF7, MRM2r, (outs GR64:$dst), (ins GR64:$src), "not{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000592 [(set GR64:$dst, (not GR64:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000593def NOT64m : RI<0xF7, MRM2m, (outs), (ins i64mem:$dst), "not{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000594 [(store (not (loadi64 addr:$dst)), addr:$dst)]>;
595
596let isTwoAddress = 1 in {
597let isCommutable = 1 in
598def AND64rr : RI<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000599 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000600 "and{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000601 [(set GR64:$dst, (and GR64:$src1, GR64:$src2))]>;
602def AND64rm : RI<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000603 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000604 "and{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000605 [(set GR64:$dst, (and GR64:$src1, (load addr:$src2)))]>;
606def AND64ri32 : RIi32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +0000607 (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000608 "and{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000609 [(set GR64:$dst, (and GR64:$src1, i64immSExt32:$src2))]>;
610def AND64ri8 : RIi8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +0000611 (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000612 "and{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000613 [(set GR64:$dst, (and GR64:$src1, i64immSExt8:$src2))]>;
614} // isTwoAddress
615
616def AND64mr : RI<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000617 (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000618 "and{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000619 [(store (and (load addr:$dst), GR64:$src), addr:$dst)]>;
620def AND64mi32 : RIi32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +0000621 (outs), (ins i64mem:$dst, i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000622 "and{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000623 [(store (and (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>;
624def AND64mi8 : RIi8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +0000625 (outs), (ins i64mem:$dst, i64i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000626 "and{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000627 [(store (and (load addr:$dst), i64immSExt8:$src), addr:$dst)]>;
628
629let isTwoAddress = 1 in {
630let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000631def OR64rr : RI<0x09, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000632 "or{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000633 [(set GR64:$dst, (or GR64:$src1, GR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000634def OR64rm : RI<0x0B, MRMSrcMem , (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000635 "or{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000636 [(set GR64:$dst, (or GR64:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000637def OR64ri32 : RIi32<0x81, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000638 "or{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000639 [(set GR64:$dst, (or GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000640def OR64ri8 : RIi8<0x83, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000641 "or{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000642 [(set GR64:$dst, (or GR64:$src1, i64immSExt8:$src2))]>;
643} // isTwoAddress
644
Evan Chengb783fa32007-07-19 01:14:50 +0000645def OR64mr : RI<0x09, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000646 "or{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000647 [(store (or (load addr:$dst), GR64:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000648def OR64mi32 : RIi32<0x81, MRM1m, (outs), (ins i64mem:$dst, i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000649 "or{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000650 [(store (or (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000651def OR64mi8 : RIi8<0x83, MRM1m, (outs), (ins i64mem:$dst, i64i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000652 "or{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000653 [(store (or (load addr:$dst), i64immSExt8:$src), addr:$dst)]>;
654
655let isTwoAddress = 1 in {
656let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000657def XOR64rr : RI<0x31, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000658 "xor{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000659 [(set GR64:$dst, (xor GR64:$src1, GR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000660def XOR64rm : RI<0x33, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000661 "xor{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000662 [(set GR64:$dst, (xor GR64:$src1, (load addr:$src2)))]>;
663def XOR64ri32 : RIi32<0x81, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +0000664 (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000665 "xor{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000666 [(set GR64:$dst, (xor GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000667def XOR64ri8 : RIi8<0x83, MRM6r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000668 "xor{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000669 [(set GR64:$dst, (xor GR64:$src1, i64immSExt8:$src2))]>;
670} // isTwoAddress
671
Evan Chengb783fa32007-07-19 01:14:50 +0000672def XOR64mr : RI<0x31, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000673 "xor{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000674 [(store (xor (load addr:$dst), GR64:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000675def XOR64mi32 : RIi32<0x81, MRM6m, (outs), (ins i64mem:$dst, i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000676 "xor{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000677 [(store (xor (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000678def XOR64mi8 : RIi8<0x83, MRM6m, (outs), (ins i64mem:$dst, i64i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000679 "xor{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000680 [(store (xor (load addr:$dst), i64immSExt8:$src), addr:$dst)]>;
681
682//===----------------------------------------------------------------------===//
683// Comparison Instructions...
684//
685
686// Integer comparison
687let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000688def TEST64rr : RI<0x85, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000689 "test{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000690 [(X86cmp (and GR64:$src1, GR64:$src2), 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000691def TEST64rm : RI<0x85, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000692 "test{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000693 [(X86cmp (and GR64:$src1, (loadi64 addr:$src2)), 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000694def TEST64ri32 : RIi32<0xF7, MRM0r, (outs), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000695 "test{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000696 [(X86cmp (and GR64:$src1, i64immSExt32:$src2), 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000697def TEST64mi32 : RIi32<0xF7, MRM0m, (outs), (ins i64mem:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000698 "test{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000699 [(X86cmp (and (loadi64 addr:$src1), i64immSExt32:$src2), 0)]>;
700
Evan Chengb783fa32007-07-19 01:14:50 +0000701def CMP64rr : RI<0x39, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000702 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000703 [(X86cmp GR64:$src1, GR64:$src2)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000704def CMP64mr : RI<0x39, MRMDestMem, (outs), (ins i64mem:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000705 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000706 [(X86cmp (loadi64 addr:$src1), GR64:$src2)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000707def CMP64rm : RI<0x3B, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000708 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000709 [(X86cmp GR64:$src1, (loadi64 addr:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000710def CMP64ri32 : RIi32<0x81, MRM7r, (outs), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000711 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000712 [(X86cmp GR64:$src1, i64immSExt32:$src2)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000713def CMP64mi32 : RIi32<0x81, MRM7m, (outs), (ins i64mem:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000714 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000715 [(X86cmp (loadi64 addr:$src1), i64immSExt32:$src2)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000716def CMP64mi8 : RIi8<0x83, MRM7m, (outs), (ins i64mem:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000717 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000718 [(X86cmp (loadi64 addr:$src1), i64immSExt8:$src2)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000719def CMP64ri8 : RIi8<0x83, MRM7r, (outs), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000720 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000721 [(X86cmp GR64:$src1, i64immSExt8:$src2)]>;
722
723// Conditional moves
724let isTwoAddress = 1 in {
725def CMOVB64rr : RI<0x42, MRMSrcReg, // if <u, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000726 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000727 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000728 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
729 X86_COND_B))]>, TB;
730def CMOVB64rm : RI<0x42, MRMSrcMem, // if <u, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000731 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000732 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000733 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
734 X86_COND_B))]>, TB;
735def CMOVAE64rr: RI<0x43, MRMSrcReg, // if >=u, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000736 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000737 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000738 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
739 X86_COND_AE))]>, TB;
740def CMOVAE64rm: RI<0x43, MRMSrcMem, // if >=u, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000741 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000742 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000743 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
744 X86_COND_AE))]>, TB;
745def CMOVE64rr : RI<0x44, MRMSrcReg, // if ==, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000746 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000747 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000748 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
749 X86_COND_E))]>, TB;
750def CMOVE64rm : RI<0x44, MRMSrcMem, // if ==, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000751 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000752 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000753 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
754 X86_COND_E))]>, TB;
755def CMOVNE64rr: RI<0x45, MRMSrcReg, // if !=, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000756 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000757 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000758 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
759 X86_COND_NE))]>, TB;
760def CMOVNE64rm: RI<0x45, MRMSrcMem, // if !=, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000761 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000762 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000763 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
764 X86_COND_NE))]>, TB;
765def CMOVBE64rr: RI<0x46, MRMSrcReg, // if <=u, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000766 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000767 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000768 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
769 X86_COND_BE))]>, TB;
770def CMOVBE64rm: RI<0x46, MRMSrcMem, // if <=u, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000771 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000772 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000773 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
774 X86_COND_BE))]>, TB;
775def CMOVA64rr : RI<0x47, MRMSrcReg, // if >u, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000776 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000777 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000778 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
779 X86_COND_A))]>, TB;
780def CMOVA64rm : RI<0x47, MRMSrcMem, // if >u, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000781 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000782 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000783 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
784 X86_COND_A))]>, TB;
785def CMOVL64rr : RI<0x4C, MRMSrcReg, // if <s, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000786 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000787 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000788 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
789 X86_COND_L))]>, TB;
790def CMOVL64rm : RI<0x4C, MRMSrcMem, // if <s, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000791 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000792 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000793 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
794 X86_COND_L))]>, TB;
795def CMOVGE64rr: RI<0x4D, MRMSrcReg, // if >=s, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000796 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000797 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000798 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
799 X86_COND_GE))]>, TB;
800def CMOVGE64rm: RI<0x4D, MRMSrcMem, // if >=s, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000801 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000802 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000803 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
804 X86_COND_GE))]>, TB;
805def CMOVLE64rr: RI<0x4E, MRMSrcReg, // if <=s, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000806 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000807 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000808 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
809 X86_COND_LE))]>, TB;
810def CMOVLE64rm: RI<0x4E, MRMSrcMem, // if <=s, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000811 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000812 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000813 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
814 X86_COND_LE))]>, TB;
815def CMOVG64rr : RI<0x4F, MRMSrcReg, // if >s, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000816 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000817 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000818 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
819 X86_COND_G))]>, TB;
820def CMOVG64rm : RI<0x4F, MRMSrcMem, // if >s, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000821 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000822 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000823 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
824 X86_COND_G))]>, TB;
825def CMOVS64rr : RI<0x48, MRMSrcReg, // if signed, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000826 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000827 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000828 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
829 X86_COND_S))]>, TB;
830def CMOVS64rm : RI<0x48, MRMSrcMem, // if signed, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000831 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000832 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000833 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
834 X86_COND_S))]>, TB;
835def CMOVNS64rr: RI<0x49, MRMSrcReg, // if !signed, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000836 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000837 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000838 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
839 X86_COND_NS))]>, TB;
840def CMOVNS64rm: RI<0x49, MRMSrcMem, // if !signed, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000841 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000842 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000843 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
844 X86_COND_NS))]>, TB;
845def CMOVP64rr : RI<0x4A, MRMSrcReg, // if parity, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000846 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000847 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000848 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
849 X86_COND_P))]>, TB;
850def CMOVP64rm : RI<0x4A, MRMSrcMem, // if parity, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000851 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000852 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000853 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
854 X86_COND_P))]>, TB;
855def CMOVNP64rr : RI<0x4B, MRMSrcReg, // if !parity, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000856 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000857 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000858 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
859 X86_COND_NP))]>, TB;
860def CMOVNP64rm : RI<0x4B, MRMSrcMem, // if !parity, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000861 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000862 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000863 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
864 X86_COND_NP))]>, TB;
865} // isTwoAddress
866
867//===----------------------------------------------------------------------===//
868// Conversion Instructions...
869//
870
871// f64 -> signed i64
Evan Chengb783fa32007-07-19 01:14:50 +0000872def Int_CVTSD2SI64rr: RSDI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000873 "cvtsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +0000874 [(set GR64:$dst,
875 (int_x86_sse2_cvtsd2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000876def Int_CVTSD2SI64rm: RSDI<0x2D, MRMSrcMem, (outs GR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000877 "cvtsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +0000878 [(set GR64:$dst, (int_x86_sse2_cvtsd2si64
879 (load addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000880def CVTTSD2SI64rr: RSDI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000881 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000882 [(set GR64:$dst, (fp_to_sint FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000883def CVTTSD2SI64rm: RSDI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000884 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000885 [(set GR64:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000886def Int_CVTTSD2SI64rr: RSDI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000887 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +0000888 [(set GR64:$dst,
889 (int_x86_sse2_cvttsd2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000890def Int_CVTTSD2SI64rm: RSDI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000891 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +0000892 [(set GR64:$dst,
893 (int_x86_sse2_cvttsd2si64
894 (load addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000895
896// Signed i64 -> f64
Evan Chengb783fa32007-07-19 01:14:50 +0000897def CVTSI2SD64rr: RSDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000898 "cvtsi2sd{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000899 [(set FR64:$dst, (sint_to_fp GR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000900def CVTSI2SD64rm: RSDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000901 "cvtsi2sd{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000902 [(set FR64:$dst, (sint_to_fp (loadi64 addr:$src)))]>;
903let isTwoAddress = 1 in {
904def Int_CVTSI2SD64rr: RSDI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000905 (outs VR128:$dst), (ins VR128:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000906 "cvtsi2sd{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendling6227d462007-07-23 03:07:27 +0000907 [(set VR128:$dst,
908 (int_x86_sse2_cvtsi642sd VR128:$src1,
909 GR64:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000910def Int_CVTSI2SD64rm: RSDI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000911 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000912 "cvtsi2sd{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendling6227d462007-07-23 03:07:27 +0000913 [(set VR128:$dst,
914 (int_x86_sse2_cvtsi642sd VR128:$src1,
915 (loadi64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000916} // isTwoAddress
917
918// Signed i64 -> f32
Evan Chengb783fa32007-07-19 01:14:50 +0000919def CVTSI2SS64rr: RSSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000920 "cvtsi2ss{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000921 [(set FR32:$dst, (sint_to_fp GR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000922def CVTSI2SS64rm: RSSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000923 "cvtsi2ss{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000924 [(set FR32:$dst, (sint_to_fp (loadi64 addr:$src)))]>;
925let isTwoAddress = 1 in {
926def Int_CVTSI2SS64rr: RSSI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000927 (outs VR128:$dst), (ins VR128:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000928 "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000929 []>; // TODO: add intrinsic
930def Int_CVTSI2SS64rm: RSSI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000931 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000932 "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000933 []>; // TODO: add intrinsic
934} // isTwoAddress
935
936// f32 -> signed i64
Evan Chengb783fa32007-07-19 01:14:50 +0000937def Int_CVTSS2SI64rr: RSSI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000938 "cvtss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +0000939 [(set GR64:$dst,
940 (int_x86_sse_cvtss2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000941def Int_CVTSS2SI64rm: RSSI<0x2D, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000942 "cvtss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +0000943 [(set GR64:$dst, (int_x86_sse_cvtss2si64
944 (load addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000945def CVTTSS2SI64rr: RSSI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000946 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000947 [(set GR64:$dst, (fp_to_sint FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000948def CVTTSS2SI64rm: RSSI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000949 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000950 [(set GR64:$dst, (fp_to_sint (loadf32 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000951def Int_CVTTSS2SI64rr: RSSI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000952 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +0000953 [(set GR64:$dst,
954 (int_x86_sse_cvttss2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000955def Int_CVTTSS2SI64rm: RSSI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000956 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +0000957 [(set GR64:$dst,
958 (int_x86_sse_cvttss2si64 (load addr:$src)))]>;
959
960let isTwoAddress = 1 in {
961 def Int_CVTSI642SSrr : RSSI<0x2A, MRMSrcReg,
962 (outs VR128:$dst), (ins VR128:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000963 "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendling6227d462007-07-23 03:07:27 +0000964 [(set VR128:$dst,
965 (int_x86_sse_cvtsi642ss VR128:$src1,
966 GR64:$src2))]>;
967 def Int_CVTSI642SSrm : RSSI<0x2A, MRMSrcMem,
968 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000969 "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendling6227d462007-07-23 03:07:27 +0000970 [(set VR128:$dst,
971 (int_x86_sse_cvtsi642ss VR128:$src1,
972 (loadi64 addr:$src2)))]>;
973}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000974
975//===----------------------------------------------------------------------===//
976// Alias Instructions
977//===----------------------------------------------------------------------===//
978
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000979// Zero-extension
980// TODO: Remove this after proper i32 -> i64 zext support.
Evan Chengb783fa32007-07-19 01:14:50 +0000981def PsMOVZX64rr32: I<0x89, MRMDestReg, (outs GR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000982 "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000983 [(set GR64:$dst, (zext GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000984def PsMOVZX64rm32: I<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000985 "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000986 [(set GR64:$dst, (zextloadi64i32 addr:$src))]>;
987
988
989// Alias instructions that map movr0 to xor.
990// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
991// FIXME: AddedComplexity gives MOV64r0 a higher priority than MOV64ri32. Remove
992// when we have a better way to specify isel priority.
993let AddedComplexity = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000994def MOV64r0 : RI<0x31, MRMInitReg, (outs GR64:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000995 "xor{q}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000996 [(set GR64:$dst, 0)]>;
997
998// Materialize i64 constant where top 32-bits are zero.
999let AddedComplexity = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001000def MOV64ri64i32 : Ii32<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001001 "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001002 [(set GR64:$dst, i64immZExt32:$src)]>;
1003
1004//===----------------------------------------------------------------------===//
1005// Non-Instruction Patterns
1006//===----------------------------------------------------------------------===//
1007
1008// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
1009def : Pat<(i64 (X86Wrapper tconstpool :$dst)),
1010 (MOV64ri tconstpool :$dst)>, Requires<[NotSmallCode]>;
1011def : Pat<(i64 (X86Wrapper tjumptable :$dst)),
1012 (MOV64ri tjumptable :$dst)>, Requires<[NotSmallCode]>;
1013def : Pat<(i64 (X86Wrapper tglobaladdr :$dst)),
1014 (MOV64ri tglobaladdr :$dst)>, Requires<[NotSmallCode]>;
1015def : Pat<(i64 (X86Wrapper texternalsym:$dst)),
1016 (MOV64ri texternalsym:$dst)>, Requires<[NotSmallCode]>;
1017
1018def : Pat<(store (i64 (X86Wrapper tconstpool:$src)), addr:$dst),
1019 (MOV64mi32 addr:$dst, tconstpool:$src)>,
Evan Cheng415e2e92007-08-01 23:46:10 +00001020 Requires<[SmallCode, HasLow4G, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001021def : Pat<(store (i64 (X86Wrapper tjumptable:$src)), addr:$dst),
1022 (MOV64mi32 addr:$dst, tjumptable:$src)>,
Evan Cheng415e2e92007-08-01 23:46:10 +00001023 Requires<[SmallCode, HasLow4G, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001024def : Pat<(store (i64 (X86Wrapper tglobaladdr:$src)), addr:$dst),
1025 (MOV64mi32 addr:$dst, tglobaladdr:$src)>,
Evan Cheng415e2e92007-08-01 23:46:10 +00001026 Requires<[SmallCode, HasLow4G, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001027def : Pat<(store (i64 (X86Wrapper texternalsym:$src)), addr:$dst),
1028 (MOV64mi32 addr:$dst, texternalsym:$src)>,
Evan Cheng415e2e92007-08-01 23:46:10 +00001029 Requires<[SmallCode, HasLow4G, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001030
1031// Calls
1032// Direct PC relative function call for small code model. 32-bit displacement
1033// sign extended to 64-bit.
1034def : Pat<(X86call (i64 tglobaladdr:$dst)),
1035 (CALL64pcrel32 tglobaladdr:$dst)>;
1036def : Pat<(X86call (i64 texternalsym:$dst)),
1037 (CALL64pcrel32 texternalsym:$dst)>;
1038
1039def : Pat<(X86tailcall (i64 tglobaladdr:$dst)),
1040 (CALL64pcrel32 tglobaladdr:$dst)>;
1041def : Pat<(X86tailcall (i64 texternalsym:$dst)),
1042 (CALL64pcrel32 texternalsym:$dst)>;
1043
1044def : Pat<(X86tailcall GR64:$dst),
1045 (CALL64r GR64:$dst)>;
1046
1047// {s|z}extload bool -> {s|z}extload byte
1048def : Pat<(sextloadi64i1 addr:$src), (MOVSX64rm8 addr:$src)>;
1049def : Pat<(zextloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>;
1050
1051// extload
1052def : Pat<(extloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>;
1053def : Pat<(extloadi64i8 addr:$src), (MOVZX64rm8 addr:$src)>;
1054def : Pat<(extloadi64i16 addr:$src), (MOVZX64rm16 addr:$src)>;
1055def : Pat<(extloadi64i32 addr:$src), (PsMOVZX64rm32 addr:$src)>;
1056
1057// anyext -> zext
1058def : Pat<(i64 (anyext GR8 :$src)), (MOVZX64rr8 GR8 :$src)>;
1059def : Pat<(i64 (anyext GR16:$src)), (MOVZX64rr16 GR16:$src)>;
1060def : Pat<(i64 (anyext GR32:$src)), (PsMOVZX64rr32 GR32:$src)>;
1061def : Pat<(i64 (anyext (loadi8 addr:$src))), (MOVZX64rm8 addr:$src)>;
1062def : Pat<(i64 (anyext (loadi16 addr:$src))), (MOVZX64rm16 addr:$src)>;
1063def : Pat<(i64 (anyext (loadi32 addr:$src))), (PsMOVZX64rm32 addr:$src)>;
1064
1065//===----------------------------------------------------------------------===//
1066// Some peepholes
1067//===----------------------------------------------------------------------===//
1068
1069// (shl x, 1) ==> (add x, x)
1070def : Pat<(shl GR64:$src1, (i8 1)), (ADD64rr GR64:$src1, GR64:$src1)>;
1071
1072// (or (x >> c) | (y << (64 - c))) ==> (shrd64 x, y, c)
1073def : Pat<(or (srl GR64:$src1, CL:$amt),
1074 (shl GR64:$src2, (sub 64, CL:$amt))),
1075 (SHRD64rrCL GR64:$src1, GR64:$src2)>;
1076
1077def : Pat<(store (or (srl (loadi64 addr:$dst), CL:$amt),
1078 (shl GR64:$src2, (sub 64, CL:$amt))), addr:$dst),
1079 (SHRD64mrCL addr:$dst, GR64:$src2)>;
1080
1081// (or (x << c) | (y >> (64 - c))) ==> (shld64 x, y, c)
1082def : Pat<(or (shl GR64:$src1, CL:$amt),
1083 (srl GR64:$src2, (sub 64, CL:$amt))),
1084 (SHLD64rrCL GR64:$src1, GR64:$src2)>;
1085
1086def : Pat<(store (or (shl (loadi64 addr:$dst), CL:$amt),
1087 (srl GR64:$src2, (sub 64, CL:$amt))), addr:$dst),
1088 (SHLD64mrCL addr:$dst, GR64:$src2)>;
1089
1090// X86 specific add which produces a flag.
1091def : Pat<(addc GR64:$src1, GR64:$src2),
1092 (ADD64rr GR64:$src1, GR64:$src2)>;
1093def : Pat<(addc GR64:$src1, (load addr:$src2)),
1094 (ADD64rm GR64:$src1, addr:$src2)>;
1095def : Pat<(addc GR64:$src1, i64immSExt32:$src2),
1096 (ADD64ri32 GR64:$src1, imm:$src2)>;
1097def : Pat<(addc GR64:$src1, i64immSExt8:$src2),
1098 (ADD64ri8 GR64:$src1, i64immSExt8:$src2)>;
1099
1100def : Pat<(subc GR64:$src1, GR64:$src2),
1101 (SUB64rr GR64:$src1, GR64:$src2)>;
1102def : Pat<(subc GR64:$src1, (load addr:$src2)),
1103 (SUB64rm GR64:$src1, addr:$src2)>;
1104def : Pat<(subc GR64:$src1, imm:$src2),
1105 (SUB64ri32 GR64:$src1, i64immSExt32:$src2)>;
1106def : Pat<(subc GR64:$src1, i64immSExt8:$src2),
1107 (SUB64ri8 GR64:$src1, i64immSExt8:$src2)>;
1108
1109
1110//===----------------------------------------------------------------------===//
1111// X86-64 SSE Instructions
1112//===----------------------------------------------------------------------===//
1113
1114// Move instructions...
1115
Evan Chengb783fa32007-07-19 01:14:50 +00001116def MOV64toPQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001117 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001118 [(set VR128:$dst,
1119 (v2i64 (scalar_to_vector GR64:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001120def MOV64toPQIrm : RPDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001121 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001122 [(set VR128:$dst,
1123 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>;
1124
Evan Chengb783fa32007-07-19 01:14:50 +00001125def MOVPQIto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001126 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001127 [(set GR64:$dst, (vector_extract (v2i64 VR128:$src),
1128 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001129def MOVPQIto64mr : RPDI<0x7E, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001130 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001131 [(store (i64 (vector_extract (v2i64 VR128:$src),
1132 (iPTR 0))), addr:$dst)]>;
1133
Evan Chengb783fa32007-07-19 01:14:50 +00001134def MOV64toSDrr : RPDI<0x6E, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001135 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001136 [(set FR64:$dst, (bitconvert GR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001137def MOV64toSDrm : RPDI<0x6E, MRMSrcMem, (outs FR64:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001138 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001139 [(set FR64:$dst, (bitconvert (loadi64 addr:$src)))]>;
1140
Evan Chengb783fa32007-07-19 01:14:50 +00001141def MOVSDto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001142 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001143 [(set GR64:$dst, (bitconvert FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001144def MOVSDto64mr : RPDI<0x7E, MRMDestMem, (outs), (ins i64mem:$dst, FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001145 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001146 [(store (i64 (bitconvert FR64:$src)), addr:$dst)]>;