|
6 | 6 | //
|
7 | 7 | //===----------------------------------------------------------------------===//
|
8 | 8 |
|
9 |
| -#ifndef LLVM_CLANG_TOOLS_CLANG_LINKER_WRAPPER_OFFLOAD_WRAPPER_H |
10 |
| -#define LLVM_CLANG_TOOLS_CLANG_LINKER_WRAPPER_OFFLOAD_WRAPPER_H |
| 9 | +#ifndef LLVM_FRONTEND_OFFLOADING_OFFLOADWRAPPER_H |
| 10 | +#define LLVM_FRONTEND_OFFLOADING_OFFLOADWRAPPER_H |
11 | 11 |
|
12 | 12 | #include "llvm/ADT/ArrayRef.h"
|
13 | 13 | #include "llvm/IR/Module.h"
|
14 | 14 |
|
15 |
| -/// Wraps the input device images into the module \p M as global symbols and |
16 |
| -/// registers the images with the OpenMP Offloading runtime libomptarget. |
17 |
| -llvm::Error wrapOpenMPBinaries(llvm::Module &M, |
18 |
| - llvm::ArrayRef<llvm::ArrayRef<char>> Images); |
| 15 | +namespace llvm { |
| 16 | +namespace offloading { |
| 17 | +/// Class for embedding and registering offloading images and related objects in |
| 18 | +/// a Module. |
| 19 | +class OffloadWrapper { |
| 20 | +public: |
| 21 | + using EntryArrayTy = std::pair<GlobalVariable *, GlobalVariable *>; |
19 | 22 |
|
20 |
| -/// Wraps the input fatbinary image into the module \p M as global symbols and |
21 |
| -/// registers the images with the CUDA runtime. |
22 |
| -llvm::Error wrapCudaBinary(llvm::Module &M, llvm::ArrayRef<char> Images); |
| 23 | + OffloadWrapper(const Twine &Suffix = "", bool EmitSurfacesAndTextures = true) |
| 24 | + : Suffix(Suffix.str()), EmitSurfacesAndTextures(EmitSurfacesAndTextures) { |
| 25 | + } |
23 | 26 |
|
24 |
| -/// Wraps the input bundled image into the module \p M as global symbols and |
25 |
| -/// registers the images with the HIP runtime. |
26 |
| -llvm::Error wrapHIPBinary(llvm::Module &M, llvm::ArrayRef<char> Images); |
| 27 | + /// Wraps the input device images into the module \p M as global symbols and |
| 28 | + /// registers the images with the OpenMP Offloading runtime libomptarget. |
| 29 | + /// \param EntryArray Optional pair pointing to the `__start` and `__stop` |
| 30 | + /// symbols holding the `__tgt_offload_entry` array. |
| 31 | + llvm::Error wrapOpenMPBinaries( |
| 32 | + llvm::Module &M, llvm::ArrayRef<llvm::ArrayRef<char>> Images, |
| 33 | + std::optional<EntryArrayTy> EntryArray = std::nullopt) const; |
27 | 34 |
|
28 |
| -#endif |
| 35 | + /// Wraps the input fatbinary image into the module \p M as global symbols and |
| 36 | + /// registers the images with the CUDA runtime. |
| 37 | + /// \param EntryArray Optional pair pointing to the `__start` and `__stop` |
| 38 | + /// symbols holding the `__tgt_offload_entry` array. |
| 39 | + llvm::Error |
| 40 | + wrapCudaBinary(llvm::Module &M, llvm::ArrayRef<char> Images, |
| 41 | + std::optional<EntryArrayTy> EntryArray = std::nullopt) const; |
| 42 | + |
| 43 | + /// Wraps the input bundled image into the module \p M as global symbols and |
| 44 | + /// registers the images with the HIP runtime. |
| 45 | + /// \param EntryArray Optional pair pointing to the `__start` and `__stop` |
| 46 | + /// symbols holding the `__tgt_offload_entry` array. |
| 47 | + llvm::Error |
| 48 | + wrapHIPBinary(llvm::Module &M, llvm::ArrayRef<char> Images, |
| 49 | + std::optional<EntryArrayTy> EntryArray = std::nullopt) const; |
| 50 | + |
| 51 | +protected: |
| 52 | + /// Suffix used when emitting symbols. It defaults to the empty string. |
| 53 | + std::string Suffix; |
| 54 | + |
| 55 | + /// Whether to emit surface and textures registration code. It defaults to |
| 56 | + /// false. |
| 57 | + bool EmitSurfacesAndTextures; |
| 58 | +}; |
| 59 | +} // namespace offloading |
| 60 | +} // namespace llvm |
| 61 | + |
| 62 | +#endif // LLVM_FRONTEND_OFFLOADING_OFFLOADWRAPPER_H |
0 commit comments