[Mlir-commits] [mlir] f8077a1 - mlir/tblgen test: add a test for EnumAttr customAssemblyFormat

Ramkumar Ramachandra llvmlistbot at llvm.org
Thu Dec 22 08:31:50 PST 2022


Author: Ramkumar Ramachandra
Date: 2022-12-22T17:31:16+01:00
New Revision: f8077a1f0247bbf06f81737c50ad1c868046e4c7

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

LOG: mlir/tblgen test: add a test for EnumAttr customAssemblyFormat

attr-or-type-format.td contains tests for various attributes and types,
but nowhere in the testsuite is the customAssemblyFormat for an EnumAttr
(enum class in C++) exercised. Fix this by adding a test.

Signed-off-by: Ramkumar Ramachandra <r at artagnon.com>

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

Added: 
    

Modified: 
    mlir/test/mlir-tblgen/attr-or-type-format.td

Removed: 
    


################################################################################
diff  --git a/mlir/test/mlir-tblgen/attr-or-type-format.td b/mlir/test/mlir-tblgen/attr-or-type-format.td
index 675104a17d146..d4794c2438620 100644
--- a/mlir/test/mlir-tblgen/attr-or-type-format.td
+++ b/mlir/test/mlir-tblgen/attr-or-type-format.td
@@ -2,6 +2,7 @@
 // RUN: mlir-tblgen -gen-typedef-defs -I %S/../../include %s | FileCheck %s --check-prefix=TYPE
 
 include "mlir/IR/AttrTypeBase.td"
+include "mlir/IR/EnumAttr.td"
 include "mlir/IR/OpBase.td"
 
 /// Test that attribute and type printers and parsers are correctly generated.
@@ -194,6 +195,23 @@ def AttrE : TestAttr<"TestH"> {
   let assemblyFormat = "custom<UseType>(ref($type))";
 }
 
+def TestEnum : I32EnumAttr<"TestEnum", "TestEnumType", [
+  I32EnumAttrCase<"first", 0>,
+  I32EnumAttrCase<"second", 1>
+]> {
+  let genSpecializedAttr = 0;
+}
+
+// ATTR-LABEL: TestEnumAttr::parse
+// ATTR: parseFoo(odsParser,
+// ATTR-NEXT: _result_value
+// ATTR-LABEL: TestEnumAttr::print
+// ATTR: printFoo(odsPrinter,
+// ATTR-NEXT: getValue()
+def EnumAttrA : EnumAttr<Test_Dialect, TestEnum, "EnumAttrA"> {
+  let assemblyFormat = "custom<Foo>($value)";
+}
+
 /// Test type parser and printer that mix variables and struct are generated
 /// correctly.
 


        


More information about the Mlir-commits mailing list