v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
reducer-traits.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_COMPILER_TURBOSHAFT_REDUCER_TRAITS_H_
6
#define V8_COMPILER_TURBOSHAFT_REDUCER_TRAITS_H_
7
8
#include <limits>
9
#include <type_traits>
10
11
#include "
src/base/template-meta-programming/common.h
"
12
#include "
src/base/template-meta-programming/list.h
"
13
14
namespace
v8::internal::compiler::turboshaft
{
15
16
template
<
typename
Next>
17
class
GenericReducerBase
;
18
template
<
typename
Next>
19
class
EmitProjectionReducer
;
20
template
<
typename
Next>
21
class
TSReducerBase
;
22
23
template
<
template
<
typename
>
typename
... Ts>
24
using
reducer_list
=
base::tmp::list1
<Ts...>;
25
26
// Get the length of a reducer_list<> {RL}.
27
template
<
typename
RL>
28
struct
reducer_list_length
:
base::tmp::length1
<RL> {};
29
30
// Checks if a reducer_list<> {RL} contains reducer {R}.
31
template
<
typename
RL,
template
<
typename
>
typename
R>
32
struct
reducer_list_contains
:
base::tmp::contains1
<RL, R> {};
33
34
// Checks if a reducer_list<> {RL} starts with reducer {R}.
35
template
<
typename
RL,
template
<
typename
>
typename
R>
36
struct
reducer_list_starts_with
{
37
static
constexpr
bool
value =
base::tmp::index_of1<RL, R>::value
== 0;
38
};
39
40
// Get the index of {R} in the reducer_list<> {RL} or {Otherwise} if it is not
41
// in the list.
42
template
<
typename
RL,
template
<
typename
>
typename
R,
43
size_t
Otherwise = std::numeric_limits<size_t>::max()>
44
struct
reducer_list_index_of
:
public
base::tmp::index_of1
<RL, R, Otherwise> {};
45
46
// Inserts reducer {R} into reducer_list<> {RL} at index {I}. If I >= length of
47
// {RL}, then {R} is appended.
48
template
<
typename
RL,
size_t
I,
template
<
typename
>
typename
R>
49
struct
reducer_list_insert_at
:
base::tmp::insert_at1
<RL, I, R> {};
50
51
// Turns a reducer_list<> into the instantiated class for the stack.
52
template
<
typename
RL,
typename
Bottom>
53
struct
reducer_list_to_stack
54
:
base::tmp::fold_right1
<base::tmp::instantiate, RL, Bottom> {};
55
56
// Check if in the {Next} ReducerStack, any of {Reducer} comes next.
57
template
<
typename
Next,
template
<
typename
>
typename
...
Reducer
>
58
struct
next_reducer_is
{
59
static
constexpr
bool
value =
60
(
base::tmp::is_instantiation_of<Next, Reducer>::value
|| ...);
61
};
62
63
// Check if the {Next} ReducerStack contains {Reducer}.
64
template
<
typename
Next,
template
<
typename
>
typename
Reducer
>
65
struct
next_contains_reducer
:
public
std::bool_constant<false> {};
66
67
template
<
template
<
typename
>
typename
R,
typename
T
,
68
template
<
typename
>
typename
Reducer
>
69
struct
next_contains_reducer
<R<T>,
Reducer
> {
70
static
constexpr
bool
value =
base::tmp::equals1<R, Reducer>::value
||
71
next_contains_reducer<T, Reducer>::value
;
72
};
73
74
// TODO(dmercadier): EmitProjectionReducer is not always the bottom of the stack
75
// because it could be succeeded by a ValueNumberingReducer. We should take this
76
// into account in next_is_bottom_of_assembler_stack.
77
template
<
typename
Next>
78
struct
next_is_bottom_of_assembler_stack
79
:
public
next_reducer_is
<Next, GenericReducerBase, EmitProjectionReducer,
80
TSReducerBase> {};
81
82
}
// namespace v8::internal::compiler::turboshaft
83
84
#endif
// V8_COMPILER_TURBOSHAFT_REDUCER_TRAITS_H_
T
#define T
list.h
v8::internal::compiler::Reducer
Definition
graph-reducer.h:55
v8::internal::compiler::turboshaft::EmitProjectionReducer
Definition
reducer-traits.h:19
v8::internal::compiler::turboshaft::GenericReducerBase
Definition
reducer-traits.h:17
v8::internal::compiler::turboshaft::TSReducerBase
Definition
reducer-traits.h:21
v8::internal::compiler::turboshaft
Definition
builtins.h:33
common.h
v8::base::tmp::contains1
Definition
list.h:203
v8::base::tmp::equals1
Definition
common.h:22
v8::base::tmp::fold_right1
Definition
list.h:237
v8::base::tmp::index_of1
Definition
list.h:192
v8::base::tmp::insert_at1
Definition
list.h:222
v8::base::tmp::is_instantiation_of
Definition
common.h:32
v8::base::tmp::length1
Definition
list.h:165
v8::base::tmp::list1
Definition
list.h:26
v8::internal::compiler::turboshaft::next_contains_reducer
Definition
reducer-traits.h:65
v8::internal::compiler::turboshaft::next_is_bottom_of_assembler_stack
Definition
reducer-traits.h:80
v8::internal::compiler::turboshaft::next_reducer_is
Definition
reducer-traits.h:58
v8::internal::compiler::turboshaft::reducer_list_contains
Definition
reducer-traits.h:32
v8::internal::compiler::turboshaft::reducer_list_index_of
Definition
reducer-traits.h:44
v8::internal::compiler::turboshaft::reducer_list_insert_at
Definition
reducer-traits.h:49
v8::internal::compiler::turboshaft::reducer_list_length
Definition
reducer-traits.h:28
v8::internal::compiler::turboshaft::reducer_list_starts_with
Definition
reducer-traits.h:36
v8::internal::compiler::turboshaft::reducer_list_to_stack
Definition
reducer-traits.h:54
src
compiler
turboshaft
reducer-traits.h
Generated on Sun Apr 6 2025 21:08:52 for v8 by
1.12.0