mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-21 13:40:16 +01:00
aco: print assembly with CLRXdisasm for GFX6-GFX7 if found on the system
LLVM only supports GFX8+. Using CLRXdisasm works most of the time, so it's useful to add support for it. Original patch by Daniel Schürmann. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Daniel Schürmann <daniel@schuermann.dev> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3439> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3439>
This commit is contained in:
parent
51de5d5ac6
commit
0099f85232
1 changed files with 39 additions and 1 deletions
|
|
@ -8,13 +8,51 @@
|
||||||
|
|
||||||
namespace aco {
|
namespace aco {
|
||||||
|
|
||||||
|
/* LLVM disassembler only supports GFX8+, try to disassemble with CLRXdisasm
|
||||||
|
* for GFX6-GFX7 if found on the system, this is better than nothing.
|
||||||
|
*/
|
||||||
|
void print_asm_gfx6_gfx7(Program *program, std::vector<uint32_t>& binary,
|
||||||
|
std::ostream& out)
|
||||||
|
{
|
||||||
|
char path[] = "/tmp/fileXXXXXX";
|
||||||
|
char line[2048], command[128];
|
||||||
|
FILE *p;
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
/* Dump the binary into a temporary file. */
|
||||||
|
fd = mkstemp(path);
|
||||||
|
if (fd < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (uint32_t w : binary)
|
||||||
|
{
|
||||||
|
if (write(fd, &w, sizeof(w)) == -1)
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(command, "clrxdisasm --gpuType=%s -r %s",
|
||||||
|
program->chip_class == GFX6 ? "gfx600" : "gfx700", path);
|
||||||
|
|
||||||
|
p = popen(command, "r");
|
||||||
|
if (p) {
|
||||||
|
while (fgets(line, sizeof(line), p))
|
||||||
|
out << line;
|
||||||
|
pclose(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
fail:
|
||||||
|
close(fd);
|
||||||
|
unlink(path);
|
||||||
|
}
|
||||||
|
|
||||||
void print_asm(Program *program, std::vector<uint32_t>& binary,
|
void print_asm(Program *program, std::vector<uint32_t>& binary,
|
||||||
unsigned exec_size, std::ostream& out)
|
unsigned exec_size, std::ostream& out)
|
||||||
{
|
{
|
||||||
if (program->chip_class <= GFX7) {
|
if (program->chip_class <= GFX7) {
|
||||||
out << "Disassembly for this GPU currently not supported." << std::endl;
|
print_asm_gfx6_gfx7(program, binary, out);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<bool> referenced_blocks(program->blocks.size());
|
std::vector<bool> referenced_blocks(program->blocks.size());
|
||||||
referenced_blocks[0] = true;
|
referenced_blocks[0] = true;
|
||||||
for (Block& block : program->blocks) {
|
for (Block& block : program->blocks) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue