[dynarmic] reduce use 2 bits for LRU and 4 bits for clog2 of bit size

Signed-off-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
lizzie 2025-09-03 06:40:07 +00:00 committed by crueter
parent cca70732bf
commit ac5c2ae64b
2 changed files with 4 additions and 4 deletions

View file

@ -118,7 +118,7 @@ void HostLocInfo::AddValue(IR::Inst* inst) noexcept {
values.push_back(inst); values.push_back(inst);
ASSERT(size_t(total_uses) + inst->UseCount() < (std::numeric_limits<uint16_t>::max)()); ASSERT(size_t(total_uses) + inst->UseCount() < (std::numeric_limits<uint16_t>::max)());
total_uses += inst->UseCount(); total_uses += inst->UseCount();
max_bit_width = std::max<uint8_t>(max_bit_width, GetBitWidth(inst->GetType())); max_bit_width = std::max<uint8_t>(max_bit_width, std::countr_zero(GetBitWidth(inst->GetType())));
} }
void HostLocInfo::EmitVerboseDebuggingOutput(BlockOfCode* code, size_t host_loc_index) const noexcept { void HostLocInfo::EmitVerboseDebuggingOutput(BlockOfCode* code, size_t host_loc_index) const noexcept {

View file

@ -78,7 +78,7 @@ public:
return std::find(values.begin(), values.end(), inst) != values.end(); return std::find(values.begin(), values.end(), inst) != values.end();
} }
inline size_t GetMaxBitWidth() const noexcept { inline size_t GetMaxBitWidth() const noexcept {
return max_bit_width; return 1 << max_bit_width;
} }
void AddValue(IR::Inst* inst) noexcept; void AddValue(IR::Inst* inst) noexcept;
void EmitVerboseDebuggingOutput(BlockOfCode* code, size_t host_loc_index) const noexcept; void EmitVerboseDebuggingOutput(BlockOfCode* code, size_t host_loc_index) const noexcept;
@ -94,10 +94,10 @@ private:
uint16_t is_being_used_count = 0; //8 uint16_t is_being_used_count = 0; //8
uint16_t current_references = 0; //8 uint16_t current_references = 0; //8
// Value state // Value state
uint8_t max_bit_width = 0; //Valid values: 1,2,4,8,16,32,128 uint8_t max_bit_width : 4 = 0; //Valid values: log2(1,2,4,8,16,32,128) = (0, 1, 2, 3, 4, 5, 6)
uint8_t lru_counter : 2 = 0; //1
bool is_scratch : 1 = false; //1 bool is_scratch : 1 = false; //1
bool is_set_last_use : 1 = false; //1 bool is_set_last_use : 1 = false; //1
uint8_t lru_counter = 0; //1
friend class RegAlloc; friend class RegAlloc;
}; };
static_assert(sizeof(HostLocInfo) == 64); static_assert(sizeof(HostLocInfo) == 64);