2 * Copyright (C) 2014 Paul Cercueil <paul@crapouillou.net>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
15 #ifndef __REGCACHE_H__
16 #define __REGCACHE_H__
18 #include "lightrec-private.h"
20 #define NUM_REGS (JIT_V_NUM - 2)
21 #define NUM_TEMPS (JIT_R_NUM)
22 #define LIGHTREC_REG_STATE (JIT_V(JIT_V_NUM - 1))
23 #define LIGHTREC_REG_CYCLE (JIT_V(JIT_V_NUM - 2))
28 struct register_value {
33 struct native_register;
36 u8 lightrec_alloc_reg(struct regcache *cache, jit_state_t *_jit, u8 jit_reg);
37 u8 lightrec_alloc_reg_temp(struct regcache *cache, jit_state_t *_jit);
38 u8 lightrec_alloc_reg_out(struct regcache *cache, jit_state_t *_jit, u8 reg);
39 u8 lightrec_alloc_reg_in(struct regcache *cache, jit_state_t *_jit, u8 reg);
40 u8 lightrec_alloc_reg_out_ext(struct regcache *cache,
41 jit_state_t *_jit, u8 reg);
42 u8 lightrec_alloc_reg_in_ext(struct regcache *cache, jit_state_t *_jit, u8 reg);
44 u8 lightrec_request_reg_in(struct regcache *cache, jit_state_t *_jit,
47 void lightrec_regcache_reset(struct regcache *cache);
49 void lightrec_lock_reg(struct regcache *cache, jit_state_t *_jit, u8 jit_reg);
50 void lightrec_free_reg(struct regcache *cache, u8 jit_reg);
51 void lightrec_free_regs(struct regcache *cache);
52 void lightrec_clean_reg(struct regcache *cache, jit_state_t *_jit, u8 jit_reg);
53 void lightrec_clean_regs(struct regcache *cache, jit_state_t *_jit);
54 void lightrec_unload_reg(struct regcache *cache, jit_state_t *_jit, u8 jit_reg);
55 void lightrec_storeback_regs(struct regcache *cache, jit_state_t *_jit);
57 void lightrec_clean_reg_if_loaded(struct regcache *cache, jit_state_t *_jit,
58 u8 reg, _Bool unload);
60 u8 lightrec_alloc_reg_in_address(struct regcache *cache,
61 jit_state_t *_jit, u8 reg, s16 offset);
63 struct native_register * lightrec_regcache_enter_branch(struct regcache *cache);
64 void lightrec_regcache_leave_branch(struct regcache *cache,
65 struct native_register *regs);
67 struct regcache * lightrec_regcache_init(struct lightrec_state *state);
68 void lightrec_free_regcache(struct regcache *cache);
70 const char * lightrec_reg_name(u8 reg);
72 void lightrec_regcache_mark_live(struct regcache *cache, jit_state_t *_jit);
74 #endif /* __REGCACHE_H__ */