//===- MathOps.cpp - MLIR operations for math 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/Arith/IR/Arith.h" #include "mlir/Dialect/CommonFolders.h" #include "mlir/Dialect/Math/IR/Math.h" #include "mlir/Dialect/UB/IR/UBOps.h" #include "mlir/IR/Builders.h" #include <optional> usingnamespacemlir; usingnamespacemlir::math; //===----------------------------------------------------------------------===// // TableGen'd op method definitions //===----------------------------------------------------------------------===// #define GET_OP_CLASSES #include "mlir/Dialect/Math/IR/MathOps.cpp.inc" //===----------------------------------------------------------------------===// // AbsFOp folder //===----------------------------------------------------------------------===// OpFoldResult math::AbsFOp::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // AbsIOp folder //===----------------------------------------------------------------------===// OpFoldResult math::AbsIOp::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // AcosOp folder //===----------------------------------------------------------------------===// OpFoldResult math::AcosOp::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // AcoshOp folder //===----------------------------------------------------------------------===// OpFoldResult math::AcoshOp::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // AsinOp folder //===----------------------------------------------------------------------===// OpFoldResult math::AsinOp::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // AsinhOp folder //===----------------------------------------------------------------------===// OpFoldResult math::AsinhOp::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // AtanOp folder //===----------------------------------------------------------------------===// OpFoldResult math::AtanOp::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // AtanhOp folder //===----------------------------------------------------------------------===// OpFoldResult math::AtanhOp::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // Atan2Op folder //===----------------------------------------------------------------------===// OpFoldResult math::Atan2Op::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // CeilOp folder //===----------------------------------------------------------------------===// OpFoldResult math::CeilOp::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // CopySignOp folder //===----------------------------------------------------------------------===// OpFoldResult math::CopySignOp::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // CosOp folder //===----------------------------------------------------------------------===// OpFoldResult math::CosOp::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // CoshOp folder //===----------------------------------------------------------------------===// OpFoldResult math::CoshOp::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // SinOp folder //===----------------------------------------------------------------------===// OpFoldResult math::SinOp::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // SinhOp folder //===----------------------------------------------------------------------===// OpFoldResult math::SinhOp::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // CountLeadingZerosOp folder //===----------------------------------------------------------------------===// OpFoldResult math::CountLeadingZerosOp::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // CountTrailingZerosOp folder //===----------------------------------------------------------------------===// OpFoldResult math::CountTrailingZerosOp::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // CtPopOp folder //===----------------------------------------------------------------------===// OpFoldResult math::CtPopOp::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // ErfOp folder //===----------------------------------------------------------------------===// OpFoldResult math::ErfOp::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // IPowIOp folder //===----------------------------------------------------------------------===// OpFoldResult math::IPowIOp::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // LogOp folder //===----------------------------------------------------------------------===// OpFoldResult math::LogOp::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // Log2Op folder //===----------------------------------------------------------------------===// OpFoldResult math::Log2Op::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // Log10Op folder //===----------------------------------------------------------------------===// OpFoldResult math::Log10Op::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // Log1pOp folder //===----------------------------------------------------------------------===// OpFoldResult math::Log1pOp::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // PowFOp folder //===----------------------------------------------------------------------===// OpFoldResult math::PowFOp::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // SqrtOp folder //===----------------------------------------------------------------------===// OpFoldResult math::SqrtOp::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // ExpOp folder //===----------------------------------------------------------------------===// OpFoldResult math::ExpOp::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // Exp2Op folder //===----------------------------------------------------------------------===// OpFoldResult math::Exp2Op::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // ExpM1Op folder //===----------------------------------------------------------------------===// OpFoldResult math::ExpM1Op::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // TanOp folder //===----------------------------------------------------------------------===// OpFoldResult math::TanOp::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // TanhOp folder //===----------------------------------------------------------------------===// OpFoldResult math::TanhOp::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // RoundEvenOp folder //===----------------------------------------------------------------------===// OpFoldResult math::RoundEvenOp::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // FloorOp folder //===----------------------------------------------------------------------===// OpFoldResult math::FloorOp::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // RoundOp folder //===----------------------------------------------------------------------===// OpFoldResult math::RoundOp::fold(FoldAdaptor adaptor) { … } //===----------------------------------------------------------------------===// // TruncOp folder //===----------------------------------------------------------------------===// OpFoldResult math::TruncOp::fold(FoldAdaptor adaptor) { … } /// Materialize an integer or floating point constant. Operation *math::MathDialect::materializeConstant(OpBuilder &builder, Attribute value, Type type, Location loc) { … }