LLVM 23.0.0git
OffloadYAML.cpp
Go to the documentation of this file.
1//===- OffloadYAML.cpp - Offload Binary YAMLIO implementation -------------===//
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// This file defines classes for handling the YAML representation of offload
10// binaries.
11//
12//===----------------------------------------------------------------------===//
13
15
16namespace llvm {
17
18namespace yaml {
19
22#define ECase(X) IO.enumCase(Value, #X, object::X)
23 ECase(IMG_None);
24 ECase(IMG_Object);
25 ECase(IMG_Bitcode);
26 ECase(IMG_Cubin);
27 ECase(IMG_Fatbinary);
28 ECase(IMG_PTX);
29 ECase(IMG_LAST);
30#undef ECase
31 IO.enumFallback<Hex16>(Value);
32}
33
36#define ECase(X) IO.enumCase(Value, #X, object::X)
37 ECase(OFK_None);
38 ECase(OFK_OpenMP);
39 ECase(OFK_Cuda);
40 ECase(OFK_HIP);
41 ECase(OFK_SYCL);
42 ECase(OFK_LAST);
43#undef ECase
44 IO.enumFallback<Hex16>(Value);
45}
46
49 assert(!IO.getContext() && "The IO context is initialized already");
50 IO.setContext(&O);
51 IO.mapTag("!Offload", true);
52 IO.mapOptional("Version", O.Version);
53 IO.mapOptional("Size", O.Size);
54 IO.mapOptional("EntriesOffset", O.EntriesOffset);
55 IO.mapOptional("EntriesCount", O.EntriesCount);
56 IO.mapRequired("Members", O.Members);
57 IO.setContext(nullptr);
58}
59
62 assert(IO.getContext() && "The IO context is not initialized");
63 IO.mapRequired("Key", SE.Key);
64 IO.mapRequired("Value", SE.Value);
65}
66
69 assert(IO.getContext() && "The IO context is not initialized");
70 IO.mapOptional("ImageKind", M.ImageKind);
71 IO.mapOptional("OffloadKind", M.OffloadKind);
72 IO.mapOptional("Flags", M.Flags);
73 IO.mapOptional("String", M.StringEntries);
74 IO.mapOptional("Content", M.Content);
75}
76
77} // namespace yaml
78
79} // namespace llvm
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file declares classes for handling the YAML representation of offloading binaries.
#define ECase(X)
LLVM Value Representation.
Definition Value.h:75
void setContext(void *)
virtual bool mapTag(StringRef Tag, bool Default=false)=0
void mapOptional(StringRef Key, T &Val)
Definition YAMLTraits.h:799
void * getContext() const
void enumFallback(T &Val)
Definition YAMLTraits.h:748
void mapRequired(StringRef Key, T &Val)
Definition YAMLTraits.h:789
OffloadKind
The producer of the associated offloading image.
ImageKind
The type of contents the offloading image contains.
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
This class should be specialized by any type that needs to be converted to/from a YAML mapping.
Definition YAMLTraits.h:62
This class should be specialized by any integral type that converts to/from a YAML scalar where there...
Definition YAMLTraits.h:107