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 executor addresseses.
200 
201 template <>
203  : public SPSSerializationTraits<uint64_t, uint64_t> {};
204 
205 /// SPS tag type for maps.
206 ///
207 /// SPS maps are just sequences of (Key, Value) tuples.
208 template <typename SPSTagT1, typename SPSTagT2>
210 
211 /// Serialization for SPSEmpty type.
213 public:
214  static size_t size(const SPSEmpty &EP) { return 0; }
215  static bool serialize(SPSOutputBuffer &OB, const SPSEmpty &BE) {
216  return true;
217  }
218  static bool deserialize(SPSInputBuffer &IB, SPSEmpty &BE) { return true; }
219 };
220 
221 /// Specialize this to implement 'trivial' sequence serialization for
222 /// a concrete sequence type.
223 ///
224 /// Trivial sequence serialization uses the sequence's 'size' member to get the
225 /// length of the sequence, and uses a range-based for loop to iterate over the
226 /// elements.
227 ///
228 /// Specializing this template class means that you do not need to provide a
229 /// specialization of SPSSerializationTraits for your type.
230 template <typename SPSElementTagT, typename ConcreteSequenceT>
232 public:
233  static constexpr bool available = false;
234 };
235 
236 /// Specialize this to implement 'trivial' sequence deserialization for
237 /// a concrete sequence type.
238 ///
239 /// Trivial deserialization calls a static 'reserve(SequenceT&)' method on your
240 /// specialization (you must implement this) to reserve space, and then calls
241 /// a static 'append(SequenceT&, ElementT&) method to append each of the
242 /// deserialized elements.
243 ///
244 /// Specializing this template class means that you do not need to provide a
245 /// specialization of SPSSerializationTraits for your type.
246 template <typename SPSElementTagT, typename ConcreteSequenceT>
248 public:
249  static constexpr bool available = false;
250 };
251 
252 /// Trivial std::string -> SPSSequence<char> serialization.
253 template <> class TrivialSPSSequenceSerialization<char, std::string> {
254 public:
255  static constexpr bool available = true;
256 };
257 
258 /// Trivial SPSSequence<char> -> std::string deserialization.
259 template <> class TrivialSPSSequenceDeserialization<char, std::string> {
260 public:
261  static constexpr bool available = true;
262 
263  using element_type = char;
264 
265  static void reserve(std::string &S, uint64_t Size) { S.reserve(Size); }
266  static bool append(std::string &S, char C) {
267  S.push_back(C);
268  return true;
269  }
270 };
271 
272 /// Trivial std::vector<T> -> SPSSequence<SPSElementTagT> serialization.
273 template <typename SPSElementTagT, typename T>
274 class TrivialSPSSequenceSerialization<SPSElementTagT, std::vector<T>> {
275 public:
276  static constexpr bool available = true;
277 };
278 
279 /// Trivial SPSSequence<SPSElementTagT> -> std::vector<T> deserialization.
280 template <typename SPSElementTagT, typename T>
281 class TrivialSPSSequenceDeserialization<SPSElementTagT, std::vector<T>> {
282 public:
283  static constexpr bool available = true;
284 
285  using element_type = typename std::vector<T>::value_type;
286 
287  static void reserve(std::vector<T> &V, uint64_t Size) { V.reserve(Size); }
288  static bool append(std::vector<T> &V, T E) {
289  V.push_back(std::move(E));
290  return true;
291  }
292 };
293 
294 /// Trivial ArrayRef<T> -> SPSSequence<SPSElementTagT> serialization.
295 template <typename SPSElementTagT, typename T>
296 class TrivialSPSSequenceSerialization<SPSElementTagT, ArrayRef<T>> {
297 public:
298  static constexpr bool available = true;
299 };
300 
301 /// Specialized SPSSequence<char> -> ArrayRef<char> serialization.
302 ///
303 /// On deserialize, points directly into the input buffer.
304 template <> class SPSSerializationTraits<SPSSequence<char>, ArrayRef<char>> {
305 public:
306  static size_t size(const ArrayRef<char> &A) {
307  return SPSArgList<uint64_t>::size(static_cast<uint64_t>(A.size())) +
308  A.size();
309  }
310 
311  static bool serialize(SPSOutputBuffer &OB, const ArrayRef<char> &A) {
312  if (!SPSArgList<uint64_t>::serialize(OB, static_cast<uint64_t>(A.size())))
313  return false;
314  return OB.write(A.data(), A.size());
315  }
316 
318  uint64_t Size;
320  return false;
322  return false;
323  A = {IB.data(), static_cast<size_t>(Size)};
324  return IB.skip(Size);
325  }
326 };
327 
328 /// 'Trivial' sequence serialization: Sequence is serialized as a uint64_t size
329 /// followed by a for-earch loop over the elements of the sequence to serialize
330 /// each of them.
331 template <typename SPSElementTagT, typename SequenceT>
332 class SPSSerializationTraits<SPSSequence<SPSElementTagT>, SequenceT,
333  std::enable_if_t<TrivialSPSSequenceSerialization<
334  SPSElementTagT, SequenceT>::available>> {
335 public:
336  static size_t size(const SequenceT &S) {
337  size_t Size = SPSArgList<uint64_t>::size(static_cast<uint64_t>(S.size()));
338  for (const auto &E : S)
340  return Size;
341  }
342 
343  static bool serialize(SPSOutputBuffer &OB, const SequenceT &S) {
344  if (!SPSArgList<uint64_t>::serialize(OB, static_cast<uint64_t>(S.size())))
345  return false;
346  for (const auto &E : S)
348  return false;
349  return true;
350  }
351 
352  static bool deserialize(SPSInputBuffer &IB, SequenceT &S) {
354  uint64_t Size;
356  return false;
357  TBSD::reserve(S, Size);
358  for (size_t I = 0; I != Size; ++I) {
359  typename TBSD::element_type E;
361  return false;
362  if (!TBSD::append(S, std::move(E)))
363  return false;
364  }
365  return true;
366  }
367 };
368 
369 /// SPSTuple serialization for std::tuple.
370 template <typename... SPSTagTs, typename... Ts>
371 class SPSSerializationTraits<SPSTuple<SPSTagTs...>, std::tuple<Ts...>> {
372 private:
373  using TupleArgList = typename SPSTuple<SPSTagTs...>::AsArgList;
374  using ArgIndices = std::make_index_sequence<sizeof...(Ts)>;
375 
376  template <std::size_t... I>
377  static size_t size(const std::tuple<Ts...> &T, std::index_sequence<I...>) {
378  return TupleArgList::size(std::get<I>(T)...);
379  }
380 
381  template <std::size_t... I>
382  static bool serialize(SPSOutputBuffer &OB, const std::tuple<Ts...> &T,
383  std::index_sequence<I...>) {
384  return TupleArgList::serialize(OB, std::get<I>(T)...);
385  }
386 
387  template <std::size_t... I>
388  static bool deserialize(SPSInputBuffer &IB, std::tuple<Ts...> &T,
389  std::index_sequence<I...>) {
390  return TupleArgList::deserialize(IB, std::get<I>(T)...);
391  }
392 
393 public:
394  static size_t size(const std::tuple<Ts...> &T) {
395  return size(T, ArgIndices{});
396  }
397 
398  static bool serialize(SPSOutputBuffer &OB, const std::tuple<Ts...> &T) {
399  return serialize(OB, T, ArgIndices{});
400  }
401 
402  static bool deserialize(SPSInputBuffer &IB, std::tuple<Ts...> &T) {
403  return deserialize(IB, T, ArgIndices{});
404  }
405 };
406 
407 /// SPSTuple serialization for std::pair.
408 template <typename SPSTagT1, typename SPSTagT2, typename T1, typename T2>
409 class SPSSerializationTraits<SPSTuple<SPSTagT1, SPSTagT2>, std::pair<T1, T2>> {
410 public:
411  static size_t size(const std::pair<T1, T2> &P) {
412  return SPSArgList<SPSTagT1>::size(P.first) +
414  }
415 
416  static bool serialize(SPSOutputBuffer &OB, const std::pair<T1, T2> &P) {
417  return SPSArgList<SPSTagT1>::serialize(OB, P.first) &&
419  }
420 
421  static bool deserialize(SPSInputBuffer &IB, std::pair<T1, T2> &P) {
422  return SPSArgList<SPSTagT1>::deserialize(IB, P.first) &&
424  }
425 };
426 
427 /// Serialization for StringRefs.
428 ///
429 /// Serialization is as for regular strings. Deserialization points directly
430 /// into the blob.
432 public:
433  static size_t size(const StringRef &S) {
434  return SPSArgList<uint64_t>::size(static_cast<uint64_t>(S.size())) +
435  S.size();
436  }
437 
439  if (!SPSArgList<uint64_t>::serialize(OB, static_cast<uint64_t>(S.size())))
440  return false;
441  return OB.write(S.data(), S.size());
442  }
443 
444  static bool deserialize(SPSInputBuffer &IB, StringRef &S) {
445  const char *Data = nullptr;
446  uint64_t Size;
448  return false;
449  Data = IB.data();
450  if (!IB.skip(Size))
451  return false;
452  S = StringRef(Data, Size);
453  return true;
454  }
455 };
456 
457 /// Serialization for StringMap<ValueT>s.
458 template <typename SPSValueT, typename ValueT>
460  StringMap<ValueT>> {
461 public:
462  static size_t size(const StringMap<ValueT> &M) {
463  size_t Sz = SPSArgList<uint64_t>::size(static_cast<uint64_t>(M.size()));
464  for (auto &E : M)
465  Sz += SPSArgList<SPSString, SPSValueT>::size(E.first(), E.second);
466  return Sz;
467  }
468 
469  static bool serialize(SPSOutputBuffer &OB, const StringMap<ValueT> &M) {
470  if (!SPSArgList<uint64_t>::serialize(OB, static_cast<uint64_t>(M.size())))
471  return false;
472 
473  for (auto &E : M)
474  if (!SPSArgList<SPSString, SPSValueT>::serialize(OB, E.first(), E.second))
475  return false;
476 
477  return true;
478  }
479 
481  uint64_t Size;
482  assert(M.empty() && "M already contains elements");
483 
485  return false;
486 
487  while (Size--) {
488  StringRef S;
489  ValueT V;
491  return false;
492  if (!M.insert(std::make_pair(S, V)).second)
493  return false;
494  }
495 
496  return true;
497  }
498 };
499 
500 /// SPS tag type for errors.
501 class SPSError;
502 
503 /// SPS tag type for expecteds, which are either a T or a string representing
504 /// an error.
505 template <typename SPSTagT> class SPSExpected;
506 
507 namespace detail {
508 
509 /// Helper type for serializing Errors.
510 ///
511 /// llvm::Errors are move-only, and not inspectable except by consuming them.
512 /// This makes them unsuitable for direct serialization via
513 /// SPSSerializationTraits, which needs to inspect values twice (once to
514 /// determine the amount of space to reserve, and then again to serialize).
515 ///
516 /// The SPSSerializableError type is a helper that can be
517 /// constructed from an llvm::Error, but inspected more than once.
519  bool HasError = false;
520  std::string ErrMsg;
521 };
522 
523 /// Helper type for serializing Expected<T>s.
524 ///
525 /// See SPSSerializableError for more details.
526 ///
527 // FIXME: Use std::variant for storage once we have c++17.
528 template <typename T> struct SPSSerializableExpected {
529  bool HasValue = false;
530  T Value{};
531  std::string ErrMsg;
532 };
533 
535  if (Err)
536  return {true, toString(std::move(Err))};
537  return {false, {}};
538 }
539 
541  if (BSE.HasError)
542  return make_error<StringError>(BSE.ErrMsg, inconvertibleErrorCode());
543  return Error::success();
544 }
545 
546 template <typename T>
548  if (E)
549  return {true, std::move(*E), {}};
550  else
551  return {false, {}, toString(E.takeError())};
552 }
553 
554 template <typename T>
556  if (BSE.HasValue)
557  return std::move(BSE.Value);
558  else
559  return make_error<StringError>(BSE.ErrMsg, inconvertibleErrorCode());
560 }
561 
562 } // end namespace detail
563 
564 /// Serialize to a SPSError from a detail::SPSSerializableError.
565 template <>
566 class SPSSerializationTraits<SPSError, detail::SPSSerializableError> {
567 public:
568  static size_t size(const detail::SPSSerializableError &BSE) {
569  size_t Size = SPSArgList<bool>::size(BSE.HasError);
570  if (BSE.HasError)
572  return Size;
573  }
574 
576  const detail::SPSSerializableError &BSE) {
578  return false;
579  if (BSE.HasError)
581  return false;
582  return true;
583  }
584 
585  static bool deserialize(SPSInputBuffer &IB,
588  return false;
589 
590  if (!BSE.HasError)
591  return true;
592 
594  }
595 };
596 
597 /// Serialize to a SPSExpected<SPSTagT> from a
598 /// detail::SPSSerializableExpected<T>.
599 template <typename SPSTagT, typename T>
601  detail::SPSSerializableExpected<T>> {
602 public:
603  static size_t size(const detail::SPSSerializableExpected<T> &BSE) {
604  size_t Size = SPSArgList<bool>::size(BSE.HasValue);
605  if (BSE.HasValue)
607  else
609  return Size;
610  }
611 
615  return false;
616 
617  if (BSE.HasValue)
619 
621  }
622 
623  static bool deserialize(SPSInputBuffer &IB,
626  return false;
627 
628  if (BSE.HasValue)
629  return SPSArgList<SPSTagT>::deserialize(IB, BSE.Value);
630 
632  }
633 };
634 
635 /// Serialize to a SPSExpected<SPSTagT> from a detail::SPSSerializableError.
636 template <typename SPSTagT>
638  detail::SPSSerializableError> {
639 public:
640  static size_t size(const detail::SPSSerializableError &BSE) {
641  assert(BSE.HasError && "Cannot serialize expected from a success value");
642  return SPSArgList<bool>::size(false) +
644  }
645 
647  const detail::SPSSerializableError &BSE) {
648  assert(BSE.HasError && "Cannot serialize expected from a success value");
649  if (!SPSArgList<bool>::serialize(OB, false))
650  return false;
652  }
653 };
654 
655 /// Serialize to a SPSExpected<SPSTagT> from a T.
656 template <typename SPSTagT, typename T>
658 public:
659  static size_t size(const T &Value) {
661  }
662 
663  static bool serialize(SPSOutputBuffer &OB, const T &Value) {
664  if (!SPSArgList<bool>::serialize(OB, true))
665  return false;
667  }
668 };
669 
670 } // end namespace shared
671 } // end namespace orc
672 } // end namespace llvm
673 
674 #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:612
llvm
---------------------— PointerInfo ------------------------------------—
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:231
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:287
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:1020
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:480
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:394
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:416
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:311
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:336
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:317
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:462
llvm::X86II::OB
@ OB
Definition: X86BaseInfo.h:796
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:454
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:285
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:421
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::orc::shared::detail::fromSPSSerializable
Error fromSPSSerializable(SPSSerializableError BSE)
Definition: SimplePackedSerialization.h:540
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:518
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:640
llvm::orc::shared::SPSSerializationTraits< SPSSequence< char >, ArrayRef< char > >::size
static size_t size(const ArrayRef< char > &A)
Definition: SimplePackedSerialization.h:306
StringMap.h
llvm::orc::shared::SPSSerializationTraits< SPSString, StringRef >::size
static size_t size(const StringRef &S)
Definition: SimplePackedSerialization.h:433
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:266
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:568
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:249
llvm::orc::shared::SPSSerializationTraits< SPSExpected< SPSTagT >, T >::serialize
static bool serialize(SPSOutputBuffer &OB, const T &Value)
Definition: SimplePackedSerialization.h:663
llvm::orc::shared::SPSSerializationTraits< SPSString, StringRef >::serialize
static bool serialize(SPSOutputBuffer &OB, StringRef S)
Definition: SimplePackedSerialization.h:438
llvm::orc::shared::TrivialSPSSequenceSerialization::available
static constexpr bool available
Definition: SimplePackedSerialization.h:233
llvm::orc::shared::SPSSerializationTraits< SPSExpected< SPSTagT >, T >::size
static size_t size(const T &Value)
Definition: SimplePackedSerialization.h:659
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:218
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:505
llvm::orc::shared::SPSSerializationTraits< SPSExpected< SPSTagT >, detail::SPSSerializableError >::serialize
static bool serialize(SPSOutputBuffer &OB, const detail::SPSSerializableError &BSE)
Definition: SimplePackedSerialization.h:646
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::orc::shared::detail::SPSSerializableError::HasError
bool HasError
Definition: SimplePackedSerialization.h:519
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:263
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:343
llvm::orc::shared::SPSSerializationTraits< SPSError, detail::SPSSerializableError >::deserialize
static bool deserialize(SPSInputBuffer &IB, detail::SPSSerializableError &BSE)
Definition: SimplePackedSerialization.h:585
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:531
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:1528
llvm::orc::shared::SPSSerializationTraits< SPSExpected< SPSTagT >, detail::SPSSerializableExpected< T > >::deserialize
static bool deserialize(SPSInputBuffer &IB, detail::SPSSerializableExpected< T > &BSE)
Definition: SimplePackedSerialization.h:623
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:58
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:469
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:288
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:520
llvm::orc::shared::SPSSerializationTraits< SPSString, StringRef >::deserialize
static bool deserialize(SPSInputBuffer &IB, StringRef &S)
Definition: SimplePackedSerialization.h:444
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:247
llvm::orc::shared::detail::toSPSSerializable
SPSSerializableError toSPSSerializable(Error Err)
Definition: SimplePackedSerialization.h:534
llvm::orc::shared::SPSSerializationTraits< SPSError, detail::SPSSerializableError >::serialize
static bool serialize(SPSOutputBuffer &OB, const detail::SPSSerializableError &BSE)
Definition: SimplePackedSerialization.h:575
llvm::TargetStackID::Value
Value
Definition: TargetFrameLowering.h:27
llvm::orc::shared::SPSExecutorAddress
SPS tag type for executor addresseses.
Definition: SimplePackedSerialization.h:199
llvm::orc::shared::detail::SPSSerializableExpected::HasValue
bool HasValue
Definition: SimplePackedSerialization.h:529
llvm::orc::shared::detail::SPSSerializableExpected
Helper type for serializing Expected<T>s.
Definition: SimplePackedSerialization.h:528
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:352
llvm::orc::shared::SPSSerializationTraits< SPSTuple< SPSTagTs... >, std::tuple< Ts... > >::deserialize
static bool deserialize(SPSInputBuffer &IB, std::tuple< Ts... > &T)
Definition: SimplePackedSerialization.h:402
llvm::orc::shared::SPSSerializationTraits< SPSExpected< SPSTagT >, detail::SPSSerializableExpected< T > >::size
static size_t size(const detail::SPSSerializableExpected< T > &BSE)
Definition: SimplePackedSerialization.h:603
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:411
llvm::orc::shared::detail::SPSSerializableExpected::Value
T Value
Definition: SimplePackedSerialization.h:530
llvm::orc::shared::TrivialSPSSequenceDeserialization< char, std::string >::reserve
static void reserve(std::string &S, uint64_t Size)
Definition: SimplePackedSerialization.h:265
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:398
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
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:214
llvm::orc::shared::SPSSerializationTraits< SPSEmpty, SPSEmpty >::serialize
static bool serialize(SPSOutputBuffer &OB, const SPSEmpty &BE)
Definition: SimplePackedSerialization.h:215