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; 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 selects the exact binary semantics shared with the generic kernels, and in particular the default bias. 64 < fracWidth places the sign, the exponent field, and the upper fraction bits in the high word and fills the low word with fraction bits. Only the fraction spans both words; the exponent and sign are contained in the high word. The fraction-width bound also keeps every four-limb product-rounding shift strictly above one word. bitWidth ≤ 128 bounds the storage to two words. Layouts whose fraction has at most 64 bits are outside this capability.

Instances For
    @[instance_reducible, inline]

    Decide eligibility from the descriptor fields.

    The explicit conditional and @[inline] annotation expose the decision to simplification 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]

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

                                  The exponent is masked to the exponent field, and the significand's implicit bit is discarded by the high fraction mask. The result is meaningful when the exponent fits the field and the significand is normal; Core.Proof.packNormal_eq_ofFields states that contract.

                                  Instances For