xref: /freebsd-src/contrib/llvm-project/llvm/lib/Target/CSKY/CSKYInstrFormats16Instr.td (revision 0eae32dcef82f6f06de6419a0d623d7def0cc8f6)
1349cc55cSDimitry Andric//===- CSKYInstrFormats16Instr.td - 16-bit Instr. Formats -*- tablegen --*-===//
2349cc55cSDimitry Andric//
3349cc55cSDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4349cc55cSDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
5349cc55cSDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6349cc55cSDimitry Andric//
7349cc55cSDimitry Andric//===----------------------------------------------------------------------===//
8349cc55cSDimitry Andric
9349cc55cSDimitry Andricclass J16<bits<5> sop, string opstr, dag ins>
10349cc55cSDimitry Andric  : CSKY16Inst<AddrModeNone, (outs), ins,
11349cc55cSDimitry Andric    !strconcat(opstr, "\t$offset"), []> {
12349cc55cSDimitry Andric  bits<10> offset;
13349cc55cSDimitry Andric  let Inst{15} = 0;
14349cc55cSDimitry Andric  let Inst{14 - 10} = sop;
15349cc55cSDimitry Andric  let Inst{9 - 0} = offset;
16349cc55cSDimitry Andric}
17349cc55cSDimitry Andric
18349cc55cSDimitry Andricclass J16_B<bits<5> sop, string opstr>
19349cc55cSDimitry Andric  : CSKY16Inst<AddrModeNone, (outs), (ins CARRY:$ca, br_symbol_16bit:$offset),
20349cc55cSDimitry Andric    !strconcat(opstr, "\t$offset"), []> {
21349cc55cSDimitry Andric  bits<10> offset;
22349cc55cSDimitry Andric  let Inst{15} = 0;
23349cc55cSDimitry Andric  let Inst{14 - 10} = sop;
24349cc55cSDimitry Andric  let Inst{9 - 0} = offset;
25349cc55cSDimitry Andric}
26349cc55cSDimitry Andric
27349cc55cSDimitry Andricclass R16_XYZ<bits<2> sop, string opstr, SDNode opnode> : CSKY16Inst<AddrModeNone,
28349cc55cSDimitry Andric  (outs mGPR:$rz), (ins mGPR:$rx, mGPR:$ry), !strconcat(opstr, "\t$rz, $rx, $ry"),
29349cc55cSDimitry Andric  [(set mGPR:$rz, (opnode mGPR:$rx, mGPR:$ry)) ]> {
30349cc55cSDimitry Andric  bits<3> rz;
31349cc55cSDimitry Andric  bits<3> rx;
32349cc55cSDimitry Andric  bits<3> ry;
33349cc55cSDimitry Andric  let Inst{15 - 11} = 0b01011;
34349cc55cSDimitry Andric  let Inst{10 - 8} = rx;
35349cc55cSDimitry Andric  let Inst{7 - 5} = rz;
36349cc55cSDimitry Andric  let Inst{4 - 2} = ry;
37349cc55cSDimitry Andric  let Inst{1, 0} = sop;
38349cc55cSDimitry Andric}
39349cc55cSDimitry Andric
40349cc55cSDimitry Andricclass R16_XZ_BINOP<bits<4> op, bits<2> sop, string opstr, PatFrag opnode> : CSKY16Inst<
41349cc55cSDimitry Andric  AddrModeNone, (outs sGPR:$rz), (ins sGPR:$rZ, sGPR:$rx), !strconcat(opstr, "\t$rz, $rx"),
42349cc55cSDimitry Andric  [(set sGPR:$rz, (opnode sGPR:$rZ, sGPR:$rx))]> {
43349cc55cSDimitry Andric  bits<4> rz;
44349cc55cSDimitry Andric  bits<4> rx;
45349cc55cSDimitry Andric  let Inst{15, 14} = 0b01;
46349cc55cSDimitry Andric  let Inst{13 - 10} = op;
47349cc55cSDimitry Andric  let Inst{9 - 6} = rz;
48349cc55cSDimitry Andric  let Inst{5 - 2} = rx;
49349cc55cSDimitry Andric  let Inst{1, 0} = sop;
50349cc55cSDimitry Andric  let Constraints = "$rz = $rZ";
51349cc55cSDimitry Andric}
52349cc55cSDimitry Andric
53349cc55cSDimitry Andricclass R16_XZ_BINOP_NOPat<bits<4> op, bits<2> sop, string opstr> : CSKY16Inst<
54349cc55cSDimitry Andric  AddrModeNone, (outs sGPR:$rz), (ins sGPR:$rZ, sGPR:$rx), !strconcat(opstr, "\t$rz, $rx"),
55349cc55cSDimitry Andric  []> {
56349cc55cSDimitry Andric  bits<4> rz;
57349cc55cSDimitry Andric  bits<4> rx;
58349cc55cSDimitry Andric  let Inst{15, 14} = 0b01;
59349cc55cSDimitry Andric  let Inst{13 - 10} = op;
60349cc55cSDimitry Andric  let Inst{9 - 6} = rz;
61349cc55cSDimitry Andric  let Inst{5 - 2} = rx;
62349cc55cSDimitry Andric  let Inst{1, 0} = sop;
63349cc55cSDimitry Andric  let Constraints = "$rz = $rZ";
64349cc55cSDimitry Andric}
65349cc55cSDimitry Andric
66349cc55cSDimitry Andricclass R16_XZ_BINOP_C<bits<4> op, bits<2> sop, string opstr> : CSKY16Inst<
67349cc55cSDimitry Andric  AddrModeNone, (outs sGPR:$rz, CARRY:$cout),
68349cc55cSDimitry Andric  (ins sGPR:$rZ, sGPR:$rx, CARRY:$cin), !strconcat(opstr, "\t$rz, $rx"), []> {
69349cc55cSDimitry Andric  bits<4> rz;
70349cc55cSDimitry Andric  bits<4> rx;
71349cc55cSDimitry Andric  let Inst{15, 14} = 0b01;
72349cc55cSDimitry Andric  let Inst{13 - 10} = op;
73349cc55cSDimitry Andric  let Inst{9 - 6} = rz;
74349cc55cSDimitry Andric  let Inst{5 - 2} = rx;
75349cc55cSDimitry Andric  let Inst{1, 0} = sop;
76349cc55cSDimitry Andric  let Constraints = "$rz = $rZ";
77349cc55cSDimitry Andric}
78349cc55cSDimitry Andric
79349cc55cSDimitry Andricclass R16_XZ_UNOP<bits<4> op, bits<2> sop, string opstr> : CSKY16Inst<
80349cc55cSDimitry Andric  AddrModeNone, (outs sGPR:$rz), (ins sGPR:$rx), !strconcat(opstr, "\t$rz, $rx"),
81349cc55cSDimitry Andric  []> {
82349cc55cSDimitry Andric  bits<4> rz;
83349cc55cSDimitry Andric  bits<4> rx;
84349cc55cSDimitry Andric  let Inst{15, 14} = 0b01;
85349cc55cSDimitry Andric  let Inst{13 - 10} = op;
86349cc55cSDimitry Andric  let Inst{9 - 6} = rz;
87349cc55cSDimitry Andric  let Inst{5 - 2} = rx;
88349cc55cSDimitry Andric  let Inst{1, 0} = sop;
89349cc55cSDimitry Andric}
90349cc55cSDimitry Andric
91*0eae32dcSDimitry Andricclass R16_Z_UNOP<bits<4> op, bits<2> sop, string opstr> : CSKY16Inst<
92*0eae32dcSDimitry Andric  AddrModeNone, (outs sGPR:$rz), (ins sGPR:$rx), !strconcat(opstr, "\t$rz"),
93*0eae32dcSDimitry Andric  []> {
94*0eae32dcSDimitry Andric  bits<4> rz;
95*0eae32dcSDimitry Andric  bits<4> rx;
96*0eae32dcSDimitry Andric  let Inst{15, 14} = 0b01;
97*0eae32dcSDimitry Andric  let Inst{13 - 10} = op;
98*0eae32dcSDimitry Andric  let Inst{9 - 6} = rz;
99*0eae32dcSDimitry Andric  let Inst{5 - 2} = rx;
100*0eae32dcSDimitry Andric  let Inst{1, 0} = sop;
101*0eae32dcSDimitry Andric  let Constraints = "$rz = $rx";
102*0eae32dcSDimitry Andric}
103*0eae32dcSDimitry Andric
104349cc55cSDimitry Andricclass R16_XY_CMP<bits<2> sop, string opstr> : CSKY16Inst<
105349cc55cSDimitry Andric  AddrModeNone, (outs CARRY:$ca), (ins sGPR:$rx, sGPR:$ry), !strconcat(opstr, "\t$rx, $ry"),
106349cc55cSDimitry Andric  []> {
107349cc55cSDimitry Andric  bits<4> ry;
108349cc55cSDimitry Andric  bits<4> rx;
109349cc55cSDimitry Andric  let Inst{15, 14} = 0b01;
110349cc55cSDimitry Andric  let Inst{13 - 10} = 0b1001;
111349cc55cSDimitry Andric  let Inst{9 - 6} = ry;
112349cc55cSDimitry Andric  let Inst{5 - 2} = rx;
113349cc55cSDimitry Andric  let Inst{1, 0} = sop;
114349cc55cSDimitry Andric  let isCompare = 1;
115349cc55cSDimitry Andric}
116349cc55cSDimitry Andric
117349cc55cSDimitry Andricclass R16_X_J<bits<8> op_rz, bits<2> sop, string opstr> : CSKY16Inst<
118349cc55cSDimitry Andric  AddrModeNone, (outs), (ins sGPR:$rx), !strconcat(opstr, "\t$rx"), []> {
119349cc55cSDimitry Andric  bits<4> rx;
120349cc55cSDimitry Andric  let Inst{15, 14} = 0b01;
121349cc55cSDimitry Andric  let Inst{13 - 6} = op_rz;
122349cc55cSDimitry Andric  let Inst{5 - 2} = rx;
123349cc55cSDimitry Andric  let Inst{1, 0} = sop;
124349cc55cSDimitry Andric}
125349cc55cSDimitry Andric
126349cc55cSDimitry Andricclass I16_Z_8<bits<3> op, dag ins, string asmstr>
127349cc55cSDimitry Andric  : CSKY16Inst<AddrModeNone, (outs mGPR:$rz), ins, asmstr, []> {
128349cc55cSDimitry Andric  bits<3> rz;
129349cc55cSDimitry Andric  bits<8> imm8;
130349cc55cSDimitry Andric  let Inst{15, 14} = 0b00;
131349cc55cSDimitry Andric  let Inst{13 - 11} = op;
132349cc55cSDimitry Andric  let Inst{10 - 8} = rz;
133349cc55cSDimitry Andric  let Inst{7 - 0} = imm8;
134349cc55cSDimitry Andric}
135349cc55cSDimitry Andric
136349cc55cSDimitry Andricclass I16_Z_5<bits<3> sop, dag outs, dag ins,string opstr>
137349cc55cSDimitry Andric  : CSKY16Inst<AddrModeNone, outs, ins,
138349cc55cSDimitry Andric  !strconcat(opstr, "\t$rz, $imm5"), []> {
139349cc55cSDimitry Andric  bits<3> rz;
140349cc55cSDimitry Andric  bits<5> imm5;
141349cc55cSDimitry Andric  let Inst{15, 14} = 0b00;
142349cc55cSDimitry Andric  let Inst{13 - 11} = 0b111;
143349cc55cSDimitry Andric  let Inst{10 - 8} = rz;
144349cc55cSDimitry Andric  let Inst{7 - 5} = sop;
145349cc55cSDimitry Andric  let Inst{4 - 0} = imm5;
146349cc55cSDimitry Andric}
147349cc55cSDimitry Andric
148349cc55cSDimitry Andricclass I16_X_CMP<bits<3> sop, string opstr, Operand Immoperand> : CSKY16Inst<
149349cc55cSDimitry Andric  AddrModeNone, (outs CARRY:$ca), (ins mGPR:$rx, Immoperand:$imm5),
150349cc55cSDimitry Andric  !strconcat(opstr, "\t$rx, $imm5"), []> {
151349cc55cSDimitry Andric  bits<3> rx;
152349cc55cSDimitry Andric  bits<5> imm5;
153349cc55cSDimitry Andric  let Inst{15, 14} = 0b00;
154349cc55cSDimitry Andric  let Inst{13 - 11} = 0b111;
155349cc55cSDimitry Andric  let Inst{10 - 8} = rx;
156349cc55cSDimitry Andric  let Inst{7 - 5} = sop;
157349cc55cSDimitry Andric  let Inst{4 - 0} = imm5;
158349cc55cSDimitry Andric  let isCompare = 1;
159349cc55cSDimitry Andric}
160349cc55cSDimitry Andric
161349cc55cSDimitry Andricclass I16_SP_IMM7<bits<3> sop, string opstr> : CSKY16Inst<
162*0eae32dcSDimitry Andric  AddrModeNone, (outs GPRSP:$sp2), (ins GPRSP:$sp1, uimm7_2:$imm7),
163349cc55cSDimitry Andric  !strconcat(opstr, "\t$sp2, $sp1, $imm7"), []> {
164349cc55cSDimitry Andric  bits<7> imm7;
165349cc55cSDimitry Andric  let Inst{15, 14} = 0b00;
166349cc55cSDimitry Andric  let Inst{13 - 10} = 0b0101;
167349cc55cSDimitry Andric  let Inst{9, 8} = imm7{6,5};
168349cc55cSDimitry Andric  let Inst{7 - 5} = sop;
169349cc55cSDimitry Andric  let Inst{4 - 0} = imm7{4 - 0};
170349cc55cSDimitry Andric}
171349cc55cSDimitry Andric
172349cc55cSDimitry Andricclass I16_XZ_IMM5<bits<3> sop, string opstr, SDNode opnode> : CSKY16Inst<
173349cc55cSDimitry Andric  AddrModeNone, (outs mGPR:$rz), (ins mGPR:$rx, uimm5:$imm5),
174349cc55cSDimitry Andric  !strconcat(opstr, "\t$rz, $rx, $imm5"), [(set mGPR:$rz, (opnode mGPR:$rx, uimm5:$imm5))]> {
175349cc55cSDimitry Andric  bits<3> rx;
176349cc55cSDimitry Andric  bits<3> rz;
177349cc55cSDimitry Andric  bits<5> imm5;
178349cc55cSDimitry Andric  let Inst{15, 14} = 0b01;
179349cc55cSDimitry Andric  let Inst{13 - 11} = sop;
180349cc55cSDimitry Andric  let Inst{10 - 8} = rx;
181349cc55cSDimitry Andric  let Inst{7 - 5} = rz;
182349cc55cSDimitry Andric  let Inst{4 - 0} = imm5;
183349cc55cSDimitry Andric}
184349cc55cSDimitry Andric
185349cc55cSDimitry Andricclass I16_XZ_LDST<AddrMode am, bits<3> sop, string opstr, dag outs, dag ins>
186349cc55cSDimitry Andric  : CSKY16Inst<am, outs, ins, !strconcat(opstr, "\t$rz, ($rx, ${imm})"),
187349cc55cSDimitry Andric  []> {
188349cc55cSDimitry Andric  bits<3> rx;
189349cc55cSDimitry Andric  bits<3> rz;
190349cc55cSDimitry Andric  bits<5> imm;
191349cc55cSDimitry Andric  let Inst{15, 14} = 0b10;
192349cc55cSDimitry Andric  let Inst{13 - 11} = sop;
193349cc55cSDimitry Andric  let Inst{10 - 8} = rx;
194349cc55cSDimitry Andric  let Inst{7 - 5} = rz;
195349cc55cSDimitry Andric  let Inst{4 - 0} = imm;
196349cc55cSDimitry Andric}
197349cc55cSDimitry Andric
198349cc55cSDimitry Andricclass I16_ZSP_LDST<AddrMode am, bits<3> sop, string opstr, dag outs, dag ins> : CSKY16Inst<
199349cc55cSDimitry Andric  am,  outs, ins, !strconcat(opstr, "\t$rz, ($sp, ${addr})"),
200349cc55cSDimitry Andric  []> {
201349cc55cSDimitry Andric  bits<3> rz;
202349cc55cSDimitry Andric  bits<8> addr;
203349cc55cSDimitry Andric  let Inst{15, 14} = 0b10;
204349cc55cSDimitry Andric  let Inst{13 - 11} = sop;
205349cc55cSDimitry Andric  let Inst{10 - 8} = addr{7 - 5};
206349cc55cSDimitry Andric  let Inst{7 - 5} = rz;
207349cc55cSDimitry Andric  let Inst{4 - 0} = addr{4 - 0};
208349cc55cSDimitry Andric}
209349cc55cSDimitry Andric
210349cc55cSDimitry Andricclass I16_XZ_IMM3<bits<2> sop, string opstr, SDNode opnode> : CSKY16Inst<
211349cc55cSDimitry Andric  AddrModeNone, (outs mGPR:$rz), (ins mGPR:$rx, oimm3:$oimm3),
212349cc55cSDimitry Andric  !strconcat(opstr, "\t$rz, $rx, $oimm3"), [(set mGPR:$rz, (opnode mGPR:$rx, oimm3:$oimm3))]> {
213349cc55cSDimitry Andric  bits<3> rx;
214349cc55cSDimitry Andric  bits<3> rz;
215349cc55cSDimitry Andric  bits<3> oimm3;
216349cc55cSDimitry Andric  let Inst{15, 14} = 0b01;
217349cc55cSDimitry Andric  let Inst{13 - 11} = 0b011;
218349cc55cSDimitry Andric  let Inst{10 - 8} = rx;
219349cc55cSDimitry Andric  let Inst{7 - 5} = rz;
220349cc55cSDimitry Andric  let Inst{4 - 2} = oimm3;
221349cc55cSDimitry Andric  let Inst{1, 0} = sop;
222349cc55cSDimitry Andric}
223349cc55cSDimitry Andric
224349cc55cSDimitry Andricclass I16_BPushPop<bits<11> op, bits<2> uop, dag out, dag ins, string opstr> :
225349cc55cSDimitry Andric  CSKY16Inst<AddrModeNone, out, ins, opstr, []>{
226349cc55cSDimitry Andric  bits<3> rz;
227349cc55cSDimitry Andric  let Inst{15- 5} = op;
228349cc55cSDimitry Andric  let Inst{4 -2} = rz;
229349cc55cSDimitry Andric  let Inst{1,0} = uop;
230349cc55cSDimitry Andric  let Predicates = [HasJAVA];
231349cc55cSDimitry Andric  let hasSideEffects = 1;
232349cc55cSDimitry Andric}
233