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 defvar MxROKind_R = true;
28 defvar MxROKind_I = false;
30 defvar MxRODI_R = false;
31 defvar MxRODI_L = true;
33 defvar MxROOP_AS = 0b00;
34 defvar MxROOP_LS = 0b01;
35 defvar MxROOP_ROX = 0b10;
36 defvar MxROOP_RO = 0b11;
38 /// ------------+---------+---+------+---+------+---------
39 /// F E D C | B A 9 | 8 | 7 6 | 5 | 4 3 | 2 1 0
40 /// ------------+---------+---+------+---+------+---------
41 /// 1 1 1 0 | REG/IMM | D | SIZE |R/I| OP | REG
42 /// ------------+---------+---+------+---+------+---------
43 class MxSREncoding<bit kind, string src_opnd, string dst_opnd,
44 bit direction, bits<2> ro_op, MxEncSize size> {
45 dag Value = (descend 0b1110,
47 (operand "$"#src_opnd, 3),
48 direction, size.Value, kind, ro_op,
50 (operand "$"#dst_opnd, 3)
54 // $reg <- $reg op $reg
55 class MxSR_DD<string MN, MxType TYPE, SDNode NODE, bit RODI, bits<2> ROOP>
56 : MxInst<(outs TYPE.ROp:$dst), (ins TYPE.ROp:$src, TYPE.ROp:$opd),
57 MN#"."#TYPE.Prefix#"\t$opd, $dst",
58 [(set TYPE.VT:$dst, (NODE TYPE.VT:$src, TYPE.VT:$opd))]> {
59 let Inst = MxSREncoding<MxROKind_R, "opd", "dst", RODI, ROOP,
60 !cast<MxEncSize>("MxEncSize"#TYPE.Size)>.Value;
63 // $reg <- $reg op $imm
64 class MxSR_DI<string MN, MxType TYPE, SDNode NODE, bit RODI, bits<2> ROOP>
65 : MxInst<(outs TYPE.ROp:$dst),
66 (ins TYPE.ROp:$src, !cast<Operand>("Mxi"#TYPE.Size#"imm"):$opd),
67 MN#"."#TYPE.Prefix#"\t$opd, $dst",
70 !cast<ImmLeaf>("Mximm"#TYPE.Size#"_1to8"):$opd))]> {
71 let Inst = MxSREncoding<MxROKind_I, "opd", "dst", RODI, ROOP,
72 !cast<MxEncSize>("MxEncSize"#TYPE.Size)>.Value;
75 multiclass MxSROp<string MN, SDNode NODE, bit RODI, bits<2> ROOP> {
78 let Constraints = "$src = $dst" in {
80 def NAME#"8dd" : MxSR_DD<MN, MxType8d, NODE, RODI, ROOP>;
81 def NAME#"16dd" : MxSR_DD<MN, MxType16d, NODE, RODI, ROOP>;
82 def NAME#"32dd" : MxSR_DD<MN, MxType32d, NODE, RODI, ROOP>;
84 def NAME#"8di" : MxSR_DI<MN, MxType8d, NODE, RODI, ROOP>;
85 def NAME#"16di" : MxSR_DI<MN, MxType16d, NODE, RODI, ROOP>;
86 def NAME#"32di" : MxSR_DI<MN, MxType32d, NODE, RODI, ROOP>;
93 defm SHL : MxSROp<"lsl", shl, MxRODI_L, MxROOP_LS>;
94 defm LSR : MxSROp<"lsr", srl, MxRODI_R, MxROOP_LS>;
95 defm ASR : MxSROp<"asr", sra, MxRODI_R, MxROOP_AS>;
97 defm ROL : MxSROp<"rol", rotl, MxRODI_L, MxROOP_RO>;
98 defm ROR : MxSROp<"ror", rotr, MxRODI_R, MxROOP_RO>;