blob: 8a9a052add7621652ebeebb9e93d55d7714e6f84 [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
Dan Gohmand16fdc02008-12-19 18:25:21 +000046def i64immSExt8 : PatLeaf<(i64 imm), [{
47 // i64immSExt8 predicate - True if the 64-bit immediate fits in a 8-bit
48 // sign extended field.
49 return (int64_t)N->getZExtValue() == (int8_t)N->getZExtValue();
50}]>;
51
Dan Gohmanf17a25c2007-07-18 16:29:46 +000052def i64immSExt32 : PatLeaf<(i64 imm), [{
53 // i64immSExt32 predicate - True if the 64-bit immediate fits in a 32-bit
54 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +000055 return (int64_t)N->getZExtValue() == (int32_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +000056}]>;
57
58def i64immZExt32 : PatLeaf<(i64 imm), [{
59 // i64immZExt32 predicate - True if the 64-bit immediate fits in a 32-bit
60 // unsignedsign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +000061 return (uint64_t)N->getZExtValue() == (uint32_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +000062}]>;
63
Dan Gohmanf17a25c2007-07-18 16:29:46 +000064def sextloadi64i8 : PatFrag<(ops node:$ptr), (i64 (sextloadi8 node:$ptr))>;
65def sextloadi64i16 : PatFrag<(ops node:$ptr), (i64 (sextloadi16 node:$ptr))>;
66def sextloadi64i32 : PatFrag<(ops node:$ptr), (i64 (sextloadi32 node:$ptr))>;
67
68def zextloadi64i1 : PatFrag<(ops node:$ptr), (i64 (zextloadi1 node:$ptr))>;
69def zextloadi64i8 : PatFrag<(ops node:$ptr), (i64 (zextloadi8 node:$ptr))>;
70def zextloadi64i16 : PatFrag<(ops node:$ptr), (i64 (zextloadi16 node:$ptr))>;
71def zextloadi64i32 : PatFrag<(ops node:$ptr), (i64 (zextloadi32 node:$ptr))>;
72
73def extloadi64i1 : PatFrag<(ops node:$ptr), (i64 (extloadi1 node:$ptr))>;
74def extloadi64i8 : PatFrag<(ops node:$ptr), (i64 (extloadi8 node:$ptr))>;
75def extloadi64i16 : PatFrag<(ops node:$ptr), (i64 (extloadi16 node:$ptr))>;
76def extloadi64i32 : PatFrag<(ops node:$ptr), (i64 (extloadi32 node:$ptr))>;
77
78//===----------------------------------------------------------------------===//
79// Instruction list...
80//
81
Dan Gohman01c9f772008-10-01 18:28:06 +000082// ADJCALLSTACKDOWN/UP implicitly use/def RSP because they may be expanded into
83// a stack adjustment and the codegen must know that they may modify the stack
84// pointer before prolog-epilog rewriting occurs.
85// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
86// sub / add which can clobber EFLAGS.
87let Defs = [RSP, EFLAGS], Uses = [RSP] in {
88def ADJCALLSTACKDOWN64 : I<0, Pseudo, (outs), (ins i32imm:$amt),
89 "#ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +000090 [(X86callseq_start timm:$amt)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +000091 Requires<[In64BitMode]>;
92def ADJCALLSTACKUP64 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
93 "#ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +000094 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +000095 Requires<[In64BitMode]>;
96}
97
Dan Gohmanf17a25c2007-07-18 16:29:46 +000098//===----------------------------------------------------------------------===//
99// Call Instructions...
100//
Evan Cheng37e7c752007-07-21 00:34:19 +0000101let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000102 // All calls clobber the non-callee saved registers. RSP is marked as
103 // a use to prevent stack-pointer assignments that appear immediately
104 // before calls from potentially appearing dead. Uses for argument
105 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000106 let Defs = [RAX, RCX, RDX, RSI, RDI, R8, R9, R10, R11,
Evan Cheng931a8f42008-01-29 19:34:22 +0000107 FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0, ST1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000108 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
109 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
Dan Gohman9499cfe2008-10-01 04:14:30 +0000110 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
111 Uses = [RSP] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000112 def CALL64pcrel32 : I<0xE8, RawFrm, (outs), (ins i64imm:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000113 "call\t${dst:call}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000114 def CALL64r : I<0xFF, MRM2r, (outs), (ins GR64:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000115 "call\t{*}$dst", [(X86call GR64:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000116 def CALL64m : I<0xFF, MRM2m, (outs), (ins i64mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000117 "call\t{*}$dst", [(X86call (loadi64 addr:$dst))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000118 }
119
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000120
121
122let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengbd780d22009-02-10 21:39:44 +0000123def TCRETURNdi64 : I<0, Pseudo, (outs), (ins i64imm:$dst, i32imm:$offset,
124 variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000125 "#TC_RETURN $dst $offset",
126 []>;
127
128let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengbd780d22009-02-10 21:39:44 +0000129def TCRETURNri64 : I<0, Pseudo, (outs), (ins GR64:$dst, i32imm:$offset,
130 variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000131 "#TC_RETURN $dst $offset",
132 []>;
133
134
135let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengbd780d22009-02-10 21:39:44 +0000136 def TAILJMPr64 : I<0xFF, MRM4r, (outs), (ins GR64:$dst),
137 "jmp{q}\t{*}$dst # TAILCALL",
138 []>;
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000139
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000140// Branches
Owen Andersonf8053082007-11-12 07:39:39 +0000141let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000142 def JMP64r : I<0xFF, MRM4r, (outs), (ins GR64:$dst), "jmp{q}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000143 [(brind GR64:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000144 def JMP64m : I<0xFF, MRM4m, (outs), (ins i64mem:$dst), "jmp{q}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000145 [(brind (loadi64 addr:$dst))]>;
146}
147
148//===----------------------------------------------------------------------===//
Anton Korobeynikov1ec04ee2008-09-08 21:12:47 +0000149// EH Pseudo Instructions
150//
151let isTerminator = 1, isReturn = 1, isBarrier = 1,
152 hasCtrlDep = 1 in {
153def EH_RETURN64 : I<0xC3, RawFrm, (outs), (ins GR64:$addr),
154 "ret\t#eh_return, addr: $addr",
155 [(X86ehret GR64:$addr)]>;
156
157}
158
159//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000160// Miscellaneous Instructions...
161//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000162let Defs = [RBP,RSP], Uses = [RBP,RSP], mayLoad = 1, neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000163def LEAVE64 : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000164 (outs), (ins), "leave", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000165let Defs = [RSP], Uses = [RSP], neverHasSideEffects=1 in {
166let mayLoad = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000167def POP64r : I<0x58, AddRegFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000168 (outs GR64:$reg), (ins), "pop{q}\t$reg", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000169let mayStore = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000170def PUSH64r : I<0x50, AddRegFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000171 (outs), (ins GR64:$reg), "push{q}\t$reg", []>;
172}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000173
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000174let Defs = [RSP, EFLAGS], Uses = [RSP], mayLoad = 1 in
Evan Chengf1341312007-09-26 21:28:00 +0000175def POPFQ : I<0x9D, RawFrm, (outs), (ins), "popf", []>, REX_W;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000176let Defs = [RSP], Uses = [RSP, EFLAGS], mayStore = 1 in
Evan Chengf1341312007-09-26 21:28:00 +0000177def PUSHFQ : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000178
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000179def LEA64_32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000180 (outs GR32:$dst), (ins lea64_32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000181 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000182 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In64BitMode]>;
183
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000184let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000185def LEA64r : RI<0x8D, MRMSrcMem, (outs GR64:$dst), (ins lea64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000186 "lea{q}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000187 [(set GR64:$dst, lea64addr:$src)]>;
188
189let isTwoAddress = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000190def BSWAP64r : RI<0xC8, AddRegFrm, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000191 "bswap{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000192 [(set GR64:$dst, (bswap GR64:$src))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000193
Evan Cheng48679f42007-12-14 02:13:44 +0000194// Bit scan instructions.
195let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000196def BSF64rr : RI<0xBC, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000197 "bsf{q}\t{$src, $dst|$dst, $src}",
Evan Cheng9a8ffd52007-12-14 18:25:34 +0000198 [(set GR64:$dst, (X86bsf GR64:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000199def BSF64rm : RI<0xBC, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000200 "bsf{q}\t{$src, $dst|$dst, $src}",
Evan Cheng9a8ffd52007-12-14 18:25:34 +0000201 [(set GR64:$dst, (X86bsf (loadi64 addr:$src))),
202 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000203
Evan Cheng4e33de92007-12-14 18:49:43 +0000204def BSR64rr : RI<0xBD, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000205 "bsr{q}\t{$src, $dst|$dst, $src}",
Evan Cheng9a8ffd52007-12-14 18:25:34 +0000206 [(set GR64:$dst, (X86bsr GR64:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000207def BSR64rm : RI<0xBD, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000208 "bsr{q}\t{$src, $dst|$dst, $src}",
Evan Cheng9a8ffd52007-12-14 18:25:34 +0000209 [(set GR64:$dst, (X86bsr (loadi64 addr:$src))),
210 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000211} // Defs = [EFLAGS]
212
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000213// Repeat string ops
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000214let Defs = [RCX,RDI,RSI], Uses = [RCX,RDI,RSI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000215def REP_MOVSQ : RI<0xA5, RawFrm, (outs), (ins), "{rep;movsq|rep movsq}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000216 [(X86rep_movs i64)]>, REP;
217let Defs = [RCX,RDI], Uses = [RAX,RCX,RDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000218def REP_STOSQ : RI<0xAB, RawFrm, (outs), (ins), "{rep;stosq|rep stosq}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000219 [(X86rep_stos i64)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000220
221//===----------------------------------------------------------------------===//
222// Move Instructions...
223//
224
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000225let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000226def MOV64rr : RI<0x89, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000227 "mov{q}\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000228
Evan Chengd2b9d302008-06-25 01:16:38 +0000229let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000230def MOV64ri : RIi64<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000231 "movabs{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000232 [(set GR64:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000233def MOV64ri32 : RIi32<0xC7, MRM0r, (outs GR64:$dst), (ins i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000234 "mov{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000235 [(set GR64:$dst, i64immSExt32:$src)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +0000236}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000237
Dan Gohman5574cc72008-12-03 18:15:48 +0000238let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000239def MOV64rm : RI<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000240 "mov{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000241 [(set GR64:$dst, (load addr:$src))]>;
242
Evan Chengb783fa32007-07-19 01:14:50 +0000243def MOV64mr : RI<0x89, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000244 "mov{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000245 [(store GR64:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000246def MOV64mi32 : RIi32<0xC7, MRM0m, (outs), (ins i64mem:$dst, i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000247 "mov{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000248 [(store i64immSExt32:$src, addr:$dst)]>;
249
250// Sign/Zero extenders
251
Evan Chengb783fa32007-07-19 01:14:50 +0000252def MOVSX64rr8 : RI<0xBE, MRMSrcReg, (outs GR64:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000253 "movs{bq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000254 [(set GR64:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000255def MOVSX64rm8 : RI<0xBE, MRMSrcMem, (outs GR64:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000256 "movs{bq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000257 [(set GR64:$dst, (sextloadi64i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000258def MOVSX64rr16: RI<0xBF, MRMSrcReg, (outs GR64:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000259 "movs{wq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000260 [(set GR64:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000261def MOVSX64rm16: RI<0xBF, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000262 "movs{wq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000263 [(set GR64:$dst, (sextloadi64i16 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000264def MOVSX64rr32: RI<0x63, MRMSrcReg, (outs GR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000265 "movs{lq|xd}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000266 [(set GR64:$dst, (sext GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000267def MOVSX64rm32: RI<0x63, MRMSrcMem, (outs GR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000268 "movs{lq|xd}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000269 [(set GR64:$dst, (sextloadi64i32 addr:$src))]>;
270
Dan Gohman9203ab42008-07-30 18:09:17 +0000271// Use movzbl instead of movzbq when the destination is a register; it's
272// equivalent due to implicit zero-extending, and it has a smaller encoding.
273def MOVZX64rr8 : I<0xB6, MRMSrcReg, (outs GR64:$dst), (ins GR8 :$src),
274 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
275 [(set GR64:$dst, (zext GR8:$src))]>, TB;
276def MOVZX64rm8 : I<0xB6, MRMSrcMem, (outs GR64:$dst), (ins i8mem :$src),
277 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
278 [(set GR64:$dst, (zextloadi64i8 addr:$src))]>, TB;
279// Use movzwl instead of movzwq when the destination is a register; it's
280// equivalent due to implicit zero-extending, and it has a smaller encoding.
281def MOVZX64rr16: I<0xB7, MRMSrcReg, (outs GR64:$dst), (ins GR16:$src),
282 "movz{wl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
283 [(set GR64:$dst, (zext GR16:$src))]>, TB;
284def MOVZX64rm16: I<0xB7, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
285 "movz{wl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
286 [(set GR64:$dst, (zextloadi64i16 addr:$src))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000287
Dan Gohman47a419d2008-08-07 02:54:50 +0000288// There's no movzlq instruction, but movl can be used for this purpose, using
289// implicit zero-extension. We need this because the seeming alternative for
290// implementing zext from 32 to 64, an EXTRACT_SUBREG/SUBREG_TO_REG pair, isn't
291// safe because both instructions could be optimized away in the
292// register-to-register case, leaving nothing behind to do the zero extension.
293def MOVZX64rr32 : I<0x89, MRMDestReg, (outs GR64:$dst), (ins GR32:$src),
294 "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
295 [(set GR64:$dst, (zext GR32:$src))]>;
296def MOVZX64rm32 : I<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i32mem:$src),
297 "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
298 [(set GR64:$dst, (zextloadi64i32 addr:$src))]>;
299
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000300let neverHasSideEffects = 1 in {
301 let Defs = [RAX], Uses = [EAX] in
302 def CDQE : RI<0x98, RawFrm, (outs), (ins),
303 "{cltq|cdqe}", []>; // RAX = signext(EAX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000304
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000305 let Defs = [RAX,RDX], Uses = [RAX] in
306 def CQO : RI<0x99, RawFrm, (outs), (ins),
307 "{cqto|cqo}", []>; // RDX:RAX = signext(RAX)
308}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000309
310//===----------------------------------------------------------------------===//
311// Arithmetic Instructions...
312//
313
Evan Cheng55687072007-09-14 21:48:26 +0000314let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000315let isTwoAddress = 1 in {
316let isConvertibleToThreeAddress = 1 in {
317let isCommutable = 1 in
Bill Wendlingae034ed2008-12-12 00:56:36 +0000318// Register-Register Addition
319def ADD64rr : RI<0x01, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
320 "add{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +0000321 [(set GR64:$dst, (add GR64:$src1, GR64:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +0000322 (implicit EFLAGS)]>;
323
324// Register-Integer Addition
Bill Wendlingae034ed2008-12-12 00:56:36 +0000325def ADD64ri8 : RIi8<0x83, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
326 "add{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +0000327 [(set GR64:$dst, (add GR64:$src1, i64immSExt8:$src2)),
328 (implicit EFLAGS)]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000329def ADD64ri32 : RIi32<0x81, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
330 "add{q}\t{$src2, $dst|$dst, $src2}",
331 [(set GR64:$dst, (add GR64:$src1, i64immSExt32:$src2)),
332 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000333} // isConvertibleToThreeAddress
334
Bill Wendlingae034ed2008-12-12 00:56:36 +0000335// Register-Memory Addition
336def ADD64rm : RI<0x03, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
337 "add{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +0000338 [(set GR64:$dst, (add GR64:$src1, (load addr:$src2))),
Bill Wendlingae034ed2008-12-12 00:56:36 +0000339 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000340} // isTwoAddress
341
Bill Wendlingae034ed2008-12-12 00:56:36 +0000342// Memory-Register Addition
Evan Chengb783fa32007-07-19 01:14:50 +0000343def ADD64mr : RI<0x01, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000344 "add{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +0000345 [(store (add (load addr:$dst), GR64:$src2), addr:$dst),
346 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000347def ADD64mi8 : RIi8<0x83, MRM0m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000348 "add{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +0000349 [(store (add (load addr:$dst), i64immSExt8:$src2), addr:$dst),
350 (implicit EFLAGS)]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000351def ADD64mi32 : RIi32<0x81, MRM0m, (outs), (ins i64mem:$dst, i64i32imm :$src2),
352 "add{q}\t{$src2, $dst|$dst, $src2}",
353 [(store (add (load addr:$dst), i64immSExt32:$src2), addr:$dst),
354 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000355
Evan Cheng259471d2007-10-05 17:59:57 +0000356let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000357let isTwoAddress = 1 in {
358let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000359def ADC64rr : RI<0x11, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000360 "adc{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +0000361 [(set GR64:$dst, (adde GR64:$src1, GR64:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000362
Evan Chengb783fa32007-07-19 01:14:50 +0000363def ADC64rm : RI<0x13, MRMSrcMem , (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000364 "adc{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +0000365 [(set GR64:$dst, (adde GR64:$src1, (load addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000366
Evan Chengb783fa32007-07-19 01:14:50 +0000367def ADC64ri8 : RIi8<0x83, MRM2r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000368 "adc{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +0000369 [(set GR64:$dst, (adde GR64:$src1, i64immSExt8:$src2))]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000370def ADC64ri32 : RIi32<0x81, MRM2r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
371 "adc{q}\t{$src2, $dst|$dst, $src2}",
372 [(set GR64:$dst, (adde GR64:$src1, i64immSExt32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000373} // isTwoAddress
374
Evan Chengb783fa32007-07-19 01:14:50 +0000375def ADC64mr : RI<0x11, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000376 "adc{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +0000377 [(store (adde (load addr:$dst), GR64:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000378def ADC64mi8 : RIi8<0x83, MRM2m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000379 "adc{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendling0c52d0a2008-12-02 00:07:05 +0000380 [(store (adde (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000381def ADC64mi32 : RIi32<0x81, MRM2m, (outs), (ins i64mem:$dst, i64i32imm:$src2),
382 "adc{q}\t{$src2, $dst|$dst, $src2}",
383 [(store (adde (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
Evan Cheng259471d2007-10-05 17:59:57 +0000384} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000385
386let isTwoAddress = 1 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +0000387// Register-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +0000388def SUB64rr : RI<0x29, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000389 "sub{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +0000390 [(set GR64:$dst, (sub GR64:$src1, GR64:$src2)),
391 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +0000392
393// Register-Memory Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +0000394def SUB64rm : RI<0x2B, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000395 "sub{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +0000396 [(set GR64:$dst, (sub GR64:$src1, (load addr:$src2))),
397 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +0000398
399// Register-Integer Subtraction
Bill Wendlingae034ed2008-12-12 00:56:36 +0000400def SUB64ri8 : RIi8<0x83, MRM5r, (outs GR64:$dst),
401 (ins GR64:$src1, i64i8imm:$src2),
402 "sub{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +0000403 [(set GR64:$dst, (sub GR64:$src1, i64immSExt8:$src2)),
404 (implicit EFLAGS)]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000405def SUB64ri32 : RIi32<0x81, MRM5r, (outs GR64:$dst),
406 (ins GR64:$src1, i64i32imm:$src2),
407 "sub{q}\t{$src2, $dst|$dst, $src2}",
408 [(set GR64:$dst, (sub GR64:$src1, i64immSExt32:$src2)),
409 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000410} // isTwoAddress
411
Bill Wendlingae034ed2008-12-12 00:56:36 +0000412// Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +0000413def SUB64mr : RI<0x29, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000414 "sub{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +0000415 [(store (sub (load addr:$dst), GR64:$src2), addr:$dst),
416 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +0000417
418// Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +0000419def SUB64mi8 : RIi8<0x83, MRM5m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000420 "sub{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +0000421 [(store (sub (load addr:$dst), i64immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +0000422 addr:$dst),
423 (implicit EFLAGS)]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000424def SUB64mi32 : RIi32<0x81, MRM5m, (outs), (ins i64mem:$dst, i64i32imm:$src2),
425 "sub{q}\t{$src2, $dst|$dst, $src2}",
426 [(store (sub (load addr:$dst), i64immSExt32:$src2),
427 addr:$dst),
428 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000429
Evan Cheng259471d2007-10-05 17:59:57 +0000430let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000431let isTwoAddress = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000432def SBB64rr : RI<0x19, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000433 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000434 [(set GR64:$dst, (sube GR64:$src1, GR64:$src2))]>;
435
Evan Chengb783fa32007-07-19 01:14:50 +0000436def SBB64rm : RI<0x1B, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000437 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000438 [(set GR64:$dst, (sube GR64:$src1, (load addr:$src2)))]>;
439
Evan Chengb783fa32007-07-19 01:14:50 +0000440def SBB64ri8 : RIi8<0x83, MRM3r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000441 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000442 [(set GR64:$dst, (sube GR64:$src1, i64immSExt8:$src2))]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000443def SBB64ri32 : RIi32<0x81, MRM3r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
444 "sbb{q}\t{$src2, $dst|$dst, $src2}",
445 [(set GR64:$dst, (sube GR64:$src1, i64immSExt32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000446} // isTwoAddress
447
Evan Chengb783fa32007-07-19 01:14:50 +0000448def SBB64mr : RI<0x19, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000449 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000450 [(store (sube (load addr:$dst), GR64:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000451def SBB64mi8 : RIi8<0x83, MRM3m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000452 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000453 [(store (sube (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000454def SBB64mi32 : RIi32<0x81, MRM3m, (outs), (ins i64mem:$dst, i64i32imm:$src2),
455 "sbb{q}\t{$src2, $dst|$dst, $src2}",
456 [(store (sube (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>;
Evan Cheng259471d2007-10-05 17:59:57 +0000457} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +0000458} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000459
460// Unsigned multiplication
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000461let Defs = [RAX,RDX,EFLAGS], Uses = [RAX], neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000462def MUL64r : RI<0xF7, MRM4r, (outs), (ins GR64:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000463 "mul{q}\t$src", []>; // RAX,RDX = RAX*GR64
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000464let mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000465def MUL64m : RI<0xF7, MRM4m, (outs), (ins i64mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000466 "mul{q}\t$src", []>; // RAX,RDX = RAX*[mem64]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000467
468// Signed multiplication
Evan Chengb783fa32007-07-19 01:14:50 +0000469def IMUL64r : RI<0xF7, MRM5r, (outs), (ins GR64:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000470 "imul{q}\t$src", []>; // RAX,RDX = RAX*GR64
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000471let mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000472def IMUL64m : RI<0xF7, MRM5m, (outs), (ins i64mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000473 "imul{q}\t$src", []>; // RAX,RDX = RAX*[mem64]
474}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000475
Evan Cheng55687072007-09-14 21:48:26 +0000476let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000477let isTwoAddress = 1 in {
478let isCommutable = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000479// Register-Register Signed Integer Multiplication
Bill Wendlingae034ed2008-12-12 00:56:36 +0000480def IMUL64rr : RI<0xAF, MRMSrcReg, (outs GR64:$dst),
481 (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000482 "imul{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +0000483 [(set GR64:$dst, (mul GR64:$src1, GR64:$src2)),
484 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000485
Bill Wendlingf5399032008-12-12 21:15:41 +0000486// Register-Memory Signed Integer Multiplication
Bill Wendlingae034ed2008-12-12 00:56:36 +0000487def IMUL64rm : RI<0xAF, MRMSrcMem, (outs GR64:$dst),
488 (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000489 "imul{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +0000490 [(set GR64:$dst, (mul GR64:$src1, (load addr:$src2))),
491 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000492} // isTwoAddress
493
494// Suprisingly enough, these are not two address instructions!
Bill Wendlingae034ed2008-12-12 00:56:36 +0000495
Bill Wendlingf5399032008-12-12 21:15:41 +0000496// Register-Integer Signed Integer Multiplication
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000497def IMUL64rri8 : RIi8<0x6B, MRMSrcReg, // GR64 = GR64*I8
Evan Chengb783fa32007-07-19 01:14:50 +0000498 (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000499 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +0000500 [(set GR64:$dst, (mul GR64:$src1, i64immSExt8:$src2)),
501 (implicit EFLAGS)]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000502def IMUL64rri32 : RIi32<0x69, MRMSrcReg, // GR64 = GR64*I32
503 (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
504 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
505 [(set GR64:$dst, (mul GR64:$src1, i64immSExt32:$src2)),
506 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +0000507
Bill Wendlingf5399032008-12-12 21:15:41 +0000508// Memory-Integer Signed Integer Multiplication
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000509def IMUL64rmi8 : RIi8<0x6B, MRMSrcMem, // GR64 = [mem64]*I8
Evan Chengb783fa32007-07-19 01:14:50 +0000510 (outs GR64:$dst), (ins i64mem:$src1, i64i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000511 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +0000512 [(set GR64:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +0000513 i64immSExt8:$src2)),
514 (implicit EFLAGS)]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000515def IMUL64rmi32 : RIi32<0x69, MRMSrcMem, // GR64 = [mem64]*I32
516 (outs GR64:$dst), (ins i64mem:$src1, i64i32imm:$src2),
517 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
518 [(set GR64:$dst, (mul (load addr:$src1),
519 i64immSExt32:$src2)),
520 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000521} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000522
523// Unsigned division / remainder
Evan Cheng55687072007-09-14 21:48:26 +0000524let Defs = [RAX,RDX,EFLAGS], Uses = [RAX,RDX] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000525def DIV64r : RI<0xF7, MRM6r, (outs), (ins GR64:$src), // RDX:RAX/r64 = RAX,RDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000526 "div{q}\t$src", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000527// Signed division / remainder
Evan Chengb783fa32007-07-19 01:14:50 +0000528def IDIV64r: RI<0xF7, MRM7r, (outs), (ins GR64:$src), // RDX:RAX/r64 = RAX,RDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000529 "idiv{q}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000530let mayLoad = 1 in {
531def DIV64m : RI<0xF7, MRM6m, (outs), (ins i64mem:$src), // RDX:RAX/[mem64] = RAX,RDX
532 "div{q}\t$src", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000533def IDIV64m: RI<0xF7, MRM7m, (outs), (ins i64mem:$src), // RDX:RAX/[mem64] = RAX,RDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000534 "idiv{q}\t$src", []>;
535}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000536}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000537
538// Unary instructions
Evan Cheng55687072007-09-14 21:48:26 +0000539let Defs = [EFLAGS], CodeSize = 2 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000540let isTwoAddress = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000541def NEG64r : RI<0xF7, MRM3r, (outs GR64:$dst), (ins GR64:$src), "neg{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000542 [(set GR64:$dst, (ineg GR64:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000543def NEG64m : RI<0xF7, MRM3m, (outs), (ins i64mem:$dst), "neg{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000544 [(store (ineg (loadi64 addr:$dst)), addr:$dst)]>;
545
546let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000547def INC64r : RI<0xFF, MRM0r, (outs GR64:$dst), (ins GR64:$src), "inc{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000548 [(set GR64:$dst, (add GR64:$src, 1))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000549def INC64m : RI<0xFF, MRM0m, (outs), (ins i64mem:$dst), "inc{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000550 [(store (add (loadi64 addr:$dst), 1), addr:$dst)]>;
551
552let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000553def DEC64r : RI<0xFF, MRM1r, (outs GR64:$dst), (ins GR64:$src), "dec{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000554 [(set GR64:$dst, (add GR64:$src, -1))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000555def DEC64m : RI<0xFF, MRM1m, (outs), (ins i64mem:$dst), "dec{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000556 [(store (add (loadi64 addr:$dst), -1), addr:$dst)]>;
557
558// In 64-bit mode, single byte INC and DEC cannot be encoded.
559let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in {
560// Can transform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +0000561def INC64_16r : I<0xFF, MRM0r, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000562 [(set GR16:$dst, (add GR16:$src, 1))]>,
563 OpSize, Requires<[In64BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000564def INC64_32r : I<0xFF, MRM0r, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000565 [(set GR32:$dst, (add GR32:$src, 1))]>,
566 Requires<[In64BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000567def DEC64_16r : I<0xFF, MRM1r, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000568 [(set GR16:$dst, (add GR16:$src, -1))]>,
569 OpSize, Requires<[In64BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000570def DEC64_32r : I<0xFF, MRM1r, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000571 [(set GR32:$dst, (add GR32:$src, -1))]>,
572 Requires<[In64BitMode]>;
573} // isConvertibleToThreeAddress
Evan Cheng4a7e72f2007-10-19 21:23:22 +0000574
575// These are duplicates of their 32-bit counterparts. Only needed so X86 knows
576// how to unfold them.
577let isTwoAddress = 0, CodeSize = 2 in {
578 def INC64_16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
579 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>,
580 OpSize, Requires<[In64BitMode]>;
581 def INC64_32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
582 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>,
583 Requires<[In64BitMode]>;
584 def DEC64_16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
585 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>,
586 OpSize, Requires<[In64BitMode]>;
587 def DEC64_32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
588 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>,
589 Requires<[In64BitMode]>;
590}
Evan Cheng55687072007-09-14 21:48:26 +0000591} // Defs = [EFLAGS], CodeSize
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000592
593
Evan Cheng55687072007-09-14 21:48:26 +0000594let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000595// Shift instructions
596let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000597let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000598def SHL64rCL : RI<0xD3, MRM4r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000599 "shl{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000600 [(set GR64:$dst, (shl GR64:$src, CL))]>;
Evan Chenga98f6272007-10-05 18:20:36 +0000601let isConvertibleToThreeAddress = 1 in // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +0000602def SHL64ri : RIi8<0xC1, MRM4r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000603 "shl{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000604 [(set GR64:$dst, (shl GR64:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +0000605// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
606// cheaper.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000607} // isTwoAddress
608
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000609let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000610def SHL64mCL : RI<0xD3, MRM4m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000611 "shl{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000612 [(store (shl (loadi64 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000613def SHL64mi : RIi8<0xC1, MRM4m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000614 "shl{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000615 [(store (shl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000616def SHL64m1 : RI<0xD1, MRM4m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000617 "shl{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000618 [(store (shl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
619
620let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000621let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000622def SHR64rCL : RI<0xD3, MRM5r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000623 "shr{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000624 [(set GR64:$dst, (srl GR64:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000625def SHR64ri : RIi8<0xC1, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000626 "shr{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000627 [(set GR64:$dst, (srl GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000628def SHR64r1 : RI<0xD1, MRM5r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000629 "shr{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000630 [(set GR64:$dst, (srl GR64:$src1, (i8 1)))]>;
631} // isTwoAddress
632
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000633let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000634def SHR64mCL : RI<0xD3, MRM5m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000635 "shr{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000636 [(store (srl (loadi64 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000637def SHR64mi : RIi8<0xC1, MRM5m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000638 "shr{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000639 [(store (srl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000640def SHR64m1 : RI<0xD1, MRM5m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000641 "shr{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000642 [(store (srl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
643
644let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000645let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000646def SAR64rCL : RI<0xD3, MRM7r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000647 "sar{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000648 [(set GR64:$dst, (sra GR64:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000649def SAR64ri : RIi8<0xC1, MRM7r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000650 "sar{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000651 [(set GR64:$dst, (sra GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000652def SAR64r1 : RI<0xD1, MRM7r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000653 "sar{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000654 [(set GR64:$dst, (sra GR64:$src1, (i8 1)))]>;
655} // isTwoAddress
656
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000657let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000658def SAR64mCL : RI<0xD3, MRM7m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000659 "sar{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000660 [(store (sra (loadi64 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000661def SAR64mi : RIi8<0xC1, MRM7m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000662 "sar{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000663 [(store (sra (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000664def SAR64m1 : RI<0xD1, MRM7m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000665 "sar{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000666 [(store (sra (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
667
668// Rotate instructions
669let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000670let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000671def ROL64rCL : RI<0xD3, MRM0r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000672 "rol{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000673 [(set GR64:$dst, (rotl GR64:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000674def ROL64ri : RIi8<0xC1, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000675 "rol{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000676 [(set GR64:$dst, (rotl GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000677def ROL64r1 : RI<0xD1, MRM0r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000678 "rol{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000679 [(set GR64:$dst, (rotl GR64:$src1, (i8 1)))]>;
680} // isTwoAddress
681
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000682let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000683def ROL64mCL : I<0xD3, MRM0m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000684 "rol{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000685 [(store (rotl (loadi64 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000686def ROL64mi : RIi8<0xC1, MRM0m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000687 "rol{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000688 [(store (rotl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000689def ROL64m1 : RI<0xD1, MRM0m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000690 "rol{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000691 [(store (rotl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
692
693let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000694let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000695def ROR64rCL : RI<0xD3, MRM1r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000696 "ror{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000697 [(set GR64:$dst, (rotr GR64:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000698def ROR64ri : RIi8<0xC1, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000699 "ror{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000700 [(set GR64:$dst, (rotr GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000701def ROR64r1 : RI<0xD1, MRM1r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000702 "ror{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000703 [(set GR64:$dst, (rotr GR64:$src1, (i8 1)))]>;
704} // isTwoAddress
705
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000706let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000707def ROR64mCL : RI<0xD3, MRM1m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000708 "ror{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000709 [(store (rotr (loadi64 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000710def ROR64mi : RIi8<0xC1, MRM1m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000711 "ror{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000712 [(store (rotr (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000713def ROR64m1 : RI<0xD1, MRM1m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000714 "ror{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000715 [(store (rotr (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
716
717// Double shift instructions (generalizations of rotate)
718let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000719let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000720def SHLD64rrCL : RI<0xA5, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000721 "shld{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
722 [(set GR64:$dst, (X86shld GR64:$src1, GR64:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000723def SHRD64rrCL : RI<0xAD, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000724 "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
725 [(set GR64:$dst, (X86shrd GR64:$src1, GR64:$src2, CL))]>, TB;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000726}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000727
728let isCommutable = 1 in { // FIXME: Update X86InstrInfo::commuteInstruction
729def SHLD64rri8 : RIi8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000730 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2, i8imm:$src3),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000731 "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
732 [(set GR64:$dst, (X86shld GR64:$src1, GR64:$src2,
733 (i8 imm:$src3)))]>,
734 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000735def SHRD64rri8 : RIi8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000736 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2, i8imm:$src3),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000737 "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
738 [(set GR64:$dst, (X86shrd GR64:$src1, GR64:$src2,
739 (i8 imm:$src3)))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000740 TB;
741} // isCommutable
742} // isTwoAddress
743
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000744let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000745def SHLD64mrCL : RI<0xA5, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000746 "shld{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
747 [(store (X86shld (loadi64 addr:$dst), GR64:$src2, CL),
748 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000749def SHRD64mrCL : RI<0xAD, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000750 "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
751 [(store (X86shrd (loadi64 addr:$dst), GR64:$src2, CL),
752 addr:$dst)]>, TB;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000753}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000754def SHLD64mri8 : RIi8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000755 (outs), (ins i64mem:$dst, GR64:$src2, i8imm:$src3),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000756 "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
757 [(store (X86shld (loadi64 addr:$dst), GR64:$src2,
758 (i8 imm:$src3)), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000759 TB;
760def SHRD64mri8 : RIi8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000761 (outs), (ins i64mem:$dst, GR64:$src2, i8imm:$src3),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000762 "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
763 [(store (X86shrd (loadi64 addr:$dst), GR64:$src2,
764 (i8 imm:$src3)), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000765 TB;
Evan Cheng55687072007-09-14 21:48:26 +0000766} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000767
768//===----------------------------------------------------------------------===//
769// Logical Instructions...
770//
771
Evan Cheng5b51c242009-01-21 19:45:31 +0000772let isTwoAddress = 1 , AddedComplexity = 15 in
Dan Gohman91888f02007-07-31 20:11:57 +0000773def NOT64r : RI<0xF7, MRM2r, (outs GR64:$dst), (ins GR64:$src), "not{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000774 [(set GR64:$dst, (not GR64:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000775def NOT64m : RI<0xF7, MRM2m, (outs), (ins i64mem:$dst), "not{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000776 [(store (not (loadi64 addr:$dst)), addr:$dst)]>;
777
Evan Cheng55687072007-09-14 21:48:26 +0000778let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000779let isTwoAddress = 1 in {
780let isCommutable = 1 in
781def AND64rr : RI<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000782 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000783 "and{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000784 [(set GR64:$dst, (and GR64:$src1, GR64:$src2))]>;
785def AND64rm : RI<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000786 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000787 "and{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000788 [(set GR64:$dst, (and GR64:$src1, (load addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000789def AND64ri8 : RIi8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +0000790 (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000791 "and{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000792 [(set GR64:$dst, (and GR64:$src1, i64immSExt8:$src2))]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000793def AND64ri32 : RIi32<0x81, MRM4r,
794 (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
795 "and{q}\t{$src2, $dst|$dst, $src2}",
796 [(set GR64:$dst, (and GR64:$src1, i64immSExt32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000797} // isTwoAddress
798
799def AND64mr : RI<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000800 (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000801 "and{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000802 [(store (and (load addr:$dst), GR64:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000803def AND64mi8 : RIi8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +0000804 (outs), (ins i64mem:$dst, i64i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000805 "and{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000806 [(store (and (load addr:$dst), i64immSExt8:$src), addr:$dst)]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000807def AND64mi32 : RIi32<0x81, MRM4m,
808 (outs), (ins i64mem:$dst, i64i32imm:$src),
809 "and{q}\t{$src, $dst|$dst, $src}",
810 [(store (and (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000811
812let isTwoAddress = 1 in {
813let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000814def OR64rr : RI<0x09, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000815 "or{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000816 [(set GR64:$dst, (or GR64:$src1, GR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000817def OR64rm : RI<0x0B, MRMSrcMem , (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000818 "or{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000819 [(set GR64:$dst, (or GR64:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000820def OR64ri8 : RIi8<0x83, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000821 "or{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000822 [(set GR64:$dst, (or GR64:$src1, i64immSExt8:$src2))]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000823def OR64ri32 : RIi32<0x81, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
824 "or{q}\t{$src2, $dst|$dst, $src2}",
825 [(set GR64:$dst, (or GR64:$src1, i64immSExt32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000826} // isTwoAddress
827
Evan Chengb783fa32007-07-19 01:14:50 +0000828def OR64mr : RI<0x09, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000829 "or{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000830 [(store (or (load addr:$dst), GR64:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000831def OR64mi8 : RIi8<0x83, MRM1m, (outs), (ins i64mem:$dst, i64i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000832 "or{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000833 [(store (or (load addr:$dst), i64immSExt8:$src), addr:$dst)]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000834def OR64mi32 : RIi32<0x81, MRM1m, (outs), (ins i64mem:$dst, i64i32imm:$src),
835 "or{q}\t{$src, $dst|$dst, $src}",
836 [(store (or (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000837
838let isTwoAddress = 1 in {
Evan Cheng0685efa2008-08-30 08:54:22 +0000839let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000840def XOR64rr : RI<0x31, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000841 "xor{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000842 [(set GR64:$dst, (xor GR64:$src1, GR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000843def XOR64rm : RI<0x33, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000844 "xor{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000845 [(set GR64:$dst, (xor GR64:$src1, (load addr:$src2)))]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000846def XOR64ri8 : RIi8<0x83, MRM6r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
847 "xor{q}\t{$src2, $dst|$dst, $src2}",
848 [(set GR64:$dst, (xor GR64:$src1, i64immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000849def XOR64ri32 : RIi32<0x81, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +0000850 (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000851 "xor{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000852 [(set GR64:$dst, (xor GR64:$src1, i64immSExt32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000853} // isTwoAddress
854
Evan Chengb783fa32007-07-19 01:14:50 +0000855def XOR64mr : RI<0x31, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000856 "xor{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000857 [(store (xor (load addr:$dst), GR64:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000858def XOR64mi8 : RIi8<0x83, MRM6m, (outs), (ins i64mem:$dst, i64i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000859 "xor{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000860 [(store (xor (load addr:$dst), i64immSExt8:$src), addr:$dst)]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000861def XOR64mi32 : RIi32<0x81, MRM6m, (outs), (ins i64mem:$dst, i64i32imm:$src),
862 "xor{q}\t{$src, $dst|$dst, $src}",
863 [(store (xor (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000864} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000865
866//===----------------------------------------------------------------------===//
867// Comparison Instructions...
868//
869
870// Integer comparison
Evan Cheng55687072007-09-14 21:48:26 +0000871let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000872let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000873def TEST64rr : RI<0x85, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000874 "test{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000875 [(X86cmp (and GR64:$src1, GR64:$src2), 0),
876 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000877def TEST64rm : RI<0x85, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000878 "test{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000879 [(X86cmp (and GR64:$src1, (loadi64 addr:$src2)), 0),
880 (implicit EFLAGS)]>;
881def TEST64ri32 : RIi32<0xF7, MRM0r, (outs),
882 (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000883 "test{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000884 [(X86cmp (and GR64:$src1, i64immSExt32:$src2), 0),
885 (implicit EFLAGS)]>;
886def TEST64mi32 : RIi32<0xF7, MRM0m, (outs),
887 (ins i64mem:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000888 "test{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000889 [(X86cmp (and (loadi64 addr:$src1), i64immSExt32:$src2), 0),
890 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000891
Evan Chengb783fa32007-07-19 01:14:50 +0000892def CMP64rr : RI<0x39, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000893 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000894 [(X86cmp GR64:$src1, GR64:$src2),
895 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000896def CMP64mr : RI<0x39, MRMDestMem, (outs), (ins i64mem:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000897 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000898 [(X86cmp (loadi64 addr:$src1), GR64:$src2),
899 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000900def CMP64rm : RI<0x3B, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000901 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000902 [(X86cmp GR64:$src1, (loadi64 addr:$src2)),
903 (implicit EFLAGS)]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000904def CMP64ri8 : RIi8<0x83, MRM7r, (outs), (ins GR64:$src1, i64i8imm:$src2),
905 "cmp{q}\t{$src2, $src1|$src1, $src2}",
906 [(X86cmp GR64:$src1, i64immSExt8:$src2),
907 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000908def CMP64ri32 : RIi32<0x81, MRM7r, (outs), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000909 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000910 [(X86cmp GR64:$src1, i64immSExt32:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000911 (implicit EFLAGS)]>;
Evan Cheng621216e2007-09-29 00:00:36 +0000912def CMP64mi8 : RIi8<0x83, MRM7m, (outs), (ins i64mem:$src1, i64i8imm:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000913 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000914 [(X86cmp (loadi64 addr:$src1), i64immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000915 (implicit EFLAGS)]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000916def CMP64mi32 : RIi32<0x81, MRM7m, (outs),
917 (ins i64mem:$src1, i64i32imm:$src2),
918 "cmp{q}\t{$src2, $src1|$src1, $src2}",
919 [(X86cmp (loadi64 addr:$src1), i64immSExt32:$src2),
920 (implicit EFLAGS)]>;
Evan Cheng950aac02007-09-25 01:57:46 +0000921} // Defs = [EFLAGS]
922
Dan Gohman7fe9b7f2008-12-23 22:45:23 +0000923// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +0000924// TODO: BTC, BTR, and BTS
925let Defs = [EFLAGS] in {
Chris Lattner5a95cde2008-12-25 01:32:49 +0000926def BT64rr : RI<0xA3, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +0000927 "bt{q}\t{$src2, $src1|$src1, $src2}",
928 [(X86bt GR64:$src1, GR64:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +0000929 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +0000930
931// Unlike with the register+register form, the memory+register form of the
932// bt instruction does not ignore the high bits of the index. From ISel's
933// perspective, this is pretty bizarre. Disable these instructions for now.
934//def BT64mr : RI<0xA3, MRMDestMem, (outs), (ins i64mem:$src1, GR64:$src2),
935// "bt{q}\t{$src2, $src1|$src1, $src2}",
936// [(X86bt (loadi64 addr:$src1), GR64:$src2),
937// (implicit EFLAGS)]>, TB;
Dan Gohman46fb1cf2009-01-13 20:33:23 +0000938
939def BT64ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR64:$src1, i64i8imm:$src2),
940 "bt{q}\t{$src2, $src1|$src1, $src2}",
941 [(X86bt GR64:$src1, i64immSExt8:$src2),
942 (implicit EFLAGS)]>, TB;
943// Note that these instructions don't need FastBTMem because that
944// only applies when the other operand is in a register. When it's
945// an immediate, bt is still fast.
946def BT64mi8 : Ii8<0xBA, MRM4m, (outs), (ins i64mem:$src1, i64i8imm:$src2),
947 "bt{q}\t{$src2, $src1|$src1, $src2}",
948 [(X86bt (loadi64 addr:$src1), i64immSExt8:$src2),
949 (implicit EFLAGS)]>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +0000950} // Defs = [EFLAGS]
951
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000952// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000953let Uses = [EFLAGS], isTwoAddress = 1 in {
Evan Cheng926658c2007-10-05 23:13:21 +0000954let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000955def CMOVB64rr : RI<0x42, MRMSrcReg, // if <u, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000956 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000957 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000958 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000959 X86_COND_B, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000960def CMOVAE64rr: RI<0x43, MRMSrcReg, // if >=u, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000961 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000962 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000963 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000964 X86_COND_AE, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000965def CMOVE64rr : RI<0x44, MRMSrcReg, // if ==, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000966 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000967 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000968 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000969 X86_COND_E, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000970def CMOVNE64rr: RI<0x45, MRMSrcReg, // if !=, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000971 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000972 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000973 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000974 X86_COND_NE, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000975def CMOVBE64rr: RI<0x46, MRMSrcReg, // if <=u, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000976 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000977 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000978 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000979 X86_COND_BE, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000980def CMOVA64rr : RI<0x47, MRMSrcReg, // if >u, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000981 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000982 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000983 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000984 X86_COND_A, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000985def CMOVL64rr : RI<0x4C, MRMSrcReg, // if <s, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000986 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000987 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000988 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000989 X86_COND_L, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000990def CMOVGE64rr: RI<0x4D, MRMSrcReg, // if >=s, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000991 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000992 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000993 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000994 X86_COND_GE, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000995def CMOVLE64rr: RI<0x4E, MRMSrcReg, // if <=s, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +0000996 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000997 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000998 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000999 X86_COND_LE, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001000def CMOVG64rr : RI<0x4F, MRMSrcReg, // if >s, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +00001001 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001002 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001003 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001004 X86_COND_G, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001005def CMOVS64rr : RI<0x48, MRMSrcReg, // if signed, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +00001006 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001007 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001008 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001009 X86_COND_S, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001010def CMOVNS64rr: RI<0x49, MRMSrcReg, // if !signed, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +00001011 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001012 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001013 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001014 X86_COND_NS, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001015def CMOVP64rr : RI<0x4A, MRMSrcReg, // if parity, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +00001016 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001017 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001018 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001019 X86_COND_P, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001020def CMOVNP64rr : RI<0x4B, MRMSrcReg, // if !parity, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +00001021 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001022 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001023 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001024 X86_COND_NP, EFLAGS))]>, TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001025def CMOVO64rr : RI<0x40, MRMSrcReg, // if overflow, GR64 = GR64
1026 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
1027 "cmovo\t{$src2, $dst|$dst, $src2}",
1028 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
1029 X86_COND_O, EFLAGS))]>, TB;
1030def CMOVNO64rr : RI<0x41, MRMSrcReg, // if !overflow, GR64 = GR64
1031 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
1032 "cmovno\t{$src2, $dst|$dst, $src2}",
1033 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
1034 X86_COND_NO, EFLAGS))]>, TB;
Evan Cheng926658c2007-10-05 23:13:21 +00001035} // isCommutable = 1
1036
1037def CMOVB64rm : RI<0x42, MRMSrcMem, // if <u, GR64 = [mem64]
1038 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1039 "cmovb\t{$src2, $dst|$dst, $src2}",
1040 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1041 X86_COND_B, EFLAGS))]>, TB;
1042def CMOVAE64rm: RI<0x43, MRMSrcMem, // if >=u, GR64 = [mem64]
1043 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1044 "cmovae\t{$src2, $dst|$dst, $src2}",
1045 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1046 X86_COND_AE, EFLAGS))]>, TB;
1047def CMOVE64rm : RI<0x44, MRMSrcMem, // if ==, GR64 = [mem64]
1048 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1049 "cmove\t{$src2, $dst|$dst, $src2}",
1050 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1051 X86_COND_E, EFLAGS))]>, TB;
1052def CMOVNE64rm: RI<0x45, MRMSrcMem, // if !=, GR64 = [mem64]
1053 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1054 "cmovne\t{$src2, $dst|$dst, $src2}",
1055 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1056 X86_COND_NE, EFLAGS))]>, TB;
1057def CMOVBE64rm: RI<0x46, MRMSrcMem, // if <=u, GR64 = [mem64]
1058 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1059 "cmovbe\t{$src2, $dst|$dst, $src2}",
1060 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1061 X86_COND_BE, EFLAGS))]>, TB;
1062def CMOVA64rm : RI<0x47, MRMSrcMem, // if >u, GR64 = [mem64]
1063 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1064 "cmova\t{$src2, $dst|$dst, $src2}",
1065 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1066 X86_COND_A, EFLAGS))]>, TB;
1067def CMOVL64rm : RI<0x4C, MRMSrcMem, // if <s, GR64 = [mem64]
1068 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1069 "cmovl\t{$src2, $dst|$dst, $src2}",
1070 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1071 X86_COND_L, EFLAGS))]>, TB;
1072def CMOVGE64rm: RI<0x4D, MRMSrcMem, // if >=s, GR64 = [mem64]
1073 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1074 "cmovge\t{$src2, $dst|$dst, $src2}",
1075 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1076 X86_COND_GE, EFLAGS))]>, TB;
1077def CMOVLE64rm: RI<0x4E, MRMSrcMem, // if <=s, GR64 = [mem64]
1078 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1079 "cmovle\t{$src2, $dst|$dst, $src2}",
1080 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1081 X86_COND_LE, EFLAGS))]>, TB;
1082def CMOVG64rm : RI<0x4F, MRMSrcMem, // if >s, GR64 = [mem64]
1083 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1084 "cmovg\t{$src2, $dst|$dst, $src2}",
1085 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1086 X86_COND_G, EFLAGS))]>, TB;
1087def CMOVS64rm : RI<0x48, MRMSrcMem, // if signed, GR64 = [mem64]
1088 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1089 "cmovs\t{$src2, $dst|$dst, $src2}",
1090 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1091 X86_COND_S, EFLAGS))]>, TB;
1092def CMOVNS64rm: RI<0x49, MRMSrcMem, // if !signed, GR64 = [mem64]
1093 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1094 "cmovns\t{$src2, $dst|$dst, $src2}",
1095 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1096 X86_COND_NS, EFLAGS))]>, TB;
1097def CMOVP64rm : RI<0x4A, MRMSrcMem, // if parity, GR64 = [mem64]
1098 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1099 "cmovp\t{$src2, $dst|$dst, $src2}",
1100 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1101 X86_COND_P, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001102def CMOVNP64rm : RI<0x4B, MRMSrcMem, // if !parity, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +00001103 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001104 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001105 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00001106 X86_COND_NP, EFLAGS))]>, TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001107def CMOVO64rm : RI<0x40, MRMSrcMem, // if overflow, GR64 = [mem64]
1108 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1109 "cmovo\t{$src2, $dst|$dst, $src2}",
1110 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1111 X86_COND_O, EFLAGS))]>, TB;
1112def CMOVNO64rm : RI<0x41, MRMSrcMem, // if !overflow, GR64 = [mem64]
1113 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1114 "cmovno\t{$src2, $dst|$dst, $src2}",
1115 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1116 X86_COND_NO, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001117} // isTwoAddress
1118
1119//===----------------------------------------------------------------------===//
1120// Conversion Instructions...
1121//
1122
1123// f64 -> signed i64
Evan Chengb783fa32007-07-19 01:14:50 +00001124def Int_CVTSD2SI64rr: RSDI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001125 "cvtsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001126 [(set GR64:$dst,
1127 (int_x86_sse2_cvtsd2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001128def Int_CVTSD2SI64rm: RSDI<0x2D, MRMSrcMem, (outs GR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001129 "cvtsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001130 [(set GR64:$dst, (int_x86_sse2_cvtsd2si64
1131 (load addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001132def CVTTSD2SI64rr: RSDI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001133 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001134 [(set GR64:$dst, (fp_to_sint FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001135def CVTTSD2SI64rm: RSDI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001136 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001137 [(set GR64:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001138def Int_CVTTSD2SI64rr: RSDI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001139 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001140 [(set GR64:$dst,
1141 (int_x86_sse2_cvttsd2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001142def Int_CVTTSD2SI64rm: RSDI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001143 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001144 [(set GR64:$dst,
1145 (int_x86_sse2_cvttsd2si64
1146 (load addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001147
1148// Signed i64 -> f64
Evan Chengb783fa32007-07-19 01:14:50 +00001149def CVTSI2SD64rr: RSDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001150 "cvtsi2sd{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001151 [(set FR64:$dst, (sint_to_fp GR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001152def CVTSI2SD64rm: RSDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001153 "cvtsi2sd{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001154 [(set FR64:$dst, (sint_to_fp (loadi64 addr:$src)))]>;
Evan Cheng1d5832e2008-01-11 07:37:44 +00001155
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001156let isTwoAddress = 1 in {
1157def Int_CVTSI2SD64rr: RSDI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001158 (outs VR128:$dst), (ins VR128:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001159 "cvtsi2sd{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendling6227d462007-07-23 03:07:27 +00001160 [(set VR128:$dst,
1161 (int_x86_sse2_cvtsi642sd VR128:$src1,
1162 GR64:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001163def Int_CVTSI2SD64rm: RSDI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001164 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001165 "cvtsi2sd{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendling6227d462007-07-23 03:07:27 +00001166 [(set VR128:$dst,
1167 (int_x86_sse2_cvtsi642sd VR128:$src1,
1168 (loadi64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001169} // isTwoAddress
1170
1171// Signed i64 -> f32
Evan Chengb783fa32007-07-19 01:14:50 +00001172def CVTSI2SS64rr: RSSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001173 "cvtsi2ss{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001174 [(set FR32:$dst, (sint_to_fp GR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001175def CVTSI2SS64rm: RSSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001176 "cvtsi2ss{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001177 [(set FR32:$dst, (sint_to_fp (loadi64 addr:$src)))]>;
Evan Cheng1d5832e2008-01-11 07:37:44 +00001178
1179let isTwoAddress = 1 in {
1180 def Int_CVTSI2SS64rr : RSSI<0x2A, MRMSrcReg,
1181 (outs VR128:$dst), (ins VR128:$src1, GR64:$src2),
1182 "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}",
1183 [(set VR128:$dst,
1184 (int_x86_sse_cvtsi642ss VR128:$src1,
1185 GR64:$src2))]>;
1186 def Int_CVTSI2SS64rm : RSSI<0x2A, MRMSrcMem,
1187 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
1188 "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}",
1189 [(set VR128:$dst,
1190 (int_x86_sse_cvtsi642ss VR128:$src1,
1191 (loadi64 addr:$src2)))]>;
1192}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001193
1194// f32 -> signed i64
Evan Chengb783fa32007-07-19 01:14:50 +00001195def Int_CVTSS2SI64rr: RSSI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001196 "cvtss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001197 [(set GR64:$dst,
1198 (int_x86_sse_cvtss2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001199def Int_CVTSS2SI64rm: RSSI<0x2D, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001200 "cvtss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001201 [(set GR64:$dst, (int_x86_sse_cvtss2si64
1202 (load addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001203def CVTTSS2SI64rr: RSSI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001204 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001205 [(set GR64:$dst, (fp_to_sint FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001206def CVTTSS2SI64rm: RSSI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001207 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001208 [(set GR64:$dst, (fp_to_sint (loadf32 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001209def Int_CVTTSS2SI64rr: RSSI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001210 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001211 [(set GR64:$dst,
1212 (int_x86_sse_cvttss2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001213def Int_CVTTSS2SI64rm: RSSI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001214 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001215 [(set GR64:$dst,
1216 (int_x86_sse_cvttss2si64 (load addr:$src)))]>;
1217
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001218//===----------------------------------------------------------------------===//
1219// Alias Instructions
1220//===----------------------------------------------------------------------===//
1221
Dan Gohman027cd112007-09-17 14:55:08 +00001222// Alias instructions that map movr0 to xor. Use xorl instead of xorq; it's
1223// equivalent due to implicit zero-extending, and it sometimes has a smaller
1224// encoding.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001225// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
1226// FIXME: AddedComplexity gives MOV64r0 a higher priority than MOV64ri32. Remove
1227// when we have a better way to specify isel priority.
Bill Wendling12e97212008-05-30 06:47:04 +00001228let Defs = [EFLAGS], AddedComplexity = 1,
1229 isReMaterializable = 1, isAsCheapAsAMove = 1 in
Dan Gohman9203ab42008-07-30 18:09:17 +00001230def MOV64r0 : I<0x31, MRMInitReg, (outs GR64:$dst), (ins),
1231 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
1232 [(set GR64:$dst, 0)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001233
1234// Materialize i64 constant where top 32-bits are zero.
Evan Chengbd0ca9c2009-02-05 08:42:55 +00001235let AddedComplexity = 1, isReMaterializable = 1, isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001236def MOV64ri64i32 : Ii32<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001237 "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001238 [(set GR64:$dst, i64immZExt32:$src)]>;
1239
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +00001240//===----------------------------------------------------------------------===//
1241// Thread Local Storage Instructions
1242//===----------------------------------------------------------------------===//
1243
1244def TLS_addr64 : I<0, Pseudo, (outs GR64:$dst), (ins i64imm:$sym),
Anton Korobeynikov5577e2e2008-05-05 17:08:59 +00001245 ".byte\t0x66; leaq\t${sym:mem}(%rip), $dst; .word\t0x6666; rex64",
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +00001246 [(set GR64:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
Andrew Lenharthbd7d3262008-03-04 21:13:33 +00001247
sampo9cc09a32009-01-26 01:24:32 +00001248let AddedComplexity = 5 in
1249def MOV64GSrm : RI<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
1250 "movq\t%gs:$src, $dst",
1251 [(set GR64:$dst, (gsload addr:$src))]>, SegGS;
1252
Andrew Lenharthbd7d3262008-03-04 21:13:33 +00001253//===----------------------------------------------------------------------===//
1254// Atomic Instructions
1255//===----------------------------------------------------------------------===//
1256
Andrew Lenharthbd7d3262008-03-04 21:13:33 +00001257let Defs = [RAX, EFLAGS], Uses = [RAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00001258def LCMPXCHG64 : RI<0xB1, MRMDestMem, (outs), (ins i64mem:$ptr, GR64:$swap),
Bill Wendling6f189e22008-08-19 23:09:18 +00001259 "lock\n\tcmpxchgq\t$swap,$ptr",
Andrew Lenharthbd7d3262008-03-04 21:13:33 +00001260 [(X86cas addr:$ptr, GR64:$swap, 8)]>, TB, LOCK;
1261}
1262
Dan Gohmana41a1c092008-08-06 15:52:50 +00001263let Constraints = "$val = $dst" in {
1264let Defs = [EFLAGS] in
Evan Chengd49dbb82008-04-18 20:55:36 +00001265def LXADD64 : RI<0xC1, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$ptr,GR64:$val),
Bill Wendling6f189e22008-08-19 23:09:18 +00001266 "lock\n\txadd\t$val, $ptr",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00001267 [(set GR64:$dst, (atomic_load_add_64 addr:$ptr, GR64:$val))]>,
Andrew Lenharthbd7d3262008-03-04 21:13:33 +00001268 TB, LOCK;
Evan Chenga1e80602008-04-19 02:05:42 +00001269def XCHG64rm : RI<0x87, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$ptr,GR64:$val),
Bill Wendling6f189e22008-08-19 23:09:18 +00001270 "xchg\t$val, $ptr",
Evan Chenga1e80602008-04-19 02:05:42 +00001271 [(set GR64:$dst, (atomic_swap_64 addr:$ptr, GR64:$val))]>;
Andrew Lenharthbd7d3262008-03-04 21:13:33 +00001272}
1273
Dale Johannesen6b60eca2008-08-20 00:48:50 +00001274// Atomic exchange, and, or, xor
1275let Constraints = "$val = $dst", Defs = [EFLAGS],
1276 usesCustomDAGSchedInserter = 1 in {
1277def ATOMAND64 : I<0, Pseudo, (outs GR64:$dst),(ins i64mem:$ptr, GR64:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00001278 "#ATOMAND64 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00001279 [(set GR64:$dst, (atomic_load_and_64 addr:$ptr, GR64:$val))]>;
Dale Johannesen6b60eca2008-08-20 00:48:50 +00001280def ATOMOR64 : I<0, Pseudo, (outs GR64:$dst),(ins i64mem:$ptr, GR64:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00001281 "#ATOMOR64 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00001282 [(set GR64:$dst, (atomic_load_or_64 addr:$ptr, GR64:$val))]>;
Dale Johannesen6b60eca2008-08-20 00:48:50 +00001283def ATOMXOR64 : I<0, Pseudo,(outs GR64:$dst),(ins i64mem:$ptr, GR64:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00001284 "#ATOMXOR64 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00001285 [(set GR64:$dst, (atomic_load_xor_64 addr:$ptr, GR64:$val))]>;
Dale Johannesen6b60eca2008-08-20 00:48:50 +00001286def ATOMNAND64 : I<0, Pseudo,(outs GR64:$dst),(ins i64mem:$ptr, GR64:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00001287 "#ATOMNAND64 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00001288 [(set GR64:$dst, (atomic_load_nand_64 addr:$ptr, GR64:$val))]>;
Dale Johannesen6b60eca2008-08-20 00:48:50 +00001289def ATOMMIN64: I<0, Pseudo, (outs GR64:$dst), (ins i64mem:$ptr, GR64:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00001290 "#ATOMMIN64 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00001291 [(set GR64:$dst, (atomic_load_min_64 addr:$ptr, GR64:$val))]>;
Dale Johannesen6b60eca2008-08-20 00:48:50 +00001292def ATOMMAX64: I<0, Pseudo, (outs GR64:$dst),(ins i64mem:$ptr, GR64:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00001293 "#ATOMMAX64 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00001294 [(set GR64:$dst, (atomic_load_max_64 addr:$ptr, GR64:$val))]>;
Dale Johannesen6b60eca2008-08-20 00:48:50 +00001295def ATOMUMIN64: I<0, Pseudo, (outs GR64:$dst),(ins i64mem:$ptr, GR64:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00001296 "#ATOMUMIN64 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00001297 [(set GR64:$dst, (atomic_load_umin_64 addr:$ptr, GR64:$val))]>;
Dale Johannesen6b60eca2008-08-20 00:48:50 +00001298def ATOMUMAX64: I<0, Pseudo, (outs GR64:$dst),(ins i64mem:$ptr, GR64:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00001299 "#ATOMUMAX64 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00001300 [(set GR64:$dst, (atomic_load_umax_64 addr:$ptr, GR64:$val))]>;
Dale Johannesen6b60eca2008-08-20 00:48:50 +00001301}
Andrew Lenharthbd7d3262008-03-04 21:13:33 +00001302
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001303//===----------------------------------------------------------------------===//
1304// Non-Instruction Patterns
1305//===----------------------------------------------------------------------===//
1306
Bill Wendlingfef06052008-09-16 21:48:12 +00001307// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001308def : Pat<(i64 (X86Wrapper tconstpool :$dst)),
1309 (MOV64ri tconstpool :$dst)>, Requires<[NotSmallCode]>;
1310def : Pat<(i64 (X86Wrapper tjumptable :$dst)),
1311 (MOV64ri tjumptable :$dst)>, Requires<[NotSmallCode]>;
1312def : Pat<(i64 (X86Wrapper tglobaladdr :$dst)),
1313 (MOV64ri tglobaladdr :$dst)>, Requires<[NotSmallCode]>;
1314def : Pat<(i64 (X86Wrapper texternalsym:$dst)),
1315 (MOV64ri texternalsym:$dst)>, Requires<[NotSmallCode]>;
1316
1317def : Pat<(store (i64 (X86Wrapper tconstpool:$src)), addr:$dst),
1318 (MOV64mi32 addr:$dst, tconstpool:$src)>,
Evan Cheng3b5a1272008-02-07 08:53:49 +00001319 Requires<[SmallCode, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001320def : Pat<(store (i64 (X86Wrapper tjumptable:$src)), addr:$dst),
1321 (MOV64mi32 addr:$dst, tjumptable:$src)>,
Evan Cheng3b5a1272008-02-07 08:53:49 +00001322 Requires<[SmallCode, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001323def : Pat<(store (i64 (X86Wrapper tglobaladdr:$src)), addr:$dst),
1324 (MOV64mi32 addr:$dst, tglobaladdr:$src)>,
Evan Cheng3b5a1272008-02-07 08:53:49 +00001325 Requires<[SmallCode, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001326def : Pat<(store (i64 (X86Wrapper texternalsym:$src)), addr:$dst),
1327 (MOV64mi32 addr:$dst, texternalsym:$src)>,
Evan Cheng3b5a1272008-02-07 08:53:49 +00001328 Requires<[SmallCode, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001329
1330// Calls
1331// Direct PC relative function call for small code model. 32-bit displacement
1332// sign extended to 64-bit.
1333def : Pat<(X86call (i64 tglobaladdr:$dst)),
1334 (CALL64pcrel32 tglobaladdr:$dst)>;
1335def : Pat<(X86call (i64 texternalsym:$dst)),
1336 (CALL64pcrel32 texternalsym:$dst)>;
1337
1338def : Pat<(X86tailcall (i64 tglobaladdr:$dst)),
1339 (CALL64pcrel32 tglobaladdr:$dst)>;
1340def : Pat<(X86tailcall (i64 texternalsym:$dst)),
1341 (CALL64pcrel32 texternalsym:$dst)>;
1342
1343def : Pat<(X86tailcall GR64:$dst),
1344 (CALL64r GR64:$dst)>;
1345
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00001346
1347// tailcall stuff
1348def : Pat<(X86tailcall GR32:$dst),
1349 (TAILCALL)>;
1350def : Pat<(X86tailcall (i64 tglobaladdr:$dst)),
1351 (TAILCALL)>;
1352def : Pat<(X86tailcall (i64 texternalsym:$dst)),
1353 (TAILCALL)>;
1354
1355def : Pat<(X86tcret GR64:$dst, imm:$off),
1356 (TCRETURNri64 GR64:$dst, imm:$off)>;
1357
1358def : Pat<(X86tcret (i64 tglobaladdr:$dst), imm:$off),
1359 (TCRETURNdi64 texternalsym:$dst, imm:$off)>;
1360
1361def : Pat<(X86tcret (i64 texternalsym:$dst), imm:$off),
1362 (TCRETURNdi64 texternalsym:$dst, imm:$off)>;
1363
Dan Gohmanec596042007-09-17 14:35:24 +00001364// Comparisons.
1365
1366// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00001367def : Pat<(parallel (X86cmp GR64:$src1, 0), (implicit EFLAGS)),
Dan Gohmanec596042007-09-17 14:35:24 +00001368 (TEST64rr GR64:$src1, GR64:$src1)>;
1369
Dan Gohman0a3c5222009-01-07 01:00:24 +00001370// Conditional moves with folded loads with operands swapped and conditions
1371// inverted.
1372def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_B, EFLAGS),
1373 (CMOVAE64rm GR64:$src2, addr:$src1)>;
1374def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_AE, EFLAGS),
1375 (CMOVB64rm GR64:$src2, addr:$src1)>;
1376def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_E, EFLAGS),
1377 (CMOVNE64rm GR64:$src2, addr:$src1)>;
1378def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_NE, EFLAGS),
1379 (CMOVE64rm GR64:$src2, addr:$src1)>;
1380def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_BE, EFLAGS),
1381 (CMOVA64rm GR64:$src2, addr:$src1)>;
1382def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_A, EFLAGS),
1383 (CMOVBE64rm GR64:$src2, addr:$src1)>;
1384def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_L, EFLAGS),
1385 (CMOVGE64rm GR64:$src2, addr:$src1)>;
1386def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_GE, EFLAGS),
1387 (CMOVL64rm GR64:$src2, addr:$src1)>;
1388def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_LE, EFLAGS),
1389 (CMOVG64rm GR64:$src2, addr:$src1)>;
1390def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_G, EFLAGS),
1391 (CMOVLE64rm GR64:$src2, addr:$src1)>;
1392def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_P, EFLAGS),
1393 (CMOVNP64rm GR64:$src2, addr:$src1)>;
1394def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_NP, EFLAGS),
1395 (CMOVP64rm GR64:$src2, addr:$src1)>;
1396def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_S, EFLAGS),
1397 (CMOVNS64rm GR64:$src2, addr:$src1)>;
1398def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_NS, EFLAGS),
1399 (CMOVS64rm GR64:$src2, addr:$src1)>;
1400def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_O, EFLAGS),
1401 (CMOVNO64rm GR64:$src2, addr:$src1)>;
1402def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_NO, EFLAGS),
1403 (CMOVO64rm GR64:$src2, addr:$src1)>;
Christopher Lambb371e032008-03-13 05:47:01 +00001404
1405// Zero-extension
Christopher Lamb76d72da2008-03-16 03:12:01 +00001406def : Pat<(i64 (zext GR32:$src)),
1407 (SUBREG_TO_REG (i64 0), GR32:$src, x86_subreg_32bit)>;
Christopher Lambb371e032008-03-13 05:47:01 +00001408
Duncan Sands082524c2008-01-23 20:39:46 +00001409// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001410def : Pat<(zextloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>;
1411
1412// extload
Dan Gohmanab460da2008-08-27 17:33:15 +00001413// When extloading from 16-bit and smaller memory locations into 64-bit registers,
1414// use zero-extending loads so that the entire 64-bit register is defined, avoiding
1415// partial-register updates.
1416def : Pat<(extloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>;
1417def : Pat<(extloadi64i8 addr:$src), (MOVZX64rm8 addr:$src)>;
1418def : Pat<(extloadi64i16 addr:$src), (MOVZX64rm16 addr:$src)>;
1419// For other extloads, use subregs, since the high contents of the register are
1420// defined after an extload.
Dan Gohmandd612bb2008-08-20 21:27:32 +00001421def : Pat<(extloadi64i32 addr:$src),
1422 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (MOV32rm addr:$src),
1423 x86_subreg_32bit)>;
1424def : Pat<(extloadi16i1 addr:$src),
1425 (INSERT_SUBREG (i16 (IMPLICIT_DEF)), (MOV8rm addr:$src),
1426 x86_subreg_8bit)>,
1427 Requires<[In64BitMode]>;
1428def : Pat<(extloadi16i8 addr:$src),
1429 (INSERT_SUBREG (i16 (IMPLICIT_DEF)), (MOV8rm addr:$src),
1430 x86_subreg_8bit)>,
1431 Requires<[In64BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001432
Dan Gohmandd612bb2008-08-20 21:27:32 +00001433// anyext
1434def : Pat<(i64 (anyext GR8:$src)),
1435 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GR8:$src, x86_subreg_8bit)>;
1436def : Pat<(i64 (anyext GR16:$src)),
1437 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Christopher Lamb76d72da2008-03-16 03:12:01 +00001438def : Pat<(i64 (anyext GR32:$src)),
1439 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GR32:$src, x86_subreg_32bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00001440def : Pat<(i16 (anyext GR8:$src)),
1441 (INSERT_SUBREG (i16 (IMPLICIT_DEF)), GR8:$src, x86_subreg_8bit)>,
1442 Requires<[In64BitMode]>;
1443def : Pat<(i32 (anyext GR8:$src)),
1444 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR8:$src, x86_subreg_8bit)>,
1445 Requires<[In64BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001446
1447//===----------------------------------------------------------------------===//
1448// Some peepholes
1449//===----------------------------------------------------------------------===//
1450
Dan Gohman5a5e6e92008-10-17 01:33:43 +00001451// Odd encoding trick: -128 fits into an 8-bit immediate field while
1452// +128 doesn't, so in this special case use a sub instead of an add.
1453def : Pat<(add GR64:$src1, 128),
1454 (SUB64ri8 GR64:$src1, -128)>;
1455def : Pat<(store (add (loadi64 addr:$dst), 128), addr:$dst),
1456 (SUB64mi8 addr:$dst, -128)>;
1457
1458// The same trick applies for 32-bit immediate fields in 64-bit
1459// instructions.
1460def : Pat<(add GR64:$src1, 0x0000000080000000),
1461 (SUB64ri32 GR64:$src1, 0xffffffff80000000)>;
1462def : Pat<(store (add (loadi64 addr:$dst), 0x00000000800000000), addr:$dst),
1463 (SUB64mi32 addr:$dst, 0xffffffff80000000)>;
1464
Dan Gohman47a419d2008-08-07 02:54:50 +00001465// r & (2^32-1) ==> movz
Dan Gohman5a5e6e92008-10-17 01:33:43 +00001466def : Pat<(and GR64:$src, 0x00000000FFFFFFFF),
Dan Gohman47a419d2008-08-07 02:54:50 +00001467 (MOVZX64rr32 (i32 (EXTRACT_SUBREG GR64:$src, x86_subreg_32bit)))>;
Dan Gohman9203ab42008-07-30 18:09:17 +00001468// r & (2^16-1) ==> movz
1469def : Pat<(and GR64:$src, 0xffff),
1470 (MOVZX64rr16 (i16 (EXTRACT_SUBREG GR64:$src, x86_subreg_16bit)))>;
1471// r & (2^8-1) ==> movz
1472def : Pat<(and GR64:$src, 0xff),
1473 (MOVZX64rr8 (i8 (EXTRACT_SUBREG GR64:$src, x86_subreg_8bit)))>;
Dan Gohman9203ab42008-07-30 18:09:17 +00001474// r & (2^8-1) ==> movz
1475def : Pat<(and GR32:$src1, 0xff),
1476 (MOVZX32rr8 (i8 (EXTRACT_SUBREG GR32:$src1, x86_subreg_8bit)))>,
1477 Requires<[In64BitMode]>;
1478// r & (2^8-1) ==> movz
1479def : Pat<(and GR16:$src1, 0xff),
1480 (MOVZX16rr8 (i8 (EXTRACT_SUBREG GR16:$src1, x86_subreg_8bit)))>,
1481 Requires<[In64BitMode]>;
Christopher Lambb371e032008-03-13 05:47:01 +00001482
Dan Gohmandd612bb2008-08-20 21:27:32 +00001483// sext_inreg patterns
1484def : Pat<(sext_inreg GR64:$src, i32),
1485 (MOVSX64rr32 (i32 (EXTRACT_SUBREG GR64:$src, x86_subreg_32bit)))>;
1486def : Pat<(sext_inreg GR64:$src, i16),
1487 (MOVSX64rr16 (i16 (EXTRACT_SUBREG GR64:$src, x86_subreg_16bit)))>;
1488def : Pat<(sext_inreg GR64:$src, i8),
1489 (MOVSX64rr8 (i8 (EXTRACT_SUBREG GR64:$src, x86_subreg_8bit)))>;
1490def : Pat<(sext_inreg GR32:$src, i8),
1491 (MOVSX32rr8 (i8 (EXTRACT_SUBREG GR32:$src, x86_subreg_8bit)))>,
1492 Requires<[In64BitMode]>;
1493def : Pat<(sext_inreg GR16:$src, i8),
1494 (MOVSX16rr8 (i8 (EXTRACT_SUBREG GR16:$src, x86_subreg_8bit)))>,
1495 Requires<[In64BitMode]>;
1496
1497// trunc patterns
1498def : Pat<(i32 (trunc GR64:$src)),
1499 (i32 (EXTRACT_SUBREG GR64:$src, x86_subreg_32bit))>;
1500def : Pat<(i16 (trunc GR64:$src)),
1501 (i16 (EXTRACT_SUBREG GR64:$src, x86_subreg_16bit))>;
1502def : Pat<(i8 (trunc GR64:$src)),
1503 (i8 (EXTRACT_SUBREG GR64:$src, x86_subreg_8bit))>;
1504def : Pat<(i8 (trunc GR32:$src)),
1505 (i8 (EXTRACT_SUBREG GR32:$src, x86_subreg_8bit))>,
1506 Requires<[In64BitMode]>;
1507def : Pat<(i8 (trunc GR16:$src)),
1508 (i8 (EXTRACT_SUBREG GR16:$src, x86_subreg_8bit))>,
1509 Requires<[In64BitMode]>;
1510
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001511// (shl x, 1) ==> (add x, x)
1512def : Pat<(shl GR64:$src1, (i8 1)), (ADD64rr GR64:$src1, GR64:$src1)>;
1513
Evan Cheng76a64c72008-08-30 02:03:58 +00001514// (shl x (and y, 63)) ==> (shl x, y)
1515def : Pat<(shl GR64:$src1, (and CL:$amt, 63)),
1516 (SHL64rCL GR64:$src1)>;
1517def : Pat<(store (shl (loadi64 addr:$dst), (and CL:$amt, 63)), addr:$dst),
1518 (SHL64mCL addr:$dst)>;
1519
1520def : Pat<(srl GR64:$src1, (and CL:$amt, 63)),
1521 (SHR64rCL GR64:$src1)>;
1522def : Pat<(store (srl (loadi64 addr:$dst), (and CL:$amt, 63)), addr:$dst),
1523 (SHR64mCL addr:$dst)>;
1524
1525def : Pat<(sra GR64:$src1, (and CL:$amt, 63)),
1526 (SAR64rCL GR64:$src1)>;
1527def : Pat<(store (sra (loadi64 addr:$dst), (and CL:$amt, 63)), addr:$dst),
1528 (SAR64mCL addr:$dst)>;
1529
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001530// (or (x >> c) | (y << (64 - c))) ==> (shrd64 x, y, c)
1531def : Pat<(or (srl GR64:$src1, CL:$amt),
1532 (shl GR64:$src2, (sub 64, CL:$amt))),
1533 (SHRD64rrCL GR64:$src1, GR64:$src2)>;
1534
1535def : Pat<(store (or (srl (loadi64 addr:$dst), CL:$amt),
1536 (shl GR64:$src2, (sub 64, CL:$amt))), addr:$dst),
1537 (SHRD64mrCL addr:$dst, GR64:$src2)>;
1538
Dan Gohman921581d2008-10-17 01:23:35 +00001539def : Pat<(or (srl GR64:$src1, (i8 (trunc RCX:$amt))),
1540 (shl GR64:$src2, (i8 (trunc (sub 64, RCX:$amt))))),
1541 (SHRD64rrCL GR64:$src1, GR64:$src2)>;
1542
1543def : Pat<(store (or (srl (loadi64 addr:$dst), (i8 (trunc RCX:$amt))),
1544 (shl GR64:$src2, (i8 (trunc (sub 64, RCX:$amt))))),
1545 addr:$dst),
1546 (SHRD64mrCL addr:$dst, GR64:$src2)>;
1547
1548def : Pat<(shrd GR64:$src1, (i8 imm:$amt1), GR64:$src2, (i8 imm:$amt2)),
1549 (SHRD64rri8 GR64:$src1, GR64:$src2, (i8 imm:$amt1))>;
1550
1551def : Pat<(store (shrd (loadi64 addr:$dst), (i8 imm:$amt1),
1552 GR64:$src2, (i8 imm:$amt2)), addr:$dst),
1553 (SHRD64mri8 addr:$dst, GR64:$src2, (i8 imm:$amt1))>;
1554
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001555// (or (x << c) | (y >> (64 - c))) ==> (shld64 x, y, c)
1556def : Pat<(or (shl GR64:$src1, CL:$amt),
1557 (srl GR64:$src2, (sub 64, CL:$amt))),
1558 (SHLD64rrCL GR64:$src1, GR64:$src2)>;
1559
1560def : Pat<(store (or (shl (loadi64 addr:$dst), CL:$amt),
1561 (srl GR64:$src2, (sub 64, CL:$amt))), addr:$dst),
1562 (SHLD64mrCL addr:$dst, GR64:$src2)>;
1563
Dan Gohman921581d2008-10-17 01:23:35 +00001564def : Pat<(or (shl GR64:$src1, (i8 (trunc RCX:$amt))),
1565 (srl GR64:$src2, (i8 (trunc (sub 64, RCX:$amt))))),
1566 (SHLD64rrCL GR64:$src1, GR64:$src2)>;
1567
1568def : Pat<(store (or (shl (loadi64 addr:$dst), (i8 (trunc RCX:$amt))),
1569 (srl GR64:$src2, (i8 (trunc (sub 64, RCX:$amt))))),
1570 addr:$dst),
1571 (SHLD64mrCL addr:$dst, GR64:$src2)>;
1572
1573def : Pat<(shld GR64:$src1, (i8 imm:$amt1), GR64:$src2, (i8 imm:$amt2)),
1574 (SHLD64rri8 GR64:$src1, GR64:$src2, (i8 imm:$amt1))>;
1575
1576def : Pat<(store (shld (loadi64 addr:$dst), (i8 imm:$amt1),
1577 GR64:$src2, (i8 imm:$amt2)), addr:$dst),
1578 (SHLD64mri8 addr:$dst, GR64:$src2, (i8 imm:$amt1))>;
1579
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001580// X86 specific add which produces a flag.
1581def : Pat<(addc GR64:$src1, GR64:$src2),
1582 (ADD64rr GR64:$src1, GR64:$src2)>;
1583def : Pat<(addc GR64:$src1, (load addr:$src2)),
1584 (ADD64rm GR64:$src1, addr:$src2)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001585def : Pat<(addc GR64:$src1, i64immSExt8:$src2),
1586 (ADD64ri8 GR64:$src1, i64immSExt8:$src2)>;
Dan Gohmand16fdc02008-12-19 18:25:21 +00001587def : Pat<(addc GR64:$src1, i64immSExt32:$src2),
1588 (ADD64ri32 GR64:$src1, imm:$src2)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001589
1590def : Pat<(subc GR64:$src1, GR64:$src2),
1591 (SUB64rr GR64:$src1, GR64:$src2)>;
1592def : Pat<(subc GR64:$src1, (load addr:$src2)),
1593 (SUB64rm GR64:$src1, addr:$src2)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001594def : Pat<(subc GR64:$src1, i64immSExt8:$src2),
1595 (SUB64ri8 GR64:$src1, i64immSExt8:$src2)>;
Dan Gohmand16fdc02008-12-19 18:25:21 +00001596def : Pat<(subc GR64:$src1, imm:$src2),
1597 (SUB64ri32 GR64:$src1, i64immSExt32:$src2)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001598
Bill Wendlingf5399032008-12-12 21:15:41 +00001599//===----------------------------------------------------------------------===//
1600// Overflow Patterns
1601//===----------------------------------------------------------------------===//
1602
1603// Register-Register Addition with Overflow
1604def : Pat<(parallel (X86add_ovf GR64:$src1, GR64:$src2),
1605 (implicit EFLAGS)),
1606 (ADD64rr GR64:$src1, GR64:$src2)>;
1607
1608// Register-Integer Addition with Overflow
Bill Wendlingf5399032008-12-12 21:15:41 +00001609def : Pat<(parallel (X86add_ovf GR64:$src1, i64immSExt8:$src2),
1610 (implicit EFLAGS)),
1611 (ADD64ri8 GR64:$src1, i64immSExt8:$src2)>;
Dan Gohmand16fdc02008-12-19 18:25:21 +00001612def : Pat<(parallel (X86add_ovf GR64:$src1, i64immSExt32:$src2),
1613 (implicit EFLAGS)),
1614 (ADD64ri32 GR64:$src1, i64immSExt32:$src2)>;
Bill Wendlingf5399032008-12-12 21:15:41 +00001615
1616// Register-Memory Addition with Overflow
1617def : Pat<(parallel (X86add_ovf GR64:$src1, (load addr:$src2)),
1618 (implicit EFLAGS)),
1619 (ADD64rm GR64:$src1, addr:$src2)>;
1620
1621// Memory-Register Addition with Overflow
1622def : Pat<(parallel (store (X86add_ovf (load addr:$dst), GR64:$src2),
1623 addr:$dst),
1624 (implicit EFLAGS)),
1625 (ADD64mr addr:$dst, GR64:$src2)>;
Bill Wendlingf5399032008-12-12 21:15:41 +00001626def : Pat<(parallel (store (X86add_ovf (load addr:$dst), i64immSExt8:$src2),
1627 addr:$dst),
1628 (implicit EFLAGS)),
1629 (ADD64mi8 addr:$dst, i64immSExt8:$src2)>;
Dan Gohmand16fdc02008-12-19 18:25:21 +00001630def : Pat<(parallel (store (X86add_ovf (load addr:$dst), i64immSExt32:$src2),
1631 addr:$dst),
1632 (implicit EFLAGS)),
1633 (ADD64mi32 addr:$dst, i64immSExt32:$src2)>;
Bill Wendlingf5399032008-12-12 21:15:41 +00001634
1635// Register-Register Subtraction with Overflow
1636def : Pat<(parallel (X86sub_ovf GR64:$src1, GR64:$src2),
1637 (implicit EFLAGS)),
1638 (SUB64rr GR64:$src1, GR64:$src2)>;
1639
1640// Register-Memory Subtraction with Overflow
1641def : Pat<(parallel (X86sub_ovf GR64:$src1, (load addr:$src2)),
1642 (implicit EFLAGS)),
1643 (SUB64rm GR64:$src1, addr:$src2)>;
1644
1645// Register-Integer Subtraction with Overflow
Bill Wendlingf5399032008-12-12 21:15:41 +00001646def : Pat<(parallel (X86sub_ovf GR64:$src1, i64immSExt8:$src2),
1647 (implicit EFLAGS)),
1648 (SUB64ri8 GR64:$src1, i64immSExt8:$src2)>;
Dan Gohmand16fdc02008-12-19 18:25:21 +00001649def : Pat<(parallel (X86sub_ovf GR64:$src1, i64immSExt32:$src2),
1650 (implicit EFLAGS)),
1651 (SUB64ri32 GR64:$src1, i64immSExt32:$src2)>;
Bill Wendlingf5399032008-12-12 21:15:41 +00001652
1653// Memory-Register Subtraction with Overflow
1654def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), GR64:$src2),
1655 addr:$dst),
1656 (implicit EFLAGS)),
1657 (SUB64mr addr:$dst, GR64:$src2)>;
1658
1659// Memory-Integer Subtraction with Overflow
Bill Wendlingf5399032008-12-12 21:15:41 +00001660def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), i64immSExt8:$src2),
1661 addr:$dst),
1662 (implicit EFLAGS)),
1663 (SUB64mi8 addr:$dst, i64immSExt8:$src2)>;
Dan Gohmand16fdc02008-12-19 18:25:21 +00001664def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), i64immSExt32:$src2),
1665 addr:$dst),
1666 (implicit EFLAGS)),
1667 (SUB64mi32 addr:$dst, i64immSExt32:$src2)>;
Bill Wendlingf5399032008-12-12 21:15:41 +00001668
1669// Register-Register Signed Integer Multiplication with Overflow
1670def : Pat<(parallel (X86smul_ovf GR64:$src1, GR64:$src2),
1671 (implicit EFLAGS)),
1672 (IMUL64rr GR64:$src1, GR64:$src2)>;
1673
1674// Register-Memory Signed Integer Multiplication with Overflow
1675def : Pat<(parallel (X86smul_ovf GR64:$src1, (load addr:$src2)),
1676 (implicit EFLAGS)),
1677 (IMUL64rm GR64:$src1, addr:$src2)>;
1678
1679// Register-Integer Signed Integer Multiplication with Overflow
Bill Wendlingf5399032008-12-12 21:15:41 +00001680def : Pat<(parallel (X86smul_ovf GR64:$src1, i64immSExt8:$src2),
1681 (implicit EFLAGS)),
1682 (IMUL64rri8 GR64:$src1, i64immSExt8:$src2)>;
Dan Gohmand16fdc02008-12-19 18:25:21 +00001683def : Pat<(parallel (X86smul_ovf GR64:$src1, i64immSExt32:$src2),
1684 (implicit EFLAGS)),
1685 (IMUL64rri32 GR64:$src1, i64immSExt32:$src2)>;
Bill Wendlingf5399032008-12-12 21:15:41 +00001686
1687// Memory-Integer Signed Integer Multiplication with Overflow
Bill Wendlingf5399032008-12-12 21:15:41 +00001688def : Pat<(parallel (X86smul_ovf (load addr:$src1), i64immSExt8:$src2),
1689 (implicit EFLAGS)),
1690 (IMUL64rmi8 addr:$src1, i64immSExt8:$src2)>;
Dan Gohmand16fdc02008-12-19 18:25:21 +00001691def : Pat<(parallel (X86smul_ovf (load addr:$src1), i64immSExt32:$src2),
1692 (implicit EFLAGS)),
1693 (IMUL64rmi32 addr:$src1, i64immSExt32:$src2)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001694
1695//===----------------------------------------------------------------------===//
1696// X86-64 SSE Instructions
1697//===----------------------------------------------------------------------===//
1698
1699// Move instructions...
1700
Evan Chengb783fa32007-07-19 01:14:50 +00001701def MOV64toPQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001702 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001703 [(set VR128:$dst,
1704 (v2i64 (scalar_to_vector GR64:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001705def MOVPQIto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001706 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001707 [(set GR64:$dst, (vector_extract (v2i64 VR128:$src),
1708 (iPTR 0)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001709
Evan Chengb783fa32007-07-19 01:14:50 +00001710def MOV64toSDrr : RPDI<0x6E, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001711 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001712 [(set FR64:$dst, (bitconvert GR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001713def MOV64toSDrm : RPDI<0x6E, MRMSrcMem, (outs FR64:$dst), (ins i64mem:$src),
Evan Cheng69ca4da2008-08-25 04:11:42 +00001714 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001715 [(set FR64:$dst, (bitconvert (loadi64 addr:$src)))]>;
1716
Evan Chengb783fa32007-07-19 01:14:50 +00001717def MOVSDto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001718 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001719 [(set GR64:$dst, (bitconvert FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001720def MOVSDto64mr : RPDI<0x7E, MRMDestMem, (outs), (ins i64mem:$dst, FR64:$src),
Evan Cheng69ca4da2008-08-25 04:11:42 +00001721 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001722 [(store (i64 (bitconvert FR64:$src)), addr:$dst)]>;
Nate Begemanb2975562008-02-03 07:18:54 +00001723
1724//===----------------------------------------------------------------------===//
1725// X86-64 SSE4.1 Instructions
1726//===----------------------------------------------------------------------===//
1727
Nate Begeman4294c1f2008-02-12 22:51:28 +00001728/// SS41I_extract32 - SSE 4.1 extract 32 bits to int reg or memory destination
1729multiclass SS41I_extract64<bits<8> opc, string OpcodeStr> {
Nate Begeman0050ab52008-10-29 23:07:17 +00001730 def rr : SS4AIi8<opc, MRMDestReg, (outs GR64:$dst),
Nate Begeman4294c1f2008-02-12 22:51:28 +00001731 (ins VR128:$src1, i32i8imm:$src2),
1732 !strconcat(OpcodeStr,
1733 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
1734 [(set GR64:$dst,
1735 (extractelt (v2i64 VR128:$src1), imm:$src2))]>, OpSize, REX_W;
Evan Cheng78d00612008-03-14 07:39:27 +00001736 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman4294c1f2008-02-12 22:51:28 +00001737 (ins i64mem:$dst, VR128:$src1, i32i8imm:$src2),
1738 !strconcat(OpcodeStr,
1739 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
1740 [(store (extractelt (v2i64 VR128:$src1), imm:$src2),
1741 addr:$dst)]>, OpSize, REX_W;
1742}
1743
1744defm PEXTRQ : SS41I_extract64<0x16, "pextrq">;
1745
1746let isTwoAddress = 1 in {
1747 multiclass SS41I_insert64<bits<8> opc, string OpcodeStr> {
Evan Cheng78d00612008-03-14 07:39:27 +00001748 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begeman4294c1f2008-02-12 22:51:28 +00001749 (ins VR128:$src1, GR64:$src2, i32i8imm:$src3),
1750 !strconcat(OpcodeStr,
1751 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
1752 [(set VR128:$dst,
1753 (v2i64 (insertelt VR128:$src1, GR64:$src2, imm:$src3)))]>,
1754 OpSize, REX_W;
Evan Cheng78d00612008-03-14 07:39:27 +00001755 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begeman4294c1f2008-02-12 22:51:28 +00001756 (ins VR128:$src1, i64mem:$src2, i32i8imm:$src3),
1757 !strconcat(OpcodeStr,
1758 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
1759 [(set VR128:$dst,
1760 (v2i64 (insertelt VR128:$src1, (loadi64 addr:$src2),
1761 imm:$src3)))]>, OpSize, REX_W;
1762 }
1763}
1764
1765defm PINSRQ : SS41I_insert64<0x22, "pinsrq">;