[Mlir-commits] [mlir] d536569 - [MLIR] Expose target configuration for lowering to NVVM
Frederik Gossen
llvmlistbot at llvm.org
Wed Dec 9 01:30:05 PST 2020
Author: Frederik Gossen
Date: 2020-12-09T10:29:38+01:00
New Revision: d53656900921de5bb26b849b5910efd05a233107
URL: https://github.com/llvm/llvm-project/commit/d53656900921de5bb26b849b5910efd05a233107
DIFF: https://github.com/llvm/llvm-project/commit/d53656900921de5bb26b849b5910efd05a233107.diff
LOG: [MLIR] Expose target configuration for lowering to NVVM
Differential Revision: https://reviews.llvm.org/D92871
Added:
Modified:
mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h
mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h b/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h
index 1af13057f2ea..8be0a7cad017 100644
--- a/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h
+++ b/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h
@@ -14,6 +14,7 @@
namespace mlir {
class LLVMTypeConverter;
class OwningRewritePatternList;
+class ConversionTarget;
template <typename OpT> class OperationPass;
@@ -21,6 +22,9 @@ namespace gpu {
class GPUModuleOp;
}
+/// Configure target to convert from to convert from the GPU dialect to NVVM.
+void configureGpuToNVVMConversionLegality(ConversionTarget &target);
+
/// Collect a set of patterns to convert from the GPU dialect to NVVM.
void populateGpuToNVVMConversionPatterns(LLVMTypeConverter &converter,
OwningRewritePatternList &patterns);
diff --git a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
index 467c622f8bde..a0fe48175636 100644
--- a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
+++ b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
@@ -135,14 +135,7 @@ struct LowerGpuOpsToNVVMOpsPass
populateStdToLLVMConversionPatterns(converter, llvmPatterns);
populateGpuToNVVMConversionPatterns(converter, llvmPatterns);
LLVMConversionTarget target(getContext());
- target.addIllegalDialect<gpu::GPUDialect>();
- target.addIllegalOp<LLVM::CosOp, LLVM::ExpOp, LLVM::FAbsOp, LLVM::FCeilOp,
- LLVM::FFloorOp, LLVM::LogOp, LLVM::Log10Op,
- LLVM::Log2Op, LLVM::SinOp, LLVM::SqrtOp>();
- target.addIllegalOp<FuncOp>();
- target.addLegalDialect<NVVM::NVVMDialect>();
- // TODO: Remove once we support replacing non-root ops.
- target.addLegalOp<gpu::YieldOp, gpu::GPUModuleOp, gpu::ModuleEndOp>();
+ configureGpuToNVVMConversionLegality(target);
if (failed(applyPartialConversion(m, target, std::move(llvmPatterns))))
signalPassFailure();
}
@@ -150,6 +143,19 @@ struct LowerGpuOpsToNVVMOpsPass
} // anonymous namespace
+void mlir::configureGpuToNVVMConversionLegality(ConversionTarget &target) {
+ target.addIllegalOp<FuncOp>();
+ target.addLegalDialect<::mlir::LLVM::LLVMDialect>();
+ target.addLegalDialect<::mlir::NVVM::NVVMDialect>();
+ target.addIllegalDialect<gpu::GPUDialect>();
+ target.addIllegalOp<LLVM::CosOp, LLVM::ExpOp, LLVM::FAbsOp, LLVM::FCeilOp,
+ LLVM::FFloorOp, LLVM::LogOp, LLVM::Log10Op, LLVM::Log2Op,
+ LLVM::SinOp, LLVM::SqrtOp>();
+
+ // TODO: Remove once we support replacing non-root ops.
+ target.addLegalOp<gpu::YieldOp, gpu::GPUModuleOp, gpu::ModuleEndOp>();
+}
+
void mlir::populateGpuToNVVMConversionPatterns(
LLVMTypeConverter &converter, OwningRewritePatternList &patterns) {
populateWithGenerated(converter.getDialect()->getContext(), patterns);
More information about the Mlir-commits
mailing list