Direct storage-word arithmetic for configured binary formats #
On the word64 plan the code is the encoding itself. Binary64 addition and subtraction run the
one-word kernel on the stored UInt64 values and rebuild the proof model only when the kernel
declines. A binary64 model value with the sign bit set is a natural number of at least 2 ^ 63,
which the runtime allocates, so negative operands would otherwise pay for several allocations per
operation.
On the pair plan the code is the two storage words of the encoding. Formats with the two-word
layout of NativePair add, subtract, multiply, divide, fuse multiply-adds, and take square roots
through the two-word kernels on those words. Above 64 bits every model value is an allocated
natural number, and splitting and joining it costs far more than the arithmetic. Direct.Proof
shows each direct operation equals the word operation it replaces.
Pack a kernel's storage word as a word64 code, masked below the radix.
Instances For
The model fallback of binary64Add, kept out of line so the word path stays small, and
specialized on the format so declined inputs run the descriptor-specialized dispatcher.
Instances For
Addition on stored binary64 words, rebuilding the model only when the word kernel declines.
Instances For
Out-of-line model fallback of binary64Sub, as for binary64Add.
Instances For
Subtraction on stored binary64 words, with the right operand's sign toggled in the kernel.
Instances For
Out-of-line model fallback of binary64Mul, as for binary64Add.
Instances For
Multiplication on stored binary64 words through the two-word normal-product kernel.
Instances For
Out-of-line model fallback of binary64Div, as for binary64Add.
Instances For
Division on stored binary64 words through the normal-result divider.
Instances For
Out-of-line model fallback of binary64Fma, as for binary64Add.
Instances For
Fused multiply-add on stored binary64 words through the normal-result kernel.
Instances For
Two-word carriers #
Mask of the encoded bits in the high word of a pair code: 2 ^ (bitWidth - 64) - 1.
Instances For
The high-word mask is exact for every width up to 128 bits.
A high word masked by pairHighMask and any low word form an encoding below the radix.
Pack a kernel's two storage words as a pair code, masked below the radix.
Instances For
Out-of-line model fallback of pairAdd, as for binary64Add.
Instances For
Addition on stored two-word codes through the two-word finite addition kernel.
Instances For
Out-of-line model fallback of pairSub, as for binary64Add.
Instances For
Subtraction on stored two-word codes, with the right operand's sign toggled in the kernel.
Instances For
Out-of-line model fallback of pairMul, as for binary64Add.
Instances For
Multiplication on stored two-word codes through the two-word normal-product kernel.
Instances For
Out-of-line model fallback of pairDiv, as for binary64Add.
Instances For
Division on stored two-word codes through the certified two-word normal divider.
Instances For
Out-of-line fixed-limb fallback of pairSqrt, as for binary64Add.
Instances For
Square root of a stored two-word code through the two-word normal root kernel.
Instances For
Out-of-line fixed-limb fallback of pairFma, as for binary64Add.
Instances For
Fused multiply-add on stored two-word codes through the two-word finite FMA kernel.
Instances For
Plan dispatch #
Word addition for the configured code, with direct binary64 and two-word kernels.
Instances For
Word subtraction for the configured code, with direct binary64 and two-word kernels.
Instances For
Word multiplication for the configured code, using the two-word kernel when the layout allows.
Instances For
Word division for the configured code, using the two-word kernel when the layout allows.