rusticl/nir: add a nir_pass macro
Signed-off-by: Karol Herbst <git@karolherbst.de> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21451>
This commit is contained in:
@@ -40,6 +40,75 @@ impl<'a, T: 'a> Iterator for ExecListIter<'a, T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
#[cfg(debug_assertions)]
|
||||
macro_rules! nir_pass_impl {
|
||||
($nir:ident, $pass:ident, $func:ident $(,$arg:expr)* $(,)?) => {
|
||||
{
|
||||
let func_str = ::std::stringify!($func);
|
||||
let func_cstr = ::std::ffi::CString::new(func_str).unwrap();
|
||||
let res = if unsafe { should_skip_nir(func_cstr.as_ptr()) } {
|
||||
println!("skipping {}", func_str);
|
||||
false
|
||||
} else {
|
||||
$nir.metadata_set_validation_flag();
|
||||
if $nir.should_print() {
|
||||
println!("{}", func_str);
|
||||
}
|
||||
if $nir.$pass($func $(,$arg)*) {
|
||||
$nir.validate(&format!("after {} in {}:{}", func_str, file!(), line!()));
|
||||
if $nir.should_print() {
|
||||
$nir.print();
|
||||
}
|
||||
$nir.metadata_check_validation_flag();
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
};
|
||||
|
||||
// SAFETY: mutable static can't be read safely, but this value isn't going to change
|
||||
let ndebug = unsafe { nir_debug };
|
||||
if ndebug & NIR_DEBUG_CLONE != 0 {
|
||||
$nir.validate_clone();
|
||||
}
|
||||
|
||||
if ndebug & NIR_DEBUG_SERIALIZE != 0 {
|
||||
$nir.validate_serialize_deserialize();
|
||||
}
|
||||
|
||||
res
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
#[cfg(not(debug_assertions))]
|
||||
macro_rules! nir_pass_impl {
|
||||
($nir:ident, $pass:ident, $func:ident $(,$arg:expr)* $(,)?) => {
|
||||
$nir.$pass($func $(,$arg)*)
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! nir_pass {
|
||||
($nir:ident, $func:ident $(,)?) => {
|
||||
$crate::nir_pass_impl!($nir, pass0, $func)
|
||||
};
|
||||
|
||||
($nir:ident, $func:ident, $a:expr $(,)?) => {
|
||||
$crate::nir_pass_impl!($nir, pass1, $func, $a)
|
||||
};
|
||||
|
||||
($nir:ident, $func:ident, $a:expr, $b:expr $(,)?) => {
|
||||
$crate::nir_pass_impl!($nir, pass2, $func, $a, $b)
|
||||
};
|
||||
|
||||
($nir:ident, $func:ident, $a:expr, $b:expr, $c:expr $(,)?) => {
|
||||
$crate::nir_pass_impl!($nir, pass3, $func, $a, $b, $c)
|
||||
};
|
||||
}
|
||||
|
||||
pub struct NirPrintfInfo {
|
||||
count: usize,
|
||||
printf_info: *mut u_printf_info,
|
||||
|
||||
@@ -267,6 +267,8 @@ rusticl_mesa_bindings_rs = rust.bindgen(
|
||||
|
||||
# nir and spirv
|
||||
'--allowlist-function', 'nir_.*',
|
||||
'--allowlist-var', 'nir_debug',
|
||||
'--allowlist-var', 'NIR_DEBUG_.*',
|
||||
'--bitfield-enum', 'nir_lower_int64_options',
|
||||
'--bitfield-enum', 'nir_opt_if_options',
|
||||
'--bitfield-enum', 'nir_variable_mode',
|
||||
|
||||
Reference in New Issue
Block a user