-
-
Notifications
You must be signed in to change notification settings - Fork 326
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
Improve internal register API #699
Comments
@10110111 I've started to more seriously prototype this out in a branch and sometime soon, I'd love some feedback. Basically, our State API isn't amazing for supporting multiple arches. And it requires that the The idea is that a This should allow us to vastly simplify our I'd like to have a single API where we can just say:
etc.. The main benefit being that the state API becomes entirely arch independent. Thoughts? |
You'd still need the whole |
Not necessarily. A write operation would allow for overloading (unlike a read operation since we can't overload on return type). So we could have an API that looks like this:
This would allow the underlying |
Another option which I like less... is to instead just use inheritance with polymorphism. Have the state return a heap-allocated object which has an opaque platform-agnostic API, but is an instance of a platform-specific register class. |
This variant sounds good.
Isn't this mostly the same as returning In any case, I don't have more thoughts currently. I need to see the changes you're going to do as concrete code. |
Yea, for writing values, the path seems pretty easy, it's the reading values without so much inefficiency that's hard. I suppose... We could have the Less user-friendly, but would be optimally efficient (as far as we continue to copy data around goes). The "Ref" version would be copy-less for reads.... but we'd want to copy when the user asks for a concrete editable value, so maybe that's not a huge win overall? I'll play with it some more and see if I get to a point where it makes sense to push a branch to look at. |
A while ago I checked in the file
RegisterRef
with the goal of improving the Register API to make it more robust and involve less copying.Essentially it is kinda analogous to what
string_view
is to strings. It is a non-owning view of part of thePlatformState
object.The idea is that we can unify all of the "get_xxx_register" functions to always return a
RegisterRef
regardless of the register type, since it will simply point to the right bytes in the State object and know how many bytes are part of that register.The example I have checked in needs some work as it is clunky and requires a state object. I think a pointer can be even better and avoid this requirement. I think we don't even really have to worry about alignment issues since the underlying structures that we'd be pointing to would require that the data members be aligned.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: