Module: Mesa
Branch: master
Commit: 068a72fbcb50176f31e9ecd588bd8225922cef2a
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=068a72fbcb50176f31e9ecd588bd8225922cef2a

Author: Tobias Klausmann <tobias.johannes.klausm...@mni.thm.de>
Date:   Sun Nov 12 02:51:55 2017 +0100

nouveau/compiler: Allow to omit line numbers when printing instructions

This comes in handy when checking "NV50_PROG_DEBUG=1" outputs with diff!

V2:
 - Use environmental variable (Karol Herbst)
V3:
 - Use the already populated nv50_ir_prog_info to forward information to the
   print pass (Pierre Moreau)
V4:
 - get rid of default value in PrintPass constructor

Signed-off-by: Tobias Klausmann <tobias.johannes.klausm...@mni.thm.de>
Reviewed-by: Pierre Moreau <pierre.mor...@free.fr>
Reviewed-by: Ilia Mirkin <imir...@alum.mit.edu>

---

 src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h  |  1 +
 src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp | 13 +++++++++----
 src/gallium/drivers/nouveau/nouveau_compiler.c        |  1 +
 src/gallium/drivers/nouveau/nv50/nv50_program.c       |  1 +
 src/gallium/drivers/nouveau/nvc0/nvc0_program.c       |  1 +
 5 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h 
b/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h
index ffd53c9cd3..520d1d6743 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h
@@ -82,6 +82,7 @@ struct nv50_ir_prog_info
 
    uint8_t optLevel; /* optimization level (0 to 3) */
    uint8_t dbgFlags;
+   bool omitLineNum; /* only used for printing the prog when dbgFlags is set */
 
    struct {
       int16_t maxGPR;     /* may be -1 if none used */
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp 
b/src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp
index f5253b3745..ab39f9fdf6 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp
@@ -689,7 +689,7 @@ void Instruction::print() const
 class PrintPass : public Pass
 {
 public:
-   PrintPass() : serial(0) { }
+   PrintPass(bool omitLineNum) : serial(0), omit_serial(omitLineNum) { }
 
    virtual bool visit(Function *);
    virtual bool visit(BasicBlock *);
@@ -697,6 +697,7 @@ public:
 
 private:
    int serial;
+   bool omit_serial;
 };
 
 bool
@@ -760,7 +761,11 @@ PrintPass::visit(BasicBlock *bb)
 bool
 PrintPass::visit(Instruction *insn)
 {
-   INFO("%3i: ", serial++);
+   if (omit_serial)
+      INFO("     ");
+   else
+      INFO("%3i: ", serial);
+   serial++;
    insn->print();
    return true;
 }
@@ -768,14 +773,14 @@ PrintPass::visit(Instruction *insn)
 void
 Function::print()
 {
-   PrintPass pass;
+   PrintPass pass(prog->driver->omitLineNum);
    pass.run(this, true, false);
 }
 
 void
 Program::print()
 {
-   PrintPass pass;
+   PrintPass pass(driver->omitLineNum);
    init_colours();
    pass.run(this, true, false);
 }
diff --git a/src/gallium/drivers/nouveau/nouveau_compiler.c 
b/src/gallium/drivers/nouveau/nouveau_compiler.c
index 3151a6f420..f2c175661b 100644
--- a/src/gallium/drivers/nouveau/nouveau_compiler.c
+++ b/src/gallium/drivers/nouveau/nouveau_compiler.c
@@ -122,6 +122,7 @@ nouveau_codegen(int chipset, int type, struct tgsi_token 
tokens[],
 
    info.optLevel = debug_get_num_option("NV50_PROG_OPTIMIZE", 3);
    info.dbgFlags = debug_get_num_option("NV50_PROG_DEBUG", 0);
+   info.omitLineNum = debug_get_num_option("NV50_PROG_DEBUG_OMIT_LINENUM", 0);
 
    ret = nv50_ir_generate_code(&info);
    if (ret) {
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_program.c 
b/src/gallium/drivers/nouveau/nv50/nv50_program.c
index 6e943a3d94..b117790d6e 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_program.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_program.c
@@ -367,6 +367,7 @@ nv50_program_translate(struct nv50_program *prog, uint16_t 
chipset,
 #ifdef DEBUG
    info->optLevel = debug_get_num_option("NV50_PROG_OPTIMIZE", 3);
    info->dbgFlags = debug_get_num_option("NV50_PROG_DEBUG", 0);
+   info->omitLineNum = debug_get_num_option("NV50_PROG_DEBUG_OMIT_LINENUM", 0);
 #else
    info->optLevel = 3;
 #endif
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_program.c 
b/src/gallium/drivers/nouveau/nvc0/nvc0_program.c
index c95a96c717..46a15d76df 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_program.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_program.c
@@ -575,6 +575,7 @@ nvc0_program_translate(struct nvc0_program *prog, uint16_t 
chipset,
    info->target = debug_get_num_option("NV50_PROG_CHIPSET", chipset);
    info->optLevel = debug_get_num_option("NV50_PROG_OPTIMIZE", 3);
    info->dbgFlags = debug_get_num_option("NV50_PROG_DEBUG", 0);
+   info->omitLineNum = debug_get_num_option("NV50_PROG_DEBUG_OMIT_LINENUM", 0);
 #else
    info->optLevel = 3;
 #endif

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to