Commit 9667b17b authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[liftoff] Use C++14 constexpr switch

Since C++14, we can use a switch in a constexpr function.

R=ahaas@chromium.org

Bug: v8:9686, v8:9687
Change-Id: I082a7be6c54d6c705b678f19aa56bdb7a3313f80
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1786284Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63596}
parent 7fd9999f
......@@ -32,15 +32,18 @@ static inline constexpr bool needs_reg_pair(ValueType type) {
return kNeedI64RegPair && type == kWasmI64;
}
// TODO(clemensh): Use a switch once we require C++14 support.
static inline constexpr RegClass reg_class_for(ValueType type) {
return needs_reg_pair(type) // i64 on 32 bit
? kGpRegPair
: type == kWasmI32 || type == kWasmI64 // int types
? kGpReg
: type == kWasmF32 || type == kWasmF64 // float types
? kFpReg
: kNoReg; // other (unsupported) types
switch (type) {
case kWasmF32:
case kWasmF64:
return kFpReg;
case kWasmI32:
return kGpReg;
case kWasmI64:
return kNeedI64RegPair ? kGpRegPair : kGpReg;
default:
return kNoReg; // unsupported type
}
}
// Maximum code of a gp cache register.
......
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