OffloadYAML.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- OffloadYAML.h - Offload Binary YAMLIO implementation -----*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. ///
  14. /// \file
  15. /// This file declares classes for handling the YAML representation of
  16. /// offloading binaries.
  17. ///
  18. //===----------------------------------------------------------------------===//
  19. #ifndef LLVM_OBJECTYAML_OFFLOADYAML_H
  20. #define LLVM_OBJECTYAML_OFFLOADYAML_H
  21. #include "llvm/ADT/MapVector.h"
  22. #include "llvm/Object/OffloadBinary.h"
  23. #include "llvm/ObjectYAML/YAML.h"
  24. #include "llvm/Support/YAMLTraits.h"
  25. #include <optional>
  26. namespace llvm {
  27. namespace OffloadYAML {
  28. struct Binary {
  29. struct StringEntry {
  30. StringRef Key;
  31. StringRef Value;
  32. };
  33. struct Member {
  34. std::optional<object::ImageKind> ImageKind;
  35. std::optional<object::OffloadKind> OffloadKind;
  36. std::optional<uint32_t> Flags;
  37. std::optional<std::vector<StringEntry>> StringEntries;
  38. std::optional<yaml::BinaryRef> Content;
  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. } // end namespace OffloadYAML
  47. } // end namespace llvm
  48. LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::OffloadYAML::Binary::Member)
  49. LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::OffloadYAML::Binary::StringEntry)
  50. namespace llvm {
  51. namespace yaml {
  52. template <> struct ScalarEnumerationTraits<object::ImageKind> {
  53. static void enumeration(IO &IO, object::ImageKind &Value);
  54. };
  55. template <> struct ScalarEnumerationTraits<object::OffloadKind> {
  56. static void enumeration(IO &IO, object::OffloadKind &Value);
  57. };
  58. template <> struct MappingTraits<OffloadYAML::Binary> {
  59. static void mapping(IO &IO, OffloadYAML::Binary &O);
  60. };
  61. template <> struct MappingTraits<OffloadYAML::Binary::StringEntry> {
  62. static void mapping(IO &IO, OffloadYAML::Binary::StringEntry &M);
  63. };
  64. template <> struct MappingTraits<OffloadYAML::Binary::Member> {
  65. static void mapping(IO &IO, OffloadYAML::Binary::Member &M);
  66. };
  67. } // end namespace yaml
  68. } // end namespace llvm
  69. #endif // LLVM_OBJECTYAML_OFFLOADYAML_H
  70. #ifdef __GNUC__
  71. #pragma GCC diagnostic pop
  72. #endif