• Clemens Hammacher's avatar
    Allow constexpr RegList construction from Registers · fd306a06
    Clemens Hammacher authored
    Before, the standard way to create a RegList was either:
    RegList list = (1 << 0) | (1 << 1) | ...
    or
    RegList list = rax.bit() | rdx.bit() | ...
    
    The first way allows to make the RegList constexpr, but needs comments
    to document which registers you are referring to, and it has no checks
    that all bits you set on the RegList actually belong to valid registers.
    The second one uses the symbolic names, hence is much more readable and
    makes it harder to construct invalid RegLists. It's not constexpr
    though, since the {bit()} method on the register types is not constexpr.
    
    This CL adds a constexpr accessor to get the code and bit of a
    constexpr Register, and adds a helper method to create a constexpr
    RegList like this:
    constexpr RegList list = Register::ListOf<rax, rdx, rdi>();
    
    This new method is used in a number of places to test its
    applicability. Other uses of the old pattern remain and can be cleaned
    up later.
    
    R=tebbi@chromium.org
    
    Change-Id: Ie7b1d6342dc5f316dcfedd0363b3540ad5e7f413
    Reviewed-on: https://chromium-review.googlesource.com/728026
    Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
    Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#48887}
    fd306a06
Name
Last commit
Last update
benchmarks Loading commit data...
build_overrides Loading commit data...
docs Loading commit data...
gni Loading commit data...
gypfiles Loading commit data...
include Loading commit data...
infra Loading commit data...
samples Loading commit data...
src Loading commit data...
test Loading commit data...
testing Loading commit data...
third_party Loading commit data...
tools Loading commit data...
.clang-format Loading commit data...
.editorconfig Loading commit data...
.git-blame-ignore-revs Loading commit data...
.gitignore Loading commit data...
.gn Loading commit data...
.vpython Loading commit data...
.ycm_extra_conf.py Loading commit data...
AUTHORS Loading commit data...
BUILD.gn Loading commit data...
CODE_OF_CONDUCT.md Loading commit data...
ChangeLog Loading commit data...
DEPS Loading commit data...
LICENSE Loading commit data...
LICENSE.fdlibm Loading commit data...
LICENSE.strongtalk Loading commit data...
LICENSE.v8 Loading commit data...
LICENSE.valgrind Loading commit data...
Makefile Loading commit data...
Makefile.android Loading commit data...
OWNERS Loading commit data...
PRESUBMIT.py Loading commit data...
README.md Loading commit data...
WATCHLISTS Loading commit data...
codereview.settings Loading commit data...
snapshot_toolchain.gni Loading commit data...