LLVM  14.0.0git
SimplePackedSerialization.h
Go to the documentation of this file.
1 //===---- SimplePackedSerialization.h - simple serialization ----*- 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 // The behavior of the utilities in this header must be synchronized with the
10 // behavior of the utilities in
11 // compiler-rt/lib/orc/simple_packed_serialization.h.
12 //
13 // The Simple Packed Serialization (SPS) utilities are used to generate
14 // argument and return buffers for wrapper functions using the following
15 // serialization scheme:
16 //
17 // Primitives (signed types should be two's complement):
18 // bool, char, int8_t, uint8_t -- 8-bit (0=false, 1=true)
19 // int16_t, uint16_t -- 16-bit little endian
20 // int32_t, uint32_t -- 32-bit little endian
21 // int64_t, int64_t -- 64-bit little endian
22 //
23 // Sequence<T>:
24 // Serialized as the sequence length (as a uint64_t) followed by the
25 // serialization of each of the elements without padding.
26 //
27 // Tuple<T1, ..., TN>:
28 // Serialized as each of the element types from T1 to TN without padding.
29 //
30 //===----------------------------------------------------------------------===//
31 
32 #ifndef LLVM_EXECUTIONENGINE_ORC_SHARED_SIMPLEPACKEDSERIALIZATION_H
33 #define LLVM_EXECUTIONENGINE_ORC_SHARED_SIMPLEPACKEDSERIALIZATION_H
34 
35 #include "llvm/ADT/STLExtras.h"
36 #include "llvm/ADT/StringMap.h"
37 #include "llvm/ADT/StringRef.h"
38 #include "llvm/Support/Error.h"
40 
41 #include <limits>
42 #include <string>
43 #include <tuple>
44 #include <type_traits>
45 #include <utility>
46 #include <vector>
47 
48 namespace llvm {
49 namespace orc {
50 namespace shared {
51 
52 /// Output char buffer with overflow check.
54 public:
55  SPSOutputBuffer(char *Buffer, size_t Remaining)
56  : Buffer(Buffer), Remaining(Remaining) {}
57  bool write(const char *Data, size_t Size) {
58  if (Size > Remaining)
59  return false;
60  memcpy(Buffer, Data, Size);
61  Buffer += Size;
62  Remaining -= Size;
63  return true;
64  }
65 
66 private:
67  char *Buffer = nullptr;
68  size_t Remaining = 0;
69 };
70 
71 /// Input char buffer with underflow check.
73 public:
74  SPSInputBuffer() = default;
75  SPSInputBuffer(const char *Buffer, size_t Remaining)
76  : Buffer(Buffer), Remaining(Remaining) {}
77  bool read(char *Data, size_t Size) {
78  if (Size > Remaining)
79  return false;
80  memcpy(Data, Buffer, Size);
81  Buffer += Size;
82  Remaining -= Size;
83  return true;
84  }
85 
86  const char *data() const { return Buffer; }
87  bool skip(size_t Size) {
88  if (Size > Remaining)
89  return false;
90  Buffer += Size;
91  Remaining -= Size;
92  return true;
93  }
94 
95 private:
96  const char *Buffer = nullptr;
97  size_t Remaining = 0;
98 };
99 
100 /// Specialize to describe how to serialize/deserialize to/from the given
101 /// concrete type.
102 template <typename SPSTagT, typename ConcreteT, typename _ = void>
104 
105 /// A utility class for serializing to a blob from a variadic list.
106 template <typename... ArgTs> class SPSArgList;
107 
108 // Empty list specialization for SPSArgList.
109 template <> class SPSArgList<> {
110 public:
111  static size_t size() { return 0; }
112 
113  static bool serialize(SPSOutputBuffer &OB) { return true; }
114  static bool deserialize(SPSInputBuffer &IB) { return true; }
115 };
116 
117 // Non-empty list specialization for SPSArgList.
118 template <typename SPSTagT, typename... SPSTagTs>
119 class SPSArgList<SPSTagT, SPSTagTs...> {
120 public:
121  template <typename ArgT, typename... ArgTs>
122  static size_t size(const ArgT &Arg, const ArgTs &...Args) {
125  }
126 
127  template <typename ArgT, typename... ArgTs>
128  static bool serialize(SPSOutputBuffer &OB, const ArgT &Arg,
129  const ArgTs &...Args) {
132  }
133 
134  template <typename ArgT, typename... ArgTs>
135  static bool deserialize(SPSInputBuffer &IB, ArgT &Arg, ArgTs &...Args) {
138  }
139 };
140 
141 /// SPS serialization for integral types, bool, and char.
142 template <typename SPSTagT>
144  SPSTagT, SPSTagT,
145  std::enable_if_t<std::is_same<SPSTagT, bool>::value ||
146  std::is_same<SPSTagT, char>::value ||
147  std::is_same<SPSTagT, int8_t>::value ||
148  std::is_same<SPSTagT, int16_t>::value ||
149  std::is_same<SPSTagT, int32_t>::value ||
150  std::is_same<SPSTagT, int64_t>::value ||
151  std::is_same<SPSTagT, uint8_t>::value ||
152  std::is_same<SPSTagT, uint16_t>::value ||
153  std::is_same<SPSTagT, uint32_t>::value ||
154  std::is_same<SPSTagT, uint64_t>::value>> {
155 public:
156  static size_t size(const SPSTagT &Value) { return sizeof(SPSTagT); }
157 
158  static bool serialize(SPSOutputBuffer &OB, const SPSTagT &Value) {
159  SPSTagT Tmp = Value;
161  sys::swapByteOrder(Tmp);
162  return OB.write(reinterpret_cast<const char *>(&Tmp), sizeof(Tmp));
163  }
164 
165  static bool deserialize(SPSInputBuffer &IB, SPSTagT &Value) {
166  SPSTagT Tmp;
167  if (!IB.read(reinterpret_cast<char *>(&Tmp), sizeof(Tmp)))
168  return false;
170  sys::swapByteOrder(Tmp);
171  Value = Tmp;
172  return true;
173  }
174 };
175 
176 // Any empty placeholder suitable as a substitute for void when deserializing
177 class SPSEmpty {};
178 
179 /// SPS tag type for tuples.
180 ///
181 /// A blob tuple should be serialized by serializing each of the elements in
182 /// sequence.
183 template <typename... SPSTagTs> class SPSTuple {
184 public:
185  /// Convenience typedef of the corresponding arg list.
186  typedef SPSArgList<SPSTagTs...> AsArgList;
187 };
188 
189 /// SPS tag type for sequences.
190 ///
191 /// SPSSequences should be serialized as a uint64_t sequence length,
192 /// followed by the serialization of each of the elements.
193 template <typename SPSElementTagT> class SPSSequence;
194 
195 /// SPS tag type for strings, which are equivalent to sequences of chars.
197 
198 /// SPS tag type for maps.
199 ///
200 /// SPS maps are just sequences of (Key, Value) tuples.
201 template <typename SPSTagT1, typename SPSTagT2>
203 
204 /// Serialization for SPSEmpty type.
206 public:
207  static size_t size(const SPSEmpty &EP) { return 0; }
208  static bool serialize(SPSOutputBuffer &OB, const SPSEmpty &BE) {
209  return true;
210  }
211  static bool deserialize(SPSInputBuffer &IB, SPSEmpty &BE) { return true; }
212 };
213 
214 /// Specialize this to implement 'trivial' sequence serialization for
215 /// a concrete sequence type.
216 ///
217 /// Trivial sequence serialization uses the sequence's 'size' member to get the
218 /// length of the sequence, and uses a range-based for loop to iterate over the
219 /// elements.
220 ///
221 /// Specializing this template class means that you do not need to provide a
222 /// specialization of SPSSerializationTraits for your type.
223 template <typename SPSElementTagT, typename ConcreteSequenceT>
225 public:
226  static constexpr bool available = false;
227 };
228 
229 /// Specialize this to implement 'trivial' sequence deserialization for
230 /// a concrete sequence type.
231 ///
232 /// Trivial deserialization calls a static 'reserve(SequenceT&)' method on your
233 /// specialization (you must implement this) to reserve space, and then calls
234 /// a static 'append(SequenceT&, ElementT&) method to append each of the
235 /// deserialized elements.
236 ///
237 /// Specializing this template class means that you do not need to provide a
238 /// specialization of SPSSerializationTraits for your type.
239 template <typename SPSElementTagT, typename ConcreteSequenceT>
241 public:
242  static constexpr bool available = false;
243 };
244 
245 /// Trivial std::string -> SPSSequence<char> serialization.
246 template <> class TrivialSPSSequenceSerialization<char, std::string> {
247 public:
248  static constexpr bool available = true;
249 };
250 
251 /// Trivial SPSSequence<char> -> std::string deserialization.
252 template <> class TrivialSPSSequenceDeserialization<char, std::string> {
253 public:
254  static constexpr bool available = true;
255 
256  using element_type = char;
257 
258  static void reserve(std::string &S, uint64_t Size) { S.reserve(Size); }
259  static bool append(std::string &S, char C) {
260  S.push_back(C);
261  return true;
262  }
263 };
264 
265 /// Trivial std::vector<T> -> SPSSequence<SPSElementTagT> serialization.
266 template <typename SPSElementTagT, typename T>
267 class TrivialSPSSequenceSerialization<SPSElementTagT, std::vector<T>> {
268 public:
269  static constexpr bool available = true;
270 };
271 
272 /// Trivial SPSSequence<SPSElementTagT> -> std::vector<T> deserialization.
273 template <typename SPSElementTagT, typename T>
274 class TrivialSPSSequenceDeserialization<SPSElementTagT, std::vector<T>> {
275 public:
276  static constexpr bool available = true;
277 
278  using element_type = typename std::vector<T>::value_type;
279 
280  static void reserve(std::vector<T> &V, uint64_t Size) { V.reserve(Size); }
281  static bool append(std::vector<T> &V, T E) {
282  V.push_back(std::move(E));
283  return true;
284  }
285 };
286 
287 /// Trivial ArrayRef<T> -> SPSSequence<SPSElementTagT> serialization.
288 template <typename SPSElementTagT, typename T>
289 class TrivialSPSSequenceSerialization<SPSElementTagT, ArrayRef<T>> {
290 public:
291  static constexpr bool available = true;
292 };
293 
294 /// Specialized SPSSequence<char> -> ArrayRef<char> serialization.
295 ///
296 /// On deserialize, points directly into the input buffer.
297 template <> class SPSSerializationTraits<SPSSequence<char>, ArrayRef<char>> {
298 public:
299  static size_t size(const ArrayRef<char> &A) {
300  return SPSArgList<uint64_t>::size(static_cast<uint64_t>(A.size())) +
301  A.size();
302  }
303 
304  static bool serialize(SPSOutputBuffer &OB, const ArrayRef<char> &A) {
305  if (!SPSArgList<uint64_t>::serialize(OB, static_cast<uint64_t>(A.size())))
306  return false;
307  return OB.write(A.data(), A.size());
308  }
309 
311  uint64_t Size;
313  return false;
315  return false;
316  A = {IB.data(), static_cast<size_t>(Size)};
317  return IB.skip(Size);
318  }
319 };
320 
321 /// 'Trivial' sequence serialization: Sequence is serialized as a uint64_t size
322 /// followed by a for-earch loop over the elements of the sequence to serialize
323 /// each of them.
324 template <typename SPSElementTagT, typename SequenceT>
325 class SPSSerializationTraits<SPSSequence<SPSElementTagT>, SequenceT,
326  std::enable_if_t<TrivialSPSSequenceSerialization<
327  SPSElementTagT, SequenceT>::available>> {
328 public:
329  static size_t size(const SequenceT &S) {
330  size_t Size = SPSArgList<uint64_t>::size(static_cast<uint64_t>(S.size()));
331  for (const auto &E : S)
333  return Size;
334  }
335 
336  static bool serialize(SPSOutputBuffer &OB, const SequenceT &S) {
337  if (!SPSArgList<uint64_t>::serialize(OB, static_cast<uint64_t>(S.size())))
338  return false;
339  for (const auto &E : S)
341  return false;
342  return true;
343  }
344 
345  static bool deserialize(SPSInputBuffer &IB, SequenceT &S) {
347  uint64_t Size;
349  return false;
350  TBSD::reserve(S, Size);
351  for (size_t I = 0; I != Size; ++I) {
352  typename TBSD::element_type E;
354  return false;
355  if (!TBSD::append(S, std::move(E)))
356  return false;
357  }
358  return true;
359  }
360 };
361 
362 /// SPSTuple serialization for std::tuple.
363 template <typename... SPSTagTs, typename... Ts>
364 class SPSSerializationTraits<SPSTuple<SPSTagTs...>, std::tuple<Ts...>> {
365 private:
366  using TupleArgList = typename SPSTuple<SPSTagTs...>::AsArgList;
367  using ArgIndices = std::make_index_sequence<sizeof...(Ts)>;
368 
369  template <std::size_t... I>
370  static size_t size(const std::tuple<Ts...> &T, std::index_sequence<I...>) {
371  return TupleArgList::size(std::get<I>(T)...);
372  }
373 
374  template <std::size_t... I>
375  static bool serialize(SPSOutputBuffer &OB, const std::tuple<Ts...> &T,
376  std::index_sequence<I...>) {
377  return TupleArgList::serialize(OB, std::get<I>(T)...);
378  }
379 
380  template <std::size_t... I>
381  static bool deserialize(SPSInputBuffer &IB, std::tuple<Ts...> &T,
382  std::index_sequence<I...>) {
383  return TupleArgList::deserialize(IB, std::get<I>(T)...);
384  }
385 
386 public:
387  static size_t size(const std::tuple<Ts...> &T) {
388  return size(T, ArgIndices{});
389  }
390 
391  static bool serialize(SPSOutputBuffer &OB, const std::tuple<Ts...> &T) {
392  return serialize(OB, T, ArgIndices{});
393  }
394 
395  static bool deserialize(SPSInputBuffer &IB, std::tuple<Ts...> &T) {
396  return deserialize(IB, T, ArgIndices{});
397  }
398 };
399 
400 /// SPSTuple serialization for std::pair.
401 template <typename SPSTagT1, typename SPSTagT2, typename T1, typename T2>
402 class SPSSerializationTraits<SPSTuple<SPSTagT1, SPSTagT2>, std::pair<T1, T2>> {
403 public:
404  static size_t size(const std::pair<T1, T2> &P) {
405  return SPSArgList<SPSTagT1>::size(P.first) +
407  }
408 
409  static bool serialize(SPSOutputBuffer &OB, const std::pair<T1, T2> &P) {
410  return SPSArgList<SPSTagT1>::serialize(OB, P.first) &&
412  }
413 
414  static bool deserialize(SPSInputBuffer &IB, std::pair<T1, T2> &P) {
415  return SPSArgList<SPSTagT1>::deserialize(IB, P.first) &&
417  }
418 };
419 
420 /// Serialization for StringRefs.
421 ///
422 /// Serialization is as for regular strings. Deserialization points directly
423 /// into the blob.
425 public:
426  static size_t size(const StringRef &S) {
427  return SPSArgList<uint64_t>::size(static_cast<uint64_t>(S.size())) +
428  S.size();
429  }
430 
432  if (!SPSArgList<uint64_t>::serialize(OB, static_cast<uint64_t>(S.size())))
433  return false;
434  return OB.write(S.data(), S.size());
435  }
436 
437  static bool deserialize(SPSInputBuffer &IB, StringRef &S) {
438  const char *Data = nullptr;
439  uint64_t Size;
441  return false;
442  Data = IB.data();
443  if (!IB.skip(Size))
444  return false;
445  S = StringRef(Data, Size);
446  return true;
447  }
448 };
449 
450 /// Serialization for StringMap<ValueT>s.
451 template <typename SPSValueT, typename ValueT>
453  StringMap<ValueT>> {
454 public:
455  static size_t size(const StringMap<ValueT> &M) {
456  size_t Sz = SPSArgList<uint64_t>::size(static_cast<uint64_t>(M.size()));
457  for (auto &E : M)
458  Sz += SPSArgList<SPSString, SPSValueT>::size(E.first(), E.second);
459  return Sz;
460  }
461 
462  static bool serialize(SPSOutputBuffer &OB, const StringMap<ValueT> &M) {
463  if (!SPSArgList<uint64_t>::serialize(OB, static_cast<uint64_t>(M.size())))
464  return false;
465 
466  for (auto &E : M)
467  if (!SPSArgList<SPSString, SPSValueT>::serialize(OB, E.first(), E.second))
468  return false;
469 
470  return true;
471  }
472 
474  uint64_t Size;
475  assert(M.empty() && "M already contains elements");
476 
478  return false;
479 
480  while (Size--) {
481  StringRef S;
482  ValueT V;
484  return false;
485  if (!M.insert(std::make_pair(S, V)).second)
486  return false;
487  }
488 
489  return true;
490  }
491 };
492 
493 /// SPS tag type for errors.
494 class SPSError;
495 
496 /// SPS tag type for expecteds, which are either a T or a string representing
497 /// an error.
498 template <typename SPSTagT> class SPSExpected;
499 
500 namespace detail {
501 
502 /// Helper type for serializing Errors.
503 ///
504 /// llvm::Errors are move-only, and not inspectable except by consuming them.
505 /// This makes them unsuitable for direct serialization via
506 /// SPSSerializationTraits, which needs to inspect values twice (once to
507 /// determine the amount of space to reserve, and then again to serialize).
508 ///
509 /// The SPSSerializableError type is a helper that can be
510 /// constructed from an llvm::Error, but inspected more than once.
512  bool HasError = false;
513  std::string ErrMsg;
514 };
515 
516 /// Helper type for serializing Expected<T>s.
517 ///
518 /// See SPSSerializableError for more details.
519 ///
520 // FIXME: Use std::variant for storage once we have c++17.
521 template <typename T> struct SPSSerializableExpected {
522  bool HasValue = false;
523  T Value{};
524  std::string ErrMsg;
525 };
526 
528  if (Err)
529  return {true, toString(std::move(Err))};
530  return {false, {}};
531 }
532 
534  if (BSE.HasError)
535  return make_error<StringError>(BSE.ErrMsg, inconvertibleErrorCode());
536  return Error::success();
537 }
538 
539 template <typename T>
541  if (E)
542  return {true, std::move(*E), {}};
543  else
544  return {false, {}, toString(E.takeError())};
545 }
546 
547 template <typename T>
549  if (BSE.HasValue)
550  return std::move(BSE.Value);
551  else
552  return make_error<StringError>(BSE.ErrMsg, inconvertibleErrorCode());
553 }
554 
555 } // end namespace detail
556 
557 /// Serialize to a SPSError from a detail::SPSSerializableError.
558 template <>
559 class SPSSerializationTraits<SPSError, detail::SPSSerializableError> {
560 public:
561  static size_t size(const detail::SPSSerializableError &BSE) {
562  size_t Size = SPSArgList<bool>::size(BSE.HasError);
563  if (BSE.HasError)
565  return Size;
566  }
567 
569  const detail::SPSSerializableError &BSE) {
571  return false;
572  if (BSE.HasError)
574  return false;
575  return true;
576  }
577 
578  static bool deserialize(SPSInputBuffer &IB,
581  return false;
582 
583  if (!BSE.HasError)
584  return true;
585 
587  }
588 };
589 
590 /// Serialize to a SPSExpected<SPSTagT> from a
591 /// detail::SPSSerializableExpected<T>.
592 template <typename SPSTagT, typename T>
594  detail::SPSSerializableExpected<T>> {
595 public:
596  static size_t size(const detail::SPSSerializableExpected<T> &BSE) {
597  size_t Size = SPSArgList<bool>::size(BSE.HasValue);
598  if (BSE.HasValue)
600  else
602  return Size;
603  }
604 
608  return false;
609 
610  if (BSE.HasValue)
612 
614  }
615 
616  static bool deserialize(SPSInputBuffer &IB,
619  return false;
620 
621  if (BSE.HasValue)
622  return SPSArgList<SPSTagT>::deserialize(IB, BSE.Value);
623 
625  }
626 };
627 
628 /// Serialize to a SPSExpected<SPSTagT> from a detail::SPSSerializableError.
629 template <typename SPSTagT>
631  detail::SPSSerializableError> {
632 public:
633  static size_t size(const detail::SPSSerializableError &BSE) {
634  assert(BSE.HasError && "Cannot serialize expected from a success value");
635  return SPSArgList<bool>::size(false) +
637  }
638 
640  const detail::SPSSerializableError &BSE) {
641  assert(BSE.HasError && "Cannot serialize expected from a success value");
642  if (!SPSArgList<bool>::serialize(OB, false))
643  return false;
645  }
646 };
647 
648 /// Serialize to a SPSExpected<SPSTagT> from a T.
649 template <typename SPSTagT, typename T>
651 public:
652  static size_t size(const T &Value) {
654  }
655 
656  static bool serialize(SPSOutputBuffer &OB, const T &Value) {
657  if (!SPSArgList<bool>::serialize(OB, true))
658  return false;
660  }
661 };
662 
663 } // end namespace shared
664 } // end namespace orc
665 } // end namespace llvm
666 
667 #endif // LLVM_EXECUTIONENGINE_ORC_SHARED_SIMPLEPACKEDSERIALIZATION_H
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm::orc::shared::SPSSerializationTraits< SPSExpected< SPSTagT >, detail::SPSSerializableExpected< T > >::serialize
static bool serialize(SPSOutputBuffer &OB, const detail::SPSSerializableExpected< T > &BSE)
Definition: SimplePackedSerialization.h:605
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::sys::IsBigEndianHost
constexpr bool IsBigEndianHost
Definition: SwapByteOrder.h:98
llvm::orc::shared::SPSSequence
SPS tag type for sequences.
Definition: SimplePackedSerialization.h:193
llvm::sys::swapByteOrder
void swapByteOrder(T &Value)
Definition: SwapByteOrder.h:158
llvm::orc::shared::TrivialSPSSequenceSerialization
Specialize this to implement 'trivial' sequence serialization for a concrete sequence type.
Definition: SimplePackedSerialization.h:224
llvm::orc::shared::SPSSerializationTraits
Specialize to describe how to serialize/deserialize to/from the given concrete type.
Definition: SimplePackedSerialization.h:103
llvm::orc::shared::TrivialSPSSequenceDeserialization< SPSElementTagT, std::vector< T > >::reserve
static void reserve(std::vector< T > &V, uint64_t Size)
Definition: SimplePackedSerialization.h:280
StringRef.h
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::toString
std::string toString(Error E)
Write all error messages (if any) in E to a string.
Definition: Error.h:1030
llvm::orc::shared::SPSOutputBuffer
Output char buffer with overflow check.
Definition: SimplePackedSerialization.h:53
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:331
llvm::orc::shared::SPSSerializationTraits< SPSSequence< SPSTuple< SPSString, SPSValueT > >, StringMap< ValueT > >::deserialize
static bool deserialize(SPSInputBuffer &IB, StringMap< ValueT > &M)
Definition: SimplePackedSerialization.h:473
Error.h
SwapByteOrder.h
llvm::orc::shared::SPSArgList<>::serialize
static bool serialize(SPSOutputBuffer &OB)
Definition: SimplePackedSerialization.h:113
llvm::orc::shared::SPSSerializationTraits< SPSTuple< SPSTagTs... >, std::tuple< Ts... > >::size
static size_t size(const std::tuple< Ts... > &T)
Definition: SimplePackedSerialization.h:387
llvm::orc::shared::SPSSerializationTraits< SPSTuple< SPSTagT1, SPSTagT2 >, std::pair< T1, T2 > >::serialize
static bool serialize(SPSOutputBuffer &OB, const std::pair< T1, T2 > &P)
Definition: SimplePackedSerialization.h:409
T
#define T
Definition: Mips16ISelLowering.cpp:341
llvm::orc::shared::SPSSerializationTraits< SPSSequence< char >, ArrayRef< char > >::serialize
static bool serialize(SPSOutputBuffer &OB, const ArrayRef< char > &A)
Definition: SimplePackedSerialization.h:304
llvm::orc::shared::SPSInputBuffer
Input char buffer with underflow check.
Definition: SimplePackedSerialization.h:72
llvm::orc::shared::SPSSerializationTraits< SPSSequence< SPSElementTagT >, SequenceT, std::enable_if_t< TrivialSPSSequenceSerialization< SPSElementTagT, SequenceT >::available > >::size
static size_t size(const SequenceT &S)
Definition: SimplePackedSerialization.h:329
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:42
STLExtras.h
llvm::orc::shared::SPSSerializationTraits< SPSSequence< char >, ArrayRef< char > >::deserialize
static bool deserialize(SPSInputBuffer &IB, ArrayRef< char > &A)
Definition: SimplePackedSerialization.h:310
llvm::orc::shared::SPSTuple
SPS tag type for tuples.
Definition: SimplePackedSerialization.h:183
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
llvm::orc::shared::SPSSerializationTraits< SPSSequence< SPSTuple< SPSString, SPSValueT > >, StringMap< ValueT > >::size
static size_t size(const StringMap< ValueT > &M)
Definition: SimplePackedSerialization.h:455
llvm::sys::path::append
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
Definition: Path.cpp:456
Arg
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Definition: AMDGPULibCalls.cpp:206
llvm::orc::shared::SPSInputBuffer::SPSInputBuffer
SPSInputBuffer()=default
llvm::orc::shared::SPSArgList< SPSTagT, SPSTagTs... >::size
static size_t size(const ArgT &Arg, const ArgTs &...Args)
Definition: SimplePackedSerialization.h:122
llvm::orc::shared::TrivialSPSSequenceDeserialization< SPSElementTagT, std::vector< T > >::element_type
typename std::vector< T >::value_type element_type
Definition: SimplePackedSerialization.h:278
llvm::orc::shared::SPSSerializationTraits< SPSTuple< SPSTagT1, SPSTagT2 >, std::pair< T1, T2 > >::deserialize
static bool deserialize(SPSInputBuffer &IB, std::pair< T1, T2 > &P)
Definition: SimplePackedSerialization.h:414
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::orc::shared::detail::fromSPSSerializable
Error fromSPSSerializable(SPSSerializableError BSE)
Definition: SimplePackedSerialization.h:533
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::orc::shared::detail::SPSSerializableError
Helper type for serializing Errors.
Definition: SimplePackedSerialization.h:511
llvm::orc::shared::SPSSerializationTraits< SPSTagT, SPSTagT, std::enable_if_t< std::is_same< SPSTagT, bool >::value||std::is_same< SPSTagT, char >::value||std::is_same< SPSTagT, int8_t >::value||std::is_same< SPSTagT, int16_t >::value||std::is_same< SPSTagT, int32_t >::value||std::is_same< SPSTagT, int64_t >::value||std::is_same< SPSTagT, uint8_t >::value||std::is_same< SPSTagT, uint16_t >::value||std::is_same< SPSTagT, uint32_t >::value||std::is_same< SPSTagT, uint64_t >::value > >::deserialize
static bool deserialize(SPSInputBuffer &IB, SPSTagT &Value)
Definition: SimplePackedSerialization.h:165
llvm::orc::shared::SPSOutputBuffer::write
bool write(const char *Data, size_t Size)
Definition: SimplePackedSerialization.h:57
llvm::orc::shared::SPSEmpty
Definition: SimplePackedSerialization.h:177
llvm::orc::shared::SPSSerializationTraits< SPSExpected< SPSTagT >, detail::SPSSerializableError >::size
static size_t size(const detail::SPSSerializableError &BSE)
Definition: SimplePackedSerialization.h:633
llvm::orc::shared::SPSSerializationTraits< SPSSequence< char >, ArrayRef< char > >::size
static size_t size(const ArrayRef< char > &A)
Definition: SimplePackedSerialization.h:299
StringMap.h
llvm::orc::shared::SPSSerializationTraits< SPSString, StringRef >::size
static size_t size(const StringRef &S)
Definition: SimplePackedSerialization.h:426
llvm::orc::shared::SPSInputBuffer::read
bool read(char *Data, size_t Size)
Definition: SimplePackedSerialization.h:77
llvm::orc::shared::TrivialSPSSequenceDeserialization< char, std::string >::append
static bool append(std::string &S, char C)
Definition: SimplePackedSerialization.h:259
llvm::orc::shared::SPSOutputBuffer::SPSOutputBuffer
SPSOutputBuffer(char *Buffer, size_t Remaining)
Definition: SimplePackedSerialization.h:55
llvm::orc::shared::SPSSerializationTraits< SPSError, detail::SPSSerializableError >::size
static size_t size(const detail::SPSSerializableError &BSE)
Definition: SimplePackedSerialization.h:561
llvm::orc::shared::SPSSerializationTraits< SPSTagT, SPSTagT, std::enable_if_t< std::is_same< SPSTagT, bool >::value||std::is_same< SPSTagT, char >::value||std::is_same< SPSTagT, int8_t >::value||std::is_same< SPSTagT, int16_t >::value||std::is_same< SPSTagT, int32_t >::value||std::is_same< SPSTagT, int64_t >::value||std::is_same< SPSTagT, uint8_t >::value||std::is_same< SPSTagT, uint16_t >::value||std::is_same< SPSTagT, uint32_t >::value||std::is_same< SPSTagT, uint64_t >::value > >::size
static size_t size(const SPSTagT &Value)
Definition: SimplePackedSerialization.h:156
llvm::orc::shared::SPSArgList<>::deserialize
static bool deserialize(SPSInputBuffer &IB)
Definition: SimplePackedSerialization.h:114
llvm::StringMap
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition: StringMap.h:108
llvm::orc::shared::SPSArgList< SPSTagT, SPSTagTs... >::deserialize
static bool deserialize(SPSInputBuffer &IB, ArgT &Arg, ArgTs &...Args)
Definition: SimplePackedSerialization.h:135
llvm::orc::shared::TrivialSPSSequenceDeserialization::available
static constexpr bool available
Definition: SimplePackedSerialization.h:242
llvm::orc::shared::SPSSerializationTraits< SPSExpected< SPSTagT >, T >::serialize
static bool serialize(SPSOutputBuffer &OB, const T &Value)
Definition: SimplePackedSerialization.h:656
llvm::orc::shared::SPSSerializationTraits< SPSString, StringRef >::serialize
static bool serialize(SPSOutputBuffer &OB, StringRef S)
Definition: SimplePackedSerialization.h:431
llvm::orc::shared::TrivialSPSSequenceSerialization::available
static constexpr bool available
Definition: SimplePackedSerialization.h:226
llvm::orc::shared::SPSSerializationTraits< SPSExpected< SPSTagT >, T >::size
static size_t size(const T &Value)
Definition: SimplePackedSerialization.h:652
uint64_t
llvm::orc::shared::SPSSerializationTraits< SPSTagT, SPSTagT, std::enable_if_t< std::is_same< SPSTagT, bool >::value||std::is_same< SPSTagT, char >::value||std::is_same< SPSTagT, int8_t >::value||std::is_same< SPSTagT, int16_t >::value||std::is_same< SPSTagT, int32_t >::value||std::is_same< SPSTagT, int64_t >::value||std::is_same< SPSTagT, uint8_t >::value||std::is_same< SPSTagT, uint16_t >::value||std::is_same< SPSTagT, uint32_t >::value||std::is_same< SPSTagT, uint64_t >::value > >::serialize
static bool serialize(SPSOutputBuffer &OB, const SPSTagT &Value)
Definition: SimplePackedSerialization.h:158
llvm::orc::shared::SPSSerializationTraits< SPSEmpty, SPSEmpty >::deserialize
static bool deserialize(SPSInputBuffer &IB, SPSEmpty &BE)
Definition: SimplePackedSerialization.h:211
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::orc::shared::SPSExpected
SPS tag type for expecteds, which are either a T or a string representing an error.
Definition: SimplePackedSerialization.h:498
llvm::orc::shared::SPSSerializationTraits< SPSExpected< SPSTagT >, detail::SPSSerializableError >::serialize
static bool serialize(SPSOutputBuffer &OB, const detail::SPSSerializableError &BSE)
Definition: SimplePackedSerialization.h:639
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::orc::shared::detail::SPSSerializableError::HasError
bool HasError
Definition: SimplePackedSerialization.h:512
llvm::orc::shared::SPSInputBuffer::data
const char * data() const
Definition: SimplePackedSerialization.h:86
llvm::orc::shared::TrivialSPSSequenceDeserialization< char, std::string >::element_type
char element_type
Definition: SimplePackedSerialization.h:256
size
i< reg-> size
Definition: README.txt:166
llvm::orc::shared::SPSSerializationTraits< SPSSequence< SPSElementTagT >, SequenceT, std::enable_if_t< TrivialSPSSequenceSerialization< SPSElementTagT, SequenceT >::available > >::serialize
static bool serialize(SPSOutputBuffer &OB, const SequenceT &S)
Definition: SimplePackedSerialization.h:336
llvm::orc::shared::SPSSerializationTraits< SPSError, detail::SPSSerializableError >::deserialize
static bool deserialize(SPSInputBuffer &IB, detail::SPSSerializableError &BSE)
Definition: SimplePackedSerialization.h:578
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
memcpy
<%struct.s * > cast struct s *S to sbyte *< sbyte * > sbyte uint cast struct s *agg result to sbyte *< sbyte * > sbyte uint cast struct s *memtmp to sbyte *< sbyte * > sbyte uint ret void llc ends up issuing two memcpy or custom lower memcpy(of small size) to be ldmia/stmia. I think option 2 is better but the current register allocator cannot allocate a chunk of registers at a time. A feasible temporary solution is to use specific physical registers at the lowering time for small(<
llvm::orc::shared::detail::SPSSerializableExpected::ErrMsg
std::string ErrMsg
Definition: SimplePackedSerialization.h:524
llvm::size
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
Definition: STLExtras.h:1581
llvm::orc::shared::SPSSerializationTraits< SPSExpected< SPSTagT >, detail::SPSSerializableExpected< T > >::deserialize
static bool deserialize(SPSInputBuffer &IB, detail::SPSSerializableExpected< T > &BSE)
Definition: SimplePackedSerialization.h:616
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
llvm::orc::shared::SPSArgList< SPSTagT, SPSTagTs... >::serialize
static bool serialize(SPSOutputBuffer &OB, const ArgT &Arg, const ArgTs &...Args)
Definition: SimplePackedSerialization.h:128
ValueT
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::orc::shared::SPSTuple::AsArgList
SPSArgList< SPSTagTs... > AsArgList
Convenience typedef of the corresponding arg list.
Definition: SimplePackedSerialization.h:186
llvm::orc::shared::SPSSerializationTraits< SPSSequence< SPSTuple< SPSString, SPSValueT > >, StringMap< ValueT > >::serialize
static bool serialize(SPSOutputBuffer &OB, const StringMap< ValueT > &M)
Definition: SimplePackedSerialization.h:462
std
Definition: BitVector.h:838
llvm::orc::shared::TrivialSPSSequenceDeserialization< SPSElementTagT, std::vector< T > >::append
static bool append(std::vector< T > &V, T E)
Definition: SimplePackedSerialization.h:281
llvm::inconvertibleErrorCode
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition: Error.cpp:77
llvm::orc::shared::SPSInputBuffer::SPSInputBuffer
SPSInputBuffer(const char *Buffer, size_t Remaining)
Definition: SimplePackedSerialization.h:75
llvm::orc::shared::detail::SPSSerializableError::ErrMsg
std::string ErrMsg
Definition: SimplePackedSerialization.h:513
llvm::orc::shared::SPSSerializationTraits< SPSString, StringRef >::deserialize
static bool deserialize(SPSInputBuffer &IB, StringRef &S)
Definition: SimplePackedSerialization.h:437
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::orc::shared::TrivialSPSSequenceDeserialization
Specialize this to implement 'trivial' sequence deserialization for a concrete sequence type.
Definition: SimplePackedSerialization.h:240
llvm::orc::shared::detail::toSPSSerializable
SPSSerializableError toSPSSerializable(Error Err)
Definition: SimplePackedSerialization.h:527
llvm::orc::shared::SPSSerializationTraits< SPSError, detail::SPSSerializableError >::serialize
static bool serialize(SPSOutputBuffer &OB, const detail::SPSSerializableError &BSE)
Definition: SimplePackedSerialization.h:568
llvm::TargetStackID::Value
Value
Definition: TargetFrameLowering.h:27
llvm::orc::shared::detail::SPSSerializableExpected::HasValue
bool HasValue
Definition: SimplePackedSerialization.h:522
llvm::orc::shared::detail::SPSSerializableExpected
Helper type for serializing Expected<T>s.
Definition: SimplePackedSerialization.h:521
llvm::orc::shared::SPSSerializationTraits< SPSSequence< SPSElementTagT >, SequenceT, std::enable_if_t< TrivialSPSSequenceSerialization< SPSElementTagT, SequenceT >::available > >::deserialize
static bool deserialize(SPSInputBuffer &IB, SequenceT &S)
Definition: SimplePackedSerialization.h:345
llvm::orc::shared::SPSSerializationTraits< SPSTuple< SPSTagTs... >, std::tuple< Ts... > >::deserialize
static bool deserialize(SPSInputBuffer &IB, std::tuple< Ts... > &T)
Definition: SimplePackedSerialization.h:395
llvm::orc::shared::SPSSerializationTraits< SPSExpected< SPSTagT >, detail::SPSSerializableExpected< T > >::size
static size_t size(const detail::SPSSerializableExpected< T > &BSE)
Definition: SimplePackedSerialization.h:596
llvm::orc::shared::SPSSerializationTraits< SPSTuple< SPSTagT1, SPSTagT2 >, std::pair< T1, T2 > >::size
static size_t size(const std::pair< T1, T2 > &P)
Definition: SimplePackedSerialization.h:404
llvm::orc::shared::detail::SPSSerializableExpected::Value
T Value
Definition: SimplePackedSerialization.h:523
llvm::orc::shared::TrivialSPSSequenceDeserialization< char, std::string >::reserve
static void reserve(std::string &S, uint64_t Size)
Definition: SimplePackedSerialization.h:258
llvm::X86II::OB
@ OB
Definition: X86BaseInfo.h:801
llvm::max
Align max(MaybeAlign Lhs, Align Rhs)
Definition: Alignment.h:340
llvm::orc::shared::SPSArgList<>::size
static size_t size()
Definition: SimplePackedSerialization.h:111
llvm::AMDGPU::HSAMD::Kernel::Key::Args
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Definition: AMDGPUMetadata.h:389
llvm::orc::shared::SPSInputBuffer::skip
bool skip(size_t Size)
Definition: SimplePackedSerialization.h:87
llvm::orc::shared::SPSSerializationTraits< SPSTuple< SPSTagTs... >, std::tuple< Ts... > >::serialize
static bool serialize(SPSOutputBuffer &OB, const std::tuple< Ts... > &T)
Definition: SimplePackedSerialization.h:391
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::orc::shared::SPSArgList
A utility class for serializing to a blob from a variadic list.
Definition: SimplePackedSerialization.h:106
SpecialSubKind::string
@ string
llvm::orc::shared::SPSSerializationTraits< SPSEmpty, SPSEmpty >::size
static size_t size(const SPSEmpty &EP)
Definition: SimplePackedSerialization.h:207
llvm::orc::shared::SPSSerializationTraits< SPSEmpty, SPSEmpty >::serialize
static bool serialize(SPSOutputBuffer &OB, const SPSEmpty &BE)
Definition: SimplePackedSerialization.h:208