mirror of
https://github.com/clang-retro/llvm.git
synced 2026-11-28 13:19:18 -08:00
Create a src and include directory for libomptarget and libompaccsupport following the same structure as liboffload. Move headers from the base include directory to the directories that use them. Just a few utility headers remain in the share base include/Shared directory. Of those, Environment.h and RPCOpcodes.h seem questionable but seem in used in both the plugins and libomptarget (which seems to point to further refactoring needed). Changes in source files are basically due to directory changes, leftover headers, and in a few cases, changing headers that were only used transitively for their own dependence. Headers in libompaccsupport seem like they could be further refined as they contain both shared and things only neeeded by libomptarget, but that's a larger refactoring to be done later. Mechanical work done by Claude.
68 lines
2.6 KiB
C++
68 lines
2.6 KiB
C++
//===------------ Program.h - liboffload program abstraction ------------===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Declares ProgramTy, which wraps a liboffload program handle (a device
|
|
// image loaded via olCreateProgram) along with the routines used to resolve
|
|
// its global-variable and kernel symbols.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef _OMPTARGET_PROGRAM_H
|
|
#define _OMPTARGET_PROGRAM_H
|
|
|
|
#include "APITypes.h"
|
|
#include "OffloadAPI.h"
|
|
#include "llvm/Support/Error.h"
|
|
#include "llvm/Support/MemoryBufferRef.h"
|
|
|
|
class ProgramTy {
|
|
public:
|
|
ProgramTy() = default;
|
|
|
|
/// Load \p Img onto \p Device within \p Context via liboffload.
|
|
static llvm::Expected<ProgramTy> create(ol_context_handle_t Context,
|
|
ol_device_handle_t Device,
|
|
__tgt_device_image *Img);
|
|
|
|
/// Resolve the device address of the global variable \p Name. If \p Size
|
|
/// is non-null, it is set to the size in bytes of the global.
|
|
llvm::Expected<void *> getGlobalAddress(const char *Name,
|
|
size_t *Size = nullptr) const;
|
|
|
|
/// Copy the \p Size bytes of the global variable \p Name from the host-side
|
|
/// program image into \p Dst. Fails if the global's size is not \p Size.
|
|
llvm::Error readGlobalFromImage(const char *Name, void *Dst,
|
|
size_t Size) const;
|
|
|
|
/// Return the symbol handle for the kernel \p Name.
|
|
llvm::Expected<ol_symbol_handle_t> getKernelAddress(const char *Name) const;
|
|
|
|
ol_program_handle_t getHandle() const { return Handle; }
|
|
|
|
/// The image loaded for this program.
|
|
llvm::Expected<llvm::MemoryBufferRef> getImage() const;
|
|
|
|
/// The IR image this program was created from, or an empty buffer if the
|
|
/// input was not IR.
|
|
llvm::MemoryBufferRef getIRImage() const { return IRImage; }
|
|
|
|
/// Device buffer holding the indirect call table of this program, or null.
|
|
void *getIndirectCallTable() const { return IndirectCallTable; }
|
|
void setIndirectCallTable(void *Table) { IndirectCallTable = Table; }
|
|
|
|
private:
|
|
ProgramTy(ol_program_handle_t Handle, llvm::MemoryBufferRef IRImage)
|
|
: Handle(Handle), IRImage(IRImage) {}
|
|
|
|
ol_program_handle_t Handle = nullptr;
|
|
llvm::MemoryBufferRef IRImage;
|
|
void *IndirectCallTable = nullptr;
|
|
};
|
|
|
|
#endif
|