freedreno/ir3: convert dynamic arrays to ralloc
authorRob Clark <robdclark@gmail.com>
Wed, 5 Apr 2017 00:22:57 +0000 (20:22 -0400)
committerRob Clark <robdclark@gmail.com>
Fri, 14 Apr 2017 16:46:12 +0000 (12:46 -0400)
Want to move one of these under ir3_block, so that gives a reason to
migrate the remaining malloc/realloc to ralloc.

Signed-off-by: Rob Clark <robdclark@gmail.com>
src/gallium/drivers/freedreno/ir3/ir3.c
src/gallium/drivers/freedreno/ir3/ir3.h
src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c

index 7c925ee7cb07017cec470b9c97a60494fdd824a0..c5a030282d8f832ef172c7ede24eb22b358cfdfd 100644 (file)
@@ -63,12 +63,6 @@ struct ir3 * ir3_create(struct ir3_compiler *compiler,
 
 void ir3_destroy(struct ir3 *shader)
 {
-       /* TODO convert the dynamic array to ralloc too: */
-       free(shader->indirects);
-       free(shader->predicates);
-       free(shader->baryfs);
-       free(shader->keeps);
-       free(shader->astc_srgb);
        ralloc_free(shader);
 }
 
@@ -626,7 +620,7 @@ static void insert_instr(struct ir3_block *block,
        list_addtail(&instr->node, &block->instr_list);
 
        if (is_input(instr))
-               array_insert(shader->baryfs, instr);
+               array_insert(shader, shader->baryfs, instr);
 }
 
 struct ir3_block * ir3_block_create(struct ir3 *shader)
@@ -729,7 +723,7 @@ ir3_instr_set_address(struct ir3_instruction *instr,
        if (instr->address != addr) {
                struct ir3 *ir = instr->block->shader;
                instr->address = addr;
-               array_insert(ir->indirects, instr);
+               array_insert(ir, ir->indirects, instr);
        }
 }
 
index e0d0eeebc815110c02812ebaa53d4fff363d8acb..c205c8fac48d66d820cf75ce815a5f0aea59e63f 100644 (file)
@@ -854,10 +854,10 @@ static inline unsigned ir3_cat3_absneg(opc_t opc)
        }
 }
 
-#define array_insert(arr, val) do { \
+#define array_insert(ctx, arr, val) do { \
                if (arr ## _count == arr ## _sz) { \
                        arr ## _sz = MAX2(2 * arr ## _sz, 16); \
-                       arr = realloc(arr, arr ## _sz * sizeof(arr[0])); \
+                       arr = reralloc_size(ctx, arr, arr ## _sz * sizeof(arr[0])); \
                } \
                arr[arr ##_count++] = val; \
        } while (0)
index fd4a1d6eccebf4010c1ddfd8e8a8579c5007f4c8..7932a6f18a37a2d2cd66f3e6dcff5b4dc44de21f 100644 (file)
@@ -1306,9 +1306,9 @@ emit_intrinsic(struct ir3_compile *ctx, nir_intrinsic_instr *intr)
                cond->regs[0]->num = regid(REG_P0, 0);
 
                kill = ir3_KILL(b, cond, 0);
-               array_insert(ctx->ir->predicates, kill);
+               array_insert(ctx->ir, ctx->ir->predicates, kill);
 
-               array_insert(ctx->ir->keeps, kill);
+               array_insert(ctx->ir, ctx->ir->keeps, kill);
                ctx->so->has_kill = true;
 
                break;
@@ -1583,7 +1583,7 @@ emit_tex(struct ir3_compile *ctx, nir_tex_instr *tex)
                sam = ir3_SAM(b, opc, type, TGSI_WRITEMASK_W, flags,
                                tex_idx, tex_idx, col0, col1);
 
-               array_insert(ctx->ir->astc_srgb, sam);
+               array_insert(ctx->ir, ctx->ir->astc_srgb, sam);
 
                /* fixup .w component: */
                split_dest(b, &dst[3], sam, 3, 1);
@@ -1972,7 +1972,7 @@ emit_stream_out(struct ir3_compile *ctx)
                        stg->cat6.type = TYPE_U32;
                        stg->cat6.dst_offset = (strmout->output[i].dst_offset + j) * 4;
 
-                       array_insert(ctx->ir->keeps, stg);
+                       array_insert(ctx->ir, ctx->ir->keeps, stg);
                }
        }