[Mlir-commits] [mlir] 7c59120 - [mlir][ods] Look through OpVariable for type constraint
Jacques Pienaar
llvmlistbot at llvm.org
Thu Jun 18 12:52:08 PDT 2020
Author: Jacques Pienaar
Date: 2020-06-18T12:51:51-07:00
New Revision: 7c59120f6e4ca769ab2bfb26484eb8eaca2eadc0
URL: https://github.com/llvm/llvm-project/commit/7c59120f6e4ca769ab2bfb26484eb8eaca2eadc0
DIFF: https://github.com/llvm/llvm-project/commit/7c59120f6e4ca769ab2bfb26484eb8eaca2eadc0.diff
LOG: [mlir][ods] Look through OpVariable for type constraint
If one uses an OpVariable (such as via Res) then the result type constraint
should be returned.
Differential Revision: https://reviews.llvm.org/D82119
Added:
Modified:
mlir/lib/TableGen/Constraint.cpp
mlir/test/mlir-tblgen/op-decl.td
Removed:
################################################################################
diff --git a/mlir/lib/TableGen/Constraint.cpp b/mlir/lib/TableGen/Constraint.cpp
index 98bb7d63d06d..b8e1b9f05acd 100644
--- a/mlir/lib/TableGen/Constraint.cpp
+++ b/mlir/lib/TableGen/Constraint.cpp
@@ -17,21 +17,28 @@ using namespace mlir::tblgen;
Constraint::Constraint(const llvm::Record *record)
: def(record), kind(CK_Uncategorized) {
- if (record->isSubClassOf("TypeConstraint")) {
+ // Look through OpVariable's to their constraint.
+ if (def->isSubClassOf("OpVariable"))
+ def = def->getValueAsDef("constraint");
+ if (def->isSubClassOf("TypeConstraint")) {
kind = CK_Type;
- } else if (record->isSubClassOf("AttrConstraint")) {
+ } else if (def->isSubClassOf("AttrConstraint")) {
kind = CK_Attr;
- } else if (record->isSubClassOf("RegionConstraint")) {
+ } else if (def->isSubClassOf("RegionConstraint")) {
kind = CK_Region;
- } else if (record->isSubClassOf("SuccessorConstraint")) {
+ } else if (def->isSubClassOf("SuccessorConstraint")) {
kind = CK_Successor;
} else {
- assert(record->isSubClassOf("Constraint"));
+ assert(def->isSubClassOf("Constraint"));
}
}
Constraint::Constraint(Kind kind, const llvm::Record *record)
- : def(record), kind(kind) {}
+ : def(record), kind(kind) {
+ // Look through OpVariable's to their constraint.
+ if (def->isSubClassOf("OpVariable"))
+ def = def->getValueAsDef("constraint");
+}
Pred Constraint::getPredicate() const {
auto *val = def->getValue("predicate");
diff --git a/mlir/test/mlir-tblgen/op-decl.td b/mlir/test/mlir-tblgen/op-decl.td
index c0297da28445..f5bf03e57ce7 100644
--- a/mlir/test/mlir-tblgen/op-decl.td
+++ b/mlir/test/mlir-tblgen/op-decl.td
@@ -155,7 +155,7 @@ def NS_EOp : NS_Op<"op_with_optionals", []> {
def NS_FOp : NS_Op<"op_with_all_types_constraint",
[AllTypesMatch<["a", "b"]>]> {
let arguments = (ins AnyType:$a);
- let results = (outs AnyType:$b);
+ let results = (outs Res<AnyType, "output b", []>:$b);
}
// CHECK-LABEL: class FOp :
More information about the Mlir-commits
mailing list