[llvm] 057c063 - [RISCV] Add a encodeLMUL function to RISCVVType. NFC
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 12 13:50:36 PDT 2022
Author: Craig Topper
Date: 2022-04-12T13:39:47-07:00
New Revision: 057c063c9b0638916adffe53767242bdf507d129
URL: https://github.com/llvm/llvm-project/commit/057c063c9b0638916adffe53767242bdf507d129
DIFF: https://github.com/llvm/llvm-project/commit/057c063c9b0638916adffe53767242bdf507d129.diff
LOG: [RISCV] Add a encodeLMUL function to RISCVVType. NFC
This moves the encoding handling out of the assembly parser.
Reviewed By: khchen, frasercrmck
Differential Revision: https://reviews.llvm.org/D123553
Added:
Modified:
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index 2954f9d1a1f6f..ffa30b27756f9 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -1776,9 +1776,7 @@ OperandMatchResultTy RISCVAsmParser::parseVTypeI(OperandVector &Operands) {
else
goto MatchFail;
- unsigned LmulLog2 = Log2_32(Lmul);
- RISCVII::VLMUL VLMUL =
- static_cast<RISCVII::VLMUL>(Fractional ? 8 - LmulLog2 : LmulLog2);
+ RISCVII::VLMUL VLMUL = RISCVVType::encodeLMUL(Lmul, Fractional);
unsigned VTypeI =
RISCVVType::encodeVTYPE(VLMUL, Sew, TailAgnostic, MaskAgnostic);
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
index 5826a2c2a4ef4..56c217eb77e66 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
@@ -383,6 +383,12 @@ inline static RISCVII::VLMUL getVLMUL(unsigned VType) {
// Decode VLMUL into 1,2,4,8 and fractional indicator.
std::pair<unsigned, bool> decodeVLMUL(RISCVII::VLMUL VLMUL);
+inline static RISCVII::VLMUL encodeLMUL(unsigned LMUL, bool Fractional) {
+ assert(isValidLMUL(LMUL, Fractional) && "Unsupported LMUL");
+ unsigned LmulLog2 = Log2_32(LMUL);
+ return static_cast<RISCVII::VLMUL>(Fractional ? 8 - LmulLog2 : LmulLog2);
+}
+
inline static unsigned decodeVSEW(unsigned VSEW) {
assert(VSEW < 8 && "Unexpected VSEW value");
return 1 << (VSEW + 3);
More information about the llvm-commits
mailing list