[Mlir-commits] [mlir] 83f3c61 - Add missing storageType to AttrDef to ODS

Mehdi Amini llvmlistbot at llvm.org
Thu Sep 23 18:30:39 PDT 2021


Author: Mehdi Amini
Date: 2021-09-24T01:30:29Z
New Revision: 83f3c615dde3fce5c0560c19316b08c1e6aa8c27

URL: https://github.com/llvm/llvm-project/commit/83f3c615dde3fce5c0560c19316b08c1e6aa8c27
DIFF: https://github.com/llvm/llvm-project/commit/83f3c615dde3fce5c0560c19316b08c1e6aa8c27.diff

LOG: Add missing storageType to AttrDef to ODS

This is only noticeable when using an attribute across dialects I think.
Previously the namespace would be ommited, but it wouldn't matter as
long as the generated code stays within a single namespace.

Differential Revision: https://reviews.llvm.org/D110367

Added: 
    

Modified: 
    mlir/include/mlir/IR/OpBase.td
    mlir/test/mlir-tblgen/op-attribute.td

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td
index 9dfff98bdcada..d5ec098224571 100644
--- a/mlir/include/mlir/IR/OpBase.td
+++ b/mlir/include/mlir/IR/OpBase.td
@@ -2861,6 +2861,7 @@ class AttrDef<Dialect dialect, string name, list<Trait> traits = [],
       AttrOrTypeDef<"Attr", name, traits, baseCppClass> {
   // The name of the C++ Attribute class.
   string cppClassName = name # "Attr";
+  let storageType = dialect.cppNamespace # "::" # name # "Attr";
 
   // The underlying C++ value type
   let returnType = dialect.cppNamespace # "::" # cppClassName;

diff  --git a/mlir/test/mlir-tblgen/op-attribute.td b/mlir/test/mlir-tblgen/op-attribute.td
index 02d63c04355b7..1656b42cbf3cb 100644
--- a/mlir/test/mlir-tblgen/op-attribute.td
+++ b/mlir/test/mlir-tblgen/op-attribute.td
@@ -6,6 +6,7 @@ include "mlir/IR/OpBase.td"
 
 def Test_Dialect : Dialect {
   let name = "test";
+  let cppNamespace = "foobar";
 }
 class NS_Op<string mnemonic, list<OpTrait> traits> :
     Op<Test_Dialect, mnemonic, traits>;
@@ -17,6 +18,10 @@ def SomeAttr : Attr<CPred<"some-condition">, "some attribute kind"> {
   let constBuilderCall = "some-const-builder-call($_builder, $0)";
 }
 
+def SomeAttrDef : AttrDef<Test_Dialect, "SomeAttr"> {
+}
+
+
 // Test required, optional, default-valued attributes
 // ---
 
@@ -271,6 +276,19 @@ def EOp : NS_Op<"e_op", []> {
 // DECL-LABEL: EOp declarations
 // DECL: static void build({{.*}}, uint32_t i32_attr, uint32_t dv_i32_attr, ::llvm::APFloat f64_attr, ::llvm::APFloat dv_f64_attr, ::llvm::StringRef str_attr, ::llvm::StringRef dv_str_attr, bool bool_attr, bool dv_bool_attr, ::SomeI32Enum enum_attr, ::SomeI32Enum dv_enum_attr = ::SomeI32Enum::case5)
 
+
+// Test proper namespacing for AttrDef
+// ---
+
+def NamespaceOp : NS_Op<"namespace_op", []> {
+  let arguments = (ins
+      SomeAttrDef:$AttrDef
+  );
+}
+// DECL: NamespaceOp
+// DECL: foobar::SomeAttrAttr AttrDef()
+
+
 // Test mixing operands and attributes in arbitrary order
 // ---
 


        


More information about the Mlir-commits mailing list