Changeset View
Changeset View
Standalone View
Standalone View
mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp
Show First 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | TypeSwitch<Position *>(pos) | ||||
TypePosition>([&](auto *derivedPos) { | TypePosition>([&](auto *derivedPos) { | ||||
getTreePredicates(predList, val, builder, inputs, derivedPos); | getTreePredicates(predList, val, builder, inputs, derivedPos); | ||||
}) | }) | ||||
.Default([](auto *) { llvm_unreachable("unexpected position kind"); }); | .Default([](auto *) { llvm_unreachable("unexpected position kind"); }); | ||||
} | } | ||||
/// Collect all of the predicates related to constraints within the given | /// Collect all of the predicates related to constraints within the given | ||||
/// pattern operation. | /// pattern operation. | ||||
static void getConstraintPredicates(pdl::ApplyConstraintOp op, | static void getConstraintPredicates(pdl::ApplyNativeConstraintOp op, | ||||
std::vector<PositionalPredicate> &predList, | std::vector<PositionalPredicate> &predList, | ||||
PredicateBuilder &builder, | PredicateBuilder &builder, | ||||
DenseMap<Value, Position *> &inputs) { | DenseMap<Value, Position *> &inputs) { | ||||
OperandRange arguments = op.args(); | OperandRange arguments = op.args(); | ||||
ArrayAttr parameters = op.constParamsAttr(); | ArrayAttr parameters = op.constParamsAttr(); | ||||
std::vector<Position *> allPositions; | std::vector<Position *> allPositions; | ||||
allPositions.reserve(arguments.size()); | allPositions.reserve(arguments.size()); | ||||
Show All 22 Lines | |||||
/// Collect all of the predicates that cannot be determined via walking the | /// Collect all of the predicates that cannot be determined via walking the | ||||
/// tree. | /// tree. | ||||
static void getNonTreePredicates(pdl::PatternOp pattern, | static void getNonTreePredicates(pdl::PatternOp pattern, | ||||
std::vector<PositionalPredicate> &predList, | std::vector<PositionalPredicate> &predList, | ||||
PredicateBuilder &builder, | PredicateBuilder &builder, | ||||
DenseMap<Value, Position *> &inputs) { | DenseMap<Value, Position *> &inputs) { | ||||
for (Operation &op : pattern.body().getOps()) { | for (Operation &op : pattern.body().getOps()) { | ||||
if (auto constraintOp = dyn_cast<pdl::ApplyConstraintOp>(&op)) | if (auto constraintOp = dyn_cast<pdl::ApplyNativeConstraintOp>(&op)) | ||||
getConstraintPredicates(constraintOp, predList, builder, inputs); | getConstraintPredicates(constraintOp, predList, builder, inputs); | ||||
else if (auto resultOp = dyn_cast<pdl::ResultOp>(&op)) | else if (auto resultOp = dyn_cast<pdl::ResultOp>(&op)) | ||||
getResultPredicates(resultOp, predList, builder, inputs); | getResultPredicates(resultOp, predList, builder, inputs); | ||||
} | } | ||||
} | } | ||||
/// Given a pattern operation, build the set of matcher predicates necessary to | /// Given a pattern operation, build the set of matcher predicates necessary to | ||||
/// match this pattern. | /// match this pattern. | ||||
▲ Show 20 Lines • Show All 290 Lines • Show Last 20 Lines |