Skip to content

Commit f0dc236

Browse files
authored
[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.
1 parent 75dea80 commit f0dc236

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfoC.td

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ def c_lui_imm : RISCVOp,
8585
let OperandType = "OPERAND_CLUI_IMM";
8686
let MCOperandPredicate = [{
8787
int64_t Imm;
88-
if (MCOp.evaluateAsConstantImm(Imm))
89-
return (Imm != 0) && (isUInt<5>(Imm) ||
90-
(Imm >= 0xfffe0 && Imm <= 0xfffff));
91-
return MCOp.isBareSymbolRef();
88+
if (!MCOp.evaluateAsConstantImm(Imm))
89+
return false;
90+
return (Imm != 0) && (isUInt<5>(Imm) ||
91+
(Imm >= 0xfffe0 && Imm <= 0xfffff));
9292
}];
9393
}
9494

llvm/test/MC/RISCV/rv32c-invalid.s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ c.lui t0, 0 # CHECK: :[[@LINE]]:11: error: immediate must be in [0xfffe0, 0xffff
6969
c.lui t0, 32 # CHECK: :[[@LINE]]:11: error: immediate must be in [0xfffe0, 0xfffff] or [1, 31]
7070
c.lui t0, 0xffffdf # CHECK: :[[@LINE]]:11: error: immediate must be in [0xfffe0, 0xfffff] or [1, 31]
7171
c.lui t0, 0x1000000 # CHECK: :[[@LINE]]:11: error: immediate must be in [0xfffe0, 0xfffff] or [1, 31]
72+
c.lui t0, foo # CHECK: [[@LINE]]:11: error: immediate must be in [0xfffe0, 0xfffff] or [1, 31]
7273

7374
## uimm8_lsb00
7475
c.lwsp ra, 256(sp) # CHECK: :[[@LINE]]:13: error: immediate must be a multiple of 4 bytes in the range [0, 252]

0 commit comments

Comments
 (0)