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