psxmem: Add support for Lightrec's custom mem init sequence
[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
9#include "lightrec-private.h"
10
11#define NUM_REGS (JIT_V_NUM - 2)
12#define NUM_TEMPS (JIT_R_NUM)
13#define LIGHTREC_REG_STATE (JIT_V(JIT_V_NUM - 1))
14#define LIGHTREC_REG_CYCLE (JIT_V(JIT_V_NUM - 2))
15
98fa08a5
PC
16/* Flags for lightrec_alloc_reg_in / lightrec_alloc_reg_out. */
17#define REG_EXT BIT(0) /* register is sign-extended */
18#define REG_ZEXT BIT(1) /* register is zero-extended */
d16005f8
PC
19
20struct register_value {
21 _Bool known;
22 u32 value;
23};
24
25struct native_register;
26struct regcache;
27
28u8 lightrec_alloc_reg(struct regcache *cache, jit_state_t *_jit, u8 jit_reg);
29u8 lightrec_alloc_reg_temp(struct regcache *cache, jit_state_t *_jit);
98fa08a5
PC
30u8 lightrec_alloc_reg_out(struct regcache *cache, jit_state_t *_jit,
31 u8 reg, u8 flags);
32u8 lightrec_alloc_reg_in(struct regcache *cache, jit_state_t *_jit,
33 u8 reg, u8 flags);
d16005f8
PC
34
35u8 lightrec_request_reg_in(struct regcache *cache, jit_state_t *_jit,
36 u8 reg, u8 jit_reg);
37
98fa08a5
PC
38u8 lightrec_get_reg_in_flags(struct regcache *cache, u8 jit_reg);
39void lightrec_set_reg_out_flags(struct regcache *cache, u8 jit_reg, u8 flags);
40
d16005f8
PC
41void lightrec_regcache_reset(struct regcache *cache);
42
43void lightrec_lock_reg(struct regcache *cache, jit_state_t *_jit, u8 jit_reg);
44void lightrec_free_reg(struct regcache *cache, u8 jit_reg);
45void lightrec_free_regs(struct regcache *cache);
46void lightrec_clean_reg(struct regcache *cache, jit_state_t *_jit, u8 jit_reg);
47void lightrec_clean_regs(struct regcache *cache, jit_state_t *_jit);
48void lightrec_unload_reg(struct regcache *cache, jit_state_t *_jit, u8 jit_reg);
49void lightrec_storeback_regs(struct regcache *cache, jit_state_t *_jit);
50
51void lightrec_clean_reg_if_loaded(struct regcache *cache, jit_state_t *_jit,
52 u8 reg, _Bool unload);
53
54u8 lightrec_alloc_reg_in_address(struct regcache *cache,
55 jit_state_t *_jit, u8 reg, s16 offset);
56
57struct native_register * lightrec_regcache_enter_branch(struct regcache *cache);
58void lightrec_regcache_leave_branch(struct regcache *cache,
59 struct native_register *regs);
60
61struct regcache * lightrec_regcache_init(struct lightrec_state *state);
62void lightrec_free_regcache(struct regcache *cache);
63
64const char * lightrec_reg_name(u8 reg);
65
66void lightrec_regcache_mark_live(struct regcache *cache, jit_state_t *_jit);
67
68#endif /* __REGCACHE_H__ */