#include "mlir/Conversion/MathToLibm/MathToLibm.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/Dialect/Math/IR/Math.h"
#include "mlir/Dialect/Utils/IndexingUtils.h"
#include "mlir/Dialect/Vector/IR/VectorOps.h"
#include "mlir/IR/BuiltinDialect.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Transforms/DialectConversion.h"
namespace mlir {
#define GEN_PASS_DEF_CONVERTMATHTOLIBM
#include "mlir/Conversion/Passes.h.inc"
}
usingnamespacemlir;
namespace {
template <typename Op>
struct VecOpToScalarOp : public OpRewritePattern<Op> { … };
template <typename Op>
struct PromoteOpToF32 : public OpRewritePattern<Op> { … };
template <typename Op>
struct ScalarOpToLibmCall : public OpRewritePattern<Op> { … };
template <typename OpTy>
void populatePatternsForOp(RewritePatternSet &patterns, MLIRContext *ctx,
StringRef floatFunc, StringRef doubleFunc) { … }
}
template <typename Op>
LogicalResult
VecOpToScalarOp<Op>::matchAndRewrite(Op op, PatternRewriter &rewriter) const { … }
template <typename Op>
LogicalResult
PromoteOpToF32<Op>::matchAndRewrite(Op op, PatternRewriter &rewriter) const { … }
template <typename Op>
LogicalResult
ScalarOpToLibmCall<Op>::matchAndRewrite(Op op,
PatternRewriter &rewriter) const { … }
void mlir::populateMathToLibmConversionPatterns(RewritePatternSet &patterns) { … }
namespace {
struct ConvertMathToLibmPass
: public impl::ConvertMathToLibmBase<ConvertMathToLibmPass> { … };
}
void ConvertMathToLibmPass::runOnOperation() { … }
std::unique_ptr<OperationPass<ModuleOp>> mlir::createConvertMathToLibmPass() { … }