[llvm] [RISCV] Use a switch in VSETVLIInfo::print(). NFC (PR #169441)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 24 17:51:54 PST 2025


https://github.com/topperc created https://github.com/llvm/llvm-project/pull/169441

This allows the compiler to verify we've covered all enum values.

>From 6e3c3d0adc2710e1f5d201bb78d0a53606cab2c5 Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Mon, 24 Nov 2025 17:50:00 -0800
Subject: [PATCH] [RISCV] Use a switch in VSETVLIInfo::print(). NFC

This allows the compiler to verify we've covered all enum values.
---
 llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

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;



More information about the llvm-commits mailing list