11cb0ef41Sopenharmony_ci// Copyright 2014 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci// found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci#ifndef V8_COMPILER_SIMPLIFIED_OPERATOR_REDUCER_H_
61cb0ef41Sopenharmony_ci#define V8_COMPILER_SIMPLIFIED_OPERATOR_REDUCER_H_
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ci#include "src/base/compiler-specific.h"
91cb0ef41Sopenharmony_ci#include "src/common/globals.h"
101cb0ef41Sopenharmony_ci#include "src/compiler/common-operator.h"
111cb0ef41Sopenharmony_ci#include "src/compiler/graph-reducer.h"
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_cinamespace v8 {
141cb0ef41Sopenharmony_cinamespace internal {
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ci// Forward declarations.
171cb0ef41Sopenharmony_ciclass Factory;
181cb0ef41Sopenharmony_ciclass Isolate;
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_cinamespace compiler {
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ci// Forward declarations.
231cb0ef41Sopenharmony_ciclass JSGraph;
241cb0ef41Sopenharmony_ciclass MachineOperatorBuilder;
251cb0ef41Sopenharmony_ciclass SimplifiedOperatorBuilder;
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_ciclass V8_EXPORT_PRIVATE SimplifiedOperatorReducer final
281cb0ef41Sopenharmony_ci    : public NON_EXPORTED_BASE(AdvancedReducer) {
291cb0ef41Sopenharmony_ci public:
301cb0ef41Sopenharmony_ci  SimplifiedOperatorReducer(Editor* editor, JSGraph* jsgraph,
311cb0ef41Sopenharmony_ci                            JSHeapBroker* broker,
321cb0ef41Sopenharmony_ci                            BranchSemantics branch_semantics);
331cb0ef41Sopenharmony_ci  ~SimplifiedOperatorReducer() final;
341cb0ef41Sopenharmony_ci  SimplifiedOperatorReducer(const SimplifiedOperatorReducer&) = delete;
351cb0ef41Sopenharmony_ci  SimplifiedOperatorReducer& operator=(const SimplifiedOperatorReducer&) =
361cb0ef41Sopenharmony_ci      delete;
371cb0ef41Sopenharmony_ci
381cb0ef41Sopenharmony_ci  const char* reducer_name() const override {
391cb0ef41Sopenharmony_ci    return "SimplifiedOperatorReducer";
401cb0ef41Sopenharmony_ci  }
411cb0ef41Sopenharmony_ci
421cb0ef41Sopenharmony_ci  Reduction Reduce(Node* node) final;
431cb0ef41Sopenharmony_ci
441cb0ef41Sopenharmony_ci private:
451cb0ef41Sopenharmony_ci  Reduction Change(Node* node, const Operator* op, Node* a);
461cb0ef41Sopenharmony_ci  Reduction ReplaceBoolean(bool value);
471cb0ef41Sopenharmony_ci  Reduction ReplaceFloat64(double value);
481cb0ef41Sopenharmony_ci  Reduction ReplaceInt32(int32_t value);
491cb0ef41Sopenharmony_ci  Reduction ReplaceUint32(uint32_t value) {
501cb0ef41Sopenharmony_ci    return ReplaceInt32(bit_cast<int32_t>(value));
511cb0ef41Sopenharmony_ci  }
521cb0ef41Sopenharmony_ci  Reduction ReplaceNumber(double value);
531cb0ef41Sopenharmony_ci  Reduction ReplaceNumber(int32_t value);
541cb0ef41Sopenharmony_ci
551cb0ef41Sopenharmony_ci  Factory* factory() const;
561cb0ef41Sopenharmony_ci  Graph* graph() const;
571cb0ef41Sopenharmony_ci  MachineOperatorBuilder* machine() const;
581cb0ef41Sopenharmony_ci  SimplifiedOperatorBuilder* simplified() const;
591cb0ef41Sopenharmony_ci
601cb0ef41Sopenharmony_ci  JSGraph* jsgraph() const { return jsgraph_; }
611cb0ef41Sopenharmony_ci  JSHeapBroker* broker() const { return broker_; }
621cb0ef41Sopenharmony_ci
631cb0ef41Sopenharmony_ci  JSGraph* const jsgraph_;
641cb0ef41Sopenharmony_ci  JSHeapBroker* const broker_;
651cb0ef41Sopenharmony_ci  BranchSemantics branch_semantics_;
661cb0ef41Sopenharmony_ci};
671cb0ef41Sopenharmony_ci
681cb0ef41Sopenharmony_ci}  // namespace compiler
691cb0ef41Sopenharmony_ci}  // namespace internal
701cb0ef41Sopenharmony_ci}  // namespace v8
711cb0ef41Sopenharmony_ci
721cb0ef41Sopenharmony_ci#endif  // V8_COMPILER_SIMPLIFIED_OPERATOR_REDUCER_H_
73