Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/Support/Endian.h
Line
Count
Source (jump to first uncovered line)
1
//===- Endian.h - Utilities for IO with endian specific data ----*- 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
// This file declares generic functions to read and write endian specific data.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#ifndef LLVM_SUPPORT_ENDIAN_H
14
#define LLVM_SUPPORT_ENDIAN_H
15
16
#include "llvm/Support/AlignOf.h"
17
#include "llvm/Support/Compiler.h"
18
#include "llvm/Support/Host.h"
19
#include "llvm/Support/SwapByteOrder.h"
20
#include <cassert>
21
#include <cstddef>
22
#include <cstdint>
23
#include <cstring>
24
#include <type_traits>
25
26
namespace llvm {
27
namespace support {
28
29
enum endianness {big, little, native};
30
31
// These are named values for common alignments.
32
enum {aligned = 0, unaligned = 1};
33
34
namespace detail {
35
36
/// ::value is either alignment, or alignof(T) if alignment is 0.
37
template<class T, int alignment>
38
struct PickAlignment {
39
 enum { value = alignment == 0 ? alignof(T) : alignment };
40
};
41
42
} // end namespace detail
43
44
namespace endian {
45
46
231M
constexpr endianness system_endianness() {
47
231M
  return sys::IsBigEndianHost ? 
big0
: little;
48
231M
}
49
50
template <typename value_type>
51
231M
inline value_type byte_swap(value_type value, endianness endian) {
52
231M
  if ((endian != native) && 
(endian != system_endianness())231M
)
53
996k
    sys::swapByteOrder(value);
54
231M
  return value;
55
231M
}
unsigned short llvm::support::endian::byte_swap<unsigned short>(unsigned short, llvm::support::endianness)
Line
Count
Source
51
47.4M
inline value_type byte_swap(value_type value, endianness endian) {
52
47.4M
  if ((endian != native) && 
(endian != system_endianness())47.4M
)
53
218k
    sys::swapByteOrder(value);
54
47.4M
  return value;
55
47.4M
}
unsigned int llvm::support::endian::byte_swap<unsigned int>(unsigned int, llvm::support::endianness)
Line
Count
Source
51
114M
inline value_type byte_swap(value_type value, endianness endian) {
52
114M
  if ((endian != native) && 
(endian != system_endianness())114M
)
53
394k
    sys::swapByteOrder(value);
54
114M
  return value;
55
114M
}
unsigned long long llvm::support::endian::byte_swap<unsigned long long>(unsigned long long, llvm::support::endianness)
Line
Count
Source
51
33.5M
inline value_type byte_swap(value_type value, endianness endian) {
52
33.5M
  if ((endian != native) && 
(endian != system_endianness())33.5M
)
53
263k
    sys::swapByteOrder(value);
54
33.5M
  return value;
55
33.5M
}
unsigned char llvm::support::endian::byte_swap<unsigned char>(unsigned char, llvm::support::endianness)
Line
Count
Source
51
411k
inline value_type byte_swap(value_type value, endianness endian) {
52
411k
  if ((endian != native) && 
(endian != system_endianness())411k
)
53
100k
    sys::swapByteOrder(value);
54
411k
  return value;
55
411k
}
int llvm::support::endian::byte_swap<int>(int, llvm::support::endianness)
Line
Count
Source
51
29.8k
inline value_type byte_swap(value_type value, endianness endian) {
52
29.8k
  if ((endian != native) && 
(endian != system_endianness())29.7k
)
53
6.19k
    sys::swapByteOrder(value);
54
29.8k
  return value;
55
29.8k
}
char llvm::support::endian::byte_swap<char>(char, llvm::support::endianness)
Line
Count
Source
51
3.67k
inline value_type byte_swap(value_type value, endianness endian) {
52
3.67k
  if ((endian != native) && 
(endian != system_endianness())2.52k
)
53
0
    sys::swapByteOrder(value);
54
3.67k
  return value;
55
3.67k
}
unsigned long llvm::support::endian::byte_swap<unsigned long>(unsigned long, llvm::support::endianness)
Line
Count
Source
51
36.2M
inline value_type byte_swap(value_type value, endianness endian) {
52
36.2M
  if (
(endian != native)36.2M
&& (endian != system_endianness()))
53
4
    sys::swapByteOrder(value);
54
36.2M
  return value;
55
36.2M
}
long long llvm::support::endian::byte_swap<long long>(long long, llvm::support::endianness)
Line
Count
Source
51
64.7k
inline value_type byte_swap(value_type value, endianness endian) {
52
64.7k
  if ((endian != native) && 
(endian != system_endianness())64.7k
)
53
13.7k
    sys::swapByteOrder(value);
54
64.7k
  return value;
55
64.7k
}
llvm::minidump::StreamType llvm::support::endian::byte_swap<llvm::minidump::StreamType>(llvm::minidump::StreamType, llvm::support::endianness)
Line
Count
Source
51
55
inline value_type byte_swap(value_type value, endianness endian) {
52
55
  if ((endian != native) && (endian != system_endianness()))
53
0
    sys::swapByteOrder(value);
54
55
  return value;
55
55
}
short llvm::support::endian::byte_swap<short>(short, llvm::support::endianness)
Line
Count
Source
51
3.05k
inline value_type byte_swap(value_type value, endianness endian) {
52
3.05k
  if ((endian != native) && 
(endian != system_endianness())3.04k
)
53
23
    sys::swapByteOrder(value);
54
3.05k
  return value;
55
3.05k
}
signed char llvm::support::endian::byte_swap<signed char>(signed char, llvm::support::endianness)
Line
Count
Source
51
60
inline value_type byte_swap(value_type value, endianness endian) {
52
60
  if ((endian != native) && (endian != system_endianness()))
53
56
    sys::swapByteOrder(value);
54
60
  return value;
55
60
}
56
57
/// Swap the bytes of value to match the given endianness.
58
template<typename value_type, endianness endian>
59
31.3M
inline value_type byte_swap(value_type value) {
60
31.3M
  return byte_swap(value, endian);
61
31.3M
}
unsigned int llvm::support::endian::byte_swap<unsigned int, (llvm::support::endianness)1>(unsigned int)
Line
Count
Source
59
31.2M
inline value_type byte_swap(value_type value) {
60
31.2M
  return byte_swap(value, endian);
61
31.2M
}
unsigned long long llvm::support::endian::byte_swap<unsigned long long, (llvm::support::endianness)1>(unsigned long long)
Line
Count
Source
59
41.7k
inline value_type byte_swap(value_type value) {
60
41.7k
  return byte_swap(value, endian);
61
41.7k
}
unsigned int llvm::support::endian::byte_swap<unsigned int, (llvm::support::endianness)0>(unsigned int)
Line
Count
Source
59
5.62k
inline value_type byte_swap(value_type value) {
60
5.62k
  return byte_swap(value, endian);
61
5.62k
}
unsigned long long llvm::support::endian::byte_swap<unsigned long long, (llvm::support::endianness)0>(unsigned long long)
Line
Count
Source
59
1.60k
inline value_type byte_swap(value_type value) {
60
1.60k
  return byte_swap(value, endian);
61
1.60k
}
62
63
/// Read a value of a particular endianness from memory.
64
template <typename value_type, std::size_t alignment>
65
103M
inline value_type read(const void *memory, endianness endian) {
66
103M
  value_type ret;
67
103M
68
103M
  memcpy(&ret,
69
103M
         LLVM_ASSUME_ALIGNED(
70
103M
             memory, (detail::PickAlignment<value_type, alignment>::value)),
71
103M
         sizeof(value_type));
72
103M
  return byte_swap<value_type>(ret, endian);
73
103M
}
unsigned short llvm::support::endian::read<unsigned short, 1ul>(void const*, llvm::support::endianness)
Line
Count
Source
65
17.5M
inline value_type read(const void *memory, endianness endian) {
66
17.5M
  value_type ret;
67
17.5M
68
17.5M
  memcpy(&ret,
69
17.5M
         LLVM_ASSUME_ALIGNED(
70
17.5M
             memory, (detail::PickAlignment<value_type, alignment>::value)),
71
17.5M
         sizeof(value_type));
72
17.5M
  return byte_swap<value_type>(ret, endian);
73
17.5M
}
unsigned int llvm::support::endian::read<unsigned int, 1ul>(void const*, llvm::support::endianness)
Line
Count
Source
65
23.0M
inline value_type read(const void *memory, endianness endian) {
66
23.0M
  value_type ret;
67
23.0M
68
23.0M
  memcpy(&ret,
69
23.0M
         LLVM_ASSUME_ALIGNED(
70
23.0M
             memory, (detail::PickAlignment<value_type, alignment>::value)),
71
23.0M
         sizeof(value_type));
72
23.0M
  return byte_swap<value_type>(ret, endian);
73
23.0M
}
unsigned long long llvm::support::endian::read<unsigned long long, 1ul>(void const*, llvm::support::endianness)
Line
Count
Source
65
24.2M
inline value_type read(const void *memory, endianness endian) {
66
24.2M
  value_type ret;
67
24.2M
68
24.2M
  memcpy(&ret,
69
24.2M
         LLVM_ASSUME_ALIGNED(
70
24.2M
             memory, (detail::PickAlignment<value_type, alignment>::value)),
71
24.2M
         sizeof(value_type));
72
24.2M
  return byte_swap<value_type>(ret, endian);
73
24.2M
}
unsigned char llvm::support::endian::read<unsigned char, 1ul>(void const*, llvm::support::endianness)
Line
Count
Source
65
20.0k
inline value_type read(const void *memory, endianness endian) {
66
20.0k
  value_type ret;
67
20.0k
68
20.0k
  memcpy(&ret,
69
20.0k
         LLVM_ASSUME_ALIGNED(
70
20.0k
             memory, (detail::PickAlignment<value_type, alignment>::value)),
71
20.0k
         sizeof(value_type));
72
20.0k
  return byte_swap<value_type>(ret, endian);
73
20.0k
}
unsigned long llvm::support::endian::read<unsigned long, 1ul>(void const*, llvm::support::endianness)
Line
Count
Source
65
36.2M
inline value_type read(const void *memory, endianness endian) {
66
36.2M
  value_type ret;
67
36.2M
68
36.2M
  memcpy(&ret,
69
36.2M
         LLVM_ASSUME_ALIGNED(
70
36.2M
             memory, (detail::PickAlignment<value_type, alignment>::value)),
71
36.2M
         sizeof(value_type));
72
36.2M
  return byte_swap<value_type>(ret, endian);
73
36.2M
}
unsigned int llvm::support::endian::read<unsigned int, 0ul>(void const*, llvm::support::endianness)
Line
Count
Source
65
1.87M
inline value_type read(const void *memory, endianness endian) {
66
1.87M
  value_type ret;
67
1.87M
68
1.87M
  memcpy(&ret,
69
1.87M
         LLVM_ASSUME_ALIGNED(
70
1.87M
             memory, (detail::PickAlignment<value_type, alignment>::value)),
71
1.87M
         sizeof(value_type));
72
1.87M
  return byte_swap<value_type>(ret, endian);
73
1.87M
}
unsigned long long llvm::support::endian::read<unsigned long long, 0ul>(void const*, llvm::support::endianness)
Line
Count
Source
65
2.65k
inline value_type read(const void *memory, endianness endian) {
66
2.65k
  value_type ret;
67
2.65k
68
2.65k
  memcpy(&ret,
69
2.65k
         LLVM_ASSUME_ALIGNED(
70
2.65k
             memory, (detail::PickAlignment<value_type, alignment>::value)),
71
2.65k
         sizeof(value_type));
72
2.65k
  return byte_swap<value_type>(ret, endian);
73
2.65k
}
int llvm::support::endian::read<int, 1ul>(void const*, llvm::support::endianness)
Line
Count
Source
65
20.6k
inline value_type read(const void *memory, endianness endian) {
66
20.6k
  value_type ret;
67
20.6k
68
20.6k
  memcpy(&ret,
69
20.6k
         LLVM_ASSUME_ALIGNED(
70
20.6k
             memory, (detail::PickAlignment<value_type, alignment>::value)),
71
20.6k
         sizeof(value_type));
72
20.6k
  return byte_swap<value_type>(ret, endian);
73
20.6k
}
long long llvm::support::endian::read<long long, 1ul>(void const*, llvm::support::endianness)
Line
Count
Source
65
53.7k
inline value_type read(const void *memory, endianness endian) {
66
53.7k
  value_type ret;
67
53.7k
68
53.7k
  memcpy(&ret,
69
53.7k
         LLVM_ASSUME_ALIGNED(
70
53.7k
             memory, (detail::PickAlignment<value_type, alignment>::value)),
71
53.7k
         sizeof(value_type));
72
53.7k
  return byte_swap<value_type>(ret, endian);
73
53.7k
}
llvm::minidump::StreamType llvm::support::endian::read<llvm::minidump::StreamType, 1ul>(void const*, llvm::support::endianness)
Line
Count
Source
65
43
inline value_type read(const void *memory, endianness endian) {
66
43
  value_type ret;
67
43
68
43
  memcpy(&ret,
69
43
         LLVM_ASSUME_ALIGNED(
70
43
             memory, (detail::PickAlignment<value_type, alignment>::value)),
71
43
         sizeof(value_type));
72
43
  return byte_swap<value_type>(ret, endian);
73
43
}
short llvm::support::endian::read<short, 1ul>(void const*, llvm::support::endianness)
Line
Count
Source
65
31
inline value_type read(const void *memory, endianness endian) {
66
31
  value_type ret;
67
31
68
31
  memcpy(&ret,
69
31
         LLVM_ASSUME_ALIGNED(
70
31
             memory, (detail::PickAlignment<value_type, alignment>::value)),
71
31
         sizeof(value_type));
72
31
  return byte_swap<value_type>(ret, endian);
73
31
}
signed char llvm::support::endian::read<signed char, 1ul>(void const*, llvm::support::endianness)
Line
Count
Source
65
11
inline value_type read(const void *memory, endianness endian) {
66
11
  value_type ret;
67
11
68
11
  memcpy(&ret,
69
11
         LLVM_ASSUME_ALIGNED(
70
11
             memory, (detail::PickAlignment<value_type, alignment>::value)),
71
11
         sizeof(value_type));
72
11
  return byte_swap<value_type>(ret, endian);
73
11
}
74
75
template<typename value_type,
76
         endianness endian,
77
         std::size_t alignment>
78
92.1M
inline value_type read(const void *memory) {
79
92.1M
  return read<value_type, alignment>(memory, endian);
80
92.1M
}
unsigned short llvm::support::endian::read<unsigned short, (llvm::support::endianness)1, 1ul>(void const*)
Line
Count
Source
78
11.1M
inline value_type read(const void *memory) {
79
11.1M
  return read<value_type, alignment>(memory, endian);
80
11.1M
}
unsigned int llvm::support::endian::read<unsigned int, (llvm::support::endianness)1, 1ul>(void const*)
Line
Count
Source
78
20.0M
inline value_type read(const void *memory) {
79
20.0M
  return read<value_type, alignment>(memory, endian);
80
20.0M
}
unsigned short llvm::support::endian::read<unsigned short, (llvm::support::endianness)0, 1ul>(void const*)
Line
Count
Source
78
186k
inline value_type read(const void *memory) {
79
186k
  return read<value_type, alignment>(memory, endian);
80
186k
}
unsigned int llvm::support::endian::read<unsigned int, (llvm::support::endianness)0, 1ul>(void const*)
Line
Count
Source
78
244k
inline value_type read(const void *memory) {
79
244k
  return read<value_type, alignment>(memory, endian);
80
244k
}
unsigned long long llvm::support::endian::read<unsigned long long, (llvm::support::endianness)0, 1ul>(void const*)
Line
Count
Source
78
160k
inline value_type read(const void *memory) {
79
160k
  return read<value_type, alignment>(memory, endian);
80
160k
}
unsigned long long llvm::support::endian::read<unsigned long long, (llvm::support::endianness)1, 1ul>(void const*)
Line
Count
Source
78
24.0M
inline value_type read(const void *memory) {
79
24.0M
  return read<value_type, alignment>(memory, endian);
80
24.0M
}
unsigned char llvm::support::endian::read<unsigned char, (llvm::support::endianness)1, 1ul>(void const*)
Line
Count
Source
78
32
inline value_type read(const void *memory) {
79
32
  return read<value_type, alignment>(memory, endian);
80
32
}
unsigned long llvm::support::endian::read<unsigned long, (llvm::support::endianness)1, 1ul>(void const*)
Line
Count
Source
78
36.2M
inline value_type read(const void *memory) {
79
36.2M
  return read<value_type, alignment>(memory, endian);
80
36.2M
}
unsigned int llvm::support::endian::read<unsigned int, (llvm::support::endianness)2, 1ul>(void const*)
Line
Count
Source
78
71.4k
inline value_type read(const void *memory) {
79
71.4k
  return read<value_type, alignment>(memory, endian);
80
71.4k
}
unsigned long long llvm::support::endian::read<unsigned long long, (llvm::support::endianness)2, 1ul>(void const*)
Line
Count
Source
78
19.8k
inline value_type read(const void *memory) {
79
19.8k
  return read<value_type, alignment>(memory, endian);
80
19.8k
}
unsigned long long llvm::support::endian::read<unsigned long long, (llvm::support::endianness)1, 0ul>(void const*)
Line
Count
Source
78
739
inline value_type read(const void *memory) {
79
739
  return read<value_type, alignment>(memory, endian);
80
739
}
int llvm::support::endian::read<int, (llvm::support::endianness)1, 1ul>(void const*)
Line
Count
Source
78
13.4k
inline value_type read(const void *memory) {
79
13.4k
  return read<value_type, alignment>(memory, endian);
80
13.4k
}
long long llvm::support::endian::read<long long, (llvm::support::endianness)1, 1ul>(void const*)
Line
Count
Source
78
40.6k
inline value_type read(const void *memory) {
79
40.6k
  return read<value_type, alignment>(memory, endian);
80
40.6k
}
int llvm::support::endian::read<int, (llvm::support::endianness)0, 1ul>(void const*)
Line
Count
Source
78
4.60k
inline value_type read(const void *memory) {
79
4.60k
  return read<value_type, alignment>(memory, endian);
80
4.60k
}
long long llvm::support::endian::read<long long, (llvm::support::endianness)0, 1ul>(void const*)
Line
Count
Source
78
13.0k
inline value_type read(const void *memory) {
79
13.0k
  return read<value_type, alignment>(memory, endian);
80
13.0k
}
llvm::minidump::StreamType llvm::support::endian::read<llvm::minidump::StreamType, (llvm::support::endianness)1, 1ul>(void const*)
Line
Count
Source
78
43
inline value_type read(const void *memory) {
79
43
  return read<value_type, alignment>(memory, endian);
80
43
}
short llvm::support::endian::read<short, (llvm::support::endianness)0, 1ul>(void const*)
Line
Count
Source
78
14
inline value_type read(const void *memory) {
79
14
  return read<value_type, alignment>(memory, endian);
80
14
}
signed char llvm::support::endian::read<signed char, (llvm::support::endianness)0, 1ul>(void const*)
Line
Count
Source
78
7
inline value_type read(const void *memory) {
79
7
  return read<value_type, alignment>(memory, endian);
80
7
}
unsigned char llvm::support::endian::read<unsigned char, (llvm::support::endianness)0, 1ul>(void const*)
Line
Count
Source
78
89
inline value_type read(const void *memory) {
79
89
  return read<value_type, alignment>(memory, endian);
80
89
}
81
82
/// Read a value of a particular endianness from a buffer, and increment the
83
/// buffer past that value.
84
template <typename value_type, std::size_t alignment, typename CharT>
85
10.2M
inline value_type readNext(const CharT *&memory, endianness endian) {
86
10.2M
  value_type ret = read<value_type, alignment>(memory, endian);
87
10.2M
  memory += sizeof(value_type);
88
10.2M
  return ret;
89
10.2M
}
unsigned long long llvm::support::endian::readNext<unsigned long long, 1ul, unsigned char>(unsigned char const*&, llvm::support::endianness)
Line
Count
Source
85
38.2k
inline value_type readNext(const CharT *&memory, endianness endian) {
86
38.2k
  value_type ret = read<value_type, alignment>(memory, endian);
87
38.2k
  memory += sizeof(value_type);
88
38.2k
  return ret;
89
38.2k
}
unsigned int llvm::support::endian::readNext<unsigned int, 0ul, unsigned char>(unsigned char const*&, llvm::support::endianness)
Line
Count
Source
85
1.87M
inline value_type readNext(const CharT *&memory, endianness endian) {
86
1.87M
  value_type ret = read<value_type, alignment>(memory, endian);
87
1.87M
  memory += sizeof(value_type);
88
1.87M
  return ret;
89
1.87M
}
unsigned short llvm::support::endian::readNext<unsigned short, 1ul, unsigned char>(unsigned char const*&, llvm::support::endianness)
Line
Count
Source
85
6.11M
inline value_type readNext(const CharT *&memory, endianness endian) {
86
6.11M
  value_type ret = read<value_type, alignment>(memory, endian);
87
6.11M
  memory += sizeof(value_type);
88
6.11M
  return ret;
89
6.11M
}
unsigned int llvm::support::endian::readNext<unsigned int, 1ul, unsigned char>(unsigned char const*&, llvm::support::endianness)
Line
Count
Source
85
2.20M
inline value_type readNext(const CharT *&memory, endianness endian) {
86
2.20M
  value_type ret = read<value_type, alignment>(memory, endian);
87
2.20M
  memory += sizeof(value_type);
88
2.20M
  return ret;
89
2.20M
}
unsigned char llvm::support::endian::readNext<unsigned char, 1ul, unsigned char>(unsigned char const*&, llvm::support::endianness)
Line
Count
Source
85
12.8k
inline value_type readNext(const CharT *&memory, endianness endian) {
86
12.8k
  value_type ret = read<value_type, alignment>(memory, endian);
87
12.8k
  memory += sizeof(value_type);
88
12.8k
  return ret;
89
12.8k
}
unsigned long long llvm::support::endian::readNext<unsigned long long, 0ul, unsigned char>(unsigned char const*&, llvm::support::endianness)
Line
Count
Source
85
1.91k
inline value_type readNext(const CharT *&memory, endianness endian) {
86
1.91k
  value_type ret = read<value_type, alignment>(memory, endian);
87
1.91k
  memory += sizeof(value_type);
88
1.91k
  return ret;
89
1.91k
}
90
91
template<typename value_type, endianness endian, std::size_t alignment,
92
         typename CharT>
93
10.2M
inline value_type readNext(const CharT *&memory) {
94
10.2M
  return readNext<value_type, alignment, CharT>(memory, endian);
95
10.2M
}
unsigned long long llvm::support::endian::readNext<unsigned long long, (llvm::support::endianness)1, 1ul, unsigned char>(unsigned char const*&)
Line
Count
Source
93
38.2k
inline value_type readNext(const CharT *&memory) {
94
38.2k
  return readNext<value_type, alignment, CharT>(memory, endian);
95
38.2k
}
unsigned int llvm::support::endian::readNext<unsigned int, (llvm::support::endianness)1, 0ul, unsigned char>(unsigned char const*&)
Line
Count
Source
93
1.87M
inline value_type readNext(const CharT *&memory) {
94
1.87M
  return readNext<value_type, alignment, CharT>(memory, endian);
95
1.87M
}
unsigned short llvm::support::endian::readNext<unsigned short, (llvm::support::endianness)1, 1ul, unsigned char>(unsigned char const*&)
Line
Count
Source
93
6.11M
inline value_type readNext(const CharT *&memory) {
94
6.11M
  return readNext<value_type, alignment, CharT>(memory, endian);
95
6.11M
}
unsigned int llvm::support::endian::readNext<unsigned int, (llvm::support::endianness)1, 1ul, unsigned char>(unsigned char const*&)
Line
Count
Source
93
2.20M
inline value_type readNext(const CharT *&memory) {
94
2.20M
  return readNext<value_type, alignment, CharT>(memory, endian);
95
2.20M
}
unsigned char llvm::support::endian::readNext<unsigned char, (llvm::support::endianness)1, 1ul, unsigned char>(unsigned char const*&)
Line
Count
Source
93
12.8k
inline value_type readNext(const CharT *&memory) {
94
12.8k
  return readNext<value_type, alignment, CharT>(memory, endian);
95
12.8k
}
unsigned int llvm::support::endian::readNext<unsigned int, (llvm::support::endianness)0, 1ul, unsigned char>(unsigned char const*&)
Line
Count
Source
93
2
inline value_type readNext(const CharT *&memory) {
94
2
  return readNext<value_type, alignment, CharT>(memory, endian);
95
2
}
unsigned long long llvm::support::endian::readNext<unsigned long long, (llvm::support::endianness)1, 0ul, unsigned char>(unsigned char const*&)
Line
Count
Source
93
1.91k
inline value_type readNext(const CharT *&memory) {
94
1.91k
  return readNext<value_type, alignment, CharT>(memory, endian);
95
1.91k
}
96
97
/// Write a value to memory with a particular endianness.
98
template <typename value_type, std::size_t alignment>
99
11.3M
inline void write(void *memory, value_type value, endianness endian) {
100
11.3M
  value = byte_swap<value_type>(value, endian);
101
11.3M
  memcpy(LLVM_ASSUME_ALIGNED(
102
11.3M
             memory, (detail::PickAlignment<value_type, alignment>::value)),
103
11.3M
         &value, sizeof(value_type));
104
11.3M
}
void llvm::support::endian::write<unsigned short, 1ul>(void*, unsigned short, llvm::support::endianness)
Line
Count
Source
99
1.42M
inline void write(void *memory, value_type value, endianness endian) {
100
1.42M
  value = byte_swap<value_type>(value, endian);
101
1.42M
  memcpy(LLVM_ASSUME_ALIGNED(
102
1.42M
             memory, (detail::PickAlignment<value_type, alignment>::value)),
103
1.42M
         &value, sizeof(value_type));
104
1.42M
}
void llvm::support::endian::write<unsigned int, 1ul>(void*, unsigned int, llvm::support::endianness)
Line
Count
Source
99
4.91M
inline void write(void *memory, value_type value, endianness endian) {
100
4.91M
  value = byte_swap<value_type>(value, endian);
101
4.91M
  memcpy(LLVM_ASSUME_ALIGNED(
102
4.91M
             memory, (detail::PickAlignment<value_type, alignment>::value)),
103
4.91M
         &value, sizeof(value_type));
104
4.91M
}
void llvm::support::endian::write<unsigned long long, 1ul>(void*, unsigned long long, llvm::support::endianness)
Line
Count
Source
99
5.00M
inline void write(void *memory, value_type value, endianness endian) {
100
5.00M
  value = byte_swap<value_type>(value, endian);
101
5.00M
  memcpy(LLVM_ASSUME_ALIGNED(
102
5.00M
             memory, (detail::PickAlignment<value_type, alignment>::value)),
103
5.00M
         &value, sizeof(value_type));
104
5.00M
}
void llvm::support::endian::write<char, 1ul>(void*, char, llvm::support::endianness)
Line
Count
Source
99
2.52k
inline void write(void *memory, value_type value, endianness endian) {
100
2.52k
  value = byte_swap<value_type>(value, endian);
101
2.52k
  memcpy(LLVM_ASSUME_ALIGNED(
102
2.52k
             memory, (detail::PickAlignment<value_type, alignment>::value)),
103
2.52k
         &value, sizeof(value_type));
104
2.52k
}
void llvm::support::endian::write<int, 1ul>(void*, int, llvm::support::endianness)
Line
Count
Source
99
8.98k
inline void write(void *memory, value_type value, endianness endian) {
100
8.98k
  value = byte_swap<value_type>(value, endian);
101
8.98k
  memcpy(LLVM_ASSUME_ALIGNED(
102
8.98k
             memory, (detail::PickAlignment<value_type, alignment>::value)),
103
8.98k
         &value, sizeof(value_type));
104
8.98k
}
void llvm::support::endian::write<long long, 1ul>(void*, long long, llvm::support::endianness)
Line
Count
Source
99
10.9k
inline void write(void *memory, value_type value, endianness endian) {
100
10.9k
  value = byte_swap<value_type>(value, endian);
101
10.9k
  memcpy(LLVM_ASSUME_ALIGNED(
102
10.9k
             memory, (detail::PickAlignment<value_type, alignment>::value)),
103
10.9k
         &value, sizeof(value_type));
104
10.9k
}
void llvm::support::endian::write<unsigned char, 1ul>(void*, unsigned char, llvm::support::endianness)
Line
Count
Source
99
13.3k
inline void write(void *memory, value_type value, endianness endian) {
100
13.3k
  value = byte_swap<value_type>(value, endian);
101
13.3k
  memcpy(LLVM_ASSUME_ALIGNED(
102
13.3k
             memory, (detail::PickAlignment<value_type, alignment>::value)),
103
13.3k
         &value, sizeof(value_type));
104
13.3k
}
Unexecuted instantiation: void llvm::support::endian::write<signed char, 1ul>(void*, signed char, llvm::support::endianness)
void llvm::support::endian::write<short, 1ul>(void*, short, llvm::support::endianness)
Line
Count
Source
99
3.01k
inline void write(void *memory, value_type value, endianness endian) {
100
3.01k
  value = byte_swap<value_type>(value, endian);
101
3.01k
  memcpy(LLVM_ASSUME_ALIGNED(
102
3.01k
             memory, (detail::PickAlignment<value_type, alignment>::value)),
103
3.01k
         &value, sizeof(value_type));
104
3.01k
}
105
106
template<typename value_type,
107
         endianness endian,
108
         std::size_t alignment>
109
11.2M
inline void write(void *memory, value_type value) {
110
11.2M
  write<value_type, alignment>(memory, value, endian);
111
11.2M
}
void llvm::support::endian::write<unsigned short, (llvm::support::endianness)1, 1ul>(void*, unsigned short)
Line
Count
Source
109
1.35M
inline void write(void *memory, value_type value) {
110
1.35M
  write<value_type, alignment>(memory, value, endian);
111
1.35M
}
void llvm::support::endian::write<unsigned int, (llvm::support::endianness)1, 1ul>(void*, unsigned int)
Line
Count
Source
109
4.82M
inline void write(void *memory, value_type value) {
110
4.82M
  write<value_type, alignment>(memory, value, endian);
111
4.82M
}
void llvm::support::endian::write<unsigned long long, (llvm::support::endianness)1, 1ul>(void*, unsigned long long)
Line
Count
Source
109
4.95M
inline void write(void *memory, value_type value) {
110
4.95M
  write<value_type, alignment>(memory, value, endian);
111
4.95M
}
void llvm::support::endian::write<unsigned short, (llvm::support::endianness)0, 1ul>(void*, unsigned short)
Line
Count
Source
109
14.0k
inline void write(void *memory, value_type value) {
110
14.0k
  write<value_type, alignment>(memory, value, endian);
111
14.0k
}
void llvm::support::endian::write<unsigned int, (llvm::support::endianness)0, 1ul>(void*, unsigned int)
Line
Count
Source
109
62.1k
inline void write(void *memory, value_type value) {
110
62.1k
  write<value_type, alignment>(memory, value, endian);
111
62.1k
}
void llvm::support::endian::write<unsigned long long, (llvm::support::endianness)0, 1ul>(void*, unsigned long long)
Line
Count
Source
109
33.7k
inline void write(void *memory, value_type value) {
110
33.7k
  write<value_type, alignment>(memory, value, endian);
111
33.7k
}
void llvm::support::endian::write<int, (llvm::support::endianness)1, 1ul>(void*, int)
Line
Count
Source
109
6.98k
inline void write(void *memory, value_type value) {
110
6.98k
  write<value_type, alignment>(memory, value, endian);
111
6.98k
}
void llvm::support::endian::write<int, (llvm::support::endianness)0, 1ul>(void*, int)
Line
Count
Source
109
1.47k
inline void write(void *memory, value_type value) {
110
1.47k
  write<value_type, alignment>(memory, value, endian);
111
1.47k
}
void llvm::support::endian::write<long long, (llvm::support::endianness)1, 1ul>(void*, long long)
Line
Count
Source
109
10.2k
inline void write(void *memory, value_type value) {
110
10.2k
  write<value_type, alignment>(memory, value, endian);
111
10.2k
}
void llvm::support::endian::write<long long, (llvm::support::endianness)0, 1ul>(void*, long long)
Line
Count
Source
109
700
inline void write(void *memory, value_type value) {
110
700
  write<value_type, alignment>(memory, value, endian);
111
700
}
112
113
template <typename value_type>
114
using make_unsigned_t = typename std::make_unsigned<value_type>::type;
115
116
/// Read a value of a particular endianness from memory, for a location
117
/// that starts at the given bit offset within the first byte.
118
template <typename value_type, endianness endian, std::size_t alignment>
119
inline value_type readAtBitAlignment(const void *memory, uint64_t startBit) {
120
  assert(startBit < 8);
121
  if (startBit == 0)
122
    return read<value_type, endian, alignment>(memory);
123
  else {
124
    // Read two values and compose the result from them.
125
    value_type val[2];
126
    memcpy(&val[0],
127
           LLVM_ASSUME_ALIGNED(
128
               memory, (detail::PickAlignment<value_type, alignment>::value)),
129
           sizeof(value_type) * 2);
130
    val[0] = byte_swap<value_type, endian>(val[0]);
131
    val[1] = byte_swap<value_type, endian>(val[1]);
132
133
    // Shift bits from the lower value into place.
134
    make_unsigned_t<value_type> lowerVal = val[0] >> startBit;
135
    // Mask off upper bits after right shift in case of signed type.
136
    make_unsigned_t<value_type> numBitsFirstVal =
137
        (sizeof(value_type) * 8) - startBit;
138
    lowerVal &= ((make_unsigned_t<value_type>)1 << numBitsFirstVal) - 1;
139
140
    // Get the bits from the upper value.
141
    make_unsigned_t<value_type> upperVal =
142
        val[1] & (((make_unsigned_t<value_type>)1 << startBit) - 1);
143
    // Shift them in to place.
144
    upperVal <<= numBitsFirstVal;
145
146
    return lowerVal | upperVal;
147
  }
148
}
149
150
/// Write a value to memory with a particular endianness, for a location
151
/// that starts at the given bit offset within the first byte.
152
template <typename value_type, endianness endian, std::size_t alignment>
153
inline void writeAtBitAlignment(void *memory, value_type value,
154
133k
                                uint64_t startBit) {
155
133k
  assert(startBit < 8);
156
133k
  if (startBit == 0)
157
128k
    write<value_type, endian, alignment>(memory, value);
158
4.86k
  else {
159
4.86k
    // Read two values and shift the result into them.
160
4.86k
    value_type val[2];
161
4.86k
    memcpy(&val[0],
162
4.86k
           LLVM_ASSUME_ALIGNED(
163
4.86k
               memory, (detail::PickAlignment<value_type, alignment>::value)),
164
4.86k
           sizeof(value_type) * 2);
165
4.86k
    val[0] = byte_swap<value_type, endian>(val[0]);
166
4.86k
    val[1] = byte_swap<value_type, endian>(val[1]);
167
4.86k
168
4.86k
    // Mask off any existing bits in the upper part of the lower value that
169
4.86k
    // we want to replace.
170
4.86k
    val[0] &= ((make_unsigned_t<value_type>)1 << startBit) - 1;
171
4.86k
    make_unsigned_t<value_type> numBitsFirstVal =
172
4.86k
        (sizeof(value_type) * 8) - startBit;
173
4.86k
    make_unsigned_t<value_type> lowerVal = value;
174
4.86k
    if (startBit > 0) {
175
4.86k
      // Mask off the upper bits in the new value that are not going to go into
176
4.86k
      // the lower value. This avoids a left shift of a negative value, which
177
4.86k
      // is undefined behavior.
178
4.86k
      lowerVal &= (((make_unsigned_t<value_type>)1 << numBitsFirstVal) - 1);
179
4.86k
      // Now shift the new bits into place
180
4.86k
      lowerVal <<= startBit;
181
4.86k
    }
182
4.86k
    val[0] |= lowerVal;
183
4.86k
184
4.86k
    // Mask off any existing bits in the lower part of the upper value that
185
4.86k
    // we want to replace.
186
4.86k
    val[1] &= ~(((make_unsigned_t<value_type>)1 << startBit) - 1);
187
4.86k
    // Next shift the bits that go into the upper value into position.
188
4.86k
    make_unsigned_t<value_type> upperVal = value >> numBitsFirstVal;
189
4.86k
    // Mask off upper bits after right shift in case of signed type.
190
4.86k
    upperVal &= ((make_unsigned_t<value_type>)1 << startBit) - 1;
191
4.86k
    val[1] |= upperVal;
192
4.86k
193
4.86k
    // Finally, rewrite values.
194
4.86k
    val[0] = byte_swap<value_type, endian>(val[0]);
195
4.86k
    val[1] = byte_swap<value_type, endian>(val[1]);
196
4.86k
    memcpy(LLVM_ASSUME_ALIGNED(
197
4.86k
               memory, (detail::PickAlignment<value_type, alignment>::value)),
198
4.86k
           &val[0], sizeof(value_type) * 2);
199
4.86k
  }
200
133k
}
201
202
} // end namespace endian
203
204
namespace detail {
205
206
template<typename ValueType,
207
         endianness Endian,
208
         std::size_t Alignment>
209
struct packed_endian_specific_integral {
210
  using value_type = ValueType;
211
  static constexpr endianness endian = Endian;
212
  static constexpr std::size_t alignment = Alignment;
213
214
  packed_endian_specific_integral() = default;
215
216
941k
  explicit packed_endian_specific_integral(value_type val) { *this = val; }
llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)1, 1ul>::packed_endian_specific_integral(unsigned int)
Line
Count
Source
216
471k
  explicit packed_endian_specific_integral(value_type val) { *this = val; }
llvm::support::detail::packed_endian_specific_integral<int, (llvm::support::endianness)1, 1ul>::packed_endian_specific_integral(int)
Line
Count
Source
216
421
  explicit packed_endian_specific_integral(value_type val) { *this = val; }
llvm::support::detail::packed_endian_specific_integral<unsigned short, (llvm::support::endianness)1, 1ul>::packed_endian_specific_integral(unsigned short)
Line
Count
Source
216
469k
  explicit packed_endian_specific_integral(value_type val) { *this = val; }
217
218
55.9M
  operator value_type() const {
219
55.9M
    return endian::read<value_type, endian, alignment>(
220
55.9M
      (const void*)Value.buffer);
221
55.9M
  }
llvm::support::detail::packed_endian_specific_integral<unsigned short, (llvm::support::endianness)1, 1ul>::operator unsigned short() const
Line
Count
Source
218
11.1M
  operator value_type() const {
219
11.1M
    return endian::read<value_type, endian, alignment>(
220
11.1M
      (const void*)Value.buffer);
221
11.1M
  }
llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)1, 1ul>::operator unsigned int() const
Line
Count
Source
218
20.0M
  operator value_type() const {
219
20.0M
    return endian::read<value_type, endian, alignment>(
220
20.0M
      (const void*)Value.buffer);
221
20.0M
  }
llvm::support::detail::packed_endian_specific_integral<unsigned long long, (llvm::support::endianness)1, 1ul>::operator unsigned long long() const
Line
Count
Source
218
24.0M
  operator value_type() const {
219
24.0M
    return endian::read<value_type, endian, alignment>(
220
24.0M
      (const void*)Value.buffer);
221
24.0M
  }
llvm::support::detail::packed_endian_specific_integral<unsigned short, (llvm::support::endianness)0, 1ul>::operator unsigned short() const
Line
Count
Source
218
186k
  operator value_type() const {
219
186k
    return endian::read<value_type, endian, alignment>(
220
186k
      (const void*)Value.buffer);
221
186k
  }
llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)0, 1ul>::operator unsigned int() const
Line
Count
Source
218
244k
  operator value_type() const {
219
244k
    return endian::read<value_type, endian, alignment>(
220
244k
      (const void*)Value.buffer);
221
244k
  }
llvm::support::detail::packed_endian_specific_integral<unsigned long long, (llvm::support::endianness)0, 1ul>::operator unsigned long long() const
Line
Count
Source
218
160k
  operator value_type() const {
219
160k
    return endian::read<value_type, endian, alignment>(
220
160k
      (const void*)Value.buffer);
221
160k
  }
llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)2, 1ul>::operator unsigned int() const
Line
Count
Source
218
71.4k
  operator value_type() const {
219
71.4k
    return endian::read<value_type, endian, alignment>(
220
71.4k
      (const void*)Value.buffer);
221
71.4k
  }
llvm::support::detail::packed_endian_specific_integral<unsigned long long, (llvm::support::endianness)2, 1ul>::operator unsigned long long() const
Line
Count
Source
218
19.8k
  operator value_type() const {
219
19.8k
    return endian::read<value_type, endian, alignment>(
220
19.8k
      (const void*)Value.buffer);
221
19.8k
  }
llvm::support::detail::packed_endian_specific_integral<int, (llvm::support::endianness)1, 1ul>::operator int() const
Line
Count
Source
218
13.3k
  operator value_type() const {
219
13.3k
    return endian::read<value_type, endian, alignment>(
220
13.3k
      (const void*)Value.buffer);
221
13.3k
  }
llvm::support::detail::packed_endian_specific_integral<long long, (llvm::support::endianness)1, 1ul>::operator long long() const
Line
Count
Source
218
40.6k
  operator value_type() const {
219
40.6k
    return endian::read<value_type, endian, alignment>(
220
40.6k
      (const void*)Value.buffer);
221
40.6k
  }
llvm::support::detail::packed_endian_specific_integral<int, (llvm::support::endianness)0, 1ul>::operator int() const
Line
Count
Source
218
4.60k
  operator value_type() const {
219
4.60k
    return endian::read<value_type, endian, alignment>(
220
4.60k
      (const void*)Value.buffer);
221
4.60k
  }
llvm::support::detail::packed_endian_specific_integral<long long, (llvm::support::endianness)0, 1ul>::operator long long() const
Line
Count
Source
218
13.0k
  operator value_type() const {
219
13.0k
    return endian::read<value_type, endian, alignment>(
220
13.0k
      (const void*)Value.buffer);
221
13.0k
  }
llvm::support::detail::packed_endian_specific_integral<llvm::minidump::StreamType, (llvm::support::endianness)1, 1ul>::operator llvm::minidump::StreamType() const
Line
Count
Source
218
43
  operator value_type() const {
219
43
    return endian::read<value_type, endian, alignment>(
220
43
      (const void*)Value.buffer);
221
43
  }
llvm::support::detail::packed_endian_specific_integral<short, (llvm::support::endianness)0, 1ul>::operator short() const
Line
Count
Source
218
14
  operator value_type() const {
219
14
    return endian::read<value_type, endian, alignment>(
220
14
      (const void*)Value.buffer);
221
14
  }
llvm::support::detail::packed_endian_specific_integral<signed char, (llvm::support::endianness)0, 1ul>::operator signed char() const
Line
Count
Source
218
7
  operator value_type() const {
219
7
    return endian::read<value_type, endian, alignment>(
220
7
      (const void*)Value.buffer);
221
7
  }
llvm::support::detail::packed_endian_specific_integral<unsigned char, (llvm::support::endianness)0, 1ul>::operator unsigned char() const
Line
Count
Source
218
89
  operator value_type() const {
219
89
    return endian::read<value_type, endian, alignment>(
220
89
      (const void*)Value.buffer);
221
89
  }
222
223
11.1M
  void operator=(value_type newValue) {
224
11.1M
    endian::write<value_type, endian, alignment>(
225
11.1M
      (void*)Value.buffer, newValue);
226
11.1M
  }
llvm::support::detail::packed_endian_specific_integral<unsigned short, (llvm::support::endianness)1, 1ul>::operator=(unsigned short)
Line
Count
Source
223
1.35M
  void operator=(value_type newValue) {
224
1.35M
    endian::write<value_type, endian, alignment>(
225
1.35M
      (void*)Value.buffer, newValue);
226
1.35M
  }
llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)1, 1ul>::operator=(unsigned int)
Line
Count
Source
223
4.68M
  void operator=(value_type newValue) {
224
4.68M
    endian::write<value_type, endian, alignment>(
225
4.68M
      (void*)Value.buffer, newValue);
226
4.68M
  }
llvm::support::detail::packed_endian_specific_integral<unsigned long long, (llvm::support::endianness)1, 1ul>::operator=(unsigned long long)
Line
Count
Source
223
4.95M
  void operator=(value_type newValue) {
224
4.95M
    endian::write<value_type, endian, alignment>(
225
4.95M
      (void*)Value.buffer, newValue);
226
4.95M
  }
llvm::support::detail::packed_endian_specific_integral<unsigned short, (llvm::support::endianness)0, 1ul>::operator=(unsigned short)
Line
Count
Source
223
14.0k
  void operator=(value_type newValue) {
224
14.0k
    endian::write<value_type, endian, alignment>(
225
14.0k
      (void*)Value.buffer, newValue);
226
14.0k
  }
llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)0, 1ul>::operator=(unsigned int)
Line
Count
Source
223
62.1k
  void operator=(value_type newValue) {
224
62.1k
    endian::write<value_type, endian, alignment>(
225
62.1k
      (void*)Value.buffer, newValue);
226
62.1k
  }
llvm::support::detail::packed_endian_specific_integral<unsigned long long, (llvm::support::endianness)0, 1ul>::operator=(unsigned long long)
Line
Count
Source
223
33.7k
  void operator=(value_type newValue) {
224
33.7k
    endian::write<value_type, endian, alignment>(
225
33.7k
      (void*)Value.buffer, newValue);
226
33.7k
  }
llvm::support::detail::packed_endian_specific_integral<int, (llvm::support::endianness)1, 1ul>::operator=(int)
Line
Count
Source
223
6.98k
  void operator=(value_type newValue) {
224
6.98k
    endian::write<value_type, endian, alignment>(
225
6.98k
      (void*)Value.buffer, newValue);
226
6.98k
  }
llvm::support::detail::packed_endian_specific_integral<int, (llvm::support::endianness)0, 1ul>::operator=(int)
Line
Count
Source
223
1.47k
  void operator=(value_type newValue) {
224
1.47k
    endian::write<value_type, endian, alignment>(
225
1.47k
      (void*)Value.buffer, newValue);
226
1.47k
  }
llvm::support::detail::packed_endian_specific_integral<long long, (llvm::support::endianness)1, 1ul>::operator=(long long)
Line
Count
Source
223
10.2k
  void operator=(value_type newValue) {
224
10.2k
    endian::write<value_type, endian, alignment>(
225
10.2k
      (void*)Value.buffer, newValue);
226
10.2k
  }
llvm::support::detail::packed_endian_specific_integral<long long, (llvm::support::endianness)0, 1ul>::operator=(long long)
Line
Count
Source
223
700
  void operator=(value_type newValue) {
224
700
    endian::write<value_type, endian, alignment>(
225
700
      (void*)Value.buffer, newValue);
226
700
  }
227
228
53.1k
  packed_endian_specific_integral &operator+=(value_type newValue) {
229
53.1k
    *this = *this + newValue;
230
53.1k
    return *this;
231
53.1k
  }
232
233
0
  packed_endian_specific_integral &operator-=(value_type newValue) {
234
0
    *this = *this - newValue;
235
0
    return *this;
236
0
  }
237
238
72.8k
  packed_endian_specific_integral &operator|=(value_type newValue) {
239
72.8k
    *this = *this | newValue;
240
72.8k
    return *this;
241
72.8k
  }
242
243
  packed_endian_specific_integral &operator&=(value_type newValue) {
244
    *this = *this & newValue;
245
    return *this;
246
  }
247
248
private:
249
  AlignedCharArray<PickAlignment<value_type, alignment>::value,
250
                   sizeof(value_type)> Value;
251
252
public:
253
  struct ref {
254
    explicit ref(void *Ptr) : Ptr(Ptr) {}
255
256
    operator value_type() const {
257
      return endian::read<value_type, endian, alignment>(Ptr);
258
    }
259
260
    void operator=(value_type NewValue) {
261
      endian::write<value_type, endian, alignment>(Ptr, NewValue);
262
    }
263
264
  private:
265
    void *Ptr;
266
  };
267
};
268
269
} // end namespace detail
270
271
using ulittle16_t =
272
    detail::packed_endian_specific_integral<uint16_t, little, unaligned>;
273
using ulittle32_t =
274
    detail::packed_endian_specific_integral<uint32_t, little, unaligned>;
275
using ulittle64_t =
276
    detail::packed_endian_specific_integral<uint64_t, little, unaligned>;
277
278
using little16_t =
279
    detail::packed_endian_specific_integral<int16_t, little, unaligned>;
280
using little32_t =
281
    detail::packed_endian_specific_integral<int32_t, little, unaligned>;
282
using little64_t =
283
    detail::packed_endian_specific_integral<int64_t, little, unaligned>;
284
285
using aligned_ulittle16_t =
286
    detail::packed_endian_specific_integral<uint16_t, little, aligned>;
287
using aligned_ulittle32_t =
288
    detail::packed_endian_specific_integral<uint32_t, little, aligned>;
289
using aligned_ulittle64_t =
290
    detail::packed_endian_specific_integral<uint64_t, little, aligned>;
291
292
using aligned_little16_t =
293
    detail::packed_endian_specific_integral<int16_t, little, aligned>;
294
using aligned_little32_t =
295
    detail::packed_endian_specific_integral<int32_t, little, aligned>;
296
using aligned_little64_t =
297
    detail::packed_endian_specific_integral<int64_t, little, aligned>;
298
299
using ubig16_t =
300
    detail::packed_endian_specific_integral<uint16_t, big, unaligned>;
301
using ubig32_t =
302
    detail::packed_endian_specific_integral<uint32_t, big, unaligned>;
303
using ubig64_t =
304
    detail::packed_endian_specific_integral<uint64_t, big, unaligned>;
305
306
using big16_t =
307
    detail::packed_endian_specific_integral<int16_t, big, unaligned>;
308
using big32_t =
309
    detail::packed_endian_specific_integral<int32_t, big, unaligned>;
310
using big64_t =
311
    detail::packed_endian_specific_integral<int64_t, big, unaligned>;
312
313
using aligned_ubig16_t =
314
    detail::packed_endian_specific_integral<uint16_t, big, aligned>;
315
using aligned_ubig32_t =
316
    detail::packed_endian_specific_integral<uint32_t, big, aligned>;
317
using aligned_ubig64_t =
318
    detail::packed_endian_specific_integral<uint64_t, big, aligned>;
319
320
using aligned_big16_t =
321
    detail::packed_endian_specific_integral<int16_t, big, aligned>;
322
using aligned_big32_t =
323
    detail::packed_endian_specific_integral<int32_t, big, aligned>;
324
using aligned_big64_t =
325
    detail::packed_endian_specific_integral<int64_t, big, aligned>;
326
327
using unaligned_uint16_t =
328
    detail::packed_endian_specific_integral<uint16_t, native, unaligned>;
329
using unaligned_uint32_t =
330
    detail::packed_endian_specific_integral<uint32_t, native, unaligned>;
331
using unaligned_uint64_t =
332
    detail::packed_endian_specific_integral<uint64_t, native, unaligned>;
333
334
using unaligned_int16_t =
335
    detail::packed_endian_specific_integral<int16_t, native, unaligned>;
336
using unaligned_int32_t =
337
    detail::packed_endian_specific_integral<int32_t, native, unaligned>;
338
using unaligned_int64_t =
339
    detail::packed_endian_specific_integral<int64_t, native, unaligned>;
340
341
template <typename T>
342
using little_t = detail::packed_endian_specific_integral<T, little, unaligned>;
343
template <typename T>
344
using big_t = detail::packed_endian_specific_integral<T, big, unaligned>;
345
346
template <typename T>
347
using aligned_little_t =
348
    detail::packed_endian_specific_integral<T, little, aligned>;
349
template <typename T>
350
using aligned_big_t = detail::packed_endian_specific_integral<T, big, aligned>;
351
352
namespace endian {
353
354
1.08k
template <typename T> inline T read(const void *P, endianness E) {
355
1.08k
  return read<T, unaligned>(P, E);
356
1.08k
}
357
358
1.39M
template <typename T, endianness E> inline T read(const void *P) {
359
1.39M
  return *(const detail::packed_endian_specific_integral<T, E, unaligned> *)P;
360
1.39M
}
unsigned short llvm::support::endian::read<unsigned short, (llvm::support::endianness)1>(void const*)
Line
Count
Source
358
32.0k
template <typename T, endianness E> inline T read(const void *P) {
359
32.0k
  return *(const detail::packed_endian_specific_integral<T, E, unaligned> *)P;
360
32.0k
}
unsigned int llvm::support::endian::read<unsigned int, (llvm::support::endianness)1>(void const*)
Line
Count
Source
358
203k
template <typename T, endianness E> inline T read(const void *P) {
359
203k
  return *(const detail::packed_endian_specific_integral<T, E, unaligned> *)P;
360
203k
}
unsigned long long llvm::support::endian::read<unsigned long long, (llvm::support::endianness)1>(void const*)
Line
Count
Source
358
1.13M
template <typename T, endianness E> inline T read(const void *P) {
359
1.13M
  return *(const detail::packed_endian_specific_integral<T, E, unaligned> *)P;
360
1.13M
}
unsigned short llvm::support::endian::read<unsigned short, (llvm::support::endianness)0>(void const*)
Line
Count
Source
358
323
template <typename T, endianness E> inline T read(const void *P) {
359
323
  return *(const detail::packed_endian_specific_integral<T, E, unaligned> *)P;
360
323
}
unsigned int llvm::support::endian::read<unsigned int, (llvm::support::endianness)0>(void const*)
Line
Count
Source
358
15.5k
template <typename T, endianness E> inline T read(const void *P) {
359
15.5k
  return *(const detail::packed_endian_specific_integral<T, E, unaligned> *)P;
360
15.5k
}
unsigned long long llvm::support::endian::read<unsigned long long, (llvm::support::endianness)0>(void const*)
Line
Count
Source
358
70
template <typename T, endianness E> inline T read(const void *P) {
359
70
  return *(const detail::packed_endian_specific_integral<T, E, unaligned> *)P;
360
70
}
signed char llvm::support::endian::read<signed char, (llvm::support::endianness)0>(void const*)
Line
Count
Source
358
7
template <typename T, endianness E> inline T read(const void *P) {
359
7
  return *(const detail::packed_endian_specific_integral<T, E, unaligned> *)P;
360
7
}
short llvm::support::endian::read<short, (llvm::support::endianness)0>(void const*)
Line
Count
Source
358
3
template <typename T, endianness E> inline T read(const void *P) {
359
3
  return *(const detail::packed_endian_specific_integral<T, E, unaligned> *)P;
360
3
}
int llvm::support::endian::read<int, (llvm::support::endianness)0>(void const*)
Line
Count
Source
358
3
template <typename T, endianness E> inline T read(const void *P) {
359
3
  return *(const detail::packed_endian_specific_integral<T, E, unaligned> *)P;
360
3
}
long long llvm::support::endian::read<long long, (llvm::support::endianness)0>(void const*)
Line
Count
Source
358
3
template <typename T, endianness E> inline T read(const void *P) {
359
3
  return *(const detail::packed_endian_specific_integral<T, E, unaligned> *)P;
360
3
}
unsigned char llvm::support::endian::read<unsigned char, (llvm::support::endianness)0>(void const*)
Line
Count
Source
358
89
template <typename T, endianness E> inline T read(const void *P) {
359
89
  return *(const detail::packed_endian_specific_integral<T, E, unaligned> *)P;
360
89
}
361
362
inline uint16_t read16(const void *P, endianness E) {
363
  return read<uint16_t>(P, E);
364
}
365
inline uint32_t read32(const void *P, endianness E) {
366
  return read<uint32_t>(P, E);
367
}
368
1.04k
inline uint64_t read64(const void *P, endianness E) {
369
1.04k
  return read<uint64_t>(P, E);
370
1.04k
}
371
372
32.0k
template <endianness E> inline uint16_t read16(const void *P) {
373
32.0k
  return read<uint16_t, E>(P);
374
32.0k
}
375
38.8k
template <endianness E> inline uint32_t read32(const void *P) {
376
38.8k
  return read<uint32_t, E>(P);
377
38.8k
}
unsigned int llvm::support::endian::read32<(llvm::support::endianness)1>(void const*)
Line
Count
Source
375
23.3k
template <endianness E> inline uint32_t read32(const void *P) {
376
23.3k
  return read<uint32_t, E>(P);
377
23.3k
}
unsigned int llvm::support::endian::read32<(llvm::support::endianness)0>(void const*)
Line
Count
Source
375
15.5k
template <endianness E> inline uint32_t read32(const void *P) {
376
15.5k
  return read<uint32_t, E>(P);
377
15.5k
}
378
996k
template <endianness E> inline uint64_t read64(const void *P) {
379
996k
  return read<uint64_t, E>(P);
380
996k
}
unsigned long long llvm::support::endian::read64<(llvm::support::endianness)1>(void const*)
Line
Count
Source
378
996k
template <endianness E> inline uint64_t read64(const void *P) {
379
996k
  return read<uint64_t, E>(P);
380
996k
}
unsigned long long llvm::support::endian::read64<(llvm::support::endianness)0>(void const*)
Line
Count
Source
378
60
template <endianness E> inline uint64_t read64(const void *P) {
379
60
  return read<uint64_t, E>(P);
380
60
}
381
382
32.0k
inline uint16_t read16le(const void *P) { return read16<little>(P); }
383
23.1k
inline uint32_t read32le(const void *P) { return read32<little>(P); }
384
996k
inline uint64_t read64le(const void *P) { return read64<little>(P); }
385
0
inline uint16_t read16be(const void *P) { return read16<big>(P); }
386
4.75k
inline uint32_t read32be(const void *P) { return read32<big>(P); }
387
60
inline uint64_t read64be(const void *P) { return read64<big>(P); }
388
389
27.6k
template <typename T> inline void write(void *P, T V, endianness E) {
390
27.6k
  write<T, unaligned>(P, V, E);
391
27.6k
}
void llvm::support::endian::write<unsigned short>(void*, unsigned short, llvm::support::endianness)
Line
Count
Source
389
1.50k
template <typename T> inline void write(void *P, T V, endianness E) {
390
1.50k
  write<T, unaligned>(P, V, E);
391
1.50k
}
void llvm::support::endian::write<unsigned int>(void*, unsigned int, llvm::support::endianness)
Line
Count
Source
389
14.7k
template <typename T> inline void write(void *P, T V, endianness E) {
390
14.7k
  write<T, unaligned>(P, V, E);
391
14.7k
}
void llvm::support::endian::write<unsigned long long>(void*, unsigned long long, llvm::support::endianness)
Line
Count
Source
389
11.3k
template <typename T> inline void write(void *P, T V, endianness E) {
390
11.3k
  write<T, unaligned>(P, V, E);
391
11.3k
}
392
393
221k
template <typename T, endianness E> inline void write(void *P, T V) {
394
221k
  *(detail::packed_endian_specific_integral<T, E, unaligned> *)P = V;
395
221k
}
void llvm::support::endian::write<unsigned short, (llvm::support::endianness)1>(void*, unsigned short)
Line
Count
Source
393
2.03k
template <typename T, endianness E> inline void write(void *P, T V) {
394
2.03k
  *(detail::packed_endian_specific_integral<T, E, unaligned> *)P = V;
395
2.03k
}
void llvm::support::endian::write<unsigned int, (llvm::support::endianness)1>(void*, unsigned int)
Line
Count
Source
393
207k
template <typename T, endianness E> inline void write(void *P, T V) {
394
207k
  *(detail::packed_endian_specific_integral<T, E, unaligned> *)P = V;
395
207k
}
void llvm::support::endian::write<unsigned long long, (llvm::support::endianness)1>(void*, unsigned long long)
Line
Count
Source
393
1.33k
template <typename T, endianness E> inline void write(void *P, T V) {
394
1.33k
  *(detail::packed_endian_specific_integral<T, E, unaligned> *)P = V;
395
1.33k
}
void llvm::support::endian::write<unsigned short, (llvm::support::endianness)0>(void*, unsigned short)
Line
Count
Source
393
79
template <typename T, endianness E> inline void write(void *P, T V) {
394
79
  *(detail::packed_endian_specific_integral<T, E, unaligned> *)P = V;
395
79
}
void llvm::support::endian::write<unsigned int, (llvm::support::endianness)0>(void*, unsigned int)
Line
Count
Source
393
10.6k
template <typename T, endianness E> inline void write(void *P, T V) {
394
10.6k
  *(detail::packed_endian_specific_integral<T, E, unaligned> *)P = V;
395
10.6k
}
396
397
inline void write16(void *P, uint16_t V, endianness E) {
398
  write<uint16_t>(P, V, E);
399
}
400
inline void write32(void *P, uint32_t V, endianness E) {
401
  write<uint32_t>(P, V, E);
402
}
403
inline void write64(void *P, uint64_t V, endianness E) {
404
  write<uint64_t>(P, V, E);
405
}
406
407
2.11k
template <endianness E> inline void write16(void *P, uint16_t V) {
408
2.11k
  write<uint16_t, E>(P, V);
409
2.11k
}
void llvm::support::endian::write16<(llvm::support::endianness)1>(void*, unsigned short)
Line
Count
Source
407
2.03k
template <endianness E> inline void write16(void *P, uint16_t V) {
408
2.03k
  write<uint16_t, E>(P, V);
409
2.03k
}
void llvm::support::endian::write16<(llvm::support::endianness)0>(void*, unsigned short)
Line
Count
Source
407
79
template <endianness E> inline void write16(void *P, uint16_t V) {
408
79
  write<uint16_t, E>(P, V);
409
79
}
410
218k
template <endianness E> inline void write32(void *P, uint32_t V) {
411
218k
  write<uint32_t, E>(P, V);
412
218k
}
void llvm::support::endian::write32<(llvm::support::endianness)1>(void*, unsigned int)
Line
Count
Source
410
207k
template <endianness E> inline void write32(void *P, uint32_t V) {
411
207k
  write<uint32_t, E>(P, V);
412
207k
}
void llvm::support::endian::write32<(llvm::support::endianness)0>(void*, unsigned int)
Line
Count
Source
410
10.6k
template <endianness E> inline void write32(void *P, uint32_t V) {
411
10.6k
  write<uint32_t, E>(P, V);
412
10.6k
}
413
1.32k
template <endianness E> inline void write64(void *P, uint64_t V) {
414
1.32k
  write<uint64_t, E>(P, V);
415
1.32k
}
416
417
2.00k
inline void write16le(void *P, uint16_t V) { write16<little>(P, V); }
418
207k
inline void write32le(void *P, uint32_t V) { write32<little>(P, V); }
419
1.32k
inline void write64le(void *P, uint64_t V) { write64<little>(P, V); }
420
20
inline void write16be(void *P, uint16_t V) { write16<big>(P, V); }
421
20
inline void write32be(void *P, uint32_t V) { write32<big>(P, V); }
422
0
inline void write64be(void *P, uint64_t V) { write64<big>(P, V); }
423
424
} // end namespace endian
425
426
} // end namespace support
427
} // end namespace llvm
428
429
#endif // LLVM_SUPPORT_ENDIAN_H