1//===- OffloadYAML.h - Offload Binary YAMLIO implementation -----*- 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 declares classes for handling the YAML representation of
11/// offloading binaries.
12///
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_OBJECTYAML_OFFLOADYAML_H
16#define LLVM_OBJECTYAML_OFFLOADYAML_H
17
18#include "llvm/Object/OffloadBinary.h"
19#include "llvm/ObjectYAML/YAML.h"
20#include "llvm/Support/YAMLTraits.h"
21#include <optional>
22
23namespace llvm {
24namespace OffloadYAML {
25
26struct Binary {
27 struct StringEntry {
28 StringRef Key;
29 StringRef Value;
30 };
31
32 struct Member {
33 std::optional<object::ImageKind> ImageKind;
34 std::optional<object::OffloadKind> OffloadKind;
35 std::optional<uint32_t> Flags;
36 std::optional<std::vector<StringEntry>> StringEntries;
37 std::optional<yaml::BinaryRef> Content;
38 };
39
40 std::optional<uint32_t> Version;
41 std::optional<uint64_t> Size;
42 std::optional<uint64_t> EntryOffset;
43 std::optional<uint64_t> EntrySize;
44 std::vector<Member> Members;
45};
46
47} // end namespace OffloadYAML
48} // end namespace llvm
49
50LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::OffloadYAML::Binary::Member)
51LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::OffloadYAML::Binary::StringEntry)
52
53namespace llvm {
54namespace yaml {
55
56template <> struct ScalarEnumerationTraits<object::ImageKind> {
57 static void enumeration(IO &IO, object::ImageKind &Value);
58};
59
60template <> struct ScalarEnumerationTraits<object::OffloadKind> {
61 static void enumeration(IO &IO, object::OffloadKind &Value);
62};
63
64template <> struct MappingTraits<OffloadYAML::Binary> {
65 static void mapping(IO &IO, OffloadYAML::Binary &O);
66};
67
68template <> struct MappingTraits<OffloadYAML::Binary::StringEntry> {
69 static void mapping(IO &IO, OffloadYAML::Binary::StringEntry &M);
70};
71
72template <> struct MappingTraits<OffloadYAML::Binary::Member> {
73 static void mapping(IO &IO, OffloadYAML::Binary::Member &M);
74};
75
76} // end namespace yaml
77} // end namespace llvm
78
79#endif // LLVM_OBJECTYAML_OFFLOADYAML_H
80

source code of llvm/include/llvm/ObjectYAML/OffloadYAML.h