Skip to content

Commit 1c17484

Browse files
authored
[RISCV] Use RVInst16CB for C_SRLI64_HINT and C_SRAI64_HINT. (#112250)
c.srli(64) and c.srai(64) are encoded differently than c.slli(64). The former have a 3-bit register, while the latter has a 5-bit register. c.srli and c.srai already use RVInst16CB. The "let Inst{11-10} =" prevented this from causing any functional issues by dropping the upper 2 bits of the register. The ins/outs list uses GPRC so the register class is constrained.
1 parent b8ee0aa commit 1c17484

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfoC.td

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -707,23 +707,23 @@ def C_SLLI64_HINT : RVInst16CI<0b000, 0b10, (outs GPR:$rd_wb), (ins GPR:$rd),
707707
let Inst{12} = 0;
708708
}
709709

710-
def C_SRLI64_HINT : RVInst16CI<0b100, 0b01, (outs GPRC:$rd_wb),
711-
(ins GPRC:$rd),
712-
"c.srli64", "$rd">,
710+
def C_SRLI64_HINT : RVInst16CB<0b100, 0b01, (outs GPRC:$rs1_wb),
711+
(ins GPRC:$rs1),
712+
"c.srli64", "$rs1">,
713713
Sched<[WriteShiftImm, ReadShiftImm]> {
714-
let Constraints = "$rd = $rd_wb";
714+
let Constraints = "$rs1 = $rs1_wb";
715715
let Inst{6-2} = 0;
716-
let Inst{11-10} = 0;
716+
let Inst{11-10} = 0b00;
717717
let Inst{12} = 0;
718718
}
719719

720-
def C_SRAI64_HINT : RVInst16CI<0b100, 0b01, (outs GPRC:$rd_wb),
721-
(ins GPRC:$rd),
722-
"c.srai64", "$rd">,
720+
def C_SRAI64_HINT : RVInst16CB<0b100, 0b01, (outs GPRC:$rs1_wb),
721+
(ins GPRC:$rs1),
722+
"c.srai64", "$rs1">,
723723
Sched<[WriteShiftImm, ReadShiftImm]> {
724-
let Constraints = "$rd = $rd_wb";
724+
let Constraints = "$rs1 = $rs1_wb";
725725
let Inst{6-2} = 0;
726-
let Inst{11-10} = 1;
726+
let Inst{11-10} = 0b01;
727727
let Inst{12} = 0;
728728
}
729729

0 commit comments

Comments
 (0)