[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
This commit is contained in:
Jacques Pienaar 2020-06-18 12:51:51 -07:00
parent 41d53194fb
commit 7c59120f6e
2 changed files with 14 additions and 7 deletions

View File

@ -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");

View File

@ -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 :