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
15namespace llvm {
16namespace offloading {
17using 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/// \param Relocatable Indicate if we need to change the offloading section to
24/// create a relocatable object.
25llvm::Error wrapOpenMPBinaries(llvm::Module &M,
26 llvm::ArrayRef<llvm::ArrayRef<char>> Images,
27 EntryArrayTy EntryArray,
28 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.
38llvm::Error wrapCudaBinary(llvm::Module &M, llvm::ArrayRef<char> Images,
39 EntryArrayTy EntryArray, llvm::StringRef Suffix = "",
40 bool EmitSurfacesAndTextures = true);
41
42/// Wraps the input bundled image into the module \p M as global symbols and
43/// registers the images with the HIP runtime.
44/// \param EntryArray Optional pair pointing to the `__start` and `__stop`
45/// symbols holding the `__tgt_offload_entry` array.
46/// \param Suffix An optional suffix appended to the emitted symbols.
47/// \param EmitSurfacesAndTextures Whether to emit surface and textures
48/// registration code. It defaults to false.
49llvm::Error wrapHIPBinary(llvm::Module &M, llvm::ArrayRef<char> Images,
50 EntryArrayTy EntryArray, llvm::StringRef Suffix = "",
51 bool EmitSurfacesAndTextures = true);
52} // namespace offloading
53} // namespace llvm
54
55#endif // LLVM_FRONTEND_OFFLOADING_OFFLOADWRAPPER_H
56

source code of llvm/include/llvm/Frontend/Offloading/OffloadWrapper.h