r300/compiler: Use memory_pool_array_reserve in deadcode elimination
[mesa.git] / src / mesa / drivers / dri / r300 / compiler / radeon_dataflow_deadcode.c
index e0c66c4aeb06bc0caf0154bfd738c17c93b46b3f..e3c2c83c0cfba29da029b589f4a0f659f84d2799 100644 (file)
@@ -80,19 +80,8 @@ static void or_updatemasks(
 
 static void push_branch(struct deadcode_state * s)
 {
-       if (s->BranchStackSize >= s->BranchStackReserved) {
-               unsigned int new_reserve = 2 * s->BranchStackReserved;
-               struct branchinfo * new_stack;
-
-               if (!new_reserve)
-                       new_reserve = 4;
-
-               new_stack = memory_pool_malloc(&s->C->Pool, new_reserve * sizeof(struct branchinfo));
-               memcpy(new_stack, s->BranchStack, s->BranchStackSize * sizeof(struct branchinfo));
-
-               s->BranchStack = new_stack;
-               s->BranchStackReserved = new_reserve;
-       }
+       memory_pool_array_reserve(&s->C->Pool, struct branchinfo, s->BranchStack,
+                       s->BranchStackSize, s->BranchStackReserved, 1);
 
        struct branchinfo * branch = &s->BranchStack[s->BranchStackSize++];
        branch->HaveElse = 0;
@@ -162,7 +151,7 @@ static void update_instruction(struct deadcode_state * s, struct rc_instruction
        }
 
        unsigned int srcmasks[3];
-       rc_compute_sources_for_writemask(opcode, usedmask, srcmasks);
+       rc_compute_sources_for_writemask(inst, usedmask, srcmasks);
 
        for(unsigned int src = 0; src < opcode->NumSrcRegs; ++src) {
                unsigned int refmask = 0;
@@ -250,7 +239,7 @@ void rc_dataflow_deadcode(struct radeon_compiler * c, rc_dataflow_mark_outputs_f
        for(struct rc_instruction * inst = c->Program.Instructions.Next;
            inst != &c->Program.Instructions;
            inst = inst->Next, ++ip) {
-               const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->U.I.Opcode);\
+               const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->U.I.Opcode);
                int dead = 1;
 
                if (!opcode->HasDstReg) {
@@ -281,7 +270,7 @@ void rc_dataflow_deadcode(struct radeon_compiler * c, rc_dataflow_mark_outputs_f
                else if (inst->U.I.WriteALUResult == RC_ALURESULT_W)
                        usemask |= RC_MASK_W;
 
-               rc_compute_sources_for_writemask(opcode, usemask, srcmasks);
+               rc_compute_sources_for_writemask(inst, usemask, srcmasks);
 
                for(unsigned int src = 0; src < 3; ++src) {
                        for(unsigned int chan = 0; chan < 4; ++chan) {