From: Ramkumar Ramachandra Date: Wed, 14 Dec 2022 17:55:07 +0000 (+0100) Subject: mlir/tblgen test: add a test for EnumAttr customAssemblyFormat X-Git-Tag: upstream/17.0.6~22834 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f8077a1f0247bbf06f81737c50ad1c868046e4c7;p=platform%2Fupstream%2Fllvm.git 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 Differential Revision: https://reviews.llvm.org/D140034 --- diff --git a/mlir/test/mlir-tblgen/attr-or-type-format.td b/mlir/test/mlir-tblgen/attr-or-type-format.td index 675104a..d4794c2 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(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 { + let assemblyFormat = "custom($value)"; +} + /// Test type parser and printer that mix variables and struct are generated /// correctly.