nak: impl fmt::Debug for SSAValue

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38807>
This commit is contained in:
Mel Henning 2025-12-05 15:17:52 -05:00 committed by Eric Engestrom
parent 9f830f622f
commit f48fcfe552

View file

@ -67,6 +67,12 @@ impl fmt::Display for SSAValue {
}
}
impl fmt::Debug for SSAValue {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(self, f)
}
}
#[derive(Clone, Eq, Hash, PartialEq)]
struct SSAValueArray<const SIZE: usize> {
v: [SSAValue; SIZE],
@ -343,3 +349,15 @@ impl SSAValueAllocator {
SSARef::from_iter((0..comps).map(|_| self.alloc(file)))
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_ssa_value_print() {
let ssa = SSAValue::new(RegFile::UPred, 42);
assert_eq!(format!("{}", ssa), "%up42");
assert_eq!(format!("{:?}", ssa), "%up42");
}
}