[RISCV][NFC] Correct c_lui_imm (#135448)

The MCOperandPredicate seems to allow symbols as well as immediates, but
the parser/matcher does not due to `isCLUIImm`. This brings both in line
with each other, and should prevent trying to compress a `lui` with a
symbol, which cannot be emitted as a `c.lui` as there are no relocations
for this as `R_RISCV_RVC_LUI` is deprecated/removed.
This commit is contained in:
Sam Elliott 2025-04-12 13:57:29 -07:00 committed by GitHub
parent 75dea80085
commit f0dc236d33
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 4 deletions

View File

@ -85,10 +85,10 @@ def c_lui_imm : RISCVOp,
let OperandType = "OPERAND_CLUI_IMM";
let MCOperandPredicate = [{
int64_t Imm;
if (MCOp.evaluateAsConstantImm(Imm))
return (Imm != 0) && (isUInt<5>(Imm) ||
(Imm >= 0xfffe0 && Imm <= 0xfffff));
return MCOp.isBareSymbolRef();
if (!MCOp.evaluateAsConstantImm(Imm))
return false;
return (Imm != 0) && (isUInt<5>(Imm) ||
(Imm >= 0xfffe0 && Imm <= 0xfffff));
}];
}

View File

@ -69,6 +69,7 @@ c.lui t0, 0 # CHECK: :[[@LINE]]:11: error: immediate must be in [0xfffe0, 0xffff
c.lui t0, 32 # CHECK: :[[@LINE]]:11: error: immediate must be in [0xfffe0, 0xfffff] or [1, 31]
c.lui t0, 0xffffdf # CHECK: :[[@LINE]]:11: error: immediate must be in [0xfffe0, 0xfffff] or [1, 31]
c.lui t0, 0x1000000 # CHECK: :[[@LINE]]:11: error: immediate must be in [0xfffe0, 0xfffff] or [1, 31]
c.lui t0, foo # CHECK: [[@LINE]]:11: error: immediate must be in [0xfffe0, 0xfffff] or [1, 31]
## uimm8_lsb00
c.lwsp ra, 256(sp) # CHECK: :[[@LINE]]:13: error: immediate must be a multiple of 4 bytes in the range [0, 252]