[llvm] [RISCV] Use a switch in VSETVLIInfo::print(). NFC (PR #169441)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 24 17:52:24 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-risc-v
Author: Craig Topper (topperc)
<details>
<summary>Changes</summary>
This allows the compiler to verify we've covered all enum values.
---
Full diff: https://github.com/llvm/llvm-project/pull/169441.diff
1 Files Affected:
- (modified) llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp (+12-5)
``````````diff
diff --git a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
index e5819d90526d9..2ddc9b0adb9e1 100644
--- a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
@@ -838,16 +838,23 @@ class VSETVLIInfo {
/// @{
void print(raw_ostream &OS) const {
OS << "{";
- if (!isValid())
+ switch (State) {
+ case Uninitialized:
OS << "Uninitialized";
- if (isUnknown())
+ break;
+ case Unknown:
OS << "unknown";
- if (hasAVLReg())
+ break;
+ case AVLIsReg:
OS << "AVLReg=" << llvm::printReg(getAVLReg());
- if (hasAVLImm())
+ break;
+ case AVLIsImm:
OS << "AVLImm=" << (unsigned)AVLImm;
- if (hasAVLVLMAX())
+ break;
+ case AVLIsVLMAX:
OS << "AVLVLMAX";
+ break;
+ }
OS << ", ";
unsigned LMul;
``````````
</details>
https://github.com/llvm/llvm-project/pull/169441
More information about the llvm-commits
mailing list