| 1 |
/* |
| 2 |
* Copyright © 2024 Imagination Technologies Ltd. |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: MIT |
| 5 |
*/ |
| 6 |
|
| 7 |
/** |
| 8 |
* \file pco_schedule.c |
| 9 |
* |
| 10 |
* \brief PCO instruction scheduling pass. |
| 11 |
*/ |
| 12 |
|
| 13 |
#include "pco.h" |
| 14 |
#include "pco_builder.h" |
| 15 |
#include "pco_internal.h" |
| 16 |
#include "util/macros.h" |
| 17 |
|
| 18 |
#include <stdbool.h> |
| 19 |
|
| 20 |
/** |
| 21 |
* \brief Schedules instructions and inserts waits. |
| 22 |
* |
| 23 |
* \param[in,out] shader PCO shader. |
| 24 |
* \return True if the pass made progress. |
| 25 |
*/ |
| 26 |
bool pco_schedule(pco_shader *shader) |
| 27 |
{ |
| 28 |
bool progress = false; |
| 29 |
pco_builder b; |
| 30 |
|
| 31 |
pco_foreach_func_in_shader (func, shader) { |
| 32 |
pco_foreach_instr_in_func_safe (instr, func) { |
| 33 |
if (instr->op == PCO_OP_WDF || instr->op == PCO_OP_IDF) |
| 34 |
continue; |
| 35 |
|
| 36 |
pco_foreach_instr_src (psrc, instr) { |
| 37 |
if (!pco_ref_is_drc(*psrc)) |
| 38 |
continue; |
| 39 |
|
| 40 |
b = pco_builder_create(func, pco_cursor_after_instr(instr)); |
| 41 |
|
| 42 |
if ((instr->op == PCO_OP_ST32 || instr->op == PCO_OP_ST32_REGBL) && |
| 43 |
pco_instr_get_idf(instr)) { |
| 44 |
pco_ref addr = pco_ref_chans(instr->src[3], 2); |
| 45 |
pco_idf(&b, *psrc, addr); |
| 46 |
pco_instr_set_idf(instr, false); |
| 47 |
} |
| 48 |
|
| 49 |
pco_wdf(&b, *psrc); |
| 50 |
|
| 51 |
progress = true; |
| 52 |
break; |
| 53 |
} |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
return progress; |
| 58 |
} |