[llvm] [ValueTypes] Remove MVT::MAX_ALLOWED_VALUETYPE. NFC (PR #93654)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed May 29 09:02:45 PDT 2024


https://github.com/topperc updated https://github.com/llvm/llvm-project/pull/93654

>From b5129828c3fec0413428196522fe9279b914c593 Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Tue, 28 May 2024 23:44:40 -0700
Subject: [PATCH] [ValueTypes] Remove MVT::MAX_ALLOWED_VALUETYPE. NFC

Despite the comment, this isn't used to size bit vectors or tables.
That's done by VALUETYPE_SIZE. MAX_ALLOWED_VALUETYPE is only used by
some static_asserts that compare it to VALUETYPE_SIZE.

This patch removes it and most of the static_asserts. I left one
where I compared VALUETYPE_SIZE to token which is the first type
that isn't part of the VALUETYPE range. This isn't strictly needed,
we'd probably catch duplication error from VTEmitter.cpp first.

I've removed the hardcoded 224 that was present in tablegen by
adding a new bit to the ValueType class to mark value types that
should be excluded from the VALUETYPE range.

While here I've converted the 'is*' flags to bits and used getValueAsBit
instead of getValueAsInt. I can make this a separate change if desired.
---
 llvm/include/llvm/CodeGenTypes/MachineValueType.h | 7 +------
 llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h     | 2 --
 llvm/lib/CodeGen/TargetLoweringBase.cpp           | 3 ---
 3 files changed, 1 insertion(+), 11 deletions(-)

diff --git a/llvm/include/llvm/CodeGenTypes/MachineValueType.h b/llvm/include/llvm/CodeGenTypes/MachineValueType.h
index 3b2a9b535c0945..e008503f734b95 100644
--- a/llvm/include/llvm/CodeGenTypes/MachineValueType.h
+++ b/llvm/include/llvm/CodeGenTypes/MachineValueType.h
@@ -45,15 +45,10 @@ namespace llvm {
 #undef GET_VT_RANGES
 
       VALUETYPE_SIZE = LAST_VALUETYPE + 1,
-
-      // This is the current maximum for LAST_VALUETYPE.
-      // MVT::MAX_ALLOWED_VALUETYPE is used for asserts and to size bit vectors
-      // This value must be a multiple of 32.
-      MAX_ALLOWED_VALUETYPE = 224,
     };
 
     static_assert(FIRST_VALUETYPE > 0);
-    static_assert(LAST_VALUETYPE < MAX_ALLOWED_VALUETYPE);
+    static_assert(LAST_VALUETYPE < token);
 
     SimpleValueType SimpleTy = INVALID_SIMPLE_VALUE_TYPE;
 
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h b/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
index ba3c7582d5a8a2..bec9cb49b58649 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
@@ -168,8 +168,6 @@ class LLVM_LIBRARY_VISIBILITY DAGTypeLegalizer {
   explicit DAGTypeLegalizer(SelectionDAG &dag)
     : TLI(dag.getTargetLoweringInfo()), DAG(dag),
     ValueTypeActions(TLI.getValueTypeActions()) {
-    static_assert(MVT::LAST_VALUETYPE <= MVT::MAX_ALLOWED_VALUETYPE,
-                  "Too many value types for ValueTypeActions to hold!");
   }
 
   /// This is the main entry point for the type legalizer.  This does a
diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp
index 82a59918b085b3..f2e4632b248f4b 100644
--- a/llvm/lib/CodeGen/TargetLoweringBase.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp
@@ -1430,9 +1430,6 @@ TargetLoweringBase::findRepresentativeClass(const TargetRegisterInfo *TRI,
 /// this allows us to compute derived properties we expose.
 void TargetLoweringBase::computeRegisterProperties(
     const TargetRegisterInfo *TRI) {
-  static_assert(MVT::VALUETYPE_SIZE <= MVT::MAX_ALLOWED_VALUETYPE,
-                "Too many value types for ValueTypeActions to hold!");
-
   // Everything defaults to needing one register.
   for (unsigned i = 0; i != MVT::VALUETYPE_SIZE; ++i) {
     NumRegistersForVT[i] = 1;



More information about the llvm-commits mailing list