1 // LoongArchLBTInstrFormats.td - LoongArch LBT 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 //===----------------------------------------------------------------------===//
10 // Describe LoongArch LBT instructions format
12 // opcode - operation code.
13 // rd/sd - destination register operand.
14 // rj/rk/sj - source register operand.
15 // immN/ptr - immediate data operand.
17 // Note: The definition of "NoDstFmt..." conveys the meaning of no explicit
18 // output operand. In other words, there will be no output operand in the
19 // assembly notation of these instructions. In fact, they always manipulate
20 // the "EFLAGS" register.
21 // Since these instructions are currently not used for code generation,
22 // we do not need to add `let Defs/Uses = [EFLAGS]`.
23 //===----------------------------------------------------------------------===//
27 class NoDstFmt1R<bits<32> op>
28 : LAInst<(outs), (ins GPR:$rj),
29 deriveInsnMnemonic<NAME>.ret, "$rj"> {
36 // 1RI3-type (no outs)
38 class NoDstFmt1RI3<bits<32> op>
39 : LAInst<(outs), (ins GPR:$rj, uimm3:$imm3),
40 deriveInsnMnemonic<NAME>.ret, "$rj, $imm3"> {
45 let Inst{12-10} = imm3;
49 // 1RI4-type (no outs)
51 class NoDstFmt1RI4<bits<32> op>
52 : LAInst<(outs), (ins GPR:$rj, uimm4:$imm4),
53 deriveInsnMnemonic<NAME>.ret, "$rj, $imm4"> {
58 let Inst{13-10} = imm4;
64 class Fmt1RI4<bits<32> op>
65 : LAInst<(outs GPR:$rd), (ins uimm4:$imm4),
66 deriveInsnMnemonic<NAME>.ret, "$rd, $imm4"> {
71 let Inst{13-10} = imm4;
75 // 1RI5-type (no outs)
77 class NoDstFmt1RI5<bits<32> op>
78 : LAInst<(outs), (ins GPR:$rj, uimm5:$imm5),
79 deriveInsnMnemonic<NAME>.ret, "$rj, $imm5"> {
84 let Inst{14-10} = imm5;
88 // 1RI5I4-type (no outs)
89 // <opcode | rd | I5 | I4>
90 class NoDstFmt1RI5I4<bits<32> op>
91 : LAInst<(outs), (ins GPR:$rj, uimm5:$imm5, uimm4:$imm4),
92 deriveInsnMnemonic<NAME>.ret, "$rj, $imm5, $imm4"> {
98 let Inst{14-10} = imm5;
100 let Inst{3-0} = imm4;
104 // <opcode | rd | I5 | I8>
105 class Fmt1RI5I8<bits<32> op>
106 : LAInst<(outs GPR:$rd), (ins uimm5:$imm5, uimm8:$imm8),
107 deriveInsnMnemonic<NAME>.ret, "$rd, $imm5, $imm8"> {
113 let Inst{17-10} = imm8;
114 let Inst{9-5} = imm5;
118 // 1RI6-type (no outs)
119 // <opcode | I6 | rj>
120 class NoDstFmt1RI6<bits<32> op>
121 : LAInst<(outs), (ins GPR:$rj, uimm6:$imm6),
122 deriveInsnMnemonic<NAME>.ret, "$rj, $imm6"> {
127 let Inst{15-10} = imm6;
132 // <opcode | I8 | rd>
133 class Fmt1RI8<bits<32> op>
134 : LAInst<(outs GPR:$rd), (ins uimm8:$imm8),
135 deriveInsnMnemonic<NAME>.ret, "$rd, $imm8"> {
140 let Inst{17-10} = imm8;
145 // <opcode | rk | rj>
146 class NoDstFmt2R<bits<32> op>
147 : LAInst<(outs), (ins GPR:$rj, GPR:$rk),
148 deriveInsnMnemonic<NAME>.ret, "$rj, $rk"> {
153 let Inst{14-10} = rk;
157 // 2RI4-type (no outs)
158 // <opcode | rk | rj | imm4>
159 class NoDstFmt2RI4<bits<32> op>
160 : LAInst<(outs), (ins GPR:$rj, GPR:$rk, uimm4:$imm4),
161 deriveInsnMnemonic<NAME>.ret, "$rj, $rk, $imm4"> {
167 let Inst{14-10} = rk;
169 let Inst{3-0} = imm4;
173 // <opcode | I3 | rj | rd>
174 class Fmt2RI3<bits<32> op>
175 : LAInst<(outs GPR:$rd), (ins GPR:$rj, uimm3:$imm3),
176 deriveInsnMnemonic<NAME>.ret, "$rd, $rj, $imm3"> {
182 let Inst{12-10} = imm3;
188 // <opcode | I4 | rj | rd>
189 class Fmt2RI4<bits<32> op>
190 : LAInst<(outs GPR:$rd), (ins GPR:$rj, uimm4:$imm4),
191 deriveInsnMnemonic<NAME>.ret, "$rd, $rj, $imm4"> {
197 let Inst{13-10} = imm4;
202 // <opcode | rj | sd>
203 class FmtGR2SCR<bits<32> op>
204 : LAInst<(outs SCR:$sd), (ins GPR:$rj), deriveInsnMnemonic<NAME>.ret,
214 // <opcode | sj | rd>
215 class FmtSCR2GR<bits<32> op>
216 : LAInst<(outs GPR:$rd), (ins SCR:$sj), deriveInsnMnemonic<NAME>.ret,
226 // <opcode | I21[15:0] | I21[20:16]>
227 class FmtJISCR<bits<32> op>
228 : LAInst<(outs), (ins simm21_lsl2:$imm21), deriveInsnMnemonic<NAME>.ret,
234 let Inst{25-10} = imm21{15-0};
235 let Inst{4-0} = imm21{20-16};
239 class FmtMFTOP<bits<32> op>
240 : LAInst<(outs GPR:$rd), (ins), deriveInsnMnemonic<NAME>.ret,
249 class FmtMTTOP<bits<32> op>
250 : LAInst<(outs), (ins uimm3:$ptr), deriveInsnMnemonic<NAME>.ret,