[Mesa-dev] [PATCH 2/2] nouveau: Avoid pasting TGSI_OPCODE_ tokens together.
Ilia Mirkin
imirkin at alum.mit.edu
Mon Nov 24 17:10:20 PST 2014
I like the macros.... Nouveau, and probably other drivers, do lits of token
pasting on all sorts of gallium tokens. I think it makes the code
considerably easier to read.
On Nov 24, 2014 7:07 PM, "Eric Anholt" <eric at anholt.net> wrote:
> This made it harder to modify TGSI_OPCODE_ enums without breaking the
> driver.
> ---
> .../drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp | 278
> ++++++++++-----------
> 1 file changed, 139 insertions(+), 139 deletions(-)
>
> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
> b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
> index 39a70aa..4ed0d5d 100644
> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
> @@ -497,149 +497,149 @@ nv50_ir::CondCode Instruction::getSetCond() const
> }
> }
>
> -#define NV50_IR_OPCODE_CASE(a, b) case TGSI_OPCODE_##a: return
> nv50_ir::OP_##b
> +#define NV50_IR_OPCODE_CASE(a, b) case a: return nv50_ir::OP_##b
>
> static nv50_ir::operation translateOpcode(uint opcode)
> {
> switch (opcode) {
> - NV50_IR_OPCODE_CASE(ARL, SHL);
> - NV50_IR_OPCODE_CASE(MOV, MOV);
> -
> - NV50_IR_OPCODE_CASE(RCP, RCP);
> - NV50_IR_OPCODE_CASE(RSQ, RSQ);
> -
> - NV50_IR_OPCODE_CASE(MUL, MUL);
> - NV50_IR_OPCODE_CASE(ADD, ADD);
> -
> - NV50_IR_OPCODE_CASE(MIN, MIN);
> - NV50_IR_OPCODE_CASE(MAX, MAX);
> - NV50_IR_OPCODE_CASE(SLT, SET);
> - NV50_IR_OPCODE_CASE(SGE, SET);
> - NV50_IR_OPCODE_CASE(MAD, MAD);
> - NV50_IR_OPCODE_CASE(SUB, SUB);
> -
> - NV50_IR_OPCODE_CASE(FLR, FLOOR);
> - NV50_IR_OPCODE_CASE(ROUND, CVT);
> - NV50_IR_OPCODE_CASE(EX2, EX2);
> - NV50_IR_OPCODE_CASE(LG2, LG2);
> - NV50_IR_OPCODE_CASE(POW, POW);
> -
> - NV50_IR_OPCODE_CASE(ABS, ABS);
> -
> - NV50_IR_OPCODE_CASE(COS, COS);
> - NV50_IR_OPCODE_CASE(DDX, DFDX);
> - NV50_IR_OPCODE_CASE(DDX_FINE, DFDX);
> - NV50_IR_OPCODE_CASE(DDY, DFDY);
> - NV50_IR_OPCODE_CASE(DDY_FINE, DFDY);
> - NV50_IR_OPCODE_CASE(KILL, DISCARD);
> -
> - NV50_IR_OPCODE_CASE(SEQ, SET);
> - NV50_IR_OPCODE_CASE(SGT, SET);
> - NV50_IR_OPCODE_CASE(SIN, SIN);
> - NV50_IR_OPCODE_CASE(SLE, SET);
> - NV50_IR_OPCODE_CASE(SNE, SET);
> - NV50_IR_OPCODE_CASE(TEX, TEX);
> - NV50_IR_OPCODE_CASE(TXD, TXD);
> - NV50_IR_OPCODE_CASE(TXP, TEX);
> -
> - NV50_IR_OPCODE_CASE(CAL, CALL);
> - NV50_IR_OPCODE_CASE(RET, RET);
> - NV50_IR_OPCODE_CASE(CMP, SLCT);
> -
> - NV50_IR_OPCODE_CASE(TXB, TXB);
> -
> - NV50_IR_OPCODE_CASE(DIV, DIV);
> -
> - NV50_IR_OPCODE_CASE(TXL, TXL);
> -
> - NV50_IR_OPCODE_CASE(CEIL, CEIL);
> - NV50_IR_OPCODE_CASE(I2F, CVT);
> - NV50_IR_OPCODE_CASE(NOT, NOT);
> - NV50_IR_OPCODE_CASE(TRUNC, TRUNC);
> - NV50_IR_OPCODE_CASE(SHL, SHL);
> -
> - NV50_IR_OPCODE_CASE(AND, AND);
> - NV50_IR_OPCODE_CASE(OR, OR);
> - NV50_IR_OPCODE_CASE(MOD, MOD);
> - NV50_IR_OPCODE_CASE(XOR, XOR);
> - NV50_IR_OPCODE_CASE(SAD, SAD);
> - NV50_IR_OPCODE_CASE(TXF, TXF);
> - NV50_IR_OPCODE_CASE(TXQ, TXQ);
> - NV50_IR_OPCODE_CASE(TG4, TXG);
> - NV50_IR_OPCODE_CASE(LODQ, TXLQ);
> -
> - NV50_IR_OPCODE_CASE(EMIT, EMIT);
> - NV50_IR_OPCODE_CASE(ENDPRIM, RESTART);
> -
> - NV50_IR_OPCODE_CASE(KILL_IF, DISCARD);
> -
> - NV50_IR_OPCODE_CASE(F2I, CVT);
> - NV50_IR_OPCODE_CASE(FSEQ, SET);
> - NV50_IR_OPCODE_CASE(FSGE, SET);
> - NV50_IR_OPCODE_CASE(FSLT, SET);
> - NV50_IR_OPCODE_CASE(FSNE, SET);
> - NV50_IR_OPCODE_CASE(IDIV, DIV);
> - NV50_IR_OPCODE_CASE(IMAX, MAX);
> - NV50_IR_OPCODE_CASE(IMIN, MIN);
> - NV50_IR_OPCODE_CASE(IABS, ABS);
> - NV50_IR_OPCODE_CASE(INEG, NEG);
> - NV50_IR_OPCODE_CASE(ISGE, SET);
> - NV50_IR_OPCODE_CASE(ISHR, SHR);
> - NV50_IR_OPCODE_CASE(ISLT, SET);
> - NV50_IR_OPCODE_CASE(F2U, CVT);
> - NV50_IR_OPCODE_CASE(U2F, CVT);
> - NV50_IR_OPCODE_CASE(UADD, ADD);
> - NV50_IR_OPCODE_CASE(UDIV, DIV);
> - NV50_IR_OPCODE_CASE(UMAD, MAD);
> - NV50_IR_OPCODE_CASE(UMAX, MAX);
> - NV50_IR_OPCODE_CASE(UMIN, MIN);
> - NV50_IR_OPCODE_CASE(UMOD, MOD);
> - NV50_IR_OPCODE_CASE(UMUL, MUL);
> - NV50_IR_OPCODE_CASE(USEQ, SET);
> - NV50_IR_OPCODE_CASE(USGE, SET);
> - NV50_IR_OPCODE_CASE(USHR, SHR);
> - NV50_IR_OPCODE_CASE(USLT, SET);
> - NV50_IR_OPCODE_CASE(USNE, SET);
> -
> - NV50_IR_OPCODE_CASE(IMUL_HI, MUL);
> - NV50_IR_OPCODE_CASE(UMUL_HI, MUL);
> -
> - NV50_IR_OPCODE_CASE(SAMPLE, TEX);
> - NV50_IR_OPCODE_CASE(SAMPLE_B, TXB);
> - NV50_IR_OPCODE_CASE(SAMPLE_C, TEX);
> - NV50_IR_OPCODE_CASE(SAMPLE_C_LZ, TEX);
> - NV50_IR_OPCODE_CASE(SAMPLE_D, TXD);
> - NV50_IR_OPCODE_CASE(SAMPLE_L, TXL);
> - NV50_IR_OPCODE_CASE(SAMPLE_I, TXF);
> - NV50_IR_OPCODE_CASE(SAMPLE_I_MS, TXF);
> - NV50_IR_OPCODE_CASE(GATHER4, TXG);
> - NV50_IR_OPCODE_CASE(SVIEWINFO, TXQ);
> -
> - NV50_IR_OPCODE_CASE(ATOMUADD, ATOM);
> - NV50_IR_OPCODE_CASE(ATOMXCHG, ATOM);
> - NV50_IR_OPCODE_CASE(ATOMCAS, ATOM);
> - NV50_IR_OPCODE_CASE(ATOMAND, ATOM);
> - NV50_IR_OPCODE_CASE(ATOMOR, ATOM);
> - NV50_IR_OPCODE_CASE(ATOMXOR, ATOM);
> - NV50_IR_OPCODE_CASE(ATOMUMIN, ATOM);
> - NV50_IR_OPCODE_CASE(ATOMUMAX, ATOM);
> - NV50_IR_OPCODE_CASE(ATOMIMIN, ATOM);
> - NV50_IR_OPCODE_CASE(ATOMIMAX, ATOM);
> -
> - NV50_IR_OPCODE_CASE(TEX2, TEX);
> - NV50_IR_OPCODE_CASE(TXB2, TXB);
> - NV50_IR_OPCODE_CASE(TXL2, TXL);
> -
> - NV50_IR_OPCODE_CASE(IBFE, EXTBF);
> - NV50_IR_OPCODE_CASE(UBFE, EXTBF);
> - NV50_IR_OPCODE_CASE(BFI, INSBF);
> - NV50_IR_OPCODE_CASE(BREV, EXTBF);
> - NV50_IR_OPCODE_CASE(POPC, POPCNT);
> - NV50_IR_OPCODE_CASE(LSB, BFIND);
> - NV50_IR_OPCODE_CASE(IMSB, BFIND);
> - NV50_IR_OPCODE_CASE(UMSB, BFIND);
> -
> - NV50_IR_OPCODE_CASE(END, EXIT);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_ARL, SHL);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_MOV, MOV);
> +
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_RCP, RCP);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_RSQ, RSQ);
> +
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_MUL, MUL);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_ADD, ADD);
> +
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_MIN, MIN);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_MAX, MAX);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_SLT, SET);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_SGE, SET);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_MAD, MAD);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_SUB, SUB);
> +
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_FLR, FLOOR);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_ROUND, CVT);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_EX2, EX2);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_LG2, LG2);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_POW, POW);
> +
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_ABS, ABS);
> +
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_COS, COS);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_DDX, DFDX);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_DDX_FINE, DFDX);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_DDY, DFDY);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_DDY_FINE, DFDY);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_KILL, DISCARD);
> +
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_SEQ, SET);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_SGT, SET);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_SIN, SIN);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_SLE, SET);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_SNE, SET);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_TEX, TEX);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_TXD, TXD);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_TXP, TEX);
> +
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_CAL, CALL);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_RET, RET);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_CMP, SLCT);
> +
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_TXB, TXB);
> +
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_DIV, DIV);
> +
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_TXL, TXL);
> +
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_CEIL, CEIL);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_I2F, CVT);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_NOT, NOT);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_TRUNC, TRUNC);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_SHL, SHL);
> +
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_AND, AND);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_OR, OR);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_MOD, MOD);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_XOR, XOR);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_SAD, SAD);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_TXF, TXF);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_TXQ, TXQ);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_TG4, TXG);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_LODQ, TXLQ);
> +
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_EMIT, EMIT);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_ENDPRIM, RESTART);
> +
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_KILL_IF, DISCARD);
> +
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_F2I, CVT);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_FSEQ, SET);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_FSGE, SET);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_FSLT, SET);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_FSNE, SET);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_IDIV, DIV);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_IMAX, MAX);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_IMIN, MIN);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_IABS, ABS);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_INEG, NEG);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_ISGE, SET);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_ISHR, SHR);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_ISLT, SET);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_F2U, CVT);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_U2F, CVT);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_UADD, ADD);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_UDIV, DIV);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_UMAD, MAD);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_UMAX, MAX);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_UMIN, MIN);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_UMOD, MOD);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_UMUL, MUL);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_USEQ, SET);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_USGE, SET);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_USHR, SHR);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_USLT, SET);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_USNE, SET);
> +
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_IMUL_HI, MUL);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_UMUL_HI, MUL);
> +
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_SAMPLE, TEX);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_SAMPLE_B, TXB);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_SAMPLE_C, TEX);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_SAMPLE_C_LZ, TEX);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_SAMPLE_D, TXD);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_SAMPLE_L, TXL);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_SAMPLE_I, TXF);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_SAMPLE_I_MS, TXF);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_GATHER4, TXG);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_SVIEWINFO, TXQ);
> +
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_ATOMUADD, ATOM);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_ATOMXCHG, ATOM);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_ATOMCAS, ATOM);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_ATOMAND, ATOM);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_ATOMOR, ATOM);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_ATOMXOR, ATOM);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_ATOMUMIN, ATOM);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_ATOMUMAX, ATOM);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_ATOMIMIN, ATOM);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_ATOMIMAX, ATOM);
> +
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_TEX2, TEX);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_TXB2, TXB);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_TXL2, TXL);
> +
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_IBFE, EXTBF);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_UBFE, EXTBF);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_BFI, INSBF);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_BREV, EXTBF);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_POPC, POPCNT);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_LSB, BFIND);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_IMSB, BFIND);
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_UMSB, BFIND);
> +
> + NV50_IR_OPCODE_CASE(TGSI_OPCODE_END, EXIT);
>
> default:
> return nv50_ir::OP_NOP;
> --
> 2.1.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20141124/c75c5f9b/attachment-0001.html>
More information about the mesa-dev
mailing list