Open bgamari opened 2 months ago
It is not entirely clear what to do about this. Ideally we would be able to disable the rewrite into foldr/build
form, but sadly GHC isn't really equipped for this sort of selective disabling of rules. The obvious alternative is to perform the inverse rewrite in Clash, although this could get tricky.
We should add an primitive evaluator rule for unpackFoldrCString#
to https://github.com/clash-lang/clash-compiler/blob/b14ff0ef2ccfad8854210a9035e9db1e32b3be07/clash-ghc/src-ghc/Clash/GHC/Evaluator/Primitive.hs#L236
I suppose this rule should rewrite unpackFoldrCString# "..."# (:) []
to "..."
?
Yes, preferably rewrite it to unpackCString# “…”
instead of (:) '.' ((:) '.' ((:) '.' []))
. Although it’s probably good to always have the latter translation as a fallback in case the function and the starting value are something else than (:)
and []
If one writes
nameHint (SSym @"hi") ...
there is a good chance that GHC'sunpack
rewrite rule will rewrite theString
in the term-level evidence carried bySSym
(which is the only thing preserved in the netlist) intobuild (unpackFoldrCString# "hi")
. The logic inClash.Netlist.BlackBox.Util.exprToString
understandably cannot deal with this, resulting in errors of the form:Perplexingly, the
build
call doesn't seem to be reflected in the netlist.