diff --git a/mlir/lib/Dialect/SCF/SCF.cpp b/mlir/lib/Dialect/SCF/SCF.cpp --- a/mlir/lib/Dialect/SCF/SCF.cpp +++ b/mlir/lib/Dialect/SCF/SCF.cpp @@ -19,10 +19,33 @@ #include "mlir/IR/StandardTypes.h" #include "mlir/IR/Value.h" #include "mlir/Support/MathExtras.h" +#include "mlir/Transforms/InliningUtils.h" using namespace mlir; using namespace mlir::scf; +//===----------------------------------------------------------------------===// +// SCFDialect Dialect Interfaces +//===----------------------------------------------------------------------===// + +namespace { +struct SCFInlinerInterface : public DialectInlinerInterface { + using DialectInlinerInterface::DialectInlinerInterface; + // We don't have any special restrictions on what can be inlined into + // destination regions (e.g. while/conditional bodies). Always allow it. + bool isLegalToInline(Region *dest, Region *src, + BlockAndValueMapping &valueMapping) const final { + return true; + } + // Operations in scf dialect are always legal to inline since they are + // pure. + bool isLegalToInline(Operation *, Region *, + BlockAndValueMapping &) const final { + return true; + } +}; +} // end anonymous namespace + //===----------------------------------------------------------------------===// // SCFDialect //===----------------------------------------------------------------------===// @@ -33,6 +56,7 @@ #define GET_OP_LIST #include "mlir/Dialect/SCF/SCFOps.cpp.inc" >(); + addInterfaces(); } /// Default callback for IfOp builders. Inserts a yield without arguments.