Skip to content

Commit 4a76c20

Browse files
committed
[RISCV] Reduce arguments for CVStore_rr_inc and CVStore_rr clases in RISCVInstrInfoXCV.td. NFC
The ins, outs, and argstr for all instantiations of the classes are the same so just make them part of the class.
1 parent 016557f commit 4a76c20

File tree

1 file changed

+19
-37
lines changed

1 file changed

+19
-37
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td

Lines changed: 19 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,8 @@ class CVLoad_rr<bits<7> funct7, bits<3> funct3, string opcodestr>
555555
let DecoderNamespace = "XCV";
556556
}
557557

558-
let Predicates = [HasVendorXCVmem, IsRV32], hasSideEffects = 0,
559-
mayLoad = 1, mayStore = 0, Constraints = "$rs1_wb = $rs1" in {
558+
let Predicates = [HasVendorXCVmem, IsRV32], hasSideEffects = 0, mayLoad = 1,
559+
mayStore = 0 in {
560560
// Register-Immediate load with post-increment
561561
def CV_LB_ri_inc : CVLoad_ri_inc<0b000, "cv.lb">;
562562
def CV_LBU_ri_inc : CVLoad_ri_inc<0b100, "cv.lbu">;
@@ -570,10 +570,7 @@ let Predicates = [HasVendorXCVmem, IsRV32], hasSideEffects = 0,
570570
def CV_LH_rr_inc : CVLoad_rr_inc<0b0000001, 0b011, "cv.lh">;
571571
def CV_LHU_rr_inc : CVLoad_rr_inc<0b0001001, 0b011, "cv.lhu">;
572572
def CV_LW_rr_inc : CVLoad_rr_inc<0b0000010, 0b011, "cv.lw">;
573-
}
574573

575-
let Predicates = [HasVendorXCVmem, IsRV32], hasSideEffects = 0,
576-
mayLoad = 1, mayStore = 0 in {
577574
// Register-Register load
578575
def CV_LB_rr : CVLoad_rr<0b0000100, 0b011, "cv.lb">;
579576
def CV_LBU_rr : CVLoad_rr<0b0001100, 0b011, "cv.lbu">;
@@ -583,16 +580,16 @@ let Predicates = [HasVendorXCVmem, IsRV32], hasSideEffects = 0,
583580
}
584581

585582
class CVStore_ri_inc<bits<3> funct3, string opcodestr>
586-
: RVInstS<funct3, OPC_CUSTOM_1, (outs GPR:$rs1_wb),
583+
: RVInstS<funct3, OPC_CUSTOM_1, (outs GPR:$rs1_wb),
587584
(ins GPR:$rs2, GPR:$rs1, simm12:$imm12),
588585
opcodestr, "$rs2, (${rs1}), ${imm12}"> {
589586
let Constraints = "$rs1_wb = $rs1";
590587
let DecoderNamespace = "XCV";
591588
}
592589

593-
class CVStore_rr_inc<bits<3> funct3, bits<7> funct7, dag outs, dag ins,
594-
string opcodestr, string argstr>
595-
: RVInst<outs, ins, opcodestr, argstr, [], InstFormatOther> {
590+
class CVStore_rr_inc<bits<3> funct3, bits<7> funct7, string opcodestr>
591+
: RVInst<(outs GPR:$rs1_wb), (ins GPR:$rs2, GPR:$rs1, GPR:$rs3), opcodestr,
592+
"$rs2, (${rs1}), ${rs3}", [], InstFormatOther> {
596593
bits<5> rs3;
597594
bits<5> rs2;
598595
bits<5> rs1;
@@ -603,13 +600,14 @@ class CVStore_rr_inc<bits<3> funct3, bits<7> funct7, dag outs, dag ins,
603600
let Inst{14-12} = funct3;
604601
let Inst{11-7} = rs3;
605602
let Inst{6-0} = OPC_CUSTOM_1.Value;
603+
let Constraints = "$rs1_wb = $rs1";
606604
let DecoderNamespace = "XCV";
607605
}
608606

609607

610-
class CVStore_rr<bits<3> funct3, bits<7> funct7, dag outs, dag ins,
611-
string opcodestr, string argstr>
612-
: RVInst<outs, ins, opcodestr, argstr, [], InstFormatOther> {
608+
class CVStore_rr<bits<3> funct3, bits<7> funct7, string opcodestr>
609+
: RVInst<(outs), (ins GPR:$rs2, CVrr:$cvrr), opcodestr, "$rs2, $cvrr", [],
610+
InstFormatOther> {
613611
bits<5> rs2;
614612
bits<10> cvrr;
615613

@@ -622,39 +620,23 @@ class CVStore_rr<bits<3> funct3, bits<7> funct7, dag outs, dag ins,
622620
let DecoderNamespace = "XCV";
623621
}
624622

625-
let Predicates = [HasVendorXCVmem, IsRV32], hasSideEffects = 0,
626-
mayLoad = 0, mayStore = 1, Constraints = "$rs1_wb = $rs1" in {
623+
let Predicates = [HasVendorXCVmem, IsRV32], hasSideEffects = 0, mayLoad = 0,
624+
mayStore = 1 in {
627625
// Register-Immediate store with post-increment
628626
def CV_SB_ri_inc : CVStore_ri_inc<0b000, "cv.sb">;
629627
def CV_SH_ri_inc : CVStore_ri_inc<0b001, "cv.sh">;
630628
def CV_SW_ri_inc : CVStore_ri_inc<0b010, "cv.sw">;
631629

632630
// Register-Register store with post-increment
633-
def CV_SB_rr_inc : CVStore_rr_inc<0b011, 0b0010000,
634-
(outs GPR:$rs1_wb), (ins GPR:$rs2, GPR:$rs1, GPR:$rs3),
635-
"cv.sb", "$rs2, (${rs1}), ${rs3}">;
636-
def CV_SH_rr_inc : CVStore_rr_inc<0b011, 0b0010001,
637-
(outs GPR:$rs1_wb), (ins GPR:$rs2, GPR:$rs1, GPR:$rs3),
638-
"cv.sh", "$rs2, (${rs1}), ${rs3}">;
639-
def CV_SW_rr_inc : CVStore_rr_inc<0b011, 0b0010010,
640-
(outs GPR:$rs1_wb), (ins GPR:$rs2, GPR:$rs1, GPR:$rs3),
641-
"cv.sw", "$rs2, (${rs1}), ${rs3}">;
642-
}
631+
def CV_SB_rr_inc : CVStore_rr_inc<0b011, 0b0010000, "cv.sb">;
632+
def CV_SH_rr_inc : CVStore_rr_inc<0b011, 0b0010001, "cv.sh">;
633+
def CV_SW_rr_inc : CVStore_rr_inc<0b011, 0b0010010, "cv.sw">;
643634

644-
645-
let Predicates = [HasVendorXCVmem, IsRV32], hasSideEffects = 0,
646-
mayLoad = 0, mayStore = 1 in {
647635
// Register-Register store
648-
def CV_SB_rr : CVStore_rr<0b011, 0b0010100,
649-
(outs), (ins GPR:$rs2, CVrr:$cvrr),
650-
"cv.sb", "$rs2, $cvrr">;
651-
def CV_SH_rr : CVStore_rr<0b011, 0b0010101,
652-
(outs), (ins GPR:$rs2, CVrr:$cvrr),
653-
"cv.sh", "$rs2, $cvrr">;
654-
def CV_SW_rr : CVStore_rr<0b011, 0b0010110,
655-
(outs), (ins GPR:$rs2, CVrr:$cvrr),
656-
"cv.sw", "$rs2, $cvrr">;
657-
}
636+
def CV_SB_rr : CVStore_rr<0b011, 0b0010100, "cv.sb">;
637+
def CV_SH_rr : CVStore_rr<0b011, 0b0010101, "cv.sh">;
638+
def CV_SW_rr : CVStore_rr<0b011, 0b0010110, "cv.sw">;
639+
}
658640

659641
let DecoderNamespace = "XCV" in
660642
class CVLoad_ri<bits<3> funct3, string opcodestr>

0 commit comments

Comments
 (0)