Commit | Line | Data |
---|---|---|
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 | |
20 | struct register_value { | |
21 | _Bool known; | |
22 | u32 value; | |
23 | }; | |
24 | ||
25 | struct native_register; | |
26 | struct regcache; | |
27 | ||
28 | u8 lightrec_alloc_reg(struct regcache *cache, jit_state_t *_jit, u8 jit_reg); | |
29 | u8 lightrec_alloc_reg_temp(struct regcache *cache, jit_state_t *_jit); | |
98fa08a5 PC |
30 | u8 lightrec_alloc_reg_out(struct regcache *cache, jit_state_t *_jit, |
31 | u8 reg, u8 flags); | |
32 | u8 lightrec_alloc_reg_in(struct regcache *cache, jit_state_t *_jit, | |
33 | u8 reg, u8 flags); | |
d16005f8 PC |
34 | |
35 | u8 lightrec_request_reg_in(struct regcache *cache, jit_state_t *_jit, | |
36 | u8 reg, u8 jit_reg); | |
37 | ||
98fa08a5 PC |
38 | u8 lightrec_get_reg_in_flags(struct regcache *cache, u8 jit_reg); |
39 | void lightrec_set_reg_out_flags(struct regcache *cache, u8 jit_reg, u8 flags); | |
40 | ||
d16005f8 PC |
41 | void lightrec_regcache_reset(struct regcache *cache); |
42 | ||
43 | void lightrec_lock_reg(struct regcache *cache, jit_state_t *_jit, u8 jit_reg); | |
44 | void lightrec_free_reg(struct regcache *cache, u8 jit_reg); | |
45 | void lightrec_free_regs(struct regcache *cache); | |
46 | void lightrec_clean_reg(struct regcache *cache, jit_state_t *_jit, u8 jit_reg); | |
47 | void lightrec_clean_regs(struct regcache *cache, jit_state_t *_jit); | |
48 | void lightrec_unload_reg(struct regcache *cache, jit_state_t *_jit, u8 jit_reg); | |
49 | void lightrec_storeback_regs(struct regcache *cache, jit_state_t *_jit); | |
50 | ||
51 | void lightrec_clean_reg_if_loaded(struct regcache *cache, jit_state_t *_jit, | |
52 | u8 reg, _Bool unload); | |
03535202 | 53 | void lightrec_discard_reg_if_loaded(struct regcache *cache, u8 reg); |
d16005f8 PC |
54 | |
55 | u8 lightrec_alloc_reg_in_address(struct regcache *cache, | |
56 | jit_state_t *_jit, u8 reg, s16 offset); | |
57 | ||
58 | struct native_register * lightrec_regcache_enter_branch(struct regcache *cache); | |
59 | void lightrec_regcache_leave_branch(struct regcache *cache, | |
60 | struct native_register *regs); | |
61 | ||
62 | struct regcache * lightrec_regcache_init(struct lightrec_state *state); | |
63 | void lightrec_free_regcache(struct regcache *cache); | |
64 | ||
65 | const char * lightrec_reg_name(u8 reg); | |
66 | ||
67 | void lightrec_regcache_mark_live(struct regcache *cache, jit_state_t *_jit); | |
68 | ||
69 | #endif /* __REGCACHE_H__ */ |