blob: bdf2269bcfd8a05422aff372da8943cff9575c1c [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 Chengb783fa32007-07-19 01:14:50 +0000166def MOV64rm : RI<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$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, (load addr:$src))]>;
169
Evan Chengb783fa32007-07-19 01:14:50 +0000170def MOV64mr : RI<0x89, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000171 "mov{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000172 [(store GR64:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000173def MOV64mi32 : RIi32<0xC7, MRM0m, (outs), (ins i64mem:$dst, i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000174 "mov{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000175 [(store i64immSExt32:$src, addr:$dst)]>;
176
177// Sign/Zero extenders
178
Evan Chengb783fa32007-07-19 01:14:50 +0000179def MOVSX64rr8 : RI<0xBE, MRMSrcReg, (outs GR64:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000180 "movs{bq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000181 [(set GR64:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000182def MOVSX64rm8 : RI<0xBE, MRMSrcMem, (outs GR64:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000183 "movs{bq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000184 [(set GR64:$dst, (sextloadi64i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000185def MOVSX64rr16: RI<0xBF, MRMSrcReg, (outs GR64:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000186 "movs{wq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000187 [(set GR64:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000188def MOVSX64rm16: RI<0xBF, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000189 "movs{wq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000190 [(set GR64:$dst, (sextloadi64i16 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000191def MOVSX64rr32: RI<0x63, MRMSrcReg, (outs GR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000192 "movs{lq|xd}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000193 [(set GR64:$dst, (sext GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000194def MOVSX64rm32: RI<0x63, MRMSrcMem, (outs GR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000195 "movs{lq|xd}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000196 [(set GR64:$dst, (sextloadi64i32 addr:$src))]>;
197
Evan Chengb783fa32007-07-19 01:14:50 +0000198def MOVZX64rr8 : RI<0xB6, MRMSrcReg, (outs GR64:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000199 "movz{bq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000200 [(set GR64:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000201def MOVZX64rm8 : RI<0xB6, MRMSrcMem, (outs GR64:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000202 "movz{bq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000203 [(set GR64:$dst, (zextloadi64i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000204def MOVZX64rr16: RI<0xB7, MRMSrcReg, (outs GR64:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000205 "movz{wq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000206 [(set GR64:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000207def MOVZX64rm16: RI<0xB7, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000208 "movz{wq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000209 [(set GR64:$dst, (zextloadi64i16 addr:$src))]>, TB;
210
Evan Chengb783fa32007-07-19 01:14:50 +0000211def CDQE : RI<0x98, RawFrm, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000212 "{cltq|cdqe}", []>, Imp<[EAX],[RAX]>; // RAX = signext(EAX)
213
Evan Chengb783fa32007-07-19 01:14:50 +0000214def CQO : RI<0x99, RawFrm, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000215 "{cqto|cqo}", []>, Imp<[RAX],[RAX,RDX]>; // RDX:RAX = signext(RAX)
216
217//===----------------------------------------------------------------------===//
218// Arithmetic Instructions...
219//
220
221let isTwoAddress = 1 in {
222let isConvertibleToThreeAddress = 1 in {
223let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000224def ADD64rr : RI<0x01, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000225 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000226 [(set GR64:$dst, (add GR64:$src1, GR64:$src2))]>;
227
Evan Chengb783fa32007-07-19 01:14:50 +0000228def ADD64ri32 : RIi32<0x81, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000229 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000230 [(set GR64:$dst, (add GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000231def ADD64ri8 : RIi8<0x83, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000232 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000233 [(set GR64:$dst, (add GR64:$src1, i64immSExt8:$src2))]>;
234} // isConvertibleToThreeAddress
235
Evan Chengb783fa32007-07-19 01:14:50 +0000236def ADD64rm : RI<0x03, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000237 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000238 [(set GR64:$dst, (add GR64:$src1, (load addr:$src2)))]>;
239} // isTwoAddress
240
Evan Chengb783fa32007-07-19 01:14:50 +0000241def ADD64mr : RI<0x01, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000242 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000243 [(store (add (load addr:$dst), GR64:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000244def ADD64mi32 : RIi32<0x81, MRM0m, (outs), (ins i64mem:$dst, i64i32imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000245 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000246 [(store (add (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000247def ADD64mi8 : RIi8<0x83, MRM0m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000248 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000249 [(store (add (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
250
251let isTwoAddress = 1 in {
252let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000253def ADC64rr : RI<0x11, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000254 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000255 [(set GR64:$dst, (adde GR64:$src1, GR64:$src2))]>;
256
Evan Chengb783fa32007-07-19 01:14:50 +0000257def ADC64rm : RI<0x13, MRMSrcMem , (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000258 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000259 [(set GR64:$dst, (adde GR64:$src1, (load addr:$src2)))]>;
260
Evan Chengb783fa32007-07-19 01:14:50 +0000261def ADC64ri32 : RIi32<0x81, MRM2r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000262 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000263 [(set GR64:$dst, (adde GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000264def ADC64ri8 : RIi8<0x83, MRM2r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000265 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000266 [(set GR64:$dst, (adde GR64:$src1, i64immSExt8:$src2))]>;
267} // isTwoAddress
268
Evan Chengb783fa32007-07-19 01:14:50 +0000269def ADC64mr : RI<0x11, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000270 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000271 [(store (adde (load addr:$dst), GR64:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000272def ADC64mi32 : RIi32<0x81, MRM2m, (outs), (ins i64mem:$dst, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000273 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000274 [(store (adde (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000275def ADC64mi8 : RIi8<0x83, MRM2m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000276 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000277 [(store (adde (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
278
279let isTwoAddress = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000280def SUB64rr : RI<0x29, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000281 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000282 [(set GR64:$dst, (sub GR64:$src1, GR64:$src2))]>;
283
Evan Chengb783fa32007-07-19 01:14:50 +0000284def SUB64rm : RI<0x2B, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000285 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000286 [(set GR64:$dst, (sub GR64:$src1, (load addr:$src2)))]>;
287
Evan Chengb783fa32007-07-19 01:14:50 +0000288def SUB64ri32 : RIi32<0x81, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000289 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000290 [(set GR64:$dst, (sub GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000291def SUB64ri8 : RIi8<0x83, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000292 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000293 [(set GR64:$dst, (sub GR64:$src1, i64immSExt8:$src2))]>;
294} // isTwoAddress
295
Evan Chengb783fa32007-07-19 01:14:50 +0000296def SUB64mr : RI<0x29, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000297 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000298 [(store (sub (load addr:$dst), GR64:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000299def SUB64mi32 : RIi32<0x81, MRM5m, (outs), (ins i64mem:$dst, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000300 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000301 [(store (sub (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000302def SUB64mi8 : RIi8<0x83, MRM5m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000303 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000304 [(store (sub (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
305
306let isTwoAddress = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000307def SBB64rr : RI<0x19, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000308 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000309 [(set GR64:$dst, (sube GR64:$src1, GR64:$src2))]>;
310
Evan Chengb783fa32007-07-19 01:14:50 +0000311def SBB64rm : RI<0x1B, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000312 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000313 [(set GR64:$dst, (sube GR64:$src1, (load addr:$src2)))]>;
314
Evan Chengb783fa32007-07-19 01:14:50 +0000315def SBB64ri32 : RIi32<0x81, MRM3r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000316 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000317 [(set GR64:$dst, (sube GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000318def SBB64ri8 : RIi8<0x83, MRM3r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000319 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000320 [(set GR64:$dst, (sube GR64:$src1, i64immSExt8:$src2))]>;
321} // isTwoAddress
322
Evan Chengb783fa32007-07-19 01:14:50 +0000323def SBB64mr : RI<0x19, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000324 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000325 [(store (sube (load addr:$dst), GR64:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000326def SBB64mi32 : RIi32<0x81, MRM3m, (outs), (ins i64mem:$dst, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000327 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000328 [(store (sube (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000329def SBB64mi8 : RIi8<0x83, MRM3m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000330 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000331 [(store (sube (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
332
333// Unsigned multiplication
Evan Chengb783fa32007-07-19 01:14:50 +0000334def MUL64r : RI<0xF7, MRM4r, (outs), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000335 "mul{q}\t$src", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000336 Imp<[RAX],[RAX,RDX]>; // RAX,RDX = RAX*GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000337def MUL64m : RI<0xF7, MRM4m, (outs), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000338 "mul{q}\t$src", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000339 Imp<[RAX],[RAX,RDX]>; // RAX,RDX = RAX*[mem64]
340
341// Signed multiplication
Evan Chengb783fa32007-07-19 01:14:50 +0000342def IMUL64r : RI<0xF7, MRM5r, (outs), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000343 "imul{q}\t$src", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000344 Imp<[RAX],[RAX,RDX]>; // RAX,RDX = RAX*GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000345def IMUL64m : RI<0xF7, MRM5m, (outs), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000346 "imul{q}\t$src", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000347 Imp<[RAX],[RAX,RDX]>; // RAX,RDX = RAX*[mem64]
348
349let isTwoAddress = 1 in {
350let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000351def IMUL64rr : RI<0xAF, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000352 "imul{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000353 [(set GR64:$dst, (mul GR64:$src1, GR64:$src2))]>, TB;
354
Evan Chengb783fa32007-07-19 01:14:50 +0000355def IMUL64rm : RI<0xAF, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000356 "imul{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000357 [(set GR64:$dst, (mul GR64:$src1, (load addr:$src2)))]>, TB;
358} // isTwoAddress
359
360// Suprisingly enough, these are not two address instructions!
361def IMUL64rri32 : RIi32<0x69, MRMSrcReg, // GR64 = GR64*I32
Evan Chengb783fa32007-07-19 01:14:50 +0000362 (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000363 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000364 [(set GR64:$dst, (mul GR64:$src1, i64immSExt32:$src2))]>;
365def IMUL64rri8 : RIi8<0x6B, MRMSrcReg, // GR64 = GR64*I8
Evan Chengb783fa32007-07-19 01:14:50 +0000366 (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000367 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000368 [(set GR64:$dst, (mul GR64:$src1, i64immSExt8:$src2))]>;
369def IMUL64rmi32 : RIi32<0x69, MRMSrcMem, // GR64 = [mem64]*I32
Evan Chengb783fa32007-07-19 01:14:50 +0000370 (outs GR64:$dst), (ins i64mem:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000371 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000372 [(set GR64:$dst, (mul (load addr:$src1), i64immSExt32:$src2))]>;
373def IMUL64rmi8 : RIi8<0x6B, MRMSrcMem, // GR64 = [mem64]*I8
Evan Chengb783fa32007-07-19 01:14:50 +0000374 (outs GR64:$dst), (ins i64mem:$src1, i64i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000375 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000376 [(set GR64:$dst, (mul (load addr:$src1), i64immSExt8:$src2))]>;
377
378// Unsigned division / remainder
Evan Chengb783fa32007-07-19 01:14:50 +0000379def DIV64r : RI<0xF7, MRM6r, (outs), (ins GR64:$src), // RDX:RAX/r64 = RAX,RDX
Dan Gohman91888f02007-07-31 20:11:57 +0000380 "div{q}\t$src", []>, Imp<[RAX,RDX],[RAX,RDX]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000381def DIV64m : RI<0xF7, MRM6m, (outs), (ins i64mem:$src), // RDX:RAX/[mem64] = RAX,RDX
Dan Gohman91888f02007-07-31 20:11:57 +0000382 "div{q}\t$src", []>, Imp<[RAX,RDX],[RAX,RDX]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000383
384// Signed division / remainder
Evan Chengb783fa32007-07-19 01:14:50 +0000385def IDIV64r: RI<0xF7, MRM7r, (outs), (ins GR64:$src), // RDX:RAX/r64 = RAX,RDX
Dan Gohman91888f02007-07-31 20:11:57 +0000386 "idiv{q}\t$src", []>, Imp<[RAX,RDX],[RAX,RDX]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000387def IDIV64m: RI<0xF7, MRM7m, (outs), (ins i64mem:$src), // RDX:RAX/[mem64] = RAX,RDX
Dan Gohman91888f02007-07-31 20:11:57 +0000388 "idiv{q}\t$src", []>, Imp<[RAX,RDX],[RAX,RDX]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000389
390// Unary instructions
391let CodeSize = 2 in {
392let isTwoAddress = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000393def NEG64r : RI<0xF7, MRM3r, (outs GR64:$dst), (ins GR64:$src), "neg{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000394 [(set GR64:$dst, (ineg GR64:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000395def NEG64m : RI<0xF7, MRM3m, (outs), (ins i64mem:$dst), "neg{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000396 [(store (ineg (loadi64 addr:$dst)), addr:$dst)]>;
397
398let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000399def INC64r : RI<0xFF, MRM0r, (outs GR64:$dst), (ins GR64:$src), "inc{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000400 [(set GR64:$dst, (add GR64:$src, 1))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000401def INC64m : RI<0xFF, MRM0m, (outs), (ins i64mem:$dst), "inc{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000402 [(store (add (loadi64 addr:$dst), 1), addr:$dst)]>;
403
404let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000405def DEC64r : RI<0xFF, MRM1r, (outs GR64:$dst), (ins GR64:$src), "dec{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000406 [(set GR64:$dst, (add GR64:$src, -1))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000407def DEC64m : RI<0xFF, MRM1m, (outs), (ins i64mem:$dst), "dec{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000408 [(store (add (loadi64 addr:$dst), -1), addr:$dst)]>;
409
410// In 64-bit mode, single byte INC and DEC cannot be encoded.
411let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in {
412// Can transform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +0000413def INC64_16r : I<0xFF, MRM0r, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000414 [(set GR16:$dst, (add GR16:$src, 1))]>,
415 OpSize, Requires<[In64BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000416def INC64_32r : I<0xFF, MRM0r, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000417 [(set GR32:$dst, (add GR32:$src, 1))]>,
418 Requires<[In64BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000419def DEC64_16r : I<0xFF, MRM1r, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000420 [(set GR16:$dst, (add GR16:$src, -1))]>,
421 OpSize, Requires<[In64BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000422def DEC64_32r : I<0xFF, MRM1r, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000423 [(set GR32:$dst, (add GR32:$src, -1))]>,
424 Requires<[In64BitMode]>;
425} // isConvertibleToThreeAddress
426} // CodeSize
427
428
429// Shift instructions
430let isTwoAddress = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000431def SHL64rCL : RI<0xD3, MRM4r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000432 "shl{q}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000433 [(set GR64:$dst, (shl GR64:$src, CL))]>,
434 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000435def SHL64ri : RIi8<0xC1, MRM4r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000436 "shl{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000437 [(set GR64:$dst, (shl GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000438def SHL64r1 : RI<0xD1, MRM4r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000439 "shl{q}\t$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000440} // isTwoAddress
441
Evan Chengb783fa32007-07-19 01:14:50 +0000442def SHL64mCL : RI<0xD3, MRM4m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000443 "shl{q}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000444 [(store (shl (loadi64 addr:$dst), CL), addr:$dst)]>,
445 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000446def SHL64mi : RIi8<0xC1, MRM4m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000447 "shl{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000448 [(store (shl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000449def SHL64m1 : RI<0xD1, MRM4m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000450 "shl{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000451 [(store (shl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
452
453let isTwoAddress = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000454def SHR64rCL : RI<0xD3, MRM5r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000455 "shr{q}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000456 [(set GR64:$dst, (srl GR64:$src, CL))]>,
457 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000458def SHR64ri : RIi8<0xC1, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000459 "shr{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000460 [(set GR64:$dst, (srl GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000461def SHR64r1 : RI<0xD1, MRM5r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000462 "shr{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000463 [(set GR64:$dst, (srl GR64:$src1, (i8 1)))]>;
464} // isTwoAddress
465
Evan Chengb783fa32007-07-19 01:14:50 +0000466def SHR64mCL : RI<0xD3, MRM5m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000467 "shr{q}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000468 [(store (srl (loadi64 addr:$dst), CL), addr:$dst)]>,
469 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000470def SHR64mi : RIi8<0xC1, MRM5m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000471 "shr{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000472 [(store (srl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000473def SHR64m1 : RI<0xD1, MRM5m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000474 "shr{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000475 [(store (srl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
476
477let isTwoAddress = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000478def SAR64rCL : RI<0xD3, MRM7r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000479 "sar{q}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000480 [(set GR64:$dst, (sra GR64:$src, CL))]>, Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000481def SAR64ri : RIi8<0xC1, MRM7r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000482 "sar{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000483 [(set GR64:$dst, (sra GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000484def SAR64r1 : RI<0xD1, MRM7r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000485 "sar{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000486 [(set GR64:$dst, (sra GR64:$src1, (i8 1)))]>;
487} // isTwoAddress
488
Evan Chengb783fa32007-07-19 01:14:50 +0000489def SAR64mCL : RI<0xD3, MRM7m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000490 "sar{q}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000491 [(store (sra (loadi64 addr:$dst), CL), addr:$dst)]>,
492 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000493def SAR64mi : RIi8<0xC1, MRM7m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000494 "sar{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000495 [(store (sra (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000496def SAR64m1 : RI<0xD1, MRM7m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000497 "sar{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000498 [(store (sra (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
499
500// Rotate instructions
501let isTwoAddress = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000502def ROL64rCL : RI<0xD3, MRM0r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000503 "rol{q}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000504 [(set GR64:$dst, (rotl GR64:$src, CL))]>, Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000505def ROL64ri : RIi8<0xC1, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000506 "rol{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000507 [(set GR64:$dst, (rotl GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000508def ROL64r1 : RI<0xD1, MRM0r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000509 "rol{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000510 [(set GR64:$dst, (rotl GR64:$src1, (i8 1)))]>;
511} // isTwoAddress
512
Evan Chengb783fa32007-07-19 01:14:50 +0000513def ROL64mCL : I<0xD3, MRM0m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000514 "rol{q}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000515 [(store (rotl (loadi64 addr:$dst), CL), addr:$dst)]>,
516 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000517def ROL64mi : RIi8<0xC1, MRM0m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000518 "rol{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000519 [(store (rotl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000520def ROL64m1 : RI<0xD1, MRM0m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000521 "rol{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000522 [(store (rotl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
523
524let isTwoAddress = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000525def ROR64rCL : RI<0xD3, MRM1r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000526 "ror{q}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000527 [(set GR64:$dst, (rotr GR64:$src, CL))]>, Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000528def ROR64ri : RIi8<0xC1, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000529 "ror{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000530 [(set GR64:$dst, (rotr GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000531def ROR64r1 : RI<0xD1, MRM1r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000532 "ror{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000533 [(set GR64:$dst, (rotr GR64:$src1, (i8 1)))]>;
534} // isTwoAddress
535
Evan Chengb783fa32007-07-19 01:14:50 +0000536def ROR64mCL : RI<0xD3, MRM1m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000537 "ror{q}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000538 [(store (rotr (loadi64 addr:$dst), CL), addr:$dst)]>,
539 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000540def ROR64mi : RIi8<0xC1, MRM1m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000541 "ror{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000542 [(store (rotr (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000543def ROR64m1 : RI<0xD1, MRM1m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000544 "ror{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000545 [(store (rotr (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
546
547// Double shift instructions (generalizations of rotate)
548let isTwoAddress = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000549def SHLD64rrCL : RI<0xA5, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000550 "shld{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000551 Imp<[CL],[]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000552def SHRD64rrCL : RI<0xAD, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000553 "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000554 Imp<[CL],[]>, TB;
555
556let isCommutable = 1 in { // FIXME: Update X86InstrInfo::commuteInstruction
557def SHLD64rri8 : RIi8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000558 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000559 "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000560 TB;
561def SHRD64rri8 : RIi8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000562 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000563 "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000564 TB;
565} // isCommutable
566} // isTwoAddress
567
568// Temporary hack: there is no patterns associated with these instructions
569// so we have to tell tblgen that these do not produce results.
Evan Chengb783fa32007-07-19 01:14:50 +0000570def SHLD64mrCL : RI<0xA5, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000571 "shld{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000572 Imp<[CL],[]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000573def SHRD64mrCL : RI<0xAD, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000574 "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000575 Imp<[CL],[]>, TB;
576def SHLD64mri8 : RIi8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000577 (outs), (ins i64mem:$dst, GR64:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000578 "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000579 TB;
580def SHRD64mri8 : RIi8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000581 (outs), (ins i64mem:$dst, GR64:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000582 "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000583 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000584
585//===----------------------------------------------------------------------===//
586// Logical Instructions...
587//
588
589let isTwoAddress = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000590def NOT64r : RI<0xF7, MRM2r, (outs GR64:$dst), (ins GR64:$src), "not{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000591 [(set GR64:$dst, (not GR64:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000592def NOT64m : RI<0xF7, MRM2m, (outs), (ins i64mem:$dst), "not{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000593 [(store (not (loadi64 addr:$dst)), addr:$dst)]>;
594
595let isTwoAddress = 1 in {
596let isCommutable = 1 in
597def AND64rr : RI<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000598 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000599 "and{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000600 [(set GR64:$dst, (and GR64:$src1, GR64:$src2))]>;
601def AND64rm : RI<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000602 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000603 "and{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000604 [(set GR64:$dst, (and GR64:$src1, (load addr:$src2)))]>;
605def AND64ri32 : RIi32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +0000606 (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000607 "and{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000608 [(set GR64:$dst, (and GR64:$src1, i64immSExt32:$src2))]>;
609def AND64ri8 : RIi8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +0000610 (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000611 "and{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000612 [(set GR64:$dst, (and GR64:$src1, i64immSExt8:$src2))]>;
613} // isTwoAddress
614
615def AND64mr : RI<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000616 (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000617 "and{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000618 [(store (and (load addr:$dst), GR64:$src), addr:$dst)]>;
619def AND64mi32 : RIi32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +0000620 (outs), (ins i64mem:$dst, i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000621 "and{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000622 [(store (and (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>;
623def AND64mi8 : RIi8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +0000624 (outs), (ins i64mem:$dst, i64i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000625 "and{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000626 [(store (and (load addr:$dst), i64immSExt8:$src), addr:$dst)]>;
627
628let isTwoAddress = 1 in {
629let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000630def OR64rr : RI<0x09, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000631 "or{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000632 [(set GR64:$dst, (or GR64:$src1, GR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000633def OR64rm : RI<0x0B, MRMSrcMem , (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000634 "or{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000635 [(set GR64:$dst, (or GR64:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000636def OR64ri32 : RIi32<0x81, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000637 "or{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000638 [(set GR64:$dst, (or GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000639def OR64ri8 : RIi8<0x83, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000640 "or{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000641 [(set GR64:$dst, (or GR64:$src1, i64immSExt8:$src2))]>;
642} // isTwoAddress
643
Evan Chengb783fa32007-07-19 01:14:50 +0000644def OR64mr : RI<0x09, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000645 "or{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000646 [(store (or (load addr:$dst), GR64:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000647def OR64mi32 : RIi32<0x81, MRM1m, (outs), (ins i64mem:$dst, i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000648 "or{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000649 [(store (or (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000650def OR64mi8 : RIi8<0x83, MRM1m, (outs), (ins i64mem:$dst, i64i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000651 "or{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000652 [(store (or (load addr:$dst), i64immSExt8:$src), addr:$dst)]>;
653
654let isTwoAddress = 1 in {
655let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000656def XOR64rr : RI<0x31, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000657 "xor{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000658 [(set GR64:$dst, (xor GR64:$src1, GR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000659def XOR64rm : RI<0x33, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000660 "xor{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000661 [(set GR64:$dst, (xor GR64:$src1, (load addr:$src2)))]>;
662def XOR64ri32 : RIi32<0x81, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +0000663 (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000664 "xor{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000665 [(set GR64:$dst, (xor GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000666def XOR64ri8 : RIi8<0x83, MRM6r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000667 "xor{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000668 [(set GR64:$dst, (xor GR64:$src1, i64immSExt8:$src2))]>;
669} // isTwoAddress
670
Evan Chengb783fa32007-07-19 01:14:50 +0000671def XOR64mr : RI<0x31, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000672 "xor{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000673 [(store (xor (load addr:$dst), GR64:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000674def XOR64mi32 : RIi32<0x81, MRM6m, (outs), (ins i64mem:$dst, i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000675 "xor{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000676 [(store (xor (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000677def XOR64mi8 : RIi8<0x83, MRM6m, (outs), (ins i64mem:$dst, i64i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000678 "xor{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000679 [(store (xor (load addr:$dst), i64immSExt8:$src), addr:$dst)]>;
680
681//===----------------------------------------------------------------------===//
682// Comparison Instructions...
683//
684
685// Integer comparison
686let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000687def TEST64rr : RI<0x85, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000688 "test{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000689 [(X86cmp (and GR64:$src1, GR64:$src2), 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000690def TEST64rm : RI<0x85, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000691 "test{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000692 [(X86cmp (and GR64:$src1, (loadi64 addr:$src2)), 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000693def TEST64ri32 : RIi32<0xF7, MRM0r, (outs), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000694 "test{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000695 [(X86cmp (and GR64:$src1, i64immSExt32:$src2), 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000696def TEST64mi32 : RIi32<0xF7, MRM0m, (outs), (ins i64mem:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000697 "test{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000698 [(X86cmp (and (loadi64 addr:$src1), i64immSExt32:$src2), 0)]>;
699
Evan Chengb783fa32007-07-19 01:14:50 +0000700def CMP64rr : RI<0x39, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000701 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000702 [(X86cmp GR64:$src1, GR64:$src2)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000703def CMP64mr : RI<0x39, MRMDestMem, (outs), (ins i64mem:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000704 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000705 [(X86cmp (loadi64 addr:$src1), GR64:$src2)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000706def CMP64rm : RI<0x3B, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000707 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000708 [(X86cmp GR64:$src1, (loadi64 addr:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000709def CMP64ri32 : RIi32<0x81, MRM7r, (outs), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000710 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000711 [(X86cmp GR64:$src1, i64immSExt32:$src2)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000712def CMP64mi32 : RIi32<0x81, MRM7m, (outs), (ins i64mem:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000713 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000714 [(X86cmp (loadi64 addr:$src1), i64immSExt32:$src2)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000715def CMP64mi8 : RIi8<0x83, MRM7m, (outs), (ins i64mem:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000716 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000717 [(X86cmp (loadi64 addr:$src1), i64immSExt8:$src2)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000718def CMP64ri8 : RIi8<0x83, MRM7r, (outs), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000719 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000720 [(X86cmp GR64:$src1, i64immSExt8:$src2)]>;
721
722// Conditional moves
723let isTwoAddress = 1 in {
724def CMOVB64rr : RI<0x42, MRMSrcReg, // if <u, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000725 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000726 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000727 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
728 X86_COND_B))]>, TB;
729def CMOVB64rm : RI<0x42, MRMSrcMem, // if <u, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000730 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000731 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000732 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
733 X86_COND_B))]>, TB;
734def CMOVAE64rr: RI<0x43, MRMSrcReg, // if >=u, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000735 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000736 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000737 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
738 X86_COND_AE))]>, TB;
739def CMOVAE64rm: RI<0x43, MRMSrcMem, // if >=u, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000740 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000741 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000742 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
743 X86_COND_AE))]>, TB;
744def CMOVE64rr : RI<0x44, MRMSrcReg, // if ==, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000745 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000746 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000747 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
748 X86_COND_E))]>, TB;
749def CMOVE64rm : RI<0x44, MRMSrcMem, // if ==, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000750 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000751 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000752 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
753 X86_COND_E))]>, TB;
754def CMOVNE64rr: RI<0x45, MRMSrcReg, // if !=, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000755 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000756 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000757 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
758 X86_COND_NE))]>, TB;
759def CMOVNE64rm: RI<0x45, MRMSrcMem, // if !=, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000760 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000761 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000762 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
763 X86_COND_NE))]>, TB;
764def CMOVBE64rr: RI<0x46, MRMSrcReg, // if <=u, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000765 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000766 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000767 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
768 X86_COND_BE))]>, TB;
769def CMOVBE64rm: RI<0x46, MRMSrcMem, // if <=u, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000770 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000771 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000772 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
773 X86_COND_BE))]>, TB;
774def CMOVA64rr : RI<0x47, MRMSrcReg, // if >u, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000775 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000776 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000777 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
778 X86_COND_A))]>, TB;
779def CMOVA64rm : RI<0x47, MRMSrcMem, // if >u, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000780 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000781 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000782 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
783 X86_COND_A))]>, TB;
784def CMOVL64rr : RI<0x4C, MRMSrcReg, // if <s, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000785 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000786 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000787 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
788 X86_COND_L))]>, TB;
789def CMOVL64rm : RI<0x4C, MRMSrcMem, // if <s, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000790 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000791 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000792 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
793 X86_COND_L))]>, TB;
794def CMOVGE64rr: RI<0x4D, MRMSrcReg, // if >=s, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000795 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000796 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000797 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
798 X86_COND_GE))]>, TB;
799def CMOVGE64rm: RI<0x4D, MRMSrcMem, // if >=s, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000800 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000801 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000802 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
803 X86_COND_GE))]>, TB;
804def CMOVLE64rr: RI<0x4E, MRMSrcReg, // if <=s, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000805 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000806 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000807 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
808 X86_COND_LE))]>, TB;
809def CMOVLE64rm: RI<0x4E, MRMSrcMem, // if <=s, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000810 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000811 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000812 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
813 X86_COND_LE))]>, TB;
814def CMOVG64rr : RI<0x4F, MRMSrcReg, // if >s, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000815 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000816 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000817 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
818 X86_COND_G))]>, TB;
819def CMOVG64rm : RI<0x4F, MRMSrcMem, // if >s, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000820 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000821 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000822 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
823 X86_COND_G))]>, TB;
824def CMOVS64rr : RI<0x48, MRMSrcReg, // if signed, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000825 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000826 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000827 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
828 X86_COND_S))]>, TB;
829def CMOVS64rm : RI<0x48, MRMSrcMem, // if signed, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000830 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000831 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000832 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
833 X86_COND_S))]>, TB;
834def CMOVNS64rr: RI<0x49, MRMSrcReg, // if !signed, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000835 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000836 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000837 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
838 X86_COND_NS))]>, TB;
839def CMOVNS64rm: RI<0x49, MRMSrcMem, // if !signed, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000840 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000841 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000842 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
843 X86_COND_NS))]>, TB;
844def CMOVP64rr : RI<0x4A, MRMSrcReg, // if parity, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000845 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000846 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000847 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
848 X86_COND_P))]>, TB;
849def CMOVP64rm : RI<0x4A, MRMSrcMem, // if parity, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000850 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000851 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000852 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
853 X86_COND_P))]>, TB;
854def CMOVNP64rr : RI<0x4B, MRMSrcReg, // if !parity, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000855 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000856 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000857 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
858 X86_COND_NP))]>, TB;
859def CMOVNP64rm : RI<0x4B, MRMSrcMem, // if !parity, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000860 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000861 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000862 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
863 X86_COND_NP))]>, TB;
864} // isTwoAddress
865
866//===----------------------------------------------------------------------===//
867// Conversion Instructions...
868//
869
870// f64 -> signed i64
Evan Chengb783fa32007-07-19 01:14:50 +0000871def Int_CVTSD2SI64rr: RSDI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000872 "cvtsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +0000873 [(set GR64:$dst,
874 (int_x86_sse2_cvtsd2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000875def Int_CVTSD2SI64rm: RSDI<0x2D, MRMSrcMem, (outs GR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000876 "cvtsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +0000877 [(set GR64:$dst, (int_x86_sse2_cvtsd2si64
878 (load addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000879def CVTTSD2SI64rr: RSDI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000880 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000881 [(set GR64:$dst, (fp_to_sint FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000882def CVTTSD2SI64rm: RSDI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000883 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000884 [(set GR64:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000885def Int_CVTTSD2SI64rr: RSDI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000886 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +0000887 [(set GR64:$dst,
888 (int_x86_sse2_cvttsd2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000889def Int_CVTTSD2SI64rm: RSDI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000890 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +0000891 [(set GR64:$dst,
892 (int_x86_sse2_cvttsd2si64
893 (load addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000894
895// Signed i64 -> f64
Evan Chengb783fa32007-07-19 01:14:50 +0000896def CVTSI2SD64rr: RSDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000897 "cvtsi2sd{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000898 [(set FR64:$dst, (sint_to_fp GR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000899def CVTSI2SD64rm: RSDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000900 "cvtsi2sd{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000901 [(set FR64:$dst, (sint_to_fp (loadi64 addr:$src)))]>;
902let isTwoAddress = 1 in {
903def Int_CVTSI2SD64rr: RSDI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000904 (outs VR128:$dst), (ins VR128:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000905 "cvtsi2sd{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendling6227d462007-07-23 03:07:27 +0000906 [(set VR128:$dst,
907 (int_x86_sse2_cvtsi642sd VR128:$src1,
908 GR64:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000909def Int_CVTSI2SD64rm: RSDI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000910 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000911 "cvtsi2sd{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendling6227d462007-07-23 03:07:27 +0000912 [(set VR128:$dst,
913 (int_x86_sse2_cvtsi642sd VR128:$src1,
914 (loadi64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000915} // isTwoAddress
916
917// Signed i64 -> f32
Evan Chengb783fa32007-07-19 01:14:50 +0000918def CVTSI2SS64rr: RSSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000919 "cvtsi2ss{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000920 [(set FR32:$dst, (sint_to_fp GR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000921def CVTSI2SS64rm: RSSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000922 "cvtsi2ss{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000923 [(set FR32:$dst, (sint_to_fp (loadi64 addr:$src)))]>;
924let isTwoAddress = 1 in {
925def Int_CVTSI2SS64rr: RSSI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000926 (outs VR128:$dst), (ins VR128:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000927 "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000928 []>; // TODO: add intrinsic
929def Int_CVTSI2SS64rm: RSSI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000930 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000931 "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000932 []>; // TODO: add intrinsic
933} // isTwoAddress
934
935// f32 -> signed i64
Evan Chengb783fa32007-07-19 01:14:50 +0000936def Int_CVTSS2SI64rr: RSSI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000937 "cvtss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +0000938 [(set GR64:$dst,
939 (int_x86_sse_cvtss2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000940def Int_CVTSS2SI64rm: RSSI<0x2D, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000941 "cvtss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +0000942 [(set GR64:$dst, (int_x86_sse_cvtss2si64
943 (load addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000944def CVTTSS2SI64rr: RSSI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000945 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000946 [(set GR64:$dst, (fp_to_sint FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000947def CVTTSS2SI64rm: RSSI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000948 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000949 [(set GR64:$dst, (fp_to_sint (loadf32 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000950def Int_CVTTSS2SI64rr: RSSI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000951 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +0000952 [(set GR64:$dst,
953 (int_x86_sse_cvttss2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000954def Int_CVTTSS2SI64rm: RSSI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000955 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +0000956 [(set GR64:$dst,
957 (int_x86_sse_cvttss2si64 (load addr:$src)))]>;
958
959let isTwoAddress = 1 in {
960 def Int_CVTSI642SSrr : RSSI<0x2A, MRMSrcReg,
961 (outs VR128:$dst), (ins VR128:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000962 "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendling6227d462007-07-23 03:07:27 +0000963 [(set VR128:$dst,
964 (int_x86_sse_cvtsi642ss VR128:$src1,
965 GR64:$src2))]>;
966 def Int_CVTSI642SSrm : RSSI<0x2A, MRMSrcMem,
967 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000968 "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendling6227d462007-07-23 03:07:27 +0000969 [(set VR128:$dst,
970 (int_x86_sse_cvtsi642ss VR128:$src1,
971 (loadi64 addr:$src2)))]>;
972}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000973
974//===----------------------------------------------------------------------===//
975// Alias Instructions
976//===----------------------------------------------------------------------===//
977
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000978// Zero-extension
979// TODO: Remove this after proper i32 -> i64 zext support.
Evan Chengb783fa32007-07-19 01:14:50 +0000980def PsMOVZX64rr32: I<0x89, MRMDestReg, (outs GR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000981 "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000982 [(set GR64:$dst, (zext GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000983def PsMOVZX64rm32: I<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000984 "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000985 [(set GR64:$dst, (zextloadi64i32 addr:$src))]>;
986
987
988// Alias instructions that map movr0 to xor.
989// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
990// FIXME: AddedComplexity gives MOV64r0 a higher priority than MOV64ri32. Remove
991// when we have a better way to specify isel priority.
992let AddedComplexity = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000993def MOV64r0 : RI<0x31, MRMInitReg, (outs GR64:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000994 "xor{q}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000995 [(set GR64:$dst, 0)]>;
996
997// Materialize i64 constant where top 32-bits are zero.
998let AddedComplexity = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000999def MOV64ri64i32 : Ii32<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001000 "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001001 [(set GR64:$dst, i64immZExt32:$src)]>;
1002
1003//===----------------------------------------------------------------------===//
1004// Non-Instruction Patterns
1005//===----------------------------------------------------------------------===//
1006
1007// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
1008def : Pat<(i64 (X86Wrapper tconstpool :$dst)),
1009 (MOV64ri tconstpool :$dst)>, Requires<[NotSmallCode]>;
1010def : Pat<(i64 (X86Wrapper tjumptable :$dst)),
1011 (MOV64ri tjumptable :$dst)>, Requires<[NotSmallCode]>;
1012def : Pat<(i64 (X86Wrapper tglobaladdr :$dst)),
1013 (MOV64ri tglobaladdr :$dst)>, Requires<[NotSmallCode]>;
1014def : Pat<(i64 (X86Wrapper texternalsym:$dst)),
1015 (MOV64ri texternalsym:$dst)>, Requires<[NotSmallCode]>;
1016
1017def : Pat<(store (i64 (X86Wrapper tconstpool:$src)), addr:$dst),
1018 (MOV64mi32 addr:$dst, tconstpool:$src)>,
Evan Cheng415e2e92007-08-01 23:46:10 +00001019 Requires<[SmallCode, HasLow4G, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001020def : Pat<(store (i64 (X86Wrapper tjumptable:$src)), addr:$dst),
1021 (MOV64mi32 addr:$dst, tjumptable:$src)>,
Evan Cheng415e2e92007-08-01 23:46:10 +00001022 Requires<[SmallCode, HasLow4G, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001023def : Pat<(store (i64 (X86Wrapper tglobaladdr:$src)), addr:$dst),
1024 (MOV64mi32 addr:$dst, tglobaladdr:$src)>,
Evan Cheng415e2e92007-08-01 23:46:10 +00001025 Requires<[SmallCode, HasLow4G, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001026def : Pat<(store (i64 (X86Wrapper texternalsym:$src)), addr:$dst),
1027 (MOV64mi32 addr:$dst, texternalsym:$src)>,
Evan Cheng415e2e92007-08-01 23:46:10 +00001028 Requires<[SmallCode, HasLow4G, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001029
1030// Calls
1031// Direct PC relative function call for small code model. 32-bit displacement
1032// sign extended to 64-bit.
1033def : Pat<(X86call (i64 tglobaladdr:$dst)),
1034 (CALL64pcrel32 tglobaladdr:$dst)>;
1035def : Pat<(X86call (i64 texternalsym:$dst)),
1036 (CALL64pcrel32 texternalsym:$dst)>;
1037
1038def : Pat<(X86tailcall (i64 tglobaladdr:$dst)),
1039 (CALL64pcrel32 tglobaladdr:$dst)>;
1040def : Pat<(X86tailcall (i64 texternalsym:$dst)),
1041 (CALL64pcrel32 texternalsym:$dst)>;
1042
1043def : Pat<(X86tailcall GR64:$dst),
1044 (CALL64r GR64:$dst)>;
1045
1046// {s|z}extload bool -> {s|z}extload byte
1047def : Pat<(sextloadi64i1 addr:$src), (MOVSX64rm8 addr:$src)>;
1048def : Pat<(zextloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>;
1049
1050// extload
1051def : Pat<(extloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>;
1052def : Pat<(extloadi64i8 addr:$src), (MOVZX64rm8 addr:$src)>;
1053def : Pat<(extloadi64i16 addr:$src), (MOVZX64rm16 addr:$src)>;
1054def : Pat<(extloadi64i32 addr:$src), (PsMOVZX64rm32 addr:$src)>;
1055
1056// anyext -> zext
1057def : Pat<(i64 (anyext GR8 :$src)), (MOVZX64rr8 GR8 :$src)>;
1058def : Pat<(i64 (anyext GR16:$src)), (MOVZX64rr16 GR16:$src)>;
1059def : Pat<(i64 (anyext GR32:$src)), (PsMOVZX64rr32 GR32:$src)>;
1060def : Pat<(i64 (anyext (loadi8 addr:$src))), (MOVZX64rm8 addr:$src)>;
1061def : Pat<(i64 (anyext (loadi16 addr:$src))), (MOVZX64rm16 addr:$src)>;
1062def : Pat<(i64 (anyext (loadi32 addr:$src))), (PsMOVZX64rm32 addr:$src)>;
1063
1064//===----------------------------------------------------------------------===//
1065// Some peepholes
1066//===----------------------------------------------------------------------===//
1067
1068// (shl x, 1) ==> (add x, x)
1069def : Pat<(shl GR64:$src1, (i8 1)), (ADD64rr GR64:$src1, GR64:$src1)>;
1070
1071// (or (x >> c) | (y << (64 - c))) ==> (shrd64 x, y, c)
1072def : Pat<(or (srl GR64:$src1, CL:$amt),
1073 (shl GR64:$src2, (sub 64, CL:$amt))),
1074 (SHRD64rrCL GR64:$src1, GR64:$src2)>;
1075
1076def : Pat<(store (or (srl (loadi64 addr:$dst), CL:$amt),
1077 (shl GR64:$src2, (sub 64, CL:$amt))), addr:$dst),
1078 (SHRD64mrCL addr:$dst, GR64:$src2)>;
1079
1080// (or (x << c) | (y >> (64 - c))) ==> (shld64 x, y, c)
1081def : Pat<(or (shl GR64:$src1, CL:$amt),
1082 (srl GR64:$src2, (sub 64, CL:$amt))),
1083 (SHLD64rrCL GR64:$src1, GR64:$src2)>;
1084
1085def : Pat<(store (or (shl (loadi64 addr:$dst), CL:$amt),
1086 (srl GR64:$src2, (sub 64, CL:$amt))), addr:$dst),
1087 (SHLD64mrCL addr:$dst, GR64:$src2)>;
1088
1089// X86 specific add which produces a flag.
1090def : Pat<(addc GR64:$src1, GR64:$src2),
1091 (ADD64rr GR64:$src1, GR64:$src2)>;
1092def : Pat<(addc GR64:$src1, (load addr:$src2)),
1093 (ADD64rm GR64:$src1, addr:$src2)>;
1094def : Pat<(addc GR64:$src1, i64immSExt32:$src2),
1095 (ADD64ri32 GR64:$src1, imm:$src2)>;
1096def : Pat<(addc GR64:$src1, i64immSExt8:$src2),
1097 (ADD64ri8 GR64:$src1, i64immSExt8:$src2)>;
1098
1099def : Pat<(subc GR64:$src1, GR64:$src2),
1100 (SUB64rr GR64:$src1, GR64:$src2)>;
1101def : Pat<(subc GR64:$src1, (load addr:$src2)),
1102 (SUB64rm GR64:$src1, addr:$src2)>;
1103def : Pat<(subc GR64:$src1, imm:$src2),
1104 (SUB64ri32 GR64:$src1, i64immSExt32:$src2)>;
1105def : Pat<(subc GR64:$src1, i64immSExt8:$src2),
1106 (SUB64ri8 GR64:$src1, i64immSExt8:$src2)>;
1107
1108
1109//===----------------------------------------------------------------------===//
1110// X86-64 SSE Instructions
1111//===----------------------------------------------------------------------===//
1112
1113// Move instructions...
1114
Evan Chengb783fa32007-07-19 01:14:50 +00001115def MOV64toPQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001116 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001117 [(set VR128:$dst,
1118 (v2i64 (scalar_to_vector GR64:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001119def MOV64toPQIrm : RPDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001120 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001121 [(set VR128:$dst,
1122 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>;
1123
Evan Chengb783fa32007-07-19 01:14:50 +00001124def MOVPQIto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001125 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001126 [(set GR64:$dst, (vector_extract (v2i64 VR128:$src),
1127 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001128def MOVPQIto64mr : RPDI<0x7E, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001129 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001130 [(store (i64 (vector_extract (v2i64 VR128:$src),
1131 (iPTR 0))), addr:$dst)]>;
1132
Evan Chengb783fa32007-07-19 01:14:50 +00001133def MOV64toSDrr : RPDI<0x6E, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001134 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001135 [(set FR64:$dst, (bitconvert GR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001136def MOV64toSDrm : RPDI<0x6E, MRMSrcMem, (outs FR64:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001137 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001138 [(set FR64:$dst, (bitconvert (loadi64 addr:$src)))]>;
1139
Evan Chengb783fa32007-07-19 01:14:50 +00001140def MOVSDto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001141 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001142 [(set GR64:$dst, (bitconvert FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001143def MOVSDto64mr : RPDI<0x7E, MRMDestMem, (outs), (ins i64mem:$dst, FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001144 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001145 [(store (i64 (bitconvert FR64:$src)), addr:$dst)]>;