Commit ec803eee authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[arm64] Remove duplicated register logic

Instead of having both a templatized and a parameter-based method, just
have the parameter-based one, but make it constexpr. DCHECKs in these
constexpr methods need to be guarded because GCC 5 does not support them
yet.

R=thibaudm@chromium.org

Bug: v8:10021
Change-Id: If362de42f1a4c2cda4435fce63beb9244795d008
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1986001Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65611}
parent ae8eb6c2
......@@ -108,14 +108,10 @@ class CPURegister : public RegisterBase<CPURegister, kRegAfterLast> {
return CPURegister{kCode_no_reg, 0, kNoRegister};
}
template <int code, int size, RegisterType type>
static constexpr CPURegister Create() {
static_assert(IsValid(code, size, type), "Cannot create invalid registers");
return CPURegister{code, size, type};
}
static CPURegister Create(int code, int size, RegisterType type) {
static constexpr CPURegister Create(int code, int size, RegisterType type) {
#if V8_HAS_CXX14_CONSTEXPR
DCHECK(IsValid(code, size, type));
#endif
return CPURegister{code, size, type};
}
......@@ -242,29 +238,18 @@ class Register : public CPURegister {
public:
static constexpr Register no_reg() { return Register(CPURegister::no_reg()); }
template <int code, int size>
static constexpr Register Create() {
return Register(CPURegister::Create<code, size, CPURegister::kRegister>());
}
static Register Create(int code, int size) {
static constexpr Register Create(int code, int size) {
return Register(CPURegister::Create(code, size, CPURegister::kRegister));
}
static Register XRegFromCode(unsigned code);
static Register WRegFromCode(unsigned code);
static Register from_code(int code) {
static constexpr Register from_code(int code) {
// Always return an X register.
return Register::Create(code, kXRegSizeInBits);
}
template <int code>
static Register from_code() {
// Always return an X register.
return Register::Create<code, kXRegSizeInBits>();
}
static const char* GetSpecialRegisterName(int code) {
return (code == kSPRegInternalCode) ? "sp" : "UNKNOWN";
}
......@@ -335,14 +320,10 @@ class VRegister : public CPURegister {
return VRegister(CPURegister::no_reg(), 0);
}
template <int code, int size, int lane_count = 1>
static constexpr VRegister Create() {
static_assert(IsValidLaneCount(lane_count), "Invalid lane count");
return VRegister(CPURegister::Create<code, size, kVRegister>(), lane_count);
}
static VRegister Create(int code, int size, int lane_count = 1) {
static constexpr VRegister Create(int code, int size, int lane_count = 1) {
#if V8_HAS_CXX14_CONSTEXPR
DCHECK(IsValidLaneCount(lane_count));
#endif
return VRegister(CPURegister::Create(code, size, CPURegister::kVRegister),
lane_count);
}
......@@ -459,7 +440,7 @@ constexpr Register no_reg = NoReg;
constexpr VRegister no_dreg = NoVReg;
#define DEFINE_REGISTER(register_class, name, ...) \
constexpr register_class name = register_class::Create<__VA_ARGS__>()
constexpr register_class name = register_class::Create(__VA_ARGS__)
#define ALIAS_REGISTER(register_class, alias, name) \
constexpr register_class alias = name
......
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