-
Notifications
You must be signed in to change notification settings - Fork 685
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
Add initial Sail snippets #1838
base: main
Are you sure you want to change the base?
Conversation
Add Makefile targets to download the Sail JSON bundle from Github releases (it's a few MB so this avoids bloating the repo). I updated a few scalar crypto functions that already had copy & pasted Sail code to use the model source instead. The result is almost identical.
Note, @Alasdair has demonstrated a fancier version of this with syntax highlighting and hyperlinked code (e.g. so you can click on Before: After: (The Sail code has changed a little since that was copy/pasted.) |
Question, do we need to care about the version of the SAIL model we're pulling the index from? I recognize SAIL isn't at v.1.0 yet so perhaps at this point we don't, but in the future should we? Or perhaps we pair a SAIL version with the riscv-isa-manual src when we build a release for publication? |
There are a couple of aspects to that:
For the second point my vague plan was:
and you say "yeah but I know the version is 1.12", and then it will only insert I don't think Alasdair has published that yet so I'm not exactly sure what you have to do but it will probably end up with us having separate However, I also don't think that is a blocker. I would suggest initially we just use it for snippets where the behaviour has never changed and is unlikely to change in future. |
Excellent, thanks Tim, I mostly wanted to be sure the versioning question was on the table for discussion. So thanks for confirming to me that it is indeed out there. |
I'm curious what parts of sail are actually supposed to be integrated into the risc-v manual? Are we just talking about the execution function of each instruction? |
Mostly the
(And I think this code could be improved a fair bit too before we include it, e.g. |
@Timmmm I have a question on this. Can you pull Sail code per instruction? Or in case of switch-case style of Sail, you are pulling that whole block? |
Yeah you can, though not in this PR. E.g. for this:
You can say "show me the code for when
However I've only seen that in a prototype that @Alasdair showed. I don't know if it has made it into the Sail compiler or asciidoctor-sail yet. Also someone brought up the valid point that it might be confusing to see synthetic code in the ISA manual that isn't literally in the Sail model. But... I think it is probably fine anyway. We can hyperlink to the place the code came from (also part of that prototype), and maybe even add a little disclaimer explaining the situation. |
You can learn more about the features of the asciidoctor-sail plugin here: https://github.com/Alasdair/asciidoctor-sail |
I've came across that before @nadime15, but is that where all this transformations @Timmmm mentioned is being done? |
Something to consider here is that the asciidoctor-sail plugin currently only targets PDF (as far as I know). It may be possible to transpile it to work with asciidoctor.js but I have not tried yet. |
@AFOliveira The last chapter, Splitting Sail Definitions, seems to describe what @Timmmm demonstrated. However, I would double-check if it actually works as expected. For instance, when I tried pulling in Sail code, including the function header ( |
I've tried this many months ago and I was also not able to do so. Thus, my question on individual instructions, rather than blocks. Isn't what @Timmmm was describing a new feature, that may not be on that repo yet? |
Moreover, I see that as a problem given that the information is not going to be static in this manual, how would ratification look? Would the output pdf be ratified rather than the asciidoc source? Would we it be dependent on Sail being ratified and this tool? Please don't misunderstand me, I think this is awesome work, I just want to poke around and understand how this process may happen. |
The thinking was/is that the SAIL index would be versioned at the time a riscv-isa-manual release was published with the SAIL index version described within the release as a point-in-time index. However, I don't believe a decision was ever made for how to do this. I was always hopeful that v1.0 of the SAIL model would be the first version included with a published ISA release. |
It should just work with any Asciidoctor output format, for example the Sail manual is built with the plugin outputting to html. You only need asciidoctor.js if you want to build Asciidoc into html client-side right? Last I looked, the RISC-V manuals used quite a few other plugins like asciidoctor-bibtex and asciidoctor-mathematical, do those work with asciidoctor.js?
Currently the translation is done by Sail - provided it's explicitly requested with an annotation on the definition. Right now the structure of the Sail tries to follow the granularity of the unprivileged spec, so because 4.2.2 has a single section and encoding diagram for "Integer Register-Register Operations" which combines SLL, SRA, ADDW etc. we also do the same. I think for the transformation to really work it might require the development version of the Sail compiler/plugin, as I had to implement additional annotations in the AST to correctly re-sugar the code after the constant-folding and constant-propagation passes are applied to simplify the definition. I'm planning a new release soon though. |
@Alasdair I may not have fully understood your answer, but from what you're saying, in cases like Integer Register-Register Operations, we can't split them apart for now, correct? Would the idea be to place them in the spec exactly where that text appears so they serve as complementary information? I see how this approach might make merging into the spec easier in its current form, but I find the switch-case style of Sail somewhat problematic. The way the spec is written in those sections makes it difficult to locate information throughout the manual, and importing that structure into Sail seems to perpetuate that issue—would you agree? I'm working on developing a well-structured instruction index (similar to what other ISAs have) to improve manual searchability. Ideally, I’d love to have Sail indexed per instruction, but I assume that isn't feasible yet. My questions were meant to clarify whether, regardless of the current Sail source code, we will eventually be able to see this information split. Is that something your new release will enable? |
I would agree with this regarding the structure of both the Sail and the manual. We could re-factor the Sail, but I do think staying as close as possible to current manual is also important.
I hope so! I did some experiments a while ago where I generated a big html document of all the instructions in the Sail model with this splitting a while ago, and it seemed to work. Right now I'm quite focused on configurability and modularisation of the model, but this is something I'd like to re-visit. |
Yes, should be.
It definitely works with HTML too. We've been using it for CHERI for a long time.
It is static. When a new release of the Sail model happens there would be a PR to update the |
Thank you all for the explanations! |
Who do we need to review this? There's loads of scope for improvements in future but I think we need to actually start somewhere and this feels like an uncontroversial first step. |
@aswaterman any thoughts here? |
Add Makefile targets to download the Sail JSON bundle from Github releases (it's a few MB so this avoids bloating the repo).
I updated a few scalar crypto functions that already had copy & pasted Sail code to use the model source instead. The result is almost identical.
See #1369.