pan: Move disassembly wrappers to a new pan_compiler.h

This is going to be where we put the compiler interface.  For now,
disassembly wrappers are as good a place to start as any.

Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Acked-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38753>
This commit is contained in:
Faith Ekstrand 2025-12-01 10:30:06 -05:00 committed by Marge Bot
parent 1f068d8c71
commit 55ae25f2d7
6 changed files with 85 additions and 26 deletions

View file

@ -2,6 +2,8 @@
# SPDX-License-Identifier: MIT
libpanfrost_compiler_files = files(
'pan_compiler.c',
'pan_compiler.h',
'pan_ir.c',
'pan_ir.h',
'pan_nir_collect_varyings.c',

View file

@ -0,0 +1,43 @@
/*
* Copyright (C) 2025 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.
*
*/
#include "pan_compiler.h"
#include "bifrost/bifrost/disassemble.h"
#include "bifrost/valhall/disassemble.h"
#include "midgard/disassemble.h"
#include "panfrost/model/pan_model.h"
void
pan_disassemble(FILE *fp, const void *code, size_t size,
unsigned gpu_id, bool verbose)
{
if (pan_arch(gpu_id) >= 9)
disassemble_valhall(fp, (const uint64_t *)code, size, verbose);
else if (pan_arch(gpu_id) >= 6)
disassemble_bifrost(fp, code, size, verbose);
else
disassemble_midgard(fp, code, size, gpu_id, verbose);
}

View file

@ -0,0 +1,34 @@
/*
* Copyright (C) 2025 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 __PAN_COMPILER_H__
#define __PAN_COMPILER_H__
#include <stdbool.h>
#include <stdio.h>
void pan_disassemble(FILE *fp, const void *code, size_t size,
unsigned gpu_id, bool verbose);
#endif /* __PAN_COMPILER_H__ */

View file

@ -38,9 +38,7 @@
#include "util/u_process.h"
#include "decode.h"
#include "compiler/bifrost/bifrost/disassemble.h"
#include "compiler/bifrost/valhall/disassemble.h"
#include "midgard/disassemble.h"
#include "compiler/pan_compiler.h"
/* Used to distiguish dumped files, otherwise we would have to print the ctx
* pointer, which is annoying for the user since it changes with every run */
@ -513,12 +511,8 @@ pandecode_shader_disassemble(struct pandecode_context *ctx, uint64_t shader_ptr,
pandecode_log_cont(ctx, "\nShader %p (GPU VA %" PRIx64 ") sz %" PRId64 "\n",
code, shader_ptr, sz);
if (pan_arch(gpu_id) >= 9) {
disassemble_valhall(ctx->dump_stream, (const uint64_t *)code, sz, true);
} else if (pan_arch(gpu_id) >= 6)
disassemble_bifrost(ctx->dump_stream, code, sz, false);
else
disassemble_midgard(ctx->dump_stream, code, sz, gpu_id, true);
bool verbose = pan_arch(gpu_id) >= 6 && pan_arch(gpu_id) < 9;
pan_disassemble(ctx->dump_stream, code, sz, gpu_id, verbose);
pandecode_log_cont(ctx, "\n\n");
}

View file

@ -27,9 +27,6 @@
#include "compiler/nir/nir.h"
#include "genxml/gen_macros.h"
#include "panfrost/compiler/bifrost/bifrost/disassemble.h"
#include "panfrost/compiler/bifrost/valhall/disassemble.h"
#include "panfrost/compiler/midgard/disassemble.h"
#include "panfrost/lib/pan_props.h"
#include "panfrost/compiler/pan_ir.h"
#include "panfrost/compiler/pan_nir_lower_framebuffer.h"
@ -101,18 +98,6 @@ pan_shader_lower_texture_late(nir_shader *nir, unsigned gpu_id)
bifrost_lower_texture_late_nir(nir, gpu_id);
}
static inline void
pan_shader_disassemble(FILE *fp, const void *code, size_t size, unsigned gpu_id,
bool verbose)
{
if (pan_arch(gpu_id) >= 9)
disassemble_valhall(fp, (const uint64_t *)code, size, verbose);
else if (pan_arch(gpu_id) >= 6)
disassemble_bifrost(fp, code, size, verbose);
else
disassemble_midgard(fp, code, size, gpu_id, verbose);
}
void pan_shader_compile(nir_shader *nir, struct pan_compile_inputs *inputs,
struct util_dynarray *binary,
struct pan_shader_info *info);

View file

@ -55,6 +55,7 @@
#include "vk_ycbcr_conversion.h"
#include "compiler/bifrost/bifrost_nir.h"
#include "compiler/pan_compiler.h"
#include "pan_shader.h"
#include "vk_log.h"
@ -995,8 +996,8 @@ panvk_compile_nir(struct panvk_device *dev, nir_shader *nir,
struct u_memstream mem;
if (u_memstream_open(&mem, &data, &disasm_size)) {
FILE *const stream = u_memstream_get(&mem);
pan_shader_disassemble(stream, shader->bin_ptr, shader->bin_size,
compile_input->gpu_id, false);
pan_disassemble(stream, shader->bin_ptr, shader->bin_size,
compile_input->gpu_id, false);
u_memstream_close(&mem);
}
}