Changeset View
Changeset View
Standalone View
Standalone View
mlir/lib/Dialect/PDL/IR/PDL.cpp
Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | verifyHasBindingUseInMatcher(Operation *op, | ||||
if (hasBindingUseInMatcher(op, op->getBlock())) | if (hasBindingUseInMatcher(op, op->getBlock())) | ||||
return success(); | return success(); | ||||
return op->emitOpError() | return op->emitOpError() | ||||
<< "expected a bindable (i.e. " << bindableContextStr | << "expected a bindable (i.e. " << bindableContextStr | ||||
<< ") user when defined in the matcher body of a `pdl.pattern`"; | << ") user when defined in the matcher body of a `pdl.pattern`"; | ||||
} | } | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// pdl::ApplyConstraintOp | // pdl::ApplyNativeConstraintOp | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
static LogicalResult verify(ApplyConstraintOp op) { | static LogicalResult verify(ApplyNativeConstraintOp op) { | ||||
if (op.getNumOperands() == 0) | if (op.getNumOperands() == 0) | ||||
return op.emitOpError("expected at least one argument"); | return op.emitOpError("expected at least one argument"); | ||||
return success(); | return success(); | ||||
} | } | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// pdl::ApplyNativeRewriteOp | |||||
//===----------------------------------------------------------------------===// | |||||
static LogicalResult verify(ApplyNativeRewriteOp op) { | |||||
if (op.getNumOperands() == 0 && op.getNumResults() == 0) | |||||
return op.emitOpError("expected at least one argument or result"); | |||||
return success(); | |||||
} | |||||
//===----------------------------------------------------------------------===// | |||||
// pdl::AttributeOp | // pdl::AttributeOp | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
static LogicalResult verify(AttributeOp op) { | static LogicalResult verify(AttributeOp op) { | ||||
Value attrType = op.type(); | Value attrType = op.type(); | ||||
Optional<Attribute> attrValue = op.value(); | Optional<Attribute> attrValue = op.value(); | ||||
if (!attrValue && isa<RewriteOp>(op->getParentOp())) | if (!attrValue && isa<RewriteOp>(op->getParentOp())) | ||||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | static LogicalResult verifyResultTypesAreInferrable(OperationOp op, | ||||
if (llvm::any_of(op.op().getUses(), canInferTypeFromUse)) | if (llvm::any_of(op.op().getUses(), canInferTypeFromUse)) | ||||
return success(); | return success(); | ||||
// Otherwise, make sure each of the types can be inferred. | // Otherwise, make sure each of the types can be inferred. | ||||
for (auto it : llvm::enumerate(resultTypes)) { | for (auto it : llvm::enumerate(resultTypes)) { | ||||
Operation *resultTypeOp = it.value().getDefiningOp(); | Operation *resultTypeOp = it.value().getDefiningOp(); | ||||
assert(resultTypeOp && "expected valid result type operation"); | assert(resultTypeOp && "expected valid result type operation"); | ||||
// If the op was defined by a `create_native`, it is guaranteed to be | // If the op was defined by a `apply_native_rewrite`, it is guaranteed to be | ||||
// usable. | // usable. | ||||
if (isa<CreateNativeOp>(resultTypeOp)) | if (isa<ApplyNativeRewriteOp>(resultTypeOp)) | ||||
continue; | continue; | ||||
// If the type is already constrained, there is nothing to do. | // If the type is already constrained, there is nothing to do. | ||||
TypeOp typeOp = cast<TypeOp>(resultTypeOp); | TypeOp typeOp = cast<TypeOp>(resultTypeOp); | ||||
if (typeOp.type()) | if (typeOp.type()) | ||||
continue; | continue; | ||||
// If the type operation was defined in the matcher and constrains the | // If the type operation was defined in the matcher and constrains the | ||||
▲ Show 20 Lines • Show All 163 Lines • Show Last 20 Lines |