MLIR  15.0.0git
GPUCommonPass.h
Go to the documentation of this file.
1 //===- GPUCommonPass.h - MLIR GPU runtime support -------------------------===//
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 #ifndef MLIR_CONVERSION_GPUCOMMON_GPUCOMMONPASS_H_
9 #define MLIR_CONVERSION_GPUCOMMON_GPUCOMMONPASS_H_
10 
11 #include "mlir/Support/LLVM.h"
12 #include "llvm/ADT/StringRef.h"
13 #include <functional>
14 #include <vector>
15 
16 namespace llvm {
17 class LLVMContext;
18 class Module;
19 } // namespace llvm
20 
21 namespace mlir {
22 
23 class LLVMTypeConverter;
24 class Location;
25 struct LogicalResult;
26 class ModuleOp;
27 class Operation;
28 class RewritePatternSet;
29 
30 template <typename T>
31 class OperationPass;
32 
33 namespace gpu {
34 class GPUModuleOp;
35 } // namespace gpu
36 
37 namespace LLVM {
38 class LLVMDialect;
39 } // namespace LLVM
40 
41 using OwnedBlob = std::unique_ptr<std::vector<char>>;
42 using BlobGenerator =
43  std::function<OwnedBlob(const std::string &, Location, StringRef)>;
44 using LoweringCallback = std::function<std::unique_ptr<llvm::Module>(
45  Operation *, llvm::LLVMContext &, StringRef)>;
46 
47 /// Creates a pass to convert a GPU operations into a sequence of GPU runtime
48 /// calls.
49 ///
50 /// This pass does not generate code to call GPU runtime APIs directly but
51 /// instead uses a small wrapper library that exports a stable and conveniently
52 /// typed ABI on top of GPU runtimes such as CUDA or ROCm (HIP).
53 std::unique_ptr<OperationPass<ModuleOp>> createGpuToLLVMConversionPass();
54 
55 /// Collect a set of patterns to convert from the GPU dialect to LLVM and
56 /// populate converter for gpu types.
58  RewritePatternSet &patterns,
59  StringRef gpuBinaryAnnotation = {});
60 
61 } // namespace mlir
62 
63 #endif // MLIR_CONVERSION_GPUCOMMON_GPUCOMMONPASS_H_
TODO: Remove this file when SCCP and integer range analysis have been ported to the new framework...
The OpAsmOpInterface, see OpAsmInterface.td for more details.
Definition: CallGraph.h:221
Operation is a basic unit of execution within MLIR.
Definition: Operation.h:28
std::function< std::unique_ptr< llvm::Module >(Operation *, llvm::LLVMContext &, StringRef)> LoweringCallback
Definition: GPUCommonPass.h:45
std::function< OwnedBlob(const std::string &, Location, StringRef)> BlobGenerator
Definition: GPUCommonPass.h:43
std::unique_ptr< OperationPass< ModuleOp > > createGpuToLLVMConversionPass()
Creates a pass to convert a GPU operations into a sequence of GPU runtime calls.
void populateGpuToLLVMConversionPatterns(LLVMTypeConverter &converter, RewritePatternSet &patterns, StringRef gpuBinaryAnnotation={})
Collect a set of patterns to convert from the GPU dialect to LLVM and populate converter for gpu type...
std::unique_ptr< std::vector< char > > OwnedBlob
Definition: GPUCommonPass.h:41
Conversion from types to the LLVM IR dialect.
Definition: TypeConverter.h:30