From 3ac373df6e47a65bdb5e5bda57dfc9f2a8010f53 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Thu, 21 Jul 2016 01:18:45 +0200 Subject: [PATCH] gm107/ir: add a legalize SSA pass for PFETCH PFETCH, actually ISBERD on GM107+ ISA only accepts a GPR for src0. Signed-off-by: Samuel Pitoiset Reviewed-by: Ilia Mirkin --- .../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 a5deaef14e0..84ef4e0fb7d 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 036abf055ed..81749bf57ed 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 104bc0361fe..6f4da8ca99c 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 92caeb22c12..6b8f767a3c0 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.30.2