gpu_neon: some hack to enhanced mode
[pcsx_rearmed.git] / deps / lightrec / regcache.h
CommitLineData
98fa08a5 1/* SPDX-License-Identifier: LGPL-2.1-or-later */
d16005f8 2/*
98fa08a5 3 * Copyright (C) 2014-2021 Paul Cercueil <paul@crapouillou.net>
d16005f8
PC
4 */
5
6#ifndef __REGCACHE_H__
7#define __REGCACHE_H__
8
ba3814c1 9#include "lightning-wrapper.h"
d16005f8 10
cb72ea13
PC
11#if defined(__sh__)
12# define NUM_REGS JIT_V_NUM
13# define LIGHTREC_REG_STATE _GBR
14#else
15# define NUM_REGS (JIT_V_NUM - 1)
16# define LIGHTREC_REG_STATE (JIT_V(JIT_V_NUM - 1))
17#endif
ba3814c1
PC
18
19#if defined(__powerpc__)
20# define NUM_TEMPS JIT_R_NUM
21/* JIT_R0 is callee-saved on PowerPC, we have to use something else */
22# define LIGHTREC_REG_CYCLE _R10
23# define FIRST_TEMP 0
24#else
25# define NUM_TEMPS (JIT_R_NUM - 1)
26# define LIGHTREC_REG_CYCLE JIT_R0
27# define FIRST_TEMP 1
28#endif
29
30#include "lightrec-private.h"
31
32#define FIRST_REG 0
d16005f8 33
98fa08a5
PC
34/* Flags for lightrec_alloc_reg_in / lightrec_alloc_reg_out. */
35#define REG_EXT BIT(0) /* register is sign-extended */
36#define REG_ZEXT BIT(1) /* register is zero-extended */
d16005f8
PC
37
38struct register_value {
39 _Bool known;
40 u32 value;
41};
42
43struct native_register;
44struct regcache;
45
46u8 lightrec_alloc_reg(struct regcache *cache, jit_state_t *_jit, u8 jit_reg);
47u8 lightrec_alloc_reg_temp(struct regcache *cache, jit_state_t *_jit);
98fa08a5 48u8 lightrec_alloc_reg_out(struct regcache *cache, jit_state_t *_jit,
9259d748 49 u16 reg, u8 flags);
98fa08a5 50u8 lightrec_alloc_reg_in(struct regcache *cache, jit_state_t *_jit,
9259d748 51 u16 reg, u8 flags);
d16005f8 52
9259d748
PC
53void lightrec_load_imm(struct regcache *cache,
54 jit_state_t *_jit, u8 jit_reg, u32 pc, u32 imm);
55void lightrec_load_next_pc(struct regcache *cache, jit_state_t *_jit, u8 reg);
56void lightrec_load_next_pc_imm(struct regcache *cache,
57 jit_state_t *_jit, u32 pc, u32 imm);
d16005f8 58
ba3814c1
PC
59s8 lightrec_get_reg_with_value(struct regcache *cache, intptr_t value);
60void lightrec_temp_set_value(struct regcache *cache, u8 jit_reg, intptr_t value);
61
98fa08a5
PC
62u8 lightrec_get_reg_in_flags(struct regcache *cache, u8 jit_reg);
63void lightrec_set_reg_out_flags(struct regcache *cache, u8 jit_reg, u8 flags);
64
d16005f8 65void lightrec_regcache_reset(struct regcache *cache);
0e720fb1 66void lightrec_preload_pc(struct regcache *cache, jit_state_t *_jit);
d16005f8 67
d16005f8
PC
68void lightrec_free_reg(struct regcache *cache, u8 jit_reg);
69void lightrec_free_regs(struct regcache *cache);
70void lightrec_clean_reg(struct regcache *cache, jit_state_t *_jit, u8 jit_reg);
71void lightrec_clean_regs(struct regcache *cache, jit_state_t *_jit);
72void lightrec_unload_reg(struct regcache *cache, jit_state_t *_jit, u8 jit_reg);
73void lightrec_storeback_regs(struct regcache *cache, jit_state_t *_jit);
ba3814c1 74_Bool lightrec_has_dirty_regs(struct regcache *cache);
d16005f8 75
cb72ea13 76_Bool lightrec_reg_is_loaded(struct regcache *cache, u16 reg);
d16005f8 77void lightrec_clean_reg_if_loaded(struct regcache *cache, jit_state_t *_jit,
9259d748
PC
78 u16 reg, _Bool unload);
79void lightrec_discard_reg_if_loaded(struct regcache *cache, u16 reg);
d16005f8
PC
80
81u8 lightrec_alloc_reg_in_address(struct regcache *cache,
9259d748 82 jit_state_t *_jit, u16 reg, s16 offset);
d16005f8
PC
83
84struct native_register * lightrec_regcache_enter_branch(struct regcache *cache);
85void lightrec_regcache_leave_branch(struct regcache *cache,
86 struct native_register *regs);
87
88struct regcache * lightrec_regcache_init(struct lightrec_state *state);
89void lightrec_free_regcache(struct regcache *cache);
90
cb72ea13 91__cnst const char * lightrec_reg_name(u8 reg);
d16005f8
PC
92
93void lightrec_regcache_mark_live(struct regcache *cache, jit_state_t *_jit);
94
95#endif /* __REGCACHE_H__ */