18c08f21bSMogball //===- ArithmeticDialect.cpp - MLIR Arithmetic dialect implementation -----===//
28c08f21bSMogball //
38c08f21bSMogball // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
48c08f21bSMogball // See https://llvm.org/LICENSE.txt for license information.
58c08f21bSMogball // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
68c08f21bSMogball //
78c08f21bSMogball //===----------------------------------------------------------------------===//
88c08f21bSMogball
98c08f21bSMogball #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h"
10a54f4eaeSMogball #include "mlir/IR/Builders.h"
118c08f21bSMogball #include "mlir/Transforms/InliningUtils.h"
128c08f21bSMogball
138c08f21bSMogball using namespace mlir;
148c08f21bSMogball using namespace mlir::arith;
158c08f21bSMogball
168c08f21bSMogball #include "mlir/Dialect/Arithmetic/IR/ArithmeticOpsDialect.cpp.inc"
178c08f21bSMogball
188c08f21bSMogball namespace {
198c08f21bSMogball /// This class defines the interface for handling inlining for arithmetic
208c08f21bSMogball /// dialect operations.
218c08f21bSMogball struct ArithmeticInlinerInterface : public DialectInlinerInterface {
228c08f21bSMogball using DialectInlinerInterface::DialectInlinerInterface;
238c08f21bSMogball
248c08f21bSMogball /// All arithmetic dialect ops can be inlined.
isLegalToInline__anond5bc71810111::ArithmeticInlinerInterface258c08f21bSMogball bool isLegalToInline(Operation *, Region *, bool,
268c08f21bSMogball BlockAndValueMapping &) const final {
278c08f21bSMogball return true;
288c08f21bSMogball }
298c08f21bSMogball };
30*be0a7e9fSMehdi Amini } // namespace
318c08f21bSMogball
initialize()32a54f4eaeSMogball void arith::ArithmeticDialect::initialize() {
338c08f21bSMogball addOperations<
348c08f21bSMogball #define GET_OP_LIST
358c08f21bSMogball #include "mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
368c08f21bSMogball >();
378c08f21bSMogball addInterfaces<ArithmeticInlinerInterface>();
388c08f21bSMogball }
39a54f4eaeSMogball
40a54f4eaeSMogball /// Materialize an integer or floating point constant.
materializeConstant(OpBuilder & builder,Attribute value,Type type,Location loc)41a54f4eaeSMogball Operation *arith::ArithmeticDialect::materializeConstant(OpBuilder &builder,
42a54f4eaeSMogball Attribute value,
43a54f4eaeSMogball Type type,
44a54f4eaeSMogball Location loc) {
45a54f4eaeSMogball return builder.create<arith::ConstantOp>(loc, value, type);
46a54f4eaeSMogball }
47