binary-op-assembler.h 2.31 KB
Newer Older
1 2 3 4
// Copyright 2017 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.

5 6
#ifndef V8_IC_BINARY_OP_ASSEMBLER_H_
#define V8_IC_BINARY_OP_ASSEMBLER_H_
7

8
#include <functional>
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#include "src/code-stub-assembler.h"

namespace v8 {
namespace internal {

namespace compiler {
class CodeAssemblerState;
}

class BinaryOpAssembler : public CodeStubAssembler {
 public:
  typedef compiler::Node Node;

  explicit BinaryOpAssembler(compiler::CodeAssemblerState* state)
      : CodeStubAssembler(state) {}

  Node* Generate_AddWithFeedback(Node* context, Node* lhs, Node* rhs,
26
                                 Node* slot_id, Node* feedback_vector,
27
                                 bool rhs_is_smi);
28 29

  Node* Generate_SubtractWithFeedback(Node* context, Node* lhs, Node* rhs,
30
                                      Node* slot_id, Node* feedback_vector,
31
                                      bool rhs_is_smi);
32 33

  Node* Generate_MultiplyWithFeedback(Node* context, Node* lhs, Node* rhs,
34
                                      Node* slot_id, Node* feedback_vector,
35
                                      bool rhs_is_smi);
36 37 38

  Node* Generate_DivideWithFeedback(Node* context, Node* dividend,
                                    Node* divisor, Node* slot_id,
39
                                    Node* feedback_vector, bool rhs_is_smi);
40 41 42

  Node* Generate_ModulusWithFeedback(Node* context, Node* dividend,
                                     Node* divisor, Node* slot_id,
43
                                     Node* feedback_vector, bool rhs_is_smi);
44

45 46 47 48 49
  Node* Generate_ExponentiateWithFeedback(Node* context, Node* dividend,
                                          Node* divisor, Node* slot_id,
                                          Node* feedback_vector,
                                          bool rhs_is_smi);

50 51 52 53 54 55
 private:
  typedef std::function<Node*(Node*, Node*, Variable*)> SmiOperation;
  typedef std::function<Node*(Node*, Node*)> FloatOperation;

  Node* Generate_BinaryOperationWithFeedback(
      Node* context, Node* lhs, Node* rhs, Node* slot_id, Node* feedback_vector,
56
      const SmiOperation& smiOperation, const FloatOperation& floatOperation,
57
      Operation op, bool rhs_is_smi);
58 59 60 61 62
};

}  // namespace internal
}  // namespace v8

63
#endif  // V8_IC_BINARY_OP_ASSEMBLER_H_