Skip to content

Conversation

@topperc
Copy link
Collaborator

@topperc topperc commented Jan 2, 2026

These were the only uses of getType. Both of these calls are after HwMode has been expanded so we can use getSimpleType like other code.

Remove getType since it is now unused.

While there, simplify the hasBFloatType to use getScalarType for the scalar and vector case.

These were the only uses of getType. Both of these calls are after
HwMode has been expanded so we can use getSimpleTye like other code.

Remove getType since it is now unused.

While there, simplify the hasBFloatType to use getScalarType for the
scalar and vector case.
@llvmbot
Copy link
Member

llvmbot commented Jan 2, 2026

@llvm/pr-subscribers-llvm-globalisel

Author: Craig Topper (topperc)

Changes

These were the only uses of getType. Both of these calls are after HwMode has been expanded so we can use getSimpleType like other code.

Remove getType since it is now unused.

While there, simplify the hasBFloatType to use getScalarType for the scalar and vector case.


Full diff: https://github.com/llvm/llvm-project/pull/174231.diff

3 Files Affected:

  • (modified) llvm/utils/TableGen/Common/CodeGenDAGPatterns.h (-3)
  • (modified) llvm/utils/TableGen/FastISelEmitter.cpp (+2-4)
  • (modified) llvm/utils/TableGen/GlobalISelEmitter.cpp (+3-5)
diff --git a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.h b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.h
index f65f0e7ddbc98..a624f938e8564 100644
--- a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.h
+++ b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.h
@@ -681,9 +681,6 @@ class TreePatternNode : public RefCountedBase<TreePatternNode> {
 
   // Type accessors.
   unsigned getNumTypes() const { return Types.size(); }
-  ValueTypeByHwMode getType(unsigned ResNo) const {
-    return Types[ResNo].getValueTypeByHwMode();
-  }
   const std::vector<TypeSetByHwMode> &getExtTypes() const { return Types; }
   const TypeSetByHwMode &getExtType(unsigned ResNo) const {
     return Types[ResNo];
diff --git a/llvm/utils/TableGen/FastISelEmitter.cpp b/llvm/utils/TableGen/FastISelEmitter.cpp
index d7f21f1c4e7ef..381e857fca822 100644
--- a/llvm/utils/TableGen/FastISelEmitter.cpp
+++ b/llvm/utils/TableGen/FastISelEmitter.cpp
@@ -175,10 +175,8 @@ struct OperandsSignature {
 
       // Emit the type check.
       TreePattern *TP = PredFn.getOrigPatFragRecord();
-      ValueTypeByHwMode VVT = TP->getTree(0)->getType(0);
-      assert(VVT.isSimple() &&
-             "Cannot use variable value types with fast isel");
-      OS << LS << "VT == " << getEnumName(VVT.getSimple().SimpleTy) << " && ";
+      MVT VT = TP->getTree(0)->getSimpleType(0);
+      OS << LS << "VT == " << getEnumName(VT) << " && ";
 
       OS << PredFn.getFnName() << "(imm" << Idx << ')';
     }
diff --git a/llvm/utils/TableGen/GlobalISelEmitter.cpp b/llvm/utils/TableGen/GlobalISelEmitter.cpp
index bd79c423a00e2..84024ec086808 100644
--- a/llvm/utils/TableGen/GlobalISelEmitter.cpp
+++ b/llvm/utils/TableGen/GlobalISelEmitter.cpp
@@ -2412,11 +2412,9 @@ void GlobalISelEmitter::emitRunCustomAction(raw_ostream &OS) {
 
 bool hasBFloatType(const TreePatternNode &Node) {
   for (unsigned I = 0, E = Node.getNumTypes(); I < E; I++) {
-    auto Ty = Node.getType(I);
-    for (auto T : Ty)
-      if (T.second == MVT::bf16 ||
-          (T.second.isVector() && T.second.getScalarType() == MVT::bf16))
-        return true;
+    MVT VT = Node.getSimpleType(I);
+    if (VT.getScalarType() == MVT::bf16)
+      return true;
   }
   for (const TreePatternNode &C : Node.children())
     if (hasBFloatType(C))

@llvmbot
Copy link
Member

llvmbot commented Jan 2, 2026

@llvm/pr-subscribers-tablegen

Author: Craig Topper (topperc)

Changes

These were the only uses of getType. Both of these calls are after HwMode has been expanded so we can use getSimpleType like other code.

Remove getType since it is now unused.

While there, simplify the hasBFloatType to use getScalarType for the scalar and vector case.


Full diff: https://github.com/llvm/llvm-project/pull/174231.diff

3 Files Affected:

  • (modified) llvm/utils/TableGen/Common/CodeGenDAGPatterns.h (-3)
  • (modified) llvm/utils/TableGen/FastISelEmitter.cpp (+2-4)
  • (modified) llvm/utils/TableGen/GlobalISelEmitter.cpp (+3-5)
diff --git a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.h b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.h
index f65f0e7ddbc98..a624f938e8564 100644
--- a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.h
+++ b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.h
@@ -681,9 +681,6 @@ class TreePatternNode : public RefCountedBase<TreePatternNode> {
 
   // Type accessors.
   unsigned getNumTypes() const { return Types.size(); }
-  ValueTypeByHwMode getType(unsigned ResNo) const {
-    return Types[ResNo].getValueTypeByHwMode();
-  }
   const std::vector<TypeSetByHwMode> &getExtTypes() const { return Types; }
   const TypeSetByHwMode &getExtType(unsigned ResNo) const {
     return Types[ResNo];
diff --git a/llvm/utils/TableGen/FastISelEmitter.cpp b/llvm/utils/TableGen/FastISelEmitter.cpp
index d7f21f1c4e7ef..381e857fca822 100644
--- a/llvm/utils/TableGen/FastISelEmitter.cpp
+++ b/llvm/utils/TableGen/FastISelEmitter.cpp
@@ -175,10 +175,8 @@ struct OperandsSignature {
 
       // Emit the type check.
       TreePattern *TP = PredFn.getOrigPatFragRecord();
-      ValueTypeByHwMode VVT = TP->getTree(0)->getType(0);
-      assert(VVT.isSimple() &&
-             "Cannot use variable value types with fast isel");
-      OS << LS << "VT == " << getEnumName(VVT.getSimple().SimpleTy) << " && ";
+      MVT VT = TP->getTree(0)->getSimpleType(0);
+      OS << LS << "VT == " << getEnumName(VT) << " && ";
 
       OS << PredFn.getFnName() << "(imm" << Idx << ')';
     }
diff --git a/llvm/utils/TableGen/GlobalISelEmitter.cpp b/llvm/utils/TableGen/GlobalISelEmitter.cpp
index bd79c423a00e2..84024ec086808 100644
--- a/llvm/utils/TableGen/GlobalISelEmitter.cpp
+++ b/llvm/utils/TableGen/GlobalISelEmitter.cpp
@@ -2412,11 +2412,9 @@ void GlobalISelEmitter::emitRunCustomAction(raw_ostream &OS) {
 
 bool hasBFloatType(const TreePatternNode &Node) {
   for (unsigned I = 0, E = Node.getNumTypes(); I < E; I++) {
-    auto Ty = Node.getType(I);
-    for (auto T : Ty)
-      if (T.second == MVT::bf16 ||
-          (T.second.isVector() && T.second.getScalarType() == MVT::bf16))
-        return true;
+    MVT VT = Node.getSimpleType(I);
+    if (VT.getScalarType() == MVT::bf16)
+      return true;
   }
   for (const TreePatternNode &C : Node.children())
     if (hasBFloatType(C))

Copy link
Contributor

@s-barannikov s-barannikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@topperc topperc merged commit 7eed4d2 into llvm:main Jan 2, 2026
12 of 13 checks passed
@topperc topperc deleted the pr/getSimpleType branch January 2, 2026 19:05
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Jan 6, 2026
…llvm#174231)

These were the only uses of getType. Both of these calls are after
HwMode has been expanded so we can use getSimpleType like other code.

Remove getType since it is now unused.

While there, simplify the hasBFloatType to use getScalarType for the
scalar and vector case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants