-
Notifications
You must be signed in to change notification settings - Fork 188
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
Create generalized interface for repetitive load/store instructions #766
Comments
Yeah I've thought about this before. Especially wrt. unaligned loads/stores. In theory it's not too hard and we have implemented a version of this in our fork. The showstopper is the call to announce the effective address for stores. As I understand it it has to happen before the store value is read, but Sail doesn't have first class functions so you can't pass a lambda function or whatever into your generic It only matters for the concurrency model which we aren't using so I don't really know too much about it. But yeah I agree it's annoying and it makes the Sail code look more complicated than it is. |
I did this in #467, creating generic read/write functions that handled misaligned accesses better. In that PR I just ignored the effective address thing. You can use scattered functions to work around the lack of lambdas if you want, but it does make the code a little bit more complex. The general pattern would be:
then in the file with
this is effectively the same as passing |
Ah clever! So... can we ignore the effective address thing? I don't really care about it personally, but presumably some people do? How much does it matter? |
Right now nobody is really using it. We could work around it by having the effective address announce take an explicit set of register dependencies if needed, so I don't think it should get in the way of writing the spec in the cleanest way. |
Okay, this looks good! I’m just wondering if it might make sense to generalize LOAD/STORE even further by passing the effective addresses directly. The reason I ask is that Zcmt, for example, reads directly from instruction memory without storing the address in a register. You can’t use LOAD directly, nor can I use the current implementation of LOAD because it relies on Another point is that, while I'm not sure how much it matters right now, the We could define some wrapper functions that use our current LOAD/STORE functions and call something like LOAD_RAW (I am pretty sure there is a better name 😄) and define a layered approach. |
Problem
Many current instructions and probably many future ones are based on load and store operations. I have noticed that the same code is repeated over and over again. Some examples are in Zcmp (#730), Zcmt (#757), Zilsd/Zcl (#765) and in extensions that are already implemented and lead to:
Proposed solution
Create a generalized interface or template mechanism that can handle the common aspects of load/store operations.
This abstraction would accept common arguments, like AccessType, Aquire, Release etc.
Expected benefits
As we also plan to integrate Sail Code into the specification we would also reduce the number of lines for all affected instructions (The generalized interface will be provided as part of the appendix)
Implementation approach
I thought of something like I did in Zcmt (#757) but only in better (return error cause + Retired Illegal, in case you want to take further action)
I would like to discuss the idea of generalizing load and store operations to reduce code redundancy, as many instructions essentially perform the same function. Before I start working on this, I would like to confirm whether this approach makes sense and if there is agreement.
The text was updated successfully, but these errors were encountered: