Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:22

0001 //===- OffloadYAML.h - Offload Binary YAMLIO implementation -----*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 ///
0009 /// \file
0010 /// This file declares classes for handling the YAML representation of
0011 /// offloading binaries.
0012 ///
0013 //===----------------------------------------------------------------------===//
0014 
0015 #ifndef LLVM_OBJECTYAML_OFFLOADYAML_H
0016 #define LLVM_OBJECTYAML_OFFLOADYAML_H
0017 
0018 #include "llvm/Object/OffloadBinary.h"
0019 #include "llvm/ObjectYAML/YAML.h"
0020 #include "llvm/Support/YAMLTraits.h"
0021 #include <optional>
0022 
0023 namespace llvm {
0024 namespace OffloadYAML {
0025 
0026 struct Binary {
0027   struct StringEntry {
0028     StringRef Key;
0029     StringRef Value;
0030   };
0031 
0032   struct Member {
0033     std::optional<object::ImageKind> ImageKind;
0034     std::optional<object::OffloadKind> OffloadKind;
0035     std::optional<uint32_t> Flags;
0036     std::optional<std::vector<StringEntry>> StringEntries;
0037     std::optional<yaml::BinaryRef> Content;
0038   };
0039 
0040   std::optional<uint32_t> Version;
0041   std::optional<uint64_t> Size;
0042   std::optional<uint64_t> EntryOffset;
0043   std::optional<uint64_t> EntrySize;
0044   std::vector<Member> Members;
0045 };
0046 
0047 } // end namespace OffloadYAML
0048 } // end namespace llvm
0049 
0050 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::OffloadYAML::Binary::Member)
0051 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::OffloadYAML::Binary::StringEntry)
0052 
0053 namespace llvm {
0054 namespace yaml {
0055 
0056 template <> struct ScalarEnumerationTraits<object::ImageKind> {
0057   static void enumeration(IO &IO, object::ImageKind &Value);
0058 };
0059 
0060 template <> struct ScalarEnumerationTraits<object::OffloadKind> {
0061   static void enumeration(IO &IO, object::OffloadKind &Value);
0062 };
0063 
0064 template <> struct MappingTraits<OffloadYAML::Binary> {
0065   static void mapping(IO &IO, OffloadYAML::Binary &O);
0066 };
0067 
0068 template <> struct MappingTraits<OffloadYAML::Binary::StringEntry> {
0069   static void mapping(IO &IO, OffloadYAML::Binary::StringEntry &M);
0070 };
0071 
0072 template <> struct MappingTraits<OffloadYAML::Binary::Member> {
0073   static void mapping(IO &IO, OffloadYAML::Binary::Member &M);
0074 };
0075 
0076 } // end namespace yaml
0077 } // end namespace llvm
0078 
0079 #endif // LLVM_OBJECTYAML_OFFLOADYAML_H