agx: isolate compiler debug flags
The gallium disk cache is about to depend on these, and I don't want to create a dependency on agx_opcodes.h.py for that. So, make a new header for them that doesn't have build dependencies. Rename them to agx_compiler_* too, to avoid collisions with the other driver debug flags. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21776>
This commit is contained in:
@@ -30,6 +30,7 @@
|
|||||||
#include "util/u_debug.h"
|
#include "util/u_debug.h"
|
||||||
#include "agx_builder.h"
|
#include "agx_builder.h"
|
||||||
#include "agx_compiler.h"
|
#include "agx_compiler.h"
|
||||||
|
#include "agx_debug.h"
|
||||||
#include "agx_internal_formats.h"
|
#include "agx_internal_formats.h"
|
||||||
#include "agx_nir.h"
|
#include "agx_nir.h"
|
||||||
|
|
||||||
@@ -51,13 +52,14 @@ static const struct debug_named_value agx_debug_options[] = {
|
|||||||
};
|
};
|
||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
|
|
||||||
DEBUG_GET_ONCE_FLAGS_OPTION(agx_debug, "AGX_MESA_DEBUG", agx_debug_options, 0)
|
DEBUG_GET_ONCE_FLAGS_OPTION(agx_compiler_debug, "AGX_MESA_DEBUG",
|
||||||
|
agx_debug_options, 0)
|
||||||
|
|
||||||
int agx_debug = 0;
|
int agx_compiler_debug = 0;
|
||||||
|
|
||||||
#define DBG(fmt, ...) \
|
#define DBG(fmt, ...) \
|
||||||
do { \
|
do { \
|
||||||
if (agx_debug & AGX_DBG_MSGS) \
|
if (agx_compiler_debug & AGX_DBG_MSGS) \
|
||||||
fprintf(stderr, "%s:%d: " fmt, __func__, __LINE__, ##__VA_ARGS__); \
|
fprintf(stderr, "%s:%d: " fmt, __func__, __LINE__, ##__VA_ARGS__); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
@@ -1931,7 +1933,7 @@ agx_optimize_nir(nir_shader *nir, unsigned *preamble_size)
|
|||||||
} while (progress);
|
} while (progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (likely(!(agx_debug & AGX_DBG_NOPREAMBLE)))
|
if (likely(!(agx_compiler_debug & AGX_DBG_NOPREAMBLE)))
|
||||||
NIR_PASS_V(nir, agx_nir_opt_preamble, preamble_size);
|
NIR_PASS_V(nir, agx_nir_opt_preamble, preamble_size);
|
||||||
|
|
||||||
/* Forming preambles may dramatically reduce the instruction count
|
/* Forming preambles may dramatically reduce the instruction count
|
||||||
@@ -2079,8 +2081,8 @@ agx_fp32_varying_mask(nir_shader *nir)
|
|||||||
static bool
|
static bool
|
||||||
agx_should_dump(nir_shader *nir, unsigned agx_dbg_bit)
|
agx_should_dump(nir_shader *nir, unsigned agx_dbg_bit)
|
||||||
{
|
{
|
||||||
return (agx_debug & agx_dbg_bit) &&
|
return (agx_compiler_debug & agx_dbg_bit) &&
|
||||||
!(nir->info.internal && !(agx_debug & AGX_DBG_INTERNAL));
|
!(nir->info.internal && !(agx_compiler_debug & AGX_DBG_INTERNAL));
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned
|
static unsigned
|
||||||
@@ -2123,7 +2125,7 @@ agx_compile_function_nir(nir_shader *nir, nir_function_impl *impl,
|
|||||||
|
|
||||||
agx_validate(ctx, "IR translation");
|
agx_validate(ctx, "IR translation");
|
||||||
|
|
||||||
if (likely(!(agx_debug & AGX_DBG_NOOPT))) {
|
if (likely(!(agx_compiler_debug & AGX_DBG_NOOPT))) {
|
||||||
/* Dead code eliminate before instruction combining so use counts are
|
/* Dead code eliminate before instruction combining so use counts are
|
||||||
* right */
|
* right */
|
||||||
agx_dce(ctx);
|
agx_dce(ctx);
|
||||||
@@ -2303,7 +2305,7 @@ agx_compile_shader_nir(nir_shader *nir, struct agx_shader_key *key,
|
|||||||
struct util_dynarray *binary,
|
struct util_dynarray *binary,
|
||||||
struct agx_shader_info *out)
|
struct agx_shader_info *out)
|
||||||
{
|
{
|
||||||
agx_debug = debug_get_option_agx_debug();
|
agx_compiler_debug = debug_get_option_agx_compiler_debug();
|
||||||
|
|
||||||
memset(out, 0, sizeof *out);
|
memset(out, 0, sizeof *out);
|
||||||
|
|
||||||
|
@@ -38,22 +38,6 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* clang-format off */
|
|
||||||
enum agx_dbg {
|
|
||||||
AGX_DBG_MSGS = BITFIELD_BIT(0),
|
|
||||||
AGX_DBG_SHADERS = BITFIELD_BIT(1),
|
|
||||||
AGX_DBG_SHADERDB = BITFIELD_BIT(2),
|
|
||||||
AGX_DBG_VERBOSE = BITFIELD_BIT(3),
|
|
||||||
AGX_DBG_INTERNAL = BITFIELD_BIT(4),
|
|
||||||
AGX_DBG_NOVALIDATE = BITFIELD_BIT(5),
|
|
||||||
AGX_DBG_NOOPT = BITFIELD_BIT(6),
|
|
||||||
AGX_DBG_WAIT = BITFIELD_BIT(7),
|
|
||||||
AGX_DBG_NOPREAMBLE = BITFIELD_BIT(8),
|
|
||||||
};
|
|
||||||
/* clang-format on */
|
|
||||||
|
|
||||||
extern int agx_debug;
|
|
||||||
|
|
||||||
/* r0-r127 inclusive, as pairs of 16-bits, gives 256 registers */
|
/* r0-r127 inclusive, as pairs of 16-bits, gives 256 registers */
|
||||||
#define AGX_NUM_REGS (256)
|
#define AGX_NUM_REGS (256)
|
||||||
|
|
||||||
|
54
src/asahi/compiler/agx_debug.h
Normal file
54
src/asahi/compiler/agx_debug.h
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021 Alyssa Rosenzweig <alyssa@rosenzweig.io>
|
||||||
|
* Copyright (C) 2020 Collabora Ltd.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation
|
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice (including the next
|
||||||
|
* paragraph) shall be included in all copies or substantial portions of the
|
||||||
|
* Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __AGX_DEBUG_H
|
||||||
|
#define __AGX_DEBUG_H
|
||||||
|
|
||||||
|
#include "util/macros.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* clang-format off */
|
||||||
|
enum agx_compiler_dbg {
|
||||||
|
AGX_DBG_MSGS = BITFIELD_BIT(0),
|
||||||
|
AGX_DBG_SHADERS = BITFIELD_BIT(1),
|
||||||
|
AGX_DBG_SHADERDB = BITFIELD_BIT(2),
|
||||||
|
AGX_DBG_VERBOSE = BITFIELD_BIT(3),
|
||||||
|
AGX_DBG_INTERNAL = BITFIELD_BIT(4),
|
||||||
|
AGX_DBG_NOVALIDATE = BITFIELD_BIT(5),
|
||||||
|
AGX_DBG_NOOPT = BITFIELD_BIT(6),
|
||||||
|
AGX_DBG_WAIT = BITFIELD_BIT(7),
|
||||||
|
AGX_DBG_NOPREAMBLE = BITFIELD_BIT(8),
|
||||||
|
};
|
||||||
|
/* clang-format on */
|
||||||
|
|
||||||
|
extern int agx_compiler_debug;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* extern C */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "agx_builder.h"
|
#include "agx_builder.h"
|
||||||
#include "agx_compiler.h"
|
#include "agx_compiler.h"
|
||||||
|
#include "agx_debug.h"
|
||||||
|
|
||||||
#define AGX_MAX_PENDING (8)
|
#define AGX_MAX_PENDING (8)
|
||||||
|
|
||||||
@@ -136,7 +137,7 @@ void
|
|||||||
agx_insert_waits(agx_context *ctx)
|
agx_insert_waits(agx_context *ctx)
|
||||||
{
|
{
|
||||||
agx_foreach_block(ctx, block) {
|
agx_foreach_block(ctx, block) {
|
||||||
if (agx_debug & AGX_DBG_WAIT)
|
if (agx_compiler_debug & AGX_DBG_WAIT)
|
||||||
agx_insert_waits_trivial(ctx, block);
|
agx_insert_waits_trivial(ctx, block);
|
||||||
else
|
else
|
||||||
agx_insert_waits_local(ctx, block);
|
agx_insert_waits_local(ctx, block);
|
||||||
|
@@ -23,6 +23,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "agx_compiler.h"
|
#include "agx_compiler.h"
|
||||||
|
#include "agx_debug.h"
|
||||||
|
|
||||||
/* Validatation doesn't make sense in release builds */
|
/* Validatation doesn't make sense in release builds */
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
@@ -190,7 +191,7 @@ agx_validate(agx_context *ctx, const char *after)
|
|||||||
{
|
{
|
||||||
bool fail = false;
|
bool fail = false;
|
||||||
|
|
||||||
if (agx_debug & AGX_DBG_NOVALIDATE)
|
if (agx_compiler_debug & AGX_DBG_NOVALIDATE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
agx_foreach_block(ctx, block) {
|
agx_foreach_block(ctx, block) {
|
||||||
|
Reference in New Issue
Block a user