Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

saturating arithmetic builtins: add, sub, mul, shl #9619

Merged
merged 16 commits into from
Sep 1, 2021

Commits on Aug 29, 2021

  1. saturating arithmetic builtins: add, sub, mul, shl

    - adds 1 simple behavior tests for each
      which does integer and vector ops at
      runtime and comptime
    - adds bigint_*_sat() methods for each
      which simply set dest to the type
      min/max boundaries if they are
      exceeded.  these should to be
      audited for correctness and perhaps
      there is a better existing way to
      accomplish this.
    - the mul intrinsic needs to somehow
      explicitly provide a scale parameter
      (which seems to default to 0?)
    travisstaloch committed Aug 29, 2021
    Configuration menu
    Copy the full SHA
    63ef1db View commit details
    Browse the repository at this point in the history
  2. bigint saturation: compute bits required

    - rather than initializing new integers
      for min/max, compute the number of
      bits required using
      bigint_bits_needed(). NOTE: this
      doesn't allow for types larger than 64
      bits.
    - rename bigint_saturate() ->
      bigint_clamp_by_bitcount()
    - adds a few more test cases
    travisstaloch committed Aug 29, 2021
    Configuration menu
    Copy the full SHA
    69e64bf View commit details
    Browse the repository at this point in the history
  3. zig_llvm: pass scale = 0 to mul_fix_sat intrinsics

    - use CreateIntrinsic() which accepts a
      variable number of arguments to pass
      the scale parameter
    travisstaloch committed Aug 29, 2021
    Configuration menu
    Copy the full SHA
    bf33759 View commit details
    Browse the repository at this point in the history
  4. update langref

    travisstaloch committed Aug 29, 2021
    Configuration menu
    Copy the full SHA
    b18d436 View commit details
    Browse the repository at this point in the history
  5. simplify bigint_clamp_by_bitcount()

    - rather than re-initializing, we only
      need to shift the least significant digit
      right by the number of 'extra' bits
    travisstaloch committed Aug 29, 2021
    Configuration menu
    Copy the full SHA
    1a4d70a View commit details
    Browse the repository at this point in the history
  6. rework bigint_clamp_by_bitcount() again

    - works for ints > 64 bits
    - add a few more test cases for ints >
      64 bits
    travisstaloch committed Aug 29, 2021
    Configuration menu
    Copy the full SHA
    db389ce View commit details
    Browse the repository at this point in the history
  7. clean up bigint_clamp_by_bitcount()

    - move bound computations closer to usage within cases
    - rename op -> dest for consistency
    travisstaloch committed Aug 29, 2021
    Configuration menu
    Copy the full SHA
    0b74123 View commit details
    Browse the repository at this point in the history
  8. sat-arithmetic: add more test cases

    - adds more test cases suggested by matu3ba
    - better explain clamping algorithm in comments
    travisstaloch committed Aug 29, 2021
    Configuration menu
    Copy the full SHA
    6b6c63a View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    437fba2 View commit details
    Browse the repository at this point in the history
  10. sat-arithmetic: make tests actually run at runtime

    - rework test cases which were skipping runtime evaluation. this uncovered
      bugs related to *mul.fix.sat intrinsic.
    - removed extra type args in ZigLLVMBuild*MulFixSat so mul.fix.sat intrinsic
      is called correctly
    - replaced panics in ir.cpp with compile errors.
    - added case to test/compile_errors.zig given floats
    - updated langref: indcate future `a +| b` syntax
    travisstaloch committed Aug 29, 2021
    Configuration menu
    Copy the full SHA
    6b21164 View commit details
    Browse the repository at this point in the history

Commits on Aug 30, 2021

  1. sat-arithmetic: make tests actually run at runtime

    - rework test cases which were skipping runtime evaluation. this uncovered
      bugs related to *mul.fix.sat intrinsic.
    - removed extra type args in ZigLLVMBuild*MulFixSat so mul.fix.sat intrinsic
      is called correctly
    - replaced panics in ir.cpp with compile errors.
    - added case to test/compile_errors.zig given floats
    - updated langref: indcate future `a +| b` syntax
    travisstaloch committed Aug 30, 2021
    Configuration menu
    Copy the full SHA
    d72cb46 View commit details
    Browse the repository at this point in the history
  2. sat-arithmetic: tweak bigint clamping

    - account for `maxInt(iN) *| -1 == minInt(iN) + 1`
    - explain upstream bug in llvm.smul.fix.sat and link to ziglang#9643 in langref and commented out test cases
    travisstaloch committed Aug 30, 2021
    Configuration menu
    Copy the full SHA
    fc0ff06 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    039c35c View commit details
    Browse the repository at this point in the history

Commits on Aug 31, 2021

  1. sat-arithmetic: skip mul tests if arch == .wasm32

    - ci is erroring with 'LLVM ERROR: Unable to expand fixed point multiplication' when compiling for wasm32
    - just trying to get ci to pass. not sure this is correct to skip
    travisstaloch committed Aug 31, 2021
    Configuration menu
    Copy the full SHA
    4e11ae1 View commit details
    Browse the repository at this point in the history
  2. sat-arithmetic: skip mul tests if arch == .wasm32

    - prevent the llvm error by making test helper param `op` comptime.  this way mul instructions are only generated in mul test
    travisstaloch committed Aug 31, 2021
    Configuration menu
    Copy the full SHA
    4880d87 View commit details
    Browse the repository at this point in the history

Commits on Sep 1, 2021

  1. Configuration menu
    Copy the full SHA
    938b5bf View commit details
    Browse the repository at this point in the history