[Mlir-commits] [mlir] Fix tablegen bug with `Complex` class (PR #104974)

Alex Rice llvmlistbot at llvm.org
Tue Aug 20 07:51:45 PDT 2024


https://github.com/alexarice created https://github.com/llvm/llvm-project/pull/104974

The `Complex` class in tablegen tries to store its element type, but due to a name collision it actually ends up storing the `type` field of the `ConfinedType` superclass, and so `elementType` is always set to `AnyComplex`.

This renames the field so that it gets correctly set.

@math-fehr 

>From b2b88e5c13497d98ecae552782a9ec03ae3b919d Mon Sep 17 00:00:00 2001
From: Alex Rice <alexrice999 at hotmail.co.uk>
Date: Tue, 13 Aug 2024 17:44:00 +0100
Subject: [PATCH] Fix tablegen complex bug

---
 mlir/include/mlir/IR/CommonTypeConstraints.td | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/mlir/include/mlir/IR/CommonTypeConstraints.td b/mlir/include/mlir/IR/CommonTypeConstraints.td
index 70c3e485679e57..4536d781ef674f 100644
--- a/mlir/include/mlir/IR/CommonTypeConstraints.td
+++ b/mlir/include/mlir/IR/CommonTypeConstraints.td
@@ -348,16 +348,16 @@ def F8E3M4 : Type<CPred<"$_self.isFloat8E3M4()">, "f8E3M4 type">,
 def AnyComplex : Type<CPred<"::llvm::isa<::mlir::ComplexType>($_self)">,
                       "complex-type", "::mlir::ComplexType">;
 
-class Complex<Type type>
+class Complex<Type elType>
     : ConfinedType<AnyComplex, [
           SubstLeaves<"$_self",
                       "::llvm::cast<::mlir::ComplexType>($_self).getElementType()",
-           type.predicate>],
-           "complex type with " # type.summary # " elements",
+           elType.predicate>],
+           "complex type with " # elType.summary # " elements",
            "::mlir::ComplexType">,
-      SameBuildabilityAs<type, "::mlir::ComplexType::get($_builder.get" # type #
+      SameBuildabilityAs<elType, "::mlir::ComplexType::get($_builder.get" # elType #
                                "Type())"> {
-  Type elementType = type;
+  Type elementType = elType;
 }
 
 class OpaqueType<string dialect, string name, string summary>



More information about the Mlir-commits mailing list