Skip to content

Commit 23b82c9

Browse files
authored
[RISCV] Move Zimop to RISCVInstrInfoZimop.td (#76392)
So the structure of TableGen files is still clear.
1 parent 4a601cf commit 23b82c9

File tree

3 files changed

+60
-49
lines changed

3 files changed

+60
-49
lines changed

llvm/lib/Target/RISCV/RISCVInstrFormats.td

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -410,27 +410,6 @@ class RVInstIUnary<bits<12> imm12, bits<3> funct3, RISCVOpcode opcode,
410410
let Inst{31-20} = imm12;
411411
}
412412

413-
class RVInstIMopr<bits<7> imm7, bits<5> imm5, bits<3> funct3, RISCVOpcode opcode,
414-
dag outs, dag ins, string opcodestr, string argstr>
415-
: RVInstIBase<funct3, opcode, outs, ins, opcodestr, argstr> {
416-
let Inst{31} = imm7{6};
417-
let Inst{30} = imm5{4};
418-
let Inst{29-28} = imm7{5-4};
419-
let Inst{27-26} = imm5{3-2};
420-
let Inst{25-22} = imm7{3-0};
421-
let Inst{21-20} = imm5{1-0};
422-
}
423-
424-
class RVInstRMoprr<bits<4> imm4, bits<3> imm3, bits<3> funct3, RISCVOpcode opcode,
425-
dag outs, dag ins, string opcodestr, string argstr>
426-
: RVInstRBase<funct3, opcode, outs, ins, opcodestr, argstr> {
427-
let Inst{31} = imm4{3};
428-
let Inst{30} = imm3{2};
429-
let Inst{29-28} = imm4{2-1};
430-
let Inst{27-26} = imm3{1-0};
431-
let Inst{25} = imm4{0};
432-
}
433-
434413
class RVInstS<bits<3> funct3, RISCVOpcode opcode, dag outs, dag ins,
435414
string opcodestr, string argstr>
436415
: RVInst<outs, ins, opcodestr, argstr, [], InstFormatS> {

llvm/lib/Target/RISCV/RISCVInstrInfo.td

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -597,18 +597,6 @@ class Priv_rr<string opcodestr, bits<7> funct7>
597597
let rd = 0;
598598
}
599599

600-
let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
601-
class RVMopr<bits<7> imm7, bits<5> imm5, bits<3> funct3,
602-
RISCVOpcode opcode, string opcodestr>
603-
: RVInstIMopr<imm7, imm5, funct3, opcode, (outs GPR:$rd), (ins GPR:$rs1),
604-
opcodestr, "$rd, $rs1">;
605-
606-
let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
607-
class RVMoprr<bits<4> imm4, bits<3> imm3, bits<3> funct3,
608-
RISCVOpcode opcode, string opcodestr>
609-
: RVInstRMoprr<imm4, imm3, funct3, opcode, (outs GPR:$rd), (ins GPR:$rs1, GPR:$rs2),
610-
opcodestr, "$rd, $rs1, $rs2">;
611-
612600
//===----------------------------------------------------------------------===//
613601
// Instructions
614602
//===----------------------------------------------------------------------===//
@@ -798,22 +786,6 @@ def SRAW : ALUW_rr<0b0100000, 0b101, "sraw">,
798786
} // IsSignExtendingOpW = 1
799787
} // Predicates = [IsRV64]
800788

801-
// Zimop instructions
802-
803-
foreach i = 0...31 in {
804-
let Predicates = [HasStdExtZimop] in {
805-
def MOPR#i : RVMopr<0b1000111, i, 0b100, OPC_SYSTEM, "mop.r."#i>,
806-
Sched<[]>;
807-
} // Predicates = [HasStdExtZimop]
808-
}
809-
810-
foreach i = 0...7 in {
811-
let Predicates = [HasStdExtZimop] in {
812-
def MOPRR#i : RVMoprr<0b1001, i, 0b100, OPC_SYSTEM, "mop.rr."#i>,
813-
Sched<[]>;
814-
} // Predicates = [HasStdExtZimop]
815-
}
816-
817789
//===----------------------------------------------------------------------===//
818790
// Privileged instructions
819791
//===----------------------------------------------------------------------===//
@@ -2140,6 +2112,7 @@ include "RISCVInstrInfoV.td"
21402112
include "RISCVInstrInfoZvk.td"
21412113

21422114
// Integer
2115+
include "RISCVInstrInfoZimop.td"
21432116
include "RISCVInstrInfoZicbo.td"
21442117
include "RISCVInstrInfoZicond.td"
21452118

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
//===-- RISCVInstrInfoZimop.td -----------------------------*- tablegen -*-===//
2+
//
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
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file describes the RISC-V instructions from the standard
10+
// May-Be-Operations Extension (Zimop).
11+
// This version is still experimental as the 'Zimop' extension hasn't been
12+
// ratified yet. It is based on v0.1 of the specification.
13+
//
14+
//===----------------------------------------------------------------------===//
15+
16+
class RVInstIMopr<bits<7> imm7, bits<5> imm5, bits<3> funct3, RISCVOpcode opcode,
17+
dag outs, dag ins, string opcodestr, string argstr>
18+
: RVInstIBase<funct3, opcode, outs, ins, opcodestr, argstr> {
19+
let Inst{31} = imm7{6};
20+
let Inst{30} = imm5{4};
21+
let Inst{29-28} = imm7{5-4};
22+
let Inst{27-26} = imm5{3-2};
23+
let Inst{25-22} = imm7{3-0};
24+
let Inst{21-20} = imm5{1-0};
25+
}
26+
27+
class RVInstRMoprr<bits<4> imm4, bits<3> imm3, bits<3> funct3, RISCVOpcode opcode,
28+
dag outs, dag ins, string opcodestr, string argstr>
29+
: RVInstRBase<funct3, opcode, outs, ins, opcodestr, argstr> {
30+
let Inst{31} = imm4{3};
31+
let Inst{30} = imm3{2};
32+
let Inst{29-28} = imm4{2-1};
33+
let Inst{27-26} = imm3{1-0};
34+
let Inst{25} = imm4{0};
35+
}
36+
37+
let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
38+
class RVMopr<bits<7> imm7, bits<5> imm5, bits<3> funct3,
39+
RISCVOpcode opcode, string opcodestr>
40+
: RVInstIMopr<imm7, imm5, funct3, opcode, (outs GPR:$rd), (ins GPR:$rs1),
41+
opcodestr, "$rd, $rs1">;
42+
43+
let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
44+
class RVMoprr<bits<4> imm4, bits<3> imm3, bits<3> funct3,
45+
RISCVOpcode opcode, string opcodestr>
46+
: RVInstRMoprr<imm4, imm3, funct3, opcode, (outs GPR:$rd), (ins GPR:$rs1, GPR:$rs2),
47+
opcodestr, "$rd, $rs1, $rs2">;
48+
49+
foreach i = 0...31 in {
50+
let Predicates = [HasStdExtZimop] in
51+
def MOPR#i : RVMopr<0b1000111, i, 0b100, OPC_SYSTEM, "mop.r."#i>,
52+
Sched<[]>;
53+
}
54+
55+
foreach i = 0...7 in {
56+
let Predicates = [HasStdExtZimop] in
57+
def MOPRR#i : RVMoprr<0b1001, i, 0b100, OPC_SYSTEM, "mop.rr."#i>,
58+
Sched<[]>;
59+
}

0 commit comments

Comments
 (0)