-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[RISCV][NFC] Correct c_lui_imm #135448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RISCV][NFC] Correct c_lui_imm #135448
Conversation
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.
@llvm/pr-subscribers-backend-risc-v Author: Sam Elliott (lenary) ChangesThe MCOperandPredicate seems to allow symbols as well as immediates, but the parser/matcher does not due to Full diff: https://github.com/llvm/llvm-project/pull/135448.diff 2 Files Affected:
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoC.td b/llvm/lib/Target/RISCV/RISCVInstrInfoC.td
index fc036f6516116..252100c814f2b 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoC.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoC.td
@@ -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));
}];
}
diff --git a/llvm/test/MC/RISCV/rv32c-invalid.s b/llvm/test/MC/RISCV/rv32c-invalid.s
index 1027c08505d50..8dddbf887c87c 100644
--- a/llvm/test/MC/RISCV/rv32c-invalid.s
+++ b/llvm/test/MC/RISCV/rv32c-invalid.s
@@ -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]
|
@llvm/pr-subscribers-mc Author: Sam Elliott (lenary) ChangesThe MCOperandPredicate seems to allow symbols as well as immediates, but the parser/matcher does not due to Full diff: https://github.com/llvm/llvm-project/pull/135448.diff 2 Files Affected:
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoC.td b/llvm/lib/Target/RISCV/RISCVInstrInfoC.td
index fc036f6516116..252100c814f2b 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoC.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoC.td
@@ -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));
}];
}
diff --git a/llvm/test/MC/RISCV/rv32c-invalid.s b/llvm/test/MC/RISCV/rv32c-invalid.s
index 1027c08505d50..8dddbf887c87c 100644
--- a/llvm/test/MC/RISCV/rv32c-invalid.s
+++ b/llvm/test/MC/RISCV/rv32c-invalid.s
@@ -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]
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/186/builds/8154 Here is the relevant piece of the build log for the reference
|
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 alui
with a symbol, which cannot be emitted as ac.lui
as there are no relocations for this asR_RISCV_RVC_LUI
is deprecated/removed.