simplified-operator-reducer.h 1.82 KB
Newer Older
1 2 3 4 5 6 7
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_COMPILER_SIMPLIFIED_OPERATOR_REDUCER_H_
#define V8_COMPILER_SIMPLIFIED_OPERATOR_REDUCER_H_

8
#include "src/base/compiler-specific.h"
9
#include "src/common/globals.h"
10 11 12 13
#include "src/compiler/graph-reducer.h"

namespace v8 {
namespace internal {
14 15 16 17 18

// Forward declarations.
class Factory;
class Isolate;

19 20 21 22 23
namespace compiler {

// Forward declarations.
class JSGraph;
class MachineOperatorBuilder;
24
class SimplifiedOperatorBuilder;
25

26 27
class V8_EXPORT_PRIVATE SimplifiedOperatorReducer final
    : public NON_EXPORTED_BASE(AdvancedReducer) {
28
 public:
29
  SimplifiedOperatorReducer(Editor* editor, JSGraph* jsgraph,
30
                            JSHeapBroker* broker);
31 32
  ~SimplifiedOperatorReducer() final;

33 34 35 36
  const char* reducer_name() const override {
    return "SimplifiedOperatorReducer";
  }

37 38 39 40
  Reduction Reduce(Node* node) final;

 private:
  Reduction Change(Node* node, const Operator* op, Node* a);
41
  Reduction ReplaceBoolean(bool value);
42 43 44 45 46 47 48 49
  Reduction ReplaceFloat64(double value);
  Reduction ReplaceInt32(int32_t value);
  Reduction ReplaceUint32(uint32_t value) {
    return ReplaceInt32(bit_cast<int32_t>(value));
  }
  Reduction ReplaceNumber(double value);
  Reduction ReplaceNumber(int32_t value);

50
  Factory* factory() const;
51 52
  Graph* graph() const;
  MachineOperatorBuilder* machine() const;
53
  SimplifiedOperatorBuilder* simplified() const;
54

55
  JSGraph* jsgraph() const { return jsgraph_; }
56
  JSHeapBroker* broker() const { return broker_; }
57

58
  JSGraph* const jsgraph_;
59
  JSHeapBroker* const broker_;
60 61 62 63 64 65 66 67 68

  DISALLOW_COPY_AND_ASSIGN(SimplifiedOperatorReducer);
};

}  // namespace compiler
}  // namespace internal
}  // namespace v8

#endif  // V8_COMPILER_SIMPLIFIED_OPERATOR_REDUCER_H_