Commit c5ce66b1 authored by Toon Verwaest's avatar Toon Verwaest Committed by V8 LUCI CQ

[reg] Add RegisterBase::TakeAny(RegList*) helper

The helper function removes a register from the list and returns it

Bug: v8:7700
Change-Id: I3f9fe9d30113b9e6c7362dc8443e39ae3d1adf07
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3488372Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79284}
parent f0962559
......@@ -5,6 +5,7 @@
#ifndef V8_CODEGEN_REGISTER_H_
#define V8_CODEGEN_REGISTER_H_
#include "src/base/bits.h"
#include "src/base/bounds.h"
#include "src/codegen/reglist.h"
......@@ -53,6 +54,13 @@ class RegisterBase {
return is_valid() ? RegList{1} << code() : RegList{};
}
static constexpr SubType TakeAny(RegList* list) {
RegList& value = *list;
SubType result = from_code(base::bits::CountTrailingZerosNonZero(value));
*list = value & (value - 1);
return result;
}
inline constexpr bool operator==(SubType other) const {
return reg_code_ == other.reg_code_;
}
......
......@@ -20,6 +20,8 @@ using RegList = uint64_t;
using RegList = uint32_t;
#endif
constexpr RegList kEmptyRegList = 0;
// Get the number of registers in a given register list.
constexpr int NumRegs(RegList list) {
return base::bits::CountPopulation(list);
......
......@@ -497,8 +497,8 @@ void CheckMaps::GenerateCode(MaglevCodeGenState* code_gen_state,
const ProcessingState& state) {
Register object = ToRegister(actual_map_input());
RegList temps = temporaries();
Register map_tmp =
Register::from_code(base::bits::CountTrailingZerosNonZero(temps));
Register map_tmp = Register::TakeAny(&temps);
DCHECK_EQ(kEmptyRegList, temps);
__ LoadMap(map_tmp, object);
__ Cmp(map_tmp, map().object());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment