|
1 |
| -// Copyright (C) Intel |
2 |
| - |
3 |
| -//===--- SYCLToLLVM.cpp ---------------------------------------------------===// |
| 1 | +//===- SYCLToLLVM.cpp - SYCL to LLVM Patterns -----------------------------===// |
4 | 2 | //
|
5 |
| -// MLIR-SYCL is under the Apache License v2.0 with LLVM Exceptions. |
| 3 | +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
6 | 4 | // See https://llvm.org/LICENSE.txt for license information.
|
7 | 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
8 | 6 | //
|
9 | 7 | //===----------------------------------------------------------------------===//
|
10 | 8 | //
|
11 |
| -// This file implements a pass to convert SYCL dialects types to their |
12 |
| -// corresponding LLVM dialect types. |
| 9 | +// This file implements patterns to convert SYCL dialect to LLVM dialect. |
13 | 10 | //
|
14 | 11 | //===----------------------------------------------------------------------===//
|
15 | 12 |
|
16 |
| -#include "SYCL/SYCLToLLVM.h" |
17 |
| -#include "SYCL/SYCLOpsTypes.h" |
| 13 | +#include "mlir/Conversion/SYCLToLLVM/SYCLToLLVM.h" |
18 | 14 | #include "mlir/Conversion/LLVMCommon/Pattern.h"
|
| 15 | +#include "mlir/Conversion/LLVMCommon/TypeConverter.h" |
19 | 16 | #include "mlir/Dialect/LLVMIR/LLVMDialect.h"
|
| 17 | +#include "mlir/Dialect/SYCL/IR/SYCLOpsDialect.h" |
| 18 | +#include "mlir/Dialect/SYCL/IR/SYCLOpsTypes.h" |
| 19 | +#include "mlir/IR/BuiltinOps.h" |
| 20 | +#include "mlir/IR/PatternMatch.h" |
| 21 | +#include "mlir/Support/LogicalResult.h" |
| 22 | +#include "mlir/Transforms/DialectConversion.h" |
| 23 | +#include "llvm/Support/Debug.h" |
| 24 | + |
| 25 | +#define DEBUG_TYPE "sycl-to-llvm-pattern" |
20 | 26 |
|
21 | 27 | using namespace mlir;
|
22 | 28 |
|
23 |
| -namespace { |
| 29 | +//===----------------------------------------------------------------------===// |
| 30 | +// Utility functions |
| 31 | +//===----------------------------------------------------------------------===// |
| 32 | + |
24 | 33 | // Get the LLVM type of "class.cl::sycl::detail::array" with number of
|
25 | 34 | // dimentions \p dimNum and element type \p type.
|
26 | 35 | static Type getSYCLArrayTy(MLIRContext &context, unsigned dimNum, Type type) {
|
@@ -55,16 +64,24 @@ static Type getSYCLRangeOrIDTy(T type, StringRef name,
|
55 | 64 | }
|
56 | 65 | return LLVM::LLVMPointerType::get(structTy);
|
57 | 66 | }
|
58 |
| -} // namespace |
59 | 67 |
|
60 |
| -void mlir::sycl::populateSYCLToLLVMConversionPatterns( |
61 |
| - LLVMTypeConverter &converter, RewritePatternSet &patterns) { |
62 |
| - converter.addConversion([&](mlir::sycl::IDType type) { |
| 68 | +//===----------------------------------------------------------------------===// |
| 69 | +// Pattern population |
| 70 | +//===----------------------------------------------------------------------===// |
| 71 | + |
| 72 | +void mlir::sycl::populateSYCLToLLVMTypeConversion( |
| 73 | + LLVMTypeConverter &typeConverter) { |
| 74 | + typeConverter.addConversion([&](mlir::sycl::IDType type) { |
63 | 75 | return getSYCLRangeOrIDTy<mlir::sycl::IDType>(type, "class.cl::sycl::id",
|
64 |
| - converter); |
| 76 | + typeConverter); |
65 | 77 | });
|
66 |
| - converter.addConversion([&](mlir::sycl::RangeType type) { |
| 78 | + typeConverter.addConversion([&](mlir::sycl::RangeType type) { |
67 | 79 | return getSYCLRangeOrIDTy<mlir::sycl::RangeType>(
|
68 |
| - type, "class.cl::sycl::range", converter); |
| 80 | + type, "class.cl::sycl::range", typeConverter); |
69 | 81 | });
|
70 | 82 | }
|
| 83 | + |
| 84 | +void mlir::sycl::populateSYCLToLLVMConversionPatterns( |
| 85 | + LLVMTypeConverter &typeConverter, RewritePatternSet &patterns) { |
| 86 | + populateSYCLToLLVMTypeConversion(typeConverter); |
| 87 | +} |
0 commit comments