vc4: Add support for 16-bit signed/unsigned norm/scaled vertex attrs.
[mesa.git] / src / gallium / drivers / r600 / r600_shader.c
index 08125b79edb2d984f894df6379595f75aacedd4b..471df91d8f38c7af1eb4602e0e6488142a6b245f 100644 (file)
@@ -161,6 +161,8 @@ int r600_pipe_shader_create(struct pipe_context *ctx,
 
        /* disable SB for geom shaders - it can't handle the CF_EMIT instructions */
        use_sb &= (shader->shader.processor_type != TGSI_PROCESSOR_GEOMETRY);
+       /* disable SB for shaders using CF_INDEX_0/1 (sampler/ubo array indexing) as it doesn't handle those currently */
+       use_sb &= !shader->shader.uses_index_registers;
 
        /* Check if the bytecode has already been built.  When using the llvm
         * backend, r600_shader_from_tgsi() will take care of building the
@@ -265,6 +267,7 @@ struct r600_shader_src {
        unsigned                                abs;
        unsigned                                rel;
        unsigned                                kc_bank;
+       boolean                                 kc_rel; /* true if cache bank is indexed */
        uint32_t                                value[4];
 };
 
@@ -325,7 +328,7 @@ static int tgsi_bgnloop(struct r600_shader_ctx *ctx);
 static int tgsi_endloop(struct r600_shader_ctx *ctx);
 static int tgsi_loop_brk_cont(struct r600_shader_ctx *ctx);
 static int tgsi_fetch_rel_const(struct r600_shader_ctx *ctx,
-                                unsigned int cb_idx, unsigned int offset, unsigned ar_chan,
+                                unsigned int cb_idx, unsigned cb_rel, unsigned int offset, unsigned ar_chan,
                                 unsigned int dst_reg);
 static void r600_bytecode_src(struct r600_bytecode_alu_src *bc_src,
                        const struct r600_shader_src *shader_src,
@@ -1031,12 +1034,15 @@ static void tgsi_src(struct r600_shader_ctx *ctx,
        if (tgsi_src->Register.File == TGSI_FILE_CONSTANT) {
                if (tgsi_src->Register.Dimension) {
                        r600_src->kc_bank = tgsi_src->Dimension.Index;
+                       if (tgsi_src->Dimension.Indirect) {
+                               r600_src->kc_rel = 1;
+                       }
                }
        }
 }
 
 static int tgsi_fetch_rel_const(struct r600_shader_ctx *ctx,
-                                unsigned int cb_idx, unsigned int offset, unsigned ar_chan,
+                                unsigned int cb_idx, unsigned cb_rel, unsigned int offset, unsigned ar_chan,
                                 unsigned int dst_reg)
 {
        struct r600_bytecode_vtx vtx;
@@ -1083,6 +1089,7 @@ static int tgsi_fetch_rel_const(struct r600_shader_ctx *ctx,
        vtx.num_format_all = 2;         /* NUM_FORMAT_SCALED */
        vtx.format_comp_all = 1;        /* FORMAT_COMP_SIGNED */
        vtx.endian = r600_endian_swap(32);
+       vtx.buffer_index_mode = cb_rel; // cb_rel ? V_SQ_CF_INDEX_0 : V_SQ_CF_INDEX_NONE;
 
        if ((r = r600_bytecode_add_vtx(ctx->bc, &vtx)))
                return r;
@@ -1211,13 +1218,17 @@ static int tgsi_split_constant(struct r600_shader_ctx *ctx)
                        continue;
                }
 
+               if (ctx->src[i].kc_rel)
+                       ctx->shader->uses_index_registers = true;
+
                if (ctx->src[i].rel) {
                        int chan = inst->Src[i].Indirect.Swizzle;
                        int treg = r600_get_temp(ctx);
-                       if ((r = tgsi_fetch_rel_const(ctx, ctx->src[i].kc_bank, ctx->src[i].sel - 512, chan, treg)))
+                       if ((r = tgsi_fetch_rel_const(ctx, ctx->src[i].kc_bank, ctx->src[i].kc_rel, ctx->src[i].sel - 512, chan, treg)))
                                return r;
 
                        ctx->src[i].kc_bank = 0;
+                       ctx->src[i].kc_rel = 0;
                        ctx->src[i].sel = treg;
                        ctx->src[i].rel = 0;
                        j--;
@@ -1230,6 +1241,7 @@ static int tgsi_split_constant(struct r600_shader_ctx *ctx)
                                alu.src[0].chan = k;
                                alu.src[0].rel = ctx->src[i].rel;
                                alu.src[0].kc_bank = ctx->src[i].kc_bank;
+                               alu.src[0].kc_rel = ctx->src[i].kc_rel;
                                alu.dst.sel = treg;
                                alu.dst.chan = k;
                                alu.dst.write = 1;
@@ -1813,6 +1825,7 @@ static int r600_shader_from_tgsi(struct r600_context *rctx,
        ctx.gs_out_ring_offset = 0;
        ctx.gs_next_vertex = 0;
 
+       shader->uses_index_registers = false;
        ctx.face_gpr = -1;
        ctx.fixed_pt_position_gpr = -1;
        ctx.fragcoord_input = -1;
@@ -1896,8 +1909,13 @@ static int r600_shader_from_tgsi(struct r600_context *rctx,
        if (ctx.type == TGSI_PROCESSOR_GEOMETRY) {
                ctx.gs_export_gpr_treg = ctx.bc->ar_reg + 1;
                ctx.temp_reg = ctx.bc->ar_reg + 2;
-       } else
+               ctx.bc->index_reg[0] = ctx.bc->ar_reg + 3;
+               ctx.bc->index_reg[1] = ctx.bc->ar_reg + 4;
+       } else {
                ctx.temp_reg = ctx.bc->ar_reg + 1;
+               ctx.bc->index_reg[0] = ctx.bc->ar_reg + 2;
+               ctx.bc->index_reg[1] = ctx.bc->ar_reg + 3;
+       }
 
        if (indirect_gprs) {
                shader->max_arrays = 0;
@@ -2515,6 +2533,7 @@ static void r600_bytecode_src(struct r600_bytecode_alu_src *bc_src,
        bc_src->rel = shader_src->rel;
        bc_src->value = shader_src->value[bc_src->chan];
        bc_src->kc_bank = shader_src->kc_bank;
+       bc_src->kc_rel = shader_src->kc_rel;
 }
 
 static void r600_bytecode_src_set_abs(struct r600_bytecode_alu_src *bc_src)
@@ -2709,8 +2728,10 @@ static int cayman_mul_int_instr(struct r600_shader_ctx *ctx)
        struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
        int i, j, k, r;
        struct r600_bytecode_alu alu;
-       int last_slot = (inst->Dst[0].Register.WriteMask & 0x8) ? 4 : 3;
-       for (k = 0; k < last_slot; k++) {
+       int lasti = tgsi_last_instruction(inst->Dst[0].Register.WriteMask);
+       int t1 = ctx->temp_reg;
+
+       for (k = 0; k <= lasti; k++) {
                if (!(inst->Dst[0].Register.WriteMask & (1 << k)))
                        continue;
 
@@ -2720,7 +2741,8 @@ static int cayman_mul_int_instr(struct r600_shader_ctx *ctx)
                        for (j = 0; j < inst->Instruction.NumSrcRegs; j++) {
                                r600_bytecode_src(&alu.src[j], &ctx->src[j], k);
                        }
-                       tgsi_dst(ctx, &inst->Dst[0], i, &alu.dst);
+                       alu.dst.sel = t1;
+                       alu.dst.chan = i;
                        alu.dst.write = (i == k);
                        if (i == 3)
                                alu.last = 1;
@@ -2729,6 +2751,23 @@ static int cayman_mul_int_instr(struct r600_shader_ctx *ctx)
                                return r;
                }
        }
+
+       for (i = 0 ; i <= lasti; i++) {
+               if (!(inst->Dst[0].Register.WriteMask & (1 << i)))
+                       continue;
+               memset(&alu, 0, sizeof(struct r600_bytecode_alu));
+               alu.op = ALU_OP1_MOV;
+               alu.src[0].sel = t1;
+               alu.src[0].chan = i;
+               tgsi_dst(ctx, &inst->Dst[0], i, &alu.dst);
+               alu.dst.write = 1;
+               if (i == lasti)
+                       alu.last = 1;
+               r = r600_bytecode_add_alu(ctx->bc, &alu);
+               if (r)
+                       return r;
+       }
+
        return 0;
 }
 
@@ -4880,7 +4919,8 @@ static inline boolean tgsi_tex_src_requires_loading(struct r600_shader_ctx *ctx,
        return  (inst->Src[index].Register.File != TGSI_FILE_TEMPORARY &&
                inst->Src[index].Register.File != TGSI_FILE_INPUT &&
                inst->Src[index].Register.File != TGSI_FILE_OUTPUT) ||
-               ctx->src[index].neg || ctx->src[index].abs;
+               ctx->src[index].neg || ctx->src[index].abs ||
+               (inst->Src[index].Register.File == TGSI_FILE_INPUT && ctx->type == TGSI_PROCESSOR_GEOMETRY);
 }
 
 static inline unsigned tgsi_tex_get_src_gpr(struct r600_shader_ctx *ctx,
@@ -4995,8 +5035,9 @@ static int r600_do_buffer_txq(struct r600_shader_ctx *ctx)
        alu.op = ALU_OP1_MOV;
 
        if (ctx->bc->chip_class >= EVERGREEN) {
-               alu.src[0].sel = 512 + (id / 4);
-               alu.src[0].chan = id % 4;
+               /* channel 0 or 2 of each word */
+               alu.src[0].sel = 512 + (id / 2);
+               alu.src[0].chan = (id % 2) * 2;
        } else {
                /* r600 we have them at channel 2 of the second dword */
                alu.src[0].sel = 512 + (id * 2) + 1;
@@ -5039,6 +5080,7 @@ static int tgsi_tex(struct r600_shader_ctx *ctx)
        unsigned sampler_src_reg = inst->Instruction.Opcode == TGSI_OPCODE_TXQ_LZ ? 0 : 1;
        int8_t offset_x = 0, offset_y = 0, offset_z = 0;
        boolean has_txq_cube_array_z = false;
+       unsigned sampler_index_mode;
 
        if (inst->Instruction.Opcode == TGSI_OPCODE_TXQ &&
            ((inst->Texture.Texture == TGSI_TEXTURE_CUBE_ARRAY ||
@@ -5054,6 +5096,14 @@ static int tgsi_tex(struct r600_shader_ctx *ctx)
            inst->Instruction.Opcode == TGSI_OPCODE_TG4)
                sampler_src_reg = 2;
 
+       /* TGSI moves the sampler to src reg 3 for TXD */
+       if (inst->Instruction.Opcode == TGSI_OPCODE_TXD)
+               sampler_src_reg = 3;
+
+       sampler_index_mode = inst->Src[sampler_src_reg].Indirect.Index == 2 ? 2 : 0; // CF_INDEX_1 : CF_INDEX_NONE
+       if (sampler_index_mode)
+               ctx->shader->uses_index_registers = true;
+
        src_gpr = tgsi_tex_get_src_gpr(ctx, 0);
 
        if (inst->Texture.Texture == TGSI_TEXTURE_BUFFER) {
@@ -5068,60 +5118,7 @@ static int tgsi_tex(struct r600_shader_ctx *ctx)
                }
        }
 
-       if (inst->Instruction.Opcode == TGSI_OPCODE_TXD) {
-               /* TGSI moves the sampler to src reg 3 for TXD */
-               sampler_src_reg = 3;
-
-               for (i = 1; i < 3; i++) {
-                       /* set gradients h/v */
-                       memset(&tex, 0, sizeof(struct r600_bytecode_tex));
-                       tex.op = (i == 1) ? FETCH_OP_SET_GRADIENTS_H :
-                               FETCH_OP_SET_GRADIENTS_V;
-                       tex.sampler_id = tgsi_tex_get_src_gpr(ctx, sampler_src_reg);
-                       tex.resource_id = tex.sampler_id + R600_MAX_CONST_BUFFERS;
-
-                       if (tgsi_tex_src_requires_loading(ctx, i)) {
-                               tex.src_gpr = r600_get_temp(ctx);
-                               tex.src_sel_x = 0;
-                               tex.src_sel_y = 1;
-                               tex.src_sel_z = 2;
-                               tex.src_sel_w = 3;
-
-                               for (j = 0; j < 4; j++) {
-                                       memset(&alu, 0, sizeof(struct r600_bytecode_alu));
-                                       alu.op = ALU_OP1_MOV;
-                                        r600_bytecode_src(&alu.src[0], &ctx->src[i], j);
-                                        alu.dst.sel = tex.src_gpr;
-                                        alu.dst.chan = j;
-                                        if (j == 3)
-                                                alu.last = 1;
-                                        alu.dst.write = 1;
-                                        r = r600_bytecode_add_alu(ctx->bc, &alu);
-                                        if (r)
-                                                return r;
-                               }
-
-                       } else {
-                               tex.src_gpr = tgsi_tex_get_src_gpr(ctx, i);
-                               tex.src_sel_x = ctx->src[i].swizzle[0];
-                               tex.src_sel_y = ctx->src[i].swizzle[1];
-                               tex.src_sel_z = ctx->src[i].swizzle[2];
-                               tex.src_sel_w = ctx->src[i].swizzle[3];
-                               tex.src_rel = ctx->src[i].rel;
-                       }
-                       tex.dst_gpr = ctx->temp_reg; /* just to avoid confusing the asm scheduler */
-                       tex.dst_sel_x = tex.dst_sel_y = tex.dst_sel_z = tex.dst_sel_w = 7;
-                       if (inst->Texture.Texture != TGSI_TEXTURE_RECT) {
-                               tex.coord_type_x = 1;
-                               tex.coord_type_y = 1;
-                               tex.coord_type_z = 1;
-                               tex.coord_type_w = 1;
-                       }
-                       r = r600_bytecode_add_tex(ctx->bc, &tex);
-                       if (r)
-                               return r;
-               }
-       } else if (inst->Instruction.Opcode == TGSI_OPCODE_TXP) {
+       if (inst->Instruction.Opcode == TGSI_OPCODE_TXP) {
                int out_chan;
                /* Add perspective divide */
                if (ctx->bc->chip_class == CAYMAN) {
@@ -5185,6 +5182,7 @@ static int tgsi_tex(struct r600_shader_ctx *ctx)
                src_gpr = ctx->temp_reg;
        }
 
+
        if ((inst->Texture.Texture == TGSI_TEXTURE_CUBE ||
             inst->Texture.Texture == TGSI_TEXTURE_CUBE_ARRAY ||
             inst->Texture.Texture == TGSI_TEXTURE_SHADOWCUBE ||
@@ -5402,6 +5400,69 @@ static int tgsi_tex(struct r600_shader_ctx *ctx)
                src_gpr = ctx->temp_reg;
        }
 
+       if (inst->Instruction.Opcode == TGSI_OPCODE_TXD) {
+               int temp_h = 0, temp_v = 0;
+               int start_val = 0;
+
+               /* if we've already loaded the src (i.e. CUBE don't reload it). */
+               if (src_loaded == TRUE)
+                       start_val = 1;
+               else
+                       src_loaded = TRUE;
+               for (i = start_val; i < 3; i++) {
+                       int treg = r600_get_temp(ctx);
+
+                       if (i == 0)
+                               src_gpr = treg;
+                       else if (i == 1)
+                               temp_h = treg;
+                       else
+                               temp_v = treg;
+
+                       for (j = 0; j < 4; j++) {
+                               memset(&alu, 0, sizeof(struct r600_bytecode_alu));
+                               alu.op = ALU_OP1_MOV;
+                                r600_bytecode_src(&alu.src[0], &ctx->src[i], j);
+                                alu.dst.sel = treg;
+                                alu.dst.chan = j;
+                                if (j == 3)
+                                   alu.last = 1;
+                                alu.dst.write = 1;
+                                r = r600_bytecode_add_alu(ctx->bc, &alu);
+                                if (r)
+                                    return r;
+                       }
+               }
+               for (i = 1; i < 3; i++) {
+                       /* set gradients h/v */
+                       memset(&tex, 0, sizeof(struct r600_bytecode_tex));
+                       tex.op = (i == 1) ? FETCH_OP_SET_GRADIENTS_H :
+                               FETCH_OP_SET_GRADIENTS_V;
+                       tex.sampler_id = tgsi_tex_get_src_gpr(ctx, sampler_src_reg);
+                       tex.sampler_index_mode = sampler_index_mode;
+                       tex.resource_id = tex.sampler_id + R600_MAX_CONST_BUFFERS;
+                       tex.resource_index_mode = sampler_index_mode;
+
+                       tex.src_gpr = (i == 1) ? temp_h : temp_v;
+                       tex.src_sel_x = 0;
+                       tex.src_sel_y = 1;
+                       tex.src_sel_z = 2;
+                       tex.src_sel_w = 3;
+
+                       tex.dst_gpr = r600_get_temp(ctx); /* just to avoid confusing the asm scheduler */
+                       tex.dst_sel_x = tex.dst_sel_y = tex.dst_sel_z = tex.dst_sel_w = 7;
+                       if (inst->Texture.Texture != TGSI_TEXTURE_RECT) {
+                               tex.coord_type_x = 1;
+                               tex.coord_type_y = 1;
+                               tex.coord_type_z = 1;
+                               tex.coord_type_w = 1;
+                       }
+                       r = r600_bytecode_add_tex(ctx->bc, &tex);
+                       if (r)
+                               return r;
+               }
+       }
+
        if (src_requires_loading && !src_loaded) {
                for (i = 0; i < 4; i++) {
                        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
@@ -5486,9 +5547,24 @@ static int tgsi_tex(struct r600_shader_ctx *ctx)
                                /* texture offsets do not apply to other texture targets */
                        }
                } else {
-                       offset_x = ctx->literals[4 * inst->TexOffsets[0].Index + inst->TexOffsets[0].SwizzleX] << 1;
-                       offset_y = ctx->literals[4 * inst->TexOffsets[0].Index + inst->TexOffsets[0].SwizzleY] << 1;
-                       offset_z = ctx->literals[4 * inst->TexOffsets[0].Index + inst->TexOffsets[0].SwizzleZ] << 1;
+                       switch (inst->Texture.Texture) {
+                       case TGSI_TEXTURE_3D:
+                               offset_z = ctx->literals[4 * inst->TexOffsets[0].Index + inst->TexOffsets[0].SwizzleZ] << 1;
+                               /* fallthrough */
+                       case TGSI_TEXTURE_2D:
+                       case TGSI_TEXTURE_SHADOW2D:
+                       case TGSI_TEXTURE_RECT:
+                       case TGSI_TEXTURE_SHADOWRECT:
+                       case TGSI_TEXTURE_2D_ARRAY:
+                       case TGSI_TEXTURE_SHADOW2D_ARRAY:
+                               offset_y = ctx->literals[4 * inst->TexOffsets[0].Index + inst->TexOffsets[0].SwizzleY] << 1;
+                               /* fallthrough */
+                       case TGSI_TEXTURE_1D:
+                       case TGSI_TEXTURE_SHADOW1D:
+                       case TGSI_TEXTURE_1D_ARRAY:
+                       case TGSI_TEXTURE_SHADOW1D_ARRAY:
+                               offset_x = ctx->literals[4 * inst->TexOffsets[0].Index + inst->TexOffsets[0].SwizzleX] << 1;
+                       }
                }
        }
 
@@ -5513,7 +5589,9 @@ static int tgsi_tex(struct r600_shader_ctx *ctx)
                tex.op = FETCH_OP_LD;
                tex.inst_mod = 1; /* to indicate this is ldfptr */
                tex.sampler_id = tgsi_tex_get_src_gpr(ctx, sampler_src_reg);
+               tex.sampler_index_mode = sampler_index_mode;
                tex.resource_id = tex.sampler_id + R600_MAX_CONST_BUFFERS;
+               tex.resource_index_mode = sampler_index_mode;
                tex.src_gpr = src_gpr;
                tex.dst_gpr = temp;
                tex.dst_sel_x = 7; /* mask out these components */
@@ -5620,9 +5698,16 @@ static int tgsi_tex(struct r600_shader_ctx *ctx)
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
                alu.op = ALU_OP1_MOV;
 
-               alu.src[0].sel = 512 + (id / 4);
-               alu.src[0].kc_bank = R600_TXQ_CONST_BUFFER;
-               alu.src[0].chan = id % 4;
+               if (ctx->bc->chip_class >= EVERGREEN) {
+                       /* channel 1 or 3 of each word */
+                       alu.src[0].sel = 512 + (id / 2);
+                       alu.src[0].chan = ((id % 2) * 2) + 1;
+               } else {
+                       /* r600 we have them at channel 2 of the second dword */
+                       alu.src[0].sel = 512 + (id * 2) + 1;
+                       alu.src[0].chan = 2;
+               }
+               alu.src[0].kc_bank = R600_BUFFER_INFO_CONST_BUFFER;
                tgsi_dst(ctx, &inst->Dst[0], 2, &alu.dst);
                alu.last = 1;
                r = r600_bytecode_add_alu(ctx->bc, &alu);
@@ -5644,7 +5729,9 @@ static int tgsi_tex(struct r600_shader_ctx *ctx)
                memset(&tex, 0, sizeof(struct r600_bytecode_tex));
                tex.op = FETCH_OP_SET_TEXTURE_OFFSETS;
                tex.sampler_id = tgsi_tex_get_src_gpr(ctx, sampler_src_reg);
+               tex.sampler_index_mode = sampler_index_mode;
                tex.resource_id = tex.sampler_id + R600_MAX_CONST_BUFFERS;
+               tex.resource_index_mode = sampler_index_mode;
 
                tex.src_gpr = ctx->file_offset[inst->TexOffsets[0].File] + inst->TexOffsets[0].Index;
                tex.src_sel_x = inst->TexOffsets[0].SwizzleX;
@@ -5696,7 +5783,9 @@ static int tgsi_tex(struct r600_shader_ctx *ctx)
        tex.op = opcode;
 
        tex.sampler_id = tgsi_tex_get_src_gpr(ctx, sampler_src_reg);
+       tex.sampler_index_mode = sampler_index_mode;
        tex.resource_id = tex.sampler_id + R600_MAX_CONST_BUFFERS;
+       tex.resource_index_mode = sampler_index_mode;
        tex.src_gpr = src_gpr;
        tex.dst_gpr = ctx->file_offset[inst->Dst[0].Register.File] + inst->Dst[0].Register.Index;
 
@@ -5709,11 +5798,18 @@ static int tgsi_tex(struct r600_shader_ctx *ctx)
                int8_t texture_component_select = ctx->literals[4 * inst->Src[1].Register.Index + inst->Src[1].Register.SwizzleX];
                tex.inst_mod = texture_component_select;
 
+               if (ctx->bc->chip_class == CAYMAN) {
                /* GATHER4 result order is different from TGSI TG4 */
-               tex.dst_sel_x = (inst->Dst[0].Register.WriteMask & 2) ? 1 : 7;
-               tex.dst_sel_y = (inst->Dst[0].Register.WriteMask & 4) ? 2 : 7;
-               tex.dst_sel_z = (inst->Dst[0].Register.WriteMask & 1) ? 0 : 7;
-               tex.dst_sel_w = (inst->Dst[0].Register.WriteMask & 8) ? 3 : 7;
+                       tex.dst_sel_x = (inst->Dst[0].Register.WriteMask & 2) ? 0 : 7;
+                       tex.dst_sel_y = (inst->Dst[0].Register.WriteMask & 4) ? 1 : 7;
+                       tex.dst_sel_z = (inst->Dst[0].Register.WriteMask & 1) ? 2 : 7;
+                       tex.dst_sel_w = (inst->Dst[0].Register.WriteMask & 8) ? 3 : 7;
+               } else {
+                       tex.dst_sel_x = (inst->Dst[0].Register.WriteMask & 2) ? 1 : 7;
+                       tex.dst_sel_y = (inst->Dst[0].Register.WriteMask & 4) ? 2 : 7;
+                       tex.dst_sel_z = (inst->Dst[0].Register.WriteMask & 1) ? 0 : 7;
+                       tex.dst_sel_w = (inst->Dst[0].Register.WriteMask & 8) ? 3 : 7;
+               }
        }
        else if (inst->Instruction.Opcode == TGSI_OPCODE_LODQ) {
                tex.dst_sel_x = (inst->Dst[0].Register.WriteMask & 2) ? 1 : 7;
@@ -5975,7 +6071,7 @@ static int tgsi_ucmp(struct r600_shader_ctx *ctx)
                        continue;
 
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
-               alu.op = ALU_OP3_CNDGE_INT;
+               alu.op = ALU_OP3_CNDE_INT;
                r600_bytecode_src(&alu.src[0], &ctx->src[0], i);
                r600_bytecode_src(&alu.src[1], &ctx->src[2], i);
                r600_bytecode_src(&alu.src[2], &ctx->src[1], i);
@@ -6459,7 +6555,9 @@ static int tgsi_eg_arl(struct r600_shader_ctx *ctx)
        struct r600_bytecode_alu alu;
        int r;
        int i, lasti = tgsi_last_instruction(inst->Dst[0].Register.WriteMask);
+       unsigned reg = inst->Dst[0].Register.Index > 0 ? ctx->bc->index_reg[inst->Dst[0].Register.Index - 1] : ctx->bc->ar_reg;
 
+       assert(inst->Dst[0].Register.Index < 3);
        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
 
        switch (inst->Instruction.Opcode) {
@@ -6482,7 +6580,7 @@ static int tgsi_eg_arl(struct r600_shader_ctx *ctx)
                        continue;
                r600_bytecode_src(&alu.src[0], &ctx->src[0], i);
                alu.last = i == lasti;
-               alu.dst.sel = ctx->bc->ar_reg;
+               alu.dst.sel = reg;
                alu.dst.chan = i;
                alu.dst.write = 1;
                r = r600_bytecode_add_alu(ctx->bc, &alu);
@@ -6490,7 +6588,11 @@ static int tgsi_eg_arl(struct r600_shader_ctx *ctx)
                        return r;
        }
 
-       ctx->bc->ar_loaded = 0;
+       if (inst->Dst[0].Register.Index > 0)
+               ctx->bc->index_loaded[inst->Dst[0].Register.Index - 1] = 0;
+       else
+               ctx->bc->ar_loaded = 0;
+
        return 0;
 }
 static int tgsi_r600_arl(struct r600_shader_ctx *ctx)
@@ -7035,7 +7137,7 @@ static int tgsi_umad(struct r600_shader_ctx *ctx)
                                for (k = 0; k < inst->Instruction.NumSrcRegs; k++) {
                                        r600_bytecode_src(&alu.src[k], &ctx->src[k], i);
                                }
-                               tgsi_dst(ctx, &inst->Dst[0], j, &alu.dst);
+                               alu.dst.chan = j;
                                alu.dst.sel = ctx->temp_reg;
                                alu.dst.write = (j == i);
                                if (j == 3)
@@ -7113,10 +7215,9 @@ static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction[] = {
        {TGSI_OPCODE_MAD,       1, ALU_OP3_MULADD, tgsi_op3},
        {TGSI_OPCODE_SUB,       0, ALU_OP2_ADD, tgsi_op2},
        {TGSI_OPCODE_LRP,       0, ALU_OP0_NOP, tgsi_lrp},
-       {TGSI_OPCODE_CND,       0, ALU_OP0_NOP, tgsi_unsupported},
+       {19,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_SQRT,      0, ALU_OP1_SQRT_IEEE, tgsi_trans_srcx_replicate},
        {TGSI_OPCODE_DP2A,      0, ALU_OP0_NOP, tgsi_unsupported},
-       /* gap */
        {22,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {23,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_FRC,       0, ALU_OP1_FRACT, tgsi_op2},
@@ -7127,10 +7228,9 @@ static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction[] = {
        {TGSI_OPCODE_LG2,       0, ALU_OP1_LOG_IEEE, tgsi_trans_srcx_replicate},
        {TGSI_OPCODE_POW,       0, ALU_OP0_NOP, tgsi_pow},
        {TGSI_OPCODE_XPD,       0, ALU_OP0_NOP, tgsi_xpd},
-       /* gap */
        {32,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_ABS,       0, ALU_OP1_MOV, tgsi_op2},
-       {TGSI_OPCODE_RCC,       0, ALU_OP0_NOP, tgsi_unsupported},
+       {34,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_DPH,       0, ALU_OP2_DOT4, tgsi_dp},
        {TGSI_OPCODE_COS,       0, ALU_OP1_COS, tgsi_trig},
        {TGSI_OPCODE_DDX,       0, FETCH_OP_GET_GRADIENTS_H, tgsi_tex},
@@ -7140,14 +7240,14 @@ static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction[] = {
        {TGSI_OPCODE_PK2US,     0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_PK4B,      0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_PK4UB,     0, ALU_OP0_NOP, tgsi_unsupported},
-       {TGSI_OPCODE_RFL,       0, ALU_OP0_NOP, tgsi_unsupported},
+       {44,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_SEQ,       0, ALU_OP2_SETE, tgsi_op2},
-       {TGSI_OPCODE_SFL,       0, ALU_OP0_NOP, tgsi_unsupported},
+       {46,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_SGT,       0, ALU_OP2_SETGT, tgsi_op2},
        {TGSI_OPCODE_SIN,       0, ALU_OP1_SIN, tgsi_trig},
        {TGSI_OPCODE_SLE,       0, ALU_OP2_SETGE, tgsi_op2_swap},
        {TGSI_OPCODE_SNE,       0, ALU_OP2_SETNE, tgsi_op2},
-       {TGSI_OPCODE_STR,       0, ALU_OP0_NOP, tgsi_unsupported},
+       {51,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_TEX,       0, FETCH_OP_SAMPLE, tgsi_tex},
        {TGSI_OPCODE_TXD,       0, FETCH_OP_SAMPLE_G, tgsi_tex},
        {TGSI_OPCODE_TXP,       0, FETCH_OP_SAMPLE, tgsi_tex},
@@ -7155,17 +7255,17 @@ static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction[] = {
        {TGSI_OPCODE_UP2US,     0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_UP4B,      0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_UP4UB,     0, ALU_OP0_NOP, tgsi_unsupported},
-       {TGSI_OPCODE_X2D,       0, ALU_OP0_NOP, tgsi_unsupported},
-       {TGSI_OPCODE_ARA,       0, ALU_OP0_NOP, tgsi_unsupported},
+       {59,                    0, ALU_OP0_NOP, tgsi_unsupported},
+       {60,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_ARR,       0, ALU_OP0_NOP, tgsi_r600_arl},
-       {TGSI_OPCODE_BRA,       0, ALU_OP0_NOP, tgsi_unsupported},
+       {62,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_CAL,       0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_RET,       0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_SSG,       0, ALU_OP0_NOP, tgsi_ssg},
        {TGSI_OPCODE_CMP,       0, ALU_OP0_NOP, tgsi_cmp},
        {TGSI_OPCODE_SCS,       0, ALU_OP0_NOP, tgsi_scs},
        {TGSI_OPCODE_TXB,       0, FETCH_OP_SAMPLE_LB, tgsi_tex},
-       {TGSI_OPCODE_NRM,       0, ALU_OP0_NOP, tgsi_unsupported},
+       {69,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_DIV,       0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_DP2,       0, ALU_OP2_DOT4, tgsi_dp},
        {TGSI_OPCODE_TXL,       0, FETCH_OP_SAMPLE_L, tgsi_tex},
@@ -7184,7 +7284,6 @@ static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction[] = {
        {TGSI_OPCODE_NOT,       0, ALU_OP1_NOT_INT, tgsi_op2},
        {TGSI_OPCODE_TRUNC,     0, ALU_OP1_TRUNC, tgsi_op2},
        {TGSI_OPCODE_SHL,       0, ALU_OP2_LSHL_INT, tgsi_op2_trans},
-       /* gap */
        {88,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_AND,       0, ALU_OP2_AND_INT, tgsi_op2},
        {TGSI_OPCODE_OR,        0, ALU_OP2_OR_INT, tgsi_op2},
@@ -7201,7 +7300,6 @@ static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction[] = {
        {TGSI_OPCODE_ENDLOOP,   0, ALU_OP0_NOP, tgsi_endloop},
        {TGSI_OPCODE_ENDSUB,    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_TXQ_LZ,    0, FETCH_OP_GET_TEXTURE_RESINFO, tgsi_tex},
-       /* gap */
        {104,                   0, ALU_OP0_NOP, tgsi_unsupported},
        {105,                   0, ALU_OP0_NOP, tgsi_unsupported},
        {106,                   0, ALU_OP0_NOP, tgsi_unsupported},
@@ -7210,14 +7308,12 @@ static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction[] = {
        {TGSI_OPCODE_FSGE,      0, ALU_OP2_SETGE_DX10, tgsi_op2},
        {TGSI_OPCODE_FSLT,      0, ALU_OP2_SETGT_DX10, tgsi_op2_swap},
        {TGSI_OPCODE_FSNE,      0, ALU_OP2_SETNE_DX10, tgsi_op2_swap},
-       {TGSI_OPCODE_NRM4,      0, ALU_OP0_NOP, tgsi_unsupported},
+       {112,                   0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_CALLNZ,    0, ALU_OP0_NOP, tgsi_unsupported},
-       /* gap */
        {114,                   0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_BREAKC,    0, ALU_OP0_NOP, tgsi_loop_breakc},
        {TGSI_OPCODE_KILL_IF,   0, ALU_OP2_KILLGT, tgsi_kill},  /* conditional kill */
        {TGSI_OPCODE_END,       0, ALU_OP0_NOP, tgsi_end},  /* aka HALT */
-       /* gap */
        {118,                   0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_F2I,       0, ALU_OP1_FLT_TO_INT, tgsi_op2_trans},
        {TGSI_OPCODE_IDIV,      0, ALU_OP0_NOP, tgsi_idiv},
@@ -7318,10 +7414,9 @@ static struct r600_shader_tgsi_instruction eg_shader_tgsi_instruction[] = {
        {TGSI_OPCODE_MAD,       1, ALU_OP3_MULADD, tgsi_op3},
        {TGSI_OPCODE_SUB,       0, ALU_OP2_ADD, tgsi_op2},
        {TGSI_OPCODE_LRP,       0, ALU_OP0_NOP, tgsi_lrp},
-       {TGSI_OPCODE_CND,       0, ALU_OP0_NOP, tgsi_unsupported},
+       {19,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_SQRT,      0, ALU_OP1_SQRT_IEEE, tgsi_trans_srcx_replicate},
        {TGSI_OPCODE_DP2A,      0, ALU_OP0_NOP, tgsi_unsupported},
-       /* gap */
        {22,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {23,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_FRC,       0, ALU_OP1_FRACT, tgsi_op2},
@@ -7332,10 +7427,9 @@ static struct r600_shader_tgsi_instruction eg_shader_tgsi_instruction[] = {
        {TGSI_OPCODE_LG2,       0, ALU_OP1_LOG_IEEE, tgsi_trans_srcx_replicate},
        {TGSI_OPCODE_POW,       0, ALU_OP0_NOP, tgsi_pow},
        {TGSI_OPCODE_XPD,       0, ALU_OP0_NOP, tgsi_xpd},
-       /* gap */
        {32,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_ABS,       0, ALU_OP1_MOV, tgsi_op2},
-       {TGSI_OPCODE_RCC,       0, ALU_OP0_NOP, tgsi_unsupported},
+       {34,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_DPH,       0, ALU_OP2_DOT4, tgsi_dp},
        {TGSI_OPCODE_COS,       0, ALU_OP1_COS, tgsi_trig},
        {TGSI_OPCODE_DDX,       0, FETCH_OP_GET_GRADIENTS_H, tgsi_tex},
@@ -7345,14 +7439,14 @@ static struct r600_shader_tgsi_instruction eg_shader_tgsi_instruction[] = {
        {TGSI_OPCODE_PK2US,     0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_PK4B,      0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_PK4UB,     0, ALU_OP0_NOP, tgsi_unsupported},
-       {TGSI_OPCODE_RFL,       0, ALU_OP0_NOP, tgsi_unsupported},
+       {44,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_SEQ,       0, ALU_OP2_SETE, tgsi_op2},
-       {TGSI_OPCODE_SFL,       0, ALU_OP0_NOP, tgsi_unsupported},
+       {46,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_SGT,       0, ALU_OP2_SETGT, tgsi_op2},
        {TGSI_OPCODE_SIN,       0, ALU_OP1_SIN, tgsi_trig},
        {TGSI_OPCODE_SLE,       0, ALU_OP2_SETGE, tgsi_op2_swap},
        {TGSI_OPCODE_SNE,       0, ALU_OP2_SETNE, tgsi_op2},
-       {TGSI_OPCODE_STR,       0, ALU_OP0_NOP, tgsi_unsupported},
+       {51,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_TEX,       0, FETCH_OP_SAMPLE, tgsi_tex},
        {TGSI_OPCODE_TXD,       0, FETCH_OP_SAMPLE_G, tgsi_tex},
        {TGSI_OPCODE_TXP,       0, FETCH_OP_SAMPLE, tgsi_tex},
@@ -7360,17 +7454,17 @@ static struct r600_shader_tgsi_instruction eg_shader_tgsi_instruction[] = {
        {TGSI_OPCODE_UP2US,     0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_UP4B,      0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_UP4UB,     0, ALU_OP0_NOP, tgsi_unsupported},
-       {TGSI_OPCODE_X2D,       0, ALU_OP0_NOP, tgsi_unsupported},
-       {TGSI_OPCODE_ARA,       0, ALU_OP0_NOP, tgsi_unsupported},
+       {59,                    0, ALU_OP0_NOP, tgsi_unsupported},
+       {60,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_ARR,       0, ALU_OP0_NOP, tgsi_eg_arl},
-       {TGSI_OPCODE_BRA,       0, ALU_OP0_NOP, tgsi_unsupported},
+       {62,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_CAL,       0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_RET,       0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_SSG,       0, ALU_OP0_NOP, tgsi_ssg},
        {TGSI_OPCODE_CMP,       0, ALU_OP0_NOP, tgsi_cmp},
        {TGSI_OPCODE_SCS,       0, ALU_OP0_NOP, tgsi_scs},
        {TGSI_OPCODE_TXB,       0, FETCH_OP_SAMPLE_LB, tgsi_tex},
-       {TGSI_OPCODE_NRM,       0, ALU_OP0_NOP, tgsi_unsupported},
+       {69,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_DIV,       0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_DP2,       0, ALU_OP2_DOT4, tgsi_dp},
        {TGSI_OPCODE_TXL,       0, FETCH_OP_SAMPLE_L, tgsi_tex},
@@ -7389,7 +7483,6 @@ static struct r600_shader_tgsi_instruction eg_shader_tgsi_instruction[] = {
        {TGSI_OPCODE_NOT,       0, ALU_OP1_NOT_INT, tgsi_op2},
        {TGSI_OPCODE_TRUNC,     0, ALU_OP1_TRUNC, tgsi_op2},
        {TGSI_OPCODE_SHL,       0, ALU_OP2_LSHL_INT, tgsi_op2},
-       /* gap */
        {88,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_AND,       0, ALU_OP2_AND_INT, tgsi_op2},
        {TGSI_OPCODE_OR,        0, ALU_OP2_OR_INT, tgsi_op2},
@@ -7406,7 +7499,6 @@ static struct r600_shader_tgsi_instruction eg_shader_tgsi_instruction[] = {
        {TGSI_OPCODE_ENDLOOP,   0, ALU_OP0_NOP, tgsi_endloop},
        {TGSI_OPCODE_ENDSUB,    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_TXQ_LZ,    0, FETCH_OP_GET_TEXTURE_RESINFO, tgsi_tex},
-       /* gap */
        {104,                   0, ALU_OP0_NOP, tgsi_unsupported},
        {105,                   0, ALU_OP0_NOP, tgsi_unsupported},
        {106,                   0, ALU_OP0_NOP, tgsi_unsupported},
@@ -7415,14 +7507,12 @@ static struct r600_shader_tgsi_instruction eg_shader_tgsi_instruction[] = {
        {TGSI_OPCODE_FSGE,      0, ALU_OP2_SETGE_DX10, tgsi_op2},
        {TGSI_OPCODE_FSLT,      0, ALU_OP2_SETGT_DX10, tgsi_op2_swap},
        {TGSI_OPCODE_FSNE,      0, ALU_OP2_SETNE_DX10, tgsi_op2_swap},
-       {TGSI_OPCODE_NRM4,      0, ALU_OP0_NOP, tgsi_unsupported},
+       {112,                   0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_CALLNZ,    0, ALU_OP0_NOP, tgsi_unsupported},
-       /* gap */
        {114,                   0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_BREAKC,    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_KILL_IF,   0, ALU_OP2_KILLGT, tgsi_kill},  /* conditional kill */
        {TGSI_OPCODE_END,       0, ALU_OP0_NOP, tgsi_end},  /* aka HALT */
-       /* gap */
        {118,                   0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_F2I,       0, ALU_OP1_FLT_TO_INT, tgsi_f2i},
        {TGSI_OPCODE_IDIV,      0, ALU_OP0_NOP, tgsi_idiv},
@@ -7523,10 +7613,9 @@ static struct r600_shader_tgsi_instruction cm_shader_tgsi_instruction[] = {
        {TGSI_OPCODE_MAD,       1, ALU_OP3_MULADD, tgsi_op3},
        {TGSI_OPCODE_SUB,       0, ALU_OP2_ADD, tgsi_op2},
        {TGSI_OPCODE_LRP,       0, ALU_OP0_NOP, tgsi_lrp},
-       {TGSI_OPCODE_CND,       0, ALU_OP0_NOP, tgsi_unsupported},
+       {19,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_SQRT,      0, ALU_OP1_SQRT_IEEE, cayman_emit_float_instr},
        {TGSI_OPCODE_DP2A,      0, ALU_OP0_NOP, tgsi_unsupported},
-       /* gap */
        {22,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {23,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_FRC,       0, ALU_OP1_FRACT, tgsi_op2},
@@ -7537,10 +7626,9 @@ static struct r600_shader_tgsi_instruction cm_shader_tgsi_instruction[] = {
        {TGSI_OPCODE_LG2,       0, ALU_OP1_LOG_IEEE, cayman_emit_float_instr},
        {TGSI_OPCODE_POW,       0, ALU_OP0_NOP, cayman_pow},
        {TGSI_OPCODE_XPD,       0, ALU_OP0_NOP, tgsi_xpd},
-       /* gap */
        {32,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_ABS,       0, ALU_OP1_MOV, tgsi_op2},
-       {TGSI_OPCODE_RCC,       0, ALU_OP0_NOP, tgsi_unsupported},
+       {34,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_DPH,       0, ALU_OP2_DOT4, tgsi_dp},
        {TGSI_OPCODE_COS,       0, ALU_OP1_COS, cayman_trig},
        {TGSI_OPCODE_DDX,       0, FETCH_OP_GET_GRADIENTS_H, tgsi_tex},
@@ -7550,14 +7638,14 @@ static struct r600_shader_tgsi_instruction cm_shader_tgsi_instruction[] = {
        {TGSI_OPCODE_PK2US,     0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_PK4B,      0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_PK4UB,     0, ALU_OP0_NOP, tgsi_unsupported},
-       {TGSI_OPCODE_RFL,       0, ALU_OP0_NOP, tgsi_unsupported},
+       {44,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_SEQ,       0, ALU_OP2_SETE, tgsi_op2},
-       {TGSI_OPCODE_SFL,       0, ALU_OP0_NOP, tgsi_unsupported},
+       {46,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_SGT,       0, ALU_OP2_SETGT, tgsi_op2},
        {TGSI_OPCODE_SIN,       0, ALU_OP1_SIN, cayman_trig},
        {TGSI_OPCODE_SLE,       0, ALU_OP2_SETGE, tgsi_op2_swap},
        {TGSI_OPCODE_SNE,       0, ALU_OP2_SETNE, tgsi_op2},
-       {TGSI_OPCODE_STR,       0, ALU_OP0_NOP, tgsi_unsupported},
+       {51,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_TEX,       0, FETCH_OP_SAMPLE, tgsi_tex},
        {TGSI_OPCODE_TXD,       0, FETCH_OP_SAMPLE_G, tgsi_tex},
        {TGSI_OPCODE_TXP,       0, FETCH_OP_SAMPLE, tgsi_tex},
@@ -7565,17 +7653,17 @@ static struct r600_shader_tgsi_instruction cm_shader_tgsi_instruction[] = {
        {TGSI_OPCODE_UP2US,     0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_UP4B,      0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_UP4UB,     0, ALU_OP0_NOP, tgsi_unsupported},
-       {TGSI_OPCODE_X2D,       0, ALU_OP0_NOP, tgsi_unsupported},
-       {TGSI_OPCODE_ARA,       0, ALU_OP0_NOP, tgsi_unsupported},
+       {59,                    0, ALU_OP0_NOP, tgsi_unsupported},
+       {60,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_ARR,       0, ALU_OP0_NOP, tgsi_eg_arl},
-       {TGSI_OPCODE_BRA,       0, ALU_OP0_NOP, tgsi_unsupported},
+       {62,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_CAL,       0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_RET,       0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_SSG,       0, ALU_OP0_NOP, tgsi_ssg},
        {TGSI_OPCODE_CMP,       0, ALU_OP0_NOP, tgsi_cmp},
        {TGSI_OPCODE_SCS,       0, ALU_OP0_NOP, tgsi_scs},
        {TGSI_OPCODE_TXB,       0, FETCH_OP_SAMPLE_LB, tgsi_tex},
-       {TGSI_OPCODE_NRM,       0, ALU_OP0_NOP, tgsi_unsupported},
+       {69,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_DIV,       0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_DP2,       0, ALU_OP2_DOT4, tgsi_dp},
        {TGSI_OPCODE_TXL,       0, FETCH_OP_SAMPLE_L, tgsi_tex},
@@ -7594,7 +7682,6 @@ static struct r600_shader_tgsi_instruction cm_shader_tgsi_instruction[] = {
        {TGSI_OPCODE_NOT,       0, ALU_OP1_NOT_INT, tgsi_op2},
        {TGSI_OPCODE_TRUNC,     0, ALU_OP1_TRUNC, tgsi_op2},
        {TGSI_OPCODE_SHL,       0, ALU_OP2_LSHL_INT, tgsi_op2},
-       /* gap */
        {88,                    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_AND,       0, ALU_OP2_AND_INT, tgsi_op2},
        {TGSI_OPCODE_OR,        0, ALU_OP2_OR_INT, tgsi_op2},
@@ -7611,24 +7698,20 @@ static struct r600_shader_tgsi_instruction cm_shader_tgsi_instruction[] = {
        {TGSI_OPCODE_ENDLOOP,   0, ALU_OP0_NOP, tgsi_endloop},
        {TGSI_OPCODE_ENDSUB,    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_TXQ_LZ,    0, FETCH_OP_GET_TEXTURE_RESINFO, tgsi_tex},
-       /* gap */
        {104,                   0, ALU_OP0_NOP, tgsi_unsupported},
        {105,                   0, ALU_OP0_NOP, tgsi_unsupported},
        {106,                   0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_NOP,       0, ALU_OP0_NOP, tgsi_unsupported},
-       /* gap */
        {TGSI_OPCODE_FSEQ,      0, ALU_OP2_SETE_DX10, tgsi_op2},
        {TGSI_OPCODE_FSGE,      0, ALU_OP2_SETGE_DX10, tgsi_op2},
        {TGSI_OPCODE_FSLT,      0, ALU_OP2_SETGT_DX10, tgsi_op2_swap},
        {TGSI_OPCODE_FSNE,      0, ALU_OP2_SETNE_DX10, tgsi_op2_swap},
-       {TGSI_OPCODE_NRM4,      0, ALU_OP0_NOP, tgsi_unsupported},
+       {112,                   0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_CALLNZ,    0, ALU_OP0_NOP, tgsi_unsupported},
-       /* gap */
        {114,                   0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_BREAKC,    0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_KILL_IF,   0, ALU_OP2_KILLGT, tgsi_kill},  /* conditional kill */
        {TGSI_OPCODE_END,       0, ALU_OP0_NOP, tgsi_end},  /* aka HALT */
-       /* gap */
        {118,                   0, ALU_OP0_NOP, tgsi_unsupported},
        {TGSI_OPCODE_F2I,       0, ALU_OP1_FLT_TO_INT, tgsi_op2},
        {TGSI_OPCODE_IDIV,      0, ALU_OP0_NOP, tgsi_idiv},