|
| 1 | +//===-- SPSMemoryFlags.h - SPS-serialization for MemoryFlags.h --*- 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 | +// SPSSerialization for relevant types in MemoryFlags.h. |
| 10 | +// |
| 11 | +//===----------------------------------------------------------------------===// |
| 12 | + |
| 13 | +#ifndef ORC_RT_SPSMEMORYFLAGS_H |
| 14 | +#define ORC_RT_SPSMEMORYFLAGS_H |
| 15 | + |
| 16 | +#include "orc-rt/MemoryFlags.h" |
| 17 | +#include "orc-rt/SimplePackedSerialization.h" |
| 18 | + |
| 19 | +namespace orc_rt { |
| 20 | + |
| 21 | +struct SPSAllocGroup; |
| 22 | + |
| 23 | +template <> class SPSSerializationTraits<SPSAllocGroup, AllocGroup> { |
| 24 | +private: |
| 25 | + typedef detail::AllocGroupInternals::underlying_type UT; |
| 26 | + |
| 27 | +public: |
| 28 | + static size_t size(const AllocGroup &AG) { |
| 29 | + return SPSSerializationTraits<UT, UT>::size( |
| 30 | + detail::AllocGroupInternals::getId(AG)); |
| 31 | + } |
| 32 | + |
| 33 | + static bool serialize(SPSOutputBuffer &OB, const AllocGroup &AG) { |
| 34 | + return SPSSerializationTraits<UT, UT>::serialize( |
| 35 | + OB, detail::AllocGroupInternals::getId(AG)); |
| 36 | + } |
| 37 | + |
| 38 | + static bool deserialize(SPSInputBuffer &IB, AllocGroup &AG) { |
| 39 | + UT Id = 0; |
| 40 | + if (!SPSSerializationTraits<UT, UT>::deserialize(IB, Id)) |
| 41 | + return false; |
| 42 | + AG = detail::AllocGroupInternals::fromId(Id); |
| 43 | + return true; |
| 44 | + } |
| 45 | +}; |
| 46 | + |
| 47 | +} // namespace orc_rt |
| 48 | + |
| 49 | +#endif // ORC_RT_SPSMEMORYFLAGS_H |
0 commit comments