[Mesa-dev] [PATCH v2 3/9] nvc0/ir: Emit OP_SHFL

Ilia Mirkin imirkin at alum.mit.edu
Mon Apr 10 01:35:06 UTC 2017


On Sun, Apr 9, 2017 at 8:58 PM, Boyan Ding <boyan.j.ding at gmail.com> wrote:
> v2: (Samuel Pitoiset)
> Add an assertion to check if the target is Kepler
> Make sure that asImm() is not NULL
> ---
>  .../drivers/nouveau/codegen/nv50_ir_emit_nvc0.cpp  | 59 ++++++++++++++++++++++
>  1 file changed, 59 insertions(+)
>
> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_nvc0.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_nvc0.cpp
> index d5a310f88c..ee2d2f06c1 100644
> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_nvc0.cpp
> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_nvc0.cpp
> @@ -150,6 +150,8 @@ private:
>
>     void emitPIXLD(const Instruction *);
>
> +   void emitSHFL(const Instruction *);
> +
>     void emitVOTE(const Instruction *);
>
>     inline void defId(const ValueDef&, const int pos);
> @@ -2529,6 +2531,60 @@ CodeEmitterNVC0::emitPIXLD(const Instruction *i)
>  }
>
>  void
> +CodeEmitterNVC0::emitSHFL(const Instruction *i)
> +{
> +   const ImmediateValue *imm;
> +
> +   assert(targ->getChipset() >= NVISA_GK104_CHIPSET);
> +
> +   code[0] = 0x00000005;
> +   code[1] = 0x88000000 | (i->subOp << 23);
> +
> +   emitPredicate(i);
> +
> +   defId(i->def(0), 14);
> +   srcId(i->src(0), 20);
> +
> +   switch (i->src(1).getFile()) {
> +   case FILE_GPR:
> +      srcId(i->src(1), 26);
> +      break;
> +   case FILE_IMMEDIATE:
> +      imm = i->src(1).get()->asImm();

The common thing to do is i->getSrc(1)->asImm(). Should be identical.
Same below.

> +      assert(imm);
> +      code[0] |= (imm->reg.data.u32 & 0x1f) << 26;
> +      code[0] |= 1 << 5;
> +      break;
> +   default:
> +      assert(!"invalid src1 file");
> +      break;
> +   }
> +
> +   switch (i->src(2).getFile()) {
> +   case FILE_GPR:
> +      srcId(i->src(2), 49);
> +      break;
> +   case FILE_IMMEDIATE:
> +      imm = i->src(2).get()->asImm();
> +      assert(imm);

&& imm->reg.data.u32 < 0x2000

> +      code[1] |= (imm->reg.data.u32 & 0x1fff) << 10;
> +      code[0] |= 1 << 6;
> +      break;
> +   default:
> +      assert(!"invalid src2 file");
> +      break;
> +   }
> +
> +   if (!i->defExists(1)) {
> +      code[0] |= 3 << 8;
> +      code[1] |= 1 << 26;
> +   } else {
> +      assert(i->def(1).getFile() == FILE_PREDICATE);
> +      setPDSTL(i->def(1));

setPDSTL should be able to handle the no-exists case too, no? You
might change the API to be

setPDSTL(const Instruction *, int d)

to avoid confusion.

> +   }
> +}
> +
> +void
>  CodeEmitterNVC0::emitVOTE(const Instruction *i)
>  {
>     assert(i->src(0).getFile() == FILE_PREDICATE);
> @@ -2837,6 +2893,9 @@ CodeEmitterNVC0::emitInstruction(Instruction *insn)
>     case OP_PIXLD:
>        emitPIXLD(insn);
>        break;
> +   case OP_SHFL:
> +      emitSHFL(insn);
> +      break;
>     case OP_VOTE:
>        emitVOTE(insn);
>        break;
> --
> 2.12.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list