Skip to content

Add GHC 9.10.2 support #2983

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Add GHC 9.10.2 support #2983

wants to merge 6 commits into from

Conversation

martijnbastiaan
Copy link
Member

Still TODO:

  • Write a changelog entry (see changelog/README.md)
  • Check copyright notices are up to date in edited files

GHC may insert coercions making Clash see underlying types. For the
types mentioned in the commit title, this means Clash will see either a
`Natural` or an `Integer`. These types are (for better or for worse)
represented as machine words, potentially truncating any operations. As
a concrete example, take:

    top :: Unsinged 68 -> Unsigned 68 -> Vec 1 (Unsigned 64)
    top x y = let res = x + y in res `seq` res :> Nil

Translated to core, we get:

    λ(x :: Unsigned 68) ->
    λ(y :: Unsigned 68) ->
    let
      nt :: Natural
      = +# @68 topEntity2[GlobalId] x[LocalId]
          y[LocalId]
    in case nt[LocalId] of
         _ ->
           Cons @(+ 0 1) @(Unsigned 68) @0
             (_CO_ @(~# Natural Natural (+ 0 1) (+ 0 1)))
             nt[LocalId]
             ((Λb ->
                Nil @0 @b (_CO_ @(~# Natural Natural 0 0)))
                @(Unsigned 68))

I.e., the result of `x + y` gets assinged to a binder of type `Natural`,
making the calculation truncate.
@kleinreact
Copy link
Member

Great update!

I think we still should wait until the plugins run on 9.10.2 though (cf. clash-lang/ghc-typelits-natnormalise#89). It may be worth to reference this as a dependency here.

@martijnbastiaan
Copy link
Member Author

clash-lang/ghc-typelits-natnormalise#91

Luckily it's just an issue with the testsuite, not the plugin itself, so I feel okay merging this. I've published a fix in the linked PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants