🐛 Fix write mask for whole-register write - #190
Merged
Conversation
elbeno
force-pushed
the
fix-written-mask
branch
from
August 31, 2026 15:28
2d843fd to
b90893d
Compare
bdeane-intel
requested review from
SANTOSHKUMARLAXMINARAYANRAI,
lukevalenty,
mjcaisse-intel and
siauthun
August 31, 2026 15:28
Problem: - When some bits in a register are not allocated into fields, writing a value to that register (`"reg"_r = value`) may incur a read-modify-write, because the mask used is the fields mask, despite the intention to write to the whole register. Solution: - When writing to a path, use the mask for the path rather than the mask aggregated from its known children.
elbeno
force-pushed
the
fix-written-mask
branch
from
August 31, 2026 15:34
b90893d to
baaeb03
Compare
Problem:
- There is no test exercising overlapping field writes.
Solution:
- Add a test.
- This is a niche situation, but when fields overlap and are written, the
ordering of the arguments determines the actual written value.
Example:
```cpp
// given fields:
using F0 = field<"f0", std::uint8_t, 0, 0>;
using F1 = field<"f1", std::uint8_t, 1, 0>; // contains (overlaps) F0
// when we say
write(grp("r.f0"_f = 1, "r.f1"_f = 0));
// the resulting value is 0b00
// i.e. as-if 1 is written to F0, then 0 is written to F1
// F1 "overwrites" F0
// when we say
write(grp("r.f1"_f = 0, "r.f0"_f = 1));
// the resulting value is 0b01
// i.e. as-if 0 is written to F1, then 1 is written to F0
// F0 "overwrites" F1
```
Note:
- Fields which overlap in a parent-child relationship already provoke a
compile-time error. i.e. the following is ill-formed:
```cpp
write(grp("r"_r = 0, "r.f0" = 1));
```
mjcaisse-intel
approved these changes
Sep 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem:
"reg"_r = value) may incur a read-modify-write, because the mask used is the fields mask, despite the intention to write to the whole register.Solution: