blob: e43d1729b1809130bacca461f874abd203627d1b [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
546def INT3 : I<0xcc, RawFrm, (outs), (ins), "int 3", []>;
547def 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
Arnold Schwaighofera0032722008-04-30 09:16:33 +0000721
Chris Lattner357a0ca2009-06-20 19:34:09 +0000722 def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000723 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000724let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000725 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
726 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000727let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000728 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000729 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000730
731//===----------------------------------------------------------------------===//
732// Miscellaneous Instructions...
733//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000734let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000735def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000736 (outs), (ins), "leave", []>;
737
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000738let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000739let mayLoad = 1 in {
740def POP16r : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
741 OpSize;
742def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
743def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
744 OpSize;
745def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
746 OpSize;
747def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
748def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
749}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000750
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000751let mayStore = 1 in {
752def PUSH16r : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
753 OpSize;
Evan Chengd8434332007-09-26 01:29:06 +0000754def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000755def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
756 OpSize;
757def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
758 OpSize;
759def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
760def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
761}
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000762}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000763
Bill Wendling4c2638c2009-06-15 19:39:04 +0000764let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
765def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000766 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000767def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000768 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000769def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000770 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000771}
772
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000773let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000774def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000775let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000776def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000777
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000778let isTwoAddress = 1 in // GR32 = bswap GR32
779 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000780 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000781 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000782 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
783
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000784
Evan Cheng48679f42007-12-14 02:13:44 +0000785// Bit scan instructions.
786let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000787def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000788 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000789 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000790def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000791 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000792 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
793 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000794def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000795 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000796 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000797def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000798 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000799 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
800 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000801
Evan Cheng4e33de92007-12-14 18:49:43 +0000802def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000803 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000804 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000805def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000806 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000807 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
808 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000809def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000810 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000811 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000812def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000813 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000814 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
815 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000816} // Defs = [EFLAGS]
817
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000818let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000819def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000820 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000821 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000822let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000823def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000824 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000825 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000826 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
827
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000828let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000829def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000830 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000831def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000832 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000833def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000834 [(X86rep_movs i32)]>, REP;
835}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000836
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000837let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000838def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000839 [(X86rep_stos i8)]>, REP;
840let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000841def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000842 [(X86rep_stos i16)]>, REP, OpSize;
843let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000844def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000845 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000846
Sean Callanan481f06d2009-09-12 00:37:19 +0000847def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
848def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
849def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
850
Sean Callanan25220d62009-09-12 02:25:20 +0000851def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
852def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
853def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
854
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000855let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000856def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000857 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000858
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000859let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000860def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000861}
862
Chris Lattnerc96e27c2009-08-11 16:58:39 +0000863def SYSCALL : I<0x05, RawFrm,
864 (outs), (ins), "syscall", []>, TB;
865def SYSRET : I<0x07, RawFrm,
866 (outs), (ins), "sysret", []>, TB;
867def SYSENTER : I<0x34, RawFrm,
868 (outs), (ins), "sysenter", []>, TB;
869def SYSEXIT : I<0x35, RawFrm,
870 (outs), (ins), "sysexit", []>, TB;
871
Sean Callanan2c2313a2009-09-12 02:52:41 +0000872def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
Chris Lattnerc96e27c2009-08-11 16:58:39 +0000873
874
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000875//===----------------------------------------------------------------------===//
876// Input/Output Instructions...
877//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000878let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000879def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000880 "in{b}\t{%dx, %al|%AL, %DX}", []>;
881let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000882def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000883 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
884let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000885def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000886 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000887
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000888let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000889def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000890 "in{b}\t{$port, %al|%AL, $port}", []>;
891let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000892def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000893 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
894let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000895def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000896 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000897
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000898let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000899def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000900 "out{b}\t{%al, %dx|%DX, %AL}", []>;
901let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000902def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000903 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
904let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000905def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000906 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000907
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000908let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000909def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000910 "out{b}\t{%al, $port|$port, %AL}", []>;
911let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000912def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000913 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
914let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000915def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000916 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000917
918//===----------------------------------------------------------------------===//
919// Move Instructions...
920//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000921let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000922def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000923 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000924def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000925 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000926def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000927 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000928}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000929let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000930def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000931 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000932 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000933def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000934 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000935 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000936def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000937 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000938 [(set GR32:$dst, imm:$src)]>;
939}
Evan Chengb783fa32007-07-19 01:14:50 +0000940def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000941 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000942 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000943def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000944 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000945 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000946def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000947 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000948 [(store (i32 imm:$src), addr:$dst)]>;
949
Sean Callanan70953a52009-09-10 18:33:42 +0000950def MOV8o8a : Ii8 <0xA0, RawFrm, (outs), (ins i8imm:$src),
951 "mov{b}\t{$src, %al|%al, $src}", []>;
952def MOV16o16a : Ii16 <0xA1, RawFrm, (outs), (ins i16imm:$src),
953 "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
954def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins i32imm:$src),
955 "mov{l}\t{$src, %eax|%eax, $src}", []>;
956
957def MOV8ao8 : Ii8 <0xA2, RawFrm, (outs i8imm:$dst), (ins),
958 "mov{b}\t{%al, $dst|$dst, %al}", []>;
959def MOV16ao16 : Ii16 <0xA3, RawFrm, (outs i16imm:$dst), (ins),
960 "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize;
961def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs i32imm:$dst), (ins),
962 "mov{l}\t{%eax, $dst|$dst, %eax}", []>;
963
Sean Callananad87a3a2009-09-15 18:47:29 +0000964// Moves to and from segment registers
965def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
966 "mov{w}\t{$src, $dst|$dst, $src}", []>;
967def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src),
968 "mov{w}\t{$src, $dst|$dst, $src}", []>;
969def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
970 "mov{w}\t{$src, $dst|$dst, $src}", []>;
971def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
972 "mov{w}\t{$src, $dst|$dst, $src}", []>;
973
Dan Gohman5574cc72008-12-03 18:15:48 +0000974let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000975def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000976 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000977 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000978def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000979 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000980 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000981def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000982 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000983 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000984}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000985
Evan Chengb783fa32007-07-19 01:14:50 +0000986def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000987 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000988 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000989def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000990 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000991 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000992def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000993 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000994 [(store GR32:$src, addr:$dst)]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000995
Dan Gohman1d8ce9c2009-04-27 16:41:36 +0000996// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
997// that they can be used for copying and storing h registers, which can't be
998// encoded when a REX prefix is present.
Dan Gohman2da0db32009-04-15 00:04:23 +0000999let neverHasSideEffects = 1 in
Dan Gohman40ddc362009-04-15 19:48:57 +00001000def MOV8rr_NOREX : I<0x88, MRMDestReg,
1001 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman2da0db32009-04-15 00:04:23 +00001002 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +00001003let mayStore = 1 in
Dan Gohman2da0db32009-04-15 00:04:23 +00001004def MOV8mr_NOREX : I<0x88, MRMDestMem,
1005 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
1006 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +00001007let mayLoad = 1,
1008 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Dan Gohman1d8ce9c2009-04-27 16:41:36 +00001009def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
1010 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
1011 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman744d4622009-04-13 16:09:41 +00001012
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001013//===----------------------------------------------------------------------===//
1014// Fixed-Register Multiplication and Division Instructions...
1015//
1016
1017// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +00001018let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +00001019def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001020 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1021 // This probably ought to be moved to a def : Pat<> if the
1022 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +00001023 [(set AL, (mul AL, GR8:$src)),
1024 (implicit EFLAGS)]>; // AL,AH = AL*GR8
1025
Chris Lattnerc7e96e72008-01-11 07:18:17 +00001026let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +00001027def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
1028 "mul{w}\t$src",
1029 []>, OpSize; // AX,DX = AX*GR16
1030
Chris Lattnerc7e96e72008-01-11 07:18:17 +00001031let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +00001032def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
1033 "mul{l}\t$src",
1034 []>; // EAX,EDX = EAX*GR32
1035
Evan Cheng55687072007-09-14 21:48:26 +00001036let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +00001037def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001038 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001039 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1040 // This probably ought to be moved to a def : Pat<> if the
1041 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +00001042 [(set AL, (mul AL, (loadi8 addr:$src))),
1043 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
1044
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001045let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001046let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001047def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +00001048 "mul{w}\t$src",
1049 []>, OpSize; // AX,DX = AX*[mem16]
1050
Evan Cheng55687072007-09-14 21:48:26 +00001051let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001052def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +00001053 "mul{l}\t$src",
1054 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001055}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001056
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001057let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001058let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001059def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
1060 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +00001061let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +00001062def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001063 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +00001064let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001065def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
1066 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001067let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001068let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +00001069def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001070 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +00001071let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001072def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001073 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
1074let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001075def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001076 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001077}
Dan Gohmand44572d2008-11-18 21:29:14 +00001078} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001079
1080// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +00001081let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001082def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001083 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001084let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001085def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001086 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001087let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001088def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001089 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001090let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +00001091let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001092def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001093 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001094let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001095def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001096 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001097let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001098def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001099 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001100}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001101
1102// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +00001103let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001104def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001105 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001106let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001107def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001108 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001109let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001110def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001111 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001112let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +00001113let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001114def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001115 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001116let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001117def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001118 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001119let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001120def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001121 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001122}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001123
1124//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001125// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001126//
1127let isTwoAddress = 1 in {
1128
1129// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +00001130let Uses = [EFLAGS] in {
Dan Gohman29b998f2009-08-27 00:14:12 +00001131
Dan Gohman30afe012009-10-29 18:10:34 +00001132// X86 doesn't have 8-bit conditional moves. Use a customInserter to
Dan Gohman29b998f2009-08-27 00:14:12 +00001133// emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1134// however that requires promoting the operands, and can induce additional
Dan Gohman1596dd22009-08-29 22:19:15 +00001135// i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1136// clobber EFLAGS, because if one of the operands is zero, the expansion
1137// could involve an xor.
Dan Gohman30afe012009-10-29 18:10:34 +00001138let usesCustomInserter = 1, isTwoAddress = 0, Defs = [EFLAGS] in
Dan Gohman29b998f2009-08-27 00:14:12 +00001139def CMOV_GR8 : I<0, Pseudo,
1140 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1141 "#CMOV_GR8 PSEUDO!",
1142 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1143 imm:$cond, EFLAGS))]>;
1144
Dan Gohman90adb6c2009-08-27 18:16:24 +00001145let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001146def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001147 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001148 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001149 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001150 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001151 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001152def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001153 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001154 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001155 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001156 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001157 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001158def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001159 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001160 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001161 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001162 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001163 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001164def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001165 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001166 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001167 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001168 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001169 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001170def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001171 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001172 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001173 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001174 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001175 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001176def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001177 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001178 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001179 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001180 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001181 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001182def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001183 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001184 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001185 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001186 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001187 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001188def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001189 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001190 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001191 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001192 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001193 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001194def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001195 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001196 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001197 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001198 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001199 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001200def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001201 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001202 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001203 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001204 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001205 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001206def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001207 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001208 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001209 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001210 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001211 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001212def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001213 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001214 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001215 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001216 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001217 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001218def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001219 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001220 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001221 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001222 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001223 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001224def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001225 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001226 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001227 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001228 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001229 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001230def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001231 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001232 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001233 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001234 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001235 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001236def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001237 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001238 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001239 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001240 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001241 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001242def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001243 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001244 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001245 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001246 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001247 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001248def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001249 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001250 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001251 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001252 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001253 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001254def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001255 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001256 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001257 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001258 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001259 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001260def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001261 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001262 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001263 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001264 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001265 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001266def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001267 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001268 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001269 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001270 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001271 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001272def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001273 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001274 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001275 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001276 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001277 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001278def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001279 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001280 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001281 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001282 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001283 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001284def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001285 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001286 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001287 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001288 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001289 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001290def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001291 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001292 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001293 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001294 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001295 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001296def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001297 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001298 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001299 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001300 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001301 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001302def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001303 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001304 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001305 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001306 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001307 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001308def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001309 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001310 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001311 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001312 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001313 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001314def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1315 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1316 "cmovo\t{$src2, $dst|$dst, $src2}",
1317 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1318 X86_COND_O, EFLAGS))]>,
1319 TB, OpSize;
1320def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1321 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1322 "cmovo\t{$src2, $dst|$dst, $src2}",
1323 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1324 X86_COND_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001325 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001326def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1327 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1328 "cmovno\t{$src2, $dst|$dst, $src2}",
1329 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1330 X86_COND_NO, EFLAGS))]>,
1331 TB, OpSize;
1332def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1333 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1334 "cmovno\t{$src2, $dst|$dst, $src2}",
1335 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1336 X86_COND_NO, EFLAGS))]>,
1337 TB;
1338} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001339
1340def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1341 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1342 "cmovb\t{$src2, $dst|$dst, $src2}",
1343 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1344 X86_COND_B, EFLAGS))]>,
1345 TB, OpSize;
1346def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1347 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1348 "cmovb\t{$src2, $dst|$dst, $src2}",
1349 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1350 X86_COND_B, EFLAGS))]>,
1351 TB;
1352def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1353 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1354 "cmovae\t{$src2, $dst|$dst, $src2}",
1355 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1356 X86_COND_AE, EFLAGS))]>,
1357 TB, OpSize;
1358def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1359 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1360 "cmovae\t{$src2, $dst|$dst, $src2}",
1361 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1362 X86_COND_AE, EFLAGS))]>,
1363 TB;
1364def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1365 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1366 "cmove\t{$src2, $dst|$dst, $src2}",
1367 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1368 X86_COND_E, EFLAGS))]>,
1369 TB, OpSize;
1370def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1371 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1372 "cmove\t{$src2, $dst|$dst, $src2}",
1373 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1374 X86_COND_E, EFLAGS))]>,
1375 TB;
1376def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1377 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1378 "cmovne\t{$src2, $dst|$dst, $src2}",
1379 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1380 X86_COND_NE, EFLAGS))]>,
1381 TB, OpSize;
1382def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1383 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1384 "cmovne\t{$src2, $dst|$dst, $src2}",
1385 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1386 X86_COND_NE, EFLAGS))]>,
1387 TB;
1388def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1389 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1390 "cmovbe\t{$src2, $dst|$dst, $src2}",
1391 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1392 X86_COND_BE, EFLAGS))]>,
1393 TB, OpSize;
1394def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1395 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1396 "cmovbe\t{$src2, $dst|$dst, $src2}",
1397 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1398 X86_COND_BE, EFLAGS))]>,
1399 TB;
1400def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1401 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1402 "cmova\t{$src2, $dst|$dst, $src2}",
1403 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1404 X86_COND_A, EFLAGS))]>,
1405 TB, OpSize;
1406def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1407 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1408 "cmova\t{$src2, $dst|$dst, $src2}",
1409 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1410 X86_COND_A, EFLAGS))]>,
1411 TB;
1412def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1413 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1414 "cmovl\t{$src2, $dst|$dst, $src2}",
1415 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1416 X86_COND_L, EFLAGS))]>,
1417 TB, OpSize;
1418def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1419 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1420 "cmovl\t{$src2, $dst|$dst, $src2}",
1421 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1422 X86_COND_L, EFLAGS))]>,
1423 TB;
1424def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1425 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1426 "cmovge\t{$src2, $dst|$dst, $src2}",
1427 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1428 X86_COND_GE, EFLAGS))]>,
1429 TB, OpSize;
1430def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1431 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1432 "cmovge\t{$src2, $dst|$dst, $src2}",
1433 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1434 X86_COND_GE, EFLAGS))]>,
1435 TB;
1436def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1437 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1438 "cmovle\t{$src2, $dst|$dst, $src2}",
1439 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1440 X86_COND_LE, EFLAGS))]>,
1441 TB, OpSize;
1442def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1443 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1444 "cmovle\t{$src2, $dst|$dst, $src2}",
1445 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1446 X86_COND_LE, EFLAGS))]>,
1447 TB;
1448def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1449 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1450 "cmovg\t{$src2, $dst|$dst, $src2}",
1451 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1452 X86_COND_G, EFLAGS))]>,
1453 TB, OpSize;
1454def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1455 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1456 "cmovg\t{$src2, $dst|$dst, $src2}",
1457 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1458 X86_COND_G, EFLAGS))]>,
1459 TB;
1460def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1461 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1462 "cmovs\t{$src2, $dst|$dst, $src2}",
1463 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1464 X86_COND_S, EFLAGS))]>,
1465 TB, OpSize;
1466def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1467 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1468 "cmovs\t{$src2, $dst|$dst, $src2}",
1469 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1470 X86_COND_S, EFLAGS))]>,
1471 TB;
1472def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1473 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1474 "cmovns\t{$src2, $dst|$dst, $src2}",
1475 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1476 X86_COND_NS, EFLAGS))]>,
1477 TB, OpSize;
1478def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1479 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1480 "cmovns\t{$src2, $dst|$dst, $src2}",
1481 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1482 X86_COND_NS, EFLAGS))]>,
1483 TB;
1484def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1485 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1486 "cmovp\t{$src2, $dst|$dst, $src2}",
1487 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1488 X86_COND_P, EFLAGS))]>,
1489 TB, OpSize;
1490def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1491 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1492 "cmovp\t{$src2, $dst|$dst, $src2}",
1493 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1494 X86_COND_P, EFLAGS))]>,
1495 TB;
1496def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1497 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1498 "cmovnp\t{$src2, $dst|$dst, $src2}",
1499 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1500 X86_COND_NP, EFLAGS))]>,
1501 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001502def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1503 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1504 "cmovnp\t{$src2, $dst|$dst, $src2}",
1505 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1506 X86_COND_NP, EFLAGS))]>,
1507 TB;
1508def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1509 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1510 "cmovo\t{$src2, $dst|$dst, $src2}",
1511 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1512 X86_COND_O, EFLAGS))]>,
1513 TB, OpSize;
1514def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1515 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1516 "cmovo\t{$src2, $dst|$dst, $src2}",
1517 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1518 X86_COND_O, EFLAGS))]>,
1519 TB;
1520def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1521 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1522 "cmovno\t{$src2, $dst|$dst, $src2}",
1523 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1524 X86_COND_NO, EFLAGS))]>,
1525 TB, OpSize;
1526def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1527 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1528 "cmovno\t{$src2, $dst|$dst, $src2}",
1529 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1530 X86_COND_NO, EFLAGS))]>,
1531 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001532} // Uses = [EFLAGS]
1533
1534
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001535// unary instructions
1536let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001537let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001538def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001539 [(set GR8:$dst, (ineg GR8:$src)),
1540 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001541def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001542 [(set GR16:$dst, (ineg GR16:$src)),
1543 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001544def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001545 [(set GR32:$dst, (ineg GR32:$src)),
1546 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001547let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001548 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001549 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1550 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001551 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001552 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1553 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001554 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001555 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1556 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001557}
Evan Cheng55687072007-09-14 21:48:26 +00001558} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001559
Evan Chengc6cee682009-01-21 02:09:05 +00001560// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1561let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001562def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001563 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001564def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001565 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001566def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001567 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001568}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001569let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001570 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001571 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001572 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001573 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001574 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001575 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1576}
1577} // CodeSize
1578
1579// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001580let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001581let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001582def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001583 [(set GR8:$dst, (add GR8:$src, 1)),
1584 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001585let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001586def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001587 [(set GR16:$dst, (add GR16:$src, 1)),
1588 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001589 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001590def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001591 [(set GR32:$dst, (add GR32:$src, 1)),
1592 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001593}
1594let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001595 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001596 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1597 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001598 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001599 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1600 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001601 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001602 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001603 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1604 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001605 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001606}
1607
1608let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001609def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001610 [(set GR8:$dst, (add GR8:$src, -1)),
1611 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001612let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001613def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001614 [(set GR16:$dst, (add GR16:$src, -1)),
1615 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001616 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001617def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001618 [(set GR32:$dst, (add GR32:$src, -1)),
1619 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001620}
1621
1622let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001623 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001624 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1625 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001626 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001627 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1628 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001629 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001630 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001631 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1632 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001633 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001634}
Evan Cheng55687072007-09-14 21:48:26 +00001635} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001636
1637// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001638let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001639let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1640def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001641 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001642 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001643 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1644 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001645def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001646 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001647 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001648 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1649 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001650def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001651 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001652 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001653 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1654 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001655}
1656
1657def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001658 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001659 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001660 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001661 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001662def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001663 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001664 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001665 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001666 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001667def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001668 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001669 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001670 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001671 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001672
1673def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001674 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001675 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001676 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1677 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001678def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001679 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001680 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001681 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1682 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001683def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001684 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001685 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001686 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1687 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001688def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001689 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001690 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001691 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1692 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001693 OpSize;
1694def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001695 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001696 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001697 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1698 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001699
1700let isTwoAddress = 0 in {
1701 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001702 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001703 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001704 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1705 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001706 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001707 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001708 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001709 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1710 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001711 OpSize;
1712 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001713 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001714 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001715 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1716 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001717 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001718 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001719 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001720 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1721 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001722 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001723 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001724 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001725 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1726 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001727 OpSize;
1728 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001729 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001730 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001731 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1732 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001733 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001734 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001735 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001736 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1737 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001738 OpSize;
1739 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001740 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001741 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001742 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1743 (implicit EFLAGS)]>;
Sean Callanan251676e2009-09-02 00:55:49 +00001744
1745 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1746 "and{b}\t{$src, %al|%al, $src}", []>;
1747 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1748 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1749 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1750 "and{l}\t{$src, %eax|%eax, $src}", []>;
1751
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001752}
1753
1754
1755let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001756def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001757 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001758 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1759 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001760def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001761 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001762 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1763 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001764def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001765 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001766 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1767 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001768}
Evan Chengb783fa32007-07-19 01:14:50 +00001769def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001770 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001771 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1772 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001773def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001774 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001775 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1776 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001777def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001778 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001779 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1780 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001781
Evan Chengb783fa32007-07-19 01:14:50 +00001782def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001783 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001784 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1785 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001786def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001787 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001788 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1789 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001790def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001791 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001792 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1793 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001794
Evan Chengb783fa32007-07-19 01:14:50 +00001795def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001796 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001797 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1798 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001799def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001800 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001801 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1802 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001803let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001804 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001805 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001806 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1807 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001808 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001809 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001810 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1811 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001812 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001813 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001814 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1815 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001816 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001817 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001818 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1819 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001820 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001821 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001822 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1823 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001824 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001825 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001826 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001827 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1828 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001829 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001830 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001831 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1832 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001833 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001834 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001835 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001836 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1837 (implicit EFLAGS)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00001838
1839 def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
1840 "or{b}\t{$src, %al|%al, $src}", []>;
1841 def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
1842 "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1843 def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
1844 "or{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001845} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001846
1847
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001848let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001849 def XOR8rr : I<0x30, MRMDestReg,
1850 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1851 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001852 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1853 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001854 def XOR16rr : I<0x31, MRMDestReg,
1855 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1856 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001857 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1858 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001859 def XOR32rr : I<0x31, MRMDestReg,
1860 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1861 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001862 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1863 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001864} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001865
1866def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001867 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001868 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001869 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1870 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001871def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001872 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001873 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001874 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1875 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001876 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001877def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001878 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001879 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001880 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1881 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001882
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001883def XOR8ri : Ii8<0x80, MRM6r,
1884 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1885 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001886 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1887 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001888def XOR16ri : Ii16<0x81, MRM6r,
1889 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1890 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001891 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1892 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001893def XOR32ri : Ii32<0x81, MRM6r,
1894 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1895 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001896 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1897 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001898def XOR16ri8 : Ii8<0x83, MRM6r,
1899 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1900 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001901 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1902 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001903 OpSize;
1904def XOR32ri8 : Ii8<0x83, MRM6r,
1905 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1906 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001907 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1908 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001909
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001910let isTwoAddress = 0 in {
1911 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001912 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001913 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001914 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1915 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001916 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001917 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001918 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001919 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1920 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001921 OpSize;
1922 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001923 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001924 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001925 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1926 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001927 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001928 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001929 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001930 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1931 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001932 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001933 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001934 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001935 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1936 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001937 OpSize;
1938 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001939 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001940 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001941 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1942 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001943 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001944 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001945 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001946 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1947 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001948 OpSize;
1949 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001950 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001951 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001952 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1953 (implicit EFLAGS)]>;
Sean Callanan794457a2009-09-10 19:52:26 +00001954
1955 def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
1956 "xor{b}\t{$src, %al|%al, $src}", []>;
1957 def XOR16i16 : Ii16 <0x35, RawFrm, (outs), (ins i16imm:$src),
1958 "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1959 def XOR32i32 : Ii32 <0x35, RawFrm, (outs), (ins i32imm:$src),
1960 "xor{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001961} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001962} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001963
1964// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001965let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001966let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001967def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001968 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001969 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001970def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001971 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001972 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001973def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001974 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001975 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001976} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001977
Evan Chengb783fa32007-07-19 01:14:50 +00001978def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001979 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001980 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1981let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001982def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001983 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001984 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001985def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001986 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001987 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Sean Callananca503e02009-09-16 02:28:43 +00001988
1989// NOTE: We don't include patterns for shifts of a register by one, because
1990// 'add reg,reg' is cheaper.
1991
1992def SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
1993 "shl{b}\t$dst", []>;
1994def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
1995 "shl{w}\t$dst", []>, OpSize;
1996def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
1997 "shl{l}\t$dst", []>;
1998
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001999} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002000
2001let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002002 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002003 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002004 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002005 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002006 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002007 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002008 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002009 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002010 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002011 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
2012 }
Evan Chengb783fa32007-07-19 01:14:50 +00002013 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002014 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002015 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002016 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002017 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002018 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2019 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002020 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002021 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002022 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2023
2024 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002025 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002026 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002027 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002028 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002029 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002030 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2031 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002032 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002033 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002034 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2035}
2036
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002037let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002038def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002039 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002040 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002041def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002042 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002043 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002044def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002045 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002046 [(set GR32:$dst, (srl GR32:$src, CL))]>;
2047}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002048
Evan Chengb783fa32007-07-19 01:14:50 +00002049def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002050 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002051 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002052def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002053 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002054 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002055def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002056 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002057 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
2058
2059// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002060def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002061 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002062 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002063def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002064 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002065 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002066def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002067 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002068 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
2069
2070let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002071 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002072 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002073 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002074 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002075 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002076 "shr{w}\t{%cl, $dst|$dst, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002077 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002078 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002079 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002080 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002081 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
2082 }
Evan Chengb783fa32007-07-19 01:14:50 +00002083 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002084 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002085 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002086 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002087 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002088 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2089 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002090 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002091 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002092 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2093
2094 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002095 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002096 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002097 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002098 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002099 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002100 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002101 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002102 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002103 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2104}
2105
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002106let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002107def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002108 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002109 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002110def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002111 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002112 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002113def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002114 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002115 [(set GR32:$dst, (sra GR32:$src, CL))]>;
2116}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002117
Evan Chengb783fa32007-07-19 01:14:50 +00002118def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002119 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002120 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002121def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002122 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002123 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
2124 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002125def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002126 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002127 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
2128
2129// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002130def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002131 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002132 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002133def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002134 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002135 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002136def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002137 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002138 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2139
2140let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002141 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002142 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002143 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002144 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002145 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002146 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002147 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002148 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002149 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002150 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2151 }
Evan Chengb783fa32007-07-19 01:14:50 +00002152 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002153 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002154 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002155 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002156 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002157 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2158 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002159 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002160 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002161 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2162
2163 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002164 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002165 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002166 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002167 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002168 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002169 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2170 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002171 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002172 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002173 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2174}
2175
2176// Rotate instructions
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002177
2178def RCL8r1 : I<0xD0, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2179 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2180def RCL8m1 : I<0xD0, MRM2m, (outs i8mem:$dst), (ins i8mem:$src),
2181 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2182let Uses = [CL] in {
2183def RCL8rCL : I<0xD2, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2184 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2185def RCL8mCL : I<0xD2, MRM2m, (outs i8mem:$dst), (ins i8mem:$src),
2186 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2187}
2188def RCL8ri : Ii8<0xC0, MRM2r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2189 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2190def RCL8mi : Ii8<0xC0, MRM2m, (outs i8mem:$dst), (ins i8mem:$src, i8imm:$cnt),
2191 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2192
2193def RCL16r1 : I<0xD1, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2194 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2195def RCL16m1 : I<0xD1, MRM2m, (outs i16mem:$dst), (ins i16mem:$src),
2196 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2197let Uses = [CL] in {
2198def RCL16rCL : I<0xD3, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2199 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2200def RCL16mCL : I<0xD3, MRM2m, (outs i16mem:$dst), (ins i16mem:$src),
2201 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2202}
2203def RCL16ri : Ii8<0xC1, MRM2r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2204 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2205def RCL16mi : Ii8<0xC1, MRM2m, (outs i16mem:$dst), (ins i16mem:$src, i8imm:$cnt),
2206 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2207
2208def RCL32r1 : I<0xD1, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2209 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2210def RCL32m1 : I<0xD1, MRM2m, (outs i32mem:$dst), (ins i32mem:$src),
2211 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2212let Uses = [CL] in {
2213def RCL32rCL : I<0xD3, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2214 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2215def RCL32mCL : I<0xD3, MRM2m, (outs i32mem:$dst), (ins i32mem:$src),
2216 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2217}
2218def RCL32ri : Ii8<0xC1, MRM2r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2219 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2220def RCL32mi : Ii8<0xC1, MRM2m, (outs i32mem:$dst), (ins i32mem:$src, i8imm:$cnt),
2221 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2222
2223def RCR8r1 : I<0xD0, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2224 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2225def RCR8m1 : I<0xD0, MRM3m, (outs i8mem:$dst), (ins i8mem:$src),
2226 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2227let Uses = [CL] in {
2228def RCR8rCL : I<0xD2, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2229 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2230def RCR8mCL : I<0xD2, MRM3m, (outs i8mem:$dst), (ins i8mem:$src),
2231 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2232}
2233def RCR8ri : Ii8<0xC0, MRM3r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2234 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2235def RCR8mi : Ii8<0xC0, MRM3m, (outs i8mem:$dst), (ins i8mem:$src, i8imm:$cnt),
2236 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2237
2238def RCR16r1 : I<0xD1, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2239 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2240def RCR16m1 : I<0xD1, MRM3m, (outs i16mem:$dst), (ins i16mem:$src),
2241 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2242let Uses = [CL] in {
2243def RCR16rCL : I<0xD3, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2244 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2245def RCR16mCL : I<0xD3, MRM3m, (outs i16mem:$dst), (ins i16mem:$src),
2246 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2247}
2248def RCR16ri : Ii8<0xC1, MRM3r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2249 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2250def RCR16mi : Ii8<0xC1, MRM3m, (outs i16mem:$dst), (ins i16mem:$src, i8imm:$cnt),
2251 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2252
2253def RCR32r1 : I<0xD1, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2254 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2255def RCR32m1 : I<0xD1, MRM3m, (outs i32mem:$dst), (ins i32mem:$src),
2256 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2257let Uses = [CL] in {
2258def RCR32rCL : I<0xD3, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2259 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2260def RCR32mCL : I<0xD3, MRM3m, (outs i32mem:$dst), (ins i32mem:$src),
2261 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2262}
2263def RCR32ri : Ii8<0xC1, MRM3r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2264 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2265def RCR32mi : Ii8<0xC1, MRM3m, (outs i32mem:$dst), (ins i32mem:$src, i8imm:$cnt),
2266 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2267
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002268// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002269let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002270def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002271 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002272 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002273def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002274 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002275 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002276def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002277 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002278 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2279}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002280
Evan Chengb783fa32007-07-19 01:14:50 +00002281def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002282 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002283 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002284def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002285 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002286 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002287def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002288 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002289 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2290
2291// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002292def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002293 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002294 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002295def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002296 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002297 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002298def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002299 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002300 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2301
2302let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002303 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002304 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002305 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002306 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002307 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002308 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002309 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002310 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002311 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002312 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2313 }
Evan Chengb783fa32007-07-19 01:14:50 +00002314 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002315 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002316 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002317 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002318 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002319 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2320 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002321 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002322 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002323 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2324
2325 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002326 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002327 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002328 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002329 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002330 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002331 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2332 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002333 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002334 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002335 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2336}
2337
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002338let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002339def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002340 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002341 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002342def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002343 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002344 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002345def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002346 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002347 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2348}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002349
Evan Chengb783fa32007-07-19 01:14:50 +00002350def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002351 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002352 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002353def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002354 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002355 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002356def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002357 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002358 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2359
2360// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002361def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002362 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002363 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002364def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002365 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002366 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002367def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002368 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002369 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2370
2371let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002372 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002373 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002374 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002375 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002376 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002377 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002378 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002379 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002380 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002381 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2382 }
Evan Chengb783fa32007-07-19 01:14:50 +00002383 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002384 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002385 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002386 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002387 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002388 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2389 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002390 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002391 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002392 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2393
2394 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002395 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002396 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002397 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002398 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002399 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002400 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2401 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002402 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002403 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002404 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2405}
2406
2407
2408
2409// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002410let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002411def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002412 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002413 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002414def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002415 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002416 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002417def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002418 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002419 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002420 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002421def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002422 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002423 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002424 TB, OpSize;
2425}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002426
2427let isCommutable = 1 in { // These instructions commute to each other.
2428def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002429 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002430 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002431 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2432 (i8 imm:$src3)))]>,
2433 TB;
2434def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002435 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002436 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002437 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2438 (i8 imm:$src3)))]>,
2439 TB;
2440def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002441 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002442 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002443 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2444 (i8 imm:$src3)))]>,
2445 TB, OpSize;
2446def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002447 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002448 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002449 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2450 (i8 imm:$src3)))]>,
2451 TB, OpSize;
2452}
2453
2454let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002455 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002456 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002457 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002458 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002459 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002460 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002461 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002462 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002463 addr:$dst)]>, TB;
2464 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002465 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002466 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002467 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002468 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2469 (i8 imm:$src3)), addr:$dst)]>,
2470 TB;
2471 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002472 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002473 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002474 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2475 (i8 imm:$src3)), addr:$dst)]>,
2476 TB;
2477
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002478 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002479 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002480 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002481 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002482 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002483 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002484 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002485 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002486 addr:$dst)]>, TB, OpSize;
2487 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002488 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002489 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002490 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002491 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2492 (i8 imm:$src3)), addr:$dst)]>,
2493 TB, OpSize;
2494 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002495 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002496 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002497 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2498 (i8 imm:$src3)), addr:$dst)]>,
2499 TB, OpSize;
2500}
Evan Cheng55687072007-09-14 21:48:26 +00002501} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002502
2503
2504// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002505let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002506let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002507// Register-Register Addition
2508def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2509 (ins GR8 :$src1, GR8 :$src2),
2510 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002511 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002512 (implicit EFLAGS)]>;
2513
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002514let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002515// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002516def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2517 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002518 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002519 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2520 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002521def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2522 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002523 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002524 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2525 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002526} // end isConvertibleToThreeAddress
2527} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002528
2529// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002530def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2531 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002532 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002533 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2534 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002535def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2536 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002537 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002538 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2539 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002540def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2541 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002542 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002543 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2544 (implicit EFLAGS)]>;
Sean Callanan7e7df0e2009-09-15 20:53:57 +00002545
Sean Callanan84df9312009-09-15 21:43:27 +00002546// Register-Register Addition - Equivalent to the normal rr forms (ADD8rr,
2547// ADD16rr, and ADD32rr), but differently encoded.
Sean Callanan7e7df0e2009-09-15 20:53:57 +00002548def ADD8mrmrr: I<0x02, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2549 "add{b}\t{$src2, $dst|$dst, $src2}", []>;
2550def ADD16mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2551 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2552def ADD32mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2553 "add{l}\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002554
Bill Wendlingae034ed2008-12-12 00:56:36 +00002555// Register-Integer Addition
2556def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2557 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002558 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2559 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002560
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002561let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002562// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002563def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2564 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002565 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002566 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2567 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002568def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2569 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002570 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002571 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2572 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002573def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2574 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002575 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002576 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2577 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002578def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2579 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002580 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002581 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2582 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002583}
2584
2585let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002586 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002587 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002588 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002589 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2590 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002591 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002592 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002593 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2594 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002595 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002596 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002597 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2598 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002599 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002600 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002601 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2602 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002603 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002604 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002605 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2606 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002607 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002608 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002609 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2610 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002611 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002612 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002613 [(store (add (load addr:$dst), i16immSExt8:$src2),
2614 addr:$dst),
2615 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002616 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002617 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002618 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002619 addr:$dst),
2620 (implicit EFLAGS)]>;
Sean Callanan0316b342009-08-11 21:26:06 +00002621
2622 // addition to rAX
2623 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002624 "add{b}\t{$src, %al|%al, $src}", []>;
Sean Callanan0316b342009-08-11 21:26:06 +00002625 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002626 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callanan0316b342009-08-11 21:26:06 +00002627 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002628 "add{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002629}
2630
Evan Cheng259471d2007-10-05 17:59:57 +00002631let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002632let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen747fe522009-06-02 03:12:52 +00002633def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002634 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002635 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002636def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2637 (ins GR16:$src1, GR16:$src2),
2638 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002639 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002640def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2641 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002642 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002643 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002644}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002645def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2646 (ins GR8:$src1, i8mem:$src2),
2647 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002648 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002649def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2650 (ins GR16:$src1, i16mem:$src2),
2651 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002652 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002653 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002654def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2655 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002656 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002657 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2658def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002659 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002660 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002661def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2662 (ins GR16:$src1, i16imm:$src2),
2663 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002664 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002665def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2666 (ins GR16:$src1, i16i8imm:$src2),
2667 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002668 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2669 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002670def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2671 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002672 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002673 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002674def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2675 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002676 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002677 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002678
2679let isTwoAddress = 0 in {
Dale Johannesen747fe522009-06-02 03:12:52 +00002680 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002681 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002682 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2683 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002684 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002685 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2686 OpSize;
2687 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002688 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002689 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2690 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002691 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002692 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2693 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002694 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002695 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2696 OpSize;
2697 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002698 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002699 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2700 OpSize;
2701 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002702 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002703 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2704 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002705 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002706 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00002707
2708 def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2709 "adc{b}\t{$src, %al|%al, $src}", []>;
2710 def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
2711 "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2712 def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
2713 "adc{l}\t{$src, %eax|%eax, $src}", []>;
Dale Johannesen747fe522009-06-02 03:12:52 +00002714}
Evan Cheng259471d2007-10-05 17:59:57 +00002715} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002716
Bill Wendlingae034ed2008-12-12 00:56:36 +00002717// Register-Register Subtraction
2718def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2719 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002720 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2721 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002722def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2723 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002724 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2725 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002726def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2727 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002728 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2729 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002730
2731// Register-Memory Subtraction
2732def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2733 (ins GR8 :$src1, i8mem :$src2),
2734 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002735 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2736 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002737def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2738 (ins GR16:$src1, i16mem:$src2),
2739 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002740 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2741 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002742def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2743 (ins GR32:$src1, i32mem:$src2),
2744 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002745 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2746 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002747
2748// Register-Integer Subtraction
2749def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2750 (ins GR8:$src1, i8imm:$src2),
2751 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002752 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2753 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002754def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2755 (ins GR16:$src1, i16imm:$src2),
2756 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002757 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2758 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002759def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2760 (ins GR32:$src1, i32imm:$src2),
2761 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002762 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2763 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002764def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2765 (ins GR16:$src1, i16i8imm:$src2),
2766 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002767 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2768 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002769def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2770 (ins GR32:$src1, i32i8imm:$src2),
2771 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002772 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2773 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002774
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002775let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002776 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002777 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002778 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002779 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2780 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002781 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002782 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002783 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2784 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002785 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002786 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002787 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2788 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002789
2790 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002791 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002792 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002793 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2794 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002795 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002796 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002797 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2798 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002799 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002800 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002801 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2802 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002803 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002804 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002805 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002806 addr:$dst),
2807 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002808 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002809 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002810 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002811 addr:$dst),
2812 (implicit EFLAGS)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00002813
2814 def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
2815 "sub{b}\t{$src, %al|%al, $src}", []>;
2816 def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
2817 "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2818 def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
2819 "sub{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002820}
2821
Evan Cheng259471d2007-10-05 17:59:57 +00002822let Uses = [EFLAGS] in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002823def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2824 (ins GR8:$src1, GR8:$src2),
2825 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002826 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002827def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2828 (ins GR16:$src1, GR16:$src2),
2829 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002830 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002831def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2832 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002833 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002834 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002835
2836let isTwoAddress = 0 in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002837 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2838 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002839 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002840 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2841 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002842 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002843 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002844 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002845 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002846 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002847 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002848 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002849 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002850 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2851 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002852 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002853 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002854 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2855 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002856 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002857 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002858 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002859 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002860 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002861 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002862 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002863 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00002864
2865 def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
2866 "sbb{b}\t{$src, %al|%al, $src}", []>;
2867 def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
2868 "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2869 def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
2870 "sbb{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002871}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002872def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2873 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002874 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002875def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2876 (ins GR16:$src1, i16mem:$src2),
2877 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002878 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002879 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002880def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2881 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002882 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002883 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002884def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2885 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002886 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002887def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
2888 (ins GR16:$src1, i16imm:$src2),
2889 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002890 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002891def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2892 (ins GR16:$src1, i16i8imm:$src2),
2893 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002894 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
2895 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002896def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
2897 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002898 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002899 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002900def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2901 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002902 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002903 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002904} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002905} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002906
Evan Cheng55687072007-09-14 21:48:26 +00002907let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002908let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00002909// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002910def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002911 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002912 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2913 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002914def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002915 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002916 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2917 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002918}
Bill Wendlingae034ed2008-12-12 00:56:36 +00002919
Bill Wendlingf5399032008-12-12 21:15:41 +00002920// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002921def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2922 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002923 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002924 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2925 (implicit EFLAGS)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002926def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002927 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002928 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2929 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002930} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002931} // end Two Address instructions
2932
2933// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002934let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00002935// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002936def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002937 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002938 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002939 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2940 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002941def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002942 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002943 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002944 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2945 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002946def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002947 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002948 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002949 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2950 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002951def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002952 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002953 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002954 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2955 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002956
Bill Wendlingf5399032008-12-12 21:15:41 +00002957// Memory-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002958def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002959 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002960 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002961 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2962 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002963def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002964 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002965 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002966 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2967 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002968def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002969 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002970 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002971 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002972 i16immSExt8:$src2)),
2973 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002974def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002975 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002976 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002977 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002978 i32immSExt8:$src2)),
2979 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002980} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002981
2982//===----------------------------------------------------------------------===//
2983// Test instructions are just like AND, except they don't generate a result.
2984//
Evan Cheng950aac02007-09-25 01:57:46 +00002985let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002986let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002987def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002988 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002989 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002990 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002991def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002992 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002993 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002994 (implicit EFLAGS)]>,
2995 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002996def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002997 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002998 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002999 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003000}
3001
Sean Callanan3e4b1a32009-09-01 18:14:18 +00003002def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
3003 "test{b}\t{$src, %al|%al, $src}", []>;
3004def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
3005 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3006def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
3007 "test{l}\t{$src, %eax|%eax, $src}", []>;
3008
Evan Chengb783fa32007-07-19 01:14:50 +00003009def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003010 "test{b}\t{$src2, $src1|$src1, $src2}",
3011 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
3012 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003013def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003014 "test{w}\t{$src2, $src1|$src1, $src2}",
3015 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
3016 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003017def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003018 "test{l}\t{$src2, $src1|$src1, $src2}",
3019 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
3020 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003021
3022def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00003023 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003024 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003025 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003026 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003027def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00003028 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003029 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003030 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003031 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003032def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00003033 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003034 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003035 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003036 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003037
Evan Cheng621216e2007-09-29 00:00:36 +00003038def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00003039 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003040 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003041 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
3042 (implicit EFLAGS)]>;
3043def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00003044 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003045 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003046 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
3047 (implicit EFLAGS)]>, OpSize;
3048def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00003049 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003050 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003051 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00003052 (implicit EFLAGS)]>;
3053} // Defs = [EFLAGS]
3054
3055
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003056// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003057let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00003058def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003059let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00003060def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003061
Evan Cheng950aac02007-09-25 01:57:46 +00003062let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003063def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003064 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003065 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003066 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003067 TB; // GR8 = ==
3068def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003069 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003070 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003071 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003072 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003073
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003074def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003075 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003076 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003077 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003078 TB; // GR8 = !=
3079def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003080 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003081 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003082 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003083 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003084
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003085def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003086 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003087 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003088 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003089 TB; // GR8 = < signed
3090def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003091 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003092 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003093 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003094 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003095
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003096def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003097 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003098 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003099 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003100 TB; // GR8 = >= signed
3101def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003102 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003103 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003104 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003105 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003106
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003107def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003108 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003109 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003110 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003111 TB; // GR8 = <= signed
3112def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003113 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003114 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003115 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003116 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003117
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003118def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003119 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003120 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003121 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003122 TB; // GR8 = > signed
3123def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003124 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003125 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003126 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003127 TB; // [mem8] = > signed
3128
3129def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003130 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003131 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003132 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003133 TB; // GR8 = < unsign
3134def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003135 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003136 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003137 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003138 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003139
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003140def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003141 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003142 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003143 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003144 TB; // GR8 = >= unsign
3145def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003146 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003147 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003148 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003149 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003150
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003151def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003152 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003153 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003154 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003155 TB; // GR8 = <= unsign
3156def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003157 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003158 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003159 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003160 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003161
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003162def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003163 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003164 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003165 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003166 TB; // GR8 = > signed
3167def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003168 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003169 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003170 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003171 TB; // [mem8] = > signed
3172
3173def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003174 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003175 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003176 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003177 TB; // GR8 = <sign bit>
3178def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003179 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003180 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003181 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003182 TB; // [mem8] = <sign bit>
3183def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003184 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003185 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003186 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003187 TB; // GR8 = !<sign bit>
3188def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003189 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003190 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003191 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003192 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003193
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003194def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003195 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003196 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003197 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003198 TB; // GR8 = parity
3199def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003200 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003201 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003202 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003203 TB; // [mem8] = parity
3204def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003205 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003206 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003207 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003208 TB; // GR8 = not parity
3209def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003210 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003211 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003212 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003213 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003214
3215def SETOr : I<0x90, MRM0r,
3216 (outs GR8 :$dst), (ins),
3217 "seto\t$dst",
3218 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
3219 TB; // GR8 = overflow
3220def SETOm : I<0x90, MRM0m,
3221 (outs), (ins i8mem:$dst),
3222 "seto\t$dst",
3223 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
3224 TB; // [mem8] = overflow
3225def SETNOr : I<0x91, MRM0r,
3226 (outs GR8 :$dst), (ins),
3227 "setno\t$dst",
3228 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3229 TB; // GR8 = not overflow
3230def SETNOm : I<0x91, MRM0m,
3231 (outs), (ins i8mem:$dst),
3232 "setno\t$dst",
3233 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3234 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00003235} // Uses = [EFLAGS]
3236
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003237
3238// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00003239let Defs = [EFLAGS] in {
Sean Callanan251676e2009-09-02 00:55:49 +00003240def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3241 "cmp{b}\t{$src, %al|%al, $src}", []>;
3242def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3243 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3244def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3245 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3246
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003247def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003248 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003249 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003250 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003251def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003252 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003253 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003254 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003255def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003256 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003257 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003258 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003259def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003260 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003261 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003262 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
3263 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003264def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003265 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003266 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003267 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
3268 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003269def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003270 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003271 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003272 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
3273 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003274def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003275 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003276 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003277 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
3278 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003279def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003280 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003281 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003282 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
3283 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003284def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003285 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003286 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003287 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
3288 (implicit EFLAGS)]>;
Sean Callanan11490dc2009-09-16 21:11:23 +00003289def CMP8mrmrr : I<0x3A, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3290 "cmp{b}\t{$src2, $src1|$src1, $src2}", []>;
3291def CMP16mrmrr : I<0x3B, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3292 "cmp{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize;
3293def CMP32mrmrr : I<0x3B, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3294 "cmp{l}\t{$src2, $src1|$src1, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003295def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003296 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003297 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003298 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003299def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003300 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003301 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003302 [(X86cmp GR16:$src1, imm:$src2),
3303 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003304def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003305 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003306 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003307 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003308def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003309 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003310 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003311 [(X86cmp (loadi8 addr:$src1), imm:$src2),
3312 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003313def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003314 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003315 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003316 [(X86cmp (loadi16 addr:$src1), imm:$src2),
3317 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003318def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003319 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003320 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003321 [(X86cmp (loadi32 addr:$src1), imm:$src2),
3322 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003323def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003324 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003325 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003326 [(X86cmp GR16:$src1, i16immSExt8:$src2),
3327 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003328def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003329 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003330 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003331 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
3332 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003333def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003334 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003335 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003336 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
3337 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003338def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003339 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003340 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003341 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00003342 (implicit EFLAGS)]>;
3343} // Defs = [EFLAGS]
3344
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003345// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003346// TODO: BTC, BTR, and BTS
3347let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003348def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003349 "bt{w}\t{$src2, $src1|$src1, $src2}",
3350 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003351 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003352def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003353 "bt{l}\t{$src2, $src1|$src1, $src2}",
3354 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003355 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00003356
3357// Unlike with the register+register form, the memory+register form of the
3358// bt instruction does not ignore the high bits of the index. From ISel's
3359// perspective, this is pretty bizarre. Disable these instructions for now.
3360//def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3361// "bt{w}\t{$src2, $src1|$src1, $src2}",
3362// [(X86bt (loadi16 addr:$src1), GR16:$src2),
3363// (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
3364//def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3365// "bt{l}\t{$src2, $src1|$src1, $src2}",
3366// [(X86bt (loadi32 addr:$src1), GR32:$src2),
3367// (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00003368
3369def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3370 "bt{w}\t{$src2, $src1|$src1, $src2}",
3371 [(X86bt GR16:$src1, i16immSExt8:$src2),
3372 (implicit EFLAGS)]>, OpSize, TB;
3373def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3374 "bt{l}\t{$src2, $src1|$src1, $src2}",
3375 [(X86bt GR32:$src1, i32immSExt8:$src2),
3376 (implicit EFLAGS)]>, TB;
3377// Note that these instructions don't need FastBTMem because that
3378// only applies when the other operand is in a register. When it's
3379// an immediate, bt is still fast.
3380def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3381 "bt{w}\t{$src2, $src1|$src1, $src2}",
3382 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3383 (implicit EFLAGS)]>, OpSize, TB;
3384def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3385 "bt{l}\t{$src2, $src1|$src1, $src2}",
3386 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3387 (implicit EFLAGS)]>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003388} // Defs = [EFLAGS]
3389
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003390// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00003391// Use movsbl intead of movsbw; we don't care about the high 16 bits
3392// of the register here. This has a smaller encoding and avoids a
3393// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003394def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003395 "", [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003396def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003397 "", [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003398def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003399 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003400 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003401def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003402 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003403 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003404def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003405 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003406 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003407def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003408 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003409 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3410
Dan Gohman9203ab42008-07-30 18:09:17 +00003411// Use movzbl intead of movzbw; we don't care about the high 16 bits
3412// of the register here. This has a smaller encoding and avoids a
3413// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003414def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003415 "", [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003416def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003417 "", [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003418def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003419 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003420 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003421def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003422 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003423 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003424def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003425 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003426 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003427def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003428 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003429 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3430
Dan Gohman744d4622009-04-13 16:09:41 +00003431// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3432// except that they use GR32_NOREX for the output operand register class
3433// instead of GR32. This allows them to operate on h registers on x86-64.
3434def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3435 (outs GR32_NOREX:$dst), (ins GR8:$src),
3436 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3437 []>, TB;
Dan Gohman89f4cda2009-04-30 03:11:48 +00003438let mayLoad = 1 in
Dan Gohman744d4622009-04-13 16:09:41 +00003439def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3440 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3441 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3442 []>, TB;
3443
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003444let neverHasSideEffects = 1 in {
3445 let Defs = [AX], Uses = [AL] in
3446 def CBW : I<0x98, RawFrm, (outs), (ins),
3447 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3448 let Defs = [EAX], Uses = [AX] in
3449 def CWDE : I<0x98, RawFrm, (outs), (ins),
3450 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003451
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003452 let Defs = [AX,DX], Uses = [AX] in
3453 def CWD : I<0x99, RawFrm, (outs), (ins),
3454 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3455 let Defs = [EAX,EDX], Uses = [EAX] in
3456 def CDQ : I<0x99, RawFrm, (outs), (ins),
3457 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3458}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003459
3460//===----------------------------------------------------------------------===//
3461// Alias Instructions
3462//===----------------------------------------------------------------------===//
3463
3464// Alias instructions that map movr0 to xor.
3465// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Daniel Dunbara0e62002009-08-11 22:17:52 +00003466let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3467 isCodeGenOnly = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003468def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003469 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003470 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003471// Use xorl instead of xorw since we don't care about the high 16 bits,
3472// it's smaller, and it avoids a partial-register update.
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003473def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
3474 "", [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003475def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003476 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003477 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00003478}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003479
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003480//===----------------------------------------------------------------------===//
3481// Thread Local Storage Instructions
3482//
3483
Rafael Espindola7fc4b8d2009-04-24 12:59:40 +00003484// All calls clobber the non-callee saved registers. ESP is marked as
3485// a use to prevent stack-pointer assignments that appear immediately
3486// before calls from potentially appearing dead.
3487let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3488 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3489 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3490 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Chris Lattnerf1940742009-06-20 20:38:48 +00003491 Uses = [ESP] in
3492def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3493 "leal\t$sym, %eax; "
Dan Gohman70a8a112009-04-27 15:13:28 +00003494 "call\t___tls_get_addr@PLT",
Chris Lattnerf1940742009-06-20 20:38:48 +00003495 [(X86tlsaddr tls32addr:$sym)]>,
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00003496 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003497
Daniel Dunbar75a07302009-08-11 22:24:40 +00003498let AddedComplexity = 5, isCodeGenOnly = 1 in
sampo9cc09a32009-01-26 01:24:32 +00003499def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3500 "movl\t%gs:$src, $dst",
3501 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3502
Daniel Dunbar75a07302009-08-11 22:24:40 +00003503let AddedComplexity = 5, isCodeGenOnly = 1 in
Chris Lattnera7c2d8a2009-05-05 18:52:19 +00003504def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3505 "movl\t%fs:$src, $dst",
3506 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3507
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003508//===----------------------------------------------------------------------===//
3509// DWARF Pseudo Instructions
3510//
3511
Evan Chengb783fa32007-07-19 01:14:50 +00003512def DWARF_LOC : I<0, Pseudo, (outs),
3513 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Chris Lattner64b54552009-07-10 22:34:11 +00003514 ".loc\t$file $line $col",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003515 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3516 (i32 imm:$file))]>;
3517
3518//===----------------------------------------------------------------------===//
3519// EH Pseudo Instructions
3520//
3521let isTerminator = 1, isReturn = 1, isBarrier = 1,
Daniel Dunbar75513bd2009-08-27 07:58:05 +00003522 hasCtrlDep = 1, isCodeGenOnly = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003523def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00003524 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003525 [(X86ehret GR32:$addr)]>;
3526
3527}
3528
3529//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003530// Atomic support
3531//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003532
Evan Cheng3e171562008-04-19 01:20:30 +00003533// Atomic swap. These are just normal xchg instructions. But since a memory
3534// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00003535let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00003536def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3537 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3538 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3539def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3540 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3541 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3542 OpSize;
3543def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3544 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3545 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3546}
3547
Evan Chengd49dbb82008-04-18 20:55:36 +00003548// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003549let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003550def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003551 "lock\n\t"
3552 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003553 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003554}
Dale Johannesenf160d802008-10-02 18:53:47 +00003555let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00003556def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003557 "lock\n\t"
3558 "cmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00003559 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3560}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003561
3562let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003563def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003564 "lock\n\t"
3565 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003566 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003567}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003568let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003569def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003570 "lock\n\t"
3571 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003572 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003573}
3574
Evan Chengd49dbb82008-04-18 20:55:36 +00003575// Atomic exchange and add
3576let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3577def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003578 "lock\n\t"
3579 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003580 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003581 TB, LOCK;
3582def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003583 "lock\n\t"
3584 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003585 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003586 TB, OpSize, LOCK;
3587def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003588 "lock\n\t"
3589 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003590 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003591 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003592}
3593
Evan Chengb723fb52009-07-30 08:33:02 +00003594// Optimized codegen when the non-memory output is not used.
3595// FIXME: Use normal add / sub instructions and add lock prefix dynamically.
Dan Gohman1c286992009-10-20 18:14:49 +00003596let Defs = [EFLAGS] in {
Evan Chengb723fb52009-07-30 08:33:02 +00003597def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3598 "lock\n\t"
3599 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3600def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3601 "lock\n\t"
3602 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3603def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3604 "lock\n\t"
3605 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3606def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3607 "lock\n\t"
3608 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3609def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3610 "lock\n\t"
3611 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3612def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3613 "lock\n\t"
3614 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3615def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3616 "lock\n\t"
3617 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3618def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3619 "lock\n\t"
3620 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3621
3622def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3623 "lock\n\t"
3624 "inc{b}\t$dst", []>, LOCK;
3625def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3626 "lock\n\t"
3627 "inc{w}\t$dst", []>, OpSize, LOCK;
3628def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3629 "lock\n\t"
3630 "inc{l}\t$dst", []>, LOCK;
3631
3632def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3633 "lock\n\t"
3634 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3635def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3636 "lock\n\t"
3637 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3638def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3639 "lock\n\t"
3640 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3641def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3642 "lock\n\t"
3643 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3644def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3645 "lock\n\t"
3646 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3647def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3648 "lock\n\t"
3649 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3650def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3651 "lock\n\t"
3652 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3653def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3654 "lock\n\t"
3655 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3656
3657def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3658 "lock\n\t"
3659 "dec{b}\t$dst", []>, LOCK;
3660def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3661 "lock\n\t"
3662 "dec{w}\t$dst", []>, OpSize, LOCK;
3663def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3664 "lock\n\t"
3665 "dec{l}\t$dst", []>, LOCK;
Dan Gohman1c286992009-10-20 18:14:49 +00003666}
Evan Chengb723fb52009-07-30 08:33:02 +00003667
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003668// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003669let Constraints = "$val = $dst", Defs = [EFLAGS],
Dan Gohman30afe012009-10-29 18:10:34 +00003670 usesCustomInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003671def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003672 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003673 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003674def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003675 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003676 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003677def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003678 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003679 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003680def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003681 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003682 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003683def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003684 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003685 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003686def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003687 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003688 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003689def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003690 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003691 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003692def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003693 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003694 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003695
3696def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003697 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003698 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003699def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003700 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003701 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003702def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003703 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003704 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003705def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003706 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003707 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003708def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003709 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003710 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003711def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003712 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003713 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003714def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003715 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003716 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003717def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003718 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003719 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003720
3721def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003722 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003723 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003724def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003725 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003726 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003727def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003728 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003729 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003730def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003731 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003732 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00003733}
3734
Dale Johannesenf160d802008-10-02 18:53:47 +00003735let Constraints = "$val1 = $dst1, $val2 = $dst2",
3736 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3737 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00003738 mayLoad = 1, mayStore = 1,
Dan Gohman30afe012009-10-29 18:10:34 +00003739 usesCustomInserter = 1 in {
Dale Johannesenf160d802008-10-02 18:53:47 +00003740def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3741 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003742 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003743def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3744 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003745 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003746def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3747 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003748 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003749def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3750 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003751 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003752def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3753 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003754 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003755def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3756 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003757 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00003758def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3759 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003760 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003761}
3762
Sean Callanan2eddf5d2009-09-16 21:55:34 +00003763// Segmentation support instructions.
3764
3765def LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
3766 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3767def LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
3768 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3769
3770// i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo.
3771def LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3772 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
3773def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
3774 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
Sean Callanan23f33d72009-09-16 22:59:28 +00003775
3776// String manipulation instructions
3777
3778def LODSB : I<0xAC, RawFrm, (outs), (ins), "lodsb", []>;
3779def LODSW : I<0xAD, RawFrm, (outs), (ins), "lodsw", []>, OpSize;
3780def LODSD : I<0xAD, RawFrm, (outs), (ins), "lodsd", []>;
Sean Callanan2eddf5d2009-09-16 21:55:34 +00003781
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003782//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003783// Non-Instruction Patterns
3784//===----------------------------------------------------------------------===//
3785
Bill Wendlingfef06052008-09-16 21:48:12 +00003786// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003787def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3788def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00003789def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003790def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3791def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3792
3793def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3794 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3795def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3796 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3797def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3798 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3799def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3800 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3801
3802def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3803 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3804def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3805 (MOV32mi addr:$dst, texternalsym:$src)>;
3806
3807// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003808// tailcall stuff
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003809def : Pat<(X86tcret GR32:$dst, imm:$off),
3810 (TCRETURNri GR32:$dst, imm:$off)>;
3811
3812def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3813 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3814
3815def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3816 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003817
Dan Gohmance5dbff2009-08-02 16:10:01 +00003818// Normal calls, with various flavors of addresses.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003819def : Pat<(X86call (i32 tglobaladdr:$dst)),
3820 (CALLpcrel32 tglobaladdr:$dst)>;
3821def : Pat<(X86call (i32 texternalsym:$dst)),
3822 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng6d35a4d2009-05-20 04:53:57 +00003823def : Pat<(X86call (i32 imm:$dst)),
3824 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003825
3826// X86 specific add which produces a flag.
3827def : Pat<(addc GR32:$src1, GR32:$src2),
3828 (ADD32rr GR32:$src1, GR32:$src2)>;
3829def : Pat<(addc GR32:$src1, (load addr:$src2)),
3830 (ADD32rm GR32:$src1, addr:$src2)>;
3831def : Pat<(addc GR32:$src1, imm:$src2),
3832 (ADD32ri GR32:$src1, imm:$src2)>;
3833def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3834 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3835
3836def : Pat<(subc GR32:$src1, GR32:$src2),
3837 (SUB32rr GR32:$src1, GR32:$src2)>;
3838def : Pat<(subc GR32:$src1, (load addr:$src2)),
3839 (SUB32rm GR32:$src1, addr:$src2)>;
3840def : Pat<(subc GR32:$src1, imm:$src2),
3841 (SUB32ri GR32:$src1, imm:$src2)>;
3842def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3843 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3844
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003845// Comparisons.
3846
3847// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00003848def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003849 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003850def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003851 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003852def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003853 (TEST32rr GR32:$src1, GR32:$src1)>;
3854
Dan Gohman0a3c5222009-01-07 01:00:24 +00003855// Conditional moves with folded loads with operands swapped and conditions
3856// inverted.
3857def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3858 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3859def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3860 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3861def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3862 (CMOVB16rm GR16:$src2, addr:$src1)>;
3863def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3864 (CMOVB32rm GR32:$src2, addr:$src1)>;
3865def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3866 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3867def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3868 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3869def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3870 (CMOVE16rm GR16:$src2, addr:$src1)>;
3871def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3872 (CMOVE32rm GR32:$src2, addr:$src1)>;
3873def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3874 (CMOVA16rm GR16:$src2, addr:$src1)>;
3875def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3876 (CMOVA32rm GR32:$src2, addr:$src1)>;
3877def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3878 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3879def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3880 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3881def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3882 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3883def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3884 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3885def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3886 (CMOVL16rm GR16:$src2, addr:$src1)>;
3887def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3888 (CMOVL32rm GR32:$src2, addr:$src1)>;
3889def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3890 (CMOVG16rm GR16:$src2, addr:$src1)>;
3891def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3892 (CMOVG32rm GR32:$src2, addr:$src1)>;
3893def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3894 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3895def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3896 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3897def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3898 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3899def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3900 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3901def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3902 (CMOVP16rm GR16:$src2, addr:$src1)>;
3903def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3904 (CMOVP32rm GR32:$src2, addr:$src1)>;
3905def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3906 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3907def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3908 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3909def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3910 (CMOVS16rm GR16:$src2, addr:$src1)>;
3911def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3912 (CMOVS32rm GR32:$src2, addr:$src1)>;
3913def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3914 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3915def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3916 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3917def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3918 (CMOVO16rm GR16:$src2, addr:$src1)>;
3919def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3920 (CMOVO32rm GR32:$src2, addr:$src1)>;
3921
Duncan Sands082524c2008-01-23 20:39:46 +00003922// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003923def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3924def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3925def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3926
3927// extload bool -> extload byte
3928def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Dan Gohman9959b052009-08-26 14:59:13 +00003929def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003930def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Dan Gohman9959b052009-08-26 14:59:13 +00003931def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003932def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3933def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3934
Dan Gohman9959b052009-08-26 14:59:13 +00003935// anyext. Define these to do an explicit zero-extend to
3936// avoid partial-register updates.
3937def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
3938def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
3939def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003940
Evan Chengf2abee72007-12-13 00:43:27 +00003941// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00003942def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3943 (MOVZX32rm8 addr:$src)>;
3944def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3945 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00003946
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003947//===----------------------------------------------------------------------===//
3948// Some peepholes
3949//===----------------------------------------------------------------------===//
3950
Dan Gohman5a5e6e92008-10-17 01:33:43 +00003951// Odd encoding trick: -128 fits into an 8-bit immediate field while
3952// +128 doesn't, so in this special case use a sub instead of an add.
3953def : Pat<(add GR16:$src1, 128),
3954 (SUB16ri8 GR16:$src1, -128)>;
3955def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3956 (SUB16mi8 addr:$dst, -128)>;
3957def : Pat<(add GR32:$src1, 128),
3958 (SUB32ri8 GR32:$src1, -128)>;
3959def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3960 (SUB32mi8 addr:$dst, -128)>;
3961
Dan Gohman9203ab42008-07-30 18:09:17 +00003962// r & (2^16-1) ==> movz
3963def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman744d4622009-04-13 16:09:41 +00003964 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003965// r & (2^8-1) ==> movz
3966def : Pat<(and GR32:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003967 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003968 x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003969 Requires<[In32BitMode]>;
3970// r & (2^8-1) ==> movz
3971def : Pat<(and GR16:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003972 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003973 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003974 Requires<[In32BitMode]>;
3975
3976// sext_inreg patterns
3977def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman744d4622009-04-13 16:09:41 +00003978 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003979def : Pat<(sext_inreg GR32:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003980 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003981 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003982 Requires<[In32BitMode]>;
3983def : Pat<(sext_inreg GR16:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003984 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003985 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003986 Requires<[In32BitMode]>;
3987
3988// trunc patterns
3989def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00003990 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003991def : Pat<(i8 (trunc GR32:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003992 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003993 x86_subreg_8bit)>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003994 Requires<[In32BitMode]>;
3995def : Pat<(i8 (trunc GR16:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003996 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003997 x86_subreg_8bit)>,
3998 Requires<[In32BitMode]>;
3999
4000// h-register tricks
4001def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00004002 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00004003 x86_subreg_8bit_hi)>,
4004 Requires<[In32BitMode]>;
4005def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00004006 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00004007 x86_subreg_8bit_hi)>,
4008 Requires<[In32BitMode]>;
4009def : Pat<(srl_su GR16:$src, (i8 8)),
4010 (EXTRACT_SUBREG
4011 (MOVZX32rr8
Dan Gohman6e438702009-04-27 16:33:14 +00004012 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00004013 x86_subreg_8bit_hi)),
4014 x86_subreg_16bit)>,
4015 Requires<[In32BitMode]>;
Evan Cheng957ca282009-05-29 01:44:43 +00004016def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
4017 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
4018 x86_subreg_8bit_hi))>,
4019 Requires<[In32BitMode]>;
Dan Gohman9959b052009-08-26 14:59:13 +00004020def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
4021 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
4022 x86_subreg_8bit_hi))>,
4023 Requires<[In32BitMode]>;
Dan Gohman744d4622009-04-13 16:09:41 +00004024def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Dan Gohman6e438702009-04-27 16:33:14 +00004025 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00004026 x86_subreg_8bit_hi))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00004027 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00004028
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004029// (shl x, 1) ==> (add x, x)
4030def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
4031def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
4032def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
4033
Evan Cheng76a64c72008-08-30 02:03:58 +00004034// (shl x (and y, 31)) ==> (shl x, y)
4035def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
4036 (SHL8rCL GR8:$src1)>;
4037def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
4038 (SHL16rCL GR16:$src1)>;
4039def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
4040 (SHL32rCL GR32:$src1)>;
4041def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4042 (SHL8mCL addr:$dst)>;
4043def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4044 (SHL16mCL addr:$dst)>;
4045def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4046 (SHL32mCL addr:$dst)>;
4047
4048def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
4049 (SHR8rCL GR8:$src1)>;
4050def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
4051 (SHR16rCL GR16:$src1)>;
4052def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
4053 (SHR32rCL GR32:$src1)>;
4054def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4055 (SHR8mCL addr:$dst)>;
4056def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4057 (SHR16mCL addr:$dst)>;
4058def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4059 (SHR32mCL addr:$dst)>;
4060
4061def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
4062 (SAR8rCL GR8:$src1)>;
4063def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
4064 (SAR16rCL GR16:$src1)>;
4065def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
4066 (SAR32rCL GR32:$src1)>;
4067def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4068 (SAR8mCL addr:$dst)>;
4069def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4070 (SAR16mCL addr:$dst)>;
4071def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4072 (SAR32mCL addr:$dst)>;
4073
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004074// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
4075def : Pat<(or (srl GR32:$src1, CL:$amt),
4076 (shl GR32:$src2, (sub 32, CL:$amt))),
4077 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
4078
4079def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
4080 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4081 (SHRD32mrCL addr:$dst, GR32:$src2)>;
4082
Dan Gohman921581d2008-10-17 01:23:35 +00004083def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
4084 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4085 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
4086
4087def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4088 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4089 addr:$dst),
4090 (SHRD32mrCL addr:$dst, GR32:$src2)>;
4091
4092def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
4093 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4094
4095def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
4096 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
4097 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4098
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004099// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
4100def : Pat<(or (shl GR32:$src1, CL:$amt),
4101 (srl GR32:$src2, (sub 32, CL:$amt))),
4102 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
4103
4104def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
4105 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4106 (SHLD32mrCL addr:$dst, GR32:$src2)>;
4107
Dan Gohman921581d2008-10-17 01:23:35 +00004108def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
4109 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4110 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
4111
4112def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4113 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4114 addr:$dst),
4115 (SHLD32mrCL addr:$dst, GR32:$src2)>;
4116
4117def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
4118 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4119
4120def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
4121 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
4122 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4123
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004124// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
4125def : Pat<(or (srl GR16:$src1, CL:$amt),
4126 (shl GR16:$src2, (sub 16, CL:$amt))),
4127 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4128
4129def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
4130 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4131 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4132
Dan Gohman921581d2008-10-17 01:23:35 +00004133def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
4134 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4135 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4136
4137def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4138 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4139 addr:$dst),
4140 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4141
4142def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4143 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4144
4145def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
4146 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4147 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4148
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004149// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
4150def : Pat<(or (shl GR16:$src1, CL:$amt),
4151 (srl GR16:$src2, (sub 16, CL:$amt))),
4152 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4153
4154def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
4155 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4156 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4157
Dan Gohman921581d2008-10-17 01:23:35 +00004158def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
4159 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4160 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4161
4162def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4163 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4164 addr:$dst),
4165 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4166
4167def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4168 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4169
4170def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
4171 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4172 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4173
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004174//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00004175// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00004176//===----------------------------------------------------------------------===//
4177
Dan Gohman99a12192009-03-04 19:44:21 +00004178// Register-Register Addition with EFLAGS result
4179def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004180 (implicit EFLAGS)),
4181 (ADD8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004182def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004183 (implicit EFLAGS)),
4184 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004185def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004186 (implicit EFLAGS)),
4187 (ADD32rr GR32:$src1, GR32:$src2)>;
4188
Dan Gohman99a12192009-03-04 19:44:21 +00004189// Register-Memory Addition with EFLAGS result
4190def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004191 (implicit EFLAGS)),
4192 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004193def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004194 (implicit EFLAGS)),
4195 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004196def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004197 (implicit EFLAGS)),
4198 (ADD32rm GR32:$src1, addr:$src2)>;
4199
Dan Gohman99a12192009-03-04 19:44:21 +00004200// Register-Integer Addition with EFLAGS result
4201def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004202 (implicit EFLAGS)),
4203 (ADD8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004204def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004205 (implicit EFLAGS)),
4206 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004207def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004208 (implicit EFLAGS)),
4209 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004210def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004211 (implicit EFLAGS)),
4212 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004213def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004214 (implicit EFLAGS)),
4215 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4216
Dan Gohman99a12192009-03-04 19:44:21 +00004217// Memory-Register Addition with EFLAGS result
4218def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004219 addr:$dst),
4220 (implicit EFLAGS)),
4221 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004222def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004223 addr:$dst),
4224 (implicit EFLAGS)),
4225 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004226def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004227 addr:$dst),
4228 (implicit EFLAGS)),
4229 (ADD32mr addr:$dst, GR32:$src2)>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00004230
4231// Memory-Integer Addition with EFLAGS result
Dan Gohman99a12192009-03-04 19:44:21 +00004232def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004233 addr:$dst),
4234 (implicit EFLAGS)),
4235 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004236def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004237 addr:$dst),
4238 (implicit EFLAGS)),
4239 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004240def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004241 addr:$dst),
4242 (implicit EFLAGS)),
4243 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004244def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004245 addr:$dst),
4246 (implicit EFLAGS)),
4247 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004248def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004249 addr:$dst),
4250 (implicit EFLAGS)),
4251 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
4252
Dan Gohman99a12192009-03-04 19:44:21 +00004253// Register-Register Subtraction with EFLAGS result
4254def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004255 (implicit EFLAGS)),
4256 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004257def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004258 (implicit EFLAGS)),
4259 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004260def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004261 (implicit EFLAGS)),
4262 (SUB32rr GR32:$src1, GR32:$src2)>;
4263
Dan Gohman99a12192009-03-04 19:44:21 +00004264// Register-Memory Subtraction with EFLAGS result
4265def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004266 (implicit EFLAGS)),
4267 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004268def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004269 (implicit EFLAGS)),
4270 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004271def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004272 (implicit EFLAGS)),
4273 (SUB32rm GR32:$src1, addr:$src2)>;
4274
Dan Gohman99a12192009-03-04 19:44:21 +00004275// Register-Integer Subtraction with EFLAGS result
4276def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004277 (implicit EFLAGS)),
4278 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004279def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004280 (implicit EFLAGS)),
4281 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004282def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004283 (implicit EFLAGS)),
4284 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004285def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004286 (implicit EFLAGS)),
4287 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004288def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004289 (implicit EFLAGS)),
4290 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4291
Dan Gohman99a12192009-03-04 19:44:21 +00004292// Memory-Register Subtraction with EFLAGS result
4293def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004294 addr:$dst),
4295 (implicit EFLAGS)),
4296 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004297def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004298 addr:$dst),
4299 (implicit EFLAGS)),
4300 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004301def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004302 addr:$dst),
4303 (implicit EFLAGS)),
4304 (SUB32mr addr:$dst, GR32:$src2)>;
4305
Dan Gohman99a12192009-03-04 19:44:21 +00004306// Memory-Integer Subtraction with EFLAGS result
4307def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004308 addr:$dst),
4309 (implicit EFLAGS)),
4310 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004311def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004312 addr:$dst),
4313 (implicit EFLAGS)),
4314 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004315def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004316 addr:$dst),
4317 (implicit EFLAGS)),
4318 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004319def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004320 addr:$dst),
4321 (implicit EFLAGS)),
4322 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004323def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004324 addr:$dst),
4325 (implicit EFLAGS)),
4326 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
4327
4328
Dan Gohman99a12192009-03-04 19:44:21 +00004329// Register-Register Signed Integer Multiply with EFLAGS result
4330def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004331 (implicit EFLAGS)),
4332 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004333def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004334 (implicit EFLAGS)),
4335 (IMUL32rr GR32:$src1, GR32:$src2)>;
4336
Dan Gohman99a12192009-03-04 19:44:21 +00004337// Register-Memory Signed Integer Multiply with EFLAGS result
4338def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004339 (implicit EFLAGS)),
4340 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004341def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004342 (implicit EFLAGS)),
4343 (IMUL32rm GR32:$src1, addr:$src2)>;
4344
Dan Gohman99a12192009-03-04 19:44:21 +00004345// Register-Integer Signed Integer Multiply with EFLAGS result
4346def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004347 (implicit EFLAGS)),
4348 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004349def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004350 (implicit EFLAGS)),
4351 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004352def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004353 (implicit EFLAGS)),
4354 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004355def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004356 (implicit EFLAGS)),
4357 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4358
Dan Gohman99a12192009-03-04 19:44:21 +00004359// Memory-Integer Signed Integer Multiply with EFLAGS result
4360def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004361 (implicit EFLAGS)),
4362 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004363def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004364 (implicit EFLAGS)),
4365 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004366def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004367 (implicit EFLAGS)),
4368 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004369def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004370 (implicit EFLAGS)),
4371 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4372
Dan Gohman99a12192009-03-04 19:44:21 +00004373// Optimize multiply by 2 with EFLAGS result.
Evan Cheng00cf7932009-01-27 03:30:42 +00004374let AddedComplexity = 2 in {
Dan Gohman99a12192009-03-04 19:44:21 +00004375def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004376 (implicit EFLAGS)),
4377 (ADD16rr GR16:$src1, GR16:$src1)>;
4378
Dan Gohman99a12192009-03-04 19:44:21 +00004379def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004380 (implicit EFLAGS)),
4381 (ADD32rr GR32:$src1, GR32:$src1)>;
4382}
4383
Dan Gohman99a12192009-03-04 19:44:21 +00004384// INC and DEC with EFLAGS result. Note that these do not set CF.
4385def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
4386 (INC8r GR8:$src)>;
4387def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
4388 (implicit EFLAGS)),
4389 (INC8m addr:$dst)>;
4390def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
4391 (DEC8r GR8:$src)>;
4392def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
4393 (implicit EFLAGS)),
4394 (DEC8m addr:$dst)>;
4395
4396def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004397 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004398def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
4399 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004400 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004401def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004402 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004403def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
4404 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004405 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004406
4407def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004408 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004409def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
4410 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004411 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004412def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004413 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004414def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
4415 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004416 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004417
Dan Gohman12e03292009-09-18 19:59:53 +00004418// Register-Register Or with EFLAGS result
4419def : Pat<(parallel (X86or_flag GR8:$src1, GR8:$src2),
4420 (implicit EFLAGS)),
4421 (OR8rr GR8:$src1, GR8:$src2)>;
4422def : Pat<(parallel (X86or_flag GR16:$src1, GR16:$src2),
4423 (implicit EFLAGS)),
4424 (OR16rr GR16:$src1, GR16:$src2)>;
4425def : Pat<(parallel (X86or_flag GR32:$src1, GR32:$src2),
4426 (implicit EFLAGS)),
4427 (OR32rr GR32:$src1, GR32:$src2)>;
4428
4429// Register-Memory Or with EFLAGS result
4430def : Pat<(parallel (X86or_flag GR8:$src1, (loadi8 addr:$src2)),
4431 (implicit EFLAGS)),
4432 (OR8rm GR8:$src1, addr:$src2)>;
4433def : Pat<(parallel (X86or_flag GR16:$src1, (loadi16 addr:$src2)),
4434 (implicit EFLAGS)),
4435 (OR16rm GR16:$src1, addr:$src2)>;
4436def : Pat<(parallel (X86or_flag GR32:$src1, (loadi32 addr:$src2)),
4437 (implicit EFLAGS)),
4438 (OR32rm GR32:$src1, addr:$src2)>;
4439
4440// Register-Integer Or with EFLAGS result
4441def : Pat<(parallel (X86or_flag GR8:$src1, imm:$src2),
4442 (implicit EFLAGS)),
4443 (OR8ri GR8:$src1, imm:$src2)>;
4444def : Pat<(parallel (X86or_flag GR16:$src1, imm:$src2),
4445 (implicit EFLAGS)),
4446 (OR16ri GR16:$src1, imm:$src2)>;
4447def : Pat<(parallel (X86or_flag GR32:$src1, imm:$src2),
4448 (implicit EFLAGS)),
4449 (OR32ri GR32:$src1, imm:$src2)>;
4450def : Pat<(parallel (X86or_flag GR16:$src1, i16immSExt8:$src2),
4451 (implicit EFLAGS)),
4452 (OR16ri8 GR16:$src1, i16immSExt8:$src2)>;
4453def : Pat<(parallel (X86or_flag GR32:$src1, i32immSExt8:$src2),
4454 (implicit EFLAGS)),
4455 (OR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4456
4457// Memory-Register Or with EFLAGS result
4458def : Pat<(parallel (store (X86or_flag (loadi8 addr:$dst), GR8:$src2),
4459 addr:$dst),
4460 (implicit EFLAGS)),
4461 (OR8mr addr:$dst, GR8:$src2)>;
4462def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), GR16:$src2),
4463 addr:$dst),
4464 (implicit EFLAGS)),
4465 (OR16mr addr:$dst, GR16:$src2)>;
4466def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), GR32:$src2),
4467 addr:$dst),
4468 (implicit EFLAGS)),
4469 (OR32mr addr:$dst, GR32:$src2)>;
4470
4471// Memory-Integer Or with EFLAGS result
4472def : Pat<(parallel (store (X86or_flag (loadi8 addr:$dst), imm:$src2),
4473 addr:$dst),
4474 (implicit EFLAGS)),
4475 (OR8mi addr:$dst, imm:$src2)>;
4476def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), imm:$src2),
4477 addr:$dst),
4478 (implicit EFLAGS)),
4479 (OR16mi addr:$dst, imm:$src2)>;
4480def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), imm:$src2),
4481 addr:$dst),
4482 (implicit EFLAGS)),
4483 (OR32mi addr:$dst, imm:$src2)>;
4484def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), i16immSExt8:$src2),
4485 addr:$dst),
4486 (implicit EFLAGS)),
4487 (OR16mi8 addr:$dst, i16immSExt8:$src2)>;
4488def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), i32immSExt8:$src2),
4489 addr:$dst),
4490 (implicit EFLAGS)),
4491 (OR32mi8 addr:$dst, i32immSExt8:$src2)>;
4492
4493// Register-Register XOr with EFLAGS result
4494def : Pat<(parallel (X86xor_flag GR8:$src1, GR8:$src2),
4495 (implicit EFLAGS)),
4496 (XOR8rr GR8:$src1, GR8:$src2)>;
4497def : Pat<(parallel (X86xor_flag GR16:$src1, GR16:$src2),
4498 (implicit EFLAGS)),
4499 (XOR16rr GR16:$src1, GR16:$src2)>;
4500def : Pat<(parallel (X86xor_flag GR32:$src1, GR32:$src2),
4501 (implicit EFLAGS)),
4502 (XOR32rr GR32:$src1, GR32:$src2)>;
4503
4504// Register-Memory XOr with EFLAGS result
4505def : Pat<(parallel (X86xor_flag GR8:$src1, (loadi8 addr:$src2)),
4506 (implicit EFLAGS)),
4507 (XOR8rm GR8:$src1, addr:$src2)>;
4508def : Pat<(parallel (X86xor_flag GR16:$src1, (loadi16 addr:$src2)),
4509 (implicit EFLAGS)),
4510 (XOR16rm GR16:$src1, addr:$src2)>;
4511def : Pat<(parallel (X86xor_flag GR32:$src1, (loadi32 addr:$src2)),
4512 (implicit EFLAGS)),
4513 (XOR32rm GR32:$src1, addr:$src2)>;
4514
4515// Register-Integer XOr with EFLAGS result
4516def : Pat<(parallel (X86xor_flag GR8:$src1, imm:$src2),
4517 (implicit EFLAGS)),
4518 (XOR8ri GR8:$src1, imm:$src2)>;
4519def : Pat<(parallel (X86xor_flag GR16:$src1, imm:$src2),
4520 (implicit EFLAGS)),
4521 (XOR16ri GR16:$src1, imm:$src2)>;
4522def : Pat<(parallel (X86xor_flag GR32:$src1, imm:$src2),
4523 (implicit EFLAGS)),
4524 (XOR32ri GR32:$src1, imm:$src2)>;
4525def : Pat<(parallel (X86xor_flag GR16:$src1, i16immSExt8:$src2),
4526 (implicit EFLAGS)),
4527 (XOR16ri8 GR16:$src1, i16immSExt8:$src2)>;
4528def : Pat<(parallel (X86xor_flag GR32:$src1, i32immSExt8:$src2),
4529 (implicit EFLAGS)),
4530 (XOR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4531
4532// Memory-Register XOr with EFLAGS result
4533def : Pat<(parallel (store (X86xor_flag (loadi8 addr:$dst), GR8:$src2),
4534 addr:$dst),
4535 (implicit EFLAGS)),
4536 (XOR8mr addr:$dst, GR8:$src2)>;
4537def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), GR16:$src2),
4538 addr:$dst),
4539 (implicit EFLAGS)),
4540 (XOR16mr addr:$dst, GR16:$src2)>;
4541def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), GR32:$src2),
4542 addr:$dst),
4543 (implicit EFLAGS)),
4544 (XOR32mr addr:$dst, GR32:$src2)>;
4545
4546// Memory-Integer XOr with EFLAGS result
4547def : Pat<(parallel (store (X86xor_flag (loadi8 addr:$dst), imm:$src2),
4548 addr:$dst),
4549 (implicit EFLAGS)),
4550 (XOR8mi addr:$dst, imm:$src2)>;
4551def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), imm:$src2),
4552 addr:$dst),
4553 (implicit EFLAGS)),
4554 (XOR16mi addr:$dst, imm:$src2)>;
4555def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), imm:$src2),
4556 addr:$dst),
4557 (implicit EFLAGS)),
4558 (XOR32mi addr:$dst, imm:$src2)>;
4559def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), i16immSExt8:$src2),
4560 addr:$dst),
4561 (implicit EFLAGS)),
4562 (XOR16mi8 addr:$dst, i16immSExt8:$src2)>;
4563def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), i32immSExt8:$src2),
4564 addr:$dst),
4565 (implicit EFLAGS)),
4566 (XOR32mi8 addr:$dst, i32immSExt8:$src2)>;
4567
4568// Register-Register And with EFLAGS result
4569def : Pat<(parallel (X86and_flag GR8:$src1, GR8:$src2),
4570 (implicit EFLAGS)),
4571 (AND8rr GR8:$src1, GR8:$src2)>;
4572def : Pat<(parallel (X86and_flag GR16:$src1, GR16:$src2),
4573 (implicit EFLAGS)),
4574 (AND16rr GR16:$src1, GR16:$src2)>;
4575def : Pat<(parallel (X86and_flag GR32:$src1, GR32:$src2),
4576 (implicit EFLAGS)),
4577 (AND32rr GR32:$src1, GR32:$src2)>;
4578
4579// Register-Memory And with EFLAGS result
4580def : Pat<(parallel (X86and_flag GR8:$src1, (loadi8 addr:$src2)),
4581 (implicit EFLAGS)),
4582 (AND8rm GR8:$src1, addr:$src2)>;
4583def : Pat<(parallel (X86and_flag GR16:$src1, (loadi16 addr:$src2)),
4584 (implicit EFLAGS)),
4585 (AND16rm GR16:$src1, addr:$src2)>;
4586def : Pat<(parallel (X86and_flag GR32:$src1, (loadi32 addr:$src2)),
4587 (implicit EFLAGS)),
4588 (AND32rm GR32:$src1, addr:$src2)>;
4589
4590// Register-Integer And with EFLAGS result
4591def : Pat<(parallel (X86and_flag GR8:$src1, imm:$src2),
4592 (implicit EFLAGS)),
4593 (AND8ri GR8:$src1, imm:$src2)>;
4594def : Pat<(parallel (X86and_flag GR16:$src1, imm:$src2),
4595 (implicit EFLAGS)),
4596 (AND16ri GR16:$src1, imm:$src2)>;
4597def : Pat<(parallel (X86and_flag GR32:$src1, imm:$src2),
4598 (implicit EFLAGS)),
4599 (AND32ri GR32:$src1, imm:$src2)>;
4600def : Pat<(parallel (X86and_flag GR16:$src1, i16immSExt8:$src2),
4601 (implicit EFLAGS)),
4602 (AND16ri8 GR16:$src1, i16immSExt8:$src2)>;
4603def : Pat<(parallel (X86and_flag GR32:$src1, i32immSExt8:$src2),
4604 (implicit EFLAGS)),
4605 (AND32ri8 GR32:$src1, i32immSExt8:$src2)>;
4606
4607// Memory-Register And with EFLAGS result
4608def : Pat<(parallel (store (X86and_flag (loadi8 addr:$dst), GR8:$src2),
4609 addr:$dst),
4610 (implicit EFLAGS)),
4611 (AND8mr addr:$dst, GR8:$src2)>;
4612def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), GR16:$src2),
4613 addr:$dst),
4614 (implicit EFLAGS)),
4615 (AND16mr addr:$dst, GR16:$src2)>;
4616def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), GR32:$src2),
4617 addr:$dst),
4618 (implicit EFLAGS)),
4619 (AND32mr addr:$dst, GR32:$src2)>;
4620
4621// Memory-Integer And with EFLAGS result
4622def : Pat<(parallel (store (X86and_flag (loadi8 addr:$dst), imm:$src2),
4623 addr:$dst),
4624 (implicit EFLAGS)),
4625 (AND8mi addr:$dst, imm:$src2)>;
4626def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), imm:$src2),
4627 addr:$dst),
4628 (implicit EFLAGS)),
4629 (AND16mi addr:$dst, imm:$src2)>;
4630def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), imm:$src2),
4631 addr:$dst),
4632 (implicit EFLAGS)),
4633 (AND32mi addr:$dst, imm:$src2)>;
4634def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), i16immSExt8:$src2),
4635 addr:$dst),
4636 (implicit EFLAGS)),
4637 (AND16mi8 addr:$dst, i16immSExt8:$src2)>;
4638def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), i32immSExt8:$src2),
4639 addr:$dst),
4640 (implicit EFLAGS)),
4641 (AND32mi8 addr:$dst, i32immSExt8:$src2)>;
4642
Dan Gohmane84197b2009-09-03 17:18:51 +00004643// -disable-16bit support.
4644def : Pat<(truncstorei16 (i32 imm:$src), addr:$dst),
4645 (MOV16mi addr:$dst, imm:$src)>;
4646def : Pat<(truncstorei16 GR32:$src, addr:$dst),
4647 (MOV16mr addr:$dst, (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
4648def : Pat<(i32 (sextloadi16 addr:$dst)),
4649 (MOVSX32rm16 addr:$dst)>;
4650def : Pat<(i32 (zextloadi16 addr:$dst)),
4651 (MOVZX32rm16 addr:$dst)>;
4652def : Pat<(i32 (extloadi16 addr:$dst)),
4653 (MOVZX32rm16 addr:$dst)>;
4654
Bill Wendlingf5399032008-12-12 21:15:41 +00004655//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004656// Floating Point Stack Support
4657//===----------------------------------------------------------------------===//
4658
4659include "X86InstrFPStack.td"
4660
4661//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00004662// X86-64 Support
4663//===----------------------------------------------------------------------===//
4664
Chris Lattner2de8d2b2008-01-10 05:50:42 +00004665include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00004666
4667//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004668// XMM Floating point support (requires SSE / SSE2)
4669//===----------------------------------------------------------------------===//
4670
4671include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00004672
4673//===----------------------------------------------------------------------===//
4674// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
4675//===----------------------------------------------------------------------===//
4676
4677include "X86InstrMMX.td"