[llvm] [AMDGPU][NFC] Refine the representation of MODE register values. (PR #177574)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 23 05:25:59 PST 2026
================
@@ -60,26 +58,44 @@ class AMDGPULowerVGPREncoding {
static constexpr unsigned OpNum = 4;
static constexpr unsigned BitsPerField = 2;
static constexpr unsigned NumFields = 4;
- static constexpr unsigned FieldMask = (1 << BitsPerField) - 1;
static constexpr unsigned ModeWidth = NumFields * BitsPerField;
static constexpr unsigned ModeMask = (1 << ModeWidth) - 1;
- using ModeType = PackedVector<unsigned, BitsPerField,
- std::bitset<BitsPerField * NumFields>>;
-
static constexpr unsigned VGPRMSBShift =
llvm::countr_zero_constexpr<unsigned>(AMDGPU::Hwreg::DST_VGPR_MSB);
- class ModeTy : public ModeType {
- public:
- // bitset constructor will set all bits to zero
- ModeTy() : ModeType(0) {}
+ struct OpMode {
+ // No MSBs set means they are not required to be of a particular value.
+ std::optional<unsigned> MSBits;
+
+ bool update(const OpMode &New, bool &Rewritten) {
+ bool Updated = false;
+ if (New.MSBits) {
+ if (*New.MSBits != MSBits.value_or(0)) {
+ Updated = true;
+ Rewritten |= MSBits.has_value();
+ }
+ MSBits = New.MSBits;
+ }
+ return Updated;
----------------
arsenm wrote:
I feel like there's a simpler way to write this
https://github.com/llvm/llvm-project/pull/177574
More information about the llvm-commits
mailing list