[Mesa-dev] [PATCH v1 2/3] gm107/ir: add a legalize SSA pass for PFETCH

Samuel Pitoiset samuel.pitoiset at gmail.com
Wed Jul 27 20:51:14 UTC 2016


PFETCH, actually ISBERD on GM107+ ISA only accepts a GPR for src0.

v1: make NVC0LegalizeSSA::bld as protected attribute

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
 .../nouveau/codegen/nv50_ir_lowering_gm107.cpp     | 33 ++++++++++++++++++++++
 .../nouveau/codegen/nv50_ir_lowering_gm107.h       |  8 ++++++
 .../nouveau/codegen/nv50_ir_lowering_nvc0.h        |  2 +-
 .../nouveau/codegen/nv50_ir_target_gm107.cpp       |  2 +-
 4 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_gm107.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_gm107.cpp
index a5deaef..84ef4e0 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_gm107.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_gm107.cpp
@@ -41,6 +41,39 @@ namespace nv50_ir {
    ((QOP_##q << 6) | (QOP_##r << 4) |           \
     (QOP_##s << 2) | (QOP_##t << 0))
 
+void
+GM107LegalizeSSA::handlePFETCH(Instruction *i)
+{
+   Value *src0;
+
+   if (i->src(0).getFile() == FILE_GPR && !i->srcExists(1))
+      return;
+
+   bld.setPosition(i, false);
+   src0 = bld.getSSA();
+
+   if (i->srcExists(1))
+      bld.mkOp2(OP_ADD , TYPE_U32, src0, i->getSrc(0), i->getSrc(1));
+   else
+      bld.mkOp1(OP_MOV , TYPE_U32, src0, i->getSrc(0));
+
+   i->setSrc(0, src0);
+   i->setSrc(1, NULL);
+}
+
+bool
+GM107LegalizeSSA::visit(Instruction *i)
+{
+   switch (i->op) {
+   case OP_PFETCH:
+      handlePFETCH(i);
+      break;
+   default:
+      break;
+   }
+   return true;
+}
+
 bool
 GM107LoweringPass::handleManualTXD(TexInstruction *i)
 {
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_gm107.h b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_gm107.h
index 036abf0..81749bf 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_gm107.h
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_gm107.h
@@ -15,4 +15,12 @@ private:
    bool handlePOPCNT(Instruction *);
 };
 
+class GM107LegalizeSSA : public NVC0LegalizeSSA
+{
+private:
+   virtual bool visit(Instruction *);
+
+   void handlePFETCH(Instruction *);
+};
+
 } // namespace nv50_ir
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.h b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.h
index 104bc03..6f4da8c 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.h
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.h
@@ -36,7 +36,7 @@ private:
    void handleRCPRSQ(Instruction *); // double precision float recip/rsqrt
    void handleFTZ(Instruction *);
 
-private:
+protected:
    BuildUtil bld;
 };
 
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_target_gm107.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_target_gm107.cpp
index 92caeb2..6b8f767 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_target_gm107.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_target_gm107.cpp
@@ -80,7 +80,7 @@ TargetGM107::runLegalizePass(Program *prog, CGStage stage) const
       return pass.run(prog, false, true);
    } else
    if (stage == CG_STAGE_SSA) {
-      NVC0LegalizeSSA pass;
+      GM107LegalizeSSA pass;
       return pass.run(prog, false, true);
    }
    return false;
-- 
2.9.0



More information about the mesa-dev mailing list