[Mesa-dev] [PATCH 1/2] freedreno: Avoid pasting TGSI_OPCODE_ tokens together.
Eric Anholt
eric at anholt.net
Mon Nov 24 16:07:48 PST 2014
This made it harder to modify TGSI_OPCODE_ enums without breaking the driver.
---
src/gallium/drivers/freedreno/ir3/ir3_compiler.c | 172 ++++++++++-----------
.../drivers/freedreno/ir3/ir3_compiler_old.c | 74 ++++-----
2 files changed, 123 insertions(+), 123 deletions(-)
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c
index aaf362d..d01dec9 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c
@@ -2508,92 +2508,92 @@ instr_cat4(const struct instr_translater *t,
static const struct instr_translater translaters[TGSI_OPCODE_LAST] = {
#define INSTR(n, f, ...) \
- [TGSI_OPCODE_ ## n] = { .fxn = (f), .tgsi_opc = TGSI_OPCODE_ ## n, ##__VA_ARGS__ }
-
- INSTR(MOV, instr_cat1),
- INSTR(RCP, instr_cat4, .opc = OPC_RCP),
- INSTR(RSQ, instr_cat4, .opc = OPC_RSQ),
- INSTR(SQRT, instr_cat4, .opc = OPC_SQRT),
- INSTR(MUL, instr_cat2, .opc = OPC_MUL_F),
- INSTR(ADD, instr_cat2, .opc = OPC_ADD_F),
- INSTR(SUB, instr_cat2, .opc = OPC_ADD_F),
- INSTR(MIN, instr_cat2, .opc = OPC_MIN_F),
- INSTR(MAX, instr_cat2, .opc = OPC_MAX_F),
- INSTR(UADD, instr_cat2, .opc = OPC_ADD_U),
- INSTR(IMIN, instr_cat2, .opc = OPC_MIN_S),
- INSTR(UMIN, instr_cat2, .opc = OPC_MIN_U),
- INSTR(IMAX, instr_cat2, .opc = OPC_MAX_S),
- INSTR(UMAX, instr_cat2, .opc = OPC_MAX_U),
- INSTR(AND, instr_cat2, .opc = OPC_AND_B),
- INSTR(OR, instr_cat2, .opc = OPC_OR_B),
- INSTR(NOT, instr_cat2, .opc = OPC_NOT_B),
- INSTR(XOR, instr_cat2, .opc = OPC_XOR_B),
- INSTR(UMUL, trans_umul),
- INSTR(UMAD, trans_umul),
- INSTR(UDIV, trans_idiv),
- INSTR(IDIV, trans_idiv),
- INSTR(MOD, trans_idiv),
- INSTR(UMOD, trans_idiv),
- INSTR(SHL, instr_cat2, .opc = OPC_SHL_B),
- INSTR(USHR, instr_cat2, .opc = OPC_SHR_B),
- INSTR(ISHR, instr_cat2, .opc = OPC_ASHR_B),
- INSTR(IABS, instr_cat2, .opc = OPC_ABSNEG_S),
- INSTR(INEG, instr_cat2, .opc = OPC_ABSNEG_S),
- INSTR(AND, instr_cat2, .opc = OPC_AND_B),
- INSTR(MAD, instr_cat3, .opc = OPC_MAD_F32, .hopc = OPC_MAD_F16),
- INSTR(TRUNC, instr_cat2, .opc = OPC_TRUNC_F),
- INSTR(CLAMP, trans_clamp),
- INSTR(FLR, instr_cat2, .opc = OPC_FLOOR_F),
- INSTR(ROUND, instr_cat2, .opc = OPC_RNDNE_F),
- INSTR(SSG, instr_cat2, .opc = OPC_SIGN_F),
- INSTR(CEIL, instr_cat2, .opc = OPC_CEIL_F),
- INSTR(ARL, trans_arl),
- INSTR(UARL, trans_arl),
- INSTR(EX2, instr_cat4, .opc = OPC_EXP2),
- INSTR(LG2, instr_cat4, .opc = OPC_LOG2),
- INSTR(ABS, instr_cat2, .opc = OPC_ABSNEG_F),
- INSTR(COS, instr_cat4, .opc = OPC_COS),
- INSTR(SIN, instr_cat4, .opc = OPC_SIN),
- INSTR(TEX, trans_samp, .opc = OPC_SAM, .arg = TGSI_OPCODE_TEX),
- INSTR(TXP, trans_samp, .opc = OPC_SAM, .arg = TGSI_OPCODE_TXP),
- INSTR(TXB, trans_samp, .opc = OPC_SAMB, .arg = TGSI_OPCODE_TXB),
- INSTR(TXB2, trans_samp, .opc = OPC_SAMB, .arg = TGSI_OPCODE_TXB2),
- INSTR(TXL, trans_samp, .opc = OPC_SAML, .arg = TGSI_OPCODE_TXL),
- INSTR(TXD, trans_samp, .opc = OPC_SAMGQ, .arg = TGSI_OPCODE_TXD),
- INSTR(TXF, trans_samp, .opc = OPC_ISAML, .arg = TGSI_OPCODE_TXF),
- INSTR(TXQ, trans_txq),
- INSTR(DDX, trans_deriv, .opc = OPC_DSX),
- INSTR(DDY, trans_deriv, .opc = OPC_DSY),
- INSTR(SGT, trans_cmp),
- INSTR(SLT, trans_cmp),
- INSTR(FSLT, trans_cmp),
- INSTR(SGE, trans_cmp),
- INSTR(FSGE, trans_cmp),
- INSTR(SLE, trans_cmp),
- INSTR(SNE, trans_cmp),
- INSTR(FSNE, trans_cmp),
- INSTR(SEQ, trans_cmp),
- INSTR(FSEQ, trans_cmp),
- INSTR(CMP, trans_cmp),
- INSTR(USNE, trans_icmp, .opc = OPC_CMPS_U),
- INSTR(USEQ, trans_icmp, .opc = OPC_CMPS_U),
- INSTR(ISGE, trans_icmp, .opc = OPC_CMPS_S),
- INSTR(USGE, trans_icmp, .opc = OPC_CMPS_U),
- INSTR(ISLT, trans_icmp, .opc = OPC_CMPS_S),
- INSTR(USLT, trans_icmp, .opc = OPC_CMPS_U),
- INSTR(UCMP, trans_ucmp),
- INSTR(ISSG, trans_issg),
- INSTR(IF, trans_if, .opc = OPC_CMPS_F),
- INSTR(UIF, trans_if, .opc = OPC_CMPS_U),
- INSTR(ELSE, trans_else),
- INSTR(ENDIF, trans_endif),
- INSTR(END, instr_cat0, .opc = OPC_END),
- INSTR(KILL, trans_kill, .opc = OPC_KILL),
- INSTR(KILL_IF, trans_killif, .opc = OPC_KILL),
- INSTR(I2F, trans_cov),
- INSTR(U2F, trans_cov),
- INSTR(F2I, trans_cov),
- INSTR(F2U, trans_cov),
+ [n] = { .fxn = (f), .tgsi_opc = n, ##__VA_ARGS__ }
+
+ INSTR(TGSI_OPCODE_MOV, instr_cat1),
+ INSTR(TGSI_OPCODE_RCP, instr_cat4, .opc = OPC_RCP),
+ INSTR(TGSI_OPCODE_RSQ, instr_cat4, .opc = OPC_RSQ),
+ INSTR(TGSI_OPCODE_SQRT, instr_cat4, .opc = OPC_SQRT),
+ INSTR(TGSI_OPCODE_MUL, instr_cat2, .opc = OPC_MUL_F),
+ INSTR(TGSI_OPCODE_ADD, instr_cat2, .opc = OPC_ADD_F),
+ INSTR(TGSI_OPCODE_SUB, instr_cat2, .opc = OPC_ADD_F),
+ INSTR(TGSI_OPCODE_MIN, instr_cat2, .opc = OPC_MIN_F),
+ INSTR(TGSI_OPCODE_MAX, instr_cat2, .opc = OPC_MAX_F),
+ INSTR(TGSI_OPCODE_UADD, instr_cat2, .opc = OPC_ADD_U),
+ INSTR(TGSI_OPCODE_IMIN, instr_cat2, .opc = OPC_MIN_S),
+ INSTR(TGSI_OPCODE_UMIN, instr_cat2, .opc = OPC_MIN_U),
+ INSTR(TGSI_OPCODE_IMAX, instr_cat2, .opc = OPC_MAX_S),
+ INSTR(TGSI_OPCODE_UMAX, instr_cat2, .opc = OPC_MAX_U),
+ INSTR(TGSI_OPCODE_AND, instr_cat2, .opc = OPC_AND_B),
+ INSTR(TGSI_OPCODE_OR, instr_cat2, .opc = OPC_OR_B),
+ INSTR(TGSI_OPCODE_NOT, instr_cat2, .opc = OPC_NOT_B),
+ INSTR(TGSI_OPCODE_XOR, instr_cat2, .opc = OPC_XOR_B),
+ INSTR(TGSI_OPCODE_UMUL, trans_umul),
+ INSTR(TGSI_OPCODE_UMAD, trans_umul),
+ INSTR(TGSI_OPCODE_UDIV, trans_idiv),
+ INSTR(TGSI_OPCODE_IDIV, trans_idiv),
+ INSTR(TGSI_OPCODE_MOD, trans_idiv),
+ INSTR(TGSI_OPCODE_UMOD, trans_idiv),
+ INSTR(TGSI_OPCODE_SHL, instr_cat2, .opc = OPC_SHL_B),
+ INSTR(TGSI_OPCODE_USHR, instr_cat2, .opc = OPC_SHR_B),
+ INSTR(TGSI_OPCODE_ISHR, instr_cat2, .opc = OPC_ASHR_B),
+ INSTR(TGSI_OPCODE_IABS, instr_cat2, .opc = OPC_ABSNEG_S),
+ INSTR(TGSI_OPCODE_INEG, instr_cat2, .opc = OPC_ABSNEG_S),
+ INSTR(TGSI_OPCODE_AND, instr_cat2, .opc = OPC_AND_B),
+ INSTR(TGSI_OPCODE_MAD, instr_cat3, .opc = OPC_MAD_F32, .hopc = OPC_MAD_F16),
+ INSTR(TGSI_OPCODE_TRUNC, instr_cat2, .opc = OPC_TRUNC_F),
+ INSTR(TGSI_OPCODE_CLAMP, trans_clamp),
+ INSTR(TGSI_OPCODE_FLR, instr_cat2, .opc = OPC_FLOOR_F),
+ INSTR(TGSI_OPCODE_ROUND, instr_cat2, .opc = OPC_RNDNE_F),
+ INSTR(TGSI_OPCODE_SSG, instr_cat2, .opc = OPC_SIGN_F),
+ INSTR(TGSI_OPCODE_CEIL, instr_cat2, .opc = OPC_CEIL_F),
+ INSTR(TGSI_OPCODE_ARL, trans_arl),
+ INSTR(TGSI_OPCODE_UARL, trans_arl),
+ INSTR(TGSI_OPCODE_EX2, instr_cat4, .opc = OPC_EXP2),
+ INSTR(TGSI_OPCODE_LG2, instr_cat4, .opc = OPC_LOG2),
+ INSTR(TGSI_OPCODE_ABS, instr_cat2, .opc = OPC_ABSNEG_F),
+ INSTR(TGSI_OPCODE_COS, instr_cat4, .opc = OPC_COS),
+ INSTR(TGSI_OPCODE_SIN, instr_cat4, .opc = OPC_SIN),
+ INSTR(TGSI_OPCODE_TEX, trans_samp, .opc = OPC_SAM, .arg = TGSI_OPCODE_TEX),
+ INSTR(TGSI_OPCODE_TXP, trans_samp, .opc = OPC_SAM, .arg = TGSI_OPCODE_TXP),
+ INSTR(TGSI_OPCODE_TXB, trans_samp, .opc = OPC_SAMB, .arg = TGSI_OPCODE_TXB),
+ INSTR(TGSI_OPCODE_TXB2, trans_samp, .opc = OPC_SAMB, .arg = TGSI_OPCODE_TXB2),
+ INSTR(TGSI_OPCODE_TXL, trans_samp, .opc = OPC_SAML, .arg = TGSI_OPCODE_TXL),
+ INSTR(TGSI_OPCODE_TXD, trans_samp, .opc = OPC_SAMGQ, .arg = TGSI_OPCODE_TXD),
+ INSTR(TGSI_OPCODE_TXF, trans_samp, .opc = OPC_ISAML, .arg = TGSI_OPCODE_TXF),
+ INSTR(TGSI_OPCODE_TXQ, trans_txq),
+ INSTR(TGSI_OPCODE_DDX, trans_deriv, .opc = OPC_DSX),
+ INSTR(TGSI_OPCODE_DDY, trans_deriv, .opc = OPC_DSY),
+ INSTR(TGSI_OPCODE_SGT, trans_cmp),
+ INSTR(TGSI_OPCODE_SLT, trans_cmp),
+ INSTR(TGSI_OPCODE_FSLT, trans_cmp),
+ INSTR(TGSI_OPCODE_SGE, trans_cmp),
+ INSTR(TGSI_OPCODE_FSGE, trans_cmp),
+ INSTR(TGSI_OPCODE_SLE, trans_cmp),
+ INSTR(TGSI_OPCODE_SNE, trans_cmp),
+ INSTR(TGSI_OPCODE_FSNE, trans_cmp),
+ INSTR(TGSI_OPCODE_SEQ, trans_cmp),
+ INSTR(TGSI_OPCODE_FSEQ, trans_cmp),
+ INSTR(TGSI_OPCODE_CMP, trans_cmp),
+ INSTR(TGSI_OPCODE_USNE, trans_icmp, .opc = OPC_CMPS_U),
+ INSTR(TGSI_OPCODE_USEQ, trans_icmp, .opc = OPC_CMPS_U),
+ INSTR(TGSI_OPCODE_ISGE, trans_icmp, .opc = OPC_CMPS_S),
+ INSTR(TGSI_OPCODE_USGE, trans_icmp, .opc = OPC_CMPS_U),
+ INSTR(TGSI_OPCODE_ISLT, trans_icmp, .opc = OPC_CMPS_S),
+ INSTR(TGSI_OPCODE_USLT, trans_icmp, .opc = OPC_CMPS_U),
+ INSTR(TGSI_OPCODE_UCMP, trans_ucmp),
+ INSTR(TGSI_OPCODE_ISSG, trans_issg),
+ INSTR(TGSI_OPCODE_IF, trans_if, .opc = OPC_CMPS_F),
+ INSTR(TGSI_OPCODE_UIF, trans_if, .opc = OPC_CMPS_U),
+ INSTR(TGSI_OPCODE_ELSE, trans_else),
+ INSTR(TGSI_OPCODE_ENDIF, trans_endif),
+ INSTR(TGSI_OPCODE_END, instr_cat0, .opc = OPC_END),
+ INSTR(TGSI_OPCODE_KILL, trans_kill, .opc = OPC_KILL),
+ INSTR(TGSI_OPCODE_KILL_IF, trans_killif, .opc = OPC_KILL),
+ INSTR(TGSI_OPCODE_I2F, trans_cov),
+ INSTR(TGSI_OPCODE_U2F, trans_cov),
+ INSTR(TGSI_OPCODE_F2I, trans_cov),
+ INSTR(TGSI_OPCODE_F2U, trans_cov),
};
static ir3_semantic
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler_old.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler_old.c
index 3353156..9238b3c 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_compiler_old.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler_old.c
@@ -1265,43 +1265,43 @@ instr_cat4(const struct instr_translater *t,
static const struct instr_translater translaters[TGSI_OPCODE_LAST] = {
#define INSTR(n, f, ...) \
- [TGSI_OPCODE_ ## n] = { .fxn = (f), .tgsi_opc = TGSI_OPCODE_ ## n, ##__VA_ARGS__ }
-
- INSTR(MOV, instr_cat1),
- INSTR(RCP, instr_cat4, .opc = OPC_RCP),
- INSTR(RSQ, instr_cat4, .opc = OPC_RSQ),
- INSTR(SQRT, instr_cat4, .opc = OPC_SQRT),
- INSTR(MUL, instr_cat2, .opc = OPC_MUL_F),
- INSTR(ADD, instr_cat2, .opc = OPC_ADD_F),
- INSTR(SUB, instr_cat2, .opc = OPC_ADD_F),
- INSTR(MIN, instr_cat2, .opc = OPC_MIN_F),
- INSTR(MAX, instr_cat2, .opc = OPC_MAX_F),
- INSTR(MAD, instr_cat3, .opc = OPC_MAD_F32, .hopc = OPC_MAD_F16),
- INSTR(TRUNC, instr_cat2, .opc = OPC_TRUNC_F),
- INSTR(CLAMP, trans_clamp),
- INSTR(FLR, instr_cat2, .opc = OPC_FLOOR_F),
- INSTR(ROUND, instr_cat2, .opc = OPC_RNDNE_F),
- INSTR(SSG, instr_cat2, .opc = OPC_SIGN_F),
- INSTR(ARL, trans_arl),
- INSTR(EX2, instr_cat4, .opc = OPC_EXP2),
- INSTR(LG2, instr_cat4, .opc = OPC_LOG2),
- INSTR(ABS, instr_cat2, .opc = OPC_ABSNEG_F),
- INSTR(COS, instr_cat4, .opc = OPC_COS),
- INSTR(SIN, instr_cat4, .opc = OPC_SIN),
- INSTR(TEX, trans_samp, .opc = OPC_SAM, .arg = TGSI_OPCODE_TEX),
- INSTR(TXP, trans_samp, .opc = OPC_SAM, .arg = TGSI_OPCODE_TXP),
- INSTR(SGT, trans_cmp),
- INSTR(SLT, trans_cmp),
- INSTR(SGE, trans_cmp),
- INSTR(SLE, trans_cmp),
- INSTR(SNE, trans_cmp),
- INSTR(SEQ, trans_cmp),
- INSTR(CMP, trans_cmp),
- INSTR(IF, trans_if),
- INSTR(ELSE, trans_else),
- INSTR(ENDIF, trans_endif),
- INSTR(END, instr_cat0, .opc = OPC_END),
- INSTR(KILL, instr_cat0, .opc = OPC_KILL),
+ [n] = { .fxn = (f), .tgsi_opc = n, ##__VA_ARGS__ }
+
+ INSTR(TGSI_OPCODE_MOV, instr_cat1),
+ INSTR(TGSI_OPCODE_RCP, instr_cat4, .opc = OPC_RCP),
+ INSTR(TGSI_OPCODE_RSQ, instr_cat4, .opc = OPC_RSQ),
+ INSTR(TGSI_OPCODE_SQRT, instr_cat4, .opc = OPC_SQRT),
+ INSTR(TGSI_OPCODE_MUL, instr_cat2, .opc = OPC_MUL_F),
+ INSTR(TGSI_OPCODE_ADD, instr_cat2, .opc = OPC_ADD_F),
+ INSTR(TGSI_OPCODE_SUB, instr_cat2, .opc = OPC_ADD_F),
+ INSTR(TGSI_OPCODE_MIN, instr_cat2, .opc = OPC_MIN_F),
+ INSTR(TGSI_OPCODE_MAX, instr_cat2, .opc = OPC_MAX_F),
+ INSTR(TGSI_OPCODE_MAD, instr_cat3, .opc = OPC_MAD_F32, .hopc = OPC_MAD_F16),
+ INSTR(TGSI_OPCODE_TRUNC, instr_cat2, .opc = OPC_TRUNC_F),
+ INSTR(TGSI_OPCODE_CLAMP, trans_clamp),
+ INSTR(TGSI_OPCODE_FLR, instr_cat2, .opc = OPC_FLOOR_F),
+ INSTR(TGSI_OPCODE_ROUND, instr_cat2, .opc = OPC_RNDNE_F),
+ INSTR(TGSI_OPCODE_SSG, instr_cat2, .opc = OPC_SIGN_F),
+ INSTR(TGSI_OPCODE_ARL, trans_arl),
+ INSTR(TGSI_OPCODE_EX2, instr_cat4, .opc = OPC_EXP2),
+ INSTR(TGSI_OPCODE_LG2, instr_cat4, .opc = OPC_LOG2),
+ INSTR(TGSI_OPCODE_ABS, instr_cat2, .opc = OPC_ABSNEG_F),
+ INSTR(TGSI_OPCODE_COS, instr_cat4, .opc = OPC_COS),
+ INSTR(TGSI_OPCODE_SIN, instr_cat4, .opc = OPC_SIN),
+ INSTR(TGSI_OPCODE_TEX, trans_samp, .opc = OPC_SAM, .arg = TGSI_OPCODE_TEX),
+ INSTR(TGSI_OPCODE_TXP, trans_samp, .opc = OPC_SAM, .arg = TGSI_OPCODE_TXP),
+ INSTR(TGSI_OPCODE_SGT, trans_cmp),
+ INSTR(TGSI_OPCODE_SLT, trans_cmp),
+ INSTR(TGSI_OPCODE_SGE, trans_cmp),
+ INSTR(TGSI_OPCODE_SLE, trans_cmp),
+ INSTR(TGSI_OPCODE_SNE, trans_cmp),
+ INSTR(TGSI_OPCODE_SEQ, trans_cmp),
+ INSTR(TGSI_OPCODE_CMP, trans_cmp),
+ INSTR(TGSI_OPCODE_IF, trans_if),
+ INSTR(TGSI_OPCODE_ELSE, trans_else),
+ INSTR(TGSI_OPCODE_ENDIF, trans_endif),
+ INSTR(TGSI_OPCODE_END, instr_cat0, .opc = OPC_END),
+ INSTR(TGSI_OPCODE_KILL, instr_cat0, .opc = OPC_KILL),
};
static ir3_semantic
--
2.1.3
More information about the mesa-dev
mailing list