#include "mlir/Conversion/AffineToStandard/AffineToStandard.h"
#include "mlir/Conversion/FuncToLLVM/ConvertFuncToLLVMPass.h"
#include "mlir/Conversion/IndexToLLVM/IndexToLLVM.h"
#include "mlir/Conversion/MathToLLVM/MathToLLVM.h"
#include "mlir/Conversion/MemRefToLLVM/MemRefToLLVM.h"
#include "mlir/Conversion/ReconcileUnrealizedCasts/ReconcileUnrealizedCasts.h"
#include "mlir/Conversion/SCFToControlFlow/SCFToControlFlow.h"
#include "mlir/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.h"
#include "mlir/Conversion/VectorToSCF/VectorToSCF.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/Dialect/Linalg/Passes.h"
#include "mlir/Dialect/MemRef/Transforms/Passes.h"
#include "mlir/IR/DialectRegistry.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Pass/PassManager.h"
#include "mlir/Pass/PassOptions.h"
#include "mlir/Transforms/Passes.h"
using namespace mlir;
namespace {
struct TestLowerToLLVMOptions
: public PassPipelineOptions<TestLowerToLLVMOptions> {
PassOptions::Option<bool> reassociateFPReductions{
*this, "reassociate-fp-reductions",
llvm::cl::desc("Allow reassociation og FP reductions"),
llvm::cl::init(false)};
};
void buildTestLowerToLLVM(OpPassManager &pm,
const TestLowerToLLVMOptions &options) {
pm.addNestedPass<func::FuncOp>(createConvertVectorToSCFPass());
pm.addNestedPass<func::FuncOp>(createConvertLinalgToLoopsPass());
pm.addPass(createLowerAffinePass());
pm.addPass(createConvertSCFToCFPass());
pm.addPass(createCanonicalizerPass());
pm.addPass(createCSEPass());
pm.addPass(createConvertVectorToLLVMPass(
ConvertVectorToLLVMPassOptions{options.reassociateFPReductions}));
pm.addNestedPass<func::FuncOp>(createConvertMathToLLVMPass());
pm.addPass(memref::createExpandStridedMetadataPass());
pm.addPass(createLowerAffinePass());
pm.addPass(createFinalizeMemRefToLLVMConversionPass());
pm.addPass(createConvertFuncToLLVMPass());
pm.addPass(createConvertIndexToLLVMPass());
pm.addPass(createReconcileUnrealizedCastsPass());
}
}
namespace mlir {
namespace test {
void registerTestLowerToLLVM() {
PassPipelineRegistration<TestLowerToLLVMOptions>(
"test-lower-to-llvm",
"An example of pipeline to lower the main dialects (arith, linalg, "
"memref, scf, vector) down to LLVM.",
buildTestLowerToLLVM);
}
}
}