radeonsi: make LLVM IR dumping less messy
authorMarek Olšák <marek.olsak@amd.com>
Tue, 26 Jan 2016 22:32:23 +0000 (23:32 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 9 Feb 2016 20:19:51 +0000 (21:19 +0100)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeonsi/si_compute.c
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader.h

index 825fbb181ba1069a7d649c355c8f4e0b1b39c58d..4d27e86b4146da9a07b04e7ad0b978de5165cb52 100644 (file)
@@ -124,7 +124,8 @@ static void *si_create_compute_state(
                                                         code, header->num_bytes);
                        si_compile_llvm(sctx->screen, &program->kernels[i].binary,
                                        &program->kernels[i].config, sctx->tm,
-                                       mod, &sctx->b.debug, TGSI_PROCESSOR_COMPUTE);
+                                       mod, &sctx->b.debug, TGSI_PROCESSOR_COMPUTE,
+                                       "Compute Shader");
                        si_shader_dump(sctx->screen, &program->kernels[i],
                                       &sctx->b.debug, TGSI_PROCESSOR_COMPUTE);
                        si_shader_binary_upload(sctx->screen, &program->kernels[i]);
index 7f151516b8bd7350869d926d794c741614d48947..4551831dd2ac87e73951f7a656e7f9f0ad6f0dfe 100644 (file)
@@ -4081,7 +4081,8 @@ int si_compile_llvm(struct si_screen *sscreen,
                    LLVMTargetMachineRef tm,
                    LLVMModuleRef mod,
                    struct pipe_debug_callback *debug,
-                   unsigned processor)
+                   unsigned processor,
+                   const char *name)
 {
        int r = 0;
        unsigned count = p_atomic_inc_return(&sscreen->b.num_compilations);
@@ -4089,8 +4090,11 @@ int si_compile_llvm(struct si_screen *sscreen,
        if (r600_can_dump_shader(&sscreen->b, processor)) {
                fprintf(stderr, "radeonsi: Compiling shader %d\n", count);
 
-               if (!(sscreen->b.debug_flags & (DBG_NO_IR | DBG_PREOPT_IR)))
+               if (!(sscreen->b.debug_flags & (DBG_NO_IR | DBG_PREOPT_IR))) {
+                       fprintf(stderr, "%s LLVM IR:\n\n", name);
                        LLVMDumpModule(mod);
+                       fprintf(stderr, "\n");
+               }
        }
 
        if (!si_replace_shader(count, binary)) {
@@ -4183,14 +4187,14 @@ static int si_generate_gs_copy_shader(struct si_screen *sscreen,
 
        radeon_llvm_finalize_module(&si_shader_ctx->radeon_bld);
 
-       if (r600_can_dump_shader(&sscreen->b, TGSI_PROCESSOR_GEOMETRY))
-               fprintf(stderr, "Copy Vertex Shader for Geometry Shader:\n\n");
-
        r = si_compile_llvm(sscreen, &si_shader_ctx->shader->binary,
                            &si_shader_ctx->shader->config, si_shader_ctx->tm,
                            bld_base->base.gallivm->module,
-                           debug, TGSI_PROCESSOR_GEOMETRY);
+                           debug, TGSI_PROCESSOR_GEOMETRY,
+                           "GS Copy Shader");
        if (!r) {
+               if (r600_can_dump_shader(&sscreen->b, TGSI_PROCESSOR_GEOMETRY))
+                       fprintf(stderr, "GS Copy Shader:\n");
                si_shader_dump(sscreen, si_shader_ctx->shader, debug,
                               TGSI_PROCESSOR_GEOMETRY);
                r = si_shader_binary_upload(sscreen, si_shader_ctx->shader);
@@ -4410,7 +4414,7 @@ int si_shader_create(struct si_screen *sscreen, LLVMTargetMachineRef tm,
        radeon_llvm_finalize_module(&si_shader_ctx.radeon_bld);
 
        r = si_compile_llvm(sscreen, &shader->binary, &shader->config, tm,
-                           mod, debug, si_shader_ctx.type);
+                           mod, debug, si_shader_ctx.type, "TGSI shader");
        if (r) {
                fprintf(stderr, "LLVM failed to compile shader\n");
                goto out;
index e3d1f4f39a1789b193034b66c4fc4d8ea4460340..c42c51e0455bcdfcca9644979903964a83aff3fc 100644 (file)
@@ -328,7 +328,8 @@ int si_compile_llvm(struct si_screen *sscreen,
                    LLVMTargetMachineRef tm,
                    LLVMModuleRef mod,
                    struct pipe_debug_callback *debug,
-                   unsigned processor);
+                   unsigned processor,
+                   const char *name);
 void si_shader_destroy(struct si_shader *shader);
 unsigned si_shader_io_get_unique_index(unsigned semantic_name, unsigned index);
 int si_shader_binary_upload(struct si_screen *sscreen, struct si_shader *shader);