[ORC] Merge LLVMSPSSerializers.h into SimplePackedSerialization.h.

Since the ORC runtime and LLVM are no longer sharing SPS code (the ORC runtime
has its own copy) there is no reason to keep these separate.
This commit is contained in:
Lang Hames 2021-09-06 10:02:56 +10:00
parent 22641f5853
commit a0a91ed3dd
5 changed files with 44 additions and 72 deletions

View File

@ -16,7 +16,6 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/ExecutionEngine/Orc/Core.h"
#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
#include "llvm/ExecutionEngine/Orc/LLVMSPSSerializers.h"
#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
#include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"

View File

@ -1,69 +0,0 @@
//===-- LLVMSPSSerializers.h - SPS serialization for LLVM types -*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// SPS Serialization for common LLVM types.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_EXECUTIONENGINE_ORC_LLVMSPSSERIALIZERS_H
#define LLVM_EXECUTIONENGINE_ORC_LLVMSPSSERIALIZERS_H
#include "llvm/ADT/StringMap.h"
#include "llvm/ExecutionEngine/Orc/Shared/SimplePackedSerialization.h"
namespace llvm {
namespace orc {
namespace shared {
template <typename SPSValueT, typename ValueT>
class SPSSerializationTraits<SPSSequence<SPSTuple<SPSString, SPSValueT>>,
StringMap<ValueT>> {
public:
static size_t size(const StringMap<ValueT> &M) {
size_t Sz = SPSArgList<uint64_t>::size(static_cast<uint64_t>(M.size()));
for (auto &E : M)
Sz += SPSArgList<SPSString, SPSValueT>::size(E.first(), E.second);
return Sz;
}
static bool serialize(SPSOutputBuffer &OB, const StringMap<ValueT> &M) {
if (!SPSArgList<uint64_t>::serialize(OB, static_cast<uint64_t>(M.size())))
return false;
for (auto &E : M)
if (!SPSArgList<SPSString, SPSValueT>::serialize(OB, E.first(), E.second))
return false;
return true;
}
static bool deserialize(SPSInputBuffer &IB, StringMap<ValueT> &M) {
uint64_t Size;
assert(M.empty() && "M already contains elements");
if (!SPSArgList<uint64_t>::deserialize(IB, Size))
return false;
while (Size--) {
StringRef S;
ValueT V;
if (!SPSArgList<SPSString, SPSValueT>::deserialize(IB, S, V))
return false;
if (!M.insert(std::make_pair(S, V)).second)
return false;
}
return true;
}
};
} // end namespace shared
} // end namespace orc
} // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_LLVMSPSSERIALIZERS_H

View File

@ -16,7 +16,6 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/ExecutionEngine/Orc/Core.h"
#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
#include "llvm/ExecutionEngine/Orc/LLVMSPSSerializers.h"
#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
#include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"

View File

@ -33,6 +33,7 @@
#define LLVM_EXECUTIONENGINE_ORC_SHARED_SIMPLEPACKEDSERIALIZATION_H
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/SwapByteOrder.h"
@ -453,6 +454,49 @@ public:
}
};
/// Serialization for StringMap<ValueT>s.
template <typename SPSValueT, typename ValueT>
class SPSSerializationTraits<SPSSequence<SPSTuple<SPSString, SPSValueT>>,
StringMap<ValueT>> {
public:
static size_t size(const StringMap<ValueT> &M) {
size_t Sz = SPSArgList<uint64_t>::size(static_cast<uint64_t>(M.size()));
for (auto &E : M)
Sz += SPSArgList<SPSString, SPSValueT>::size(E.first(), E.second);
return Sz;
}
static bool serialize(SPSOutputBuffer &OB, const StringMap<ValueT> &M) {
if (!SPSArgList<uint64_t>::serialize(OB, static_cast<uint64_t>(M.size())))
return false;
for (auto &E : M)
if (!SPSArgList<SPSString, SPSValueT>::serialize(OB, E.first(), E.second))
return false;
return true;
}
static bool deserialize(SPSInputBuffer &IB, StringMap<ValueT> &M) {
uint64_t Size;
assert(M.empty() && "M already contains elements");
if (!SPSArgList<uint64_t>::deserialize(IB, Size))
return false;
while (Size--) {
StringRef S;
ValueT V;
if (!SPSArgList<SPSString, SPSValueT>::deserialize(IB, S, V))
return false;
if (!M.insert(std::make_pair(S, V)).second)
return false;
}
return true;
}
};
/// SPS tag type for errors.
class SPSError;

View File

@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
#include "llvm/ExecutionEngine/Orc/Shared/SimplePackedSerialization.h"
#include "llvm/ExecutionEngine/Orc/LLVMSPSSerializers.h"
#include "gtest/gtest.h"
using namespace llvm;