nak: Add a Dst::file() helper function

Reviewed-by: Mary Guillemard <mary@mary.zone>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38939>
This commit is contained in:
Mel Henning 2025-04-25 13:47:18 -04:00 committed by Marge Bot
parent f5f89407f6
commit b4bac84d3b
3 changed files with 20 additions and 24 deletions

View file

@ -505,6 +505,14 @@ impl Dst {
Dst::Reg(reg) => reg.comps(),
}
}
pub fn file(&self) -> Option<RegFile> {
match self {
Dst::None => None,
Dst::SSA(ssa) => Some(ssa.file()),
Dst::Reg(reg) => Some(reg.file()),
}
}
}
impl From<RegRef> for Dst {

View file

@ -1215,10 +1215,8 @@ impl SM75Latency {
read: Option<&Op>,
src_idx: usize,
) -> u32 {
let dst_file = match &write.dsts_as_slice()[dst_idx] {
Dst::None => return 0,
Dst::SSA(vec) => vec.file(),
Dst::Reg(reg) => reg.file(),
let Some(dst_file) = write.dsts_as_slice()[dst_idx].file() else {
return 0;
};
match dst_file {
@ -1274,10 +1272,8 @@ impl SM75Latency {
}
pub fn war(read: &Op, src_idx: usize, write: &Op, dst_idx: usize) -> u32 {
let dst_file = match &write.dsts_as_slice()[dst_idx] {
Dst::None => return 0,
Dst::SSA(vec) => vec.file(),
Dst::Reg(reg) => reg.file(),
let Some(dst_file) = write.dsts_as_slice()[dst_idx].file() else {
return 0;
};
match dst_file {
@ -1330,10 +1326,8 @@ impl SM75Latency {
b_dst_idx: usize,
a_op_pred: bool,
) -> u32 {
let dst_file = match &a.dsts_as_slice()[a_dst_idx] {
Dst::None => return 0,
Dst::SSA(vec) => vec.file(),
Dst::Reg(reg) => reg.file(),
let Some(dst_file) = a.dsts_as_slice()[a_dst_idx].file() else {
return 0;
};
match dst_file {

View file

@ -1473,10 +1473,8 @@ impl SM80Latency {
read: Option<&Op>,
src_idx: usize,
) -> u32 {
let dst_file = match &write.dsts_as_slice()[dst_idx] {
Dst::None => return 0,
Dst::SSA(vec) => vec.file(),
Dst::Reg(reg) => reg.file(),
let Some(dst_file) = write.dsts_as_slice()[dst_idx].file() else {
return 0;
};
match dst_file {
@ -1530,10 +1528,8 @@ impl SM80Latency {
}
pub fn war(read: &Op, src_idx: usize, write: &Op, dst_idx: usize) -> u32 {
let dst_file = match &write.dsts_as_slice()[dst_idx] {
Dst::None => return 0,
Dst::SSA(vec) => vec.file(),
Dst::Reg(reg) => reg.file(),
let Some(dst_file) = write.dsts_as_slice()[dst_idx].file() else {
return 0;
};
match dst_file {
@ -1582,10 +1578,8 @@ impl SM80Latency {
b_dst_idx: usize,
a_op_pred: bool,
) -> u32 {
let dst_file = match &a.dsts_as_slice()[a_dst_idx] {
Dst::None => return 0,
Dst::SSA(vec) => vec.file(),
Dst::Reg(reg) => reg.file(),
let Some(dst_file) = a.dsts_as_slice()[a_dst_idx].file() else {
return 0;
};
match dst_file {