Create the Arithmetic dialect that contains basic integer and floating point arithmetic operations. Ops that did not meet this criterion were moved to the Math dialect. First of two atomic patches to remove integer and floating point operations from the standard dialect. Ops will be removed from the standard dialect in a subsequent patch. Reviewed By: ftynse, silvas Differential Revision: https://reviews.llvm.org/D110200
38 lines
1.2 KiB
C++
38 lines
1.2 KiB
C++
//===- ArithmeticDialect.cpp - MLIR Arithmetic dialect implementation -----===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h"
|
|
#include "mlir/Transforms/InliningUtils.h"
|
|
|
|
using namespace mlir;
|
|
using namespace mlir::arith;
|
|
|
|
#include "mlir/Dialect/Arithmetic/IR/ArithmeticOpsDialect.cpp.inc"
|
|
|
|
namespace {
|
|
/// This class defines the interface for handling inlining for arithmetic
|
|
/// dialect operations.
|
|
struct ArithmeticInlinerInterface : public DialectInlinerInterface {
|
|
using DialectInlinerInterface::DialectInlinerInterface;
|
|
|
|
/// All arithmetic dialect ops can be inlined.
|
|
bool isLegalToInline(Operation *, Region *, bool,
|
|
BlockAndValueMapping &) const final {
|
|
return true;
|
|
}
|
|
};
|
|
} // end anonymous namespace
|
|
|
|
void mlir::arith::ArithmeticDialect::initialize() {
|
|
addOperations<
|
|
#define GET_OP_LIST
|
|
#include "mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
|
|
>();
|
|
addInterfaces<ArithmeticInlinerInterface>();
|
|
}
|