[liftoff] Make RegsUnusedByParams constexpr
After dropping support for older GCC versions, we can now assume full c++14 constexpr support, and can hence resolve a TODO to make a LiftoffCompiler method constexpr. This is also a proof-of-concept to verify that this indeed works on all bots now. R=ahaas@chromium.org Bug: v8:9686, v8:11384 Change-Id: I9b7da91152b0af98778312d653aebbf4236fed0d Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2876850 Reviewed-by: Andreas Haas <ahaas@chromium.org> Commit-Queue: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/master@{#74407}
This commit is contained in:
parent
dc7906c99e
commit
d54e2bc781
@ -593,8 +593,7 @@ class LiftoffCompiler {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(ahaas): Make this function constexpr once GCC allows it.
|
||||
LiftoffRegList RegsUnusedByParams() {
|
||||
constexpr static LiftoffRegList RegsUnusedByParams() {
|
||||
LiftoffRegList regs = kGpCacheRegList;
|
||||
for (auto reg : kGpParamRegisters) {
|
||||
regs.clear(reg);
|
||||
@ -619,8 +618,9 @@ class LiftoffCompiler {
|
||||
// For reference type parameters we have to use registers that were not
|
||||
// used for parameters because some reference type stack parameters may
|
||||
// get processed before some value type register parameters.
|
||||
static constexpr auto kRegsUnusedByParams = RegsUnusedByParams();
|
||||
LiftoffRegister reg = is_reference(reg_kind)
|
||||
? __ GetUnusedRegister(RegsUnusedByParams())
|
||||
? __ GetUnusedRegister(kRegsUnusedByParams)
|
||||
: __ GetUnusedRegister(rc, pinned);
|
||||
__ LoadCallerFrameSlot(reg, -location.AsCallerFrameSlot(), reg_kind);
|
||||
return reg;
|
||||
|
@ -152,11 +152,12 @@ class LiftoffRegister {
|
||||
"chosen type is small enough");
|
||||
|
||||
public:
|
||||
explicit LiftoffRegister(Register reg) : LiftoffRegister(reg.code()) {
|
||||
constexpr explicit LiftoffRegister(Register reg)
|
||||
: LiftoffRegister(reg.code()) {
|
||||
DCHECK_NE(0, kLiftoffAssemblerGpCacheRegs & reg.bit());
|
||||
DCHECK_EQ(reg, gp());
|
||||
}
|
||||
explicit LiftoffRegister(DoubleRegister reg)
|
||||
constexpr explicit LiftoffRegister(DoubleRegister reg)
|
||||
: LiftoffRegister(kAfterMaxLiftoffGpRegCode + reg.code()) {
|
||||
DCHECK_NE(0, kLiftoffAssemblerFpCacheRegs & reg.bit());
|
||||
DCHECK_EQ(reg, fp());
|
||||
@ -275,22 +276,22 @@ class LiftoffRegister {
|
||||
return DoubleRegister::from_code((code_ & kCodeMask) + 1);
|
||||
}
|
||||
|
||||
Register gp() const {
|
||||
constexpr Register gp() const {
|
||||
DCHECK(is_gp());
|
||||
return Register::from_code(code_);
|
||||
}
|
||||
|
||||
DoubleRegister fp() const {
|
||||
constexpr DoubleRegister fp() const {
|
||||
DCHECK(is_fp());
|
||||
return DoubleRegister::from_code(code_ - kAfterMaxLiftoffGpRegCode);
|
||||
}
|
||||
|
||||
int liftoff_code() const {
|
||||
constexpr int liftoff_code() const {
|
||||
STATIC_ASSERT(sizeof(int) >= sizeof(storage_t));
|
||||
return static_cast<int>(code_);
|
||||
}
|
||||
|
||||
RegClass reg_class() const {
|
||||
constexpr RegClass reg_class() const {
|
||||
return is_fp_pair() ? kFpRegPair
|
||||
: is_gp_pair() ? kGpRegPair : is_gp() ? kGpReg : kFpReg;
|
||||
}
|
||||
@ -364,7 +365,7 @@ class LiftoffRegList {
|
||||
return reg;
|
||||
}
|
||||
|
||||
LiftoffRegister clear(LiftoffRegister reg) {
|
||||
constexpr LiftoffRegister clear(LiftoffRegister reg) {
|
||||
if (reg.is_pair()) {
|
||||
regs_ &= ~(storage_t{1} << reg.low().liftoff_code());
|
||||
regs_ &= ~(storage_t{1} << reg.high().liftoff_code());
|
||||
@ -373,8 +374,10 @@ class LiftoffRegList {
|
||||
}
|
||||
return reg;
|
||||
}
|
||||
Register clear(Register reg) { return clear(LiftoffRegister{reg}).gp(); }
|
||||
DoubleRegister clear(DoubleRegister reg) {
|
||||
constexpr Register clear(Register reg) {
|
||||
return clear(LiftoffRegister{reg}).gp();
|
||||
}
|
||||
constexpr DoubleRegister clear(DoubleRegister reg) {
|
||||
return clear(LiftoffRegister{reg}).fp();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user