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 namespace {
16 /// This class defines the interface for handling inlining with math
17 /// operations.
18 struct MathInlinerInterface : public DialectInlinerInterface {
19   using DialectInlinerInterface::DialectInlinerInterface;
20 
21   /// All operations within math ops can be inlined.
22   bool isLegalToInline(Operation *, Region *, bool,
23                        BlockAndValueMapping &) const final {
24     return true;
25   }
26 };
27 } // end anonymous namespace
28 
29 void mlir::math::MathDialect::initialize() {
30   addOperations<
31 #define GET_OP_LIST
32 #include "mlir/Dialect/Math/IR/MathOps.cpp.inc"
33       >();
34   addInterfaces<MathInlinerInterface>();
35 }
36