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