blob: 5278ccc84b949d630c1fe80af25b3ee14fb4f52d [file] [log] [blame]
Chris Lattner1cca5e32003-08-03 21:54:21 +00001//===- X86InstrInfo.td - Describe the X86 Instruction Set -------*- C++ -*-===//
John Criswell856ba762003-10-21 15:17:13 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +00009//
10// This file describes the X86 instruction set, defining the instructions, and
11// properties of the instructions which are needed for code generation, machine
12// code emission, and analysis.
13//
14//===----------------------------------------------------------------------===//
15
Evan Chengaed7c722005-12-17 01:24:02 +000016//===----------------------------------------------------------------------===//
17// X86 specific DAG Nodes.
18//
19
Evan Chenge3413162006-01-09 18:33:28 +000020def SDTIntShiftDOp: SDTypeProfile<1, 3,
21 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
22 SDTCisInt<0>, SDTCisInt<3>]>;
23
Evan Cheng71fb9ad2006-01-26 00:29:36 +000024def SDTX86CmpTest : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000025
Evan Cheng71fb9ad2006-01-26 00:29:36 +000026def SDTX86Cmov : SDTypeProfile<1, 3,
Evan Chengaed7c722005-12-17 01:24:02 +000027 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +000028 SDTCisVT<3, i8>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000029
Evan Cheng71fb9ad2006-01-26 00:29:36 +000030def SDTX86BrCond : SDTypeProfile<0, 2,
31 [SDTCisVT<0, OtherVT>, SDTCisVT<1, i8>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000032
Evan Cheng71fb9ad2006-01-26 00:29:36 +000033def SDTX86SetCC : SDTypeProfile<1, 1,
34 [SDTCisVT<0, i8>, SDTCisVT<1, i8>]>;
Evan Chengd5781fc2005-12-21 20:21:51 +000035
Evan Chengd9558e02006-01-06 00:43:03 +000036def SDTX86Ret : SDTypeProfile<0, 1, [SDTCisVT<0, i16>]>;
Evan Cheng898101c2005-12-19 23:12:38 +000037
Evan Chenge3413162006-01-09 18:33:28 +000038def SDT_X86CallSeqStart : SDTypeProfile<0, 1, [ SDTCisVT<0, i32> ]>;
39def SDT_X86CallSeqEnd : SDTypeProfile<0, 2, [ SDTCisVT<0, i32>,
40 SDTCisVT<1, i32> ]>;
41
Evan Cheng25ab6902006-09-08 06:48:29 +000042def SDT_X86Call : SDTypeProfile<0, 1, [SDTCisVT<0, iPTR>]>;
Evan Chenge3413162006-01-09 18:33:28 +000043
Evan Cheng67f92a72006-01-11 22:15:48 +000044def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
45
Evan Chenge3413162006-01-09 18:33:28 +000046def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
Evan Chengd90eb7f2006-01-05 00:27:02 +000047
Evan Cheng71fb8342006-02-25 10:02:21 +000048def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
49
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +000050def SDT_X86TLSADDR : SDTypeProfile<1, 1, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
51
52def SDT_X86TLSTP : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
53
Anton Korobeynikov2365f512007-07-14 14:06:15 +000054def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
55
Evan Chenge3413162006-01-09 18:33:28 +000056def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
57def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
Evan Chengb077b842005-12-21 02:39:21 +000058
Evan Cheng71fb9ad2006-01-26 00:29:36 +000059def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest,
Evan Cheng734503b2006-09-11 02:19:56 +000060 [SDNPHasChain, SDNPOutFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +000061
Evan Chenge3413162006-01-09 18:33:28 +000062def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov,
Evan Cheng71fb9ad2006-01-26 00:29:36 +000063 [SDNPInFlag, SDNPOutFlag]>;
Evan Chenge3413162006-01-09 18:33:28 +000064def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng71fb9ad2006-01-26 00:29:36 +000065 [SDNPHasChain, SDNPInFlag]>;
Evan Cheng5ee4ccc2006-01-12 08:27:59 +000066def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC,
Evan Cheng71fb9ad2006-01-26 00:29:36 +000067 [SDNPInFlag, SDNPOutFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +000068
Evan Chenge3413162006-01-09 18:33:28 +000069def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
70 [SDNPHasChain, SDNPOptInFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +000071
Evan Chenge3413162006-01-09 18:33:28 +000072def X86callseq_start :
73 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
Evan Chengbb7b8442006-08-11 09:03:33 +000074 [SDNPHasChain, SDNPOutFlag]>;
Evan Chenge3413162006-01-09 18:33:28 +000075def X86callseq_end :
76 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Chris Lattneraf63bb02006-01-24 05:17:12 +000077 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +000078
Evan Chenge3413162006-01-09 18:33:28 +000079def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
80 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
Evan Chengaed7c722005-12-17 01:24:02 +000081
Evan Chengfb914c42006-05-20 01:40:16 +000082def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
Evan Chengfea89c12006-04-27 08:40:39 +000083 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
84
Evan Cheng67f92a72006-01-11 22:15:48 +000085def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Evan Cheng99256422006-03-07 23:34:23 +000086 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
Evan Cheng67f92a72006-01-11 22:15:48 +000087def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Evan Cheng99256422006-03-07 23:34:23 +000088 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
Evan Cheng67f92a72006-01-11 22:15:48 +000089
Evan Chenge3413162006-01-09 18:33:28 +000090def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
91 [SDNPHasChain, SDNPOutFlag]>;
Evan Chengd90eb7f2006-01-05 00:27:02 +000092
Evan Cheng0085a282006-11-30 21:55:46 +000093def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
94def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
Evan Cheng71fb8342006-02-25 10:02:21 +000095
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +000096def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
97 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
98def X86TLStp : SDNode<"X86ISD::THREAD_POINTER", SDT_X86TLSTP, []>;
99
Anton Korobeynikov2365f512007-07-14 14:06:15 +0000100def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
101 [SDNPHasChain]>;
102
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000103
Evan Chengaed7c722005-12-17 01:24:02 +0000104//===----------------------------------------------------------------------===//
105// X86 Operand Definitions.
106//
107
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000108// *mem - Operand definitions for the funky X86 addressing mode operands.
109//
Evan Chengaf78ef52006-05-17 21:21:41 +0000110class X86MemOperand<string printMethod> : Operand<iPTR> {
Nate Begeman391c5d22005-11-30 18:54:35 +0000111 let PrintMethod = printMethod;
Evan Cheng25ab6902006-09-08 06:48:29 +0000112 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000113}
Nate Begeman391c5d22005-11-30 18:54:35 +0000114
Chris Lattner45432512005-12-17 19:47:05 +0000115def i8mem : X86MemOperand<"printi8mem">;
116def i16mem : X86MemOperand<"printi16mem">;
117def i32mem : X86MemOperand<"printi32mem">;
118def i64mem : X86MemOperand<"printi64mem">;
Evan Cheng470a6ad2006-02-22 02:26:30 +0000119def i128mem : X86MemOperand<"printi128mem">;
Chris Lattner45432512005-12-17 19:47:05 +0000120def f32mem : X86MemOperand<"printf32mem">;
121def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen59a58732007-08-05 18:49:15 +0000122def f80mem : X86MemOperand<"printf80mem">;
Evan Cheng223547a2006-01-31 22:28:30 +0000123def f128mem : X86MemOperand<"printf128mem">;
Nate Begeman391c5d22005-11-30 18:54:35 +0000124
Evan Cheng25ab6902006-09-08 06:48:29 +0000125def lea32mem : Operand<i32> {
126 let PrintMethod = "printi32mem";
Evan Cheng25ab6902006-09-08 06:48:29 +0000127 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
128}
129
Nate Begeman16b04f32005-07-15 00:38:55 +0000130def SSECC : Operand<i8> {
131 let PrintMethod = "printSSECC";
132}
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000133
Evan Cheng7ccced62006-02-18 00:15:05 +0000134def piclabel: Operand<i32> {
135 let PrintMethod = "printPICLabel";
136}
137
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000138// A couple of more descriptive operand definitions.
139// 16-bits but only 8 bits are significant.
140def i16i8imm : Operand<i16>;
141// 32-bits but only 8 bits are significant.
142def i32i8imm : Operand<i32>;
143
Evan Chengd35b8c12005-12-04 08:19:43 +0000144// Branch targets have OtherVT type.
145def brtarget : Operand<OtherVT>;
146
Evan Chengaed7c722005-12-17 01:24:02 +0000147//===----------------------------------------------------------------------===//
148// X86 Complex Pattern Definitions.
149//
150
Evan Chengec693f72005-12-08 02:01:35 +0000151// Define X86 specific addressing mode.
Evan Chengaf9db752006-10-11 21:03:53 +0000152def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
Evan Cheng25ab6902006-09-08 06:48:29 +0000153def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
Evan Chengaf9db752006-10-11 21:03:53 +0000154 [add, mul, shl, or, frameindex], []>;
Evan Chengec693f72005-12-08 02:01:35 +0000155
Evan Chengaed7c722005-12-17 01:24:02 +0000156//===----------------------------------------------------------------------===//
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000157// X86 Instruction Predicate Definitions.
Evan Cheng28b514392006-12-05 19:50:18 +0000158def HasMMX : Predicate<"Subtarget->hasMMX()">;
159def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
160def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
161def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
Bill Wendlingbb1ee052007-04-10 22:10:25 +0000162def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Evan Cheng28b514392006-12-05 19:50:18 +0000163def FPStack : Predicate<"!Subtarget->hasSSE2()">;
164def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
165def In64BitMode : Predicate<"Subtarget->is64Bit()">;
Evan Chengf6844ca2007-08-01 23:45:51 +0000166def HasLow4G : Predicate<"Subtarget->hasLow4GUserSpaceAddress()">;
Evan Cheng28b514392006-12-05 19:50:18 +0000167def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
168def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
169def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000170
171//===----------------------------------------------------------------------===//
Evan Chengc64a1a92007-07-31 08:04:03 +0000172// X86 Instruction Format Definitions.
Evan Chengaed7c722005-12-17 01:24:02 +0000173//
174
Evan Chengc64a1a92007-07-31 08:04:03 +0000175include "X86InstrFormats.td"
Chris Lattner1cca5e32003-08-03 21:54:21 +0000176
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000177//===----------------------------------------------------------------------===//
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000178// Pattern fragments...
179//
Evan Chengd9558e02006-01-06 00:43:03 +0000180
181// X86 specific condition code. These correspond to CondCode in
Nate Begeman9a225302007-05-06 04:00:55 +0000182// X86InstrInfo.h. They must be kept in synch.
Evan Chengd9558e02006-01-06 00:43:03 +0000183def X86_COND_A : PatLeaf<(i8 0)>;
184def X86_COND_AE : PatLeaf<(i8 1)>;
185def X86_COND_B : PatLeaf<(i8 2)>;
186def X86_COND_BE : PatLeaf<(i8 3)>;
187def X86_COND_E : PatLeaf<(i8 4)>;
188def X86_COND_G : PatLeaf<(i8 5)>;
189def X86_COND_GE : PatLeaf<(i8 6)>;
190def X86_COND_L : PatLeaf<(i8 7)>;
191def X86_COND_LE : PatLeaf<(i8 8)>;
192def X86_COND_NE : PatLeaf<(i8 9)>;
193def X86_COND_NO : PatLeaf<(i8 10)>;
194def X86_COND_NP : PatLeaf<(i8 11)>;
195def X86_COND_NS : PatLeaf<(i8 12)>;
196def X86_COND_O : PatLeaf<(i8 13)>;
197def X86_COND_P : PatLeaf<(i8 14)>;
198def X86_COND_S : PatLeaf<(i8 15)>;
199
Evan Cheng9b6b6422005-12-13 00:14:11 +0000200def i16immSExt8 : PatLeaf<(i16 imm), [{
201 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000202 // sign extended field.
Evan Cheng09e3c802006-05-19 18:40:54 +0000203 return (int16_t)N->getValue() == (int8_t)N->getValue();
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000204}]>;
205
Evan Cheng9b6b6422005-12-13 00:14:11 +0000206def i32immSExt8 : PatLeaf<(i32 imm), [{
207 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000208 // sign extended field.
Evan Cheng09e3c802006-05-19 18:40:54 +0000209 return (int32_t)N->getValue() == (int8_t)N->getValue();
Evan Chengb3558542005-12-13 00:01:09 +0000210}]>;
211
Evan Cheng605c4152005-12-13 01:57:51 +0000212// Helper fragments for loads.
Evan Cheng7a7e8372005-12-14 02:22:27 +0000213def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
214def loadi16 : PatFrag<(ops node:$ptr), (i16 (load node:$ptr))>;
215def loadi32 : PatFrag<(ops node:$ptr), (i32 (load node:$ptr))>;
Evan Cheng11e15b32006-04-03 20:53:28 +0000216def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
Evan Cheng06a8aa12006-03-17 19:55:52 +0000217
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000218def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
219def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
Dale Johannesen59a58732007-08-05 18:49:15 +0000220def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000221
Evan Cheng466685d2006-10-09 20:57:25 +0000222def sextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (sextloadi1 node:$ptr))>;
223def sextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (sextloadi1 node:$ptr))>;
224def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
225def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
226def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000227
Evan Cheng466685d2006-10-09 20:57:25 +0000228def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
229def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
230def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
231def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
232def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
233def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000234
Evan Cheng466685d2006-10-09 20:57:25 +0000235def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
236def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
237def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
238def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
239def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
240def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
Evan Cheng747a90d2006-02-21 02:24:38 +0000241
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000242//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000243// Instruction list...
244//
245
Chris Lattnerf18c0742006-10-12 17:42:56 +0000246// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
247// a stack adjustment and the codegen must know that they may modify the stack
248// pointer before prolog-epilog rewriting occurs.
Evan Cheng64d80e32007-07-19 01:14:50 +0000249def ADJCALLSTACKDOWN : I<0, Pseudo, (outs), (ins i32imm:$amt), "#ADJCALLSTACKDOWN",
Chris Lattnerf18c0742006-10-12 17:42:56 +0000250 [(X86callseq_start imm:$amt)]>, Imp<[ESP],[ESP]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000251def ADJCALLSTACKUP : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
Evan Chengd90eb7f2006-01-05 00:27:02 +0000252 "#ADJCALLSTACKUP",
Chris Lattnerf18c0742006-10-12 17:42:56 +0000253 [(X86callseq_end imm:$amt1, imm:$amt2)]>,
254 Imp<[ESP],[ESP]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000255def IMPLICIT_USE : I<0, Pseudo, (outs), (ins variable_ops),
256 "#IMPLICIT_USE", []>;
257def IMPLICIT_DEF : I<0, Pseudo, (outs variable_ops), (ins),
258 "#IMPLICIT_DEF", []>;
259def IMPLICIT_DEF_GR8 : I<0, Pseudo, (outs GR8:$dst), (ins),
Evan Cheng510e4782006-01-09 23:10:28 +0000260 "#IMPLICIT_DEF $dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000261 [(set GR8:$dst, (undef))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000262def IMPLICIT_DEF_GR16 : I<0, Pseudo, (outs GR16:$dst), (ins),
Evan Cheng510e4782006-01-09 23:10:28 +0000263 "#IMPLICIT_DEF $dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000264 [(set GR16:$dst, (undef))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000265def IMPLICIT_DEF_GR32 : I<0, Pseudo, (outs GR32:$dst), (ins),
Evan Cheng510e4782006-01-09 23:10:28 +0000266 "#IMPLICIT_DEF $dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000267 [(set GR32:$dst, (undef))]>;
Evan Cheng4a460802006-01-11 00:33:36 +0000268
269// Nop
Evan Cheng64d80e32007-07-19 01:14:50 +0000270def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Evan Cheng4a460802006-01-11 00:33:36 +0000271
Evan Cheng8f7f7122006-05-05 05:40:20 +0000272
Chris Lattner1cca5e32003-08-03 21:54:21 +0000273//===----------------------------------------------------------------------===//
274// Control Flow Instructions...
275//
276
Chris Lattner1be48112005-05-13 17:56:48 +0000277// Return instructions.
Evan Cheng2b4ea792005-12-26 09:11:45 +0000278let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Chengffbacca2007-07-21 00:34:19 +0000279 hasCtrlDep = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000280 def RET : I<0xC3, RawFrm, (outs), (ins), "ret", [(X86retflag 0)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000281 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt), "ret\t$amt",
Evan Chenge3413162006-01-09 18:33:28 +0000282 [(X86retflag imm:$amt)]>;
Evan Cheng171049d2005-12-23 22:14:32 +0000283}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000284
285// All branches are RawFrm, Void, Branch, and Terminators
Evan Chengffbacca2007-07-21 00:34:19 +0000286let isBranch = 1, isTerminator = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000287 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
288 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000289
Nate Begeman37efe672006-04-22 18:53:45 +0000290// Indirect branches
Evan Chengec3bc392006-09-07 19:03:48 +0000291let isBranch = 1, isBarrier = 1 in
Dan Gohmanb1576f52007-07-31 20:11:57 +0000292 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Evan Cheng898101c2005-12-19 23:12:38 +0000293
Evan Chengffbacca2007-07-21 00:34:19 +0000294let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +0000295 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000296 [(brind GR32:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000297 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +0000298 [(brind (loadi32 addr:$dst))]>;
Nate Begeman37efe672006-04-22 18:53:45 +0000299}
300
301// Conditional branches
Dan Gohmanb1576f52007-07-31 20:11:57 +0000302def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000303 [(X86brcond bb:$dst, X86_COND_E)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000304def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000305 [(X86brcond bb:$dst, X86_COND_NE)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000306def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000307 [(X86brcond bb:$dst, X86_COND_L)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000308def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000309 [(X86brcond bb:$dst, X86_COND_LE)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000310def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000311 [(X86brcond bb:$dst, X86_COND_G)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000312def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000313 [(X86brcond bb:$dst, X86_COND_GE)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000314
Dan Gohmanb1576f52007-07-31 20:11:57 +0000315def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000316 [(X86brcond bb:$dst, X86_COND_B)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000317def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000318 [(X86brcond bb:$dst, X86_COND_BE)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000319def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000320 [(X86brcond bb:$dst, X86_COND_A)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000321def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000322 [(X86brcond bb:$dst, X86_COND_AE)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000323
Dan Gohmanb1576f52007-07-31 20:11:57 +0000324def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000325 [(X86brcond bb:$dst, X86_COND_S)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000326def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000327 [(X86brcond bb:$dst, X86_COND_NS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000328def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000329 [(X86brcond bb:$dst, X86_COND_P)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000330def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000331 [(X86brcond bb:$dst, X86_COND_NP)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000332def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000333 [(X86brcond bb:$dst, X86_COND_O)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000334def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000335 [(X86brcond bb:$dst, X86_COND_NO)]>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000336
337//===----------------------------------------------------------------------===//
338// Call Instructions...
339//
Evan Chengffbacca2007-07-21 00:34:19 +0000340let isCall = 1 in
Chris Lattner1cca5e32003-08-03 21:54:21 +0000341 // All calls clobber the non-callee saved registers...
Nate Begemanf63be7d2005-07-06 18:59:04 +0000342 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
Bill Wendling3f3a17d2007-04-25 21:31:48 +0000343 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Nate Begeman16b04f32005-07-15 00:38:55 +0000344 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7] in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000345 def CALLpcrel32 : I<0xE8, RawFrm, (outs), (ins i32imm:$dst, variable_ops),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000346 "call\t${dst:call}", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000347 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000348 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000349 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000350 "call\t{*}$dst", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000351 }
352
Chris Lattner1e9448b2005-05-15 03:10:37 +0000353// Tail call stuff.
Evan Chengffbacca2007-07-21 00:34:19 +0000354let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Dan Gohmanb1576f52007-07-31 20:11:57 +0000355 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAIL CALL",
Evan Chengf10c17f2006-09-22 21:43:59 +0000356 []>;
Evan Chengffbacca2007-07-21 00:34:19 +0000357let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Dan Gohmanb1576f52007-07-31 20:11:57 +0000358 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp\t{*}$dst # TAIL CALL",
Evan Chengf10c17f2006-09-22 21:43:59 +0000359 []>;
Evan Chengffbacca2007-07-21 00:34:19 +0000360let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000361 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000362 "jmp\t{*}$dst # TAIL CALL", []>;
Chris Lattner1e9448b2005-05-15 03:10:37 +0000363
Chris Lattner1cca5e32003-08-03 21:54:21 +0000364//===----------------------------------------------------------------------===//
365// Miscellaneous Instructions...
366//
Chris Lattner30bf2d82004-08-10 20:17:41 +0000367def LEAVE : I<0xC9, RawFrm,
Evan Cheng64d80e32007-07-19 01:14:50 +0000368 (outs), (ins), "leave", []>, Imp<[EBP,ESP],[EBP,ESP]>;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000369def POP32r : I<0x58, AddRegFrm,
Dan Gohmanb1576f52007-07-31 20:11:57 +0000370 (outs GR32:$reg), (ins), "pop{l}\t$reg", []>, Imp<[ESP],[ESP]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000371
Anton Korobeynikov57fc00d2007-04-17 09:20:00 +0000372def PUSH32r : I<0x50, AddRegFrm,
Dan Gohmanb1576f52007-07-31 20:11:57 +0000373 (outs), (ins GR32:$reg), "push{l}\t$reg", []>, Imp<[ESP],[ESP]>;
Anton Korobeynikov57fc00d2007-04-17 09:20:00 +0000374
Evan Cheng64d80e32007-07-19 01:14:50 +0000375def MovePCtoStack : I<0, Pseudo, (outs), (ins piclabel:$label),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000376 "call\t$label", []>;
Evan Cheng7ccced62006-02-18 00:15:05 +0000377
Evan Cheng069287d2006-05-16 07:21:53 +0000378let isTwoAddress = 1 in // GR32 = bswap GR32
Chris Lattner30bf2d82004-08-10 20:17:41 +0000379 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Cheng64d80e32007-07-19 01:14:50 +0000380 (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000381 "bswap{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000382 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000383
Evan Cheng64d80e32007-07-19 01:14:50 +0000384// FIXME: Model xchg* as two address instructions?
Evan Cheng069287d2006-05-16 07:21:53 +0000385def XCHG8rr : I<0x86, MRMDestReg, // xchg GR8, GR8
Evan Cheng64d80e32007-07-19 01:14:50 +0000386 (outs), (ins GR8:$src1, GR8:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000387 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
Evan Cheng069287d2006-05-16 07:21:53 +0000388def XCHG16rr : I<0x87, MRMDestReg, // xchg GR16, GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000389 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000390 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000391def XCHG32rr : I<0x87, MRMDestReg, // xchg GR32, GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000392 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000393 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
Chris Lattnerfc752712004-08-01 09:52:59 +0000394
Chris Lattner3a173df2004-10-03 20:35:00 +0000395def XCHG8mr : I<0x86, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000396 (outs), (ins i8mem:$src1, GR8:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000397 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000398def XCHG16mr : I<0x87, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000399 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000400 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000401def XCHG32mr : I<0x87, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000402 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000403 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000404def XCHG8rm : I<0x86, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000405 (outs), (ins GR8:$src1, i8mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000406 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000407def XCHG16rm : I<0x87, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000408 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000409 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000410def XCHG32rm : I<0x87, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000411 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000412 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000413
Chris Lattner3a173df2004-10-03 20:35:00 +0000414def LEA16r : I<0x8D, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000415 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000416 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000417def LEA32r : I<0x8D, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000418 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000419 "lea{l}\t{$src|$dst}, {$dst|$src}",
Evan Cheng25ab6902006-09-08 06:48:29 +0000420 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000421
Evan Cheng64d80e32007-07-19 01:14:50 +0000422def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng67f92a72006-01-11 22:15:48 +0000423 [(X86rep_movs i8)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000424 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
Evan Cheng64d80e32007-07-19 01:14:50 +0000425def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng67f92a72006-01-11 22:15:48 +0000426 [(X86rep_movs i16)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000427 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000428def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng67f92a72006-01-11 22:15:48 +0000429 [(X86rep_movs i32)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000430 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
Chris Lattner915e5e52004-02-12 17:53:22 +0000431
Evan Cheng64d80e32007-07-19 01:14:50 +0000432def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng67f92a72006-01-11 22:15:48 +0000433 [(X86rep_stos i8)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000434 Imp<[AL,ECX,EDI], [ECX,EDI]>, REP;
Evan Cheng64d80e32007-07-19 01:14:50 +0000435def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng67f92a72006-01-11 22:15:48 +0000436 [(X86rep_stos i16)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000437 Imp<[AX,ECX,EDI], [ECX,EDI]>, REP, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000438def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng67f92a72006-01-11 22:15:48 +0000439 [(X86rep_stos i32)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000440 Imp<[EAX,ECX,EDI], [ECX,EDI]>, REP;
441
Evan Cheng64d80e32007-07-19 01:14:50 +0000442def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng3fa9dff2006-11-29 08:28:13 +0000443 TB, Imp<[],[RAX,RDX]>;
Chris Lattnerb89abef2004-02-14 04:45:37 +0000444
Chris Lattner1cca5e32003-08-03 21:54:21 +0000445//===----------------------------------------------------------------------===//
John Criswell4ffff9e2004-04-08 20:31:47 +0000446// Input/Output Instructions...
447//
Evan Cheng64d80e32007-07-19 01:14:50 +0000448def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000449 "in{b}\t{%dx, %al|%AL, %DX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000450 []>, Imp<[DX], [AL]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000451def IN16rr : I<0xED, RawFrm, (outs), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000452 "in{w}\t{%dx, %ax|%AX, %DX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000453 []>, Imp<[DX], [AX]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000454def IN32rr : I<0xED, RawFrm, (outs), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000455 "in{l}\t{%dx, %eax|%EAX, %DX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000456 []>, Imp<[DX],[EAX]>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000457
Evan Cheng64d80e32007-07-19 01:14:50 +0000458def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000459 "in{b}\t{$port, %al|%AL, $port}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000460 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000461 Imp<[], [AL]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000462def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000463 "in{w}\t{$port, %ax|%AX, $port}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000464 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000465 Imp<[], [AX]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000466def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000467 "in{l}\t{$port, %eax|%EAX, $port}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000468 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000469 Imp<[],[EAX]>;
Chris Lattner440bbc22004-04-13 17:19:31 +0000470
Evan Cheng64d80e32007-07-19 01:14:50 +0000471def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000472 "out{b}\t{%al, %dx|%DX, %AL}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000473 []>, Imp<[DX, AL], []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000474def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000475 "out{w}\t{%ax, %dx|%DX, %AX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000476 []>, Imp<[DX, AX], []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000477def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000478 "out{l}\t{%eax, %dx|%DX, %EAX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000479 []>, Imp<[DX, EAX], []>;
Chris Lattnerffff7082004-08-01 07:44:35 +0000480
Evan Cheng64d80e32007-07-19 01:14:50 +0000481def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000482 "out{b}\t{%al, $port|$port, %AL}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000483 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000484 Imp<[AL], []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000485def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000486 "out{w}\t{%ax, $port|$port, %AX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000487 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000488 Imp<[AX], []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000489def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000490 "out{l}\t{%eax, $port|$port, %EAX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000491 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000492 Imp<[EAX], []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000493
494//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000495// Move Instructions...
496//
Evan Cheng64d80e32007-07-19 01:14:50 +0000497def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000498 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000499def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000500 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000501def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000502 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Dan Gohmand45eddd2007-06-26 00:48:07 +0000503let isReMaterializable = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000504def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000505 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000506 [(set GR8:$dst, imm:$src)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000507def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000508 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000509 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000510def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000511 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000512 [(set GR32:$dst, imm:$src)]>;
Dan Gohmand45eddd2007-06-26 00:48:07 +0000513}
Evan Cheng64d80e32007-07-19 01:14:50 +0000514def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000515 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000516 [(store (i8 imm:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000517def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000518 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000519 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000520def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000521 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000522 [(store (i32 imm:$src), addr:$dst)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000523
Evan Cheng64d80e32007-07-19 01:14:50 +0000524def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000525 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000526 [(set GR8:$dst, (load addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000527def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000528 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000529 [(set GR16:$dst, (load addr:$src))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000530def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000531 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000532 [(set GR32:$dst, (load addr:$src))]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000533
Evan Cheng64d80e32007-07-19 01:14:50 +0000534def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000535 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000536 [(store GR8:$src, addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000537def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000538 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000539 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000540def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000541 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000542 [(store GR32:$src, addr:$dst)]>;
Nate Begemanf1702ac2005-06-27 21:20:31 +0000543
Chris Lattner1cca5e32003-08-03 21:54:21 +0000544//===----------------------------------------------------------------------===//
545// Fixed-Register Multiplication and Division Instructions...
546//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000547
Chris Lattnerc8f45872003-08-04 04:59:56 +0000548// Extra precision multiplication
Dan Gohmanb1576f52007-07-31 20:11:57 +0000549def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +0000550 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
551 // This probably ought to be moved to a def : Pat<> if the
552 // syntax can be accepted.
Evan Cheng7afa1662007-08-02 05:48:35 +0000553 []>,
Evan Cheng1c3017c2007-08-01 20:22:37 +0000554 Imp<[AL],[AL,AH]>; // AL,AH = AL*GR8
Dan Gohmanb1576f52007-07-31 20:11:57 +0000555def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src), "mul{w}\t$src", []>,
Evan Cheng069287d2006-05-16 07:21:53 +0000556 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*GR16
Dan Gohmanb1576f52007-07-31 20:11:57 +0000557def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src), "mul{l}\t$src", []>,
Evan Cheng069287d2006-05-16 07:21:53 +0000558 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000559def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000560 "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +0000561 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
562 // This probably ought to be moved to a def : Pat<> if the
563 // syntax can be accepted.
Evan Cheng7afa1662007-08-02 05:48:35 +0000564 []>,
565 Imp<[AL],[AL,AH]>; // AL,AH = AL*[mem8]
Evan Cheng64d80e32007-07-19 01:14:50 +0000566def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000567 "mul{w}\t$src", []>, Imp<[AX],[AX,DX]>,
Evan Chengf0701842005-11-29 19:38:52 +0000568 OpSize; // AX,DX = AX*[mem16]
Evan Cheng64d80e32007-07-19 01:14:50 +0000569def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Evan Cheng7afa1662007-08-02 05:48:35 +0000570 "mul{l}\t$src", []>, Imp<[EAX],[EAX,EDX]>;// EAX,EDX = EAX*[mem32]
Chris Lattner1cca5e32003-08-03 21:54:21 +0000571
Dan Gohmanb1576f52007-07-31 20:11:57 +0000572def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>,
Evan Cheng7afa1662007-08-02 05:48:35 +0000573 Imp<[AL],[AL,AH]>; // AL,AH = AL*GR8
Dan Gohmanb1576f52007-07-31 20:11:57 +0000574def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng069287d2006-05-16 07:21:53 +0000575 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*GR16
Dan Gohmanb1576f52007-07-31 20:11:57 +0000576def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>,
Evan Cheng069287d2006-05-16 07:21:53 +0000577 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000578def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng7afa1662007-08-02 05:48:35 +0000579 "imul{b}\t$src", []>, Imp<[AL],[AL,AH]>; // AL,AH = AL*[mem8]
Evan Cheng64d80e32007-07-19 01:14:50 +0000580def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000581 "imul{w}\t$src", []>, Imp<[AX],[AX,DX]>,
Evan Chengf0701842005-11-29 19:38:52 +0000582 OpSize; // AX,DX = AX*[mem16]
Evan Cheng64d80e32007-07-19 01:14:50 +0000583def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000584 "imul{l}\t$src", []>,
Evan Chengf0701842005-11-29 19:38:52 +0000585 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*[mem32]
Chris Lattner1e6a7152005-04-06 04:19:22 +0000586
Chris Lattnerc8f45872003-08-04 04:59:56 +0000587// unsigned division/remainder
Evan Cheng64d80e32007-07-19 01:14:50 +0000588def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Dan Gohmanb1576f52007-07-31 20:11:57 +0000589 "div{b}\t$src", []>, Imp<[AX],[AX]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000590def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Dan Gohmanb1576f52007-07-31 20:11:57 +0000591 "div{w}\t$src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000592def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Dan Gohmanb1576f52007-07-31 20:11:57 +0000593 "div{l}\t$src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000594def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Dan Gohmanb1576f52007-07-31 20:11:57 +0000595 "div{b}\t$src", []>, Imp<[AX],[AX]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000596def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Dan Gohmanb1576f52007-07-31 20:11:57 +0000597 "div{w}\t$src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000598def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Dan Gohmanb1576f52007-07-31 20:11:57 +0000599 "div{l}\t$src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000600
Chris Lattnerfc752712004-08-01 09:52:59 +0000601// Signed division/remainder.
Evan Cheng64d80e32007-07-19 01:14:50 +0000602def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Dan Gohmanb1576f52007-07-31 20:11:57 +0000603 "idiv{b}\t$src", []>, Imp<[AX],[AX]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000604def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Dan Gohmanb1576f52007-07-31 20:11:57 +0000605 "idiv{w}\t$src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000606def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Dan Gohmanb1576f52007-07-31 20:11:57 +0000607 "idiv{l}\t$src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000608def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Dan Gohmanb1576f52007-07-31 20:11:57 +0000609 "idiv{b}\t$src", []>, Imp<[AX],[AX]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000610def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Dan Gohmanb1576f52007-07-31 20:11:57 +0000611 "idiv{w}\t$src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000612def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Dan Gohmanb1576f52007-07-31 20:11:57 +0000613 "idiv{l}\t$src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattnerc8f45872003-08-04 04:59:56 +0000614
Chris Lattner1cca5e32003-08-03 21:54:21 +0000615
Chris Lattner1cca5e32003-08-03 21:54:21 +0000616//===----------------------------------------------------------------------===//
617// Two address Instructions...
618//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000619let isTwoAddress = 1 in {
Chris Lattner1cca5e32003-08-03 21:54:21 +0000620
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000621// Conditional moves
Evan Cheng069287d2006-05-16 07:21:53 +0000622def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000623 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000624 "cmovb\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000625 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000626 X86_COND_B))]>,
627 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000628def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
Evan Cheng64d80e32007-07-19 01:14:50 +0000629 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000630 "cmovb\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000631 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000632 X86_COND_B))]>,
633 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000634def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000635 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000636 "cmovb\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000637 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000638 X86_COND_B))]>,
639 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000640def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
Evan Cheng64d80e32007-07-19 01:14:50 +0000641 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000642 "cmovb\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000643 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000644 X86_COND_B))]>,
645 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000646
Evan Cheng069287d2006-05-16 07:21:53 +0000647def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000648 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000649 "cmovae\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000650 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000651 X86_COND_AE))]>,
652 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000653def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
Evan Cheng64d80e32007-07-19 01:14:50 +0000654 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000655 "cmovae\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000656 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000657 X86_COND_AE))]>,
658 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000659def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000660 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000661 "cmovae\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000662 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000663 X86_COND_AE))]>,
664 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000665def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
Evan Cheng64d80e32007-07-19 01:14:50 +0000666 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000667 "cmovae\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000668 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000669 X86_COND_AE))]>,
670 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000671
Evan Cheng069287d2006-05-16 07:21:53 +0000672def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000673 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000674 "cmove\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000675 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000676 X86_COND_E))]>,
677 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000678def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
Evan Cheng64d80e32007-07-19 01:14:50 +0000679 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000680 "cmove\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000681 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000682 X86_COND_E))]>,
683 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000684def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000685 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000686 "cmove\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000687 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000688 X86_COND_E))]>,
689 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000690def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
Evan Cheng64d80e32007-07-19 01:14:50 +0000691 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000692 "cmove\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000693 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000694 X86_COND_E))]>,
695 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000696
Evan Cheng069287d2006-05-16 07:21:53 +0000697def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000698 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000699 "cmovne\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000700 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000701 X86_COND_NE))]>,
702 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000703def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
Evan Cheng64d80e32007-07-19 01:14:50 +0000704 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000705 "cmovne\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000706 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000707 X86_COND_NE))]>,
708 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000709def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000710 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000711 "cmovne\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000712 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000713 X86_COND_NE))]>,
714 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000715def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
Evan Cheng64d80e32007-07-19 01:14:50 +0000716 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000717 "cmovne\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000718 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000719 X86_COND_NE))]>,
720 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000721
Evan Cheng069287d2006-05-16 07:21:53 +0000722def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000723 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000724 "cmovbe\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000725 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000726 X86_COND_BE))]>,
727 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000728def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
Evan Cheng64d80e32007-07-19 01:14:50 +0000729 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000730 "cmovbe\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000731 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000732 X86_COND_BE))]>,
733 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000734def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000735 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000736 "cmovbe\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000737 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000738 X86_COND_BE))]>,
739 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000740def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
Evan Cheng64d80e32007-07-19 01:14:50 +0000741 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000742 "cmovbe\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000743 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000744 X86_COND_BE))]>,
745 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000746
Evan Cheng069287d2006-05-16 07:21:53 +0000747def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000748 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000749 "cmova\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000750 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000751 X86_COND_A))]>,
752 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000753def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
Evan Cheng64d80e32007-07-19 01:14:50 +0000754 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000755 "cmova\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000756 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000757 X86_COND_A))]>,
758 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000759def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000760 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000761 "cmova\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000762 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000763 X86_COND_A))]>,
764 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000765def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
Evan Cheng64d80e32007-07-19 01:14:50 +0000766 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000767 "cmova\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000768 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000769 X86_COND_A))]>,
770 TB;
Evan Chengaed7c722005-12-17 01:24:02 +0000771
Evan Cheng069287d2006-05-16 07:21:53 +0000772def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000773 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000774 "cmovl\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000775 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000776 X86_COND_L))]>,
777 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000778def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
Evan Cheng64d80e32007-07-19 01:14:50 +0000779 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000780 "cmovl\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000781 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000782 X86_COND_L))]>,
783 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000784def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000785 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000786 "cmovl\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000787 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000788 X86_COND_L))]>,
789 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000790def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
Evan Cheng64d80e32007-07-19 01:14:50 +0000791 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000792 "cmovl\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000793 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000794 X86_COND_L))]>,
795 TB;
Evan Chengaed7c722005-12-17 01:24:02 +0000796
Evan Cheng069287d2006-05-16 07:21:53 +0000797def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000798 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000799 "cmovge\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000800 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000801 X86_COND_GE))]>,
802 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000803def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
Evan Cheng64d80e32007-07-19 01:14:50 +0000804 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000805 "cmovge\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000806 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000807 X86_COND_GE))]>,
808 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000809def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000810 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000811 "cmovge\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000812 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000813 X86_COND_GE))]>,
814 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000815def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
Evan Cheng64d80e32007-07-19 01:14:50 +0000816 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000817 "cmovge\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000818 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000819 X86_COND_GE))]>,
820 TB;
Evan Chengaed7c722005-12-17 01:24:02 +0000821
Evan Cheng069287d2006-05-16 07:21:53 +0000822def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000823 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000824 "cmovle\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000825 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000826 X86_COND_LE))]>,
827 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000828def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
Evan Cheng64d80e32007-07-19 01:14:50 +0000829 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000830 "cmovle\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000831 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000832 X86_COND_LE))]>,
833 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000834def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000835 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000836 "cmovle\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000837 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000838 X86_COND_LE))]>,
839 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000840def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
Evan Cheng64d80e32007-07-19 01:14:50 +0000841 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000842 "cmovle\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000843 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000844 X86_COND_LE))]>,
845 TB;
Evan Chengaed7c722005-12-17 01:24:02 +0000846
Evan Cheng069287d2006-05-16 07:21:53 +0000847def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000848 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000849 "cmovg\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000850 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000851 X86_COND_G))]>,
852 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000853def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
Evan Cheng64d80e32007-07-19 01:14:50 +0000854 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000855 "cmovg\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000856 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000857 X86_COND_G))]>,
858 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000859def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000860 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000861 "cmovg\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000862 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000863 X86_COND_G))]>,
864 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000865def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
Evan Cheng64d80e32007-07-19 01:14:50 +0000866 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000867 "cmovg\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000868 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000869 X86_COND_G))]>,
870 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000871
Evan Cheng069287d2006-05-16 07:21:53 +0000872def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000873 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000874 "cmovs\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000875 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000876 X86_COND_S))]>,
877 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000878def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
Evan Cheng64d80e32007-07-19 01:14:50 +0000879 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000880 "cmovs\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000881 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000882 X86_COND_S))]>,
883 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000884def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000885 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000886 "cmovs\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000887 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000888 X86_COND_S))]>,
889 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000890def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
Evan Cheng64d80e32007-07-19 01:14:50 +0000891 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000892 "cmovs\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000893 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000894 X86_COND_S))]>,
895 TB;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000896
Evan Cheng069287d2006-05-16 07:21:53 +0000897def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000898 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000899 "cmovns\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000900 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000901 X86_COND_NS))]>,
902 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000903def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
Evan Cheng64d80e32007-07-19 01:14:50 +0000904 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000905 "cmovns\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000906 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000907 X86_COND_NS))]>,
908 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000909def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000910 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000911 "cmovns\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000912 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000913 X86_COND_NS))]>,
914 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000915def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
Evan Cheng64d80e32007-07-19 01:14:50 +0000916 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000917 "cmovns\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000918 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000919 X86_COND_NS))]>,
920 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000921
Evan Cheng069287d2006-05-16 07:21:53 +0000922def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000923 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000924 "cmovp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000925 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000926 X86_COND_P))]>,
927 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000928def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
Evan Cheng64d80e32007-07-19 01:14:50 +0000929 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000930 "cmovp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000931 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000932 X86_COND_P))]>,
933 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000934def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000935 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000936 "cmovp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000937 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000938 X86_COND_P))]>,
939 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000940def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
Evan Cheng64d80e32007-07-19 01:14:50 +0000941 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000942 "cmovp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000943 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000944 X86_COND_P))]>,
945 TB;
Chris Lattner57fbfb52005-01-10 22:09:33 +0000946
Evan Cheng069287d2006-05-16 07:21:53 +0000947def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000948 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000949 "cmovnp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000950 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000951 X86_COND_NP))]>,
952 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000953def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
Evan Cheng64d80e32007-07-19 01:14:50 +0000954 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000955 "cmovnp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000956 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000957 X86_COND_NP))]>,
958 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000959def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000960 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000961 "cmovnp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000962 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000963 X86_COND_NP))]>,
964 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000965def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
Evan Cheng64d80e32007-07-19 01:14:50 +0000966 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000967 "cmovnp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000968 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000969 X86_COND_NP))]>,
970 TB;
Chris Lattner57fbfb52005-01-10 22:09:33 +0000971
972
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000973// unary instructions
Evan Cheng1693e482006-07-19 00:27:29 +0000974let CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +0000975def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000976 [(set GR8:$dst, (ineg GR8:$src))]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000977def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000978 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000979def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000980 [(set GR32:$dst, (ineg GR32:$src))]>;
Chris Lattner57a02302004-08-11 04:31:00 +0000981let isTwoAddress = 0 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +0000982 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +0000983 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000984 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +0000985 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000986 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +0000987 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
988
Chris Lattner57a02302004-08-11 04:31:00 +0000989}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000990
Dan Gohmanb1576f52007-07-31 20:11:57 +0000991def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000992 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000993def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000994 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000995def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000996 [(set GR32:$dst, (not GR32:$src))]>;
Chris Lattner57a02302004-08-11 04:31:00 +0000997let isTwoAddress = 0 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +0000998 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +0000999 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001000 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001001 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001002 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001003 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001004}
Evan Cheng1693e482006-07-19 00:27:29 +00001005} // CodeSize
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001006
Evan Chengb51a0592005-12-10 00:48:20 +00001007// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng1693e482006-07-19 00:27:29 +00001008let CodeSize = 2 in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001009def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001010 [(set GR8:$dst, (add GR8:$src, 1))]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001011let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohmanb1576f52007-07-31 20:11:57 +00001012def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +00001013 [(set GR16:$dst, (add GR16:$src, 1))]>,
1014 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001015def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +00001016 [(set GR32:$dst, (add GR32:$src, 1))]>, Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001017}
Evan Cheng1693e482006-07-19 00:27:29 +00001018let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001019 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001020 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001021 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001022 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001023 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001024 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001025}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001026
Evan Cheng1693e482006-07-19 00:27:29 +00001027let CodeSize = 2 in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001028def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001029 [(set GR8:$dst, (add GR8:$src, -1))]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001030let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohmanb1576f52007-07-31 20:11:57 +00001031def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +00001032 [(set GR16:$dst, (add GR16:$src, -1))]>,
1033 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001034def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +00001035 [(set GR32:$dst, (add GR32:$src, -1))]>, Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001036}
Chris Lattner57a02302004-08-11 04:31:00 +00001037
Evan Cheng1693e482006-07-19 00:27:29 +00001038let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001039 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001040 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001041 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001042 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001043 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001044 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001045}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001046
1047// Logical operators...
Chris Lattnercc65bee2005-01-02 02:35:46 +00001048let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001049def AND8rr : I<0x20, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001050 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001051 "and{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001052 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001053def AND16rr : I<0x21, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001054 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001055 "and{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001056 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001057def AND32rr : I<0x21, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001058 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001059 "and{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001060 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001061}
Chris Lattner57a02302004-08-11 04:31:00 +00001062
Chris Lattner3a173df2004-10-03 20:35:00 +00001063def AND8rm : I<0x22, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001064 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001065 "and{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001066 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001067def AND16rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001068 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001069 "and{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001070 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001071def AND32rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001072 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001073 "and{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001074 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001075
Chris Lattner3a173df2004-10-03 20:35:00 +00001076def AND8ri : Ii8<0x80, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001077 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001078 "and{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001079 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001080def AND16ri : Ii16<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001081 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001082 "and{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001083 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001084def AND32ri : Ii32<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001085 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001086 "and{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001087 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001088def AND16ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001089 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001090 "and{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001091 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001092 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001093def AND32ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001094 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001095 "and{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001096 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001097
1098let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001099 def AND8mr : I<0x20, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001100 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001101 "and{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001102 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001103 def AND16mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001104 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001105 "and{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001106 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001107 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001108 def AND32mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001109 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001110 "and{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001111 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001112 def AND8mi : Ii8<0x80, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001113 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001114 "and{b}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001115 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001116 def AND16mi : Ii16<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001117 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001118 "and{w}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001119 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001120 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001121 def AND32mi : Ii32<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001122 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001123 "and{l}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001124 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001125 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001126 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001127 "and{w}\t{$src, $dst|$dst, $src}",
Evan Cheng0ef3a772005-12-13 01:41:36 +00001128 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1129 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001130 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001131 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001132 "and{l}\t{$src, $dst|$dst, $src}",
Evan Chenge3703d42006-01-14 01:18:49 +00001133 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001134}
1135
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001136
Chris Lattnercc65bee2005-01-02 02:35:46 +00001137let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Cheng64d80e32007-07-19 01:14:50 +00001138def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001139 "or{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001140 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001141def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001142 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001143 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001144def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001145 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001146 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001147}
Evan Cheng64d80e32007-07-19 01:14:50 +00001148def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001149 "or{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001150 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001151def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001152 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001153 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001154def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001155 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001156 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001157
Evan Cheng64d80e32007-07-19 01:14:50 +00001158def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001159 "or{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001160 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001161def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001162 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001163 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001164def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001165 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001166 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001167
Evan Cheng64d80e32007-07-19 01:14:50 +00001168def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001169 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001170 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001171def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001172 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001173 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001174let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001175 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001176 "or{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001177 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001178 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001179 "or{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001180 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001181 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001182 "or{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001183 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001184 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001185 "or{b}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001186 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001187 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001188 "or{w}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001189 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001190 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001191 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001192 "or{l}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001193 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001194 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001195 "or{w}\t{$src, $dst|$dst, $src}",
Evan Cheng0ef3a772005-12-13 01:41:36 +00001196 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1197 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001198 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001199 "or{l}\t{$src, $dst|$dst, $src}",
Evan Cheng0ef3a772005-12-13 01:41:36 +00001200 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001201}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001202
1203
Chris Lattnercc65bee2005-01-02 02:35:46 +00001204let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001205def XOR8rr : I<0x30, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001206 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001207 "xor{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001208 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001209def XOR16rr : I<0x31, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001210 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001211 "xor{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001212 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001213def XOR32rr : I<0x31, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001214 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001215 "xor{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001216 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001217}
1218
Chris Lattner3a173df2004-10-03 20:35:00 +00001219def XOR8rm : I<0x32, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00001220 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001221 "xor{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001222 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001223def XOR16rm : I<0x33, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00001224 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001225 "xor{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001226 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001227def XOR32rm : I<0x33, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00001228 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001229 "xor{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001230 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001231
Chris Lattner3a173df2004-10-03 20:35:00 +00001232def XOR8ri : Ii8<0x80, MRM6r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001233 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001234 "xor{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001235 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001236def XOR16ri : Ii16<0x81, MRM6r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001237 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001238 "xor{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001239 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001240def XOR32ri : Ii32<0x81, MRM6r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001241 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001242 "xor{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001243 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001244def XOR16ri8 : Ii8<0x83, MRM6r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001245 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001246 "xor{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001247 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001248 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001249def XOR32ri8 : Ii8<0x83, MRM6r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001250 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001251 "xor{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001252 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001253let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001254 def XOR8mr : I<0x30, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001255 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001256 "xor{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001257 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001258 def XOR16mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001259 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001260 "xor{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001261 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001262 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001263 def XOR32mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001264 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001265 "xor{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001266 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001267 def XOR8mi : Ii8<0x80, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001268 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001269 "xor{b}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001270 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001271 def XOR16mi : Ii16<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001272 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001273 "xor{w}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001274 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001275 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001276 def XOR32mi : Ii32<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001277 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001278 "xor{l}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001279 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001280 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001281 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001282 "xor{w}\t{$src, $dst|$dst, $src}",
Evan Cheng0ef3a772005-12-13 01:41:36 +00001283 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1284 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001285 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001286 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001287 "xor{l}\t{$src, $dst|$dst, $src}",
Evan Cheng0ef3a772005-12-13 01:41:36 +00001288 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001289}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001290
1291// Shift instructions
Evan Cheng64d80e32007-07-19 01:14:50 +00001292def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001293 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001294 [(set GR8:$dst, (shl GR8:$src, CL))]>, Imp<[CL],[]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001295def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001296 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001297 [(set GR16:$dst, (shl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001298def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001299 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001300 [(set GR32:$dst, (shl GR32:$src, CL))]>, Imp<[CL],[]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001301
Evan Cheng64d80e32007-07-19 01:14:50 +00001302def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001303 "shl{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001304 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001305let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng64d80e32007-07-19 01:14:50 +00001306def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001307 "shl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001308 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001309def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001310 "shl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001311 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001312}
Chris Lattnerf29ed092004-08-11 05:07:25 +00001313
Evan Cheng09c54572006-06-29 00:36:51 +00001314// Shift left by one. Not used because (add x, x) is slightly cheaper.
Evan Cheng64d80e32007-07-19 01:14:50 +00001315def SHL8r1 : I<0xD0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001316 "shl{b}\t$dst", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001317def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001318 "shl{w}\t$dst", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001319def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001320 "shl{l}\t$dst", []>;
Evan Cheng09c54572006-06-29 00:36:51 +00001321
Chris Lattnerf29ed092004-08-11 05:07:25 +00001322let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001323 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001324 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng763b0292005-12-13 02:34:51 +00001325 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>,
1326 Imp<[CL],[]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001327 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001328 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng763b0292005-12-13 02:34:51 +00001329 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>,
1330 Imp<[CL],[]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001331 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001332 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng763b0292005-12-13 02:34:51 +00001333 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>,
1334 Imp<[CL],[]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001335 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001336 "shl{b}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00001337 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001338 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001339 "shl{w}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00001340 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1341 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001342 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001343 "shl{l}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00001344 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001345
1346 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001347 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001348 "shl{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001349 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001350 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001351 "shl{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001352 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1353 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001354 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001355 "shl{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001356 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001357}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001358
Evan Cheng64d80e32007-07-19 01:14:50 +00001359def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001360 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001361 [(set GR8:$dst, (srl GR8:$src, CL))]>, Imp<[CL],[]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001362def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001363 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001364 [(set GR16:$dst, (srl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001365def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001366 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001367 [(set GR32:$dst, (srl GR32:$src, CL))]>, Imp<[CL],[]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001368
Evan Cheng64d80e32007-07-19 01:14:50 +00001369def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001370 "shr{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001371 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001372def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001373 "shr{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001374 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001375def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001376 "shr{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001377 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001378
Evan Cheng09c54572006-06-29 00:36:51 +00001379// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001380def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001381 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001382 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001383def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001384 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001385 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001386def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001387 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001388 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1389
Chris Lattner57a02302004-08-11 04:31:00 +00001390let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001391 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001392 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001393 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>,
1394 Imp<[CL],[]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001395 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001396 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001397 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1398 Imp<[CL],[]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001399 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001400 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001401 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>,
1402 Imp<[CL],[]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001403 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001404 "shr{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001405 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001406 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001407 "shr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001408 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1409 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001410 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001411 "shr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001412 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001413
1414 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001415 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001416 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001417 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001418 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001419 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001420 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001421 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001422 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001423 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001424}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001425
Evan Cheng64d80e32007-07-19 01:14:50 +00001426def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001427 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001428 [(set GR8:$dst, (sra GR8:$src, CL))]>, Imp<[CL],[]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001429def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001430 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001431 [(set GR16:$dst, (sra GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001432def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001433 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001434 [(set GR32:$dst, (sra GR32:$src, CL))]>, Imp<[CL],[]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001435
Evan Cheng64d80e32007-07-19 01:14:50 +00001436def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001437 "sar{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001438 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001439def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001440 "sar{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001441 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001442 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001443def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001444 "sar{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001445 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001446
1447// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001448def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001449 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001450 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001451def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001452 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001453 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001454def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001455 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001456 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1457
Chris Lattnerf29ed092004-08-11 05:07:25 +00001458let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001459 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001460 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001461 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>,
1462 Imp<[CL],[]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001463 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001464 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001465 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>,
1466 Imp<[CL],[]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001467 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001468 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001469 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>,
1470 Imp<[CL],[]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001471 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001472 "sar{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001473 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001474 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001475 "sar{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001476 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1477 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001478 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001479 "sar{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001480 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001481
1482 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001483 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001484 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001485 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001486 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001487 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001488 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1489 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001490 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001491 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001492 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001493}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001494
Chris Lattner40ff6332005-01-19 07:50:03 +00001495// Rotate instructions
1496// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001497def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001498 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001499 [(set GR8:$dst, (rotl GR8:$src, CL))]>, Imp<[CL],[]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001500def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001501 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001502 [(set GR16:$dst, (rotl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001503def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001504 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001505 [(set GR32:$dst, (rotl GR32:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001506
Evan Cheng64d80e32007-07-19 01:14:50 +00001507def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001508 "rol{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001509 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001510def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001511 "rol{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001512 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001513def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001514 "rol{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001515 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001516
Evan Cheng09c54572006-06-29 00:36:51 +00001517// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001518def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001519 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001520 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001521def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001522 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001523 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001524def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001525 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001526 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1527
Chris Lattner40ff6332005-01-19 07:50:03 +00001528let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001529 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001530 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Chengeb422a72006-01-11 23:20:05 +00001531 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>,
1532 Imp<[CL],[]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001533 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001534 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Chengeb422a72006-01-11 23:20:05 +00001535 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>,
1536 Imp<[CL],[]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001537 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001538 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Chengeb422a72006-01-11 23:20:05 +00001539 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>,
1540 Imp<[CL],[]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001541 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001542 "rol{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001543 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001544 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001545 "rol{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001546 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1547 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001548 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001549 "rol{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001550 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001551
1552 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001553 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001554 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001555 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001556 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001557 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001558 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1559 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001560 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001561 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001562 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001563}
1564
Evan Cheng64d80e32007-07-19 01:14:50 +00001565def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001566 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001567 [(set GR8:$dst, (rotr GR8:$src, CL))]>, Imp<[CL],[]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001568def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001569 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001570 [(set GR16:$dst, (rotr GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001571def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001572 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001573 [(set GR32:$dst, (rotr GR32:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001574
Evan Cheng64d80e32007-07-19 01:14:50 +00001575def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001576 "ror{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001577 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001578def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001579 "ror{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001580 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001581def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001582 "ror{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001583 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001584
1585// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001586def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001587 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001588 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001589def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001590 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001591 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001592def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001593 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001594 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1595
Chris Lattner40ff6332005-01-19 07:50:03 +00001596let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001597 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001598 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Chengeb422a72006-01-11 23:20:05 +00001599 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>,
1600 Imp<[CL],[]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001601 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001602 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Chengeb422a72006-01-11 23:20:05 +00001603 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>,
1604 Imp<[CL],[]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001605 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001606 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Chengeb422a72006-01-11 23:20:05 +00001607 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>,
1608 Imp<[CL],[]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001609 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001610 "ror{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001611 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001612 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001613 "ror{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001614 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1615 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001616 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001617 "ror{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001618 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001619
1620 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001621 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001622 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001623 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001624 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001625 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001626 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1627 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001628 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001629 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001630 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001631}
1632
1633
1634
1635// Double shift instructions (generalizations of rotate)
Evan Cheng64d80e32007-07-19 01:14:50 +00001636def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001637 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001638 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001639 Imp<[CL],[]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00001640def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001641 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001642 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001643 Imp<[CL],[]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00001644def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001645 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001646 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001647 Imp<[CL],[]>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001648def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001649 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001650 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001651 Imp<[CL],[]>, TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00001652
1653let isCommutable = 1 in { // These instructions commute to each other.
Chris Lattner3a173df2004-10-03 20:35:00 +00001654def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001655 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001656 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001657 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001658 (i8 imm:$src3)))]>,
1659 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001660def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001661 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001662 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001663 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001664 (i8 imm:$src3)))]>,
1665 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00001666def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001667 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001668 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001669 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001670 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001671 TB, OpSize;
1672def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001673 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001674 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001675 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001676 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001677 TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00001678}
Chris Lattner0e967d42004-08-01 08:13:11 +00001679
Chris Lattner57a02302004-08-11 04:31:00 +00001680let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001681 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001682 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001683 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Chenge3413162006-01-09 18:33:28 +00001684 addr:$dst)]>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001685 Imp<[CL],[]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00001686 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001687 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001688 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Chenge3413162006-01-09 18:33:28 +00001689 addr:$dst)]>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001690 Imp<[CL],[]>, TB;
1691 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001692 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001693 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001694 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001695 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001696 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001697 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001698 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001699 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001700 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001701 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001702 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00001703
Evan Cheng64d80e32007-07-19 01:14:50 +00001704 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001705 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001706 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Chenge3413162006-01-09 18:33:28 +00001707 addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001708 Imp<[CL],[]>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001709 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001710 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001711 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Chenge3413162006-01-09 18:33:28 +00001712 addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001713 Imp<[CL],[]>, TB, OpSize;
1714 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001715 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001716 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001717 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001718 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001719 TB, OpSize;
1720 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001721 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001722 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001723 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001724 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001725 TB, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00001726}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001727
1728
Chris Lattnercc65bee2005-01-02 02:35:46 +00001729// Arithmetic.
1730let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Evan Cheng64d80e32007-07-19 01:14:50 +00001731def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001732 "add{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001733 [(set GR8:$dst, (add GR8:$src1, GR8:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001734let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng64d80e32007-07-19 01:14:50 +00001735def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001736 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001737 [(set GR16:$dst, (add GR16:$src1, GR16:$src2))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001738def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001739 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001740 [(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001741} // end isConvertibleToThreeAddress
1742} // end isCommutable
Evan Cheng64d80e32007-07-19 01:14:50 +00001743def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001744 "add{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001745 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001746def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001747 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001748 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001749def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001750 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001751 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001752
Evan Cheng64d80e32007-07-19 01:14:50 +00001753def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001754 "add{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001755 [(set GR8:$dst, (add GR8:$src1, imm:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001756
1757let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng64d80e32007-07-19 01:14:50 +00001758def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001759 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001760 [(set GR16:$dst, (add GR16:$src1, imm:$src2))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001761def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001762 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001763 [(set GR32:$dst, (add GR32:$src1, imm:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001764def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001765 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001766 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001767 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001768def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001769 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001770 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng09e3c802006-05-19 18:40:54 +00001771}
Chris Lattner57a02302004-08-11 04:31:00 +00001772
1773let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001774 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001775 "add{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001776 [(store (add (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001777 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001778 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001779 [(store (add (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001780 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001781 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001782 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001783 [(store (add (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001784 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001785 "add{b}\t{$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001786 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001787 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001788 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001789 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001790 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001791 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001792 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001793 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001794 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001795 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001796 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1797 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001798 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001799 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001800 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001801}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001802
Chris Lattner10197ff2005-01-03 01:27:59 +00001803let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Cheng64d80e32007-07-19 01:14:50 +00001804def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001805 "adc{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001806 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Chris Lattner10197ff2005-01-03 01:27:59 +00001807}
Evan Cheng64d80e32007-07-19 01:14:50 +00001808def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001809 "adc{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001810 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001811def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001812 "adc{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001813 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001814def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001815 "adc{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001816 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001817
1818let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001819 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001820 "adc{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001821 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001822 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001823 "adc{l}\t{$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001824 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001825 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001826 "adc{l}\t{$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001827 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001828}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001829
Evan Cheng64d80e32007-07-19 01:14:50 +00001830def SUB8rr : I<0x28, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001831 "sub{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001832 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001833def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001834 "sub{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001835 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001836def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001837 "sub{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001838 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001839def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001840 "sub{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001841 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001842def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001843 "sub{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001844 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001845def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001846 "sub{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001847 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001848
Evan Cheng64d80e32007-07-19 01:14:50 +00001849def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001850 "sub{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001851 [(set GR8:$dst, (sub GR8:$src1, imm:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001852def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001853 "sub{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001854 [(set GR16:$dst, (sub GR16:$src1, imm:$src2))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001855def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001856 "sub{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001857 [(set GR32:$dst, (sub GR32:$src1, imm:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001858def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001859 "sub{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001860 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001861 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001862def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001863 "sub{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001864 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001865let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001866 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001867 "sub{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001868 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001869 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001870 "sub{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001871 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001872 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001873 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001874 "sub{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001875 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001876 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001877 "sub{b}\t{$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001878 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001879 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001880 "sub{w}\t{$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001881 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001882 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001883 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001884 "sub{l}\t{$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001885 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001886 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001887 "sub{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001888 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1889 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001890 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001891 "sub{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001892 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001893}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001894
Evan Cheng64d80e32007-07-19 01:14:50 +00001895def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001896 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001897 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001898
Chris Lattner57a02302004-08-11 04:31:00 +00001899let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001900 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001901 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001902 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001903 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001904 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001905 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001906 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001907 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001908 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001909 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001910 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001911 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001912}
Evan Cheng64d80e32007-07-19 01:14:50 +00001913def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001914 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001915 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001916def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001917 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001918 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001919def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001920 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001921 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001922
Chris Lattner10197ff2005-01-03 01:27:59 +00001923let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Evan Cheng64d80e32007-07-19 01:14:50 +00001924def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001925 "imul{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001926 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2))]>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001927def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001928 "imul{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001929 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2))]>, TB;
Chris Lattner10197ff2005-01-03 01:27:59 +00001930}
Evan Cheng64d80e32007-07-19 01:14:50 +00001931def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001932 "imul{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001933 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2)))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001934 TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001935def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001936 "imul{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001937 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2)))]>, TB;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001938
1939} // end Two Address instructions
1940
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001941// Suprisingly enough, these are not two address instructions!
Evan Cheng069287d2006-05-16 07:21:53 +00001942def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00001943 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001944 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001945 [(set GR16:$dst, (mul GR16:$src1, imm:$src2))]>, OpSize;
1946def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00001947 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001948 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001949 [(set GR32:$dst, (mul GR32:$src1, imm:$src2))]>;
1950def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00001951 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001952 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001953 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001954 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001955def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00001956 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001957 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001958 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001959
Evan Cheng069287d2006-05-16 07:21:53 +00001960def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00001961 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001962 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001963 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2))]>,
Evan Chengf281e022005-12-12 23:47:46 +00001964 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001965def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00001966 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001967 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001968 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2))]>;
1969def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00001970 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001971 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001972 [(set GR16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001973 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001974def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00001975 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001976 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001977 [(set GR32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001978
1979//===----------------------------------------------------------------------===//
1980// Test instructions are just like AND, except they don't generate a result.
Chris Lattner3a173df2004-10-03 20:35:00 +00001981//
Chris Lattnercc65bee2005-01-02 02:35:46 +00001982let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Cheng64d80e32007-07-19 01:14:50 +00001983def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001984 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerffc0b262006-09-07 20:33:45 +00001985 [(X86cmp (and GR8:$src1, GR8:$src2), 0)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001986def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001987 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerffc0b262006-09-07 20:33:45 +00001988 [(X86cmp (and GR16:$src1, GR16:$src2), 0)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001989def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001990 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerffc0b262006-09-07 20:33:45 +00001991 [(X86cmp (and GR32:$src1, GR32:$src2), 0)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001992}
Evan Cheng734503b2006-09-11 02:19:56 +00001993
Evan Cheng64d80e32007-07-19 01:14:50 +00001994def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001995 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng734503b2006-09-11 02:19:56 +00001996 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001997def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001998 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng734503b2006-09-11 02:19:56 +00001999 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0)]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002000 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002001def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002002 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng734503b2006-09-11 02:19:56 +00002003 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002004
Evan Cheng069287d2006-05-16 07:21:53 +00002005def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00002006 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002007 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerffc0b262006-09-07 20:33:45 +00002008 [(X86cmp (and GR8:$src1, imm:$src2), 0)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00002009def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00002010 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002011 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerffc0b262006-09-07 20:33:45 +00002012 [(X86cmp (and GR16:$src1, imm:$src2), 0)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002013def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00002014 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002015 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerffc0b262006-09-07 20:33:45 +00002016 [(X86cmp (and GR32:$src1, imm:$src2), 0)]>;
Evan Cheng734503b2006-09-11 02:19:56 +00002017
Chris Lattner707c6fe2004-10-04 01:38:10 +00002018def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00002019 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002020 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng734503b2006-09-11 02:19:56 +00002021 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0)]>;
Chris Lattner707c6fe2004-10-04 01:38:10 +00002022def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00002023 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002024 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng734503b2006-09-11 02:19:56 +00002025 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0)]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002026 OpSize;
Chris Lattner707c6fe2004-10-04 01:38:10 +00002027def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00002028 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002029 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng734503b2006-09-11 02:19:56 +00002030 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002031
2032
2033// Condition code ops, incl. set if equal/not equal/...
Evan Cheng64d80e32007-07-19 01:14:50 +00002034def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>, Imp<[AH],[]>; // flags = AH
2035def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>, Imp<[],[AH]>; // AH = flags
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002036
Chris Lattner3a173df2004-10-03 20:35:00 +00002037def SETEr : I<0x94, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002038 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002039 "sete\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002040 [(set GR8:$dst, (X86setcc X86_COND_E))]>,
2041 TB; // GR8 = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00002042def SETEm : I<0x94, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002043 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002044 "sete\t$dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002045 [(store (X86setcc X86_COND_E), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002046 TB; // [mem8] = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00002047def SETNEr : I<0x95, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002048 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002049 "setne\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002050 [(set GR8:$dst, (X86setcc X86_COND_NE))]>,
2051 TB; // GR8 = !=
Chris Lattner3a173df2004-10-03 20:35:00 +00002052def SETNEm : I<0x95, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002053 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002054 "setne\t$dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002055 [(store (X86setcc X86_COND_NE), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002056 TB; // [mem8] = !=
2057def SETLr : I<0x9C, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002058 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002059 "setl\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002060 [(set GR8:$dst, (X86setcc X86_COND_L))]>,
2061 TB; // GR8 = < signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002062def SETLm : I<0x9C, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002063 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002064 "setl\t$dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002065 [(store (X86setcc X86_COND_L), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002066 TB; // [mem8] = < signed
2067def SETGEr : I<0x9D, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002068 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002069 "setge\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002070 [(set GR8:$dst, (X86setcc X86_COND_GE))]>,
2071 TB; // GR8 = >= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002072def SETGEm : I<0x9D, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002073 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002074 "setge\t$dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002075 [(store (X86setcc X86_COND_GE), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002076 TB; // [mem8] = >= signed
2077def SETLEr : I<0x9E, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002078 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002079 "setle\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002080 [(set GR8:$dst, (X86setcc X86_COND_LE))]>,
2081 TB; // GR8 = <= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002082def SETLEm : I<0x9E, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002083 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002084 "setle\t$dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002085 [(store (X86setcc X86_COND_LE), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002086 TB; // [mem8] = <= signed
2087def SETGr : I<0x9F, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002088 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002089 "setg\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002090 [(set GR8:$dst, (X86setcc X86_COND_G))]>,
2091 TB; // GR8 = > signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002092def SETGm : I<0x9F, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002093 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002094 "setg\t$dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002095 [(store (X86setcc X86_COND_G), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002096 TB; // [mem8] = > signed
2097
2098def SETBr : I<0x92, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002099 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002100 "setb\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002101 [(set GR8:$dst, (X86setcc X86_COND_B))]>,
2102 TB; // GR8 = < unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00002103def SETBm : I<0x92, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002104 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002105 "setb\t$dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002106 [(store (X86setcc X86_COND_B), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002107 TB; // [mem8] = < unsign
2108def SETAEr : I<0x93, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002109 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002110 "setae\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002111 [(set GR8:$dst, (X86setcc X86_COND_AE))]>,
2112 TB; // GR8 = >= unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00002113def SETAEm : I<0x93, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002114 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002115 "setae\t$dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002116 [(store (X86setcc X86_COND_AE), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002117 TB; // [mem8] = >= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002118def SETBEr : I<0x96, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002119 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002120 "setbe\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002121 [(set GR8:$dst, (X86setcc X86_COND_BE))]>,
2122 TB; // GR8 = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002123def SETBEm : I<0x96, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002124 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002125 "setbe\t$dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002126 [(store (X86setcc X86_COND_BE), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002127 TB; // [mem8] = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002128def SETAr : I<0x97, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002129 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002130 "seta\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002131 [(set GR8:$dst, (X86setcc X86_COND_A))]>,
2132 TB; // GR8 = > signed
Chris Lattner3a173df2004-10-03 20:35:00 +00002133def SETAm : I<0x97, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002134 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002135 "seta\t$dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002136 [(store (X86setcc X86_COND_A), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002137 TB; // [mem8] = > signed
Evan Chengd9558e02006-01-06 00:43:03 +00002138
Chris Lattner3a173df2004-10-03 20:35:00 +00002139def SETSr : I<0x98, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002140 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002141 "sets\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002142 [(set GR8:$dst, (X86setcc X86_COND_S))]>,
2143 TB; // GR8 = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002144def SETSm : I<0x98, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002145 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002146 "sets\t$dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002147 [(store (X86setcc X86_COND_S), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002148 TB; // [mem8] = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002149def SETNSr : I<0x99, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002150 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002151 "setns\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002152 [(set GR8:$dst, (X86setcc X86_COND_NS))]>,
2153 TB; // GR8 = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002154def SETNSm : I<0x99, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002155 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002156 "setns\t$dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002157 [(store (X86setcc X86_COND_NS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002158 TB; // [mem8] = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002159def SETPr : I<0x9A, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002160 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002161 "setp\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002162 [(set GR8:$dst, (X86setcc X86_COND_P))]>,
2163 TB; // GR8 = parity
Chris Lattner3a173df2004-10-03 20:35:00 +00002164def SETPm : I<0x9A, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002165 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002166 "setp\t$dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002167 [(store (X86setcc X86_COND_P), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002168 TB; // [mem8] = parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002169def SETNPr : I<0x9B, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002170 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002171 "setnp\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002172 [(set GR8:$dst, (X86setcc X86_COND_NP))]>,
2173 TB; // GR8 = not parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002174def SETNPm : I<0x9B, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002175 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002176 "setnp\t$dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002177 [(store (X86setcc X86_COND_NP), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002178 TB; // [mem8] = not parity
Chris Lattner1cca5e32003-08-03 21:54:21 +00002179
2180// Integer comparisons
Chris Lattner3a173df2004-10-03 20:35:00 +00002181def CMP8rr : I<0x38, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002182 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002183 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002184 [(X86cmp GR8:$src1, GR8:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002185def CMP16rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002186 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002187 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002188 [(X86cmp GR16:$src1, GR16:$src2)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002189def CMP32rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002190 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002191 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002192 [(X86cmp GR32:$src1, GR32:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002193def CMP8mr : I<0x38, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002194 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002195 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002196 [(X86cmp (loadi8 addr:$src1), GR8:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002197def CMP16mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002198 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002199 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002200 [(X86cmp (loadi16 addr:$src1), GR16:$src2)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002201def CMP32mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002202 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002203 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002204 [(X86cmp (loadi32 addr:$src1), GR32:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002205def CMP8rm : I<0x3A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002206 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002207 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002208 [(X86cmp GR8:$src1, (loadi8 addr:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002209def CMP16rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002210 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002211 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002212 [(X86cmp GR16:$src1, (loadi16 addr:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002213def CMP32rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002214 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002215 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002216 [(X86cmp GR32:$src1, (loadi32 addr:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002217def CMP8ri : Ii8<0x80, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002218 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002219 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002220 [(X86cmp GR8:$src1, imm:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002221def CMP16ri : Ii16<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002222 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002223 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002224 [(X86cmp GR16:$src1, imm:$src2)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002225def CMP32ri : Ii32<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002226 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002227 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002228 [(X86cmp GR32:$src1, imm:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002229def CMP8mi : Ii8 <0x80, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002230 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002231 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002232 [(X86cmp (loadi8 addr:$src1), imm:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002233def CMP16mi : Ii16<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002234 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002235 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002236 [(X86cmp (loadi16 addr:$src1), imm:$src2)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002237def CMP32mi : Ii32<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002238 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002239 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002240 [(X86cmp (loadi32 addr:$src1), imm:$src2)]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002241def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002242 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002243 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002244 [(X86cmp GR16:$src1, i16immSExt8:$src2)]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002245def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002246 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002247 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Nate Begemance944822006-03-23 01:29:48 +00002248 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2)]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002249def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002250 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002251 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Nate Begemance944822006-03-23 01:29:48 +00002252 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2)]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002253def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002254 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002255 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002256 [(X86cmp GR32:$src1, i32immSExt8:$src2)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +00002257
2258// Sign/Zero extenders
Evan Cheng64d80e32007-07-19 01:14:50 +00002259def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002260 "movs{bw|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002261 [(set GR16:$dst, (sext GR8:$src))]>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002262def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002263 "movs{bw|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002264 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002265def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002266 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002267 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002268def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002269 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002270 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002271def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002272 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002273 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002274def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002275 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002276 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
Alkis Evlogimenosa7be9822004-02-17 09:14:23 +00002277
Evan Cheng64d80e32007-07-19 01:14:50 +00002278def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002279 "movz{bw|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002280 [(set GR16:$dst, (zext GR8:$src))]>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002281def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002282 "movz{bw|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002283 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002284def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002285 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002286 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002287def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002288 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002289 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002290def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002291 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002292 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002293def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002294 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002295 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
Evan Cheng7a7e8372005-12-14 02:22:27 +00002296
Evan Cheng64d80e32007-07-19 01:14:50 +00002297def CBW : I<0x98, RawFrm, (outs), (ins),
Chris Lattnerd06b2ab2007-01-24 18:31:00 +00002298 "{cbtw|cbw}", []>, Imp<[AL],[AX]>, OpSize; // AX = signext(AL)
Evan Cheng64d80e32007-07-19 01:14:50 +00002299def CWDE : I<0x98, RawFrm, (outs), (ins),
Evan Chengf91c1012006-05-31 22:05:11 +00002300 "{cwtl|cwde}", []>, Imp<[AX],[EAX]>; // EAX = signext(AX)
2301
Evan Cheng64d80e32007-07-19 01:14:50 +00002302def CWD : I<0x99, RawFrm, (outs), (ins),
Chris Lattnerd06b2ab2007-01-24 18:31:00 +00002303 "{cwtd|cwd}", []>, Imp<[AX],[AX,DX]>, OpSize; // DX:AX = signext(AX)
Evan Cheng64d80e32007-07-19 01:14:50 +00002304def CDQ : I<0x99, RawFrm, (outs), (ins),
Evan Chengf91c1012006-05-31 22:05:11 +00002305 "{cltd|cdq}", []>, Imp<[EAX],[EAX,EDX]>; // EDX:EAX = signext(EAX)
2306
Evan Cheng747a90d2006-02-21 02:24:38 +00002307
Evan Cheng747a90d2006-02-21 02:24:38 +00002308//===----------------------------------------------------------------------===//
2309// Alias Instructions
2310//===----------------------------------------------------------------------===//
2311
2312// Alias instructions that map movr0 to xor.
2313// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Evan Cheng64d80e32007-07-19 01:14:50 +00002314def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002315 "xor{b}\t$dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002316 [(set GR8:$dst, 0)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002317def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002318 "xor{w}\t$dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002319 [(set GR16:$dst, 0)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002320def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002321 "xor{l}\t$dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002322 [(set GR32:$dst, 0)]>;
Evan Cheng747a90d2006-02-21 02:24:38 +00002323
Evan Cheng069287d2006-05-16 07:21:53 +00002324// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2325// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
Evan Cheng64d80e32007-07-19 01:14:50 +00002326def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002327 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002328def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002329 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng403be7e2006-05-08 08:01:26 +00002330
Evan Cheng64d80e32007-07-19 01:14:50 +00002331def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002332 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002333def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002334 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002335def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002336 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002337def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002338 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002339def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002340 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002341def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002342 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng403be7e2006-05-08 08:01:26 +00002343
Evan Cheng510e4782006-01-09 23:10:28 +00002344//===----------------------------------------------------------------------===//
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00002345// Thread Local Storage Instructions
2346//
2347
Evan Cheng64d80e32007-07-19 01:14:50 +00002348def TLS_addr : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002349 "leal\t${sym:mem}(,%ebx,1), $dst",
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00002350 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>,
2351 Imp<[EBX],[]>;
2352
Lauro Ramos Venancio7d2cc2b2007-04-22 22:50:52 +00002353let AddedComplexity = 10 in
Evan Cheng64d80e32007-07-19 01:14:50 +00002354def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002355 "movl\t%gs:($src), $dst",
Lauro Ramos Venancioede1d782007-04-23 01:28:10 +00002356 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2357
2358let AddedComplexity = 15 in
Evan Cheng64d80e32007-07-19 01:14:50 +00002359def TLS_gs_ri : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002360 "movl\t%gs:${src:mem}, $dst",
Lauro Ramos Venancioede1d782007-04-23 01:28:10 +00002361 [(set GR32:$dst,
2362 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>;
Lauro Ramos Venancio7d2cc2b2007-04-22 22:50:52 +00002363
Evan Cheng64d80e32007-07-19 01:14:50 +00002364def TLS_tp : I<0, Pseudo, (outs GR32:$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002365 "movl\t%gs:0, $dst",
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00002366 [(set GR32:$dst, X86TLStp)]>;
2367
2368//===----------------------------------------------------------------------===//
Evan Cheng3c992d22006-03-07 02:02:57 +00002369// DWARF Pseudo Instructions
2370//
2371
Evan Cheng64d80e32007-07-19 01:14:50 +00002372def DWARF_LOC : I<0, Pseudo, (outs),
2373 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohmanb6bbe392007-07-26 15:24:15 +00002374 "; .loc ${file:debug}, ${line:debug}, ${col:debug}",
Evan Cheng3c992d22006-03-07 02:02:57 +00002375 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2376 (i32 imm:$file))]>;
2377
Evan Cheng3c992d22006-03-07 02:02:57 +00002378//===----------------------------------------------------------------------===//
Anton Korobeynikov2365f512007-07-14 14:06:15 +00002379// EH Pseudo Instructions
2380//
2381let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Chengffbacca2007-07-21 00:34:19 +00002382 hasCtrlDep = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002383def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002384 "ret\t#eh_return, addr: $addr",
Anton Korobeynikov2365f512007-07-14 14:06:15 +00002385 [(X86ehret GR32:$addr)]>;
2386
2387}
2388
2389//===----------------------------------------------------------------------===//
Evan Cheng510e4782006-01-09 23:10:28 +00002390// Non-Instruction Patterns
2391//===----------------------------------------------------------------------===//
2392
Evan Cheng25ab6902006-09-08 06:48:29 +00002393// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Evan Cheng71fb8342006-02-25 10:02:21 +00002394def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
Nate Begeman37efe672006-04-22 18:53:45 +00002395def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Lauro Ramos Venancioede1d782007-04-23 01:28:10 +00002396def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)), (MOV32ri tglobaltlsaddr:$dst)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00002397def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2398def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2399
Evan Cheng069287d2006-05-16 07:21:53 +00002400def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2401 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2402def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2403 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2404def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2405 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
2406def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
2407 (ADD32ri GR32:$src1, texternalsym:$src2)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00002408
Evan Chengfc8feb12006-05-19 07:30:36 +00002409def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00002410 (MOV32mi addr:$dst, tglobaladdr:$src)>;
Evan Chengfc8feb12006-05-19 07:30:36 +00002411def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00002412 (MOV32mi addr:$dst, texternalsym:$src)>;
2413
Evan Cheng510e4782006-01-09 23:10:28 +00002414// Calls
Evan Cheng069287d2006-05-16 07:21:53 +00002415def : Pat<(X86tailcall GR32:$dst),
Evan Cheng25ab6902006-09-08 06:48:29 +00002416 (CALL32r GR32:$dst)>;
Evan Chengfea89c12006-04-27 08:40:39 +00002417
Evan Cheng25ab6902006-09-08 06:48:29 +00002418def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Evan Chengfea89c12006-04-27 08:40:39 +00002419 (CALLpcrel32 tglobaladdr:$dst)>;
Evan Cheng25ab6902006-09-08 06:48:29 +00002420def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Evan Chengfea89c12006-04-27 08:40:39 +00002421 (CALLpcrel32 texternalsym:$dst)>;
2422
Evan Cheng25ab6902006-09-08 06:48:29 +00002423def : Pat<(X86call (i32 tglobaladdr:$dst)),
Evan Cheng510e4782006-01-09 23:10:28 +00002424 (CALLpcrel32 tglobaladdr:$dst)>;
Evan Cheng25ab6902006-09-08 06:48:29 +00002425def : Pat<(X86call (i32 texternalsym:$dst)),
Evan Cheng8700e142006-01-11 06:09:51 +00002426 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002427
2428// X86 specific add which produces a flag.
Evan Cheng069287d2006-05-16 07:21:53 +00002429def : Pat<(addc GR32:$src1, GR32:$src2),
2430 (ADD32rr GR32:$src1, GR32:$src2)>;
2431def : Pat<(addc GR32:$src1, (load addr:$src2)),
2432 (ADD32rm GR32:$src1, addr:$src2)>;
2433def : Pat<(addc GR32:$src1, imm:$src2),
2434 (ADD32ri GR32:$src1, imm:$src2)>;
2435def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
2436 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002437
Evan Cheng069287d2006-05-16 07:21:53 +00002438def : Pat<(subc GR32:$src1, GR32:$src2),
2439 (SUB32rr GR32:$src1, GR32:$src2)>;
2440def : Pat<(subc GR32:$src1, (load addr:$src2)),
2441 (SUB32rm GR32:$src1, addr:$src2)>;
2442def : Pat<(subc GR32:$src1, imm:$src2),
2443 (SUB32ri GR32:$src1, imm:$src2)>;
2444def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
2445 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002446
Evan Cheng8b2794a2006-10-13 21:14:26 +00002447def : Pat<(truncstorei1 (i8 imm:$src), addr:$dst),
Evan Chengb8414332006-01-13 21:45:19 +00002448 (MOV8mi addr:$dst, imm:$src)>;
Evan Cheng8b2794a2006-10-13 21:14:26 +00002449def : Pat<(truncstorei1 GR8:$src, addr:$dst),
Evan Cheng069287d2006-05-16 07:21:53 +00002450 (MOV8mr addr:$dst, GR8:$src)>;
Evan Chengb8414332006-01-13 21:45:19 +00002451
Chris Lattnerffc0b262006-09-07 20:33:45 +00002452// Comparisons.
2453
2454// TEST R,R is smaller than CMP R,0
2455def : Pat<(X86cmp GR8:$src1, 0),
2456 (TEST8rr GR8:$src1, GR8:$src1)>;
2457def : Pat<(X86cmp GR16:$src1, 0),
2458 (TEST16rr GR16:$src1, GR16:$src1)>;
2459def : Pat<(X86cmp GR32:$src1, 0),
2460 (TEST32rr GR32:$src1, GR32:$src1)>;
2461
Evan Cheng510e4782006-01-09 23:10:28 +00002462// {s|z}extload bool -> {s|z}extload byte
2463def : Pat<(sextloadi16i1 addr:$src), (MOVSX16rm8 addr:$src)>;
2464def : Pat<(sextloadi32i1 addr:$src), (MOVSX32rm8 addr:$src)>;
Evan Chenge5d93432006-01-17 07:02:46 +00002465def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002466def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2467def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2468
2469// extload bool -> extload byte
Evan Cheng47137242006-05-05 08:23:07 +00002470def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2471def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2472def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2473def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
2474def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
2475def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002476
2477// anyext -> zext
Evan Cheng069287d2006-05-16 07:21:53 +00002478def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
2479def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
2480def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
Evan Cheng6e16ee52006-03-25 09:45:48 +00002481def : Pat<(i16 (anyext (loadi8 addr:$src))), (MOVZX16rm8 addr:$src)>;
2482def : Pat<(i32 (anyext (loadi8 addr:$src))), (MOVZX32rm8 addr:$src)>;
2483def : Pat<(i32 (anyext (loadi16 addr:$src))), (MOVZX32rm16 addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002484
Evan Chengcfa260b2006-01-06 02:31:59 +00002485//===----------------------------------------------------------------------===//
2486// Some peepholes
2487//===----------------------------------------------------------------------===//
2488
2489// (shl x, 1) ==> (add x, x)
Evan Cheng069287d2006-05-16 07:21:53 +00002490def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
2491def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
2492def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00002493
Evan Cheng956044c2006-01-19 23:26:24 +00002494// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00002495def : Pat<(or (srl GR32:$src1, CL:$amt),
2496 (shl GR32:$src2, (sub 32, CL:$amt))),
2497 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00002498
Evan Cheng21d54432006-01-20 01:13:30 +00002499def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00002500 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2501 (SHRD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00002502
Evan Cheng956044c2006-01-19 23:26:24 +00002503// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00002504def : Pat<(or (shl GR32:$src1, CL:$amt),
2505 (srl GR32:$src2, (sub 32, CL:$amt))),
2506 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00002507
Evan Cheng21d54432006-01-20 01:13:30 +00002508def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00002509 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2510 (SHLD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00002511
Evan Cheng956044c2006-01-19 23:26:24 +00002512// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00002513def : Pat<(or (srl GR16:$src1, CL:$amt),
2514 (shl GR16:$src2, (sub 16, CL:$amt))),
2515 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00002516
Evan Cheng21d54432006-01-20 01:13:30 +00002517def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00002518 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2519 (SHRD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00002520
Evan Cheng956044c2006-01-19 23:26:24 +00002521// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00002522def : Pat<(or (shl GR16:$src1, CL:$amt),
2523 (srl GR16:$src2, (sub 16, CL:$amt))),
2524 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00002525
2526def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00002527 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2528 (SHLD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +00002529
2530
2531//===----------------------------------------------------------------------===//
2532// Floating Point Stack Support
2533//===----------------------------------------------------------------------===//
2534
2535include "X86InstrFPStack.td"
2536
2537//===----------------------------------------------------------------------===//
Evan Chengc64a1a92007-07-31 08:04:03 +00002538// X86-64 Support
2539//===----------------------------------------------------------------------===//
2540
2541include "X86InstrX86-64.td"
2542
2543//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00002544// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
2545//===----------------------------------------------------------------------===//
2546
2547include "X86InstrMMX.td"
2548
2549//===----------------------------------------------------------------------===//
2550// XMM Floating point support (requires SSE / SSE2)
2551//===----------------------------------------------------------------------===//
2552
2553include "X86InstrSSE.td"