1/*
2 * Copyright (c) 2023-2024 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_GATE_META_DATA_H
17#define ECMASCRIPT_COMPILER_LCR_GATE_META_DATA_H
18
19#include <string>
20
21#include "ecmascript/compiler/type.h"
22#include "libpandabase/macros.h"
23
24namespace panda::ecmascript::kungfu {
25
26enum MachineType : uint8_t { // Bit width
27    NOVALUE = 0,
28    ANYVALUE,
29    ARCH,
30    FLEX,
31    I1,
32    I8,
33    I16,
34    I32,
35    I64,
36    F32,
37    F64,
38};
39
40enum class ICmpCondition : uint8_t {
41    EQ = 1,
42    UGT,
43    UGE,
44    ULT,
45    ULE,
46    NE,
47    SGT,
48    SGE,
49    SLT,
50    SLE,
51};
52
53enum class FCmpCondition : uint8_t {
54    ALW_FALSE = 0,
55    OEQ,
56    OGT,
57    OGE,
58    OLT,
59    OLE,
60    ONE,
61    ORD,
62    UNO,
63    UEQ,
64    UGT,
65    UGE,
66    ULT,
67    ULE,
68    UNE,
69    ALW_TRUE,
70};
71
72std::string MachineTypeToStr(MachineType machineType);
73
74class BranchWeight {
75public:
76    static constexpr uint32_t ZERO_WEIGHT = 0;
77    static constexpr uint32_t ONE_WEIGHT = 1;
78    static constexpr uint32_t WEAK_WEIGHT = 10;
79    static constexpr uint32_t STRONG_WEIGHT = 1000;
80    static constexpr uint32_t DEOPT_WEIGHT = 2000;
81};
82
83}
84
85#endif  // ECMASCRIPT_COMPILER_LCR_GATE_META_DATA_H