Skip to content

Commit 74192a9

Browse files
committed
run rustfmt
1 parent 71aba93 commit 74192a9

File tree

8 files changed

+27
-27
lines changed

8 files changed

+27
-27
lines changed

src/int/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ pub mod addsub;
44
pub mod mul;
55
pub mod shift;
66

7+
pub mod sdiv;
78
mod specialized_div_rem;
89
pub mod udiv;
9-
pub mod sdiv;
1010

1111
/// Trait for some basic operations on integers
1212
pub trait Int:

src/int/sdiv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ intrinsics! {
3838
pub extern "C" fn __moddi3(a: i64, b: i64) -> i64 {
3939
i64_div_rem(a, b).1
4040
}
41-
41+
4242
#[aapcs_on_arm]
4343
/// Returns `n / d` and sets `*rem = n % d`
4444
pub extern "C" fn __divmoddi4(a: i64, b: i64, rem: &mut i64) -> i64 {
@@ -52,7 +52,7 @@ intrinsics! {
5252
pub extern "C" fn __divti3(a: i128, b: i128) -> i128 {
5353
i128_div_rem(a, b).0
5454
}
55-
55+
5656
#[win64_128bit_abi_hack]
5757
/// Returns `n % d`
5858
pub extern "C" fn __modti3(a: i128, b: i128) -> i128 {

src/int/specialized_div_rem/asymmetric.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ macro_rules! impl_asymmetric {
1414
) => {
1515
/// Computes the quotient and remainder of `duo` divided by `div` and returns them as a
1616
/// tuple.
17-
///
17+
///
1818
/// This is optimized for dividing integers with the same bitwidth as the largest operand in
1919
/// an asymmetrically sized division. For example, the x86-64 `divq` assembly instruction
2020
/// can divide a 128 bit integer by a 64 bit integer if the quotient fits in 64 bits.
@@ -129,7 +129,7 @@ macro_rules! impl_asymmetric {
129129
}
130130
// Note that this is a large $uD multiplication being used here
131131
let mut rem = duo - ((quo as $uD) * div);
132-
132+
133133
if rem >= div {
134134
quo += 1;
135135
rem -= div;
@@ -140,7 +140,7 @@ macro_rules! impl_asymmetric {
140140

141141
/// Computes the quotient and remainder of `duo` divided by `div` and returns them as a
142142
/// tuple.
143-
///
143+
///
144144
/// This is optimized for dividing integers with the same bitwidth as the largest operand in
145145
/// an asymmetrically sized division. For example, the x86-64 `divq` assembly instruction
146146
/// can divide a 128 bit integer by a 64 bit integer if the quotient fits in 64 bits.

src/int/specialized_div_rem/binary_long.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ macro_rules! impl_binary_long {
1111

1212
/// Computes the quotient and remainder of `duo` divided by `div` and returns them as a
1313
/// tuple.
14-
///
14+
///
1515
/// This uses binary shift long division only, and is designed for CPUs without fast
1616
/// multiplication or division hardware.
1717
///
@@ -79,7 +79,7 @@ macro_rules! impl_binary_long {
7979

8080
/// Computes the quotient and remainder of `duo` divided by `div` and returns them as a
8181
/// tuple.
82-
///
82+
///
8383
/// This uses binary shift long division only, and is designed for CPUs without fast
8484
/// multiplication or division hardware.
8585
///

src/int/specialized_div_rem/delegate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ macro_rules! impl_delegate {
1414

1515
/// Computes the quotient and remainder of `duo` divided by `div` and returns them as a
1616
/// tuple.
17-
///
17+
///
1818
/// This uses binary shift long division, but if it can delegates work to a smaller
1919
/// division. This function is used for CPUs with a register size smaller than the division
2020
/// size, and that do not have fast multiplication or division hardware. For CPUs with a
@@ -168,7 +168,7 @@ macro_rules! impl_delegate {
168168

169169
/// Computes the quotient and remainder of `duo` divided by `div` and returns them as a
170170
/// tuple.
171-
///
171+
///
172172
/// This uses binary shift long division, but if it can delegates work to a smaller
173173
/// division. This function is used for CPUs with a register size smaller than the division
174174
/// size, and that do not have fast multiplication or division hardware. For CPUs with a

src/int/specialized_div_rem/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// be used which calls `u32_div_rem_binary_long`. The `impl_binary_long!` macro uses
2020
// no half division, so the chain of calls ends there.
2121
// - LLVM supplies 16 bit divisions and smaller
22-
//
22+
//
2323
// I could replace all `u64_by_u64_div_rem` in the macros by `u64_div_rem` and likewise
2424
// for `u32_by_u32_div_rem`, but that would mean that hardware divisions would never be
2525
// used.
@@ -79,7 +79,7 @@ unsafe fn u128_by_u64_div_rem(duo: u128, div: u64) -> (u64, u64) {
7979
: "{rax}"(duo_lo), "{rdx}"(duo_hi), "r"(div)
8080
: "rax", "rdx"
8181
);
82-
return (quo, rem)
82+
return (quo, rem);
8383
}
8484

8585
// use `_asymmetric` instead of `_trifecta`, because x86_64 supplies the `divq` instruction

src/int/specialized_div_rem/trifecta.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ macro_rules! impl_trifecta {
1313
) => {
1414
/// Computes the quotient and remainder of `duo` divided by `div` and returns them as a
1515
/// tuple.
16-
///
16+
///
1717
/// This is optimized for division of two integers with bit widths twice as large
1818
/// as the largest hardware integer division supported. Note that some architectures supply
1919
/// a division of an integer larger than register size by a regular sized integer (e.x.
2020
/// x86_64 has a `divq` instruction which can divide a 128 bit integer by a 64 bit integer).
2121
/// In that case, the `_asymmetric` algorithm should be used instead of this one.
22-
///
22+
///
2323
/// This is called the trifecta algorithm because it uses three main algorithms: short
2424
/// division for small divisors, the "mul or mul - 1" algorithm for when the divisor is
2525
/// large enough for the quotient to be determined to be one of two values via only one
@@ -92,10 +92,10 @@ macro_rules! impl_trifecta {
9292
tmp.1 as $uD
9393
)
9494
}
95-
95+
9696
// relative leading significant bits, cannot overflow because of above branches
9797
let rel_leading_sb = div_lz.wrapping_sub(duo_lz);
98-
98+
9999
// `{2^n, 2^div_sb} <= duo < 2^n_d`
100100
// `1 <= div < {2^duo_sb, 2^(n_d - 1)}`
101101
// short division branch
@@ -122,7 +122,7 @@ macro_rules! impl_trifecta {
122122
rem_1 as $uD
123123
)
124124
}
125-
125+
126126
// `{2^n, 2^div_sb} <= duo < 2^n_d`
127127
// `2^n_h <= div < {2^duo_sb, 2^(n_d - 1)}`
128128
// `mul` or `mul - 1` branch
@@ -266,11 +266,11 @@ macro_rules! impl_trifecta {
266266
// correct it. This long division algorithm has been carefully constructed to always
267267
// underguess the quotient by slim margins. This allows different subalgorithms
268268
// to be blindly jumped to without needing an extra correction step.
269-
//
269+
//
270270
// The only problem is that it will not work
271271
// for many ranges of `duo` and `div`. Fortunately, the short division,
272272
// mul or mul - 1 algorithms, and simple divisions happen to exactly fill these gaps.
273-
//
273+
//
274274
// For an example, consider the division of 76543210 by 213 and assume that `n_h`
275275
// is equal to two decimal digits (note: we are working with base 10 here for
276276
// readability).
@@ -399,13 +399,13 @@ macro_rules! impl_trifecta {
399399

400400
/// Computes the quotient and remainder of `duo` divided by `div` and returns them as a
401401
/// tuple.
402-
///
402+
///
403403
/// This is optimized for division of two integers with bit widths twice as large
404404
/// as the largest hardware integer division supported. Note that some architectures supply
405405
/// a division of an integer larger than register size by a regular sized integer (e.x.
406406
/// x86_64 has a `divq` instruction which can divide a 128 bit integer by a 64 bit integer).
407407
/// In that case, the `_asymmetric` algorithm should be used instead of this one.
408-
///
408+
///
409409
/// This is called the trifecta algorithm because it uses three main algorithms: short
410410
/// division for small divisors, the "mul or mul - 1" algorithm for when the divisor is
411411
/// large enough for the quotient to be determined to be one of two values via only one

src/int/udiv.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ intrinsics! {
1212
pub extern "C" fn __udivsi3(n: u32, d: u32) -> u32 {
1313
u32_div_rem(n, d).0
1414
}
15-
15+
1616
#[maybe_use_optimized_c_shim]
1717
/// Returns `n % d`
1818
pub extern "C" fn __umodsi3(n: u32, d: u32) -> u32 {
1919
u32_div_rem(n, d).1
2020
}
21-
21+
2222
#[maybe_use_optimized_c_shim]
2323
/// Returns `n / d` and sets `*rem = n % d`
2424
pub extern "C" fn __udivmodsi4(n: u32, d: u32, rem: Option<&mut u32>) -> u32 {
@@ -28,19 +28,19 @@ intrinsics! {
2828
}
2929
quo_rem.0
3030
}
31-
31+
3232
#[maybe_use_optimized_c_shim]
3333
/// Returns `n / d`
3434
pub extern "C" fn __udivdi3(n: u64, d: u64) -> u64 {
3535
u64_div_rem(n, d).0
3636
}
37-
37+
3838
#[maybe_use_optimized_c_shim]
3939
/// Returns `n % d`
4040
pub extern "C" fn __umoddi3(n: u64, d: u64) -> u64 {
4141
u64_div_rem(n, d).1
4242
}
43-
43+
4444
/// Returns `n / d` and sets `*rem = n % d`
4545
pub extern "C" fn __udivmoddi4(n: u64, d: u64, rem: Option<&mut u64>) -> u64 {
4646
let quo_rem = u64_div_rem(n, d);
@@ -49,7 +49,7 @@ intrinsics! {
4949
}
5050
quo_rem.0
5151
}
52-
52+
5353
#[win64_128bit_abi_hack]
5454
/// Returns `n / d`
5555
pub extern "C" fn __udivti3(n: u128, d: u128) -> u128 {

0 commit comments

Comments
 (0)