• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021-2022 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 COMPILER_OPTIMIZER_IR_CONSTANTS_H
17 #define COMPILER_OPTIMIZER_IR_CONSTANTS_H
18 
19 #include <cstdint>
20 #include <limits>
21 #include <variant>
22 
23 namespace panda::compiler {
24 constexpr int BITS_PER_BYTE = 8;
25 constexpr int BITS_PER_INSTPTR = sizeof(intptr_t) * BITS_PER_BYTE;
26 
27 using PcType = uint32_t;
28 using LinearNumber = uint32_t;
29 
30 // Update this when it will be strictly necessary to assign more than 255 registers in bytecode optimizer.
31 #ifdef IR_FOR_LIBARK_DEFECT_SCAN_AUX
32 using Register = uint16_t;
33 using StackSlot = uint16_t;
34 using ImmTableSlot = uint16_t;
35 #else
36 using Register = uint8_t;
37 using StackSlot = uint8_t;
38 using ImmTableSlot = uint8_t;
39 #endif
40 constexpr uint32_t MAX_NUM_STACK_SLOTS = std::numeric_limits<StackSlot>::max();
41 constexpr uint32_t MAX_NUM_IMM_SLOTS = std::numeric_limits<ImmTableSlot>::max();
42 
43 constexpr uint32_t INVALID_PC = std::numeric_limits<PcType>::max();
44 constexpr uint32_t INVALID_ID = std::numeric_limits<uint32_t>::max();
45 constexpr uint32_t INVALID_VN = std::numeric_limits<uint32_t>::max();
46 constexpr LinearNumber INVALID_LINEAR_NUM = std::numeric_limits<LinearNumber>::max();
47 constexpr Register INVALID_REG = std::numeric_limits<Register>::max();
48 constexpr StackSlot INVALID_STACK_SLOT = std::numeric_limits<StackSlot>::max();
49 constexpr ImmTableSlot INVALID_IMM_TABLE_SLOT = std::numeric_limits<ImmTableSlot>::max();
50 constexpr std::uint32_t INVALID_COLUMN_NUM = std::numeric_limits<std::uint32_t>::max();
51 constexpr std::size_t CALLEE_THRESHOLD = 2;
52 
53 constexpr Register VIRTUAL_FRAME_SIZE = INVALID_REG - 1U;
54 
55 constexpr Register INVALID_REG_ID = std::numeric_limits<Register>::max();
56 constexpr Register ACC_REG_ID = INVALID_REG_ID - 1U;
57 constexpr uint8_t MAX_NUM_REGS = 32;
58 constexpr uint8_t MAX_NUM_VREGS = 32;
59 
60 using LifeNumber = uint32_t;
61 constexpr auto INVALID_LIFE_NUMBER = std::numeric_limits<LifeNumber>::max();
62 constexpr auto LIFE_NUMBER_GAP = 2U;
63 
64 enum ShiftType : uint8_t { LSL, LSR, ASR, ROR, INVALID_SHIFT };
65 
66 enum ShiftOpcode { NEG_SR, ADD_SR, SUB_SR, AND_SR, OR_SR, XOR_SR, AND_NOT_SR, OR_NOT_SR, XOR_NOT_SR, INVALID_SR };
67 
68 constexpr uint32_t MAX_SCALE = 3;
69 
70 constexpr int MAX_SUCCS_NUM = 2;
71 }  // namespace panda::compiler
72 
73 #endif  // COMPILER_OPTIMIZER_IR_CONSTANTS_H
74