summaryrefslogtreecommitdiff
path: root/deps/v8/src/ic/binary-op-assembler.h
blob: 26324660c859e17b27e6cf2d72eaa5a2a62a8e85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// 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.

#ifndef V8_IC_BINARY_OP_ASSEMBLER_H_
#define V8_IC_BINARY_OP_ASSEMBLER_H_

#include <functional>
#include "src/codegen/code-stub-assembler.h"

namespace v8 {
namespace internal {

namespace compiler {
class CodeAssemblerState;
}

class BinaryOpAssembler : public CodeStubAssembler {
 public:
  using Node = compiler::Node;

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

  Node* Generate_AddWithFeedback(Node* context, Node* lhs, Node* rhs,
                                 Node* slot_id, Node* feedback_vector,
                                 bool rhs_is_smi);

  Node* Generate_SubtractWithFeedback(Node* context, Node* lhs, Node* rhs,
                                      Node* slot_id, Node* feedback_vector,
                                      bool rhs_is_smi);

  Node* Generate_MultiplyWithFeedback(Node* context, Node* lhs, Node* rhs,
                                      Node* slot_id, Node* feedback_vector,
                                      bool rhs_is_smi);

  Node* Generate_DivideWithFeedback(Node* context, Node* dividend,
                                    Node* divisor, Node* slot_id,
                                    Node* feedback_vector, bool rhs_is_smi);

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

  Node* Generate_ExponentiateWithFeedback(Node* context, Node* dividend,
                                          Node* divisor, Node* slot_id,
                                          Node* feedback_vector,
                                          bool rhs_is_smi);

 private:
  using SmiOperation = std::function<Node*(Node*, Node*, Variable*)>;
  using FloatOperation = std::function<Node*(Node*, Node*)>;

  Node* Generate_BinaryOperationWithFeedback(
      Node* context, Node* lhs, Node* rhs, Node* slot_id, Node* feedback_vector,
      const SmiOperation& smiOperation, const FloatOperation& floatOperation,
      Operation op, bool rhs_is_smi);
};

}  // namespace internal
}  // namespace v8

#endif  // V8_IC_BINARY_OP_ASSEMBLER_H_