[Mlir-commits] [mlir] c5b0609 - [mlir] Add setters for Dynamic[Type|Attr]Definition
Renato Golin
llvmlistbot at llvm.org
Thu Mar 9 10:53:44 PST 2023
Author: Fehr Mathieu
Date: 2023-03-09T18:53:29Z
New Revision: c5b060900e985ac1d5b80b957d9067c6d6959095
URL: https://github.com/llvm/llvm-project/commit/c5b060900e985ac1d5b80b957d9067c6d6959095
DIFF: https://github.com/llvm/llvm-project/commit/c5b060900e985ac1d5b80b957d9067c6d6959095.diff
LOG: [mlir] Add setters for Dynamic[Type|Attr]Definition
Add functions to set the verifier, printer, and parser of
dynamic attributes definitions, and dynamic type definitions.
This feature was already implemented for dynamic operations, but
is missing for attributes and types. This is necessary to define
attributes and types verifiers that refer to each others in a cyclic way.
Differential Revision: https://reviews.llvm.org/D144690
Added:
Modified:
mlir/include/mlir/IR/ExtensibleDialect.h
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/ExtensibleDialect.h b/mlir/include/mlir/IR/ExtensibleDialect.h
index 304ff96e0f73..cb8f4fcfa722 100644
--- a/mlir/include/mlir/IR/ExtensibleDialect.h
+++ b/mlir/include/mlir/IR/ExtensibleDialect.h
@@ -69,6 +69,17 @@ class DynamicAttrDefinition : public SelfOwningTypeID {
get(StringRef name, ExtensibleDialect *dialect, VerifierFn &&verifier,
ParserFn &&parser, PrinterFn &&printer);
+ /// Sets the verifier function for this attribute. It should emits an error
+ /// message and returns failure if a problem is detected, or returns success
+ /// if everything is ok.
+ void setVerifyFn(VerifierFn &&verify) { verifier = std::move(verify); }
+
+ /// Sets the static hook for parsing this attribute assembly.
+ void setParseFn(ParserFn &&parse) { parser = std::move(parse); }
+
+ /// Sets the static hook for printing this attribute assembly.
+ void setPrintFn(PrinterFn &&print) { printer = std::move(print); }
+
/// Check that the attribute parameters are valid.
LogicalResult verify(function_ref<InFlightDiagnostic()> emitError,
ArrayRef<Attribute> params) const {
@@ -214,6 +225,17 @@ class DynamicTypeDefinition : public SelfOwningTypeID {
get(StringRef name, ExtensibleDialect *dialect, VerifierFn &&verifier,
ParserFn &&parser, PrinterFn &&printer);
+ /// Sets the verifier function for this type. It should emits an error
+ /// message and returns failure if a problem is detected, or returns success
+ /// if everything is ok.
+ void setVerifyFn(VerifierFn &&verify) { verifier = std::move(verify); }
+
+ /// Sets the static hook for parsing this type assembly.
+ void setParseFn(ParserFn &&parse) { parser = std::move(parse); }
+
+ /// Sets the static hook for printing this type assembly.
+ void setPrintFn(PrinterFn &&print) { printer = std::move(print); }
+
/// Check that the type parameters are valid.
LogicalResult verify(function_ref<InFlightDiagnostic()> emitError,
ArrayRef<Attribute> params) const {
More information about the Mlir-commits
mailing list