Summary: This patch reorganizes a lot of the code used to check for compatibility with the current environment. The main bulk of this patch involves moving from using a separate `__tgt_image_info` struct (which just contains a string for the architecture) to instead simply checking this information from the ELF directly. Checking information in the ELF is very inexpensive as creating an ELF file is simply writing a base pointer. The main desire to do this was to reorganize everything into the ELF image. We can then do the majority of these checks without first initializing the plugin. A future patch will move the first ELF checks to happen without initializing the plugin so we no longer need to initialize and plugins that don't have needed images. This patch also adds a lot more sanity checks for whether or not the ELF is actually compatible. Such as if the images have a valid ABI, 64-bit width, executable, etc.
44 lines
1.3 KiB
C++
44 lines
1.3 KiB
C++
//===-- DeviceImage.h - Representation of the device code/image -*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef OMPTARGET_DEVICE_IMAGE_H
|
|
#define OMPTARGET_DEVICE_IMAGE_H
|
|
|
|
#include "OffloadEntry.h"
|
|
#include "Shared/APITypes.h"
|
|
|
|
#include "llvm/ADT/SmallVector.h"
|
|
#include "llvm/ADT/StringRef.h"
|
|
#include "llvm/ADT/iterator.h"
|
|
#include "llvm/ADT/iterator_range.h"
|
|
#include "llvm/Object/OffloadBinary.h"
|
|
|
|
#include <memory>
|
|
|
|
class DeviceImageTy {
|
|
|
|
std::unique_ptr<llvm::object::OffloadBinary> Binary;
|
|
llvm::SmallVector<std::unique_ptr<OffloadEntryTy>> OffloadEntries;
|
|
|
|
__tgt_bin_desc *BinaryDesc;
|
|
__tgt_device_image Image;
|
|
|
|
public:
|
|
DeviceImageTy(__tgt_bin_desc &BinaryDesc, __tgt_device_image &Image);
|
|
|
|
__tgt_device_image &getExecutableImage() { return Image; }
|
|
__tgt_bin_desc &getBinaryDesc() { return *BinaryDesc; }
|
|
|
|
auto entries() { return llvm::make_pointee_range(OffloadEntries); }
|
|
};
|
|
|
|
#endif // OMPTARGET_DEVICE_IMAGE_H
|