radeonsi: Only dump shaders with environment variable RADEON_DUMP_SHADERS=1.
authorMichel Dänzer <michel.daenzer@amd.com>
Thu, 7 Jun 2012 17:30:47 +0000 (19:30 +0200)
committerMichel Dänzer <michel@daenzer.net>
Tue, 12 Jun 2012 16:33:54 +0000 (18:33 +0200)
src/gallium/drivers/radeon/SICodeEmitter.cpp
src/gallium/drivers/radeonsi/radeonsi_shader.c

index 1d247061e41ae2762efc6acf733375a36f0caa84..585d4180e4d5d7e079ffbf2fee1a18ce68c560ab 100644 (file)
@@ -156,8 +156,12 @@ void SICodeEmitter::emitState(MachineFunction & MF)
 
 bool SICodeEmitter::runOnMachineFunction(MachineFunction &MF)
 {
-  MF.dump();
   TM = &MF.getTarget();
+  const AMDILSubtarget &STM = TM->getSubtarget<AMDILSubtarget>();
+
+  if (STM.dumpCode()) {
+    MF.dump();
+  }
 
   emitState(MF);
 
index e625a74338af695605f67831fc94af70c87aef9b..0a4f04bdb12d660e9f2471f73b625df1082690f5 100644 (file)
@@ -543,6 +543,9 @@ int si_pipe_shader_create(
        unsigned char * inst_bytes;
        unsigned inst_byte_count;
        unsigned i;
+       bool dump;
+
+       dump = debug_get_bool_option("RADEON_DUMP_SHADERS", FALSE);
 
        radeon_llvm_context_init(&si_shader_ctx.radeon_bld);
        bld_base = &si_shader_ctx.radeon_bld.soa.bld_base;
@@ -568,14 +571,18 @@ int si_pipe_shader_create(
        radeon_llvm_finalize_module(&si_shader_ctx.radeon_bld);
 
        mod = bld_base->base.gallivm->module;
-       tgsi_dump(shader->tokens, 0);
-       LLVMDumpModule(mod);
-       radeon_llvm_compile(mod, &inst_bytes, &inst_byte_count, "SI", 1 /* dump */);
-       fprintf(stderr, "SI CODE:\n");
-       for (i = 0; i < inst_byte_count; i+=4 ) {
-               fprintf(stderr, "%02x%02x%02x%02x\n", inst_bytes[i + 3],
-                       inst_bytes[i + 2], inst_bytes[i + 1],
-                       inst_bytes[i]);
+       if (dump) {
+               tgsi_dump(shader->tokens, 0);
+               LLVMDumpModule(mod);
+       }
+       radeon_llvm_compile(mod, &inst_bytes, &inst_byte_count, "SI", dump);
+       if (dump) {
+               fprintf(stderr, "SI CODE:\n");
+               for (i = 0; i < inst_byte_count; i+=4 ) {
+                       fprintf(stderr, "%02x%02x%02x%02x\n", inst_bytes[i + 3],
+                               inst_bytes[i + 2], inst_bytes[i + 1],
+                               inst_bytes[i]);
+               }
        }
 
        shader->num_sgprs = util_le32_to_cpu(*(uint32_t*)inst_bytes);