v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
select-lowering-reducer.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_SELECT_LOWERING_REDUCER_H_
6
#define V8_COMPILER_TURBOSHAFT_SELECT_LOWERING_REDUCER_H_
7
8
#include "
src/base/vector.h
"
9
#include "
src/compiler/common-operator.h
"
10
#include "
src/compiler/turboshaft/assembler.h
"
11
#include "
src/compiler/turboshaft/operations.h
"
12
13
namespace
v8::internal::compiler::turboshaft
{
14
15
#include "
src/compiler/turboshaft/define-assembler-macros.inc
"
16
17
// Lowers Select operations to diamonds.
18
//
19
// A Select is conceptually somewhat similar to a ternary if:
20
//
21
// res = Select(cond, val_true, val_false)
22
//
23
// means:
24
//
25
// res = cond ? val_true : val_false
26
//
27
// SelectLoweringReducer lowers such operations into:
28
//
29
// if (cond) {
30
// res = val_true
31
// } else {
32
// res = val_false
33
// }
34
35
template
<
class
Next>
36
class
SelectLoweringReducer
:
public
Next {
37
public
:
38
TURBOSHAFT_REDUCER_BOILERPLATE
(
SelectLowering
)
39
40
V
<
Any
>
REDUCE
(Select)(
V
<
Word32
> cond,
V
<
Any
> vtrue,
V
<
Any
> vfalse,
41
RegisterRepresentation
rep,
BranchHint
hint,
42
SelectOp
::Implementation implem) {
43
if
(implem ==
SelectOp::Implementation::kCMove
) {
44
// We do not lower Select operations that should be implemented with
45
// CMove.
46
return
Next::ReduceSelect(cond, vtrue, vfalse, rep, hint, implem);
47
}
48
49
Variable
result
=
__
NewLoopInvariantVariable(rep);
50
IF
(cond) {
51
__
SetVariable(
result
, vtrue);
52
}
ELSE
{
53
__
SetVariable(
result
, vfalse);
54
}
55
56
return
__
GetVariable(
result
);
57
}
58
};
59
60
#include "
src/compiler/turboshaft/undef-assembler-macros.inc
"
61
62
}
// namespace v8::internal::compiler::turboshaft
63
64
#endif
// V8_COMPILER_TURBOSHAFT_SELECT_LOWERING_REDUCER_H_
__
#define __
Definition
baseline-assembler-arm-inl.h:52
REDUCE
#define REDUCE(operation)
ELSE
#define ELSE
IF
#define IF(...)
v8::internal::compiler::SelectLowering
Definition
select-lowering.h:18
v8::internal::compiler::turboshaft::RegisterRepresentation
Definition
representations.h:210
v8::internal::compiler::turboshaft::SelectLoweringReducer
Definition
select-lowering-reducer.h:36
v8::internal::compiler::turboshaft::SnapshotTableKey
Definition
snapshot-table.h:73
v8::internal::compiler::turboshaft::V
Definition
index.h:607
common-operator.h
assembler.h
TURBOSHAFT_REDUCER_BOILERPLATE
#define TURBOSHAFT_REDUCER_BOILERPLATE(Name)
Definition
assembler.h:823
define-assembler-macros.inc
result
ZoneVector< RpoNumber > & result
Definition
jump-threading.cc:21
v8::internal::compiler::turboshaft
Definition
builtins.h:33
v8::internal::BranchHint
BranchHint
Definition
globals.h:1824
operations.h
v8::internal::compiler::turboshaft::Any
Definition
index.h:214
v8::internal::compiler::turboshaft::SelectOp
Definition
operations.h:2502
v8::internal::compiler::turboshaft::SelectOp::Implementation::kCMove
@ kCMove
v8::internal::compiler::turboshaft::WordWithBits< 32 >
undef-assembler-macros.inc
vector.h
src
compiler
turboshaft
select-lowering-reducer.h
Generated on Sun Apr 6 2025 21:08:52 for v8 by
1.12.0