NFC: Refactor Dialect Conversion targeting SPIR-V.
Refactoring the conversion from StandardOps/GPU dialect to SPIR-V dialect: 1) Move the SPIRVTypeConversion and SPIRVOpLowering class into SPIR-V dialect. 2) Add header files that expose functions to add patterns for the dialects to SPIR-V lowering, as well as a pass that does the dialect to SPIR-V lowering. 3) Make SPIRVOpLowering derive from OpLowering class. PiperOrigin-RevId: 280486871
This commit is contained in:
committed by
A. Unique TensorFlower
parent
a4669cd3b4
commit
a78bd84cf8
@@ -16,13 +16,15 @@
|
||||
// =============================================================================
|
||||
//
|
||||
// This file implements a pass to convert MLIR standard ops into the SPIR-V
|
||||
// ops. It does not legalize FuncOps.
|
||||
// ops.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.h"
|
||||
#include "mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.h"
|
||||
#include "mlir/Dialect/SPIRV/Passes.h"
|
||||
#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
|
||||
#include "mlir/Dialect/SPIRV/SPIRVLowering.h"
|
||||
#include "mlir/Pass/Pass.h"
|
||||
|
||||
using namespace mlir;
|
||||
|
||||
@@ -38,7 +40,9 @@ void ConvertStandardToSPIRVPass::runOnModule() {
|
||||
OwningRewritePatternList patterns;
|
||||
auto module = getModule();
|
||||
|
||||
populateStandardToSPIRVPatterns(module.getContext(), patterns);
|
||||
SPIRVBasicTypeConverter basicTypeConverter;
|
||||
SPIRVTypeConverter typeConverter(&basicTypeConverter);
|
||||
populateStandardToSPIRVPatterns(module.getContext(), typeConverter, patterns);
|
||||
ConversionTarget target(*(module.getContext()));
|
||||
target.addLegalDialect<spirv::SPIRVDialect>();
|
||||
target.addLegalOp<FuncOp>();
|
||||
@@ -48,8 +52,7 @@ void ConvertStandardToSPIRVPass::runOnModule() {
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<OpPassBase<ModuleOp>>
|
||||
mlir::spirv::createConvertStandardToSPIRVPass() {
|
||||
std::unique_ptr<OpPassBase<ModuleOp>> mlir::createConvertStandardToSPIRVPass() {
|
||||
return std::make_unique<ConvertStandardToSPIRVPass>();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user