macro_rules! impl_asymmetric {
(
$fn:ident, // name of the unsigned division function
$zero_div_fn:ident, // function called when division by zero is attempted
$half_division:ident, // function for division of a $uX by a $uX
$asymmetric_division:ident, // function for division of a $uD by a $uX
$n_h:expr, // the number of bits in a $iH or $uH
$uH:ident, // unsigned integer with half the bit width of $uX
$uX:ident, // unsigned integer with half the bit width of $uD
$uD:ident // unsigned integer type for the inputs and outputs of `$fn`
) => { ... };
}
Expand description
Creates an unsigned division function optimized for dividing integers with the same bitwidth as the largest operand in an asymmetrically sized division. For example, x86-64 has an assembly instruction that can divide a 128 bit integer by a 64 bit integer if the quotient fits in 64 bits. The 128 bit version of this algorithm would use that fast hardware division to construct a full 128 bit by 128 bit division.