nak: Add more NIR wrappers for walking the NIR CFG

Reviewed-by: M Henning <drawoc@darkrefraction.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28300>
This commit is contained in:
Faith Ekstrand 2024-03-08 15:12:10 -06:00 committed by Marge Bot
parent 9312356d99
commit 8e7f33818f

View file

@ -44,6 +44,14 @@ impl<'a, T> ExecListIter<'a, T> {
_marker: PhantomData,
}
}
fn at(n: &'a exec_node, offset: usize) -> Self {
Self {
n,
offset: offset,
_marker: PhantomData,
}
}
}
impl<'a, T: 'a> Iterator for ExecListIter<'a, T> {
@ -556,6 +564,7 @@ pub trait NirCfNode {
fn as_block(&self) -> Option<&nir_block>;
fn as_if(&self) -> Option<&nir_if>;
fn as_loop(&self) -> Option<&nir_loop>;
fn next(&self) -> Option<&nir_cf_node>;
}
impl NirCfNode for nir_cf_node {
@ -582,6 +591,12 @@ impl NirCfNode for nir_cf_node {
None
}
}
fn next(&self) -> Option<&nir_cf_node> {
let mut iter: ExecListIter<nir_cf_node> =
ExecListIter::at(&self.node, offset_of!(nir_cf_node, node));
iter.next()
}
}
pub trait NirFunctionImpl {