MLIR  14.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 using OwningRewritePatternList = RewritePatternSet;
30 
31 template <typename T>
32 class OperationPass;
33 
34 namespace gpu {
35 class GPUModuleOp;
36 } // namespace gpu
37 
38 namespace LLVM {
39 class LLVMDialect;
40 } // namespace LLVM
41 
42 using OwnedBlob = std::unique_ptr<std::vector<char>>;
43 using BlobGenerator =
44  std::function<OwnedBlob(const std::string &, Location, StringRef)>;
45 using LoweringCallback = std::function<std::unique_ptr<llvm::Module>(
46  Operation *, llvm::LLVMContext &, StringRef)>;
47 
48 /// Creates a pass to convert a GPU operations into a sequence of GPU runtime
49 /// calls.
50 ///
51 /// This pass does not generate code to call GPU runtime APIs directly but
52 /// instead uses a small wrapper library that exports a stable and conveniently
53 /// typed ABI on top of GPU runtimes such as CUDA or ROCm (HIP).
54 std::unique_ptr<OperationPass<ModuleOp>> createGpuToLLVMConversionPass();
55 
56 /// Collect a set of patterns to convert from the GPU dialect to LLVM and
57 /// populate converter for gpu types.
59  OwningRewritePatternList &patterns,
60  StringRef gpuBinaryAnnotation = {});
61 
62 } // namespace mlir
63 
64 #endif // MLIR_CONVERSION_GPUCOMMON_GPUCOMMONPASS_H_
Include the generated interface declarations.
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:46
std::function< OwnedBlob(const std::string &, Location, StringRef)> BlobGenerator
Definition: GPUCommonPass.h:44
void populateGpuToLLVMConversionPatterns(LLVMTypeConverter &converter, OwningRewritePatternList &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< OperationPass< ModuleOp > > createGpuToLLVMConversionPass()
Creates a pass to convert a GPU operations into a sequence of GPU runtime calls.
std::unique_ptr< std::vector< char > > OwnedBlob
Definition: GPUCommonPass.h:42
Conversion from types in the Standard dialect to the LLVM IR dialect.
Definition: TypeConverter.h:30
RewritePatternSet OwningRewritePatternList