[llvm] [AArch64][SME2] Add ZT0 attributes to SMEAttrs (PR #77607)
Sander de Smalen via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 15 07:41:26 PST 2024
================
@@ -92,13 +97,22 @@ class SMEAttrs {
}
// Interfaces to query ZT0 State
- bool hasNewZT0Body() const { return Bitmask & ZT0_New; }
- bool isZT0In() const { return Bitmask & ZT0_In; }
- bool isZT0Out() const { return Bitmask & ZT0_Out; }
- bool isZT0InOut() const { return Bitmask & ZT0_InOut; }
- bool preservesZT0() const { return Bitmask & ZT0_Preserved; }
+ StateValue getZT0State() const {
+ return static_cast<StateValue>((Bitmask & ZT0_Mask) >> ZT0_Shift);
+ }
+ void setZT0State(StateValue S) {
+ Bitmask |= (static_cast<unsigned>(S) << ZT0_Shift);
+ }
----------------
sdesmalen-arm wrote:
To enable the use of the `SMEAttrs` constructor using e.g. `SMEAttrs(<mask>)`, perhaps it makes more sense to change `setZT0State` to something that encodes the value given a bitmask, i.e.
```
static unsigned decodeZT0State(unsigned Bitmask) {
return static_cast<StateValue>((Bitmask & ZT0_Mask) >> ZT0_Shift);
}
static unsigned encodeZT0State(StateValue S) {
return static_cast<unsigned>(S) << ZT0_Shift;
}
```
That avoids having to do:
```
SA ZT0_In = SA(SA::Normal);
ZT0_In.setZT0State(SA::StateValue::In);
```
and instead allows:
```
SA ZT0_In = SA(SA::encodeZT0State(SA::StateValue::In));
```
without the extra level of indirection.
https://github.com/llvm/llvm-project/pull/77607
More information about the llvm-commits
mailing list