Skip to content

Commit 502d3b9

Browse files
committed
Create infrastructure for SYCLToLLVM conversion (#37)
Signed-off-by: Tiotto, Ettore <[email protected]>
1 parent 800f288 commit 502d3b9

31 files changed

+290
-94
lines changed

mlir-sycl/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ set(MLIR_SYCL_TOOLS_DIR ${CMAKE_BINARY_DIR}/bin)
6767
set(LLVM_LIT_ARGS "-sv" CACHE STRING "lit default options")
6868
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules")
6969

70-
add_subdirectory(include)
70+
add_subdirectory(include/mlir)
7171
add_subdirectory(lib)
7272
add_subdirectory(test)
7373

mlir-sycl/include/CMakeLists.txt

Lines changed: 0 additions & 11 deletions
This file was deleted.

mlir-sycl/include/SYCL/SYCLToLLVM.h

Lines changed: 0 additions & 27 deletions
This file was deleted.

mlir-sycl/include/mlir/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
add_subdirectory(Conversion)
2+
add_subdirectory(Dialect)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
set(LLVM_TARGET_DEFINITIONS SYCLPasses.td)
2+
mlir_tablegen(SYCLPasses.h.inc -gen-pass-decls -name Conversion)
3+
add_public_tablegen_target(MLIRSYCLConversionPassIncGen)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//===- SYCLPasses.h - Conversion Pass Construction and Registration -----------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef MLIR_CONVERSION_SYCLPASSES_H
10+
#define MLIR_CONVERSION_SYCLPASSES_H
11+
12+
#include "mlir/Conversion/SYCLToLLVM/SYCLToLLVM.h"
13+
14+
namespace mlir {
15+
16+
/// Generate the code for registering conversion passes.
17+
#define GEN_PASS_REGISTRATION
18+
#include "mlir/Conversion/SYCLPasses.h.inc"
19+
20+
} // namespace mlir
21+
22+
#endif // MLIR_CONVERSION_SYCLPASSES_H
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//===-- SYCLPasses.td - Conversion pass definition file ----*- tablegen -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef MLIR_CONVERSION_SYCLPASSES
10+
#define MLIR_CONVERSION_SYCLPASSES
11+
12+
include "mlir/Pass/PassBase.td"
13+
14+
//===----------------------------------------------------------------------===//
15+
// SYCLToLLVM
16+
//===----------------------------------------------------------------------===//
17+
18+
def ConvertSYCLToLLVM : Pass<"convert-sycl-to-llvm", "ModuleOp"> {
19+
let summary = "Convert SYCL dialect to LLVM dialect";
20+
let description = [{
21+
See docs/SYCLToLLVMDialectConversion/ for more details.
22+
TODO: add docs referenced above.
23+
}];
24+
let constructor = "mlir::createConvertSYCLToLLVMPass()";
25+
let dependentDialects = ["LLVM::LLVMDialect"];
26+
}
27+
28+
#endif // MLIR_CONVERSION_SYCLPASSES
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//===- SYCLToLLVM.h - SYCL to LLVM Patterns ---------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// Provides patterns to convert SYCL dialect to LLVM dialect.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef MLIR_CONVERSION_SYCLTOLLVM_SYCLTOLLVM_H
14+
#define MLIR_CONVERSION_SYCLTOLLVM_SYCLTOLLVM_H
15+
16+
#include "mlir/Transforms/DialectConversion.h"
17+
18+
namespace mlir {
19+
class LLVMTypeConverter;
20+
class MLIRContext;
21+
class ModuleOp;
22+
23+
namespace sycl {
24+
template <typename SYCLOp>
25+
class SYCLToLLVMConversion : public OpConversionPattern<SYCLOp> {
26+
public:
27+
SYCLToLLVMConversion(MLIRContext *context, LLVMTypeConverter &typeConverter,
28+
PatternBenefit benefit = 1)
29+
: OpConversionPattern<SYCLOp>(typeConverter, context, benefit),
30+
typeConverter(typeConverter) {}
31+
32+
protected:
33+
LLVMTypeConverter &typeConverter;
34+
};
35+
36+
/// Populates type conversions with additional SYCL types.
37+
void populateSYCLToLLVMTypeConversion(LLVMTypeConverter &typeConverter);
38+
39+
/// Populates the given list with patterns that convert from SYCL to LLVM.
40+
void populateSYCLToLLVMConversionPatterns(LLVMTypeConverter &typeConverter,
41+
RewritePatternSet &patterns);
42+
43+
} // namespace sycl
44+
} // namespace mlir
45+
46+
#endif // MLIR_CONVERSION_SYCLTOLLVM_SYCLTOLLVM_H
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//===- SYCLToLLVMPass.h - SYCL to LLVM Passes -------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// Provides passes to convert SYCL dialect to LLVM dialect.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef MLIR_CONVERSION_SYCLTOLLVM_SYCLTOLLVMPASS_H
14+
#define MLIR_CONVERSION_SYCLTOLLVM_SYCLTOLLVMPASS_H
15+
16+
#include <memory>
17+
18+
namespace mlir {
19+
class ModuleOp;
20+
template <typename T> class OperationPass;
21+
22+
/// Creates a pass to convert SYCL operations to the LLVMIR dialect.
23+
std::unique_ptr<OperationPass<ModuleOp>> createConvertSYCLToLLVMPass();
24+
25+
} // namespace mlir
26+
27+
#endif // MLIR_CONVERSION_SYCLTOLLVM_SYCLTOLLVMPASS_H
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_subdirectory(SYCL)

0 commit comments

Comments
 (0)