1 //===------ M68kInstrShiftRotate.td - Logical Instrs -----*- tablegen -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
10 /// This file describes the logical instructions in the M68k architecture.
11 /// Here is the current status of the file:
15 /// SHL [~] ASR [~] LSR [~] SWAP [ ]
16 /// ROL [~] ROR [~] ROXL [ ] ROXR [ ]
20 /// [ ] - was not touched at all
21 /// [!] - requires extarnal stuff implemented
22 /// [~] - in progress but usable
25 //===----------------------------------------------------------------------===//
27 def MxRODI_R : MxBead1Bit<0>;
28 def MxRODI_L : MxBead1Bit<1>;
30 def MxROOP_AS : MxBead2Bits<0b00>;
31 def MxROOP_LS : MxBead2Bits<0b01>;
32 def MxROOP_ROX : MxBead2Bits<0b10>;
33 def MxROOP_RO : MxBead2Bits<0b11>;
35 /// ------------+---------+---+------+---+------+---------
36 /// F E D C | B A 9 | 8 | 7 6 | 5 | 4 3 | 2 1 0
37 /// ------------+---------+---+------+---+------+---------
38 /// 1 1 1 0 | REG/IMM | D | SIZE |R/I| OP | REG
39 /// ------------+---------+---+------+---+------+---------
40 class MxSREncoding_R<MxBead1Bit DIRECTION, MxBead2Bits ROOP, MxEncSize SIZE>
41 : MxEncoding<MxBeadDReg<0>, ROOP, MxBead1Bit<1>, SIZE, DIRECTION,
42 MxBeadDReg<2>, MxBead4Bits<0b1110>>;
44 class MxSREncoding_I<MxBead1Bit DIRECTION, MxBead2Bits ROOP, MxEncSize SIZE>
45 : MxEncoding<MxBeadDReg<0>, ROOP, MxBead1Bit<0>, SIZE, DIRECTION,
46 MxBead3Imm<2, 1>, MxBead4Bits<0b1110>>;
48 // $reg <- $reg op $reg
49 class MxSR_DD<string MN, MxType TYPE, SDNode NODE,
50 MxBead1Bit RODI, MxBead2Bits ROOP>
51 : MxInst<(outs TYPE.ROp:$dst), (ins TYPE.ROp:$src, TYPE.ROp:$opd),
52 MN#"."#TYPE.Prefix#"\t$opd, $dst",
53 [(set TYPE.VT:$dst, (NODE TYPE.VT:$src, TYPE.VT:$opd))],
54 MxSREncoding_R<RODI, ROOP,
55 !cast<MxEncSize>("MxEncSize"#TYPE.Size)>>;
57 // $reg <- $reg op $imm
58 class MxSR_DI<string MN, MxType TYPE, SDNode NODE,
59 MxBead1Bit RODI, MxBead2Bits ROOP>
60 : MxInst<(outs TYPE.ROp:$dst),
61 (ins TYPE.ROp:$src, !cast<Operand>("Mxi"#TYPE.Size#"imm"):$opd),
62 MN#"."#TYPE.Prefix#"\t$opd, $dst",
65 !cast<ImmLeaf>("Mximm"#TYPE.Size#"_1to8"):$opd))],
66 MxSREncoding_I<RODI, ROOP,
67 !cast<MxEncSize>("MxEncSize"#TYPE.Size)>>;
69 multiclass MxSROp<string MN, SDNode NODE, MxBead1Bit RODI, MxBead2Bits ROOP> {
72 let Constraints = "$src = $dst" in {
74 def NAME#"8dd" : MxSR_DD<MN, MxType8d, NODE, RODI, ROOP>;
75 def NAME#"16dd" : MxSR_DD<MN, MxType16d, NODE, RODI, ROOP>;
76 def NAME#"32dd" : MxSR_DD<MN, MxType32d, NODE, RODI, ROOP>;
78 def NAME#"8di" : MxSR_DI<MN, MxType8d, NODE, RODI, ROOP>;
79 def NAME#"16di" : MxSR_DI<MN, MxType16d, NODE, RODI, ROOP>;
80 def NAME#"32di" : MxSR_DI<MN, MxType32d, NODE, RODI, ROOP>;
87 defm SHL : MxSROp<"lsl", shl, MxRODI_L, MxROOP_LS>;
88 defm LSR : MxSROp<"lsr", srl, MxRODI_R, MxROOP_LS>;
89 defm ASR : MxSROp<"asr", sra, MxRODI_R, MxROOP_AS>;
91 defm ROL : MxSROp<"rol", rotl, MxRODI_L, MxROOP_RO>;
92 defm ROR : MxSROp<"ror", rotr, MxRODI_R, MxROOP_RO>;