1 //===- OffloadWrapper.h --r-------------------------------------*- C++ -*-===// 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 9 #ifndef LLVM_FRONTEND_OFFLOADING_OFFLOADWRAPPER_H 10 #define LLVM_FRONTEND_OFFLOADING_OFFLOADWRAPPER_H 11 12 #include "llvm/ADT/ArrayRef.h" 13 #include "llvm/IR/Module.h" 14 15 namespace llvm { 16 namespace offloading { 17 using EntryArrayTy = std::pair<GlobalVariable *, GlobalVariable *>; 18 /// Wraps the input device images into the module \p M as global symbols and 19 /// registers the images with the OpenMP Offloading runtime libomptarget. 20 /// \param EntryArray Optional pair pointing to the `__start` and `__stop` 21 /// symbols holding the `__tgt_offload_entry` array. 22 /// \param Suffix An optional suffix appended to the emitted symbols. 23 llvm::Error wrapOpenMPBinaries(llvm::Module &M, 24 llvm::ArrayRef<llvm::ArrayRef<char>> Images, 25 EntryArrayTy EntryArray, 26 llvm::StringRef Suffix = ""); 27 28 /// Wraps the input fatbinary image into the module \p M as global symbols and 29 /// registers the images with the CUDA runtime. 30 /// \param EntryArray Optional pair pointing to the `__start` and `__stop` 31 /// symbols holding the `__tgt_offload_entry` array. 32 /// \param Suffix An optional suffix appended to the emitted symbols. 33 /// \param EmitSurfacesAndTextures Whether to emit surface and textures 34 /// registration code. It defaults to false. 35 llvm::Error wrapCudaBinary(llvm::Module &M, llvm::ArrayRef<char> Images, 36 EntryArrayTy EntryArray, llvm::StringRef Suffix = "", 37 bool EmitSurfacesAndTextures = true); 38 39 /// Wraps the input bundled image into the module \p M as global symbols and 40 /// registers the images with the HIP runtime. 41 /// \param EntryArray Optional pair pointing to the `__start` and `__stop` 42 /// symbols holding the `__tgt_offload_entry` array. 43 /// \param Suffix An optional suffix appended to the emitted symbols. 44 /// \param EmitSurfacesAndTextures Whether to emit surface and textures 45 /// registration code. It defaults to false. 46 llvm::Error wrapHIPBinary(llvm::Module &M, llvm::ArrayRef<char> Images, 47 EntryArrayTy EntryArray, llvm::StringRef Suffix = "", 48 bool EmitSurfacesAndTextures = true); 49 } // namespace offloading 50 } // namespace llvm 51 52 #endif // LLVM_FRONTEND_OFFLOADING_OFFLOADWRAPPER_H 53