pco: fix idx reg print colors and sq brackets

Signed-off-by: Simon Perretta <simon.perretta@imgtec.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36412>
This commit is contained in:
Simon Perretta
2025-01-22 18:10:32 +00:00
committed by Marge Bot
parent 9488aa4957
commit c5b78ffba7
2 changed files with 18 additions and 3 deletions
+11
View File
@@ -1419,6 +1419,17 @@ static inline bool pco_ref_is_idx_reg(pco_ref ref)
return ref.type == PCO_REF_TYPE_IDX_REG;
}
/**
* \brief Returns whether a reference is an index register pointing to itself.
*
* \param[in] ref PCO reference.
* \return True if the reference is an index register pointing to itself.
*/
static inline bool pco_ref_is_self_idx_reg(pco_ref ref)
{
return pco_ref_is_idx_reg(ref) && ref.reg_class == PCO_REG_CLASS_INDEX;
}
/**
* \brief Returns whether a reference is an immediate.
*
+7 -3
View File
@@ -218,7 +218,6 @@ static void pco_print_ref_color(pco_print_state *state, pco_ref ref)
case PCO_REF_TYPE_SSA:
case PCO_REF_TYPE_REG:
case PCO_REF_TYPE_IDX_REG:
YELLOW(state);
return;
@@ -229,6 +228,7 @@ static void pco_print_ref_color(pco_print_state *state, pco_ref ref)
case PCO_REF_TYPE_IO:
case PCO_REF_TYPE_PRED:
case PCO_REF_TYPE_DRC:
case PCO_REF_TYPE_IDX_REG:
WHITE(state);
return;
@@ -262,11 +262,15 @@ static void _pco_print_ref(pco_print_state *state, pco_ref ref)
pco_printf(state, "%s%u", pco_reg_class_str(ref.reg_class), ref.val);
break;
case PCO_REF_TYPE_IDX_REG:
case PCO_REF_TYPE_IDX_REG: {
_pco_print_ref(state, pco_ref_get_idx_pointee(ref));
if (pco_ref_is_self_idx_reg(ref))
break;
pco_print_ref_color(state, ref);
pco_printf(state, "[idx%u", ref.idx_reg.num);
break;
}
case PCO_REF_TYPE_IMM:
assert(pco_ref_is_scalar(ref));
@@ -316,7 +320,7 @@ static void _pco_print_ref(pco_print_state *state, pco_ref ref)
if (chans > 1 && !pco_ref_is_ssa(ref))
pco_printf(state, "..%u", ref.val + chans - 1);
if (ref.type == PCO_REF_TYPE_IDX_REG)
if (ref.type == PCO_REF_TYPE_IDX_REG && !pco_ref_is_self_idx_reg(ref))
pco_printf(state, "]");
RESET(state);