git subrepo pull --force deps/lightning
[pcsx_rearmed.git] / deps / lightning / include / lightning / jit_arm.h
1 /*
2  * Copyright (C) 2012-2022  Free Software Foundation, Inc.
3  *
4  * This file is part of GNU lightning.
5  *
6  * GNU lightning is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License as published
8  * by the Free Software Foundation; either version 3, or (at your option)
9  * any later version.
10  *
11  * GNU lightning is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14  * License for more details.
15  *
16  * Authors:
17  *      Paulo Cesar Pereira de Andrade
18  */
19
20 #ifndef _jit_arm_h
21 #define _jit_arm_h
22
23 #define JIT_HASH_CONSTS         0
24 #define JIT_NUM_OPERANDS        3
25
26 /*
27  * Types
28  */
29 #define jit_swf_p()             (jit_cpu.vfp == 0)
30 #define jit_hardfp_p()          jit_cpu.abi
31 #define jit_ldrt_strt_p()       jit_cpu.ldrt_strt
32
33 #define JIT_FP                  _R11
34 typedef enum {
35 #define jit_r(i)                (_R4 + (i))
36 #define jit_r_num()             3
37 #define jit_v(i)                (_R7 + (i))
38 #define jit_v_num()             3
39 #define jit_f(i)                (jit_cpu.abi ? _D8 + ((i)<<1) : _D0 - ((i)<<1))
40 #define jit_f_num()             8
41     _R12,                       /* ip - temporary */
42 #define JIT_R0                  _R4
43 #define JIT_R1                  _R5
44 #define JIT_R2                  _R6
45     _R4,                        /* r4 - variable */
46     _R5,                        /* r5 - variable */
47     _R6,                        /* r6 - variable */
48 #define JIT_V0                  _R7
49 #define JIT_V1                  _R8
50 #define JIT_V2                  _R9
51     _R7,                        /* r7 - variable */
52     _R8,                        /* r8 - variable */
53     _R9,                        /* r9 - variable */
54     _R10,                       /* sl - stack limit */
55     _R11,                       /* fp - frame pointer */
56     _R13,                       /* sp - stack pointer */
57     _R14,                       /* lr - link register */
58     _R15,                       /* pc - program counter */
59     _R3,                        /* r3 - argument/result */
60     _R2,                        /* r2 - argument/result */
61     _R1,                        /* r1 - argument/result */
62     _R0,                        /* r0 - argument/result */
63 #define JIT_F0                  (jit_hardfp_p() ? _D8 : _D0)
64 #define JIT_F1                  (jit_hardfp_p() ? _D9 : _D1)
65 #define JIT_F2                  (jit_hardfp_p() ? _D10 : _D2)
66 #define JIT_F3                  (jit_hardfp_p() ? _D11 : _D3)
67 #define JIT_F4                  (jit_hardfp_p() ? _D12 : _D4)
68 #define JIT_F5                  (jit_hardfp_p() ? _D13 : _D5)
69 #define JIT_F6                  (jit_hardfp_p() ? _D14 : _D6)
70 #define JIT_F7                  (jit_hardfp_p() ? _D15 : _D7)
71     _S16,       _D8 = _S16,     _Q4 = _D8,
72     _S17,
73     _S18,       _D9 = _S18,
74     _S19,
75     _S20,       _D10 = _S20,    _Q5 = _D10,
76     _S21,
77     _S22,       _D11 = _S22,
78     _S23,
79     _S24,       _D12 = _S24,    _Q6 = _D12,
80     _S25,
81     _S26,       _D13 = _S26,
82     _S27,
83     _S28,       _D14 = _S28,    _Q7 = _D14,
84     _S29,
85     _S30,       _D15 = _S30,
86     _S31,
87     _S15,
88     _S14,       _D7 = _S14,
89     _S13,
90     _S12,       _D6 = _S12,     _Q3 = _D6,
91     _S11,
92     _S10,       _D5 = _S10,
93     _S9,
94     _S8,        _D4 = _S8,      _Q2 = _D4,
95     _S7,
96     _S6,        _D3 = _S6,
97     _S5,
98     _S4,        _D2 = _S4,      _Q1 = _D2,
99     _S3,
100     _S2,        _D1 = _S2,
101     _S1,
102     _S0,        _D0 = _S0,      _Q0 = _D0,
103     _NOREG,
104 #define JIT_NOREG               _NOREG
105 } jit_reg_t;
106
107 typedef struct {
108     jit_uint32_t version        : 4;
109     jit_uint32_t extend         : 1;
110     /* only generate thumb instructions for thumb2 */
111     jit_uint32_t thumb          : 1;
112     jit_uint32_t vfp            : 3;
113     jit_uint32_t neon           : 1;
114     jit_uint32_t abi            : 2;
115     /* use strt+offset instead of str.w?
116      * on special cases it causes a SIGILL at least on qemu, probably
117      * due to some memory ordering constraint not being respected, so,
118      * disable by default */
119     jit_uint32_t ldrt_strt      : 1;
120 } jit_cpu_t;
121
122 /*
123  * Initialization
124  */
125 extern jit_cpu_t                jit_cpu;
126
127 #endif /* _jit_arm_h */