-
Notifications
You must be signed in to change notification settings - Fork 235
Scatter termination.sail #1376
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
base: master
Are you sure you want to change the base?
Scatter termination.sail #1376
Conversation
|
Would #905 eliminate the need for |
That's blocked on rems-project/sail#1357, so I'm okay with merging this first and removing |
|
@Ptival looks like this needs newlines at end-of-file fixes to pass pre-commit. |
|
Looks like I might have broken something on the Lean side too, I'll investigate: https://github.com/riscv/sail-riscv/actions/runs/19080408022/job/54510837967 |
ef03dc8 to
b3a7375
Compare
f5c10d0 to
cd5a62a
Compare
Timmmm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks much better to me! It would be good to get an explanation of exactly what this is for and how it works for people who aren't formal experts.
647b481 to
83fcead
Compare
83fcead to
61540a5
Compare
Ah interesting, I'm going to have a quick look at why your error happens. In the meantime, I have updated the Leaving this as a draft PR until we figure out whether we can remove the whole |
8eebf25 to
65d90f2
Compare
|
I have followed the removal of |
pmundkur
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Since the measures are now appearing in the main code, it would be helpful to have some explanatory comments where previously there weren't any.
| Ok(data) | ||
| } | ||
|
|
||
| termination_measure vmem_read_addr repeat n |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be helpful to explain the repeat construct here, and refer to it for the vmem_write_addr case below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I honestly don't know what this does precisely.
It's not very documented... according to the syntax documentation in the SAIL repo this shouldn't even be valid syntax...

@Alasdair I think maybe you added this, could you explain to me what this variant of termination_measure is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if I added it, but it's a termination measure for the loop in the function body. In the syntax repeat n is a valid loop_measure.
I think this can be placed inline and attached to the loop itself, which might be more clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I think I saw the syntax for putting it next to the loop, I will give it a try, as I agree it would be more clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I attempted something. It needs magic_hash for some reason. I'll wait for CI to check because I think this is specifically exercised by the Rocq backend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't use that option in the model, it's for debugging generated code that uses internally generated identifiers that can't clash with user identifiers (by allowing it to be passed back into the frontend) . If it doesn't support it we should just keep the termination measure separate for now. I also don't guarantee that debug flags will persist between Sail versions, and that flag has mostly been superseeded by the $sail_internal directive which is file-local and more descriptive, so it is actual risk of being removed.
I'm really not sure why using an inline termination measure would require that option anyway. I'll look into changing that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright I reverted it!
5ddc35b to
762e228
Compare
762e228 to
9714790
Compare
Following the merge of #1219 , it would be nice to scatter the termination module, in such a way that one could require some termination measures without having to include every single instruction in their output.
The main culprit here was
compressed_measure, but once that one is scattered (thanks @jn80842), it's a small extra step to just move around the rest of the code and get rid of the termination module altogether.I tried to remove all references to the module, but may have missed some.
I was also instructed that the termination measures for
vmem_read_addrandvmem_write_addrmight no longer need to be protected only for the Rocq output, so they get taken out of the$iftarget coq.I have only tested the Lean output, so I'm hoping the CI will check whether my changes are consistent.
Happy to discuss any of the decisions I made, they could be based on incorrect assumptions on my end.