1 //===- CSKYInstrFormats16Instr.td - 16-bit Instr. Formats -*- 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 //===----------------------------------------------------------------------===//
9 class J16<bits<5> sop, string opstr, dag ins>
10 : CSKY16Inst<AddrModeNone, (outs), ins,
11 !strconcat(opstr, "\t$offset"), []> {
14 let Inst{14 - 10} = sop;
15 let Inst{9 - 0} = offset;
18 class J16_B<bits<5> sop, string opstr>
19 : CSKY16Inst<AddrModeNone, (outs), (ins CARRY:$ca, br_symbol_16bit:$offset),
20 !strconcat(opstr, "\t$offset"), []> {
23 let Inst{14 - 10} = sop;
24 let Inst{9 - 0} = offset;
27 class R16_XYZ<bits<2> sop, string opstr, SDNode opnode> : CSKY16Inst<AddrModeNone,
28 (outs mGPR:$rz), (ins mGPR:$rx, mGPR:$ry), !strconcat(opstr, "\t$rz, $rx, $ry"),
29 [(set mGPR:$rz, (opnode mGPR:$rx, mGPR:$ry)) ]> {
33 let Inst{15 - 11} = 0b01011;
34 let Inst{10 - 8} = rx;
40 class R16_XZ_BINOP<bits<4> op, bits<2> sop, string opstr, PatFrag opnode> : CSKY16Inst<
41 AddrModeNone, (outs sGPR:$rz), (ins sGPR:$rZ, sGPR:$rx), !strconcat(opstr, "\t$rz, $rx"),
42 [(set sGPR:$rz, (opnode sGPR:$rZ, sGPR:$rx))]> {
45 let Inst{15, 14} = 0b01;
46 let Inst{13 - 10} = op;
50 let Constraints = "$rz = $rZ";
53 class R16_XZ_BINOP_NOPat<bits<4> op, bits<2> sop, string opstr> : CSKY16Inst<
54 AddrModeNone, (outs sGPR:$rz), (ins sGPR:$rZ, sGPR:$rx), !strconcat(opstr, "\t$rz, $rx"),
58 let Inst{15, 14} = 0b01;
59 let Inst{13 - 10} = op;
63 let Constraints = "$rz = $rZ";
66 class R16_XZ_BINOP_C<bits<4> op, bits<2> sop, string opstr> : CSKY16Inst<
67 AddrModeNone, (outs sGPR:$rz, CARRY:$cout),
68 (ins sGPR:$rZ, sGPR:$rx, CARRY:$cin), !strconcat(opstr, "\t$rz, $rx"), []> {
71 let Inst{15, 14} = 0b01;
72 let Inst{13 - 10} = op;
76 let Constraints = "$rz = $rZ";
79 class R16_XZ_UNOP<bits<4> op, bits<2> sop, string opstr> : CSKY16Inst<
80 AddrModeNone, (outs sGPR:$rz), (ins sGPR:$rx), !strconcat(opstr, "\t$rz, $rx"),
84 let Inst{15, 14} = 0b01;
85 let Inst{13 - 10} = op;
91 class R16_Z_UNOP<bits<4> op, bits<2> sop, string opstr> : CSKY16Inst<
92 AddrModeNone, (outs sGPR:$rz), (ins sGPR:$rx), !strconcat(opstr, "\t$rz"),
96 let Inst{15, 14} = 0b01;
97 let Inst{13 - 10} = op;
100 let Inst{1, 0} = sop;
101 let Constraints = "$rz = $rx";
104 class R16_XY_CMP<bits<2> sop, string opstr> : CSKY16Inst<
105 AddrModeNone, (outs CARRY:$ca), (ins sGPR:$rx, sGPR:$ry), !strconcat(opstr, "\t$rx, $ry"),
109 let Inst{15, 14} = 0b01;
110 let Inst{13 - 10} = 0b1001;
111 let Inst{9 - 6} = ry;
112 let Inst{5 - 2} = rx;
113 let Inst{1, 0} = sop;
117 class R16_X_J<bits<8> op_rz, bits<2> sop, string opstr> : CSKY16Inst<
118 AddrModeNone, (outs), (ins sGPR:$rx), !strconcat(opstr, "\t$rx"), []> {
120 let Inst{15, 14} = 0b01;
121 let Inst{13 - 6} = op_rz;
122 let Inst{5 - 2} = rx;
123 let Inst{1, 0} = sop;
126 class I16_Z_8<bits<3> op, dag ins, string asmstr>
127 : CSKY16Inst<AddrModeNone, (outs mGPR:$rz), ins, asmstr, []> {
130 let Inst{15, 14} = 0b00;
131 let Inst{13 - 11} = op;
132 let Inst{10 - 8} = rz;
133 let Inst{7 - 0} = imm8;
136 class I16_Z_5<bits<3> sop, dag outs, dag ins,string opstr>
137 : CSKY16Inst<AddrModeNone, outs, ins,
138 !strconcat(opstr, "\t$rz, $imm5"), []> {
141 let Inst{15, 14} = 0b00;
142 let Inst{13 - 11} = 0b111;
143 let Inst{10 - 8} = rz;
144 let Inst{7 - 5} = sop;
145 let Inst{4 - 0} = imm5;
148 class I16_X_CMP<bits<3> sop, string opstr, Operand Immoperand> : CSKY16Inst<
149 AddrModeNone, (outs CARRY:$ca), (ins mGPR:$rx, Immoperand:$imm5),
150 !strconcat(opstr, "\t$rx, $imm5"), []> {
153 let Inst{15, 14} = 0b00;
154 let Inst{13 - 11} = 0b111;
155 let Inst{10 - 8} = rx;
156 let Inst{7 - 5} = sop;
157 let Inst{4 - 0} = imm5;
161 class I16_SP_IMM7<bits<3> sop, string opstr> : CSKY16Inst<
162 AddrModeNone, (outs GPRSP:$sp2), (ins GPRSP:$sp1, uimm7_2:$imm7),
163 !strconcat(opstr, "\t$sp2, $sp1, $imm7"), []> {
165 let Inst{15, 14} = 0b00;
166 let Inst{13 - 10} = 0b0101;
167 let Inst{9, 8} = imm7{6,5};
168 let Inst{7 - 5} = sop;
169 let Inst{4 - 0} = imm7{4 - 0};
172 class I16_XZ_IMM5<bits<3> sop, string opstr, SDNode opnode> : CSKY16Inst<
173 AddrModeNone, (outs mGPR:$rz), (ins mGPR:$rx, uimm5:$imm5),
174 !strconcat(opstr, "\t$rz, $rx, $imm5"), [(set mGPR:$rz, (opnode mGPR:$rx, uimm5:$imm5))]> {
178 let Inst{15, 14} = 0b01;
179 let Inst{13 - 11} = sop;
180 let Inst{10 - 8} = rx;
181 let Inst{7 - 5} = rz;
182 let Inst{4 - 0} = imm5;
185 class I16_XZ_LDST<AddrMode am, bits<3> sop, string opstr, dag outs, dag ins>
186 : CSKY16Inst<am, outs, ins, !strconcat(opstr, "\t$rz, ($rx, ${imm})"),
191 let Inst{15, 14} = 0b10;
192 let Inst{13 - 11} = sop;
193 let Inst{10 - 8} = rx;
194 let Inst{7 - 5} = rz;
195 let Inst{4 - 0} = imm;
198 class I16_ZSP_LDST<AddrMode am, bits<3> sop, string opstr, dag outs, dag ins> : CSKY16Inst<
199 am, outs, ins, !strconcat(opstr, "\t$rz, ($sp, ${addr})"),
203 let Inst{15, 14} = 0b10;
204 let Inst{13 - 11} = sop;
205 let Inst{10 - 8} = addr{7 - 5};
206 let Inst{7 - 5} = rz;
207 let Inst{4 - 0} = addr{4 - 0};
210 class I16_XZ_IMM3<bits<2> sop, string opstr, SDNode opnode> : CSKY16Inst<
211 AddrModeNone, (outs mGPR:$rz), (ins mGPR:$rx, oimm3:$oimm3),
212 !strconcat(opstr, "\t$rz, $rx, $oimm3"), [(set mGPR:$rz, (opnode mGPR:$rx, oimm3:$oimm3))]> {
216 let Inst{15, 14} = 0b01;
217 let Inst{13 - 11} = 0b011;
218 let Inst{10 - 8} = rx;
219 let Inst{7 - 5} = rz;
220 let Inst{4 - 2} = oimm3;
221 let Inst{1, 0} = sop;
224 class I16_BPushPop<bits<11> op, bits<2> uop, dag out, dag ins, string opstr> :
225 CSKY16Inst<AddrModeNone, out, ins, opstr, []>{
227 let Inst{15- 5} = op;
230 let Predicates = [HasJAVA];
231 let hasSideEffects = 1;