1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//! The portable kernels of the shifts, for Miri and for the targets without NEON kernels: all
//! but the 64-bit little-endian aarch64 targets whose operating system allows unaligned
//! accesses. The bytes go eight at a time as `u64`s, read from and written as `[u8; 8]`, which
//! has alignment 1, in the layout of the magnitude: big-endian ones are put through a byte swap
//! on the way in and out, which the compiler folds into the access where the target has one
//! (`movbe`, a reversing load).
//!
//! Each group of eight bytes of the result takes the bits of its own group of the input and
//! the bits shifted out of the group next to it, which the loop carries in a register, so that
//! every byte is read once.
use ;
/// Writes positions `q..q + l` of `x << (8q + r)` at the least significant end `dst` in the
/// layout `BE`, for `x` of `l >= 16` significant bytes at the least significant end `src`, and
/// `r` from 1 to 7: the low `l` bytes of `x << r`. The bits shifted out of the top are left to
/// the caller.
///
/// The groups are written from the most significant down, each read before a write reaches it:
/// in place little-endian the result lies `q` bytes above the input, and big-endian it ends at
/// most one byte further towards the end of the vector than the input does.
///
/// # Safety
///
/// The `l` bytes at `src` must be valid for reads and the bytes at positions `q..q + l` at `dst`
/// for writes. If they overlap, `dst` must be `src` little-endian, and big-endian at most
/// `src + 1`.
pub unsafe
/// Writes positions `0..n` of `x >> (8q + r)` at the least significant end `dst` in the layout
/// `BE`, for `x` of `l` significant bytes at the least significant end `src`, `r` from 1 to 7 and
/// `n >= 16` the length of the quotient, `l - q` or `l - q - 1`: positions `q..q + n` of `x` and
/// `above`, its byte at position `q + n` (zero when that is above its top).
///
/// The groups of eight are taken from the top of the quotient down, positions `n - 8`,
/// `n - 16`, and so on, and written from the least significant up: first the `n % 8` bytes
/// below them, if any, as the eight at position 0, over which the group above is written. Each
/// group is read before a write reaches it: in place little-endian the result lies `q` bytes
/// below the input; big-endian the input ends at the end of the vector, and the result `q` or
/// `q + 1` bytes before.
///
/// # Safety
///
/// Positions `q..q + n` at `src` must be valid for reads and positions `0..n` at `dst` for
/// writes. If they overlap, `dst` must be `src` little-endian, and big-endian
/// `src - (l - q - n)` with `l` the significant length of `x`, its significant bytes at the start
/// of the vector.
pub unsafe