xref: /freebsd-src/contrib/llvm-project/llvm/lib/Target/CSKY/CSKYInstrFormatsF2.td (revision 04eeddc0aa8e0a417a16eaf9d7d095207f4a8623)
1*04eeddc0SDimitry Andric//===- CSKYInstrFormatsF2.td - CSKY Float2.0 Instr Format --*- tablegen -*-===//
2*04eeddc0SDimitry Andric//
3*04eeddc0SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*04eeddc0SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
5*04eeddc0SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*04eeddc0SDimitry Andric//
7*04eeddc0SDimitry Andric//===----------------------------------------------------------------------===//
8*04eeddc0SDimitry Andric//
9*04eeddc0SDimitry Andric// CSKY Instruction Format Float2.0 Definitions.
10*04eeddc0SDimitry Andric//
11*04eeddc0SDimitry Andric//===----------------------------------------------------------------------===//
12*04eeddc0SDimitry Andric
13*04eeddc0SDimitry Andricclass CSKYInstF2<AddrMode am, dag outs, dag ins, string opcodestr,
14*04eeddc0SDimitry Andric                 list<dag> pattern>
15*04eeddc0SDimitry Andric    : CSKY32Inst<am, 0x3d, outs, ins, opcodestr, pattern> {
16*04eeddc0SDimitry Andric  let Predicates = [HasFPUv3_SF];
17*04eeddc0SDimitry Andric  let DecoderNamespace = "FPUV3";
18*04eeddc0SDimitry Andric}
19*04eeddc0SDimitry Andric
20*04eeddc0SDimitry Andricclass F2_XYZ<bits<5> datatype, bits<6> sop, string opcodestr, dag outs, dag ins,
21*04eeddc0SDimitry Andric             list<dag> pattern>
22*04eeddc0SDimitry Andric    : CSKYInstF2<AddrModeNone, outs, ins, opcodestr, pattern> {
23*04eeddc0SDimitry Andric  bits<5> vry;
24*04eeddc0SDimitry Andric  bits<5> vrx;
25*04eeddc0SDimitry Andric  bits<5> vrz;
26*04eeddc0SDimitry Andric
27*04eeddc0SDimitry Andric  let Inst{25-21} = vry;
28*04eeddc0SDimitry Andric  let Inst{20-16} = vrx;
29*04eeddc0SDimitry Andric  let Inst{15-11} = datatype;
30*04eeddc0SDimitry Andric  let Inst{10-5} = sop;
31*04eeddc0SDimitry Andric  let Inst{4-0} = vrz;
32*04eeddc0SDimitry Andric}
33*04eeddc0SDimitry Andric
34*04eeddc0SDimitry Andricmulticlass F2_XYZ_T<bits<6> sop, string op, PatFrag opnode> {
35*04eeddc0SDimitry Andric  def _S : F2_XYZ<0b00000, sop, op#".32"#"\t$vrz, $vrx, $vry",
36*04eeddc0SDimitry Andric             (outs FPR32Op:$vrz), (ins FPR32Op:$vrx, FPR32Op:$vry),
37*04eeddc0SDimitry Andric             [(set FPR32Op:$vrz, (opnode FPR32Op:$vrx, FPR32Op:$vry))]>;
38*04eeddc0SDimitry Andric  let Predicates = [HasFPUv3_DF] in
39*04eeddc0SDimitry Andric  def _D : F2_XYZ<0b00001, sop, op#".64"#"\t$vrz, $vrx, $vry",
40*04eeddc0SDimitry Andric             (outs FPR64Op:$vrz), (ins FPR64Op:$vrx, FPR64Op:$vry),
41*04eeddc0SDimitry Andric             [(set FPR64Op:$vrz, (opnode FPR64Op:$vrx, FPR64Op:$vry))]>;
42*04eeddc0SDimitry Andric}
43*04eeddc0SDimitry Andric
44*04eeddc0SDimitry Andriclet Constraints = "$vrZ = $vrz" in
45*04eeddc0SDimitry Andricmulticlass F2_XYZZ_T<bits<6> sop, string op, PatFrag opnode> {
46*04eeddc0SDimitry Andric  def _S : F2_XYZ<0b00000, sop, op#".32"#"\t$vrz, $vrx, $vry",
47*04eeddc0SDimitry Andric                  (outs FPR32Op:$vrz), (ins FPR32Op:$vrZ, FPR32Op:$vrx, FPR32Op:$vry),
48*04eeddc0SDimitry Andric                  [(set FPR32Op:$vrz, (opnode FPR32Op:$vrx, FPR32Op:$vry, FPR32Op:$vrZ))]>;
49*04eeddc0SDimitry Andric  let Predicates = [HasFPUv3_DF] in
50*04eeddc0SDimitry Andric  def _D : F2_XYZ<0b00001, sop, op#".64"#"\t$vrz, $vrx, $vry",
51*04eeddc0SDimitry Andric                  (outs FPR64Op:$vrz), (ins FPR64Op:$vrZ, FPR64Op:$vrx, FPR64Op:$vry),
52*04eeddc0SDimitry Andric                  [(set FPR64Op:$vrz, (opnode FPR64Op:$vrx, FPR64Op:$vry, FPR64Op:$vrZ))]>;
53*04eeddc0SDimitry Andric}
54*04eeddc0SDimitry Andric
55*04eeddc0SDimitry Andriclet vry = 0 in {
56*04eeddc0SDimitry Andricclass F2_XZ<bits<5> datatype, RegisterOperand regtype, bits<6> sop, string op, SDNode opnode>
57*04eeddc0SDimitry Andric    : F2_XYZ<datatype, sop, !strconcat(op, "\t$vrz, $vrx"),
58*04eeddc0SDimitry Andric             (outs regtype:$vrz), (ins regtype:$vrx),
59*04eeddc0SDimitry Andric             [(set regtype:$vrz, (opnode regtype:$vrx))]>;
60*04eeddc0SDimitry Andric
61*04eeddc0SDimitry Andricclass F2_XZ_SET<bits<5> datatype, RegisterOperand regtype, bits<6> sop, string op>
62*04eeddc0SDimitry Andric    : F2_XYZ<datatype, sop, !strconcat(op, "\t$vrz, $vrx"),
63*04eeddc0SDimitry Andric             (outs regtype:$vrz), (ins regtype:$vrx),
64*04eeddc0SDimitry Andric             []>;
65*04eeddc0SDimitry Andric
66*04eeddc0SDimitry Andricclass F2_XZ_P<bits<5> datatype, bits<6> sop, string op, list<dag> pattern = [],
67*04eeddc0SDimitry Andric              dag outs, dag ins>
68*04eeddc0SDimitry Andric    : F2_XYZ<datatype, sop, op#"\t$vrz, $vrx", outs, ins, pattern>;
69*04eeddc0SDimitry Andric}
70*04eeddc0SDimitry Andric
71*04eeddc0SDimitry Andricmulticlass F2_XZ_RM<bits<5> datatype, bits<4> sop, string op, dag outs, dag ins> {
72*04eeddc0SDimitry Andric  def _RN  : F2_XZ_P<datatype, {sop, 0b00}, op#".rn", [], outs, ins>;
73*04eeddc0SDimitry Andric  def _RZ  : F2_XZ_P<datatype, {sop, 0b01}, op#".rz", [], outs, ins>;
74*04eeddc0SDimitry Andric  def _RPI : F2_XZ_P<datatype, {sop, 0b10}, op#".rpi", [], outs, ins>;
75*04eeddc0SDimitry Andric  def _RNI : F2_XZ_P<datatype, {sop, 0b11}, op#".rni", [], outs, ins>;
76*04eeddc0SDimitry Andric}
77*04eeddc0SDimitry Andric
78*04eeddc0SDimitry Andricmulticlass F2_XZ_T<bits<6> sop, string op, SDNode opnode> {
79*04eeddc0SDimitry Andric  def _S : F2_XZ<0b00000, FPR32Op, sop, op#".32", opnode>;
80*04eeddc0SDimitry Andric  let Predicates = [HasFPUv3_DF] in
81*04eeddc0SDimitry Andric  def _D : F2_XZ<0b00001, FPR64Op, sop, op#".64", opnode>;
82*04eeddc0SDimitry Andric}
83*04eeddc0SDimitry Andric
84*04eeddc0SDimitry Andricmulticlass F2_XZ_SET_T<bits<6> sop, string op, string suffix = ""> {
85*04eeddc0SDimitry Andric  def _S : F2_XZ_SET<0b00000, FPR32Op, sop, op#".32"#suffix>;
86*04eeddc0SDimitry Andric  let Predicates = [HasFPUv3_DF] in
87*04eeddc0SDimitry Andric  def _D : F2_XZ_SET<0b00001, FPR64Op, sop, op#".64"#suffix>;
88*04eeddc0SDimitry Andric}
89*04eeddc0SDimitry Andric
90*04eeddc0SDimitry Andric
91*04eeddc0SDimitry Andriclet vrz = 0, isCompare = 1 in
92*04eeddc0SDimitry Andricclass F2_CXY<bits<5> datatype, RegisterOperand regtype, bits<6> sop, string op>
93*04eeddc0SDimitry Andric    : F2_XYZ<datatype, sop, !strconcat(op, "\t$vrx, $vry"),
94*04eeddc0SDimitry Andric             (outs CARRY:$ca), (ins regtype:$vrx, regtype:$vry),
95*04eeddc0SDimitry Andric             []>;
96*04eeddc0SDimitry Andric
97*04eeddc0SDimitry Andricmulticlass F2_CXY_T<bits<6> sop, string op> {
98*04eeddc0SDimitry Andric  def _S : F2_CXY<0b00000, FPR32Op, sop, op#".32">;
99*04eeddc0SDimitry Andric  let Predicates = [HasFPUv3_DF] in
100*04eeddc0SDimitry Andric  def _D : F2_CXY<0b00001, FPR64Op, sop, op#".64">;
101*04eeddc0SDimitry Andric}
102*04eeddc0SDimitry Andric
103*04eeddc0SDimitry Andric
104*04eeddc0SDimitry Andriclet vrz = 0, vry = 0, isCompare = 1 in
105*04eeddc0SDimitry Andricclass F2_CX<bits<5> datatype, RegisterOperand regtype, bits<6> sop, string op>
106*04eeddc0SDimitry Andric    : F2_XYZ<datatype, sop, !strconcat(op, "\t$vrx"),
107*04eeddc0SDimitry Andric             (outs CARRY:$ca), (ins regtype:$vrx),
108*04eeddc0SDimitry Andric             []>;
109*04eeddc0SDimitry Andric
110*04eeddc0SDimitry Andricmulticlass F2_CX_T<bits<6> sop, string op> {
111*04eeddc0SDimitry Andric  def _S : F2_CX<0b00000, FPR32Op, sop, op#".32">;
112*04eeddc0SDimitry Andric  let Predicates = [HasFPUv3_DF] in
113*04eeddc0SDimitry Andric  def _D : F2_CX<0b00001, FPR64Op, sop, op#".64">;
114*04eeddc0SDimitry Andric}
115*04eeddc0SDimitry Andric
116*04eeddc0SDimitry Andric
117*04eeddc0SDimitry Andricclass F2_LDST<bits<2> datatype, bits<1> sop, string op, dag outs, dag ins>
118*04eeddc0SDimitry Andric    : CSKYInstF2<AddrMode32SDF, outs, ins,
119*04eeddc0SDimitry Andric                 !strconcat(op, "\t$vrz, ($rx, ${imm8})"), []> {
120*04eeddc0SDimitry Andric  bits<10> imm8;
121*04eeddc0SDimitry Andric  bits<5> rx;
122*04eeddc0SDimitry Andric  bits<5> vrz;
123*04eeddc0SDimitry Andric
124*04eeddc0SDimitry Andric  let Inst{25} = vrz{4};
125*04eeddc0SDimitry Andric  let Inst{24-21} = imm8{7-4};
126*04eeddc0SDimitry Andric  let Inst{20-16} = rx;
127*04eeddc0SDimitry Andric  let Inst{15-11} = 0b00100;
128*04eeddc0SDimitry Andric  let Inst{10} = sop;
129*04eeddc0SDimitry Andric  let Inst{9-8} = datatype;
130*04eeddc0SDimitry Andric  let Inst{7-4} = imm8{3-0};
131*04eeddc0SDimitry Andric  let Inst{3-0} = vrz{3-0};
132*04eeddc0SDimitry Andric}
133*04eeddc0SDimitry Andric
134*04eeddc0SDimitry Andricclass F2_LDST_S<bits<1> sop, string op, dag outs, dag ins>
135*04eeddc0SDimitry Andric    : F2_LDST<0b00, sop, op#".32", outs, ins>;
136*04eeddc0SDimitry Andricclass F2_LDST_D<bits<1> sop, string op, dag outs, dag ins>
137*04eeddc0SDimitry Andric    : F2_LDST<0b01, sop, op#".64", outs, ins>;
138*04eeddc0SDimitry Andric
139*04eeddc0SDimitry Andricclass F2_LDSTM<bits<2> datatype, bits<1> sop, bits<3> sop2, string op, dag outs, dag ins>
140*04eeddc0SDimitry Andric    : CSKYInstF2<AddrMode32SDF, outs, ins,
141*04eeddc0SDimitry Andric                 !strconcat(op, "\t$regs, (${rx})"), []> {
142*04eeddc0SDimitry Andric  bits<10> regs;
143*04eeddc0SDimitry Andric  bits<5> rx;
144*04eeddc0SDimitry Andric
145*04eeddc0SDimitry Andric  let Inst{25-21} = regs{4-0};
146*04eeddc0SDimitry Andric  let Inst{20-16} = rx;
147*04eeddc0SDimitry Andric  let Inst{15-11} = 0b00110;
148*04eeddc0SDimitry Andric  let Inst{10} = sop;
149*04eeddc0SDimitry Andric  let Inst{9-8} = datatype;
150*04eeddc0SDimitry Andric  let Inst{7-5} = sop2;
151*04eeddc0SDimitry Andric  let Inst{4-0} = regs{9-5};
152*04eeddc0SDimitry Andric}
153*04eeddc0SDimitry Andric
154*04eeddc0SDimitry Andricclass F2_LDSTM_S<bits<1> sop, bits<3> sop2, string op, dag outs, dag ins>
155*04eeddc0SDimitry Andric    : F2_LDSTM<0b00, sop, sop2, op#".32", outs, ins>;
156*04eeddc0SDimitry Andricclass F2_LDSTM_D<bits<1> sop, bits<3> sop2, string op, dag outs, dag ins>
157*04eeddc0SDimitry Andric    : F2_LDSTM<0b01, sop, sop2, op#".64", outs, ins>;
158*04eeddc0SDimitry Andric
159*04eeddc0SDimitry Andric
160*04eeddc0SDimitry Andricclass F2_LDSTR<bits<2> datatype, bits<1> sop, string op, dag outs, dag ins>
161*04eeddc0SDimitry Andric    : CSKYInstF2<AddrModeNone, outs, ins,
162*04eeddc0SDimitry Andric                 op#"\t$rz, ($rx, $ry << ${imm})", []> {
163*04eeddc0SDimitry Andric  bits<5> rx;
164*04eeddc0SDimitry Andric  bits<5> ry;
165*04eeddc0SDimitry Andric  bits<5> rz;
166*04eeddc0SDimitry Andric  bits<2> imm;
167*04eeddc0SDimitry Andric
168*04eeddc0SDimitry Andric  let Inst{25-21} = ry;
169*04eeddc0SDimitry Andric  let Inst{20-16} = rx;
170*04eeddc0SDimitry Andric  let Inst{15-11} = 0b00101;
171*04eeddc0SDimitry Andric  let Inst{10} = sop;
172*04eeddc0SDimitry Andric  let Inst{9-8} = datatype;
173*04eeddc0SDimitry Andric  let Inst{7} = 0;
174*04eeddc0SDimitry Andric  let Inst{6-5} = imm;
175*04eeddc0SDimitry Andric  let Inst{4-0} = rz;
176*04eeddc0SDimitry Andric}
177*04eeddc0SDimitry Andric
178*04eeddc0SDimitry Andricclass F2_LDSTR_S<bits<1> sop, string op, dag outs, dag ins>
179*04eeddc0SDimitry Andric    : F2_LDSTR<0b00, sop, op#".32", outs, ins>;
180*04eeddc0SDimitry Andricclass F2_LDSTR_D<bits<1> sop, string op, dag outs, dag ins>
181*04eeddc0SDimitry Andric    : F2_LDSTR<0b01, sop, op#".64", outs, ins>;
182*04eeddc0SDimitry Andric
183*04eeddc0SDimitry Andricclass F2_CXYZ<bits<5> datatype, RegisterOperand regtype, bits<6> sop, string op>
184*04eeddc0SDimitry Andric    : F2_XYZ<datatype, sop, !strconcat(op, "\t$vrz, $vrx, $vry"),
185*04eeddc0SDimitry Andric             (outs regtype:$vrz), (ins CARRY:$ca, regtype:$vrx, regtype:$vry),
186*04eeddc0SDimitry Andric             []>;
187*04eeddc0SDimitry Andricmulticlass F2_CXYZ_T<bits<6> sop, string op> {
188*04eeddc0SDimitry Andric  def _S : F2_CXYZ<0b00000, FPR32Op, sop, op#".32">;
189*04eeddc0SDimitry Andric  let Predicates = [HasFPUv3_DF] in
190*04eeddc0SDimitry Andric  def _D : F2_CXYZ<0b00001, FPR64Op, sop, op#".64">;
191*04eeddc0SDimitry Andric}
192*04eeddc0SDimitry Andric
193*04eeddc0SDimitry Andricclass F2_LRW<bits<2> datatype, bits<1> sop, string op, dag outs, dag ins>
194*04eeddc0SDimitry Andric    : CSKYInstF2<AddrModeNone, outs, ins,
195*04eeddc0SDimitry Andric                 !strconcat(op, "\t$vrz, ${imm8}"), []> {
196*04eeddc0SDimitry Andric  bits<10> imm8;
197*04eeddc0SDimitry Andric  bits<5> rx;
198*04eeddc0SDimitry Andric  bits<5> vrz;
199*04eeddc0SDimitry Andric
200*04eeddc0SDimitry Andric  let Inst{25} = vrz{4};
201*04eeddc0SDimitry Andric  let Inst{24-21} = imm8{7-4};
202*04eeddc0SDimitry Andric  let Inst{20-16} = 0;
203*04eeddc0SDimitry Andric  let Inst{15-11} = 0b00111;
204*04eeddc0SDimitry Andric  let Inst{10} = sop;
205*04eeddc0SDimitry Andric  let Inst{9-8} = datatype;
206*04eeddc0SDimitry Andric  let Inst{7-4} = imm8{3-0};
207*04eeddc0SDimitry Andric  let Inst{3-0} = vrz{3-0};
208*04eeddc0SDimitry Andric}
209