pan/compiler: Split bi_debug.c from bifrost_compile.c

Signed-off-by: Lorenzo Rossi <lorenzo.rossi@collabora.com>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Reviewed-by: Christoph Pillmayer <christoph.pillmayer@arm.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40717>
This commit is contained in:
Lorenzo Rossi 2026-03-30 18:54:45 +02:00 committed by Marge Bot
parent f19b9eddb6
commit 7d8b2c4128
12 changed files with 113 additions and 66 deletions

View file

@ -0,0 +1,58 @@
/*
* Copyright (C) 2020 Collabora Ltd.
* Copyright (C) 2022 Alyssa Rosenzweig
* Copyright (C) 2025 Arm Ltd.
* SPDX-License-Identifier: MIT
*/
#include "util/u_debug.h"
#include "bi_debug.h"
/* clang-format off */
static const struct debug_named_value bifrost_debug_options[] = {
{"shaders", BIFROST_DBG_SHADERS, "Dump shaders in NIR and MIR"},
{"shaderdb", BIFROST_DBG_SHADERDB, "Print statistics"},
{"verbose", BIFROST_DBG_VERBOSE, "Disassemble verbosely"},
{"internal", BIFROST_DBG_INTERNAL, "Dump even internal shaders"},
{"nosched", BIFROST_DBG_NOSCHED, "Force trivial bundling"},
{"nopsched", BIFROST_DBG_NOPSCHED, "Disable scheduling for pressure"},
{"inorder", BIFROST_DBG_INORDER, "Force in-order bundling"},
{"novalidate", BIFROST_DBG_NOVALIDATE, "Skip IR validation"},
{"noopt", BIFROST_DBG_NOOPT, "Skip optimization passes"},
{"noidvs", BIFROST_DBG_NOIDVS, "Disable IDVS"},
{"nosb", BIFROST_DBG_NOSB, "Disable scoreboarding"},
{"nopreload", BIFROST_DBG_NOPRELOAD, "Disable message preloading"},
{"spill", BIFROST_DBG_SPILL, "Test register spilling"},
{"nossara", BIFROST_DBG_NOSSARA, "Disable SSA in register allocation"},
{"statsabs", BIFROST_DBG_STATSABS, "Don't normalize statistics"},
{"statsfull", BIFROST_DBG_STATSFULL, "Print verbose statistics"},
{"debuginfo", BIFROST_DBG_DEBUGINFO, "Print debug information"},
DEBUG_NAMED_VALUE_END
};
/* clang-format on */
DEBUG_GET_ONCE_FLAGS_OPTION(bifrost_debug, "BIFROST_MESA_DEBUG",
bifrost_debug_options, 0)
unsigned bifrost_debug = 0;
void
bifrost_init_debug_options() {
bifrost_debug = debug_get_option_bifrost_debug();
}
bool
bifrost_will_dump_shaders(void)
{
bifrost_init_debug_options();
return bifrost_debug & BIFROST_DBG_SHADERS;
}
bool
bifrost_want_debug_info(void)
{
bifrost_init_debug_options();
return bifrost_debug & BIFROST_DBG_DEBUGINFO;
}

View file

@ -0,0 +1,47 @@
/*
* Copyright (C) 2019 Connor Abbott <cwabbott0@gmail.com>
* Copyright (C) 2019 Lyude Paul <thatslyude@gmail.com>
* Copyright (C) 2019 Ryan Houdek <Sonicadvance1@gmail.com>
* SPDX-License-Identifier: MIT
*/
#ifndef __bi_debug_h__
#define __bi_debug_h__
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
#define BIFROST_DBG_MSGS 0x0001
#define BIFROST_DBG_SHADERS 0x0002
#define BIFROST_DBG_SHADERDB 0x0004
#define BIFROST_DBG_VERBOSE 0x0008
#define BIFROST_DBG_INTERNAL 0x0010
#define BIFROST_DBG_NOSCHED 0x0020
#define BIFROST_DBG_INORDER 0x0040
#define BIFROST_DBG_NOVALIDATE 0x0080
#define BIFROST_DBG_NOOPT 0x0100
#define BIFROST_DBG_NOIDVS 0x0200
#define BIFROST_DBG_NOSB 0x0400
#define BIFROST_DBG_NOPRELOAD 0x0800
#define BIFROST_DBG_SPILL 0x1000
#define BIFROST_DBG_NOPSCHED 0x2000
#define BIFROST_DBG_NOSSARA 0x4000
#define BIFROST_DBG_STATSABS 0x8000
#define BIFROST_DBG_STATSFULL 0x10000
#define BIFROST_DBG_DEBUGINFO 0x20000
extern unsigned bifrost_debug;
void bifrost_init_debug_options(void);
bool bifrost_will_dump_shaders(void);
bool bifrost_want_debug_info(void);
#ifdef __cplusplus
} /* extern C */
#endif
#endif

View file

@ -4,6 +4,7 @@
*/
#include "util/u_memory.h"
#include "bi_debug.h"
#include "bi_builder.h"
#include "compiler.h"
#include "nodearray.h"

View file

@ -4,6 +4,7 @@
*/
#include "util/u_memory.h"
#include "bi_debug.h"
#include "compiler.h"
/* Validatation doesn't make sense in release builds */

View file

@ -17,27 +17,6 @@
extern "C" {
#endif
#define BIFROST_DBG_MSGS 0x0001
#define BIFROST_DBG_SHADERS 0x0002
#define BIFROST_DBG_SHADERDB 0x0004
#define BIFROST_DBG_VERBOSE 0x0008
#define BIFROST_DBG_INTERNAL 0x0010
#define BIFROST_DBG_NOSCHED 0x0020
#define BIFROST_DBG_INORDER 0x0040
#define BIFROST_DBG_NOVALIDATE 0x0080
#define BIFROST_DBG_NOOPT 0x0100
#define BIFROST_DBG_NOIDVS 0x0200
#define BIFROST_DBG_NOSB 0x0400
#define BIFROST_DBG_NOPRELOAD 0x0800
#define BIFROST_DBG_SPILL 0x1000
#define BIFROST_DBG_NOPSCHED 0x2000
#define BIFROST_DBG_NOSSARA 0x4000
#define BIFROST_DBG_STATSABS 0x8000
#define BIFROST_DBG_STATSFULL 0x10000
#define BIFROST_DBG_DEBUGINFO 0x20000
extern unsigned bifrost_debug;
enum bifrost_message_type {
BIFROST_MESSAGE_NONE = 0,
BIFROST_MESSAGE_VARYING = 1,

View file

@ -3,6 +3,7 @@
* SPDX-License-Identifier: MIT
*/
#include "bi_debug.h"
#include "bi_builder.h"
#include "compiler.h"

View file

@ -4,6 +4,7 @@
*/
#include "compiler.h"
#include "bi_debug.h"
/* Assign dependency slots to each clause and calculate dependencies, This pass
* must be run after scheduling.

View file

@ -15,6 +15,7 @@
#include "util/u_debug.h"
#include "util/u_qsort.h"
#include "bifrost/bi_debug.h"
#include "bifrost/disassemble.h"
#include "panfrost/lib/pan_props.h"
#include "valhall/disassemble.h"
@ -29,52 +30,11 @@ static void pan_stats_verbose(FILE *f, const char *prefix, bi_context *ctx,
const struct pan_stats *stats,
const struct pan_shader_info *info);
/* clang-format off */
static const struct debug_named_value bifrost_debug_options[] = {
{"shaders", BIFROST_DBG_SHADERS, "Dump shaders in NIR and MIR"},
{"shaderdb", BIFROST_DBG_SHADERDB, "Print statistics"},
{"verbose", BIFROST_DBG_VERBOSE, "Disassemble verbosely"},
{"internal", BIFROST_DBG_INTERNAL, "Dump even internal shaders"},
{"nosched", BIFROST_DBG_NOSCHED, "Force trivial bundling"},
{"nopsched", BIFROST_DBG_NOPSCHED, "Disable scheduling for pressure"},
{"inorder", BIFROST_DBG_INORDER, "Force in-order bundling"},
{"novalidate", BIFROST_DBG_NOVALIDATE, "Skip IR validation"},
{"noopt", BIFROST_DBG_NOOPT, "Skip optimization passes"},
{"noidvs", BIFROST_DBG_NOIDVS, "Disable IDVS"},
{"nosb", BIFROST_DBG_NOSB, "Disable scoreboarding"},
{"nopreload", BIFROST_DBG_NOPRELOAD, "Disable message preloading"},
{"spill", BIFROST_DBG_SPILL, "Test register spilling"},
{"nossara", BIFROST_DBG_NOSSARA, "Disable SSA in register allocation"},
{"statsabs", BIFROST_DBG_STATSABS, "Don't normalize statistics"},
{"statsfull", BIFROST_DBG_STATSFULL, "Print verbose statistics"},
{"debuginfo", BIFROST_DBG_DEBUGINFO, "Print debug information"},
DEBUG_NAMED_VALUE_END
};
/* clang-format on */
DEBUG_GET_ONCE_FLAGS_OPTION(bifrost_debug, "BIFROST_MESA_DEBUG",
bifrost_debug_options, 0)
/* How many bytes are prefetched by the Bifrost shader core. From the final
* clause of the shader, this range must be valid instructions or zero. */
#define BIFROST_SHADER_PREFETCH 128
unsigned bifrost_debug = 0;
bool
bifrost_will_dump_shaders(void)
{
bifrost_debug = debug_get_option_bifrost_debug();
return bifrost_debug & BIFROST_DBG_SHADERS;
}
bool
bifrost_want_debug_info(void)
{
bifrost_debug = debug_get_option_bifrost_debug();
return bifrost_debug & BIFROST_DBG_DEBUGINFO;
}
static bi_block *emit_cf_list(bi_context *ctx, struct exec_list *list);
static bi_index

View file

@ -18,7 +18,6 @@ struct bifrost_precompiled_kernel_sysvals {
} num_workgroups;
uint64_t printf_buffer_address;
} __attribute__((aligned(8)));
;
#define BIFROST_PRECOMPILED_KERNEL_SYSVALS_SIZE \
sizeof(struct bifrost_precompiled_kernel_sysvals)
@ -69,9 +68,6 @@ void bifrost_postprocess_nir(nir_shader *nir, unsigned gpu_id);
void bifrost_lower_texture_nir(nir_shader *nir, unsigned gpu_id);
void bifrost_lower_texture_late_nir(nir_shader *nir, unsigned gpu_id);
bool bifrost_will_dump_shaders(void);
bool bifrost_want_debug_info(void);
void bifrost_compile_shader_nir(nir_shader *nir,
const struct pan_compile_inputs *inputs,
struct util_dynarray *binary,

View file

@ -31,6 +31,7 @@ libpanfrost_bifrost_files = files(
'bi_repair_ssa.c',
'bi_validate.c',
'bi_dominance.c',
'bi_debug.c',
'bir.c',
'bifrost_compile.c',
'bifrost/bi_opt_message_preload.c',

View file

@ -5,6 +5,7 @@
#include "panfrost/lib/pan_props.h"
#include "bi_debug.h"
#include "bi_builder.h"
#include "va_compiler.h"
#include "valhall_enums.h"

View file

@ -6,6 +6,7 @@
#include "pan_compiler.h"
#include "pan_nir.h"
#include "bifrost/bi_debug.h"
#include "bifrost/bifrost_compile.h"
#include "bifrost/bifrost/disassemble.h"
#include "bifrost/valhall/disassemble.h"