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 */ pco_schedule(pco_shader * shader)26bool 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 pco_foreach_instr_src (psrc, instr) { 34 if (!pco_ref_is_drc(*psrc)) 35 continue; 36 37 b = pco_builder_create(func, pco_cursor_after_instr(instr)); 38 pco_wdf(&b, *psrc); 39 40 progress = true; 41 break; 42 } 43 } 44 } 45 46 return progress; 47 } 48