Skip to content

Conversation

@Qwinci
Copy link

@Qwinci Qwinci commented May 6, 2025

Add versions of read/write that take in an additional offset. It is useful for accessing register arrays, previously you had to do something like

auto value = arch::scalar_load_relaxed<arch::bit_value<uint32_t>>(space, regs::myRegStart + index * 4);
value |= myReg::value(true);
arch::scalar_store_relaxed(space, regArrayStartOffset + index * 4, value);

whereas with this change you can do

auto value = space.load_relaxed(regs::myReg, index * 4);
value |= myReg::value(true);
space.store_relaxed(regs::myReg, index * 4, value);

@avdgrinten
Copy link
Member

There are some alternatives to this that are worth considering:

@avdgrinten
Copy link
Member

Is still useful to have functions that take an offset despite these alternatives being available? I'm not necessarily against the new functions but I'd like some justification why the existing approaches are inconvenient.

@Qwinci
Copy link
Author

Qwinci commented May 7, 2025

I guess the approach with a function is pretty nice, I didn't think of that. The functions that take in offsets aren't probably needed over that though I think they could possibly still be a nice option for e.g. registers where the offset depends on multiple runtime variables (as in that case for the function approach you'd have to either pass multiple parameters/have it as a member function and the subspace method is kinda long).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants