• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef ECMASCRIPT_IC_IC_BINARY_OP_H_
17 #define ECMASCRIPT_IC_IC_BINARY_OP_H_
18 
19 #include "ecmascript/js_tagged_value.h"
20 #include "ecmascript/property_attributes.h"
21 #include "ecmascript/ic/profile_type_info.h"
22 #include "ecmascript/runtime_call_id.h"
23 
24 namespace panda::ecmascript {
25 enum class BinaryType : uint8_t {
26     NUMBER,
27     NUMBER_GEN,
28     STRING,
29     STRING_GEN,
30     GENERIC,
31 };
32 
33 class ICBinaryOP {
34 public:
35     static inline JSTaggedValue AddWithTSType(JSThread *thread, EcmaVM *ecma_vm, JSTaggedValue left,
36                                              JSTaggedValue right, JSTaggedValue argType);
37     static inline JSTaggedValue SubWithTSType(JSThread *thread, EcmaVM *ecma_vm, JSTaggedValue left,
38                                              JSTaggedValue right, JSTaggedValue argType);
39     static inline JSTaggedValue MulWithTSType(JSThread *thread, EcmaVM *ecma_vm, JSTaggedValue left,
40                                              JSTaggedValue right, JSTaggedValue argType);
41     static inline JSTaggedValue DivWithTSType(JSThread *thread, EcmaVM *ecma_vm, JSTaggedValue left,
42                                              JSTaggedValue right, JSTaggedValue argType);
43     static inline JSTaggedValue ModWithTSType(JSThread *thread, EcmaVM *ecma_vm, JSTaggedValue left,
44                                               JSTaggedValue right, JSTaggedValue argType);
45     static inline void GetBitOPDate(JSThread *thread, JSTaggedValue left, JSTaggedValue right,
46                                     int32_t &opNumber0, int32_t &opNumber1, BinaryType opType);
47     static inline JSTaggedValue ShlWithTSType(JSThread *thread, EcmaVM *ecma_vm, JSTaggedValue left,
48                                               JSTaggedValue right, JSTaggedValue argType);
49     static inline JSTaggedValue ShrWithTSType(JSThread *thread, EcmaVM *ecma_vm, JSTaggedValue left,
50                                               JSTaggedValue right, JSTaggedValue argType);
51     static inline JSTaggedValue AshrWithTSType(JSThread *thread, EcmaVM *ecma_vm, JSTaggedValue left,
52                                                JSTaggedValue right, JSTaggedValue argType);
53     static inline JSTaggedValue AndWithTSType(JSThread *thread, EcmaVM *ecma_vm, JSTaggedValue left,
54                                               JSTaggedValue right, JSTaggedValue argType);
55     static inline JSTaggedValue OrWithTSType(JSThread *thread, EcmaVM *ecma_vm, JSTaggedValue left,
56                                              JSTaggedValue right, JSTaggedValue argType);
57     static inline JSTaggedValue XorWithTSType(JSThread *thread, EcmaVM *ecma_vm, JSTaggedValue left,
58                                               JSTaggedValue right, JSTaggedValue argType);
59 };
60 }  // namespace panda::ecmascript
61 
62 #endif  // ECMASCRIPT_IC_IC_BINARY_OP_H_