[cleanup] Ignore no_regs in AreAliased()
in order to make it also work with optional registers. Bug: v8:8562 Change-Id: Iaea905913cc9fd1637026b83e9356c740965e128 Reviewed-on: https://chromium-review.googlesource.com/c/1367807 Commit-Queue: Igor Sheludko <ishell@chromium.org> Reviewed-by: Clemens Hammacher <clemensh@chromium.org> Cr-Commit-Position: refs/heads/master@{#58105}
This commit is contained in:
parent
d79762a8ed
commit
03ea675422
@ -475,9 +475,14 @@ class RegisterBase {
|
||||
return static_cast<int>(reg_code);
|
||||
}
|
||||
|
||||
template <RegisterCode reg_code>
|
||||
static constexpr int is_valid() {
|
||||
return static_cast<int>(reg_code) != kCode_no_reg;
|
||||
}
|
||||
|
||||
template <RegisterCode reg_code>
|
||||
static constexpr RegList bit() {
|
||||
return RegList{1} << code<reg_code>();
|
||||
return is_valid<reg_code>() ? RegList{1} << code<reg_code>() : RegList{};
|
||||
}
|
||||
|
||||
static SubType from_code(int code) {
|
||||
@ -498,14 +503,14 @@ class RegisterBase {
|
||||
return CombineRegLists(regs.bit()...);
|
||||
}
|
||||
|
||||
bool is_valid() const { return reg_code_ != kCode_no_reg; }
|
||||
constexpr bool is_valid() const { return reg_code_ != kCode_no_reg; }
|
||||
|
||||
int code() const {
|
||||
DCHECK(is_valid());
|
||||
return reg_code_;
|
||||
}
|
||||
|
||||
RegList bit() const { return RegList{1} << code(); }
|
||||
RegList bit() const { return is_valid() ? RegList{1} << code() : RegList{}; }
|
||||
|
||||
inline constexpr bool operator==(SubType other) const {
|
||||
return reg_code_ == other.reg_code_;
|
||||
|
@ -131,6 +131,13 @@ class HardAbortScope {
|
||||
enum class StubCallMode { kCallOnHeapBuiltin, kCallWasmRuntimeStub };
|
||||
|
||||
#ifdef DEBUG
|
||||
struct CountIfValidRegisterFunctor {
|
||||
template <typename RegType>
|
||||
constexpr int operator()(int count, RegType reg) const {
|
||||
return count + (reg.is_valid() ? 1 : 0);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename RegType, typename... RegTypes,
|
||||
// All arguments must be either Register or DoubleRegister.
|
||||
typename = typename std::enable_if<
|
||||
@ -138,7 +145,8 @@ template <typename RegType, typename... RegTypes,
|
||||
base::is_same<DoubleRegister, RegType, RegTypes...>::value>::type>
|
||||
inline bool AreAliased(RegType first_reg, RegTypes... regs) {
|
||||
int num_different_regs = NumRegs(RegType::ListOf(first_reg, regs...));
|
||||
int num_given_regs = sizeof...(regs) + 1;
|
||||
int num_given_regs =
|
||||
base::fold(CountIfValidRegisterFunctor{}, 0, first_reg, regs...);
|
||||
return num_different_regs < num_given_regs;
|
||||
}
|
||||
#endif
|
||||
|
@ -1114,6 +1114,22 @@ TEST(SIMDMacros) {
|
||||
CHECK_EQ(0, result);
|
||||
}
|
||||
|
||||
TEST(AreAliased) {
|
||||
DCHECK(!AreAliased(rax));
|
||||
DCHECK(!AreAliased(rax, no_reg));
|
||||
DCHECK(!AreAliased(no_reg, rax, no_reg));
|
||||
|
||||
DCHECK(AreAliased(rax, rax));
|
||||
DCHECK(!AreAliased(no_reg, no_reg));
|
||||
|
||||
DCHECK(!AreAliased(rax, rbx, rcx, rdx, no_reg));
|
||||
DCHECK(AreAliased(rax, rbx, rcx, rdx, rax, no_reg));
|
||||
|
||||
// no_regs are allowed in
|
||||
DCHECK(!AreAliased(rax, no_reg, rbx, no_reg, rcx, no_reg, rdx, no_reg));
|
||||
DCHECK(AreAliased(rax, no_reg, rbx, no_reg, rcx, no_reg, rdx, rax, no_reg));
|
||||
}
|
||||
|
||||
#undef __
|
||||
|
||||
} // namespace test_macro_assembler_x64
|
||||
|
Loading…
Reference in New Issue
Block a user