blob: 78870ab364fb08f9b8a6d6a5cda53cfe1c060fe6 [file] [log] [blame]
Chris Lattner2de8d2b2008-01-10 05:50:42 +00001//====- X86Instr64bit.td - Describe X86-64 Instructions ----*- tablegen -*-===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
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//===----------------------------------------------------------------------===//
Chris Lattner2de8d2b2008-01-10 05:50:42 +000017// Operand Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000018//
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//===----------------------------------------------------------------------===//
Chris Lattner2de8d2b2008-01-10 05:50:42 +000036// Complex Pattern Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000037//
38def lea64addr : ComplexPattern<i64, 4, "SelectLEAAddr",
39 [add, mul, shl, or, frameindex, X86Wrapper],
40 []>;
41
42//===----------------------------------------------------------------------===//
Chris Lattner2de8d2b2008-01-10 05:50:42 +000043// Pattern fragments.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000044//
45
46def i64immSExt32 : PatLeaf<(i64 imm), [{
47 // i64immSExt32 predicate - True if the 64-bit immediate fits in a 32-bit
48 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +000049 return (int64_t)N->getZExtValue() == (int32_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +000050}]>;
51
52def i64immZExt32 : PatLeaf<(i64 imm), [{
53 // i64immZExt32 predicate - True if the 64-bit immediate fits in a 32-bit
54 // unsignedsign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +000055 return (uint64_t)N->getZExtValue() == (uint32_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +000056}]>;
57
58def i64immSExt8 : PatLeaf<(i64 imm), [{
59 // i64immSExt8 predicate - True if the 64-bit immediate fits in a 8-bit
60 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +000061 return (int64_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +000062}]>;
63
Chris Lattner20be7d72008-02-27 05:47:54 +000064def i64immFFFFFFFF : PatLeaf<(i64 imm), [{
65 // i64immFFFFFFFF - True if this is a specific constant we can't write in
66 // tblgen files.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +000067 return N->getZExtValue() == 0x00000000FFFFFFFFULL;
Chris Lattner20be7d72008-02-27 05:47:54 +000068}]>;
69
70
Dan Gohmanf17a25c2007-07-18 16:29:46 +000071def sextloadi64i8 : PatFrag<(ops node:$ptr), (i64 (sextloadi8 node:$ptr))>;
72def sextloadi64i16 : PatFrag<(ops node:$ptr), (i64 (sextloadi16 node:$ptr))>;
73def sextloadi64i32 : PatFrag<(ops node:$ptr), (i64 (sextloadi32 node:$ptr))>;
74
75def zextloadi64i1 : PatFrag<(ops node:$ptr), (i64 (zextloadi1 node:$ptr))>;
76def zextloadi64i8 : PatFrag<(ops node:$ptr), (i64 (zextloadi8 node:$ptr))>;
77def zextloadi64i16 : PatFrag<(ops node:$ptr), (i64 (zextloadi16 node:$ptr))>;
78def zextloadi64i32 : PatFrag<(ops node:$ptr), (i64 (zextloadi32 node:$ptr))>;
79
80def extloadi64i1 : PatFrag<(ops node:$ptr), (i64 (extloadi1 node:$ptr))>;
81def extloadi64i8 : PatFrag<(ops node:$ptr), (i64 (extloadi8 node:$ptr))>;
82def extloadi64i16 : PatFrag<(ops node:$ptr), (i64 (extloadi16 node:$ptr))>;
83def extloadi64i32 : PatFrag<(ops node:$ptr), (i64 (extloadi32 node:$ptr))>;
84
85//===----------------------------------------------------------------------===//
86// Instruction list...
87//
88
Dan Gohmanf17a25c2007-07-18 16:29:46 +000089//===----------------------------------------------------------------------===//
90// Call Instructions...
91//
Evan Cheng37e7c752007-07-21 00:34:19 +000092let isCall = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +000093 // All calls clobber the non-callee saved registers...
94 let Defs = [RAX, RCX, RDX, RSI, RDI, R8, R9, R10, R11,
Evan Cheng931a8f42008-01-29 19:34:22 +000095 FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0, ST1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +000096 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
97 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
Dan Gohman9499cfe2008-10-01 04:14:30 +000098 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
99 Uses = [RSP] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000100 def CALL64pcrel32 : I<0xE8, RawFrm, (outs), (ins i64imm:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000101 "call\t${dst:call}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000102 def CALL64r : I<0xFF, MRM2r, (outs), (ins GR64:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000103 "call\t{*}$dst", [(X86call GR64:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000104 def CALL64m : I<0xFF, MRM2m, (outs), (ins i64mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000105 "call\t{*}$dst", [(X86call (loadi64 addr:$dst))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000106 }
107
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000108
109
110let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000111def TCRETURNdi64 : I<0, Pseudo, (outs), (ins i64imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000112 "#TC_RETURN $dst $offset",
113 []>;
114
115let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000116def TCRETURNri64 : I<0, Pseudo, (outs), (ins GR64:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000117 "#TC_RETURN $dst $offset",
118 []>;
119
120
121let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
122 def TAILJMPr64 : I<0xFF, MRM4r, (outs), (ins GR64:$dst), "jmp{q}\t{*}$dst # TAILCALL",
123 []>;
124
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000125// Branches
Owen Andersonf8053082007-11-12 07:39:39 +0000126let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000127 def JMP64r : I<0xFF, MRM4r, (outs), (ins GR64:$dst), "jmp{q}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000128 [(brind GR64:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000129 def JMP64m : I<0xFF, MRM4m, (outs), (ins i64mem:$dst), "jmp{q}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000130 [(brind (loadi64 addr:$dst))]>;
131}
132
133//===----------------------------------------------------------------------===//
Anton Korobeynikov1ec04ee2008-09-08 21:12:47 +0000134// EH Pseudo Instructions
135//
136let isTerminator = 1, isReturn = 1, isBarrier = 1,
137 hasCtrlDep = 1 in {
138def EH_RETURN64 : I<0xC3, RawFrm, (outs), (ins GR64:$addr),
139 "ret\t#eh_return, addr: $addr",
140 [(X86ehret GR64:$addr)]>;
141
142}
143
144//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000145// Miscellaneous Instructions...
146//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000147let Defs = [RBP,RSP], Uses = [RBP,RSP], mayLoad = 1, neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000148def LEAVE64 : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000149 (outs), (ins), "leave", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000150let Defs = [RSP], Uses = [RSP], neverHasSideEffects=1 in {
151let mayLoad = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000152def POP64r : I<0x58, AddRegFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000153 (outs GR64:$reg), (ins), "pop{q}\t$reg", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000154let mayStore = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000155def PUSH64r : I<0x50, AddRegFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000156 (outs), (ins GR64:$reg), "push{q}\t$reg", []>;
157}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000158
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000159let Defs = [RSP, EFLAGS], Uses = [RSP], mayLoad = 1 in
Evan Chengf1341312007-09-26 21:28:00 +0000160def POPFQ : I<0x9D, RawFrm, (outs), (ins), "popf", []>, REX_W;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000161let Defs = [RSP], Uses = [RSP, EFLAGS], mayStore = 1 in
Evan Chengf1341312007-09-26 21:28:00 +0000162def PUSHFQ : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000163
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000164def LEA64_32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000165 (outs GR32:$dst), (ins lea64_32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000166 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000167 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In64BitMode]>;
168
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000169let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000170def LEA64r : RI<0x8D, MRMSrcMem, (outs GR64:$dst), (ins lea64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000171 "lea{q}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000172 [(set GR64:$dst, lea64addr:$src)]>;
173
174let isTwoAddress = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000175def BSWAP64r : RI<0xC8, AddRegFrm, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000176 "bswap{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000177 [(set GR64:$dst, (bswap GR64:$src))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000178
Evan Cheng48679f42007-12-14 02:13:44 +0000179// Bit scan instructions.
180let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000181def BSF64rr : RI<0xBC, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000182 "bsf{q}\t{$src, $dst|$dst, $src}",
Evan Cheng9a8ffd52007-12-14 18:25:34 +0000183 [(set GR64:$dst, (X86bsf GR64:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000184def BSF64rm : RI<0xBC, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000185 "bsf{q}\t{$src, $dst|$dst, $src}",
Evan Cheng9a8ffd52007-12-14 18:25:34 +0000186 [(set GR64:$dst, (X86bsf (loadi64 addr:$src))),
187 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000188
Evan Cheng4e33de92007-12-14 18:49:43 +0000189def BSR64rr : RI<0xBD, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000190 "bsr{q}\t{$src, $dst|$dst, $src}",
Evan Cheng9a8ffd52007-12-14 18:25:34 +0000191 [(set GR64:$dst, (X86bsr GR64:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000192def BSR64rm : RI<0xBD, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000193 "bsr{q}\t{$src, $dst|$dst, $src}",
Evan Cheng9a8ffd52007-12-14 18:25:34 +0000194 [(set GR64:$dst, (X86bsr (loadi64 addr:$src))),
195 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000196} // Defs = [EFLAGS]
197
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000198// Repeat string ops
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000199let Defs = [RCX,RDI,RSI], Uses = [RCX,RDI,RSI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000200def REP_MOVSQ : RI<0xA5, RawFrm, (outs), (ins), "{rep;movsq|rep movsq}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000201 [(X86rep_movs i64)]>, REP;
202let Defs = [RCX,RDI], Uses = [RAX,RCX,RDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000203def REP_STOSQ : RI<0xAB, RawFrm, (outs), (ins), "{rep;stosq|rep stosq}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000204 [(X86rep_stos i64)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000205
206//===----------------------------------------------------------------------===//
207// Move Instructions...
208//
209
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000210let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000211def MOV64rr : RI<0x89, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000212 "mov{q}\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000213
Evan Chengd2b9d302008-06-25 01:16:38 +0000214let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000215def MOV64ri : RIi64<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000216 "movabs{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000217 [(set GR64:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000218def MOV64ri32 : RIi32<0xC7, MRM0r, (outs GR64:$dst), (ins i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000219 "mov{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000220 [(set GR64:$dst, i64immSExt32:$src)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +0000221}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000222
Chris Lattner1a1932c2008-01-06 23:38:27 +0000223let isSimpleLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000224def MOV64rm : RI<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000225 "mov{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000226 [(set GR64:$dst, (load addr:$src))]>;
227
Evan Chengb783fa32007-07-19 01:14:50 +0000228def MOV64mr : RI<0x89, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000229 "mov{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000230 [(store GR64:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000231def MOV64mi32 : RIi32<0xC7, MRM0m, (outs), (ins i64mem:$dst, i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000232 "mov{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000233 [(store i64immSExt32:$src, addr:$dst)]>;
234
235// Sign/Zero extenders
236
Evan Chengb783fa32007-07-19 01:14:50 +0000237def MOVSX64rr8 : RI<0xBE, MRMSrcReg, (outs GR64:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000238 "movs{bq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000239 [(set GR64:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000240def MOVSX64rm8 : RI<0xBE, MRMSrcMem, (outs GR64:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000241 "movs{bq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000242 [(set GR64:$dst, (sextloadi64i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000243def MOVSX64rr16: RI<0xBF, MRMSrcReg, (outs GR64:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000244 "movs{wq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000245 [(set GR64:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000246def MOVSX64rm16: RI<0xBF, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000247 "movs{wq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000248 [(set GR64:$dst, (sextloadi64i16 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000249def MOVSX64rr32: RI<0x63, MRMSrcReg, (outs GR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000250 "movs{lq|xd}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000251 [(set GR64:$dst, (sext GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000252def MOVSX64rm32: RI<0x63, MRMSrcMem, (outs GR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000253 "movs{lq|xd}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000254 [(set GR64:$dst, (sextloadi64i32 addr:$src))]>;
255
Dan Gohman9203ab42008-07-30 18:09:17 +0000256// Use movzbl instead of movzbq when the destination is a register; it's
257// equivalent due to implicit zero-extending, and it has a smaller encoding.
258def MOVZX64rr8 : I<0xB6, MRMSrcReg, (outs GR64:$dst), (ins GR8 :$src),
259 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
260 [(set GR64:$dst, (zext GR8:$src))]>, TB;
261def MOVZX64rm8 : I<0xB6, MRMSrcMem, (outs GR64:$dst), (ins i8mem :$src),
262 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
263 [(set GR64:$dst, (zextloadi64i8 addr:$src))]>, TB;
264// Use movzwl instead of movzwq when the destination is a register; it's
265// equivalent due to implicit zero-extending, and it has a smaller encoding.
266def MOVZX64rr16: I<0xB7, MRMSrcReg, (outs GR64:$dst), (ins GR16:$src),
267 "movz{wl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
268 [(set GR64:$dst, (zext GR16:$src))]>, TB;
269def MOVZX64rm16: I<0xB7, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
270 "movz{wl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
271 [(set GR64:$dst, (zextloadi64i16 addr:$src))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000272
Dan Gohman47a419d2008-08-07 02:54:50 +0000273// There's no movzlq instruction, but movl can be used for this purpose, using
274// implicit zero-extension. We need this because the seeming alternative for
275// implementing zext from 32 to 64, an EXTRACT_SUBREG/SUBREG_TO_REG pair, isn't
276// safe because both instructions could be optimized away in the
277// register-to-register case, leaving nothing behind to do the zero extension.
278def MOVZX64rr32 : I<0x89, MRMDestReg, (outs GR64:$dst), (ins GR32:$src),
279 "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
280 [(set GR64:$dst, (zext GR32:$src))]>;
281def MOVZX64rm32 : I<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i32mem:$src),
282 "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
283 [(set GR64:$dst, (zextloadi64i32 addr:$src))]>;
284
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000285let neverHasSideEffects = 1 in {
286 let Defs = [RAX], Uses = [EAX] in
287 def CDQE : RI<0x98, RawFrm, (outs), (ins),
288 "{cltq|cdqe}", []>; // RAX = signext(EAX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000289
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000290 let Defs = [RAX,RDX], Uses = [RAX] in
291 def CQO : RI<0x99, RawFrm, (outs), (ins),
292 "{cqto|cqo}", []>; // RDX:RAX = signext(RAX)
293}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000294
295//===----------------------------------------------------------------------===//
296// Arithmetic Instructions...
297//
298
Evan Cheng55687072007-09-14 21:48:26 +0000299let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000300let isTwoAddress = 1 in {
301let isConvertibleToThreeAddress = 1 in {
302let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000303def ADD64rr : RI<0x01, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000304 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000305 [(set GR64:$dst, (add GR64:$src1, GR64:$src2))]>;
306
Evan Chengb783fa32007-07-19 01:14:50 +0000307def ADD64ri32 : RIi32<0x81, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000308 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000309 [(set GR64:$dst, (add GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000310def ADD64ri8 : RIi8<0x83, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000311 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000312 [(set GR64:$dst, (add GR64:$src1, i64immSExt8:$src2))]>;
313} // isConvertibleToThreeAddress
314
Evan Chengb783fa32007-07-19 01:14:50 +0000315def ADD64rm : RI<0x03, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000316 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000317 [(set GR64:$dst, (add GR64:$src1, (load addr:$src2)))]>;
318} // isTwoAddress
319
Evan Chengb783fa32007-07-19 01:14:50 +0000320def ADD64mr : RI<0x01, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000321 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000322 [(store (add (load addr:$dst), GR64:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000323def ADD64mi32 : RIi32<0x81, MRM0m, (outs), (ins i64mem:$dst, i64i32imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000324 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000325 [(store (add (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000326def ADD64mi8 : RIi8<0x83, MRM0m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000327 "add{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000328 [(store (add (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
329
Evan Cheng259471d2007-10-05 17:59:57 +0000330let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000331let isTwoAddress = 1 in {
332let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000333def ADC64rr : RI<0x11, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000334 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000335 [(set GR64:$dst, (adde GR64:$src1, GR64:$src2))]>;
336
Evan Chengb783fa32007-07-19 01:14:50 +0000337def ADC64rm : RI<0x13, MRMSrcMem , (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000338 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000339 [(set GR64:$dst, (adde GR64:$src1, (load addr:$src2)))]>;
340
Evan Chengb783fa32007-07-19 01:14:50 +0000341def ADC64ri32 : RIi32<0x81, MRM2r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000342 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000343 [(set GR64:$dst, (adde GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000344def ADC64ri8 : RIi8<0x83, MRM2r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000345 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000346 [(set GR64:$dst, (adde GR64:$src1, i64immSExt8:$src2))]>;
347} // isTwoAddress
348
Evan Chengb783fa32007-07-19 01:14:50 +0000349def ADC64mr : RI<0x11, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000350 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000351 [(store (adde (load addr:$dst), GR64:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000352def ADC64mi32 : RIi32<0x81, MRM2m, (outs), (ins i64mem:$dst, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000353 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000354 [(store (adde (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000355def ADC64mi8 : RIi8<0x83, MRM2m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000356 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000357 [(store (adde (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
Evan Cheng259471d2007-10-05 17:59:57 +0000358} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000359
360let isTwoAddress = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000361def SUB64rr : RI<0x29, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000362 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000363 [(set GR64:$dst, (sub GR64:$src1, GR64:$src2))]>;
364
Evan Chengb783fa32007-07-19 01:14:50 +0000365def SUB64rm : RI<0x2B, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000366 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000367 [(set GR64:$dst, (sub GR64:$src1, (load addr:$src2)))]>;
368
Evan Chengb783fa32007-07-19 01:14:50 +0000369def SUB64ri32 : RIi32<0x81, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000370 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000371 [(set GR64:$dst, (sub GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000372def SUB64ri8 : RIi8<0x83, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000373 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000374 [(set GR64:$dst, (sub GR64:$src1, i64immSExt8:$src2))]>;
375} // isTwoAddress
376
Evan Chengb783fa32007-07-19 01:14:50 +0000377def SUB64mr : RI<0x29, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000378 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000379 [(store (sub (load addr:$dst), GR64:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000380def SUB64mi32 : RIi32<0x81, MRM5m, (outs), (ins i64mem:$dst, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000381 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000382 [(store (sub (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000383def SUB64mi8 : RIi8<0x83, MRM5m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000384 "sub{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000385 [(store (sub (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
386
Evan Cheng259471d2007-10-05 17:59:57 +0000387let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000388let isTwoAddress = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000389def SBB64rr : RI<0x19, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000390 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000391 [(set GR64:$dst, (sube GR64:$src1, GR64:$src2))]>;
392
Evan Chengb783fa32007-07-19 01:14:50 +0000393def SBB64rm : RI<0x1B, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000394 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000395 [(set GR64:$dst, (sube GR64:$src1, (load addr:$src2)))]>;
396
Evan Chengb783fa32007-07-19 01:14:50 +0000397def SBB64ri32 : RIi32<0x81, MRM3r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000398 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000399 [(set GR64:$dst, (sube GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000400def SBB64ri8 : RIi8<0x83, MRM3r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000401 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000402 [(set GR64:$dst, (sube GR64:$src1, i64immSExt8:$src2))]>;
403} // isTwoAddress
404
Evan Chengb783fa32007-07-19 01:14:50 +0000405def SBB64mr : RI<0x19, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000406 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000407 [(store (sube (load addr:$dst), GR64:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000408def SBB64mi32 : RIi32<0x81, MRM3m, (outs), (ins i64mem:$dst, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000409 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000410 [(store (sube (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000411def SBB64mi8 : RIi8<0x83, MRM3m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000412 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000413 [(store (sube (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
Evan Cheng259471d2007-10-05 17:59:57 +0000414} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +0000415} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000416
417// Unsigned multiplication
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000418let Defs = [RAX,RDX,EFLAGS], Uses = [RAX], neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000419def MUL64r : RI<0xF7, MRM4r, (outs), (ins GR64:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000420 "mul{q}\t$src", []>; // RAX,RDX = RAX*GR64
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000421let mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000422def MUL64m : RI<0xF7, MRM4m, (outs), (ins i64mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000423 "mul{q}\t$src", []>; // RAX,RDX = RAX*[mem64]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000424
425// Signed multiplication
Evan Chengb783fa32007-07-19 01:14:50 +0000426def IMUL64r : RI<0xF7, MRM5r, (outs), (ins GR64:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000427 "imul{q}\t$src", []>; // RAX,RDX = RAX*GR64
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000428let mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000429def IMUL64m : RI<0xF7, MRM5m, (outs), (ins i64mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000430 "imul{q}\t$src", []>; // RAX,RDX = RAX*[mem64]
431}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000432
Evan Cheng55687072007-09-14 21:48:26 +0000433let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000434let isTwoAddress = 1 in {
435let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000436def IMUL64rr : RI<0xAF, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000437 "imul{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000438 [(set GR64:$dst, (mul GR64:$src1, GR64:$src2))]>, TB;
439
Evan Chengb783fa32007-07-19 01:14:50 +0000440def IMUL64rm : RI<0xAF, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000441 "imul{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000442 [(set GR64:$dst, (mul GR64:$src1, (load addr:$src2)))]>, TB;
443} // isTwoAddress
444
445// Suprisingly enough, these are not two address instructions!
446def IMUL64rri32 : RIi32<0x69, MRMSrcReg, // GR64 = GR64*I32
Evan Chengb783fa32007-07-19 01:14:50 +0000447 (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000448 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000449 [(set GR64:$dst, (mul GR64:$src1, i64immSExt32:$src2))]>;
450def IMUL64rri8 : RIi8<0x6B, MRMSrcReg, // GR64 = GR64*I8
Evan Chengb783fa32007-07-19 01:14:50 +0000451 (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000452 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000453 [(set GR64:$dst, (mul GR64:$src1, i64immSExt8:$src2))]>;
454def IMUL64rmi32 : RIi32<0x69, MRMSrcMem, // GR64 = [mem64]*I32
Evan Chengb783fa32007-07-19 01:14:50 +0000455 (outs GR64:$dst), (ins i64mem:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000456 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000457 [(set GR64:$dst, (mul (load addr:$src1), i64immSExt32:$src2))]>;
458def IMUL64rmi8 : RIi8<0x6B, MRMSrcMem, // GR64 = [mem64]*I8
Evan Chengb783fa32007-07-19 01:14:50 +0000459 (outs GR64:$dst), (ins i64mem:$src1, i64i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000460 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000461 [(set GR64:$dst, (mul (load addr:$src1), i64immSExt8:$src2))]>;
Evan Cheng55687072007-09-14 21:48:26 +0000462} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000463
464// Unsigned division / remainder
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000465let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000466let Defs = [RAX,RDX,EFLAGS], Uses = [RAX,RDX] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000467def DIV64r : RI<0xF7, MRM6r, (outs), (ins GR64:$src), // RDX:RAX/r64 = RAX,RDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000468 "div{q}\t$src", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000469// Signed division / remainder
Evan Chengb783fa32007-07-19 01:14:50 +0000470def IDIV64r: RI<0xF7, MRM7r, (outs), (ins GR64:$src), // RDX:RAX/r64 = RAX,RDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000471 "idiv{q}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000472let mayLoad = 1 in {
473def DIV64m : RI<0xF7, MRM6m, (outs), (ins i64mem:$src), // RDX:RAX/[mem64] = RAX,RDX
474 "div{q}\t$src", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000475def IDIV64m: RI<0xF7, MRM7m, (outs), (ins i64mem:$src), // RDX:RAX/[mem64] = RAX,RDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000476 "idiv{q}\t$src", []>;
477}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000478}
479}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000480
481// Unary instructions
Evan Cheng55687072007-09-14 21:48:26 +0000482let Defs = [EFLAGS], CodeSize = 2 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000483let isTwoAddress = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000484def NEG64r : RI<0xF7, MRM3r, (outs GR64:$dst), (ins GR64:$src), "neg{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000485 [(set GR64:$dst, (ineg GR64:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000486def NEG64m : RI<0xF7, MRM3m, (outs), (ins i64mem:$dst), "neg{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000487 [(store (ineg (loadi64 addr:$dst)), addr:$dst)]>;
488
489let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000490def INC64r : RI<0xFF, MRM0r, (outs GR64:$dst), (ins GR64:$src), "inc{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000491 [(set GR64:$dst, (add GR64:$src, 1))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000492def INC64m : RI<0xFF, MRM0m, (outs), (ins i64mem:$dst), "inc{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000493 [(store (add (loadi64 addr:$dst), 1), addr:$dst)]>;
494
495let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000496def DEC64r : RI<0xFF, MRM1r, (outs GR64:$dst), (ins GR64:$src), "dec{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000497 [(set GR64:$dst, (add GR64:$src, -1))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000498def DEC64m : RI<0xFF, MRM1m, (outs), (ins i64mem:$dst), "dec{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000499 [(store (add (loadi64 addr:$dst), -1), addr:$dst)]>;
500
501// In 64-bit mode, single byte INC and DEC cannot be encoded.
502let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in {
503// Can transform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +0000504def INC64_16r : I<0xFF, MRM0r, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000505 [(set GR16:$dst, (add GR16:$src, 1))]>,
506 OpSize, Requires<[In64BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000507def INC64_32r : I<0xFF, MRM0r, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000508 [(set GR32:$dst, (add GR32:$src, 1))]>,
509 Requires<[In64BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000510def DEC64_16r : I<0xFF, MRM1r, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000511 [(set GR16:$dst, (add GR16:$src, -1))]>,
512 OpSize, Requires<[In64BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000513def DEC64_32r : I<0xFF, MRM1r, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000514 [(set GR32:$dst, (add GR32:$src, -1))]>,
515 Requires<[In64BitMode]>;
516} // isConvertibleToThreeAddress
Evan Cheng4a7e72f2007-10-19 21:23:22 +0000517
518// These are duplicates of their 32-bit counterparts. Only needed so X86 knows
519// how to unfold them.
520let isTwoAddress = 0, CodeSize = 2 in {
521 def INC64_16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
522 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>,
523 OpSize, Requires<[In64BitMode]>;
524 def INC64_32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
525 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>,
526 Requires<[In64BitMode]>;
527 def DEC64_16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
528 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>,
529 OpSize, Requires<[In64BitMode]>;
530 def DEC64_32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
531 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>,
532 Requires<[In64BitMode]>;
533}
Evan Cheng55687072007-09-14 21:48:26 +0000534} // Defs = [EFLAGS], CodeSize
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000535
536
Evan Cheng55687072007-09-14 21:48:26 +0000537let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000538// Shift instructions
539let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000540let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000541def SHL64rCL : RI<0xD3, MRM4r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000542 "shl{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000543 [(set GR64:$dst, (shl GR64:$src, CL))]>;
Evan Chenga98f6272007-10-05 18:20:36 +0000544let isConvertibleToThreeAddress = 1 in // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +0000545def SHL64ri : RIi8<0xC1, MRM4r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000546 "shl{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000547 [(set GR64:$dst, (shl GR64:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +0000548// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
549// cheaper.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000550} // isTwoAddress
551
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000552let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000553def SHL64mCL : RI<0xD3, MRM4m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000554 "shl{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000555 [(store (shl (loadi64 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000556def SHL64mi : RIi8<0xC1, MRM4m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000557 "shl{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000558 [(store (shl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000559def SHL64m1 : RI<0xD1, MRM4m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000560 "shl{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000561 [(store (shl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
562
563let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000564let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000565def SHR64rCL : RI<0xD3, MRM5r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000566 "shr{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000567 [(set GR64:$dst, (srl GR64:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000568def SHR64ri : RIi8<0xC1, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000569 "shr{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000570 [(set GR64:$dst, (srl GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000571def SHR64r1 : RI<0xD1, MRM5r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000572 "shr{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000573 [(set GR64:$dst, (srl GR64:$src1, (i8 1)))]>;
574} // isTwoAddress
575
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000576let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000577def SHR64mCL : RI<0xD3, MRM5m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000578 "shr{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000579 [(store (srl (loadi64 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000580def SHR64mi : RIi8<0xC1, MRM5m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000581 "shr{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000582 [(store (srl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000583def SHR64m1 : RI<0xD1, MRM5m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000584 "shr{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000585 [(store (srl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
586
587let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000588let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000589def SAR64rCL : RI<0xD3, MRM7r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000590 "sar{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000591 [(set GR64:$dst, (sra GR64:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000592def SAR64ri : RIi8<0xC1, MRM7r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000593 "sar{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000594 [(set GR64:$dst, (sra GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000595def SAR64r1 : RI<0xD1, MRM7r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000596 "sar{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000597 [(set GR64:$dst, (sra GR64:$src1, (i8 1)))]>;
598} // isTwoAddress
599
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000600let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000601def SAR64mCL : RI<0xD3, MRM7m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000602 "sar{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000603 [(store (sra (loadi64 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000604def SAR64mi : RIi8<0xC1, MRM7m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000605 "sar{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000606 [(store (sra (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000607def SAR64m1 : RI<0xD1, MRM7m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000608 "sar{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000609 [(store (sra (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
610
611// Rotate instructions
612let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000613let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000614def ROL64rCL : RI<0xD3, MRM0r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000615 "rol{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000616 [(set GR64:$dst, (rotl GR64:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000617def ROL64ri : RIi8<0xC1, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000618 "rol{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000619 [(set GR64:$dst, (rotl GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000620def ROL64r1 : RI<0xD1, MRM0r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000621 "rol{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000622 [(set GR64:$dst, (rotl GR64:$src1, (i8 1)))]>;
623} // isTwoAddress
624
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000625let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000626def ROL64mCL : I<0xD3, MRM0m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000627 "rol{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000628 [(store (rotl (loadi64 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000629def ROL64mi : RIi8<0xC1, MRM0m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000630 "rol{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000631 [(store (rotl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000632def ROL64m1 : RI<0xD1, MRM0m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000633 "rol{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000634 [(store (rotl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
635
636let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000637let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000638def ROR64rCL : RI<0xD3, MRM1r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000639 "ror{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000640 [(set GR64:$dst, (rotr GR64:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000641def ROR64ri : RIi8<0xC1, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000642 "ror{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000643 [(set GR64:$dst, (rotr GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000644def ROR64r1 : RI<0xD1, MRM1r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000645 "ror{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000646 [(set GR64:$dst, (rotr GR64:$src1, (i8 1)))]>;
647} // isTwoAddress
648
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000649let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000650def ROR64mCL : RI<0xD3, MRM1m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000651 "ror{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000652 [(store (rotr (loadi64 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000653def ROR64mi : RIi8<0xC1, MRM1m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000654 "ror{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000655 [(store (rotr (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000656def ROR64m1 : RI<0xD1, MRM1m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000657 "ror{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000658 [(store (rotr (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
659
660// Double shift instructions (generalizations of rotate)
661let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000662let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000663def SHLD64rrCL : RI<0xA5, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000664 "shld{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
665 [(set GR64:$dst, (X86shld GR64:$src1, GR64:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000666def SHRD64rrCL : RI<0xAD, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000667 "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
668 [(set GR64:$dst, (X86shrd GR64:$src1, GR64:$src2, CL))]>, TB;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000669}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000670
671let isCommutable = 1 in { // FIXME: Update X86InstrInfo::commuteInstruction
672def SHLD64rri8 : RIi8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000673 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2, i8imm:$src3),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000674 "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
675 [(set GR64:$dst, (X86shld GR64:$src1, GR64:$src2,
676 (i8 imm:$src3)))]>,
677 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000678def SHRD64rri8 : RIi8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000679 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2, i8imm:$src3),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000680 "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
681 [(set GR64:$dst, (X86shrd GR64:$src1, GR64:$src2,
682 (i8 imm:$src3)))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000683 TB;
684} // isCommutable
685} // isTwoAddress
686
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000687let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000688def SHLD64mrCL : RI<0xA5, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000689 "shld{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
690 [(store (X86shld (loadi64 addr:$dst), GR64:$src2, CL),
691 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000692def SHRD64mrCL : RI<0xAD, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000693 "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
694 [(store (X86shrd (loadi64 addr:$dst), GR64:$src2, CL),
695 addr:$dst)]>, TB;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000696}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000697def SHLD64mri8 : RIi8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000698 (outs), (ins i64mem:$dst, GR64:$src2, i8imm:$src3),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000699 "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
700 [(store (X86shld (loadi64 addr:$dst), GR64:$src2,
701 (i8 imm:$src3)), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000702 TB;
703def SHRD64mri8 : RIi8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000704 (outs), (ins i64mem:$dst, GR64:$src2, i8imm:$src3),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000705 "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
706 [(store (X86shrd (loadi64 addr:$dst), GR64:$src2,
707 (i8 imm:$src3)), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000708 TB;
Evan Cheng55687072007-09-14 21:48:26 +0000709} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000710
711//===----------------------------------------------------------------------===//
712// Logical Instructions...
713//
714
715let isTwoAddress = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000716def NOT64r : RI<0xF7, MRM2r, (outs GR64:$dst), (ins GR64:$src), "not{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000717 [(set GR64:$dst, (not GR64:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000718def NOT64m : RI<0xF7, MRM2m, (outs), (ins i64mem:$dst), "not{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000719 [(store (not (loadi64 addr:$dst)), addr:$dst)]>;
720
Evan Cheng55687072007-09-14 21:48:26 +0000721let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000722let isTwoAddress = 1 in {
723let isCommutable = 1 in
724def AND64rr : RI<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000725 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000726 "and{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000727 [(set GR64:$dst, (and GR64:$src1, GR64:$src2))]>;
728def AND64rm : RI<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000729 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000730 "and{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000731 [(set GR64:$dst, (and GR64:$src1, (load addr:$src2)))]>;
732def AND64ri32 : RIi32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +0000733 (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000734 "and{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000735 [(set GR64:$dst, (and GR64:$src1, i64immSExt32:$src2))]>;
736def AND64ri8 : RIi8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +0000737 (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000738 "and{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000739 [(set GR64:$dst, (and GR64:$src1, i64immSExt8:$src2))]>;
740} // isTwoAddress
741
742def AND64mr : RI<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000743 (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000744 "and{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000745 [(store (and (load addr:$dst), GR64:$src), addr:$dst)]>;
746def AND64mi32 : RIi32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +0000747 (outs), (ins i64mem:$dst, i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000748 "and{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000749 [(store (and (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>;
750def AND64mi8 : RIi8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +0000751 (outs), (ins i64mem:$dst, i64i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000752 "and{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000753 [(store (and (load addr:$dst), i64immSExt8:$src), addr:$dst)]>;
754
755let isTwoAddress = 1 in {
756let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000757def OR64rr : RI<0x09, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000758 "or{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000759 [(set GR64:$dst, (or GR64:$src1, GR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000760def OR64rm : RI<0x0B, MRMSrcMem , (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000761 "or{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000762 [(set GR64:$dst, (or GR64:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000763def OR64ri32 : RIi32<0x81, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000764 "or{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000765 [(set GR64:$dst, (or GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000766def OR64ri8 : RIi8<0x83, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000767 "or{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000768 [(set GR64:$dst, (or GR64:$src1, i64immSExt8:$src2))]>;
769} // isTwoAddress
770
Evan Chengb783fa32007-07-19 01:14:50 +0000771def OR64mr : RI<0x09, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000772 "or{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000773 [(store (or (load addr:$dst), GR64:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000774def OR64mi32 : RIi32<0x81, MRM1m, (outs), (ins i64mem:$dst, i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000775 "or{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000776 [(store (or (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000777def OR64mi8 : RIi8<0x83, MRM1m, (outs), (ins i64mem:$dst, i64i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000778 "or{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000779 [(store (or (load addr:$dst), i64immSExt8:$src), addr:$dst)]>;
780
781let isTwoAddress = 1 in {
Evan Cheng0685efa2008-08-30 08:54:22 +0000782let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000783def XOR64rr : RI<0x31, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000784 "xor{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000785 [(set GR64:$dst, (xor GR64:$src1, GR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000786def XOR64rm : RI<0x33, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000787 "xor{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000788 [(set GR64:$dst, (xor GR64:$src1, (load addr:$src2)))]>;
789def XOR64ri32 : RIi32<0x81, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +0000790 (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000791 "xor{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000792 [(set GR64:$dst, (xor GR64:$src1, i64immSExt32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000793def XOR64ri8 : RIi8<0x83, MRM6r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000794 "xor{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000795 [(set GR64:$dst, (xor GR64:$src1, i64immSExt8:$src2))]>;
796} // isTwoAddress
797
Evan Chengb783fa32007-07-19 01:14:50 +0000798def XOR64mr : RI<0x31, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000799 "xor{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000800 [(store (xor (load addr:$dst), GR64:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000801def XOR64mi32 : RIi32<0x81, MRM6m, (outs), (ins i64mem:$dst, i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000802 "xor{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000803 [(store (xor (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000804def XOR64mi8 : RIi8<0x83, MRM6m, (outs), (ins i64mem:$dst, i64i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000805 "xor{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000806 [(store (xor (load addr:$dst), i64immSExt8:$src), addr:$dst)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000807} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000808
809//===----------------------------------------------------------------------===//
810// Comparison Instructions...
811//
812
813// Integer comparison
Evan Cheng55687072007-09-14 21:48:26 +0000814let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000815let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000816def TEST64rr : RI<0x85, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000817 "test{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000818 [(X86cmp (and GR64:$src1, GR64:$src2), 0),
819 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000820def TEST64rm : RI<0x85, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000821 "test{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000822 [(X86cmp (and GR64:$src1, (loadi64 addr:$src2)), 0),
823 (implicit EFLAGS)]>;
824def TEST64ri32 : RIi32<0xF7, MRM0r, (outs),
825 (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000826 "test{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000827 [(X86cmp (and GR64:$src1, i64immSExt32:$src2), 0),
828 (implicit EFLAGS)]>;
829def TEST64mi32 : RIi32<0xF7, MRM0m, (outs),
830 (ins i64mem:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000831 "test{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000832 [(X86cmp (and (loadi64 addr:$src1), i64immSExt32:$src2), 0),
833 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000834
Evan Chengb783fa32007-07-19 01:14:50 +0000835def CMP64rr : RI<0x39, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000836 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000837 [(X86cmp GR64:$src1, GR64:$src2),
838 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000839def CMP64mr : RI<0x39, MRMDestMem, (outs), (ins i64mem:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000840 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000841 [(X86cmp (loadi64 addr:$src1), GR64:$src2),
842 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000843def CMP64rm : RI<0x3B, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000844 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000845 [(X86cmp GR64:$src1, (loadi64 addr:$src2)),
846 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000847def CMP64ri32 : RIi32<0x81, MRM7r, (outs), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000848 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000849 [(X86cmp GR64:$src1, i64immSExt32:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000850 (implicit EFLAGS)]>;
Evan Cheng621216e2007-09-29 00:00:36 +0000851def CMP64mi32 : RIi32<0x81, MRM7m, (outs),
Evan Cheng950aac02007-09-25 01:57:46 +0000852 (ins i64mem:$src1, i64i32imm:$src2),
853 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000854 [(X86cmp (loadi64 addr:$src1), i64immSExt32:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000855 (implicit EFLAGS)]>;
Evan Cheng621216e2007-09-29 00:00:36 +0000856def CMP64mi8 : RIi8<0x83, MRM7m, (outs), (ins i64mem:$src1, i64i8imm:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000857 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000858 [(X86cmp (loadi64 addr:$src1), i64immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000859 (implicit EFLAGS)]>;
Evan Cheng621216e2007-09-29 00:00:36 +0000860def CMP64ri8 : RIi8<0x83, MRM7r, (outs), (ins GR64:$src1, i64i8imm:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000861 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000862 [(X86cmp GR64:$src1, i64immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000863 (implicit EFLAGS)]>;
864} // Defs = [EFLAGS]
865
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000866// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000867let Uses = [EFLAGS], isTwoAddress = 1 in {
Evan Cheng926658c2007-10-05 23:13:21 +0000868let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000869def CMOVB64rr : RI<0x42, MRMSrcReg, // if <u, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000870 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000871 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000872 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000873 X86_COND_B, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000874def CMOVAE64rr: RI<0x43, MRMSrcReg, // if >=u, 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 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000877 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000878 X86_COND_AE, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000879def CMOVE64rr : RI<0x44, MRMSrcReg, // if ==, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000880 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000881 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000882 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000883 X86_COND_E, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000884def CMOVNE64rr: RI<0x45, MRMSrcReg, // if !=, 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 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000887 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000888 X86_COND_NE, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000889def CMOVBE64rr: RI<0x46, MRMSrcReg, // if <=u, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000890 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000891 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000892 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000893 X86_COND_BE, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000894def CMOVA64rr : RI<0x47, MRMSrcReg, // if >u, 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 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000897 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000898 X86_COND_A, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000899def CMOVL64rr : RI<0x4C, MRMSrcReg, // if <s, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000900 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000901 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000902 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000903 X86_COND_L, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000904def CMOVGE64rr: RI<0x4D, 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 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000907 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000908 X86_COND_GE, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000909def CMOVLE64rr: RI<0x4E, MRMSrcReg, // if <=s, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000910 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000911 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000912 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000913 X86_COND_LE, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000914def CMOVG64rr : RI<0x4F, MRMSrcReg, // if >s, 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 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000917 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000918 X86_COND_G, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000919def CMOVS64rr : RI<0x48, MRMSrcReg, // if signed, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000920 (outs GR64:$dst), (ins GR64:$src1, GR64:$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, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000923 X86_COND_S, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000924def 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,
Evan Cheng621216e2007-09-29 00:00:36 +0000928 X86_COND_NS, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000929def CMOVP64rr : RI<0x4A, MRMSrcReg, // if parity, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000930 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000931 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000932 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000933 X86_COND_P, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000934def CMOVNP64rr : RI<0x4B, 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 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000937 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000938 X86_COND_NP, EFLAGS))]>, TB;
Evan Cheng926658c2007-10-05 23:13:21 +0000939} // isCommutable = 1
940
941def CMOVB64rm : RI<0x42, MRMSrcMem, // if <u, GR64 = [mem64]
942 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
943 "cmovb\t{$src2, $dst|$dst, $src2}",
944 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
945 X86_COND_B, EFLAGS))]>, TB;
946def CMOVAE64rm: RI<0x43, MRMSrcMem, // if >=u, GR64 = [mem64]
947 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
948 "cmovae\t{$src2, $dst|$dst, $src2}",
949 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
950 X86_COND_AE, EFLAGS))]>, TB;
951def CMOVE64rm : RI<0x44, MRMSrcMem, // if ==, GR64 = [mem64]
952 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
953 "cmove\t{$src2, $dst|$dst, $src2}",
954 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
955 X86_COND_E, EFLAGS))]>, TB;
956def CMOVNE64rm: RI<0x45, MRMSrcMem, // if !=, GR64 = [mem64]
957 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
958 "cmovne\t{$src2, $dst|$dst, $src2}",
959 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
960 X86_COND_NE, EFLAGS))]>, TB;
961def CMOVBE64rm: RI<0x46, MRMSrcMem, // if <=u, GR64 = [mem64]
962 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
963 "cmovbe\t{$src2, $dst|$dst, $src2}",
964 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
965 X86_COND_BE, EFLAGS))]>, TB;
966def CMOVA64rm : RI<0x47, MRMSrcMem, // if >u, GR64 = [mem64]
967 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
968 "cmova\t{$src2, $dst|$dst, $src2}",
969 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
970 X86_COND_A, EFLAGS))]>, TB;
971def CMOVL64rm : RI<0x4C, MRMSrcMem, // if <s, GR64 = [mem64]
972 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
973 "cmovl\t{$src2, $dst|$dst, $src2}",
974 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
975 X86_COND_L, EFLAGS))]>, TB;
976def CMOVGE64rm: RI<0x4D, MRMSrcMem, // if >=s, GR64 = [mem64]
977 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
978 "cmovge\t{$src2, $dst|$dst, $src2}",
979 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
980 X86_COND_GE, EFLAGS))]>, TB;
981def CMOVLE64rm: RI<0x4E, MRMSrcMem, // if <=s, GR64 = [mem64]
982 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
983 "cmovle\t{$src2, $dst|$dst, $src2}",
984 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
985 X86_COND_LE, EFLAGS))]>, TB;
986def CMOVG64rm : RI<0x4F, MRMSrcMem, // if >s, GR64 = [mem64]
987 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
988 "cmovg\t{$src2, $dst|$dst, $src2}",
989 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
990 X86_COND_G, EFLAGS))]>, TB;
991def CMOVS64rm : RI<0x48, MRMSrcMem, // if signed, GR64 = [mem64]
992 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
993 "cmovs\t{$src2, $dst|$dst, $src2}",
994 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
995 X86_COND_S, EFLAGS))]>, TB;
996def CMOVNS64rm: RI<0x49, MRMSrcMem, // if !signed, GR64 = [mem64]
997 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
998 "cmovns\t{$src2, $dst|$dst, $src2}",
999 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1000 X86_COND_NS, EFLAGS))]>, TB;
1001def CMOVP64rm : RI<0x4A, MRMSrcMem, // if parity, GR64 = [mem64]
1002 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1003 "cmovp\t{$src2, $dst|$dst, $src2}",
1004 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1005 X86_COND_P, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001006def CMOVNP64rm : RI<0x4B, MRMSrcMem, // if !parity, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +00001007 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001008 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001009 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00001010 X86_COND_NP, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001011} // isTwoAddress
1012
1013//===----------------------------------------------------------------------===//
1014// Conversion Instructions...
1015//
1016
1017// f64 -> signed i64
Evan Chengb783fa32007-07-19 01:14:50 +00001018def Int_CVTSD2SI64rr: RSDI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001019 "cvtsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001020 [(set GR64:$dst,
1021 (int_x86_sse2_cvtsd2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001022def Int_CVTSD2SI64rm: RSDI<0x2D, MRMSrcMem, (outs GR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001023 "cvtsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001024 [(set GR64:$dst, (int_x86_sse2_cvtsd2si64
1025 (load addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001026def CVTTSD2SI64rr: RSDI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001027 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001028 [(set GR64:$dst, (fp_to_sint FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001029def CVTTSD2SI64rm: RSDI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001030 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001031 [(set GR64:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001032def Int_CVTTSD2SI64rr: RSDI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001033 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001034 [(set GR64:$dst,
1035 (int_x86_sse2_cvttsd2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001036def Int_CVTTSD2SI64rm: RSDI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001037 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001038 [(set GR64:$dst,
1039 (int_x86_sse2_cvttsd2si64
1040 (load addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001041
1042// Signed i64 -> f64
Evan Chengb783fa32007-07-19 01:14:50 +00001043def CVTSI2SD64rr: RSDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001044 "cvtsi2sd{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001045 [(set FR64:$dst, (sint_to_fp GR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001046def CVTSI2SD64rm: RSDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001047 "cvtsi2sd{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001048 [(set FR64:$dst, (sint_to_fp (loadi64 addr:$src)))]>;
Evan Cheng1d5832e2008-01-11 07:37:44 +00001049
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001050let isTwoAddress = 1 in {
1051def Int_CVTSI2SD64rr: RSDI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001052 (outs VR128:$dst), (ins VR128:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001053 "cvtsi2sd{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendling6227d462007-07-23 03:07:27 +00001054 [(set VR128:$dst,
1055 (int_x86_sse2_cvtsi642sd VR128:$src1,
1056 GR64:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001057def Int_CVTSI2SD64rm: RSDI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001058 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001059 "cvtsi2sd{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendling6227d462007-07-23 03:07:27 +00001060 [(set VR128:$dst,
1061 (int_x86_sse2_cvtsi642sd VR128:$src1,
1062 (loadi64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001063} // isTwoAddress
1064
1065// Signed i64 -> f32
Evan Chengb783fa32007-07-19 01:14:50 +00001066def CVTSI2SS64rr: RSSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001067 "cvtsi2ss{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001068 [(set FR32:$dst, (sint_to_fp GR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001069def CVTSI2SS64rm: RSSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001070 "cvtsi2ss{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001071 [(set FR32:$dst, (sint_to_fp (loadi64 addr:$src)))]>;
Evan Cheng1d5832e2008-01-11 07:37:44 +00001072
1073let isTwoAddress = 1 in {
1074 def Int_CVTSI2SS64rr : RSSI<0x2A, MRMSrcReg,
1075 (outs VR128:$dst), (ins VR128:$src1, GR64:$src2),
1076 "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}",
1077 [(set VR128:$dst,
1078 (int_x86_sse_cvtsi642ss VR128:$src1,
1079 GR64:$src2))]>;
1080 def Int_CVTSI2SS64rm : RSSI<0x2A, MRMSrcMem,
1081 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
1082 "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}",
1083 [(set VR128:$dst,
1084 (int_x86_sse_cvtsi642ss VR128:$src1,
1085 (loadi64 addr:$src2)))]>;
1086}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001087
1088// f32 -> signed i64
Evan Chengb783fa32007-07-19 01:14:50 +00001089def Int_CVTSS2SI64rr: RSSI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001090 "cvtss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001091 [(set GR64:$dst,
1092 (int_x86_sse_cvtss2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001093def Int_CVTSS2SI64rm: RSSI<0x2D, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001094 "cvtss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001095 [(set GR64:$dst, (int_x86_sse_cvtss2si64
1096 (load addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001097def CVTTSS2SI64rr: RSSI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001098 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001099 [(set GR64:$dst, (fp_to_sint FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001100def CVTTSS2SI64rm: RSSI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001101 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001102 [(set GR64:$dst, (fp_to_sint (loadf32 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001103def Int_CVTTSS2SI64rr: RSSI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001104 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001105 [(set GR64:$dst,
1106 (int_x86_sse_cvttss2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001107def Int_CVTTSS2SI64rm: RSSI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001108 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001109 [(set GR64:$dst,
1110 (int_x86_sse_cvttss2si64 (load addr:$src)))]>;
1111
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001112//===----------------------------------------------------------------------===//
1113// Alias Instructions
1114//===----------------------------------------------------------------------===//
1115
Dan Gohman027cd112007-09-17 14:55:08 +00001116// Alias instructions that map movr0 to xor. Use xorl instead of xorq; it's
1117// equivalent due to implicit zero-extending, and it sometimes has a smaller
1118// encoding.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001119// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
1120// FIXME: AddedComplexity gives MOV64r0 a higher priority than MOV64ri32. Remove
1121// when we have a better way to specify isel priority.
Bill Wendling12e97212008-05-30 06:47:04 +00001122let Defs = [EFLAGS], AddedComplexity = 1,
1123 isReMaterializable = 1, isAsCheapAsAMove = 1 in
Dan Gohman9203ab42008-07-30 18:09:17 +00001124def MOV64r0 : I<0x31, MRMInitReg, (outs GR64:$dst), (ins),
1125 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
1126 [(set GR64:$dst, 0)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001127
1128// Materialize i64 constant where top 32-bits are zero.
Chris Lattner17dab4a2008-01-10 05:45:39 +00001129let AddedComplexity = 1, isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001130def MOV64ri64i32 : Ii32<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001131 "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001132 [(set GR64:$dst, i64immZExt32:$src)]>;
1133
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +00001134//===----------------------------------------------------------------------===//
1135// Thread Local Storage Instructions
1136//===----------------------------------------------------------------------===//
1137
1138def TLS_addr64 : I<0, Pseudo, (outs GR64:$dst), (ins i64imm:$sym),
Anton Korobeynikov5577e2e2008-05-05 17:08:59 +00001139 ".byte\t0x66; leaq\t${sym:mem}(%rip), $dst; .word\t0x6666; rex64",
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +00001140 [(set GR64:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
Andrew Lenharthbd7d3262008-03-04 21:13:33 +00001141
1142//===----------------------------------------------------------------------===//
1143// Atomic Instructions
1144//===----------------------------------------------------------------------===//
1145
Andrew Lenharthbd7d3262008-03-04 21:13:33 +00001146let Defs = [RAX, EFLAGS], Uses = [RAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00001147def LCMPXCHG64 : RI<0xB1, MRMDestMem, (outs), (ins i64mem:$ptr, GR64:$swap),
Bill Wendling6f189e22008-08-19 23:09:18 +00001148 "lock\n\tcmpxchgq\t$swap,$ptr",
Andrew Lenharthbd7d3262008-03-04 21:13:33 +00001149 [(X86cas addr:$ptr, GR64:$swap, 8)]>, TB, LOCK;
1150}
1151
Dan Gohmana41a1c092008-08-06 15:52:50 +00001152let Constraints = "$val = $dst" in {
1153let Defs = [EFLAGS] in
Evan Chengd49dbb82008-04-18 20:55:36 +00001154def LXADD64 : RI<0xC1, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$ptr,GR64:$val),
Bill Wendling6f189e22008-08-19 23:09:18 +00001155 "lock\n\txadd\t$val, $ptr",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00001156 [(set GR64:$dst, (atomic_load_add_64 addr:$ptr, GR64:$val))]>,
Andrew Lenharthbd7d3262008-03-04 21:13:33 +00001157 TB, LOCK;
Evan Chenga1e80602008-04-19 02:05:42 +00001158def XCHG64rm : RI<0x87, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$ptr,GR64:$val),
Bill Wendling6f189e22008-08-19 23:09:18 +00001159 "xchg\t$val, $ptr",
Evan Chenga1e80602008-04-19 02:05:42 +00001160 [(set GR64:$dst, (atomic_swap_64 addr:$ptr, GR64:$val))]>;
Andrew Lenharthbd7d3262008-03-04 21:13:33 +00001161}
1162
Dale Johannesen6b60eca2008-08-20 00:48:50 +00001163// Atomic exchange, and, or, xor
1164let Constraints = "$val = $dst", Defs = [EFLAGS],
1165 usesCustomDAGSchedInserter = 1 in {
1166def ATOMAND64 : I<0, Pseudo, (outs GR64:$dst),(ins i64mem:$ptr, GR64:$val),
1167 "#ATOMAND64 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00001168 [(set GR64:$dst, (atomic_load_and_64 addr:$ptr, GR64:$val))]>;
Dale Johannesen6b60eca2008-08-20 00:48:50 +00001169def ATOMOR64 : I<0, Pseudo, (outs GR64:$dst),(ins i64mem:$ptr, GR64:$val),
1170 "#ATOMOR64 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00001171 [(set GR64:$dst, (atomic_load_or_64 addr:$ptr, GR64:$val))]>;
Dale Johannesen6b60eca2008-08-20 00:48:50 +00001172def ATOMXOR64 : I<0, Pseudo,(outs GR64:$dst),(ins i64mem:$ptr, GR64:$val),
1173 "#ATOMXOR64 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00001174 [(set GR64:$dst, (atomic_load_xor_64 addr:$ptr, GR64:$val))]>;
Dale Johannesen6b60eca2008-08-20 00:48:50 +00001175def ATOMNAND64 : I<0, Pseudo,(outs GR64:$dst),(ins i64mem:$ptr, GR64:$val),
1176 "#ATOMNAND64 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00001177 [(set GR64:$dst, (atomic_load_nand_64 addr:$ptr, GR64:$val))]>;
Dale Johannesen6b60eca2008-08-20 00:48:50 +00001178def ATOMMIN64: I<0, Pseudo, (outs GR64:$dst), (ins i64mem:$ptr, GR64:$val),
1179 "#ATOMMIN64 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00001180 [(set GR64:$dst, (atomic_load_min_64 addr:$ptr, GR64:$val))]>;
Dale Johannesen6b60eca2008-08-20 00:48:50 +00001181def ATOMMAX64: I<0, Pseudo, (outs GR64:$dst),(ins i64mem:$ptr, GR64:$val),
1182 "#ATOMMAX64 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00001183 [(set GR64:$dst, (atomic_load_max_64 addr:$ptr, GR64:$val))]>;
Dale Johannesen6b60eca2008-08-20 00:48:50 +00001184def ATOMUMIN64: I<0, Pseudo, (outs GR64:$dst),(ins i64mem:$ptr, GR64:$val),
1185 "#ATOMUMIN64 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00001186 [(set GR64:$dst, (atomic_load_umin_64 addr:$ptr, GR64:$val))]>;
Dale Johannesen6b60eca2008-08-20 00:48:50 +00001187def ATOMUMAX64: I<0, Pseudo, (outs GR64:$dst),(ins i64mem:$ptr, GR64:$val),
1188 "#ATOMUMAX64 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00001189 [(set GR64:$dst, (atomic_load_umax_64 addr:$ptr, GR64:$val))]>;
Dale Johannesen6b60eca2008-08-20 00:48:50 +00001190}
Andrew Lenharthbd7d3262008-03-04 21:13:33 +00001191
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001192//===----------------------------------------------------------------------===//
1193// Non-Instruction Patterns
1194//===----------------------------------------------------------------------===//
1195
Bill Wendlingfef06052008-09-16 21:48:12 +00001196// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001197def : Pat<(i64 (X86Wrapper tconstpool :$dst)),
1198 (MOV64ri tconstpool :$dst)>, Requires<[NotSmallCode]>;
1199def : Pat<(i64 (X86Wrapper tjumptable :$dst)),
1200 (MOV64ri tjumptable :$dst)>, Requires<[NotSmallCode]>;
1201def : Pat<(i64 (X86Wrapper tglobaladdr :$dst)),
1202 (MOV64ri tglobaladdr :$dst)>, Requires<[NotSmallCode]>;
1203def : Pat<(i64 (X86Wrapper texternalsym:$dst)),
1204 (MOV64ri texternalsym:$dst)>, Requires<[NotSmallCode]>;
1205
1206def : Pat<(store (i64 (X86Wrapper tconstpool:$src)), addr:$dst),
1207 (MOV64mi32 addr:$dst, tconstpool:$src)>,
Evan Cheng3b5a1272008-02-07 08:53:49 +00001208 Requires<[SmallCode, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001209def : Pat<(store (i64 (X86Wrapper tjumptable:$src)), addr:$dst),
1210 (MOV64mi32 addr:$dst, tjumptable:$src)>,
Evan Cheng3b5a1272008-02-07 08:53:49 +00001211 Requires<[SmallCode, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001212def : Pat<(store (i64 (X86Wrapper tglobaladdr:$src)), addr:$dst),
1213 (MOV64mi32 addr:$dst, tglobaladdr:$src)>,
Evan Cheng3b5a1272008-02-07 08:53:49 +00001214 Requires<[SmallCode, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001215def : Pat<(store (i64 (X86Wrapper texternalsym:$src)), addr:$dst),
1216 (MOV64mi32 addr:$dst, texternalsym:$src)>,
Evan Cheng3b5a1272008-02-07 08:53:49 +00001217 Requires<[SmallCode, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001218
1219// Calls
1220// Direct PC relative function call for small code model. 32-bit displacement
1221// sign extended to 64-bit.
1222def : Pat<(X86call (i64 tglobaladdr:$dst)),
1223 (CALL64pcrel32 tglobaladdr:$dst)>;
1224def : Pat<(X86call (i64 texternalsym:$dst)),
1225 (CALL64pcrel32 texternalsym:$dst)>;
1226
1227def : Pat<(X86tailcall (i64 tglobaladdr:$dst)),
1228 (CALL64pcrel32 tglobaladdr:$dst)>;
1229def : Pat<(X86tailcall (i64 texternalsym:$dst)),
1230 (CALL64pcrel32 texternalsym:$dst)>;
1231
1232def : Pat<(X86tailcall GR64:$dst),
1233 (CALL64r GR64:$dst)>;
1234
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00001235
1236// tailcall stuff
1237def : Pat<(X86tailcall GR32:$dst),
1238 (TAILCALL)>;
1239def : Pat<(X86tailcall (i64 tglobaladdr:$dst)),
1240 (TAILCALL)>;
1241def : Pat<(X86tailcall (i64 texternalsym:$dst)),
1242 (TAILCALL)>;
1243
1244def : Pat<(X86tcret GR64:$dst, imm:$off),
1245 (TCRETURNri64 GR64:$dst, imm:$off)>;
1246
1247def : Pat<(X86tcret (i64 tglobaladdr:$dst), imm:$off),
1248 (TCRETURNdi64 texternalsym:$dst, imm:$off)>;
1249
1250def : Pat<(X86tcret (i64 texternalsym:$dst), imm:$off),
1251 (TCRETURNdi64 texternalsym:$dst, imm:$off)>;
1252
Dan Gohmanec596042007-09-17 14:35:24 +00001253// Comparisons.
1254
1255// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00001256def : Pat<(parallel (X86cmp GR64:$src1, 0), (implicit EFLAGS)),
Dan Gohmanec596042007-09-17 14:35:24 +00001257 (TEST64rr GR64:$src1, GR64:$src1)>;
1258
Christopher Lambb371e032008-03-13 05:47:01 +00001259
1260
1261// Zero-extension
Christopher Lamb76d72da2008-03-16 03:12:01 +00001262def : Pat<(i64 (zext GR32:$src)),
1263 (SUBREG_TO_REG (i64 0), GR32:$src, x86_subreg_32bit)>;
Christopher Lambb371e032008-03-13 05:47:01 +00001264
Duncan Sands082524c2008-01-23 20:39:46 +00001265// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001266def : Pat<(zextloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>;
1267
1268// extload
Dan Gohmanab460da2008-08-27 17:33:15 +00001269// When extloading from 16-bit and smaller memory locations into 64-bit registers,
1270// use zero-extending loads so that the entire 64-bit register is defined, avoiding
1271// partial-register updates.
1272def : Pat<(extloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>;
1273def : Pat<(extloadi64i8 addr:$src), (MOVZX64rm8 addr:$src)>;
1274def : Pat<(extloadi64i16 addr:$src), (MOVZX64rm16 addr:$src)>;
1275// For other extloads, use subregs, since the high contents of the register are
1276// defined after an extload.
Dan Gohmandd612bb2008-08-20 21:27:32 +00001277def : Pat<(extloadi64i32 addr:$src),
1278 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (MOV32rm addr:$src),
1279 x86_subreg_32bit)>;
1280def : Pat<(extloadi16i1 addr:$src),
1281 (INSERT_SUBREG (i16 (IMPLICIT_DEF)), (MOV8rm addr:$src),
1282 x86_subreg_8bit)>,
1283 Requires<[In64BitMode]>;
1284def : Pat<(extloadi16i8 addr:$src),
1285 (INSERT_SUBREG (i16 (IMPLICIT_DEF)), (MOV8rm addr:$src),
1286 x86_subreg_8bit)>,
1287 Requires<[In64BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001288
Dan Gohmandd612bb2008-08-20 21:27:32 +00001289// anyext
1290def : Pat<(i64 (anyext GR8:$src)),
1291 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GR8:$src, x86_subreg_8bit)>;
1292def : Pat<(i64 (anyext GR16:$src)),
1293 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Christopher Lamb76d72da2008-03-16 03:12:01 +00001294def : Pat<(i64 (anyext GR32:$src)),
1295 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GR32:$src, x86_subreg_32bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00001296def : Pat<(i16 (anyext GR8:$src)),
1297 (INSERT_SUBREG (i16 (IMPLICIT_DEF)), GR8:$src, x86_subreg_8bit)>,
1298 Requires<[In64BitMode]>;
1299def : Pat<(i32 (anyext GR8:$src)),
1300 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR8:$src, x86_subreg_8bit)>,
1301 Requires<[In64BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001302
1303//===----------------------------------------------------------------------===//
1304// Some peepholes
1305//===----------------------------------------------------------------------===//
1306
Dan Gohman47a419d2008-08-07 02:54:50 +00001307// r & (2^32-1) ==> movz
1308def : Pat<(and GR64:$src, i64immFFFFFFFF),
1309 (MOVZX64rr32 (i32 (EXTRACT_SUBREG GR64:$src, x86_subreg_32bit)))>;
Dan Gohman9203ab42008-07-30 18:09:17 +00001310// r & (2^16-1) ==> movz
1311def : Pat<(and GR64:$src, 0xffff),
1312 (MOVZX64rr16 (i16 (EXTRACT_SUBREG GR64:$src, x86_subreg_16bit)))>;
1313// r & (2^8-1) ==> movz
1314def : Pat<(and GR64:$src, 0xff),
1315 (MOVZX64rr8 (i8 (EXTRACT_SUBREG GR64:$src, x86_subreg_8bit)))>;
Dan Gohman9203ab42008-07-30 18:09:17 +00001316// r & (2^8-1) ==> movz
1317def : Pat<(and GR32:$src1, 0xff),
1318 (MOVZX32rr8 (i8 (EXTRACT_SUBREG GR32:$src1, x86_subreg_8bit)))>,
1319 Requires<[In64BitMode]>;
1320// r & (2^8-1) ==> movz
1321def : Pat<(and GR16:$src1, 0xff),
1322 (MOVZX16rr8 (i8 (EXTRACT_SUBREG GR16:$src1, x86_subreg_8bit)))>,
1323 Requires<[In64BitMode]>;
Christopher Lambb371e032008-03-13 05:47:01 +00001324
Dan Gohmandd612bb2008-08-20 21:27:32 +00001325// sext_inreg patterns
1326def : Pat<(sext_inreg GR64:$src, i32),
1327 (MOVSX64rr32 (i32 (EXTRACT_SUBREG GR64:$src, x86_subreg_32bit)))>;
1328def : Pat<(sext_inreg GR64:$src, i16),
1329 (MOVSX64rr16 (i16 (EXTRACT_SUBREG GR64:$src, x86_subreg_16bit)))>;
1330def : Pat<(sext_inreg GR64:$src, i8),
1331 (MOVSX64rr8 (i8 (EXTRACT_SUBREG GR64:$src, x86_subreg_8bit)))>;
1332def : Pat<(sext_inreg GR32:$src, i8),
1333 (MOVSX32rr8 (i8 (EXTRACT_SUBREG GR32:$src, x86_subreg_8bit)))>,
1334 Requires<[In64BitMode]>;
1335def : Pat<(sext_inreg GR16:$src, i8),
1336 (MOVSX16rr8 (i8 (EXTRACT_SUBREG GR16:$src, x86_subreg_8bit)))>,
1337 Requires<[In64BitMode]>;
1338
1339// trunc patterns
1340def : Pat<(i32 (trunc GR64:$src)),
1341 (i32 (EXTRACT_SUBREG GR64:$src, x86_subreg_32bit))>;
1342def : Pat<(i16 (trunc GR64:$src)),
1343 (i16 (EXTRACT_SUBREG GR64:$src, x86_subreg_16bit))>;
1344def : Pat<(i8 (trunc GR64:$src)),
1345 (i8 (EXTRACT_SUBREG GR64:$src, x86_subreg_8bit))>;
1346def : Pat<(i8 (trunc GR32:$src)),
1347 (i8 (EXTRACT_SUBREG GR32:$src, x86_subreg_8bit))>,
1348 Requires<[In64BitMode]>;
1349def : Pat<(i8 (trunc GR16:$src)),
1350 (i8 (EXTRACT_SUBREG GR16:$src, x86_subreg_8bit))>,
1351 Requires<[In64BitMode]>;
1352
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001353// (shl x, 1) ==> (add x, x)
1354def : Pat<(shl GR64:$src1, (i8 1)), (ADD64rr GR64:$src1, GR64:$src1)>;
1355
Evan Cheng76a64c72008-08-30 02:03:58 +00001356// (shl x (and y, 63)) ==> (shl x, y)
1357def : Pat<(shl GR64:$src1, (and CL:$amt, 63)),
1358 (SHL64rCL GR64:$src1)>;
1359def : Pat<(store (shl (loadi64 addr:$dst), (and CL:$amt, 63)), addr:$dst),
1360 (SHL64mCL addr:$dst)>;
1361
1362def : Pat<(srl GR64:$src1, (and CL:$amt, 63)),
1363 (SHR64rCL GR64:$src1)>;
1364def : Pat<(store (srl (loadi64 addr:$dst), (and CL:$amt, 63)), addr:$dst),
1365 (SHR64mCL addr:$dst)>;
1366
1367def : Pat<(sra GR64:$src1, (and CL:$amt, 63)),
1368 (SAR64rCL GR64:$src1)>;
1369def : Pat<(store (sra (loadi64 addr:$dst), (and CL:$amt, 63)), addr:$dst),
1370 (SAR64mCL addr:$dst)>;
1371
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001372// (or (x >> c) | (y << (64 - c))) ==> (shrd64 x, y, c)
1373def : Pat<(or (srl GR64:$src1, CL:$amt),
1374 (shl GR64:$src2, (sub 64, CL:$amt))),
1375 (SHRD64rrCL GR64:$src1, GR64:$src2)>;
1376
1377def : Pat<(store (or (srl (loadi64 addr:$dst), CL:$amt),
1378 (shl GR64:$src2, (sub 64, CL:$amt))), addr:$dst),
1379 (SHRD64mrCL addr:$dst, GR64:$src2)>;
1380
1381// (or (x << c) | (y >> (64 - c))) ==> (shld64 x, y, c)
1382def : Pat<(or (shl GR64:$src1, CL:$amt),
1383 (srl GR64:$src2, (sub 64, CL:$amt))),
1384 (SHLD64rrCL GR64:$src1, GR64:$src2)>;
1385
1386def : Pat<(store (or (shl (loadi64 addr:$dst), CL:$amt),
1387 (srl GR64:$src2, (sub 64, CL:$amt))), addr:$dst),
1388 (SHLD64mrCL addr:$dst, GR64:$src2)>;
1389
1390// X86 specific add which produces a flag.
1391def : Pat<(addc GR64:$src1, GR64:$src2),
1392 (ADD64rr GR64:$src1, GR64:$src2)>;
1393def : Pat<(addc GR64:$src1, (load addr:$src2)),
1394 (ADD64rm GR64:$src1, addr:$src2)>;
1395def : Pat<(addc GR64:$src1, i64immSExt32:$src2),
1396 (ADD64ri32 GR64:$src1, imm:$src2)>;
1397def : Pat<(addc GR64:$src1, i64immSExt8:$src2),
1398 (ADD64ri8 GR64:$src1, i64immSExt8:$src2)>;
1399
1400def : Pat<(subc GR64:$src1, GR64:$src2),
1401 (SUB64rr GR64:$src1, GR64:$src2)>;
1402def : Pat<(subc GR64:$src1, (load addr:$src2)),
1403 (SUB64rm GR64:$src1, addr:$src2)>;
1404def : Pat<(subc GR64:$src1, imm:$src2),
1405 (SUB64ri32 GR64:$src1, i64immSExt32:$src2)>;
1406def : Pat<(subc GR64:$src1, i64immSExt8:$src2),
1407 (SUB64ri8 GR64:$src1, i64immSExt8:$src2)>;
1408
1409
1410//===----------------------------------------------------------------------===//
1411// X86-64 SSE Instructions
1412//===----------------------------------------------------------------------===//
1413
1414// Move instructions...
1415
Evan Chengb783fa32007-07-19 01:14:50 +00001416def MOV64toPQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001417 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001418 [(set VR128:$dst,
1419 (v2i64 (scalar_to_vector GR64:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001420def MOVPQIto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001421 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001422 [(set GR64:$dst, (vector_extract (v2i64 VR128:$src),
1423 (iPTR 0)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001424
Evan Chengb783fa32007-07-19 01:14:50 +00001425def MOV64toSDrr : RPDI<0x6E, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001426 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001427 [(set FR64:$dst, (bitconvert GR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001428def MOV64toSDrm : RPDI<0x6E, MRMSrcMem, (outs FR64:$dst), (ins i64mem:$src),
Evan Cheng69ca4da2008-08-25 04:11:42 +00001429 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001430 [(set FR64:$dst, (bitconvert (loadi64 addr:$src)))]>;
1431
Evan Chengb783fa32007-07-19 01:14:50 +00001432def MOVSDto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001433 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001434 [(set GR64:$dst, (bitconvert FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001435def MOVSDto64mr : RPDI<0x7E, MRMDestMem, (outs), (ins i64mem:$dst, FR64:$src),
Evan Cheng69ca4da2008-08-25 04:11:42 +00001436 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001437 [(store (i64 (bitconvert FR64:$src)), addr:$dst)]>;
Nate Begemanb2975562008-02-03 07:18:54 +00001438
1439//===----------------------------------------------------------------------===//
1440// X86-64 SSE4.1 Instructions
1441//===----------------------------------------------------------------------===//
1442
Nate Begeman4294c1f2008-02-12 22:51:28 +00001443/// SS41I_extract32 - SSE 4.1 extract 32 bits to int reg or memory destination
1444multiclass SS41I_extract64<bits<8> opc, string OpcodeStr> {
Evan Cheng78d00612008-03-14 07:39:27 +00001445 def rr : SS4AIi8<opc, MRMSrcReg, (outs GR64:$dst),
Nate Begeman4294c1f2008-02-12 22:51:28 +00001446 (ins VR128:$src1, i32i8imm:$src2),
1447 !strconcat(OpcodeStr,
1448 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
1449 [(set GR64:$dst,
1450 (extractelt (v2i64 VR128:$src1), imm:$src2))]>, OpSize, REX_W;
Evan Cheng78d00612008-03-14 07:39:27 +00001451 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman4294c1f2008-02-12 22:51:28 +00001452 (ins i64mem:$dst, VR128:$src1, i32i8imm:$src2),
1453 !strconcat(OpcodeStr,
1454 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
1455 [(store (extractelt (v2i64 VR128:$src1), imm:$src2),
1456 addr:$dst)]>, OpSize, REX_W;
1457}
1458
1459defm PEXTRQ : SS41I_extract64<0x16, "pextrq">;
1460
1461let isTwoAddress = 1 in {
1462 multiclass SS41I_insert64<bits<8> opc, string OpcodeStr> {
Evan Cheng78d00612008-03-14 07:39:27 +00001463 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begeman4294c1f2008-02-12 22:51:28 +00001464 (ins VR128:$src1, GR64:$src2, i32i8imm:$src3),
1465 !strconcat(OpcodeStr,
1466 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
1467 [(set VR128:$dst,
1468 (v2i64 (insertelt VR128:$src1, GR64:$src2, imm:$src3)))]>,
1469 OpSize, REX_W;
Evan Cheng78d00612008-03-14 07:39:27 +00001470 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begeman4294c1f2008-02-12 22:51:28 +00001471 (ins VR128:$src1, i64mem:$src2, i32i8imm:$src3),
1472 !strconcat(OpcodeStr,
1473 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
1474 [(set VR128:$dst,
1475 (v2i64 (insertelt VR128:$src1, (loadi64 addr:$src2),
1476 imm:$src3)))]>, OpSize, REX_W;
1477 }
1478}
1479
1480defm PINSRQ : SS41I_insert64<0x22, "pinsrq">;