1 //===- MathDialect.cpp - MLIR dialect for Math implementation -------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "mlir/Dialect/Math/IR/Math.h"
10 #include "mlir/Transforms/InliningUtils.h"
11 
12 using namespace mlir;
13 using namespace mlir::math;
14 
15 #include "mlir/Dialect/Math/IR/MathOpsDialect.cpp.inc"
16 
17 namespace {
18 /// This class defines the interface for handling inlining with math
19 /// operations.
20 struct MathInlinerInterface : public DialectInlinerInterface {
21   using DialectInlinerInterface::DialectInlinerInterface;
22 
23   /// All operations within math ops can be inlined.
24   bool isLegalToInline(Operation *, Region *, bool,
25                        BlockAndValueMapping &) const final {
26     return true;
27   }
28 };
29 } // end anonymous namespace
30 
31 void mlir::math::MathDialect::initialize() {
32   addOperations<
33 #define GET_OP_LIST
34 #include "mlir/Dialect/Math/IR/MathOps.cpp.inc"
35       >();
36   addInterfaces<MathInlinerInterface>();
37 }
38