[llvm] [TableGen] Simplify PtrAddrSpace handling in TypeSetByHwMode. NFC (PR #218564)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 24 23:13:41 PDT 2026


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

>From 811231d375e4855d471de8f46de6eec9b074635b Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Mon, 24 Aug 2026 17:51:06 -0700
Subject: [PATCH] [TableGen] Simplify PtrAddrSpace handling in TypeSetByHwMode.
 NFC

The PtrAddrSpace field was previously unused and has been its entire
life. The AddrSpace field used to be vector, but was made a single
value in 83507644ed1c59d76ca0b1ffc3e837fcb3677e41.

Replace AddrSpace with PtrAddrSpace for clarity.

Remove unnecessary conversions to ValueTypeByHwMode to get the
pointer address space. The conversion copies the PtrAddrSpace directly
from the TypeSetByHwMode without modification.
---
 llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp | 4 ++--
 llvm/utils/TableGen/Common/CodeGenDAGPatterns.h   | 7 ++++---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
index 8278f63eb4041..c695213b5e9e4 100644
--- a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
+++ b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
@@ -78,7 +78,7 @@ void MachineValueTypeSet::writeToStream(raw_ostream &OS) const {
 TypeSetByHwMode::TypeSetByHwMode(ArrayRef<ValueTypeByHwMode> VTList) {
   // Take the address space from the first type in the list.
   if (!VTList.empty())
-    AddrSpace = VTList[0].PtrAddrSpace;
+    PtrAddrSpace = VTList[0].PtrAddrSpace;
 
   for (const ValueTypeByHwMode &VVT : VTList)
     insert(VVT);
@@ -98,7 +98,7 @@ ValueTypeByHwMode TypeSetByHwMode::getValueTypeByHwMode(bool SkipEmpty) const {
   assert(isValueTypeByHwMode(true) &&
          "The type set has multiple types for at least one HW mode");
   ValueTypeByHwMode VVT;
-  VVT.PtrAddrSpace = AddrSpace;
+  VVT.PtrAddrSpace = PtrAddrSpace;
 
   for (const auto &I : *this) {
     if (SkipEmpty && I.second.empty())
diff --git a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.h b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.h
index 1aee697e5d203..ac60ff0c398b2 100644
--- a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.h
+++ b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.h
@@ -180,7 +180,6 @@ raw_ostream &operator<<(raw_ostream &OS, const MachineValueTypeSet &T);
 
 struct TypeSetByHwMode : public InfoByHwMode<MachineValueTypeSet> {
   using SetType = MachineValueTypeSet;
-  unsigned AddrSpace = std::numeric_limits<unsigned>::max();
 
   TypeSetByHwMode() = default;
   TypeSetByHwMode(const TypeSetByHwMode &VTS) = default;
@@ -206,11 +205,13 @@ struct TypeSetByHwMode : public InfoByHwMode<MachineValueTypeSet> {
 
   bool isPossible() const;
 
-  bool isPointer() const { return getValueTypeByHwMode().isPointer(); }
+  bool isPointer() const {
+    return PtrAddrSpace != std::numeric_limits<unsigned>::max();
+  }
 
   unsigned getPtrAddrSpace() const {
     assert(isPointer());
-    return getValueTypeByHwMode().PtrAddrSpace;
+    return PtrAddrSpace;
   }
 
   bool insert(const ValueTypeByHwMode &VVT);



More information about the llvm-commits mailing list