mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 11:00:11 +01:00
nak: Add helpers to BasicBlock to get phis
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
This commit is contained in:
parent
2f9565e725
commit
d574d29102
1 changed files with 48 additions and 0 deletions
|
|
@ -4001,6 +4001,54 @@ impl BasicBlock {
|
|||
self.instrs = instrs;
|
||||
}
|
||||
|
||||
pub fn phi_dsts(&self) -> Option<&OpPhiDsts> {
|
||||
for instr in self.instrs.iter() {
|
||||
match &instr.op {
|
||||
Op::PhiDsts(phi) => return Some(phi),
|
||||
_ => break,
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn phi_dsts_mut(&mut self) -> Option<&mut OpPhiDsts> {
|
||||
for instr in self.instrs.iter_mut() {
|
||||
match &mut instr.op {
|
||||
Op::PhiDsts(phi) => return Some(phi),
|
||||
_ => break,
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn phi_srcs(&self) -> Option<&OpPhiSrcs> {
|
||||
for instr in self.instrs.iter().rev() {
|
||||
if instr.is_branch() {
|
||||
continue;
|
||||
}
|
||||
|
||||
match &instr.op {
|
||||
Op::PhiSrcs(phi) => return Some(phi),
|
||||
_ => break,
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn phi_srcs_mut(&mut self) -> Option<&mut OpPhiSrcs> {
|
||||
for instr in self.instrs.iter_mut().rev() {
|
||||
if instr.is_branch() {
|
||||
continue;
|
||||
}
|
||||
|
||||
match &mut instr.op {
|
||||
Op::PhiSrcs(phi) => return Some(phi),
|
||||
_ => break,
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn branch(&self) -> Option<&Instr> {
|
||||
if let Some(i) = self.instrs.last() {
|
||||
if i.is_branch() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue