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
[Proposal] Optional embedded metadata in Calyx #994
Comments
+1 I think the the approach mentioned above is already better than what we currently have. Another (future) suggestion would be to embed a Calyx program in some top-level
|
Yeah, this sounds great if it simplifies the weird file-on-the-side logistics we're currently dealing with! IMO a hacky approach where To expand on what @cgyurgyik said, the LLVM way to do this would be that the metadata is structured, i.e., it is implemented as an arbitrary data structure of sorts. That would look notionally like this:
Glancing over the LLVM LangRef's metadata section could be instructive. Anyway, just getting this out of the way to say it's what a fully-over-engineered version of this would look like, and that a flat blob seems fine for now. I didn't quite understand this:
I don't quite see how the compiler gets involved here TBH? |
Sorry I meant the language parser, which I suppose is distinct from the compiler itself |
+1 for Metadata hack. We can bikeshed on the syntax once the PR is up but I think parsing it as an opaque string and making it available to the context is the good thing to do. |
I was more so thinking of just abusing MLIR attributes, but I think they're both capable of accomplishing the task :-). |
Worked up a simple prototype for this in llvm/circt#2959. |
To document some of the things we've been discussing synchronously. The current metadata system/format works with
pos
attributes attached to leaf nodes in the Calyx control tree (invoke
s andenable
s) and a separate metadata file which defines a map between these position tags and the source position to emit when active.The mapping file being separate from the Calyx code it is attached to creates a bit of a "linking" problem as it requires our toolchains (and really the end user) keep track of where the file is and what Calyx program it belongs to. The advantage of this is that the main Calyx parser does not need to be aware of the metadata and if a program is not being given to the debugger there is minimal overhead for the position attributes.
On the whole after talking to y'all and @cgyurgyik, I am generally of the opinion at this point that it would be better overall to have some in IR notion of an optional metadata table/blob as part of the file itself.
There are some disadvantages to this in that it requires the Calyx parser to be aware of the metadata format and places it on the main path with respect to maintainability. This also introduces a "backedge" type of dependency between Cider and the compiler which is potentially undesireable.
On the other hand, this makes the metadata far easier to use on the toolchain (no need to track separate files) and making it an optional component should hopefully reduce some of the overhead from having it in the first place. This also gives us a good site to think about further extensions to the metadata in tandem with language changes and gives us the opportunity to sanitize and otherwise operate on the metadata through program transformations though I don't know whether we would actually want to do that.
As a concrete syntax proposal, we could add an optional block at the end of the file which looks like:
where the internals of the block are the current contents of the (separate) metadata file.
I think this is no harder for front-ends to generate as it requires the same information but frees them of needing to open/write a separate file.
The text was updated successfully, but these errors were encountered: