aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/shader/prog_optimize.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-04-02 14:47:58 +0000
committermarha <marha@users.sourceforge.net>2010-04-02 14:47:58 +0000
commit7933658107276f9d5491f8736a743cf8f8bbd5f2 (patch)
treef2893a761364e7abc9d934e9c5427e5cf5190c7a /mesalib/src/mesa/shader/prog_optimize.c
parent83fa9a9811e2c18cffd83a020757f7fb51ffddaa (diff)
downloadvcxsrv-7933658107276f9d5491f8736a743cf8f8bbd5f2.tar.gz
vcxsrv-7933658107276f9d5491f8736a743cf8f8bbd5f2.tar.bz2
vcxsrv-7933658107276f9d5491f8736a743cf8f8bbd5f2.zip
Updated to following packages:
mesa-7.8
Diffstat (limited to 'mesalib/src/mesa/shader/prog_optimize.c')
-rw-r--r--mesalib/src/mesa/shader/prog_optimize.c81
1 files changed, 40 insertions, 41 deletions
diff --git a/mesalib/src/mesa/shader/prog_optimize.c b/mesalib/src/mesa/shader/prog_optimize.c
index 4fe351251..2941a17da 100644
--- a/mesalib/src/mesa/shader/prog_optimize.c
+++ b/mesalib/src/mesa/shader/prog_optimize.c
@@ -111,7 +111,6 @@ remove_instructions(struct gl_program *prog, const GLboolean *removeFlags)
if (removeCount > 0) {
GLint removeStart = removeEnd - removeCount + 1;
_mesa_delete_instructions(prog, removeStart, removeCount);
- removeStart = removeCount = 0; /* reset removal info */
}
return totalRemoved;
}
@@ -160,7 +159,7 @@ _mesa_consolidate_registers(struct gl_program *prog)
GLuint tempMax = 0, i;
if (dbg) {
- _mesa_printf("Optimize: Begin register consolidation\n");
+ printf("Optimize: Begin register consolidation\n");
}
memset(tempUsed, 0, sizeof(tempUsed));
@@ -197,7 +196,7 @@ _mesa_consolidate_registers(struct gl_program *prog)
for (i = 0; i <= tempMax; i++) {
if (tempUsed[i]) {
tempMap[i] = freeTemp++;
- /*_mesa_printf("replace %u with %u\n", i, tempMap[i]);*/
+ /*printf("replace %u with %u\n", i, tempMap[i]);*/
}
}
if (freeTemp == tempMax + 1) {
@@ -205,14 +204,14 @@ _mesa_consolidate_registers(struct gl_program *prog)
return;
}
if (dbg) {
- _mesa_printf("Replace regs 0..%u with 0..%u\n", tempMax, freeTemp-1);
+ printf("Replace regs 0..%u with 0..%u\n", tempMax, freeTemp-1);
}
}
replace_regs(prog, PROGRAM_TEMPORARY, tempMap);
if (dbg) {
- _mesa_printf("Optimize: End register consolidation\n");
+ printf("Optimize: End register consolidation\n");
}
}
@@ -233,12 +232,12 @@ _mesa_remove_dead_code(struct gl_program *prog)
memset(tempRead, 0, sizeof(tempRead));
if (dbg) {
- _mesa_printf("Optimize: Begin dead code removal\n");
+ printf("Optimize: Begin dead code removal\n");
/*_mesa_print_program(prog);*/
}
removeInst = (GLboolean *)
- _mesa_calloc(prog->NumInstructions * sizeof(GLboolean));
+ calloc(1, prog->NumInstructions * sizeof(GLboolean));
/* Determine which temps are read and written */
for (i = 0; i < prog->NumInstructions; i++) {
@@ -256,7 +255,7 @@ _mesa_remove_dead_code(struct gl_program *prog)
if (inst->SrcReg[j].RelAddr) {
if (dbg)
- _mesa_printf("abort remove dead code (indirect temp)\n");
+ printf("abort remove dead code (indirect temp)\n");
goto done;
}
@@ -291,7 +290,7 @@ _mesa_remove_dead_code(struct gl_program *prog)
if (inst->DstReg.RelAddr) {
if (dbg)
- _mesa_printf("abort remove dead code (indirect temp)\n");
+ printf("abort remove dead code (indirect temp)\n");
goto done;
}
@@ -320,7 +319,7 @@ _mesa_remove_dead_code(struct gl_program *prog)
if (!tempRead[index][chan] &&
inst->DstReg.WriteMask & (1 << chan)) {
if (dbg) {
- _mesa_printf("Remove writemask on %u.%c\n", i,
+ printf("Remove writemask on %u.%c\n", i,
chan == 3 ? 'w' : 'x' + chan);
}
inst->DstReg.WriteMask &= ~(1 << chan);
@@ -331,7 +330,7 @@ _mesa_remove_dead_code(struct gl_program *prog)
if (inst->DstReg.WriteMask == 0) {
/* If we cleared all writes, the instruction can be removed. */
if (dbg)
- _mesa_printf("Remove instruction %u: \n", i);
+ printf("Remove instruction %u: \n", i);
removeInst[i] = GL_TRUE;
}
}
@@ -341,14 +340,14 @@ _mesa_remove_dead_code(struct gl_program *prog)
rem = remove_instructions(prog, removeInst);
if (dbg) {
- _mesa_printf("Optimize: End dead code removal.\n");
- _mesa_printf(" %u channel writes removed\n", rem);
- _mesa_printf(" %u instructions removed\n", rem);
+ printf("Optimize: End dead code removal.\n");
+ printf(" %u channel writes removed\n", rem);
+ printf(" %u instructions removed\n", rem);
/*_mesa_print_program(prog);*/
}
done:
- _mesa_free(removeInst);
+ free(removeInst);
}
@@ -428,7 +427,7 @@ _mesa_remove_extra_move_use(struct gl_program *prog)
GLuint i, j;
if (dbg) {
- _mesa_printf("Optimize: Begin remove extra move use\n");
+ printf("Optimize: Begin remove extra move use\n");
_mesa_print_program(prog);
}
@@ -460,7 +459,7 @@ _mesa_remove_extra_move_use(struct gl_program *prog)
*/
for (j = i + 1; j < prog->NumInstructions; j++) {
struct prog_instruction *inst2 = prog->Instructions + j;
- int arg;
+ GLuint arg;
if (_mesa_is_flow_control_opcode(inst2->Opcode))
break;
@@ -519,7 +518,7 @@ _mesa_remove_extra_move_use(struct gl_program *prog)
}
if (dbg) {
- _mesa_printf("Optimize: End remove extra move use.\n");
+ printf("Optimize: End remove extra move use.\n");
/*_mesa_print_program(prog);*/
}
}
@@ -534,12 +533,12 @@ _mesa_remove_extra_moves(struct gl_program *prog)
GLuint i, rem, loopNesting = 0, subroutineNesting = 0;
if (dbg) {
- _mesa_printf("Optimize: Begin remove extra moves\n");
+ printf("Optimize: Begin remove extra moves\n");
_mesa_print_program(prog);
}
removeInst = (GLboolean *)
- _mesa_calloc(prog->NumInstructions * sizeof(GLboolean));
+ calloc(1, prog->NumInstructions * sizeof(GLboolean));
/*
* Look for sequences such as this:
@@ -578,7 +577,7 @@ _mesa_remove_extra_moves(struct gl_program *prog)
/* get pointer to previous instruction */
prevI = i - 1;
- while (removeInst[prevI] && prevI > 0)
+ while (prevI > 0 && removeInst[prevI])
prevI--;
prevInst = prog->Instructions + prevI;
@@ -606,8 +605,8 @@ _mesa_remove_extra_moves(struct gl_program *prog)
removeInst[i] = GL_TRUE;
if (dbg) {
- _mesa_printf("Remove MOV at %u\n", i);
- _mesa_printf("new prev inst %u: ", prevI);
+ printf("Remove MOV at %u\n", i);
+ printf("new prev inst %u: ", prevI);
_mesa_print_instruction(prevInst);
}
}
@@ -622,10 +621,10 @@ _mesa_remove_extra_moves(struct gl_program *prog)
/* now remove the instructions which aren't needed */
rem = remove_instructions(prog, removeInst);
- _mesa_free(removeInst);
+ free(removeInst);
if (dbg) {
- _mesa_printf("Optimize: End remove extra moves. %u instructions removed\n", rem);
+ printf("Optimize: End remove extra moves. %u instructions removed\n", rem);
/*_mesa_print_program(prog);*/
}
}
@@ -838,7 +837,7 @@ find_live_intervals(struct gl_program *prog,
*/
if (dbg) {
- _mesa_printf("Optimize: Begin find intervals\n");
+ printf("Optimize: Begin find intervals\n");
}
/* build intermediate arrays */
@@ -865,16 +864,16 @@ find_live_intervals(struct gl_program *prog,
/* print interval info */
for (i = 0; i < liveIntervals->Num; i++) {
const struct interval *inv = liveIntervals->Intervals + i;
- _mesa_printf("Reg[%d] live [%d, %d]:",
+ printf("Reg[%d] live [%d, %d]:",
inv->Reg, inv->Start, inv->End);
if (1) {
- int j;
+ GLuint j;
for (j = 0; j < inv->Start; j++)
- _mesa_printf(" ");
+ printf(" ");
for (j = inv->Start; j <= inv->End; j++)
- _mesa_printf("x");
+ printf("x");
}
- _mesa_printf("\n");
+ printf("\n");
}
}
@@ -915,7 +914,7 @@ _mesa_reallocate_registers(struct gl_program *prog)
GLint maxTemp = -1;
if (dbg) {
- _mesa_printf("Optimize: Begin live-interval register reallocation\n");
+ printf("Optimize: Begin live-interval register reallocation\n");
_mesa_print_program(prog);
}
@@ -926,7 +925,7 @@ _mesa_reallocate_registers(struct gl_program *prog)
if (!find_live_intervals(prog, &liveIntervals)) {
if (dbg)
- _mesa_printf("Aborting register reallocation\n");
+ printf("Aborting register reallocation\n");
return;
}
@@ -939,14 +938,14 @@ _mesa_reallocate_registers(struct gl_program *prog)
const struct interval *live = liveIntervals.Intervals + i;
if (dbg)
- _mesa_printf("Consider register %u\n", live->Reg);
+ printf("Consider register %u\n", live->Reg);
/* Expire old intervals. Intervals which have ended with respect
* to the live interval can have their remapped registers freed.
*/
{
GLint j;
- for (j = 0; j < activeIntervals.Num; j++) {
+ for (j = 0; j < (GLint) activeIntervals.Num; j++) {
const struct interval *inv = activeIntervals.Intervals + j;
if (inv->End >= live->Start) {
/* Stop now. Since the activeInterval list is sorted
@@ -960,7 +959,7 @@ _mesa_reallocate_registers(struct gl_program *prog)
ASSERT(regNew >= 0);
if (dbg)
- _mesa_printf(" expire interval for reg %u\n", inv->Reg);
+ printf(" expire interval for reg %u\n", inv->Reg);
/* remove interval j from active list */
remove_interval(&activeIntervals, inv);
@@ -968,7 +967,7 @@ _mesa_reallocate_registers(struct gl_program *prog)
/* return register regNew to the free pool */
if (dbg)
- _mesa_printf(" free reg %d\n", regNew);
+ printf(" free reg %d\n", regNew);
ASSERT(usedRegs[regNew] == GL_TRUE);
usedRegs[regNew] = GL_FALSE;
}
@@ -985,7 +984,7 @@ _mesa_reallocate_registers(struct gl_program *prog)
registerMap[live->Reg] = k;
maxTemp = MAX2(maxTemp, k);
if (dbg)
- _mesa_printf(" remap register %u -> %d\n", live->Reg, k);
+ printf(" remap register %u -> %d\n", live->Reg, k);
}
/* Insert this live interval into the active list which is sorted
@@ -995,7 +994,7 @@ _mesa_reallocate_registers(struct gl_program *prog)
}
}
- if (maxTemp + 1 < liveIntervals.Num) {
+ if (maxTemp + 1 < (GLint) liveIntervals.Num) {
/* OK, we've reduced the number of registers needed.
* Scan the program and replace all the old temporary register
* indexes with the new indexes.
@@ -1006,8 +1005,8 @@ _mesa_reallocate_registers(struct gl_program *prog)
}
if (dbg) {
- _mesa_printf("Optimize: End live-interval register reallocation\n");
- _mesa_printf("Num temp regs before: %u after: %u\n",
+ printf("Optimize: End live-interval register reallocation\n");
+ printf("Num temp regs before: %u after: %u\n",
liveIntervals.Num, maxTemp + 1);
_mesa_print_program(prog);
}