[Mesa-dev] [PATCH] radeon/llvm: show LLVM disassembly when available
Tom Stellard
tom at stellard.net
Sat Oct 12 07:06:16 CEST 2013
On Thu, Oct 10, 2013 at 08:06:48PM -0500, Jay Cornwall wrote:
> With code dump enabled LLVM may generate disassembly during compilation.
> Show this disassembly when available and prefer it to SI bytecode dump.
>
I've pushed this and the LLVM patch. Thanks!
-Tom
> Signed-off-by: Jay Cornwall <jay at jcornwall.me>
> ---
> src/gallium/drivers/radeon/radeon_llvm_emit.c | 7 +++++++
> src/gallium/drivers/radeon/radeon_llvm_emit.h | 1 +
> src/gallium/drivers/radeonsi/radeonsi_shader.c | 2 +-
> 3 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/radeon/radeon_llvm_emit.c b/src/gallium/drivers/radeon/radeon_llvm_emit.c
> index 2dd7bf7..6478a4b 100644
> --- a/src/gallium/drivers/radeon/radeon_llvm_emit.c
> +++ b/src/gallium/drivers/radeon/radeon_llvm_emit.c
> @@ -143,6 +143,7 @@ unsigned radeon_llvm_compile(LLVMModuleRef M, struct radeon_llvm_binary *binary,
> elf = elf_memory(elf_buffer, buffer_size);
>
> elf_getshdrstrndx(elf, §ion_str_index);
> + binary->disassembled = 0;
>
> while ((section = elf_nextscn(elf, section))) {
> const char *name;
> @@ -163,6 +164,12 @@ unsigned radeon_llvm_compile(LLVMModuleRef M, struct radeon_llvm_binary *binary,
> binary->config_size = section_data->d_size;
> binary->config = MALLOC(binary->config_size * sizeof(unsigned char));
> memcpy(binary->config, section_data->d_buf, binary->config_size);
> + } else if (dump && !strcmp(name, ".AMDGPU.disasm")) {
> + binary->disassembled = 1;
> + section_data = elf_getdata(section, section_data);
> + fprintf(stderr, "\nShader Disassembly:\n\n");
> + fprintf(stderr, "%.*s\n", (int)section_data->d_size,
> + (char *)section_data->d_buf);
> }
> }
>
> diff --git a/src/gallium/drivers/radeon/radeon_llvm_emit.h b/src/gallium/drivers/radeon/radeon_llvm_emit.h
> index 72c24c6..532b7b8 100644
> --- a/src/gallium/drivers/radeon/radeon_llvm_emit.h
> +++ b/src/gallium/drivers/radeon/radeon_llvm_emit.h
> @@ -34,6 +34,7 @@ struct radeon_llvm_binary {
> unsigned code_size;
> unsigned char *config;
> unsigned config_size;
> + int disassembled;
> };
>
> void radeon_llvm_shader_type(LLVMValueRef F, unsigned type);
> diff --git a/src/gallium/drivers/radeonsi/radeonsi_shader.c b/src/gallium/drivers/radeonsi/radeonsi_shader.c
> index 97ed4e3..88fc040 100644
> --- a/src/gallium/drivers/radeonsi/radeonsi_shader.c
> +++ b/src/gallium/drivers/radeonsi/radeonsi_shader.c
> @@ -1764,7 +1764,7 @@ int si_compile_llvm(struct r600_context *rctx, struct si_pipe_shader *shader,
> memset(&binary, 0, sizeof(binary));
> radeon_llvm_compile(mod, &binary,
> r600_get_llvm_processor_name(rctx->screen->b.family), dump);
> - if (dump) {
> + if (dump && ! binary.disassembled) {
> fprintf(stderr, "SI CODE:\n");
> for (i = 0; i < binary.code_size; i+=4 ) {
> fprintf(stderr, "%02x%02x%02x%02x\n", binary.code[i + 3],
> --
> 1.8.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list