Debian Codegraph @

src/imagination/pco/pco_bool.c

raw
1 /*
2 * Copyright © 2025 Imagination Technologies Ltd.
3 *
4 * SPDX-License-Identifier: MIT
5 */
6
7 /**
8 * \file pco_bool.c
9 *
10 * \brief PCO bool passes.
11 */
12
13 #include "pco.h"
14 #include "pco_builder.h"
15 #include "util/bitscan.h"
16 #include "util/bitset.h"
17 #include "util/macros.h"
18 #include "util/ralloc.h"
19 #include "util/u_dynarray.h"
20
21 #include <assert.h>
22 #include <stdbool.h>
23
24 static bool lower_bools(pco_func *func)
25 {
26 bool progress = false;
27
28 /* Update to 32-bit. */
29 pco_foreach_instr_in_func (instr, func) {
30 pco_foreach_instr_dest_vreg_ssa (pdest, instr) {
31 if (pco_ref_get_bits(*pdest) != 1)
32 continue;
33
34 *pdest = pco_ref_bits(*pdest, 32);
35
36 progress = true;
37 }
38
39 pco_foreach_instr_src_vreg_ssa (psrc, instr) {
40 if (pco_ref_get_bits(*psrc) != 1)
41 continue;
42
43 *psrc = pco_ref_bits(*psrc, 32);
44
45 progress = true;
46 }
47 }
48
49 pco_foreach_ssa_bool_if_in_func (pif, func) {
50 pif->cond = pco_ref_bits(pif->cond, 32);
51
52 progress = true;
53 }
54
55 return progress;
56 }
57
58 /**
59 * \brief Bool lowering pass.
60 *
61 * \param[in,out] shader PCO shader.
62 * \return True if the pass made progress.
63 */
64 bool pco_bool(pco_shader *shader)
65 {
66 bool progress = false;
67
68 pco_foreach_func_in_shader (func, shader) {
69 progress |= lower_bools(func);
70 }
71
72 return progress;
73 }