v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
use-map.h
Go to the documentation of this file.
1// Copyright 2023 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_USE_MAP_H_
6#define V8_COMPILER_TURBOSHAFT_USE_MAP_H_
7
9
11
12typedef bool (*FunctionType)(const Operation& op, Zone* zone);
13
14// UseMap computes uses of all operations of the given turboshaft graph. It
15// provides a mapping from `OpIndex` to its `uses`.
16class UseMap {
18 // We encode offsets as follows:
19 // offset < 0: -offset-1 indexes into {saturated_uses_}.
20 // offset = 0: definition not visited yet.
21 // offset > 0: offset indexes into {uses_}.
22 int32_t offset = 0;
23 uint32_t count = 0;
24 };
25
26 public:
27 UseMap(const Graph& graph, Zone* zone, FunctionType filter);
28
29 UseMap(const Graph& graph, Zone* zone)
30 : UseMap(graph, zone,
31 [](const Operation& op, Zone* zone) { return false; }) {}
32
34
35 private:
36 void AddUse(const Graph* graph, OpIndex node, OpIndex use);
37
41};
42
43// SimdUseMap computes uses of SIMD operations of the given turboshaft graph and
44// skip other operations.
45class SimdUseMap : public UseMap, public NON_EXPORTED_BASE(ZoneObject) {
46 public:
47 SimdUseMap(const Graph& graph, Zone* zone)
48 : UseMap(graph, zone, [](const Operation& op, Zone* zone) {
49 if (op.outputs_rep().size() == 1 &&
50 op.outputs_rep()[0] == RegisterRepresentation::Simd128()) {
51 return false;
52 }
53
55 for (auto rep : op.inputs_rep(storage)) {
56 if (rep == MaybeRegisterRepresentation::Simd128()) return false;
57 }
58 return true;
59 }) {}
60};
61
62} // namespace v8::internal::compiler::turboshaft
63
64#endif // V8_COMPILER_TURBOSHAFT_USE_MAP_H_
static constexpr RegisterRepresentation Simd128()
SimdUseMap(const Graph &graph, Zone *zone)
Definition use-map.h:47
ZoneVector< ZoneVector< OpIndex > > saturated_uses_
Definition use-map.h:40
UseMap(const Graph &graph, Zone *zone)
Definition use-map.h:29
FixedOpIndexSidetable< PerOperationUses > table_
Definition use-map.h:38
base::Vector< const OpIndex > uses(OpIndex index) const
Definition use-map.cc:69
void AddUse(const Graph *graph, OpIndex node, OpIndex use)
Definition use-map.cc:83
UseMap(const Graph &graph, Zone *zone, FunctionType filter)
Definition use-map.cc:11
bool(* FunctionType)(const Operation &op, Zone *zone)
Definition use-map.h:12
template const Signature< wasm::ValueType > bool
#define NON_EXPORTED_BASE(code)