[Mesa-dev] [PATCH] gm107/ir: add emission for BAR
Samuel Pitoiset
samuel.pitoiset at gmail.com
Mon Mar 7 17:34:47 UTC 2016
On 03/06/2016 11:37 PM, Ilia Mirkin wrote:
> On Tue, Mar 1, 2016 at 12:44 PM, Samuel Pitoiset
> <samuel.pitoiset at gmail.com> wrote:
>> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
>> ---
>> .../drivers/nouveau/codegen/nv50_ir_emit_gm107.cpp | 52 ++++++++++++++++++++++
>> 1 file changed, 52 insertions(+)
>>
>> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_gm107.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_gm107.cpp
>> index a383c53..0e621e0 100644
>> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_gm107.cpp
>> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_gm107.cpp
>> @@ -194,6 +194,7 @@ private:
>> void emitKIL();
>> void emitOUT();
>>
>> + void emitBAR();
>> void emitMEMBAR();
>>
>> void emitVOTE();
>> @@ -2649,6 +2650,54 @@ CodeEmitterGM107::emitOUT()
>> }
>>
>> void
>> +CodeEmitterGM107::emitBAR()
>> +{
>> + uint8_t subop;
>> +
>> + emitInsn (0xf0a80000);
>> +
>> + switch (insn->subOp) {
>> + case NV50_IR_SUBOP_BAR_RED_POPC: subop = 0x02; break;
>> + case NV50_IR_SUBOP_BAR_RED_AND: subop = 0x0a; break;
>> + case NV50_IR_SUBOP_BAR_RED_OR: subop = 0x12; break;
>> + case NV50_IR_SUBOP_BAR_ARRIVE: subop = 0x81; break;
>> + default:
>> + subop = 0x80;
>> + assert(insn->subOp == NV50_IR_SUBOP_BAR_SYNC);
>> + break;
>> + }
>> +
>> + emitField(0x20, 8, subop);
>> +
>> + // barrier id
>> + if (insn->src(0).getFile() == FILE_GPR) {
>> + emitGPR(0x08, insn->src(0));
>> + } else {
>> + ImmediateValue *imm = insn->getSrc(0)->asImm();
>> + assert(imm);
>> + emitField(0x08, 8, imm->reg.data.u32);
>> + emitField(0x2b, 1, 1);
>> + }
>> +
>> + // thread count
>> + if (insn->src(1).getFile() == FILE_GPR) {
>> + emitGPR(0x14, insn->src(1));
>> + } else {
>> + ImmediateValue *imm = insn->getSrc(0)->asImm();
>> + assert(imm);
>> + emitField(0x14, 12, imm->reg.data.u32);
>> + emitField(0x2c, 1, 1);
>> + }
>> +
>> + if (insn->srcExists(2) && (insn->predSrc != 2)) {
>> + emitPRED (0x27, insn->src(2));
>> + emitField(0x2a, 1, insn->src(2).mod == Modifier(NV50_IR_MOD_NOT));
>> + } else {
>> + emitField(0x27, 3, 7);
>> + }
>
> Can a bar be predicated? If so, you probably want emitPredicate(i)
> somewhere in there.
The predicate is added by emitInsn() when the second parameter is true
which is the default behaviour, and emitField() already takes care of that.
>
> Also please assert that the barrier id/thread count immediates fit
> within the specified field widths (or does emitField take care of
> that?)
>
> With those resolved, this is
>
> Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>
>
>> +}
>> +
>> +void
>> CodeEmitterGM107::emitMEMBAR()
>> {
>> emitInsn (0xef980000);
>> @@ -2978,6 +3027,9 @@ CodeEmitterGM107::emitInstruction(Instruction *i)
>> case OP_RESTART:
>> emitOUT();
>> break;
>> + case OP_BAR:
>> + emitBAR();
>> + break;
>> case OP_MEMBAR:
>> emitMEMBAR();
>> break;
>> --
>> 2.7.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