[llvm] [RISCV] Use RVInst16CB for C_SRLI64_HINT and C_SRAI64_HINT. (PR #112250)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 14 12:38:47 PDT 2024
https://github.com/topperc created https://github.com/llvm/llvm-project/pull/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 use RVInst16CB.
The "let Inst{11-10} =" prevented this from causing any functional issues by dropping the upper 2 bits of the reigster. The ins/outs list uses GPRC so the register class is constrained.
>From 4008b007774c650239af096a6a24ec5cedc18c95 Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Mon, 14 Oct 2024 12:33:42 -0700
Subject: [PATCH] [RISCV] Use RVInst16CB for C_SRLI64_HINT and C_SRAI64_HINT.
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.
The "let Inst{11-10} =" prevented this from causing any functional
issues by dropping the upper 2 bits of the reigster. The ins/outs list
uses GPRC so the register class is constrained.
---
llvm/lib/Target/RISCV/RISCVInstrInfoC.td | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoC.td b/llvm/lib/Target/RISCV/RISCVInstrInfoC.td
index 7d742322b42969..c9f880f1565192 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoC.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoC.td
@@ -705,23 +705,23 @@ def C_SLLI64_HINT : RVInst16CI<0b000, 0b10, (outs GPR:$rd_wb), (ins GPR:$rd),
let Inst{12} = 0;
}
-def C_SRLI64_HINT : RVInst16CI<0b100, 0b01, (outs GPRC:$rd_wb),
- (ins GPRC:$rd),
- "c.srli64", "$rd">,
+def C_SRLI64_HINT : RVInst16CB<0b100, 0b01, (outs GPRC:$rs1_wb),
+ (ins GPRC:$rs1),
+ "c.srli64", "$rs1">,
Sched<[WriteShiftImm, ReadShiftImm]> {
- let Constraints = "$rd = $rd_wb";
+ let Constraints = "$rs1 = $rs1_wb";
let Inst{6-2} = 0;
- let Inst{11-10} = 0;
+ let Inst{11-10} = 0b00;
let Inst{12} = 0;
}
-def C_SRAI64_HINT : RVInst16CI<0b100, 0b01, (outs GPRC:$rd_wb),
- (ins GPRC:$rd),
- "c.srai64", "$rd">,
+def C_SRAI64_HINT : RVInst16CB<0b100, 0b01, (outs GPRC:$rs1_wb),
+ (ins GPRC:$rs1),
+ "c.srai64", "$rs1">,
Sched<[WriteShiftImm, ReadShiftImm]> {
- let Constraints = "$rd = $rd_wb";
+ let Constraints = "$rs1 = $rs1_wb";
let Inst{6-2} = 0;
- let Inst{11-10} = 1;
+ let Inst{11-10} = 0b01;
let Inst{12} = 0;
}
More information about the llvm-commits
mailing list