forked from OSchip/llvm-project
[mlir][NFC] Update PDL operations to use `hasVerifier` instead of `verifier`
The verifier field is deprecated, and slated for removal. Differential Revision: https://reviews.llvm.org/D118828
This commit is contained in:
parent
094ede6d20
commit
0d86e53e18
|
@ -26,7 +26,6 @@ class PDL_Op<string mnemonic, list<Trait> traits = []>
|
||||||
: Op<PDL_Dialect, mnemonic, traits> {
|
: Op<PDL_Dialect, mnemonic, traits> {
|
||||||
let printer = [{ ::print(p, *this); }];
|
let printer = [{ ::print(p, *this); }];
|
||||||
let parser = [{ return ::parse$cppClass(parser, result); }];
|
let parser = [{ return ::parse$cppClass(parser, result); }];
|
||||||
let verifier = [{ return ::verify(*this); }];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -66,6 +65,7 @@ def PDL_ApplyNativeConstraintOp
|
||||||
params.empty() ? ArrayAttr() : $_builder.getArrayAttr(params));
|
params.empty() ? ArrayAttr() : $_builder.getArrayAttr(params));
|
||||||
}]>,
|
}]>,
|
||||||
];
|
];
|
||||||
|
let hasVerifier = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -118,6 +118,7 @@ def PDL_ApplyNativeRewriteOp
|
||||||
$name ($constParams^)? (`(` $args^ `:` type($args) `)`)?
|
$name ($constParams^)? (`(` $args^ `:` type($args) `)`)?
|
||||||
(`:` type($results)^)? attr-dict
|
(`:` type($results)^)? attr-dict
|
||||||
}];
|
}];
|
||||||
|
let hasVerifier = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -164,6 +165,7 @@ def PDL_AttributeOp : PDL_Op<"attribute", [NoSideEffect]> {
|
||||||
build($_builder, $_state, $_builder.getType<AttributeType>(), Value(), attr);
|
build($_builder, $_state, $_builder.getType<AttributeType>(), Value(), attr);
|
||||||
}]>,
|
}]>,
|
||||||
];
|
];
|
||||||
|
let hasVerifier = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -185,7 +187,6 @@ def PDL_EraseOp : PDL_Op<"erase", [HasParent<"pdl::RewriteOp">]> {
|
||||||
}];
|
}];
|
||||||
let arguments = (ins PDL_Operation:$operation);
|
let arguments = (ins PDL_Operation:$operation);
|
||||||
let assemblyFormat = "$operation attr-dict";
|
let assemblyFormat = "$operation attr-dict";
|
||||||
let verifier = ?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -224,6 +225,7 @@ def PDL_OperandOp
|
||||||
build($_builder, $_state, $_builder.getType<ValueType>(), Value());
|
build($_builder, $_state, $_builder.getType<ValueType>(), Value());
|
||||||
}]>,
|
}]>,
|
||||||
];
|
];
|
||||||
|
let hasVerifier = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -263,6 +265,7 @@ def PDL_OperandsOp
|
||||||
Value());
|
Value());
|
||||||
}]>,
|
}]>,
|
||||||
];
|
];
|
||||||
|
let hasVerifier = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -396,6 +399,7 @@ def PDL_OperationOp : PDL_Op<"operation", [AttrSizedOperandSegments]> {
|
||||||
/// inference.
|
/// inference.
|
||||||
bool hasTypeInference();
|
bool hasTypeInference();
|
||||||
}];
|
}];
|
||||||
|
let hasVerifier = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -452,6 +456,7 @@ def PDL_PatternOp : PDL_Op<"pattern", [
|
||||||
/// Returns the rewrite operation of this pattern.
|
/// Returns the rewrite operation of this pattern.
|
||||||
RewriteOp getRewriter();
|
RewriteOp getRewriter();
|
||||||
}];
|
}];
|
||||||
|
let hasVerifier = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -492,6 +497,7 @@ def PDL_ReplaceOp : PDL_Op<"replace", [
|
||||||
$operation `with` (`(` $replValues^ `:` type($replValues) `)`)?
|
$operation `with` (`(` $replValues^ `:` type($replValues) `)`)?
|
||||||
($replOperation^)? attr-dict
|
($replOperation^)? attr-dict
|
||||||
}];
|
}];
|
||||||
|
let hasVerifier = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -524,7 +530,6 @@ def PDL_ResultOp : PDL_Op<"result", [NoSideEffect]> {
|
||||||
let arguments = (ins PDL_Operation:$parent, I32Attr:$index);
|
let arguments = (ins PDL_Operation:$parent, I32Attr:$index);
|
||||||
let results = (outs PDL_Value:$val);
|
let results = (outs PDL_Value:$val);
|
||||||
let assemblyFormat = "$index `of` $parent attr-dict";
|
let assemblyFormat = "$index `of` $parent attr-dict";
|
||||||
let verifier = ?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -567,6 +572,7 @@ def PDL_ResultsOp : PDL_Op<"results", [NoSideEffect]> {
|
||||||
($index^)? `of` $parent custom<ResultsValueType>(ref($index), type($val))
|
($index^)? `of` $parent custom<ResultsValueType>(ref($index), type($val))
|
||||||
attr-dict
|
attr-dict
|
||||||
}];
|
}];
|
||||||
|
let hasVerifier = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -629,6 +635,7 @@ def PDL_RewriteOp : PDL_Op<"rewrite", [
|
||||||
($body^)?
|
($body^)?
|
||||||
attr-dict-with-keyword
|
attr-dict-with-keyword
|
||||||
}];
|
}];
|
||||||
|
let hasVerifier = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -657,6 +664,7 @@ def PDL_TypeOp : PDL_Op<"type", [NoSideEffect]> {
|
||||||
let arguments = (ins OptionalAttr<TypeAttr>:$type);
|
let arguments = (ins OptionalAttr<TypeAttr>:$type);
|
||||||
let results = (outs PDL_Type:$result);
|
let results = (outs PDL_Type:$result);
|
||||||
let assemblyFormat = "attr-dict (`:` $type^)?";
|
let assemblyFormat = "attr-dict (`:` $type^)?";
|
||||||
|
let hasVerifier = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -685,6 +693,7 @@ def PDL_TypesOp : PDL_Op<"types", [NoSideEffect]> {
|
||||||
let arguments = (ins OptionalAttr<TypeArrayAttr>:$types);
|
let arguments = (ins OptionalAttr<TypeArrayAttr>:$types);
|
||||||
let results = (outs PDL_RangeOf<PDL_Type>:$result);
|
let results = (outs PDL_RangeOf<PDL_Type>:$result);
|
||||||
let assemblyFormat = "attr-dict (`:` $types^)?";
|
let assemblyFormat = "attr-dict (`:` $types^)?";
|
||||||
|
let hasVerifier = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // MLIR_DIALECT_PDL_IR_PDLOPS
|
#endif // MLIR_DIALECT_PDL_IR_PDLOPS
|
||||||
|
|
|
@ -75,19 +75,6 @@ class PDLInterp_SwitchOp<string mnemonic, list<Trait> traits = []> :
|
||||||
PDLInterp_Op<mnemonic, !listconcat([Terminator], traits)> {
|
PDLInterp_Op<mnemonic, !listconcat([Terminator], traits)> {
|
||||||
let successors = (successor AnySuccessor:$defaultDest,
|
let successors = (successor AnySuccessor:$defaultDest,
|
||||||
VariadicSuccessor<AnySuccessor>:$cases);
|
VariadicSuccessor<AnySuccessor>:$cases);
|
||||||
|
|
||||||
let verifier = [{
|
|
||||||
// Verify that the number of case destinations matches the number of case
|
|
||||||
// values.
|
|
||||||
size_t numDests = cases().size();
|
|
||||||
size_t numValues = caseValues().size();
|
|
||||||
if (numDests != numValues) {
|
|
||||||
return emitOpError("expected number of cases to match the number of case "
|
|
||||||
"values, got ")
|
|
||||||
<< numDests << " but expected " << numValues;
|
|
||||||
}
|
|
||||||
return success();
|
|
||||||
}];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -638,7 +625,7 @@ def PDLInterp_ForEachOp
|
||||||
}];
|
}];
|
||||||
let parser = [{ return ::parseForEachOp(parser, result); }];
|
let parser = [{ return ::parseForEachOp(parser, result); }];
|
||||||
let printer = [{ return ::print(p, *this); }];
|
let printer = [{ return ::print(p, *this); }];
|
||||||
let verifier = [{ return ::verify(*this); }];
|
let hasVerifier = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -1078,6 +1065,7 @@ def PDLInterp_SwitchAttributeOp
|
||||||
build($_builder, $_state, attribute, $_builder.getArrayAttr(caseValues),
|
build($_builder, $_state, attribute, $_builder.getArrayAttr(caseValues),
|
||||||
defaultDest, dests);
|
defaultDest, dests);
|
||||||
}]>];
|
}]>];
|
||||||
|
let hasVerifier = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -1111,6 +1099,7 @@ def PDLInterp_SwitchOperandCountOp
|
||||||
build($_builder, $_state, operation, $_builder.getI32VectorAttr(counts),
|
build($_builder, $_state, operation, $_builder.getI32VectorAttr(counts),
|
||||||
defaultDest, dests);
|
defaultDest, dests);
|
||||||
}]>];
|
}]>];
|
||||||
|
let hasVerifier = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -1148,6 +1137,7 @@ def PDLInterp_SwitchOperationNameOp
|
||||||
defaultDest, dests);
|
defaultDest, dests);
|
||||||
}]>,
|
}]>,
|
||||||
];
|
];
|
||||||
|
let hasVerifier = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -1181,6 +1171,7 @@ def PDLInterp_SwitchResultCountOp
|
||||||
build($_builder, $_state, operation, $_builder.getI32VectorAttr(counts),
|
build($_builder, $_state, operation, $_builder.getI32VectorAttr(counts),
|
||||||
defaultDest, dests);
|
defaultDest, dests);
|
||||||
}]>];
|
}]>];
|
||||||
|
let hasVerifier = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -1218,6 +1209,7 @@ def PDLInterp_SwitchTypeOp : PDLInterp_SwitchOp<"switch_type", [NoSideEffect]> {
|
||||||
let extraClassDeclaration = [{
|
let extraClassDeclaration = [{
|
||||||
auto getCaseTypes() { return caseValues().getAsValueRange<TypeAttr>(); }
|
auto getCaseTypes() { return caseValues().getAsValueRange<TypeAttr>(); }
|
||||||
}];
|
}];
|
||||||
|
let hasVerifier = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -1259,6 +1251,7 @@ def PDLInterp_SwitchTypesOp : PDLInterp_SwitchOp<"switch_types",
|
||||||
let extraClassDeclaration = [{
|
let extraClassDeclaration = [{
|
||||||
auto getCaseTypes() { return caseValues().getAsRange<ArrayAttr>(); }
|
auto getCaseTypes() { return caseValues().getAsRange<ArrayAttr>(); }
|
||||||
}];
|
}];
|
||||||
|
let hasVerifier = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // MLIR_DIALECT_PDLINTERP_IR_PDLINTERPOPS
|
#endif // MLIR_DIALECT_PDLINTERP_IR_PDLINTERPOPS
|
||||||
|
|
|
@ -90,9 +90,9 @@ static void visit(Operation *op, DenseSet<Operation *> &visited) {
|
||||||
// pdl::ApplyNativeConstraintOp
|
// pdl::ApplyNativeConstraintOp
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
static LogicalResult verify(ApplyNativeConstraintOp op) {
|
LogicalResult ApplyNativeConstraintOp::verify() {
|
||||||
if (op.getNumOperands() == 0)
|
if (getNumOperands() == 0)
|
||||||
return op.emitOpError("expected at least one argument");
|
return emitOpError("expected at least one argument");
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,9 +100,9 @@ static LogicalResult verify(ApplyNativeConstraintOp op) {
|
||||||
// pdl::ApplyNativeRewriteOp
|
// pdl::ApplyNativeRewriteOp
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
static LogicalResult verify(ApplyNativeRewriteOp op) {
|
LogicalResult ApplyNativeRewriteOp::verify() {
|
||||||
if (op.getNumOperands() == 0 && op.getNumResults() == 0)
|
if (getNumOperands() == 0 && getNumResults() == 0)
|
||||||
return op.emitOpError("expected at least one argument or result");
|
return emitOpError("expected at least one argument or result");
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,18 +110,18 @@ static LogicalResult verify(ApplyNativeRewriteOp op) {
|
||||||
// pdl::AttributeOp
|
// pdl::AttributeOp
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
static LogicalResult verify(AttributeOp op) {
|
LogicalResult AttributeOp::verify() {
|
||||||
Value attrType = op.type();
|
Value attrType = type();
|
||||||
Optional<Attribute> attrValue = op.value();
|
Optional<Attribute> attrValue = value();
|
||||||
|
|
||||||
if (!attrValue) {
|
if (!attrValue) {
|
||||||
if (isa<RewriteOp>(op->getParentOp()))
|
if (isa<RewriteOp>((*this)->getParentOp()))
|
||||||
return op.emitOpError("expected constant value when specified within a "
|
return emitOpError(
|
||||||
"`pdl.rewrite`");
|
"expected constant value when specified within a `pdl.rewrite`");
|
||||||
return verifyHasBindingUse(op);
|
return verifyHasBindingUse(*this);
|
||||||
}
|
}
|
||||||
if (attrType)
|
if (attrType)
|
||||||
return op.emitOpError("expected only one of [`type`, `value`] to be set");
|
return emitOpError("expected only one of [`type`, `value`] to be set");
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,13 +129,13 @@ static LogicalResult verify(AttributeOp op) {
|
||||||
// pdl::OperandOp
|
// pdl::OperandOp
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
static LogicalResult verify(OperandOp op) { return verifyHasBindingUse(op); }
|
LogicalResult OperandOp::verify() { return verifyHasBindingUse(*this); }
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// pdl::OperandsOp
|
// pdl::OperandsOp
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
static LogicalResult verify(OperandsOp op) { return verifyHasBindingUse(op); }
|
LogicalResult OperandsOp::verify() { return verifyHasBindingUse(*this); }
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// pdl::OperationOp
|
// pdl::OperationOp
|
||||||
|
@ -230,15 +230,15 @@ static LogicalResult verifyResultTypesAreInferrable(OperationOp op,
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
static LogicalResult verify(OperationOp op) {
|
LogicalResult OperationOp::verify() {
|
||||||
bool isWithinRewrite = isa<RewriteOp>(op->getParentOp());
|
bool isWithinRewrite = isa<RewriteOp>((*this)->getParentOp());
|
||||||
if (isWithinRewrite && !op.name())
|
if (isWithinRewrite && !name())
|
||||||
return op.emitOpError("must have an operation name when nested within "
|
return emitOpError("must have an operation name when nested within "
|
||||||
"a `pdl.rewrite`");
|
"a `pdl.rewrite`");
|
||||||
ArrayAttr attributeNames = op.attributeNames();
|
ArrayAttr attributeNames = attributeNamesAttr();
|
||||||
auto attributeValues = op.attributes();
|
auto attributeValues = attributes();
|
||||||
if (attributeNames.size() != attributeValues.size()) {
|
if (attributeNames.size() != attributeValues.size()) {
|
||||||
return op.emitOpError()
|
return emitOpError()
|
||||||
<< "expected the same number of attribute values and attribute "
|
<< "expected the same number of attribute values and attribute "
|
||||||
"names, got "
|
"names, got "
|
||||||
<< attributeNames.size() << " names and " << attributeValues.size()
|
<< attributeNames.size() << " names and " << attributeValues.size()
|
||||||
|
@ -247,12 +247,12 @@ static LogicalResult verify(OperationOp op) {
|
||||||
|
|
||||||
// If the operation is within a rewrite body and doesn't have type inference,
|
// If the operation is within a rewrite body and doesn't have type inference,
|
||||||
// ensure that the result types can be resolved.
|
// ensure that the result types can be resolved.
|
||||||
if (isWithinRewrite && !op.hasTypeInference()) {
|
if (isWithinRewrite && !hasTypeInference()) {
|
||||||
if (failed(verifyResultTypesAreInferrable(op, op.types())))
|
if (failed(verifyResultTypesAreInferrable(*this, types())))
|
||||||
return failure();
|
return failure();
|
||||||
}
|
}
|
||||||
|
|
||||||
return verifyHasBindingUse(op);
|
return verifyHasBindingUse(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OperationOp::hasTypeInference() {
|
bool OperationOp::hasTypeInference() {
|
||||||
|
@ -269,12 +269,12 @@ bool OperationOp::hasTypeInference() {
|
||||||
// pdl::PatternOp
|
// pdl::PatternOp
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
static LogicalResult verify(PatternOp pattern) {
|
LogicalResult PatternOp::verify() {
|
||||||
Region &body = pattern.body();
|
Region &body = getBodyRegion();
|
||||||
Operation *term = body.front().getTerminator();
|
Operation *term = body.front().getTerminator();
|
||||||
auto rewriteOp = dyn_cast<RewriteOp>(term);
|
auto rewriteOp = dyn_cast<RewriteOp>(term);
|
||||||
if (!rewriteOp) {
|
if (!rewriteOp) {
|
||||||
return pattern.emitOpError("expected body to terminate with `pdl.rewrite`")
|
return emitOpError("expected body to terminate with `pdl.rewrite`")
|
||||||
.attachNote(term->getLoc())
|
.attachNote(term->getLoc())
|
||||||
.append("see terminator defined here");
|
.append("see terminator defined here");
|
||||||
}
|
}
|
||||||
|
@ -283,8 +283,7 @@ static LogicalResult verify(PatternOp pattern) {
|
||||||
// dialect.
|
// dialect.
|
||||||
WalkResult result = body.walk([&](Operation *op) -> WalkResult {
|
WalkResult result = body.walk([&](Operation *op) -> WalkResult {
|
||||||
if (!isa_and_nonnull<PDLDialect>(op->getDialect())) {
|
if (!isa_and_nonnull<PDLDialect>(op->getDialect())) {
|
||||||
pattern
|
emitOpError("expected only `pdl` operations within the pattern body")
|
||||||
.emitOpError("expected only `pdl` operations within the pattern body")
|
|
||||||
.attachNote(op->getLoc())
|
.attachNote(op->getLoc())
|
||||||
.append("see non-`pdl` operation defined here");
|
.append("see non-`pdl` operation defined here");
|
||||||
return WalkResult::interrupt();
|
return WalkResult::interrupt();
|
||||||
|
@ -296,8 +295,7 @@ static LogicalResult verify(PatternOp pattern) {
|
||||||
|
|
||||||
// Check that there is at least one operation.
|
// Check that there is at least one operation.
|
||||||
if (body.front().getOps<OperationOp>().empty())
|
if (body.front().getOps<OperationOp>().empty())
|
||||||
return pattern.emitOpError(
|
return emitOpError("the pattern must contain at least one `pdl.operation`");
|
||||||
"the pattern must contain at least one `pdl.operation`");
|
|
||||||
|
|
||||||
// Determine if the operations within the pdl.pattern form a connected
|
// Determine if the operations within the pdl.pattern form a connected
|
||||||
// component. This is determined by starting the search from the first
|
// component. This is determined by starting the search from the first
|
||||||
|
@ -333,8 +331,7 @@ static LogicalResult verify(PatternOp pattern) {
|
||||||
first = false;
|
first = false;
|
||||||
} else if (!visited.count(&op)) {
|
} else if (!visited.count(&op)) {
|
||||||
// For the subsequent operations, check if already visited.
|
// For the subsequent operations, check if already visited.
|
||||||
return pattern
|
return emitOpError("the operations must form a connected component")
|
||||||
.emitOpError("the operations must form a connected component")
|
|
||||||
.attachNote(op.getLoc())
|
.attachNote(op.getLoc())
|
||||||
.append("see a disconnected value / operation here");
|
.append("see a disconnected value / operation here");
|
||||||
}
|
}
|
||||||
|
@ -364,10 +361,10 @@ StringRef PatternOp::getDefaultDialect() {
|
||||||
// pdl::ReplaceOp
|
// pdl::ReplaceOp
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
static LogicalResult verify(ReplaceOp op) {
|
LogicalResult ReplaceOp::verify() {
|
||||||
if (op.replOperation() && !op.replValues().empty())
|
if (replOperation() && !replValues().empty())
|
||||||
return op.emitOpError() << "expected no replacement values to be provided"
|
return emitOpError() << "expected no replacement values to be provided"
|
||||||
" when the replacement operation is present";
|
" when the replacement operation is present";
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,11 +389,11 @@ static void printResultsValueType(OpAsmPrinter &p, ResultsOp op,
|
||||||
p << " -> " << resultType;
|
p << " -> " << resultType;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LogicalResult verify(ResultsOp op) {
|
LogicalResult ResultsOp::verify() {
|
||||||
if (!op.index() && op.getType().isa<pdl::ValueType>()) {
|
if (!index() && getType().isa<pdl::ValueType>()) {
|
||||||
return op.emitOpError() << "expected `pdl.range<value>` result type when "
|
return emitOpError() << "expected `pdl.range<value>` result type when "
|
||||||
"no index is specified, but got: "
|
"no index is specified, but got: "
|
||||||
<< op.getType();
|
<< getType();
|
||||||
}
|
}
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
@ -405,13 +402,13 @@ static LogicalResult verify(ResultsOp op) {
|
||||||
// pdl::RewriteOp
|
// pdl::RewriteOp
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
static LogicalResult verify(RewriteOp op) {
|
LogicalResult RewriteOp::verify() {
|
||||||
Region &rewriteRegion = op.body();
|
Region &rewriteRegion = body();
|
||||||
|
|
||||||
// Handle the case where the rewrite is external.
|
// Handle the case where the rewrite is external.
|
||||||
if (op.name()) {
|
if (name()) {
|
||||||
if (!rewriteRegion.empty()) {
|
if (!rewriteRegion.empty()) {
|
||||||
return op.emitOpError()
|
return emitOpError()
|
||||||
<< "expected rewrite region to be empty when rewrite is external";
|
<< "expected rewrite region to be empty when rewrite is external";
|
||||||
}
|
}
|
||||||
return success();
|
return success();
|
||||||
|
@ -419,18 +416,18 @@ static LogicalResult verify(RewriteOp op) {
|
||||||
|
|
||||||
// Otherwise, check that the rewrite region only contains a single block.
|
// Otherwise, check that the rewrite region only contains a single block.
|
||||||
if (rewriteRegion.empty()) {
|
if (rewriteRegion.empty()) {
|
||||||
return op.emitOpError() << "expected rewrite region to be non-empty if "
|
return emitOpError() << "expected rewrite region to be non-empty if "
|
||||||
"external name is not specified";
|
"external name is not specified";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that no additional arguments were provided.
|
// Check that no additional arguments were provided.
|
||||||
if (!op.externalArgs().empty()) {
|
if (!externalArgs().empty()) {
|
||||||
return op.emitOpError() << "expected no external arguments when the "
|
return emitOpError() << "expected no external arguments when the "
|
||||||
"rewrite is specified inline";
|
"rewrite is specified inline";
|
||||||
}
|
}
|
||||||
if (op.externalConstParams()) {
|
if (externalConstParams()) {
|
||||||
return op.emitOpError() << "expected no external constant parameters when "
|
return emitOpError() << "expected no external constant parameters when "
|
||||||
"the rewrite is specified inline";
|
"the rewrite is specified inline";
|
||||||
}
|
}
|
||||||
|
|
||||||
return success();
|
return success();
|
||||||
|
@ -445,9 +442,9 @@ StringRef RewriteOp::getDefaultDialect() {
|
||||||
// pdl::TypeOp
|
// pdl::TypeOp
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
static LogicalResult verify(TypeOp op) {
|
LogicalResult TypeOp::verify() {
|
||||||
if (!op.typeAttr())
|
if (!typeAttr())
|
||||||
return verifyHasBindingUse(op);
|
return verifyHasBindingUse(*this);
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -455,9 +452,9 @@ static LogicalResult verify(TypeOp op) {
|
||||||
// pdl::TypesOp
|
// pdl::TypesOp
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
static LogicalResult verify(TypesOp op) {
|
LogicalResult TypesOp::verify() {
|
||||||
if (!op.typesAttr())
|
if (!typesAttr())
|
||||||
return verifyHasBindingUse(op);
|
return verifyHasBindingUse(*this);
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,21 @@ void PDLInterpDialect::initialize() {
|
||||||
>();
|
>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename OpT>
|
||||||
|
static LogicalResult verifySwitchOp(OpT op) {
|
||||||
|
// Verify that the number of case destinations matches the number of case
|
||||||
|
// values.
|
||||||
|
size_t numDests = op.cases().size();
|
||||||
|
size_t numValues = op.caseValues().size();
|
||||||
|
if (numDests != numValues) {
|
||||||
|
return op.emitOpError(
|
||||||
|
"expected number of cases to match the number of case "
|
||||||
|
"values, got ")
|
||||||
|
<< numDests << " but expected " << numValues;
|
||||||
|
}
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// pdl_interp::CreateOperationOp
|
// pdl_interp::CreateOperationOp
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -131,17 +146,17 @@ static void print(OpAsmPrinter &p, ForEachOp op) {
|
||||||
p.printSuccessor(op.successor());
|
p.printSuccessor(op.successor());
|
||||||
}
|
}
|
||||||
|
|
||||||
static LogicalResult verify(ForEachOp op) {
|
LogicalResult ForEachOp::verify() {
|
||||||
// Verify that the operation has exactly one argument.
|
// Verify that the operation has exactly one argument.
|
||||||
if (op.region().getNumArguments() != 1)
|
if (region().getNumArguments() != 1)
|
||||||
return op.emitOpError("requires exactly one argument");
|
return emitOpError("requires exactly one argument");
|
||||||
|
|
||||||
// Verify that the loop variable and the operand (value range)
|
// Verify that the loop variable and the operand (value range)
|
||||||
// have compatible types.
|
// have compatible types.
|
||||||
BlockArgument arg = op.getLoopVariable();
|
BlockArgument arg = getLoopVariable();
|
||||||
Type rangeType = pdl::RangeType::get(arg.getType());
|
Type rangeType = pdl::RangeType::get(arg.getType());
|
||||||
if (rangeType != op.values().getType())
|
if (rangeType != values().getType())
|
||||||
return op.emitOpError("operand must be a range of loop variable type");
|
return emitOpError("operand must be a range of loop variable type");
|
||||||
|
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
@ -156,6 +171,42 @@ static Type getGetValueTypeOpValueType(Type type) {
|
||||||
return type.isa<pdl::RangeType>() ? pdl::RangeType::get(valueTy) : valueTy;
|
return type.isa<pdl::RangeType>() ? pdl::RangeType::get(valueTy) : valueTy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
// pdl_interp::SwitchAttributeOp
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
LogicalResult SwitchAttributeOp::verify() { return verifySwitchOp(*this); }
|
||||||
|
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
// pdl_interp::SwitchOperandCountOp
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
LogicalResult SwitchOperandCountOp::verify() { return verifySwitchOp(*this); }
|
||||||
|
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
// pdl_interp::SwitchOperationNameOp
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
LogicalResult SwitchOperationNameOp::verify() { return verifySwitchOp(*this); }
|
||||||
|
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
// pdl_interp::SwitchResultCountOp
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
LogicalResult SwitchResultCountOp::verify() { return verifySwitchOp(*this); }
|
||||||
|
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
// pdl_interp::SwitchTypeOp
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
LogicalResult SwitchTypeOp::verify() { return verifySwitchOp(*this); }
|
||||||
|
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
// pdl_interp::SwitchTypesOp
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
LogicalResult SwitchTypesOp::verify() { return verifySwitchOp(*this); }
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// TableGen Auto-Generated Op and Interface Definitions
|
// TableGen Auto-Generated Op and Interface Definitions
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
Loading…
Reference in New Issue