summaryrefslogtreecommitdiffstats
path: root/mlir/test/lib/TestDialect
diff options
context:
space:
mode:
authorSean Silva <silvasean@google.com>2019-10-18 16:02:56 -0700
committerA. Unique TensorFlower <gardener@tensorflow.org>2019-10-18 16:03:28 -0700
commit9c9a7e9268bdd4fe3433ea4499eebbd74e015919 (patch)
tree6bc78019d8569d99e489ea0d912fceaba05cb0e0 /mlir/test/lib/TestDialect
parent9e7e297da33be70ec41335800c05b554f5de065b (diff)
downloadbcm5719-llvm-9c9a7e9268bdd4fe3433ea4499eebbd74e015919.tar.gz
bcm5719-llvm-9c9a7e9268bdd4fe3433ea4499eebbd74e015919.zip
Add support for function result attributes.
This allows dialect-specific attributes to be attached to func results. (or more specifically, FunctionLike ops). For example: ``` func @f() -> (i32 {my_dialect.some_attr = 3}) ``` This attaches my_dialect.some_attr with value 3 to the first result of func @f. Another more complex example: ``` func @g() -> (i32, f32 {my_dialect.some_attr = "foo", other_dialect.some_other_attr = [1,2,3]}, i1) ``` Here, the second result has two attributes attached. PiperOrigin-RevId: 275564165
Diffstat (limited to 'mlir/test/lib/TestDialect')
-rw-r--r--mlir/test/lib/TestDialect/TestDialect.cpp18
-rw-r--r--mlir/test/lib/TestDialect/TestDialect.h8
2 files changed, 26 insertions, 0 deletions
diff --git a/mlir/test/lib/TestDialect/TestDialect.cpp b/mlir/test/lib/TestDialect/TestDialect.cpp
index ee8325fd13e..2e3d97b473f 100644
--- a/mlir/test/lib/TestDialect/TestDialect.cpp
+++ b/mlir/test/lib/TestDialect/TestDialect.cpp
@@ -114,6 +114,24 @@ TestDialect::TestDialect(MLIRContext *context)
allowUnknownOperations();
}
+LogicalResult TestDialect::verifyRegionArgAttribute(Operation *op,
+ unsigned regionIndex,
+ unsigned argIndex,
+ NamedAttribute namedAttr) {
+ if (namedAttr.first == "test.invalid_attr")
+ return op->emitError() << "invalid to use 'test.invalid_attr'";
+ return success();
+}
+
+LogicalResult
+TestDialect::verifyRegionResultAttribute(Operation *op, unsigned regionIndex,
+ unsigned resultIndex,
+ NamedAttribute namedAttr) {
+ if (namedAttr.first == "test.invalid_attr")
+ return op->emitError() << "invalid to use 'test.invalid_attr'";
+ return success();
+}
+
//===----------------------------------------------------------------------===//
// Test IsolatedRegionOp - parse passthrough region arguments.
//===----------------------------------------------------------------------===//
diff --git a/mlir/test/lib/TestDialect/TestDialect.h b/mlir/test/lib/TestDialect/TestDialect.h
index ffe2a1c50ec..ade0eb81c40 100644
--- a/mlir/test/lib/TestDialect/TestDialect.h
+++ b/mlir/test/lib/TestDialect/TestDialect.h
@@ -40,6 +40,14 @@ public:
/// Get the canonical string name of the dialect.
static StringRef getDialectName() { return "test"; }
+
+ LogicalResult verifyRegionArgAttribute(Operation *, unsigned regionIndex,
+ unsigned argIndex,
+ NamedAttribute) override;
+
+ LogicalResult verifyRegionResultAttribute(Operation *, unsigned regionIndex,
+ unsigned resultIndex,
+ NamedAttribute) override;
};
#define GET_OP_CLASSES
OpenPOWER on IntegriCloud