[PATCH] D98136: [RISCV][RFC] Initially support the K-extension instructions on the LLVM MC layer

Xinlong Wu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 14 23:21:53 PDT 2021


VincentWu added inline comments.


================
Comment at: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:724
+    bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK);
+    return IsConstantImm && isUInt<4>(Imm + 5) &&
+           VK == RISCVMCExpr::VK_RISCV_None;
----------------
craig.topper wrote:
>  This line has undefined behavior if the user tries to pass a value near INT64_MAX since the +5 would wrap around which isn't undefined.
> 
> But I'm not sure it does what you want. This would accept -5, -4, -3, -2, and -1.
right it's my fault. I forgot the numbers -5~-1, the spec defines the range of number is [0,10], I limit the upper bound is `(1 << 4) -5` but forget it also causes the wrong lower bound. I will fix it soon.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98136/new/

https://reviews.llvm.org/D98136



More information about the llvm-commits mailing list