|
clang 22.0.0git
|
This file implements an offload bundling API that bundles different files that relate with the same source code but different targets into a single one. More...
#include "clang/Driver/OffloadBundler.h"#include "clang/Basic/Cuda.h"#include "clang/Basic/TargetID.h"#include "llvm/ADT/ArrayRef.h"#include "llvm/ADT/SmallString.h"#include "llvm/ADT/SmallVector.h"#include "llvm/ADT/StringExtras.h"#include "llvm/ADT/StringMap.h"#include "llvm/ADT/StringRef.h"#include "llvm/BinaryFormat/Magic.h"#include "llvm/Object/Archive.h"#include "llvm/Object/ArchiveWriter.h"#include "llvm/Object/Binary.h"#include "llvm/Object/ObjectFile.h"#include "llvm/Support/Casting.h"#include "llvm/Support/Compiler.h"#include "llvm/Support/Compression.h"#include "llvm/Support/Debug.h"#include "llvm/Support/EndianStream.h"#include "llvm/Support/Errc.h"#include "llvm/Support/Error.h"#include "llvm/Support/ErrorOr.h"#include "llvm/Support/FileSystem.h"#include "llvm/Support/MD5.h"#include "llvm/Support/ManagedStatic.h"#include "llvm/Support/MemoryBuffer.h"#include "llvm/Support/Path.h"#include "llvm/Support/Program.h"#include "llvm/Support/Signals.h"#include "llvm/Support/StringSaver.h"#include "llvm/Support/Timer.h"#include "llvm/Support/WithColor.h"#include "llvm/Support/raw_ostream.h"#include "llvm/TargetParser/Host.h"#include "llvm/TargetParser/Triple.h"#include <algorithm>#include <cassert>#include <cstddef>#include <cstdint>#include <forward_list>#include <llvm/Support/Process.h>#include <memory>#include <set>#include <string>#include <system_error>#include <utility>Go to the source code of this file.
Classes | |
| union | RawCompressedBundleHeader |
| struct | RawCompressedBundleHeader::CommonFields |
| struct | RawCompressedBundleHeader::V1Header |
| struct | RawCompressedBundleHeader::V2Header |
| struct | RawCompressedBundleHeader::V3Header |
Macros | |
| #define | OFFLOAD_BUNDLER_MAGIC_STR "__CLANG_OFFLOAD_BUNDLE__" |
| Magic string that marks the existence of offloading data. | |
Functions | |
| static StringRef | getDeviceFileExtension (StringRef Device, StringRef BundleFileName) |
| static std::string | getDeviceLibraryFileName (StringRef BundleFileName, StringRef Device) |
| static std::unique_ptr< FileHandler > | CreateObjectFileHandler (MemoryBuffer &FirstInput, const OffloadBundlerConfig &BundlerConfig) |
| Return an appropriate object file handler. | |
| static Expected< std::unique_ptr< FileHandler > > | CreateFileHandler (MemoryBuffer &FirstInput, const OffloadBundlerConfig &BundlerConfig) |
| Return an appropriate handler given the input files and options. | |
| static std::string | formatWithCommas (unsigned long long Value) |
| static LLVM_PACKED_END size_t | getHeaderSize (uint16_t Version) |
| bool | isCodeObjectCompatible (const OffloadTargetInfo &CodeObjectInfo, const OffloadTargetInfo &TargetInfo) |
Checks if a code object CodeObjectInfo is compatible with a given target TargetInfo. | |
| static Archive::Kind | getDefaultArchiveKindForHost () |
| static bool | getCompatibleOffloadTargets (OffloadTargetInfo &CodeObjectInfo, SmallVectorImpl< StringRef > &CompatibleTargets, const OffloadBundlerConfig &BundlerConfig) |
| Computes a list of targets among all given targets which are compatible with this code object. | |
| static Error | CheckHeterogeneousArchive (StringRef ArchiveName, const OffloadBundlerConfig &BundlerConfig) |
Variables | |
| static llvm::ManagedStatic< llvm::TimerGroup, CreateClangOffloadBundlerTimerGroup > | ClangOffloadBundlerTimerGroup |
This file implements an offload bundling API that bundles different files that relate with the same source code but different targets into a single one.
Also the implements the opposite functionality, i.e. unbundle files previous created by this API.
Definition in file OffloadBundler.cpp.
| #define OFFLOAD_BUNDLER_MAGIC_STR "__CLANG_OFFLOAD_BUNDLE__" |
Magic string that marks the existence of offloading data.
Definition at line 81 of file OffloadBundler.cpp.
|
static |
Iterate over all bundled code object files in the input archive.
Definition at line 1713 of file OffloadBundler.cpp.
References CreateFileHandler(), clang::Error, and clang::getConflictTargetIDCombination().
Referenced by clang::OffloadBundler::UnbundleArchive().
|
static |
Return an appropriate handler given the input files and options.
Definition at line 909 of file OffloadBundler.cpp.
References CreateObjectFileHandler(), and clang::OffloadBundlerConfig::FilesType.
Referenced by clang::OffloadBundler::BundleFiles(), CheckHeterogeneousArchive(), clang::OffloadBundler::ListBundleIDsInFile(), clang::OffloadBundler::UnbundleArchive(), and clang::OffloadBundler::UnbundleFiles().
|
static |
Return an appropriate object file handler.
We use the specific object handler if we know how to deal with that format, otherwise we use a default binary file handler.
Definition at line 890 of file OffloadBundler.cpp.
References clang::cast(), and clang::isa().
Referenced by CreateFileHandler().
|
static |
Definition at line 1003 of file OffloadBundler.cpp.
References clang::Num.
Referenced by clang::CompressedOffloadBundle::compress(), and clang::CompressedOffloadBundle::decompress().
|
static |
Computes a list of targets among all given targets which are compatible with this code object.
| [in] | CodeObjectInfo | Code Object |
| [out] | CompatibleTargets | List of all compatible targets among all given targets |
Definition at line 1692 of file OffloadBundler.cpp.
References isCodeObjectCompatible(), and clang::OffloadBundlerConfig::TargetNames.
Referenced by clang::OffloadBundler::UnbundleArchive().
|
static |
Definition at line 1680 of file OffloadBundler.cpp.
Referenced by clang::OffloadBundler::UnbundleArchive().
|
static |
Definition at line 161 of file OffloadBundler.cpp.
References clang::Device.
Referenced by getDeviceLibraryFileName().
|
static |
Definition at line 170 of file OffloadBundler.cpp.
References clang::Device, and getDeviceFileExtension().
Referenced by clang::OffloadBundler::UnbundleArchive().
|
static |
Definition at line 1168 of file OffloadBundler.cpp.
Referenced by clang::CompressedOffloadBundle::decompress(), and clang::CompressedOffloadBundle::CompressedBundleHeader::tryParse().
| bool isCodeObjectCompatible | ( | const OffloadTargetInfo & | CodeObjectInfo, |
| const OffloadTargetInfo & | TargetInfo ) |
Checks if a code object CodeObjectInfo is compatible with a given target TargetInfo.
https://clang.llvm.org/docs/ClangOffloadBundler.html#bundle-entry-id
Definition at line 1365 of file OffloadBundler.cpp.
References clang::OffloadTargetInfo::isOffloadKindCompatible(), clang::parseTargetID(), clang::OffloadTargetInfo::str(), clang::OffloadTargetInfo::TargetID, and clang::OffloadTargetInfo::Triple.
Referenced by getCompatibleOffloadTargets(), and clang::OffloadBundler::UnbundleFiles().
|
static |
Definition at line 78 of file OffloadBundler.cpp.
Referenced by clang::CompressedOffloadBundle::compress(), and clang::CompressedOffloadBundle::decompress().