nak: Fold Src::fold_imm() into the legalization pass

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34818>
This commit is contained in:
Faith Ekstrand
2025-05-05 10:37:43 -04:00
committed by Marge Bot
parent c3417c3c82
commit 2f8b27713d
2 changed files with 9 additions and 14 deletions
-13
View File
@@ -1197,19 +1197,6 @@ impl Src {
})
}
pub fn fold_imm(&self, src_type: SrcType) -> Src {
// Don't fold Zero
if !matches!(self.src_ref, SrcRef::Imm32(_)) {
return *self;
}
if let Some(u) = self.as_u32(src_type) {
u.into()
} else {
*self
}
}
pub fn as_ssa(&self) -> Option<&SSARef> {
if self.src_mod.is_none() {
self.src_ref.as_ssa()
+9 -1
View File
@@ -387,7 +387,15 @@ fn legalize_instr(
let src_types = instr.src_types();
for (i, src) in instr.srcs_mut().iter_mut().enumerate() {
*src = src.fold_imm(src_types[i]);
if matches!(src.src_ref, SrcRef::Imm32(_)) {
// Fold modifiers on Imm32 sources whenever possible. Not all
// instructions suppport modifiers and immediates at the same time.
// But leave Zero sources alone as we don't want to make things
// immediates that could just be rZ.
if let Some(u) = src.as_u32(src_types[i]) {
*src = u.into();
}
}
b.copy_src_if_not_same_file(src);
if !block_uniform {