blob: c0287c40012ce056b3a1f63487d1bf31516ed3ae [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//====- X86InstrX86-64.td - Describe the X86 Instruction Set ----*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by the Evan Cheng and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file describes the X86-64 instruction set, defining the instructions,
11// and properties of the instructions which are needed for code generation,
12// machine code emission, and analysis.
13//
14//===----------------------------------------------------------------------===//
15
16//===----------------------------------------------------------------------===//
17// Operand Definitions...
18//
19
20// 64-bits but only 32 bits are significant.
21def i64i32imm : Operand<i64>;
22// 64-bits but only 8 bits are significant.
23def i64i8imm : Operand<i64>;
24
25def lea64mem : Operand<i64> {
26 let PrintMethod = "printi64mem";
27 let MIOperandInfo = (ops GR64, i8imm, GR64, i32imm);
28}
29
30def lea64_32mem : Operand<i32> {
31 let PrintMethod = "printlea64_32mem";
32 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
33}
34
35//===----------------------------------------------------------------------===//
36// Complex Pattern Definitions...
37//
38def lea64addr : ComplexPattern<i64, 4, "SelectLEAAddr",
39 [add, mul, shl, or, frameindex, X86Wrapper],
40 []>;
41
42//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +000043// Pattern fragments...
44//
45
46def i64immSExt32 : PatLeaf<(i64 imm), [{
47 // i64immSExt32 predicate - True if the 64-bit immediate fits in a 32-bit
48 // sign extended field.
49 return (int64_t)N->getValue() == (int32_t)N->getValue();
50}]>;
51
52def i64immZExt32 : PatLeaf<(i64 imm), [{
53 // i64immZExt32 predicate - True if the 64-bit immediate fits in a 32-bit
54 // unsignedsign extended field.
55 return (uint64_t)N->getValue() == (uint32_t)N->getValue();
56}]>;
57
58def i64immSExt8 : PatLeaf<(i64 imm), [{
59 // i64immSExt8 predicate - True if the 64-bit immediate fits in a 8-bit
60 // sign extended field.
61 return (int64_t)N->getValue() == (int8_t)N->getValue();
62}]>;
63
64def sextloadi64i1 : PatFrag<(ops node:$ptr), (i64 (sextloadi1 node:$ptr))>;
65def sextloadi64i8 : PatFrag<(ops node:$ptr), (i64 (sextloadi8 node:$ptr))>;
66def sextloadi64i16 : PatFrag<(ops node:$ptr), (i64 (sextloadi16 node:$ptr))>;
67def sextloadi64i32 : PatFrag<(ops node:$ptr), (i64 (sextloadi32 node:$ptr))>;
68
69def zextloadi64i1 : PatFrag<(ops node:$ptr), (i64 (zextloadi1 node:$ptr))>;
70def zextloadi64i8 : PatFrag<(ops node:$ptr), (i64 (zextloadi8 node:$ptr))>;
71def zextloadi64i16 : PatFrag<(ops node:$ptr), (i64 (zextloadi16 node:$ptr))>;
72def zextloadi64i32 : PatFrag<(ops node:$ptr), (i64 (zextloadi32 node:$ptr))>;
73
74def extloadi64i1 : PatFrag<(ops node:$ptr), (i64 (extloadi1 node:$ptr))>;
75def extloadi64i8 : PatFrag<(ops node:$ptr), (i64 (extloadi8 node:$ptr))>;
76def extloadi64i16 : PatFrag<(ops node:$ptr), (i64 (extloadi16 node:$ptr))>;
77def extloadi64i32 : PatFrag<(ops node:$ptr), (i64 (extloadi32 node:$ptr))>;
78
79//===----------------------------------------------------------------------===//
80// Instruction list...
81//
82
Evan Chengb783fa32007-07-19 01:14:50 +000083def IMPLICIT_DEF_GR64 : I<0, Pseudo, (outs GR64:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000084 "#IMPLICIT_DEF $dst",
85 [(set GR64:$dst, (undef))]>;
86
87//===----------------------------------------------------------------------===//
88// Call Instructions...
89//
Evan Cheng37e7c752007-07-21 00:34:19 +000090let isCall = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +000091 // All calls clobber the non-callee saved registers...
92 let Defs = [RAX, RCX, RDX, RSI, RDI, R8, R9, R10, R11,
93 FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
94 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
95 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
96 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15] in {
Evan Chengb783fa32007-07-19 01:14:50 +000097 def CALL64pcrel32 : I<0xE8, RawFrm, (outs), (ins i64imm:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +000098 "call\t${dst:call}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +000099 def CALL64r : I<0xFF, MRM2r, (outs), (ins GR64:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000100 "call\t{*}$dst", [(X86call GR64:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000101 def CALL64m : I<0xFF, MRM2m, (outs), (ins i64mem:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000102 "call\t{*}$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000103 }
104
105// Branches
Evan Cheng37e7c752007-07-21 00:34:19 +0000106let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000107 def JMP64r : I<0xFF, MRM4r, (outs), (ins GR64:$dst), "jmp{q}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000108 [(brind GR64:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000109 def JMP64m : I<0xFF, MRM4m, (outs), (ins i64mem:$dst), "jmp{q}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000110 [(brind (loadi64 addr:$dst))]>;
111}
112
113//===----------------------------------------------------------------------===//
114// Miscellaneous Instructions...
115//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000116let Defs = [RBP,RSP], Uses = [RBP,RSP] in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000117def LEAVE64 : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000118 (outs), (ins), "leave", []>;
119let Defs = [RSP], Uses = [RSP] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000120def POP64r : I<0x58, AddRegFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000121 (outs GR64:$reg), (ins), "pop{q}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000122def PUSH64r : I<0x50, AddRegFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000123 (outs), (ins GR64:$reg), "push{q}\t$reg", []>;
124}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000125
Evan Chengd8434332007-09-26 01:29:06 +0000126let Defs = [RSP, EFLAGS], Uses = [RSP] in
Evan Chengf1341312007-09-26 21:28:00 +0000127def POPFQ : I<0x9D, RawFrm, (outs), (ins), "popf", []>, REX_W;
Evan Chengd8434332007-09-26 01:29:06 +0000128let Defs = [RSP], Uses = [RSP, EFLAGS] in
Evan Chengf1341312007-09-26 21:28:00 +0000129def PUSHFQ : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000130
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000131def LEA64_32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000132 (outs GR32:$dst), (ins lea64_32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000133 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000134 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In64BitMode]>;
135
Evan Chengb783fa32007-07-19 01:14:50 +0000136def LEA64r : RI<0x8D, MRMSrcMem, (outs GR64:$dst), (ins lea64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000137 "lea{q}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000138 [(set GR64:$dst, lea64addr:$src)]>;
139
140let isTwoAddress = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000141def BSWAP64r : RI<0xC8, AddRegFrm, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000142 "bswap{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000143 [(set GR64:$dst, (bswap GR64:$src))]>, TB;
144// Exchange
Evan Chengb783fa32007-07-19 01:14:50 +0000145def XCHG64rr : RI<0x87, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000146 "xchg{q}\t{$src2|$src1}, {$src1|$src2}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000147def XCHG64mr : RI<0x87, MRMDestMem, (outs), (ins i64mem:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000148 "xchg{q}\t{$src2|$src1}, {$src1|$src2}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000149def XCHG64rm : RI<0x87, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000150 "xchg{q}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000151
152// Repeat string ops
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000153let Defs = [RCX,RDI,RSI], Uses = [RCX,RDI,RSI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000154def REP_MOVSQ : RI<0xA5, RawFrm, (outs), (ins), "{rep;movsq|rep movsq}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000155 [(X86rep_movs i64)]>, REP;
156let Defs = [RCX,RDI], Uses = [RAX,RCX,RDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000157def REP_STOSQ : RI<0xAB, RawFrm, (outs), (ins), "{rep;stosq|rep stosq}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000158 [(X86rep_stos i64)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000159
160//===----------------------------------------------------------------------===//
161// Move Instructions...
162//
163
Evan Chengb783fa32007-07-19 01:14:50 +0000164def MOV64rr : RI<0x89, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000165 "mov{q}\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000166
Dan Gohman8aef09b2007-09-07 21:32:51 +0000167let isReMaterializable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000168def MOV64ri : RIi64<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000169 "movabs{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000170 [(set GR64:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000171def MOV64ri32 : RIi32<0xC7, MRM0r, (outs GR64:$dst), (ins i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000172 "mov{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000173 [(set GR64:$dst, i64immSExt32:$src)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +0000174}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000175
Evan Cheng4e84e452007-08-30 05:49:43 +0000176let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000177def MOV64rm : RI<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000178 "mov{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000179 [(set GR64:$dst, (load addr:$src))]>;
180
Evan Chengb783fa32007-07-19 01:14:50 +0000181def MOV64mr : RI<0x89, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000182 "mov{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000183 [(store GR64:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000184def MOV64mi32 : RIi32<0xC7, MRM0m, (outs), (ins i64mem:$dst, i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000185 "mov{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000186 [(store i64immSExt32:$src, addr:$dst)]>;
187
188// Sign/Zero extenders
189
Evan Chengb783fa32007-07-19 01:14:50 +0000190def MOVSX64rr8 : RI<0xBE, MRMSrcReg, (outs GR64:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000191 "movs{bq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000192 [(set GR64:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000193def MOVSX64rm8 : RI<0xBE, MRMSrcMem, (outs GR64:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000194 "movs{bq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000195 [(set GR64:$dst, (sextloadi64i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000196def MOVSX64rr16: RI<0xBF, MRMSrcReg, (outs GR64:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000197 "movs{wq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000198 [(set GR64:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000199def MOVSX64rm16: RI<0xBF, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000200 "movs{wq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000201 [(set GR64:$dst, (sextloadi64i16 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000202def MOVSX64rr32: RI<0x63, MRMSrcReg, (outs GR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000203 "movs{lq|xd}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000204 [(set GR64:$dst, (sext GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000205def MOVSX64rm32: RI<0x63, MRMSrcMem, (outs GR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000206 "movs{lq|xd}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000207 [(set GR64:$dst, (sextloadi64i32 addr:$src))]>;
208
Evan Chengb783fa32007-07-19 01:14:50 +0000209def MOVZX64rr8 : RI<0xB6, MRMSrcReg, (outs GR64:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000210 "movz{bq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000211 [(set GR64:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000212def MOVZX64rm8 : RI<0xB6, MRMSrcMem, (outs GR64:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000213 "movz{bq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000214 [(set GR64:$dst, (zextloadi64i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000215def MOVZX64rr16: RI<0xB7, MRMSrcReg, (outs GR64:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000216 "movz{wq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000217 [(set GR64:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000218def MOVZX64rm16: RI<0xB7, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000219 "movz{wq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000220 [(set GR64:$dst, (zextloadi64i16 addr:$src))]>, TB;
221
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000222let Defs = [RAX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000223def CDQE : RI<0x98, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000224 "{cltq|cdqe}", []>; // RAX = signext(EAX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000225
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000226let Defs = [RAX,RDX], Uses = [RAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000227def CQO : RI<0x99, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000228 "{cqto|cqo}", []>; // RDX:RAX = signext(RAX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000229
230//===----------------------------------------------------------------------===//
231// Arithmetic Instructions...
232//
233
Evan Cheng55687072007-09-14 21:48:26 +0000234let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000235let isTwoAddress = 1 in {
236let isConvertibleToThreeAddress = 1 in {
237let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000238def ADD64rr : RI<0x01, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000239 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000240 [(set GR64:$dst, (add GR64:$src1, GR64:$src2))]>;
241
Evan Chengb783fa32007-07-19 01:14:50 +0000242def ADD64ri32 : RIi32<0x81, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000243 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000244 [(set GR64:$dst, (add GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000245def ADD64ri8 : RIi8<0x83, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000246 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000247 [(set GR64:$dst, (add GR64:$src1, i64immSExt8:$src2))]>;
248} // isConvertibleToThreeAddress
249
Evan Chengb783fa32007-07-19 01:14:50 +0000250def ADD64rm : RI<0x03, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000251 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000252 [(set GR64:$dst, (add GR64:$src1, (load addr:$src2)))]>;
253} // isTwoAddress
254
Evan Chengb783fa32007-07-19 01:14:50 +0000255def ADD64mr : RI<0x01, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000256 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000257 [(store (add (load addr:$dst), GR64:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000258def ADD64mi32 : RIi32<0x81, MRM0m, (outs), (ins i64mem:$dst, i64i32imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000259 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000260 [(store (add (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000261def ADD64mi8 : RIi8<0x83, MRM0m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000262 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000263 [(store (add (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
264
265let isTwoAddress = 1 in {
266let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000267def ADC64rr : RI<0x11, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000268 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000269 [(set GR64:$dst, (adde GR64:$src1, GR64:$src2))]>;
270
Evan Chengb783fa32007-07-19 01:14:50 +0000271def ADC64rm : RI<0x13, MRMSrcMem , (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000272 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000273 [(set GR64:$dst, (adde GR64:$src1, (load addr:$src2)))]>;
274
Evan Chengb783fa32007-07-19 01:14:50 +0000275def ADC64ri32 : RIi32<0x81, MRM2r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000276 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000277 [(set GR64:$dst, (adde GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000278def ADC64ri8 : RIi8<0x83, MRM2r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000279 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000280 [(set GR64:$dst, (adde GR64:$src1, i64immSExt8:$src2))]>;
281} // isTwoAddress
282
Evan Chengb783fa32007-07-19 01:14:50 +0000283def ADC64mr : RI<0x11, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000284 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000285 [(store (adde (load addr:$dst), GR64:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000286def ADC64mi32 : RIi32<0x81, MRM2m, (outs), (ins i64mem:$dst, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000287 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000288 [(store (adde (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000289def ADC64mi8 : RIi8<0x83, MRM2m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000290 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000291 [(store (adde (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
292
293let isTwoAddress = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000294def SUB64rr : RI<0x29, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000295 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000296 [(set GR64:$dst, (sub GR64:$src1, GR64:$src2))]>;
297
Evan Chengb783fa32007-07-19 01:14:50 +0000298def SUB64rm : RI<0x2B, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000299 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000300 [(set GR64:$dst, (sub GR64:$src1, (load addr:$src2)))]>;
301
Evan Chengb783fa32007-07-19 01:14:50 +0000302def SUB64ri32 : RIi32<0x81, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000303 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000304 [(set GR64:$dst, (sub GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000305def SUB64ri8 : RIi8<0x83, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000306 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000307 [(set GR64:$dst, (sub GR64:$src1, i64immSExt8:$src2))]>;
308} // isTwoAddress
309
Evan Chengb783fa32007-07-19 01:14:50 +0000310def SUB64mr : RI<0x29, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000311 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000312 [(store (sub (load addr:$dst), GR64:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000313def SUB64mi32 : RIi32<0x81, MRM5m, (outs), (ins i64mem:$dst, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000314 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000315 [(store (sub (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000316def SUB64mi8 : RIi8<0x83, MRM5m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000317 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000318 [(store (sub (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
319
320let isTwoAddress = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000321def SBB64rr : RI<0x19, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000322 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000323 [(set GR64:$dst, (sube GR64:$src1, GR64:$src2))]>;
324
Evan Chengb783fa32007-07-19 01:14:50 +0000325def SBB64rm : RI<0x1B, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000326 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000327 [(set GR64:$dst, (sube GR64:$src1, (load addr:$src2)))]>;
328
Evan Chengb783fa32007-07-19 01:14:50 +0000329def SBB64ri32 : RIi32<0x81, MRM3r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000330 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000331 [(set GR64:$dst, (sube GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000332def SBB64ri8 : RIi8<0x83, MRM3r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000333 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000334 [(set GR64:$dst, (sube GR64:$src1, i64immSExt8:$src2))]>;
335} // isTwoAddress
336
Evan Chengb783fa32007-07-19 01:14:50 +0000337def SBB64mr : RI<0x19, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000338 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000339 [(store (sube (load addr:$dst), GR64:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000340def SBB64mi32 : RIi32<0x81, MRM3m, (outs), (ins i64mem:$dst, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000341 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000342 [(store (sube (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000343def SBB64mi8 : RIi8<0x83, MRM3m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000344 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000345 [(store (sube (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000346} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000347
348// Unsigned multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000349let Defs = [RAX,RDX,EFLAGS], Uses = [RAX] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000350def MUL64r : RI<0xF7, MRM4r, (outs), (ins GR64:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000351 "mul{q}\t$src", []>; // RAX,RDX = RAX*GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000352def MUL64m : RI<0xF7, MRM4m, (outs), (ins i64mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000353 "mul{q}\t$src", []>; // RAX,RDX = RAX*[mem64]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000354
355// Signed multiplication
Evan Chengb783fa32007-07-19 01:14:50 +0000356def IMUL64r : RI<0xF7, MRM5r, (outs), (ins GR64:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000357 "imul{q}\t$src", []>; // RAX,RDX = RAX*GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000358def IMUL64m : RI<0xF7, MRM5m, (outs), (ins i64mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000359 "imul{q}\t$src", []>; // RAX,RDX = RAX*[mem64]
360}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000361
Evan Cheng55687072007-09-14 21:48:26 +0000362let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000363let isTwoAddress = 1 in {
364let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000365def IMUL64rr : RI<0xAF, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000366 "imul{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000367 [(set GR64:$dst, (mul GR64:$src1, GR64:$src2))]>, TB;
368
Evan Chengb783fa32007-07-19 01:14:50 +0000369def IMUL64rm : RI<0xAF, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000370 "imul{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000371 [(set GR64:$dst, (mul GR64:$src1, (load addr:$src2)))]>, TB;
372} // isTwoAddress
373
374// Suprisingly enough, these are not two address instructions!
375def IMUL64rri32 : RIi32<0x69, MRMSrcReg, // GR64 = GR64*I32
Evan Chengb783fa32007-07-19 01:14:50 +0000376 (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000377 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000378 [(set GR64:$dst, (mul GR64:$src1, i64immSExt32:$src2))]>;
379def IMUL64rri8 : RIi8<0x6B, MRMSrcReg, // GR64 = GR64*I8
Evan Chengb783fa32007-07-19 01:14:50 +0000380 (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000381 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000382 [(set GR64:$dst, (mul GR64:$src1, i64immSExt8:$src2))]>;
383def IMUL64rmi32 : RIi32<0x69, MRMSrcMem, // GR64 = [mem64]*I32
Evan Chengb783fa32007-07-19 01:14:50 +0000384 (outs GR64:$dst), (ins i64mem:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000385 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000386 [(set GR64:$dst, (mul (load addr:$src1), i64immSExt32:$src2))]>;
387def IMUL64rmi8 : RIi8<0x6B, MRMSrcMem, // GR64 = [mem64]*I8
Evan Chengb783fa32007-07-19 01:14:50 +0000388 (outs GR64:$dst), (ins i64mem:$src1, i64i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000389 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000390 [(set GR64:$dst, (mul (load addr:$src1), i64immSExt8:$src2))]>;
Evan Cheng55687072007-09-14 21:48:26 +0000391} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000392
393// Unsigned division / remainder
Evan Cheng55687072007-09-14 21:48:26 +0000394let Defs = [RAX,RDX,EFLAGS], Uses = [RAX,RDX] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000395def DIV64r : RI<0xF7, MRM6r, (outs), (ins GR64:$src), // RDX:RAX/r64 = RAX,RDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000396 "div{q}\t$src", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000397def DIV64m : RI<0xF7, MRM6m, (outs), (ins i64mem:$src), // RDX:RAX/[mem64] = RAX,RDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000398 "div{q}\t$src", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000399
400// Signed division / remainder
Evan Chengb783fa32007-07-19 01:14:50 +0000401def IDIV64r: RI<0xF7, MRM7r, (outs), (ins GR64:$src), // RDX:RAX/r64 = RAX,RDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000402 "idiv{q}\t$src", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000403def IDIV64m: RI<0xF7, MRM7m, (outs), (ins i64mem:$src), // RDX:RAX/[mem64] = RAX,RDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000404 "idiv{q}\t$src", []>;
405}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000406
407// Unary instructions
Evan Cheng55687072007-09-14 21:48:26 +0000408let Defs = [EFLAGS], CodeSize = 2 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000409let isTwoAddress = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000410def NEG64r : RI<0xF7, MRM3r, (outs GR64:$dst), (ins GR64:$src), "neg{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000411 [(set GR64:$dst, (ineg GR64:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000412def NEG64m : RI<0xF7, MRM3m, (outs), (ins i64mem:$dst), "neg{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000413 [(store (ineg (loadi64 addr:$dst)), addr:$dst)]>;
414
415let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000416def INC64r : RI<0xFF, MRM0r, (outs GR64:$dst), (ins GR64:$src), "inc{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000417 [(set GR64:$dst, (add GR64:$src, 1))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000418def INC64m : RI<0xFF, MRM0m, (outs), (ins i64mem:$dst), "inc{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000419 [(store (add (loadi64 addr:$dst), 1), addr:$dst)]>;
420
421let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000422def DEC64r : RI<0xFF, MRM1r, (outs GR64:$dst), (ins GR64:$src), "dec{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000423 [(set GR64:$dst, (add GR64:$src, -1))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000424def DEC64m : RI<0xFF, MRM1m, (outs), (ins i64mem:$dst), "dec{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000425 [(store (add (loadi64 addr:$dst), -1), addr:$dst)]>;
426
427// In 64-bit mode, single byte INC and DEC cannot be encoded.
428let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in {
429// Can transform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +0000430def INC64_16r : I<0xFF, MRM0r, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000431 [(set GR16:$dst, (add GR16:$src, 1))]>,
432 OpSize, Requires<[In64BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000433def INC64_32r : I<0xFF, MRM0r, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000434 [(set GR32:$dst, (add GR32:$src, 1))]>,
435 Requires<[In64BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000436def DEC64_16r : I<0xFF, MRM1r, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000437 [(set GR16:$dst, (add GR16:$src, -1))]>,
438 OpSize, Requires<[In64BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000439def DEC64_32r : I<0xFF, MRM1r, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000440 [(set GR32:$dst, (add GR32:$src, -1))]>,
441 Requires<[In64BitMode]>;
442} // isConvertibleToThreeAddress
Evan Cheng55687072007-09-14 21:48:26 +0000443} // Defs = [EFLAGS], CodeSize
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000444
445
Evan Cheng55687072007-09-14 21:48:26 +0000446let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000447// Shift instructions
448let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000449let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000450def SHL64rCL : RI<0xD3, MRM4r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000451 "shl{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000452 [(set GR64:$dst, (shl GR64:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000453def SHL64ri : RIi8<0xC1, MRM4r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000454 "shl{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000455 [(set GR64:$dst, (shl GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000456def SHL64r1 : RI<0xD1, MRM4r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000457 "shl{q}\t$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000458} // isTwoAddress
459
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000460let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000461def SHL64mCL : RI<0xD3, MRM4m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000462 "shl{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000463 [(store (shl (loadi64 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000464def SHL64mi : RIi8<0xC1, MRM4m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000465 "shl{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000466 [(store (shl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000467def SHL64m1 : RI<0xD1, MRM4m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000468 "shl{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000469 [(store (shl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
470
471let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000472let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000473def SHR64rCL : RI<0xD3, MRM5r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000474 "shr{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000475 [(set GR64:$dst, (srl GR64:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000476def SHR64ri : RIi8<0xC1, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000477 "shr{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000478 [(set GR64:$dst, (srl GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000479def SHR64r1 : RI<0xD1, MRM5r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000480 "shr{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000481 [(set GR64:$dst, (srl GR64:$src1, (i8 1)))]>;
482} // isTwoAddress
483
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000484let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000485def SHR64mCL : RI<0xD3, MRM5m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000486 "shr{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000487 [(store (srl (loadi64 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000488def SHR64mi : RIi8<0xC1, MRM5m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000489 "shr{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000490 [(store (srl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000491def SHR64m1 : RI<0xD1, MRM5m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000492 "shr{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000493 [(store (srl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
494
495let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000496let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000497def SAR64rCL : RI<0xD3, MRM7r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000498 "sar{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000499 [(set GR64:$dst, (sra GR64:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000500def SAR64ri : RIi8<0xC1, MRM7r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000501 "sar{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000502 [(set GR64:$dst, (sra GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000503def SAR64r1 : RI<0xD1, MRM7r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000504 "sar{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000505 [(set GR64:$dst, (sra GR64:$src1, (i8 1)))]>;
506} // isTwoAddress
507
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000508let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000509def SAR64mCL : RI<0xD3, MRM7m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000510 "sar{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000511 [(store (sra (loadi64 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000512def SAR64mi : RIi8<0xC1, MRM7m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000513 "sar{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000514 [(store (sra (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000515def SAR64m1 : RI<0xD1, MRM7m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000516 "sar{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000517 [(store (sra (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
518
519// Rotate instructions
520let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000521let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000522def ROL64rCL : RI<0xD3, MRM0r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000523 "rol{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000524 [(set GR64:$dst, (rotl GR64:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000525def ROL64ri : RIi8<0xC1, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000526 "rol{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000527 [(set GR64:$dst, (rotl GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000528def ROL64r1 : RI<0xD1, MRM0r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000529 "rol{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000530 [(set GR64:$dst, (rotl GR64:$src1, (i8 1)))]>;
531} // isTwoAddress
532
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000533let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000534def ROL64mCL : I<0xD3, MRM0m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000535 "rol{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000536 [(store (rotl (loadi64 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000537def ROL64mi : RIi8<0xC1, MRM0m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000538 "rol{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000539 [(store (rotl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000540def ROL64m1 : RI<0xD1, MRM0m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000541 "rol{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000542 [(store (rotl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
543
544let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000545let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000546def ROR64rCL : RI<0xD3, MRM1r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000547 "ror{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000548 [(set GR64:$dst, (rotr GR64:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000549def ROR64ri : RIi8<0xC1, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000550 "ror{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000551 [(set GR64:$dst, (rotr GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000552def ROR64r1 : RI<0xD1, MRM1r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000553 "ror{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000554 [(set GR64:$dst, (rotr GR64:$src1, (i8 1)))]>;
555} // isTwoAddress
556
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000557let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000558def ROR64mCL : RI<0xD3, MRM1m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000559 "ror{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000560 [(store (rotr (loadi64 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000561def ROR64mi : RIi8<0xC1, MRM1m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000562 "ror{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000563 [(store (rotr (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000564def ROR64m1 : RI<0xD1, MRM1m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000565 "ror{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000566 [(store (rotr (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
567
568// Double shift instructions (generalizations of rotate)
569let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000570let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000571def SHLD64rrCL : RI<0xA5, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000572 "shld{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
573 [(set GR64:$dst, (X86shld GR64:$src1, GR64:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000574def SHRD64rrCL : RI<0xAD, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000575 "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
576 [(set GR64:$dst, (X86shrd GR64:$src1, GR64:$src2, CL))]>, TB;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000577}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000578
579let isCommutable = 1 in { // FIXME: Update X86InstrInfo::commuteInstruction
580def SHLD64rri8 : RIi8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000581 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2, i8imm:$src3),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000582 "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
583 [(set GR64:$dst, (X86shld GR64:$src1, GR64:$src2,
584 (i8 imm:$src3)))]>,
585 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000586def SHRD64rri8 : RIi8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000587 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2, i8imm:$src3),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000588 "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
589 [(set GR64:$dst, (X86shrd GR64:$src1, GR64:$src2,
590 (i8 imm:$src3)))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000591 TB;
592} // isCommutable
593} // isTwoAddress
594
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000595let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000596def SHLD64mrCL : RI<0xA5, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000597 "shld{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
598 [(store (X86shld (loadi64 addr:$dst), GR64:$src2, CL),
599 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000600def SHRD64mrCL : RI<0xAD, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000601 "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
602 [(store (X86shrd (loadi64 addr:$dst), GR64:$src2, CL),
603 addr:$dst)]>, TB;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000604}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000605def SHLD64mri8 : RIi8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000606 (outs), (ins i64mem:$dst, GR64:$src2, i8imm:$src3),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000607 "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
608 [(store (X86shld (loadi64 addr:$dst), GR64:$src2,
609 (i8 imm:$src3)), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000610 TB;
611def SHRD64mri8 : RIi8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000612 (outs), (ins i64mem:$dst, GR64:$src2, i8imm:$src3),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000613 "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
614 [(store (X86shrd (loadi64 addr:$dst), GR64:$src2,
615 (i8 imm:$src3)), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000616 TB;
Evan Cheng55687072007-09-14 21:48:26 +0000617} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000618
619//===----------------------------------------------------------------------===//
620// Logical Instructions...
621//
622
623let isTwoAddress = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000624def NOT64r : RI<0xF7, MRM2r, (outs GR64:$dst), (ins GR64:$src), "not{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000625 [(set GR64:$dst, (not GR64:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000626def NOT64m : RI<0xF7, MRM2m, (outs), (ins i64mem:$dst), "not{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000627 [(store (not (loadi64 addr:$dst)), addr:$dst)]>;
628
Evan Cheng55687072007-09-14 21:48:26 +0000629let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000630let isTwoAddress = 1 in {
631let isCommutable = 1 in
632def AND64rr : RI<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000633 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000634 "and{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000635 [(set GR64:$dst, (and GR64:$src1, GR64:$src2))]>;
636def AND64rm : RI<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000637 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000638 "and{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000639 [(set GR64:$dst, (and GR64:$src1, (load addr:$src2)))]>;
640def AND64ri32 : RIi32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +0000641 (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000642 "and{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000643 [(set GR64:$dst, (and GR64:$src1, i64immSExt32:$src2))]>;
644def AND64ri8 : RIi8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +0000645 (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000646 "and{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000647 [(set GR64:$dst, (and GR64:$src1, i64immSExt8:$src2))]>;
648} // isTwoAddress
649
650def AND64mr : RI<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000651 (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000652 "and{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000653 [(store (and (load addr:$dst), GR64:$src), addr:$dst)]>;
654def AND64mi32 : RIi32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +0000655 (outs), (ins i64mem:$dst, i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000656 "and{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000657 [(store (and (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>;
658def AND64mi8 : RIi8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +0000659 (outs), (ins i64mem:$dst, i64i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000660 "and{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000661 [(store (and (load addr:$dst), i64immSExt8:$src), addr:$dst)]>;
662
663let isTwoAddress = 1 in {
664let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000665def OR64rr : RI<0x09, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000666 "or{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000667 [(set GR64:$dst, (or GR64:$src1, GR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000668def OR64rm : RI<0x0B, MRMSrcMem , (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000669 "or{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000670 [(set GR64:$dst, (or GR64:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000671def OR64ri32 : RIi32<0x81, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000672 "or{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000673 [(set GR64:$dst, (or GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000674def OR64ri8 : RIi8<0x83, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000675 "or{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000676 [(set GR64:$dst, (or GR64:$src1, i64immSExt8:$src2))]>;
677} // isTwoAddress
678
Evan Chengb783fa32007-07-19 01:14:50 +0000679def OR64mr : RI<0x09, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000680 "or{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000681 [(store (or (load addr:$dst), GR64:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000682def OR64mi32 : RIi32<0x81, MRM1m, (outs), (ins i64mem:$dst, i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000683 "or{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000684 [(store (or (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000685def OR64mi8 : RIi8<0x83, MRM1m, (outs), (ins i64mem:$dst, i64i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000686 "or{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000687 [(store (or (load addr:$dst), i64immSExt8:$src), addr:$dst)]>;
688
689let isTwoAddress = 1 in {
690let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000691def XOR64rr : RI<0x31, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000692 "xor{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000693 [(set GR64:$dst, (xor GR64:$src1, GR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000694def XOR64rm : RI<0x33, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000695 "xor{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000696 [(set GR64:$dst, (xor GR64:$src1, (load addr:$src2)))]>;
697def XOR64ri32 : RIi32<0x81, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +0000698 (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000699 "xor{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000700 [(set GR64:$dst, (xor GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000701def XOR64ri8 : RIi8<0x83, MRM6r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000702 "xor{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000703 [(set GR64:$dst, (xor GR64:$src1, i64immSExt8:$src2))]>;
704} // isTwoAddress
705
Evan Chengb783fa32007-07-19 01:14:50 +0000706def XOR64mr : RI<0x31, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000707 "xor{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000708 [(store (xor (load addr:$dst), GR64:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000709def XOR64mi32 : RIi32<0x81, MRM6m, (outs), (ins i64mem:$dst, i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000710 "xor{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000711 [(store (xor (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000712def XOR64mi8 : RIi8<0x83, MRM6m, (outs), (ins i64mem:$dst, i64i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000713 "xor{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000714 [(store (xor (load addr:$dst), i64immSExt8:$src), addr:$dst)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000715} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000716
717//===----------------------------------------------------------------------===//
718// Comparison Instructions...
719//
720
721// Integer comparison
Evan Cheng55687072007-09-14 21:48:26 +0000722let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000723let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000724def TEST64rr : RI<0x85, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000725 "test{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000726 [(X86cmp (and GR64:$src1, GR64:$src2), 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000727def TEST64rm : RI<0x85, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000728 "test{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000729 [(X86cmp (and GR64:$src1, (loadi64 addr:$src2)), 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000730def TEST64ri32 : RIi32<0xF7, MRM0r, (outs), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000731 "test{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000732 [(X86cmp (and GR64:$src1, i64immSExt32:$src2), 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000733def TEST64mi32 : RIi32<0xF7, MRM0m, (outs), (ins i64mem:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000734 "test{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000735 [(X86cmp (and (loadi64 addr:$src1), i64immSExt32:$src2), 0)]>;
736
Evan Chengb783fa32007-07-19 01:14:50 +0000737def CMP64rr : RI<0x39, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000738 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000739 [(X86cmp GR64:$src1, GR64:$src2)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000740def CMP64mr : RI<0x39, MRMDestMem, (outs), (ins i64mem:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000741 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000742 [(X86cmp (loadi64 addr:$src1), GR64:$src2)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000743def CMP64rm : RI<0x3B, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000744 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000745 [(X86cmp GR64:$src1, (loadi64 addr:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000746def CMP64ri32 : RIi32<0x81, MRM7r, (outs), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000747 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000748 [(X86cmp GR64:$src1, i64immSExt32:$src2)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000749def CMP64mi32 : RIi32<0x81, MRM7m, (outs), (ins i64mem:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000750 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000751 [(X86cmp (loadi64 addr:$src1), i64immSExt32:$src2)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000752def CMP64mi8 : RIi8<0x83, MRM7m, (outs), (ins i64mem:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000753 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000754 [(X86cmp (loadi64 addr:$src1), i64immSExt8:$src2)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000755def CMP64ri8 : RIi8<0x83, MRM7r, (outs), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000756 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000757 [(X86cmp GR64:$src1, i64immSExt8:$src2)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000758} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000759
Evan Cheng950aac02007-09-25 01:57:46 +0000760let Defs = [EFLAGS] in {
761let isCommutable = 1 in
762def NEW_TEST64rr : RI<0x85, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2),
763 "test{q}\t{$src2, $src1|$src1, $src2}",
764 [(X86cmp_new (and GR64:$src1, GR64:$src2), 0),
765 (implicit EFLAGS)]>;
766def NEW_TEST64rm : RI<0x85, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2),
767 "test{q}\t{$src2, $src1|$src1, $src2}",
768 [(X86cmp_new (and GR64:$src1, (loadi64 addr:$src2)), 0),
769 (implicit EFLAGS)]>;
770def NEW_TEST64ri32 : RIi32<0xF7, MRM0r, (outs),
771 (ins GR64:$src1, i64i32imm:$src2),
772 "test{q}\t{$src2, $src1|$src1, $src2}",
773 [(X86cmp_new (and GR64:$src1, i64immSExt32:$src2), 0),
774 (implicit EFLAGS)]>;
775def NEW_TEST64mi32 : RIi32<0xF7, MRM0m, (outs),
776 (ins i64mem:$src1, i64i32imm:$src2),
777 "test{q}\t{$src2, $src1|$src1, $src2}",
778 [(X86cmp_new (and (loadi64 addr:$src1), i64immSExt32:$src2), 0),
779 (implicit EFLAGS)]>;
780
781def NEW_CMP64rr : RI<0x39, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2),
782 "cmp{q}\t{$src2, $src1|$src1, $src2}",
783 [(X86cmp_new GR64:$src1, GR64:$src2),
784 (implicit EFLAGS)]>;
785def NEW_CMP64mr : RI<0x39, MRMDestMem, (outs), (ins i64mem:$src1, GR64:$src2),
786 "cmp{q}\t{$src2, $src1|$src1, $src2}",
787 [(X86cmp_new (loadi64 addr:$src1), GR64:$src2),
788 (implicit EFLAGS)]>;
789def NEW_CMP64rm : RI<0x3B, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2),
790 "cmp{q}\t{$src2, $src1|$src1, $src2}",
791 [(X86cmp_new GR64:$src1, (loadi64 addr:$src2)),
792 (implicit EFLAGS)]>;
793def NEW_CMP64ri32 : RIi32<0x81, MRM7r, (outs), (ins GR64:$src1, i64i32imm:$src2),
794 "cmp{q}\t{$src2, $src1|$src1, $src2}",
795 [(X86cmp_new GR64:$src1, i64immSExt32:$src2),
796 (implicit EFLAGS)]>;
797def NEW_CMP64mi32 : RIi32<0x81, MRM7m, (outs),
798 (ins i64mem:$src1, i64i32imm:$src2),
799 "cmp{q}\t{$src2, $src1|$src1, $src2}",
800 [(X86cmp_new (loadi64 addr:$src1), i64immSExt32:$src2),
801 (implicit EFLAGS)]>;
802def NEW_CMP64mi8 : RIi8<0x83, MRM7m, (outs), (ins i64mem:$src1, i64i8imm:$src2),
803 "cmp{q}\t{$src2, $src1|$src1, $src2}",
804 [(X86cmp_new (loadi64 addr:$src1), i64immSExt8:$src2),
805 (implicit EFLAGS)]>;
806def NEW_CMP64ri8 : RIi8<0x83, MRM7r, (outs), (ins GR64:$src1, i64i8imm:$src2),
807 "cmp{q}\t{$src2, $src1|$src1, $src2}",
808 [(X86cmp_new GR64:$src1, i64immSExt8:$src2),
809 (implicit EFLAGS)]>;
810} // Defs = [EFLAGS]
811
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000812// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000813let Uses = [EFLAGS], isTwoAddress = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000814def CMOVB64rr : RI<0x42, MRMSrcReg, // if <u, 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 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000817 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
818 X86_COND_B))]>, TB;
819def CMOVB64rm : RI<0x42, MRMSrcMem, // if <u, 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 "cmovb\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_B))]>, TB;
824def CMOVAE64rr: RI<0x43, MRMSrcReg, // if >=u, 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 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000827 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
828 X86_COND_AE))]>, TB;
829def CMOVAE64rm: RI<0x43, MRMSrcMem, // if >=u, 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 "cmovae\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_AE))]>, TB;
834def CMOVE64rr : RI<0x44, MRMSrcReg, // if ==, 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 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000837 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
838 X86_COND_E))]>, TB;
839def CMOVE64rm : RI<0x44, MRMSrcMem, // if ==, 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 "cmove\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_E))]>, TB;
844def CMOVNE64rr: RI<0x45, MRMSrcReg, // if !=, 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 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000847 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
848 X86_COND_NE))]>, TB;
849def CMOVNE64rm: RI<0x45, MRMSrcMem, // if !=, 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 "cmovne\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_NE))]>, TB;
854def CMOVBE64rr: RI<0x46, MRMSrcReg, // if <=u, 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 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000857 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
858 X86_COND_BE))]>, TB;
859def CMOVBE64rm: RI<0x46, MRMSrcMem, // if <=u, 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 "cmovbe\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_BE))]>, TB;
864def CMOVA64rr : RI<0x47, MRMSrcReg, // if >u, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000865 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000866 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000867 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
868 X86_COND_A))]>, TB;
869def CMOVA64rm : RI<0x47, MRMSrcMem, // if >u, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000870 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000871 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000872 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
873 X86_COND_A))]>, TB;
874def CMOVL64rr : RI<0x4C, MRMSrcReg, // if <s, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000875 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000876 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000877 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
878 X86_COND_L))]>, TB;
879def CMOVL64rm : RI<0x4C, MRMSrcMem, // if <s, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000880 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000881 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000882 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
883 X86_COND_L))]>, TB;
884def CMOVGE64rr: RI<0x4D, MRMSrcReg, // if >=s, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000885 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000886 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000887 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
888 X86_COND_GE))]>, TB;
889def CMOVGE64rm: RI<0x4D, MRMSrcMem, // if >=s, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000890 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000891 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000892 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
893 X86_COND_GE))]>, TB;
894def CMOVLE64rr: RI<0x4E, MRMSrcReg, // if <=s, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000895 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000896 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000897 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
898 X86_COND_LE))]>, TB;
899def CMOVLE64rm: RI<0x4E, MRMSrcMem, // if <=s, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000900 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000901 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000902 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
903 X86_COND_LE))]>, TB;
904def CMOVG64rr : RI<0x4F, MRMSrcReg, // if >s, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000905 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000906 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000907 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
908 X86_COND_G))]>, TB;
909def CMOVG64rm : RI<0x4F, MRMSrcMem, // if >s, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000910 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000911 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000912 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
913 X86_COND_G))]>, TB;
914def CMOVS64rr : RI<0x48, MRMSrcReg, // if signed, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000915 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000916 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000917 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
918 X86_COND_S))]>, TB;
919def CMOVS64rm : RI<0x48, MRMSrcMem, // if signed, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000920 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000921 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000922 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
923 X86_COND_S))]>, TB;
924def CMOVNS64rr: RI<0x49, MRMSrcReg, // if !signed, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000925 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000926 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000927 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
928 X86_COND_NS))]>, TB;
929def CMOVNS64rm: RI<0x49, MRMSrcMem, // if !signed, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000930 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000931 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000932 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
933 X86_COND_NS))]>, TB;
934def CMOVP64rr : RI<0x4A, MRMSrcReg, // if parity, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000935 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000936 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000937 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
938 X86_COND_P))]>, TB;
939def CMOVP64rm : RI<0x4A, MRMSrcMem, // if parity, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000940 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000941 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000942 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
943 X86_COND_P))]>, TB;
944def CMOVNP64rr : RI<0x4B, MRMSrcReg, // if !parity, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000945 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000946 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000947 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
948 X86_COND_NP))]>, TB;
949def CMOVNP64rm : RI<0x4B, MRMSrcMem, // if !parity, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000950 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000951 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000952 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000953 X86_COND_NP))]>, TB;
954
955def NEW_CMOVB64rr : RI<0x42, MRMSrcReg, // if <u, GR64 = GR64
956 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
957 "cmovb\t{$src2, $dst|$dst, $src2}",
958 [(set GR64:$dst, (X86cmov_new GR64:$src1, GR64:$src2,
959 X86_COND_B, EFLAGS))]>, TB;
960def NEW_CMOVB64rm : RI<0x42, MRMSrcMem, // if <u, GR64 = [mem64]
961 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
962 "cmovb\t{$src2, $dst|$dst, $src2}",
963 [(set GR64:$dst, (X86cmov_new GR64:$src1, (loadi64 addr:$src2),
964 X86_COND_B, EFLAGS))]>, TB;
965def NEW_CMOVAE64rr: RI<0x43, MRMSrcReg, // if >=u, GR64 = GR64
966 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
967 "cmovae\t{$src2, $dst|$dst, $src2}",
968 [(set GR64:$dst, (X86cmov_new GR64:$src1, GR64:$src2,
969 X86_COND_AE, EFLAGS))]>, TB;
970def NEW_CMOVAE64rm: RI<0x43, MRMSrcMem, // if >=u, GR64 = [mem64]
971 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
972 "cmovae\t{$src2, $dst|$dst, $src2}",
973 [(set GR64:$dst, (X86cmov_new GR64:$src1, (loadi64 addr:$src2),
974 X86_COND_AE, EFLAGS))]>, TB;
975def NEW_CMOVE64rr : RI<0x44, MRMSrcReg, // if ==, GR64 = GR64
976 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
977 "cmove\t{$src2, $dst|$dst, $src2}",
978 [(set GR64:$dst, (X86cmov_new GR64:$src1, GR64:$src2,
979 X86_COND_E, EFLAGS))]>, TB;
980def NEW_CMOVE64rm : RI<0x44, MRMSrcMem, // if ==, GR64 = [mem64]
981 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
982 "cmove\t{$src2, $dst|$dst, $src2}",
983 [(set GR64:$dst, (X86cmov_new GR64:$src1, (loadi64 addr:$src2),
984 X86_COND_E, EFLAGS))]>, TB;
985def NEW_CMOVNE64rr: RI<0x45, MRMSrcReg, // if !=, GR64 = GR64
986 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
987 "cmovne\t{$src2, $dst|$dst, $src2}",
988 [(set GR64:$dst, (X86cmov_new GR64:$src1, GR64:$src2,
989 X86_COND_NE, EFLAGS))]>, TB;
990def NEW_CMOVNE64rm: RI<0x45, MRMSrcMem, // if !=, GR64 = [mem64]
991 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
992 "cmovne\t{$src2, $dst|$dst, $src2}",
993 [(set GR64:$dst, (X86cmov_new GR64:$src1, (loadi64 addr:$src2),
994 X86_COND_NE, EFLAGS))]>, TB;
995def NEW_CMOVBE64rr: RI<0x46, MRMSrcReg, // if <=u, GR64 = GR64
996 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
997 "cmovbe\t{$src2, $dst|$dst, $src2}",
998 [(set GR64:$dst, (X86cmov_new GR64:$src1, GR64:$src2,
999 X86_COND_BE, EFLAGS))]>, TB;
1000def NEW_CMOVBE64rm: RI<0x46, MRMSrcMem, // if <=u, GR64 = [mem64]
1001 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1002 "cmovbe\t{$src2, $dst|$dst, $src2}",
1003 [(set GR64:$dst, (X86cmov_new GR64:$src1, (loadi64 addr:$src2),
1004 X86_COND_BE, EFLAGS))]>, TB;
1005def NEW_CMOVA64rr : RI<0x47, MRMSrcReg, // if >u, GR64 = GR64
1006 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
1007 "cmova\t{$src2, $dst|$dst, $src2}",
1008 [(set GR64:$dst, (X86cmov_new GR64:$src1, GR64:$src2,
1009 X86_COND_A, EFLAGS))]>, TB;
1010def NEW_CMOVA64rm : RI<0x47, MRMSrcMem, // if >u, GR64 = [mem64]
1011 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1012 "cmova\t{$src2, $dst|$dst, $src2}",
1013 [(set GR64:$dst, (X86cmov_new GR64:$src1, (loadi64 addr:$src2),
1014 X86_COND_A, EFLAGS))]>, TB;
1015def NEW_CMOVL64rr : RI<0x4C, MRMSrcReg, // if <s, GR64 = GR64
1016 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
1017 "cmovl\t{$src2, $dst|$dst, $src2}",
1018 [(set GR64:$dst, (X86cmov_new GR64:$src1, GR64:$src2,
1019 X86_COND_L, EFLAGS))]>, TB;
1020def NEW_CMOVL64rm : RI<0x4C, MRMSrcMem, // if <s, GR64 = [mem64]
1021 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1022 "cmovl\t{$src2, $dst|$dst, $src2}",
1023 [(set GR64:$dst, (X86cmov_new GR64:$src1, (loadi64 addr:$src2),
1024 X86_COND_L, EFLAGS))]>, TB;
1025def NEW_CMOVGE64rr: RI<0x4D, MRMSrcReg, // if >=s, GR64 = GR64
1026 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
1027 "cmovge\t{$src2, $dst|$dst, $src2}",
1028 [(set GR64:$dst, (X86cmov_new GR64:$src1, GR64:$src2,
1029 X86_COND_GE, EFLAGS))]>, TB;
1030def NEW_CMOVGE64rm: RI<0x4D, MRMSrcMem, // if >=s, GR64 = [mem64]
1031 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1032 "cmovge\t{$src2, $dst|$dst, $src2}",
1033 [(set GR64:$dst, (X86cmov_new GR64:$src1, (loadi64 addr:$src2),
1034 X86_COND_GE, EFLAGS))]>, TB;
1035def NEW_CMOVLE64rr: RI<0x4E, MRMSrcReg, // if <=s, GR64 = GR64
1036 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
1037 "cmovle\t{$src2, $dst|$dst, $src2}",
1038 [(set GR64:$dst, (X86cmov_new GR64:$src1, GR64:$src2,
1039 X86_COND_LE, EFLAGS))]>, TB;
1040def NEW_CMOVLE64rm: RI<0x4E, MRMSrcMem, // if <=s, GR64 = [mem64]
1041 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1042 "cmovle\t{$src2, $dst|$dst, $src2}",
1043 [(set GR64:$dst, (X86cmov_new GR64:$src1, (loadi64 addr:$src2),
1044 X86_COND_LE, EFLAGS))]>, TB;
1045def NEW_CMOVG64rr : RI<0x4F, MRMSrcReg, // if >s, GR64 = GR64
1046 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
1047 "cmovg\t{$src2, $dst|$dst, $src2}",
1048 [(set GR64:$dst, (X86cmov_new GR64:$src1, GR64:$src2,
1049 X86_COND_G, EFLAGS))]>, TB;
1050def NEW_CMOVG64rm : RI<0x4F, MRMSrcMem, // if >s, GR64 = [mem64]
1051 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1052 "cmovg\t{$src2, $dst|$dst, $src2}",
1053 [(set GR64:$dst, (X86cmov_new GR64:$src1, (loadi64 addr:$src2),
1054 X86_COND_G, EFLAGS))]>, TB;
1055def NEW_CMOVS64rr : RI<0x48, MRMSrcReg, // if signed, GR64 = GR64
1056 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
1057 "cmovs\t{$src2, $dst|$dst, $src2}",
1058 [(set GR64:$dst, (X86cmov_new GR64:$src1, GR64:$src2,
1059 X86_COND_S, EFLAGS))]>, TB;
1060def NEW_CMOVS64rm : RI<0x48, MRMSrcMem, // if signed, GR64 = [mem64]
1061 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1062 "cmovs\t{$src2, $dst|$dst, $src2}",
1063 [(set GR64:$dst, (X86cmov_new GR64:$src1, (loadi64 addr:$src2),
1064 X86_COND_S, EFLAGS))]>, TB;
1065def NEW_CMOVNS64rr: RI<0x49, MRMSrcReg, // if !signed, GR64 = GR64
1066 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
1067 "cmovns\t{$src2, $dst|$dst, $src2}",
1068 [(set GR64:$dst, (X86cmov_new GR64:$src1, GR64:$src2,
1069 X86_COND_NS, EFLAGS))]>, TB;
1070def NEW_CMOVNS64rm: RI<0x49, MRMSrcMem, // if !signed, GR64 = [mem64]
1071 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1072 "cmovns\t{$src2, $dst|$dst, $src2}",
1073 [(set GR64:$dst, (X86cmov_new GR64:$src1, (loadi64 addr:$src2),
1074 X86_COND_NS, EFLAGS))]>, TB;
1075def NEW_CMOVP64rr : RI<0x4A, MRMSrcReg, // if parity, GR64 = GR64
1076 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
1077 "cmovp\t{$src2, $dst|$dst, $src2}",
1078 [(set GR64:$dst, (X86cmov_new GR64:$src1, GR64:$src2,
1079 X86_COND_P, EFLAGS))]>, TB;
1080def NEW_CMOVP64rm : RI<0x4A, MRMSrcMem, // if parity, GR64 = [mem64]
1081 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1082 "cmovp\t{$src2, $dst|$dst, $src2}",
1083 [(set GR64:$dst, (X86cmov_new GR64:$src1, (loadi64 addr:$src2),
1084 X86_COND_P, EFLAGS))]>, TB;
1085def NEW_CMOVNP64rr : RI<0x4B, MRMSrcReg, // if !parity, GR64 = GR64
1086 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
1087 "cmovnp\t{$src2, $dst|$dst, $src2}",
1088 [(set GR64:$dst, (X86cmov_new GR64:$src1, GR64:$src2,
1089 X86_COND_NP, EFLAGS))]>, TB;
1090def NEW_CMOVNP64rm : RI<0x4B, MRMSrcMem, // if !parity, GR64 = [mem64]
1091 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1092 "cmovnp\t{$src2, $dst|$dst, $src2}",
1093 [(set GR64:$dst, (X86cmov_new GR64:$src1, (loadi64 addr:$src2),
1094 X86_COND_NP, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001095} // isTwoAddress
1096
1097//===----------------------------------------------------------------------===//
1098// Conversion Instructions...
1099//
1100
1101// f64 -> signed i64
Evan Chengb783fa32007-07-19 01:14:50 +00001102def Int_CVTSD2SI64rr: RSDI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001103 "cvtsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001104 [(set GR64:$dst,
1105 (int_x86_sse2_cvtsd2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001106def Int_CVTSD2SI64rm: RSDI<0x2D, MRMSrcMem, (outs GR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001107 "cvtsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001108 [(set GR64:$dst, (int_x86_sse2_cvtsd2si64
1109 (load addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001110def CVTTSD2SI64rr: RSDI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001111 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001112 [(set GR64:$dst, (fp_to_sint FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001113def CVTTSD2SI64rm: RSDI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001114 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001115 [(set GR64:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001116def Int_CVTTSD2SI64rr: RSDI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001117 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001118 [(set GR64:$dst,
1119 (int_x86_sse2_cvttsd2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001120def Int_CVTTSD2SI64rm: RSDI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001121 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001122 [(set GR64:$dst,
1123 (int_x86_sse2_cvttsd2si64
1124 (load addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001125
1126// Signed i64 -> f64
Evan Chengb783fa32007-07-19 01:14:50 +00001127def CVTSI2SD64rr: RSDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001128 "cvtsi2sd{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001129 [(set FR64:$dst, (sint_to_fp GR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001130def CVTSI2SD64rm: RSDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001131 "cvtsi2sd{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001132 [(set FR64:$dst, (sint_to_fp (loadi64 addr:$src)))]>;
1133let isTwoAddress = 1 in {
1134def Int_CVTSI2SD64rr: RSDI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001135 (outs VR128:$dst), (ins VR128:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001136 "cvtsi2sd{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendling6227d462007-07-23 03:07:27 +00001137 [(set VR128:$dst,
1138 (int_x86_sse2_cvtsi642sd VR128:$src1,
1139 GR64:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001140def Int_CVTSI2SD64rm: RSDI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001141 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001142 "cvtsi2sd{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendling6227d462007-07-23 03:07:27 +00001143 [(set VR128:$dst,
1144 (int_x86_sse2_cvtsi642sd VR128:$src1,
1145 (loadi64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001146} // isTwoAddress
1147
1148// Signed i64 -> f32
Evan Chengb783fa32007-07-19 01:14:50 +00001149def CVTSI2SS64rr: RSSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001150 "cvtsi2ss{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001151 [(set FR32:$dst, (sint_to_fp GR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001152def CVTSI2SS64rm: RSSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001153 "cvtsi2ss{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001154 [(set FR32:$dst, (sint_to_fp (loadi64 addr:$src)))]>;
1155let isTwoAddress = 1 in {
1156def Int_CVTSI2SS64rr: RSSI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001157 (outs VR128:$dst), (ins VR128:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001158 "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001159 []>; // TODO: add intrinsic
1160def Int_CVTSI2SS64rm: RSSI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001161 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001162 "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001163 []>; // TODO: add intrinsic
1164} // isTwoAddress
1165
1166// f32 -> signed i64
Evan Chengb783fa32007-07-19 01:14:50 +00001167def Int_CVTSS2SI64rr: RSSI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001168 "cvtss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001169 [(set GR64:$dst,
1170 (int_x86_sse_cvtss2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001171def Int_CVTSS2SI64rm: RSSI<0x2D, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001172 "cvtss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001173 [(set GR64:$dst, (int_x86_sse_cvtss2si64
1174 (load addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001175def CVTTSS2SI64rr: RSSI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001176 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001177 [(set GR64:$dst, (fp_to_sint FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001178def CVTTSS2SI64rm: RSSI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001179 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001180 [(set GR64:$dst, (fp_to_sint (loadf32 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001181def Int_CVTTSS2SI64rr: RSSI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001182 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001183 [(set GR64:$dst,
1184 (int_x86_sse_cvttss2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001185def Int_CVTTSS2SI64rm: RSSI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001186 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001187 [(set GR64:$dst,
1188 (int_x86_sse_cvttss2si64 (load addr:$src)))]>;
1189
1190let isTwoAddress = 1 in {
1191 def Int_CVTSI642SSrr : RSSI<0x2A, MRMSrcReg,
1192 (outs VR128:$dst), (ins VR128:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001193 "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendling6227d462007-07-23 03:07:27 +00001194 [(set VR128:$dst,
1195 (int_x86_sse_cvtsi642ss VR128:$src1,
1196 GR64:$src2))]>;
1197 def Int_CVTSI642SSrm : RSSI<0x2A, MRMSrcMem,
1198 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001199 "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendling6227d462007-07-23 03:07:27 +00001200 [(set VR128:$dst,
1201 (int_x86_sse_cvtsi642ss VR128:$src1,
1202 (loadi64 addr:$src2)))]>;
1203}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001204
1205//===----------------------------------------------------------------------===//
1206// Alias Instructions
1207//===----------------------------------------------------------------------===//
1208
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001209// Zero-extension
1210// TODO: Remove this after proper i32 -> i64 zext support.
Evan Chengb783fa32007-07-19 01:14:50 +00001211def PsMOVZX64rr32: I<0x89, MRMDestReg, (outs GR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001212 "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001213 [(set GR64:$dst, (zext GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001214def PsMOVZX64rm32: I<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001215 "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001216 [(set GR64:$dst, (zextloadi64i32 addr:$src))]>;
1217
1218
Dan Gohman027cd112007-09-17 14:55:08 +00001219// Alias instructions that map movr0 to xor. Use xorl instead of xorq; it's
1220// equivalent due to implicit zero-extending, and it sometimes has a smaller
1221// encoding.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001222// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
1223// FIXME: AddedComplexity gives MOV64r0 a higher priority than MOV64ri32. Remove
1224// when we have a better way to specify isel priority.
Evan Cheng55687072007-09-14 21:48:26 +00001225let Defs = [EFLAGS], AddedComplexity = 1, isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001226def MOV64r0 : RI<0x31, MRMInitReg, (outs GR64:$dst), (ins),
Dan Gohman027cd112007-09-17 14:55:08 +00001227 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001228 [(set GR64:$dst, 0)]>;
1229
1230// Materialize i64 constant where top 32-bits are zero.
Dan Gohman8aef09b2007-09-07 21:32:51 +00001231let AddedComplexity = 1, isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001232def MOV64ri64i32 : Ii32<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001233 "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001234 [(set GR64:$dst, i64immZExt32:$src)]>;
1235
1236//===----------------------------------------------------------------------===//
1237// Non-Instruction Patterns
1238//===----------------------------------------------------------------------===//
1239
1240// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
1241def : Pat<(i64 (X86Wrapper tconstpool :$dst)),
1242 (MOV64ri tconstpool :$dst)>, Requires<[NotSmallCode]>;
1243def : Pat<(i64 (X86Wrapper tjumptable :$dst)),
1244 (MOV64ri tjumptable :$dst)>, Requires<[NotSmallCode]>;
1245def : Pat<(i64 (X86Wrapper tglobaladdr :$dst)),
1246 (MOV64ri tglobaladdr :$dst)>, Requires<[NotSmallCode]>;
1247def : Pat<(i64 (X86Wrapper texternalsym:$dst)),
1248 (MOV64ri texternalsym:$dst)>, Requires<[NotSmallCode]>;
1249
1250def : Pat<(store (i64 (X86Wrapper tconstpool:$src)), addr:$dst),
1251 (MOV64mi32 addr:$dst, tconstpool:$src)>,
Evan Cheng415e2e92007-08-01 23:46:10 +00001252 Requires<[SmallCode, HasLow4G, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001253def : Pat<(store (i64 (X86Wrapper tjumptable:$src)), addr:$dst),
1254 (MOV64mi32 addr:$dst, tjumptable:$src)>,
Evan Cheng415e2e92007-08-01 23:46:10 +00001255 Requires<[SmallCode, HasLow4G, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001256def : Pat<(store (i64 (X86Wrapper tglobaladdr:$src)), addr:$dst),
1257 (MOV64mi32 addr:$dst, tglobaladdr:$src)>,
Evan Cheng415e2e92007-08-01 23:46:10 +00001258 Requires<[SmallCode, HasLow4G, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001259def : Pat<(store (i64 (X86Wrapper texternalsym:$src)), addr:$dst),
1260 (MOV64mi32 addr:$dst, texternalsym:$src)>,
Evan Cheng415e2e92007-08-01 23:46:10 +00001261 Requires<[SmallCode, HasLow4G, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001262
1263// Calls
1264// Direct PC relative function call for small code model. 32-bit displacement
1265// sign extended to 64-bit.
1266def : Pat<(X86call (i64 tglobaladdr:$dst)),
1267 (CALL64pcrel32 tglobaladdr:$dst)>;
1268def : Pat<(X86call (i64 texternalsym:$dst)),
1269 (CALL64pcrel32 texternalsym:$dst)>;
1270
1271def : Pat<(X86tailcall (i64 tglobaladdr:$dst)),
1272 (CALL64pcrel32 tglobaladdr:$dst)>;
1273def : Pat<(X86tailcall (i64 texternalsym:$dst)),
1274 (CALL64pcrel32 texternalsym:$dst)>;
1275
1276def : Pat<(X86tailcall GR64:$dst),
1277 (CALL64r GR64:$dst)>;
1278
Dan Gohmanec596042007-09-17 14:35:24 +00001279// Comparisons.
1280
1281// TEST R,R is smaller than CMP R,0
1282def : Pat<(X86cmp GR64:$src1, 0),
1283 (TEST64rr GR64:$src1, GR64:$src1)>;
1284
Evan Cheng950aac02007-09-25 01:57:46 +00001285def : Pat<(parallel (X86cmp_new GR64:$src1, 0), (implicit EFLAGS)),
1286 (NEW_TEST64rr GR64:$src1, GR64:$src1)>;
1287
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001288// {s|z}extload bool -> {s|z}extload byte
1289def : Pat<(sextloadi64i1 addr:$src), (MOVSX64rm8 addr:$src)>;
1290def : Pat<(zextloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>;
1291
1292// extload
1293def : Pat<(extloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>;
1294def : Pat<(extloadi64i8 addr:$src), (MOVZX64rm8 addr:$src)>;
1295def : Pat<(extloadi64i16 addr:$src), (MOVZX64rm16 addr:$src)>;
1296def : Pat<(extloadi64i32 addr:$src), (PsMOVZX64rm32 addr:$src)>;
1297
1298// anyext -> zext
1299def : Pat<(i64 (anyext GR8 :$src)), (MOVZX64rr8 GR8 :$src)>;
1300def : Pat<(i64 (anyext GR16:$src)), (MOVZX64rr16 GR16:$src)>;
1301def : Pat<(i64 (anyext GR32:$src)), (PsMOVZX64rr32 GR32:$src)>;
1302def : Pat<(i64 (anyext (loadi8 addr:$src))), (MOVZX64rm8 addr:$src)>;
1303def : Pat<(i64 (anyext (loadi16 addr:$src))), (MOVZX64rm16 addr:$src)>;
1304def : Pat<(i64 (anyext (loadi32 addr:$src))), (PsMOVZX64rm32 addr:$src)>;
1305
1306//===----------------------------------------------------------------------===//
1307// Some peepholes
1308//===----------------------------------------------------------------------===//
1309
1310// (shl x, 1) ==> (add x, x)
1311def : Pat<(shl GR64:$src1, (i8 1)), (ADD64rr GR64:$src1, GR64:$src1)>;
1312
1313// (or (x >> c) | (y << (64 - c))) ==> (shrd64 x, y, c)
1314def : Pat<(or (srl GR64:$src1, CL:$amt),
1315 (shl GR64:$src2, (sub 64, CL:$amt))),
1316 (SHRD64rrCL GR64:$src1, GR64:$src2)>;
1317
1318def : Pat<(store (or (srl (loadi64 addr:$dst), CL:$amt),
1319 (shl GR64:$src2, (sub 64, CL:$amt))), addr:$dst),
1320 (SHRD64mrCL addr:$dst, GR64:$src2)>;
1321
1322// (or (x << c) | (y >> (64 - c))) ==> (shld64 x, y, c)
1323def : Pat<(or (shl GR64:$src1, CL:$amt),
1324 (srl GR64:$src2, (sub 64, CL:$amt))),
1325 (SHLD64rrCL GR64:$src1, GR64:$src2)>;
1326
1327def : Pat<(store (or (shl (loadi64 addr:$dst), CL:$amt),
1328 (srl GR64:$src2, (sub 64, CL:$amt))), addr:$dst),
1329 (SHLD64mrCL addr:$dst, GR64:$src2)>;
1330
1331// X86 specific add which produces a flag.
1332def : Pat<(addc GR64:$src1, GR64:$src2),
1333 (ADD64rr GR64:$src1, GR64:$src2)>;
1334def : Pat<(addc GR64:$src1, (load addr:$src2)),
1335 (ADD64rm GR64:$src1, addr:$src2)>;
1336def : Pat<(addc GR64:$src1, i64immSExt32:$src2),
1337 (ADD64ri32 GR64:$src1, imm:$src2)>;
1338def : Pat<(addc GR64:$src1, i64immSExt8:$src2),
1339 (ADD64ri8 GR64:$src1, i64immSExt8:$src2)>;
1340
1341def : Pat<(subc GR64:$src1, GR64:$src2),
1342 (SUB64rr GR64:$src1, GR64:$src2)>;
1343def : Pat<(subc GR64:$src1, (load addr:$src2)),
1344 (SUB64rm GR64:$src1, addr:$src2)>;
1345def : Pat<(subc GR64:$src1, imm:$src2),
1346 (SUB64ri32 GR64:$src1, i64immSExt32:$src2)>;
1347def : Pat<(subc GR64:$src1, i64immSExt8:$src2),
1348 (SUB64ri8 GR64:$src1, i64immSExt8:$src2)>;
1349
1350
1351//===----------------------------------------------------------------------===//
1352// X86-64 SSE Instructions
1353//===----------------------------------------------------------------------===//
1354
1355// Move instructions...
1356
Evan Chengb783fa32007-07-19 01:14:50 +00001357def MOV64toPQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001358 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001359 [(set VR128:$dst,
1360 (v2i64 (scalar_to_vector GR64:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001361def MOV64toPQIrm : RPDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001362 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001363 [(set VR128:$dst,
1364 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>;
1365
Evan Chengb783fa32007-07-19 01:14:50 +00001366def MOVPQIto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001367 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001368 [(set GR64:$dst, (vector_extract (v2i64 VR128:$src),
1369 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001370def MOVPQIto64mr : RPDI<0x7E, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001371 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001372 [(store (i64 (vector_extract (v2i64 VR128:$src),
1373 (iPTR 0))), addr:$dst)]>;
1374
Evan Chengb783fa32007-07-19 01:14:50 +00001375def MOV64toSDrr : RPDI<0x6E, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001376 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001377 [(set FR64:$dst, (bitconvert GR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001378def MOV64toSDrm : RPDI<0x6E, MRMSrcMem, (outs FR64:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001379 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001380 [(set FR64:$dst, (bitconvert (loadi64 addr:$src)))]>;
1381
Evan Chengb783fa32007-07-19 01:14:50 +00001382def MOVSDto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001383 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001384 [(set GR64:$dst, (bitconvert FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001385def MOVSDto64mr : RPDI<0x7E, MRMDestMem, (outs), (ins i64mem:$dst, FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001386 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001387 [(store (i64 (bitconvert FR64:$src)), addr:$dst)]>;