nak: Add a debug flag to test spilling

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
This commit is contained in:
Faith Ekstrand 2023-09-01 10:31:24 -05:00 committed by Marge Bot
parent 07b9465b5d
commit 84d1765690
2 changed files with 12 additions and 1 deletions

View file

@ -40,6 +40,7 @@ use util::NextMultipleOf;
enum DebugFlags {
Print,
Serial,
Spill,
}
struct Debug {
@ -61,6 +62,7 @@ impl Debug {
match flag.trim() {
"print" => flags |= 1 << DebugFlags::Print as u8,
"serial" => flags |= 1 << DebugFlags::Serial as u8,
"spill" => flags |= 1 << DebugFlags::Spill as u8,
unk => eprintln!("Unknown NAK_DEBUG flag \"{}\"", unk),
}
}
@ -78,6 +80,10 @@ trait GetDebugFlags {
fn serial(&self) -> bool {
self.debug_flags() & (1 << DebugFlags::Serial as u8) != 0
}
fn spill(&self) -> bool {
self.debug_flags() & (1 << DebugFlags::Spill as u8) != 0
}
}
static DEBUG: OnceLock<Debug> = OnceLock::new();

View file

@ -9,6 +9,7 @@ pub use crate::nak_builder::{
Builder, InstrBuilder, SSABuilder, SSAInstrBuilder,
};
use crate::nak_cfg::CFG;
use crate::{GetDebugFlags, DEBUG};
use nak_ir_proc::*;
use std::fmt;
use std::iter::Zip;
@ -77,7 +78,11 @@ impl RegFile {
pub fn num_regs(&self, sm: u8) -> u32 {
match self {
RegFile::GPR => {
if sm >= 75 {
if DEBUG.spill() {
// We need at least 16 registers to satisfy RA constraints
// for texture ops and another 2 for parallel copy lowering
18
} else if sm >= 75 {
// Turing+ has a maximum of 253 registers. Presumably
// because two registers get burned for UGPRs?
253