blob: a76a056c4ea19224e58a18349acc247216792211 [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>;
Chris Lattner357a0ca2009-06-20 19:34:09 +000022
23// 64-bits but only 32 bits are significant, and those bits are treated as being
24// pc relative.
25def i64i32imm_pcrel : Operand<i64> {
26 let PrintMethod = "print_pcrel_imm";
27}
28
29
Dan Gohmanf17a25c2007-07-18 16:29:46 +000030// 64-bits but only 8 bits are significant.
31def i64i8imm : Operand<i64>;
32
33def lea64mem : Operand<i64> {
Rafael Espindolabca99f72009-04-08 21:14:34 +000034 let PrintMethod = "printlea64mem";
Dan Gohmanefbd3bc2009-08-05 17:40:24 +000035 let MIOperandInfo = (ops GR64, i8imm, GR64_NOSP, i32imm);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000036}
37
38def lea64_32mem : Operand<i32> {
39 let PrintMethod = "printlea64_32mem";
Chris Lattnerf5da5902009-06-20 07:03:18 +000040 let AsmOperandLowerMethod = "lower_lea64_32mem";
Dan Gohmanefbd3bc2009-08-05 17:40:24 +000041 let MIOperandInfo = (ops GR32, i8imm, GR32_NOSP, i32imm);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000042}
43
44//===----------------------------------------------------------------------===//
Chris Lattner2de8d2b2008-01-10 05:50:42 +000045// Complex Pattern Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000046//
47def lea64addr : ComplexPattern<i64, 4, "SelectLEAAddr",
Dan Gohman0c0d7412009-08-02 16:09:17 +000048 [add, sub, mul, X86mul_imm, shl, or, frameindex,
Chris Lattnerc04cd042009-07-11 23:17:29 +000049 X86WrapperRIP], []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000050
Chris Lattnerf1940742009-06-20 20:38:48 +000051def tls64addr : ComplexPattern<i64, 4, "SelectTLSADDRAddr",
52 [tglobaltlsaddr], []>;
53
Dan Gohmanf17a25c2007-07-18 16:29:46 +000054//===----------------------------------------------------------------------===//
Chris Lattner2de8d2b2008-01-10 05:50:42 +000055// Pattern fragments.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000056//
57
Dan Gohmand16fdc02008-12-19 18:25:21 +000058def i64immSExt8 : PatLeaf<(i64 imm), [{
59 // i64immSExt8 predicate - True if the 64-bit immediate fits in a 8-bit
60 // sign extended field.
61 return (int64_t)N->getZExtValue() == (int8_t)N->getZExtValue();
62}]>;
63
Dan Gohmanf17a25c2007-07-18 16:29:46 +000064def i64immSExt32 : PatLeaf<(i64 imm), [{
65 // i64immSExt32 predicate - True if the 64-bit immediate fits in a 32-bit
66 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +000067 return (int64_t)N->getZExtValue() == (int32_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +000068}]>;
69
70def i64immZExt32 : PatLeaf<(i64 imm), [{
71 // i64immZExt32 predicate - True if the 64-bit immediate fits in a 32-bit
72 // unsignedsign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +000073 return (uint64_t)N->getZExtValue() == (uint32_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +000074}]>;
75
Dan Gohmanf17a25c2007-07-18 16:29:46 +000076def sextloadi64i8 : PatFrag<(ops node:$ptr), (i64 (sextloadi8 node:$ptr))>;
77def sextloadi64i16 : PatFrag<(ops node:$ptr), (i64 (sextloadi16 node:$ptr))>;
78def sextloadi64i32 : PatFrag<(ops node:$ptr), (i64 (sextloadi32 node:$ptr))>;
79
80def zextloadi64i1 : PatFrag<(ops node:$ptr), (i64 (zextloadi1 node:$ptr))>;
81def zextloadi64i8 : PatFrag<(ops node:$ptr), (i64 (zextloadi8 node:$ptr))>;
82def zextloadi64i16 : PatFrag<(ops node:$ptr), (i64 (zextloadi16 node:$ptr))>;
83def zextloadi64i32 : PatFrag<(ops node:$ptr), (i64 (zextloadi32 node:$ptr))>;
84
85def extloadi64i1 : PatFrag<(ops node:$ptr), (i64 (extloadi1 node:$ptr))>;
86def extloadi64i8 : PatFrag<(ops node:$ptr), (i64 (extloadi8 node:$ptr))>;
87def extloadi64i16 : PatFrag<(ops node:$ptr), (i64 (extloadi16 node:$ptr))>;
88def extloadi64i32 : PatFrag<(ops node:$ptr), (i64 (extloadi32 node:$ptr))>;
89
90//===----------------------------------------------------------------------===//
91// Instruction list...
92//
93
Dan Gohman01c9f772008-10-01 18:28:06 +000094// ADJCALLSTACKDOWN/UP implicitly use/def RSP because they may be expanded into
95// a stack adjustment and the codegen must know that they may modify the stack
96// pointer before prolog-epilog rewriting occurs.
97// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
98// sub / add which can clobber EFLAGS.
99let Defs = [RSP, EFLAGS], Uses = [RSP] in {
100def ADJCALLSTACKDOWN64 : I<0, Pseudo, (outs), (ins i32imm:$amt),
101 "#ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000102 [(X86callseq_start timm:$amt)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000103 Requires<[In64BitMode]>;
104def ADJCALLSTACKUP64 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
105 "#ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000106 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000107 Requires<[In64BitMode]>;
108}
109
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000110//===----------------------------------------------------------------------===//
111// Call Instructions...
112//
Evan Cheng37e7c752007-07-21 00:34:19 +0000113let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000114 // All calls clobber the non-callee saved registers. RSP is marked as
115 // a use to prevent stack-pointer assignments that appear immediately
116 // before calls from potentially appearing dead. Uses for argument
117 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000118 let Defs = [RAX, RCX, RDX, RSI, RDI, R8, R9, R10, R11,
Evan Cheng931a8f42008-01-29 19:34:22 +0000119 FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0, ST1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000120 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
121 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
Dan Gohman9499cfe2008-10-01 04:14:30 +0000122 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
123 Uses = [RSP] in {
Chris Lattner79552392009-03-18 00:43:52 +0000124
125 // NOTE: this pattern doesn't match "X86call imm", because we do not know
126 // that the offset between an arbitrary immediate and the call will fit in
127 // the 32-bit pcrel field that we have.
Evan Chengfa4b3bd2009-06-16 19:44:27 +0000128 def CALL64pcrel32 : Ii32<0xE8, RawFrm,
Chris Lattner357a0ca2009-06-20 19:34:09 +0000129 (outs), (ins i64i32imm_pcrel:$dst, variable_ops),
130 "call\t$dst", []>,
Anton Korobeynikov2cbcdb72009-08-03 08:12:53 +0000131 Requires<[In64BitMode, NotWin64]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000132 def CALL64r : I<0xFF, MRM2r, (outs), (ins GR64:$dst, variable_ops),
Anton Korobeynikov2cbcdb72009-08-03 08:12:53 +0000133 "call\t{*}$dst", [(X86call GR64:$dst)]>,
134 Requires<[NotWin64]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000135 def CALL64m : I<0xFF, MRM2m, (outs), (ins i64mem:$dst, variable_ops),
Anton Korobeynikov2cbcdb72009-08-03 08:12:53 +0000136 "call\t{*}$dst", [(X86call (loadi64 addr:$dst))]>,
137 Requires<[NotWin64]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000138 }
139
Anton Korobeynikov2cbcdb72009-08-03 08:12:53 +0000140 // FIXME: We need to teach codegen about single list of call-clobbered registers.
141let isCall = 1 in
142 // All calls clobber the non-callee saved registers. RSP is marked as
143 // a use to prevent stack-pointer assignments that appear immediately
144 // before calls from potentially appearing dead. Uses for argument
145 // registers are added manually.
146 let Defs = [RAX, RCX, RDX, R8, R9, R10, R11,
147 FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0, ST1,
148 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
149 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, EFLAGS],
150 Uses = [RSP] in {
151 def WINCALL64pcrel32 : I<0xE8, RawFrm,
152 (outs), (ins i64i32imm:$dst, variable_ops),
153 "call\t${dst:call}", [(X86call imm:$dst)]>,
154 Requires<[IsWin64]>;
155 def WINCALL64r : I<0xFF, MRM2r, (outs), (ins GR64:$dst, variable_ops),
156 "call\t{*}$dst",
157 [(X86call GR64:$dst)]>, Requires<[IsWin64]>;
158 def WINCALL64m : I<0xFF, MRM2m, (outs), (ins i64mem:$dst, variable_ops),
159 "call\t{*}$dst",
160 [(X86call (loadi64 addr:$dst))]>, Requires<[IsWin64]>;
161 }
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000162
163
164let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengbd780d22009-02-10 21:39:44 +0000165def TCRETURNdi64 : I<0, Pseudo, (outs), (ins i64imm:$dst, i32imm:$offset,
166 variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000167 "#TC_RETURN $dst $offset",
168 []>;
169
170let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengbd780d22009-02-10 21:39:44 +0000171def TCRETURNri64 : I<0, Pseudo, (outs), (ins GR64:$dst, i32imm:$offset,
172 variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000173 "#TC_RETURN $dst $offset",
174 []>;
175
176
177let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengbd780d22009-02-10 21:39:44 +0000178 def TAILJMPr64 : I<0xFF, MRM4r, (outs), (ins GR64:$dst),
179 "jmp{q}\t{*}$dst # TAILCALL",
180 []>;
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000181
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000182// Branches
Owen Andersonf8053082007-11-12 07:39:39 +0000183let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000184 def JMP64r : I<0xFF, MRM4r, (outs), (ins GR64:$dst), "jmp{q}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000185 [(brind GR64:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000186 def JMP64m : I<0xFF, MRM4m, (outs), (ins i64mem:$dst), "jmp{q}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000187 [(brind (loadi64 addr:$dst))]>;
188}
189
190//===----------------------------------------------------------------------===//
Anton Korobeynikov1ec04ee2008-09-08 21:12:47 +0000191// EH Pseudo Instructions
192//
193let isTerminator = 1, isReturn = 1, isBarrier = 1,
194 hasCtrlDep = 1 in {
195def EH_RETURN64 : I<0xC3, RawFrm, (outs), (ins GR64:$addr),
196 "ret\t#eh_return, addr: $addr",
197 [(X86ehret GR64:$addr)]>;
198
199}
200
201//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000202// Miscellaneous Instructions...
203//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000204let Defs = [RBP,RSP], Uses = [RBP,RSP], mayLoad = 1, neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000205def LEAVE64 : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000206 (outs), (ins), "leave", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000207let Defs = [RSP], Uses = [RSP], neverHasSideEffects=1 in {
208let mayLoad = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000209def POP64r : I<0x58, AddRegFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000210 (outs GR64:$reg), (ins), "pop{q}\t$reg", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000211let mayStore = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000212def PUSH64r : I<0x50, AddRegFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000213 (outs), (ins GR64:$reg), "push{q}\t$reg", []>;
214}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000215
Bill Wendling4c2638c2009-06-15 19:39:04 +0000216let Defs = [RSP], Uses = [RSP], neverHasSideEffects = 1, mayStore = 1 in {
217def PUSH64i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000218 "push{q}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000219def PUSH64i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000220 "push{q}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000221def PUSH64i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000222 "push{q}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000223}
224
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000225let Defs = [RSP, EFLAGS], Uses = [RSP], mayLoad = 1 in
Evan Chengf1341312007-09-26 21:28:00 +0000226def POPFQ : I<0x9D, RawFrm, (outs), (ins), "popf", []>, REX_W;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000227let Defs = [RSP], Uses = [RSP, EFLAGS], mayStore = 1 in
Evan Chengf1341312007-09-26 21:28:00 +0000228def PUSHFQ : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000229
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000230def LEA64_32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000231 (outs GR32:$dst), (ins lea64_32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000232 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000233 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In64BitMode]>;
234
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000235let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000236def LEA64r : RI<0x8D, MRMSrcMem, (outs GR64:$dst), (ins lea64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000237 "lea{q}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000238 [(set GR64:$dst, lea64addr:$src)]>;
239
240let isTwoAddress = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000241def BSWAP64r : RI<0xC8, AddRegFrm, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000242 "bswap{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000243 [(set GR64:$dst, (bswap GR64:$src))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000244
Evan Cheng48679f42007-12-14 02:13:44 +0000245// Bit scan instructions.
246let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000247def BSF64rr : RI<0xBC, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000248 "bsf{q}\t{$src, $dst|$dst, $src}",
Evan Cheng9a8ffd52007-12-14 18:25:34 +0000249 [(set GR64:$dst, (X86bsf GR64:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000250def BSF64rm : RI<0xBC, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000251 "bsf{q}\t{$src, $dst|$dst, $src}",
Evan Cheng9a8ffd52007-12-14 18:25:34 +0000252 [(set GR64:$dst, (X86bsf (loadi64 addr:$src))),
253 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000254
Evan Cheng4e33de92007-12-14 18:49:43 +0000255def BSR64rr : RI<0xBD, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000256 "bsr{q}\t{$src, $dst|$dst, $src}",
Evan Cheng9a8ffd52007-12-14 18:25:34 +0000257 [(set GR64:$dst, (X86bsr GR64:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000258def BSR64rm : RI<0xBD, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000259 "bsr{q}\t{$src, $dst|$dst, $src}",
Evan Cheng9a8ffd52007-12-14 18:25:34 +0000260 [(set GR64:$dst, (X86bsr (loadi64 addr:$src))),
261 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000262} // Defs = [EFLAGS]
263
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000264// Repeat string ops
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000265let Defs = [RCX,RDI,RSI], Uses = [RCX,RDI,RSI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000266def REP_MOVSQ : RI<0xA5, RawFrm, (outs), (ins), "{rep;movsq|rep movsq}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000267 [(X86rep_movs i64)]>, REP;
268let Defs = [RCX,RDI], Uses = [RAX,RCX,RDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000269def REP_STOSQ : RI<0xAB, RawFrm, (outs), (ins), "{rep;stosq|rep stosq}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000270 [(X86rep_stos i64)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000271
Bill Wendlinga7431ad2009-07-21 01:07:24 +0000272// Fast system-call instructions
273def SYSCALL : I<0x05, RawFrm,
274 (outs), (ins), "syscall", []>, TB;
275def SYSENTER : I<0x34, RawFrm,
276 (outs), (ins), "sysenter", []>, TB;
277def SYSEXIT : I<0x35, RawFrm,
278 (outs), (ins), "sysexit", []>, TB;
279def SYSEXIT64 : RI<0x35, RawFrm,
280 (outs), (ins), "sysexit", []>, TB;
281def SYSRET : I<0x07, RawFrm,
282 (outs), (ins), "sysret", []>, TB;
283
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000284//===----------------------------------------------------------------------===//
285// Move Instructions...
286//
287
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000288let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000289def MOV64rr : RI<0x89, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000290 "mov{q}\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000291
Evan Chengd2b9d302008-06-25 01:16:38 +0000292let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000293def MOV64ri : RIi64<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000294 "movabs{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000295 [(set GR64:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000296def MOV64ri32 : RIi32<0xC7, MRM0r, (outs GR64:$dst), (ins i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000297 "mov{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000298 [(set GR64:$dst, i64immSExt32:$src)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +0000299}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000300
Dan Gohman5574cc72008-12-03 18:15:48 +0000301let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000302def MOV64rm : RI<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000303 "mov{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000304 [(set GR64:$dst, (load addr:$src))]>;
305
Evan Chengb783fa32007-07-19 01:14:50 +0000306def MOV64mr : RI<0x89, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000307 "mov{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000308 [(store GR64:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000309def MOV64mi32 : RIi32<0xC7, MRM0m, (outs), (ins i64mem:$dst, i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000310 "mov{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000311 [(store i64immSExt32:$src, addr:$dst)]>;
312
313// Sign/Zero extenders
314
Dan Gohmanedde1992009-04-13 15:13:28 +0000315// MOVSX64rr8 always has a REX prefix and it has an 8-bit register
316// operand, which makes it a rare instruction with an 8-bit register
317// operand that can never access an h register. If support for h registers
318// were generalized, this would require a special register class.
Evan Chengb783fa32007-07-19 01:14:50 +0000319def MOVSX64rr8 : RI<0xBE, MRMSrcReg, (outs GR64:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000320 "movs{bq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000321 [(set GR64:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000322def MOVSX64rm8 : RI<0xBE, MRMSrcMem, (outs GR64:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000323 "movs{bq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000324 [(set GR64:$dst, (sextloadi64i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000325def MOVSX64rr16: RI<0xBF, MRMSrcReg, (outs GR64:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000326 "movs{wq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000327 [(set GR64:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000328def MOVSX64rm16: RI<0xBF, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000329 "movs{wq|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000330 [(set GR64:$dst, (sextloadi64i16 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000331def MOVSX64rr32: RI<0x63, MRMSrcReg, (outs GR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000332 "movs{lq|xd}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000333 [(set GR64:$dst, (sext GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000334def MOVSX64rm32: RI<0x63, MRMSrcMem, (outs GR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000335 "movs{lq|xd}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000336 [(set GR64:$dst, (sextloadi64i32 addr:$src))]>;
337
Dan Gohman9203ab42008-07-30 18:09:17 +0000338// Use movzbl instead of movzbq when the destination is a register; it's
339// equivalent due to implicit zero-extending, and it has a smaller encoding.
340def MOVZX64rr8 : I<0xB6, MRMSrcReg, (outs GR64:$dst), (ins GR8 :$src),
341 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
342 [(set GR64:$dst, (zext GR8:$src))]>, TB;
343def MOVZX64rm8 : I<0xB6, MRMSrcMem, (outs GR64:$dst), (ins i8mem :$src),
344 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
345 [(set GR64:$dst, (zextloadi64i8 addr:$src))]>, TB;
346// Use movzwl instead of movzwq when the destination is a register; it's
347// equivalent due to implicit zero-extending, and it has a smaller encoding.
348def MOVZX64rr16: I<0xB7, MRMSrcReg, (outs GR64:$dst), (ins GR16:$src),
349 "movz{wl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
350 [(set GR64:$dst, (zext GR16:$src))]>, TB;
351def MOVZX64rm16: I<0xB7, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
352 "movz{wl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
353 [(set GR64:$dst, (zextloadi64i16 addr:$src))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000354
Dan Gohman47a419d2008-08-07 02:54:50 +0000355// There's no movzlq instruction, but movl can be used for this purpose, using
Dan Gohman4cedb1c2009-04-08 00:15:30 +0000356// implicit zero-extension. The preferred way to do 32-bit-to-64-bit zero
357// extension on x86-64 is to use a SUBREG_TO_REG to utilize implicit
358// zero-extension, however this isn't possible when the 32-bit value is
359// defined by a truncate or is copied from something where the high bits aren't
360// necessarily all zero. In such cases, we fall back to these explicit zext
361// instructions.
Dan Gohman47a419d2008-08-07 02:54:50 +0000362def MOVZX64rr32 : I<0x89, MRMDestReg, (outs GR64:$dst), (ins GR32:$src),
363 "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
364 [(set GR64:$dst, (zext GR32:$src))]>;
365def MOVZX64rm32 : I<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i32mem:$src),
366 "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
367 [(set GR64:$dst, (zextloadi64i32 addr:$src))]>;
368
Dan Gohman4cedb1c2009-04-08 00:15:30 +0000369// Any instruction that defines a 32-bit result leaves the high half of the
370// register. Truncate can be lowered to EXTRACT_SUBREG, and CopyFromReg may
371// be copying from a truncate, but any other 32-bit operation will zero-extend
372// up to 64 bits.
373def def32 : PatLeaf<(i32 GR32:$src), [{
374 return N->getOpcode() != ISD::TRUNCATE &&
375 N->getOpcode() != TargetInstrInfo::EXTRACT_SUBREG &&
376 N->getOpcode() != ISD::CopyFromReg;
377}]>;
378
379// In the case of a 32-bit def that is known to implicitly zero-extend,
380// we can use a SUBREG_TO_REG.
381def : Pat<(i64 (zext def32:$src)),
382 (SUBREG_TO_REG (i64 0), GR32:$src, x86_subreg_32bit)>;
383
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000384let neverHasSideEffects = 1 in {
385 let Defs = [RAX], Uses = [EAX] in
386 def CDQE : RI<0x98, RawFrm, (outs), (ins),
387 "{cltq|cdqe}", []>; // RAX = signext(EAX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000388
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000389 let Defs = [RAX,RDX], Uses = [RAX] in
390 def CQO : RI<0x99, RawFrm, (outs), (ins),
391 "{cqto|cqo}", []>; // RDX:RAX = signext(RAX)
392}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000393
394//===----------------------------------------------------------------------===//
395// Arithmetic Instructions...
396//
397
Evan Cheng55687072007-09-14 21:48:26 +0000398let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000399let isTwoAddress = 1 in {
400let isConvertibleToThreeAddress = 1 in {
401let isCommutable = 1 in
Bill Wendlingae034ed2008-12-12 00:56:36 +0000402// Register-Register Addition
403def ADD64rr : RI<0x01, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
404 "add{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +0000405 [(set GR64:$dst, (add GR64:$src1, GR64:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +0000406 (implicit EFLAGS)]>;
407
408// Register-Integer Addition
Bill Wendlingae034ed2008-12-12 00:56:36 +0000409def ADD64ri8 : RIi8<0x83, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
410 "add{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +0000411 [(set GR64:$dst, (add GR64:$src1, i64immSExt8:$src2)),
412 (implicit EFLAGS)]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000413def ADD64ri32 : RIi32<0x81, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
414 "add{q}\t{$src2, $dst|$dst, $src2}",
415 [(set GR64:$dst, (add GR64:$src1, i64immSExt32:$src2)),
416 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000417} // isConvertibleToThreeAddress
418
Bill Wendlingae034ed2008-12-12 00:56:36 +0000419// Register-Memory Addition
420def ADD64rm : RI<0x03, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
421 "add{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +0000422 [(set GR64:$dst, (add GR64:$src1, (load addr:$src2))),
Bill Wendlingae034ed2008-12-12 00:56:36 +0000423 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000424} // isTwoAddress
425
Bill Wendlingae034ed2008-12-12 00:56:36 +0000426// Memory-Register Addition
Evan Chengb783fa32007-07-19 01:14:50 +0000427def ADD64mr : RI<0x01, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000428 "add{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +0000429 [(store (add (load addr:$dst), GR64:$src2), addr:$dst),
430 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000431def ADD64mi8 : RIi8<0x83, MRM0m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000432 "add{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +0000433 [(store (add (load addr:$dst), i64immSExt8:$src2), addr:$dst),
434 (implicit EFLAGS)]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000435def ADD64mi32 : RIi32<0x81, MRM0m, (outs), (ins i64mem:$dst, i64i32imm :$src2),
436 "add{q}\t{$src2, $dst|$dst, $src2}",
437 [(store (add (load addr:$dst), i64immSExt32:$src2), addr:$dst),
438 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000439
Evan Cheng259471d2007-10-05 17:59:57 +0000440let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000441let isTwoAddress = 1 in {
442let isCommutable = 1 in
Dale Johannesen747fe522009-06-02 03:12:52 +0000443def ADC64rr : RI<0x11, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000444 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +0000445 [(set GR64:$dst, (adde GR64:$src1, GR64:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000446
Dale Johannesen747fe522009-06-02 03:12:52 +0000447def ADC64rm : RI<0x13, MRMSrcMem , (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000448 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +0000449 [(set GR64:$dst, (adde GR64:$src1, (load addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000450
Dale Johannesen747fe522009-06-02 03:12:52 +0000451def ADC64ri8 : RIi8<0x83, MRM2r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000452 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +0000453 [(set GR64:$dst, (adde GR64:$src1, i64immSExt8:$src2))]>;
454def ADC64ri32 : RIi32<0x81, MRM2r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohmand16fdc02008-12-19 18:25:21 +0000455 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +0000456 [(set GR64:$dst, (adde GR64:$src1, i64immSExt32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000457} // isTwoAddress
458
Evan Chengb783fa32007-07-19 01:14:50 +0000459def ADC64mr : RI<0x11, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000460 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +0000461 [(store (adde (load addr:$dst), GR64:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000462def ADC64mi8 : RIi8<0x83, MRM2m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000463 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +0000464 [(store (adde (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000465def ADC64mi32 : RIi32<0x81, MRM2m, (outs), (ins i64mem:$dst, i64i32imm:$src2),
466 "adc{q}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +0000467 [(store (adde (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
Evan Cheng259471d2007-10-05 17:59:57 +0000468} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000469
470let isTwoAddress = 1 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +0000471// Register-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +0000472def SUB64rr : RI<0x29, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000473 "sub{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +0000474 [(set GR64:$dst, (sub GR64:$src1, GR64:$src2)),
475 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +0000476
477// Register-Memory Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +0000478def SUB64rm : RI<0x2B, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000479 "sub{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +0000480 [(set GR64:$dst, (sub GR64:$src1, (load addr:$src2))),
481 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +0000482
483// Register-Integer Subtraction
Bill Wendlingae034ed2008-12-12 00:56:36 +0000484def SUB64ri8 : RIi8<0x83, MRM5r, (outs GR64:$dst),
485 (ins GR64:$src1, i64i8imm:$src2),
486 "sub{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +0000487 [(set GR64:$dst, (sub GR64:$src1, i64immSExt8:$src2)),
488 (implicit EFLAGS)]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000489def SUB64ri32 : RIi32<0x81, MRM5r, (outs GR64:$dst),
490 (ins GR64:$src1, i64i32imm:$src2),
491 "sub{q}\t{$src2, $dst|$dst, $src2}",
492 [(set GR64:$dst, (sub GR64:$src1, i64immSExt32:$src2)),
493 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000494} // isTwoAddress
495
Bill Wendlingae034ed2008-12-12 00:56:36 +0000496// Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +0000497def SUB64mr : RI<0x29, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000498 "sub{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +0000499 [(store (sub (load addr:$dst), GR64:$src2), addr:$dst),
500 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +0000501
502// Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +0000503def SUB64mi8 : RIi8<0x83, MRM5m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000504 "sub{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +0000505 [(store (sub (load addr:$dst), i64immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +0000506 addr:$dst),
507 (implicit EFLAGS)]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000508def SUB64mi32 : RIi32<0x81, MRM5m, (outs), (ins i64mem:$dst, i64i32imm:$src2),
509 "sub{q}\t{$src2, $dst|$dst, $src2}",
510 [(store (sub (load addr:$dst), i64immSExt32:$src2),
511 addr:$dst),
512 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000513
Evan Cheng259471d2007-10-05 17:59:57 +0000514let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000515let isTwoAddress = 1 in {
Dale Johannesen747fe522009-06-02 03:12:52 +0000516def SBB64rr : RI<0x19, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000517 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +0000518 [(set GR64:$dst, (sube GR64:$src1, GR64:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000519
Dale Johannesen747fe522009-06-02 03:12:52 +0000520def SBB64rm : RI<0x1B, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000521 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +0000522 [(set GR64:$dst, (sube GR64:$src1, (load addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000523
Dale Johannesen747fe522009-06-02 03:12:52 +0000524def SBB64ri8 : RIi8<0x83, MRM3r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000525 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +0000526 [(set GR64:$dst, (sube GR64:$src1, i64immSExt8:$src2))]>;
527def SBB64ri32 : RIi32<0x81, MRM3r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohmand16fdc02008-12-19 18:25:21 +0000528 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +0000529 [(set GR64:$dst, (sube GR64:$src1, i64immSExt32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000530} // isTwoAddress
531
Evan Chengb783fa32007-07-19 01:14:50 +0000532def SBB64mr : RI<0x19, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000533 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +0000534 [(store (sube (load addr:$dst), GR64:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000535def SBB64mi8 : RIi8<0x83, MRM3m, (outs), (ins i64mem:$dst, i64i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000536 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +0000537 [(store (sube (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000538def SBB64mi32 : RIi32<0x81, MRM3m, (outs), (ins i64mem:$dst, i64i32imm:$src2),
539 "sbb{q}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +0000540 [(store (sube (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>;
Evan Cheng259471d2007-10-05 17:59:57 +0000541} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +0000542} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000543
544// Unsigned multiplication
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000545let Defs = [RAX,RDX,EFLAGS], Uses = [RAX], neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000546def MUL64r : RI<0xF7, MRM4r, (outs), (ins GR64:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000547 "mul{q}\t$src", []>; // RAX,RDX = RAX*GR64
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000548let mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000549def MUL64m : RI<0xF7, MRM4m, (outs), (ins i64mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000550 "mul{q}\t$src", []>; // RAX,RDX = RAX*[mem64]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000551
552// Signed multiplication
Evan Chengb783fa32007-07-19 01:14:50 +0000553def IMUL64r : RI<0xF7, MRM5r, (outs), (ins GR64:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000554 "imul{q}\t$src", []>; // RAX,RDX = RAX*GR64
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000555let mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000556def IMUL64m : RI<0xF7, MRM5m, (outs), (ins i64mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000557 "imul{q}\t$src", []>; // RAX,RDX = RAX*[mem64]
558}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000559
Evan Cheng55687072007-09-14 21:48:26 +0000560let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000561let isTwoAddress = 1 in {
562let isCommutable = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000563// Register-Register Signed Integer Multiplication
Bill Wendlingae034ed2008-12-12 00:56:36 +0000564def IMUL64rr : RI<0xAF, MRMSrcReg, (outs GR64:$dst),
565 (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000566 "imul{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +0000567 [(set GR64:$dst, (mul GR64:$src1, GR64:$src2)),
568 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000569
Bill Wendlingf5399032008-12-12 21:15:41 +0000570// Register-Memory Signed Integer Multiplication
Bill Wendlingae034ed2008-12-12 00:56:36 +0000571def IMUL64rm : RI<0xAF, MRMSrcMem, (outs GR64:$dst),
572 (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000573 "imul{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +0000574 [(set GR64:$dst, (mul GR64:$src1, (load addr:$src2))),
575 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000576} // isTwoAddress
577
578// Suprisingly enough, these are not two address instructions!
Bill Wendlingae034ed2008-12-12 00:56:36 +0000579
Bill Wendlingf5399032008-12-12 21:15:41 +0000580// Register-Integer Signed Integer Multiplication
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000581def IMUL64rri8 : RIi8<0x6B, MRMSrcReg, // GR64 = GR64*I8
Evan Chengb783fa32007-07-19 01:14:50 +0000582 (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000583 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +0000584 [(set GR64:$dst, (mul GR64:$src1, i64immSExt8:$src2)),
585 (implicit EFLAGS)]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000586def IMUL64rri32 : RIi32<0x69, MRMSrcReg, // GR64 = GR64*I32
587 (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
588 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
589 [(set GR64:$dst, (mul GR64:$src1, i64immSExt32:$src2)),
590 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +0000591
Bill Wendlingf5399032008-12-12 21:15:41 +0000592// Memory-Integer Signed Integer Multiplication
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000593def IMUL64rmi8 : RIi8<0x6B, MRMSrcMem, // GR64 = [mem64]*I8
Evan Chengb783fa32007-07-19 01:14:50 +0000594 (outs GR64:$dst), (ins i64mem:$src1, i64i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000595 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +0000596 [(set GR64:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +0000597 i64immSExt8:$src2)),
598 (implicit EFLAGS)]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000599def IMUL64rmi32 : RIi32<0x69, MRMSrcMem, // GR64 = [mem64]*I32
600 (outs GR64:$dst), (ins i64mem:$src1, i64i32imm:$src2),
601 "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
602 [(set GR64:$dst, (mul (load addr:$src1),
603 i64immSExt32:$src2)),
604 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000605} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000606
607// Unsigned division / remainder
Evan Cheng55687072007-09-14 21:48:26 +0000608let Defs = [RAX,RDX,EFLAGS], Uses = [RAX,RDX] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000609def DIV64r : RI<0xF7, MRM6r, (outs), (ins GR64:$src), // RDX:RAX/r64 = RAX,RDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000610 "div{q}\t$src", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000611// Signed division / remainder
Evan Chengb783fa32007-07-19 01:14:50 +0000612def IDIV64r: RI<0xF7, MRM7r, (outs), (ins GR64:$src), // RDX:RAX/r64 = RAX,RDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000613 "idiv{q}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000614let mayLoad = 1 in {
615def DIV64m : RI<0xF7, MRM6m, (outs), (ins i64mem:$src), // RDX:RAX/[mem64] = RAX,RDX
616 "div{q}\t$src", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000617def IDIV64m: RI<0xF7, MRM7m, (outs), (ins i64mem:$src), // RDX:RAX/[mem64] = RAX,RDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000618 "idiv{q}\t$src", []>;
619}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000620}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000621
622// Unary instructions
Evan Cheng55687072007-09-14 21:48:26 +0000623let Defs = [EFLAGS], CodeSize = 2 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000624let isTwoAddress = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000625def NEG64r : RI<0xF7, MRM3r, (outs GR64:$dst), (ins GR64:$src), "neg{q}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000626 [(set GR64:$dst, (ineg GR64:$src)),
627 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000628def NEG64m : RI<0xF7, MRM3m, (outs), (ins i64mem:$dst), "neg{q}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000629 [(store (ineg (loadi64 addr:$dst)), addr:$dst),
630 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000631
632let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000633def INC64r : RI<0xFF, MRM0r, (outs GR64:$dst), (ins GR64:$src), "inc{q}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000634 [(set GR64:$dst, (add GR64:$src, 1)),
635 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000636def INC64m : RI<0xFF, MRM0m, (outs), (ins i64mem:$dst), "inc{q}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000637 [(store (add (loadi64 addr:$dst), 1), addr:$dst),
638 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000639
640let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000641def DEC64r : RI<0xFF, MRM1r, (outs GR64:$dst), (ins GR64:$src), "dec{q}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000642 [(set GR64:$dst, (add GR64:$src, -1)),
643 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000644def DEC64m : RI<0xFF, MRM1m, (outs), (ins i64mem:$dst), "dec{q}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000645 [(store (add (loadi64 addr:$dst), -1), addr:$dst),
646 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000647
648// In 64-bit mode, single byte INC and DEC cannot be encoded.
649let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in {
650// Can transform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +0000651def INC64_16r : I<0xFF, MRM0r, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000652 [(set GR16:$dst, (add GR16:$src, 1)),
653 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000654 OpSize, Requires<[In64BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000655def INC64_32r : I<0xFF, MRM0r, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000656 [(set GR32:$dst, (add GR32:$src, 1)),
657 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000658 Requires<[In64BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000659def DEC64_16r : I<0xFF, MRM1r, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000660 [(set GR16:$dst, (add GR16:$src, -1)),
661 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000662 OpSize, Requires<[In64BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000663def DEC64_32r : I<0xFF, MRM1r, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000664 [(set GR32:$dst, (add GR32:$src, -1)),
665 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000666 Requires<[In64BitMode]>;
667} // isConvertibleToThreeAddress
Evan Cheng4a7e72f2007-10-19 21:23:22 +0000668
669// These are duplicates of their 32-bit counterparts. Only needed so X86 knows
670// how to unfold them.
671let isTwoAddress = 0, CodeSize = 2 in {
672 def INC64_16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000673 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
674 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +0000675 OpSize, Requires<[In64BitMode]>;
676 def INC64_32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000677 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
678 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +0000679 Requires<[In64BitMode]>;
680 def DEC64_16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000681 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
682 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +0000683 OpSize, Requires<[In64BitMode]>;
684 def DEC64_32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000685 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
686 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +0000687 Requires<[In64BitMode]>;
688}
Evan Cheng55687072007-09-14 21:48:26 +0000689} // Defs = [EFLAGS], CodeSize
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000690
691
Evan Cheng55687072007-09-14 21:48:26 +0000692let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000693// Shift instructions
694let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000695let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000696def SHL64rCL : RI<0xD3, MRM4r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000697 "shl{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000698 [(set GR64:$dst, (shl GR64:$src, CL))]>;
Evan Chenga98f6272007-10-05 18:20:36 +0000699let isConvertibleToThreeAddress = 1 in // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +0000700def SHL64ri : RIi8<0xC1, MRM4r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000701 "shl{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000702 [(set GR64:$dst, (shl GR64:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +0000703// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
704// cheaper.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000705} // isTwoAddress
706
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000707let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000708def SHL64mCL : RI<0xD3, MRM4m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000709 "shl{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000710 [(store (shl (loadi64 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000711def SHL64mi : RIi8<0xC1, MRM4m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000712 "shl{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000713 [(store (shl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000714def SHL64m1 : RI<0xD1, MRM4m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000715 "shl{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000716 [(store (shl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
717
718let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000719let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000720def SHR64rCL : RI<0xD3, MRM5r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000721 "shr{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000722 [(set GR64:$dst, (srl GR64:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000723def SHR64ri : RIi8<0xC1, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000724 "shr{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000725 [(set GR64:$dst, (srl GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000726def SHR64r1 : RI<0xD1, MRM5r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000727 "shr{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000728 [(set GR64:$dst, (srl GR64:$src1, (i8 1)))]>;
729} // isTwoAddress
730
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000731let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000732def SHR64mCL : RI<0xD3, MRM5m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000733 "shr{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000734 [(store (srl (loadi64 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000735def SHR64mi : RIi8<0xC1, MRM5m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000736 "shr{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000737 [(store (srl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000738def SHR64m1 : RI<0xD1, MRM5m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000739 "shr{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000740 [(store (srl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
741
742let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000743let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000744def SAR64rCL : RI<0xD3, MRM7r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000745 "sar{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000746 [(set GR64:$dst, (sra GR64:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000747def SAR64ri : RIi8<0xC1, MRM7r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000748 "sar{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000749 [(set GR64:$dst, (sra GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000750def SAR64r1 : RI<0xD1, MRM7r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000751 "sar{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000752 [(set GR64:$dst, (sra GR64:$src1, (i8 1)))]>;
753} // isTwoAddress
754
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000755let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000756def SAR64mCL : RI<0xD3, MRM7m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000757 "sar{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000758 [(store (sra (loadi64 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000759def SAR64mi : RIi8<0xC1, MRM7m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000760 "sar{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000761 [(store (sra (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000762def SAR64m1 : RI<0xD1, MRM7m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000763 "sar{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000764 [(store (sra (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
765
766// Rotate instructions
767let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000768let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000769def ROL64rCL : RI<0xD3, MRM0r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000770 "rol{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000771 [(set GR64:$dst, (rotl GR64:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000772def ROL64ri : RIi8<0xC1, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000773 "rol{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000774 [(set GR64:$dst, (rotl GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000775def ROL64r1 : RI<0xD1, MRM0r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000776 "rol{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000777 [(set GR64:$dst, (rotl GR64:$src1, (i8 1)))]>;
778} // isTwoAddress
779
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000780let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000781def ROL64mCL : I<0xD3, MRM0m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000782 "rol{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000783 [(store (rotl (loadi64 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000784def ROL64mi : RIi8<0xC1, MRM0m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000785 "rol{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000786 [(store (rotl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000787def ROL64m1 : RI<0xD1, MRM0m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000788 "rol{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000789 [(store (rotl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
790
791let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000792let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000793def ROR64rCL : RI<0xD3, MRM1r, (outs GR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000794 "ror{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000795 [(set GR64:$dst, (rotr GR64:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000796def ROR64ri : RIi8<0xC1, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000797 "ror{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000798 [(set GR64:$dst, (rotr GR64:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000799def ROR64r1 : RI<0xD1, MRM1r, (outs GR64:$dst), (ins GR64:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +0000800 "ror{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000801 [(set GR64:$dst, (rotr GR64:$src1, (i8 1)))]>;
802} // isTwoAddress
803
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000804let Uses = [CL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000805def ROR64mCL : RI<0xD3, MRM1m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000806 "ror{q}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000807 [(store (rotr (loadi64 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000808def ROR64mi : RIi8<0xC1, MRM1m, (outs), (ins i64mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000809 "ror{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000810 [(store (rotr (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000811def ROR64m1 : RI<0xD1, MRM1m, (outs), (ins i64mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000812 "ror{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000813 [(store (rotr (loadi64 addr:$dst), (i8 1)), addr:$dst)]>;
814
815// Double shift instructions (generalizations of rotate)
816let isTwoAddress = 1 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000817let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000818def SHLD64rrCL : RI<0xA5, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000819 "shld{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
820 [(set GR64:$dst, (X86shld GR64:$src1, GR64:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000821def SHRD64rrCL : RI<0xAD, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000822 "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
823 [(set GR64:$dst, (X86shrd GR64:$src1, GR64:$src2, CL))]>, TB;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000824}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000825
826let isCommutable = 1 in { // FIXME: Update X86InstrInfo::commuteInstruction
827def SHLD64rri8 : RIi8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000828 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2, i8imm:$src3),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000829 "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
830 [(set GR64:$dst, (X86shld GR64:$src1, GR64:$src2,
831 (i8 imm:$src3)))]>,
832 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000833def SHRD64rri8 : RIi8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000834 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2, i8imm:$src3),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000835 "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
836 [(set GR64:$dst, (X86shrd GR64:$src1, GR64:$src2,
837 (i8 imm:$src3)))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000838 TB;
839} // isCommutable
840} // isTwoAddress
841
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000842let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000843def SHLD64mrCL : RI<0xA5, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000844 "shld{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
845 [(store (X86shld (loadi64 addr:$dst), GR64:$src2, CL),
846 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +0000847def SHRD64mrCL : RI<0xAD, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000848 "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
849 [(store (X86shrd (loadi64 addr:$dst), GR64:$src2, CL),
850 addr:$dst)]>, TB;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000851}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000852def SHLD64mri8 : RIi8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000853 (outs), (ins i64mem:$dst, GR64:$src2, i8imm:$src3),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000854 "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
855 [(store (X86shld (loadi64 addr:$dst), GR64:$src2,
856 (i8 imm:$src3)), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000857 TB;
858def SHRD64mri8 : RIi8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000859 (outs), (ins i64mem:$dst, GR64:$src2, i8imm:$src3),
Dan Gohman4d9fc4a2007-09-14 23:17:45 +0000860 "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
861 [(store (X86shrd (loadi64 addr:$dst), GR64:$src2,
862 (i8 imm:$src3)), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000863 TB;
Evan Cheng55687072007-09-14 21:48:26 +0000864} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000865
866//===----------------------------------------------------------------------===//
867// Logical Instructions...
868//
869
Evan Cheng5b51c242009-01-21 19:45:31 +0000870let isTwoAddress = 1 , AddedComplexity = 15 in
Dan Gohman91888f02007-07-31 20:11:57 +0000871def NOT64r : RI<0xF7, MRM2r, (outs GR64:$dst), (ins GR64:$src), "not{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000872 [(set GR64:$dst, (not GR64:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000873def NOT64m : RI<0xF7, MRM2m, (outs), (ins i64mem:$dst), "not{q}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000874 [(store (not (loadi64 addr:$dst)), addr:$dst)]>;
875
Evan Cheng55687072007-09-14 21:48:26 +0000876let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000877let isTwoAddress = 1 in {
878let isCommutable = 1 in
879def AND64rr : RI<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000880 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000881 "and{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000882 [(set GR64:$dst, (and GR64:$src1, GR64:$src2)),
883 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000884def AND64rm : RI<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000885 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000886 "and{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000887 [(set GR64:$dst, (and GR64:$src1, (load addr:$src2))),
888 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000889def AND64ri8 : RIi8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +0000890 (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000891 "and{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000892 [(set GR64:$dst, (and GR64:$src1, i64immSExt8:$src2)),
893 (implicit EFLAGS)]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000894def AND64ri32 : RIi32<0x81, MRM4r,
895 (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
896 "and{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000897 [(set GR64:$dst, (and GR64:$src1, i64immSExt32:$src2)),
898 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000899} // isTwoAddress
900
901def AND64mr : RI<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000902 (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000903 "and{q}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000904 [(store (and (load addr:$dst), GR64:$src), addr:$dst),
905 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000906def AND64mi8 : RIi8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +0000907 (outs), (ins i64mem:$dst, i64i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000908 "and{q}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000909 [(store (and (load addr:$dst), i64immSExt8:$src), addr:$dst),
910 (implicit EFLAGS)]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000911def AND64mi32 : RIi32<0x81, MRM4m,
912 (outs), (ins i64mem:$dst, i64i32imm:$src),
913 "and{q}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000914 [(store (and (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst),
915 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000916
917let isTwoAddress = 1 in {
918let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000919def OR64rr : RI<0x09, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000920 "or{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000921 [(set GR64:$dst, (or GR64:$src1, GR64:$src2)),
922 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000923def OR64rm : RI<0x0B, MRMSrcMem , (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000924 "or{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000925 [(set GR64:$dst, (or GR64:$src1, (load addr:$src2))),
926 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000927def OR64ri8 : RIi8<0x83, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000928 "or{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000929 [(set GR64:$dst, (or GR64:$src1, i64immSExt8:$src2)),
930 (implicit EFLAGS)]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000931def OR64ri32 : RIi32<0x81, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
932 "or{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000933 [(set GR64:$dst, (or GR64:$src1, i64immSExt32:$src2)),
934 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000935} // isTwoAddress
936
Evan Chengb783fa32007-07-19 01:14:50 +0000937def OR64mr : RI<0x09, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000938 "or{q}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000939 [(store (or (load addr:$dst), GR64:$src), addr:$dst),
940 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000941def OR64mi8 : RIi8<0x83, MRM1m, (outs), (ins i64mem:$dst, i64i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000942 "or{q}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000943 [(store (or (load addr:$dst), i64immSExt8:$src), addr:$dst),
944 (implicit EFLAGS)]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000945def OR64mi32 : RIi32<0x81, MRM1m, (outs), (ins i64mem:$dst, i64i32imm:$src),
946 "or{q}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000947 [(store (or (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst),
948 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000949
950let isTwoAddress = 1 in {
Evan Cheng0685efa2008-08-30 08:54:22 +0000951let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000952def XOR64rr : RI<0x31, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000953 "xor{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000954 [(set GR64:$dst, (xor GR64:$src1, GR64:$src2)),
955 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000956def XOR64rm : RI<0x33, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000957 "xor{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000958 [(set GR64:$dst, (xor GR64:$src1, (load addr:$src2))),
959 (implicit EFLAGS)]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000960def XOR64ri8 : RIi8<0x83, MRM6r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
961 "xor{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000962 [(set GR64:$dst, (xor GR64:$src1, i64immSExt8:$src2)),
963 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000964def XOR64ri32 : RIi32<0x81, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +0000965 (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000966 "xor{q}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000967 [(set GR64:$dst, (xor GR64:$src1, i64immSExt32:$src2)),
968 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000969} // isTwoAddress
970
Evan Chengb783fa32007-07-19 01:14:50 +0000971def XOR64mr : RI<0x31, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000972 "xor{q}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000973 [(store (xor (load addr:$dst), GR64:$src), addr:$dst),
974 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000975def XOR64mi8 : RIi8<0x83, MRM6m, (outs), (ins i64mem:$dst, i64i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000976 "xor{q}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000977 [(store (xor (load addr:$dst), i64immSExt8:$src), addr:$dst),
978 (implicit EFLAGS)]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +0000979def XOR64mi32 : RIi32<0x81, MRM6m, (outs), (ins i64mem:$dst, i64i32imm:$src),
980 "xor{q}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +0000981 [(store (xor (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst),
982 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000983} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000984
985//===----------------------------------------------------------------------===//
986// Comparison Instructions...
987//
988
989// Integer comparison
Evan Cheng55687072007-09-14 21:48:26 +0000990let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000991let isCommutable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000992def TEST64rr : RI<0x85, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000993 "test{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000994 [(X86cmp (and GR64:$src1, GR64:$src2), 0),
995 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000996def TEST64rm : RI<0x85, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000997 "test{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000998 [(X86cmp (and GR64:$src1, (loadi64 addr:$src2)), 0),
999 (implicit EFLAGS)]>;
1000def TEST64ri32 : RIi32<0xF7, MRM0r, (outs),
1001 (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001002 "test{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001003 [(X86cmp (and GR64:$src1, i64immSExt32:$src2), 0),
1004 (implicit EFLAGS)]>;
1005def TEST64mi32 : RIi32<0xF7, MRM0m, (outs),
1006 (ins i64mem:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001007 "test{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001008 [(X86cmp (and (loadi64 addr:$src1), i64immSExt32:$src2), 0),
1009 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001010
Evan Chengb783fa32007-07-19 01:14:50 +00001011def CMP64rr : RI<0x39, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001012 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001013 [(X86cmp GR64:$src1, GR64:$src2),
1014 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001015def CMP64mr : RI<0x39, MRMDestMem, (outs), (ins i64mem:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001016 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001017 [(X86cmp (loadi64 addr:$src1), GR64:$src2),
1018 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001019def CMP64rm : RI<0x3B, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001020 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001021 [(X86cmp GR64:$src1, (loadi64 addr:$src2)),
1022 (implicit EFLAGS)]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +00001023def CMP64ri8 : RIi8<0x83, MRM7r, (outs), (ins GR64:$src1, i64i8imm:$src2),
1024 "cmp{q}\t{$src2, $src1|$src1, $src2}",
1025 [(X86cmp GR64:$src1, i64immSExt8:$src2),
1026 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001027def CMP64ri32 : RIi32<0x81, MRM7r, (outs), (ins GR64:$src1, i64i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001028 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001029 [(X86cmp GR64:$src1, i64immSExt32:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00001030 (implicit EFLAGS)]>;
Evan Cheng621216e2007-09-29 00:00:36 +00001031def CMP64mi8 : RIi8<0x83, MRM7m, (outs), (ins i64mem:$src1, i64i8imm:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00001032 "cmp{q}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001033 [(X86cmp (loadi64 addr:$src1), i64immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00001034 (implicit EFLAGS)]>;
Dan Gohmand16fdc02008-12-19 18:25:21 +00001035def CMP64mi32 : RIi32<0x81, MRM7m, (outs),
1036 (ins i64mem:$src1, i64i32imm:$src2),
1037 "cmp{q}\t{$src2, $src1|$src1, $src2}",
1038 [(X86cmp (loadi64 addr:$src1), i64immSExt32:$src2),
1039 (implicit EFLAGS)]>;
Evan Cheng950aac02007-09-25 01:57:46 +00001040} // Defs = [EFLAGS]
1041
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00001042// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00001043// TODO: BTC, BTR, and BTS
1044let Defs = [EFLAGS] in {
Chris Lattner5a95cde2008-12-25 01:32:49 +00001045def BT64rr : RI<0xA3, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00001046 "bt{q}\t{$src2, $src1|$src1, $src2}",
1047 [(X86bt GR64:$src1, GR64:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00001048 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00001049
1050// Unlike with the register+register form, the memory+register form of the
1051// bt instruction does not ignore the high bits of the index. From ISel's
1052// perspective, this is pretty bizarre. Disable these instructions for now.
1053//def BT64mr : RI<0xA3, MRMDestMem, (outs), (ins i64mem:$src1, GR64:$src2),
1054// "bt{q}\t{$src2, $src1|$src1, $src2}",
1055// [(X86bt (loadi64 addr:$src1), GR64:$src2),
1056// (implicit EFLAGS)]>, TB;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00001057
1058def BT64ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR64:$src1, i64i8imm:$src2),
1059 "bt{q}\t{$src2, $src1|$src1, $src2}",
1060 [(X86bt GR64:$src1, i64immSExt8:$src2),
1061 (implicit EFLAGS)]>, TB;
1062// Note that these instructions don't need FastBTMem because that
1063// only applies when the other operand is in a register. When it's
1064// an immediate, bt is still fast.
1065def BT64mi8 : Ii8<0xBA, MRM4m, (outs), (ins i64mem:$src1, i64i8imm:$src2),
1066 "bt{q}\t{$src2, $src1|$src1, $src2}",
1067 [(X86bt (loadi64 addr:$src1), i64immSExt8:$src2),
1068 (implicit EFLAGS)]>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00001069} // Defs = [EFLAGS]
1070
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001071// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +00001072let Uses = [EFLAGS], isTwoAddress = 1 in {
Evan Cheng926658c2007-10-05 23:13:21 +00001073let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001074def CMOVB64rr : RI<0x42, MRMSrcReg, // if <u, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +00001075 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001076 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001077 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001078 X86_COND_B, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001079def CMOVAE64rr: RI<0x43, MRMSrcReg, // if >=u, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +00001080 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001081 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001082 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001083 X86_COND_AE, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001084def CMOVE64rr : RI<0x44, MRMSrcReg, // if ==, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +00001085 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001086 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001087 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001088 X86_COND_E, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001089def CMOVNE64rr: RI<0x45, MRMSrcReg, // if !=, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +00001090 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001091 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001092 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001093 X86_COND_NE, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001094def CMOVBE64rr: RI<0x46, MRMSrcReg, // if <=u, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +00001095 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001096 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001097 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001098 X86_COND_BE, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001099def CMOVA64rr : RI<0x47, MRMSrcReg, // if >u, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +00001100 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001101 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001102 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001103 X86_COND_A, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001104def CMOVL64rr : RI<0x4C, MRMSrcReg, // if <s, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +00001105 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001106 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001107 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001108 X86_COND_L, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001109def CMOVGE64rr: RI<0x4D, MRMSrcReg, // if >=s, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +00001110 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001111 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001112 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001113 X86_COND_GE, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001114def CMOVLE64rr: RI<0x4E, MRMSrcReg, // if <=s, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +00001115 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001116 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001117 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001118 X86_COND_LE, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001119def CMOVG64rr : RI<0x4F, MRMSrcReg, // if >s, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +00001120 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001121 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001122 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001123 X86_COND_G, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001124def CMOVS64rr : RI<0x48, MRMSrcReg, // if signed, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +00001125 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001126 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001127 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001128 X86_COND_S, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001129def CMOVNS64rr: RI<0x49, MRMSrcReg, // if !signed, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +00001130 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001131 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001132 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001133 X86_COND_NS, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001134def CMOVP64rr : RI<0x4A, MRMSrcReg, // if parity, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +00001135 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001136 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001137 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001138 X86_COND_P, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001139def CMOVNP64rr : RI<0x4B, MRMSrcReg, // if !parity, GR64 = GR64
Evan Chengb783fa32007-07-19 01:14:50 +00001140 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001141 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001142 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001143 X86_COND_NP, EFLAGS))]>, TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001144def CMOVO64rr : RI<0x40, MRMSrcReg, // if overflow, GR64 = GR64
1145 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
1146 "cmovo\t{$src2, $dst|$dst, $src2}",
1147 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
1148 X86_COND_O, EFLAGS))]>, TB;
1149def CMOVNO64rr : RI<0x41, MRMSrcReg, // if !overflow, GR64 = GR64
1150 (outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
1151 "cmovno\t{$src2, $dst|$dst, $src2}",
1152 [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2,
1153 X86_COND_NO, EFLAGS))]>, TB;
Evan Cheng926658c2007-10-05 23:13:21 +00001154} // isCommutable = 1
1155
1156def CMOVB64rm : RI<0x42, MRMSrcMem, // if <u, GR64 = [mem64]
1157 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1158 "cmovb\t{$src2, $dst|$dst, $src2}",
1159 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1160 X86_COND_B, EFLAGS))]>, TB;
1161def CMOVAE64rm: RI<0x43, MRMSrcMem, // if >=u, GR64 = [mem64]
1162 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1163 "cmovae\t{$src2, $dst|$dst, $src2}",
1164 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1165 X86_COND_AE, EFLAGS))]>, TB;
1166def CMOVE64rm : RI<0x44, MRMSrcMem, // if ==, GR64 = [mem64]
1167 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1168 "cmove\t{$src2, $dst|$dst, $src2}",
1169 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1170 X86_COND_E, EFLAGS))]>, TB;
1171def CMOVNE64rm: RI<0x45, MRMSrcMem, // if !=, GR64 = [mem64]
1172 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1173 "cmovne\t{$src2, $dst|$dst, $src2}",
1174 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1175 X86_COND_NE, EFLAGS))]>, TB;
1176def CMOVBE64rm: RI<0x46, MRMSrcMem, // if <=u, GR64 = [mem64]
1177 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1178 "cmovbe\t{$src2, $dst|$dst, $src2}",
1179 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1180 X86_COND_BE, EFLAGS))]>, TB;
1181def CMOVA64rm : RI<0x47, MRMSrcMem, // if >u, GR64 = [mem64]
1182 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1183 "cmova\t{$src2, $dst|$dst, $src2}",
1184 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1185 X86_COND_A, EFLAGS))]>, TB;
1186def CMOVL64rm : RI<0x4C, MRMSrcMem, // if <s, GR64 = [mem64]
1187 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1188 "cmovl\t{$src2, $dst|$dst, $src2}",
1189 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1190 X86_COND_L, EFLAGS))]>, TB;
1191def CMOVGE64rm: RI<0x4D, MRMSrcMem, // if >=s, GR64 = [mem64]
1192 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1193 "cmovge\t{$src2, $dst|$dst, $src2}",
1194 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1195 X86_COND_GE, EFLAGS))]>, TB;
1196def CMOVLE64rm: RI<0x4E, MRMSrcMem, // if <=s, GR64 = [mem64]
1197 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1198 "cmovle\t{$src2, $dst|$dst, $src2}",
1199 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1200 X86_COND_LE, EFLAGS))]>, TB;
1201def CMOVG64rm : RI<0x4F, MRMSrcMem, // if >s, GR64 = [mem64]
1202 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1203 "cmovg\t{$src2, $dst|$dst, $src2}",
1204 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1205 X86_COND_G, EFLAGS))]>, TB;
1206def CMOVS64rm : RI<0x48, MRMSrcMem, // if signed, GR64 = [mem64]
1207 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1208 "cmovs\t{$src2, $dst|$dst, $src2}",
1209 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1210 X86_COND_S, EFLAGS))]>, TB;
1211def CMOVNS64rm: RI<0x49, MRMSrcMem, // if !signed, GR64 = [mem64]
1212 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1213 "cmovns\t{$src2, $dst|$dst, $src2}",
1214 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1215 X86_COND_NS, EFLAGS))]>, TB;
1216def CMOVP64rm : RI<0x4A, MRMSrcMem, // if parity, GR64 = [mem64]
1217 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1218 "cmovp\t{$src2, $dst|$dst, $src2}",
1219 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1220 X86_COND_P, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001221def CMOVNP64rm : RI<0x4B, MRMSrcMem, // if !parity, GR64 = [mem64]
Evan Chengb783fa32007-07-19 01:14:50 +00001222 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001223 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001224 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00001225 X86_COND_NP, EFLAGS))]>, TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001226def CMOVO64rm : RI<0x40, MRMSrcMem, // if overflow, GR64 = [mem64]
1227 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1228 "cmovo\t{$src2, $dst|$dst, $src2}",
1229 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1230 X86_COND_O, EFLAGS))]>, TB;
1231def CMOVNO64rm : RI<0x41, MRMSrcMem, // if !overflow, GR64 = [mem64]
1232 (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2),
1233 "cmovno\t{$src2, $dst|$dst, $src2}",
1234 [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2),
1235 X86_COND_NO, EFLAGS))]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001236} // isTwoAddress
1237
1238//===----------------------------------------------------------------------===//
1239// Conversion Instructions...
1240//
1241
1242// f64 -> signed i64
Evan Chengb783fa32007-07-19 01:14:50 +00001243def Int_CVTSD2SI64rr: RSDI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001244 "cvtsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001245 [(set GR64:$dst,
1246 (int_x86_sse2_cvtsd2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001247def Int_CVTSD2SI64rm: RSDI<0x2D, MRMSrcMem, (outs GR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001248 "cvtsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001249 [(set GR64:$dst, (int_x86_sse2_cvtsd2si64
1250 (load addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001251def CVTTSD2SI64rr: RSDI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001252 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001253 [(set GR64:$dst, (fp_to_sint FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001254def CVTTSD2SI64rm: RSDI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001255 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001256 [(set GR64:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001257def Int_CVTTSD2SI64rr: RSDI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001258 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001259 [(set GR64:$dst,
1260 (int_x86_sse2_cvttsd2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001261def Int_CVTTSD2SI64rm: RSDI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001262 "cvttsd2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001263 [(set GR64:$dst,
1264 (int_x86_sse2_cvttsd2si64
1265 (load addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001266
1267// Signed i64 -> f64
Evan Chengb783fa32007-07-19 01:14:50 +00001268def CVTSI2SD64rr: RSDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001269 "cvtsi2sd{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001270 [(set FR64:$dst, (sint_to_fp GR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001271def CVTSI2SD64rm: RSDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001272 "cvtsi2sd{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001273 [(set FR64:$dst, (sint_to_fp (loadi64 addr:$src)))]>;
Evan Cheng1d5832e2008-01-11 07:37:44 +00001274
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001275let isTwoAddress = 1 in {
1276def Int_CVTSI2SD64rr: RSDI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001277 (outs VR128:$dst), (ins VR128:$src1, GR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001278 "cvtsi2sd{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendling6227d462007-07-23 03:07:27 +00001279 [(set VR128:$dst,
1280 (int_x86_sse2_cvtsi642sd VR128:$src1,
1281 GR64:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001282def Int_CVTSI2SD64rm: RSDI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001283 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001284 "cvtsi2sd{q}\t{$src2, $dst|$dst, $src2}",
Bill Wendling6227d462007-07-23 03:07:27 +00001285 [(set VR128:$dst,
1286 (int_x86_sse2_cvtsi642sd VR128:$src1,
1287 (loadi64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001288} // isTwoAddress
1289
1290// Signed i64 -> f32
Evan Chengb783fa32007-07-19 01:14:50 +00001291def CVTSI2SS64rr: RSSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001292 "cvtsi2ss{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001293 [(set FR32:$dst, (sint_to_fp GR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001294def CVTSI2SS64rm: RSSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001295 "cvtsi2ss{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001296 [(set FR32:$dst, (sint_to_fp (loadi64 addr:$src)))]>;
Evan Cheng1d5832e2008-01-11 07:37:44 +00001297
1298let isTwoAddress = 1 in {
1299 def Int_CVTSI2SS64rr : RSSI<0x2A, MRMSrcReg,
1300 (outs VR128:$dst), (ins VR128:$src1, GR64:$src2),
1301 "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}",
1302 [(set VR128:$dst,
1303 (int_x86_sse_cvtsi642ss VR128:$src1,
1304 GR64:$src2))]>;
1305 def Int_CVTSI2SS64rm : RSSI<0x2A, MRMSrcMem,
1306 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
1307 "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}",
1308 [(set VR128:$dst,
1309 (int_x86_sse_cvtsi642ss VR128:$src1,
1310 (loadi64 addr:$src2)))]>;
1311}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001312
1313// f32 -> signed i64
Evan Chengb783fa32007-07-19 01:14:50 +00001314def Int_CVTSS2SI64rr: RSSI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001315 "cvtss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001316 [(set GR64:$dst,
1317 (int_x86_sse_cvtss2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001318def Int_CVTSS2SI64rm: RSSI<0x2D, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001319 "cvtss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001320 [(set GR64:$dst, (int_x86_sse_cvtss2si64
1321 (load addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001322def CVTTSS2SI64rr: RSSI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001323 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001324 [(set GR64:$dst, (fp_to_sint FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001325def CVTTSS2SI64rm: RSSI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001326 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001327 [(set GR64:$dst, (fp_to_sint (loadf32 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001328def Int_CVTTSS2SI64rr: RSSI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001329 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001330 [(set GR64:$dst,
1331 (int_x86_sse_cvttss2si64 VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001332def Int_CVTTSS2SI64rm: RSSI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001333 "cvttss2si{q}\t{$src, $dst|$dst, $src}",
Bill Wendling6227d462007-07-23 03:07:27 +00001334 [(set GR64:$dst,
1335 (int_x86_sse_cvttss2si64 (load addr:$src)))]>;
1336
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001337//===----------------------------------------------------------------------===//
1338// Alias Instructions
1339//===----------------------------------------------------------------------===//
1340
Dan Gohman027cd112007-09-17 14:55:08 +00001341// Alias instructions that map movr0 to xor. Use xorl instead of xorq; it's
1342// equivalent due to implicit zero-extending, and it sometimes has a smaller
1343// encoding.
Chris Lattner17f62252009-07-14 20:19:57 +00001344// FIXME: AddedComplexity gives this a higher priority than MOV64ri32. Remove
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001345// when we have a better way to specify isel priority.
Chris Lattner17f62252009-07-14 20:19:57 +00001346let AddedComplexity = 1 in
1347def : Pat<(i64 0),
Chris Lattner3e6fe062009-07-16 06:31:37 +00001348 (SUBREG_TO_REG (i64 0), (MOV32r0), x86_subreg_32bit)>;
Chris Lattner17f62252009-07-14 20:19:57 +00001349
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001350
1351// Materialize i64 constant where top 32-bits are zero.
Evan Chengbd0ca9c2009-02-05 08:42:55 +00001352let AddedComplexity = 1, isReMaterializable = 1, isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001353def MOV64ri64i32 : Ii32<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001354 "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001355 [(set GR64:$dst, i64immZExt32:$src)]>;
1356
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +00001357//===----------------------------------------------------------------------===//
1358// Thread Local Storage Instructions
1359//===----------------------------------------------------------------------===//
1360
Rafael Espindola7fc4b8d2009-04-24 12:59:40 +00001361// All calls clobber the non-callee saved registers. RSP is marked as
1362// a use to prevent stack-pointer assignments that appear immediately
1363// before calls from potentially appearing dead.
1364let Defs = [RAX, RCX, RDX, RSI, RDI, R8, R9, R10, R11,
1365 FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0, ST1,
1366 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
1367 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
1368 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
1369 Uses = [RSP] in
Chris Lattnerf1940742009-06-20 20:38:48 +00001370def TLS_addr64 : I<0, Pseudo, (outs), (ins lea64mem:$sym),
Dan Gohman70a8a112009-04-27 15:13:28 +00001371 ".byte\t0x66; "
Chris Lattnerf1940742009-06-20 20:38:48 +00001372 "leaq\t$sym(%rip), %rdi; "
Dan Gohman70a8a112009-04-27 15:13:28 +00001373 ".word\t0x6666; "
1374 "rex64; "
1375 "call\t__tls_get_addr@PLT",
Chris Lattnerf1940742009-06-20 20:38:48 +00001376 [(X86tlsaddr tls64addr:$sym)]>,
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00001377 Requires<[In64BitMode]>;
Andrew Lenharthbd7d3262008-03-04 21:13:33 +00001378
sampo9cc09a32009-01-26 01:24:32 +00001379let AddedComplexity = 5 in
1380def MOV64GSrm : RI<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
1381 "movq\t%gs:$src, $dst",
1382 [(set GR64:$dst, (gsload addr:$src))]>, SegGS;
1383
Chris Lattnera7c2d8a2009-05-05 18:52:19 +00001384let AddedComplexity = 5 in
1385def MOV64FSrm : RI<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
1386 "movq\t%fs:$src, $dst",
1387 [(set GR64:$dst, (fsload addr:$src))]>, SegFS;
1388
Andrew Lenharthbd7d3262008-03-04 21:13:33 +00001389//===----------------------------------------------------------------------===//
1390// Atomic Instructions
1391//===----------------------------------------------------------------------===//
1392
Andrew Lenharthbd7d3262008-03-04 21:13:33 +00001393let Defs = [RAX, EFLAGS], Uses = [RAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00001394def LCMPXCHG64 : RI<0xB1, MRMDestMem, (outs), (ins i64mem:$ptr, GR64:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00001395 "lock\n\t"
1396 "cmpxchgq\t$swap,$ptr",
Andrew Lenharthbd7d3262008-03-04 21:13:33 +00001397 [(X86cas addr:$ptr, GR64:$swap, 8)]>, TB, LOCK;
1398}
1399
Dan Gohmana41a1c092008-08-06 15:52:50 +00001400let Constraints = "$val = $dst" in {
1401let Defs = [EFLAGS] in
Evan Chengd49dbb82008-04-18 20:55:36 +00001402def LXADD64 : RI<0xC1, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$ptr,GR64:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00001403 "lock\n\t"
1404 "xadd\t$val, $ptr",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00001405 [(set GR64:$dst, (atomic_load_add_64 addr:$ptr, GR64:$val))]>,
Andrew Lenharthbd7d3262008-03-04 21:13:33 +00001406 TB, LOCK;
Evan Chengb723fb52009-07-30 08:33:02 +00001407
Evan Chenga1e80602008-04-19 02:05:42 +00001408def XCHG64rm : RI<0x87, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$ptr,GR64:$val),
Bill Wendling6f189e22008-08-19 23:09:18 +00001409 "xchg\t$val, $ptr",
Evan Chenga1e80602008-04-19 02:05:42 +00001410 [(set GR64:$dst, (atomic_swap_64 addr:$ptr, GR64:$val))]>;
Andrew Lenharthbd7d3262008-03-04 21:13:33 +00001411}
1412
Evan Chengb723fb52009-07-30 08:33:02 +00001413// Optimized codegen when the non-memory output is not used.
1414// FIXME: Use normal add / sub instructions and add lock prefix dynamically.
1415def LOCK_ADD64mr : RI<0x03, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
1416 "lock\n\t"
1417 "add{q}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
1418def LOCK_ADD64mi8 : RIi8<0x83, MRM0m, (outs),
1419 (ins i64mem:$dst, i64i8imm :$src2),
1420 "lock\n\t"
1421 "add{q}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
1422def LOCK_ADD64mi32 : RIi32<0x81, MRM0m, (outs),
1423 (ins i64mem:$dst, i64i32imm :$src2),
1424 "lock\n\t"
1425 "add{q}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
1426def LOCK_SUB64mr : RI<0x29, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
1427 "lock\n\t"
1428 "sub{q}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
1429def LOCK_SUB64mi8 : RIi8<0x83, MRM5m, (outs),
1430 (ins i64mem:$dst, i64i8imm :$src2),
1431 "lock\n\t"
1432 "sub{q}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
1433def LOCK_SUB64mi32 : RIi32<0x81, MRM5m, (outs),
1434 (ins i64mem:$dst, i64i32imm:$src2),
1435 "lock\n\t"
1436 "sub{q}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
1437def LOCK_INC64m : RI<0xFF, MRM0m, (outs), (ins i64mem:$dst),
1438 "lock\n\t"
1439 "inc{q}\t$dst", []>, LOCK;
1440def LOCK_DEC64m : RI<0xFF, MRM1m, (outs), (ins i64mem:$dst),
1441 "lock\n\t"
1442 "dec{q}\t$dst", []>, LOCK;
1443
Dale Johannesen6b60eca2008-08-20 00:48:50 +00001444// Atomic exchange, and, or, xor
1445let Constraints = "$val = $dst", Defs = [EFLAGS],
1446 usesCustomDAGSchedInserter = 1 in {
1447def ATOMAND64 : I<0, Pseudo, (outs GR64:$dst),(ins i64mem:$ptr, GR64:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00001448 "#ATOMAND64 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00001449 [(set GR64:$dst, (atomic_load_and_64 addr:$ptr, GR64:$val))]>;
Dale Johannesen6b60eca2008-08-20 00:48:50 +00001450def ATOMOR64 : I<0, Pseudo, (outs GR64:$dst),(ins i64mem:$ptr, GR64:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00001451 "#ATOMOR64 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00001452 [(set GR64:$dst, (atomic_load_or_64 addr:$ptr, GR64:$val))]>;
Dale Johannesen6b60eca2008-08-20 00:48:50 +00001453def ATOMXOR64 : I<0, Pseudo,(outs GR64:$dst),(ins i64mem:$ptr, GR64:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00001454 "#ATOMXOR64 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00001455 [(set GR64:$dst, (atomic_load_xor_64 addr:$ptr, GR64:$val))]>;
Dale Johannesen6b60eca2008-08-20 00:48:50 +00001456def ATOMNAND64 : I<0, Pseudo,(outs GR64:$dst),(ins i64mem:$ptr, GR64:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00001457 "#ATOMNAND64 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00001458 [(set GR64:$dst, (atomic_load_nand_64 addr:$ptr, GR64:$val))]>;
Dale Johannesen6b60eca2008-08-20 00:48:50 +00001459def ATOMMIN64: I<0, Pseudo, (outs GR64:$dst), (ins i64mem:$ptr, GR64:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00001460 "#ATOMMIN64 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00001461 [(set GR64:$dst, (atomic_load_min_64 addr:$ptr, GR64:$val))]>;
Dale Johannesen6b60eca2008-08-20 00:48:50 +00001462def ATOMMAX64: I<0, Pseudo, (outs GR64:$dst),(ins i64mem:$ptr, GR64:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00001463 "#ATOMMAX64 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00001464 [(set GR64:$dst, (atomic_load_max_64 addr:$ptr, GR64:$val))]>;
Dale Johannesen6b60eca2008-08-20 00:48:50 +00001465def ATOMUMIN64: I<0, Pseudo, (outs GR64:$dst),(ins i64mem:$ptr, GR64:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00001466 "#ATOMUMIN64 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00001467 [(set GR64:$dst, (atomic_load_umin_64 addr:$ptr, GR64:$val))]>;
Dale Johannesen6b60eca2008-08-20 00:48:50 +00001468def ATOMUMAX64: I<0, Pseudo, (outs GR64:$dst),(ins i64mem:$ptr, GR64:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00001469 "#ATOMUMAX64 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00001470 [(set GR64:$dst, (atomic_load_umax_64 addr:$ptr, GR64:$val))]>;
Dale Johannesen6b60eca2008-08-20 00:48:50 +00001471}
Andrew Lenharthbd7d3262008-03-04 21:13:33 +00001472
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001473//===----------------------------------------------------------------------===//
1474// Non-Instruction Patterns
1475//===----------------------------------------------------------------------===//
1476
Chris Lattner0d2dad62009-07-11 22:50:33 +00001477// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable when not in small
1478// code model mode, should use 'movabs'. FIXME: This is really a hack, the
1479// 'movabs' predicate should handle this sort of thing.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001480def : Pat<(i64 (X86Wrapper tconstpool :$dst)),
1481 (MOV64ri tconstpool :$dst)>, Requires<[NotSmallCode]>;
1482def : Pat<(i64 (X86Wrapper tjumptable :$dst)),
1483 (MOV64ri tjumptable :$dst)>, Requires<[NotSmallCode]>;
1484def : Pat<(i64 (X86Wrapper tglobaladdr :$dst)),
1485 (MOV64ri tglobaladdr :$dst)>, Requires<[NotSmallCode]>;
1486def : Pat<(i64 (X86Wrapper texternalsym:$dst)),
1487 (MOV64ri texternalsym:$dst)>, Requires<[NotSmallCode]>;
1488
Chris Lattnerc04cd042009-07-11 23:17:29 +00001489// In static codegen with small code model, we can get the address of a label
1490// into a register with 'movl'. FIXME: This is a hack, the 'imm' predicate of
1491// the MOV64ri64i32 should accept these.
1492def : Pat<(i64 (X86Wrapper tconstpool :$dst)),
1493 (MOV64ri64i32 tconstpool :$dst)>, Requires<[SmallCode]>;
1494def : Pat<(i64 (X86Wrapper tjumptable :$dst)),
1495 (MOV64ri64i32 tjumptable :$dst)>, Requires<[SmallCode]>;
1496def : Pat<(i64 (X86Wrapper tglobaladdr :$dst)),
1497 (MOV64ri64i32 tglobaladdr :$dst)>, Requires<[SmallCode]>;
1498def : Pat<(i64 (X86Wrapper texternalsym:$dst)),
1499 (MOV64ri64i32 texternalsym:$dst)>, Requires<[SmallCode]>;
1500
1501
Chris Lattnerdc6fc472009-06-27 04:16:01 +00001502// If we have small model and -static mode, it is safe to store global addresses
1503// directly as immediates. FIXME: This is really a hack, the 'imm' predicate
Chris Lattner0d2dad62009-07-11 22:50:33 +00001504// for MOV64mi32 should handle this sort of thing.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001505def : Pat<(store (i64 (X86Wrapper tconstpool:$src)), addr:$dst),
1506 (MOV64mi32 addr:$dst, tconstpool:$src)>,
Dan Gohmanb36f9f82009-06-03 00:37:20 +00001507 Requires<[SmallCode, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001508def : Pat<(store (i64 (X86Wrapper tjumptable:$src)), addr:$dst),
1509 (MOV64mi32 addr:$dst, tjumptable:$src)>,
Dan Gohmanb36f9f82009-06-03 00:37:20 +00001510 Requires<[SmallCode, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001511def : Pat<(store (i64 (X86Wrapper tglobaladdr:$src)), addr:$dst),
1512 (MOV64mi32 addr:$dst, tglobaladdr:$src)>,
Dan Gohmanb36f9f82009-06-03 00:37:20 +00001513 Requires<[SmallCode, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001514def : Pat<(store (i64 (X86Wrapper texternalsym:$src)), addr:$dst),
1515 (MOV64mi32 addr:$dst, texternalsym:$src)>,
Dan Gohmanb36f9f82009-06-03 00:37:20 +00001516 Requires<[SmallCode, IsStatic]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001517
1518// Calls
1519// Direct PC relative function call for small code model. 32-bit displacement
1520// sign extended to 64-bit.
1521def : Pat<(X86call (i64 tglobaladdr:$dst)),
Anton Korobeynikov2cbcdb72009-08-03 08:12:53 +00001522 (CALL64pcrel32 tglobaladdr:$dst)>, Requires<[NotWin64]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001523def : Pat<(X86call (i64 texternalsym:$dst)),
Anton Korobeynikov2cbcdb72009-08-03 08:12:53 +00001524 (CALL64pcrel32 texternalsym:$dst)>, Requires<[NotWin64]>;
1525
1526def : Pat<(X86call (i64 tglobaladdr:$dst)),
1527 (WINCALL64pcrel32 tglobaladdr:$dst)>, Requires<[IsWin64]>;
1528def : Pat<(X86call (i64 texternalsym:$dst)),
1529 (WINCALL64pcrel32 texternalsym:$dst)>, Requires<[IsWin64]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001530
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00001531// tailcall stuff
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00001532def : Pat<(X86tcret GR64:$dst, imm:$off),
1533 (TCRETURNri64 GR64:$dst, imm:$off)>;
1534
1535def : Pat<(X86tcret (i64 tglobaladdr:$dst), imm:$off),
1536 (TCRETURNdi64 texternalsym:$dst, imm:$off)>;
1537
1538def : Pat<(X86tcret (i64 texternalsym:$dst), imm:$off),
1539 (TCRETURNdi64 texternalsym:$dst, imm:$off)>;
1540
Dan Gohmanec596042007-09-17 14:35:24 +00001541// Comparisons.
1542
1543// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00001544def : Pat<(parallel (X86cmp GR64:$src1, 0), (implicit EFLAGS)),
Dan Gohmanec596042007-09-17 14:35:24 +00001545 (TEST64rr GR64:$src1, GR64:$src1)>;
1546
Dan Gohman0a3c5222009-01-07 01:00:24 +00001547// Conditional moves with folded loads with operands swapped and conditions
1548// inverted.
1549def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_B, EFLAGS),
1550 (CMOVAE64rm GR64:$src2, addr:$src1)>;
1551def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_AE, EFLAGS),
1552 (CMOVB64rm GR64:$src2, addr:$src1)>;
1553def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_E, EFLAGS),
1554 (CMOVNE64rm GR64:$src2, addr:$src1)>;
1555def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_NE, EFLAGS),
1556 (CMOVE64rm GR64:$src2, addr:$src1)>;
1557def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_BE, EFLAGS),
1558 (CMOVA64rm GR64:$src2, addr:$src1)>;
1559def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_A, EFLAGS),
1560 (CMOVBE64rm GR64:$src2, addr:$src1)>;
1561def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_L, EFLAGS),
1562 (CMOVGE64rm GR64:$src2, addr:$src1)>;
1563def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_GE, EFLAGS),
1564 (CMOVL64rm GR64:$src2, addr:$src1)>;
1565def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_LE, EFLAGS),
1566 (CMOVG64rm GR64:$src2, addr:$src1)>;
1567def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_G, EFLAGS),
1568 (CMOVLE64rm GR64:$src2, addr:$src1)>;
1569def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_P, EFLAGS),
1570 (CMOVNP64rm GR64:$src2, addr:$src1)>;
1571def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_NP, EFLAGS),
1572 (CMOVP64rm GR64:$src2, addr:$src1)>;
1573def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_S, EFLAGS),
1574 (CMOVNS64rm GR64:$src2, addr:$src1)>;
1575def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_NS, EFLAGS),
1576 (CMOVS64rm GR64:$src2, addr:$src1)>;
1577def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_O, EFLAGS),
1578 (CMOVNO64rm GR64:$src2, addr:$src1)>;
1579def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_NO, EFLAGS),
1580 (CMOVO64rm GR64:$src2, addr:$src1)>;
Christopher Lambb371e032008-03-13 05:47:01 +00001581
Duncan Sands082524c2008-01-23 20:39:46 +00001582// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001583def : Pat<(zextloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>;
1584
1585// extload
Dan Gohmanab460da2008-08-27 17:33:15 +00001586// When extloading from 16-bit and smaller memory locations into 64-bit registers,
1587// use zero-extending loads so that the entire 64-bit register is defined, avoiding
1588// partial-register updates.
1589def : Pat<(extloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>;
1590def : Pat<(extloadi64i8 addr:$src), (MOVZX64rm8 addr:$src)>;
1591def : Pat<(extloadi64i16 addr:$src), (MOVZX64rm16 addr:$src)>;
1592// For other extloads, use subregs, since the high contents of the register are
1593// defined after an extload.
Dan Gohmandd612bb2008-08-20 21:27:32 +00001594def : Pat<(extloadi64i32 addr:$src),
1595 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (MOV32rm addr:$src),
1596 x86_subreg_32bit)>;
1597def : Pat<(extloadi16i1 addr:$src),
1598 (INSERT_SUBREG (i16 (IMPLICIT_DEF)), (MOV8rm addr:$src),
1599 x86_subreg_8bit)>,
1600 Requires<[In64BitMode]>;
1601def : Pat<(extloadi16i8 addr:$src),
1602 (INSERT_SUBREG (i16 (IMPLICIT_DEF)), (MOV8rm addr:$src),
1603 x86_subreg_8bit)>,
1604 Requires<[In64BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001605
Dan Gohmandd612bb2008-08-20 21:27:32 +00001606// anyext
1607def : Pat<(i64 (anyext GR8:$src)),
1608 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GR8:$src, x86_subreg_8bit)>;
1609def : Pat<(i64 (anyext GR16:$src)),
1610 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Christopher Lamb76d72da2008-03-16 03:12:01 +00001611def : Pat<(i64 (anyext GR32:$src)),
1612 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GR32:$src, x86_subreg_32bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00001613def : Pat<(i16 (anyext GR8:$src)),
1614 (INSERT_SUBREG (i16 (IMPLICIT_DEF)), GR8:$src, x86_subreg_8bit)>,
1615 Requires<[In64BitMode]>;
1616def : Pat<(i32 (anyext GR8:$src)),
1617 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR8:$src, x86_subreg_8bit)>,
1618 Requires<[In64BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001619
1620//===----------------------------------------------------------------------===//
1621// Some peepholes
1622//===----------------------------------------------------------------------===//
1623
Dan Gohman5a5e6e92008-10-17 01:33:43 +00001624// Odd encoding trick: -128 fits into an 8-bit immediate field while
1625// +128 doesn't, so in this special case use a sub instead of an add.
1626def : Pat<(add GR64:$src1, 128),
1627 (SUB64ri8 GR64:$src1, -128)>;
1628def : Pat<(store (add (loadi64 addr:$dst), 128), addr:$dst),
1629 (SUB64mi8 addr:$dst, -128)>;
1630
1631// The same trick applies for 32-bit immediate fields in 64-bit
1632// instructions.
1633def : Pat<(add GR64:$src1, 0x0000000080000000),
1634 (SUB64ri32 GR64:$src1, 0xffffffff80000000)>;
1635def : Pat<(store (add (loadi64 addr:$dst), 0x00000000800000000), addr:$dst),
1636 (SUB64mi32 addr:$dst, 0xffffffff80000000)>;
1637
Dan Gohman47a419d2008-08-07 02:54:50 +00001638// r & (2^32-1) ==> movz
Dan Gohman5a5e6e92008-10-17 01:33:43 +00001639def : Pat<(and GR64:$src, 0x00000000FFFFFFFF),
Dan Gohman744d4622009-04-13 16:09:41 +00001640 (MOVZX64rr32 (EXTRACT_SUBREG GR64:$src, x86_subreg_32bit))>;
Dan Gohman9203ab42008-07-30 18:09:17 +00001641// r & (2^16-1) ==> movz
1642def : Pat<(and GR64:$src, 0xffff),
1643 (MOVZX64rr16 (i16 (EXTRACT_SUBREG GR64:$src, x86_subreg_16bit)))>;
1644// r & (2^8-1) ==> movz
1645def : Pat<(and GR64:$src, 0xff),
1646 (MOVZX64rr8 (i8 (EXTRACT_SUBREG GR64:$src, x86_subreg_8bit)))>;
Dan Gohman9203ab42008-07-30 18:09:17 +00001647// r & (2^8-1) ==> movz
1648def : Pat<(and GR32:$src1, 0xff),
Dan Gohman744d4622009-04-13 16:09:41 +00001649 (MOVZX32rr8 (EXTRACT_SUBREG GR32:$src1, x86_subreg_8bit))>,
Dan Gohman9203ab42008-07-30 18:09:17 +00001650 Requires<[In64BitMode]>;
1651// r & (2^8-1) ==> movz
1652def : Pat<(and GR16:$src1, 0xff),
1653 (MOVZX16rr8 (i8 (EXTRACT_SUBREG GR16:$src1, x86_subreg_8bit)))>,
1654 Requires<[In64BitMode]>;
Christopher Lambb371e032008-03-13 05:47:01 +00001655
Dan Gohmandd612bb2008-08-20 21:27:32 +00001656// sext_inreg patterns
1657def : Pat<(sext_inreg GR64:$src, i32),
Dan Gohman744d4622009-04-13 16:09:41 +00001658 (MOVSX64rr32 (EXTRACT_SUBREG GR64:$src, x86_subreg_32bit))>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00001659def : Pat<(sext_inreg GR64:$src, i16),
Dan Gohman744d4622009-04-13 16:09:41 +00001660 (MOVSX64rr16 (EXTRACT_SUBREG GR64:$src, x86_subreg_16bit))>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00001661def : Pat<(sext_inreg GR64:$src, i8),
Dan Gohman744d4622009-04-13 16:09:41 +00001662 (MOVSX64rr8 (EXTRACT_SUBREG GR64:$src, x86_subreg_8bit))>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00001663def : Pat<(sext_inreg GR32:$src, i8),
Dan Gohman744d4622009-04-13 16:09:41 +00001664 (MOVSX32rr8 (EXTRACT_SUBREG GR32:$src, x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00001665 Requires<[In64BitMode]>;
1666def : Pat<(sext_inreg GR16:$src, i8),
1667 (MOVSX16rr8 (i8 (EXTRACT_SUBREG GR16:$src, x86_subreg_8bit)))>,
1668 Requires<[In64BitMode]>;
1669
1670// trunc patterns
1671def : Pat<(i32 (trunc GR64:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00001672 (EXTRACT_SUBREG GR64:$src, x86_subreg_32bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00001673def : Pat<(i16 (trunc GR64:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00001674 (EXTRACT_SUBREG GR64:$src, x86_subreg_16bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00001675def : Pat<(i8 (trunc GR64:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00001676 (EXTRACT_SUBREG GR64:$src, x86_subreg_8bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00001677def : Pat<(i8 (trunc GR32:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00001678 (EXTRACT_SUBREG GR32:$src, x86_subreg_8bit)>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00001679 Requires<[In64BitMode]>;
1680def : Pat<(i8 (trunc GR16:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00001681 (EXTRACT_SUBREG GR16:$src, x86_subreg_8bit)>,
1682 Requires<[In64BitMode]>;
1683
1684// h-register tricks.
Dan Gohman3aa0b182009-05-31 17:52:18 +00001685// For now, be conservative on x86-64 and use an h-register extract only if the
1686// value is immediately zero-extended or stored, which are somewhat common
1687// cases. This uses a bunch of code to prevent a register requiring a REX prefix
1688// from being allocated in the same instruction as the h register, as there's
1689// currently no way to describe this requirement to the register allocator.
Dan Gohman744d4622009-04-13 16:09:41 +00001690
1691// h-register extract and zero-extend.
1692def : Pat<(and (srl_su GR64:$src, (i8 8)), (i64 255)),
1693 (SUBREG_TO_REG
1694 (i64 0),
1695 (MOVZX32_NOREXrr8
Dan Gohman6e438702009-04-27 16:33:14 +00001696 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR64:$src, GR64_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00001697 x86_subreg_8bit_hi)),
1698 x86_subreg_32bit)>;
1699def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
1700 (MOVZX32_NOREXrr8
Dan Gohman6e438702009-04-27 16:33:14 +00001701 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00001702 x86_subreg_8bit_hi))>,
1703 Requires<[In64BitMode]>;
1704def : Pat<(srl_su GR16:$src, (i8 8)),
1705 (EXTRACT_SUBREG
1706 (MOVZX32_NOREXrr8
Dan Gohman6e438702009-04-27 16:33:14 +00001707 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00001708 x86_subreg_8bit_hi)),
1709 x86_subreg_16bit)>,
1710 Requires<[In64BitMode]>;
Evan Cheng957ca282009-05-29 01:44:43 +00001711def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
1712 (MOVZX32_NOREXrr8
1713 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
1714 x86_subreg_8bit_hi))>,
1715 Requires<[In64BitMode]>;
1716def : Pat<(i64 (zext (srl_su GR16:$src, (i8 8)))),
1717 (SUBREG_TO_REG
1718 (i64 0),
1719 (MOVZX32_NOREXrr8
1720 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
1721 x86_subreg_8bit_hi)),
1722 x86_subreg_32bit)>;
Dan Gohman744d4622009-04-13 16:09:41 +00001723
1724// h-register extract and store.
1725def : Pat<(store (i8 (trunc_su (srl_su GR64:$src, (i8 8)))), addr:$dst),
1726 (MOV8mr_NOREX
1727 addr:$dst,
Dan Gohman6e438702009-04-27 16:33:14 +00001728 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR64:$src, GR64_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00001729 x86_subreg_8bit_hi))>;
1730def : Pat<(store (i8 (trunc_su (srl_su GR32:$src, (i8 8)))), addr:$dst),
1731 (MOV8mr_NOREX
1732 addr:$dst,
Dan Gohman6e438702009-04-27 16:33:14 +00001733 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00001734 x86_subreg_8bit_hi))>,
1735 Requires<[In64BitMode]>;
1736def : Pat<(store (i8 (trunc_su (srl_su GR16:$src, (i8 8)))), addr:$dst),
1737 (MOV8mr_NOREX
1738 addr:$dst,
Dan Gohman6e438702009-04-27 16:33:14 +00001739 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00001740 x86_subreg_8bit_hi))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00001741 Requires<[In64BitMode]>;
1742
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001743// (shl x, 1) ==> (add x, x)
1744def : Pat<(shl GR64:$src1, (i8 1)), (ADD64rr GR64:$src1, GR64:$src1)>;
1745
Evan Cheng76a64c72008-08-30 02:03:58 +00001746// (shl x (and y, 63)) ==> (shl x, y)
1747def : Pat<(shl GR64:$src1, (and CL:$amt, 63)),
1748 (SHL64rCL GR64:$src1)>;
1749def : Pat<(store (shl (loadi64 addr:$dst), (and CL:$amt, 63)), addr:$dst),
1750 (SHL64mCL addr:$dst)>;
1751
1752def : Pat<(srl GR64:$src1, (and CL:$amt, 63)),
1753 (SHR64rCL GR64:$src1)>;
1754def : Pat<(store (srl (loadi64 addr:$dst), (and CL:$amt, 63)), addr:$dst),
1755 (SHR64mCL addr:$dst)>;
1756
1757def : Pat<(sra GR64:$src1, (and CL:$amt, 63)),
1758 (SAR64rCL GR64:$src1)>;
1759def : Pat<(store (sra (loadi64 addr:$dst), (and CL:$amt, 63)), addr:$dst),
1760 (SAR64mCL addr:$dst)>;
1761
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001762// (or (x >> c) | (y << (64 - c))) ==> (shrd64 x, y, c)
1763def : Pat<(or (srl GR64:$src1, CL:$amt),
1764 (shl GR64:$src2, (sub 64, CL:$amt))),
1765 (SHRD64rrCL GR64:$src1, GR64:$src2)>;
1766
1767def : Pat<(store (or (srl (loadi64 addr:$dst), CL:$amt),
1768 (shl GR64:$src2, (sub 64, CL:$amt))), addr:$dst),
1769 (SHRD64mrCL addr:$dst, GR64:$src2)>;
1770
Dan Gohman921581d2008-10-17 01:23:35 +00001771def : Pat<(or (srl GR64:$src1, (i8 (trunc RCX:$amt))),
1772 (shl GR64:$src2, (i8 (trunc (sub 64, RCX:$amt))))),
1773 (SHRD64rrCL GR64:$src1, GR64:$src2)>;
1774
1775def : Pat<(store (or (srl (loadi64 addr:$dst), (i8 (trunc RCX:$amt))),
1776 (shl GR64:$src2, (i8 (trunc (sub 64, RCX:$amt))))),
1777 addr:$dst),
1778 (SHRD64mrCL addr:$dst, GR64:$src2)>;
1779
1780def : Pat<(shrd GR64:$src1, (i8 imm:$amt1), GR64:$src2, (i8 imm:$amt2)),
1781 (SHRD64rri8 GR64:$src1, GR64:$src2, (i8 imm:$amt1))>;
1782
1783def : Pat<(store (shrd (loadi64 addr:$dst), (i8 imm:$amt1),
1784 GR64:$src2, (i8 imm:$amt2)), addr:$dst),
1785 (SHRD64mri8 addr:$dst, GR64:$src2, (i8 imm:$amt1))>;
1786
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001787// (or (x << c) | (y >> (64 - c))) ==> (shld64 x, y, c)
1788def : Pat<(or (shl GR64:$src1, CL:$amt),
1789 (srl GR64:$src2, (sub 64, CL:$amt))),
1790 (SHLD64rrCL GR64:$src1, GR64:$src2)>;
1791
1792def : Pat<(store (or (shl (loadi64 addr:$dst), CL:$amt),
1793 (srl GR64:$src2, (sub 64, CL:$amt))), addr:$dst),
1794 (SHLD64mrCL addr:$dst, GR64:$src2)>;
1795
Dan Gohman921581d2008-10-17 01:23:35 +00001796def : Pat<(or (shl GR64:$src1, (i8 (trunc RCX:$amt))),
1797 (srl GR64:$src2, (i8 (trunc (sub 64, RCX:$amt))))),
1798 (SHLD64rrCL GR64:$src1, GR64:$src2)>;
1799
1800def : Pat<(store (or (shl (loadi64 addr:$dst), (i8 (trunc RCX:$amt))),
1801 (srl GR64:$src2, (i8 (trunc (sub 64, RCX:$amt))))),
1802 addr:$dst),
1803 (SHLD64mrCL addr:$dst, GR64:$src2)>;
1804
1805def : Pat<(shld GR64:$src1, (i8 imm:$amt1), GR64:$src2, (i8 imm:$amt2)),
1806 (SHLD64rri8 GR64:$src1, GR64:$src2, (i8 imm:$amt1))>;
1807
1808def : Pat<(store (shld (loadi64 addr:$dst), (i8 imm:$amt1),
1809 GR64:$src2, (i8 imm:$amt2)), addr:$dst),
1810 (SHLD64mri8 addr:$dst, GR64:$src2, (i8 imm:$amt1))>;
1811
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001812// X86 specific add which produces a flag.
1813def : Pat<(addc GR64:$src1, GR64:$src2),
1814 (ADD64rr GR64:$src1, GR64:$src2)>;
1815def : Pat<(addc GR64:$src1, (load addr:$src2)),
1816 (ADD64rm GR64:$src1, addr:$src2)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001817def : Pat<(addc GR64:$src1, i64immSExt8:$src2),
1818 (ADD64ri8 GR64:$src1, i64immSExt8:$src2)>;
Dan Gohmand16fdc02008-12-19 18:25:21 +00001819def : Pat<(addc GR64:$src1, i64immSExt32:$src2),
1820 (ADD64ri32 GR64:$src1, imm:$src2)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001821
1822def : Pat<(subc GR64:$src1, GR64:$src2),
1823 (SUB64rr GR64:$src1, GR64:$src2)>;
1824def : Pat<(subc GR64:$src1, (load addr:$src2)),
1825 (SUB64rm GR64:$src1, addr:$src2)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001826def : Pat<(subc GR64:$src1, i64immSExt8:$src2),
1827 (SUB64ri8 GR64:$src1, i64immSExt8:$src2)>;
Dan Gohmand16fdc02008-12-19 18:25:21 +00001828def : Pat<(subc GR64:$src1, imm:$src2),
1829 (SUB64ri32 GR64:$src1, i64immSExt32:$src2)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001830
Bill Wendlingf5399032008-12-12 21:15:41 +00001831//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00001832// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00001833//===----------------------------------------------------------------------===//
1834
Dan Gohman99a12192009-03-04 19:44:21 +00001835// Register-Register Addition with EFLAGS result
1836def : Pat<(parallel (X86add_flag GR64:$src1, GR64:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00001837 (implicit EFLAGS)),
1838 (ADD64rr GR64:$src1, GR64:$src2)>;
1839
Dan Gohman99a12192009-03-04 19:44:21 +00001840// Register-Integer Addition with EFLAGS result
1841def : Pat<(parallel (X86add_flag GR64:$src1, i64immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00001842 (implicit EFLAGS)),
1843 (ADD64ri8 GR64:$src1, i64immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00001844def : Pat<(parallel (X86add_flag GR64:$src1, i64immSExt32:$src2),
Dan Gohmand16fdc02008-12-19 18:25:21 +00001845 (implicit EFLAGS)),
1846 (ADD64ri32 GR64:$src1, i64immSExt32:$src2)>;
Bill Wendlingf5399032008-12-12 21:15:41 +00001847
Dan Gohman99a12192009-03-04 19:44:21 +00001848// Register-Memory Addition with EFLAGS result
1849def : Pat<(parallel (X86add_flag GR64:$src1, (loadi64 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00001850 (implicit EFLAGS)),
1851 (ADD64rm GR64:$src1, addr:$src2)>;
1852
Dan Gohman99a12192009-03-04 19:44:21 +00001853// Memory-Register Addition with EFLAGS result
1854def : Pat<(parallel (store (X86add_flag (loadi64 addr:$dst), GR64:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00001855 addr:$dst),
1856 (implicit EFLAGS)),
1857 (ADD64mr addr:$dst, GR64:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00001858def : Pat<(parallel (store (X86add_flag (loadi64 addr:$dst), i64immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00001859 addr:$dst),
1860 (implicit EFLAGS)),
1861 (ADD64mi8 addr:$dst, i64immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00001862def : Pat<(parallel (store (X86add_flag (loadi64 addr:$dst), i64immSExt32:$src2),
Dan Gohmand16fdc02008-12-19 18:25:21 +00001863 addr:$dst),
1864 (implicit EFLAGS)),
1865 (ADD64mi32 addr:$dst, i64immSExt32:$src2)>;
Bill Wendlingf5399032008-12-12 21:15:41 +00001866
Dan Gohman99a12192009-03-04 19:44:21 +00001867// Register-Register Subtraction with EFLAGS result
1868def : Pat<(parallel (X86sub_flag GR64:$src1, GR64:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00001869 (implicit EFLAGS)),
1870 (SUB64rr GR64:$src1, GR64:$src2)>;
1871
Dan Gohman99a12192009-03-04 19:44:21 +00001872// Register-Memory Subtraction with EFLAGS result
1873def : Pat<(parallel (X86sub_flag GR64:$src1, (loadi64 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00001874 (implicit EFLAGS)),
1875 (SUB64rm GR64:$src1, addr:$src2)>;
1876
Dan Gohman99a12192009-03-04 19:44:21 +00001877// Register-Integer Subtraction with EFLAGS result
1878def : Pat<(parallel (X86sub_flag GR64:$src1, i64immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00001879 (implicit EFLAGS)),
1880 (SUB64ri8 GR64:$src1, i64immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00001881def : Pat<(parallel (X86sub_flag GR64:$src1, i64immSExt32:$src2),
Dan Gohmand16fdc02008-12-19 18:25:21 +00001882 (implicit EFLAGS)),
1883 (SUB64ri32 GR64:$src1, i64immSExt32:$src2)>;
Bill Wendlingf5399032008-12-12 21:15:41 +00001884
Dan Gohman99a12192009-03-04 19:44:21 +00001885// Memory-Register Subtraction with EFLAGS result
1886def : Pat<(parallel (store (X86sub_flag (loadi64 addr:$dst), GR64:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00001887 addr:$dst),
1888 (implicit EFLAGS)),
1889 (SUB64mr addr:$dst, GR64:$src2)>;
1890
Dan Gohman99a12192009-03-04 19:44:21 +00001891// Memory-Integer Subtraction with EFLAGS result
1892def : Pat<(parallel (store (X86sub_flag (loadi64 addr:$dst), i64immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00001893 addr:$dst),
1894 (implicit EFLAGS)),
1895 (SUB64mi8 addr:$dst, i64immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00001896def : Pat<(parallel (store (X86sub_flag (loadi64 addr:$dst), i64immSExt32:$src2),
Dan Gohmand16fdc02008-12-19 18:25:21 +00001897 addr:$dst),
1898 (implicit EFLAGS)),
1899 (SUB64mi32 addr:$dst, i64immSExt32:$src2)>;
Bill Wendlingf5399032008-12-12 21:15:41 +00001900
Dan Gohman99a12192009-03-04 19:44:21 +00001901// Register-Register Signed Integer Multiplication with EFLAGS result
1902def : Pat<(parallel (X86smul_flag GR64:$src1, GR64:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00001903 (implicit EFLAGS)),
1904 (IMUL64rr GR64:$src1, GR64:$src2)>;
1905
Dan Gohman99a12192009-03-04 19:44:21 +00001906// Register-Memory Signed Integer Multiplication with EFLAGS result
1907def : Pat<(parallel (X86smul_flag GR64:$src1, (loadi64 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00001908 (implicit EFLAGS)),
1909 (IMUL64rm GR64:$src1, addr:$src2)>;
1910
Dan Gohman99a12192009-03-04 19:44:21 +00001911// Register-Integer Signed Integer Multiplication with EFLAGS result
1912def : Pat<(parallel (X86smul_flag GR64:$src1, i64immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00001913 (implicit EFLAGS)),
1914 (IMUL64rri8 GR64:$src1, i64immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00001915def : Pat<(parallel (X86smul_flag GR64:$src1, i64immSExt32:$src2),
Dan Gohmand16fdc02008-12-19 18:25:21 +00001916 (implicit EFLAGS)),
1917 (IMUL64rri32 GR64:$src1, i64immSExt32:$src2)>;
Bill Wendlingf5399032008-12-12 21:15:41 +00001918
Dan Gohman99a12192009-03-04 19:44:21 +00001919// Memory-Integer Signed Integer Multiplication with EFLAGS result
1920def : Pat<(parallel (X86smul_flag (loadi64 addr:$src1), i64immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00001921 (implicit EFLAGS)),
1922 (IMUL64rmi8 addr:$src1, i64immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00001923def : Pat<(parallel (X86smul_flag (loadi64 addr:$src1), i64immSExt32:$src2),
Dan Gohmand16fdc02008-12-19 18:25:21 +00001924 (implicit EFLAGS)),
1925 (IMUL64rmi32 addr:$src1, i64immSExt32:$src2)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001926
Dan Gohman99a12192009-03-04 19:44:21 +00001927// INC and DEC with EFLAGS result. Note that these do not set CF.
Dan Gohmaneebcac72009-03-05 21:32:23 +00001928def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
1929 (INC64_16r GR16:$src)>, Requires<[In64BitMode]>;
1930def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
1931 (implicit EFLAGS)),
1932 (INC64_16m addr:$dst)>, Requires<[In64BitMode]>;
1933def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
1934 (DEC64_16r GR16:$src)>, Requires<[In64BitMode]>;
1935def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
1936 (implicit EFLAGS)),
1937 (DEC64_16m addr:$dst)>, Requires<[In64BitMode]>;
1938
1939def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
1940 (INC64_32r GR32:$src)>, Requires<[In64BitMode]>;
1941def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
1942 (implicit EFLAGS)),
1943 (INC64_32m addr:$dst)>, Requires<[In64BitMode]>;
1944def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
1945 (DEC64_32r GR32:$src)>, Requires<[In64BitMode]>;
1946def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
1947 (implicit EFLAGS)),
1948 (DEC64_32m addr:$dst)>, Requires<[In64BitMode]>;
1949
Dan Gohman99a12192009-03-04 19:44:21 +00001950def : Pat<(parallel (X86inc_flag GR64:$src), (implicit EFLAGS)),
1951 (INC64r GR64:$src)>;
1952def : Pat<(parallel (store (i64 (X86inc_flag (loadi64 addr:$dst))), addr:$dst),
1953 (implicit EFLAGS)),
1954 (INC64m addr:$dst)>;
1955def : Pat<(parallel (X86dec_flag GR64:$src), (implicit EFLAGS)),
1956 (DEC64r GR64:$src)>;
1957def : Pat<(parallel (store (i64 (X86dec_flag (loadi64 addr:$dst))), addr:$dst),
1958 (implicit EFLAGS)),
1959 (DEC64m addr:$dst)>;
1960
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001961//===----------------------------------------------------------------------===//
1962// X86-64 SSE Instructions
1963//===----------------------------------------------------------------------===//
1964
1965// Move instructions...
1966
Evan Chengb783fa32007-07-19 01:14:50 +00001967def MOV64toPQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001968 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001969 [(set VR128:$dst,
1970 (v2i64 (scalar_to_vector GR64:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001971def MOVPQIto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001972 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001973 [(set GR64:$dst, (vector_extract (v2i64 VR128:$src),
1974 (iPTR 0)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001975
Evan Chengb783fa32007-07-19 01:14:50 +00001976def MOV64toSDrr : RPDI<0x6E, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001977 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001978 [(set FR64:$dst, (bitconvert GR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001979def MOV64toSDrm : RPDI<0x6E, MRMSrcMem, (outs FR64:$dst), (ins i64mem:$src),
Evan Cheng69ca4da2008-08-25 04:11:42 +00001980 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001981 [(set FR64:$dst, (bitconvert (loadi64 addr:$src)))]>;
1982
Evan Chengb783fa32007-07-19 01:14:50 +00001983def MOVSDto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001984 "mov{d|q}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001985 [(set GR64:$dst, (bitconvert FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001986def MOVSDto64mr : RPDI<0x7E, MRMDestMem, (outs), (ins i64mem:$dst, FR64:$src),
Evan Cheng69ca4da2008-08-25 04:11:42 +00001987 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001988 [(store (i64 (bitconvert FR64:$src)), addr:$dst)]>;
Nate Begemanb2975562008-02-03 07:18:54 +00001989
1990//===----------------------------------------------------------------------===//
1991// X86-64 SSE4.1 Instructions
1992//===----------------------------------------------------------------------===//
1993
Nate Begeman4294c1f2008-02-12 22:51:28 +00001994/// SS41I_extract32 - SSE 4.1 extract 32 bits to int reg or memory destination
1995multiclass SS41I_extract64<bits<8> opc, string OpcodeStr> {
Nate Begeman0050ab52008-10-29 23:07:17 +00001996 def rr : SS4AIi8<opc, MRMDestReg, (outs GR64:$dst),
Nate Begeman4294c1f2008-02-12 22:51:28 +00001997 (ins VR128:$src1, i32i8imm:$src2),
1998 !strconcat(OpcodeStr,
1999 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
2000 [(set GR64:$dst,
2001 (extractelt (v2i64 VR128:$src1), imm:$src2))]>, OpSize, REX_W;
Evan Cheng78d00612008-03-14 07:39:27 +00002002 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman4294c1f2008-02-12 22:51:28 +00002003 (ins i64mem:$dst, VR128:$src1, i32i8imm:$src2),
2004 !strconcat(OpcodeStr,
2005 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
2006 [(store (extractelt (v2i64 VR128:$src1), imm:$src2),
2007 addr:$dst)]>, OpSize, REX_W;
2008}
2009
2010defm PEXTRQ : SS41I_extract64<0x16, "pextrq">;
2011
2012let isTwoAddress = 1 in {
2013 multiclass SS41I_insert64<bits<8> opc, string OpcodeStr> {
Evan Cheng78d00612008-03-14 07:39:27 +00002014 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begeman4294c1f2008-02-12 22:51:28 +00002015 (ins VR128:$src1, GR64:$src2, i32i8imm:$src3),
2016 !strconcat(OpcodeStr,
2017 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
2018 [(set VR128:$dst,
2019 (v2i64 (insertelt VR128:$src1, GR64:$src2, imm:$src3)))]>,
2020 OpSize, REX_W;
Evan Cheng78d00612008-03-14 07:39:27 +00002021 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begeman4294c1f2008-02-12 22:51:28 +00002022 (ins VR128:$src1, i64mem:$src2, i32i8imm:$src3),
2023 !strconcat(OpcodeStr,
2024 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
2025 [(set VR128:$dst,
2026 (v2i64 (insertelt VR128:$src1, (loadi64 addr:$src2),
2027 imm:$src3)))]>, OpSize, REX_W;
2028 }
2029}
2030
2031defm PINSRQ : SS41I_insert64<0x22, "pinsrq">;