32 #include "llvm/ADT/StringExtras.h"
33 #include "llvm/ADT/TypeSwitch.h"
34 #include "llvm/Support/raw_ostream.h"
70 constexpr const ::llvm::StringLiteral
71 LinalgDialect::kMemoizedIndexingMapsAttrName;
74 template <
typename T,
typename... Args>
81 template <
typename OpType,
typename = std::enable_if_t<
84 llvm::StringMap<LinalgDialect::RegionBuilderFunType> &map) {
88 template <
typename OpType,
89 typename = std::enable_if_t<detect_has_region_builder<OpType>::value>,
92 llvm::StringMap<LinalgDialect::RegionBuilderFunType> &map) {
93 map.insert(std::make_pair(
94 OpType::getOperationName(),
95 static_cast<LinalgDialect::RegionBuilderFunType
>(OpType::regionBuilder)));
98 template <
typename... OpTypes>
100 llvm::StringMap<LinalgDialect::RegionBuilderFunType> &map) {
101 (addNamedOpBuilderImpl<OpTypes>(map), ...);
104 void mlir::linalg::LinalgDialect::initialize() {
106 #define GET_ATTRDEF_LIST
107 #include "mlir/Dialect/Linalg/IR/LinalgOpsAttrDefs.cpp.inc"
111 #include "mlir/Dialect/Linalg/IR/LinalgOps.cpp.inc"
115 #include "mlir/Dialect/Linalg/IR/LinalgStructuredOps.cpp.inc"
121 #include "mlir/Dialect/Linalg/IR/LinalgStructuredOps.cpp.inc"
122 >(namedStructuredOpRegionBuilders);
124 addInterfaces<LinalgInlinerInterface>();
126 declarePromisedInterface<mesh::ShardingInterface, GenericOp>();
127 declarePromisedInterfaces<mesh::ShardingInterface,
129 #include "mlir/Dialect/Linalg/IR/LinalgStructuredOps.cpp.inc"
131 declarePromisedInterface<SubsetOpInterface, CopyOp>();
132 declarePromisedInterface<SubsetInsertionOpInterface, CopyOp>();
133 declarePromisedInterface<ValueBoundsOpInterface, IndexOp>();
134 declarePromisedInterface<TilingInterface, linalg::GenericOp>();
135 declarePromisedInterface<PartialReductionOpInterface, linalg::GenericOp>();
136 declarePromisedInterfaces<TilingInterface,
138 #include "mlir/Dialect/Linalg/IR/LinalgStructuredOps.cpp.inc"
140 declarePromisedInterfaces<PartialReductionOpInterface,
142 #include "mlir/Dialect/Linalg/IR/LinalgStructuredOps.cpp.inc"
144 declarePromisedInterfaces<bufferization::BufferizableOpInterface,
146 #include "mlir/Dialect/Linalg/IR/LinalgStructuredOps.cpp.inc"
150 LogicalResult LinalgDialect::verifyOperationAttribute(
Operation *op,
152 if (attr.
getName() == LinalgDialect::kMemoizedIndexingMapsAttrName)
155 <<
"' not supported by the linalg dialect";
158 #include "mlir/Dialect/Linalg/IR/LinalgOpsEnums.cpp.inc"
160 #define GET_ATTRDEF_CLASSES
161 #include "mlir/Dialect/Linalg/IR/LinalgOpsAttrDefs.cpp.inc"
163 #include "mlir/Dialect/Linalg/IR/LinalgOpsDialect.cpp.inc"
static bool isLegalToInline(InlinerInterface &interface, Region *src, Region *insertRegion, bool shouldCloneInlinedRegion, IRMapping &valueMapping)
Utility to check that all of the operations within 'src' can be inlined.
llvm::is_detected< has_region_builder, T > detect_has_region_builder
decltype(T::regionBuilder) has_region_builder
Trait to check if T provides a regionBuilder method.
void addNamedOpBuilders(llvm::StringMap< LinalgDialect::RegionBuilderFunType > &map)
void addNamedOpBuilderImpl(llvm::StringMap< LinalgDialect::RegionBuilderFunType > &map)
SFINAE helper for single C++ class without a regionBuilder method (e.g.
This is the interface that must be implemented by the dialects of operations to be inlined.
DialectInlinerInterface(Dialect *dialect)
This is a utility class for mapping one set of IR entities to another.
NamedAttribute represents a combination of a name and an Attribute value.
StringAttr getName() const
Return the name of the attribute.
Operation is the basic unit of execution within MLIR.
InFlightDiagnostic emitError(const Twine &message={})
Emit an error about fatal conditions with this operation, reporting up to any diagnostic handlers tha...
This class contains a list of basic blocks and a link to the parent operation it is attached to.
This class provides an abstraction over the different types of ranges over Values.
Include the generated interface declarations.