[clang] [llvm] [RISC-V][MC] Introduce initial support for RVY (CHERI) (PR #199771)
Craig Topper via cfe-commits
cfe-commits at lists.llvm.org
Tue May 26 19:10:37 PDT 2026
================
@@ -239,6 +239,31 @@ static DecodeStatus DecodeTRM4RegisterClass(MCInst &Inst, uint32_t RegNo,
return MCDisassembler::Success;
}
+static DecodeStatus DecodeYBNDSWImm(MCInst &Inst, uint64_t Imm, int64_t Address,
+ const MCDisassembler *Decoder) {
+ assert(isUInt<9>(Imm) && "Invalid immediate");
+ uint64_t Result;
+ if (Imm == 0) {
+ // If imm[8:0] == 0, result is 4096.
+ Result = 4096;
+ } else if (Imm <= 255) {
+ // If imm[8] == 0 and imm[7:0] != 0, result is imm[7:0].
+ Result = Imm;
+ } else {
+ uint64_t Imm7To5 = (Imm & 0xFF) >> 5;
+ if (Imm7To5 == 0) {
+ // If imm[8] == 1 and imm[7:5] == 0, result is
+ // `256 | (imm[3:0] << 4) | (imm[4] << 3)`.
+ Result = 256 + ((Imm & 0xF) << 4) + (((Imm >> 4) & 1) << 3);
+ } else {
+ // Otherwise, result is imm[7:0] << 4.
----------------
topperc wrote:
The next line uses `Imm7To5` which only contains bits 7:5 of immediate in its lsbs, right?
https://github.com/llvm/llvm-project/pull/199771
More information about the cfe-commits
mailing list