git subrepo pull --force deps/lightrec
[pcsx_rearmed.git] / deps / lightrec / constprop.h
CommitLineData
9259d748
PC
1/* SPDX-License-Identifier: LGPL-2.1-or-later */
2/*
3 * Copyright (C) 2022 Paul Cercueil <paul@crapouillou.net>
4 */
5
6#ifndef __LIGHTREC_CONSTPROP_H__
7#define __LIGHTREC_CONSTPROP_H__
8
9#include "lightrec.h"
10
11#define LIGHTREC_CONSTPROP_INITIALIZER { { 0, 0xffffffff, 0 }, }
12
cb72ea13 13struct block;
9259d748
PC
14
15struct constprop_data {
16 u32 value;
17 u32 known;
18 u32 sign;
19};
20
21static inline _Bool is_known(const struct constprop_data *v, u8 reg)
22{
23 return v[reg].known == 0xffffffff;
24}
25
26static inline _Bool bits_are_known_zero(const struct constprop_data *v,
27 u8 reg, u32 mask)
28{
29 return !(~v[reg].known & mask) && !(v[reg].value & mask);
30}
31
32static inline _Bool is_known_zero(const struct constprop_data *v, u8 reg)
33{
34 return bits_are_known_zero(v, reg, 0xffffffff);
35}
36
cb72ea13 37void lightrec_consts_propagate(const struct block *block,
9259d748
PC
38 unsigned int idx,
39 struct constprop_data *v);
40
41enum psx_map
42lightrec_get_constprop_map(const struct lightrec_state *state,
43 const struct constprop_data *v, u8 reg, s16 imm);
44
45#endif /* __LIGHTREC_CONSTPROP_H__ */