diff --git a/mlir/include/mlir/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.h b/mlir/include/mlir/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.h --- a/mlir/include/mlir/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.h +++ b/mlir/include/mlir/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.h @@ -13,10 +13,10 @@ #ifndef MLIR_CONVERSION_SPIRVTOLLVM_CONVERTSPIRVTOLLVM_H #define MLIR_CONVERSION_SPIRVTOLLVM_CONVERTSPIRVTOLLVM_H -#include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h" #include "mlir/Transforms/DialectConversion.h" namespace mlir { +class LLVMTypeConverter; class MLIRContext; class ModuleOp; template diff --git a/mlir/include/mlir/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVMPass.h b/mlir/include/mlir/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVMPass.h --- a/mlir/include/mlir/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVMPass.h +++ b/mlir/include/mlir/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVMPass.h @@ -13,9 +13,12 @@ #ifndef MLIR_CONVERSION_SPIRVTOLLVM_CONVERTSPIRVTOLLVMPASS_H #define MLIR_CONVERSION_SPIRVTOLLVM_CONVERTSPIRVTOLLVMPASS_H -#include "mlir/Pass/Pass.h" +#include namespace mlir { +class ModuleOp; +template +class OperationPass; /// Create a pass to convert SPIR-V operations to the LLVMIR dialect. std::unique_ptr> createConvertSPIRVToLLVMPass(); diff --git a/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h b/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h --- a/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h +++ b/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h @@ -13,7 +13,8 @@ namespace mlir { class LLVMTypeConverter; class ModuleOp; -template class OperationPass; +template +class OperationPass; /// Collect a set of patterns to convert from Vector contractions to LLVM Matrix /// Intrinsics. To lower to assembly, the LLVM flag -lower-matrix-intrinsics diff --git a/mlir/lib/Conversion/CMakeLists.txt b/mlir/lib/Conversion/CMakeLists.txt --- a/mlir/lib/Conversion/CMakeLists.txt +++ b/mlir/lib/Conversion/CMakeLists.txt @@ -10,8 +10,8 @@ add_subdirectory(LinalgToStandard) add_subdirectory(SCFToGPU) add_subdirectory(SCFToStandard) +add_subdirectory(SPIRVToLLVM) add_subdirectory(StandardToLLVM) add_subdirectory(StandardToSPIRV) add_subdirectory(VectorToLLVM) add_subdirectory(VectorToSCF) -add_subdirectory(SPIRVToLLVM) diff --git a/mlir/lib/Conversion/SPIRVToLLVM/CMakeLists.txt b/mlir/lib/Conversion/SPIRVToLLVM/CMakeLists.txt --- a/mlir/lib/Conversion/SPIRVToLLVM/CMakeLists.txt +++ b/mlir/lib/Conversion/SPIRVToLLVM/CMakeLists.txt @@ -15,4 +15,4 @@ MLIRStandardToLLVM MLIRIR MLIRTransforms - ) \ No newline at end of file + ) diff --git a/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp b/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp --- a/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp +++ b/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// +#include "mlir/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.h" #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h" #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" @@ -21,13 +22,11 @@ #include "mlir/Support/LogicalResult.h" #include "mlir/Transforms/DialectConversion.h" -#include - using namespace mlir; using namespace mlir::LLVM; using namespace mlir::spirv; -namespace mlir { +namespace { class BitwiseAndOpConversion : public ConvertToLLVMPattern { public: @@ -39,20 +38,18 @@ LogicalResult matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { - assert(operands.size() == 2); auto bitwiseAndOp = cast(op); auto dstType = typeConverter.convertType(bitwiseAndOp.getType()); - if (!dstType) { + if (!dstType) return failure(); - } rewriter.replaceOpWithNewOp(bitwiseAndOp, dstType, operands); return success(); } }; +} // namespace -void populateSPIRVToLLVMConversionPatterns(MLIRContext *context, - LLVMTypeConverter &typeConverter, - OwningRewritePatternList &patterns) { +void mlir::populateSPIRVToLLVMConversionPatterns( + MLIRContext *context, LLVMTypeConverter &typeConverter, + OwningRewritePatternList &patterns) { patterns.insert(context, typeConverter); } -} // namespace mlir diff --git a/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVMPass.cpp b/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVMPass.cpp --- a/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVMPass.cpp +++ b/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVMPass.cpp @@ -41,9 +41,8 @@ target.addIllegalDialect(); target.addLegalDialect(); - if (failed(applyPartialConversion(module, target, patterns, &converter))) { + if (failed(applyPartialConversion(module, target, patterns, &converter))) signalPassFailure(); - } } std::unique_ptr> mlir::createConvertSPIRVToLLVMPass() {