gallium: remove TGSI_OPCODE_ABS
[mesa.git] / src / gallium / drivers / ilo / shader / toy_tgsi.c
index be1db629839ed39f06135fe8bf55b0d95c988fe9..a88f189ae88d480a7c66c6026829bc6e5a6c6dd3 100644 (file)
@@ -58,7 +58,6 @@ static const struct {
    [TGSI_OPCODE_EX2]          = { TOY_OPCODE_EXP,                 1, 1 },
    [TGSI_OPCODE_LG2]          = { TOY_OPCODE_LOG,                 1, 1 },
    [TGSI_OPCODE_POW]          = { TOY_OPCODE_POW,                 1, 2 },
-   [TGSI_OPCODE_ABS]          = { GEN6_OPCODE_MOV,                 1, 1 },
    [TGSI_OPCODE_DPH]          = { GEN6_OPCODE_DPH,                 1, 2 },
    [TGSI_OPCODE_COS]          = { TOY_OPCODE_COS,                 1, 1 },
    [TGSI_OPCODE_KILL]         = { TOY_OPCODE_KIL,                 0, 0 },
@@ -148,7 +147,6 @@ aos_simple(struct toy_compiler *tc,
    case TGSI_OPCODE_SUB:
       src[1] = tsrc_negate(src[1]);
       break;
-   case TGSI_OPCODE_ABS:
    case TGSI_OPCODE_IABS:
       src[0] = tsrc_absolute(src[0]);
       break;
@@ -190,7 +188,7 @@ aos_simple(struct toy_compiler *tc,
       inst->dst = dst[0];
    }
 
-   assert(num_src <= Elements(inst->src));
+   assert(num_src <= ARRAY_SIZE(inst->src));
    for (i = 0; i < num_src; i++)
       inst->src[i] = src[i];
 }
@@ -380,7 +378,7 @@ aos_tex(struct toy_compiler *tc,
    inst->opcode = opcode;
    inst->tex.target = tgsi_inst->Texture.Texture;
 
-   assert(tgsi_inst->Instruction.NumSrcRegs <= Elements(inst->src));
+   assert(tgsi_inst->Instruction.NumSrcRegs <= ARRAY_SIZE(inst->src));
    assert(tgsi_inst->Instruction.NumDstRegs == 1);
 
    inst->dst = dst[0];
@@ -449,7 +447,7 @@ aos_sample(struct toy_compiler *tc,
    inst = tc_add(tc);
    inst->opcode = opcode;
 
-   assert(tgsi_inst->Instruction.NumSrcRegs <= Elements(inst->src));
+   assert(tgsi_inst->Instruction.NumSrcRegs <= ARRAY_SIZE(inst->src));
    assert(tgsi_inst->Instruction.NumDstRegs == 1);
 
    inst->dst = dst[0];
@@ -568,21 +566,6 @@ aos_LRP(struct toy_compiler *tc,
    tc_MAC(tc, dst[0], src[0], src[1], tsrc_from(tmp));
 }
 
-static void
-aos_CND(struct toy_compiler *tc,
-        const struct tgsi_full_instruction *tgsi_inst,
-        struct toy_dst *dst,
-        struct toy_src *src)
-{
-   struct toy_inst *inst;
-
-   assert(!"CND untested");
-
-   tc_CMP(tc, tdst_null(), src[2], tsrc_imm_f(0.5f), GEN6_COND_G);
-   inst = tc_SEL(tc, dst[0], src[0], src[1], GEN6_COND_NONE);
-   inst->pred_ctrl = GEN6_PREDCTRL_NORMAL;
-}
-
 static void
 aos_DP2A(struct toy_compiler *tc,
          const struct tgsi_full_instruction *tgsi_inst,
@@ -650,28 +633,6 @@ aos_PK2H(struct toy_compiler *tc,
    tc_OR(tc, tdst_ud(dst[0]), h1, tsrc_from(tmp));
 }
 
-static void
-aos_SFL(struct toy_compiler *tc,
-        const struct tgsi_full_instruction *tgsi_inst,
-        struct toy_dst *dst,
-        struct toy_src *src)
-{
-   assert(!"SFL untested");
-
-   tc_MOV(tc, dst[0], tsrc_imm_f(0.0f));
-}
-
-static void
-aos_STR(struct toy_compiler *tc,
-        const struct tgsi_full_instruction *tgsi_inst,
-        struct toy_dst *dst,
-        struct toy_src *src)
-{
-   assert(!"STR untested");
-
-   tc_MOV(tc, dst[0], tsrc_imm_f(1.0f));
-}
-
 static void
 aos_UP2H(struct toy_compiler *tc,
          const struct tgsi_full_instruction *tgsi_inst,
@@ -817,7 +778,6 @@ static const toy_tgsi_translate aos_translate_table[TGSI_OPCODE_LAST] = {
    [TGSI_OPCODE_MAD]          = aos_simple,
    [TGSI_OPCODE_SUB]          = aos_simple,
    [TGSI_OPCODE_LRP]          = aos_LRP,
-   [TGSI_OPCODE_CND]          = aos_CND,
    [TGSI_OPCODE_SQRT]         = aos_simple,
    [TGSI_OPCODE_DP2A]         = aos_DP2A,
    [TGSI_OPCODE_FRC]          = aos_simple,
@@ -828,7 +788,6 @@ static const toy_tgsi_translate aos_translate_table[TGSI_OPCODE_LAST] = {
    [TGSI_OPCODE_LG2]          = aos_simple,
    [TGSI_OPCODE_POW]          = aos_simple,
    [TGSI_OPCODE_XPD]          = aos_XPD,
-   [TGSI_OPCODE_ABS]          = aos_simple,
    [TGSI_OPCODE_DPH]          = aos_simple,
    [TGSI_OPCODE_COS]          = aos_simple,
    [TGSI_OPCODE_DDX]          = aos_unsupported,
@@ -838,14 +797,11 @@ static const toy_tgsi_translate aos_translate_table[TGSI_OPCODE_LAST] = {
    [TGSI_OPCODE_PK2US]        = aos_unsupported,
    [TGSI_OPCODE_PK4B]         = aos_unsupported,
    [TGSI_OPCODE_PK4UB]        = aos_unsupported,
-   [TGSI_OPCODE_RFL]          = aos_unsupported,
    [TGSI_OPCODE_SEQ]          = aos_set_on_cond,
-   [TGSI_OPCODE_SFL]          = aos_SFL,
    [TGSI_OPCODE_SGT]          = aos_set_on_cond,
    [TGSI_OPCODE_SIN]          = aos_simple,
    [TGSI_OPCODE_SLE]          = aos_set_on_cond,
    [TGSI_OPCODE_SNE]          = aos_set_on_cond,
-   [TGSI_OPCODE_STR]          = aos_STR,
    [TGSI_OPCODE_TEX]          = aos_tex,
    [TGSI_OPCODE_TXD]          = aos_tex,
    [TGSI_OPCODE_TXP]          = aos_tex,
@@ -854,7 +810,6 @@ static const toy_tgsi_translate aos_translate_table[TGSI_OPCODE_LAST] = {
    [TGSI_OPCODE_UP4B]         = aos_unsupported,
    [TGSI_OPCODE_UP4UB]        = aos_unsupported,
    [TGSI_OPCODE_ARR]          = aos_simple,
-   [TGSI_OPCODE_BRA]          = aos_unsupported,
    [TGSI_OPCODE_CAL]          = aos_unsupported,
    [TGSI_OPCODE_RET]          = aos_unsupported,
    [TGSI_OPCODE_SSG]          = aos_set_sign,
@@ -1365,7 +1320,6 @@ static const toy_tgsi_translate soa_translate_table[TGSI_OPCODE_LAST] = {
    [TGSI_OPCODE_MAD]          = soa_per_channel,
    [TGSI_OPCODE_SUB]          = soa_per_channel,
    [TGSI_OPCODE_LRP]          = soa_per_channel,
-   [TGSI_OPCODE_CND]          = soa_per_channel,
    [TGSI_OPCODE_SQRT]         = soa_scalar_replicate,
    [TGSI_OPCODE_DP2A]         = soa_dot_product,
    [TGSI_OPCODE_FRC]          = soa_per_channel,
@@ -1376,7 +1330,6 @@ static const toy_tgsi_translate soa_translate_table[TGSI_OPCODE_LAST] = {
    [TGSI_OPCODE_LG2]          = soa_scalar_replicate,
    [TGSI_OPCODE_POW]          = soa_scalar_replicate,
    [TGSI_OPCODE_XPD]          = soa_XPD,
-   [TGSI_OPCODE_ABS]          = soa_per_channel,
    [TGSI_OPCODE_DPH]          = soa_dot_product,
    [TGSI_OPCODE_COS]          = soa_scalar_replicate,
    [TGSI_OPCODE_DDX]          = soa_partial_derivative,
@@ -1386,14 +1339,11 @@ static const toy_tgsi_translate soa_translate_table[TGSI_OPCODE_LAST] = {
    [TGSI_OPCODE_PK2US]        = soa_unsupported,
    [TGSI_OPCODE_PK4B]         = soa_unsupported,
    [TGSI_OPCODE_PK4UB]        = soa_unsupported,
-   [TGSI_OPCODE_RFL]          = soa_unsupported,
    [TGSI_OPCODE_SEQ]          = soa_per_channel,
-   [TGSI_OPCODE_SFL]          = soa_per_channel,
    [TGSI_OPCODE_SGT]          = soa_per_channel,
    [TGSI_OPCODE_SIN]          = soa_scalar_replicate,
    [TGSI_OPCODE_SLE]          = soa_per_channel,
    [TGSI_OPCODE_SNE]          = soa_per_channel,
-   [TGSI_OPCODE_STR]          = soa_per_channel,
    [TGSI_OPCODE_TEX]          = soa_passthrough,
    [TGSI_OPCODE_TXD]          = soa_passthrough,
    [TGSI_OPCODE_TXP]          = soa_passthrough,
@@ -1402,7 +1352,6 @@ static const toy_tgsi_translate soa_translate_table[TGSI_OPCODE_LAST] = {
    [TGSI_OPCODE_UP4B]         = soa_unsupported,
    [TGSI_OPCODE_UP4UB]        = soa_unsupported,
    [TGSI_OPCODE_ARR]          = soa_per_channel,
-   [TGSI_OPCODE_BRA]          = soa_unsupported,
    [TGSI_OPCODE_CAL]          = soa_unsupported,
    [TGSI_OPCODE_RET]          = soa_unsupported,
    [TGSI_OPCODE_SSG]          = soa_per_channel,
@@ -1640,7 +1589,7 @@ ra_get_type(struct toy_tgsi *tgsi, const struct tgsi_full_instruction *tgsi_inst
       tgsi_inst->Src[operand].Register.File;
    switch (file) {
    case TGSI_FILE_SAMPLER:
-   case TGSI_FILE_RESOURCE:
+   case TGSI_FILE_IMAGE:
    case TGSI_FILE_SAMPLER_VIEW:
       type = TOY_TYPE_D;
       break;
@@ -1881,7 +1830,7 @@ ra_get_src_indirect(struct toy_tgsi *tgsi,
       src = tsrc_null();
       break;
    case TGSI_FILE_SAMPLER:
-   case TGSI_FILE_RESOURCE:
+   case TGSI_FILE_IMAGE:
    case TGSI_FILE_SAMPLER_VIEW:
       is_resource = true;
       /* fall through */
@@ -1965,7 +1914,7 @@ ra_get_src(struct toy_tgsi *tgsi,
       need_vrf = true;
       break;
    case TGSI_FILE_SAMPLER:
-   case TGSI_FILE_RESOURCE:
+   case TGSI_FILE_IMAGE:
    case TGSI_FILE_SAMPLER_VIEW:
       assert(!s->Register.Dimension);
       src = tsrc_imm_d(s->Register.Index);
@@ -2083,9 +2032,6 @@ parse_instruction(struct toy_tgsi *tgsi,
       if (!dst_is_scratch[i])
          continue;
 
-      if (tgsi_inst->Instruction.Saturate == TGSI_SAT_MINUS_PLUS_ONE)
-         tc_fail(tgsi->tc, "TGSI_SAT_MINUS_PLUS_ONE unhandled");
-
       tgsi->tc->templ.saturate = tgsi_inst->Instruction.Saturate;
 
       /* emit indirect store */
@@ -2168,7 +2114,7 @@ decl_add_in(struct toy_tgsi *tgsi, const struct tgsi_full_declaration *decl)
       (decl->Declaration.Interpolate) ? &decl->Interp: &default_interp;
    int index;
 
-   if (decl->Range.Last >= Elements(tgsi->inputs)) {
+   if (decl->Range.Last >= ARRAY_SIZE(tgsi->inputs)) {
       assert(!"invalid IN");
       return;
    }
@@ -2196,7 +2142,7 @@ decl_add_out(struct toy_tgsi *tgsi, const struct tgsi_full_declaration *decl)
 {
    int index;
 
-   if (decl->Range.Last >= Elements(tgsi->outputs)) {
+   if (decl->Range.Last >= ARRAY_SIZE(tgsi->outputs)) {
       assert(!"invalid OUT");
       return;
    }
@@ -2219,7 +2165,7 @@ decl_add_sv(struct toy_tgsi *tgsi, const struct tgsi_full_declaration *decl)
 {
    int index;
 
-   if (decl->Range.Last >= Elements(tgsi->system_values)) {
+   if (decl->Range.Last >= ARRAY_SIZE(tgsi->system_values)) {
       assert(!"invalid SV");
       return;
    }
@@ -2306,7 +2252,7 @@ parse_declaration(struct toy_tgsi *tgsi,
    case TGSI_FILE_SAMPLER:
    case TGSI_FILE_PREDICATE:
    case TGSI_FILE_ADDRESS:
-   case TGSI_FILE_RESOURCE:
+   case TGSI_FILE_IMAGE:
    case TGSI_FILE_SAMPLER_VIEW:
       /* nothing to do */
       break;
@@ -2343,10 +2289,8 @@ add_imm(struct toy_tgsi *tgsi, enum toy_type type, const uint32_t *buf)
             cur_size * sizeof(new_types[0]),
             new_size * sizeof(new_types[0]));
       if (!new_buf || !new_types) {
-         if (new_buf)
-            FREE(new_buf);
-         if (new_types)
-            FREE(new_types);
+         FREE(new_buf);
+         FREE(new_types);
          return -1;
       }