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 #include "llvm/Support/Compiler.h" 15 16 namespace llvm { 17 namespace offloading { 18 using EntryArrayTy = std::pair<GlobalVariable *, GlobalVariable *>; 19 /// Wraps the input device images into the module \p M as global symbols and 20 /// registers the images with the OpenMP Offloading runtime libomptarget. 21 /// \param EntryArray Optional pair pointing to the `__start` and `__stop` 22 /// symbols holding the `__tgt_offload_entry` array. 23 /// \param Suffix An optional suffix appended to the emitted symbols. 24 /// \param Relocatable Indicate if we need to change the offloading section to 25 /// create a relocatable object. 26 LLVM_ABI llvm::Error 27 wrapOpenMPBinaries(llvm::Module &M, llvm::ArrayRef<llvm::ArrayRef<char>> Images, 28 EntryArrayTy EntryArray, llvm::StringRef Suffix = "", 29 bool Relocatable = false); 30 31 /// Wraps the input fatbinary image into the module \p M as global symbols and 32 /// registers the images with the CUDA runtime. 33 /// \param EntryArray Optional pair pointing to the `__start` and `__stop` 34 /// symbols holding the `__tgt_offload_entry` array. 35 /// \param Suffix An optional suffix appended to the emitted symbols. 36 /// \param EmitSurfacesAndTextures Whether to emit surface and textures 37 /// registration code. It defaults to false. 38 LLVM_ABI llvm::Error wrapCudaBinary(llvm::Module &M, 39 llvm::ArrayRef<char> Images, 40 EntryArrayTy EntryArray, 41 llvm::StringRef Suffix = "", 42 bool EmitSurfacesAndTextures = true); 43 44 /// Wraps the input bundled image into the module \p M as global symbols and 45 /// registers the images with the HIP runtime. 46 /// \param EntryArray Optional pair pointing to the `__start` and `__stop` 47 /// symbols holding the `__tgt_offload_entry` array. 48 /// \param Suffix An optional suffix appended to the emitted symbols. 49 /// \param EmitSurfacesAndTextures Whether to emit surface and textures 50 /// registration code. It defaults to false. 51 LLVM_ABI llvm::Error wrapHIPBinary(llvm::Module &M, llvm::ArrayRef<char> Images, 52 EntryArrayTy EntryArray, 53 llvm::StringRef Suffix = "", 54 bool EmitSurfacesAndTextures = true); 55 } // namespace offloading 56 } // namespace llvm 57 58 #endif // LLVM_FRONTEND_OFFLOADING_OFFLOADWRAPPER_H 59