Improved Compiler API #1932
Replies: 2 comments 3 replies
-
Good idea. There would have to be a part of this API in |
Beta Was this translation helpful? Give feedback.
-
My current use cases for read-back manifest files:
Something that I don't do but would like to start doing, is librarizing constraint files. Currently I have constraint files in individual projects (example), because at least for ISE, you need to list only the pins that you will actually connect (and it could be true of Vivado as well, I don't know, maybe it would cut down on warnings?). A nicer way of doing this would be to have a library of constraint files for supported boards, and then filtering them for the pins connected. I remember Kansas Lava had this, see this repo for an example of librarized UCF files. To do this fully, I would need to move more to Clash that is currently done in external hand-written HDL files. I haven't thought about this yet -- this would require target-specific Clash files that even hook up the clock managers etc. So this is just a pie-in-the-sky idea for now. |
Beta Was this translation helpful? Give feedback.
-
Problem
Historically,
clash-lib
has been designed from the point of view that it has one consumer —clash-ghc
. However, additional programs may be created which wish to use the compiler as a library. While they can interact with the compiler externally, by spawning aclash
process then collecting the output files, it is more desirable forclash-lib
to provide a suitable API.Moreover, for some use cases spawning a
clash
process is not enough. If a program wishes to use an intermediate stage of the compiler, such as the netlist, then there is currently no way to do that without piecing together calls toclash-ghc
andclash-lib
until the information can be extracted (e.g.runToNetlistStage
inclash-testsuite:lib
).Proposed Solution
I propose a new API is exposed by
Clash.Driver
which contains:ClashOpts
,TyConMap
,CompiledPrimMap
etc.BindingMap
ofTerm
Benefits
The main advantage of this proposal is that Clash becomes more amenable to third-party development. This means users who wish to develop tooling can access the output of different stages of the compiler, making it easier to develop proof-of-concept implementations for new compiler features without needing as much familiarity with the internals of
clash-lib
.This proposal also helps better set the stage for future potentially useful improvements, such as allowing Clash to start or stop compilation from a different stage. This is my initial motivation for this proposal.
Drawbacks
Even with a friendlier API for
Clash.Driver
,clash-lib
andclash-ghc
will be unstable and potentially vulnerable to change. An updated API designed for third parties to consume may be less likely to change, but users should not expect the same stability guarantees asclash-prelude
gives.CC @gergoerdi, whose mailing list post motivated me writing this proposal out
Beta Was this translation helpful? Give feedback.
All reactions