[Mesa-dev] [PATCH 1/2] nvc0: count cvt instructions and print it

Karol Herbst kherbst at redhat.com
Thu Dec 13 23:14:40 UTC 2018


Signed-off-by: Karol Herbst <kherbst at redhat.com>
---
 src/gallium/drivers/nouveau/codegen/nv50_ir.h   |  1 +
 .../drivers/nouveau/codegen/nv50_ir_driver.h    |  1 +
 .../drivers/nouveau/codegen/nv50_ir_inlines.h   | 17 +++++++++++++++++
 .../drivers/nouveau/codegen/nv50_ir_target.cpp  |  2 ++
 src/gallium/drivers/nouveau/nvc0/nvc0_program.c |  4 ++--
 5 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir.h b/src/gallium/drivers/nouveau/codegen/nv50_ir.h
index 8085bb2f542..b00a005bdef 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir.h
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir.h
@@ -867,6 +867,7 @@ public:
    inline bool isPseudo() const { return op < OP_MOV; }
    bool isDead() const;
    bool isNop() const;
+   inline bool isCvt() const;
    bool isCommutationLegal(const Instruction *) const; // must be adjacent !
    bool isActionEqual(const Instruction *) const;
    bool isResultEqual(const Instruction *) const;
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h b/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h
index 7c835ceab8d..5bee7bfd108 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h
@@ -93,6 +93,7 @@ struct nv50_ir_prog_info
       uint32_t *code;
       uint32_t codeSize;
       uint32_t instructions;
+      uint32_t cvt_instructions;
       uint8_t sourceRep;  /* PIPE_SHADER_IR_* */
       const void *source;
       void *relocData;
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_inlines.h b/src/gallium/drivers/nouveau/codegen/nv50_ir_inlines.h
index 4cb53ab42ed..06882058dc9 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_inlines.h
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_inlines.h
@@ -419,4 +419,21 @@ LValue *Function::getLValue(int id)
    return reinterpret_cast<LValue *>(allLValues.get(id));
 }
 
+bool Instruction::isCvt() const
+{
+   switch (op) {
+   case OP_ABS:
+   case OP_CEIL:
+   case OP_FLOOR:
+   case OP_NEG:
+   case OP_TRUNC:
+   case OP_SAT:
+      return true;
+   case OP_CVT:
+      return def(0).getFile() != FILE_PREDICATE && src(0).getFile() != FILE_PREDICATE;
+   default:
+      return false;
+   }
+}
+
 #endif // __NV50_IR_INLINES_H__
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_target.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_target.cpp
index 9193a01f189..85adb5b1852 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_target.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_target.cpp
@@ -393,6 +393,8 @@ Program::emitBinary(struct nv50_ir_prog_info *info)
          for (Instruction *i = fn->bbArray[b]->getEntry(); i; i = i->next) {
             emit->emitInstruction(i);
             info->bin.instructions++;
+            if (i->isCvt())
+               info->bin.cvt_instructions++;
             if ((typeSizeof(i->sType) == 8 || typeSizeof(i->dType) == 8) &&
                 (isFloatType(i->sType) || isFloatType(i->dType)))
                info->io.fp64 = true;
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_program.c b/src/gallium/drivers/nouveau/nvc0/nvc0_program.c
index 57d98753f45..139e4fec9c0 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_program.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_program.c
@@ -699,9 +699,9 @@ nvc0_program_translate(struct nvc0_program *prog, uint16_t chipset,
                                                 &prog->pipe.stream_output);
 
    pipe_debug_message(debug, SHADER_INFO,
-                      "type: %d, local: %d, shared: %d, gpr: %d, inst: %d, bytes: %d",
+                      "type: %d, local: %d, shared: %d, gpr: %d, inst: %d, cvts: %d, bytes: %d",
                       prog->type, info->bin.tlsSpace, info->bin.smemSize,
-                      prog->num_gprs, info->bin.instructions,
+                      prog->num_gprs, info->bin.instructions, info->bin.cvt_instructions,
                       info->bin.codeSize);
 
 #ifdef DEBUG
-- 
2.19.2



More information about the mesa-dev mailing list