#ifndef V8_COMPILER_TURBOSHAFT_ASSEMBLER_H_
#define V8_COMPILER_TURBOSHAFT_ASSEMBLER_H_
#include <cstring>
#include <iomanip>
#include <iterator>
#include <limits>
#include <memory>
#include <optional>
#include <type_traits>
#include <utility>
#include "include/v8-source-location.h"
#include "src/base/logging.h"
#include "src/base/macros.h"
#include "src/base/small-vector.h"
#include "src/base/string-format.h"
#include "src/base/template-utils.h"
#include "src/base/vector.h"
#include "src/codegen/callable.h"
#include "src/codegen/code-factory.h"
#include "src/codegen/heap-object-list.h"
#include "src/codegen/reloc-info.h"
#include "src/compiler/access-builder.h"
#include "src/compiler/code-assembler.h"
#include "src/compiler/common-operator.h"
#include "src/compiler/globals.h"
#include "src/compiler/js-heap-broker.h"
#include "src/compiler/simplified-operator.h"
#include "src/compiler/turboshaft/access-builder.h"
#include "src/compiler/turboshaft/builtin-call-descriptors.h"
#include "src/compiler/turboshaft/graph.h"
#include "src/compiler/turboshaft/index.h"
#include "src/compiler/turboshaft/operation-matcher.h"
#include "src/compiler/turboshaft/operations.h"
#include "src/compiler/turboshaft/phase.h"
#include "src/compiler/turboshaft/reducer-traits.h"
#include "src/compiler/turboshaft/representations.h"
#include "src/compiler/turboshaft/runtime-call-descriptors.h"
#include "src/compiler/turboshaft/sidetable.h"
#include "src/compiler/turboshaft/snapshot-table.h"
#include "src/compiler/turboshaft/uniform-reducer-adapter.h"
#include "src/compiler/turboshaft/utils.h"
#include "src/compiler/write-barrier-kind.h"
#include "src/flags/flags.h"
#include "src/logging/runtime-call-stats.h"
#include "src/objects/dictionary.h"
#include "src/objects/elements-kind.h"
#include "src/objects/fixed-array.h"
#include "src/objects/heap-number.h"
#include "src/objects/oddball.h"
#include "src/objects/property-cell.h"
#include "src/objects/scope-info.h"
#include "src/objects/swiss-name-dictionary.h"
#include "src/objects/tagged.h"
#include "src/objects/turbofan-types.h"
#ifdef V8_ENABLE_WEBASSEMBLY
#include "src/wasm/wasm-objects.h"
#endif
namespace v8::internal {
enum class Builtin : int32_t;
}
namespace v8::internal::compiler::turboshaft {
#include "src/compiler/turboshaft/define-assembler-macros.inc"
template <class AssemblerT>
class CatchScopeImpl;
enum ConditionalGotoStatus { … };
static_assert …;
#ifdef HAS_CPP_CONCEPTS
ForeachIterable;
#endif
template <typename T>
class Range { … };
template <typename T>
Range(V<T>, V<T>, V<T>) -> Range<T>;
template <typename T>
Range(V<T>, V<T>, typename ConstOrV<T>::constant_type) -> Range<T>;
template <typename T>
Range(V<T>, typename ConstOrV<T>::constant_type,
typename ConstOrV<T>::constant_type) -> Range<T>;
template <typename T>
class IndexRange : public Range<T> { … };
template <typename T>
class Sequence : private Range<T> { … };
template <typename T>
Sequence(V<T>, V<T>) -> Sequence<T>;
template <typename T>
Sequence(V<T>, typename ConstOrV<T>::constant_type) -> Sequence<T>;
template <typename T>
Sequence(V<T>) -> Sequence<T>;
template <typename... Iterables>
class Zip { … };
template <typename... Iterables>
Zip(Iterables... iterables) -> Zip<Iterables...>;
class ConditionWithHint final { … };
namespace detail {
template <typename A, typename ConstOrValues>
auto ResolveAll(A& assembler, const ConstOrValues& const_or_values) { … }
template <typename T>
struct IndexTypeFor { … };
IndexTypeFor<std::tuple<T>>;
index_type_for_t;
inline bool SuppressUnusedWarning(bool b) { … }
template <typename T>
auto unwrap_unary_tuple(std::tuple<T>&& tpl) { … }
template <typename T1, typename T2, typename... Rest>
auto unwrap_unary_tuple(std::tuple<T1, T2, Rest...>&& tpl) { … }
}
template <bool loop, typename... Ts>
class LabelBase { … };
template <typename... Ts>
class Label : public LabelBase<false, Ts...> { … };
template <typename... Ts>
class LoopLabel : public LabelBase<true, Ts...> { … };
namespace detail {
template <typename T>
struct LoopLabelForHelper;
LoopLabelForHelper<V<T>>;
LoopLabelForHelper<std::tuple<V<Ts>...>>;
}
LoopLabelFor;
Handle<Code> BuiltinCodeHandle(Builtin builtin, Isolate* isolate);
template <typename Next>
class TurboshaftAssemblerOpInterface;
template <typename T>
class Uninitialized { … };
template <class Assembler>
class GraphVisitor;
template <class Next>
class ValueNumberingReducer;
template <class Next>
class EmitProjectionReducer;
template <class Assembler, bool has_gvn, template <class> class... Reducers>
class ReducerStack { … };
template <class Assembler, template <class> class LastReducer>
class ReducerStack<Assembler, true, LastReducer>
: public GenericReducerBase<LastReducer<ReducerStack<Assembler, true>>> {
static_assert(LastReducer<ReducerStack<Assembler, false>>::kIsBottomOfStack);
public:
using GenericReducerBase<
LastReducer<ReducerStack<Assembler, true>>>::GenericReducerBase;
};
template <class Assembler, template <class> class LastReducer>
class ReducerStack<Assembler, false, LastReducer>
: public EmitProjectionReducer<
GenericReducerBase<LastReducer<ReducerStack<Assembler, false>>>> {
static_assert(LastReducer<ReducerStack<Assembler, false>>::kIsBottomOfStack);
public:
using EmitProjectionReducer<GenericReducerBase<
LastReducer<ReducerStack<Assembler, false>>>>::EmitProjectionReducer;
};
template <class Assembler, template <class> class... Reducers>
class ReducerStack<Assembler, true, ValueNumberingReducer, Reducers...>
: public EmitProjectionReducer<
ValueNumberingReducer<ReducerStack<Assembler, true, Reducers...>>> {
public:
using EmitProjectionReducer<ValueNumberingReducer<
ReducerStack<Assembler, true, Reducers...>>>::EmitProjectionReducer;
};
template <class Assembler, bool has_gvn, template <class> class FirstReducer,
template <class> class... Reducers>
class ReducerStack<Assembler, has_gvn, FirstReducer, Reducers...>
: public FirstReducer<ReducerStack<Assembler, has_gvn, Reducers...>> {
public:
using FirstReducer<
ReducerStack<Assembler, has_gvn, Reducers...>>::FirstReducer;
};
ReducerStack<Assembler<Reducers>, has_gvn>;
template <class Reducers>
struct reducer_stack_type { … };
template <template <class> class... Reducers>
struct reducer_stack_type<reducer_list<Reducers...>> {
using type =
ReducerStack<Assembler<reducer_list<Reducers...>>,
(is_same_reducer<ValueNumberingReducer, Reducers>::value ||
...),
Reducers...>;
};
template <typename Next>
class GenericReducerBase;
#define TURBOSHAFT_REDUCER_GENERIC_BOILERPLATE(Name) …
#define TURBOSHAFT_REDUCER_BOILERPLATE(Name) …
template <class T, class Assembler>
class ScopedVariable : Variable { … };
#define LABEL_BLOCK(label) …
template <class Next>
class EmitProjectionReducer
: public UniformReducerAdapter<EmitProjectionReducer, Next> { … };
template <class Next>
class TSReducerBase : public Next { … };
namespace detail {
template <typename T>
inline T&& MakeShadowy(T&& value) { … }
inline ShadowyOpIndex MakeShadowy(OpIndex value) { … }
template <typename T>
inline ShadowyOpIndex MakeShadowy(V<T> value) { … }
inline ShadowyOpIndexVectorWrapper MakeShadowy(
base::Vector<const OpIndex> value) { … }
template <typename T>
inline ShadowyOpIndexVectorWrapper MakeShadowy(base::Vector<const V<T>> value) { … }
}
template <class Next>
class ReducerBaseForwarder : public Next { … };
template <class Next>
class GenericReducerBase : public ReducerBaseForwarder<Next> { … };
namespace detail {
template <typename LoopLabel, typename Iterable, typename Iterator,
typename ValueTuple, size_t... Indices>
auto BuildResultTupleImpl(bool bound, Iterable&& iterable,
LoopLabel&& loop_header, Label<> loop_exit,
Iterator current_iterator, ValueTuple current_values,
std::index_sequence<Indices...>) { … }
template <typename LoopLabel, typename Iterable, typename Iterator,
typename Value>
auto BuildResultTuple(bool bound, Iterable&& iterable, LoopLabel&& loop_header,
Label<> loop_exit, Iterator current_iterator,
Value current_value) { … }
template <typename LoopLabel, typename Iterable, typename Iterator,
typename... Values>
auto BuildResultTuple(bool bound, Iterable&& iterable, LoopLabel&& loop_header,
Label<> loop_exit, Iterator current_iterator,
std::tuple<Values...> current_values) { … }
}
template <class Next>
class GenericAssemblerOpInterface : public Next { … };
template <class Next>
class TurboshaftAssemblerOpInterface
: public GenericAssemblerOpInterface<Next> { … } … };
struct AssemblerData { … };
template <class Reducers>
class Assembler : public AssemblerData,
public reducer_stack_type<Reducers>::type { … };
template <class AssemblerT>
class CatchScopeImpl { … };
template <template <class> class... Reducers>
class TSAssembler
: public Assembler<reducer_list<TurboshaftAssemblerOpInterface, Reducers...,
TSReducerBase>> { … };
#include "src/compiler/turboshaft/undef-assembler-macros.inc"
}
#endif