xref: /llvm-project/offload/include/DeviceImage.h (revision 330d8983d25d08580fc1642fea48b2473f47a9da)
1 //===-- DeviceImage.h - Representation of the device code/image -*- 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 //
10 //===----------------------------------------------------------------------===//
11 
12 #ifndef OMPTARGET_DEVICE_IMAGE_H
13 #define OMPTARGET_DEVICE_IMAGE_H
14 
15 #include "OffloadEntry.h"
16 #include "Shared/APITypes.h"
17 
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/ADT/StringRef.h"
20 #include "llvm/ADT/iterator.h"
21 #include "llvm/ADT/iterator_range.h"
22 #include "llvm/Object/OffloadBinary.h"
23 
24 #include <memory>
25 
26 class DeviceImageTy {
27 
28   std::unique_ptr<llvm::object::OffloadBinary> Binary;
29 
30   __tgt_bin_desc *BinaryDesc;
31   __tgt_device_image Image;
32 
33 public:
34   DeviceImageTy(__tgt_bin_desc &BinaryDesc, __tgt_device_image &Image);
35 
getExecutableImage()36   __tgt_device_image &getExecutableImage() { return Image; }
getBinaryDesc()37   __tgt_bin_desc &getBinaryDesc() { return *BinaryDesc; }
38 
entries()39   auto entries() {
40     return llvm::make_range(Image.EntriesBegin, Image.EntriesEnd);
41   }
42 };
43 
44 #endif // OMPTARGET_DEVICE_IMAGE_H
45