Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions include/imex/Conversion/ConvertToSPIRV/ConvertToSPIRV.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//===- ConvertToSPIRV.h - Converts everything to SPIR-V dialect - *-C++ -*-===//
//
// Copyright 2025 Intel Corporation
// Part of the IMEX 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
//
//===----------------------------------------------------------------------===//

#ifndef IMEX_CONVERSION_CONVERTTOSPIRV_H
#define IMEX_CONVERSION_CONVERTTOSPIRV_H

#include "imex/Utils/XeCommon.h"
#include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"
#include "mlir/IR/Operation.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Transforms/DialectConversion.h"

namespace mlir {
class ConversionTarget;
class SPIRVTypeConverter;
class Pass;
class Operation;
class RewritePatternSet;
template <typename T> class OperationPass;
} // namespace mlir

namespace imex {
#define GEN_PASS_DECL_CONVERTTOSPIRV
#include "imex/Conversion/Passes.h.inc"

std::unique_ptr<::mlir::OperationPass<::mlir::ModuleOp>>
createConvertToSPIRVPass();

} // namespace imex
#endif
1 change: 1 addition & 0 deletions include/imex/Conversion/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "mlir/Pass/Pass.h"

#include <imex/Conversion/ArithToVC/ArithToVC.h>
#include <imex/Conversion/ConvertToSPIRV/ConvertToSPIRV.h>
#include <imex/Conversion/DropRegions/DropRegions.h>
#include <imex/Conversion/GPUToGPUX/GPUToGPUX.h>
#include <imex/Conversion/GPUToSPIRV/GPUToSPIRVPass.h>
Expand Down
37 changes: 37 additions & 0 deletions include/imex/Conversion/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,43 @@ memref, arith and math.
let dependentDialects = ["::mlir::spirv::SPIRVDialect"];
}


//===----------------------------------------------------------------------===//
// ConvertToSPIRV
//===----------------------------------------------------------------------===//

def ConvertToSPIRV : Pass<"imex-convert-to-spirv", "::mlir::ModuleOp"> {
let summary = "Convert to SPIR-V dialect by using all the 'to SPIR-V' conversion patterns from all the dialect conversions";
let description = [{
This is a one-shot pass to convert to SPIR-V dialect by using all the 'to SPIR-V' conversion patterns from all the dialect conversions.
It includes the GPU to SPIR-V conversion as well as other dialects like SCF, Math, Arith etc.

}];
let dependentDialects = ["::mlir::spirv::SPIRVDialect"];
let constructor = "imex::createConvertToSPIRVPass()";
let options = [
// arith, cf, func, tensor to SPIR-V options
Option<"emulateLT32BitScalarTypes", "emulate-lt-32-bit-scalar-types",
"bool", /*default=*/"true",
"Emulate narrower scalar types with 32-bit ones if not supported by "
"the target">,
Option<"emulateUnsupportedFloatTypes", "emulate-unsupported-float-types",
"bool", /*default=*/"true",
"Emulate unsupported float types by representing them with integer "
"types of same bit width">,
// gpu, Index to SPIR-V options
Option<"use64bitIndex", "use-64bit-index",
"bool", /*default=*/"false",
"Use 64-bit integers to convert index types">,
// memref to SPIR-V options
Option<"boolNumBits", "bool-num-bits",
"int", /*default=*/"8",
"The number of bits to store a boolean value">,

];
}


//===----------------------------------------------------------------------===//
// GPUToGPUX
//===----------------------------------------------------------------------===//
Expand Down
1 change: 1 addition & 0 deletions lib/Conversion/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
add_subdirectory(ArithToVC)
add_subdirectory(ConvertToSPIRV)
add_subdirectory(NDArrayToLinalg)
add_subdirectory(DropRegions)
add_subdirectory(RegionParallelLoopToGpu)
Expand Down
24 changes: 24 additions & 0 deletions lib/Conversion/ConvertToSPIRV/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
add_imex_conversion_library(IMEXConvertToSPIRV
ConvertToSPIRVPass.cpp

ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/imex/Conversion/ConvertToSPIRV

DEPENDS
IMEXConversionPassIncGen

LINK_LIBS PUBLIC
MLIRArithToSPIRV
MLIRControlFlowToSPIRV
MLIRFuncToSPIRV
MLIRGPUDialect
MLIRGPUToSPIRV
MLIRIR
MLIRMathToSPIRV
MLIRPass
MLIRSCFToSPIRV
MLIRSPIRVDialect
MLIRSPIRVConversion
MLIRSupport
MLIRTransforms
)
Loading
Loading