11#include "llvm/Support/InterleavedRange.h"
21 os <<
"<NULL-PDLValue>";
26 os << cast<Attribute>();
29 os << *cast<Operation *>();
35 os << llvm::interleaved(cast<TypeRange>());
40 case Kind::ValueRange:
41 os << llvm::interleaved(cast<ValueRange>());
63 case Kind::ValueRange:
73void PDLPatternModule::mergeIn(PDLPatternModule &&other) {
79 for (
auto &it : other.constraintFunctions)
80 registerConstraintFunction(it.first(), std::move(it.second));
81 for (
auto &it : other.rewriteFunctions)
82 registerRewriteFunction(it.first(), std::move(it.second));
83 for (
auto &it : other.configs)
84 configs.emplace_back(std::move(it));
85 for (
auto &it : other.configMap)
90 pdlModule = std::move(other.pdlModule);
95 Block *block = pdlModule->getBody();
97 other.pdlModule->getBody()->getOperations());
100void PDLPatternModule::attachConfigToPatterns(ModuleOp module,
101 PDLPatternConfigSet &configSet) {
106 module->walk([&](Operation *op) {
107 if (op->hasTrait<SymbolOpInterface::Trait>())
108 configMap[op] = &configSet;
116void PDLPatternModule::registerConstraintFunction(
117 StringRef name, PDLConstraintFunction constraintFn) {
122 constraintFunctions.try_emplace(name, std::move(constraintFn));
125void PDLPatternModule::registerRewriteFunction(StringRef name,
126 PDLRewriteFunction rewriteFn) {
131 rewriteFunctions.try_emplace(name, std::move(rewriteFn));
OpListType & getOperations()
Include the generated interface declarations.