blob: f4a201c4b08e1a2d4171f2a9ec1e740c460ed3fb [file] [log] [blame]
Arnold Schwaighofer373e8652007-10-12 21:30:57 +00001//===- X86InstrInfo.td - Describe the X86 Instruction Set --*- tablegen -*-===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file describes the X86 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
16//===----------------------------------------------------------------------===//
17// X86 specific DAG Nodes.
18//
19
20def SDTIntShiftDOp: SDTypeProfile<1, 3,
21 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
22 SDTCisInt<0>, SDTCisInt<3>]>;
23
24def SDTX86CmpTest : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
25
Evan Cheng621216e2007-09-29 00:00:36 +000026def SDTX86Cmov : SDTypeProfile<1, 4,
Evan Cheng950aac02007-09-25 01:57:46 +000027 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
28 SDTCisVT<3, i8>, SDTCisVT<4, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000029
Dan Gohman99a12192009-03-04 19:44:21 +000030// Unary and binary operator instructions that set EFLAGS as a side-effect.
31def SDTUnaryArithWithFlags : SDTypeProfile<1, 1,
32 [SDTCisInt<0>]>;
33def SDTBinaryArithWithFlags : SDTypeProfile<1, 2,
34 [SDTCisSameAs<0, 1>,
35 SDTCisSameAs<0, 2>,
36 SDTCisInt<0>]>;
Evan Cheng621216e2007-09-29 00:00:36 +000037def SDTX86BrCond : SDTypeProfile<0, 3,
Evan Cheng950aac02007-09-25 01:57:46 +000038 [SDTCisVT<0, OtherVT>,
39 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000040
Evan Cheng621216e2007-09-29 00:00:36 +000041def SDTX86SetCC : SDTypeProfile<1, 2,
Evan Cheng950aac02007-09-25 01:57:46 +000042 [SDTCisVT<0, i8>,
43 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000044
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000045def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
46 SDTCisVT<2, i8>]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000047def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000048
Dale Johannesenf160d802008-10-02 18:53:47 +000049def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
50 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +000051def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000052
Sean Callanan2c8a2592009-06-23 23:25:37 +000053def SDT_X86CallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>]>;
54def SDT_X86CallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i32>,
55 SDTCisVT<1, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000056
Dan Gohman3329ffe2008-05-29 19:57:41 +000057def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000058
Dan Gohman34228bf2009-08-15 01:38:56 +000059def SDT_X86VASTART_SAVE_XMM_REGS : SDTypeProfile<0, -1, [SDTCisVT<0, i8>,
60 SDTCisVT<1, iPTR>,
61 SDTCisVT<2, iPTR>]>;
62
Dan Gohmanf17a25c2007-07-18 16:29:46 +000063def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
64
65def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
66
67def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
68
Rafael Espindolaaf759ab2009-04-17 14:35:58 +000069def SDT_X86TLSADDR : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000070
Rafael Espindolabca99f72009-04-08 21:14:34 +000071def SDT_X86SegmentBaseAddress : SDTypeProfile<1, 1, [SDTCisPtrTy<0>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000072
73def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
74
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +000075def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
76
Evan Cheng48679f42007-12-14 02:13:44 +000077def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
78def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000079def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
80def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
81
Evan Cheng621216e2007-09-29 00:00:36 +000082def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000083
Dan Gohman7fe9b7f2008-12-23 22:45:23 +000084def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
85
Evan Cheng621216e2007-09-29 00:00:36 +000086def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000087def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng950aac02007-09-25 01:57:46 +000088 [SDNPHasChain]>;
Evan Cheng621216e2007-09-29 00:00:36 +000089def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000090
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000091def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
92 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
93 SDNPMayLoad]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000094def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
95 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
96 SDNPMayLoad]>;
Dale Johannesenf160d802008-10-02 18:53:47 +000097def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
98 [SDNPHasChain, SDNPMayStore,
99 SDNPMayLoad, SDNPMemOperand]>;
100def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
101 [SDNPHasChain, SDNPMayStore,
102 SDNPMayLoad, SDNPMemOperand]>;
103def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
104 [SDNPHasChain, SDNPMayStore,
105 SDNPMayLoad, SDNPMemOperand]>;
106def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
107 [SDNPHasChain, SDNPMayStore,
108 SDNPMayLoad, SDNPMemOperand]>;
109def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
110 [SDNPHasChain, SDNPMayStore,
111 SDNPMayLoad, SDNPMemOperand]>;
112def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
113 [SDNPHasChain, SDNPMayStore,
114 SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +0000115def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
116 [SDNPHasChain, SDNPMayStore,
117 SDNPMayLoad, SDNPMemOperand]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000118def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
119 [SDNPHasChain, SDNPOptInFlag]>;
120
Dan Gohman34228bf2009-08-15 01:38:56 +0000121def X86vastart_save_xmm_regs :
122 SDNode<"X86ISD::VASTART_SAVE_XMM_REGS",
123 SDT_X86VASTART_SAVE_XMM_REGS,
124 [SDNPHasChain]>;
125
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000126def X86callseq_start :
127 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
128 [SDNPHasChain, SDNPOutFlag]>;
129def X86callseq_end :
130 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000131 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000132
133def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
134 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
135
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000136def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000137 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000138def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000139 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
140 SDNPMayLoad]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000141
142def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000143 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000144
145def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
146def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
147
148def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +0000149 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Rafael Espindolabca99f72009-04-08 21:14:34 +0000150def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
151 SDT_X86SegmentBaseAddress, []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000152
153def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
154 [SDNPHasChain]>;
155
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000156def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
157 [SDNPHasChain, SDNPOptInFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000158
Dan Gohman99a12192009-03-04 19:44:21 +0000159def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags>;
160def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
161def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags>;
162def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags>;
163def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
164def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
Dan Gohman12e03292009-09-18 19:59:53 +0000165def X86or_flag : SDNode<"X86ISD::OR", SDTBinaryArithWithFlags>;
166def X86xor_flag : SDNode<"X86ISD::XOR", SDTBinaryArithWithFlags>;
167def X86and_flag : SDNode<"X86ISD::AND", SDTBinaryArithWithFlags>;
Bill Wendlingae034ed2008-12-12 00:56:36 +0000168
Evan Chengc3495762009-03-30 21:36:47 +0000169def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
170
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000171//===----------------------------------------------------------------------===//
172// X86 Operand Definitions.
173//
174
Chris Lattner357a0ca2009-06-20 19:34:09 +0000175def i32imm_pcrel : Operand<i32> {
176 let PrintMethod = "print_pcrel_imm";
177}
178
Dan Gohmanfe606822009-07-30 01:56:29 +0000179// A version of ptr_rc which excludes SP, ESP, and RSP. This is used for
180// the index operand of an address, to conform to x86 encoding restrictions.
181def ptr_rc_nosp : PointerLikeRegClass<1>;
Chris Lattner357a0ca2009-06-20 19:34:09 +0000182
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000183// *mem - Operand definitions for the funky X86 addressing mode operands.
184//
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000185def X86MemAsmOperand : AsmOperandClass {
186 let Name = "Mem";
Daniel Dunbar6e9ee792009-08-10 19:08:02 +0000187 let SuperClass = ?;
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000188}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000189class X86MemOperand<string printMethod> : Operand<iPTR> {
190 let PrintMethod = printMethod;
Dan Gohmanfe606822009-07-30 01:56:29 +0000191 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000192 let ParserMatchClass = X86MemAsmOperand;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000193}
194
Sean Callanan66fdfa02009-09-03 00:04:47 +0000195def opaque32mem : X86MemOperand<"printopaquemem">;
196def opaque48mem : X86MemOperand<"printopaquemem">;
197def opaque80mem : X86MemOperand<"printopaquemem">;
198
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000199def i8mem : X86MemOperand<"printi8mem">;
200def i16mem : X86MemOperand<"printi16mem">;
201def i32mem : X86MemOperand<"printi32mem">;
202def i64mem : X86MemOperand<"printi64mem">;
203def i128mem : X86MemOperand<"printi128mem">;
Chris Lattnerd6153b42009-09-20 07:17:49 +0000204//def i256mem : X86MemOperand<"printi256mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000205def f32mem : X86MemOperand<"printf32mem">;
206def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000207def f80mem : X86MemOperand<"printf80mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000208def f128mem : X86MemOperand<"printf128mem">;
Chris Lattnerd6153b42009-09-20 07:17:49 +0000209//def f256mem : X86MemOperand<"printf256mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000210
Dan Gohman744d4622009-04-13 16:09:41 +0000211// A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
212// plain GR64, so that it doesn't potentially require a REX prefix.
213def i8mem_NOREX : Operand<i64> {
214 let PrintMethod = "printi8mem";
Dan Gohmanfe606822009-07-30 01:56:29 +0000215 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX_NOSP, i32imm, i8imm);
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000216 let ParserMatchClass = X86MemAsmOperand;
Dan Gohman744d4622009-04-13 16:09:41 +0000217}
218
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000219def lea32mem : Operand<i32> {
Rafael Espindolabca99f72009-04-08 21:14:34 +0000220 let PrintMethod = "printlea32mem";
Dan Gohmanefbd3bc2009-08-05 17:40:24 +0000221 let MIOperandInfo = (ops GR32, i8imm, GR32_NOSP, i32imm);
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000222 let ParserMatchClass = X86MemAsmOperand;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000223}
224
225def SSECC : Operand<i8> {
226 let PrintMethod = "printSSECC";
227}
228
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000229def ImmSExt8AsmOperand : AsmOperandClass {
230 let Name = "ImmSExt8";
231 let SuperClass = ImmAsmOperand;
232}
233
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000234// A couple of more descriptive operand definitions.
235// 16-bits but only 8 bits are significant.
Daniel Dunbar06d5cb62009-08-09 07:20:21 +0000236def i16i8imm : Operand<i16> {
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000237 let ParserMatchClass = ImmSExt8AsmOperand;
Daniel Dunbar06d5cb62009-08-09 07:20:21 +0000238}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000239// 32-bits but only 8 bits are significant.
Daniel Dunbar06d5cb62009-08-09 07:20:21 +0000240def i32i8imm : Operand<i32> {
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000241 let ParserMatchClass = ImmSExt8AsmOperand;
Daniel Dunbar06d5cb62009-08-09 07:20:21 +0000242}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000243
Chris Lattner357a0ca2009-06-20 19:34:09 +0000244// Branch targets have OtherVT type and print as pc-relative values.
245def brtarget : Operand<OtherVT> {
246 let PrintMethod = "print_pcrel_imm";
247}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000248
Evan Chengd11052b2009-07-21 06:00:18 +0000249def brtarget8 : Operand<OtherVT> {
250 let PrintMethod = "print_pcrel_imm";
251}
252
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000253//===----------------------------------------------------------------------===//
254// X86 Complex Pattern Definitions.
255//
256
257// Define X86 specific addressing mode.
Rafael Espindolabca99f72009-04-08 21:14:34 +0000258def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000259def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
Dan Gohman0c0d7412009-08-02 16:09:17 +0000260 [add, sub, mul, X86mul_imm, shl, or, frameindex],
261 []>;
Chris Lattnerf1940742009-06-20 20:38:48 +0000262def tls32addr : ComplexPattern<i32, 4, "SelectTLSADDRAddr",
263 [tglobaltlsaddr], []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000264
265//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000266// X86 Instruction Predicate Definitions.
267def HasMMX : Predicate<"Subtarget->hasMMX()">;
268def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
269def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
270def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
271def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begemanb2975562008-02-03 07:18:54 +0000272def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
273def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
David Greene8bf22bc2009-06-26 22:46:54 +0000274def HasSSE4A : Predicate<"Subtarget->hasSSE4A()">;
275def HasAVX : Predicate<"Subtarget->hasAVX()">;
276def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
277def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
Dale Johannesene0e0fd02007-09-23 14:52:20 +0000278def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
279def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000280def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
281def In64BitMode : Predicate<"Subtarget->is64Bit()">;
Anton Korobeynikov2cbcdb72009-08-03 08:12:53 +0000282def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
283def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">;
Anton Korobeynikov68d4eca2009-08-06 11:23:24 +0000284def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
285def KernelCode : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
286def FarData : Predicate<"TM.getCodeModel() != CodeModel::Small &&"
Anton Korobeynikov7e1178f2009-08-06 09:11:19 +0000287 "TM.getCodeModel() != CodeModel::Kernel">;
Anton Korobeynikov68d4eca2009-08-06 11:23:24 +0000288def NearData : Predicate<"TM.getCodeModel() == CodeModel::Small ||"
289 "TM.getCodeModel() == CodeModel::Kernel">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000290def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Cheng13559d62008-09-26 23:41:32 +0000291def OptForSpeed : Predicate<"!OptForSize">;
Evan Cheng95a77fd2009-01-02 05:35:45 +0000292def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Evan Cheng6d35a4d2009-05-20 04:53:57 +0000293def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000294
295//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000296// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000297//
298
Evan Cheng86ab7d32007-07-31 08:04:03 +0000299include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000300
301//===----------------------------------------------------------------------===//
302// Pattern fragments...
303//
304
305// X86 specific condition code. These correspond to CondCode in
306// X86InstrInfo.h. They must be kept in synch.
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000307def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
308def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
309def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
310def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
311def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
312def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
313def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
314def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
315def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
316def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000317def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000318def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000319def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000320def X86_COND_O : PatLeaf<(i8 13)>;
321def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
322def X86_COND_S : PatLeaf<(i8 15)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000323
324def i16immSExt8 : PatLeaf<(i16 imm), [{
325 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
326 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000327 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000328}]>;
329
330def i32immSExt8 : PatLeaf<(i32 imm), [{
331 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
332 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000333 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000334}]>;
335
336// Helper fragments for loads.
Evan Chengb3e25ea2008-05-13 18:59:59 +0000337// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
338// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman2a174122008-10-15 06:50:19 +0000339def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000340 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000341 if (const Value *Src = LD->getSrcValue())
342 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000343 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000344 return false;
Dan Gohman8335c412008-08-20 15:24:22 +0000345 ISD::LoadExtType ExtType = LD->getExtensionType();
346 if (ExtType == ISD::NON_EXTLOAD)
347 return true;
348 if (ExtType == ISD::EXTLOAD)
349 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000350 return false;
351}]>;
352
Dan Gohman2a174122008-10-15 06:50:19 +0000353def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng56ec77b2008-09-24 23:27:55 +0000354 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000355 if (const Value *Src = LD->getSrcValue())
356 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000357 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000358 return false;
Evan Cheng56ec77b2008-09-24 23:27:55 +0000359 ISD::LoadExtType ExtType = LD->getExtensionType();
360 if (ExtType == ISD::EXTLOAD)
361 return LD->getAlignment() >= 2 && !LD->isVolatile();
362 return false;
363}]>;
364
Dan Gohman2a174122008-10-15 06:50:19 +0000365def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000366 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000367 if (const Value *Src = LD->getSrcValue())
368 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000369 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000370 return false;
Dan Gohman8335c412008-08-20 15:24:22 +0000371 ISD::LoadExtType ExtType = LD->getExtensionType();
372 if (ExtType == ISD::NON_EXTLOAD)
373 return true;
374 if (ExtType == ISD::EXTLOAD)
375 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000376 return false;
377}]>;
378
Dan Gohman2a174122008-10-15 06:50:19 +0000379def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng1e5e5452008-09-29 17:26:18 +0000380 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000381 if (const Value *Src = LD->getSrcValue())
382 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000383 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000384 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000385 if (LD->isVolatile())
386 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000387 ISD::LoadExtType ExtType = LD->getExtensionType();
388 if (ExtType == ISD::NON_EXTLOAD)
389 return true;
390 if (ExtType == ISD::EXTLOAD)
391 return LD->getAlignment() >= 4;
392 return false;
393}]>;
394
sampo9cc09a32009-01-26 01:24:32 +0000395def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
Chris Lattner12208612009-04-10 00:16:23 +0000396 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
397 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
398 return PT->getAddressSpace() == 256;
sampo9cc09a32009-01-26 01:24:32 +0000399 return false;
400}]>;
401
Chris Lattnera7c2d8a2009-05-05 18:52:19 +0000402def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
403 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
404 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
405 return PT->getAddressSpace() == 257;
406 return false;
407}]>;
408
Chris Lattner12208612009-04-10 00:16:23 +0000409def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr)), [{
410 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
411 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000412 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000413 return false;
414 return true;
415}]>;
416def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr)), [{
417 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
418 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000419 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000420 return false;
421 return true;
422}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000423
Chris Lattner12208612009-04-10 00:16:23 +0000424def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr)), [{
425 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
426 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000427 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000428 return false;
429 return true;
430}]>;
431def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr)), [{
432 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
433 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000434 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000435 return false;
436 return true;
437}]>;
438def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr)), [{
439 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
440 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000441 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000442 return false;
443 return true;
444}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000445
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000446def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
447def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
448def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
449
450def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
451def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
452def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
453def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
454def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
455def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
456
457def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
458def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
459def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
460def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
461def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
462def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
463
Chris Lattner21da6382008-02-19 17:37:35 +0000464
465// An 'and' node with a single use.
466def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng9123cfa2008-03-04 00:40:35 +0000467 return N->hasOneUse();
Chris Lattner21da6382008-02-19 17:37:35 +0000468}]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000469// An 'srl' node with a single use.
470def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
471 return N->hasOneUse();
472}]>;
473// An 'trunc' node with a single use.
474def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
475 return N->hasOneUse();
476}]>;
Chris Lattner21da6382008-02-19 17:37:35 +0000477
Dan Gohman921581d2008-10-17 01:23:35 +0000478// 'shld' and 'shrd' instruction patterns. Note that even though these have
479// the srl and shl in their patterns, the C++ code must still check for them,
480// because predicates are tested before children nodes are explored.
481
482def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
483 (or (srl node:$src1, node:$amt1),
484 (shl node:$src2, node:$amt2)), [{
485 assert(N->getOpcode() == ISD::OR);
486 return N->getOperand(0).getOpcode() == ISD::SRL &&
487 N->getOperand(1).getOpcode() == ISD::SHL &&
488 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
489 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
490 N->getOperand(0).getConstantOperandVal(1) ==
491 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
492}]>;
493
494def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
495 (or (shl node:$src1, node:$amt1),
496 (srl node:$src2, node:$amt2)), [{
497 assert(N->getOpcode() == ISD::OR);
498 return N->getOperand(0).getOpcode() == ISD::SHL &&
499 N->getOperand(1).getOpcode() == ISD::SRL &&
500 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
501 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
502 N->getOperand(0).getConstantOperandVal(1) ==
503 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
504}]>;
505
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000506//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000507// Instruction list...
508//
509
510// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
511// a stack adjustment and the codegen must know that they may modify the stack
512// pointer before prolog-epilog rewriting occurs.
Chris Lattnerb56cc342008-03-11 03:23:40 +0000513// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
514// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000515let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman01c9f772008-10-01 18:28:06 +0000516def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
517 "#ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000518 [(X86callseq_start timm:$amt)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000519 Requires<[In32BitMode]>;
520def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
521 "#ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000522 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000523 Requires<[In32BitMode]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000524}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000525
Dan Gohman34228bf2009-08-15 01:38:56 +0000526// x86-64 va_start lowering magic.
Dan Gohman30afe012009-10-29 18:10:34 +0000527let usesCustomInserter = 1 in
Dan Gohman34228bf2009-08-15 01:38:56 +0000528def VASTART_SAVE_XMM_REGS : I<0, Pseudo,
529 (outs),
530 (ins GR8:$al,
531 i64imm:$regsavefi, i64imm:$offset,
532 variable_ops),
533 "#VASTART_SAVE_XMM_REGS $al, $regsavefi, $offset",
534 [(X86vastart_save_xmm_regs GR8:$al,
535 imm:$regsavefi,
536 imm:$offset)]>;
537
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000538// Nop
Sean Callananf94a0542009-07-23 23:39:34 +0000539let neverHasSideEffects = 1 in {
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000540 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Sean Callananf94a0542009-07-23 23:39:34 +0000541 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
542 "nopl\t$zero", []>, TB;
543}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000544
Sean Callanan9b195f82009-08-11 01:09:06 +0000545// Trap
Dan Gohman8112b942009-11-11 18:07:16 +0000546def INT3 : I<0xcc, RawFrm, (outs), (ins), "int\t3", []>;
Sean Callanan9b195f82009-08-11 01:09:06 +0000547def INT : I<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap", []>;
548
Chris Lattner2aa10da2009-09-20 07:32:00 +0000549// PIC base construction. This expands to code that looks like this:
550// call $next_inst
551// popl %destreg"
Dan Gohman9499cfe2008-10-01 04:14:30 +0000552let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnera7e959d2009-09-20 07:28:26 +0000553 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins i32imm:$label),
Chris Lattner2aa10da2009-09-20 07:32:00 +0000554 "", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000555
556//===----------------------------------------------------------------------===//
557// Control Flow Instructions...
558//
559
560// Return instructions.
561let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000562 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000563 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000564 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000565 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000566 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
567 "ret\t$amt",
Dan Gohmane84197b2009-09-03 17:18:51 +0000568 [(X86retflag timm:$amt)]>;
Sean Callanan7a012572009-09-15 23:37:51 +0000569 def LRET : I <0xCB, RawFrm, (outs), (ins),
570 "lret", []>;
571 def LRETI : Ii16<0xCA, RawFrm, (outs), (ins i16imm:$amt),
572 "lret\t$amt", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000573}
574
575// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000576let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000577 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
578 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000579
Sean Callananc0608152009-07-22 01:05:20 +0000580let isBranch = 1, isBarrier = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000581 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Sean Callananc0608152009-07-22 01:05:20 +0000582 def JMP8 : IBr<0xEB, (ins brtarget8:$dst), "jmp\t$dst", []>;
583}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000584
Owen Andersonf8053082007-11-12 07:39:39 +0000585// Indirect branches
586let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000587 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000588 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000589 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000590 [(brind (loadi32 addr:$dst))]>;
Sean Callananb7e73392009-09-15 00:35:17 +0000591
592 def FARJMP16i : Iseg16<0xEA, RawFrm, (outs),
593 (ins i16imm:$seg, i16imm:$off),
594 "ljmp{w}\t$seg, $off", []>, OpSize;
595 def FARJMP32i : Iseg32<0xEA, RawFrm, (outs),
596 (ins i16imm:$seg, i32imm:$off),
597 "ljmp{l}\t$seg, $off", []>;
598
599 def FARJMP16m : I<0xFF, MRM5m, (outs), (ins opaque32mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000600 "ljmp{w}\t{*}$dst", []>, OpSize;
Sean Callananb7e73392009-09-15 00:35:17 +0000601 def FARJMP32m : I<0xFF, MRM5m, (outs), (ins opaque48mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000602 "ljmp{l}\t{*}$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000603}
604
605// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000606let Uses = [EFLAGS] in {
Evan Chengd11052b2009-07-21 06:00:18 +0000607// Short conditional jumps
608def JO8 : IBr<0x70, (ins brtarget8:$dst), "jo\t$dst", []>;
609def JNO8 : IBr<0x71, (ins brtarget8:$dst), "jno\t$dst", []>;
610def JB8 : IBr<0x72, (ins brtarget8:$dst), "jb\t$dst", []>;
611def JAE8 : IBr<0x73, (ins brtarget8:$dst), "jae\t$dst", []>;
612def JE8 : IBr<0x74, (ins brtarget8:$dst), "je\t$dst", []>;
613def JNE8 : IBr<0x75, (ins brtarget8:$dst), "jne\t$dst", []>;
614def JBE8 : IBr<0x76, (ins brtarget8:$dst), "jbe\t$dst", []>;
615def JA8 : IBr<0x77, (ins brtarget8:$dst), "ja\t$dst", []>;
616def JS8 : IBr<0x78, (ins brtarget8:$dst), "js\t$dst", []>;
617def JNS8 : IBr<0x79, (ins brtarget8:$dst), "jns\t$dst", []>;
618def JP8 : IBr<0x7A, (ins brtarget8:$dst), "jp\t$dst", []>;
619def JNP8 : IBr<0x7B, (ins brtarget8:$dst), "jnp\t$dst", []>;
620def JL8 : IBr<0x7C, (ins brtarget8:$dst), "jl\t$dst", []>;
621def JGE8 : IBr<0x7D, (ins brtarget8:$dst), "jge\t$dst", []>;
622def JLE8 : IBr<0x7E, (ins brtarget8:$dst), "jle\t$dst", []>;
623def JG8 : IBr<0x7F, (ins brtarget8:$dst), "jg\t$dst", []>;
624
625def JCXZ8 : IBr<0xE3, (ins brtarget8:$dst), "jcxz\t$dst", []>;
626
Dan Gohman91888f02007-07-31 20:11:57 +0000627def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000628 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000629def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000630 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000631def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000632 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000633def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000634 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000635def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000636 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000637def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000638 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000639
Dan Gohman91888f02007-07-31 20:11:57 +0000640def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000641 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000642def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000643 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000644def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000645 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000646def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000647 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000648
Dan Gohman91888f02007-07-31 20:11:57 +0000649def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000650 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000651def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000652 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000653def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000654 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000655def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000656 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000657def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000658 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000659def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000660 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000661} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000662
Sean Callanan503784b2009-09-16 21:50:07 +0000663// Loop instructions
664
665def LOOP : I<0xE2, RawFrm, (ins brtarget8:$dst), (outs), "loop\t$dst", []>;
666def LOOPE : I<0xE1, RawFrm, (ins brtarget8:$dst), (outs), "loope\t$dst", []>;
667def LOOPNE : I<0xE0, RawFrm, (ins brtarget8:$dst), (outs), "loopne\t$dst", []>;
668
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000669//===----------------------------------------------------------------------===//
670// Call Instructions...
671//
Evan Cheng37e7c752007-07-21 00:34:19 +0000672let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000673 // All calls clobber the non-callee saved registers. ESP is marked as
674 // a use to prevent stack-pointer assignments that appear immediately
675 // before calls from potentially appearing dead. Uses for argument
676 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000677 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
678 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng2293b252008-10-17 21:02:22 +0000679 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
680 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman9499cfe2008-10-01 04:14:30 +0000681 Uses = [ESP] in {
Chris Lattner357a0ca2009-06-20 19:34:09 +0000682 def CALLpcrel32 : Ii32<0xE8, RawFrm,
683 (outs), (ins i32imm_pcrel:$dst,variable_ops),
684 "call\t$dst", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000685 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000686 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000687 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000688 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Sean Callanan66fdfa02009-09-03 00:04:47 +0000689
Sean Callananb7e73392009-09-15 00:35:17 +0000690 def FARCALL16i : Iseg16<0x9A, RawFrm, (outs),
691 (ins i16imm:$seg, i16imm:$off),
692 "lcall{w}\t$seg, $off", []>, OpSize;
693 def FARCALL32i : Iseg32<0x9A, RawFrm, (outs),
694 (ins i16imm:$seg, i32imm:$off),
695 "lcall{l}\t$seg, $off", []>;
696
697 def FARCALL16m : I<0xFF, MRM3m, (outs), (ins opaque32mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000698 "lcall{w}\t{*}$dst", []>, OpSize;
Sean Callananb7e73392009-09-15 00:35:17 +0000699 def FARCALL32m : I<0xFF, MRM3m, (outs), (ins opaque48mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000700 "lcall{l}\t{*}$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000701 }
702
Sean Callanan51b7a992009-09-16 02:57:13 +0000703// Constructing a stack frame.
704
705def ENTER : I<0xC8, RawFrm, (outs), (ins i16imm:$len, i8imm:$lvl),
706 "enter\t$len, $lvl", []>;
707
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000708// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000709
Evan Cheng37e7c752007-07-21 00:34:19 +0000710let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000711def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000712 "#TC_RETURN $dst $offset",
713 []>;
714
715let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000716def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000717 "#TC_RETURN $dst $offset",
718 []>;
719
720let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Chris Lattner357a0ca2009-06-20 19:34:09 +0000721 def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000722 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000723let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000724 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
725 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000726let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000727 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000728 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000729
730//===----------------------------------------------------------------------===//
731// Miscellaneous Instructions...
732//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000733let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000734def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000735 (outs), (ins), "leave", []>;
736
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000737let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000738let mayLoad = 1 in {
739def POP16r : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
740 OpSize;
741def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
742def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
743 OpSize;
744def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
745 OpSize;
746def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
747def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
748}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000749
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000750let mayStore = 1 in {
751def PUSH16r : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
752 OpSize;
Evan Chengd8434332007-09-26 01:29:06 +0000753def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000754def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
755 OpSize;
756def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
757 OpSize;
758def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
759def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
760}
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000761}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000762
Bill Wendling4c2638c2009-06-15 19:39:04 +0000763let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
764def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000765 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000766def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000767 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000768def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000769 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000770}
771
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000772let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000773def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000774let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000775def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000776
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000777let isTwoAddress = 1 in // GR32 = bswap GR32
778 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000779 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000780 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000781 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
782
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000783
Evan Cheng48679f42007-12-14 02:13:44 +0000784// Bit scan instructions.
785let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000786def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000787 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000788 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000789def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000790 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000791 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
792 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000793def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000794 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000795 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000796def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000797 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000798 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
799 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000800
Evan Cheng4e33de92007-12-14 18:49:43 +0000801def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000802 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000803 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000804def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000805 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000806 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
807 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000808def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000809 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000810 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000811def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000812 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000813 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
814 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000815} // Defs = [EFLAGS]
816
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000817let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000818def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengca348202009-12-12 18:51:56 +0000819 (outs GR16:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000820 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000821let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000822def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000823 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000824 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000825 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
826
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000827let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000828def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000829 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000830def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000831 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000832def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000833 [(X86rep_movs i32)]>, REP;
834}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000835
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000836let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000837def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000838 [(X86rep_stos i8)]>, REP;
839let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000840def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000841 [(X86rep_stos i16)]>, REP, OpSize;
842let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000843def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000844 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000845
Sean Callanan481f06d2009-09-12 00:37:19 +0000846def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
847def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
848def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
849
Sean Callanan25220d62009-09-12 02:25:20 +0000850def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
851def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
852def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
853
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000854let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000855def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000856 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000857
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000858let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000859def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000860}
861
Chris Lattnerc96e27c2009-08-11 16:58:39 +0000862def SYSCALL : I<0x05, RawFrm,
863 (outs), (ins), "syscall", []>, TB;
864def SYSRET : I<0x07, RawFrm,
865 (outs), (ins), "sysret", []>, TB;
866def SYSENTER : I<0x34, RawFrm,
867 (outs), (ins), "sysenter", []>, TB;
868def SYSEXIT : I<0x35, RawFrm,
869 (outs), (ins), "sysexit", []>, TB;
870
Sean Callanan2c2313a2009-09-12 02:52:41 +0000871def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
Chris Lattnerc96e27c2009-08-11 16:58:39 +0000872
873
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000874//===----------------------------------------------------------------------===//
875// Input/Output Instructions...
876//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000877let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000878def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000879 "in{b}\t{%dx, %al|%AL, %DX}", []>;
880let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000881def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000882 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
883let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000884def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000885 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000886
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000887let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000888def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000889 "in{b}\t{$port, %al|%AL, $port}", []>;
890let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000891def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000892 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
893let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000894def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000895 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000896
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000897let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000898def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000899 "out{b}\t{%al, %dx|%DX, %AL}", []>;
900let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000901def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000902 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
903let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000904def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000905 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000906
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000907let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000908def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000909 "out{b}\t{%al, $port|$port, %AL}", []>;
910let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000911def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000912 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
913let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000914def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000915 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000916
917//===----------------------------------------------------------------------===//
918// Move Instructions...
919//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000920let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000921def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000922 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000923def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000924 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000925def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000926 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000927}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000928let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000929def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000930 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000931 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000932def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000933 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000934 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000935def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000936 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000937 [(set GR32:$dst, imm:$src)]>;
938}
Evan Chengb783fa32007-07-19 01:14:50 +0000939def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000940 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000941 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000942def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000943 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000944 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000945def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000946 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000947 [(store (i32 imm:$src), addr:$dst)]>;
948
Sean Callanan70953a52009-09-10 18:33:42 +0000949def MOV8o8a : Ii8 <0xA0, RawFrm, (outs), (ins i8imm:$src),
950 "mov{b}\t{$src, %al|%al, $src}", []>;
951def MOV16o16a : Ii16 <0xA1, RawFrm, (outs), (ins i16imm:$src),
952 "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
953def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins i32imm:$src),
954 "mov{l}\t{$src, %eax|%eax, $src}", []>;
955
956def MOV8ao8 : Ii8 <0xA2, RawFrm, (outs i8imm:$dst), (ins),
957 "mov{b}\t{%al, $dst|$dst, %al}", []>;
958def MOV16ao16 : Ii16 <0xA3, RawFrm, (outs i16imm:$dst), (ins),
959 "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize;
960def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs i32imm:$dst), (ins),
961 "mov{l}\t{%eax, $dst|$dst, %eax}", []>;
962
Sean Callananad87a3a2009-09-15 18:47:29 +0000963// Moves to and from segment registers
964def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
965 "mov{w}\t{$src, $dst|$dst, $src}", []>;
966def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src),
967 "mov{w}\t{$src, $dst|$dst, $src}", []>;
968def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
969 "mov{w}\t{$src, $dst|$dst, $src}", []>;
970def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
971 "mov{w}\t{$src, $dst|$dst, $src}", []>;
972
Dan Gohman5574cc72008-12-03 18:15:48 +0000973let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000974def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000975 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000976 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000977def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000978 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000979 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000980def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000981 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000982 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000983}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000984
Evan Chengb783fa32007-07-19 01:14:50 +0000985def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000986 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000987 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000988def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000989 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000990 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000991def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000992 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000993 [(store GR32:$src, addr:$dst)]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000994
Dan Gohman1d8ce9c2009-04-27 16:41:36 +0000995// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
996// that they can be used for copying and storing h registers, which can't be
997// encoded when a REX prefix is present.
Dan Gohman2da0db32009-04-15 00:04:23 +0000998let neverHasSideEffects = 1 in
Dan Gohman40ddc362009-04-15 19:48:57 +0000999def MOV8rr_NOREX : I<0x88, MRMDestReg,
1000 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman2da0db32009-04-15 00:04:23 +00001001 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +00001002let mayStore = 1 in
Dan Gohman2da0db32009-04-15 00:04:23 +00001003def MOV8mr_NOREX : I<0x88, MRMDestMem,
1004 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
1005 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +00001006let mayLoad = 1,
1007 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Dan Gohman1d8ce9c2009-04-27 16:41:36 +00001008def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
1009 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
1010 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman744d4622009-04-13 16:09:41 +00001011
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001012//===----------------------------------------------------------------------===//
1013// Fixed-Register Multiplication and Division Instructions...
1014//
1015
1016// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +00001017let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +00001018def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001019 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1020 // This probably ought to be moved to a def : Pat<> if the
1021 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +00001022 [(set AL, (mul AL, GR8:$src)),
1023 (implicit EFLAGS)]>; // AL,AH = AL*GR8
1024
Chris Lattnerc7e96e72008-01-11 07:18:17 +00001025let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +00001026def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
1027 "mul{w}\t$src",
1028 []>, OpSize; // AX,DX = AX*GR16
1029
Chris Lattnerc7e96e72008-01-11 07:18:17 +00001030let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +00001031def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
1032 "mul{l}\t$src",
1033 []>; // EAX,EDX = EAX*GR32
1034
Evan Cheng55687072007-09-14 21:48:26 +00001035let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +00001036def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001037 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001038 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1039 // This probably ought to be moved to a def : Pat<> if the
1040 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +00001041 [(set AL, (mul AL, (loadi8 addr:$src))),
1042 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
1043
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001044let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001045let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001046def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +00001047 "mul{w}\t$src",
1048 []>, OpSize; // AX,DX = AX*[mem16]
1049
Evan Cheng55687072007-09-14 21:48:26 +00001050let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001051def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +00001052 "mul{l}\t$src",
1053 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001054}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001055
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001056let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001057let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001058def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
1059 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +00001060let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +00001061def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001062 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +00001063let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001064def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
1065 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001066let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001067let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +00001068def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001069 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +00001070let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001071def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001072 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
1073let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001074def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001075 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001076}
Dan Gohmand44572d2008-11-18 21:29:14 +00001077} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001078
1079// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +00001080let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001081def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001082 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001083let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001084def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001085 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001086let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001087def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001088 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001089let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +00001090let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001091def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001092 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001093let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001094def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001095 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001096let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001097def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001098 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001099}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001100
1101// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +00001102let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001103def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001104 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001105let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001106def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001107 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001108let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001109def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001110 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001111let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +00001112let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001113def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001114 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001115let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001116def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001117 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001118let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001119def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001120 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001121}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001122
1123//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001124// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001125//
1126let isTwoAddress = 1 in {
1127
1128// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +00001129let Uses = [EFLAGS] in {
Dan Gohman29b998f2009-08-27 00:14:12 +00001130
Dan Gohman30afe012009-10-29 18:10:34 +00001131// X86 doesn't have 8-bit conditional moves. Use a customInserter to
Dan Gohman29b998f2009-08-27 00:14:12 +00001132// emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1133// however that requires promoting the operands, and can induce additional
Dan Gohman1596dd22009-08-29 22:19:15 +00001134// i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1135// clobber EFLAGS, because if one of the operands is zero, the expansion
1136// could involve an xor.
Dan Gohman30afe012009-10-29 18:10:34 +00001137let usesCustomInserter = 1, isTwoAddress = 0, Defs = [EFLAGS] in
Dan Gohman29b998f2009-08-27 00:14:12 +00001138def CMOV_GR8 : I<0, Pseudo,
1139 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1140 "#CMOV_GR8 PSEUDO!",
1141 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1142 imm:$cond, EFLAGS))]>;
1143
Dan Gohman90adb6c2009-08-27 18:16:24 +00001144let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001145def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001146 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001147 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001148 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001149 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001150 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001151def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001152 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001153 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001154 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001155 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001156 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001157def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001158 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001159 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001160 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001161 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001162 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001163def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001164 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001165 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001166 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001167 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001168 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001169def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001170 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001171 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001172 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001173 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001174 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001175def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001176 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001177 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001178 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001179 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001180 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001181def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001182 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001183 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001184 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001185 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001186 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001187def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001188 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001189 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001190 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001191 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001192 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001193def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001194 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001195 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001196 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001197 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001198 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001199def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001200 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001201 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001202 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001203 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001204 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001205def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001206 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001207 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001208 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001209 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001210 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001211def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001212 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001213 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001214 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001215 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001216 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001217def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001218 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001219 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001220 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001221 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001222 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001223def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001224 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001225 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001226 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001227 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001228 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001229def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001230 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001231 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001232 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001233 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001234 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001235def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001236 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001237 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001238 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001239 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001240 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001241def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001242 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001243 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001244 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001245 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001246 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001247def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001248 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001249 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001250 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001251 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001252 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001253def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001254 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001255 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001256 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001257 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001258 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001259def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001260 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001261 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001262 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001263 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001264 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001265def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001266 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001267 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001268 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001269 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001270 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001271def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001272 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001273 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001274 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001275 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001276 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001277def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001278 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001279 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001280 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001281 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001282 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001283def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001284 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001285 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001286 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001287 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001288 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001289def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001290 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001291 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001292 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001293 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001294 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001295def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001296 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001297 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001298 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001299 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001300 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001301def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001302 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001303 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001304 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001305 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001306 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001307def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001308 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001309 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001310 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001311 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001312 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001313def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1314 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1315 "cmovo\t{$src2, $dst|$dst, $src2}",
1316 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1317 X86_COND_O, EFLAGS))]>,
1318 TB, OpSize;
1319def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1320 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1321 "cmovo\t{$src2, $dst|$dst, $src2}",
1322 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1323 X86_COND_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001324 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001325def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1326 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1327 "cmovno\t{$src2, $dst|$dst, $src2}",
1328 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1329 X86_COND_NO, EFLAGS))]>,
1330 TB, OpSize;
1331def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1332 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1333 "cmovno\t{$src2, $dst|$dst, $src2}",
1334 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1335 X86_COND_NO, EFLAGS))]>,
1336 TB;
1337} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001338
1339def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1340 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1341 "cmovb\t{$src2, $dst|$dst, $src2}",
1342 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1343 X86_COND_B, EFLAGS))]>,
1344 TB, OpSize;
1345def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1346 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1347 "cmovb\t{$src2, $dst|$dst, $src2}",
1348 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1349 X86_COND_B, EFLAGS))]>,
1350 TB;
1351def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1352 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1353 "cmovae\t{$src2, $dst|$dst, $src2}",
1354 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1355 X86_COND_AE, EFLAGS))]>,
1356 TB, OpSize;
1357def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1358 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1359 "cmovae\t{$src2, $dst|$dst, $src2}",
1360 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1361 X86_COND_AE, EFLAGS))]>,
1362 TB;
1363def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1364 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1365 "cmove\t{$src2, $dst|$dst, $src2}",
1366 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1367 X86_COND_E, EFLAGS))]>,
1368 TB, OpSize;
1369def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1370 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1371 "cmove\t{$src2, $dst|$dst, $src2}",
1372 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1373 X86_COND_E, EFLAGS))]>,
1374 TB;
1375def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1376 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1377 "cmovne\t{$src2, $dst|$dst, $src2}",
1378 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1379 X86_COND_NE, EFLAGS))]>,
1380 TB, OpSize;
1381def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1382 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1383 "cmovne\t{$src2, $dst|$dst, $src2}",
1384 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1385 X86_COND_NE, EFLAGS))]>,
1386 TB;
1387def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1388 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1389 "cmovbe\t{$src2, $dst|$dst, $src2}",
1390 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1391 X86_COND_BE, EFLAGS))]>,
1392 TB, OpSize;
1393def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1394 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1395 "cmovbe\t{$src2, $dst|$dst, $src2}",
1396 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1397 X86_COND_BE, EFLAGS))]>,
1398 TB;
1399def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1400 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1401 "cmova\t{$src2, $dst|$dst, $src2}",
1402 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1403 X86_COND_A, EFLAGS))]>,
1404 TB, OpSize;
1405def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1406 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1407 "cmova\t{$src2, $dst|$dst, $src2}",
1408 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1409 X86_COND_A, EFLAGS))]>,
1410 TB;
1411def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1412 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1413 "cmovl\t{$src2, $dst|$dst, $src2}",
1414 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1415 X86_COND_L, EFLAGS))]>,
1416 TB, OpSize;
1417def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1418 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1419 "cmovl\t{$src2, $dst|$dst, $src2}",
1420 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1421 X86_COND_L, EFLAGS))]>,
1422 TB;
1423def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1424 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1425 "cmovge\t{$src2, $dst|$dst, $src2}",
1426 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1427 X86_COND_GE, EFLAGS))]>,
1428 TB, OpSize;
1429def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1430 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1431 "cmovge\t{$src2, $dst|$dst, $src2}",
1432 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1433 X86_COND_GE, EFLAGS))]>,
1434 TB;
1435def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1436 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1437 "cmovle\t{$src2, $dst|$dst, $src2}",
1438 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1439 X86_COND_LE, EFLAGS))]>,
1440 TB, OpSize;
1441def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1442 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1443 "cmovle\t{$src2, $dst|$dst, $src2}",
1444 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1445 X86_COND_LE, EFLAGS))]>,
1446 TB;
1447def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1448 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1449 "cmovg\t{$src2, $dst|$dst, $src2}",
1450 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1451 X86_COND_G, EFLAGS))]>,
1452 TB, OpSize;
1453def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1454 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1455 "cmovg\t{$src2, $dst|$dst, $src2}",
1456 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1457 X86_COND_G, EFLAGS))]>,
1458 TB;
1459def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1460 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1461 "cmovs\t{$src2, $dst|$dst, $src2}",
1462 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1463 X86_COND_S, EFLAGS))]>,
1464 TB, OpSize;
1465def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1466 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1467 "cmovs\t{$src2, $dst|$dst, $src2}",
1468 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1469 X86_COND_S, EFLAGS))]>,
1470 TB;
1471def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1472 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1473 "cmovns\t{$src2, $dst|$dst, $src2}",
1474 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1475 X86_COND_NS, EFLAGS))]>,
1476 TB, OpSize;
1477def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1478 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1479 "cmovns\t{$src2, $dst|$dst, $src2}",
1480 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1481 X86_COND_NS, EFLAGS))]>,
1482 TB;
1483def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1484 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1485 "cmovp\t{$src2, $dst|$dst, $src2}",
1486 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1487 X86_COND_P, EFLAGS))]>,
1488 TB, OpSize;
1489def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1490 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1491 "cmovp\t{$src2, $dst|$dst, $src2}",
1492 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1493 X86_COND_P, EFLAGS))]>,
1494 TB;
1495def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1496 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1497 "cmovnp\t{$src2, $dst|$dst, $src2}",
1498 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1499 X86_COND_NP, EFLAGS))]>,
1500 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001501def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1502 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1503 "cmovnp\t{$src2, $dst|$dst, $src2}",
1504 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1505 X86_COND_NP, EFLAGS))]>,
1506 TB;
1507def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1508 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1509 "cmovo\t{$src2, $dst|$dst, $src2}",
1510 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1511 X86_COND_O, EFLAGS))]>,
1512 TB, OpSize;
1513def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1514 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1515 "cmovo\t{$src2, $dst|$dst, $src2}",
1516 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1517 X86_COND_O, EFLAGS))]>,
1518 TB;
1519def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1520 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1521 "cmovno\t{$src2, $dst|$dst, $src2}",
1522 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1523 X86_COND_NO, EFLAGS))]>,
1524 TB, OpSize;
1525def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1526 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1527 "cmovno\t{$src2, $dst|$dst, $src2}",
1528 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1529 X86_COND_NO, EFLAGS))]>,
1530 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001531} // Uses = [EFLAGS]
1532
1533
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001534// unary instructions
1535let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001536let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001537def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001538 [(set GR8:$dst, (ineg GR8:$src)),
1539 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001540def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001541 [(set GR16:$dst, (ineg GR16:$src)),
1542 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001543def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001544 [(set GR32:$dst, (ineg GR32:$src)),
1545 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001546let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001547 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001548 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1549 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001550 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001551 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1552 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001553 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001554 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1555 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001556}
Evan Cheng55687072007-09-14 21:48:26 +00001557} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001558
Evan Chengc6cee682009-01-21 02:09:05 +00001559// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1560let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001561def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001562 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001563def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001564 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001565def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001566 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001567}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001568let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001569 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001570 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001571 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001572 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001573 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001574 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1575}
1576} // CodeSize
1577
1578// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001579let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001580let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001581def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001582 [(set GR8:$dst, (add GR8:$src, 1)),
1583 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001584let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001585def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001586 [(set GR16:$dst, (add GR16:$src, 1)),
1587 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001588 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001589def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001590 [(set GR32:$dst, (add GR32:$src, 1)),
1591 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001592}
1593let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001594 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001595 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1596 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001597 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001598 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1599 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001600 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001601 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001602 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1603 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001604 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001605}
1606
1607let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001608def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001609 [(set GR8:$dst, (add GR8:$src, -1)),
1610 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001611let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001612def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001613 [(set GR16:$dst, (add GR16:$src, -1)),
1614 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001615 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001616def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001617 [(set GR32:$dst, (add GR32:$src, -1)),
1618 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001619}
1620
1621let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001622 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001623 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1624 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001625 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001626 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1627 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001628 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001629 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001630 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1631 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001632 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001633}
Evan Cheng55687072007-09-14 21:48:26 +00001634} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001635
1636// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001637let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001638let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1639def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001640 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001641 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001642 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1643 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001644def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001645 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001646 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001647 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1648 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001649def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001650 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001651 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001652 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1653 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001654}
1655
1656def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001657 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001658 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001659 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001660 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001661def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001662 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001663 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001664 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001665 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001666def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001667 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001668 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001669 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001670 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001671
1672def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001673 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001674 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001675 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1676 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001677def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001678 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001679 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001680 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1681 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001682def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001683 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001684 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001685 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1686 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001687def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001688 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001689 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001690 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1691 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001692 OpSize;
1693def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001694 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001695 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001696 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1697 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001698
1699let isTwoAddress = 0 in {
1700 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001701 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001702 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001703 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1704 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001705 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001706 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001707 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001708 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1709 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001710 OpSize;
1711 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001712 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001713 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001714 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1715 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001716 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001717 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001718 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001719 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1720 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001721 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001722 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001723 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001724 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1725 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001726 OpSize;
1727 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001728 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001729 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001730 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1731 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001732 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001733 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001734 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001735 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1736 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001737 OpSize;
1738 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001739 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001740 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001741 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1742 (implicit EFLAGS)]>;
Sean Callanan251676e2009-09-02 00:55:49 +00001743
1744 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1745 "and{b}\t{$src, %al|%al, $src}", []>;
1746 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1747 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1748 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1749 "and{l}\t{$src, %eax|%eax, $src}", []>;
1750
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001751}
1752
1753
1754let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001755def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001756 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001757 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1758 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001759def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001760 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001761 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1762 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001763def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001764 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001765 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1766 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001767}
Evan Chengb783fa32007-07-19 01:14:50 +00001768def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001769 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001770 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1771 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001772def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001773 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001774 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1775 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001776def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001777 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001778 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1779 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001780
Evan Chengb783fa32007-07-19 01:14:50 +00001781def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001782 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001783 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1784 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001785def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001786 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001787 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1788 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001789def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001790 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001791 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1792 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001793
Evan Chengb783fa32007-07-19 01:14:50 +00001794def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001795 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001796 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1797 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001798def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001799 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001800 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1801 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001802let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001803 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001804 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001805 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1806 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001807 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001808 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001809 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1810 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001811 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001812 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001813 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1814 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001815 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001816 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001817 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1818 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001819 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001820 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001821 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1822 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001823 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001824 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001825 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001826 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1827 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001828 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001829 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001830 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1831 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001832 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001833 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001834 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001835 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1836 (implicit EFLAGS)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00001837
1838 def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
1839 "or{b}\t{$src, %al|%al, $src}", []>;
1840 def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
1841 "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1842 def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
1843 "or{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001844} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001845
1846
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001847let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001848 def XOR8rr : I<0x30, MRMDestReg,
1849 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1850 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001851 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1852 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001853 def XOR16rr : I<0x31, MRMDestReg,
1854 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1855 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001856 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1857 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001858 def XOR32rr : I<0x31, MRMDestReg,
1859 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1860 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001861 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1862 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001863} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001864
1865def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001866 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001867 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001868 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1869 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001870def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001871 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001872 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001873 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1874 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001875 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001876def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001877 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001878 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001879 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1880 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001881
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001882def XOR8ri : Ii8<0x80, MRM6r,
1883 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1884 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001885 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1886 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001887def XOR16ri : Ii16<0x81, MRM6r,
1888 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1889 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001890 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1891 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001892def XOR32ri : Ii32<0x81, MRM6r,
1893 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1894 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001895 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1896 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001897def XOR16ri8 : Ii8<0x83, MRM6r,
1898 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1899 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001900 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1901 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001902 OpSize;
1903def XOR32ri8 : Ii8<0x83, MRM6r,
1904 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1905 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001906 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1907 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001908
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001909let isTwoAddress = 0 in {
1910 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001911 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001912 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001913 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1914 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001915 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001916 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001917 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001918 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1919 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001920 OpSize;
1921 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001922 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001923 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001924 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1925 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001926 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001927 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001928 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001929 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1930 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001931 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001932 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001933 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001934 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1935 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001936 OpSize;
1937 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001938 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001939 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001940 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1941 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001942 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001943 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001944 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001945 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1946 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001947 OpSize;
1948 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001949 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001950 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001951 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1952 (implicit EFLAGS)]>;
Sean Callanan794457a2009-09-10 19:52:26 +00001953
1954 def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
1955 "xor{b}\t{$src, %al|%al, $src}", []>;
1956 def XOR16i16 : Ii16 <0x35, RawFrm, (outs), (ins i16imm:$src),
1957 "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1958 def XOR32i32 : Ii32 <0x35, RawFrm, (outs), (ins i32imm:$src),
1959 "xor{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001960} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001961} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001962
1963// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001964let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001965let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001966def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001967 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001968 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001969def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001970 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001971 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001972def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001973 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001974 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001975} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001976
Evan Chengb783fa32007-07-19 01:14:50 +00001977def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001978 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001979 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1980let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001981def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001982 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001983 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001984def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001985 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001986 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Sean Callananca503e02009-09-16 02:28:43 +00001987
1988// NOTE: We don't include patterns for shifts of a register by one, because
1989// 'add reg,reg' is cheaper.
1990
1991def SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
1992 "shl{b}\t$dst", []>;
1993def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
1994 "shl{w}\t$dst", []>, OpSize;
1995def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
1996 "shl{l}\t$dst", []>;
1997
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001998} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001999
2000let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002001 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002002 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002003 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002004 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002005 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002006 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002007 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002008 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002009 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002010 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
2011 }
Evan Chengb783fa32007-07-19 01:14:50 +00002012 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002013 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002014 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002015 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002016 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002017 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2018 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002019 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002020 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002021 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2022
2023 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002024 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002025 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002026 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002027 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002028 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002029 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2030 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002031 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002032 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002033 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2034}
2035
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002036let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002037def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002038 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002039 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002040def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002041 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002042 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002043def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002044 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002045 [(set GR32:$dst, (srl GR32:$src, CL))]>;
2046}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002047
Evan Chengb783fa32007-07-19 01:14:50 +00002048def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002049 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002050 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002051def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002052 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002053 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002054def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002055 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002056 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
2057
2058// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002059def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002060 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002061 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002062def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002063 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002064 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002065def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002066 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002067 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
2068
2069let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002070 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002071 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002072 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002073 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002074 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002075 "shr{w}\t{%cl, $dst|$dst, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002076 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002077 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002078 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002079 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002080 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
2081 }
Evan Chengb783fa32007-07-19 01:14:50 +00002082 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002083 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002084 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002085 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002086 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002087 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2088 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002089 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002090 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002091 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2092
2093 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002094 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002095 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002096 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002097 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002098 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002099 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002100 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002101 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002102 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2103}
2104
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002105let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002106def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002107 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002108 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002109def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002110 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002111 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002112def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002113 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002114 [(set GR32:$dst, (sra GR32:$src, CL))]>;
2115}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002116
Evan Chengb783fa32007-07-19 01:14:50 +00002117def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002118 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002119 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002120def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002121 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002122 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
2123 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002124def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002125 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002126 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
2127
2128// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002129def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002130 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002131 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002132def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002133 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002134 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002135def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002136 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002137 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2138
2139let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002140 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002141 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002142 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002143 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002144 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002145 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002146 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002147 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002148 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002149 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2150 }
Evan Chengb783fa32007-07-19 01:14:50 +00002151 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002152 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002153 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002154 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002155 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002156 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2157 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002158 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002159 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002160 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2161
2162 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002163 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002164 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002165 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002166 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002167 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002168 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2169 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002170 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002171 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002172 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2173}
2174
2175// Rotate instructions
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002176
2177def RCL8r1 : I<0xD0, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2178 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2179def RCL8m1 : I<0xD0, MRM2m, (outs i8mem:$dst), (ins i8mem:$src),
2180 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2181let Uses = [CL] in {
2182def RCL8rCL : I<0xD2, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2183 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2184def RCL8mCL : I<0xD2, MRM2m, (outs i8mem:$dst), (ins i8mem:$src),
2185 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2186}
2187def RCL8ri : Ii8<0xC0, MRM2r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2188 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2189def RCL8mi : Ii8<0xC0, MRM2m, (outs i8mem:$dst), (ins i8mem:$src, i8imm:$cnt),
2190 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2191
2192def RCL16r1 : I<0xD1, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2193 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2194def RCL16m1 : I<0xD1, MRM2m, (outs i16mem:$dst), (ins i16mem:$src),
2195 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2196let Uses = [CL] in {
2197def RCL16rCL : I<0xD3, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2198 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2199def RCL16mCL : I<0xD3, MRM2m, (outs i16mem:$dst), (ins i16mem:$src),
2200 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2201}
2202def RCL16ri : Ii8<0xC1, MRM2r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2203 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2204def RCL16mi : Ii8<0xC1, MRM2m, (outs i16mem:$dst), (ins i16mem:$src, i8imm:$cnt),
2205 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2206
2207def RCL32r1 : I<0xD1, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2208 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2209def RCL32m1 : I<0xD1, MRM2m, (outs i32mem:$dst), (ins i32mem:$src),
2210 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2211let Uses = [CL] in {
2212def RCL32rCL : I<0xD3, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2213 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2214def RCL32mCL : I<0xD3, MRM2m, (outs i32mem:$dst), (ins i32mem:$src),
2215 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2216}
2217def RCL32ri : Ii8<0xC1, MRM2r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2218 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2219def RCL32mi : Ii8<0xC1, MRM2m, (outs i32mem:$dst), (ins i32mem:$src, i8imm:$cnt),
2220 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2221
2222def RCR8r1 : I<0xD0, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2223 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2224def RCR8m1 : I<0xD0, MRM3m, (outs i8mem:$dst), (ins i8mem:$src),
2225 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2226let Uses = [CL] in {
2227def RCR8rCL : I<0xD2, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2228 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2229def RCR8mCL : I<0xD2, MRM3m, (outs i8mem:$dst), (ins i8mem:$src),
2230 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2231}
2232def RCR8ri : Ii8<0xC0, MRM3r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2233 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2234def RCR8mi : Ii8<0xC0, MRM3m, (outs i8mem:$dst), (ins i8mem:$src, i8imm:$cnt),
2235 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2236
2237def RCR16r1 : I<0xD1, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2238 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2239def RCR16m1 : I<0xD1, MRM3m, (outs i16mem:$dst), (ins i16mem:$src),
2240 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2241let Uses = [CL] in {
2242def RCR16rCL : I<0xD3, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2243 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2244def RCR16mCL : I<0xD3, MRM3m, (outs i16mem:$dst), (ins i16mem:$src),
2245 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2246}
2247def RCR16ri : Ii8<0xC1, MRM3r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2248 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2249def RCR16mi : Ii8<0xC1, MRM3m, (outs i16mem:$dst), (ins i16mem:$src, i8imm:$cnt),
2250 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2251
2252def RCR32r1 : I<0xD1, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2253 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2254def RCR32m1 : I<0xD1, MRM3m, (outs i32mem:$dst), (ins i32mem:$src),
2255 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2256let Uses = [CL] in {
2257def RCR32rCL : I<0xD3, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2258 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2259def RCR32mCL : I<0xD3, MRM3m, (outs i32mem:$dst), (ins i32mem:$src),
2260 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2261}
2262def RCR32ri : Ii8<0xC1, MRM3r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2263 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2264def RCR32mi : Ii8<0xC1, MRM3m, (outs i32mem:$dst), (ins i32mem:$src, i8imm:$cnt),
2265 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2266
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002267// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002268let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002269def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002270 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002271 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002272def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002273 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002274 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002275def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002276 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002277 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2278}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002279
Evan Chengb783fa32007-07-19 01:14:50 +00002280def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002281 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002282 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002283def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002284 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002285 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002286def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002287 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002288 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2289
2290// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002291def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002292 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002293 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002294def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002295 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002296 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002297def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002298 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002299 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2300
2301let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002302 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002303 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002304 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002305 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002306 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002307 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002308 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002309 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002310 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002311 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2312 }
Evan Chengb783fa32007-07-19 01:14:50 +00002313 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002314 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002315 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002316 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002317 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002318 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2319 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002320 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002321 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002322 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2323
2324 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002325 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002326 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002327 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002328 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002329 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002330 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2331 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002332 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002333 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002334 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2335}
2336
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002337let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002338def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002339 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002340 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002341def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002342 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002343 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002344def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002345 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002346 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2347}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002348
Evan Chengb783fa32007-07-19 01:14:50 +00002349def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002350 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002351 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002352def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002353 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002354 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002355def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002356 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002357 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2358
2359// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002360def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002361 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002362 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002363def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002364 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002365 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002366def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002367 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002368 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2369
2370let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002371 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002372 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002373 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002374 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002375 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002376 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002377 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002378 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002379 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002380 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2381 }
Evan Chengb783fa32007-07-19 01:14:50 +00002382 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002383 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002384 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002385 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002386 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002387 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2388 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002389 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002390 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002391 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2392
2393 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002394 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002395 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002396 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002397 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002398 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002399 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2400 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002401 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002402 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002403 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2404}
2405
2406
2407
2408// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002409let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002410def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002411 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002412 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002413def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002414 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002415 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002416def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002417 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002418 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002419 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002420def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002421 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002422 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002423 TB, OpSize;
2424}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002425
2426let isCommutable = 1 in { // These instructions commute to each other.
2427def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002428 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002429 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002430 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2431 (i8 imm:$src3)))]>,
2432 TB;
2433def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002434 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002435 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002436 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2437 (i8 imm:$src3)))]>,
2438 TB;
2439def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002440 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002441 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002442 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2443 (i8 imm:$src3)))]>,
2444 TB, OpSize;
2445def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002446 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002447 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002448 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2449 (i8 imm:$src3)))]>,
2450 TB, OpSize;
2451}
2452
2453let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002454 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002455 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002456 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002457 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002458 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002459 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002460 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002461 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002462 addr:$dst)]>, TB;
2463 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002464 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002465 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002466 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002467 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2468 (i8 imm:$src3)), addr:$dst)]>,
2469 TB;
2470 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002471 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002472 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002473 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2474 (i8 imm:$src3)), addr:$dst)]>,
2475 TB;
2476
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002477 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002478 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002479 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002480 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002481 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002482 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002483 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002484 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002485 addr:$dst)]>, TB, OpSize;
2486 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002487 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002488 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002489 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002490 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2491 (i8 imm:$src3)), addr:$dst)]>,
2492 TB, OpSize;
2493 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002494 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002495 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002496 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2497 (i8 imm:$src3)), addr:$dst)]>,
2498 TB, OpSize;
2499}
Evan Cheng55687072007-09-14 21:48:26 +00002500} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002501
2502
2503// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002504let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002505let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002506// Register-Register Addition
2507def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2508 (ins GR8 :$src1, GR8 :$src2),
2509 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002510 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002511 (implicit EFLAGS)]>;
2512
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002513let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002514// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002515def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2516 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002517 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002518 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2519 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002520def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2521 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002522 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002523 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2524 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002525} // end isConvertibleToThreeAddress
2526} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002527
2528// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002529def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2530 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002531 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002532 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2533 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002534def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2535 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002536 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002537 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2538 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002539def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2540 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002541 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002542 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2543 (implicit EFLAGS)]>;
Sean Callanan7e7df0e2009-09-15 20:53:57 +00002544
Sean Callanan84df9312009-09-15 21:43:27 +00002545// Register-Register Addition - Equivalent to the normal rr forms (ADD8rr,
2546// ADD16rr, and ADD32rr), but differently encoded.
Sean Callanan7e7df0e2009-09-15 20:53:57 +00002547def ADD8mrmrr: I<0x02, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2548 "add{b}\t{$src2, $dst|$dst, $src2}", []>;
2549def ADD16mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2550 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2551def ADD32mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2552 "add{l}\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002553
Bill Wendlingae034ed2008-12-12 00:56:36 +00002554// Register-Integer Addition
2555def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2556 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002557 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2558 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002559
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002560let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002561// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002562def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2563 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002564 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002565 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2566 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002567def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2568 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002569 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002570 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2571 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002572def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2573 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002574 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002575 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2576 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002577def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2578 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002579 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002580 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2581 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002582}
2583
2584let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002585 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002586 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002587 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002588 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2589 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002590 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002591 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002592 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2593 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002594 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002595 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002596 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2597 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002598 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002599 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002600 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2601 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002602 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002603 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002604 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2605 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002606 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002607 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002608 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2609 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002610 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002611 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002612 [(store (add (load addr:$dst), i16immSExt8:$src2),
2613 addr:$dst),
2614 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002615 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002616 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002617 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002618 addr:$dst),
2619 (implicit EFLAGS)]>;
Sean Callanan0316b342009-08-11 21:26:06 +00002620
2621 // addition to rAX
2622 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002623 "add{b}\t{$src, %al|%al, $src}", []>;
Sean Callanan0316b342009-08-11 21:26:06 +00002624 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002625 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callanan0316b342009-08-11 21:26:06 +00002626 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002627 "add{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002628}
2629
Evan Cheng259471d2007-10-05 17:59:57 +00002630let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002631let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen747fe522009-06-02 03:12:52 +00002632def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002633 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002634 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002635def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2636 (ins GR16:$src1, GR16:$src2),
2637 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002638 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002639def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2640 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002641 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002642 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002643}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002644def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2645 (ins GR8:$src1, i8mem:$src2),
2646 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002647 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002648def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2649 (ins GR16:$src1, i16mem:$src2),
2650 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002651 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002652 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002653def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2654 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002655 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002656 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2657def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002658 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002659 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002660def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2661 (ins GR16:$src1, i16imm:$src2),
2662 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002663 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002664def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2665 (ins GR16:$src1, i16i8imm:$src2),
2666 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002667 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2668 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002669def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2670 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002671 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002672 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002673def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2674 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002675 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002676 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002677
2678let isTwoAddress = 0 in {
Dale Johannesen747fe522009-06-02 03:12:52 +00002679 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002680 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002681 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2682 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002683 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002684 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2685 OpSize;
2686 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002687 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002688 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2689 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002690 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002691 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2692 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002693 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002694 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2695 OpSize;
2696 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002697 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002698 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2699 OpSize;
2700 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002701 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002702 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2703 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002704 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002705 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00002706
2707 def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2708 "adc{b}\t{$src, %al|%al, $src}", []>;
2709 def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
2710 "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2711 def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
2712 "adc{l}\t{$src, %eax|%eax, $src}", []>;
Dale Johannesen747fe522009-06-02 03:12:52 +00002713}
Evan Cheng259471d2007-10-05 17:59:57 +00002714} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002715
Bill Wendlingae034ed2008-12-12 00:56:36 +00002716// Register-Register Subtraction
2717def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2718 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002719 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2720 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002721def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2722 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002723 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2724 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002725def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2726 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002727 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2728 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002729
2730// Register-Memory Subtraction
2731def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2732 (ins GR8 :$src1, i8mem :$src2),
2733 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002734 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2735 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002736def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2737 (ins GR16:$src1, i16mem:$src2),
2738 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002739 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2740 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002741def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2742 (ins GR32:$src1, i32mem:$src2),
2743 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002744 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2745 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002746
2747// Register-Integer Subtraction
2748def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2749 (ins GR8:$src1, i8imm:$src2),
2750 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002751 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2752 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002753def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2754 (ins GR16:$src1, i16imm:$src2),
2755 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002756 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2757 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002758def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2759 (ins GR32:$src1, i32imm:$src2),
2760 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002761 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2762 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002763def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2764 (ins GR16:$src1, i16i8imm:$src2),
2765 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002766 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2767 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002768def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2769 (ins GR32:$src1, i32i8imm:$src2),
2770 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002771 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2772 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002773
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002774let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002775 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002776 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002777 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002778 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2779 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002780 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002781 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002782 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2783 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002784 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002785 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002786 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2787 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002788
2789 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002790 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002791 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002792 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2793 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002794 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002795 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002796 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2797 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002798 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002799 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002800 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2801 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002802 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002803 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002804 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002805 addr:$dst),
2806 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002807 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002808 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002809 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002810 addr:$dst),
2811 (implicit EFLAGS)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00002812
2813 def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
2814 "sub{b}\t{$src, %al|%al, $src}", []>;
2815 def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
2816 "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2817 def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
2818 "sub{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002819}
2820
Evan Cheng259471d2007-10-05 17:59:57 +00002821let Uses = [EFLAGS] in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002822def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2823 (ins GR8:$src1, GR8:$src2),
2824 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002825 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002826def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2827 (ins GR16:$src1, GR16:$src2),
2828 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002829 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002830def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2831 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002832 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002833 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002834
2835let isTwoAddress = 0 in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002836 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2837 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002838 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002839 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2840 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002841 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002842 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002843 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002844 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002845 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002846 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002847 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002848 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002849 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2850 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002851 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002852 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002853 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2854 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002855 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002856 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002857 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002858 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002859 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002860 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002861 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002862 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00002863
2864 def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
2865 "sbb{b}\t{$src, %al|%al, $src}", []>;
2866 def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
2867 "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2868 def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
2869 "sbb{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002870}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002871def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2872 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002873 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002874def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2875 (ins GR16:$src1, i16mem:$src2),
2876 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002877 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002878 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002879def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2880 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002881 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002882 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002883def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2884 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002885 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002886def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
2887 (ins GR16:$src1, i16imm:$src2),
2888 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002889 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002890def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2891 (ins GR16:$src1, i16i8imm:$src2),
2892 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002893 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
2894 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002895def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
2896 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002897 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002898 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002899def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2900 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002901 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002902 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002903} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002904} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002905
Evan Cheng55687072007-09-14 21:48:26 +00002906let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002907let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00002908// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002909def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002910 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002911 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2912 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002913def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002914 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002915 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2916 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002917}
Bill Wendlingae034ed2008-12-12 00:56:36 +00002918
Bill Wendlingf5399032008-12-12 21:15:41 +00002919// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002920def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2921 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002922 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002923 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2924 (implicit EFLAGS)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002925def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002926 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002927 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2928 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002929} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002930} // end Two Address instructions
2931
2932// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002933let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00002934// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002935def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002936 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002937 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002938 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2939 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002940def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002941 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002942 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002943 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2944 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002945def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002946 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002947 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002948 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2949 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002950def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002951 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002952 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002953 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2954 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002955
Bill Wendlingf5399032008-12-12 21:15:41 +00002956// Memory-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002957def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002958 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002959 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002960 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2961 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002962def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002963 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002964 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002965 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2966 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002967def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002968 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002969 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002970 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002971 i16immSExt8:$src2)),
2972 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002973def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002974 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002975 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002976 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002977 i32immSExt8:$src2)),
2978 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002979} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002980
2981//===----------------------------------------------------------------------===//
2982// Test instructions are just like AND, except they don't generate a result.
2983//
Evan Cheng950aac02007-09-25 01:57:46 +00002984let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002985let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002986def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002987 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002988 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002989 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002990def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002991 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002992 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002993 (implicit EFLAGS)]>,
2994 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002995def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002996 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002997 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002998 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002999}
3000
Sean Callanan3e4b1a32009-09-01 18:14:18 +00003001def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
3002 "test{b}\t{$src, %al|%al, $src}", []>;
3003def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
3004 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3005def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
3006 "test{l}\t{$src, %eax|%eax, $src}", []>;
3007
Evan Chengb783fa32007-07-19 01:14:50 +00003008def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003009 "test{b}\t{$src2, $src1|$src1, $src2}",
3010 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
3011 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003012def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003013 "test{w}\t{$src2, $src1|$src1, $src2}",
3014 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
3015 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003016def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003017 "test{l}\t{$src2, $src1|$src1, $src2}",
3018 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
3019 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003020
3021def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00003022 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003023 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003024 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003025 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003026def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00003027 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003028 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003029 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003030 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003031def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00003032 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003033 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003034 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003035 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003036
Evan Cheng621216e2007-09-29 00:00:36 +00003037def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00003038 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003039 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003040 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
3041 (implicit EFLAGS)]>;
3042def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00003043 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003044 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003045 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
3046 (implicit EFLAGS)]>, OpSize;
3047def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00003048 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003049 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003050 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00003051 (implicit EFLAGS)]>;
3052} // Defs = [EFLAGS]
3053
3054
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003055// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003056let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00003057def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003058let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00003059def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003060
Evan Cheng950aac02007-09-25 01:57:46 +00003061let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003062def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003063 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003064 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003065 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003066 TB; // GR8 = ==
3067def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003068 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003069 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003070 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003071 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003072
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003073def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003074 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003075 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003076 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003077 TB; // GR8 = !=
3078def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003079 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003080 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003081 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003082 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003083
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003084def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003085 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003086 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003087 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003088 TB; // GR8 = < signed
3089def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003090 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003091 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003092 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003093 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003094
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003095def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003096 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003097 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003098 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003099 TB; // GR8 = >= signed
3100def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003101 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003102 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003103 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003104 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003105
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003106def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003107 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003108 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003109 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003110 TB; // GR8 = <= signed
3111def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003112 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003113 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003114 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003115 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003116
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003117def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003118 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003119 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003120 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003121 TB; // GR8 = > signed
3122def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003123 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003124 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003125 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003126 TB; // [mem8] = > signed
3127
3128def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003129 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003130 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003131 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003132 TB; // GR8 = < unsign
3133def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003134 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003135 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003136 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003137 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003138
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003139def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003140 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003141 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003142 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003143 TB; // GR8 = >= unsign
3144def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003145 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003146 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003147 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003148 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003149
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003150def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003151 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003152 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003153 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003154 TB; // GR8 = <= unsign
3155def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003156 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003157 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003158 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003159 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003160
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003161def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003162 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003163 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003164 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003165 TB; // GR8 = > signed
3166def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003167 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003168 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003169 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003170 TB; // [mem8] = > signed
3171
3172def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003173 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003174 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003175 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003176 TB; // GR8 = <sign bit>
3177def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003178 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003179 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003180 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003181 TB; // [mem8] = <sign bit>
3182def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003183 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003184 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003185 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003186 TB; // GR8 = !<sign bit>
3187def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003188 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003189 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003190 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003191 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003192
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003193def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003194 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003195 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003196 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003197 TB; // GR8 = parity
3198def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003199 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003200 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003201 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003202 TB; // [mem8] = parity
3203def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003204 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003205 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003206 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003207 TB; // GR8 = not parity
3208def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003209 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003210 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003211 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003212 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003213
3214def SETOr : I<0x90, MRM0r,
3215 (outs GR8 :$dst), (ins),
3216 "seto\t$dst",
3217 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
3218 TB; // GR8 = overflow
3219def SETOm : I<0x90, MRM0m,
3220 (outs), (ins i8mem:$dst),
3221 "seto\t$dst",
3222 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
3223 TB; // [mem8] = overflow
3224def SETNOr : I<0x91, MRM0r,
3225 (outs GR8 :$dst), (ins),
3226 "setno\t$dst",
3227 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3228 TB; // GR8 = not overflow
3229def SETNOm : I<0x91, MRM0m,
3230 (outs), (ins i8mem:$dst),
3231 "setno\t$dst",
3232 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3233 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00003234} // Uses = [EFLAGS]
3235
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003236
3237// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00003238let Defs = [EFLAGS] in {
Sean Callanan251676e2009-09-02 00:55:49 +00003239def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3240 "cmp{b}\t{$src, %al|%al, $src}", []>;
3241def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3242 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3243def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3244 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3245
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003246def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003247 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003248 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003249 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003250def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003251 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003252 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003253 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003254def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003255 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003256 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003257 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003258def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003259 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003260 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003261 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
3262 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003263def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003264 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003265 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003266 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
3267 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003268def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003269 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003270 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003271 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
3272 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003273def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003274 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003275 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003276 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
3277 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003278def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003279 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003280 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003281 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
3282 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003283def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003284 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003285 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003286 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
3287 (implicit EFLAGS)]>;
Sean Callanan11490dc2009-09-16 21:11:23 +00003288def CMP8mrmrr : I<0x3A, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3289 "cmp{b}\t{$src2, $src1|$src1, $src2}", []>;
3290def CMP16mrmrr : I<0x3B, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3291 "cmp{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize;
3292def CMP32mrmrr : I<0x3B, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3293 "cmp{l}\t{$src2, $src1|$src1, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003294def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003295 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003296 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003297 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003298def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003299 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003300 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003301 [(X86cmp GR16:$src1, imm:$src2),
3302 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003303def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003304 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003305 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003306 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003307def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003308 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003309 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003310 [(X86cmp (loadi8 addr:$src1), imm:$src2),
3311 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003312def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003313 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003314 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003315 [(X86cmp (loadi16 addr:$src1), imm:$src2),
3316 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003317def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003318 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003319 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003320 [(X86cmp (loadi32 addr:$src1), imm:$src2),
3321 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003322def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003323 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003324 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003325 [(X86cmp GR16:$src1, i16immSExt8:$src2),
3326 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003327def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003328 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003329 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003330 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
3331 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003332def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003333 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003334 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003335 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
3336 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003337def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003338 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003339 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003340 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00003341 (implicit EFLAGS)]>;
3342} // Defs = [EFLAGS]
3343
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003344// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003345// TODO: BTC, BTR, and BTS
3346let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003347def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003348 "bt{w}\t{$src2, $src1|$src1, $src2}",
3349 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003350 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003351def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003352 "bt{l}\t{$src2, $src1|$src1, $src2}",
3353 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003354 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00003355
3356// Unlike with the register+register form, the memory+register form of the
3357// bt instruction does not ignore the high bits of the index. From ISel's
3358// perspective, this is pretty bizarre. Disable these instructions for now.
3359//def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3360// "bt{w}\t{$src2, $src1|$src1, $src2}",
3361// [(X86bt (loadi16 addr:$src1), GR16:$src2),
3362// (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
3363//def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3364// "bt{l}\t{$src2, $src1|$src1, $src2}",
3365// [(X86bt (loadi32 addr:$src1), GR32:$src2),
3366// (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00003367
3368def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3369 "bt{w}\t{$src2, $src1|$src1, $src2}",
3370 [(X86bt GR16:$src1, i16immSExt8:$src2),
3371 (implicit EFLAGS)]>, OpSize, TB;
3372def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3373 "bt{l}\t{$src2, $src1|$src1, $src2}",
3374 [(X86bt GR32:$src1, i32immSExt8:$src2),
3375 (implicit EFLAGS)]>, TB;
3376// Note that these instructions don't need FastBTMem because that
3377// only applies when the other operand is in a register. When it's
3378// an immediate, bt is still fast.
3379def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3380 "bt{w}\t{$src2, $src1|$src1, $src2}",
3381 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3382 (implicit EFLAGS)]>, OpSize, TB;
3383def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3384 "bt{l}\t{$src2, $src1|$src1, $src2}",
3385 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3386 (implicit EFLAGS)]>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003387} // Defs = [EFLAGS]
3388
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003389// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00003390// Use movsbl intead of movsbw; we don't care about the high 16 bits
3391// of the register here. This has a smaller encoding and avoids a
3392// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003393def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003394 "", [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003395def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003396 "", [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003397def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003398 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003399 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003400def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003401 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003402 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003403def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003404 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003405 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003406def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003407 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003408 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3409
Dan Gohman9203ab42008-07-30 18:09:17 +00003410// Use movzbl intead of movzbw; we don't care about the high 16 bits
3411// of the register here. This has a smaller encoding and avoids a
3412// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003413def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003414 "", [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003415def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003416 "", [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003417def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003418 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003419 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003420def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003421 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003422 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003423def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003424 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003425 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003426def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003427 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003428 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3429
Dan Gohman744d4622009-04-13 16:09:41 +00003430// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3431// except that they use GR32_NOREX for the output operand register class
3432// instead of GR32. This allows them to operate on h registers on x86-64.
3433def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3434 (outs GR32_NOREX:$dst), (ins GR8:$src),
3435 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3436 []>, TB;
Dan Gohman89f4cda2009-04-30 03:11:48 +00003437let mayLoad = 1 in
Dan Gohman744d4622009-04-13 16:09:41 +00003438def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3439 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3440 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3441 []>, TB;
3442
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003443let neverHasSideEffects = 1 in {
3444 let Defs = [AX], Uses = [AL] in
3445 def CBW : I<0x98, RawFrm, (outs), (ins),
3446 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3447 let Defs = [EAX], Uses = [AX] in
3448 def CWDE : I<0x98, RawFrm, (outs), (ins),
3449 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003450
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003451 let Defs = [AX,DX], Uses = [AX] in
3452 def CWD : I<0x99, RawFrm, (outs), (ins),
3453 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3454 let Defs = [EAX,EDX], Uses = [EAX] in
3455 def CDQ : I<0x99, RawFrm, (outs), (ins),
3456 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3457}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003458
3459//===----------------------------------------------------------------------===//
3460// Alias Instructions
3461//===----------------------------------------------------------------------===//
3462
3463// Alias instructions that map movr0 to xor.
3464// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Daniel Dunbara0e62002009-08-11 22:17:52 +00003465let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3466 isCodeGenOnly = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003467def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003468 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003469 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003470// Use xorl instead of xorw since we don't care about the high 16 bits,
3471// it's smaller, and it avoids a partial-register update.
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003472def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
3473 "", [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003474def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003475 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003476 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00003477}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003478
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003479//===----------------------------------------------------------------------===//
3480// Thread Local Storage Instructions
3481//
3482
Rafael Espindola7fc4b8d2009-04-24 12:59:40 +00003483// All calls clobber the non-callee saved registers. ESP is marked as
3484// a use to prevent stack-pointer assignments that appear immediately
3485// before calls from potentially appearing dead.
3486let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3487 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3488 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3489 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Chris Lattnerf1940742009-06-20 20:38:48 +00003490 Uses = [ESP] in
3491def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3492 "leal\t$sym, %eax; "
Dan Gohman70a8a112009-04-27 15:13:28 +00003493 "call\t___tls_get_addr@PLT",
Chris Lattnerf1940742009-06-20 20:38:48 +00003494 [(X86tlsaddr tls32addr:$sym)]>,
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00003495 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003496
Daniel Dunbar75a07302009-08-11 22:24:40 +00003497let AddedComplexity = 5, isCodeGenOnly = 1 in
sampo9cc09a32009-01-26 01:24:32 +00003498def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3499 "movl\t%gs:$src, $dst",
3500 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3501
Daniel Dunbar75a07302009-08-11 22:24:40 +00003502let AddedComplexity = 5, isCodeGenOnly = 1 in
Chris Lattnera7c2d8a2009-05-05 18:52:19 +00003503def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3504 "movl\t%fs:$src, $dst",
3505 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3506
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003507//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003508// EH Pseudo Instructions
3509//
3510let isTerminator = 1, isReturn = 1, isBarrier = 1,
Daniel Dunbar75513bd2009-08-27 07:58:05 +00003511 hasCtrlDep = 1, isCodeGenOnly = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003512def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00003513 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003514 [(X86ehret GR32:$addr)]>;
3515
3516}
3517
3518//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003519// Atomic support
3520//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003521
Evan Cheng3e171562008-04-19 01:20:30 +00003522// Atomic swap. These are just normal xchg instructions. But since a memory
3523// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00003524let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00003525def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3526 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3527 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3528def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3529 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3530 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3531 OpSize;
3532def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3533 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3534 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3535}
3536
Evan Chengd49dbb82008-04-18 20:55:36 +00003537// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003538let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003539def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003540 "lock\n\t"
3541 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003542 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003543}
Dale Johannesenf160d802008-10-02 18:53:47 +00003544let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00003545def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003546 "lock\n\t"
3547 "cmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00003548 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3549}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003550
3551let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003552def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003553 "lock\n\t"
3554 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003555 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003556}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003557let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003558def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003559 "lock\n\t"
3560 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003561 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003562}
3563
Evan Chengd49dbb82008-04-18 20:55:36 +00003564// Atomic exchange and add
3565let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3566def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003567 "lock\n\t"
3568 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003569 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003570 TB, LOCK;
3571def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003572 "lock\n\t"
3573 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003574 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003575 TB, OpSize, LOCK;
3576def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003577 "lock\n\t"
3578 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003579 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003580 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003581}
3582
Evan Chengb723fb52009-07-30 08:33:02 +00003583// Optimized codegen when the non-memory output is not used.
3584// FIXME: Use normal add / sub instructions and add lock prefix dynamically.
Dan Gohman1c286992009-10-20 18:14:49 +00003585let Defs = [EFLAGS] in {
Evan Chengb723fb52009-07-30 08:33:02 +00003586def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3587 "lock\n\t"
3588 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3589def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3590 "lock\n\t"
3591 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3592def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3593 "lock\n\t"
3594 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3595def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3596 "lock\n\t"
3597 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3598def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3599 "lock\n\t"
3600 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3601def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3602 "lock\n\t"
3603 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3604def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3605 "lock\n\t"
3606 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3607def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3608 "lock\n\t"
3609 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3610
3611def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3612 "lock\n\t"
3613 "inc{b}\t$dst", []>, LOCK;
3614def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3615 "lock\n\t"
3616 "inc{w}\t$dst", []>, OpSize, LOCK;
3617def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3618 "lock\n\t"
3619 "inc{l}\t$dst", []>, LOCK;
3620
3621def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3622 "lock\n\t"
3623 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3624def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3625 "lock\n\t"
3626 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3627def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3628 "lock\n\t"
3629 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3630def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3631 "lock\n\t"
3632 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3633def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3634 "lock\n\t"
3635 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3636def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3637 "lock\n\t"
3638 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3639def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3640 "lock\n\t"
3641 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3642def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3643 "lock\n\t"
3644 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3645
3646def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3647 "lock\n\t"
3648 "dec{b}\t$dst", []>, LOCK;
3649def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3650 "lock\n\t"
3651 "dec{w}\t$dst", []>, OpSize, LOCK;
3652def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3653 "lock\n\t"
3654 "dec{l}\t$dst", []>, LOCK;
Dan Gohman1c286992009-10-20 18:14:49 +00003655}
Evan Chengb723fb52009-07-30 08:33:02 +00003656
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003657// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003658let Constraints = "$val = $dst", Defs = [EFLAGS],
Dan Gohman30afe012009-10-29 18:10:34 +00003659 usesCustomInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003660def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003661 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003662 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003663def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003664 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003665 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003666def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003667 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003668 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003669def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003670 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003671 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003672def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003673 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003674 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003675def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003676 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003677 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003678def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003679 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003680 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003681def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003682 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003683 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003684
3685def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003686 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003687 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003688def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003689 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003690 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003691def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003692 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003693 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003694def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003695 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003696 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003697def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003698 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003699 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003700def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003701 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003702 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003703def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003704 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003705 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003706def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003707 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003708 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003709
3710def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003711 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003712 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003713def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003714 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003715 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003716def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003717 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003718 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003719def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003720 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003721 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00003722}
3723
Dale Johannesenf160d802008-10-02 18:53:47 +00003724let Constraints = "$val1 = $dst1, $val2 = $dst2",
3725 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3726 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00003727 mayLoad = 1, mayStore = 1,
Dan Gohman30afe012009-10-29 18:10:34 +00003728 usesCustomInserter = 1 in {
Dale Johannesenf160d802008-10-02 18:53:47 +00003729def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3730 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003731 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003732def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3733 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003734 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003735def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3736 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003737 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003738def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3739 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003740 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003741def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3742 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003743 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003744def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3745 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003746 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00003747def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3748 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003749 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003750}
3751
Sean Callanan2eddf5d2009-09-16 21:55:34 +00003752// Segmentation support instructions.
3753
3754def LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
3755 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3756def LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
3757 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3758
3759// i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo.
3760def LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3761 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
3762def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
3763 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
Sean Callanan23f33d72009-09-16 22:59:28 +00003764
3765// String manipulation instructions
3766
3767def LODSB : I<0xAC, RawFrm, (outs), (ins), "lodsb", []>;
3768def LODSW : I<0xAD, RawFrm, (outs), (ins), "lodsw", []>, OpSize;
3769def LODSD : I<0xAD, RawFrm, (outs), (ins), "lodsd", []>;
Sean Callanan2eddf5d2009-09-16 21:55:34 +00003770
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003771//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003772// Non-Instruction Patterns
3773//===----------------------------------------------------------------------===//
3774
Bill Wendlingfef06052008-09-16 21:48:12 +00003775// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003776def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3777def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00003778def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003779def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3780def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
Dan Gohman064403e2009-10-30 01:28:02 +00003781def : Pat<(i32 (X86Wrapper tblockaddress:$dst)), (MOV32ri tblockaddress:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003782
3783def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3784 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3785def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3786 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3787def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3788 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3789def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3790 (ADD32ri GR32:$src1, texternalsym:$src2)>;
Dan Gohman064403e2009-10-30 01:28:02 +00003791def : Pat<(add GR32:$src1, (X86Wrapper tblockaddress:$src2)),
3792 (ADD32ri GR32:$src1, tblockaddress:$src2)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003793
3794def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3795 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3796def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3797 (MOV32mi addr:$dst, texternalsym:$src)>;
Dan Gohman064403e2009-10-30 01:28:02 +00003798def : Pat<(store (i32 (X86Wrapper tblockaddress:$src)), addr:$dst),
3799 (MOV32mi addr:$dst, tblockaddress:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003800
3801// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003802// tailcall stuff
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003803def : Pat<(X86tcret GR32:$dst, imm:$off),
3804 (TCRETURNri GR32:$dst, imm:$off)>;
3805
3806def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3807 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3808
3809def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3810 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003811
Dan Gohmance5dbff2009-08-02 16:10:01 +00003812// Normal calls, with various flavors of addresses.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003813def : Pat<(X86call (i32 tglobaladdr:$dst)),
3814 (CALLpcrel32 tglobaladdr:$dst)>;
3815def : Pat<(X86call (i32 texternalsym:$dst)),
3816 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng6d35a4d2009-05-20 04:53:57 +00003817def : Pat<(X86call (i32 imm:$dst)),
3818 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003819
3820// X86 specific add which produces a flag.
3821def : Pat<(addc GR32:$src1, GR32:$src2),
3822 (ADD32rr GR32:$src1, GR32:$src2)>;
3823def : Pat<(addc GR32:$src1, (load addr:$src2)),
3824 (ADD32rm GR32:$src1, addr:$src2)>;
3825def : Pat<(addc GR32:$src1, imm:$src2),
3826 (ADD32ri GR32:$src1, imm:$src2)>;
3827def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3828 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3829
3830def : Pat<(subc GR32:$src1, GR32:$src2),
3831 (SUB32rr GR32:$src1, GR32:$src2)>;
3832def : Pat<(subc GR32:$src1, (load addr:$src2)),
3833 (SUB32rm GR32:$src1, addr:$src2)>;
3834def : Pat<(subc GR32:$src1, imm:$src2),
3835 (SUB32ri GR32:$src1, imm:$src2)>;
3836def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3837 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3838
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003839// Comparisons.
3840
3841// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00003842def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003843 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003844def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003845 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003846def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003847 (TEST32rr GR32:$src1, GR32:$src1)>;
3848
Dan Gohman0a3c5222009-01-07 01:00:24 +00003849// Conditional moves with folded loads with operands swapped and conditions
3850// inverted.
3851def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3852 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3853def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3854 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3855def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3856 (CMOVB16rm GR16:$src2, addr:$src1)>;
3857def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3858 (CMOVB32rm GR32:$src2, addr:$src1)>;
3859def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3860 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3861def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3862 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3863def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3864 (CMOVE16rm GR16:$src2, addr:$src1)>;
3865def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3866 (CMOVE32rm GR32:$src2, addr:$src1)>;
3867def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3868 (CMOVA16rm GR16:$src2, addr:$src1)>;
3869def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3870 (CMOVA32rm GR32:$src2, addr:$src1)>;
3871def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3872 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3873def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3874 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3875def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3876 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3877def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3878 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3879def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3880 (CMOVL16rm GR16:$src2, addr:$src1)>;
3881def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3882 (CMOVL32rm GR32:$src2, addr:$src1)>;
3883def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3884 (CMOVG16rm GR16:$src2, addr:$src1)>;
3885def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3886 (CMOVG32rm GR32:$src2, addr:$src1)>;
3887def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3888 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3889def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3890 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3891def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3892 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3893def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3894 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3895def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3896 (CMOVP16rm GR16:$src2, addr:$src1)>;
3897def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3898 (CMOVP32rm GR32:$src2, addr:$src1)>;
3899def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3900 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3901def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3902 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3903def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3904 (CMOVS16rm GR16:$src2, addr:$src1)>;
3905def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3906 (CMOVS32rm GR32:$src2, addr:$src1)>;
3907def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3908 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3909def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3910 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3911def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3912 (CMOVO16rm GR16:$src2, addr:$src1)>;
3913def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3914 (CMOVO32rm GR32:$src2, addr:$src1)>;
3915
Duncan Sands082524c2008-01-23 20:39:46 +00003916// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003917def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3918def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3919def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3920
3921// extload bool -> extload byte
3922def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Dan Gohman9959b052009-08-26 14:59:13 +00003923def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003924def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Dan Gohman9959b052009-08-26 14:59:13 +00003925def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003926def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3927def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3928
Dan Gohman9959b052009-08-26 14:59:13 +00003929// anyext. Define these to do an explicit zero-extend to
3930// avoid partial-register updates.
3931def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
3932def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
3933def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003934
Evan Chengf2abee72007-12-13 00:43:27 +00003935// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00003936def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3937 (MOVZX32rm8 addr:$src)>;
3938def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3939 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00003940
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003941//===----------------------------------------------------------------------===//
3942// Some peepholes
3943//===----------------------------------------------------------------------===//
3944
Dan Gohman5a5e6e92008-10-17 01:33:43 +00003945// Odd encoding trick: -128 fits into an 8-bit immediate field while
3946// +128 doesn't, so in this special case use a sub instead of an add.
3947def : Pat<(add GR16:$src1, 128),
3948 (SUB16ri8 GR16:$src1, -128)>;
3949def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3950 (SUB16mi8 addr:$dst, -128)>;
3951def : Pat<(add GR32:$src1, 128),
3952 (SUB32ri8 GR32:$src1, -128)>;
3953def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3954 (SUB32mi8 addr:$dst, -128)>;
3955
Dan Gohman9203ab42008-07-30 18:09:17 +00003956// r & (2^16-1) ==> movz
3957def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman744d4622009-04-13 16:09:41 +00003958 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003959// r & (2^8-1) ==> movz
3960def : Pat<(and GR32:$src1, 0xff),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00003961 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src1,
3962 GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00003963 x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003964 Requires<[In32BitMode]>;
3965// r & (2^8-1) ==> movz
3966def : Pat<(and GR16:$src1, 0xff),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00003967 (MOVZX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src1,
3968 GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00003969 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003970 Requires<[In32BitMode]>;
3971
3972// sext_inreg patterns
3973def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman744d4622009-04-13 16:09:41 +00003974 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003975def : Pat<(sext_inreg GR32:$src, i8),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00003976 (MOVSX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
3977 GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00003978 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003979 Requires<[In32BitMode]>;
3980def : Pat<(sext_inreg GR16:$src, i8),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00003981 (MOVSX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
3982 GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00003983 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003984 Requires<[In32BitMode]>;
3985
3986// trunc patterns
3987def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00003988 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003989def : Pat<(i8 (trunc GR32:$src)),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00003990 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00003991 x86_subreg_8bit)>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003992 Requires<[In32BitMode]>;
3993def : Pat<(i8 (trunc GR16:$src)),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00003994 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00003995 x86_subreg_8bit)>,
3996 Requires<[In32BitMode]>;
3997
3998// h-register tricks
3999def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004000 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004001 x86_subreg_8bit_hi)>,
4002 Requires<[In32BitMode]>;
4003def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004004 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004005 x86_subreg_8bit_hi)>,
4006 Requires<[In32BitMode]>;
4007def : Pat<(srl_su GR16:$src, (i8 8)),
4008 (EXTRACT_SUBREG
4009 (MOVZX32rr8
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004010 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004011 x86_subreg_8bit_hi)),
4012 x86_subreg_16bit)>,
4013 Requires<[In32BitMode]>;
Evan Cheng957ca282009-05-29 01:44:43 +00004014def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004015 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Evan Cheng957ca282009-05-29 01:44:43 +00004016 x86_subreg_8bit_hi))>,
4017 Requires<[In32BitMode]>;
Dan Gohman9959b052009-08-26 14:59:13 +00004018def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004019 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman9959b052009-08-26 14:59:13 +00004020 x86_subreg_8bit_hi))>,
4021 Requires<[In32BitMode]>;
Dan Gohman744d4622009-04-13 16:09:41 +00004022def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004023 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004024 x86_subreg_8bit_hi))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00004025 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00004026
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004027// (shl x, 1) ==> (add x, x)
4028def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
4029def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
4030def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
4031
Evan Cheng76a64c72008-08-30 02:03:58 +00004032// (shl x (and y, 31)) ==> (shl x, y)
4033def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
4034 (SHL8rCL GR8:$src1)>;
4035def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
4036 (SHL16rCL GR16:$src1)>;
4037def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
4038 (SHL32rCL GR32:$src1)>;
4039def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4040 (SHL8mCL addr:$dst)>;
4041def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4042 (SHL16mCL addr:$dst)>;
4043def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4044 (SHL32mCL addr:$dst)>;
4045
4046def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
4047 (SHR8rCL GR8:$src1)>;
4048def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
4049 (SHR16rCL GR16:$src1)>;
4050def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
4051 (SHR32rCL GR32:$src1)>;
4052def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4053 (SHR8mCL addr:$dst)>;
4054def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4055 (SHR16mCL addr:$dst)>;
4056def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4057 (SHR32mCL addr:$dst)>;
4058
4059def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
4060 (SAR8rCL GR8:$src1)>;
4061def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
4062 (SAR16rCL GR16:$src1)>;
4063def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
4064 (SAR32rCL GR32:$src1)>;
4065def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4066 (SAR8mCL addr:$dst)>;
4067def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4068 (SAR16mCL addr:$dst)>;
4069def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4070 (SAR32mCL addr:$dst)>;
4071
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004072// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
4073def : Pat<(or (srl GR32:$src1, CL:$amt),
4074 (shl GR32:$src2, (sub 32, CL:$amt))),
4075 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
4076
4077def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
4078 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4079 (SHRD32mrCL addr:$dst, GR32:$src2)>;
4080
Dan Gohman921581d2008-10-17 01:23:35 +00004081def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
4082 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4083 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
4084
4085def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4086 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4087 addr:$dst),
4088 (SHRD32mrCL addr:$dst, GR32:$src2)>;
4089
4090def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
4091 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4092
4093def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
4094 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
4095 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4096
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004097// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
4098def : Pat<(or (shl GR32:$src1, CL:$amt),
4099 (srl GR32:$src2, (sub 32, CL:$amt))),
4100 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
4101
4102def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
4103 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4104 (SHLD32mrCL addr:$dst, GR32:$src2)>;
4105
Dan Gohman921581d2008-10-17 01:23:35 +00004106def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
4107 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4108 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
4109
4110def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4111 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4112 addr:$dst),
4113 (SHLD32mrCL addr:$dst, GR32:$src2)>;
4114
4115def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
4116 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4117
4118def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
4119 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
4120 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4121
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004122// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
4123def : Pat<(or (srl GR16:$src1, CL:$amt),
4124 (shl GR16:$src2, (sub 16, CL:$amt))),
4125 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4126
4127def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
4128 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4129 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4130
Dan Gohman921581d2008-10-17 01:23:35 +00004131def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
4132 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4133 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4134
4135def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4136 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4137 addr:$dst),
4138 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4139
4140def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4141 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4142
4143def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
4144 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4145 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4146
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004147// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
4148def : Pat<(or (shl GR16:$src1, CL:$amt),
4149 (srl GR16:$src2, (sub 16, CL:$amt))),
4150 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4151
4152def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
4153 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4154 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4155
Dan Gohman921581d2008-10-17 01:23:35 +00004156def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
4157 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4158 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4159
4160def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4161 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4162 addr:$dst),
4163 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4164
4165def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4166 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4167
4168def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
4169 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4170 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4171
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004172//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00004173// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00004174//===----------------------------------------------------------------------===//
4175
Dan Gohman99a12192009-03-04 19:44:21 +00004176// Register-Register Addition with EFLAGS result
4177def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004178 (implicit EFLAGS)),
4179 (ADD8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004180def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004181 (implicit EFLAGS)),
4182 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004183def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004184 (implicit EFLAGS)),
4185 (ADD32rr GR32:$src1, GR32:$src2)>;
4186
Dan Gohman99a12192009-03-04 19:44:21 +00004187// Register-Memory Addition with EFLAGS result
4188def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004189 (implicit EFLAGS)),
4190 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004191def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004192 (implicit EFLAGS)),
4193 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004194def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004195 (implicit EFLAGS)),
4196 (ADD32rm GR32:$src1, addr:$src2)>;
4197
Dan Gohman99a12192009-03-04 19:44:21 +00004198// Register-Integer Addition with EFLAGS result
4199def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004200 (implicit EFLAGS)),
4201 (ADD8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004202def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004203 (implicit EFLAGS)),
4204 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004205def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004206 (implicit EFLAGS)),
4207 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004208def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004209 (implicit EFLAGS)),
4210 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004211def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004212 (implicit EFLAGS)),
4213 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4214
Dan Gohman99a12192009-03-04 19:44:21 +00004215// Memory-Register Addition with EFLAGS result
4216def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004217 addr:$dst),
4218 (implicit EFLAGS)),
4219 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004220def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004221 addr:$dst),
4222 (implicit EFLAGS)),
4223 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004224def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004225 addr:$dst),
4226 (implicit EFLAGS)),
4227 (ADD32mr addr:$dst, GR32:$src2)>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00004228
4229// Memory-Integer Addition with EFLAGS result
Dan Gohman99a12192009-03-04 19:44:21 +00004230def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004231 addr:$dst),
4232 (implicit EFLAGS)),
4233 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004234def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004235 addr:$dst),
4236 (implicit EFLAGS)),
4237 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004238def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004239 addr:$dst),
4240 (implicit EFLAGS)),
4241 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004242def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004243 addr:$dst),
4244 (implicit EFLAGS)),
4245 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004246def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004247 addr:$dst),
4248 (implicit EFLAGS)),
4249 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
4250
Dan Gohman99a12192009-03-04 19:44:21 +00004251// Register-Register Subtraction with EFLAGS result
4252def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004253 (implicit EFLAGS)),
4254 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004255def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004256 (implicit EFLAGS)),
4257 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004258def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004259 (implicit EFLAGS)),
4260 (SUB32rr GR32:$src1, GR32:$src2)>;
4261
Dan Gohman99a12192009-03-04 19:44:21 +00004262// Register-Memory Subtraction with EFLAGS result
4263def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004264 (implicit EFLAGS)),
4265 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004266def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004267 (implicit EFLAGS)),
4268 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004269def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004270 (implicit EFLAGS)),
4271 (SUB32rm GR32:$src1, addr:$src2)>;
4272
Dan Gohman99a12192009-03-04 19:44:21 +00004273// Register-Integer Subtraction with EFLAGS result
4274def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004275 (implicit EFLAGS)),
4276 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004277def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004278 (implicit EFLAGS)),
4279 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004280def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004281 (implicit EFLAGS)),
4282 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004283def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004284 (implicit EFLAGS)),
4285 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004286def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004287 (implicit EFLAGS)),
4288 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4289
Dan Gohman99a12192009-03-04 19:44:21 +00004290// Memory-Register Subtraction with EFLAGS result
4291def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004292 addr:$dst),
4293 (implicit EFLAGS)),
4294 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004295def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004296 addr:$dst),
4297 (implicit EFLAGS)),
4298 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004299def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004300 addr:$dst),
4301 (implicit EFLAGS)),
4302 (SUB32mr addr:$dst, GR32:$src2)>;
4303
Dan Gohman99a12192009-03-04 19:44:21 +00004304// Memory-Integer Subtraction with EFLAGS result
4305def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004306 addr:$dst),
4307 (implicit EFLAGS)),
4308 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004309def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004310 addr:$dst),
4311 (implicit EFLAGS)),
4312 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004313def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004314 addr:$dst),
4315 (implicit EFLAGS)),
4316 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004317def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004318 addr:$dst),
4319 (implicit EFLAGS)),
4320 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004321def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004322 addr:$dst),
4323 (implicit EFLAGS)),
4324 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
4325
4326
Dan Gohman99a12192009-03-04 19:44:21 +00004327// Register-Register Signed Integer Multiply with EFLAGS result
4328def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004329 (implicit EFLAGS)),
4330 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004331def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004332 (implicit EFLAGS)),
4333 (IMUL32rr GR32:$src1, GR32:$src2)>;
4334
Dan Gohman99a12192009-03-04 19:44:21 +00004335// Register-Memory Signed Integer Multiply with EFLAGS result
4336def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004337 (implicit EFLAGS)),
4338 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004339def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004340 (implicit EFLAGS)),
4341 (IMUL32rm GR32:$src1, addr:$src2)>;
4342
Dan Gohman99a12192009-03-04 19:44:21 +00004343// Register-Integer Signed Integer Multiply with EFLAGS result
4344def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004345 (implicit EFLAGS)),
4346 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004347def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004348 (implicit EFLAGS)),
4349 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004350def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004351 (implicit EFLAGS)),
4352 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004353def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004354 (implicit EFLAGS)),
4355 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4356
Dan Gohman99a12192009-03-04 19:44:21 +00004357// Memory-Integer Signed Integer Multiply with EFLAGS result
4358def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004359 (implicit EFLAGS)),
4360 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004361def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004362 (implicit EFLAGS)),
4363 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004364def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004365 (implicit EFLAGS)),
4366 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004367def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004368 (implicit EFLAGS)),
4369 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4370
Dan Gohman99a12192009-03-04 19:44:21 +00004371// Optimize multiply by 2 with EFLAGS result.
Evan Cheng00cf7932009-01-27 03:30:42 +00004372let AddedComplexity = 2 in {
Dan Gohman99a12192009-03-04 19:44:21 +00004373def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004374 (implicit EFLAGS)),
4375 (ADD16rr GR16:$src1, GR16:$src1)>;
4376
Dan Gohman99a12192009-03-04 19:44:21 +00004377def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004378 (implicit EFLAGS)),
4379 (ADD32rr GR32:$src1, GR32:$src1)>;
4380}
4381
Dan Gohman99a12192009-03-04 19:44:21 +00004382// INC and DEC with EFLAGS result. Note that these do not set CF.
4383def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
4384 (INC8r GR8:$src)>;
4385def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
4386 (implicit EFLAGS)),
4387 (INC8m addr:$dst)>;
4388def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
4389 (DEC8r GR8:$src)>;
4390def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
4391 (implicit EFLAGS)),
4392 (DEC8m addr:$dst)>;
4393
4394def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004395 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004396def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
4397 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004398 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004399def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004400 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004401def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
4402 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004403 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004404
4405def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004406 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004407def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
4408 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004409 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004410def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004411 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004412def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
4413 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004414 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004415
Dan Gohman12e03292009-09-18 19:59:53 +00004416// Register-Register Or with EFLAGS result
4417def : Pat<(parallel (X86or_flag GR8:$src1, GR8:$src2),
4418 (implicit EFLAGS)),
4419 (OR8rr GR8:$src1, GR8:$src2)>;
4420def : Pat<(parallel (X86or_flag GR16:$src1, GR16:$src2),
4421 (implicit EFLAGS)),
4422 (OR16rr GR16:$src1, GR16:$src2)>;
4423def : Pat<(parallel (X86or_flag GR32:$src1, GR32:$src2),
4424 (implicit EFLAGS)),
4425 (OR32rr GR32:$src1, GR32:$src2)>;
4426
4427// Register-Memory Or with EFLAGS result
4428def : Pat<(parallel (X86or_flag GR8:$src1, (loadi8 addr:$src2)),
4429 (implicit EFLAGS)),
4430 (OR8rm GR8:$src1, addr:$src2)>;
4431def : Pat<(parallel (X86or_flag GR16:$src1, (loadi16 addr:$src2)),
4432 (implicit EFLAGS)),
4433 (OR16rm GR16:$src1, addr:$src2)>;
4434def : Pat<(parallel (X86or_flag GR32:$src1, (loadi32 addr:$src2)),
4435 (implicit EFLAGS)),
4436 (OR32rm GR32:$src1, addr:$src2)>;
4437
4438// Register-Integer Or with EFLAGS result
4439def : Pat<(parallel (X86or_flag GR8:$src1, imm:$src2),
4440 (implicit EFLAGS)),
4441 (OR8ri GR8:$src1, imm:$src2)>;
4442def : Pat<(parallel (X86or_flag GR16:$src1, imm:$src2),
4443 (implicit EFLAGS)),
4444 (OR16ri GR16:$src1, imm:$src2)>;
4445def : Pat<(parallel (X86or_flag GR32:$src1, imm:$src2),
4446 (implicit EFLAGS)),
4447 (OR32ri GR32:$src1, imm:$src2)>;
4448def : Pat<(parallel (X86or_flag GR16:$src1, i16immSExt8:$src2),
4449 (implicit EFLAGS)),
4450 (OR16ri8 GR16:$src1, i16immSExt8:$src2)>;
4451def : Pat<(parallel (X86or_flag GR32:$src1, i32immSExt8:$src2),
4452 (implicit EFLAGS)),
4453 (OR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4454
4455// Memory-Register Or with EFLAGS result
4456def : Pat<(parallel (store (X86or_flag (loadi8 addr:$dst), GR8:$src2),
4457 addr:$dst),
4458 (implicit EFLAGS)),
4459 (OR8mr addr:$dst, GR8:$src2)>;
4460def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), GR16:$src2),
4461 addr:$dst),
4462 (implicit EFLAGS)),
4463 (OR16mr addr:$dst, GR16:$src2)>;
4464def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), GR32:$src2),
4465 addr:$dst),
4466 (implicit EFLAGS)),
4467 (OR32mr addr:$dst, GR32:$src2)>;
4468
4469// Memory-Integer Or with EFLAGS result
4470def : Pat<(parallel (store (X86or_flag (loadi8 addr:$dst), imm:$src2),
4471 addr:$dst),
4472 (implicit EFLAGS)),
4473 (OR8mi addr:$dst, imm:$src2)>;
4474def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), imm:$src2),
4475 addr:$dst),
4476 (implicit EFLAGS)),
4477 (OR16mi addr:$dst, imm:$src2)>;
4478def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), imm:$src2),
4479 addr:$dst),
4480 (implicit EFLAGS)),
4481 (OR32mi addr:$dst, imm:$src2)>;
4482def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), i16immSExt8:$src2),
4483 addr:$dst),
4484 (implicit EFLAGS)),
4485 (OR16mi8 addr:$dst, i16immSExt8:$src2)>;
4486def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), i32immSExt8:$src2),
4487 addr:$dst),
4488 (implicit EFLAGS)),
4489 (OR32mi8 addr:$dst, i32immSExt8:$src2)>;
4490
4491// Register-Register XOr with EFLAGS result
4492def : Pat<(parallel (X86xor_flag GR8:$src1, GR8:$src2),
4493 (implicit EFLAGS)),
4494 (XOR8rr GR8:$src1, GR8:$src2)>;
4495def : Pat<(parallel (X86xor_flag GR16:$src1, GR16:$src2),
4496 (implicit EFLAGS)),
4497 (XOR16rr GR16:$src1, GR16:$src2)>;
4498def : Pat<(parallel (X86xor_flag GR32:$src1, GR32:$src2),
4499 (implicit EFLAGS)),
4500 (XOR32rr GR32:$src1, GR32:$src2)>;
4501
4502// Register-Memory XOr with EFLAGS result
4503def : Pat<(parallel (X86xor_flag GR8:$src1, (loadi8 addr:$src2)),
4504 (implicit EFLAGS)),
4505 (XOR8rm GR8:$src1, addr:$src2)>;
4506def : Pat<(parallel (X86xor_flag GR16:$src1, (loadi16 addr:$src2)),
4507 (implicit EFLAGS)),
4508 (XOR16rm GR16:$src1, addr:$src2)>;
4509def : Pat<(parallel (X86xor_flag GR32:$src1, (loadi32 addr:$src2)),
4510 (implicit EFLAGS)),
4511 (XOR32rm GR32:$src1, addr:$src2)>;
4512
4513// Register-Integer XOr with EFLAGS result
4514def : Pat<(parallel (X86xor_flag GR8:$src1, imm:$src2),
4515 (implicit EFLAGS)),
4516 (XOR8ri GR8:$src1, imm:$src2)>;
4517def : Pat<(parallel (X86xor_flag GR16:$src1, imm:$src2),
4518 (implicit EFLAGS)),
4519 (XOR16ri GR16:$src1, imm:$src2)>;
4520def : Pat<(parallel (X86xor_flag GR32:$src1, imm:$src2),
4521 (implicit EFLAGS)),
4522 (XOR32ri GR32:$src1, imm:$src2)>;
4523def : Pat<(parallel (X86xor_flag GR16:$src1, i16immSExt8:$src2),
4524 (implicit EFLAGS)),
4525 (XOR16ri8 GR16:$src1, i16immSExt8:$src2)>;
4526def : Pat<(parallel (X86xor_flag GR32:$src1, i32immSExt8:$src2),
4527 (implicit EFLAGS)),
4528 (XOR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4529
4530// Memory-Register XOr with EFLAGS result
4531def : Pat<(parallel (store (X86xor_flag (loadi8 addr:$dst), GR8:$src2),
4532 addr:$dst),
4533 (implicit EFLAGS)),
4534 (XOR8mr addr:$dst, GR8:$src2)>;
4535def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), GR16:$src2),
4536 addr:$dst),
4537 (implicit EFLAGS)),
4538 (XOR16mr addr:$dst, GR16:$src2)>;
4539def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), GR32:$src2),
4540 addr:$dst),
4541 (implicit EFLAGS)),
4542 (XOR32mr addr:$dst, GR32:$src2)>;
4543
4544// Memory-Integer XOr with EFLAGS result
4545def : Pat<(parallel (store (X86xor_flag (loadi8 addr:$dst), imm:$src2),
4546 addr:$dst),
4547 (implicit EFLAGS)),
4548 (XOR8mi addr:$dst, imm:$src2)>;
4549def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), imm:$src2),
4550 addr:$dst),
4551 (implicit EFLAGS)),
4552 (XOR16mi addr:$dst, imm:$src2)>;
4553def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), imm:$src2),
4554 addr:$dst),
4555 (implicit EFLAGS)),
4556 (XOR32mi addr:$dst, imm:$src2)>;
4557def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), i16immSExt8:$src2),
4558 addr:$dst),
4559 (implicit EFLAGS)),
4560 (XOR16mi8 addr:$dst, i16immSExt8:$src2)>;
4561def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), i32immSExt8:$src2),
4562 addr:$dst),
4563 (implicit EFLAGS)),
4564 (XOR32mi8 addr:$dst, i32immSExt8:$src2)>;
4565
4566// Register-Register And with EFLAGS result
4567def : Pat<(parallel (X86and_flag GR8:$src1, GR8:$src2),
4568 (implicit EFLAGS)),
4569 (AND8rr GR8:$src1, GR8:$src2)>;
4570def : Pat<(parallel (X86and_flag GR16:$src1, GR16:$src2),
4571 (implicit EFLAGS)),
4572 (AND16rr GR16:$src1, GR16:$src2)>;
4573def : Pat<(parallel (X86and_flag GR32:$src1, GR32:$src2),
4574 (implicit EFLAGS)),
4575 (AND32rr GR32:$src1, GR32:$src2)>;
4576
4577// Register-Memory And with EFLAGS result
4578def : Pat<(parallel (X86and_flag GR8:$src1, (loadi8 addr:$src2)),
4579 (implicit EFLAGS)),
4580 (AND8rm GR8:$src1, addr:$src2)>;
4581def : Pat<(parallel (X86and_flag GR16:$src1, (loadi16 addr:$src2)),
4582 (implicit EFLAGS)),
4583 (AND16rm GR16:$src1, addr:$src2)>;
4584def : Pat<(parallel (X86and_flag GR32:$src1, (loadi32 addr:$src2)),
4585 (implicit EFLAGS)),
4586 (AND32rm GR32:$src1, addr:$src2)>;
4587
4588// Register-Integer And with EFLAGS result
4589def : Pat<(parallel (X86and_flag GR8:$src1, imm:$src2),
4590 (implicit EFLAGS)),
4591 (AND8ri GR8:$src1, imm:$src2)>;
4592def : Pat<(parallel (X86and_flag GR16:$src1, imm:$src2),
4593 (implicit EFLAGS)),
4594 (AND16ri GR16:$src1, imm:$src2)>;
4595def : Pat<(parallel (X86and_flag GR32:$src1, imm:$src2),
4596 (implicit EFLAGS)),
4597 (AND32ri GR32:$src1, imm:$src2)>;
4598def : Pat<(parallel (X86and_flag GR16:$src1, i16immSExt8:$src2),
4599 (implicit EFLAGS)),
4600 (AND16ri8 GR16:$src1, i16immSExt8:$src2)>;
4601def : Pat<(parallel (X86and_flag GR32:$src1, i32immSExt8:$src2),
4602 (implicit EFLAGS)),
4603 (AND32ri8 GR32:$src1, i32immSExt8:$src2)>;
4604
4605// Memory-Register And with EFLAGS result
4606def : Pat<(parallel (store (X86and_flag (loadi8 addr:$dst), GR8:$src2),
4607 addr:$dst),
4608 (implicit EFLAGS)),
4609 (AND8mr addr:$dst, GR8:$src2)>;
4610def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), GR16:$src2),
4611 addr:$dst),
4612 (implicit EFLAGS)),
4613 (AND16mr addr:$dst, GR16:$src2)>;
4614def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), GR32:$src2),
4615 addr:$dst),
4616 (implicit EFLAGS)),
4617 (AND32mr addr:$dst, GR32:$src2)>;
4618
4619// Memory-Integer And with EFLAGS result
4620def : Pat<(parallel (store (X86and_flag (loadi8 addr:$dst), imm:$src2),
4621 addr:$dst),
4622 (implicit EFLAGS)),
4623 (AND8mi addr:$dst, imm:$src2)>;
4624def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), imm:$src2),
4625 addr:$dst),
4626 (implicit EFLAGS)),
4627 (AND16mi addr:$dst, imm:$src2)>;
4628def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), imm:$src2),
4629 addr:$dst),
4630 (implicit EFLAGS)),
4631 (AND32mi addr:$dst, imm:$src2)>;
4632def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), i16immSExt8:$src2),
4633 addr:$dst),
4634 (implicit EFLAGS)),
4635 (AND16mi8 addr:$dst, i16immSExt8:$src2)>;
4636def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), i32immSExt8:$src2),
4637 addr:$dst),
4638 (implicit EFLAGS)),
4639 (AND32mi8 addr:$dst, i32immSExt8:$src2)>;
4640
Dan Gohmane84197b2009-09-03 17:18:51 +00004641// -disable-16bit support.
4642def : Pat<(truncstorei16 (i32 imm:$src), addr:$dst),
4643 (MOV16mi addr:$dst, imm:$src)>;
4644def : Pat<(truncstorei16 GR32:$src, addr:$dst),
4645 (MOV16mr addr:$dst, (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
4646def : Pat<(i32 (sextloadi16 addr:$dst)),
4647 (MOVSX32rm16 addr:$dst)>;
4648def : Pat<(i32 (zextloadi16 addr:$dst)),
4649 (MOVZX32rm16 addr:$dst)>;
4650def : Pat<(i32 (extloadi16 addr:$dst)),
4651 (MOVZX32rm16 addr:$dst)>;
4652
Bill Wendlingf5399032008-12-12 21:15:41 +00004653//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004654// Floating Point Stack Support
4655//===----------------------------------------------------------------------===//
4656
4657include "X86InstrFPStack.td"
4658
4659//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00004660// X86-64 Support
4661//===----------------------------------------------------------------------===//
4662
Chris Lattner2de8d2b2008-01-10 05:50:42 +00004663include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00004664
4665//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004666// XMM Floating point support (requires SSE / SSE2)
4667//===----------------------------------------------------------------------===//
4668
4669include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00004670
4671//===----------------------------------------------------------------------===//
4672// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
4673//===----------------------------------------------------------------------===//
4674
4675include "X86InstrMMX.td"