blob: 036f742ac14b808122f7ea0c79400598e0bd04b0 [file] [log] [blame]
Chris Lattner5f58e842010-10-05 07:00:12 +00001//===- X86InstrShiftRotate.td - Shift and Rotate Instrs ----*- tablegen -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file describes the shift and rotate instructions.
11//
12//===----------------------------------------------------------------------===//
13
14// FIXME: Someone needs to smear multipattern goodness all over this file.
15
16let Defs = [EFLAGS] in {
17
18let Constraints = "$src1 = $dst" in {
19let Uses = [CL] in {
20def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1),
21 "shl{b}\t{%cl, $dst|$dst, CL}",
22 [(set GR8:$dst, (shl GR8:$src1, CL))]>;
23def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
24 "shl{w}\t{%cl, $dst|$dst, CL}",
25 [(set GR16:$dst, (shl GR16:$src1, CL))]>, OpSize;
26def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
27 "shl{l}\t{%cl, $dst|$dst, CL}",
28 [(set GR32:$dst, (shl GR32:$src1, CL))]>;
29} // Uses = [CL]
30
31def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
32 "shl{b}\t{$src2, $dst|$dst, $src2}",
33 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
34
35let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
36def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
37 "shl{w}\t{$src2, $dst|$dst, $src2}",
38 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
39def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
40 "shl{l}\t{$src2, $dst|$dst, $src2}",
41 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
42
43// NOTE: We don't include patterns for shifts of a register by one, because
44// 'add reg,reg' is cheaper.
45
46def SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
47 "shl{b}\t$dst", []>;
48def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
49 "shl{w}\t$dst", []>, OpSize;
50def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
51 "shl{l}\t$dst", []>;
52} // isConvertibleToThreeAddress = 1
53} // Constraints = "$src = $dst"
54
55
56let Uses = [CL] in {
57def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
58 "shl{b}\t{%cl, $dst|$dst, CL}",
59 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
60def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
61 "shl{w}\t{%cl, $dst|$dst, CL}",
62 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
63def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
64 "shl{l}\t{%cl, $dst|$dst, CL}",
65 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
66}
67def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
68 "shl{b}\t{$src, $dst|$dst, $src}",
69 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
70def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
71 "shl{w}\t{$src, $dst|$dst, $src}",
72 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
73 OpSize;
74def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
75 "shl{l}\t{$src, $dst|$dst, $src}",
76 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
77
78// Shift by 1
79def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
80 "shl{b}\t$dst",
81 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
82def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
83 "shl{w}\t$dst",
84 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
85 OpSize;
86def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
87 "shl{l}\t$dst",
88 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
89
90let Constraints = "$src1 = $dst" in {
91let Uses = [CL] in {
92def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src1),
93 "shr{b}\t{%cl, $dst|$dst, CL}",
94 [(set GR8:$dst, (srl GR8:$src1, CL))]>;
95def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
96 "shr{w}\t{%cl, $dst|$dst, CL}",
97 [(set GR16:$dst, (srl GR16:$src1, CL))]>, OpSize;
98def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
99 "shr{l}\t{%cl, $dst|$dst, CL}",
100 [(set GR32:$dst, (srl GR32:$src1, CL))]>;
101}
102
103def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
104 "shr{b}\t{$src2, $dst|$dst, $src2}",
105 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
106def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
107 "shr{w}\t{$src2, $dst|$dst, $src2}",
108 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
109def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
110 "shr{l}\t{$src2, $dst|$dst, $src2}",
111 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
112
113// Shift by 1
114def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
115 "shr{b}\t$dst",
116 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
117def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
118 "shr{w}\t$dst",
119 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
120def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
121 "shr{l}\t$dst",
122 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
123} // Constraints = "$src = $dst"
124
125
126let Uses = [CL] in {
127def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
128 "shr{b}\t{%cl, $dst|$dst, CL}",
129 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
130def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
131 "shr{w}\t{%cl, $dst|$dst, CL}",
132 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
133 OpSize;
134def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
135 "shr{l}\t{%cl, $dst|$dst, CL}",
136 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
137}
138def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
139 "shr{b}\t{$src, $dst|$dst, $src}",
140 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
141def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
142 "shr{w}\t{$src, $dst|$dst, $src}",
143 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
144 OpSize;
145def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
146 "shr{l}\t{$src, $dst|$dst, $src}",
147 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
148
149// Shift by 1
150def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
151 "shr{b}\t$dst",
152 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
153def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
154 "shr{w}\t$dst",
155 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
156def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
157 "shr{l}\t$dst",
158 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
159
160let Constraints = "$src1 = $dst" in {
161let Uses = [CL] in {
162def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
163 "sar{b}\t{%cl, $dst|$dst, CL}",
164 [(set GR8:$dst, (sra GR8:$src1, CL))]>;
165def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
166 "sar{w}\t{%cl, $dst|$dst, CL}",
167 [(set GR16:$dst, (sra GR16:$src1, CL))]>, OpSize;
168def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
169 "sar{l}\t{%cl, $dst|$dst, CL}",
170 [(set GR32:$dst, (sra GR32:$src1, CL))]>;
171}
172
173def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
174 "sar{b}\t{$src2, $dst|$dst, $src2}",
175 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
176def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
177 "sar{w}\t{$src2, $dst|$dst, $src2}",
178 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
179 OpSize;
180def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
181 "sar{l}\t{$src2, $dst|$dst, $src2}",
182 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
183
184// Shift by 1
185def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
186 "sar{b}\t$dst",
187 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
188def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
189 "sar{w}\t$dst",
190 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
191def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
192 "sar{l}\t$dst",
193 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
194} // Constraints = "$src = $dst"
195
196
197let Uses = [CL] in {
198def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
199 "sar{b}\t{%cl, $dst|$dst, CL}",
200 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
201def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
202 "sar{w}\t{%cl, $dst|$dst, CL}",
203 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
204def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
205 "sar{l}\t{%cl, $dst|$dst, CL}",
206 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
207}
208def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
209 "sar{b}\t{$src, $dst|$dst, $src}",
210 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
211def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
212 "sar{w}\t{$src, $dst|$dst, $src}",
213 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
214 OpSize;
215def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
216 "sar{l}\t{$src, $dst|$dst, $src}",
217 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
218
219// Shift by 1
220def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
221 "sar{b}\t$dst",
222 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
223def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
224 "sar{w}\t$dst",
225 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
226 OpSize;
227def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
228 "sar{l}\t$dst",
229 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
230
231//===----------------------------------------------------------------------===//
232// Rotate instructions
233//===----------------------------------------------------------------------===//
234
235let Constraints = "$src1 = $dst" in {
236def RCL8r1 : I<0xD0, MRM2r, (outs GR8:$dst), (ins GR8:$src1),
237 "rcl{b}\t{1, $dst|$dst, 1}", []>;
238let Uses = [CL] in {
239def RCL8rCL : I<0xD2, MRM2r, (outs GR8:$dst), (ins GR8:$src1),
240 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
241}
242def RCL8ri : Ii8<0xC0, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$cnt),
243 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
244
245def RCL16r1 : I<0xD1, MRM2r, (outs GR16:$dst), (ins GR16:$src1),
246 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
247let Uses = [CL] in {
248def RCL16rCL : I<0xD3, MRM2r, (outs GR16:$dst), (ins GR16:$src1),
249 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
250}
251def RCL16ri : Ii8<0xC1, MRM2r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$cnt),
252 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
253
254def RCL32r1 : I<0xD1, MRM2r, (outs GR32:$dst), (ins GR32:$src1),
255 "rcl{l}\t{1, $dst|$dst, 1}", []>;
256let Uses = [CL] in {
257def RCL32rCL : I<0xD3, MRM2r, (outs GR32:$dst), (ins GR32:$src1),
258 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
259}
260def RCL32ri : Ii8<0xC1, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$cnt),
261 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
262
263def RCR8r1 : I<0xD0, MRM3r, (outs GR8:$dst), (ins GR8:$src1),
264 "rcr{b}\t{1, $dst|$dst, 1}", []>;
265let Uses = [CL] in {
266def RCR8rCL : I<0xD2, MRM3r, (outs GR8:$dst), (ins GR8:$src1),
267 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
268}
269def RCR8ri : Ii8<0xC0, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$cnt),
270 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
271
272def RCR16r1 : I<0xD1, MRM3r, (outs GR16:$dst), (ins GR16:$src1),
273 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
274let Uses = [CL] in {
275def RCR16rCL : I<0xD3, MRM3r, (outs GR16:$dst), (ins GR16:$src1),
276 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
277}
278def RCR16ri : Ii8<0xC1, MRM3r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$cnt),
279 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
280
281def RCR32r1 : I<0xD1, MRM3r, (outs GR32:$dst), (ins GR32:$src1),
282 "rcr{l}\t{1, $dst|$dst, 1}", []>;
283let Uses = [CL] in {
284def RCR32rCL : I<0xD3, MRM3r, (outs GR32:$dst), (ins GR32:$src1),
285 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
286}
287def RCR32ri : Ii8<0xC1, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$cnt),
288 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
289} // Constraints = "$src = $dst"
290
291def RCL8m1 : I<0xD0, MRM2m, (outs), (ins i8mem:$dst),
292 "rcl{b}\t{1, $dst|$dst, 1}", []>;
293def RCL8mi : Ii8<0xC0, MRM2m, (outs), (ins i8mem:$dst, i8imm:$cnt),
294 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
295def RCL16m1 : I<0xD1, MRM2m, (outs), (ins i16mem:$dst),
296 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
297def RCL16mi : Ii8<0xC1, MRM2m, (outs), (ins i16mem:$dst, i8imm:$cnt),
298 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
299def RCL32m1 : I<0xD1, MRM2m, (outs), (ins i32mem:$dst),
300 "rcl{l}\t{1, $dst|$dst, 1}", []>;
301def RCL32mi : Ii8<0xC1, MRM2m, (outs), (ins i32mem:$dst, i8imm:$cnt),
302 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
303def RCR8m1 : I<0xD0, MRM3m, (outs), (ins i8mem:$dst),
304 "rcr{b}\t{1, $dst|$dst, 1}", []>;
305def RCR8mi : Ii8<0xC0, MRM3m, (outs), (ins i8mem:$dst, i8imm:$cnt),
306 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
307def RCR16m1 : I<0xD1, MRM3m, (outs), (ins i16mem:$dst),
308 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
309def RCR16mi : Ii8<0xC1, MRM3m, (outs), (ins i16mem:$dst, i8imm:$cnt),
310 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
311def RCR32m1 : I<0xD1, MRM3m, (outs), (ins i32mem:$dst),
312 "rcr{l}\t{1, $dst|$dst, 1}", []>;
313def RCR32mi : Ii8<0xC1, MRM3m, (outs), (ins i32mem:$dst, i8imm:$cnt),
314 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
315
316let Uses = [CL] in {
317def RCL8mCL : I<0xD2, MRM2m, (outs), (ins i8mem:$dst),
318 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
319def RCL16mCL : I<0xD3, MRM2m, (outs), (ins i16mem:$dst),
320 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
321def RCL32mCL : I<0xD3, MRM2m, (outs), (ins i32mem:$dst),
322 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
323def RCR8mCL : I<0xD2, MRM3m, (outs), (ins i8mem:$dst),
324 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
325def RCR16mCL : I<0xD3, MRM3m, (outs), (ins i16mem:$dst),
326 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
327def RCR32mCL : I<0xD3, MRM3m, (outs), (ins i32mem:$dst),
328 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
329}
330
331let Constraints = "$src1 = $dst" in {
332// FIXME: provide shorter instructions when imm8 == 1
333let Uses = [CL] in {
334def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
335 "rol{b}\t{%cl, $dst|$dst, CL}",
336 [(set GR8:$dst, (rotl GR8:$src1, CL))]>;
337def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
338 "rol{w}\t{%cl, $dst|$dst, CL}",
339 [(set GR16:$dst, (rotl GR16:$src1, CL))]>, OpSize;
340def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
341 "rol{l}\t{%cl, $dst|$dst, CL}",
342 [(set GR32:$dst, (rotl GR32:$src1, CL))]>;
343}
344
345def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
346 "rol{b}\t{$src2, $dst|$dst, $src2}",
347 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
348def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
349 "rol{w}\t{$src2, $dst|$dst, $src2}",
350 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>,
351 OpSize;
352def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
353 "rol{l}\t{$src2, $dst|$dst, $src2}",
354 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
355
356// Rotate by 1
357def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
358 "rol{b}\t$dst",
359 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
360def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
361 "rol{w}\t$dst",
362 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
363def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
364 "rol{l}\t$dst",
365 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
366} // Constraints = "$src = $dst"
367
368let Uses = [CL] in {
369def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
370 "rol{b}\t{%cl, $dst|$dst, CL}",
371 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
372def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
373 "rol{w}\t{%cl, $dst|$dst, CL}",
374 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
375def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
376 "rol{l}\t{%cl, $dst|$dst, CL}",
377 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
378}
379def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
380 "rol{b}\t{$src, $dst|$dst, $src}",
381 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
382def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
383 "rol{w}\t{$src, $dst|$dst, $src}",
384 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
385 OpSize;
386def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
387 "rol{l}\t{$src, $dst|$dst, $src}",
388 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
389
390// Rotate by 1
391def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
392 "rol{b}\t$dst",
393 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
394def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
395 "rol{w}\t$dst",
396 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
397 OpSize;
398def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
399 "rol{l}\t$dst",
400 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
401
402let Constraints = "$src1 = $dst" in {
403let Uses = [CL] in {
404def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
405 "ror{b}\t{%cl, $dst|$dst, CL}",
406 [(set GR8:$dst, (rotr GR8:$src1, CL))]>;
407def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
408 "ror{w}\t{%cl, $dst|$dst, CL}",
409 [(set GR16:$dst, (rotr GR16:$src1, CL))]>, OpSize;
410def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
411 "ror{l}\t{%cl, $dst|$dst, CL}",
412 [(set GR32:$dst, (rotr GR32:$src1, CL))]>;
413}
414
415def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
416 "ror{b}\t{$src2, $dst|$dst, $src2}",
417 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
418def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
419 "ror{w}\t{$src2, $dst|$dst, $src2}",
420 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>,
421 OpSize;
422def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
423 "ror{l}\t{$src2, $dst|$dst, $src2}",
424 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
425
426// Rotate by 1
427def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
428 "ror{b}\t$dst",
429 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
430def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
431 "ror{w}\t$dst",
432 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
433def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
434 "ror{l}\t$dst",
435 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
436} // Constraints = "$src = $dst"
437
438let Uses = [CL] in {
439def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
440 "ror{b}\t{%cl, $dst|$dst, CL}",
441 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
442def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
443 "ror{w}\t{%cl, $dst|$dst, CL}",
444 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
445def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
446 "ror{l}\t{%cl, $dst|$dst, CL}",
447 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
448}
449def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
450 "ror{b}\t{$src, $dst|$dst, $src}",
451 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
452def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
453 "ror{w}\t{$src, $dst|$dst, $src}",
454 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
455 OpSize;
456def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
457 "ror{l}\t{$src, $dst|$dst, $src}",
458 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
459
460// Rotate by 1
461def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
462 "ror{b}\t$dst",
463 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
464def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
465 "ror{w}\t$dst",
466 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
467 OpSize;
468def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
469 "ror{l}\t$dst",
470 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
471
472
473//===----------------------------------------------------------------------===//
474// Double shift instructions (generalizations of rotate)
475//===----------------------------------------------------------------------===//
476
477let Constraints = "$src1 = $dst" in {
478
479let Uses = [CL] in {
480def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst),
481 (ins GR32:$src1, GR32:$src2),
482 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
483 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
484def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst),
485 (ins GR32:$src1, GR32:$src2),
486 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
487 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
488def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst),
489 (ins GR16:$src1, GR16:$src2),
490 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
491 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
492 TB, OpSize;
493def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst),
494 (ins GR16:$src1, GR16:$src2),
495 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
496 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
497 TB, OpSize;
498}
499
500let isCommutable = 1 in { // These instructions commute to each other.
501def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
502 (outs GR32:$dst),
503 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
504 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
505 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
506 (i8 imm:$src3)))]>,
507 TB;
508def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
509 (outs GR32:$dst),
510 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
511 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
512 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
513 (i8 imm:$src3)))]>,
514 TB;
515def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
516 (outs GR16:$dst),
517 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
518 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
519 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
520 (i8 imm:$src3)))]>,
521 TB, OpSize;
522def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
523 (outs GR16:$dst),
524 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
525 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
526 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
527 (i8 imm:$src3)))]>,
528 TB, OpSize;
529}
530} // Constraints = "$src = $dst"
531
532let Uses = [CL] in {
533def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
534 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
535 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
536 addr:$dst)]>, TB;
537def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
538 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
539 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
540 addr:$dst)]>, TB;
541}
542def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
543 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
544 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
545 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
546 (i8 imm:$src3)), addr:$dst)]>,
547 TB;
548def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
549 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
550 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
551 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
552 (i8 imm:$src3)), addr:$dst)]>,
553 TB;
554
555let Uses = [CL] in {
556def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
557 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
558 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
559 addr:$dst)]>, TB, OpSize;
560def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
561 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
562 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
563 addr:$dst)]>, TB, OpSize;
564}
565def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
566 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
567 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
568 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
569 (i8 imm:$src3)), addr:$dst)]>,
570 TB, OpSize;
571def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
572 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
573 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
574 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
575 (i8 imm:$src3)), addr:$dst)]>,
576 TB, OpSize;
577} // Defs = [EFLAGS]
578