This project is mirrored from https://*****@github.com/clash-lang/clash-compiler.git. Pull mirroring updated .
  1. 16 Sep, 2021 1 commit
    • Peter Lebbing's avatar
      clash-testsuite: three fixes (#1930) · 8a52fa33
      Peter Lebbing authored
      - The logic for `TestExitCode` in `runFailingProgram` was wrong:
        - `TestExitCode`: correct
        - `NoTestExitCode`: correct
        - `TestSpecificExitCode`:
           - A program succeeding will always report error, even if
           `TestSpecificExitCode 0` is used.
           - A program failing will always report success, even if the
           specific exit code did not match the intended one.
      
      Because all current tests use `TestExitCode`, the wrong logic was not a
      problem in practice so far.
      
      - The error message for `runProgram` with its `stdF` argument set to
      `True` would be the wrong error message for that failure condition, even
      mentioning an incorrect return code of the program!
      
      - We have a test to check that a program, or alternatively specificly
      VVP, does not produce anything on stdout. However, this was in many
      places named and documented as if it checked that it _does_ produce
      something on stderr. Names and documentation adapted so they now
      correspond to the actual functionality (which was correct).
      
      Finally, some minor tuning to messages.
      8a52fa33
  2. 13 Sep, 2021 2 commits
    • Christiaan Baaij's avatar
      Don't loop on hidden recursive data type · 865da874
      Christiaan Baaij authored
      The recursive occurrence  was hiding behind a type family. So we
      should always expand type families when checking whether a
      data type is recursive.
      
      Fixes #1921
      865da874
    • Alex McKenna's avatar
      Don't use newest prettyprinter release · c73a6683
      Alex McKenna authored
      The new version of prettyprinter (1.7.1) adds a DEPRECATED pragma to the
      old-style modules for the library. To prevent CI failing, the upper
      bound is lowered to not pick this version.
      c73a6683
  3. 07 Sep, 2021 1 commit
  4. 06 Sep, 2021 1 commit
  5. 02 Sep, 2021 1 commit
  6. 31 Aug, 2021 4 commits
    • Alex McKenna's avatar
      Add Core Unfoldings to PrimInfo · 6645dda8
      Alex McKenna authored
      PrimInfo now contains the Id of a known core defnition for a primitive.
      This means that the evalautor can be made to fallback on the core
      if there is no explicit evaluation rule for a given primitive.
      6645dda8
    • Alex McKenna's avatar
      Change isAbsurdAlt to isAbsurdPat · edf2f939
      Alex McKenna authored
      The functions to check if case alternatives have absurd patterns
      should only take in the pattern instead of the entire alternative.
      The term is never used, and the partial evalautor may want to
      filter alternatives after it has turned the alternatives into Value.
      edf2f939
    • Alex McKenna's avatar
      Add extra functions on UniqSet / VarSet · 8b2c6d1e
      Alex McKenna authored
      The partial evaluator requires the ability to take the difference of
      two UniqSet / VarSet, and check if they are empty or not. These
      functions are now exposed from the underlying IntMap.
      8b2c6d1e
    • Alex McKenna's avatar
      Fixes on Type related functions · 666d75aa
      Alex McKenna authored
      Functions like piResultTys now only throw a +debug error for type
      mismtaches when the coreviews of the types are not alpha-equivalent.
      The partial evaluator can encounter some cases where an argument
      unexpectedly has / does not have a Signal type.
      
      coreView1 now looks through annotations on types, as these are
      somewhat meta, and do not change the underlying type representation.
      666d75aa
  7. 30 Aug, 2021 5 commits
    • Alex McKenna's avatar
      Remove EXPERIMENTAL_EVALUATOR · 47a69eb0
      Alex McKenna authored
      The partial evaluator should not replace the old evaluator
      everywhere it is currently used, rather it should _only_ be used
      for partial evaluation. This is because the partial evaluator may
      not result in something that still repsects invariants (e.g. it
      may not preserve invariants expected to hold after ANF).
      
      Still TODO: It should probably be possible to selectively turn PE
      on or off by a flag (i.e. -fclash-partial-evaluator). I'm not sure
      how to do this in a way where the testsuite is still useful...
      47a69eb0
    • Alex McKenna's avatar
      Correction in Clash.Core.Util · 5e3e0d80
      Alex McKenna authored
      5e3e0d80
    • Alex McKenna's avatar
      d8373006
    • Alex McKenna's avatar
      Downgrade type change invariant to trace · 2ac65959
      Alex McKenna authored
      The type change check in normalization should not be an error
      when it is encountered, but instead a trace (as it will be
      encountered a lot due to Clash discarding casts from GHC core).
      2ac65959
    • Alex McKenna's avatar
      Store argument strictness in DataCon · 4e155ce9
      Alex McKenna authored
      The clash `DataCon` type now keeps track of the strictness of
      data constructor arguments, as determined by the `HsImplBang` in
      the GHC core. This can be used in the evaluator / transformations
      to help ensure that Clash's evaluation matches GHC's more closely.
      4e155ce9
  8. 26 Aug, 2021 9 commits
    • Alex McKenna's avatar
      Add unit tests for numeric newtypes · 234aee9d
      Alex McKenna authored
      234aee9d
    • Alex McKenna's avatar
      Add Clash.Num.Erroring · 760dda4a
      Alex McKenna authored
      Erroring is a newtype around any number with a SaturatingNum
      insteance, which changes the Num instance for the type to throw
      an XException on overflow / underflow (SatError).
      760dda4a
    • Alex McKenna's avatar
      Add Clash.Num.Overflowing · 128f5cc6
      Alex McKenna authored
      128f5cc6
    • Alex McKenna's avatar
      Add Clash.Num.Zeroing · de991368
      Alex McKenna authored
      Zeroing is a newtype around any number with a SaturatingNum
      instance, which changes the Num instance for the type to return
      0 on overflow / underflow (SatZero).
      de991368
    • Alex McKenna's avatar
      Add Clash.Num.Wrapping · a9b8d033
      Alex McKenna authored
      Wrapping is a newtype around any number with a SaturatingNum
      instance, which changes the Num instance for the type to wrap
      on overflow / underflow (SatWrap).
      a9b8d033
    • Alex McKenna's avatar
      Add Clash.Num.Saturating · dd160631
      Alex McKenna authored
      Saturating is a newtype around any number with a SaturatingNum
      instance, which changes the Num instance for the type to use
      normal saturating arithmetic (SatBound).
      dd160631
    • Alex McKenna's avatar
      Fix quot#/div# for Signed · f74543de
      Alex McKenna authored
      The quot# and div# primitives for Signed allowed values to overflow
      silently when the first argument was minBound and the second was -1.
      For example
      
      ```haskell
      >>> quot @(Signed 4) -8 -1
      8 :: Signed 4
      ```
      
      The fix requires a KnownNat constraint for quot# and div#, the
      relevant black boxes are also changed.
      f74543de
    • Alex McKenna's avatar
      Change negate implementation for Index · 6d2e3015
      Alex McKenna authored
      The implementation of negate for Index was implemented as
      
        maxBound -# i
      
      which is not really a negation, and produced some surprising
      results, e.g. negate 0 == maxBound. A more sensible implementation
      is treating negate as equivalent to
      
        satSub SatWrap 0 i
      
      which still produces somewhat surprising values (on account of
      every argument other than 0 underflowing) but is more in line with
      what is implemented by other numeric types.
      6d2e3015
    • Alex McKenna's avatar
      Add SatError to SaturationMode · f34251b8
      Alex McKenna authored
      Arithmetic using SatError will always throw an XException on
      overflow / underflow. This differs from normal operations, which
      may sometimes not throw an exception and silently wrap or throw
      another form of exception (i.e. ArithException for GHC types).
      f34251b8
  9. 25 Aug, 2021 3 commits
    • Alex McKenna's avatar
      Add multiple-hidden flag to clash-testsuite · dc2be75e
      Alex McKenna authored
      Some tests in the testsuite are behind a #ifdef which checks for
      multiple hidden, however multiple hidden is not a flag of
      clash-testsuite. This is added, and the CI script updated to use
      this flag in both the testsuite and prelude.
      dc2be75e
    • Peter Lebbing's avatar
      New: hidden-argument andEnable (#1849) · 39aafcf2
      Peter Lebbing authored
      `Clash.Explicit.Signal.enable` is renamed to `andEnable` and the
      existing name is deprecated. A new `Clash.Signal.andEnable` is added
      that performs the same function but using a `HiddenEnable` instead.
      
      Documentation in Clash.Signal is corrected and extended. Parts of the
      existing documentation were not rendered before this commit due to
      incorrect interaction between CPP #ifdef and Haddock syntax.
      
      The documentation has a new section called
      _Monomorphism restriction leads to surprising behavior_
      that warns users for issues with implicit parameters and offers advice
      on how to avoid them.
      
      A developer note [Going from WithSingleDomain to WithSpecificDomain] is
      added in the source, explaining the code.
      39aafcf2
    • Alex McKenna's avatar
      Update README for clash-term · e673655e
      Alex McKenna authored
      e673655e
  10. 16 Aug, 2021 2 commits
    • Alex McKenna's avatar
      Preserve boolean combinatorial logic in HDL · 1afe0084
      Alex McKenna authored
      When rendering HDL, clash now better preserves boolean functions
      from GHC which may be targeted by the simplifier. This helps ensure
      they are rendered in HDL as the expected operator instead of being
      rendered as a multiplexer.
      
      Fixes #1881.
      1afe0084
    • Alex McKenna's avatar
      Add missing warnings to Integer/Natural prims · 78852675
      Alex McKenna authored
      The dynamic-size warning on primitives using Integer / Natural is
      not consistently included in the .primtives files. This is down to
      a mix of legacy (the warning existed after integer prims) and new
      primitives being added and not having the warning (either by
      forgetting or the primtives around them not having the warning).
      78852675
  11. 12 Aug, 2021 3 commits
  12. 11 Aug, 2021 5 commits
  13. 08 Aug, 2021 1 commit
  14. 06 Aug, 2021 2 commits
    • Alex McKenna's avatar
      Add missing test for #478 · 39a62558
      Alex McKenna authored
      Fixes #481
      39a62558
    • Alex McKenna's avatar
      Added zeroWidthSpec transformation · 2725f909
      Alex McKenna authored
      A new transformation has been defined, which replaces lambda-bound variables
      for a zero-width value with the value itself in the body of the lambda. e.g.
      
      ```haskell
      data AB = A | B
      
      ab :: KnownNat n => Index n -> AB -> AB
      ab n A = if n >  0 then A else B
      ab n B = if n == 0 then B else A
      ```
      
      would see the values of n in the function body be replaced with 0 (the only
      possible value of the type `Index 1`)
      
      ```haskell
      ab _ A = if 0 > 0 then A else B
      ab _ B = if 0 == 0 then B else A
      ```
      
      the normalizer is then free to further normalize this to
      
      ```haskell
      ab _ _ = B
      ```
      
      where previously it would not be able to improve this during normalization.
      
      Fixes #508
      2725f909