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
13
15
16template <typename Next>
18template <typename Next>
20template <typename Next>
22
23template <template <typename> typename... Ts>
25
26// Get the length of a reducer_list<> {RL}.
27template <typename RL>
29
30// Checks if a reducer_list<> {RL} contains reducer {R}.
31template <typename RL, template <typename> typename R>
33
34// Checks if a reducer_list<> {RL} starts with reducer {R}.
35template <typename RL, template <typename> typename R>
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.
42template <typename RL, template <typename> typename R,
43 size_t Otherwise = std::numeric_limits<size_t>::max()>
44struct 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.
48template <typename RL, size_t I, template <typename> typename R>
50
51// Turns a reducer_list<> into the instantiated class for the stack.
52template <typename RL, typename Bottom>
54 : base::tmp::fold_right1<base::tmp::instantiate, RL, Bottom> {};
55
56// Check if in the {Next} ReducerStack, any of {Reducer} comes next.
57template <typename Next, template <typename> typename... Reducer>
59 static constexpr bool value =
61};
62
63// Check if the {Next} ReducerStack contains {Reducer}.
64template <typename Next, template <typename> typename Reducer>
65struct next_contains_reducer : public std::bool_constant<false> {};
66
67template <template <typename> typename R, typename T,
68 template <typename> typename Reducer>
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.
77template <typename Next>
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_
#define T