10b57cec5SDimitry Andric//===-- X86InstrShiftRotate.td - Shift and Rotate Instrs ---*- tablegen -*-===// 20b57cec5SDimitry Andric// 30b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric// 70b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric// 90b57cec5SDimitry Andric// This file describes the shift and rotate instructions. 100b57cec5SDimitry Andric// 110b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric// FIXME: Someone needs to smear multipattern goodness all over this file. 140b57cec5SDimitry Andric 1506c3fb27SDimitry Andriclet Defs = [EFLAGS], hasSideEffects = 0 in { 160b57cec5SDimitry Andric 17bdd1243dSDimitry Andriclet Constraints = "$src1 = $dst" in { 180b57cec5SDimitry Andriclet Uses = [CL], SchedRW = [WriteShiftCL] in { 190b57cec5SDimitry Andricdef SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1), 200b57cec5SDimitry Andric "shl{b}\t{%cl, $dst|$dst, cl}", 210b57cec5SDimitry Andric [(set GR8:$dst, (shl GR8:$src1, CL))]>; 220b57cec5SDimitry Andricdef SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src1), 230b57cec5SDimitry Andric "shl{w}\t{%cl, $dst|$dst, cl}", 240b57cec5SDimitry Andric [(set GR16:$dst, (shl GR16:$src1, CL))]>, OpSize16; 250b57cec5SDimitry Andricdef SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src1), 260b57cec5SDimitry Andric "shl{l}\t{%cl, $dst|$dst, cl}", 270b57cec5SDimitry Andric [(set GR32:$dst, (shl GR32:$src1, CL))]>, OpSize32; 280b57cec5SDimitry Andricdef SHL64rCL : RI<0xD3, MRM4r, (outs GR64:$dst), (ins GR64:$src1), 290b57cec5SDimitry Andric "shl{q}\t{%cl, $dst|$dst, cl}", 300b57cec5SDimitry Andric [(set GR64:$dst, (shl GR64:$src1, CL))]>; 310b57cec5SDimitry Andric} // Uses = [CL], SchedRW 320b57cec5SDimitry Andric 33bdd1243dSDimitry Andriclet SchedRW = [WriteShift] in { 340b57cec5SDimitry Andriclet isConvertibleToThreeAddress = 1 in { // Can transform into LEA. 350b57cec5SDimitry Andricdef SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, u8imm:$src2), 360b57cec5SDimitry Andric "shl{b}\t{$src2, $dst|$dst, $src2}", 370b57cec5SDimitry Andric [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>; 380b57cec5SDimitry Andric 390b57cec5SDimitry Andricdef SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, u8imm:$src2), 400b57cec5SDimitry Andric "shl{w}\t{$src2, $dst|$dst, $src2}", 410b57cec5SDimitry Andric [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, 420b57cec5SDimitry Andric OpSize16; 430b57cec5SDimitry Andricdef SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, u8imm:$src2), 440b57cec5SDimitry Andric "shl{l}\t{$src2, $dst|$dst, $src2}", 450b57cec5SDimitry Andric [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>, 460b57cec5SDimitry Andric OpSize32; 470b57cec5SDimitry Andricdef SHL64ri : RIi8<0xC1, MRM4r, (outs GR64:$dst), 480b57cec5SDimitry Andric (ins GR64:$src1, u8imm:$src2), 490b57cec5SDimitry Andric "shl{q}\t{$src2, $dst|$dst, $src2}", 500b57cec5SDimitry Andric [(set GR64:$dst, (shl GR64:$src1, (i8 imm:$src2)))]>; 510b57cec5SDimitry Andric} // isConvertibleToThreeAddress = 1 520b57cec5SDimitry Andric 530b57cec5SDimitry Andricdef SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1), 540b57cec5SDimitry Andric "shl{b}\t$dst", []>; 550b57cec5SDimitry Andricdef SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1), 560b57cec5SDimitry Andric "shl{w}\t$dst", []>, OpSize16; 570b57cec5SDimitry Andricdef SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1), 580b57cec5SDimitry Andric "shl{l}\t$dst", []>, OpSize32; 590b57cec5SDimitry Andricdef SHL64r1 : RI<0xD1, MRM4r, (outs GR64:$dst), (ins GR64:$src1), 600b57cec5SDimitry Andric "shl{q}\t$dst", []>; 61bdd1243dSDimitry Andric} // SchedRW 62bdd1243dSDimitry Andric} // Constraints = "$src = $dst" 630b57cec5SDimitry Andric 640b57cec5SDimitry Andric// FIXME: Why do we need an explicit "Uses = [CL]" when the instr has a pattern 650b57cec5SDimitry Andric// using CL? 660b57cec5SDimitry Andriclet Uses = [CL], SchedRW = [WriteShiftCLLd, WriteRMW] in { 670b57cec5SDimitry Andricdef SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst), 680b57cec5SDimitry Andric "shl{b}\t{%cl, $dst|$dst, cl}", 690b57cec5SDimitry Andric [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>; 700b57cec5SDimitry Andricdef SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst), 710b57cec5SDimitry Andric "shl{w}\t{%cl, $dst|$dst, cl}", 720b57cec5SDimitry Andric [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, 730b57cec5SDimitry Andric OpSize16; 740b57cec5SDimitry Andricdef SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst), 750b57cec5SDimitry Andric "shl{l}\t{%cl, $dst|$dst, cl}", 760b57cec5SDimitry Andric [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>, 770b57cec5SDimitry Andric OpSize32; 780b57cec5SDimitry Andricdef SHL64mCL : RI<0xD3, MRM4m, (outs), (ins i64mem:$dst), 790b57cec5SDimitry Andric "shl{q}\t{%cl, $dst|$dst, cl}", 800b57cec5SDimitry Andric [(store (shl (loadi64 addr:$dst), CL), addr:$dst)]>, 810b57cec5SDimitry Andric Requires<[In64BitMode]>; 82bdd1243dSDimitry Andric} // Uses, SchedRW 830b57cec5SDimitry Andric 8406c3fb27SDimitry Andriclet SchedRW = [WriteShiftLd, WriteRMW], mayLoad = 1, mayStore = 1 in { 850b57cec5SDimitry Andricdef SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, u8imm:$src), 860b57cec5SDimitry Andric "shl{b}\t{$src, $dst|$dst, $src}", 870b57cec5SDimitry Andric [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>; 880b57cec5SDimitry Andricdef SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, u8imm:$src), 890b57cec5SDimitry Andric "shl{w}\t{$src, $dst|$dst, $src}", 900b57cec5SDimitry Andric [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>, 910b57cec5SDimitry Andric OpSize16; 920b57cec5SDimitry Andricdef SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, u8imm:$src), 930b57cec5SDimitry Andric "shl{l}\t{$src, $dst|$dst, $src}", 940b57cec5SDimitry Andric [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>, 950b57cec5SDimitry Andric OpSize32; 960b57cec5SDimitry Andricdef SHL64mi : RIi8<0xC1, MRM4m, (outs), (ins i64mem:$dst, u8imm:$src), 970b57cec5SDimitry Andric "shl{q}\t{$src, $dst|$dst, $src}", 980b57cec5SDimitry Andric [(store (shl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>, 990b57cec5SDimitry Andric Requires<[In64BitMode]>; 1000b57cec5SDimitry Andric 1010b57cec5SDimitry Andric// Shift by 1 1020b57cec5SDimitry Andricdef SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst), 10306c3fb27SDimitry Andric "shl{b}\t$dst", []>; 1040b57cec5SDimitry Andricdef SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst), 10506c3fb27SDimitry Andric "shl{w}\t$dst", []>, OpSize16; 1060b57cec5SDimitry Andricdef SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst), 10706c3fb27SDimitry Andric "shl{l}\t$dst", []>, OpSize32; 1080b57cec5SDimitry Andricdef SHL64m1 : RI<0xD1, MRM4m, (outs), (ins i64mem:$dst), 10906c3fb27SDimitry Andric "shl{q}\t$dst", []>, Requires<[In64BitMode]>; 11006c3fb27SDimitry Andric} // SchedRW, mayLoad, mayStore 1110b57cec5SDimitry Andric 112bdd1243dSDimitry Andriclet Constraints = "$src1 = $dst" in { 1130b57cec5SDimitry Andriclet Uses = [CL], SchedRW = [WriteShiftCL] in { 1140b57cec5SDimitry Andricdef SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src1), 1150b57cec5SDimitry Andric "shr{b}\t{%cl, $dst|$dst, cl}", 1160b57cec5SDimitry Andric [(set GR8:$dst, (srl GR8:$src1, CL))]>; 1170b57cec5SDimitry Andricdef SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src1), 1180b57cec5SDimitry Andric "shr{w}\t{%cl, $dst|$dst, cl}", 1190b57cec5SDimitry Andric [(set GR16:$dst, (srl GR16:$src1, CL))]>, OpSize16; 1200b57cec5SDimitry Andricdef SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src1), 1210b57cec5SDimitry Andric "shr{l}\t{%cl, $dst|$dst, cl}", 1220b57cec5SDimitry Andric [(set GR32:$dst, (srl GR32:$src1, CL))]>, OpSize32; 1230b57cec5SDimitry Andricdef SHR64rCL : RI<0xD3, MRM5r, (outs GR64:$dst), (ins GR64:$src1), 1240b57cec5SDimitry Andric "shr{q}\t{%cl, $dst|$dst, cl}", 1250b57cec5SDimitry Andric [(set GR64:$dst, (srl GR64:$src1, CL))]>; 126bdd1243dSDimitry Andric} // Uses, SchedRW 1270b57cec5SDimitry Andric 128bdd1243dSDimitry Andriclet SchedRW = [WriteShift] in { 1290b57cec5SDimitry Andricdef SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, u8imm:$src2), 1300b57cec5SDimitry Andric "shr{b}\t{$src2, $dst|$dst, $src2}", 1310b57cec5SDimitry Andric [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>; 1320b57cec5SDimitry Andricdef SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, u8imm:$src2), 1330b57cec5SDimitry Andric "shr{w}\t{$src2, $dst|$dst, $src2}", 1340b57cec5SDimitry Andric [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, 1350b57cec5SDimitry Andric OpSize16; 1360b57cec5SDimitry Andricdef SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, u8imm:$src2), 1370b57cec5SDimitry Andric "shr{l}\t{$src2, $dst|$dst, $src2}", 1380b57cec5SDimitry Andric [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>, 1390b57cec5SDimitry Andric OpSize32; 1400b57cec5SDimitry Andricdef SHR64ri : RIi8<0xC1, MRM5r, (outs GR64:$dst), (ins GR64:$src1, u8imm:$src2), 1410b57cec5SDimitry Andric "shr{q}\t{$src2, $dst|$dst, $src2}", 1420b57cec5SDimitry Andric [(set GR64:$dst, (srl GR64:$src1, (i8 imm:$src2)))]>; 1430b57cec5SDimitry Andric 1440b57cec5SDimitry Andric// Shift right by 1 1450b57cec5SDimitry Andricdef SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1), 14606c3fb27SDimitry Andric "shr{b}\t$dst", []>; 1470b57cec5SDimitry Andricdef SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1), 14806c3fb27SDimitry Andric "shr{w}\t$dst", []>, OpSize16; 1490b57cec5SDimitry Andricdef SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1), 15006c3fb27SDimitry Andric "shr{l}\t$dst", []>, OpSize32; 1510b57cec5SDimitry Andricdef SHR64r1 : RI<0xD1, MRM5r, (outs GR64:$dst), (ins GR64:$src1), 15206c3fb27SDimitry Andric "shr{q}\t$dst", []>; 153bdd1243dSDimitry Andric} // SchedRW 154bdd1243dSDimitry Andric} // Constraints = "$src = $dst" 1550b57cec5SDimitry Andric 1560b57cec5SDimitry Andric 1570b57cec5SDimitry Andriclet Uses = [CL], SchedRW = [WriteShiftCLLd, WriteRMW] in { 1580b57cec5SDimitry Andricdef SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst), 1590b57cec5SDimitry Andric "shr{b}\t{%cl, $dst|$dst, cl}", 1600b57cec5SDimitry Andric [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>; 1610b57cec5SDimitry Andricdef SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst), 1620b57cec5SDimitry Andric "shr{w}\t{%cl, $dst|$dst, cl}", 1630b57cec5SDimitry Andric [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>, 1640b57cec5SDimitry Andric OpSize16; 1650b57cec5SDimitry Andricdef SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst), 1660b57cec5SDimitry Andric "shr{l}\t{%cl, $dst|$dst, cl}", 1670b57cec5SDimitry Andric [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>, 1680b57cec5SDimitry Andric OpSize32; 1690b57cec5SDimitry Andricdef SHR64mCL : RI<0xD3, MRM5m, (outs), (ins i64mem:$dst), 1700b57cec5SDimitry Andric "shr{q}\t{%cl, $dst|$dst, cl}", 1710b57cec5SDimitry Andric [(store (srl (loadi64 addr:$dst), CL), addr:$dst)]>, 1720b57cec5SDimitry Andric Requires<[In64BitMode]>; 173bdd1243dSDimitry Andric} // Uses, SchedRW 1740b57cec5SDimitry Andric 17506c3fb27SDimitry Andriclet SchedRW = [WriteShiftLd, WriteRMW], mayLoad = 1, mayStore = 1 in { 1760b57cec5SDimitry Andricdef SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, u8imm:$src), 1770b57cec5SDimitry Andric "shr{b}\t{$src, $dst|$dst, $src}", 1780b57cec5SDimitry Andric [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>; 1790b57cec5SDimitry Andricdef SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, u8imm:$src), 1800b57cec5SDimitry Andric "shr{w}\t{$src, $dst|$dst, $src}", 1810b57cec5SDimitry Andric [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>, 1820b57cec5SDimitry Andric OpSize16; 1830b57cec5SDimitry Andricdef SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, u8imm:$src), 1840b57cec5SDimitry Andric "shr{l}\t{$src, $dst|$dst, $src}", 1850b57cec5SDimitry Andric [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>, 1860b57cec5SDimitry Andric OpSize32; 1870b57cec5SDimitry Andricdef SHR64mi : RIi8<0xC1, MRM5m, (outs), (ins i64mem:$dst, u8imm:$src), 1880b57cec5SDimitry Andric "shr{q}\t{$src, $dst|$dst, $src}", 1890b57cec5SDimitry Andric [(store (srl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>, 1900b57cec5SDimitry Andric Requires<[In64BitMode]>; 1910b57cec5SDimitry Andric 1920b57cec5SDimitry Andric// Shift by 1 1930b57cec5SDimitry Andricdef SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst), 19406c3fb27SDimitry Andric "shr{b}\t$dst", []>; 1950b57cec5SDimitry Andricdef SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst), 19606c3fb27SDimitry Andric "shr{w}\t$dst", []>, OpSize16; 1970b57cec5SDimitry Andricdef SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst), 19806c3fb27SDimitry Andric "shr{l}\t$dst", []>, OpSize32; 1990b57cec5SDimitry Andricdef SHR64m1 : RI<0xD1, MRM5m, (outs), (ins i64mem:$dst), 20006c3fb27SDimitry Andric "shr{q}\t$dst", []>, Requires<[In64BitMode]>; 20106c3fb27SDimitry Andric} // SchedRW, mayLoad, mayStore 20206c3fb27SDimitry Andric 2030b57cec5SDimitry Andric 204bdd1243dSDimitry Andriclet Constraints = "$src1 = $dst" in { 2050b57cec5SDimitry Andriclet Uses = [CL], SchedRW = [WriteShiftCL] in { 2060b57cec5SDimitry Andricdef SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1), 2070b57cec5SDimitry Andric "sar{b}\t{%cl, $dst|$dst, cl}", 2080b57cec5SDimitry Andric [(set GR8:$dst, (sra GR8:$src1, CL))]>; 2090b57cec5SDimitry Andricdef SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src1), 2100b57cec5SDimitry Andric "sar{w}\t{%cl, $dst|$dst, cl}", 2110b57cec5SDimitry Andric [(set GR16:$dst, (sra GR16:$src1, CL))]>, 2120b57cec5SDimitry Andric OpSize16; 2130b57cec5SDimitry Andricdef SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src1), 2140b57cec5SDimitry Andric "sar{l}\t{%cl, $dst|$dst, cl}", 2150b57cec5SDimitry Andric [(set GR32:$dst, (sra GR32:$src1, CL))]>, 2160b57cec5SDimitry Andric OpSize32; 2170b57cec5SDimitry Andricdef SAR64rCL : RI<0xD3, MRM7r, (outs GR64:$dst), (ins GR64:$src1), 2180b57cec5SDimitry Andric "sar{q}\t{%cl, $dst|$dst, cl}", 2190b57cec5SDimitry Andric [(set GR64:$dst, (sra GR64:$src1, CL))]>; 220bdd1243dSDimitry Andric} // Uses, SchedRW 2210b57cec5SDimitry Andric 222bdd1243dSDimitry Andriclet SchedRW = [WriteShift] in { 2230b57cec5SDimitry Andricdef SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, u8imm:$src2), 2240b57cec5SDimitry Andric "sar{b}\t{$src2, $dst|$dst, $src2}", 2250b57cec5SDimitry Andric [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>; 2260b57cec5SDimitry Andricdef SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, u8imm:$src2), 2270b57cec5SDimitry Andric "sar{w}\t{$src2, $dst|$dst, $src2}", 2280b57cec5SDimitry Andric [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>, 2290b57cec5SDimitry Andric OpSize16; 2300b57cec5SDimitry Andricdef SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, u8imm:$src2), 2310b57cec5SDimitry Andric "sar{l}\t{$src2, $dst|$dst, $src2}", 2320b57cec5SDimitry Andric [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>, 2330b57cec5SDimitry Andric OpSize32; 2340b57cec5SDimitry Andricdef SAR64ri : RIi8<0xC1, MRM7r, (outs GR64:$dst), 2350b57cec5SDimitry Andric (ins GR64:$src1, u8imm:$src2), 2360b57cec5SDimitry Andric "sar{q}\t{$src2, $dst|$dst, $src2}", 2370b57cec5SDimitry Andric [(set GR64:$dst, (sra GR64:$src1, (i8 imm:$src2)))]>; 2380b57cec5SDimitry Andric 2390b57cec5SDimitry Andric// Shift by 1 2400b57cec5SDimitry Andricdef SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1), 24106c3fb27SDimitry Andric "sar{b}\t$dst", []>; 2420b57cec5SDimitry Andricdef SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1), 24306c3fb27SDimitry Andric "sar{w}\t$dst", []>, OpSize16; 2440b57cec5SDimitry Andricdef SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1), 24506c3fb27SDimitry Andric "sar{l}\t$dst", []>, OpSize32; 2460b57cec5SDimitry Andricdef SAR64r1 : RI<0xD1, MRM7r, (outs GR64:$dst), (ins GR64:$src1), 24706c3fb27SDimitry Andric "sar{q}\t$dst", []>; 248bdd1243dSDimitry Andric} // SchedRW 249bdd1243dSDimitry Andric} // Constraints = "$src = $dst" 2500b57cec5SDimitry Andric 2510b57cec5SDimitry Andric 2520b57cec5SDimitry Andriclet Uses = [CL], SchedRW = [WriteShiftCLLd, WriteRMW] in { 2530b57cec5SDimitry Andricdef SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst), 2540b57cec5SDimitry Andric "sar{b}\t{%cl, $dst|$dst, cl}", 2550b57cec5SDimitry Andric [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>; 2560b57cec5SDimitry Andricdef SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst), 2570b57cec5SDimitry Andric "sar{w}\t{%cl, $dst|$dst, cl}", 2580b57cec5SDimitry Andric [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, 2590b57cec5SDimitry Andric OpSize16; 2600b57cec5SDimitry Andricdef SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst), 2610b57cec5SDimitry Andric "sar{l}\t{%cl, $dst|$dst, cl}", 2620b57cec5SDimitry Andric [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>, 2630b57cec5SDimitry Andric OpSize32; 2640b57cec5SDimitry Andricdef SAR64mCL : RI<0xD3, MRM7m, (outs), (ins i64mem:$dst), 2650b57cec5SDimitry Andric "sar{q}\t{%cl, $dst|$dst, cl}", 2660b57cec5SDimitry Andric [(store (sra (loadi64 addr:$dst), CL), addr:$dst)]>, 2670b57cec5SDimitry Andric Requires<[In64BitMode]>; 268bdd1243dSDimitry Andric} // Uses, SchedRW 2690b57cec5SDimitry Andric 27006c3fb27SDimitry Andriclet SchedRW = [WriteShiftLd, WriteRMW], mayLoad = 1, mayStore = 1 in { 2710b57cec5SDimitry Andricdef SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, u8imm:$src), 2720b57cec5SDimitry Andric "sar{b}\t{$src, $dst|$dst, $src}", 2730b57cec5SDimitry Andric [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>; 2740b57cec5SDimitry Andricdef SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, u8imm:$src), 2750b57cec5SDimitry Andric "sar{w}\t{$src, $dst|$dst, $src}", 2760b57cec5SDimitry Andric [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>, 2770b57cec5SDimitry Andric OpSize16; 2780b57cec5SDimitry Andricdef SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, u8imm:$src), 2790b57cec5SDimitry Andric "sar{l}\t{$src, $dst|$dst, $src}", 2800b57cec5SDimitry Andric [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>, 2810b57cec5SDimitry Andric OpSize32; 2820b57cec5SDimitry Andricdef SAR64mi : RIi8<0xC1, MRM7m, (outs), (ins i64mem:$dst, u8imm:$src), 2830b57cec5SDimitry Andric "sar{q}\t{$src, $dst|$dst, $src}", 2840b57cec5SDimitry Andric [(store (sra (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>, 2850b57cec5SDimitry Andric Requires<[In64BitMode]>; 2860b57cec5SDimitry Andric 2870b57cec5SDimitry Andric// Shift by 1 2880b57cec5SDimitry Andricdef SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst), 28906c3fb27SDimitry Andric "sar{b}\t$dst", []>; 2900b57cec5SDimitry Andricdef SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst), 29106c3fb27SDimitry Andric "sar{w}\t$dst", []>, OpSize16; 2920b57cec5SDimitry Andricdef SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst), 29306c3fb27SDimitry Andric "sar{l}\t$dst", []>, OpSize32; 2940b57cec5SDimitry Andricdef SAR64m1 : RI<0xD1, MRM7m, (outs), (ins i64mem:$dst), 29506c3fb27SDimitry Andric "sar{q}\t$dst", []>, Requires<[In64BitMode]>; 2960b57cec5SDimitry Andric} // SchedRW 2970b57cec5SDimitry Andric 2980b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 2990b57cec5SDimitry Andric// Rotate instructions 3000b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 3010b57cec5SDimitry Andric 302bdd1243dSDimitry Andriclet Constraints = "$src1 = $dst" in { 3030b57cec5SDimitry Andric 3040b57cec5SDimitry Andriclet Uses = [CL, EFLAGS], SchedRW = [WriteRotateCL] in { 3050b57cec5SDimitry Andricdef RCL8rCL : I<0xD2, MRM2r, (outs GR8:$dst), (ins GR8:$src1), 3060b57cec5SDimitry Andric "rcl{b}\t{%cl, $dst|$dst, cl}", []>; 3070b57cec5SDimitry Andricdef RCL16rCL : I<0xD3, MRM2r, (outs GR16:$dst), (ins GR16:$src1), 3080b57cec5SDimitry Andric "rcl{w}\t{%cl, $dst|$dst, cl}", []>, OpSize16; 3090b57cec5SDimitry Andricdef RCL32rCL : I<0xD3, MRM2r, (outs GR32:$dst), (ins GR32:$src1), 3100b57cec5SDimitry Andric "rcl{l}\t{%cl, $dst|$dst, cl}", []>, OpSize32; 3110b57cec5SDimitry Andricdef RCL64rCL : RI<0xD3, MRM2r, (outs GR64:$dst), (ins GR64:$src1), 3120b57cec5SDimitry Andric "rcl{q}\t{%cl, $dst|$dst, cl}", []>; 313bdd1243dSDimitry Andric} // Uses = [CL, EFLAGS], SchedRW 3140b57cec5SDimitry Andric 315bdd1243dSDimitry Andriclet Uses = [EFLAGS], SchedRW = [WriteRotate] in { 3160b57cec5SDimitry Andricdef RCL8r1 : I<0xD0, MRM2r, (outs GR8:$dst), (ins GR8:$src1), 3170b57cec5SDimitry Andric "rcl{b}\t$dst", []>; 3180b57cec5SDimitry Andricdef RCL8ri : Ii8<0xC0, MRM2r, (outs GR8:$dst), (ins GR8:$src1, u8imm:$cnt), 3190b57cec5SDimitry Andric "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>; 3200b57cec5SDimitry Andricdef RCL16r1 : I<0xD1, MRM2r, (outs GR16:$dst), (ins GR16:$src1), 3210b57cec5SDimitry Andric "rcl{w}\t$dst", []>, OpSize16; 3220b57cec5SDimitry Andricdef RCL16ri : Ii8<0xC1, MRM2r, (outs GR16:$dst), (ins GR16:$src1, u8imm:$cnt), 3230b57cec5SDimitry Andric "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize16; 3240b57cec5SDimitry Andricdef RCL32r1 : I<0xD1, MRM2r, (outs GR32:$dst), (ins GR32:$src1), 3250b57cec5SDimitry Andric "rcl{l}\t$dst", []>, OpSize32; 3260b57cec5SDimitry Andricdef RCL32ri : Ii8<0xC1, MRM2r, (outs GR32:$dst), (ins GR32:$src1, u8imm:$cnt), 3270b57cec5SDimitry Andric "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize32; 3280b57cec5SDimitry Andricdef RCL64r1 : RI<0xD1, MRM2r, (outs GR64:$dst), (ins GR64:$src1), 3290b57cec5SDimitry Andric "rcl{q}\t$dst", []>; 3300b57cec5SDimitry Andricdef RCL64ri : RIi8<0xC1, MRM2r, (outs GR64:$dst), (ins GR64:$src1, u8imm:$cnt), 3310b57cec5SDimitry Andric "rcl{q}\t{$cnt, $dst|$dst, $cnt}", []>; 332bdd1243dSDimitry Andric} // Uses = [EFLAGS], SchedRW 3330b57cec5SDimitry Andric 3340b57cec5SDimitry Andriclet Uses = [CL, EFLAGS], SchedRW = [WriteRotateCL] in { 3350b57cec5SDimitry Andricdef RCR8rCL : I<0xD2, MRM3r, (outs GR8:$dst), (ins GR8:$src1), 3360b57cec5SDimitry Andric "rcr{b}\t{%cl, $dst|$dst, cl}", []>; 3370b57cec5SDimitry Andricdef RCR16rCL : I<0xD3, MRM3r, (outs GR16:$dst), (ins GR16:$src1), 3380b57cec5SDimitry Andric "rcr{w}\t{%cl, $dst|$dst, cl}", []>, OpSize16; 3390b57cec5SDimitry Andricdef RCR32rCL : I<0xD3, MRM3r, (outs GR32:$dst), (ins GR32:$src1), 3400b57cec5SDimitry Andric "rcr{l}\t{%cl, $dst|$dst, cl}", []>, OpSize32; 3410b57cec5SDimitry Andricdef RCR64rCL : RI<0xD3, MRM3r, (outs GR64:$dst), (ins GR64:$src1), 3420b57cec5SDimitry Andric "rcr{q}\t{%cl, $dst|$dst, cl}", []>; 343bdd1243dSDimitry Andric} // Uses = [CL, EFLAGS], SchedRW 3440b57cec5SDimitry Andric 345bdd1243dSDimitry Andriclet Uses = [EFLAGS], SchedRW = [WriteRotate] in { 3460b57cec5SDimitry Andricdef RCR8r1 : I<0xD0, MRM3r, (outs GR8:$dst), (ins GR8:$src1), 3470b57cec5SDimitry Andric "rcr{b}\t$dst", []>; 3480b57cec5SDimitry Andricdef RCR8ri : Ii8<0xC0, MRM3r, (outs GR8:$dst), (ins GR8:$src1, u8imm:$cnt), 3490b57cec5SDimitry Andric "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>; 3500b57cec5SDimitry Andricdef RCR16r1 : I<0xD1, MRM3r, (outs GR16:$dst), (ins GR16:$src1), 3510b57cec5SDimitry Andric "rcr{w}\t$dst", []>, OpSize16; 3520b57cec5SDimitry Andricdef RCR16ri : Ii8<0xC1, MRM3r, (outs GR16:$dst), (ins GR16:$src1, u8imm:$cnt), 3530b57cec5SDimitry Andric "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize16; 3540b57cec5SDimitry Andricdef RCR32r1 : I<0xD1, MRM3r, (outs GR32:$dst), (ins GR32:$src1), 3550b57cec5SDimitry Andric "rcr{l}\t$dst", []>, OpSize32; 3560b57cec5SDimitry Andricdef RCR32ri : Ii8<0xC1, MRM3r, (outs GR32:$dst), (ins GR32:$src1, u8imm:$cnt), 3570b57cec5SDimitry Andric "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize32; 3580b57cec5SDimitry Andricdef RCR64r1 : RI<0xD1, MRM3r, (outs GR64:$dst), (ins GR64:$src1), 3590b57cec5SDimitry Andric "rcr{q}\t$dst", []>; 3600b57cec5SDimitry Andricdef RCR64ri : RIi8<0xC1, MRM3r, (outs GR64:$dst), (ins GR64:$src1, u8imm:$cnt), 3610b57cec5SDimitry Andric "rcr{q}\t{$cnt, $dst|$dst, $cnt}", []>; 362bdd1243dSDimitry Andric} // Uses = [EFLAGS], SchedRW 3630b57cec5SDimitry Andric} // Constraints = "$src = $dst" 3640b57cec5SDimitry Andric 36506c3fb27SDimitry Andriclet mayLoad = 1, mayStore = 1 in { 366bdd1243dSDimitry Andriclet Uses = [EFLAGS], SchedRW = [WriteRotateLd, WriteRMW] in { 3670b57cec5SDimitry Andricdef RCL8m1 : I<0xD0, MRM2m, (outs), (ins i8mem:$dst), 3680b57cec5SDimitry Andric "rcl{b}\t$dst", []>; 3690b57cec5SDimitry Andricdef RCL8mi : Ii8<0xC0, MRM2m, (outs), (ins i8mem:$dst, u8imm:$cnt), 3700b57cec5SDimitry Andric "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>; 3710b57cec5SDimitry Andricdef RCL16m1 : I<0xD1, MRM2m, (outs), (ins i16mem:$dst), 3720b57cec5SDimitry Andric "rcl{w}\t$dst", []>, OpSize16; 3730b57cec5SDimitry Andricdef RCL16mi : Ii8<0xC1, MRM2m, (outs), (ins i16mem:$dst, u8imm:$cnt), 3740b57cec5SDimitry Andric "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize16; 3750b57cec5SDimitry Andricdef RCL32m1 : I<0xD1, MRM2m, (outs), (ins i32mem:$dst), 3760b57cec5SDimitry Andric "rcl{l}\t$dst", []>, OpSize32; 3770b57cec5SDimitry Andricdef RCL32mi : Ii8<0xC1, MRM2m, (outs), (ins i32mem:$dst, u8imm:$cnt), 3780b57cec5SDimitry Andric "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize32; 3790b57cec5SDimitry Andricdef RCL64m1 : RI<0xD1, MRM2m, (outs), (ins i64mem:$dst), 3800b57cec5SDimitry Andric "rcl{q}\t$dst", []>, Requires<[In64BitMode]>; 3810b57cec5SDimitry Andricdef RCL64mi : RIi8<0xC1, MRM2m, (outs), (ins i64mem:$dst, u8imm:$cnt), 3820b57cec5SDimitry Andric "rcl{q}\t{$cnt, $dst|$dst, $cnt}", []>, 3830b57cec5SDimitry Andric Requires<[In64BitMode]>; 3840b57cec5SDimitry Andric 3850b57cec5SDimitry Andricdef RCR8m1 : I<0xD0, MRM3m, (outs), (ins i8mem:$dst), 3860b57cec5SDimitry Andric "rcr{b}\t$dst", []>; 3870b57cec5SDimitry Andricdef RCR8mi : Ii8<0xC0, MRM3m, (outs), (ins i8mem:$dst, u8imm:$cnt), 3880b57cec5SDimitry Andric "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>; 3890b57cec5SDimitry Andricdef RCR16m1 : I<0xD1, MRM3m, (outs), (ins i16mem:$dst), 3900b57cec5SDimitry Andric "rcr{w}\t$dst", []>, OpSize16; 3910b57cec5SDimitry Andricdef RCR16mi : Ii8<0xC1, MRM3m, (outs), (ins i16mem:$dst, u8imm:$cnt), 3920b57cec5SDimitry Andric "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize16; 3930b57cec5SDimitry Andricdef RCR32m1 : I<0xD1, MRM3m, (outs), (ins i32mem:$dst), 3940b57cec5SDimitry Andric "rcr{l}\t$dst", []>, OpSize32; 3950b57cec5SDimitry Andricdef RCR32mi : Ii8<0xC1, MRM3m, (outs), (ins i32mem:$dst, u8imm:$cnt), 3960b57cec5SDimitry Andric "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize32; 3970b57cec5SDimitry Andricdef RCR64m1 : RI<0xD1, MRM3m, (outs), (ins i64mem:$dst), 3980b57cec5SDimitry Andric "rcr{q}\t$dst", []>, Requires<[In64BitMode]>; 3990b57cec5SDimitry Andricdef RCR64mi : RIi8<0xC1, MRM3m, (outs), (ins i64mem:$dst, u8imm:$cnt), 4000b57cec5SDimitry Andric "rcr{q}\t{$cnt, $dst|$dst, $cnt}", []>, 4010b57cec5SDimitry Andric Requires<[In64BitMode]>; 402bdd1243dSDimitry Andric} // Uses = [EFLAGS], SchedRW 4030b57cec5SDimitry Andric 4040b57cec5SDimitry Andriclet Uses = [CL, EFLAGS], SchedRW = [WriteRotateCLLd, WriteRMW] in { 4050b57cec5SDimitry Andricdef RCL8mCL : I<0xD2, MRM2m, (outs), (ins i8mem:$dst), 4060b57cec5SDimitry Andric "rcl{b}\t{%cl, $dst|$dst, cl}", []>; 4070b57cec5SDimitry Andricdef RCL16mCL : I<0xD3, MRM2m, (outs), (ins i16mem:$dst), 4080b57cec5SDimitry Andric "rcl{w}\t{%cl, $dst|$dst, cl}", []>, OpSize16; 4090b57cec5SDimitry Andricdef RCL32mCL : I<0xD3, MRM2m, (outs), (ins i32mem:$dst), 4100b57cec5SDimitry Andric "rcl{l}\t{%cl, $dst|$dst, cl}", []>, OpSize32; 4110b57cec5SDimitry Andricdef RCL64mCL : RI<0xD3, MRM2m, (outs), (ins i64mem:$dst), 4120b57cec5SDimitry Andric "rcl{q}\t{%cl, $dst|$dst, cl}", []>, 4130b57cec5SDimitry Andric Requires<[In64BitMode]>; 4140b57cec5SDimitry Andric 4150b57cec5SDimitry Andricdef RCR8mCL : I<0xD2, MRM3m, (outs), (ins i8mem:$dst), 4160b57cec5SDimitry Andric "rcr{b}\t{%cl, $dst|$dst, cl}", []>; 4170b57cec5SDimitry Andricdef RCR16mCL : I<0xD3, MRM3m, (outs), (ins i16mem:$dst), 4180b57cec5SDimitry Andric "rcr{w}\t{%cl, $dst|$dst, cl}", []>, OpSize16; 4190b57cec5SDimitry Andricdef RCR32mCL : I<0xD3, MRM3m, (outs), (ins i32mem:$dst), 4200b57cec5SDimitry Andric "rcr{l}\t{%cl, $dst|$dst, cl}", []>, OpSize32; 4210b57cec5SDimitry Andricdef RCR64mCL : RI<0xD3, MRM3m, (outs), (ins i64mem:$dst), 4220b57cec5SDimitry Andric "rcr{q}\t{%cl, $dst|$dst, cl}", []>, 4230b57cec5SDimitry Andric Requires<[In64BitMode]>; 424bdd1243dSDimitry Andric} // Uses = [CL, EFLAGS], SchedRW 42506c3fb27SDimitry Andric} // mayLoad, mayStore 4260b57cec5SDimitry Andric 427bdd1243dSDimitry Andriclet Constraints = "$src1 = $dst" in { 4280b57cec5SDimitry Andric// FIXME: provide shorter instructions when imm8 == 1 4290b57cec5SDimitry Andriclet Uses = [CL], SchedRW = [WriteRotateCL] in { 4300b57cec5SDimitry Andricdef ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1), 4310b57cec5SDimitry Andric "rol{b}\t{%cl, $dst|$dst, cl}", 4320b57cec5SDimitry Andric [(set GR8:$dst, (rotl GR8:$src1, CL))]>; 4330b57cec5SDimitry Andricdef ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src1), 4340b57cec5SDimitry Andric "rol{w}\t{%cl, $dst|$dst, cl}", 4350b57cec5SDimitry Andric [(set GR16:$dst, (rotl GR16:$src1, CL))]>, OpSize16; 4360b57cec5SDimitry Andricdef ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src1), 4370b57cec5SDimitry Andric "rol{l}\t{%cl, $dst|$dst, cl}", 4380b57cec5SDimitry Andric [(set GR32:$dst, (rotl GR32:$src1, CL))]>, OpSize32; 4390b57cec5SDimitry Andricdef ROL64rCL : RI<0xD3, MRM0r, (outs GR64:$dst), (ins GR64:$src1), 4400b57cec5SDimitry Andric "rol{q}\t{%cl, $dst|$dst, cl}", 4410b57cec5SDimitry Andric [(set GR64:$dst, (rotl GR64:$src1, CL))]>; 442bdd1243dSDimitry Andric} // Uses, SchedRW 4430b57cec5SDimitry Andric 444bdd1243dSDimitry Andriclet SchedRW = [WriteRotate] in { 4450b57cec5SDimitry Andricdef ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, u8imm:$src2), 4460b57cec5SDimitry Andric "rol{b}\t{$src2, $dst|$dst, $src2}", 4475ffd83dbSDimitry Andric [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>; 4480b57cec5SDimitry Andricdef ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, u8imm:$src2), 4490b57cec5SDimitry Andric "rol{w}\t{$src2, $dst|$dst, $src2}", 4505ffd83dbSDimitry Andric [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, 4510b57cec5SDimitry Andric OpSize16; 4520b57cec5SDimitry Andricdef ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, u8imm:$src2), 4530b57cec5SDimitry Andric "rol{l}\t{$src2, $dst|$dst, $src2}", 4545ffd83dbSDimitry Andric [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>, 4550b57cec5SDimitry Andric OpSize32; 4560b57cec5SDimitry Andricdef ROL64ri : RIi8<0xC1, MRM0r, (outs GR64:$dst), 4570b57cec5SDimitry Andric (ins GR64:$src1, u8imm:$src2), 4580b57cec5SDimitry Andric "rol{q}\t{$src2, $dst|$dst, $src2}", 4595ffd83dbSDimitry Andric [(set GR64:$dst, (rotl GR64:$src1, (i8 imm:$src2)))]>; 4600b57cec5SDimitry Andric 4610b57cec5SDimitry Andric// Rotate by 1 4620b57cec5SDimitry Andricdef ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1), 46306c3fb27SDimitry Andric "rol{b}\t$dst", []>; 4640b57cec5SDimitry Andricdef ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1), 46506c3fb27SDimitry Andric "rol{w}\t$dst", []>, OpSize16; 4660b57cec5SDimitry Andricdef ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1), 46706c3fb27SDimitry Andric "rol{l}\t$dst", []>, OpSize32; 4680b57cec5SDimitry Andricdef ROL64r1 : RI<0xD1, MRM0r, (outs GR64:$dst), (ins GR64:$src1), 46906c3fb27SDimitry Andric "rol{q}\t$dst", []>; 470bdd1243dSDimitry Andric} // SchedRW 471bdd1243dSDimitry Andric} // Constraints = "$src = $dst" 4720b57cec5SDimitry Andric 4730b57cec5SDimitry Andriclet Uses = [CL], SchedRW = [WriteRotateCLLd, WriteRMW] in { 4740b57cec5SDimitry Andricdef ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst), 4750b57cec5SDimitry Andric "rol{b}\t{%cl, $dst|$dst, cl}", 4760b57cec5SDimitry Andric [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>; 4770b57cec5SDimitry Andricdef ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst), 4780b57cec5SDimitry Andric "rol{w}\t{%cl, $dst|$dst, cl}", 4790b57cec5SDimitry Andric [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize16; 4800b57cec5SDimitry Andricdef ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst), 4810b57cec5SDimitry Andric "rol{l}\t{%cl, $dst|$dst, cl}", 4820b57cec5SDimitry Andric [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>, OpSize32; 4830b57cec5SDimitry Andricdef ROL64mCL : RI<0xD3, MRM0m, (outs), (ins i64mem:$dst), 4840b57cec5SDimitry Andric "rol{q}\t{%cl, $dst|$dst, cl}", 4850b57cec5SDimitry Andric [(store (rotl (loadi64 addr:$dst), CL), addr:$dst)]>, 4860b57cec5SDimitry Andric Requires<[In64BitMode]>; 487bdd1243dSDimitry Andric} // Uses, SchedRW 4880b57cec5SDimitry Andric 48906c3fb27SDimitry Andriclet SchedRW = [WriteRotateLd, WriteRMW], mayLoad = 1, mayStore = 1 in { 4900b57cec5SDimitry Andricdef ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, u8imm:$src1), 4910b57cec5SDimitry Andric "rol{b}\t{$src1, $dst|$dst, $src1}", 4920b57cec5SDimitry Andric [(store (rotl (loadi8 addr:$dst), (i8 imm:$src1)), addr:$dst)]>; 4930b57cec5SDimitry Andricdef ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, u8imm:$src1), 4940b57cec5SDimitry Andric "rol{w}\t{$src1, $dst|$dst, $src1}", 4950b57cec5SDimitry Andric [(store (rotl (loadi16 addr:$dst), (i8 imm:$src1)), addr:$dst)]>, 4960b57cec5SDimitry Andric OpSize16; 4970b57cec5SDimitry Andricdef ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, u8imm:$src1), 4980b57cec5SDimitry Andric "rol{l}\t{$src1, $dst|$dst, $src1}", 4990b57cec5SDimitry Andric [(store (rotl (loadi32 addr:$dst), (i8 imm:$src1)), addr:$dst)]>, 5000b57cec5SDimitry Andric OpSize32; 5010b57cec5SDimitry Andricdef ROL64mi : RIi8<0xC1, MRM0m, (outs), (ins i64mem:$dst, u8imm:$src1), 5020b57cec5SDimitry Andric "rol{q}\t{$src1, $dst|$dst, $src1}", 5030b57cec5SDimitry Andric [(store (rotl (loadi64 addr:$dst), (i8 imm:$src1)), addr:$dst)]>, 5040b57cec5SDimitry Andric Requires<[In64BitMode]>; 5050b57cec5SDimitry Andric 5060b57cec5SDimitry Andric// Rotate by 1 5070b57cec5SDimitry Andricdef ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst), 50806c3fb27SDimitry Andric "rol{b}\t$dst", []>; 5090b57cec5SDimitry Andricdef ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst), 51006c3fb27SDimitry Andric "rol{w}\t$dst", []>, OpSize16; 5110b57cec5SDimitry Andricdef ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst), 51206c3fb27SDimitry Andric "rol{l}\t$dst", []>, OpSize32; 5130b57cec5SDimitry Andricdef ROL64m1 : RI<0xD1, MRM0m, (outs), (ins i64mem:$dst), 51406c3fb27SDimitry Andric "rol{q}\t$dst", []>, Requires<[In64BitMode]>; 51506c3fb27SDimitry Andric} // SchedRW, mayLoad, mayStore 5160b57cec5SDimitry Andric 517bdd1243dSDimitry Andriclet Constraints = "$src1 = $dst" in { 5180b57cec5SDimitry Andriclet Uses = [CL], SchedRW = [WriteRotateCL] in { 5190b57cec5SDimitry Andricdef ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1), 5200b57cec5SDimitry Andric "ror{b}\t{%cl, $dst|$dst, cl}", 5210b57cec5SDimitry Andric [(set GR8:$dst, (rotr GR8:$src1, CL))]>; 5220b57cec5SDimitry Andricdef ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src1), 5230b57cec5SDimitry Andric "ror{w}\t{%cl, $dst|$dst, cl}", 5240b57cec5SDimitry Andric [(set GR16:$dst, (rotr GR16:$src1, CL))]>, OpSize16; 5250b57cec5SDimitry Andricdef ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src1), 5260b57cec5SDimitry Andric "ror{l}\t{%cl, $dst|$dst, cl}", 5270b57cec5SDimitry Andric [(set GR32:$dst, (rotr GR32:$src1, CL))]>, OpSize32; 5280b57cec5SDimitry Andricdef ROR64rCL : RI<0xD3, MRM1r, (outs GR64:$dst), (ins GR64:$src1), 5290b57cec5SDimitry Andric "ror{q}\t{%cl, $dst|$dst, cl}", 5300b57cec5SDimitry Andric [(set GR64:$dst, (rotr GR64:$src1, CL))]>; 5310b57cec5SDimitry Andric} 5320b57cec5SDimitry Andric 533bdd1243dSDimitry Andriclet SchedRW = [WriteRotate] in { 5340b57cec5SDimitry Andricdef ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, u8imm:$src2), 5350b57cec5SDimitry Andric "ror{b}\t{$src2, $dst|$dst, $src2}", 5365ffd83dbSDimitry Andric [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>; 5370b57cec5SDimitry Andricdef ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, u8imm:$src2), 5380b57cec5SDimitry Andric "ror{w}\t{$src2, $dst|$dst, $src2}", 5395ffd83dbSDimitry Andric [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, 5400b57cec5SDimitry Andric OpSize16; 5410b57cec5SDimitry Andricdef ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, u8imm:$src2), 5420b57cec5SDimitry Andric "ror{l}\t{$src2, $dst|$dst, $src2}", 5435ffd83dbSDimitry Andric [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>, 5440b57cec5SDimitry Andric OpSize32; 5450b57cec5SDimitry Andricdef ROR64ri : RIi8<0xC1, MRM1r, (outs GR64:$dst), 5460b57cec5SDimitry Andric (ins GR64:$src1, u8imm:$src2), 5470b57cec5SDimitry Andric "ror{q}\t{$src2, $dst|$dst, $src2}", 5485ffd83dbSDimitry Andric [(set GR64:$dst, (rotr GR64:$src1, (i8 imm:$src2)))]>; 5490b57cec5SDimitry Andric 5500b57cec5SDimitry Andric// Rotate by 1 5510b57cec5SDimitry Andricdef ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1), 55206c3fb27SDimitry Andric "ror{b}\t$dst", []>; 5530b57cec5SDimitry Andricdef ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1), 55406c3fb27SDimitry Andric "ror{w}\t$dst", []>, OpSize16; 5550b57cec5SDimitry Andricdef ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1), 55606c3fb27SDimitry Andric "ror{l}\t$dst", []>, OpSize32; 5570b57cec5SDimitry Andricdef ROR64r1 : RI<0xD1, MRM1r, (outs GR64:$dst), (ins GR64:$src1), 55806c3fb27SDimitry Andric "ror{q}\t$dst", []>; 559bdd1243dSDimitry Andric} // SchedRW 5600b57cec5SDimitry Andric} // Constraints = "$src = $dst", SchedRW 5610b57cec5SDimitry Andric 5620b57cec5SDimitry Andriclet Uses = [CL], SchedRW = [WriteRotateCLLd, WriteRMW] in { 5630b57cec5SDimitry Andricdef ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst), 5640b57cec5SDimitry Andric "ror{b}\t{%cl, $dst|$dst, cl}", 5650b57cec5SDimitry Andric [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>; 5660b57cec5SDimitry Andricdef ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst), 5670b57cec5SDimitry Andric "ror{w}\t{%cl, $dst|$dst, cl}", 5680b57cec5SDimitry Andric [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize16; 5690b57cec5SDimitry Andricdef ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst), 5700b57cec5SDimitry Andric "ror{l}\t{%cl, $dst|$dst, cl}", 5710b57cec5SDimitry Andric [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>, OpSize32; 5720b57cec5SDimitry Andricdef ROR64mCL : RI<0xD3, MRM1m, (outs), (ins i64mem:$dst), 5730b57cec5SDimitry Andric "ror{q}\t{%cl, $dst|$dst, cl}", 5740b57cec5SDimitry Andric [(store (rotr (loadi64 addr:$dst), CL), addr:$dst)]>, 5750b57cec5SDimitry Andric Requires<[In64BitMode]>; 576bdd1243dSDimitry Andric} // Uses, SchedRW 5770b57cec5SDimitry Andric 57806c3fb27SDimitry Andriclet SchedRW = [WriteRotateLd, WriteRMW], mayLoad = 1, mayStore =1 in { 5790b57cec5SDimitry Andricdef ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, u8imm:$src), 5800b57cec5SDimitry Andric "ror{b}\t{$src, $dst|$dst, $src}", 5810b57cec5SDimitry Andric [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>; 5820b57cec5SDimitry Andricdef ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, u8imm:$src), 5830b57cec5SDimitry Andric "ror{w}\t{$src, $dst|$dst, $src}", 5840b57cec5SDimitry Andric [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>, 5850b57cec5SDimitry Andric OpSize16; 5860b57cec5SDimitry Andricdef ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, u8imm:$src), 5870b57cec5SDimitry Andric "ror{l}\t{$src, $dst|$dst, $src}", 5880b57cec5SDimitry Andric [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>, 5890b57cec5SDimitry Andric OpSize32; 5900b57cec5SDimitry Andricdef ROR64mi : RIi8<0xC1, MRM1m, (outs), (ins i64mem:$dst, u8imm:$src), 5910b57cec5SDimitry Andric "ror{q}\t{$src, $dst|$dst, $src}", 5920b57cec5SDimitry Andric [(store (rotr (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>, 5930b57cec5SDimitry Andric Requires<[In64BitMode]>; 5940b57cec5SDimitry Andric 5950b57cec5SDimitry Andric// Rotate by 1 5960b57cec5SDimitry Andricdef ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst), 59706c3fb27SDimitry Andric "ror{b}\t$dst", []>; 5980b57cec5SDimitry Andricdef ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst), 59906c3fb27SDimitry Andric "ror{w}\t$dst", []>, OpSize16; 6000b57cec5SDimitry Andricdef ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst), 60106c3fb27SDimitry Andric "ror{l}\t$dst", []>, 6020b57cec5SDimitry Andric OpSize32; 6030b57cec5SDimitry Andricdef ROR64m1 : RI<0xD1, MRM1m, (outs), (ins i64mem:$dst), 60406c3fb27SDimitry Andric "ror{q}\t$dst", []>, Requires<[In64BitMode]>; 60506c3fb27SDimitry Andric} // SchedRW, mayLoad, mayStore 6060b57cec5SDimitry Andric 6070b57cec5SDimitry Andric 6080b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 6090b57cec5SDimitry Andric// Double shift instructions (generalizations of rotate) 6100b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 6110b57cec5SDimitry Andric 6120b57cec5SDimitry Andriclet Constraints = "$src1 = $dst" in { 6130b57cec5SDimitry Andric 6140b57cec5SDimitry Andriclet Uses = [CL], SchedRW = [WriteSHDrrcl] in { 6150b57cec5SDimitry Andricdef SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), 6160b57cec5SDimitry Andric (ins GR16:$src1, GR16:$src2), 6170b57cec5SDimitry Andric "shld{w}\t{%cl, $src2, $dst|$dst, $src2, cl}", 6185ffd83dbSDimitry Andric [(set GR16:$dst, (X86fshl GR16:$src1, GR16:$src2, CL))]>, 6190b57cec5SDimitry Andric TB, OpSize16; 6200b57cec5SDimitry Andricdef SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), 6210b57cec5SDimitry Andric (ins GR16:$src1, GR16:$src2), 6220b57cec5SDimitry Andric "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, cl}", 6235ffd83dbSDimitry Andric [(set GR16:$dst, (X86fshr GR16:$src2, GR16:$src1, CL))]>, 6240b57cec5SDimitry Andric TB, OpSize16; 6250b57cec5SDimitry Andricdef SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), 6260b57cec5SDimitry Andric (ins GR32:$src1, GR32:$src2), 6270b57cec5SDimitry Andric "shld{l}\t{%cl, $src2, $dst|$dst, $src2, cl}", 6285ffd83dbSDimitry Andric [(set GR32:$dst, (fshl GR32:$src1, GR32:$src2, CL))]>, 6290b57cec5SDimitry Andric TB, OpSize32; 6300b57cec5SDimitry Andricdef SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), 6310b57cec5SDimitry Andric (ins GR32:$src1, GR32:$src2), 6320b57cec5SDimitry Andric "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, cl}", 6335ffd83dbSDimitry Andric [(set GR32:$dst, (fshr GR32:$src2, GR32:$src1, CL))]>, 6340b57cec5SDimitry Andric TB, OpSize32; 6350b57cec5SDimitry Andricdef SHLD64rrCL : RI<0xA5, MRMDestReg, (outs GR64:$dst), 6360b57cec5SDimitry Andric (ins GR64:$src1, GR64:$src2), 6370b57cec5SDimitry Andric "shld{q}\t{%cl, $src2, $dst|$dst, $src2, cl}", 6385ffd83dbSDimitry Andric [(set GR64:$dst, (fshl GR64:$src1, GR64:$src2, CL))]>, 6390b57cec5SDimitry Andric TB; 6400b57cec5SDimitry Andricdef SHRD64rrCL : RI<0xAD, MRMDestReg, (outs GR64:$dst), 6410b57cec5SDimitry Andric (ins GR64:$src1, GR64:$src2), 6420b57cec5SDimitry Andric "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, cl}", 6435ffd83dbSDimitry Andric [(set GR64:$dst, (fshr GR64:$src2, GR64:$src1, CL))]>, 6440b57cec5SDimitry Andric TB; 645bdd1243dSDimitry Andric} // Uses, SchedRW 6460b57cec5SDimitry Andric 6470b57cec5SDimitry Andriclet isCommutable = 1, SchedRW = [WriteSHDrri] in { // These instructions commute to each other. 6480b57cec5SDimitry Andricdef SHLD16rri8 : Ii8<0xA4, MRMDestReg, 6490b57cec5SDimitry Andric (outs GR16:$dst), 6500b57cec5SDimitry Andric (ins GR16:$src1, GR16:$src2, u8imm:$src3), 6510b57cec5SDimitry Andric "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}", 6525ffd83dbSDimitry Andric [(set GR16:$dst, (X86fshl GR16:$src1, GR16:$src2, 6530b57cec5SDimitry Andric (i8 imm:$src3)))]>, 6540b57cec5SDimitry Andric TB, OpSize16; 6550b57cec5SDimitry Andricdef SHRD16rri8 : Ii8<0xAC, MRMDestReg, 6560b57cec5SDimitry Andric (outs GR16:$dst), 6570b57cec5SDimitry Andric (ins GR16:$src1, GR16:$src2, u8imm:$src3), 6580b57cec5SDimitry Andric "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}", 6595ffd83dbSDimitry Andric [(set GR16:$dst, (X86fshr GR16:$src2, GR16:$src1, 6600b57cec5SDimitry Andric (i8 imm:$src3)))]>, 6610b57cec5SDimitry Andric TB, OpSize16; 6620b57cec5SDimitry Andricdef SHLD32rri8 : Ii8<0xA4, MRMDestReg, 6630b57cec5SDimitry Andric (outs GR32:$dst), 6640b57cec5SDimitry Andric (ins GR32:$src1, GR32:$src2, u8imm:$src3), 6650b57cec5SDimitry Andric "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}", 6665ffd83dbSDimitry Andric [(set GR32:$dst, (fshl GR32:$src1, GR32:$src2, 6670b57cec5SDimitry Andric (i8 imm:$src3)))]>, 6680b57cec5SDimitry Andric TB, OpSize32; 6690b57cec5SDimitry Andricdef SHRD32rri8 : Ii8<0xAC, MRMDestReg, 6700b57cec5SDimitry Andric (outs GR32:$dst), 6710b57cec5SDimitry Andric (ins GR32:$src1, GR32:$src2, u8imm:$src3), 6720b57cec5SDimitry Andric "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}", 6735ffd83dbSDimitry Andric [(set GR32:$dst, (fshr GR32:$src2, GR32:$src1, 6740b57cec5SDimitry Andric (i8 imm:$src3)))]>, 6750b57cec5SDimitry Andric TB, OpSize32; 6760b57cec5SDimitry Andricdef SHLD64rri8 : RIi8<0xA4, MRMDestReg, 6770b57cec5SDimitry Andric (outs GR64:$dst), 6780b57cec5SDimitry Andric (ins GR64:$src1, GR64:$src2, u8imm:$src3), 6790b57cec5SDimitry Andric "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", 6805ffd83dbSDimitry Andric [(set GR64:$dst, (fshl GR64:$src1, GR64:$src2, 6810b57cec5SDimitry Andric (i8 imm:$src3)))]>, 6820b57cec5SDimitry Andric TB; 6830b57cec5SDimitry Andricdef SHRD64rri8 : RIi8<0xAC, MRMDestReg, 6840b57cec5SDimitry Andric (outs GR64:$dst), 6850b57cec5SDimitry Andric (ins GR64:$src1, GR64:$src2, u8imm:$src3), 6860b57cec5SDimitry Andric "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", 6875ffd83dbSDimitry Andric [(set GR64:$dst, (fshr GR64:$src2, GR64:$src1, 6880b57cec5SDimitry Andric (i8 imm:$src3)))]>, 6890b57cec5SDimitry Andric TB; 6900b57cec5SDimitry Andric} // SchedRW 6910b57cec5SDimitry Andric} // Constraints = "$src = $dst" 6920b57cec5SDimitry Andric 6930b57cec5SDimitry Andriclet Uses = [CL], SchedRW = [WriteSHDmrcl] in { 6940b57cec5SDimitry Andricdef SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2), 6950b57cec5SDimitry Andric "shld{w}\t{%cl, $src2, $dst|$dst, $src2, cl}", 6965ffd83dbSDimitry Andric [(store (X86fshl (loadi16 addr:$dst), GR16:$src2, CL), 6970b57cec5SDimitry Andric addr:$dst)]>, TB, OpSize16; 6980b57cec5SDimitry Andricdef SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2), 6990b57cec5SDimitry Andric "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, cl}", 7005ffd83dbSDimitry Andric [(store (X86fshr GR16:$src2, (loadi16 addr:$dst), CL), 7010b57cec5SDimitry Andric addr:$dst)]>, TB, OpSize16; 7020b57cec5SDimitry Andric 7030b57cec5SDimitry Andricdef SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2), 7040b57cec5SDimitry Andric "shld{l}\t{%cl, $src2, $dst|$dst, $src2, cl}", 7055ffd83dbSDimitry Andric [(store (fshl (loadi32 addr:$dst), GR32:$src2, CL), 7060b57cec5SDimitry Andric addr:$dst)]>, TB, OpSize32; 7070b57cec5SDimitry Andricdef SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2), 7080b57cec5SDimitry Andric "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, cl}", 7095ffd83dbSDimitry Andric [(store (fshr GR32:$src2, (loadi32 addr:$dst), CL), 7100b57cec5SDimitry Andric addr:$dst)]>, TB, OpSize32; 7110b57cec5SDimitry Andric 7120b57cec5SDimitry Andricdef SHLD64mrCL : RI<0xA5, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), 7130b57cec5SDimitry Andric "shld{q}\t{%cl, $src2, $dst|$dst, $src2, cl}", 7145ffd83dbSDimitry Andric [(store (fshl (loadi64 addr:$dst), GR64:$src2, CL), 7150b57cec5SDimitry Andric addr:$dst)]>, TB; 7160b57cec5SDimitry Andricdef SHRD64mrCL : RI<0xAD, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), 7170b57cec5SDimitry Andric "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, cl}", 7185ffd83dbSDimitry Andric [(store (fshr GR64:$src2, (loadi64 addr:$dst), CL), 7190b57cec5SDimitry Andric addr:$dst)]>, TB; 720bdd1243dSDimitry Andric} // Uses, SchedRW 7210b57cec5SDimitry Andric 7220b57cec5SDimitry Andriclet SchedRW = [WriteSHDmri] in { 7230b57cec5SDimitry Andricdef SHLD16mri8 : Ii8<0xA4, MRMDestMem, 7240b57cec5SDimitry Andric (outs), (ins i16mem:$dst, GR16:$src2, u8imm:$src3), 7250b57cec5SDimitry Andric "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}", 7265ffd83dbSDimitry Andric [(store (X86fshl (loadi16 addr:$dst), GR16:$src2, 7270b57cec5SDimitry Andric (i8 imm:$src3)), addr:$dst)]>, 7280b57cec5SDimitry Andric TB, OpSize16; 7290b57cec5SDimitry Andricdef SHRD16mri8 : Ii8<0xAC, MRMDestMem, 7300b57cec5SDimitry Andric (outs), (ins i16mem:$dst, GR16:$src2, u8imm:$src3), 7310b57cec5SDimitry Andric "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}", 7325ffd83dbSDimitry Andric [(store (X86fshr GR16:$src2, (loadi16 addr:$dst), 7330b57cec5SDimitry Andric (i8 imm:$src3)), addr:$dst)]>, 7340b57cec5SDimitry Andric TB, OpSize16; 7350b57cec5SDimitry Andric 7360b57cec5SDimitry Andricdef SHLD32mri8 : Ii8<0xA4, MRMDestMem, 7370b57cec5SDimitry Andric (outs), (ins i32mem:$dst, GR32:$src2, u8imm:$src3), 7380b57cec5SDimitry Andric "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}", 7395ffd83dbSDimitry Andric [(store (fshl (loadi32 addr:$dst), GR32:$src2, 7400b57cec5SDimitry Andric (i8 imm:$src3)), addr:$dst)]>, 7410b57cec5SDimitry Andric TB, OpSize32; 7420b57cec5SDimitry Andricdef SHRD32mri8 : Ii8<0xAC, MRMDestMem, 7430b57cec5SDimitry Andric (outs), (ins i32mem:$dst, GR32:$src2, u8imm:$src3), 7440b57cec5SDimitry Andric "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}", 7455ffd83dbSDimitry Andric [(store (fshr GR32:$src2, (loadi32 addr:$dst), 7460b57cec5SDimitry Andric (i8 imm:$src3)), addr:$dst)]>, 7470b57cec5SDimitry Andric TB, OpSize32; 7480b57cec5SDimitry Andric 7490b57cec5SDimitry Andricdef SHLD64mri8 : RIi8<0xA4, MRMDestMem, 7500b57cec5SDimitry Andric (outs), (ins i64mem:$dst, GR64:$src2, u8imm:$src3), 7510b57cec5SDimitry Andric "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", 7525ffd83dbSDimitry Andric [(store (fshl (loadi64 addr:$dst), GR64:$src2, 7530b57cec5SDimitry Andric (i8 imm:$src3)), addr:$dst)]>, 7540b57cec5SDimitry Andric TB; 7550b57cec5SDimitry Andricdef SHRD64mri8 : RIi8<0xAC, MRMDestMem, 7560b57cec5SDimitry Andric (outs), (ins i64mem:$dst, GR64:$src2, u8imm:$src3), 7570b57cec5SDimitry Andric "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", 7585ffd83dbSDimitry Andric [(store (fshr GR64:$src2, (loadi64 addr:$dst), 7590b57cec5SDimitry Andric (i8 imm:$src3)), addr:$dst)]>, 7600b57cec5SDimitry Andric TB; 7610b57cec5SDimitry Andric} // SchedRW 7620b57cec5SDimitry Andric 76306c3fb27SDimitry Andric} // Defs = [EFLAGS], hasSideEffects 7640b57cec5SDimitry Andric 7650b57cec5SDimitry Andric// Use the opposite rotate if allows us to use the rotate by 1 instruction. 7660b57cec5SDimitry Andricdef : Pat<(rotl GR8:$src1, (i8 7)), (ROR8r1 GR8:$src1)>; 7670b57cec5SDimitry Andricdef : Pat<(rotl GR16:$src1, (i8 15)), (ROR16r1 GR16:$src1)>; 7680b57cec5SDimitry Andricdef : Pat<(rotl GR32:$src1, (i8 31)), (ROR32r1 GR32:$src1)>; 7690b57cec5SDimitry Andricdef : Pat<(rotl GR64:$src1, (i8 63)), (ROR64r1 GR64:$src1)>; 7700b57cec5SDimitry Andricdef : Pat<(rotr GR8:$src1, (i8 7)), (ROL8r1 GR8:$src1)>; 7710b57cec5SDimitry Andricdef : Pat<(rotr GR16:$src1, (i8 15)), (ROL16r1 GR16:$src1)>; 7720b57cec5SDimitry Andricdef : Pat<(rotr GR32:$src1, (i8 31)), (ROL32r1 GR32:$src1)>; 7730b57cec5SDimitry Andricdef : Pat<(rotr GR64:$src1, (i8 63)), (ROL64r1 GR64:$src1)>; 7740b57cec5SDimitry Andric 7750b57cec5SDimitry Andricdef : Pat<(store (rotl (loadi8 addr:$dst), (i8 7)), addr:$dst), 7760b57cec5SDimitry Andric (ROR8m1 addr:$dst)>; 7770b57cec5SDimitry Andricdef : Pat<(store (rotl (loadi16 addr:$dst), (i8 15)), addr:$dst), 7780b57cec5SDimitry Andric (ROR16m1 addr:$dst)>; 7790b57cec5SDimitry Andricdef : Pat<(store (rotl (loadi32 addr:$dst), (i8 31)), addr:$dst), 7800b57cec5SDimitry Andric (ROR32m1 addr:$dst)>; 7810b57cec5SDimitry Andricdef : Pat<(store (rotl (loadi64 addr:$dst), (i8 63)), addr:$dst), 7820b57cec5SDimitry Andric (ROR64m1 addr:$dst)>, Requires<[In64BitMode]>; 7830b57cec5SDimitry Andric 7840b57cec5SDimitry Andricdef : Pat<(store (rotr (loadi8 addr:$dst), (i8 7)), addr:$dst), 7850b57cec5SDimitry Andric (ROL8m1 addr:$dst)>; 7860b57cec5SDimitry Andricdef : Pat<(store (rotr (loadi16 addr:$dst), (i8 15)), addr:$dst), 7870b57cec5SDimitry Andric (ROL16m1 addr:$dst)>; 7880b57cec5SDimitry Andricdef : Pat<(store (rotr (loadi32 addr:$dst), (i8 31)), addr:$dst), 7890b57cec5SDimitry Andric (ROL32m1 addr:$dst)>; 7900b57cec5SDimitry Andricdef : Pat<(store (rotr (loadi64 addr:$dst), (i8 63)), addr:$dst), 7910b57cec5SDimitry Andric (ROL64m1 addr:$dst)>, Requires<[In64BitMode]>; 7920b57cec5SDimitry Andric 7930b57cec5SDimitry Andric// Sandy Bridge and newer Intel processors support faster rotates using 7940b57cec5SDimitry Andric// SHLD to avoid a partial flag update on the normal rotate instructions. 7950b57cec5SDimitry Andric// Use a pseudo so that TwoInstructionPass and register allocation will see 7960b57cec5SDimitry Andric// this as unary instruction. 7970b57cec5SDimitry Andriclet Predicates = [HasFastSHLDRotate], AddedComplexity = 5, 7980b57cec5SDimitry Andric Defs = [EFLAGS], isPseudo = 1, SchedRW = [WriteSHDrri], 7990b57cec5SDimitry Andric Constraints = "$src1 = $dst" in { 8000b57cec5SDimitry Andric def SHLDROT32ri : I<0, Pseudo, (outs GR32:$dst), 8010b57cec5SDimitry Andric (ins GR32:$src1, u8imm:$shamt), "", 8020b57cec5SDimitry Andric [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$shamt)))]>; 8030b57cec5SDimitry Andric def SHLDROT64ri : I<0, Pseudo, (outs GR64:$dst), 8040b57cec5SDimitry Andric (ins GR64:$src1, u8imm:$shamt), "", 8050b57cec5SDimitry Andric [(set GR64:$dst, (rotl GR64:$src1, (i8 imm:$shamt)))]>; 8060b57cec5SDimitry Andric 8070b57cec5SDimitry Andric def SHRDROT32ri : I<0, Pseudo, (outs GR32:$dst), 8080b57cec5SDimitry Andric (ins GR32:$src1, u8imm:$shamt), "", 8090b57cec5SDimitry Andric [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$shamt)))]>; 8100b57cec5SDimitry Andric def SHRDROT64ri : I<0, Pseudo, (outs GR64:$dst), 8110b57cec5SDimitry Andric (ins GR64:$src1, u8imm:$shamt), "", 8120b57cec5SDimitry Andric [(set GR64:$dst, (rotr GR64:$src1, (i8 imm:$shamt)))]>; 8130b57cec5SDimitry Andric} 8140b57cec5SDimitry Andric 8150b57cec5SDimitry Andricdef ROT32L2R_imm8 : SDNodeXForm<imm, [{ 8160b57cec5SDimitry Andric // Convert a ROTL shamt to a ROTR shamt on 32-bit integer. 8170b57cec5SDimitry Andric return getI8Imm(32 - N->getZExtValue(), SDLoc(N)); 8180b57cec5SDimitry Andric}]>; 8190b57cec5SDimitry Andric 8200b57cec5SDimitry Andricdef ROT64L2R_imm8 : SDNodeXForm<imm, [{ 8210b57cec5SDimitry Andric // Convert a ROTL shamt to a ROTR shamt on 64-bit integer. 8220b57cec5SDimitry Andric return getI8Imm(64 - N->getZExtValue(), SDLoc(N)); 8230b57cec5SDimitry Andric}]>; 8240b57cec5SDimitry Andric 8250b57cec5SDimitry Andric// NOTE: We use WriteShift for these rotates as they avoid the stalls 8260b57cec5SDimitry Andric// of many of the older x86 rotate instructions. 827*5f757f3fSDimitry Andricmulticlass bmi_rotate<string asm, RegisterClass RC, X86MemOperand x86memop, 828*5f757f3fSDimitry Andric string Suffix = ""> { 8290b57cec5SDimitry Andriclet hasSideEffects = 0 in { 830*5f757f3fSDimitry Andric def ri#Suffix : Ii8<0xF0, MRMSrcReg, (outs RC:$dst), (ins RC:$src1, u8imm:$src2), 831*5f757f3fSDimitry Andric !strconcat(asm, "\t{$src2, $src1, $dst|$dst, $src1, $src2}"), []>, 832*5f757f3fSDimitry Andric TAXD, VEX, Sched<[WriteShift]>; 8330b57cec5SDimitry Andric let mayLoad = 1 in 834*5f757f3fSDimitry Andric def mi#Suffix : Ii8<0xF0, MRMSrcMem, (outs RC:$dst), 8350b57cec5SDimitry Andric (ins x86memop:$src1, u8imm:$src2), 836*5f757f3fSDimitry Andric !strconcat(asm, "\t{$src2, $src1, $dst|$dst, $src1, $src2}"), []>, 837*5f757f3fSDimitry Andric TAXD, VEX, Sched<[WriteShiftLd]>; 8380b57cec5SDimitry Andric} 8390b57cec5SDimitry Andric} 8400b57cec5SDimitry Andric 841*5f757f3fSDimitry Andricmulticlass bmi_shift<string asm, RegisterClass RC, X86MemOperand x86memop, 842*5f757f3fSDimitry Andric string Suffix = ""> { 8430b57cec5SDimitry Andriclet hasSideEffects = 0 in { 844*5f757f3fSDimitry Andric def rr#Suffix : I<0xF7, MRMSrcReg4VOp3, (outs RC:$dst), (ins RC:$src1, RC:$src2), 8450b57cec5SDimitry Andric !strconcat(asm, "\t{$src2, $src1, $dst|$dst, $src1, $src2}"), []>, 8460b57cec5SDimitry Andric VEX, Sched<[WriteShift]>; 8470b57cec5SDimitry Andric let mayLoad = 1 in 848*5f757f3fSDimitry Andric def rm#Suffix : I<0xF7, MRMSrcMem4VOp3, 8490b57cec5SDimitry Andric (outs RC:$dst), (ins x86memop:$src1, RC:$src2), 8500b57cec5SDimitry Andric !strconcat(asm, "\t{$src2, $src1, $dst|$dst, $src1, $src2}"), []>, 8510b57cec5SDimitry Andric VEX, Sched<[WriteShift.Folded, 8520b57cec5SDimitry Andric // x86memop:$src1 8530b57cec5SDimitry Andric ReadDefault, ReadDefault, ReadDefault, ReadDefault, 8540b57cec5SDimitry Andric ReadDefault, 8550b57cec5SDimitry Andric // RC:$src2 8560b57cec5SDimitry Andric WriteShift.ReadAfterFold]>; 8570b57cec5SDimitry Andric} 8580b57cec5SDimitry Andric} 8590b57cec5SDimitry Andric 860*5f757f3fSDimitry Andriclet Predicates = [HasBMI2, NoEGPR] in { 8610b57cec5SDimitry Andric defm RORX32 : bmi_rotate<"rorx{l}", GR32, i32mem>; 86206c3fb27SDimitry Andric defm RORX64 : bmi_rotate<"rorx{q}", GR64, i64mem>, REX_W; 8630b57cec5SDimitry Andric defm SARX32 : bmi_shift<"sarx{l}", GR32, i32mem>, T8XS; 86406c3fb27SDimitry Andric defm SARX64 : bmi_shift<"sarx{q}", GR64, i64mem>, T8XS, REX_W; 8650b57cec5SDimitry Andric defm SHRX32 : bmi_shift<"shrx{l}", GR32, i32mem>, T8XD; 86606c3fb27SDimitry Andric defm SHRX64 : bmi_shift<"shrx{q}", GR64, i64mem>, T8XD, REX_W; 8670b57cec5SDimitry Andric defm SHLX32 : bmi_shift<"shlx{l}", GR32, i32mem>, T8PD; 86806c3fb27SDimitry Andric defm SHLX64 : bmi_shift<"shlx{q}", GR64, i64mem>, T8PD, REX_W; 869*5f757f3fSDimitry Andric} 8700b57cec5SDimitry Andric 871*5f757f3fSDimitry Andriclet Predicates = [HasBMI2, HasEGPR] in { 872*5f757f3fSDimitry Andric defm RORX32 : bmi_rotate<"rorx{l}", GR32, i32mem, "_EVEX">, EVEX; 873*5f757f3fSDimitry Andric defm RORX64 : bmi_rotate<"rorx{q}", GR64, i64mem, "_EVEX">, REX_W, EVEX; 874*5f757f3fSDimitry Andric defm SARX32 : bmi_shift<"sarx{l}", GR32, i32mem, "_EVEX">, T8XS, EVEX; 875*5f757f3fSDimitry Andric defm SARX64 : bmi_shift<"sarx{q}", GR64, i64mem, "_EVEX">, T8XS, REX_W, EVEX; 876*5f757f3fSDimitry Andric defm SHRX32 : bmi_shift<"shrx{l}", GR32, i32mem, "_EVEX">, T8XD, EVEX; 877*5f757f3fSDimitry Andric defm SHRX64 : bmi_shift<"shrx{q}", GR64, i64mem, "_EVEX">, T8XD, REX_W, EVEX; 878*5f757f3fSDimitry Andric defm SHLX32 : bmi_shift<"shlx{l}", GR32, i32mem, "_EVEX">, T8PD, EVEX; 879*5f757f3fSDimitry Andric defm SHLX64 : bmi_shift<"shlx{q}", GR64, i64mem, "_EVEX">, T8PD, REX_W, EVEX; 880*5f757f3fSDimitry Andric} 881*5f757f3fSDimitry Andric 882*5f757f3fSDimitry Andriclet Predicates = [HasBMI2] in { 8830b57cec5SDimitry Andric // Prefer RORX which is non-destructive and doesn't update EFLAGS. 8840b57cec5SDimitry Andric let AddedComplexity = 10 in { 8850b57cec5SDimitry Andric def : Pat<(rotr GR32:$src, (i8 imm:$shamt)), 8860b57cec5SDimitry Andric (RORX32ri GR32:$src, imm:$shamt)>; 8870b57cec5SDimitry Andric def : Pat<(rotr GR64:$src, (i8 imm:$shamt)), 8880b57cec5SDimitry Andric (RORX64ri GR64:$src, imm:$shamt)>; 8890b57cec5SDimitry Andric 8900b57cec5SDimitry Andric def : Pat<(rotl GR32:$src, (i8 imm:$shamt)), 8910b57cec5SDimitry Andric (RORX32ri GR32:$src, (ROT32L2R_imm8 imm:$shamt))>; 8920b57cec5SDimitry Andric def : Pat<(rotl GR64:$src, (i8 imm:$shamt)), 8930b57cec5SDimitry Andric (RORX64ri GR64:$src, (ROT64L2R_imm8 imm:$shamt))>; 8940b57cec5SDimitry Andric } 8950b57cec5SDimitry Andric 8960b57cec5SDimitry Andric def : Pat<(rotr (loadi32 addr:$src), (i8 imm:$shamt)), 8970b57cec5SDimitry Andric (RORX32mi addr:$src, imm:$shamt)>; 8980b57cec5SDimitry Andric def : Pat<(rotr (loadi64 addr:$src), (i8 imm:$shamt)), 8990b57cec5SDimitry Andric (RORX64mi addr:$src, imm:$shamt)>; 9000b57cec5SDimitry Andric 9010b57cec5SDimitry Andric def : Pat<(rotl (loadi32 addr:$src), (i8 imm:$shamt)), 9020b57cec5SDimitry Andric (RORX32mi addr:$src, (ROT32L2R_imm8 imm:$shamt))>; 9030b57cec5SDimitry Andric def : Pat<(rotl (loadi64 addr:$src), (i8 imm:$shamt)), 9040b57cec5SDimitry Andric (RORX64mi addr:$src, (ROT64L2R_imm8 imm:$shamt))>; 9050b57cec5SDimitry Andric 9060b57cec5SDimitry Andric // Prefer SARX/SHRX/SHLX over SAR/SHR/SHL with variable shift BUT not 9070b57cec5SDimitry Andric // immediate shift, i.e. the following code is considered better 9080b57cec5SDimitry Andric // 9090b57cec5SDimitry Andric // mov %edi, %esi 9100b57cec5SDimitry Andric // shl $imm, %esi 9110b57cec5SDimitry Andric // ... %edi, ... 9120b57cec5SDimitry Andric // 9130b57cec5SDimitry Andric // than 9140b57cec5SDimitry Andric // 9150b57cec5SDimitry Andric // movb $imm, %sil 9160b57cec5SDimitry Andric // shlx %sil, %edi, %esi 9170b57cec5SDimitry Andric // ... %edi, ... 9180b57cec5SDimitry Andric // 9190b57cec5SDimitry Andric let AddedComplexity = 1 in { 9200b57cec5SDimitry Andric def : Pat<(sra GR32:$src1, GR8:$src2), 9210b57cec5SDimitry Andric (SARX32rr GR32:$src1, 9220b57cec5SDimitry Andric (INSERT_SUBREG 9230b57cec5SDimitry Andric (i32 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>; 9240b57cec5SDimitry Andric def : Pat<(sra GR64:$src1, GR8:$src2), 9250b57cec5SDimitry Andric (SARX64rr GR64:$src1, 9260b57cec5SDimitry Andric (INSERT_SUBREG 9270b57cec5SDimitry Andric (i64 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>; 9280b57cec5SDimitry Andric 9290b57cec5SDimitry Andric def : Pat<(srl GR32:$src1, GR8:$src2), 9300b57cec5SDimitry Andric (SHRX32rr GR32:$src1, 9310b57cec5SDimitry Andric (INSERT_SUBREG 9320b57cec5SDimitry Andric (i32 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>; 9330b57cec5SDimitry Andric def : Pat<(srl GR64:$src1, GR8:$src2), 9340b57cec5SDimitry Andric (SHRX64rr GR64:$src1, 9350b57cec5SDimitry Andric (INSERT_SUBREG 9360b57cec5SDimitry Andric (i64 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>; 9370b57cec5SDimitry Andric 9380b57cec5SDimitry Andric def : Pat<(shl GR32:$src1, GR8:$src2), 9390b57cec5SDimitry Andric (SHLX32rr GR32:$src1, 9400b57cec5SDimitry Andric (INSERT_SUBREG 9410b57cec5SDimitry Andric (i32 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>; 9420b57cec5SDimitry Andric def : Pat<(shl GR64:$src1, GR8:$src2), 9430b57cec5SDimitry Andric (SHLX64rr GR64:$src1, 9440b57cec5SDimitry Andric (INSERT_SUBREG 9450b57cec5SDimitry Andric (i64 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>; 9460b57cec5SDimitry Andric } 9470b57cec5SDimitry Andric 9480b57cec5SDimitry Andric // We prefer to use 9490b57cec5SDimitry Andric // mov (%ecx), %esi 9500b57cec5SDimitry Andric // shl $imm, $esi 9510b57cec5SDimitry Andric // 9520b57cec5SDimitry Andric // over 9530b57cec5SDimitry Andric // 9540b57cec5SDimitry Andric // movb $imm, %al 9550b57cec5SDimitry Andric // shlx %al, (%ecx), %esi 9560b57cec5SDimitry Andric // 9570b57cec5SDimitry Andric // This priority is enforced by IsProfitableToFoldLoad. 9580b57cec5SDimitry Andric def : Pat<(sra (loadi32 addr:$src1), GR8:$src2), 9590b57cec5SDimitry Andric (SARX32rm addr:$src1, 9600b57cec5SDimitry Andric (INSERT_SUBREG 9610b57cec5SDimitry Andric (i32 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>; 9620b57cec5SDimitry Andric def : Pat<(sra (loadi64 addr:$src1), GR8:$src2), 9630b57cec5SDimitry Andric (SARX64rm addr:$src1, 9640b57cec5SDimitry Andric (INSERT_SUBREG 9650b57cec5SDimitry Andric (i64 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>; 9660b57cec5SDimitry Andric 9670b57cec5SDimitry Andric def : Pat<(srl (loadi32 addr:$src1), GR8:$src2), 9680b57cec5SDimitry Andric (SHRX32rm addr:$src1, 9690b57cec5SDimitry Andric (INSERT_SUBREG 9700b57cec5SDimitry Andric (i32 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>; 9710b57cec5SDimitry Andric def : Pat<(srl (loadi64 addr:$src1), GR8:$src2), 9720b57cec5SDimitry Andric (SHRX64rm addr:$src1, 9730b57cec5SDimitry Andric (INSERT_SUBREG 9740b57cec5SDimitry Andric (i64 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>; 9750b57cec5SDimitry Andric 9760b57cec5SDimitry Andric def : Pat<(shl (loadi32 addr:$src1), GR8:$src2), 9770b57cec5SDimitry Andric (SHLX32rm addr:$src1, 9780b57cec5SDimitry Andric (INSERT_SUBREG 9790b57cec5SDimitry Andric (i32 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>; 9800b57cec5SDimitry Andric def : Pat<(shl (loadi64 addr:$src1), GR8:$src2), 9810b57cec5SDimitry Andric (SHLX64rm addr:$src1, 9820b57cec5SDimitry Andric (INSERT_SUBREG 9830b57cec5SDimitry Andric (i64 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>; 9840b57cec5SDimitry Andric} 9855ffd83dbSDimitry Andric 9865ffd83dbSDimitry Andricdef : Pat<(rotl GR8:$src1, (i8 relocImm:$src2)), 9875ffd83dbSDimitry Andric (ROL8ri GR8:$src1, relocImm:$src2)>; 9885ffd83dbSDimitry Andricdef : Pat<(rotl GR16:$src1, (i8 relocImm:$src2)), 9895ffd83dbSDimitry Andric (ROL16ri GR16:$src1, relocImm:$src2)>; 9905ffd83dbSDimitry Andricdef : Pat<(rotl GR32:$src1, (i8 relocImm:$src2)), 9915ffd83dbSDimitry Andric (ROL32ri GR32:$src1, relocImm:$src2)>; 9925ffd83dbSDimitry Andricdef : Pat<(rotl GR64:$src1, (i8 relocImm:$src2)), 9935ffd83dbSDimitry Andric (ROL64ri GR64:$src1, relocImm:$src2)>; 9945ffd83dbSDimitry Andric 9955ffd83dbSDimitry Andricdef : Pat<(rotr GR8:$src1, (i8 relocImm:$src2)), 9965ffd83dbSDimitry Andric (ROR8ri GR8:$src1, relocImm:$src2)>; 9975ffd83dbSDimitry Andricdef : Pat<(rotr GR16:$src1, (i8 relocImm:$src2)), 9985ffd83dbSDimitry Andric (ROR16ri GR16:$src1, relocImm:$src2)>; 9995ffd83dbSDimitry Andricdef : Pat<(rotr GR32:$src1, (i8 relocImm:$src2)), 10005ffd83dbSDimitry Andric (ROR32ri GR32:$src1, relocImm:$src2)>; 10015ffd83dbSDimitry Andricdef : Pat<(rotr GR64:$src1, (i8 relocImm:$src2)), 10025ffd83dbSDimitry Andric (ROR64ri GR64:$src1, relocImm:$src2)>; 1003