blob: 077e9dc8a63fca9e537aa0ea99bddaa239a4758c [file] [log] [blame]
Arnold Schwaighofer373e8652007-10-12 21:30:57 +00001//====- X86InstrX86-64.td - Describe the X86 Instr. Set ----*- tablegen -*-===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002//
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,
Evan Cheng6e8b8bd2007-09-27 19:01:55 +000096 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS] 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
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000105
106
107let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
108def TCRETURNdi64 : I<0, Pseudo, (outs), (ins i64imm:$dst, i32imm:$offset),
109 "#TC_RETURN $dst $offset",
110 []>;
111
112let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
113def TCRETURNri64 : I<0, Pseudo, (outs), (ins GR64:$dst, i32imm:$offset),
114 "#TC_RETURN $dst $offset",
115 []>;
116
117
118let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
119 def TAILJMPr64 : I<0xFF, MRM4r, (outs), (ins GR64:$dst), "jmp{q}\t{*}$dst # TAILCALL",
120 []>;
121
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000122// Branches
Evan Cheng37e7c752007-07-21 00:34:19 +0000123let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000124 def JMP64r : I<0xFF, MRM4r, (outs), (ins GR64:$dst), "jmp{q}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000125 [(brind GR64:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000126 def JMP64m : I<0xFF, MRM4m, (outs), (ins i64mem:$dst), "jmp{q}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000127 [(brind (loadi64 addr:$dst))]>;
128}
129
130//===----------------------------------------------------------------------===//
131// Miscellaneous Instructions...
132//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000133let Defs = [RBP,RSP], Uses = [RBP,RSP] in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000134def LEAVE64 : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000135 (outs), (ins), "leave", []>;
136let Defs = [RSP], Uses = [RSP] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000137def POP64r : I<0x58, AddRegFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000138 (outs GR64:$reg), (ins), "pop{q}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000139def PUSH64r : I<0x50, AddRegFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000140 (outs), (ins GR64:$reg), "push{q}\t$reg", []>;
141}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000142
Evan Chengd8434332007-09-26 01:29:06 +0000143let Defs = [RSP, EFLAGS], Uses = [RSP] in
Evan Chengf1341312007-09-26 21:28:00 +0000144def POPFQ : I<0x9D, RawFrm, (outs), (ins), "popf", []>, REX_W;
Evan Chengd8434332007-09-26 01:29:06 +0000145let Defs = [RSP], Uses = [RSP, EFLAGS] in
Evan Chengf1341312007-09-26 21:28:00 +0000146def PUSHFQ : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000147
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000148def LEA64_32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000149 (outs GR32:$dst), (ins lea64_32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000150 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000151 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In64BitMode]>;
152
Evan Chengb783fa32007-07-19 01:14:50 +0000153def LEA64r : RI<0x8D, MRMSrcMem, (outs GR64:$dst), (ins lea64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000154 "lea{q}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000155 [(set GR64:$dst, lea64addr:$src)]>;
156
157let isTwoAddress = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000158def BSWAP64r : RI<0xC8, AddRegFrm, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000159 "bswap{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000160 [(set GR64:$dst, (bswap GR64:$src))]>, TB;
161// Exchange
Evan Chengb783fa32007-07-19 01:14:50 +0000162def XCHG64rr : RI<0x87, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000163 "xchg{q}\t{$src2|$src1}, {$src1|$src2}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000164def XCHG64mr : RI<0x87, MRMDestMem, (outs), (ins i64mem:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000165 "xchg{q}\t{$src2|$src1}, {$src1|$src2}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000166def XCHG64rm : RI<0x87, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000167 "xchg{q}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000168
169// Repeat string ops
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000170let Defs = [RCX,RDI,RSI], Uses = [RCX,RDI,RSI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000171def REP_MOVSQ : RI<0xA5, RawFrm, (outs), (ins), "{rep;movsq|rep movsq}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000172 [(X86rep_movs i64)]>, REP;
173let Defs = [RCX,RDI], Uses = [RAX,RCX,RDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000174def REP_STOSQ : RI<0xAB, RawFrm, (outs), (ins), "{rep;stosq|rep stosq}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000175 [(X86rep_stos i64)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000176
177//===----------------------------------------------------------------------===//
178// Move Instructions...
179//
180
Evan Chengb783fa32007-07-19 01:14:50 +0000181def MOV64rr : RI<0x89, MRMDestReg, (outs GR64:$dst), (ins 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
Dan Gohman8aef09b2007-09-07 21:32:51 +0000184let isReMaterializable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000185def MOV64ri : RIi64<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000186 "movabs{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000187 [(set GR64:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000188def MOV64ri32 : RIi32<0xC7, MRM0r, (outs GR64:$dst), (ins i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000189 "mov{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000190 [(set GR64:$dst, i64immSExt32:$src)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +0000191}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000192
Evan Cheng4e84e452007-08-30 05:49:43 +0000193let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000194def MOV64rm : RI<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000195 "mov{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000196 [(set GR64:$dst, (load addr:$src))]>;
197
Evan Chengb783fa32007-07-19 01:14:50 +0000198def MOV64mr : RI<0x89, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000199 "mov{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000200 [(store GR64:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000201def MOV64mi32 : RIi32<0xC7, MRM0m, (outs), (ins i64mem:$dst, i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000202 "mov{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000203 [(store i64immSExt32:$src, addr:$dst)]>;
204
205// Sign/Zero extenders
206
Evan Chengb783fa32007-07-19 01:14:50 +0000207def MOVSX64rr8 : RI<0xBE, MRMSrcReg, (outs GR64:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000208 "movs{bq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000209 [(set GR64:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000210def MOVSX64rm8 : RI<0xBE, MRMSrcMem, (outs GR64:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000211 "movs{bq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000212 [(set GR64:$dst, (sextloadi64i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000213def MOVSX64rr16: RI<0xBF, MRMSrcReg, (outs GR64:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000214 "movs{wq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000215 [(set GR64:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000216def MOVSX64rm16: RI<0xBF, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000217 "movs{wq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000218 [(set GR64:$dst, (sextloadi64i16 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000219def MOVSX64rr32: RI<0x63, MRMSrcReg, (outs GR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000220 "movs{lq|xd}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000221 [(set GR64:$dst, (sext GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000222def MOVSX64rm32: RI<0x63, MRMSrcMem, (outs GR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000223 "movs{lq|xd}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000224 [(set GR64:$dst, (sextloadi64i32 addr:$src))]>;
225
Evan Chengb783fa32007-07-19 01:14:50 +0000226def MOVZX64rr8 : RI<0xB6, MRMSrcReg, (outs GR64:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000227 "movz{bq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000228 [(set GR64:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000229def MOVZX64rm8 : RI<0xB6, MRMSrcMem, (outs GR64:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000230 "movz{bq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000231 [(set GR64:$dst, (zextloadi64i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000232def MOVZX64rr16: RI<0xB7, MRMSrcReg, (outs GR64:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000233 "movz{wq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000234 [(set GR64:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000235def MOVZX64rm16: RI<0xB7, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000236 "movz{wq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000237 [(set GR64:$dst, (zextloadi64i16 addr:$src))]>, TB;
238
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000239let Defs = [RAX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000240def CDQE : RI<0x98, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000241 "{cltq|cdqe}", []>; // RAX = signext(EAX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000242
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000243let Defs = [RAX,RDX], Uses = [RAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000244def CQO : RI<0x99, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000245 "{cqto|cqo}", []>; // RDX:RAX = signext(RAX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000246
247//===----------------------------------------------------------------------===//
248// Arithmetic Instructions...
249//
250
Evan Cheng55687072007-09-14 21:48:26 +0000251let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000252let isTwoAddress = 1 in {
253let isConvertibleToThreeAddress = 1 in {
254let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000255def ADD64rr : RI<0x01, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, 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 [(set GR64:$dst, (add GR64:$src1, GR64:$src2))]>;
258
Evan Chengb783fa32007-07-19 01:14:50 +0000259def ADD64ri32 : RIi32<0x81, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000260 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000261 [(set GR64:$dst, (add GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000262def ADD64ri8 : RIi8<0x83, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000263 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000264 [(set GR64:$dst, (add GR64:$src1, i64immSExt8:$src2))]>;
265} // isConvertibleToThreeAddress
266
Evan Chengb783fa32007-07-19 01:14:50 +0000267def ADD64rm : RI<0x03, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000268 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000269 [(set GR64:$dst, (add GR64:$src1, (load addr:$src2)))]>;
270} // isTwoAddress
271
Evan Chengb783fa32007-07-19 01:14:50 +0000272def ADD64mr : RI<0x01, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000273 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000274 [(store (add (load addr:$dst), GR64:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000275def ADD64mi32 : RIi32<0x81, MRM0m, (outs), (ins i64mem:$dst, i64i32imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000276 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000277 [(store (add (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000278def ADD64mi8 : RIi8<0x83, MRM0m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000279 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000280 [(store (add (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
281
Evan Cheng259471d2007-10-05 17:59:57 +0000282let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000283let isTwoAddress = 1 in {
284let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000285def ADC64rr : RI<0x11, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000286 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000287 [(set GR64:$dst, (adde GR64:$src1, GR64:$src2))]>;
288
Evan Chengb783fa32007-07-19 01:14:50 +0000289def ADC64rm : RI<0x13, MRMSrcMem , (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000290 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000291 [(set GR64:$dst, (adde GR64:$src1, (load addr:$src2)))]>;
292
Evan Chengb783fa32007-07-19 01:14:50 +0000293def ADC64ri32 : RIi32<0x81, MRM2r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000294 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000295 [(set GR64:$dst, (adde GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000296def ADC64ri8 : RIi8<0x83, MRM2r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000297 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000298 [(set GR64:$dst, (adde GR64:$src1, i64immSExt8:$src2))]>;
299} // isTwoAddress
300
Evan Chengb783fa32007-07-19 01:14:50 +0000301def ADC64mr : RI<0x11, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000302 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000303 [(store (adde (load addr:$dst), GR64:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000304def ADC64mi32 : RIi32<0x81, MRM2m, (outs), (ins i64mem:$dst, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000305 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000306 [(store (adde (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000307def ADC64mi8 : RIi8<0x83, MRM2m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000308 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000309 [(store (adde (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
Evan Cheng259471d2007-10-05 17:59:57 +0000310} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000311
312let isTwoAddress = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000313def SUB64rr : RI<0x29, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000314 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000315 [(set GR64:$dst, (sub GR64:$src1, GR64:$src2))]>;
316
Evan Chengb783fa32007-07-19 01:14:50 +0000317def SUB64rm : RI<0x2B, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000318 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000319 [(set GR64:$dst, (sub GR64:$src1, (load addr:$src2)))]>;
320
Evan Chengb783fa32007-07-19 01:14:50 +0000321def SUB64ri32 : RIi32<0x81, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000322 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000323 [(set GR64:$dst, (sub GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000324def SUB64ri8 : RIi8<0x83, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000325 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000326 [(set GR64:$dst, (sub GR64:$src1, i64immSExt8:$src2))]>;
327} // isTwoAddress
328
Evan Chengb783fa32007-07-19 01:14:50 +0000329def SUB64mr : RI<0x29, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000330 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000331 [(store (sub (load addr:$dst), GR64:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000332def SUB64mi32 : RIi32<0x81, MRM5m, (outs), (ins i64mem:$dst, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000333 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000334 [(store (sub (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000335def SUB64mi8 : RIi8<0x83, MRM5m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000336 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000337 [(store (sub (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
338
Evan Cheng259471d2007-10-05 17:59:57 +0000339let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000340let isTwoAddress = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000341def SBB64rr : RI<0x19, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000342 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000343 [(set GR64:$dst, (sube GR64:$src1, GR64:$src2))]>;
344
Evan Chengb783fa32007-07-19 01:14:50 +0000345def SBB64rm : RI<0x1B, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000346 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000347 [(set GR64:$dst, (sube GR64:$src1, (load addr:$src2)))]>;
348
Evan Chengb783fa32007-07-19 01:14:50 +0000349def SBB64ri32 : RIi32<0x81, MRM3r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000350 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000351 [(set GR64:$dst, (sube GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000352def SBB64ri8 : RIi8<0x83, MRM3r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000353 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000354 [(set GR64:$dst, (sube GR64:$src1, i64immSExt8:$src2))]>;
355} // isTwoAddress
356
Evan Chengb783fa32007-07-19 01:14:50 +0000357def SBB64mr : RI<0x19, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000358 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000359 [(store (sube (load addr:$dst), GR64:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000360def SBB64mi32 : RIi32<0x81, MRM3m, (outs), (ins i64mem:$dst, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000361 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000362 [(store (sube (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000363def SBB64mi8 : RIi8<0x83, MRM3m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000364 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000365 [(store (sube (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
Evan Cheng259471d2007-10-05 17:59:57 +0000366} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +0000367} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000368
369// Unsigned multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000370let Defs = [RAX,RDX,EFLAGS], Uses = [RAX] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000371def MUL64r : RI<0xF7, MRM4r, (outs), (ins GR64:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000372 "mul{q}\t$src", []>; // RAX,RDX = RAX*GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000373def MUL64m : RI<0xF7, MRM4m, (outs), (ins i64mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000374 "mul{q}\t$src", []>; // RAX,RDX = RAX*[mem64]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000375
376// Signed multiplication
Evan Chengb783fa32007-07-19 01:14:50 +0000377def IMUL64r : RI<0xF7, MRM5r, (outs), (ins GR64:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000378 "imul{q}\t$src", []>; // RAX,RDX = RAX*GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000379def IMUL64m : RI<0xF7, MRM5m, (outs), (ins i64mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000380 "imul{q}\t$src", []>; // RAX,RDX = RAX*[mem64]
381}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000382
Evan Cheng55687072007-09-14 21:48:26 +0000383let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000384let isTwoAddress = 1 in {
385let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000386def IMUL64rr : RI<0xAF, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000387 "imul{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000388 [(set GR64:$dst, (mul GR64:$src1, GR64:$src2))]>, TB;
389
Evan Chengb783fa32007-07-19 01:14:50 +0000390def IMUL64rm : RI<0xAF, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000391 "imul{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000392 [(set GR64:$dst, (mul GR64:$src1, (load addr:$src2)))]>, TB;
393} // isTwoAddress
394
395// Suprisingly enough, these are not two address instructions!
396def IMUL64rri32 : RIi32<0x69, MRMSrcReg, // GR64 = GR64*I32
Evan Chengb783fa32007-07-19 01:14:50 +0000397 (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000398 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000399 [(set GR64:$dst, (mul GR64:$src1, i64immSExt32:$src2))]>;
400def IMUL64rri8 : RIi8<0x6B, MRMSrcReg, // GR64 = GR64*I8
Evan Chengb783fa32007-07-19 01:14:50 +0000401 (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000402 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000403 [(set GR64:$dst, (mul GR64:$src1, i64immSExt8:$src2))]>;
404def IMUL64rmi32 : RIi32<0x69, MRMSrcMem, // GR64 = [mem64]*I32
Evan Chengb783fa32007-07-19 01:14:50 +0000405 (outs GR64:$dst), (ins i64mem:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000406 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000407 [(set GR64:$dst, (mul (load addr:$src1), i64immSExt32:$src2))]>;
408def IMUL64rmi8 : RIi8<0x6B, MRMSrcMem, // GR64 = [mem64]*I8
Evan Chengb783fa32007-07-19 01:14:50 +0000409 (outs GR64:$dst), (ins i64mem:$src1, i64i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000410 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000411 [(set GR64:$dst, (mul (load addr:$src1), i64immSExt8:$src2))]>;
Evan Cheng55687072007-09-14 21:48:26 +0000412} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000413
414// Unsigned division / remainder
Evan Cheng55687072007-09-14 21:48:26 +0000415let Defs = [RAX,RDX,EFLAGS], Uses = [RAX,RDX] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000416def DIV64r : RI<0xF7, MRM6r, (outs), (ins GR64:$src), // RDX:RAX/r64 = RAX,RDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000417 "div{q}\t$src", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000418def DIV64m : RI<0xF7, MRM6m, (outs), (ins i64mem:$src), // RDX:RAX/[mem64] = RAX,RDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000419 "div{q}\t$src", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000420
421// Signed division / remainder
Evan Chengb783fa32007-07-19 01:14:50 +0000422def IDIV64r: RI<0xF7, MRM7r, (outs), (ins GR64:$src), // RDX:RAX/r64 = RAX,RDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000423 "idiv{q}\t$src", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000424def IDIV64m: RI<0xF7, MRM7m, (outs), (ins i64mem:$src), // RDX:RAX/[mem64] = RAX,RDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000425 "idiv{q}\t$src", []>;
426}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000427
428// Unary instructions
Evan Cheng55687072007-09-14 21:48:26 +0000429let Defs = [EFLAGS], CodeSize = 2 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000430let isTwoAddress = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000431def NEG64r : RI<0xF7, MRM3r, (outs GR64:$dst), (ins GR64:$src), "neg{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000432 [(set GR64:$dst, (ineg GR64:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000433def NEG64m : RI<0xF7, MRM3m, (outs), (ins i64mem:$dst), "neg{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000434 [(store (ineg (loadi64 addr:$dst)), addr:$dst)]>;
435
436let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000437def INC64r : RI<0xFF, MRM0r, (outs GR64:$dst), (ins GR64:$src), "inc{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000438 [(set GR64:$dst, (add GR64:$src, 1))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000439def INC64m : RI<0xFF, MRM0m, (outs), (ins i64mem:$dst), "inc{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000440 [(store (add (loadi64 addr:$dst), 1), addr:$dst)]>;
441
442let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000443def DEC64r : RI<0xFF, MRM1r, (outs GR64:$dst), (ins GR64:$src), "dec{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000444 [(set GR64:$dst, (add GR64:$src, -1))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000445def DEC64m : RI<0xFF, MRM1m, (outs), (ins i64mem:$dst), "dec{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000446 [(store (add (loadi64 addr:$dst), -1), addr:$dst)]>;
447
448// In 64-bit mode, single byte INC and DEC cannot be encoded.
449let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in {
450// Can transform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +0000451def INC64_16r : I<0xFF, MRM0r, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000452 [(set GR16:$dst, (add GR16:$src, 1))]>,
453 OpSize, Requires<[In64BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000454def INC64_32r : I<0xFF, MRM0r, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000455 [(set GR32:$dst, (add GR32:$src, 1))]>,
456 Requires<[In64BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000457def DEC64_16r : I<0xFF, MRM1r, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000458 [(set GR16:$dst, (add GR16:$src, -1))]>,
459 OpSize, Requires<[In64BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000460def DEC64_32r : I<0xFF, MRM1r, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000461 [(set GR32:$dst, (add GR32:$src, -1))]>,
462 Requires<[In64BitMode]>;
463} // isConvertibleToThreeAddress
Evan Cheng55687072007-09-14 21:48:26 +0000464} // Defs = [EFLAGS], CodeSize
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000465
466
Evan Cheng55687072007-09-14 21:48:26 +0000467let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000468// Shift instructions
469let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000470let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000471def SHL64rCL : RI<0xD3, MRM4r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000472 "shl{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000473 [(set GR64:$dst, (shl GR64:$src, CL))]>;
Evan Chenga98f6272007-10-05 18:20:36 +0000474let isConvertibleToThreeAddress = 1 in // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +0000475def SHL64ri : RIi8<0xC1, MRM4r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000476 "shl{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000477 [(set GR64:$dst, (shl GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000478def SHL64r1 : RI<0xD1, MRM4r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000479 "shl{q}\t$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000480} // isTwoAddress
481
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000482let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000483def SHL64mCL : RI<0xD3, MRM4m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000484 "shl{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000485 [(store (shl (loadi64 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000486def SHL64mi : RIi8<0xC1, MRM4m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000487 "shl{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000488 [(store (shl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000489def SHL64m1 : RI<0xD1, MRM4m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000490 "shl{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000491 [(store (shl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
492
493let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000494let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000495def SHR64rCL : RI<0xD3, MRM5r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000496 "shr{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000497 [(set GR64:$dst, (srl GR64:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000498def SHR64ri : RIi8<0xC1, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000499 "shr{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000500 [(set GR64:$dst, (srl GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000501def SHR64r1 : RI<0xD1, MRM5r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000502 "shr{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000503 [(set GR64:$dst, (srl GR64:$src1, (i8 1)))]>;
504} // isTwoAddress
505
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000506let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000507def SHR64mCL : RI<0xD3, MRM5m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000508 "shr{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000509 [(store (srl (loadi64 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000510def SHR64mi : RIi8<0xC1, MRM5m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000511 "shr{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000512 [(store (srl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000513def SHR64m1 : RI<0xD1, MRM5m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000514 "shr{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000515 [(store (srl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
516
517let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000518let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000519def SAR64rCL : RI<0xD3, MRM7r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000520 "sar{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000521 [(set GR64:$dst, (sra GR64:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000522def SAR64ri : RIi8<0xC1, MRM7r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000523 "sar{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000524 [(set GR64:$dst, (sra GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000525def SAR64r1 : RI<0xD1, MRM7r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000526 "sar{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000527 [(set GR64:$dst, (sra GR64:$src1, (i8 1)))]>;
528} // isTwoAddress
529
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000530let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000531def SAR64mCL : RI<0xD3, MRM7m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000532 "sar{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000533 [(store (sra (loadi64 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000534def SAR64mi : RIi8<0xC1, MRM7m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000535 "sar{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000536 [(store (sra (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000537def SAR64m1 : RI<0xD1, MRM7m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000538 "sar{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000539 [(store (sra (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
540
541// Rotate instructions
542let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000543let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000544def ROL64rCL : RI<0xD3, MRM0r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000545 "rol{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000546 [(set GR64:$dst, (rotl GR64:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000547def ROL64ri : RIi8<0xC1, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000548 "rol{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000549 [(set GR64:$dst, (rotl GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000550def ROL64r1 : RI<0xD1, MRM0r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000551 "rol{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000552 [(set GR64:$dst, (rotl GR64:$src1, (i8 1)))]>;
553} // isTwoAddress
554
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000555let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000556def ROL64mCL : I<0xD3, MRM0m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000557 "rol{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000558 [(store (rotl (loadi64 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000559def ROL64mi : RIi8<0xC1, MRM0m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000560 "rol{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000561 [(store (rotl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000562def ROL64m1 : RI<0xD1, MRM0m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000563 "rol{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000564 [(store (rotl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
565
566let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000567let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000568def ROR64rCL : RI<0xD3, MRM1r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000569 "ror{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000570 [(set GR64:$dst, (rotr GR64:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000571def ROR64ri : RIi8<0xC1, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000572 "ror{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000573 [(set GR64:$dst, (rotr GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000574def ROR64r1 : RI<0xD1, MRM1r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000575 "ror{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000576 [(set GR64:$dst, (rotr GR64:$src1, (i8 1)))]>;
577} // isTwoAddress
578
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000579let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000580def ROR64mCL : RI<0xD3, MRM1m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000581 "ror{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000582 [(store (rotr (loadi64 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000583def ROR64mi : RIi8<0xC1, MRM1m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000584 "ror{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000585 [(store (rotr (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000586def ROR64m1 : RI<0xD1, MRM1m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000587 "ror{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000588 [(store (rotr (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
589
590// Double shift instructions (generalizations of rotate)
591let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000592let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000593def SHLD64rrCL : RI<0xA5, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000594 "shld{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
595 [(set GR64:$dst, (X86shld GR64:$src1, GR64:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000596def SHRD64rrCL : RI<0xAD, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000597 "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
598 [(set GR64:$dst, (X86shrd GR64:$src1, GR64:$src2, CL))]>, TB;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000599}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000600
601let isCommutable = 1 in { // FIXME: Update X86InstrInfo::commuteInstruction
602def SHLD64rri8 : RIi8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000603 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2, i8imm:$src3),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000604 "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
605 [(set GR64:$dst, (X86shld GR64:$src1, GR64:$src2,
606 (i8 imm:$src3)))]>,
607 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000608def SHRD64rri8 : RIi8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000609 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2, i8imm:$src3),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000610 "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
611 [(set GR64:$dst, (X86shrd GR64:$src1, GR64:$src2,
612 (i8 imm:$src3)))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000613 TB;
614} // isCommutable
615} // isTwoAddress
616
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000617let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000618def SHLD64mrCL : RI<0xA5, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000619 "shld{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
620 [(store (X86shld (loadi64 addr:$dst), GR64:$src2, CL),
621 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000622def SHRD64mrCL : RI<0xAD, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000623 "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
624 [(store (X86shrd (loadi64 addr:$dst), GR64:$src2, CL),
625 addr:$dst)]>, TB;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000626}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000627def SHLD64mri8 : RIi8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000628 (outs), (ins i64mem:$dst, GR64:$src2, i8imm:$src3),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000629 "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
630 [(store (X86shld (loadi64 addr:$dst), GR64:$src2,
631 (i8 imm:$src3)), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000632 TB;
633def SHRD64mri8 : RIi8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000634 (outs), (ins i64mem:$dst, GR64:$src2, i8imm:$src3),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000635 "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
636 [(store (X86shrd (loadi64 addr:$dst), GR64:$src2,
637 (i8 imm:$src3)), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000638 TB;
Evan Cheng55687072007-09-14 21:48:26 +0000639} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000640
641//===----------------------------------------------------------------------===//
642// Logical Instructions...
643//
644
645let isTwoAddress = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000646def NOT64r : RI<0xF7, MRM2r, (outs GR64:$dst), (ins GR64:$src), "not{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000647 [(set GR64:$dst, (not GR64:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000648def NOT64m : RI<0xF7, MRM2m, (outs), (ins i64mem:$dst), "not{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000649 [(store (not (loadi64 addr:$dst)), addr:$dst)]>;
650
Evan Cheng55687072007-09-14 21:48:26 +0000651let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000652let isTwoAddress = 1 in {
653let isCommutable = 1 in
654def AND64rr : RI<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000655 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000656 "and{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000657 [(set GR64:$dst, (and GR64:$src1, GR64:$src2))]>;
658def AND64rm : RI<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000659 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000660 "and{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000661 [(set GR64:$dst, (and GR64:$src1, (load addr:$src2)))]>;
662def AND64ri32 : RIi32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +0000663 (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000664 "and{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000665 [(set GR64:$dst, (and GR64:$src1, i64immSExt32:$src2))]>;
666def AND64ri8 : RIi8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +0000667 (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000668 "and{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000669 [(set GR64:$dst, (and GR64:$src1, i64immSExt8:$src2))]>;
670} // isTwoAddress
671
672def AND64mr : RI<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000673 (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000674 "and{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000675 [(store (and (load addr:$dst), GR64:$src), addr:$dst)]>;
676def AND64mi32 : RIi32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +0000677 (outs), (ins i64mem:$dst, i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000678 "and{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000679 [(store (and (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>;
680def AND64mi8 : RIi8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +0000681 (outs), (ins i64mem:$dst, i64i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000682 "and{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000683 [(store (and (load addr:$dst), i64immSExt8:$src), addr:$dst)]>;
684
685let isTwoAddress = 1 in {
686let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000687def OR64rr : RI<0x09, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000688 "or{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000689 [(set GR64:$dst, (or GR64:$src1, GR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000690def OR64rm : RI<0x0B, MRMSrcMem , (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000691 "or{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000692 [(set GR64:$dst, (or GR64:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000693def OR64ri32 : RIi32<0x81, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000694 "or{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000695 [(set GR64:$dst, (or GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000696def OR64ri8 : RIi8<0x83, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000697 "or{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000698 [(set GR64:$dst, (or GR64:$src1, i64immSExt8:$src2))]>;
699} // isTwoAddress
700
Evan Chengb783fa32007-07-19 01:14:50 +0000701def OR64mr : RI<0x09, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000702 "or{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000703 [(store (or (load addr:$dst), GR64:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000704def OR64mi32 : RIi32<0x81, MRM1m, (outs), (ins i64mem:$dst, i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000705 "or{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000706 [(store (or (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000707def OR64mi8 : RIi8<0x83, MRM1m, (outs), (ins i64mem:$dst, i64i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000708 "or{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000709 [(store (or (load addr:$dst), i64immSExt8:$src), addr:$dst)]>;
710
711let isTwoAddress = 1 in {
712let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000713def XOR64rr : RI<0x31, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000714 "xor{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000715 [(set GR64:$dst, (xor GR64:$src1, GR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000716def XOR64rm : RI<0x33, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000717 "xor{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000718 [(set GR64:$dst, (xor GR64:$src1, (load addr:$src2)))]>;
719def XOR64ri32 : RIi32<0x81, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +0000720 (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000721 "xor{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000722 [(set GR64:$dst, (xor GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000723def XOR64ri8 : RIi8<0x83, MRM6r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000724 "xor{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000725 [(set GR64:$dst, (xor GR64:$src1, i64immSExt8:$src2))]>;
726} // isTwoAddress
727
Evan Chengb783fa32007-07-19 01:14:50 +0000728def XOR64mr : RI<0x31, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000729 "xor{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000730 [(store (xor (load addr:$dst), GR64:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000731def XOR64mi32 : RIi32<0x81, MRM6m, (outs), (ins i64mem:$dst, i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000732 "xor{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000733 [(store (xor (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000734def XOR64mi8 : RIi8<0x83, MRM6m, (outs), (ins i64mem:$dst, i64i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000735 "xor{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000736 [(store (xor (load addr:$dst), i64immSExt8:$src), addr:$dst)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000737} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000738
739//===----------------------------------------------------------------------===//
740// Comparison Instructions...
741//
742
743// Integer comparison
Evan Cheng55687072007-09-14 21:48:26 +0000744let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000745let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000746def TEST64rr : RI<0x85, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000747 "test{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000748 [(X86cmp (and GR64:$src1, GR64:$src2), 0),
749 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000750def TEST64rm : RI<0x85, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000751 "test{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000752 [(X86cmp (and GR64:$src1, (loadi64 addr:$src2)), 0),
753 (implicit EFLAGS)]>;
754def TEST64ri32 : RIi32<0xF7, MRM0r, (outs),
755 (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000756 "test{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000757 [(X86cmp (and GR64:$src1, i64immSExt32:$src2), 0),
758 (implicit EFLAGS)]>;
759def TEST64mi32 : RIi32<0xF7, MRM0m, (outs),
760 (ins i64mem:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000761 "test{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000762 [(X86cmp (and (loadi64 addr:$src1), i64immSExt32:$src2), 0),
763 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000764
Evan Chengb783fa32007-07-19 01:14:50 +0000765def CMP64rr : RI<0x39, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000766 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000767 [(X86cmp GR64:$src1, GR64:$src2),
768 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000769def CMP64mr : RI<0x39, MRMDestMem, (outs), (ins i64mem:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000770 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000771 [(X86cmp (loadi64 addr:$src1), GR64:$src2),
772 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000773def CMP64rm : RI<0x3B, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000774 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000775 [(X86cmp GR64:$src1, (loadi64 addr:$src2)),
776 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000777def CMP64ri32 : RIi32<0x81, MRM7r, (outs), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000778 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000779 [(X86cmp GR64:$src1, i64immSExt32:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000780 (implicit EFLAGS)]>;
Evan Cheng621216e2007-09-29 00:00:36 +0000781def CMP64mi32 : RIi32<0x81, MRM7m, (outs),
Evan Cheng950aac02007-09-25 01:57:46 +0000782 (ins i64mem:$src1, i64i32imm:$src2),
783 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000784 [(X86cmp (loadi64 addr:$src1), i64immSExt32:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000785 (implicit EFLAGS)]>;
Evan Cheng621216e2007-09-29 00:00:36 +0000786def CMP64mi8 : RIi8<0x83, MRM7m, (outs), (ins i64mem:$src1, i64i8imm:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000787 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000788 [(X86cmp (loadi64 addr:$src1), i64immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000789 (implicit EFLAGS)]>;
Evan Cheng621216e2007-09-29 00:00:36 +0000790def CMP64ri8 : RIi8<0x83, MRM7r, (outs), (ins GR64:$src1, i64i8imm:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000791 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000792 [(X86cmp GR64:$src1, i64immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000793 (implicit EFLAGS)]>;
794} // Defs = [EFLAGS]
795
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000796// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000797let Uses = [EFLAGS], isTwoAddress = 1 in {
Evan Cheng926658c2007-10-05 23:13:21 +0000798let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000799def CMOVB64rr : RI<0x42, MRMSrcReg, // if <u, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000800 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000801 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000802 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000803 X86_COND_B, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000804def CMOVAE64rr: RI<0x43, MRMSrcReg, // if >=u, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000805 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000806 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000807 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000808 X86_COND_AE, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000809def CMOVE64rr : RI<0x44, MRMSrcReg, // if ==, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000810 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000811 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000812 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000813 X86_COND_E, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000814def CMOVNE64rr: RI<0x45, MRMSrcReg, // if !=, 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 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000817 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000818 X86_COND_NE, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000819def CMOVBE64rr: RI<0x46, MRMSrcReg, // if <=u, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000820 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000821 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000822 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000823 X86_COND_BE, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000824def CMOVA64rr : RI<0x47, 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 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000827 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000828 X86_COND_A, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000829def CMOVL64rr : RI<0x4C, MRMSrcReg, // if <s, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000830 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000831 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000832 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000833 X86_COND_L, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000834def CMOVGE64rr: RI<0x4D, MRMSrcReg, // if >=s, 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 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000837 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000838 X86_COND_GE, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000839def CMOVLE64rr: RI<0x4E, MRMSrcReg, // if <=s, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000840 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000841 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000842 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000843 X86_COND_LE, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000844def CMOVG64rr : RI<0x4F, MRMSrcReg, // if >s, 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 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000847 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000848 X86_COND_G, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000849def CMOVS64rr : RI<0x48, MRMSrcReg, // if signed, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000850 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000851 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000852 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000853 X86_COND_S, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000854def CMOVNS64rr: RI<0x49, MRMSrcReg, // if !signed, 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 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000857 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000858 X86_COND_NS, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000859def CMOVP64rr : RI<0x4A, MRMSrcReg, // if parity, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000860 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000861 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000862 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000863 X86_COND_P, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000864def CMOVNP64rr : RI<0x4B, MRMSrcReg, // if !parity, 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 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000867 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000868 X86_COND_NP, EFLAGS))]>, TB;
Evan Cheng926658c2007-10-05 23:13:21 +0000869} // isCommutable = 1
870
871def CMOVB64rm : RI<0x42, MRMSrcMem, // if <u, GR64 = [mem64]
872 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
873 "cmovb\t{$src2, $dst|$dst, $src2}",
874 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
875 X86_COND_B, EFLAGS))]>, TB;
876def CMOVAE64rm: RI<0x43, MRMSrcMem, // if >=u, GR64 = [mem64]
877 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
878 "cmovae\t{$src2, $dst|$dst, $src2}",
879 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
880 X86_COND_AE, EFLAGS))]>, TB;
881def CMOVE64rm : RI<0x44, MRMSrcMem, // if ==, GR64 = [mem64]
882 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
883 "cmove\t{$src2, $dst|$dst, $src2}",
884 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
885 X86_COND_E, EFLAGS))]>, TB;
886def CMOVNE64rm: RI<0x45, MRMSrcMem, // if !=, GR64 = [mem64]
887 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
888 "cmovne\t{$src2, $dst|$dst, $src2}",
889 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
890 X86_COND_NE, EFLAGS))]>, TB;
891def CMOVBE64rm: RI<0x46, MRMSrcMem, // if <=u, GR64 = [mem64]
892 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
893 "cmovbe\t{$src2, $dst|$dst, $src2}",
894 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
895 X86_COND_BE, EFLAGS))]>, TB;
896def CMOVA64rm : RI<0x47, MRMSrcMem, // if >u, GR64 = [mem64]
897 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
898 "cmova\t{$src2, $dst|$dst, $src2}",
899 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
900 X86_COND_A, EFLAGS))]>, TB;
901def CMOVL64rm : RI<0x4C, MRMSrcMem, // if <s, GR64 = [mem64]
902 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
903 "cmovl\t{$src2, $dst|$dst, $src2}",
904 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
905 X86_COND_L, EFLAGS))]>, TB;
906def CMOVGE64rm: RI<0x4D, MRMSrcMem, // if >=s, GR64 = [mem64]
907 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
908 "cmovge\t{$src2, $dst|$dst, $src2}",
909 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
910 X86_COND_GE, EFLAGS))]>, TB;
911def CMOVLE64rm: RI<0x4E, MRMSrcMem, // if <=s, GR64 = [mem64]
912 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
913 "cmovle\t{$src2, $dst|$dst, $src2}",
914 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
915 X86_COND_LE, EFLAGS))]>, TB;
916def CMOVG64rm : RI<0x4F, MRMSrcMem, // if >s, GR64 = [mem64]
917 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
918 "cmovg\t{$src2, $dst|$dst, $src2}",
919 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
920 X86_COND_G, EFLAGS))]>, TB;
921def CMOVS64rm : RI<0x48, MRMSrcMem, // if signed, GR64 = [mem64]
922 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
923 "cmovs\t{$src2, $dst|$dst, $src2}",
924 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
925 X86_COND_S, EFLAGS))]>, TB;
926def CMOVNS64rm: RI<0x49, MRMSrcMem, // if !signed, GR64 = [mem64]
927 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
928 "cmovns\t{$src2, $dst|$dst, $src2}",
929 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
930 X86_COND_NS, EFLAGS))]>, TB;
931def CMOVP64rm : RI<0x4A, MRMSrcMem, // if parity, GR64 = [mem64]
932 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
933 "cmovp\t{$src2, $dst|$dst, $src2}",
934 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
935 X86_COND_P, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000936def CMOVNP64rm : RI<0x4B, MRMSrcMem, // if !parity, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +0000937 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000938 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000939 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000940 X86_COND_NP, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000941} // isTwoAddress
942
943//===----------------------------------------------------------------------===//
944// Conversion Instructions...
945//
946
947// f64 -> signed i64
Evan Chengb783fa32007-07-19 01:14:50 +0000948def Int_CVTSD2SI64rr: RSDI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000949 "cvtsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +0000950 [(set GR64:$dst,
951 (int_x86_sse2_cvtsd2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000952def Int_CVTSD2SI64rm: RSDI<0x2D, MRMSrcMem, (outs GR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000953 "cvtsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +0000954 [(set GR64:$dst, (int_x86_sse2_cvtsd2si64
955 (load addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000956def CVTTSD2SI64rr: RSDI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000957 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000958 [(set GR64:$dst, (fp_to_sint FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000959def CVTTSD2SI64rm: RSDI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000960 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000961 [(set GR64:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000962def Int_CVTTSD2SI64rr: RSDI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000963 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +0000964 [(set GR64:$dst,
965 (int_x86_sse2_cvttsd2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000966def Int_CVTTSD2SI64rm: RSDI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000967 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +0000968 [(set GR64:$dst,
969 (int_x86_sse2_cvttsd2si64
970 (load addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000971
972// Signed i64 -> f64
Evan Chengb783fa32007-07-19 01:14:50 +0000973def CVTSI2SD64rr: RSDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000974 "cvtsi2sd{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000975 [(set FR64:$dst, (sint_to_fp GR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000976def CVTSI2SD64rm: RSDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000977 "cvtsi2sd{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000978 [(set FR64:$dst, (sint_to_fp (loadi64 addr:$src)))]>;
979let isTwoAddress = 1 in {
980def Int_CVTSI2SD64rr: RSDI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000981 (outs VR128:$dst), (ins VR128:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000982 "cvtsi2sd{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendling6227d462007-07-23 03:07:27 +0000983 [(set VR128:$dst,
984 (int_x86_sse2_cvtsi642sd VR128:$src1,
985 GR64:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000986def Int_CVTSI2SD64rm: RSDI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000987 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000988 "cvtsi2sd{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendling6227d462007-07-23 03:07:27 +0000989 [(set VR128:$dst,
990 (int_x86_sse2_cvtsi642sd VR128:$src1,
991 (loadi64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000992} // isTwoAddress
993
994// Signed i64 -> f32
Evan Chengb783fa32007-07-19 01:14:50 +0000995def CVTSI2SS64rr: RSSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000996 "cvtsi2ss{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000997 [(set FR32:$dst, (sint_to_fp GR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000998def CVTSI2SS64rm: RSSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000999 "cvtsi2ss{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001000 [(set FR32:$dst, (sint_to_fp (loadi64 addr:$src)))]>;
1001let isTwoAddress = 1 in {
1002def Int_CVTSI2SS64rr: RSSI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001003 (outs VR128:$dst), (ins VR128:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001004 "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001005 []>; // TODO: add intrinsic
1006def Int_CVTSI2SS64rm: RSSI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001007 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001008 "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001009 []>; // TODO: add intrinsic
1010} // isTwoAddress
1011
1012// f32 -> signed i64
Evan Chengb783fa32007-07-19 01:14:50 +00001013def Int_CVTSS2SI64rr: RSSI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001014 "cvtss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001015 [(set GR64:$dst,
1016 (int_x86_sse_cvtss2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001017def Int_CVTSS2SI64rm: RSSI<0x2D, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001018 "cvtss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001019 [(set GR64:$dst, (int_x86_sse_cvtss2si64
1020 (load addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001021def CVTTSS2SI64rr: RSSI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001022 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001023 [(set GR64:$dst, (fp_to_sint FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001024def CVTTSS2SI64rm: RSSI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001025 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001026 [(set GR64:$dst, (fp_to_sint (loadf32 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001027def Int_CVTTSS2SI64rr: RSSI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001028 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001029 [(set GR64:$dst,
1030 (int_x86_sse_cvttss2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001031def Int_CVTTSS2SI64rm: RSSI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001032 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001033 [(set GR64:$dst,
1034 (int_x86_sse_cvttss2si64 (load addr:$src)))]>;
1035
1036let isTwoAddress = 1 in {
1037 def Int_CVTSI642SSrr : RSSI<0x2A, MRMSrcReg,
1038 (outs VR128:$dst), (ins VR128:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001039 "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendling6227d462007-07-23 03:07:27 +00001040 [(set VR128:$dst,
1041 (int_x86_sse_cvtsi642ss VR128:$src1,
1042 GR64:$src2))]>;
1043 def Int_CVTSI642SSrm : RSSI<0x2A, MRMSrcMem,
1044 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001045 "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendling6227d462007-07-23 03:07:27 +00001046 [(set VR128:$dst,
1047 (int_x86_sse_cvtsi642ss VR128:$src1,
1048 (loadi64 addr:$src2)))]>;
1049}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001050
1051//===----------------------------------------------------------------------===//
1052// Alias Instructions
1053//===----------------------------------------------------------------------===//
1054
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001055// Zero-extension
1056// TODO: Remove this after proper i32 -> i64 zext support.
Evan Chengb783fa32007-07-19 01:14:50 +00001057def PsMOVZX64rr32: I<0x89, MRMDestReg, (outs GR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001058 "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001059 [(set GR64:$dst, (zext GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001060def PsMOVZX64rm32: I<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001061 "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001062 [(set GR64:$dst, (zextloadi64i32 addr:$src))]>;
1063
1064
Dan Gohman027cd112007-09-17 14:55:08 +00001065// Alias instructions that map movr0 to xor. Use xorl instead of xorq; it's
1066// equivalent due to implicit zero-extending, and it sometimes has a smaller
1067// encoding.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001068// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
1069// FIXME: AddedComplexity gives MOV64r0 a higher priority than MOV64ri32. Remove
1070// when we have a better way to specify isel priority.
Evan Cheng55687072007-09-14 21:48:26 +00001071let Defs = [EFLAGS], AddedComplexity = 1, isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001072def MOV64r0 : RI<0x31, MRMInitReg, (outs GR64:$dst), (ins),
Dan Gohman027cd112007-09-17 14:55:08 +00001073 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001074 [(set GR64:$dst, 0)]>;
1075
1076// Materialize i64 constant where top 32-bits are zero.
Dan Gohman8aef09b2007-09-07 21:32:51 +00001077let AddedComplexity = 1, isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001078def MOV64ri64i32 : Ii32<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001079 "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001080 [(set GR64:$dst, i64immZExt32:$src)]>;
1081
1082//===----------------------------------------------------------------------===//
1083// Non-Instruction Patterns
1084//===----------------------------------------------------------------------===//
1085
1086// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
1087def : Pat<(i64 (X86Wrapper tconstpool :$dst)),
1088 (MOV64ri tconstpool :$dst)>, Requires<[NotSmallCode]>;
1089def : Pat<(i64 (X86Wrapper tjumptable :$dst)),
1090 (MOV64ri tjumptable :$dst)>, Requires<[NotSmallCode]>;
1091def : Pat<(i64 (X86Wrapper tglobaladdr :$dst)),
1092 (MOV64ri tglobaladdr :$dst)>, Requires<[NotSmallCode]>;
1093def : Pat<(i64 (X86Wrapper texternalsym:$dst)),
1094 (MOV64ri texternalsym:$dst)>, Requires<[NotSmallCode]>;
1095
1096def : Pat<(store (i64 (X86Wrapper tconstpool:$src)), addr:$dst),
1097 (MOV64mi32 addr:$dst, tconstpool:$src)>,
Evan Cheng415e2e92007-08-01 23:46:10 +00001098 Requires<[SmallCode, HasLow4G, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001099def : Pat<(store (i64 (X86Wrapper tjumptable:$src)), addr:$dst),
1100 (MOV64mi32 addr:$dst, tjumptable:$src)>,
Evan Cheng415e2e92007-08-01 23:46:10 +00001101 Requires<[SmallCode, HasLow4G, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001102def : Pat<(store (i64 (X86Wrapper tglobaladdr:$src)), addr:$dst),
1103 (MOV64mi32 addr:$dst, tglobaladdr:$src)>,
Evan Cheng415e2e92007-08-01 23:46:10 +00001104 Requires<[SmallCode, HasLow4G, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001105def : Pat<(store (i64 (X86Wrapper texternalsym:$src)), addr:$dst),
1106 (MOV64mi32 addr:$dst, texternalsym:$src)>,
Evan Cheng415e2e92007-08-01 23:46:10 +00001107 Requires<[SmallCode, HasLow4G, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001108
1109// Calls
1110// Direct PC relative function call for small code model. 32-bit displacement
1111// sign extended to 64-bit.
1112def : Pat<(X86call (i64 tglobaladdr:$dst)),
1113 (CALL64pcrel32 tglobaladdr:$dst)>;
1114def : Pat<(X86call (i64 texternalsym:$dst)),
1115 (CALL64pcrel32 texternalsym:$dst)>;
1116
1117def : Pat<(X86tailcall (i64 tglobaladdr:$dst)),
1118 (CALL64pcrel32 tglobaladdr:$dst)>;
1119def : Pat<(X86tailcall (i64 texternalsym:$dst)),
1120 (CALL64pcrel32 texternalsym:$dst)>;
1121
1122def : Pat<(X86tailcall GR64:$dst),
1123 (CALL64r GR64:$dst)>;
1124
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00001125
1126// tailcall stuff
1127def : Pat<(X86tailcall GR32:$dst),
1128 (TAILCALL)>;
1129def : Pat<(X86tailcall (i64 tglobaladdr:$dst)),
1130 (TAILCALL)>;
1131def : Pat<(X86tailcall (i64 texternalsym:$dst)),
1132 (TAILCALL)>;
1133
1134def : Pat<(X86tcret GR64:$dst, imm:$off),
1135 (TCRETURNri64 GR64:$dst, imm:$off)>;
1136
1137def : Pat<(X86tcret (i64 tglobaladdr:$dst), imm:$off),
1138 (TCRETURNdi64 texternalsym:$dst, imm:$off)>;
1139
1140def : Pat<(X86tcret (i64 texternalsym:$dst), imm:$off),
1141 (TCRETURNdi64 texternalsym:$dst, imm:$off)>;
1142
Dan Gohmanec596042007-09-17 14:35:24 +00001143// Comparisons.
1144
1145// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00001146def : Pat<(parallel (X86cmp GR64:$src1, 0), (implicit EFLAGS)),
Dan Gohmanec596042007-09-17 14:35:24 +00001147 (TEST64rr GR64:$src1, GR64:$src1)>;
1148
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001149// {s|z}extload bool -> {s|z}extload byte
1150def : Pat<(sextloadi64i1 addr:$src), (MOVSX64rm8 addr:$src)>;
1151def : Pat<(zextloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>;
1152
1153// extload
1154def : Pat<(extloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>;
1155def : Pat<(extloadi64i8 addr:$src), (MOVZX64rm8 addr:$src)>;
1156def : Pat<(extloadi64i16 addr:$src), (MOVZX64rm16 addr:$src)>;
1157def : Pat<(extloadi64i32 addr:$src), (PsMOVZX64rm32 addr:$src)>;
1158
1159// anyext -> zext
1160def : Pat<(i64 (anyext GR8 :$src)), (MOVZX64rr8 GR8 :$src)>;
1161def : Pat<(i64 (anyext GR16:$src)), (MOVZX64rr16 GR16:$src)>;
1162def : Pat<(i64 (anyext GR32:$src)), (PsMOVZX64rr32 GR32:$src)>;
1163def : Pat<(i64 (anyext (loadi8 addr:$src))), (MOVZX64rm8 addr:$src)>;
1164def : Pat<(i64 (anyext (loadi16 addr:$src))), (MOVZX64rm16 addr:$src)>;
1165def : Pat<(i64 (anyext (loadi32 addr:$src))), (PsMOVZX64rm32 addr:$src)>;
1166
1167//===----------------------------------------------------------------------===//
1168// Some peepholes
1169//===----------------------------------------------------------------------===//
1170
1171// (shl x, 1) ==> (add x, x)
1172def : Pat<(shl GR64:$src1, (i8 1)), (ADD64rr GR64:$src1, GR64:$src1)>;
1173
1174// (or (x >> c) | (y << (64 - c))) ==> (shrd64 x, y, c)
1175def : Pat<(or (srl GR64:$src1, CL:$amt),
1176 (shl GR64:$src2, (sub 64, CL:$amt))),
1177 (SHRD64rrCL GR64:$src1, GR64:$src2)>;
1178
1179def : Pat<(store (or (srl (loadi64 addr:$dst), CL:$amt),
1180 (shl GR64:$src2, (sub 64, CL:$amt))), addr:$dst),
1181 (SHRD64mrCL addr:$dst, GR64:$src2)>;
1182
1183// (or (x << c) | (y >> (64 - c))) ==> (shld64 x, y, c)
1184def : Pat<(or (shl GR64:$src1, CL:$amt),
1185 (srl GR64:$src2, (sub 64, CL:$amt))),
1186 (SHLD64rrCL GR64:$src1, GR64:$src2)>;
1187
1188def : Pat<(store (or (shl (loadi64 addr:$dst), CL:$amt),
1189 (srl GR64:$src2, (sub 64, CL:$amt))), addr:$dst),
1190 (SHLD64mrCL addr:$dst, GR64:$src2)>;
1191
1192// X86 specific add which produces a flag.
1193def : Pat<(addc GR64:$src1, GR64:$src2),
1194 (ADD64rr GR64:$src1, GR64:$src2)>;
1195def : Pat<(addc GR64:$src1, (load addr:$src2)),
1196 (ADD64rm GR64:$src1, addr:$src2)>;
1197def : Pat<(addc GR64:$src1, i64immSExt32:$src2),
1198 (ADD64ri32 GR64:$src1, imm:$src2)>;
1199def : Pat<(addc GR64:$src1, i64immSExt8:$src2),
1200 (ADD64ri8 GR64:$src1, i64immSExt8:$src2)>;
1201
1202def : Pat<(subc GR64:$src1, GR64:$src2),
1203 (SUB64rr GR64:$src1, GR64:$src2)>;
1204def : Pat<(subc GR64:$src1, (load addr:$src2)),
1205 (SUB64rm GR64:$src1, addr:$src2)>;
1206def : Pat<(subc GR64:$src1, imm:$src2),
1207 (SUB64ri32 GR64:$src1, i64immSExt32:$src2)>;
1208def : Pat<(subc GR64:$src1, i64immSExt8:$src2),
1209 (SUB64ri8 GR64:$src1, i64immSExt8:$src2)>;
1210
1211
1212//===----------------------------------------------------------------------===//
1213// X86-64 SSE Instructions
1214//===----------------------------------------------------------------------===//
1215
1216// Move instructions...
1217
Evan Chengb783fa32007-07-19 01:14:50 +00001218def MOV64toPQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001219 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001220 [(set VR128:$dst,
1221 (v2i64 (scalar_to_vector GR64:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001222def MOV64toPQIrm : RPDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001223 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001224 [(set VR128:$dst,
1225 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>;
1226
Evan Chengb783fa32007-07-19 01:14:50 +00001227def MOVPQIto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001228 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001229 [(set GR64:$dst, (vector_extract (v2i64 VR128:$src),
1230 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001231def MOVPQIto64mr : RPDI<0x7E, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001232 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001233 [(store (i64 (vector_extract (v2i64 VR128:$src),
1234 (iPTR 0))), addr:$dst)]>;
1235
Evan Chengb783fa32007-07-19 01:14:50 +00001236def MOV64toSDrr : RPDI<0x6E, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001237 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001238 [(set FR64:$dst, (bitconvert GR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001239def MOV64toSDrm : RPDI<0x6E, MRMSrcMem, (outs FR64:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001240 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001241 [(set FR64:$dst, (bitconvert (loadi64 addr:$src)))]>;
1242
Evan Chengb783fa32007-07-19 01:14:50 +00001243def MOVSDto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001244 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001245 [(set GR64:$dst, (bitconvert FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001246def MOVSDto64mr : RPDI<0x7E, MRMDestMem, (outs), (ins i64mem:$dst, FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001247 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001248 [(store (i64 (bitconvert FR64:$src)), addr:$dst)]>;