V8 Project
machine-operator-reducer.h
Go to the documentation of this file.
1 // Copyright 2014 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_MACHINE_OPERATOR_REDUCER_H_
6 #define V8_COMPILER_MACHINE_OPERATOR_REDUCER_H_
7 
10 
11 namespace v8 {
12 namespace internal {
13 namespace compiler {
14 
15 // Forward declarations.
16 class CommonOperatorBuilder;
17 class JSGraph;
18 
19 
20 // Performs constant folding and strength reduction on nodes that have
21 // machine operators.
22 class MachineOperatorReducer FINAL : public Reducer {
23  public:
24  explicit MachineOperatorReducer(JSGraph* jsgraph);
26 
27  virtual Reduction Reduce(Node* node) OVERRIDE;
28 
29  private:
30  Node* Float32Constant(volatile float value);
31  Node* Float64Constant(volatile double value);
32  Node* Int32Constant(int32_t value);
33  Node* Int64Constant(int64_t value);
34  Node* Uint32Constant(uint32_t value) {
35  return Int32Constant(bit_cast<uint32_t>(value));
36  }
37 
38  Reduction ReplaceBool(bool value) { return ReplaceInt32(value ? 1 : 0); }
39  Reduction ReplaceFloat32(volatile float value) {
40  return Replace(Float32Constant(value));
41  }
42  Reduction ReplaceFloat64(volatile double value) {
43  return Replace(Float64Constant(value));
44  }
45  Reduction ReplaceInt32(int32_t value) {
46  return Replace(Int32Constant(value));
47  }
48  Reduction ReplaceInt64(int64_t value) {
49  return Replace(Int64Constant(value));
50  }
51 
52  Reduction ReduceProjection(size_t index, Node* node);
53 
54  Graph* graph() const;
55  JSGraph* jsgraph() const { return jsgraph_; }
56  CommonOperatorBuilder* common() const;
57  MachineOperatorBuilder* machine() const;
58 
59  JSGraph* jsgraph_;
60 };
61 
62 } // namespace compiler
63 } // namespace internal
64 } // namespace v8
65 
66 #endif // V8_COMPILER_MACHINE_OPERATOR_REDUCER_H_
Reduction ReplaceInt32(int32_t value)
Reduction ReplaceFloat64(volatile double value)
MachineOperatorBuilder * machine() const
Reduction ReduceProjection(size_t index, Node *node)
Node * Int64Constant(int64_t value)
Reduction ReplaceFloat32(volatile float value)
CommonOperatorBuilder * common() const
MachineOperatorReducer(JSGraph *jsgraph)
Node * Float32Constant(volatile float value)
Node * Float64Constant(volatile double value)
virtual Reduction Reduce(Node *node) OVERRIDE
Reduction ReplaceInt64(int64_t value)
Node * Int32Constant(int32_t value)
#define OVERRIDE
#define FINAL
int int32_t
Definition: unicode.cc:24
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20