-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Look through annotations in tyfam solving (#2677)
1. Annotations are implemented as type synonyms. 2. GHC looks through type synonyms when matching type families 3. So Clash should do the same. Fixes #2593 (cherry picked from commit da6ee06) Co-authored-by: Christiaan Baaij <[email protected]>
- Loading branch information
1 parent
77ded2e
commit 1f4c73f
Showing
4 changed files
with
29 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
FIXED: HDL generation fails when using multiple-hidden feature in combination with synthesis attributes [#2593](https://github.com/clash-lang/clash-compiler/issues/2593) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
Copyright : (C) 2012-2016, University of Twente, | ||
2016 , Myrtle Software Ltd, | ||
2017 , Google Inc. | ||
2021 , QBayLogic B.V. | ||
2021-2024, QBayLogic B.V. | ||
License : BSD2 (see the file LICENSE) | ||
Maintainer : QBayLogic B.V. <[email protected]> | ||
|
@@ -452,6 +452,10 @@ funSubst | |
funSubst _ Nothing = const Nothing | ||
funSubst tcm (Just s) = uncurry go | ||
where | ||
-- AnnType cannot be matched in type-families within regular GHC (as they | ||
-- are type synonyms) so it is fine to skip over them here. | ||
go (AnnType _ t1) t2 = go t1 t2 | ||
|
||
go (VarTy nmF) ty = case lookup nmF s of | ||
Nothing -> Just ((nmF,ty):s) | ||
-- Given, for example, the type family definition: | ||
|
@@ -470,6 +474,10 @@ funSubst tcm (Just s) = uncurry go | |
Just ty' | ty' `aeqType` ty -> Just s | ||
_ -> Nothing | ||
|
||
-- Only look through annotations in RHS after the VarTy case, so we can | ||
-- preserve annotations in the substitution created by the VarTy case above | ||
go t1 (AnnType _ t2) = go t1 t2 | ||
|
||
-- [Note] funSubst FunTy | ||
-- | ||
-- Whenever type classes have associated types whose instances 'map' to | ||
|
@@ -495,13 +503,11 @@ funSubst tcm (Just s) = uncurry go | |
, argView tcm r2 -- See [Note: Eager type families] | ||
) | ||
|
||
go ty1@(ConstTy _) ty2 = | ||
-- Looks through AnnType | ||
if ty1 `aeqType` ty2 then Just s else Nothing | ||
go (ConstTy c1) (ConstTy c2) | ||
| c1 == c2 = Just s | ||
|
||
go ty1@(LitTy _) ty2 = | ||
-- Looks through AnnType | ||
if ty1 `aeqType` ty2 then Just s else Nothing | ||
go (LitTy l1) (LitTy l2) | ||
| l1 == l2 = Just s | ||
|
||
go _ _ = Nothing | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module T2593 where | ||
|
||
import Clash.Prelude | ||
import Clash.Annotations.SynthesisAttributes | ||
|
||
topEntity :: | ||
Signal System Bit -> | ||
Signal System Bit `Annotate` 'StringAttr "breaka" "me" | ||
topEntity dIn = | ||
exposeClockResetEnable (register 0) clk rst en dIn | ||
where | ||
clk = clockGen | ||
rst = resetGen | ||
en = enableGen |