Skip to content

Commit 1d867c2

Browse files
committed
convert sycl.constructor(...) { Type = @id } (#45)
This PR implements the SYCLToLLVM conversion for lowering sycl::id<n>(....). It introduces the class ConstructorPattern which generates an llvm.call to the appropriate ctor function of the sycl::id templated class when given a sycl.constructor(%1) {Type = @id} operation. This PR also introduces a new too names sycl-mlir-opt which can be used to drive unit testing. Signed-off-by: Tiotto, Ettore <ettore.tiotto@intel.com>
1 parent 4a303d6 commit 1d867c2

File tree

23 files changed

+564
-193
lines changed

23 files changed

+564
-193
lines changed

mlir-sycl/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules")
7070
add_subdirectory(include/mlir)
7171
add_subdirectory(lib)
7272
add_subdirectory(test)
73+
add_subdirectory(tools)
7374

7475
install(DIRECTORY include/
7576
DESTINATION include

mlir-sycl/include/mlir/Conversion/SYCLPasses.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===- SYCLPasses.h - Conversion Pass Construction and Registration -----------===//
1+
//===- SYCLPasses.h - Conversion Pass Construction and Registration -------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,14 +9,16 @@
99
#ifndef MLIR_CONVERSION_SYCLPASSES_H
1010
#define MLIR_CONVERSION_SYCLPASSES_H
1111

12-
#include "mlir/Conversion/SYCLToLLVM/SYCLToLLVM.h"
12+
#include "mlir/Conversion/SYCLToLLVM/SYCLToLLVMPass.h"
1313

1414
namespace mlir {
15+
namespace sycl {
1516

1617
/// Generate the code for registering conversion passes.
1718
#define GEN_PASS_REGISTRATION
1819
#include "mlir/Conversion/SYCLPasses.h.inc"
1920

21+
} // namespace sycl
2022
} // namespace mlir
2123

2224
#endif // MLIR_CONVERSION_SYCLPASSES_H

mlir-sycl/include/mlir/Conversion/SYCLPasses.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def ConvertSYCLToLLVM : Pass<"convert-sycl-to-llvm", "ModuleOp"> {
2121
See docs/SYCLToLLVMDialectConversion/ for more details.
2222
TODO: add docs referenced above.
2323
}];
24-
let constructor = "mlir::createConvertSYCLToLLVMPass()";
24+
let constructor = "mlir::sycl::createConvertSYCLToLLVMPass()";
2525
let dependentDialects = ["LLVM::LLVMDialect"];
2626
}
2727

mlir-sycl/include/mlir/Conversion/SYCLToLLVM/DialectBuilder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ class LLVMBuilder : public DialectBuilder {
7575
LLVM::BitcastOp genBitcast(Type type, Value val) const;
7676
LLVM::ExtractValueOp genExtractValue(Type type, Value container,
7777
ArrayRef<int64_t> pos) const;
78-
LLVM::CallOp genCall(FlatSymbolRefAttr funcSym, ArrayRef<Type> resTypes,
79-
ArrayRef<Value> operands) const;
78+
LLVM::CallOp genCall(FlatSymbolRefAttr funcSym, TypeRange resTypes,
79+
ValueRange operands) const;
8080
LLVM::ConstantOp genConstant(Type type, double val) const;
8181
LLVM::SExtOp genSignExtend(Type type, Value val) const;
8282
};

mlir-sycl/include/mlir/Conversion/SYCLToLLVM/SYCLFuncRegistry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class SYCLFuncDescriptor {
5454
// clang-format on
5555

5656
// Call the SYCL constructor identified by \p id with the given \p args.
57-
static Value call(FuncId id, ArrayRef<Value> args,
57+
static Value call(FuncId id, ValueRange args,
5858
const SYCLFuncRegistry &registry, OpBuilder &b,
5959
Location loc);
6060

mlir-sycl/include/mlir/Conversion/SYCLToLLVM/SYCLToLLVM.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#define MLIR_CONVERSION_SYCLTOLLVM_SYCLTOLLVM_H
1515

1616
#include "mlir/Transforms/DialectConversion.h"
17+
#include "mlir/Dialect/Func/IR/FuncOps.h"
1718

1819
namespace mlir {
1920
class LLVMTypeConverter;

mlir-sycl/include/mlir/Conversion/SYCLToLLVM/SYCLToLLVMPass.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,19 @@
1313
#ifndef MLIR_CONVERSION_SYCLTOLLVM_SYCLTOLLVMPASS_H
1414
#define MLIR_CONVERSION_SYCLTOLLVM_SYCLTOLLVMPASS_H
1515

16+
#include "mlir/Pass/Pass.h"
1617
#include <memory>
1718

1819
namespace mlir {
1920
class ModuleOp;
2021
template <typename T> class OperationPass;
2122

23+
namespace sycl {
24+
2225
/// Creates a pass to convert SYCL operations to the LLVMIR dialect.
2326
std::unique_ptr<OperationPass<ModuleOp>> createConvertSYCLToLLVMPass();
2427

28+
} // namespace sycl
2529
} // namespace mlir
2630

2731
#endif // MLIR_CONVERSION_SYCLTOLLVM_SYCLTOLLVMPASS_H
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
add_subdirectory(IR)
2+
add_subdirectory(Transforms)
Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,2 @@
1-
# Copyright (C) Codeplay Software Limited
2-
3-
#===--- CMakeLists.txt -----------------------------------------------------===#
4-
#
5-
# MLIR-SYCL is under the Apache License v2.0 with LLVM Exceptions.
6-
# See https://llvm.org/LICENSE.txt for license information.
7-
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8-
#
9-
#===------------------------------------------------------------------------===#
10-
111
add_mlir_dialect(SYCLOps sycl)
122
add_mlir_doc(SYCLOps SYCLOps Dialects/ -gen-op-doc)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
set(LLVM_TARGET_DEFINITIONS Passes.td)
2+
mlir_tablegen(Passes.h.inc -gen-pass-decls -name SYCL)
3+
add_public_tablegen_target(MLIRSYCLTransformsIncGen)
4+
add_dependencies(mlir-headers MLIRSYCLTransformsIncGen)
5+
6+
add_mlir_doc(Passes SYCLPasses ./ -gen-pass-doc)

0 commit comments

Comments
 (0)