Renames 'x86vector' dialect to 'x86'. This is the first PR in series of cleanups around dialects targeting x86 platforms. The new naming scheme is shorter, cleaner, and opens possibility of integrating other x86-specific operations not strictly fitting pure vector representation. For example, the generalization will allow for future merger of AMX dialect into the x86 dialect to create one-stop x86 operations collection and boost discoverability.
72 lines
2.4 KiB
C++
72 lines
2.4 KiB
C++
//===- TestPolynomialApproximation.cpp - Test math ops approximations -----===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file contains test passes for expanding math operations into
|
|
// polynomial approximations.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "mlir/Dialect/Arith/IR/Arith.h"
|
|
#include "mlir/Dialect/Math/IR/Math.h"
|
|
#include "mlir/Dialect/Math/Transforms/Passes.h"
|
|
#include "mlir/Dialect/Vector/IR/VectorOps.h"
|
|
#include "mlir/Dialect/X86/X86Dialect.h"
|
|
#include "mlir/Pass/Pass.h"
|
|
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
|
|
|
|
using namespace mlir;
|
|
|
|
namespace {
|
|
struct TestMathPolynomialApproximationPass
|
|
: public PassWrapper<TestMathPolynomialApproximationPass, OperationPass<>> {
|
|
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(
|
|
TestMathPolynomialApproximationPass)
|
|
|
|
TestMathPolynomialApproximationPass() = default;
|
|
TestMathPolynomialApproximationPass(
|
|
const TestMathPolynomialApproximationPass &pass)
|
|
: PassWrapper(pass) {}
|
|
|
|
void runOnOperation() override;
|
|
void getDependentDialects(DialectRegistry ®istry) const override {
|
|
registry.insert<arith::ArithDialect, math::MathDialect,
|
|
vector::VectorDialect>();
|
|
if (enableAvx2)
|
|
registry.insert<x86::X86Dialect>();
|
|
}
|
|
StringRef getArgument() const final {
|
|
return "test-math-polynomial-approximation";
|
|
}
|
|
StringRef getDescription() const final {
|
|
return "Test math polynomial approximations";
|
|
}
|
|
|
|
Option<bool> enableAvx2{
|
|
*this, "enable-avx2",
|
|
llvm::cl::desc("Enable approximations that emit AVX2 intrinsics via the "
|
|
"X86 dialect"),
|
|
llvm::cl::init(false)};
|
|
};
|
|
} // namespace
|
|
|
|
void TestMathPolynomialApproximationPass::runOnOperation() {
|
|
RewritePatternSet patterns(&getContext());
|
|
MathPolynomialApproximationOptions approxOptions;
|
|
approxOptions.enableAvx2 = enableAvx2;
|
|
populateMathPolynomialApproximationPatterns(patterns, approxOptions);
|
|
(void)applyPatternsGreedily(getOperation(), std::move(patterns));
|
|
}
|
|
|
|
namespace mlir {
|
|
namespace test {
|
|
void registerTestMathPolynomialApproximationPass() {
|
|
PassRegistration<TestMathPolynomialApproximationPass>();
|
|
}
|
|
} // namespace test
|
|
} // namespace mlir
|