-
Notifications
You must be signed in to change notification settings - Fork 164
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
Fix lem build in Makefile #353
Conversation
I split the commits so the actual model changes are in the first commit (which are all small refactorings). The second commit contains all the lem hackery to fix the build |
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.
My review is mainly questions. I don't see anything wrong in the code and will approve the PR once the questions are answered.
One exception: the 'effects' of certain functions need to be removed, yes?
Unable to comment on lem code due to lack of knowledge.
@@ -184,15 +185,7 @@ C_LIBS += $(SAIL_LIB_DIR)/coverage/libsail_coverage.a -lm -lpthread -ldl | |||
endif | |||
|
|||
RISCV_EXTRAS_LEM_FILES = riscv_extras.lem mem_metadata.lem riscv_extras_fdext.lem | |||
# Feature detect if we are on the latest development version of Sail |
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.
Why was the check of the Sail version removed?
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's a check for a version of Sail that is many years old, and no longer works with the model.
model/riscv_insts_vext_utils.sail
Outdated
@@ -976,8 +976,7 @@ function rsqrt7 (v, sub) = { | |||
|
|||
val riscv_f16Rsqrte7 : (bits_rm, bits_H) -> (bits_fflags, bits_H) effect {rreg} |
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.
Remove effect throughout.
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.
These lines are not part of this PR
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.
You are seeing them just because this PR was opened before my other PR removing the effects separately was merged.
model/riscv_insts_vext_utils.sail
Outdated
@@ -1006,14 +1003,12 @@ function riscv_f32Rsqrte7 (rm, v) = { | |||
0x0080 => (zeros(5), 0x00000000), | |||
0x0020 => (zeros(5), rsqrt7(v, true)[31 .. 0]), | |||
_ => (zeros(5), rsqrt7(v, false)[31 .. 0]) | |||
}; | |||
(fflags, result) | |||
} | |||
} | |||
|
|||
val riscv_f64Rsqrte7 : (bits_rm, bits_D) -> (bits_fflags, bits_D) effect {rreg} |
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.
Remove effect
model/riscv_insts_vext_utils.sail
Outdated
@@ -988,14 +987,12 @@ function riscv_f16Rsqrte7 (rm, v) = { | |||
0x0080 => (zeros(5), 0x0000), | |||
0x0020 => (zeros(5), rsqrt7(v, true)[15 .. 0]), | |||
_ => (zeros(5), rsqrt7(v, false)[15 .. 0]) | |||
}; | |||
(fflags, result) | |||
} | |||
} | |||
|
|||
val riscv_f32Rsqrte7 : (bits_rm, bits_S) -> (bits_fflags, bits_S) effect {rreg} |
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.
Remove effect.
model/riscv_vlen256.sail
Outdated
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.
Why is this part of this PR? Seems like an orthogonal addition.
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.
There are two reasons the lem build fails. First, the use of class
as an identifier, and second that the vlenmax is much too high. To make the lem build work we need a smaller vlenmax.
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.
Ideally we would be able to disable V, but the extension is too intertwined into the base model right now to have a sail-riscv model without V, so having a shorter vlenmax is the best we can do.
Please rebase rather than merge to keep the history untangled |
Sorry, I didn't realise the github update branch button did a merge by default. I'll fix it. |
class is a reserved keyword in lem, so the use of class as a variable name was causing issues. While ultimately this should be fixed in Sail this can easily be worked around here. Fortunately the code in questions was ultimately using a pattern like let class = f(x); let y = match class { ... }; y which can be simplified to match f(x) { ... } removing the variable entirely, and making the code simpler so a win-win overall!
For what it's worth, I've got development versions of Lem and Sail to handle the model with vectors and machine words, but I think the switch to bitlists by default is worthwhile because it's a little more robust. However, this does mean that the |
Switch to bitlist representation because the machine words can't handle the vector code currently Remove RMEM target from default set of targets in Makefile. This is only interesting for RMEM maintainers. There's no reason for it to be generated by default, and it's also broken. While we are hacking on these files purge the duplicate versions for Sail 0.11+
Ok, the additional vlen file is gone and it seems to build fine. |
I think more people are running into this issue, would be good to get this merged I think |
Will do
…On Tue, Dec 19, 2023, 12:25 PM Alasdair Armstrong ***@***.***> wrote:
I think more people are running into this issue, would be good to get this
merged I think
—
Reply to this email directly, view it on GitHub
<#353 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AXROLOHXZTUH2L3QRLA4OBDYKHZ2VAVCNFSM6AAAAAA7QRUDXCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNRTGQZDKNBYHA>
.
You are receiving this because you were assigned.Message ID:
***@***.***>
|
'class' is a reserved keyword in lem, so the use of class as a variable name was causing issues. While ultimately this should be fixed in Sail this can easily be worked around here.
Fortunately the code in questions was always using a pattern like
which can be simplified to
So I didn't have to invent a new variable name, and got to make the code simpler in the process!
Fixing this unfortunately causes some other issues to become apparent. The machine words library can't handle the large vlenmax, so we have to create a separate file with a smaller vlenmax for the theorem provers. There were also some other issues, so I switched out the default representation to bitlists until they can be resolved, and cleaned up some legacy cruft in handwritten_support while I was there.
The rmem target has similar issues, but as this is only really useful for rmem maintainers it doesn't make sense to run by default, so I removed it from the default set of targets.
This should fix #325