TorchLean API

FloatLib.Floats.ExecFloat.Backends.FixedLimb.Pair.Core.Runtime

Two-word pair-kernel storage runtime #

The structural eligibility predicate and field helpers provide the storage interface shared by the fixed-limb arithmetic kernels. A value of an eligible format is split into a high and a low UInt64. The low word is entirely fraction, and the high word holds the remaining fracWidth - 64 fraction bits, then the exponent field, then the sign. Every field position is derived from the descriptor, so one kernel serves every eligible layout, with 68 to 128 encoded bits and a fraction wider than one word. The correspondence with the width-generic carrier is proved in Core.Proof.

Structural capability required by the two-word kernels.

The conventional IEEE encoding fixes the binary semantics shared with the generic kernels, including the default bias. 64 < fracWidth fills the low word with fraction bits and puts the sign, the exponent field, and the upper fraction bits in the high word, so only the fraction spans both words. The same bound keeps every four-limb product-rounding shift strictly above one word. bitWidth ≤ 128 bounds the storage to two words.

Instances For
    @[instance_reducible, inline]

    Decide eligibility from the descriptor fields.

    Written as an inline if, the decision simplifies at closed-format call sites.

    @[inline]

    Number of fraction bits stored in the high word.

    Instances For
      @[inline]

      Mask selecting the fraction bits stored in the high word.

      Instances For
        @[inline]

        The all-ones exponent field as a native word.

        Instances For
          @[inline]

          The implicit leading significand bit 2^fracWidth, in high-word coordinates.

          Instances For
            @[inline]

            The sign bit 2^(expWidth + fracWidth), in high-word coordinates.

            Instances For
              @[inline]

              Split a stored value into its high and low native words.

              Instances For
                @[inline]

                Join two native words into a stored value, keeping the low bitWidth bits.

                Instances For
                  @[inline]

                  Extract the sign from the high storage word.

                  Instances For
                    @[inline]

                    Extract the biased exponent field from the high storage word.

                    Instances For
                      @[inline]

                      Extract the fraction bits held in the high storage word.

                      Instances For
                        @[inline]

                        Add the implicit bit to the two fraction limbs of a normal value.

                        Instances For
                          @[inline]

                          The two-limb significand 2^fracWidth, the smallest normal significand.

                          Instances For
                            @[inline]

                            The two-limb value 2^(fracWidth + 1) produced when nearest-even rounding carries out.

                            Instances For
                              @[inline]

                              Whether a rounded two-limb significand carried out to 2^(fracWidth + 1).

                              Instances For
                                @[inline]

                                Replace a carried-out significand by 2^fracWidth, leaving other significands unchanged.

                                Instances For
                                  @[inline]

                                  The two storage words of a finite normal result with the given sign, exponent, and significand.

                                  Packing masks the exponent to the exponent field, and the high fraction mask discards the significand's implicit bit. Two-word carriers store these words as they are.

                                  Instances For
                                    @[inline]

                                    Pack a finite normal result from its native exponent and significand words.

                                    The result is meaningful when the exponent fits the field and the significand is normal, the contract that packNormal_eq_ofFields in Core.Proof states.

                                    Instances For