1 // LoongArchLSXInstrFormats.td - LoongArch LSX 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 LSX instructions format
12 // opcode - operation code.
13 // vd/rd/cd - destination register operand.
14 // {r/v}{j/k} - source register operand.
15 // immN - immediate data operand.
17 //===----------------------------------------------------------------------===//
20 // <opcode | I13 | vd>
21 class Fmt1RI13_VI<bits<32> op, dag outs, dag ins, string opnstr,
22 list<dag> pattern = []>
23 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
28 let Inst{17-5} = imm13;
34 class Fmt2R_VV<bits<32> op, dag outs, dag ins, string opnstr,
35 list<dag> pattern = []>
36 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
46 class Fmt2R_VR<bits<32> op, dag outs, dag ins, string opnstr,
47 list<dag> pattern = []>
48 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
58 class Fmt2R_CV<bits<32> op, dag outs, dag ins, string opnstr,
59 list<dag> pattern = []>
60 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
70 // <opcode | I1 | vj | vd>
71 class Fmt2RI1_VVI<bits<32> op, dag outs, dag ins, string opnstr,
72 list<dag> pattern = []>
73 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
84 // <opcode | I1 | rj | vd>
85 class Fmt2RI1_VRI<bits<32> op, dag outs, dag ins, string opnstr,
86 list<dag> pattern = []>
87 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
98 // <opcode | I1 | vj | rd>
99 class Fmt2RI1_RVI<bits<32> op, dag outs, dag ins, string opnstr,
100 list<dag> pattern = []>
101 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
113 // <opcode | I2 | vj | vd>
114 class Fmt2RI2_VVI<bits<32> op, dag outs, dag ins, string opnstr,
115 list<dag> pattern = []>
116 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
122 let Inst{11-10} = imm2;
127 // <opcode | I2 | rj | vd>
128 class Fmt2RI2_VRI<bits<32> op, dag outs, dag ins, string opnstr,
129 list<dag> pattern = []>
130 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
136 let Inst{11-10} = imm2;
141 // <opcode | I2 | vj | rd>
142 class Fmt2RI2_RVI<bits<32> op, dag outs, dag ins, string opnstr,
143 list<dag> pattern = []>
144 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
150 let Inst{11-10} = imm2;
156 // <opcode | I3 | vj | vd>
157 class Fmt2RI3_VVI<bits<32> op, dag outs, dag ins, string opnstr,
158 list<dag> pattern = []>
159 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
165 let Inst{12-10} = imm3;
170 // <opcode | I3 | rj | vd>
171 class Fmt2RI3_VRI<bits<32> op, dag outs, dag ins, string opnstr,
172 list<dag> pattern = []>
173 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
179 let Inst{12-10} = imm3;
184 // <opcode | I3 | vj | rd>
185 class Fmt2RI3_RVI<bits<32> op, dag outs, dag ins, string opnstr,
186 list<dag> pattern = []>
187 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
193 let Inst{12-10} = imm3;
199 // <opcode | I4 | vj | vd>
200 class Fmt2RI4_VVI<bits<32> op, dag outs, dag ins, string opnstr,
201 list<dag> pattern = []>
202 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
208 let Inst{13-10} = imm4;
213 // <opcode | I4 | rj | vd>
214 class Fmt2RI4_VRI<bits<32> op, dag outs, dag ins, string opnstr,
215 list<dag> pattern = []>
216 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
222 let Inst{13-10} = imm4;
227 // <opcode | I4 | vj | rd>
228 class Fmt2RI4_RVI<bits<32> op, dag outs, dag ins, string opnstr,
229 list<dag> pattern = []>
230 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
236 let Inst{13-10} = imm4;
242 // <opcode | I5 | vj | vd>
243 class Fmt2RI5_VVI<bits<32> op, dag outs, dag ins, string opnstr,
244 list<dag> pattern = []>
245 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
251 let Inst{14-10} = imm5;
257 // <opcode | I6 | vj | vd>
258 class Fmt2RI6_VVI<bits<32> op, dag outs, dag ins, string opnstr,
259 list<dag> pattern = []>
260 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
266 let Inst{15-10} = imm6;
272 // <opcode | I7 | vj | vd>
273 class Fmt2RI7_VVI<bits<32> op, dag outs, dag ins, string opnstr,
274 list<dag> pattern = []>
275 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
281 let Inst{16-10} = imm7;
287 // <opcode | I8 | vj | vd>
288 class Fmt2RI8_VVI<bits<32> op, dag outs, dag ins, string opnstr,
289 list<dag> pattern = []>
290 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
296 let Inst{17-10} = imm8;
302 // <opcode | I1 | I8 | vj | vd>
303 class Fmt2RI8I1_VRII<bits<32> op, dag outs, dag ins, string opnstr,
304 list<dag> pattern = []>
305 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
313 let Inst{17-10} = imm8;
319 // <opcode | I2 | I8 | vj | vd>
320 class Fmt2RI8I2_VRII<bits<32> op, dag outs, dag ins, string opnstr,
321 list<dag> pattern = []>
322 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
329 let Inst{19-18} = imm2;
330 let Inst{17-10} = imm8;
336 // <opcode | I3 | I8 | vj | vd>
337 class Fmt2RI8I3_VRII<bits<32> op, dag outs, dag ins, string opnstr,
338 list<dag> pattern = []>
339 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
346 let Inst{20-18} = imm3;
347 let Inst{17-10} = imm8;
353 // <opcode | I4 | I8 | vj | vd>
354 class Fmt2RI8I4_VRII<bits<32> op, dag outs, dag ins, string opnstr,
355 list<dag> pattern = []>
356 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
363 let Inst{21-18} = imm4;
364 let Inst{17-10} = imm8;
369 // <opcode | I9 | rj | vd>
370 class Fmt2RI9_VRI<bits<32> op, dag outs, dag ins, string opnstr,
371 list<dag> pattern = []>
372 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
378 let Inst{18-10} = imm9;
384 // <opcode | I10 | rj | vd>
385 class Fmt2RI10_VRI<bits<32> op, dag outs, dag ins, string opnstr,
386 list<dag> pattern = []>
387 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
393 let Inst{19-10} = imm10;
399 // <opcode | I11 | rj | vd>
400 class Fmt2RI11_VRI<bits<32> op, dag outs, dag ins, string opnstr,
401 list<dag> pattern = []>
402 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
408 let Inst{20-10} = imm11;
414 // <opcode | I12 | rj | vd>
415 class Fmt2RI12_VRI<bits<32> op, dag outs, dag ins, string opnstr,
416 list<dag> pattern = []>
417 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
423 let Inst{21-10} = imm12;
429 // <opcode | vk | vj | vd>
430 class Fmt3R_VVV<bits<32> op, dag outs, dag ins, string opnstr,
431 list<dag> pattern = []>
432 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
438 let Inst{14-10} = vk;
443 // <opcode | rk | vj | vd>
444 class Fmt3R_VVR<bits<32> op, dag outs, dag ins, string opnstr,
445 list<dag> pattern = []>
446 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
452 let Inst{14-10} = rk;
457 // <opcode | rk | rj | vd>
458 class Fmt3R_VRR<bits<32> op, dag outs, dag ins, string opnstr,
459 list<dag> pattern = []>
460 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
466 let Inst{14-10} = rk;
472 // <opcode | va | vk | vj | vd>
473 class Fmt4R_VVVV<bits<32> op, dag outs, dag ins, string opnstr,
474 list<dag> pattern = []>
475 : LAInst<outs, ins, deriveInsnMnemonic<NAME>.ret, opnstr, pattern> {
482 let Inst{19-15} = va;
483 let Inst{14-10} = vk;