v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
maglev-regalloc-data.h
Go to the documentation of this file.
1// Copyright 2022 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_MAGLEV_MAGLEV_REGALLOC_DATA_H_
6#define V8_MAGLEV_MAGLEV_REGALLOC_DATA_H_
7
12
13namespace v8 {
14namespace internal {
15namespace maglev {
16
17class ValueNode;
18
21static constexpr int kAllocatableDoubleRegisterCount =
23
24template <typename T>
26
27template <>
29 static constexpr RegList kRegisters =
31};
32
33template <>
38
40 // TODO(v8:7700): Use the good old Flags mechanism.
41 static constexpr int kIsMergeShift = 0;
42 static constexpr int kIsInitializedShift = 1;
43
44 const bool is_initialized = false;
45 const bool is_merge = false;
46
47 explicit constexpr operator uintptr_t() const {
48 return (is_initialized ? 1 << kIsInitializedShift : 0) |
49 (is_merge ? 1 << kIsMergeShift : 0);
50 }
51 constexpr explicit RegisterStateFlags(uintptr_t state)
52 : is_initialized((state & (1 << kIsInitializedShift)) != 0),
53 is_merge((state & (1 << kIsMergeShift)) != 0) {}
56};
57constexpr bool operator==(const RegisterStateFlags& left,
58 const RegisterStateFlags& right) {
59 return left.is_initialized == right.is_initialized &&
60 left.is_merge == right.is_merge;
61}
62
64
67 return reinterpret_cast<compiler::InstructionOperand*>(this + 1);
68 }
70
72};
73
74inline bool LoadMergeState(RegisterState state, RegisterMerge** merge) {
75 DCHECK(state.GetPayload().is_initialized);
76 if (state.GetPayload().is_merge) {
77 *merge = static_cast<RegisterMerge*>(state.GetPointer());
78 return true;
79 }
80 *merge = nullptr;
81 return false;
82}
83
84inline bool LoadMergeState(RegisterState state, ValueNode** node,
85 RegisterMerge** merge) {
86 DCHECK(state.GetPayload().is_initialized);
87 if (LoadMergeState(state, merge)) {
88 *node = (*merge)->node;
89 return true;
90 }
91 *node = static_cast<ValueNode*>(state.GetPointer());
92 return false;
93}
94
95} // namespace maglev
96} // namespace internal
97} // namespace v8
98
99#endif // V8_MAGLEV_MAGLEV_REGALLOC_DATA_H_
constexpr unsigned Count() const
static constexpr DoubleRegList GetAllocatableDoubleRegisters()
static constexpr RegList GetAllocatableRegisters()
static constexpr int kAllocatableDoubleRegisterCount
base::PointerWithPayload< void, RegisterStateFlags, 2 > RegisterState
constexpr bool operator==(const RegisterStateFlags &left, const RegisterStateFlags &right)
static constexpr int kAllocatableGeneralRegisterCount
bool LoadMergeState(RegisterState state, RegisterMerge **merge)
#define DCHECK(condition)
Definition logging.h:482
compiler::InstructionOperand * operands()
compiler::InstructionOperand & operand(size_t i)
constexpr RegisterStateFlags(bool is_initialized, bool is_merge)