1 //===- OffloadYAML.cpp - Offload Binary YAMLIO implementation -------------===//
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
7 //===----------------------------------------------------------------------===//
9 // This file defines classes for handling the YAML representation of offload
12 //===----------------------------------------------------------------------===//
14 #include <llvm/ObjectYAML/OffloadYAML.h>
20 void ScalarEnumerationTraits
<object::ImageKind
>::enumeration(
21 IO
&IO
, object::ImageKind
&Value
) {
22 #define ECase(X) IO.enumCase(Value, #X, object::X)
31 IO
.enumFallback
<Hex16
>(Value
);
34 void ScalarEnumerationTraits
<object::OffloadKind
>::enumeration(
35 IO
&IO
, object::OffloadKind
&Value
) {
36 #define ECase(X) IO.enumCase(Value, #X, object::X)
43 IO
.enumFallback
<Hex16
>(Value
);
46 void MappingTraits
<OffloadYAML::Binary
>::mapping(IO
&IO
,
47 OffloadYAML::Binary
&O
) {
48 assert(!IO
.getContext() && "The IO context is initialized already");
50 IO
.mapTag("!Offload", true);
51 IO
.mapOptional("Version", O
.Version
);
52 IO
.mapOptional("Size", O
.Size
);
53 IO
.mapOptional("EntryOffset", O
.EntryOffset
);
54 IO
.mapOptional("EntrySize", O
.EntrySize
);
55 IO
.mapRequired("Members", O
.Members
);
56 IO
.setContext(nullptr);
59 void MappingTraits
<OffloadYAML::Binary::StringEntry
>::mapping(
60 IO
&IO
, OffloadYAML::Binary::StringEntry
&SE
) {
61 assert(IO
.getContext() && "The IO context is not initialized");
62 IO
.mapRequired("Key", SE
.Key
);
63 IO
.mapRequired("Value", SE
.Value
);
66 void MappingTraits
<OffloadYAML::Binary::Member
>::mapping(
67 IO
&IO
, OffloadYAML::Binary::Member
&M
) {
68 assert(IO
.getContext() && "The IO context is not initialized");
69 IO
.mapOptional("ImageKind", M
.ImageKind
);
70 IO
.mapOptional("OffloadKind", M
.OffloadKind
);
71 IO
.mapOptional("Flags", M
.Flags
);
72 IO
.mapOptional("String", M
.StringEntries
);
73 IO
.mapOptional("Content", M
.Content
);