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