14514f5e3Sopenharmony_ci/*
24514f5e3Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
34514f5e3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
44514f5e3Sopenharmony_ci * you may not use this file except in compliance with the License.
54514f5e3Sopenharmony_ci * You may obtain a copy of the License at
64514f5e3Sopenharmony_ci *
74514f5e3Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
84514f5e3Sopenharmony_ci *
94514f5e3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
104514f5e3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
114514f5e3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
124514f5e3Sopenharmony_ci * See the License for the specific language governing permissions and
134514f5e3Sopenharmony_ci * limitations under the License.
144514f5e3Sopenharmony_ci */
154514f5e3Sopenharmony_ci
164514f5e3Sopenharmony_ci#ifndef ECMASCRIPT_COMPILER_ASSEMBLER_AARCH64_CONSTANTS_H
174514f5e3Sopenharmony_ci#define ECMASCRIPT_COMPILER_ASSEMBLER_AARCH64_CONSTANTS_H
184514f5e3Sopenharmony_cinamespace panda::ecmascript::aarch64 {
194514f5e3Sopenharmony_cienum RegisterId : uint8_t {
204514f5e3Sopenharmony_ci    X0, X1, X2, X3, X4, X5, X6, X7,
214514f5e3Sopenharmony_ci    X8, X9, X10, X11, X12, X13, X14, X15,
224514f5e3Sopenharmony_ci    X16, X17, X18, X19, X20, X21, X22, X23,
234514f5e3Sopenharmony_ci    X24, X25, X26, X27, X28, X29, X30, SP,
244514f5e3Sopenharmony_ci    Zero = SP,
254514f5e3Sopenharmony_ci    FP = X29,
264514f5e3Sopenharmony_ci    INVALID_REG = 0xFF,
274514f5e3Sopenharmony_ci};
284514f5e3Sopenharmony_ci
294514f5e3Sopenharmony_cienum RegisterType {
304514f5e3Sopenharmony_ci    W = 0,
314514f5e3Sopenharmony_ci    X = 1,
324514f5e3Sopenharmony_ci};
334514f5e3Sopenharmony_ci
344514f5e3Sopenharmony_cistatic const int RegXSize = 64;
354514f5e3Sopenharmony_cistatic const int RegWSize = 32;
364514f5e3Sopenharmony_ci
374514f5e3Sopenharmony_cienum VectorRegisterId : uint8_t {
384514f5e3Sopenharmony_ci    v0, v1, v2, v3, v4, v5, v6, v7,
394514f5e3Sopenharmony_ci    v8, v9, v10, v11, v12, v13, v14, v15,
404514f5e3Sopenharmony_ci    v16, v17, v18, v19, v20, v21, v22, v23,
414514f5e3Sopenharmony_ci    v24, v25, v26, v27, v28, v29, v30, v31,
424514f5e3Sopenharmony_ci    INVALID_VREG = 0xFF,
434514f5e3Sopenharmony_ci};
444514f5e3Sopenharmony_ci
454514f5e3Sopenharmony_cienum Extend : uint8_t {
464514f5e3Sopenharmony_ci    NO_EXTEND = 0xFF,
474514f5e3Sopenharmony_ci    UXTB = 0,   /* zero extend to byte */
484514f5e3Sopenharmony_ci    UXTH = 1,   /* zero extend to half word */
494514f5e3Sopenharmony_ci    UXTW = 2,   /* zero extend to word */
504514f5e3Sopenharmony_ci    UXTX = 3,   /* zero extend to 64bit */
514514f5e3Sopenharmony_ci    SXTB = 4,   /* sign extend to byte */
524514f5e3Sopenharmony_ci    SXTH = 5,   /* sign extend to half word */
534514f5e3Sopenharmony_ci    SXTW = 6,   /* sign extend to word */
544514f5e3Sopenharmony_ci    SXTX = 7,   /* sign extend to 64bit */
554514f5e3Sopenharmony_ci};
564514f5e3Sopenharmony_ci
574514f5e3Sopenharmony_cienum Shift : uint8_t {
584514f5e3Sopenharmony_ci    NO_SHIFT = 0xFF,
594514f5e3Sopenharmony_ci    LSL = 0x0,
604514f5e3Sopenharmony_ci    LSR = 0x1,
614514f5e3Sopenharmony_ci    ASR = 0x2,
624514f5e3Sopenharmony_ci    ROR = 0x3,
634514f5e3Sopenharmony_ci    MSL = 0x4,
644514f5e3Sopenharmony_ci};
654514f5e3Sopenharmony_ci
664514f5e3Sopenharmony_cienum Scale {
674514f5e3Sopenharmony_ci    B = 0,
684514f5e3Sopenharmony_ci    H = 1,
694514f5e3Sopenharmony_ci    S = 2,
704514f5e3Sopenharmony_ci    D = 3,
714514f5e3Sopenharmony_ci    Q = 4,
724514f5e3Sopenharmony_ci};
734514f5e3Sopenharmony_ci
744514f5e3Sopenharmony_cienum Condition {
754514f5e3Sopenharmony_ci    EQ = 0,
764514f5e3Sopenharmony_ci    NE = 1,
774514f5e3Sopenharmony_ci    HS = 2,
784514f5e3Sopenharmony_ci    CS = HS,
794514f5e3Sopenharmony_ci    LO = 3,
804514f5e3Sopenharmony_ci    CC = LO,
814514f5e3Sopenharmony_ci    MI = 4,
824514f5e3Sopenharmony_ci    PL = 5,
834514f5e3Sopenharmony_ci    VS = 6,
844514f5e3Sopenharmony_ci    VC = 7,
854514f5e3Sopenharmony_ci    HI = 8,
864514f5e3Sopenharmony_ci    LS = 9,
874514f5e3Sopenharmony_ci    GE = 10,
884514f5e3Sopenharmony_ci    LT = 11,
894514f5e3Sopenharmony_ci    GT = 12,
904514f5e3Sopenharmony_ci    LE = 13,
914514f5e3Sopenharmony_ci    AL = 14,
924514f5e3Sopenharmony_ci    NV = 15,
934514f5e3Sopenharmony_ci};
944514f5e3Sopenharmony_ci
954514f5e3Sopenharmony_cienum MoveOpCode {
964514f5e3Sopenharmony_ci    MOVN = 0x12800000,
974514f5e3Sopenharmony_ci    MOVZ = 0X52800000,
984514f5e3Sopenharmony_ci    MOVK = 0x72800000,
994514f5e3Sopenharmony_ci};
1004514f5e3Sopenharmony_ci
1014514f5e3Sopenharmony_cienum AddSubOpCode {
1024514f5e3Sopenharmony_ci    ADD_Imm     = 0x11000000,
1034514f5e3Sopenharmony_ci    ADD_Shift   = 0x0b000000,
1044514f5e3Sopenharmony_ci    ADD_Extend  = 0x0b200000,
1054514f5e3Sopenharmony_ci    SUB_Extend  = 0x4b200000,
1064514f5e3Sopenharmony_ci    SUB_Imm     = 0x51000000,
1074514f5e3Sopenharmony_ci    SUB_Shift   = 0x4b000000,
1084514f5e3Sopenharmony_ci};
1094514f5e3Sopenharmony_ci
1104514f5e3Sopenharmony_cienum BitwiseOpCode {
1114514f5e3Sopenharmony_ci    AND_Imm      = 0x12000000,
1124514f5e3Sopenharmony_ci    AND_Shift    = 0x0a000000,
1134514f5e3Sopenharmony_ci    ANDS_Imm     = 0x72000000,
1144514f5e3Sopenharmony_ci    ANDS_Shift   = 0x6a000000,
1154514f5e3Sopenharmony_ci    ORR_Imm      = 0x32000000,
1164514f5e3Sopenharmony_ci    ORR_Shift    = 0x2a000000,
1174514f5e3Sopenharmony_ci};
1184514f5e3Sopenharmony_ci
1194514f5e3Sopenharmony_ci// branch code
1204514f5e3Sopenharmony_cienum BranchOpCode {
1214514f5e3Sopenharmony_ci    BranchFMask = 0x7C000000,
1224514f5e3Sopenharmony_ci    BranchCondFMask = 0xFE000000,
1234514f5e3Sopenharmony_ci    BranchCompareFMask = 0x7E000000,
1244514f5e3Sopenharmony_ci    BranchTestFMask = 0x7E000000,
1254514f5e3Sopenharmony_ci    Branch      = 0x14000000,
1264514f5e3Sopenharmony_ci    BranchCond  = 0x54000000,
1274514f5e3Sopenharmony_ci    BCCond      = 0x54000010,
1284514f5e3Sopenharmony_ci    BR          = 0xd61f0000,
1294514f5e3Sopenharmony_ci    CBNZ        = 0x35000000,
1304514f5e3Sopenharmony_ci    CBZ         = 0x34000000,
1314514f5e3Sopenharmony_ci    TBZ         = 0x36000000,
1324514f5e3Sopenharmony_ci    TBNZ        = 0x37000000,
1334514f5e3Sopenharmony_ci};
1344514f5e3Sopenharmony_ci
1354514f5e3Sopenharmony_ci// brk code
1364514f5e3Sopenharmony_cienum BrkOpCode {
1374514f5e3Sopenharmony_ci    BRKImm      = 0xd4200000,
1384514f5e3Sopenharmony_ci};
1394514f5e3Sopenharmony_ci
1404514f5e3Sopenharmony_ci// call code
1414514f5e3Sopenharmony_cienum CallOpCode {
1424514f5e3Sopenharmony_ci    BL  = 0x94000000,
1434514f5e3Sopenharmony_ci    BLR = 0xd63f0000,
1444514f5e3Sopenharmony_ci};
1454514f5e3Sopenharmony_ci
1464514f5e3Sopenharmony_ci// compare code
1474514f5e3Sopenharmony_cienum CompareCode {
1484514f5e3Sopenharmony_ci    CMP_Extend  = 0x6d20000f,
1494514f5e3Sopenharmony_ci    CMP_Imm     = 0x7100000f,
1504514f5e3Sopenharmony_ci    CMP_Shift   = 0x6d00000f,
1514514f5e3Sopenharmony_ci    CSEL        = 0x1a800000,
1524514f5e3Sopenharmony_ci    CSET        = 0x1a9f07e0,
1534514f5e3Sopenharmony_ci};
1544514f5e3Sopenharmony_ci
1554514f5e3Sopenharmony_ci// memory code
1564514f5e3Sopenharmony_cienum LoadStorePairOpCode {
1574514f5e3Sopenharmony_ci    LDP_Post     = 0x28c00000,
1584514f5e3Sopenharmony_ci    LDP_Pre      = 0x29c00000,
1594514f5e3Sopenharmony_ci    LDP_Offset   = 0x29400000,
1604514f5e3Sopenharmony_ci    LDP_V_Post   = 0x2cc00000,
1614514f5e3Sopenharmony_ci    LDP_V_Pre    = 0x2dc00000,
1624514f5e3Sopenharmony_ci    LDP_V_Offset = 0x2d400000,
1634514f5e3Sopenharmony_ci    STP_Post     = 0x28800000,
1644514f5e3Sopenharmony_ci    STP_Pre      = 0x29800000,
1654514f5e3Sopenharmony_ci    STP_Offset   = 0x29000000,
1664514f5e3Sopenharmony_ci    STP_V_Post   = 0x2c800000,
1674514f5e3Sopenharmony_ci    STP_V_Pre    = 0x2d800000,
1684514f5e3Sopenharmony_ci    STP_V_Offset = 0x2d00000,
1694514f5e3Sopenharmony_ci};
1704514f5e3Sopenharmony_ci
1714514f5e3Sopenharmony_cienum LoadStoreOpCode {
1724514f5e3Sopenharmony_ci    LDR_Post     = 0xb8400400,
1734514f5e3Sopenharmony_ci    LDR_Pre      = 0xb8400c00,
1744514f5e3Sopenharmony_ci    LDR_Offset   = 0xb9400000,
1754514f5e3Sopenharmony_ci    LDRB_Post    = 0x38400400,
1764514f5e3Sopenharmony_ci    LDRB_Pre     = 0x38400c00,
1774514f5e3Sopenharmony_ci    LDRB_Offset  = 0x39400000,
1784514f5e3Sopenharmony_ci    LDRH_Post    = 0x78400400,
1794514f5e3Sopenharmony_ci    LDRH_Pre     = 0x78400c00,
1804514f5e3Sopenharmony_ci    LDRH_Offset  = 0x79400000,
1814514f5e3Sopenharmony_ci    STR_Post     = 0xb8000400,
1824514f5e3Sopenharmony_ci    STR_Pre      = 0xb8000c00,
1834514f5e3Sopenharmony_ci    STR_Offset   = 0xb9000000,
1844514f5e3Sopenharmony_ci    LDR_Register = 0xb8600800,
1854514f5e3Sopenharmony_ci    LDRB_Register = 0x38600800,
1864514f5e3Sopenharmony_ci    LDRH_Register = 0x78600800,
1874514f5e3Sopenharmony_ci    LDUR_Offset   = 0xb8400000,
1884514f5e3Sopenharmony_ci    STUR_Offset   = 0xb8000000,
1894514f5e3Sopenharmony_ci};
1904514f5e3Sopenharmony_ci
1914514f5e3Sopenharmony_cienum  AddrMode {
1924514f5e3Sopenharmony_ci    OFFSET,
1934514f5e3Sopenharmony_ci    PREINDEX,
1944514f5e3Sopenharmony_ci    POSTINDEX
1954514f5e3Sopenharmony_ci};
1964514f5e3Sopenharmony_ci
1974514f5e3Sopenharmony_cienum LogicShiftOpCode {
1984514f5e3Sopenharmony_ci    LSL_Reg = 0x1AC02000,
1994514f5e3Sopenharmony_ci    LSR_Reg = 0x1AC02400,
2004514f5e3Sopenharmony_ci    UBFM    = 0x53000000,
2014514f5e3Sopenharmony_ci    BFM     = 0xB3400000,
2024514f5e3Sopenharmony_ci};
2034514f5e3Sopenharmony_ci
2044514f5e3Sopenharmony_cienum NopOpCode {
2054514f5e3Sopenharmony_ci    Nop = 0xd503201f,
2064514f5e3Sopenharmony_ci};
2074514f5e3Sopenharmony_ci
2084514f5e3Sopenharmony_cienum RetOpCode {
2094514f5e3Sopenharmony_ci    Ret = 0xd65f0000,
2104514f5e3Sopenharmony_ci};
2114514f5e3Sopenharmony_ci
2124514f5e3Sopenharmony_ci#define COMMON_REGISTER_FIELD_LIST(V)   \
2134514f5e3Sopenharmony_ci    V(COMMON_REG, Rd, 4, 0)             \
2144514f5e3Sopenharmony_ci    V(COMMON_REG, Rn, 9, 5)             \
2154514f5e3Sopenharmony_ci    V(COMMON_REG, Rm, 20, 16)           \
2164514f5e3Sopenharmony_ci    V(COMMON_REG, Rt, 4, 0)             \
2174514f5e3Sopenharmony_ci    V(COMMON_REG, Rt2, 14, 10)          \
2184514f5e3Sopenharmony_ci    V(COMMON_REG, Sf, 31, 31)
2194514f5e3Sopenharmony_ci
2204514f5e3Sopenharmony_ci/* Aarch64 Instruction MOVZ Field Defines
2214514f5e3Sopenharmony_ci    |31 30 29 28|27 26 25 24|23 22 21 20 |        |15 14     |11 10 9  |      5 4|       0|
2224514f5e3Sopenharmony_ci    |sf| 1 0 | 1  0 0  1  0  1|  hw |                    imm16                 |    Rd    |
2234514f5e3Sopenharmony_ci   Aarch64 Instruction MOVN Field Defines
2244514f5e3Sopenharmony_ci    |31 30 29 28|27 26 25 24|23 22 21 20 |        |15 14     |11 10 9  |      5 4|       0|
2254514f5e3Sopenharmony_ci    |sf| 0 0 | 1  0 0  1  0  1|  hw |                    imm16                 |    Rd    |
2264514f5e3Sopenharmony_ci   Aarch64 Instruction MOVK Field Defines
2274514f5e3Sopenharmony_ci    |31 30 29 28|27 26 25 24|23 22 21 20 |        |15 14     |11 10 9  |      5 4|       0|
2284514f5e3Sopenharmony_ci    |sf| 1 1 | 1  0 0  1  0  1|  hw |                    imm16                 |    Rd    |
2294514f5e3Sopenharmony_ci*/
2304514f5e3Sopenharmony_ci#define MOV_WIDE_FIELD_LIST(V)   \
2314514f5e3Sopenharmony_ci    V(MOV_WIDE, Imm16, 20, 5)    \
2324514f5e3Sopenharmony_ci    V(MOV_WIDE, Hw, 22, 21)
2334514f5e3Sopenharmony_ci
2344514f5e3Sopenharmony_ci/* Aarch64 Instruction AddImm Field Defines
2354514f5e3Sopenharmony_ci    |31 30 29 28|27 26 25 24|23 22 21 20 |        |15 14     |11 10 9  |      5 4|       0|
2364514f5e3Sopenharmony_ci    |sf| 1 S | 1  0  0  0  0  1|sh|             imm12              |    Rn     |    Rd    |
2374514f5e3Sopenharmony_ci   Aarch64 Instruction AddShift Field Defines
2384514f5e3Sopenharmony_ci    |31 30 29 28|27 26 25 24|23 22 21 20 |      16|15 14     |11 10 9  |      5 4|       0|
2394514f5e3Sopenharmony_ci    |sf| 0 S | 0  1  0  1  1|shift| 0|    rm      |     imm6       |    Rn     |    Rd    |
2404514f5e3Sopenharmony_ci   Aarch64 Instruction AddExtend Field Defines
2414514f5e3Sopenharmony_ci    |31 30 29 28|27 26 25 24|23 22 21 20 |      16|15     13 12 |11 10 9  |      5 4|       0|
2424514f5e3Sopenharmony_ci    |sf| 0 S | 0  1  0  1  1|0  0 | 1|    rm      | option  |  imm3   |    Rn     |    Rd    |
2434514f5e3Sopenharmony_ci*/
2444514f5e3Sopenharmony_ci#define ADD_SUB_FIELD_LIST(V)           \
2454514f5e3Sopenharmony_ci    V(ADD_SUB, S, 29, 29)               \
2464514f5e3Sopenharmony_ci    V(ADD_SUB, Sh, 22, 22)              \
2474514f5e3Sopenharmony_ci    V(ADD_SUB, Imm12, 21, 10)           \
2484514f5e3Sopenharmony_ci    V(ADD_SUB, Shift, 23, 22)           \
2494514f5e3Sopenharmony_ci    V(ADD_SUB, ShiftAmount, 15, 10)     \
2504514f5e3Sopenharmony_ci    V(ADD_SUB, ExtendOption, 15, 13)    \
2514514f5e3Sopenharmony_ci    V(ADD_SUB, ExtendShift, 12, 10)
2524514f5e3Sopenharmony_ci
2534514f5e3Sopenharmony_ci/*
2544514f5e3Sopenharmony_ci   Aarch64 Instruction OrrImm Field Defines
2554514f5e3Sopenharmony_ci    |31 30 29 28|27 26 25 24|23 22 21 20 |       16|15 14     |11 10 9  |      5 4|       0|
2564514f5e3Sopenharmony_ci    |sf| 0 1 | 1  0  0  1  0  0|N|       immr      |      imms      |    Rn     |    Rd    |
2574514f5e3Sopenharmony_ci   Aarch64 Instruction ORRShift Field Defines
2584514f5e3Sopenharmony_ci    |31 30 29 28|27 26 25 24|23 22 21 20 |      16|15 14     |11 10 9  |      5 4|       0|
2594514f5e3Sopenharmony_ci    |sf| 0 1 | 0  1  0  1  0|shift| 0|    rm      |     imm6       |    Rn     |    Rd    |
2604514f5e3Sopenharmony_ci*/
2614514f5e3Sopenharmony_ci#define BITWISE_OP_FIELD_LIST(V)            \
2624514f5e3Sopenharmony_ci    V(BITWISE_OP, N, 22, 22)                \
2634514f5e3Sopenharmony_ci    V(BITWISE_OP, Immr, 21, 16)             \
2644514f5e3Sopenharmony_ci    V(BITWISE_OP, Shift, 23, 22)            \
2654514f5e3Sopenharmony_ci    V(BITWISE_OP, Imms, 15, 10)             \
2664514f5e3Sopenharmony_ci    V(BITWISE_OP, ShiftAmount, 15, 10)
2674514f5e3Sopenharmony_ci
2684514f5e3Sopenharmony_ci/*
2694514f5e3Sopenharmony_ci   Aarch64 Instruction CMP Instruction is aliase of Subs
2704514f5e3Sopenharmony_ci   Aarch64 Instruction CSEL Field Defines
2714514f5e3Sopenharmony_ci    |31 30 29 28|27 26 25 24|23 22 21 20 |       16|15 14   12 |11 10 9  |      5 4|       0|
2724514f5e3Sopenharmony_ci    |sf| 0  0| 1  1  0  1  0  1 0  0 |     rm      |    cond   | 0  0|    Rn     |    Rd    |
2734514f5e3Sopenharmony_ci   Aarch64 Instruction CSET Field Defines
2744514f5e3Sopenharmony_ci    |31 30 29 28|27 26 25 24|23 22 21 20|        16|15 14     |11 10 9  |    5 4|       0|
2754514f5e3Sopenharmony_ci    |sf| 0  0| 1  1  0  1  0|1  0  0| 1  1  1  1  1|   cond   | 0 1| 1 1 1 1 1|    Rd    |
2764514f5e3Sopenharmony_ci*/
2774514f5e3Sopenharmony_ci#define COMPARE_OP_FIELD_LIST(V)   \
2784514f5e3Sopenharmony_ci    V(CSEL, Cond, 15, 12)          \
2794514f5e3Sopenharmony_ci
2804514f5e3Sopenharmony_ci/* Aarch64 Instruction LDR Field Defines
2814514f5e3Sopenharmony_ci    |31 30 29 28|27 26 25 24|23 22 21 20|        |15      12|11 10 9  |      5 4|       0|
2824514f5e3Sopenharmony_ci    |1  x | 1  0 1 |0 |0  0 | 0 1 | 0|          imm9        | 0 1  |    Rn    |     Rt   |
2834514f5e3Sopenharmony_ci*/
2844514f5e3Sopenharmony_ci#define LDR_AND_STR_FIELD_LIST(V)   \
2854514f5e3Sopenharmony_ci    V(LDR_STR, Size, 31, 30)        \
2864514f5e3Sopenharmony_ci    V(LDR_STR, Opc, 23, 22)         \
2874514f5e3Sopenharmony_ci    V(LDR_STR, Imm9, 20, 12)        \
2884514f5e3Sopenharmony_ci    V(LDR_STR, Imm12, 21, 10)       \
2894514f5e3Sopenharmony_ci    V(LDR_STR, Extend, 15, 13)      \
2904514f5e3Sopenharmony_ci    V(LDR_STR, S, 12, 12)
2914514f5e3Sopenharmony_ci
2924514f5e3Sopenharmony_ci
2934514f5e3Sopenharmony_ci/* Aarch64 Instruction LDP Field Defines
2944514f5e3Sopenharmony_ci    |31 30 29 28|27 26 25 24|23 22 21   |        |15 14     |11 10 9  |      5 4|       0|
2954514f5e3Sopenharmony_ci    |x  0 | 1  0 1 |0 |0  0  1| 1|      imm7        |    Rt2      |    Rn     |     Rt   |
2964514f5e3Sopenharmony_ci*/
2974514f5e3Sopenharmony_ci#define LDP_AND_STP_FIELD_LIST(V)   \
2984514f5e3Sopenharmony_ci    V(LDP_STP, Opc, 31, 30)         \
2994514f5e3Sopenharmony_ci    V(LDP_STP, Imm7, 21, 15)
3004514f5e3Sopenharmony_ci
3014514f5e3Sopenharmony_ci
3024514f5e3Sopenharmony_ci/* Aarch64 Instruction B Field Defines
3034514f5e3Sopenharmony_ci    |31 30 29 28|27 26 25 24|23 22 21   |        |15 14     |11 10 9  |      5 4|       0|
3044514f5e3Sopenharmony_ci    |x  0 | 1  0 1 |0 |0  0  1| 1|      imm7        |    Rt2      |    Rn     |     Rt   |
3054514f5e3Sopenharmony_ci*/
3064514f5e3Sopenharmony_ci
3074514f5e3Sopenharmony_ci#define BRANCH_FIELD_LIST(V)        \
3084514f5e3Sopenharmony_ci    V(BRANCH, Imm26, 25, 0)         \
3094514f5e3Sopenharmony_ci    V(BRANCH, Imm19, 23, 5)         \
3104514f5e3Sopenharmony_ci    V(BRANCH, Imm14, 18, 5)         \
3114514f5e3Sopenharmony_ci    V(BRANCH, B5, 31, 31)           \
3124514f5e3Sopenharmony_ci    V(BRANCH, B40, 23, 19)
3134514f5e3Sopenharmony_ci
3144514f5e3Sopenharmony_ci/* Aarch64 Instruction BRK Field Defines
3154514f5e3Sopenharmony_ci    |31 30 29 28|27 26 25 24|23 22 21   |        |15 14     |11 10 9  |      5 4|       0|
3164514f5e3Sopenharmony_ci    |1  1 | 0  1  0  0  0  0| 0  0  1|                 imm16                  |0 0 0 0  0|
3174514f5e3Sopenharmony_ci*/
3184514f5e3Sopenharmony_ci#define BRK_FIELD_LIST(V)        \
3194514f5e3Sopenharmony_ci    V(BRK, Imm16, 20, 5)
3204514f5e3Sopenharmony_ci
3214514f5e3Sopenharmony_ci#define DECL_FIELDS_IN_INSTRUCTION(INSTNAME, FIELD_NAME, HIGHBITS, LOWBITS) \
3224514f5e3Sopenharmony_cistatic const uint32_t INSTNAME##_##FIELD_NAME##_HIGHBITS = HIGHBITS;  \
3234514f5e3Sopenharmony_cistatic const uint32_t INSTNAME##_##FIELD_NAME##_LOWBITS = LOWBITS;    \
3244514f5e3Sopenharmony_cistatic const uint32_t INSTNAME##_##FIELD_NAME##_WIDTH = ((HIGHBITS - LOWBITS) + 1); \
3254514f5e3Sopenharmony_cistatic const uint32_t INSTNAME##_##FIELD_NAME##_MASK = (((1 << INSTNAME##_##FIELD_NAME##_WIDTH) - 1) << LOWBITS);
3264514f5e3Sopenharmony_ci
3274514f5e3Sopenharmony_ci#define DECL_INSTRUCTION_FIELDS(V)  \
3284514f5e3Sopenharmony_ci    COMMON_REGISTER_FIELD_LIST(V)   \
3294514f5e3Sopenharmony_ci    LDP_AND_STP_FIELD_LIST(V)       \
3304514f5e3Sopenharmony_ci    LDR_AND_STR_FIELD_LIST(V)       \
3314514f5e3Sopenharmony_ci    MOV_WIDE_FIELD_LIST(V)          \
3324514f5e3Sopenharmony_ci    BITWISE_OP_FIELD_LIST(V)        \
3334514f5e3Sopenharmony_ci    ADD_SUB_FIELD_LIST(V)           \
3344514f5e3Sopenharmony_ci    COMPARE_OP_FIELD_LIST(V)        \
3354514f5e3Sopenharmony_ci    BRANCH_FIELD_LIST(V)            \
3364514f5e3Sopenharmony_ci    BRK_FIELD_LIST(V)
3374514f5e3Sopenharmony_ci
3384514f5e3Sopenharmony_ciDECL_INSTRUCTION_FIELDS(DECL_FIELDS_IN_INSTRUCTION)
3394514f5e3Sopenharmony_ci#undef DECL_INSTRUCTION_FIELDS
3404514f5e3Sopenharmony_ci};  // namespace panda::ecmascript::aarch64
3414514f5e3Sopenharmony_ci#endif