xref: /aosp_15_r20/external/llvm/lib/Target/X86/X86InstrShiftRotate.td (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker//===-- X86InstrShiftRotate.td - Shift and Rotate Instrs ---*- tablegen -*-===//
2*9880d681SAndroid Build Coastguard Worker//
3*9880d681SAndroid Build Coastguard Worker//                     The LLVM Compiler Infrastructure
4*9880d681SAndroid Build Coastguard Worker//
5*9880d681SAndroid Build Coastguard Worker// This file is distributed under the University of Illinois Open Source
6*9880d681SAndroid Build Coastguard Worker// License. See LICENSE.TXT for details.
7*9880d681SAndroid Build Coastguard Worker//
8*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===//
9*9880d681SAndroid Build Coastguard Worker//
10*9880d681SAndroid Build Coastguard Worker// This file describes the shift and rotate instructions.
11*9880d681SAndroid Build Coastguard Worker//
12*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===//
13*9880d681SAndroid Build Coastguard Worker
14*9880d681SAndroid Build Coastguard Worker// FIXME: Someone needs to smear multipattern goodness all over this file.
15*9880d681SAndroid Build Coastguard Worker
16*9880d681SAndroid Build Coastguard Workerlet Defs = [EFLAGS] in {
17*9880d681SAndroid Build Coastguard Worker
18*9880d681SAndroid Build Coastguard Workerlet Constraints = "$src1 = $dst", SchedRW = [WriteShift] in {
19*9880d681SAndroid Build Coastguard Workerlet Uses = [CL] in {
20*9880d681SAndroid Build Coastguard Workerdef SHL8rCL  : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1),
21*9880d681SAndroid Build Coastguard Worker                 "shl{b}\t{%cl, $dst|$dst, cl}",
22*9880d681SAndroid Build Coastguard Worker                 [(set GR8:$dst, (shl GR8:$src1, CL))], IIC_SR>;
23*9880d681SAndroid Build Coastguard Workerdef SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
24*9880d681SAndroid Build Coastguard Worker                 "shl{w}\t{%cl, $dst|$dst, cl}",
25*9880d681SAndroid Build Coastguard Worker                 [(set GR16:$dst, (shl GR16:$src1, CL))], IIC_SR>, OpSize16;
26*9880d681SAndroid Build Coastguard Workerdef SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
27*9880d681SAndroid Build Coastguard Worker                 "shl{l}\t{%cl, $dst|$dst, cl}",
28*9880d681SAndroid Build Coastguard Worker                 [(set GR32:$dst, (shl GR32:$src1, CL))], IIC_SR>, OpSize32;
29*9880d681SAndroid Build Coastguard Workerdef SHL64rCL : RI<0xD3, MRM4r, (outs GR64:$dst), (ins GR64:$src1),
30*9880d681SAndroid Build Coastguard Worker                  "shl{q}\t{%cl, $dst|$dst, cl}",
31*9880d681SAndroid Build Coastguard Worker                  [(set GR64:$dst, (shl GR64:$src1, CL))], IIC_SR>;
32*9880d681SAndroid Build Coastguard Worker} // Uses = [CL]
33*9880d681SAndroid Build Coastguard Worker
34*9880d681SAndroid Build Coastguard Workerdef SHL8ri   : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, u8imm:$src2),
35*9880d681SAndroid Build Coastguard Worker                   "shl{b}\t{$src2, $dst|$dst, $src2}",
36*9880d681SAndroid Build Coastguard Worker                   [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))], IIC_SR>;
37*9880d681SAndroid Build Coastguard Worker
38*9880d681SAndroid Build Coastguard Workerlet isConvertibleToThreeAddress = 1 in {   // Can transform into LEA.
39*9880d681SAndroid Build Coastguard Workerdef SHL16ri  : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, u8imm:$src2),
40*9880d681SAndroid Build Coastguard Worker                   "shl{w}\t{$src2, $dst|$dst, $src2}",
41*9880d681SAndroid Build Coastguard Worker                   [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))], IIC_SR>,
42*9880d681SAndroid Build Coastguard Worker                   OpSize16;
43*9880d681SAndroid Build Coastguard Workerdef SHL32ri  : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, u8imm:$src2),
44*9880d681SAndroid Build Coastguard Worker                   "shl{l}\t{$src2, $dst|$dst, $src2}",
45*9880d681SAndroid Build Coastguard Worker                   [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))], IIC_SR>,
46*9880d681SAndroid Build Coastguard Worker                   OpSize32;
47*9880d681SAndroid Build Coastguard Workerdef SHL64ri  : RIi8<0xC1, MRM4r, (outs GR64:$dst),
48*9880d681SAndroid Build Coastguard Worker                    (ins GR64:$src1, u8imm:$src2),
49*9880d681SAndroid Build Coastguard Worker                    "shl{q}\t{$src2, $dst|$dst, $src2}",
50*9880d681SAndroid Build Coastguard Worker                    [(set GR64:$dst, (shl GR64:$src1, (i8 imm:$src2)))],
51*9880d681SAndroid Build Coastguard Worker                    IIC_SR>;
52*9880d681SAndroid Build Coastguard Worker} // isConvertibleToThreeAddress = 1
53*9880d681SAndroid Build Coastguard Worker
54*9880d681SAndroid Build Coastguard Worker// NOTE: We don't include patterns for shifts of a register by one, because
55*9880d681SAndroid Build Coastguard Worker// 'add reg,reg' is cheaper (and we have a Pat pattern for shift-by-one).
56*9880d681SAndroid Build Coastguard Workerlet hasSideEffects = 0 in {
57*9880d681SAndroid Build Coastguard Workerdef SHL8r1   : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
58*9880d681SAndroid Build Coastguard Worker                 "shl{b}\t$dst", [], IIC_SR>;
59*9880d681SAndroid Build Coastguard Workerdef SHL16r1  : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
60*9880d681SAndroid Build Coastguard Worker                 "shl{w}\t$dst", [], IIC_SR>, OpSize16;
61*9880d681SAndroid Build Coastguard Workerdef SHL32r1  : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
62*9880d681SAndroid Build Coastguard Worker                 "shl{l}\t$dst", [], IIC_SR>, OpSize32;
63*9880d681SAndroid Build Coastguard Workerdef SHL64r1  : RI<0xD1, MRM4r, (outs GR64:$dst), (ins GR64:$src1),
64*9880d681SAndroid Build Coastguard Worker                 "shl{q}\t$dst", [], IIC_SR>;
65*9880d681SAndroid Build Coastguard Worker} // hasSideEffects = 0
66*9880d681SAndroid Build Coastguard Worker} // Constraints = "$src = $dst", SchedRW
67*9880d681SAndroid Build Coastguard Worker
68*9880d681SAndroid Build Coastguard Worker
69*9880d681SAndroid Build Coastguard Workerlet SchedRW = [WriteShiftLd, WriteRMW] in {
70*9880d681SAndroid Build Coastguard Worker// FIXME: Why do we need an explicit "Uses = [CL]" when the instr has a pattern
71*9880d681SAndroid Build Coastguard Worker// using CL?
72*9880d681SAndroid Build Coastguard Workerlet Uses = [CL] in {
73*9880d681SAndroid Build Coastguard Workerdef SHL8mCL  : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
74*9880d681SAndroid Build Coastguard Worker                 "shl{b}\t{%cl, $dst|$dst, cl}",
75*9880d681SAndroid Build Coastguard Worker                 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)], IIC_SR>;
76*9880d681SAndroid Build Coastguard Workerdef SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
77*9880d681SAndroid Build Coastguard Worker                 "shl{w}\t{%cl, $dst|$dst, cl}",
78*9880d681SAndroid Build Coastguard Worker                 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)], IIC_SR>,
79*9880d681SAndroid Build Coastguard Worker                 OpSize16;
80*9880d681SAndroid Build Coastguard Workerdef SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
81*9880d681SAndroid Build Coastguard Worker                 "shl{l}\t{%cl, $dst|$dst, cl}",
82*9880d681SAndroid Build Coastguard Worker                 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)], IIC_SR>,
83*9880d681SAndroid Build Coastguard Worker                 OpSize32;
84*9880d681SAndroid Build Coastguard Workerdef SHL64mCL : RI<0xD3, MRM4m, (outs), (ins i64mem:$dst),
85*9880d681SAndroid Build Coastguard Worker                  "shl{q}\t{%cl, $dst|$dst, cl}",
86*9880d681SAndroid Build Coastguard Worker                  [(store (shl (loadi64 addr:$dst), CL), addr:$dst)], IIC_SR>;
87*9880d681SAndroid Build Coastguard Worker}
88*9880d681SAndroid Build Coastguard Workerdef SHL8mi   : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, u8imm:$src),
89*9880d681SAndroid Build Coastguard Worker                   "shl{b}\t{$src, $dst|$dst, $src}",
90*9880d681SAndroid Build Coastguard Worker                [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)],
91*9880d681SAndroid Build Coastguard Worker                IIC_SR>;
92*9880d681SAndroid Build Coastguard Workerdef SHL16mi  : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, u8imm:$src),
93*9880d681SAndroid Build Coastguard Worker                   "shl{w}\t{$src, $dst|$dst, $src}",
94*9880d681SAndroid Build Coastguard Worker               [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)],
95*9880d681SAndroid Build Coastguard Worker               IIC_SR>, OpSize16;
96*9880d681SAndroid Build Coastguard Workerdef SHL32mi  : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, u8imm:$src),
97*9880d681SAndroid Build Coastguard Worker                   "shl{l}\t{$src, $dst|$dst, $src}",
98*9880d681SAndroid Build Coastguard Worker               [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)],
99*9880d681SAndroid Build Coastguard Worker               IIC_SR>, OpSize32;
100*9880d681SAndroid Build Coastguard Workerdef SHL64mi : RIi8<0xC1, MRM4m, (outs), (ins i64mem:$dst, u8imm:$src),
101*9880d681SAndroid Build Coastguard Worker                  "shl{q}\t{$src, $dst|$dst, $src}",
102*9880d681SAndroid Build Coastguard Worker                 [(store (shl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)],
103*9880d681SAndroid Build Coastguard Worker                 IIC_SR>;
104*9880d681SAndroid Build Coastguard Worker
105*9880d681SAndroid Build Coastguard Worker// Shift by 1
106*9880d681SAndroid Build Coastguard Workerdef SHL8m1   : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
107*9880d681SAndroid Build Coastguard Worker                 "shl{b}\t$dst",
108*9880d681SAndroid Build Coastguard Worker                [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)],
109*9880d681SAndroid Build Coastguard Worker                IIC_SR>;
110*9880d681SAndroid Build Coastguard Workerdef SHL16m1  : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
111*9880d681SAndroid Build Coastguard Worker                 "shl{w}\t$dst",
112*9880d681SAndroid Build Coastguard Worker               [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)],
113*9880d681SAndroid Build Coastguard Worker               IIC_SR>, OpSize16;
114*9880d681SAndroid Build Coastguard Workerdef SHL32m1  : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
115*9880d681SAndroid Build Coastguard Worker                 "shl{l}\t$dst",
116*9880d681SAndroid Build Coastguard Worker               [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)],
117*9880d681SAndroid Build Coastguard Worker               IIC_SR>, OpSize32;
118*9880d681SAndroid Build Coastguard Workerdef SHL64m1 : RI<0xD1, MRM4m, (outs), (ins i64mem:$dst),
119*9880d681SAndroid Build Coastguard Worker                  "shl{q}\t$dst",
120*9880d681SAndroid Build Coastguard Worker                 [(store (shl (loadi64 addr:$dst), (i8 1)), addr:$dst)],
121*9880d681SAndroid Build Coastguard Worker                 IIC_SR>;
122*9880d681SAndroid Build Coastguard Worker} // SchedRW
123*9880d681SAndroid Build Coastguard Worker
124*9880d681SAndroid Build Coastguard Workerlet Constraints = "$src1 = $dst", SchedRW = [WriteShift] in {
125*9880d681SAndroid Build Coastguard Workerlet Uses = [CL] in {
126*9880d681SAndroid Build Coastguard Workerdef SHR8rCL  : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src1),
127*9880d681SAndroid Build Coastguard Worker                 "shr{b}\t{%cl, $dst|$dst, cl}",
128*9880d681SAndroid Build Coastguard Worker                 [(set GR8:$dst, (srl GR8:$src1, CL))], IIC_SR>;
129*9880d681SAndroid Build Coastguard Workerdef SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
130*9880d681SAndroid Build Coastguard Worker                 "shr{w}\t{%cl, $dst|$dst, cl}",
131*9880d681SAndroid Build Coastguard Worker                 [(set GR16:$dst, (srl GR16:$src1, CL))], IIC_SR>, OpSize16;
132*9880d681SAndroid Build Coastguard Workerdef SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
133*9880d681SAndroid Build Coastguard Worker                 "shr{l}\t{%cl, $dst|$dst, cl}",
134*9880d681SAndroid Build Coastguard Worker                 [(set GR32:$dst, (srl GR32:$src1, CL))], IIC_SR>, OpSize32;
135*9880d681SAndroid Build Coastguard Workerdef SHR64rCL : RI<0xD3, MRM5r, (outs GR64:$dst), (ins GR64:$src1),
136*9880d681SAndroid Build Coastguard Worker                  "shr{q}\t{%cl, $dst|$dst, cl}",
137*9880d681SAndroid Build Coastguard Worker                  [(set GR64:$dst, (srl GR64:$src1, CL))], IIC_SR>;
138*9880d681SAndroid Build Coastguard Worker}
139*9880d681SAndroid Build Coastguard Worker
140*9880d681SAndroid Build Coastguard Workerdef SHR8ri   : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, u8imm:$src2),
141*9880d681SAndroid Build Coastguard Worker                   "shr{b}\t{$src2, $dst|$dst, $src2}",
142*9880d681SAndroid Build Coastguard Worker                   [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))], IIC_SR>;
143*9880d681SAndroid Build Coastguard Workerdef SHR16ri  : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, u8imm:$src2),
144*9880d681SAndroid Build Coastguard Worker                   "shr{w}\t{$src2, $dst|$dst, $src2}",
145*9880d681SAndroid Build Coastguard Worker                   [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))],
146*9880d681SAndroid Build Coastguard Worker                   IIC_SR>, OpSize16;
147*9880d681SAndroid Build Coastguard Workerdef SHR32ri  : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, u8imm:$src2),
148*9880d681SAndroid Build Coastguard Worker                   "shr{l}\t{$src2, $dst|$dst, $src2}",
149*9880d681SAndroid Build Coastguard Worker                   [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))],
150*9880d681SAndroid Build Coastguard Worker                   IIC_SR>, OpSize32;
151*9880d681SAndroid Build Coastguard Workerdef SHR64ri : RIi8<0xC1, MRM5r, (outs GR64:$dst), (ins GR64:$src1, u8imm:$src2),
152*9880d681SAndroid Build Coastguard Worker                  "shr{q}\t{$src2, $dst|$dst, $src2}",
153*9880d681SAndroid Build Coastguard Worker                  [(set GR64:$dst, (srl GR64:$src1, (i8 imm:$src2)))], IIC_SR>;
154*9880d681SAndroid Build Coastguard Worker
155*9880d681SAndroid Build Coastguard Worker// Shift right by 1
156*9880d681SAndroid Build Coastguard Workerdef SHR8r1   : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
157*9880d681SAndroid Build Coastguard Worker                 "shr{b}\t$dst",
158*9880d681SAndroid Build Coastguard Worker                 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))], IIC_SR>;
159*9880d681SAndroid Build Coastguard Workerdef SHR16r1  : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
160*9880d681SAndroid Build Coastguard Worker                 "shr{w}\t$dst",
161*9880d681SAndroid Build Coastguard Worker                 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))], IIC_SR>, OpSize16;
162*9880d681SAndroid Build Coastguard Workerdef SHR32r1  : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
163*9880d681SAndroid Build Coastguard Worker                 "shr{l}\t$dst",
164*9880d681SAndroid Build Coastguard Worker                 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))], IIC_SR>, OpSize32;
165*9880d681SAndroid Build Coastguard Workerdef SHR64r1  : RI<0xD1, MRM5r, (outs GR64:$dst), (ins GR64:$src1),
166*9880d681SAndroid Build Coastguard Worker                 "shr{q}\t$dst",
167*9880d681SAndroid Build Coastguard Worker                 [(set GR64:$dst, (srl GR64:$src1, (i8 1)))], IIC_SR>;
168*9880d681SAndroid Build Coastguard Worker} // Constraints = "$src = $dst", SchedRW
169*9880d681SAndroid Build Coastguard Worker
170*9880d681SAndroid Build Coastguard Worker
171*9880d681SAndroid Build Coastguard Workerlet SchedRW = [WriteShiftLd, WriteRMW] in {
172*9880d681SAndroid Build Coastguard Workerlet Uses = [CL] in {
173*9880d681SAndroid Build Coastguard Workerdef SHR8mCL  : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
174*9880d681SAndroid Build Coastguard Worker                 "shr{b}\t{%cl, $dst|$dst, cl}",
175*9880d681SAndroid Build Coastguard Worker                 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)], IIC_SR>;
176*9880d681SAndroid Build Coastguard Workerdef SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
177*9880d681SAndroid Build Coastguard Worker                 "shr{w}\t{%cl, $dst|$dst, cl}",
178*9880d681SAndroid Build Coastguard Worker                 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)], IIC_SR>,
179*9880d681SAndroid Build Coastguard Worker                 OpSize16;
180*9880d681SAndroid Build Coastguard Workerdef SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
181*9880d681SAndroid Build Coastguard Worker                 "shr{l}\t{%cl, $dst|$dst, cl}",
182*9880d681SAndroid Build Coastguard Worker                 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)], IIC_SR>,
183*9880d681SAndroid Build Coastguard Worker                 OpSize32;
184*9880d681SAndroid Build Coastguard Workerdef SHR64mCL : RI<0xD3, MRM5m, (outs), (ins i64mem:$dst),
185*9880d681SAndroid Build Coastguard Worker                  "shr{q}\t{%cl, $dst|$dst, cl}",
186*9880d681SAndroid Build Coastguard Worker                  [(store (srl (loadi64 addr:$dst), CL), addr:$dst)], IIC_SR>;
187*9880d681SAndroid Build Coastguard Worker}
188*9880d681SAndroid Build Coastguard Workerdef SHR8mi   : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, u8imm:$src),
189*9880d681SAndroid Build Coastguard Worker                   "shr{b}\t{$src, $dst|$dst, $src}",
190*9880d681SAndroid Build Coastguard Worker                [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)],
191*9880d681SAndroid Build Coastguard Worker                IIC_SR>;
192*9880d681SAndroid Build Coastguard Workerdef SHR16mi  : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, u8imm:$src),
193*9880d681SAndroid Build Coastguard Worker                   "shr{w}\t{$src, $dst|$dst, $src}",
194*9880d681SAndroid Build Coastguard Worker               [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)],
195*9880d681SAndroid Build Coastguard Worker               IIC_SR>, OpSize16;
196*9880d681SAndroid Build Coastguard Workerdef SHR32mi  : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, u8imm:$src),
197*9880d681SAndroid Build Coastguard Worker                   "shr{l}\t{$src, $dst|$dst, $src}",
198*9880d681SAndroid Build Coastguard Worker               [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)],
199*9880d681SAndroid Build Coastguard Worker               IIC_SR>, OpSize32;
200*9880d681SAndroid Build Coastguard Workerdef SHR64mi : RIi8<0xC1, MRM5m, (outs), (ins i64mem:$dst, u8imm:$src),
201*9880d681SAndroid Build Coastguard Worker                  "shr{q}\t{$src, $dst|$dst, $src}",
202*9880d681SAndroid Build Coastguard Worker                 [(store (srl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)],
203*9880d681SAndroid Build Coastguard Worker                 IIC_SR>;
204*9880d681SAndroid Build Coastguard Worker
205*9880d681SAndroid Build Coastguard Worker// Shift by 1
206*9880d681SAndroid Build Coastguard Workerdef SHR8m1   : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
207*9880d681SAndroid Build Coastguard Worker                 "shr{b}\t$dst",
208*9880d681SAndroid Build Coastguard Worker                [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)],
209*9880d681SAndroid Build Coastguard Worker                IIC_SR>;
210*9880d681SAndroid Build Coastguard Workerdef SHR16m1  : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
211*9880d681SAndroid Build Coastguard Worker                 "shr{w}\t$dst",
212*9880d681SAndroid Build Coastguard Worker               [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)],
213*9880d681SAndroid Build Coastguard Worker               IIC_SR>, OpSize16;
214*9880d681SAndroid Build Coastguard Workerdef SHR32m1  : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
215*9880d681SAndroid Build Coastguard Worker                 "shr{l}\t$dst",
216*9880d681SAndroid Build Coastguard Worker               [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)],
217*9880d681SAndroid Build Coastguard Worker               IIC_SR>, OpSize32;
218*9880d681SAndroid Build Coastguard Workerdef SHR64m1 : RI<0xD1, MRM5m, (outs), (ins i64mem:$dst),
219*9880d681SAndroid Build Coastguard Worker                  "shr{q}\t$dst",
220*9880d681SAndroid Build Coastguard Worker                 [(store (srl (loadi64 addr:$dst), (i8 1)), addr:$dst)],
221*9880d681SAndroid Build Coastguard Worker                 IIC_SR>;
222*9880d681SAndroid Build Coastguard Worker} // SchedRW
223*9880d681SAndroid Build Coastguard Worker
224*9880d681SAndroid Build Coastguard Workerlet Constraints = "$src1 = $dst", SchedRW = [WriteShift] in {
225*9880d681SAndroid Build Coastguard Workerlet Uses = [CL] in {
226*9880d681SAndroid Build Coastguard Workerdef SAR8rCL  : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
227*9880d681SAndroid Build Coastguard Worker                 "sar{b}\t{%cl, $dst|$dst, cl}",
228*9880d681SAndroid Build Coastguard Worker                 [(set GR8:$dst, (sra GR8:$src1, CL))],
229*9880d681SAndroid Build Coastguard Worker                 IIC_SR>;
230*9880d681SAndroid Build Coastguard Workerdef SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
231*9880d681SAndroid Build Coastguard Worker                 "sar{w}\t{%cl, $dst|$dst, cl}",
232*9880d681SAndroid Build Coastguard Worker                 [(set GR16:$dst, (sra GR16:$src1, CL))],
233*9880d681SAndroid Build Coastguard Worker                 IIC_SR>, OpSize16;
234*9880d681SAndroid Build Coastguard Workerdef SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
235*9880d681SAndroid Build Coastguard Worker                 "sar{l}\t{%cl, $dst|$dst, cl}",
236*9880d681SAndroid Build Coastguard Worker                 [(set GR32:$dst, (sra GR32:$src1, CL))],
237*9880d681SAndroid Build Coastguard Worker                 IIC_SR>, OpSize32;
238*9880d681SAndroid Build Coastguard Workerdef SAR64rCL : RI<0xD3, MRM7r, (outs GR64:$dst), (ins GR64:$src1),
239*9880d681SAndroid Build Coastguard Worker                 "sar{q}\t{%cl, $dst|$dst, cl}",
240*9880d681SAndroid Build Coastguard Worker                 [(set GR64:$dst, (sra GR64:$src1, CL))],
241*9880d681SAndroid Build Coastguard Worker                 IIC_SR>;
242*9880d681SAndroid Build Coastguard Worker}
243*9880d681SAndroid Build Coastguard Worker
244*9880d681SAndroid Build Coastguard Workerdef SAR8ri   : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, u8imm:$src2),
245*9880d681SAndroid Build Coastguard Worker                   "sar{b}\t{$src2, $dst|$dst, $src2}",
246*9880d681SAndroid Build Coastguard Worker                   [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))],
247*9880d681SAndroid Build Coastguard Worker                   IIC_SR>;
248*9880d681SAndroid Build Coastguard Workerdef SAR16ri  : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, u8imm:$src2),
249*9880d681SAndroid Build Coastguard Worker                   "sar{w}\t{$src2, $dst|$dst, $src2}",
250*9880d681SAndroid Build Coastguard Worker                   [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))],
251*9880d681SAndroid Build Coastguard Worker                   IIC_SR>, OpSize16;
252*9880d681SAndroid Build Coastguard Workerdef SAR32ri  : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, u8imm:$src2),
253*9880d681SAndroid Build Coastguard Worker                   "sar{l}\t{$src2, $dst|$dst, $src2}",
254*9880d681SAndroid Build Coastguard Worker                   [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))],
255*9880d681SAndroid Build Coastguard Worker                   IIC_SR>, OpSize32;
256*9880d681SAndroid Build Coastguard Workerdef SAR64ri  : RIi8<0xC1, MRM7r, (outs GR64:$dst),
257*9880d681SAndroid Build Coastguard Worker                    (ins GR64:$src1, u8imm:$src2),
258*9880d681SAndroid Build Coastguard Worker                    "sar{q}\t{$src2, $dst|$dst, $src2}",
259*9880d681SAndroid Build Coastguard Worker                    [(set GR64:$dst, (sra GR64:$src1, (i8 imm:$src2)))],
260*9880d681SAndroid Build Coastguard Worker                    IIC_SR>;
261*9880d681SAndroid Build Coastguard Worker
262*9880d681SAndroid Build Coastguard Worker// Shift by 1
263*9880d681SAndroid Build Coastguard Workerdef SAR8r1   : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
264*9880d681SAndroid Build Coastguard Worker                 "sar{b}\t$dst",
265*9880d681SAndroid Build Coastguard Worker                 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))],
266*9880d681SAndroid Build Coastguard Worker                 IIC_SR>;
267*9880d681SAndroid Build Coastguard Workerdef SAR16r1  : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
268*9880d681SAndroid Build Coastguard Worker                 "sar{w}\t$dst",
269*9880d681SAndroid Build Coastguard Worker                 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))],
270*9880d681SAndroid Build Coastguard Worker                 IIC_SR>, OpSize16;
271*9880d681SAndroid Build Coastguard Workerdef SAR32r1  : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
272*9880d681SAndroid Build Coastguard Worker                 "sar{l}\t$dst",
273*9880d681SAndroid Build Coastguard Worker                 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))],
274*9880d681SAndroid Build Coastguard Worker                 IIC_SR>, OpSize32;
275*9880d681SAndroid Build Coastguard Workerdef SAR64r1  : RI<0xD1, MRM7r, (outs GR64:$dst), (ins GR64:$src1),
276*9880d681SAndroid Build Coastguard Worker                 "sar{q}\t$dst",
277*9880d681SAndroid Build Coastguard Worker                 [(set GR64:$dst, (sra GR64:$src1, (i8 1)))],
278*9880d681SAndroid Build Coastguard Worker                 IIC_SR>;
279*9880d681SAndroid Build Coastguard Worker} // Constraints = "$src = $dst", SchedRW
280*9880d681SAndroid Build Coastguard Worker
281*9880d681SAndroid Build Coastguard Worker
282*9880d681SAndroid Build Coastguard Workerlet SchedRW = [WriteShiftLd, WriteRMW] in {
283*9880d681SAndroid Build Coastguard Workerlet Uses = [CL] in {
284*9880d681SAndroid Build Coastguard Workerdef SAR8mCL  : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
285*9880d681SAndroid Build Coastguard Worker                 "sar{b}\t{%cl, $dst|$dst, cl}",
286*9880d681SAndroid Build Coastguard Worker                 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)],
287*9880d681SAndroid Build Coastguard Worker                 IIC_SR>;
288*9880d681SAndroid Build Coastguard Workerdef SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
289*9880d681SAndroid Build Coastguard Worker                 "sar{w}\t{%cl, $dst|$dst, cl}",
290*9880d681SAndroid Build Coastguard Worker                 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)],
291*9880d681SAndroid Build Coastguard Worker                 IIC_SR>, OpSize16;
292*9880d681SAndroid Build Coastguard Workerdef SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
293*9880d681SAndroid Build Coastguard Worker                 "sar{l}\t{%cl, $dst|$dst, cl}",
294*9880d681SAndroid Build Coastguard Worker                 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)],
295*9880d681SAndroid Build Coastguard Worker                 IIC_SR>, OpSize32;
296*9880d681SAndroid Build Coastguard Workerdef SAR64mCL : RI<0xD3, MRM7m, (outs), (ins i64mem:$dst),
297*9880d681SAndroid Build Coastguard Worker                 "sar{q}\t{%cl, $dst|$dst, cl}",
298*9880d681SAndroid Build Coastguard Worker                 [(store (sra (loadi64 addr:$dst), CL), addr:$dst)],
299*9880d681SAndroid Build Coastguard Worker                 IIC_SR>;
300*9880d681SAndroid Build Coastguard Worker}
301*9880d681SAndroid Build Coastguard Workerdef SAR8mi   : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, u8imm:$src),
302*9880d681SAndroid Build Coastguard Worker                   "sar{b}\t{$src, $dst|$dst, $src}",
303*9880d681SAndroid Build Coastguard Worker                [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)],
304*9880d681SAndroid Build Coastguard Worker                IIC_SR>;
305*9880d681SAndroid Build Coastguard Workerdef SAR16mi  : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, u8imm:$src),
306*9880d681SAndroid Build Coastguard Worker                   "sar{w}\t{$src, $dst|$dst, $src}",
307*9880d681SAndroid Build Coastguard Worker               [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)],
308*9880d681SAndroid Build Coastguard Worker               IIC_SR>, OpSize16;
309*9880d681SAndroid Build Coastguard Workerdef SAR32mi  : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, u8imm:$src),
310*9880d681SAndroid Build Coastguard Worker                   "sar{l}\t{$src, $dst|$dst, $src}",
311*9880d681SAndroid Build Coastguard Worker               [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)],
312*9880d681SAndroid Build Coastguard Worker               IIC_SR>, OpSize32;
313*9880d681SAndroid Build Coastguard Workerdef SAR64mi  : RIi8<0xC1, MRM7m, (outs), (ins i64mem:$dst, u8imm:$src),
314*9880d681SAndroid Build Coastguard Worker                    "sar{q}\t{$src, $dst|$dst, $src}",
315*9880d681SAndroid Build Coastguard Worker                 [(store (sra (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)],
316*9880d681SAndroid Build Coastguard Worker                 IIC_SR>;
317*9880d681SAndroid Build Coastguard Worker
318*9880d681SAndroid Build Coastguard Worker// Shift by 1
319*9880d681SAndroid Build Coastguard Workerdef SAR8m1   : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
320*9880d681SAndroid Build Coastguard Worker                 "sar{b}\t$dst",
321*9880d681SAndroid Build Coastguard Worker                [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)],
322*9880d681SAndroid Build Coastguard Worker                IIC_SR>;
323*9880d681SAndroid Build Coastguard Workerdef SAR16m1  : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
324*9880d681SAndroid Build Coastguard Worker                 "sar{w}\t$dst",
325*9880d681SAndroid Build Coastguard Worker               [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)],
326*9880d681SAndroid Build Coastguard Worker               IIC_SR>, OpSize16;
327*9880d681SAndroid Build Coastguard Workerdef SAR32m1  : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
328*9880d681SAndroid Build Coastguard Worker                 "sar{l}\t$dst",
329*9880d681SAndroid Build Coastguard Worker               [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)],
330*9880d681SAndroid Build Coastguard Worker               IIC_SR>, OpSize32;
331*9880d681SAndroid Build Coastguard Workerdef SAR64m1 : RI<0xD1, MRM7m, (outs), (ins i64mem:$dst),
332*9880d681SAndroid Build Coastguard Worker                  "sar{q}\t$dst",
333*9880d681SAndroid Build Coastguard Worker                 [(store (sra (loadi64 addr:$dst), (i8 1)), addr:$dst)],
334*9880d681SAndroid Build Coastguard Worker                 IIC_SR>;
335*9880d681SAndroid Build Coastguard Worker} // SchedRW
336*9880d681SAndroid Build Coastguard Worker
337*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===//
338*9880d681SAndroid Build Coastguard Worker// Rotate instructions
339*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===//
340*9880d681SAndroid Build Coastguard Worker
341*9880d681SAndroid Build Coastguard Workerlet hasSideEffects = 0 in {
342*9880d681SAndroid Build Coastguard Workerlet Constraints = "$src1 = $dst", SchedRW = [WriteShift] in {
343*9880d681SAndroid Build Coastguard Workerdef RCL8r1 : I<0xD0, MRM2r, (outs GR8:$dst), (ins GR8:$src1),
344*9880d681SAndroid Build Coastguard Worker               "rcl{b}\t$dst", [], IIC_SR>;
345*9880d681SAndroid Build Coastguard Workerdef RCL8ri : Ii8<0xC0, MRM2r, (outs GR8:$dst), (ins GR8:$src1, u8imm:$cnt),
346*9880d681SAndroid Build Coastguard Worker                 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", [], IIC_SR>;
347*9880d681SAndroid Build Coastguard Workerlet Uses = [CL] in
348*9880d681SAndroid Build Coastguard Workerdef RCL8rCL : I<0xD2, MRM2r, (outs GR8:$dst), (ins GR8:$src1),
349*9880d681SAndroid Build Coastguard Worker                "rcl{b}\t{%cl, $dst|$dst, cl}", [], IIC_SR>;
350*9880d681SAndroid Build Coastguard Worker
351*9880d681SAndroid Build Coastguard Workerdef RCL16r1 : I<0xD1, MRM2r, (outs GR16:$dst), (ins GR16:$src1),
352*9880d681SAndroid Build Coastguard Worker                "rcl{w}\t$dst", [], IIC_SR>, OpSize16;
353*9880d681SAndroid Build Coastguard Workerdef RCL16ri : Ii8<0xC1, MRM2r, (outs GR16:$dst), (ins GR16:$src1, u8imm:$cnt),
354*9880d681SAndroid Build Coastguard Worker                  "rcl{w}\t{$cnt, $dst|$dst, $cnt}", [], IIC_SR>, OpSize16;
355*9880d681SAndroid Build Coastguard Workerlet Uses = [CL] in
356*9880d681SAndroid Build Coastguard Workerdef RCL16rCL : I<0xD3, MRM2r, (outs GR16:$dst), (ins GR16:$src1),
357*9880d681SAndroid Build Coastguard Worker                 "rcl{w}\t{%cl, $dst|$dst, cl}", [], IIC_SR>, OpSize16;
358*9880d681SAndroid Build Coastguard Worker
359*9880d681SAndroid Build Coastguard Workerdef RCL32r1 : I<0xD1, MRM2r, (outs GR32:$dst), (ins GR32:$src1),
360*9880d681SAndroid Build Coastguard Worker                "rcl{l}\t$dst", [], IIC_SR>, OpSize32;
361*9880d681SAndroid Build Coastguard Workerdef RCL32ri : Ii8<0xC1, MRM2r, (outs GR32:$dst), (ins GR32:$src1, u8imm:$cnt),
362*9880d681SAndroid Build Coastguard Worker                  "rcl{l}\t{$cnt, $dst|$dst, $cnt}", [], IIC_SR>, OpSize32;
363*9880d681SAndroid Build Coastguard Workerlet Uses = [CL] in
364*9880d681SAndroid Build Coastguard Workerdef RCL32rCL : I<0xD3, MRM2r, (outs GR32:$dst), (ins GR32:$src1),
365*9880d681SAndroid Build Coastguard Worker                 "rcl{l}\t{%cl, $dst|$dst, cl}", [], IIC_SR>, OpSize32;
366*9880d681SAndroid Build Coastguard Worker
367*9880d681SAndroid Build Coastguard Worker
368*9880d681SAndroid Build Coastguard Workerdef RCL64r1 : RI<0xD1, MRM2r, (outs GR64:$dst), (ins GR64:$src1),
369*9880d681SAndroid Build Coastguard Worker                 "rcl{q}\t$dst", [], IIC_SR>;
370*9880d681SAndroid Build Coastguard Workerdef RCL64ri : RIi8<0xC1, MRM2r, (outs GR64:$dst), (ins GR64:$src1, u8imm:$cnt),
371*9880d681SAndroid Build Coastguard Worker                   "rcl{q}\t{$cnt, $dst|$dst, $cnt}", [], IIC_SR>;
372*9880d681SAndroid Build Coastguard Workerlet Uses = [CL] in
373*9880d681SAndroid Build Coastguard Workerdef RCL64rCL : RI<0xD3, MRM2r, (outs GR64:$dst), (ins GR64:$src1),
374*9880d681SAndroid Build Coastguard Worker                  "rcl{q}\t{%cl, $dst|$dst, cl}", [], IIC_SR>;
375*9880d681SAndroid Build Coastguard Worker
376*9880d681SAndroid Build Coastguard Worker
377*9880d681SAndroid Build Coastguard Workerdef RCR8r1 : I<0xD0, MRM3r, (outs GR8:$dst), (ins GR8:$src1),
378*9880d681SAndroid Build Coastguard Worker               "rcr{b}\t$dst", [], IIC_SR>;
379*9880d681SAndroid Build Coastguard Workerdef RCR8ri : Ii8<0xC0, MRM3r, (outs GR8:$dst), (ins GR8:$src1, u8imm:$cnt),
380*9880d681SAndroid Build Coastguard Worker                 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", [], IIC_SR>;
381*9880d681SAndroid Build Coastguard Workerlet Uses = [CL] in
382*9880d681SAndroid Build Coastguard Workerdef RCR8rCL : I<0xD2, MRM3r, (outs GR8:$dst), (ins GR8:$src1),
383*9880d681SAndroid Build Coastguard Worker                "rcr{b}\t{%cl, $dst|$dst, cl}", [], IIC_SR>;
384*9880d681SAndroid Build Coastguard Worker
385*9880d681SAndroid Build Coastguard Workerdef RCR16r1 : I<0xD1, MRM3r, (outs GR16:$dst), (ins GR16:$src1),
386*9880d681SAndroid Build Coastguard Worker                "rcr{w}\t$dst", [], IIC_SR>, OpSize16;
387*9880d681SAndroid Build Coastguard Workerdef RCR16ri : Ii8<0xC1, MRM3r, (outs GR16:$dst), (ins GR16:$src1, u8imm:$cnt),
388*9880d681SAndroid Build Coastguard Worker                  "rcr{w}\t{$cnt, $dst|$dst, $cnt}", [], IIC_SR>, OpSize16;
389*9880d681SAndroid Build Coastguard Workerlet Uses = [CL] in
390*9880d681SAndroid Build Coastguard Workerdef RCR16rCL : I<0xD3, MRM3r, (outs GR16:$dst), (ins GR16:$src1),
391*9880d681SAndroid Build Coastguard Worker                 "rcr{w}\t{%cl, $dst|$dst, cl}", [], IIC_SR>, OpSize16;
392*9880d681SAndroid Build Coastguard Worker
393*9880d681SAndroid Build Coastguard Workerdef RCR32r1 : I<0xD1, MRM3r, (outs GR32:$dst), (ins GR32:$src1),
394*9880d681SAndroid Build Coastguard Worker                "rcr{l}\t$dst", [], IIC_SR>, OpSize32;
395*9880d681SAndroid Build Coastguard Workerdef RCR32ri : Ii8<0xC1, MRM3r, (outs GR32:$dst), (ins GR32:$src1, u8imm:$cnt),
396*9880d681SAndroid Build Coastguard Worker                  "rcr{l}\t{$cnt, $dst|$dst, $cnt}", [], IIC_SR>, OpSize32;
397*9880d681SAndroid Build Coastguard Workerlet Uses = [CL] in
398*9880d681SAndroid Build Coastguard Workerdef RCR32rCL : I<0xD3, MRM3r, (outs GR32:$dst), (ins GR32:$src1),
399*9880d681SAndroid Build Coastguard Worker                 "rcr{l}\t{%cl, $dst|$dst, cl}", [], IIC_SR>, OpSize32;
400*9880d681SAndroid Build Coastguard Worker
401*9880d681SAndroid Build Coastguard Workerdef RCR64r1 : RI<0xD1, MRM3r, (outs GR64:$dst), (ins GR64:$src1),
402*9880d681SAndroid Build Coastguard Worker                 "rcr{q}\t$dst", [], IIC_SR>;
403*9880d681SAndroid Build Coastguard Workerdef RCR64ri : RIi8<0xC1, MRM3r, (outs GR64:$dst), (ins GR64:$src1, u8imm:$cnt),
404*9880d681SAndroid Build Coastguard Worker                   "rcr{q}\t{$cnt, $dst|$dst, $cnt}", [], IIC_SR>;
405*9880d681SAndroid Build Coastguard Workerlet Uses = [CL] in
406*9880d681SAndroid Build Coastguard Workerdef RCR64rCL : RI<0xD3, MRM3r, (outs GR64:$dst), (ins GR64:$src1),
407*9880d681SAndroid Build Coastguard Worker                  "rcr{q}\t{%cl, $dst|$dst, cl}", [], IIC_SR>;
408*9880d681SAndroid Build Coastguard Worker
409*9880d681SAndroid Build Coastguard Worker} // Constraints = "$src = $dst"
410*9880d681SAndroid Build Coastguard Worker
411*9880d681SAndroid Build Coastguard Workerlet SchedRW = [WriteShiftLd, WriteRMW] in {
412*9880d681SAndroid Build Coastguard Workerdef RCL8m1 : I<0xD0, MRM2m, (outs), (ins i8mem:$dst),
413*9880d681SAndroid Build Coastguard Worker               "rcl{b}\t$dst", [], IIC_SR>;
414*9880d681SAndroid Build Coastguard Workerdef RCL8mi : Ii8<0xC0, MRM2m, (outs), (ins i8mem:$dst, u8imm:$cnt),
415*9880d681SAndroid Build Coastguard Worker                 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", [], IIC_SR>;
416*9880d681SAndroid Build Coastguard Workerdef RCL16m1 : I<0xD1, MRM2m, (outs), (ins i16mem:$dst),
417*9880d681SAndroid Build Coastguard Worker                "rcl{w}\t$dst", [], IIC_SR>, OpSize16;
418*9880d681SAndroid Build Coastguard Workerdef RCL16mi : Ii8<0xC1, MRM2m, (outs), (ins i16mem:$dst, u8imm:$cnt),
419*9880d681SAndroid Build Coastguard Worker                  "rcl{w}\t{$cnt, $dst|$dst, $cnt}", [], IIC_SR>, OpSize16;
420*9880d681SAndroid Build Coastguard Workerdef RCL32m1 : I<0xD1, MRM2m, (outs), (ins i32mem:$dst),
421*9880d681SAndroid Build Coastguard Worker                "rcl{l}\t$dst", [], IIC_SR>, OpSize32;
422*9880d681SAndroid Build Coastguard Workerdef RCL32mi : Ii8<0xC1, MRM2m, (outs), (ins i32mem:$dst, u8imm:$cnt),
423*9880d681SAndroid Build Coastguard Worker                  "rcl{l}\t{$cnt, $dst|$dst, $cnt}", [], IIC_SR>, OpSize32;
424*9880d681SAndroid Build Coastguard Workerdef RCL64m1 : RI<0xD1, MRM2m, (outs), (ins i64mem:$dst),
425*9880d681SAndroid Build Coastguard Worker                 "rcl{q}\t$dst", [], IIC_SR>;
426*9880d681SAndroid Build Coastguard Workerdef RCL64mi : RIi8<0xC1, MRM2m, (outs), (ins i64mem:$dst, u8imm:$cnt),
427*9880d681SAndroid Build Coastguard Worker                   "rcl{q}\t{$cnt, $dst|$dst, $cnt}", [], IIC_SR>;
428*9880d681SAndroid Build Coastguard Worker
429*9880d681SAndroid Build Coastguard Workerdef RCR8m1 : I<0xD0, MRM3m, (outs), (ins i8mem:$dst),
430*9880d681SAndroid Build Coastguard Worker               "rcr{b}\t$dst", [], IIC_SR>;
431*9880d681SAndroid Build Coastguard Workerdef RCR8mi : Ii8<0xC0, MRM3m, (outs), (ins i8mem:$dst, u8imm:$cnt),
432*9880d681SAndroid Build Coastguard Worker                 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", [], IIC_SR>;
433*9880d681SAndroid Build Coastguard Workerdef RCR16m1 : I<0xD1, MRM3m, (outs), (ins i16mem:$dst),
434*9880d681SAndroid Build Coastguard Worker                "rcr{w}\t$dst", [], IIC_SR>, OpSize16;
435*9880d681SAndroid Build Coastguard Workerdef RCR16mi : Ii8<0xC1, MRM3m, (outs), (ins i16mem:$dst, u8imm:$cnt),
436*9880d681SAndroid Build Coastguard Worker                  "rcr{w}\t{$cnt, $dst|$dst, $cnt}", [], IIC_SR>, OpSize16;
437*9880d681SAndroid Build Coastguard Workerdef RCR32m1 : I<0xD1, MRM3m, (outs), (ins i32mem:$dst),
438*9880d681SAndroid Build Coastguard Worker                "rcr{l}\t$dst", [], IIC_SR>, OpSize32;
439*9880d681SAndroid Build Coastguard Workerdef RCR32mi : Ii8<0xC1, MRM3m, (outs), (ins i32mem:$dst, u8imm:$cnt),
440*9880d681SAndroid Build Coastguard Worker                  "rcr{l}\t{$cnt, $dst|$dst, $cnt}", [], IIC_SR>, OpSize32;
441*9880d681SAndroid Build Coastguard Workerdef RCR64m1 : RI<0xD1, MRM3m, (outs), (ins i64mem:$dst),
442*9880d681SAndroid Build Coastguard Worker                 "rcr{q}\t$dst", [], IIC_SR>;
443*9880d681SAndroid Build Coastguard Workerdef RCR64mi : RIi8<0xC1, MRM3m, (outs), (ins i64mem:$dst, u8imm:$cnt),
444*9880d681SAndroid Build Coastguard Worker                   "rcr{q}\t{$cnt, $dst|$dst, $cnt}", [], IIC_SR>;
445*9880d681SAndroid Build Coastguard Worker
446*9880d681SAndroid Build Coastguard Workerlet Uses = [CL] in {
447*9880d681SAndroid Build Coastguard Workerdef RCL8mCL : I<0xD2, MRM2m, (outs), (ins i8mem:$dst),
448*9880d681SAndroid Build Coastguard Worker                "rcl{b}\t{%cl, $dst|$dst, cl}", [], IIC_SR>;
449*9880d681SAndroid Build Coastguard Workerdef RCL16mCL : I<0xD3, MRM2m, (outs), (ins i16mem:$dst),
450*9880d681SAndroid Build Coastguard Worker                 "rcl{w}\t{%cl, $dst|$dst, cl}", [], IIC_SR>, OpSize16;
451*9880d681SAndroid Build Coastguard Workerdef RCL32mCL : I<0xD3, MRM2m, (outs), (ins i32mem:$dst),
452*9880d681SAndroid Build Coastguard Worker                 "rcl{l}\t{%cl, $dst|$dst, cl}", [], IIC_SR>, OpSize32;
453*9880d681SAndroid Build Coastguard Workerdef RCL64mCL : RI<0xD3, MRM2m, (outs), (ins i64mem:$dst),
454*9880d681SAndroid Build Coastguard Worker                  "rcl{q}\t{%cl, $dst|$dst, cl}", [], IIC_SR>;
455*9880d681SAndroid Build Coastguard Worker
456*9880d681SAndroid Build Coastguard Workerdef RCR8mCL : I<0xD2, MRM3m, (outs), (ins i8mem:$dst),
457*9880d681SAndroid Build Coastguard Worker                "rcr{b}\t{%cl, $dst|$dst, cl}", [], IIC_SR>;
458*9880d681SAndroid Build Coastguard Workerdef RCR16mCL : I<0xD3, MRM3m, (outs), (ins i16mem:$dst),
459*9880d681SAndroid Build Coastguard Worker                 "rcr{w}\t{%cl, $dst|$dst, cl}", [], IIC_SR>, OpSize16;
460*9880d681SAndroid Build Coastguard Workerdef RCR32mCL : I<0xD3, MRM3m, (outs), (ins i32mem:$dst),
461*9880d681SAndroid Build Coastguard Worker                 "rcr{l}\t{%cl, $dst|$dst, cl}", [], IIC_SR>, OpSize32;
462*9880d681SAndroid Build Coastguard Workerdef RCR64mCL : RI<0xD3, MRM3m, (outs), (ins i64mem:$dst),
463*9880d681SAndroid Build Coastguard Worker                  "rcr{q}\t{%cl, $dst|$dst, cl}", [], IIC_SR>;
464*9880d681SAndroid Build Coastguard Worker}
465*9880d681SAndroid Build Coastguard Worker} // SchedRW
466*9880d681SAndroid Build Coastguard Worker} // hasSideEffects = 0
467*9880d681SAndroid Build Coastguard Worker
468*9880d681SAndroid Build Coastguard Workerlet Constraints = "$src1 = $dst", SchedRW = [WriteShift] in {
469*9880d681SAndroid Build Coastguard Worker// FIXME: provide shorter instructions when imm8 == 1
470*9880d681SAndroid Build Coastguard Workerlet Uses = [CL] in {
471*9880d681SAndroid Build Coastguard Workerdef ROL8rCL  : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
472*9880d681SAndroid Build Coastguard Worker                 "rol{b}\t{%cl, $dst|$dst, cl}",
473*9880d681SAndroid Build Coastguard Worker                 [(set GR8:$dst, (rotl GR8:$src1, CL))], IIC_SR>;
474*9880d681SAndroid Build Coastguard Workerdef ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
475*9880d681SAndroid Build Coastguard Worker                 "rol{w}\t{%cl, $dst|$dst, cl}",
476*9880d681SAndroid Build Coastguard Worker                 [(set GR16:$dst, (rotl GR16:$src1, CL))], IIC_SR>, OpSize16;
477*9880d681SAndroid Build Coastguard Workerdef ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
478*9880d681SAndroid Build Coastguard Worker                 "rol{l}\t{%cl, $dst|$dst, cl}",
479*9880d681SAndroid Build Coastguard Worker                 [(set GR32:$dst, (rotl GR32:$src1, CL))], IIC_SR>, OpSize32;
480*9880d681SAndroid Build Coastguard Workerdef ROL64rCL : RI<0xD3, MRM0r, (outs GR64:$dst), (ins GR64:$src1),
481*9880d681SAndroid Build Coastguard Worker                  "rol{q}\t{%cl, $dst|$dst, cl}",
482*9880d681SAndroid Build Coastguard Worker                  [(set GR64:$dst, (rotl GR64:$src1, CL))], IIC_SR>;
483*9880d681SAndroid Build Coastguard Worker}
484*9880d681SAndroid Build Coastguard Worker
485*9880d681SAndroid Build Coastguard Workerdef ROL8ri   : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, u8imm:$src2),
486*9880d681SAndroid Build Coastguard Worker                   "rol{b}\t{$src2, $dst|$dst, $src2}",
487*9880d681SAndroid Build Coastguard Worker                   [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))], IIC_SR>;
488*9880d681SAndroid Build Coastguard Workerdef ROL16ri  : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, u8imm:$src2),
489*9880d681SAndroid Build Coastguard Worker                   "rol{w}\t{$src2, $dst|$dst, $src2}",
490*9880d681SAndroid Build Coastguard Worker                   [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))],
491*9880d681SAndroid Build Coastguard Worker                   IIC_SR>, OpSize16;
492*9880d681SAndroid Build Coastguard Workerdef ROL32ri  : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, u8imm:$src2),
493*9880d681SAndroid Build Coastguard Worker                   "rol{l}\t{$src2, $dst|$dst, $src2}",
494*9880d681SAndroid Build Coastguard Worker                   [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))],
495*9880d681SAndroid Build Coastguard Worker                   IIC_SR>, OpSize32;
496*9880d681SAndroid Build Coastguard Workerdef ROL64ri  : RIi8<0xC1, MRM0r, (outs GR64:$dst),
497*9880d681SAndroid Build Coastguard Worker                    (ins GR64:$src1, u8imm:$src2),
498*9880d681SAndroid Build Coastguard Worker                    "rol{q}\t{$src2, $dst|$dst, $src2}",
499*9880d681SAndroid Build Coastguard Worker                    [(set GR64:$dst, (rotl GR64:$src1, (i8 imm:$src2)))],
500*9880d681SAndroid Build Coastguard Worker                    IIC_SR>;
501*9880d681SAndroid Build Coastguard Worker
502*9880d681SAndroid Build Coastguard Worker// Rotate by 1
503*9880d681SAndroid Build Coastguard Workerdef ROL8r1   : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
504*9880d681SAndroid Build Coastguard Worker                 "rol{b}\t$dst",
505*9880d681SAndroid Build Coastguard Worker                 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))],
506*9880d681SAndroid Build Coastguard Worker                 IIC_SR>;
507*9880d681SAndroid Build Coastguard Workerdef ROL16r1  : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
508*9880d681SAndroid Build Coastguard Worker                 "rol{w}\t$dst",
509*9880d681SAndroid Build Coastguard Worker                 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))],
510*9880d681SAndroid Build Coastguard Worker                 IIC_SR>, OpSize16;
511*9880d681SAndroid Build Coastguard Workerdef ROL32r1  : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
512*9880d681SAndroid Build Coastguard Worker                 "rol{l}\t$dst",
513*9880d681SAndroid Build Coastguard Worker                 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))],
514*9880d681SAndroid Build Coastguard Worker                 IIC_SR>, OpSize32;
515*9880d681SAndroid Build Coastguard Workerdef ROL64r1  : RI<0xD1, MRM0r, (outs GR64:$dst), (ins GR64:$src1),
516*9880d681SAndroid Build Coastguard Worker                  "rol{q}\t$dst",
517*9880d681SAndroid Build Coastguard Worker                  [(set GR64:$dst, (rotl GR64:$src1, (i8 1)))],
518*9880d681SAndroid Build Coastguard Worker                  IIC_SR>;
519*9880d681SAndroid Build Coastguard Worker} // Constraints = "$src = $dst", SchedRW
520*9880d681SAndroid Build Coastguard Worker
521*9880d681SAndroid Build Coastguard Workerlet SchedRW = [WriteShiftLd, WriteRMW] in {
522*9880d681SAndroid Build Coastguard Workerlet Uses = [CL] in {
523*9880d681SAndroid Build Coastguard Workerdef ROL8mCL  : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
524*9880d681SAndroid Build Coastguard Worker                 "rol{b}\t{%cl, $dst|$dst, cl}",
525*9880d681SAndroid Build Coastguard Worker                 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)],
526*9880d681SAndroid Build Coastguard Worker                 IIC_SR>;
527*9880d681SAndroid Build Coastguard Workerdef ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
528*9880d681SAndroid Build Coastguard Worker                 "rol{w}\t{%cl, $dst|$dst, cl}",
529*9880d681SAndroid Build Coastguard Worker                 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)],
530*9880d681SAndroid Build Coastguard Worker                 IIC_SR>, OpSize16;
531*9880d681SAndroid Build Coastguard Workerdef ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
532*9880d681SAndroid Build Coastguard Worker                 "rol{l}\t{%cl, $dst|$dst, cl}",
533*9880d681SAndroid Build Coastguard Worker                 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)],
534*9880d681SAndroid Build Coastguard Worker                 IIC_SR>, OpSize32;
535*9880d681SAndroid Build Coastguard Workerdef ROL64mCL :  RI<0xD3, MRM0m, (outs), (ins i64mem:$dst),
536*9880d681SAndroid Build Coastguard Worker                   "rol{q}\t{%cl, $dst|$dst, cl}",
537*9880d681SAndroid Build Coastguard Worker                   [(store (rotl (loadi64 addr:$dst), CL), addr:$dst)],
538*9880d681SAndroid Build Coastguard Worker                   IIC_SR>;
539*9880d681SAndroid Build Coastguard Worker}
540*9880d681SAndroid Build Coastguard Workerdef ROL8mi   : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, u8imm:$src1),
541*9880d681SAndroid Build Coastguard Worker                   "rol{b}\t{$src1, $dst|$dst, $src1}",
542*9880d681SAndroid Build Coastguard Worker               [(store (rotl (loadi8 addr:$dst), (i8 imm:$src1)), addr:$dst)],
543*9880d681SAndroid Build Coastguard Worker               IIC_SR>;
544*9880d681SAndroid Build Coastguard Workerdef ROL16mi  : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, u8imm:$src1),
545*9880d681SAndroid Build Coastguard Worker                   "rol{w}\t{$src1, $dst|$dst, $src1}",
546*9880d681SAndroid Build Coastguard Worker              [(store (rotl (loadi16 addr:$dst), (i8 imm:$src1)), addr:$dst)],
547*9880d681SAndroid Build Coastguard Worker              IIC_SR>, OpSize16;
548*9880d681SAndroid Build Coastguard Workerdef ROL32mi  : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, u8imm:$src1),
549*9880d681SAndroid Build Coastguard Worker                   "rol{l}\t{$src1, $dst|$dst, $src1}",
550*9880d681SAndroid Build Coastguard Worker              [(store (rotl (loadi32 addr:$dst), (i8 imm:$src1)), addr:$dst)],
551*9880d681SAndroid Build Coastguard Worker              IIC_SR>, OpSize32;
552*9880d681SAndroid Build Coastguard Workerdef ROL64mi  : RIi8<0xC1, MRM0m, (outs), (ins i64mem:$dst, u8imm:$src1),
553*9880d681SAndroid Build Coastguard Worker                    "rol{q}\t{$src1, $dst|$dst, $src1}",
554*9880d681SAndroid Build Coastguard Worker                [(store (rotl (loadi64 addr:$dst), (i8 imm:$src1)), addr:$dst)],
555*9880d681SAndroid Build Coastguard Worker                IIC_SR>;
556*9880d681SAndroid Build Coastguard Worker
557*9880d681SAndroid Build Coastguard Worker// Rotate by 1
558*9880d681SAndroid Build Coastguard Workerdef ROL8m1   : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
559*9880d681SAndroid Build Coastguard Worker                 "rol{b}\t$dst",
560*9880d681SAndroid Build Coastguard Worker               [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)],
561*9880d681SAndroid Build Coastguard Worker               IIC_SR>;
562*9880d681SAndroid Build Coastguard Workerdef ROL16m1  : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
563*9880d681SAndroid Build Coastguard Worker                 "rol{w}\t$dst",
564*9880d681SAndroid Build Coastguard Worker              [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)],
565*9880d681SAndroid Build Coastguard Worker              IIC_SR>, OpSize16;
566*9880d681SAndroid Build Coastguard Workerdef ROL32m1  : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
567*9880d681SAndroid Build Coastguard Worker                 "rol{l}\t$dst",
568*9880d681SAndroid Build Coastguard Worker              [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)],
569*9880d681SAndroid Build Coastguard Worker              IIC_SR>, OpSize32;
570*9880d681SAndroid Build Coastguard Workerdef ROL64m1  : RI<0xD1, MRM0m, (outs), (ins i64mem:$dst),
571*9880d681SAndroid Build Coastguard Worker                 "rol{q}\t$dst",
572*9880d681SAndroid Build Coastguard Worker               [(store (rotl (loadi64 addr:$dst), (i8 1)), addr:$dst)],
573*9880d681SAndroid Build Coastguard Worker               IIC_SR>;
574*9880d681SAndroid Build Coastguard Worker} // SchedRW
575*9880d681SAndroid Build Coastguard Worker
576*9880d681SAndroid Build Coastguard Workerlet Constraints = "$src1 = $dst", SchedRW = [WriteShift] in {
577*9880d681SAndroid Build Coastguard Workerlet Uses = [CL] in {
578*9880d681SAndroid Build Coastguard Workerdef ROR8rCL  : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
579*9880d681SAndroid Build Coastguard Worker                 "ror{b}\t{%cl, $dst|$dst, cl}",
580*9880d681SAndroid Build Coastguard Worker                 [(set GR8:$dst, (rotr GR8:$src1, CL))], IIC_SR>;
581*9880d681SAndroid Build Coastguard Workerdef ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
582*9880d681SAndroid Build Coastguard Worker                 "ror{w}\t{%cl, $dst|$dst, cl}",
583*9880d681SAndroid Build Coastguard Worker                 [(set GR16:$dst, (rotr GR16:$src1, CL))], IIC_SR>, OpSize16;
584*9880d681SAndroid Build Coastguard Workerdef ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
585*9880d681SAndroid Build Coastguard Worker                 "ror{l}\t{%cl, $dst|$dst, cl}",
586*9880d681SAndroid Build Coastguard Worker                 [(set GR32:$dst, (rotr GR32:$src1, CL))], IIC_SR>, OpSize32;
587*9880d681SAndroid Build Coastguard Workerdef ROR64rCL : RI<0xD3, MRM1r, (outs GR64:$dst), (ins GR64:$src1),
588*9880d681SAndroid Build Coastguard Worker                  "ror{q}\t{%cl, $dst|$dst, cl}",
589*9880d681SAndroid Build Coastguard Worker                  [(set GR64:$dst, (rotr GR64:$src1, CL))], IIC_SR>;
590*9880d681SAndroid Build Coastguard Worker}
591*9880d681SAndroid Build Coastguard Worker
592*9880d681SAndroid Build Coastguard Workerdef ROR8ri   : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, u8imm:$src2),
593*9880d681SAndroid Build Coastguard Worker                   "ror{b}\t{$src2, $dst|$dst, $src2}",
594*9880d681SAndroid Build Coastguard Worker                   [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))], IIC_SR>;
595*9880d681SAndroid Build Coastguard Workerdef ROR16ri  : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, u8imm:$src2),
596*9880d681SAndroid Build Coastguard Worker                   "ror{w}\t{$src2, $dst|$dst, $src2}",
597*9880d681SAndroid Build Coastguard Worker                   [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))],
598*9880d681SAndroid Build Coastguard Worker                   IIC_SR>, OpSize16;
599*9880d681SAndroid Build Coastguard Workerdef ROR32ri  : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, u8imm:$src2),
600*9880d681SAndroid Build Coastguard Worker                   "ror{l}\t{$src2, $dst|$dst, $src2}",
601*9880d681SAndroid Build Coastguard Worker                   [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))],
602*9880d681SAndroid Build Coastguard Worker                   IIC_SR>, OpSize32;
603*9880d681SAndroid Build Coastguard Workerdef ROR64ri  : RIi8<0xC1, MRM1r, (outs GR64:$dst),
604*9880d681SAndroid Build Coastguard Worker                    (ins GR64:$src1, u8imm:$src2),
605*9880d681SAndroid Build Coastguard Worker                    "ror{q}\t{$src2, $dst|$dst, $src2}",
606*9880d681SAndroid Build Coastguard Worker                    [(set GR64:$dst, (rotr GR64:$src1, (i8 imm:$src2)))],
607*9880d681SAndroid Build Coastguard Worker                    IIC_SR>;
608*9880d681SAndroid Build Coastguard Worker
609*9880d681SAndroid Build Coastguard Worker// Rotate by 1
610*9880d681SAndroid Build Coastguard Workerdef ROR8r1   : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
611*9880d681SAndroid Build Coastguard Worker                 "ror{b}\t$dst",
612*9880d681SAndroid Build Coastguard Worker                 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))],
613*9880d681SAndroid Build Coastguard Worker                 IIC_SR>;
614*9880d681SAndroid Build Coastguard Workerdef ROR16r1  : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
615*9880d681SAndroid Build Coastguard Worker                 "ror{w}\t$dst",
616*9880d681SAndroid Build Coastguard Worker                 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))],
617*9880d681SAndroid Build Coastguard Worker                 IIC_SR>, OpSize16;
618*9880d681SAndroid Build Coastguard Workerdef ROR32r1  : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
619*9880d681SAndroid Build Coastguard Worker                 "ror{l}\t$dst",
620*9880d681SAndroid Build Coastguard Worker                 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))],
621*9880d681SAndroid Build Coastguard Worker                 IIC_SR>, OpSize32;
622*9880d681SAndroid Build Coastguard Workerdef ROR64r1  : RI<0xD1, MRM1r, (outs GR64:$dst), (ins GR64:$src1),
623*9880d681SAndroid Build Coastguard Worker                  "ror{q}\t$dst",
624*9880d681SAndroid Build Coastguard Worker                  [(set GR64:$dst, (rotr GR64:$src1, (i8 1)))],
625*9880d681SAndroid Build Coastguard Worker                  IIC_SR>;
626*9880d681SAndroid Build Coastguard Worker} // Constraints = "$src = $dst", SchedRW
627*9880d681SAndroid Build Coastguard Worker
628*9880d681SAndroid Build Coastguard Workerlet SchedRW = [WriteShiftLd, WriteRMW] in {
629*9880d681SAndroid Build Coastguard Workerlet Uses = [CL] in {
630*9880d681SAndroid Build Coastguard Workerdef ROR8mCL  : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
631*9880d681SAndroid Build Coastguard Worker                 "ror{b}\t{%cl, $dst|$dst, cl}",
632*9880d681SAndroid Build Coastguard Worker                 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)],
633*9880d681SAndroid Build Coastguard Worker                 IIC_SR>;
634*9880d681SAndroid Build Coastguard Workerdef ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
635*9880d681SAndroid Build Coastguard Worker                 "ror{w}\t{%cl, $dst|$dst, cl}",
636*9880d681SAndroid Build Coastguard Worker                 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)],
637*9880d681SAndroid Build Coastguard Worker                 IIC_SR>, OpSize16;
638*9880d681SAndroid Build Coastguard Workerdef ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
639*9880d681SAndroid Build Coastguard Worker                 "ror{l}\t{%cl, $dst|$dst, cl}",
640*9880d681SAndroid Build Coastguard Worker                 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)],
641*9880d681SAndroid Build Coastguard Worker                 IIC_SR>, OpSize32;
642*9880d681SAndroid Build Coastguard Workerdef ROR64mCL : RI<0xD3, MRM1m, (outs), (ins i64mem:$dst),
643*9880d681SAndroid Build Coastguard Worker                  "ror{q}\t{%cl, $dst|$dst, cl}",
644*9880d681SAndroid Build Coastguard Worker                  [(store (rotr (loadi64 addr:$dst), CL), addr:$dst)],
645*9880d681SAndroid Build Coastguard Worker                  IIC_SR>;
646*9880d681SAndroid Build Coastguard Worker}
647*9880d681SAndroid Build Coastguard Workerdef ROR8mi   : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, u8imm:$src),
648*9880d681SAndroid Build Coastguard Worker                   "ror{b}\t{$src, $dst|$dst, $src}",
649*9880d681SAndroid Build Coastguard Worker               [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)],
650*9880d681SAndroid Build Coastguard Worker               IIC_SR>;
651*9880d681SAndroid Build Coastguard Workerdef ROR16mi  : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, u8imm:$src),
652*9880d681SAndroid Build Coastguard Worker                   "ror{w}\t{$src, $dst|$dst, $src}",
653*9880d681SAndroid Build Coastguard Worker              [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)],
654*9880d681SAndroid Build Coastguard Worker              IIC_SR>, OpSize16;
655*9880d681SAndroid Build Coastguard Workerdef ROR32mi  : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, u8imm:$src),
656*9880d681SAndroid Build Coastguard Worker                   "ror{l}\t{$src, $dst|$dst, $src}",
657*9880d681SAndroid Build Coastguard Worker              [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)],
658*9880d681SAndroid Build Coastguard Worker              IIC_SR>, OpSize32;
659*9880d681SAndroid Build Coastguard Workerdef ROR64mi  : RIi8<0xC1, MRM1m, (outs), (ins i64mem:$dst, u8imm:$src),
660*9880d681SAndroid Build Coastguard Worker                    "ror{q}\t{$src, $dst|$dst, $src}",
661*9880d681SAndroid Build Coastguard Worker                [(store (rotr (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)],
662*9880d681SAndroid Build Coastguard Worker                IIC_SR>;
663*9880d681SAndroid Build Coastguard Worker
664*9880d681SAndroid Build Coastguard Worker// Rotate by 1
665*9880d681SAndroid Build Coastguard Workerdef ROR8m1   : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
666*9880d681SAndroid Build Coastguard Worker                 "ror{b}\t$dst",
667*9880d681SAndroid Build Coastguard Worker               [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)],
668*9880d681SAndroid Build Coastguard Worker               IIC_SR>;
669*9880d681SAndroid Build Coastguard Workerdef ROR16m1  : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
670*9880d681SAndroid Build Coastguard Worker                 "ror{w}\t$dst",
671*9880d681SAndroid Build Coastguard Worker              [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)],
672*9880d681SAndroid Build Coastguard Worker              IIC_SR>, OpSize16;
673*9880d681SAndroid Build Coastguard Workerdef ROR32m1  : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
674*9880d681SAndroid Build Coastguard Worker                 "ror{l}\t$dst",
675*9880d681SAndroid Build Coastguard Worker              [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)],
676*9880d681SAndroid Build Coastguard Worker              IIC_SR>, OpSize32;
677*9880d681SAndroid Build Coastguard Workerdef ROR64m1  : RI<0xD1, MRM1m, (outs), (ins i64mem:$dst),
678*9880d681SAndroid Build Coastguard Worker                 "ror{q}\t$dst",
679*9880d681SAndroid Build Coastguard Worker               [(store (rotr (loadi64 addr:$dst), (i8 1)), addr:$dst)],
680*9880d681SAndroid Build Coastguard Worker               IIC_SR>;
681*9880d681SAndroid Build Coastguard Worker} // SchedRW
682*9880d681SAndroid Build Coastguard Worker
683*9880d681SAndroid Build Coastguard Worker
684*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===//
685*9880d681SAndroid Build Coastguard Worker// Double shift instructions (generalizations of rotate)
686*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===//
687*9880d681SAndroid Build Coastguard Worker
688*9880d681SAndroid Build Coastguard Workerlet Constraints = "$src1 = $dst", SchedRW = [WriteShift] in {
689*9880d681SAndroid Build Coastguard Worker
690*9880d681SAndroid Build Coastguard Workerlet Uses = [CL] in {
691*9880d681SAndroid Build Coastguard Workerdef SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst),
692*9880d681SAndroid Build Coastguard Worker                   (ins GR16:$src1, GR16:$src2),
693*9880d681SAndroid Build Coastguard Worker                   "shld{w}\t{%cl, $src2, $dst|$dst, $src2, cl}",
694*9880d681SAndroid Build Coastguard Worker                   [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))],
695*9880d681SAndroid Build Coastguard Worker                    IIC_SHD16_REG_CL>,
696*9880d681SAndroid Build Coastguard Worker                   TB, OpSize16;
697*9880d681SAndroid Build Coastguard Workerdef SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst),
698*9880d681SAndroid Build Coastguard Worker                   (ins GR16:$src1, GR16:$src2),
699*9880d681SAndroid Build Coastguard Worker                   "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, cl}",
700*9880d681SAndroid Build Coastguard Worker                   [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))],
701*9880d681SAndroid Build Coastguard Worker                    IIC_SHD16_REG_CL>,
702*9880d681SAndroid Build Coastguard Worker                   TB, OpSize16;
703*9880d681SAndroid Build Coastguard Workerdef SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst),
704*9880d681SAndroid Build Coastguard Worker                   (ins GR32:$src1, GR32:$src2),
705*9880d681SAndroid Build Coastguard Worker                   "shld{l}\t{%cl, $src2, $dst|$dst, $src2, cl}",
706*9880d681SAndroid Build Coastguard Worker                   [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))],
707*9880d681SAndroid Build Coastguard Worker                    IIC_SHD32_REG_CL>, TB, OpSize32;
708*9880d681SAndroid Build Coastguard Workerdef SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst),
709*9880d681SAndroid Build Coastguard Worker                   (ins GR32:$src1, GR32:$src2),
710*9880d681SAndroid Build Coastguard Worker                   "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, cl}",
711*9880d681SAndroid Build Coastguard Worker                   [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))],
712*9880d681SAndroid Build Coastguard Worker                   IIC_SHD32_REG_CL>, TB, OpSize32;
713*9880d681SAndroid Build Coastguard Workerdef SHLD64rrCL : RI<0xA5, MRMDestReg, (outs GR64:$dst),
714*9880d681SAndroid Build Coastguard Worker                    (ins GR64:$src1, GR64:$src2),
715*9880d681SAndroid Build Coastguard Worker                    "shld{q}\t{%cl, $src2, $dst|$dst, $src2, cl}",
716*9880d681SAndroid Build Coastguard Worker                    [(set GR64:$dst, (X86shld GR64:$src1, GR64:$src2, CL))],
717*9880d681SAndroid Build Coastguard Worker                    IIC_SHD64_REG_CL>,
718*9880d681SAndroid Build Coastguard Worker                    TB;
719*9880d681SAndroid Build Coastguard Workerdef SHRD64rrCL : RI<0xAD, MRMDestReg, (outs GR64:$dst),
720*9880d681SAndroid Build Coastguard Worker                    (ins GR64:$src1, GR64:$src2),
721*9880d681SAndroid Build Coastguard Worker                    "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, cl}",
722*9880d681SAndroid Build Coastguard Worker                    [(set GR64:$dst, (X86shrd GR64:$src1, GR64:$src2, CL))],
723*9880d681SAndroid Build Coastguard Worker                    IIC_SHD64_REG_CL>,
724*9880d681SAndroid Build Coastguard Worker                    TB;
725*9880d681SAndroid Build Coastguard Worker}
726*9880d681SAndroid Build Coastguard Worker
727*9880d681SAndroid Build Coastguard Workerlet isCommutable = 1 in {  // These instructions commute to each other.
728*9880d681SAndroid Build Coastguard Workerdef SHLD16rri8 : Ii8<0xA4, MRMDestReg,
729*9880d681SAndroid Build Coastguard Worker                     (outs GR16:$dst),
730*9880d681SAndroid Build Coastguard Worker                     (ins GR16:$src1, GR16:$src2, u8imm:$src3),
731*9880d681SAndroid Build Coastguard Worker                     "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
732*9880d681SAndroid Build Coastguard Worker                     [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
733*9880d681SAndroid Build Coastguard Worker                                      (i8 imm:$src3)))], IIC_SHD16_REG_IM>,
734*9880d681SAndroid Build Coastguard Worker                     TB, OpSize16;
735*9880d681SAndroid Build Coastguard Workerdef SHRD16rri8 : Ii8<0xAC, MRMDestReg,
736*9880d681SAndroid Build Coastguard Worker                     (outs GR16:$dst),
737*9880d681SAndroid Build Coastguard Worker                     (ins GR16:$src1, GR16:$src2, u8imm:$src3),
738*9880d681SAndroid Build Coastguard Worker                     "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
739*9880d681SAndroid Build Coastguard Worker                     [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
740*9880d681SAndroid Build Coastguard Worker                                      (i8 imm:$src3)))], IIC_SHD16_REG_IM>,
741*9880d681SAndroid Build Coastguard Worker                     TB, OpSize16;
742*9880d681SAndroid Build Coastguard Workerdef SHLD32rri8 : Ii8<0xA4, MRMDestReg,
743*9880d681SAndroid Build Coastguard Worker                     (outs GR32:$dst),
744*9880d681SAndroid Build Coastguard Worker                     (ins GR32:$src1, GR32:$src2, u8imm:$src3),
745*9880d681SAndroid Build Coastguard Worker                     "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
746*9880d681SAndroid Build Coastguard Worker                     [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
747*9880d681SAndroid Build Coastguard Worker                                      (i8 imm:$src3)))], IIC_SHD32_REG_IM>,
748*9880d681SAndroid Build Coastguard Worker                 TB, OpSize32;
749*9880d681SAndroid Build Coastguard Workerdef SHRD32rri8 : Ii8<0xAC, MRMDestReg,
750*9880d681SAndroid Build Coastguard Worker                     (outs GR32:$dst),
751*9880d681SAndroid Build Coastguard Worker                     (ins GR32:$src1, GR32:$src2, u8imm:$src3),
752*9880d681SAndroid Build Coastguard Worker                     "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
753*9880d681SAndroid Build Coastguard Worker                     [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
754*9880d681SAndroid Build Coastguard Worker                                      (i8 imm:$src3)))], IIC_SHD32_REG_IM>,
755*9880d681SAndroid Build Coastguard Worker                 TB, OpSize32;
756*9880d681SAndroid Build Coastguard Workerdef SHLD64rri8 : RIi8<0xA4, MRMDestReg,
757*9880d681SAndroid Build Coastguard Worker                      (outs GR64:$dst),
758*9880d681SAndroid Build Coastguard Worker                      (ins GR64:$src1, GR64:$src2, u8imm:$src3),
759*9880d681SAndroid Build Coastguard Worker                      "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
760*9880d681SAndroid Build Coastguard Worker                      [(set GR64:$dst, (X86shld GR64:$src1, GR64:$src2,
761*9880d681SAndroid Build Coastguard Worker                                       (i8 imm:$src3)))], IIC_SHD64_REG_IM>,
762*9880d681SAndroid Build Coastguard Worker                 TB;
763*9880d681SAndroid Build Coastguard Workerdef SHRD64rri8 : RIi8<0xAC, MRMDestReg,
764*9880d681SAndroid Build Coastguard Worker                      (outs GR64:$dst),
765*9880d681SAndroid Build Coastguard Worker                      (ins GR64:$src1, GR64:$src2, u8imm:$src3),
766*9880d681SAndroid Build Coastguard Worker                      "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
767*9880d681SAndroid Build Coastguard Worker                      [(set GR64:$dst, (X86shrd GR64:$src1, GR64:$src2,
768*9880d681SAndroid Build Coastguard Worker                                       (i8 imm:$src3)))], IIC_SHD64_REG_IM>,
769*9880d681SAndroid Build Coastguard Worker                 TB;
770*9880d681SAndroid Build Coastguard Worker}
771*9880d681SAndroid Build Coastguard Worker} // Constraints = "$src = $dst", SchedRW
772*9880d681SAndroid Build Coastguard Worker
773*9880d681SAndroid Build Coastguard Workerlet SchedRW = [WriteShiftLd, WriteRMW] in {
774*9880d681SAndroid Build Coastguard Workerlet Uses = [CL] in {
775*9880d681SAndroid Build Coastguard Workerdef SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
776*9880d681SAndroid Build Coastguard Worker                   "shld{w}\t{%cl, $src2, $dst|$dst, $src2, cl}",
777*9880d681SAndroid Build Coastguard Worker                   [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
778*9880d681SAndroid Build Coastguard Worker                     addr:$dst)], IIC_SHD16_MEM_CL>, TB, OpSize16;
779*9880d681SAndroid Build Coastguard Workerdef SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
780*9880d681SAndroid Build Coastguard Worker                  "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, cl}",
781*9880d681SAndroid Build Coastguard Worker                  [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
782*9880d681SAndroid Build Coastguard Worker                    addr:$dst)], IIC_SHD16_MEM_CL>, TB, OpSize16;
783*9880d681SAndroid Build Coastguard Worker
784*9880d681SAndroid Build Coastguard Workerdef SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
785*9880d681SAndroid Build Coastguard Worker                   "shld{l}\t{%cl, $src2, $dst|$dst, $src2, cl}",
786*9880d681SAndroid Build Coastguard Worker                   [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
787*9880d681SAndroid Build Coastguard Worker                     addr:$dst)], IIC_SHD32_MEM_CL>, TB, OpSize32;
788*9880d681SAndroid Build Coastguard Workerdef SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
789*9880d681SAndroid Build Coastguard Worker                  "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, cl}",
790*9880d681SAndroid Build Coastguard Worker                  [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
791*9880d681SAndroid Build Coastguard Worker                    addr:$dst)], IIC_SHD32_MEM_CL>, TB, OpSize32;
792*9880d681SAndroid Build Coastguard Worker
793*9880d681SAndroid Build Coastguard Workerdef SHLD64mrCL : RI<0xA5, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
794*9880d681SAndroid Build Coastguard Worker                    "shld{q}\t{%cl, $src2, $dst|$dst, $src2, cl}",
795*9880d681SAndroid Build Coastguard Worker                    [(store (X86shld (loadi64 addr:$dst), GR64:$src2, CL),
796*9880d681SAndroid Build Coastguard Worker                      addr:$dst)], IIC_SHD64_MEM_CL>, TB;
797*9880d681SAndroid Build Coastguard Workerdef SHRD64mrCL : RI<0xAD, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2),
798*9880d681SAndroid Build Coastguard Worker                    "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, cl}",
799*9880d681SAndroid Build Coastguard Worker                    [(store (X86shrd (loadi64 addr:$dst), GR64:$src2, CL),
800*9880d681SAndroid Build Coastguard Worker                      addr:$dst)], IIC_SHD64_MEM_CL>, TB;
801*9880d681SAndroid Build Coastguard Worker}
802*9880d681SAndroid Build Coastguard Worker
803*9880d681SAndroid Build Coastguard Workerdef SHLD16mri8 : Ii8<0xA4, MRMDestMem,
804*9880d681SAndroid Build Coastguard Worker                    (outs), (ins i16mem:$dst, GR16:$src2, u8imm:$src3),
805*9880d681SAndroid Build Coastguard Worker                    "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
806*9880d681SAndroid Build Coastguard Worker                    [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
807*9880d681SAndroid Build Coastguard Worker                                      (i8 imm:$src3)), addr:$dst)],
808*9880d681SAndroid Build Coastguard Worker                                      IIC_SHD16_MEM_IM>,
809*9880d681SAndroid Build Coastguard Worker                    TB, OpSize16;
810*9880d681SAndroid Build Coastguard Workerdef SHRD16mri8 : Ii8<0xAC, MRMDestMem,
811*9880d681SAndroid Build Coastguard Worker                     (outs), (ins i16mem:$dst, GR16:$src2, u8imm:$src3),
812*9880d681SAndroid Build Coastguard Worker                     "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
813*9880d681SAndroid Build Coastguard Worker                    [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
814*9880d681SAndroid Build Coastguard Worker                                      (i8 imm:$src3)), addr:$dst)],
815*9880d681SAndroid Build Coastguard Worker                                      IIC_SHD16_MEM_IM>,
816*9880d681SAndroid Build Coastguard Worker                     TB, OpSize16;
817*9880d681SAndroid Build Coastguard Worker
818*9880d681SAndroid Build Coastguard Workerdef SHLD32mri8 : Ii8<0xA4, MRMDestMem,
819*9880d681SAndroid Build Coastguard Worker                    (outs), (ins i32mem:$dst, GR32:$src2, u8imm:$src3),
820*9880d681SAndroid Build Coastguard Worker                    "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
821*9880d681SAndroid Build Coastguard Worker                    [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
822*9880d681SAndroid Build Coastguard Worker                                      (i8 imm:$src3)), addr:$dst)],
823*9880d681SAndroid Build Coastguard Worker                                      IIC_SHD32_MEM_IM>,
824*9880d681SAndroid Build Coastguard Worker                    TB, OpSize32;
825*9880d681SAndroid Build Coastguard Workerdef SHRD32mri8 : Ii8<0xAC, MRMDestMem,
826*9880d681SAndroid Build Coastguard Worker                     (outs), (ins i32mem:$dst, GR32:$src2, u8imm:$src3),
827*9880d681SAndroid Build Coastguard Worker                     "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
828*9880d681SAndroid Build Coastguard Worker                     [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
829*9880d681SAndroid Build Coastguard Worker                                       (i8 imm:$src3)), addr:$dst)],
830*9880d681SAndroid Build Coastguard Worker                                       IIC_SHD32_MEM_IM>,
831*9880d681SAndroid Build Coastguard Worker                     TB, OpSize32;
832*9880d681SAndroid Build Coastguard Worker
833*9880d681SAndroid Build Coastguard Workerdef SHLD64mri8 : RIi8<0xA4, MRMDestMem,
834*9880d681SAndroid Build Coastguard Worker                      (outs), (ins i64mem:$dst, GR64:$src2, u8imm:$src3),
835*9880d681SAndroid Build Coastguard Worker                      "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
836*9880d681SAndroid Build Coastguard Worker                      [(store (X86shld (loadi64 addr:$dst), GR64:$src2,
837*9880d681SAndroid Build Coastguard Worker                                       (i8 imm:$src3)), addr:$dst)],
838*9880d681SAndroid Build Coastguard Worker                                       IIC_SHD64_MEM_IM>,
839*9880d681SAndroid Build Coastguard Worker                 TB;
840*9880d681SAndroid Build Coastguard Workerdef SHRD64mri8 : RIi8<0xAC, MRMDestMem,
841*9880d681SAndroid Build Coastguard Worker                      (outs), (ins i64mem:$dst, GR64:$src2, u8imm:$src3),
842*9880d681SAndroid Build Coastguard Worker                      "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
843*9880d681SAndroid Build Coastguard Worker                      [(store (X86shrd (loadi64 addr:$dst), GR64:$src2,
844*9880d681SAndroid Build Coastguard Worker                                       (i8 imm:$src3)), addr:$dst)],
845*9880d681SAndroid Build Coastguard Worker                                       IIC_SHD64_MEM_IM>,
846*9880d681SAndroid Build Coastguard Worker                 TB;
847*9880d681SAndroid Build Coastguard Worker} // SchedRW
848*9880d681SAndroid Build Coastguard Worker
849*9880d681SAndroid Build Coastguard Worker} // Defs = [EFLAGS]
850*9880d681SAndroid Build Coastguard Worker
851*9880d681SAndroid Build Coastguard Workerdef ROT32L2R_imm8  : SDNodeXForm<imm, [{
852*9880d681SAndroid Build Coastguard Worker  // Convert a ROTL shamt to a ROTR shamt on 32-bit integer.
853*9880d681SAndroid Build Coastguard Worker  return getI8Imm(32 - N->getZExtValue(), SDLoc(N));
854*9880d681SAndroid Build Coastguard Worker}]>;
855*9880d681SAndroid Build Coastguard Worker
856*9880d681SAndroid Build Coastguard Workerdef ROT64L2R_imm8  : SDNodeXForm<imm, [{
857*9880d681SAndroid Build Coastguard Worker  // Convert a ROTL shamt to a ROTR shamt on 64-bit integer.
858*9880d681SAndroid Build Coastguard Worker  return getI8Imm(64 - N->getZExtValue(), SDLoc(N));
859*9880d681SAndroid Build Coastguard Worker}]>;
860*9880d681SAndroid Build Coastguard Worker
861*9880d681SAndroid Build Coastguard Workermulticlass bmi_rotate<string asm, RegisterClass RC, X86MemOperand x86memop> {
862*9880d681SAndroid Build Coastguard Workerlet hasSideEffects = 0 in {
863*9880d681SAndroid Build Coastguard Worker  def ri : Ii8<0xF0, MRMSrcReg, (outs RC:$dst), (ins RC:$src1, u8imm:$src2),
864*9880d681SAndroid Build Coastguard Worker               !strconcat(asm, "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
865*9880d681SAndroid Build Coastguard Worker               []>, TAXD, VEX, Sched<[WriteShift]>;
866*9880d681SAndroid Build Coastguard Worker  let mayLoad = 1 in
867*9880d681SAndroid Build Coastguard Worker  def mi : Ii8<0xF0, MRMSrcMem, (outs RC:$dst),
868*9880d681SAndroid Build Coastguard Worker               (ins x86memop:$src1, u8imm:$src2),
869*9880d681SAndroid Build Coastguard Worker               !strconcat(asm, "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
870*9880d681SAndroid Build Coastguard Worker               []>, TAXD, VEX, Sched<[WriteShiftLd]>;
871*9880d681SAndroid Build Coastguard Worker}
872*9880d681SAndroid Build Coastguard Worker}
873*9880d681SAndroid Build Coastguard Worker
874*9880d681SAndroid Build Coastguard Workermulticlass bmi_shift<string asm, RegisterClass RC, X86MemOperand x86memop> {
875*9880d681SAndroid Build Coastguard Workerlet hasSideEffects = 0 in {
876*9880d681SAndroid Build Coastguard Worker  def rr : I<0xF7, MRMSrcReg, (outs RC:$dst), (ins RC:$src1, RC:$src2),
877*9880d681SAndroid Build Coastguard Worker             !strconcat(asm, "\t{$src2, $src1, $dst|$dst, $src1, $src2}"), []>,
878*9880d681SAndroid Build Coastguard Worker             VEX_4VOp3, Sched<[WriteShift]>;
879*9880d681SAndroid Build Coastguard Worker  let mayLoad = 1 in
880*9880d681SAndroid Build Coastguard Worker  def rm : I<0xF7, MRMSrcMem, (outs RC:$dst), (ins x86memop:$src1, RC:$src2),
881*9880d681SAndroid Build Coastguard Worker             !strconcat(asm, "\t{$src2, $src1, $dst|$dst, $src1, $src2}"), []>,
882*9880d681SAndroid Build Coastguard Worker             VEX_4VOp3,
883*9880d681SAndroid Build Coastguard Worker             Sched<[WriteShiftLd,
884*9880d681SAndroid Build Coastguard Worker                    // x86memop:$src1
885*9880d681SAndroid Build Coastguard Worker                    ReadDefault, ReadDefault, ReadDefault, ReadDefault,
886*9880d681SAndroid Build Coastguard Worker                    ReadDefault,
887*9880d681SAndroid Build Coastguard Worker                    // RC:$src1
888*9880d681SAndroid Build Coastguard Worker                    ReadAfterLd]>;
889*9880d681SAndroid Build Coastguard Worker}
890*9880d681SAndroid Build Coastguard Worker}
891*9880d681SAndroid Build Coastguard Worker
892*9880d681SAndroid Build Coastguard Workerlet Predicates = [HasBMI2] in {
893*9880d681SAndroid Build Coastguard Worker  defm RORX32 : bmi_rotate<"rorx{l}", GR32, i32mem>;
894*9880d681SAndroid Build Coastguard Worker  defm RORX64 : bmi_rotate<"rorx{q}", GR64, i64mem>, VEX_W;
895*9880d681SAndroid Build Coastguard Worker  defm SARX32 : bmi_shift<"sarx{l}", GR32, i32mem>, T8XS;
896*9880d681SAndroid Build Coastguard Worker  defm SARX64 : bmi_shift<"sarx{q}", GR64, i64mem>, T8XS, VEX_W;
897*9880d681SAndroid Build Coastguard Worker  defm SHRX32 : bmi_shift<"shrx{l}", GR32, i32mem>, T8XD;
898*9880d681SAndroid Build Coastguard Worker  defm SHRX64 : bmi_shift<"shrx{q}", GR64, i64mem>, T8XD, VEX_W;
899*9880d681SAndroid Build Coastguard Worker  defm SHLX32 : bmi_shift<"shlx{l}", GR32, i32mem>, T8PD;
900*9880d681SAndroid Build Coastguard Worker  defm SHLX64 : bmi_shift<"shlx{q}", GR64, i64mem>, T8PD, VEX_W;
901*9880d681SAndroid Build Coastguard Worker
902*9880d681SAndroid Build Coastguard Worker  // Prefer RORX which is non-destructive and doesn't update EFLAGS.
903*9880d681SAndroid Build Coastguard Worker  let AddedComplexity = 10 in {
904*9880d681SAndroid Build Coastguard Worker    def : Pat<(rotl GR32:$src, (i8 imm:$shamt)),
905*9880d681SAndroid Build Coastguard Worker              (RORX32ri GR32:$src, (ROT32L2R_imm8 imm:$shamt))>;
906*9880d681SAndroid Build Coastguard Worker    def : Pat<(rotl GR64:$src, (i8 imm:$shamt)),
907*9880d681SAndroid Build Coastguard Worker              (RORX64ri GR64:$src, (ROT64L2R_imm8 imm:$shamt))>;
908*9880d681SAndroid Build Coastguard Worker  }
909*9880d681SAndroid Build Coastguard Worker
910*9880d681SAndroid Build Coastguard Worker  def : Pat<(rotl (loadi32 addr:$src), (i8 imm:$shamt)),
911*9880d681SAndroid Build Coastguard Worker            (RORX32mi addr:$src, (ROT32L2R_imm8 imm:$shamt))>;
912*9880d681SAndroid Build Coastguard Worker  def : Pat<(rotl (loadi64 addr:$src), (i8 imm:$shamt)),
913*9880d681SAndroid Build Coastguard Worker            (RORX64mi addr:$src, (ROT64L2R_imm8 imm:$shamt))>;
914*9880d681SAndroid Build Coastguard Worker
915*9880d681SAndroid Build Coastguard Worker  // Prefer SARX/SHRX/SHLX over SAR/SHR/SHL with variable shift BUT not
916*9880d681SAndroid Build Coastguard Worker  // immedidate shift, i.e. the following code is considered better
917*9880d681SAndroid Build Coastguard Worker  //
918*9880d681SAndroid Build Coastguard Worker  //  mov %edi, %esi
919*9880d681SAndroid Build Coastguard Worker  //  shl $imm, %esi
920*9880d681SAndroid Build Coastguard Worker  //  ... %edi, ...
921*9880d681SAndroid Build Coastguard Worker  //
922*9880d681SAndroid Build Coastguard Worker  // than
923*9880d681SAndroid Build Coastguard Worker  //
924*9880d681SAndroid Build Coastguard Worker  //  movb $imm, %sil
925*9880d681SAndroid Build Coastguard Worker  //  shlx %sil, %edi, %esi
926*9880d681SAndroid Build Coastguard Worker  //  ... %edi, ...
927*9880d681SAndroid Build Coastguard Worker  //
928*9880d681SAndroid Build Coastguard Worker  let AddedComplexity = 1 in {
929*9880d681SAndroid Build Coastguard Worker    def : Pat<(sra GR32:$src1, GR8:$src2),
930*9880d681SAndroid Build Coastguard Worker              (SARX32rr GR32:$src1,
931*9880d681SAndroid Build Coastguard Worker                        (INSERT_SUBREG
932*9880d681SAndroid Build Coastguard Worker                          (i32 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>;
933*9880d681SAndroid Build Coastguard Worker    def : Pat<(sra GR64:$src1, GR8:$src2),
934*9880d681SAndroid Build Coastguard Worker              (SARX64rr GR64:$src1,
935*9880d681SAndroid Build Coastguard Worker                        (INSERT_SUBREG
936*9880d681SAndroid Build Coastguard Worker                          (i64 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>;
937*9880d681SAndroid Build Coastguard Worker
938*9880d681SAndroid Build Coastguard Worker    def : Pat<(srl GR32:$src1, GR8:$src2),
939*9880d681SAndroid Build Coastguard Worker              (SHRX32rr GR32:$src1,
940*9880d681SAndroid Build Coastguard Worker                        (INSERT_SUBREG
941*9880d681SAndroid Build Coastguard Worker                          (i32 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>;
942*9880d681SAndroid Build Coastguard Worker    def : Pat<(srl GR64:$src1, GR8:$src2),
943*9880d681SAndroid Build Coastguard Worker              (SHRX64rr GR64:$src1,
944*9880d681SAndroid Build Coastguard Worker                        (INSERT_SUBREG
945*9880d681SAndroid Build Coastguard Worker                          (i64 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>;
946*9880d681SAndroid Build Coastguard Worker
947*9880d681SAndroid Build Coastguard Worker    def : Pat<(shl GR32:$src1, GR8:$src2),
948*9880d681SAndroid Build Coastguard Worker              (SHLX32rr GR32:$src1,
949*9880d681SAndroid Build Coastguard Worker                        (INSERT_SUBREG
950*9880d681SAndroid Build Coastguard Worker                          (i32 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>;
951*9880d681SAndroid Build Coastguard Worker    def : Pat<(shl GR64:$src1, GR8:$src2),
952*9880d681SAndroid Build Coastguard Worker              (SHLX64rr GR64:$src1,
953*9880d681SAndroid Build Coastguard Worker                        (INSERT_SUBREG
954*9880d681SAndroid Build Coastguard Worker                          (i64 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>;
955*9880d681SAndroid Build Coastguard Worker  }
956*9880d681SAndroid Build Coastguard Worker
957*9880d681SAndroid Build Coastguard Worker  // Patterns on SARXrm/SHRXrm/SHLXrm are explicitly omitted to favor
958*9880d681SAndroid Build Coastguard Worker  //
959*9880d681SAndroid Build Coastguard Worker  //  mov (%ecx), %esi
960*9880d681SAndroid Build Coastguard Worker  //  shl $imm, $esi
961*9880d681SAndroid Build Coastguard Worker  //
962*9880d681SAndroid Build Coastguard Worker  // over
963*9880d681SAndroid Build Coastguard Worker  //
964*9880d681SAndroid Build Coastguard Worker  //  movb $imm %al
965*9880d681SAndroid Build Coastguard Worker  //  shlx %al, (%ecx), %esi
966*9880d681SAndroid Build Coastguard Worker  //
967*9880d681SAndroid Build Coastguard Worker  // As SARXrr/SHRXrr/SHLXrr is favored on variable shift, the peephole
968*9880d681SAndroid Build Coastguard Worker  // optimization will fold them into SARXrm/SHRXrm/SHLXrm if possible.
969*9880d681SAndroid Build Coastguard Worker}
970