1 /*
2  * Copyright (c) 2023 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_COMPILER_LCR_OPCODE_H
17 #define ECMASCRIPT_COMPILER_LCR_OPCODE_H
18 
19 namespace panda::ecmascript::kungfu {
20 
21 #define LCR_BINARY_GATE_META_DATA_CACHE_LIST(V)                                                      \
22     V(Add, ADD, GateFlags::NONE_FLAG, 0, 0, 2)                                                       \
23     V(Sub, SUB, GateFlags::NONE_FLAG, 0, 0, 2)                                                       \
24     V(Mul, MUL, GateFlags::NONE_FLAG, 0, 0, 2)                                                       \
25     V(Exp, EXP, GateFlags::NONE_FLAG, 0, 0, 2)                                                       \
26     V(Sdiv, SDIV, GateFlags::NONE_FLAG, 0, 0, 2)                                                     \
27     V(Smod, SMOD, GateFlags::NONE_FLAG, 0, 0, 2)                                                     \
28     V(Udiv, UDIV, GateFlags::NONE_FLAG, 0, 0, 2)                                                     \
29     V(Umod, UMOD, GateFlags::NONE_FLAG, 0, 0, 2)                                                     \
30     V(Fdiv, FDIV, GateFlags::NONE_FLAG, 0, 0, 2)                                                     \
31     V(Fmod, FMOD, GateFlags::NONE_FLAG, 0, 0, 2)                                                     \
32     V(And, AND, GateFlags::NONE_FLAG, 0, 0, 2)                                                       \
33     V(Xor, XOR, GateFlags::NONE_FLAG, 0, 0, 2)                                                       \
34     V(Or, OR, GateFlags::NONE_FLAG, 0, 0, 2)                                                         \
35     V(Lsl, LSL, GateFlags::NONE_FLAG, 0, 0, 2)                                                       \
36     V(Lsr, LSR, GateFlags::NONE_FLAG, 0, 0, 2)                                                       \
37     V(Asr, ASR, GateFlags::NONE_FLAG, 0, 0, 2)                                                       \
38     V(Sqrt, SQRT, GateFlags::NO_WRITE, 0, 0, 1)                                                      \
39     V(Min, MIN, GateFlags::NO_WRITE, 0, 0, 2)                                                        \
40     V(Max, MAX, GateFlags::NO_WRITE, 0, 0, 2)                                                        \
41     V(AddWithOverflow, ADD_WITH_OVERFLOW, GateFlags::NONE_FLAG, 0, 0, 2)                             \
42     V(SubWithOverflow, SUB_WITH_OVERFLOW, GateFlags::NONE_FLAG, 0, 0, 2)                             \
43     V(MulWithOverflow, MUL_WITH_OVERFLOW, GateFlags::NONE_FLAG, 0, 0, 2)                             \
44     V(ExtractValue, EXTRACT_VALUE, GateFlags::NONE_FLAG, 0, 0, 2)
45 
46 #define LCR_UNARY_GATE_META_DATA_CACHE_LIST(V)                                   \
47     V(Zext, ZEXT, GateFlags::NONE_FLAG, 0, 0, 1)                                 \
48     V(Sext, SEXT, GateFlags::NONE_FLAG, 0, 0, 1)                                 \
49     V(DoubleTrunc, DOUBLE_TRUNC, GateFlags::NO_WRITE, 0, 0, 1)                   \
50     V(Trunc, TRUNC, GateFlags::NONE_FLAG, 0, 0, 1)                               \
51     V(Fext, FEXT, GateFlags::NONE_FLAG, 0, 0, 1)                                 \
52     V(Ftrunc, FTRUNC, GateFlags::NONE_FLAG, 0, 0, 1)                             \
53     V(Rev, REV, GateFlags::NONE_FLAG, 0, 0, 1)                                   \
54     V(TaggedToInt64, TAGGED_TO_INT64, GateFlags::NONE_FLAG, 0, 0, 1)             \
55     V(Int64ToTagged, INT64_TO_TAGGED, GateFlags::NONE_FLAG, 0, 0, 1)             \
56     V(SignedIntToFloat, SIGNED_INT_TO_FLOAT, GateFlags::NONE_FLAG, 0, 0, 1)      \
57     V(UnsignedIntToFloat, UNSIGNED_INT_TO_FLOAT, GateFlags::NONE_FLAG, 0, 0, 1)  \
58     V(FloatToSignedInt, FLOAT_TO_SIGNED_INT, GateFlags::NONE_FLAG, 0, 0, 1)      \
59     V(UnsignedFloatToInt, UNSIGNED_FLOAT_TO_INT, GateFlags::NONE_FLAG, 0, 0, 1)  \
60     V(TruncFloatToInt64, TRUNC_FLOAT_TO_INT64, GateFlags::NONE_FLAG, 0, 0, 1)    \
61     V(TruncFloatToInt32, TRUNC_FLOAT_TO_INT32, GateFlags::NONE_FLAG, 0, 0, 1)    \
62     V(Bitcast, BITCAST, GateFlags::NONE_FLAG, 0, 0, 1)                           \
63     V(Abs, ABS, GateFlags::NO_WRITE, 0, 0, 1)                                    \
64     V(Clz32, CLZ32, GateFlags::NONE_FLAG, 0, 0, 1)                               \
65     V(Ceil, CEIL, GateFlags::NO_WRITE, 0, 0, 1)                                  \
66     V(Floor, FLOOR, GateFlags::NO_WRITE, 0, 0, 1)
67 
68 #define LCR_IMMUTABLE_META_DATA_CACHE_LIST(V)                                                   \
69     V(ReadSp, READSP, GateFlags::NONE_FLAG, 0, 0, 0)                                            \
70     LCR_BINARY_GATE_META_DATA_CACHE_LIST(V)                                                     \
71     LCR_UNARY_GATE_META_DATA_CACHE_LIST(V)
72 
73 #define LCR_GATE_META_DATA_LIST_WITH_VALUE(V)                                           \
74     V(Icmp, ICMP, GateFlags::NONE_FLAG, 0, 0, 2)                                        \
75     V(Fcmp, FCMP, GateFlags::NONE_FLAG, 0, 0, 2)                                        \
76     V(Load, LOAD, GateFlags::NO_WRITE, 0, 1, 1)                                         \
77     V(Store, STORE, GateFlags::NONE_FLAG, 0, 1, 4)                                      \
78     V(StoreWithoutBarrier, STORE_WITHOUT_BARRIER, GateFlags::NONE_FLAG, 0, 1, 2)        \
79     V(Alloca, ALLOCA, GateFlags::NONE_FLAG, 0, 0, 0)
80 
81 #define LCR_GATE_META_DATA_LIST_WITH_ONE_PARAMETER(V)         \
82     LCR_GATE_META_DATA_LIST_WITH_VALUE(V)
83 
84 }
85 
86 #endif  // ECMASCRIPT_COMPILER_LCR_OPCODE_H