clang 18.0.0git
OffloadBundler.h
Go to the documentation of this file.
1//===- OffloadBundler.h - File Bundling and Unbundling ----------*- 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/// \file
10/// This file defines an offload bundling API that bundles different files
11/// that relate with the same source code but different targets into a single
12/// one. Also the implements the opposite functionality, i.e. unbundle files
13/// previous created by this API.
14///
15//===----------------------------------------------------------------------===//
16
17#ifndef LLVM_CLANG_DRIVER_OFFLOADBUNDLER_H
18#define LLVM_CLANG_DRIVER_OFFLOADBUNDLER_H
19
20#include "llvm/Support/Error.h"
21#include "llvm/TargetParser/Triple.h"
22#include <string>
23#include <vector>
24
25namespace clang {
26
28public:
29 bool AllowNoHost = false;
30 bool AllowMissingBundles = false;
31 bool CheckInputArchive = false;
33 bool HipOpenmpCompatible = false;
34
35 unsigned BundleAlignment = 1;
36 unsigned HostInputIndex = ~0u;
37
38 std::string FilesType;
39 std::string ObjcopyPath;
40
41 // TODO: Convert these to llvm::SmallVector
42 std::vector<std::string> TargetNames;
43 std::vector<std::string> InputFileNames;
44 std::vector<std::string> OutputFileNames;
45};
46
48public:
50
51 // TODO: Add error checking from ClangOffloadBundler.cpp
53
54 // List bundle IDs. Return true if an error was found.
55 static llvm::Error
56 ListBundleIDsInFile(llvm::StringRef InputFileName,
58
59 llvm::Error BundleFiles();
60 llvm::Error UnbundleFiles();
61 llvm::Error UnbundleArchive();
62};
63
64/// Obtain the offload kind, real machine triple, and an optional GPUArch
65/// out of the target information specified by the user.
66/// Bundle Entry ID (or, Offload Target String) has following components:
67/// * Offload Kind - Host, OpenMP, or HIP
68/// * Triple - Standard LLVM Triple
69/// * TargetID (Optional) - target ID, like gfx906:xnack+ or sm_30
71 llvm::StringRef OffloadKind;
72 llvm::Triple Triple;
73 llvm::StringRef TargetID;
74
76
77 OffloadTargetInfo(const llvm::StringRef Target,
78 const OffloadBundlerConfig &BC);
79 bool hasHostKind() const;
80 bool isOffloadKindValid() const;
81 bool isOffloadKindCompatible(const llvm::StringRef TargetOffloadKind) const;
82 bool isTripleValid() const;
83 bool operator==(const OffloadTargetInfo &Target) const;
84 std::string str() const;
85};
86
87} // namespace clang
88
89#endif // LLVM_CLANG_DRIVER_OFFLOADBUNDLER_H
std::vector< std::string > OutputFileNames
std::vector< std::string > TargetNames
std::vector< std::string > InputFileNames
llvm::Error BundleFiles()
Bundle the files. Return true if an error was found.
OffloadBundler(const OffloadBundlerConfig &BC)
llvm::Error UnbundleFiles()
llvm::Error UnbundleArchive()
UnbundleArchive takes an archive file (".a") as input containing bundled code object files,...
static llvm::Error ListBundleIDsInFile(llvm::StringRef InputFileName, const OffloadBundlerConfig &BundlerConfig)
const OffloadBundlerConfig & BundlerConfig
Obtain the offload kind, real machine triple, and an optional GPUArch out of the target information s...
bool operator==(const OffloadTargetInfo &Target) const
bool isOffloadKindCompatible(const llvm::StringRef TargetOffloadKind) const
llvm::StringRef OffloadKind
std::string str() const
llvm::StringRef TargetID
const OffloadBundlerConfig & BundlerConfig