LLVM  16.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/SmallVector.h"
37 #include "llvm/ADT/StringMap.h"
38 #include "llvm/ADT/StringRef.h"
39 #include "llvm/Support/Error.h"
41 
42 #include <limits>
43 #include <string>
44 #include <tuple>
45 #include <type_traits>
46 #include <utility>
47 #include <vector>
48 
49 namespace llvm {
50 namespace orc {
51 namespace shared {
52 
53 /// Output char buffer with overflow check.
55 public:
56  SPSOutputBuffer(char *Buffer, size_t Remaining)
57  : Buffer(Buffer), Remaining(Remaining) {}
58  bool write(const char *Data, size_t Size) {
59  assert(Data && "Data must not be null");
60  if (Size > Remaining)
61  return false;
62  memcpy(Buffer, Data, Size);
63  Buffer += Size;
64  Remaining -= Size;
65  return true;
66  }
67 
68 private:
69  char *Buffer = nullptr;
70  size_t Remaining = 0;
71 };
72 
73 /// Input char buffer with underflow check.
75 public:
76  SPSInputBuffer() = default;
77  SPSInputBuffer(const char *Buffer, size_t Remaining)
78  : Buffer(Buffer), Remaining(Remaining) {}
79  bool read(char *Data, size_t Size) {
80  if (Size > Remaining)
81  return false;
82  memcpy(Data, Buffer, Size);
83  Buffer += Size;
84  Remaining -= Size;
85  return true;
86  }
87 
88  const char *data() const { return Buffer; }
89  bool skip(size_t Size) {
90  if (Size > Remaining)
91  return false;
92  Buffer += Size;
93  Remaining -= Size;
94  return true;
95  }
96 
97 private:
98  const char *Buffer = nullptr;
99  size_t Remaining = 0;
100 };
101 
102 /// Specialize to describe how to serialize/deserialize to/from the given
103 /// concrete type.
104 template <typename SPSTagT, typename ConcreteT, typename _ = void>
106 
107 /// A utility class for serializing to a blob from a variadic list.
108 template <typename... ArgTs> class SPSArgList;
109 
110 // Empty list specialization for SPSArgList.
111 template <> class SPSArgList<> {
112 public:
113  static size_t size() { return 0; }
114 
115  static bool serialize(SPSOutputBuffer &OB) { return true; }
116  static bool deserialize(SPSInputBuffer &IB) { return true; }
117 
118  static bool serializeToSmallVector(SmallVectorImpl<char> &V) { return true; }
119 
121  return true;
122  }
123 };
124 
125 // Non-empty list specialization for SPSArgList.
126 template <typename SPSTagT, typename... SPSTagTs>
127 class SPSArgList<SPSTagT, SPSTagTs...> {
128 public:
129  // FIXME: This typedef is here to enable SPS arg serialization from
130  // JITLink. It can be removed once JITLink can access SPS directly.
132 
133  template <typename ArgT, typename... ArgTs>
134  static size_t size(const ArgT &Arg, const ArgTs &...Args) {
137  }
138 
139  template <typename ArgT, typename... ArgTs>
140  static bool serialize(SPSOutputBuffer &OB, const ArgT &Arg,
141  const ArgTs &...Args) {
144  }
145 
146  template <typename ArgT, typename... ArgTs>
147  static bool deserialize(SPSInputBuffer &IB, ArgT &Arg, ArgTs &...Args) {
150  }
151 };
152 
153 /// SPS serialization for integral types, bool, and char.
154 template <typename SPSTagT>
156  SPSTagT, SPSTagT,
157  std::enable_if_t<std::is_same<SPSTagT, bool>::value ||
158  std::is_same<SPSTagT, char>::value ||
159  std::is_same<SPSTagT, int8_t>::value ||
160  std::is_same<SPSTagT, int16_t>::value ||
161  std::is_same<SPSTagT, int32_t>::value ||
162  std::is_same<SPSTagT, int64_t>::value ||
163  std::is_same<SPSTagT, uint8_t>::value ||
164  std::is_same<SPSTagT, uint16_t>::value ||
165  std::is_same<SPSTagT, uint32_t>::value ||
166  std::is_same<SPSTagT, uint64_t>::value>> {
167 public:
168  static size_t size(const SPSTagT &Value) { return sizeof(SPSTagT); }
169 
170  static bool serialize(SPSOutputBuffer &OB, const SPSTagT &Value) {
171  SPSTagT Tmp = Value;
173  sys::swapByteOrder(Tmp);
174  return OB.write(reinterpret_cast<const char *>(&Tmp), sizeof(Tmp));
175  }
176 
177  static bool deserialize(SPSInputBuffer &IB, SPSTagT &Value) {
178  SPSTagT Tmp;
179  if (!IB.read(reinterpret_cast<char *>(&Tmp), sizeof(Tmp)))
180  return false;
182  sys::swapByteOrder(Tmp);
183  Value = Tmp;
184  return true;
185  }
186 };
187 
188 // Any empty placeholder suitable as a substitute for void when deserializing
189 class SPSEmpty {};
190 
191 /// SPS tag type for tuples.
192 ///
193 /// A blob tuple should be serialized by serializing each of the elements in
194 /// sequence.
195 template <typename... SPSTagTs> class SPSTuple {
196 public:
197  /// Convenience typedef of the corresponding arg list.
198  typedef SPSArgList<SPSTagTs...> AsArgList;
199 };
200 
201 /// SPS tag type for sequences.
202 ///
203 /// SPSSequences should be serialized as a uint64_t sequence length,
204 /// followed by the serialization of each of the elements.
205 template <typename SPSElementTagT> class SPSSequence;
206 
207 /// SPS tag type for strings, which are equivalent to sequences of chars.
209 
210 /// SPS tag type for maps.
211 ///
212 /// SPS maps are just sequences of (Key, Value) tuples.
213 template <typename SPSTagT1, typename SPSTagT2>
215 
216 /// Serialization for SPSEmpty type.
218 public:
219  static size_t size(const SPSEmpty &EP) { return 0; }
220  static bool serialize(SPSOutputBuffer &OB, const SPSEmpty &BE) {
221  return true;
222  }
223  static bool deserialize(SPSInputBuffer &IB, SPSEmpty &BE) { return true; }
224 };
225 
226 /// Specialize this to implement 'trivial' sequence serialization for
227 /// a concrete sequence type.
228 ///
229 /// Trivial sequence serialization uses the sequence's 'size' member to get the
230 /// length of the sequence, and uses a range-based for loop to iterate over the
231 /// elements.
232 ///
233 /// Specializing this template class means that you do not need to provide a
234 /// specialization of SPSSerializationTraits for your type.
235 template <typename SPSElementTagT, typename ConcreteSequenceT>
237 public:
238  static constexpr bool available = false;
239 };
240 
241 /// Specialize this to implement 'trivial' sequence deserialization for
242 /// a concrete sequence type.
243 ///
244 /// Trivial deserialization calls a static 'reserve(SequenceT&)' method on your
245 /// specialization (you must implement this) to reserve space, and then calls
246 /// a static 'append(SequenceT&, ElementT&) method to append each of the
247 /// deserialized elements.
248 ///
249 /// Specializing this template class means that you do not need to provide a
250 /// specialization of SPSSerializationTraits for your type.
251 template <typename SPSElementTagT, typename ConcreteSequenceT>
253 public:
254  static constexpr bool available = false;
255 };
256 
257 /// Trivial std::string -> SPSSequence<char> serialization.
258 template <> class TrivialSPSSequenceSerialization<char, std::string> {
259 public:
260  static constexpr bool available = true;
261 };
262 
263 /// Trivial SPSSequence<char> -> std::string deserialization.
264 template <> class TrivialSPSSequenceDeserialization<char, std::string> {
265 public:
266  static constexpr bool available = true;
267 
268  using element_type = char;
269 
270  static void reserve(std::string &S, uint64_t Size) { S.reserve(Size); }
271  static bool append(std::string &S, char C) {
272  S.push_back(C);
273  return true;
274  }
275 };
276 
277 /// Trivial std::vector<T> -> SPSSequence<SPSElementTagT> serialization.
278 template <typename SPSElementTagT, typename T>
279 class TrivialSPSSequenceSerialization<SPSElementTagT, std::vector<T>> {
280 public:
281  static constexpr bool available = true;
282 };
283 
284 /// Trivial SPSSequence<SPSElementTagT> -> std::vector<T> deserialization.
285 template <typename SPSElementTagT, typename T>
286 class TrivialSPSSequenceDeserialization<SPSElementTagT, std::vector<T>> {
287 public:
288  static constexpr bool available = true;
289 
290  using element_type = typename std::vector<T>::value_type;
291 
292  static void reserve(std::vector<T> &V, uint64_t Size) { V.reserve(Size); }
293  static bool append(std::vector<T> &V, T E) {
294  V.push_back(std::move(E));
295  return true;
296  }
297 };
298 
299 /// Trivial SmallVectorImpl<T> -> SPSSequence<char> serialization.
300 template <typename SPSElementTagT, typename T>
302 public:
303  static constexpr bool available = true;
304 };
305 
306 /// Trivial SPSSequence<SPSElementTagT> -> SmallVectorImpl<T> deserialization.
307 template <typename SPSElementTagT, typename T>
309 public:
310  static constexpr bool available = true;
311 
313 
314  static void reserve(SmallVectorImpl<T> &V, uint64_t Size) { V.reserve(Size); }
315  static bool append(SmallVectorImpl<T> &V, T E) {
316  V.push_back(std::move(E));
317  return true;
318  }
319 };
320 
321 /// Trivial SmallVectorImpl<T> -> SPSSequence<char> serialization.
322 template <typename SPSElementTagT, typename T, unsigned N>
324  : public TrivialSPSSequenceSerialization<SPSElementTagT,
325  SmallVectorImpl<T>> {};
326 
327 /// Trivial SPSSequence<SPSElementTagT> -> SmallVectorImpl<T> deserialization.
328 template <typename SPSElementTagT, typename T, unsigned N>
330  : public TrivialSPSSequenceDeserialization<SPSElementTagT,
331  SmallVectorImpl<T>> {};
332 
333 /// Trivial ArrayRef<T> -> SPSSequence<SPSElementTagT> serialization.
334 template <typename SPSElementTagT, typename T>
335 class TrivialSPSSequenceSerialization<SPSElementTagT, ArrayRef<T>> {
336 public:
337  static constexpr bool available = true;
338 };
339 
340 /// Specialized SPSSequence<char> -> ArrayRef<char> serialization.
341 ///
342 /// On deserialize, points directly into the input buffer.
343 template <> class SPSSerializationTraits<SPSSequence<char>, ArrayRef<char>> {
344 public:
345  static size_t size(const ArrayRef<char> &A) {
346  return SPSArgList<uint64_t>::size(static_cast<uint64_t>(A.size())) +
347  A.size();
348  }
349 
350  static bool serialize(SPSOutputBuffer &OB, const ArrayRef<char> &A) {
351  if (!SPSArgList<uint64_t>::serialize(OB, static_cast<uint64_t>(A.size())))
352  return false;
353  if (A.empty()) // Empty ArrayRef may have null data, so bail out early.
354  return true;
355  return OB.write(A.data(), A.size());
356  }
357 
359  uint64_t Size;
360  if (!SPSArgList<uint64_t>::deserialize(IB, Size))
361  return false;
363  return false;
364  A = {Size ? IB.data() : nullptr, static_cast<size_t>(Size)};
365  return IB.skip(Size);
366  }
367 };
368 
369 /// 'Trivial' sequence serialization: Sequence is serialized as a uint64_t size
370 /// followed by a for-earch loop over the elements of the sequence to serialize
371 /// each of them.
372 template <typename SPSElementTagT, typename SequenceT>
373 class SPSSerializationTraits<SPSSequence<SPSElementTagT>, SequenceT,
374  std::enable_if_t<TrivialSPSSequenceSerialization<
375  SPSElementTagT, SequenceT>::available>> {
376 public:
377  static size_t size(const SequenceT &S) {
378  size_t Size = SPSArgList<uint64_t>::size(static_cast<uint64_t>(S.size()));
379  for (const auto &E : S)
381  return Size;
382  }
383 
384  static bool serialize(SPSOutputBuffer &OB, const SequenceT &S) {
385  if (!SPSArgList<uint64_t>::serialize(OB, static_cast<uint64_t>(S.size())))
386  return false;
387  for (const auto &E : S)
389  return false;
390  return true;
391  }
392 
393  static bool deserialize(SPSInputBuffer &IB, SequenceT &S) {
395  uint64_t Size;
396  if (!SPSArgList<uint64_t>::deserialize(IB, Size))
397  return false;
398  TBSD::reserve(S, Size);
399  for (size_t I = 0; I != Size; ++I) {
400  typename TBSD::element_type E;
402  return false;
403  if (!TBSD::append(S, std::move(E)))
404  return false;
405  }
406  return true;
407  }
408 };
409 
410 /// SPSTuple serialization for std::tuple.
411 template <typename... SPSTagTs, typename... Ts>
412 class SPSSerializationTraits<SPSTuple<SPSTagTs...>, std::tuple<Ts...>> {
413 private:
414  using TupleArgList = typename SPSTuple<SPSTagTs...>::AsArgList;
415  using ArgIndices = std::make_index_sequence<sizeof...(Ts)>;
416 
417  template <std::size_t... I>
418  static size_t size(const std::tuple<Ts...> &T, std::index_sequence<I...>) {
419  return TupleArgList::size(std::get<I>(T)...);
420  }
421 
422  template <std::size_t... I>
423  static bool serialize(SPSOutputBuffer &OB, const std::tuple<Ts...> &T,
424  std::index_sequence<I...>) {
425  return TupleArgList::serialize(OB, std::get<I>(T)...);
426  }
427 
428  template <std::size_t... I>
429  static bool deserialize(SPSInputBuffer &IB, std::tuple<Ts...> &T,
430  std::index_sequence<I...>) {
431  return TupleArgList::deserialize(IB, std::get<I>(T)...);
432  }
433 
434 public:
435  static size_t size(const std::tuple<Ts...> &T) {
436  return size(T, ArgIndices{});
437  }
438 
439  static bool serialize(SPSOutputBuffer &OB, const std::tuple<Ts...> &T) {
440  return serialize(OB, T, ArgIndices{});
441  }
442 
443  static bool deserialize(SPSInputBuffer &IB, std::tuple<Ts...> &T) {
444  return deserialize(IB, T, ArgIndices{});
445  }
446 };
447 
448 /// SPSTuple serialization for std::pair.
449 template <typename SPSTagT1, typename SPSTagT2, typename T1, typename T2>
450 class SPSSerializationTraits<SPSTuple<SPSTagT1, SPSTagT2>, std::pair<T1, T2>> {
451 public:
452  static size_t size(const std::pair<T1, T2> &P) {
453  return SPSArgList<SPSTagT1>::size(P.first) +
455  }
456 
457  static bool serialize(SPSOutputBuffer &OB, const std::pair<T1, T2> &P) {
458  return SPSArgList<SPSTagT1>::serialize(OB, P.first) &&
460  }
461 
462  static bool deserialize(SPSInputBuffer &IB, std::pair<T1, T2> &P) {
463  return SPSArgList<SPSTagT1>::deserialize(IB, P.first) &&
465  }
466 };
467 
468 /// Serialization for StringRefs.
469 ///
470 /// Serialization is as for regular strings. Deserialization points directly
471 /// into the blob.
473 public:
474  static size_t size(const StringRef &S) {
475  return SPSArgList<uint64_t>::size(static_cast<uint64_t>(S.size())) +
476  S.size();
477  }
478 
480  if (!SPSArgList<uint64_t>::serialize(OB, static_cast<uint64_t>(S.size())))
481  return false;
482  if (S.empty()) // Empty StringRef may have null data, so bail out early.
483  return true;
484  return OB.write(S.data(), S.size());
485  }
486 
487  static bool deserialize(SPSInputBuffer &IB, StringRef &S) {
488  const char *Data = nullptr;
489  uint64_t Size;
490  if (!SPSArgList<uint64_t>::deserialize(IB, Size))
491  return false;
492  Data = IB.data();
493  if (!IB.skip(Size))
494  return false;
495  S = StringRef(Size ? Data : nullptr, Size);
496  return true;
497  }
498 };
499 
500 /// Serialization for StringMap<ValueT>s.
501 template <typename SPSValueT, typename ValueT>
503  StringMap<ValueT>> {
504 public:
505  static size_t size(const StringMap<ValueT> &M) {
506  size_t Sz = SPSArgList<uint64_t>::size(static_cast<uint64_t>(M.size()));
507  for (auto &E : M)
508  Sz += SPSArgList<SPSString, SPSValueT>::size(E.first(), E.second);
509  return Sz;
510  }
511 
512  static bool serialize(SPSOutputBuffer &OB, const StringMap<ValueT> &M) {
513  if (!SPSArgList<uint64_t>::serialize(OB, static_cast<uint64_t>(M.size())))
514  return false;
515 
516  for (auto &E : M)
517  if (!SPSArgList<SPSString, SPSValueT>::serialize(OB, E.first(), E.second))
518  return false;
519 
520  return true;
521  }
522 
524  uint64_t Size;
525  assert(M.empty() && "M already contains elements");
526 
527  if (!SPSArgList<uint64_t>::deserialize(IB, Size))
528  return false;
529 
530  while (Size--) {
531  StringRef S;
532  ValueT V;
534  return false;
535  if (!M.insert(std::make_pair(S, V)).second)
536  return false;
537  }
538 
539  return true;
540  }
541 };
542 
543 /// SPS tag type for errors.
544 class SPSError;
545 
546 /// SPS tag type for expecteds, which are either a T or a string representing
547 /// an error.
548 template <typename SPSTagT> class SPSExpected;
549 
550 namespace detail {
551 
552 /// Helper type for serializing Errors.
553 ///
554 /// llvm::Errors are move-only, and not inspectable except by consuming them.
555 /// This makes them unsuitable for direct serialization via
556 /// SPSSerializationTraits, which needs to inspect values twice (once to
557 /// determine the amount of space to reserve, and then again to serialize).
558 ///
559 /// The SPSSerializableError type is a helper that can be
560 /// constructed from an llvm::Error, but inspected more than once.
562  bool HasError = false;
563  std::string ErrMsg;
564 };
565 
566 /// Helper type for serializing Expected<T>s.
567 ///
568 /// See SPSSerializableError for more details.
569 ///
570 // FIXME: Use std::variant for storage once we have c++17.
571 template <typename T> struct SPSSerializableExpected {
572  bool HasValue = false;
573  T Value{};
574  std::string ErrMsg;
575 };
576 
578  if (Err)
579  return {true, toString(std::move(Err))};
580  return {false, {}};
581 }
582 
584  if (BSE.HasError)
585  return make_error<StringError>(BSE.ErrMsg, inconvertibleErrorCode());
586  return Error::success();
587 }
588 
589 template <typename T>
591  if (E)
592  return {true, std::move(*E), {}};
593  else
594  return {false, T(), toString(E.takeError())};
595 }
596 
597 template <typename T>
599  if (BSE.HasValue)
600  return std::move(BSE.Value);
601  else
602  return make_error<StringError>(BSE.ErrMsg, inconvertibleErrorCode());
603 }
604 
605 } // end namespace detail
606 
607 /// Serialize to a SPSError from a detail::SPSSerializableError.
608 template <>
609 class SPSSerializationTraits<SPSError, detail::SPSSerializableError> {
610 public:
611  static size_t size(const detail::SPSSerializableError &BSE) {
612  size_t Size = SPSArgList<bool>::size(BSE.HasError);
613  if (BSE.HasError)
614  Size += SPSArgList<SPSString>::size(BSE.ErrMsg);
615  return Size;
616  }
617 
619  const detail::SPSSerializableError &BSE) {
621  return false;
622  if (BSE.HasError)
624  return false;
625  return true;
626  }
627 
628  static bool deserialize(SPSInputBuffer &IB,
631  return false;
632 
633  if (!BSE.HasError)
634  return true;
635 
637  }
638 };
639 
640 /// Serialize to a SPSExpected<SPSTagT> from a
641 /// detail::SPSSerializableExpected<T>.
642 template <typename SPSTagT, typename T>
644  detail::SPSSerializableExpected<T>> {
645 public:
646  static size_t size(const detail::SPSSerializableExpected<T> &BSE) {
647  size_t Size = SPSArgList<bool>::size(BSE.HasValue);
648  if (BSE.HasValue)
649  Size += SPSArgList<SPSTagT>::size(BSE.Value);
650  else
651  Size += SPSArgList<SPSString>::size(BSE.ErrMsg);
652  return Size;
653  }
654 
658  return false;
659 
660  if (BSE.HasValue)
662 
664  }
665 
666  static bool deserialize(SPSInputBuffer &IB,
669  return false;
670 
671  if (BSE.HasValue)
672  return SPSArgList<SPSTagT>::deserialize(IB, BSE.Value);
673 
675  }
676 };
677 
678 /// Serialize to a SPSExpected<SPSTagT> from a detail::SPSSerializableError.
679 template <typename SPSTagT>
681  detail::SPSSerializableError> {
682 public:
683  static size_t size(const detail::SPSSerializableError &BSE) {
684  assert(BSE.HasError && "Cannot serialize expected from a success value");
685  return SPSArgList<bool>::size(false) +
687  }
688 
690  const detail::SPSSerializableError &BSE) {
691  assert(BSE.HasError && "Cannot serialize expected from a success value");
692  if (!SPSArgList<bool>::serialize(OB, false))
693  return false;
695  }
696 };
697 
698 /// Serialize to a SPSExpected<SPSTagT> from a T.
699 template <typename SPSTagT, typename T>
701 public:
702  static size_t size(const T &Value) {
704  }
705 
706  static bool serialize(SPSOutputBuffer &OB, const T &Value) {
707  if (!SPSArgList<bool>::serialize(OB, true))
708  return false;
710  }
711 };
712 
713 } // end namespace shared
714 } // end namespace orc
715 } // end namespace llvm
716 
717 #endif // LLVM_EXECUTIONENGINE_ORC_SHARED_SIMPLEPACKEDSERIALIZATION_H
llvm::orc::shared::SPSSerializationTraits< SPSExpected< SPSTagT >, detail::SPSSerializableExpected< T > >::serialize
static bool serialize(SPSOutputBuffer &OB, const detail::SPSSerializableExpected< T > &BSE)
Definition: SimplePackedSerialization.h:655
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
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:205
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:236
llvm::orc::shared::SPSSerializationTraits
Specialize to describe how to serialize/deserialize to/from the given concrete type.
Definition: SimplePackedSerialization.h:105
llvm::orc::shared::TrivialSPSSequenceDeserialization< SPSElementTagT, std::vector< T > >::reserve
static void reserve(std::vector< T > &V, uint64_t Size)
Definition: SimplePackedSerialization.h:292
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::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1182
llvm::orc::shared::SPSOutputBuffer
Output char buffer with overflow check.
Definition: SimplePackedSerialization.h:54
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:329
llvm::orc::shared::SPSSerializationTraits< SPSSequence< SPSTuple< SPSString, SPSValueT > >, StringMap< ValueT > >::deserialize
static bool deserialize(SPSInputBuffer &IB, StringMap< ValueT > &M)
Definition: SimplePackedSerialization.h:523
Error.h
SwapByteOrder.h
llvm::orc::shared::SPSArgList<>::serialize
static bool serialize(SPSOutputBuffer &OB)
Definition: SimplePackedSerialization.h:115
llvm::orc::shared::SPSSerializationTraits< SPSTuple< SPSTagTs... >, std::tuple< Ts... > >::size
static size_t size(const std::tuple< Ts... > &T)
Definition: SimplePackedSerialization.h:435
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:457
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:350
llvm::orc::shared::SPSInputBuffer
Input char buffer with underflow check.
Definition: SimplePackedSerialization.h:74
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:377
llvm::max
Expected< ExpressionValue > max(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
Definition: FileCheck.cpp:337
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:41
STLExtras.h
llvm::orc::shared::SPSSerializationTraits< SPSSequence< char >, ArrayRef< char > >::deserialize
static bool deserialize(SPSInputBuffer &IB, ArrayRef< char > &A)
Definition: SimplePackedSerialization.h:358
llvm::orc::shared::SPSTuple
SPS tag type for tuples.
Definition: SimplePackedSerialization.h:195
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:505
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
llvm::X86II::OB
@ OB
Definition: X86BaseInfo.h:801
Arg
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Definition: AMDGPULibCalls.cpp:186
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:134
llvm::orc::shared::TrivialSPSSequenceDeserialization< SPSElementTagT, std::vector< T > >::element_type
typename std::vector< T >::value_type element_type
Definition: SimplePackedSerialization.h:290
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:462
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::orc::shared::detail::fromSPSSerializable
Error fromSPSSerializable(SPSSerializableError BSE)
Definition: SimplePackedSerialization.h:583
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: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 > >::deserialize
static bool deserialize(SPSInputBuffer &IB, SPSTagT &Value)
Definition: SimplePackedSerialization.h:177
llvm::orc::shared::SPSOutputBuffer::write
bool write(const char *Data, size_t Size)
Definition: SimplePackedSerialization.h:58
llvm::orc::shared::SPSEmpty
Definition: SimplePackedSerialization.h:189
llvm::orc::shared::SPSSerializationTraits< SPSExpected< SPSTagT >, detail::SPSSerializableError >::size
static size_t size(const detail::SPSSerializableError &BSE)
Definition: SimplePackedSerialization.h:683
llvm::orc::shared::TrivialSPSSequenceDeserialization< SPSElementTagT, SmallVectorImpl< T > >::append
static bool append(SmallVectorImpl< T > &V, T E)
Definition: SimplePackedSerialization.h:315
llvm::orc::shared::TrivialSPSSequenceDeserialization< SPSElementTagT, SmallVectorImpl< T > >::reserve
static void reserve(SmallVectorImpl< T > &V, uint64_t Size)
Definition: SimplePackedSerialization.h:314
llvm::orc::shared::SPSSerializationTraits< SPSSequence< char >, ArrayRef< char > >::size
static size_t size(const ArrayRef< char > &A)
Definition: SimplePackedSerialization.h:345
llvm::orc::shared::SPSSerializationTraits< SPSString, StringRef >::size
static size_t size(const StringRef &S)
Definition: SimplePackedSerialization.h:474
llvm::orc::shared::SPSInputBuffer::read
bool read(char *Data, size_t Size)
Definition: SimplePackedSerialization.h:79
llvm::orc::shared::TrivialSPSSequenceDeserialization< char, std::string >::append
static bool append(std::string &S, char C)
Definition: SimplePackedSerialization.h:271
llvm::orc::shared::SPSOutputBuffer::SPSOutputBuffer
SPSOutputBuffer(char *Buffer, size_t Remaining)
Definition: SimplePackedSerialization.h:56
llvm::orc::shared::SPSSerializationTraits< SPSError, detail::SPSSerializableError >::size
static size_t size(const detail::SPSSerializableError &BSE)
Definition: SimplePackedSerialization.h:611
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:168
llvm::orc::shared::SPSArgList<>::deserialize
static bool deserialize(SPSInputBuffer &IB)
Definition: SimplePackedSerialization.h:116
llvm::StringMap
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition: StringMap.h:110
llvm::orc::shared::SPSArgList< SPSTagT, SPSTagTs... >::deserialize
static bool deserialize(SPSInputBuffer &IB, ArgT &Arg, ArgTs &...Args)
Definition: SimplePackedSerialization.h:147
llvm::orc::shared::TrivialSPSSequenceDeserialization::available
static constexpr bool available
Definition: SimplePackedSerialization.h:254
llvm::orc::shared::SPSSerializationTraits< SPSExpected< SPSTagT >, T >::serialize
static bool serialize(SPSOutputBuffer &OB, const T &Value)
Definition: SimplePackedSerialization.h:706
llvm::orc::shared::SPSSerializationTraits< SPSString, StringRef >::serialize
static bool serialize(SPSOutputBuffer &OB, StringRef S)
Definition: SimplePackedSerialization.h:479
llvm::orc::shared::TrivialSPSSequenceSerialization::available
static constexpr bool available
Definition: SimplePackedSerialization.h:238
llvm::orc::shared::SPSSerializationTraits< SPSExpected< SPSTagT >, T >::size
static size_t size(const T &Value)
Definition: SimplePackedSerialization.h:702
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:170
llvm::orc::shared::SPSSerializationTraits< SPSEmpty, SPSEmpty >::deserialize
static bool deserialize(SPSInputBuffer &IB, SPSEmpty &BE)
Definition: SimplePackedSerialization.h:223
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:548
llvm::orc::shared::SPSSerializationTraits< SPSExpected< SPSTagT >, detail::SPSSerializableError >::serialize
static bool serialize(SPSOutputBuffer &OB, const detail::SPSSerializableError &BSE)
Definition: SimplePackedSerialization.h:689
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::orc::shared::detail::SPSSerializableError::HasError
bool HasError
Definition: SimplePackedSerialization.h:562
llvm::orc::shared::SPSInputBuffer::data
const char * data() const
Definition: SimplePackedSerialization.h:88
llvm::orc::shared::TrivialSPSSequenceDeserialization< char, std::string >::element_type
char element_type
Definition: SimplePackedSerialization.h:268
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:384
llvm::orc::shared::SPSArgList<>::deserializeFromSmallVector
static bool deserializeFromSmallVector(const SmallVectorImpl< char > &V)
Definition: SimplePackedSerialization.h:120
llvm::orc::shared::SPSSerializationTraits< SPSError, detail::SPSSerializableError >::deserialize
static bool deserialize(SPSInputBuffer &IB, detail::SPSSerializableError &BSE)
Definition: SimplePackedSerialization.h:628
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:574
llvm::orc::shared::TrivialSPSSequenceDeserialization< SPSElementTagT, SmallVectorImpl< T > >::element_type
typename SmallVectorImpl< T >::value_type element_type
Definition: SimplePackedSerialization.h:312
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:1571
llvm::orc::shared::SPSSerializationTraits< SPSExpected< SPSTagT >, detail::SPSSerializableExpected< T > >::deserialize
static bool deserialize(SPSInputBuffer &IB, detail::SPSSerializableExpected< T > &BSE)
Definition: SimplePackedSerialization.h:666
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:50
llvm::orc::shared::SPSArgList< SPSTagT, SPSTagTs... >::serialize
static bool serialize(SPSOutputBuffer &OB, const ArgT &Arg, const ArgTs &...Args)
Definition: SimplePackedSerialization.h:140
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:198
llvm::orc::shared::SPSSerializationTraits< SPSSequence< SPSTuple< SPSString, SPSValueT > >, StringMap< ValueT > >::serialize
static bool serialize(SPSOutputBuffer &OB, const StringMap< ValueT > &M)
Definition: SimplePackedSerialization.h:512
std
Definition: BitVector.h:851
llvm::orc::shared::TrivialSPSSequenceDeserialization< SPSElementTagT, std::vector< T > >::append
static bool append(std::vector< T > &V, T E)
Definition: SimplePackedSerialization.h:293
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:79
llvm::orc::shared::SPSInputBuffer::SPSInputBuffer
SPSInputBuffer(const char *Buffer, size_t Remaining)
Definition: SimplePackedSerialization.h:77
llvm::orc::shared::detail::SPSSerializableError::ErrMsg
std::string ErrMsg
Definition: SimplePackedSerialization.h:563
llvm::orc::shared::SPSSerializationTraits< SPSString, StringRef >::deserialize
static bool deserialize(SPSInputBuffer &IB, StringRef &S)
Definition: SimplePackedSerialization.h:487
llvm::toString
const char * toString(DWARFSectionKind Kind)
Definition: DWARFUnitIndex.h:67
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
llvm::orc::shared::TrivialSPSSequenceDeserialization
Specialize this to implement 'trivial' sequence deserialization for a concrete sequence type.
Definition: SimplePackedSerialization.h:252
llvm::orc::shared::detail::toSPSSerializable
SPSSerializableError toSPSSerializable(Error Err)
Definition: SimplePackedSerialization.h:577
llvm::orc::shared::SPSSerializationTraits< SPSError, detail::SPSSerializableError >::serialize
static bool serialize(SPSOutputBuffer &OB, const detail::SPSSerializableError &BSE)
Definition: SimplePackedSerialization.h:618
llvm::TargetStackID::Value
Value
Definition: TargetFrameLowering.h:27
llvm::orc::shared::SPSArgList<>::serializeToSmallVector
static bool serializeToSmallVector(SmallVectorImpl< char > &V)
Definition: SimplePackedSerialization.h:118
llvm::orc::shared::detail::SPSSerializableExpected::HasValue
bool HasValue
Definition: SimplePackedSerialization.h:572
llvm::orc::shared::detail::SPSSerializableExpected
Helper type for serializing Expected<T>s.
Definition: SimplePackedSerialization.h:571
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:393
llvm::orc::shared::SPSSerializationTraits< SPSTuple< SPSTagTs... >, std::tuple< Ts... > >::deserialize
static bool deserialize(SPSInputBuffer &IB, std::tuple< Ts... > &T)
Definition: SimplePackedSerialization.h:443
llvm::orc::shared::SPSSerializationTraits< SPSExpected< SPSTagT >, detail::SPSSerializableExpected< T > >::size
static size_t size(const detail::SPSSerializableExpected< T > &BSE)
Definition: SimplePackedSerialization.h:646
SmallVector.h
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:452
N
#define N
llvm::orc::shared::detail::SPSSerializableExpected::Value
T Value
Definition: SimplePackedSerialization.h:573
llvm::orc::shared::TrivialSPSSequenceDeserialization< char, std::string >::reserve
static void reserve(std::string &S, uint64_t Size)
Definition: SimplePackedSerialization.h:270
llvm::SmallVectorImpl< char >
llvm::orc::shared::SPSArgList<>::size
static size_t size()
Definition: SimplePackedSerialization.h:113
StringMap.h
llvm::AMDGPU::HSAMD::Kernel::Key::Args
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Definition: AMDGPUMetadata.h:394
llvm::orc::shared::SPSInputBuffer::skip
bool skip(size_t Size)
Definition: SimplePackedSerialization.h:89
llvm::orc::shared::SPSSerializationTraits< SPSTuple< SPSTagTs... >, std::tuple< Ts... > >::serialize
static bool serialize(SPSOutputBuffer &OB, const std::tuple< Ts... > &T)
Definition: SimplePackedSerialization.h:439
llvm::SmallVectorImpl::reserve
void reserve(size_type N)
Definition: SmallVector.h:650
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:108
SpecialSubKind::string
@ string
llvm::orc::shared::SPSSerializationTraits< SPSEmpty, SPSEmpty >::size
static size_t size(const SPSEmpty &EP)
Definition: SimplePackedSerialization.h:219
llvm::orc::shared::SPSSerializationTraits< SPSEmpty, SPSEmpty >::serialize
static bool serialize(SPSOutputBuffer &OB, const SPSEmpty &BE)
Definition: SimplePackedSerialization.h:220