i965: Don't make consumers of brw_CONT/brw_WHILE track if depth in loop.
The codegen backends all had this same tracking, so just do it at the EU level. Reviewed-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
This commit is contained in:
parent
ce6be334bb
commit
f1d89638c0
|
@ -197,6 +197,7 @@ brw_init_compile(struct brw_context *brw, struct brw_compile *p, void *mem_ctx)
|
||||||
p->loop_stack_depth = 0;
|
p->loop_stack_depth = 0;
|
||||||
p->loop_stack_array_size = 16;
|
p->loop_stack_array_size = 16;
|
||||||
p->loop_stack = rzalloc_array(mem_ctx, int, p->loop_stack_array_size);
|
p->loop_stack = rzalloc_array(mem_ctx, int, p->loop_stack_array_size);
|
||||||
|
p->if_depth_in_loop = rzalloc_array(mem_ctx, int, p->loop_stack_array_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -134,6 +134,12 @@ struct brw_compile {
|
||||||
* encountered.
|
* encountered.
|
||||||
*/
|
*/
|
||||||
int *loop_stack;
|
int *loop_stack;
|
||||||
|
/**
|
||||||
|
* pre-gen6, the BREAK and CONT instructions had to tell how many IF/ENDIF
|
||||||
|
* blocks they were popping out of, to fix up the mask stack. This tracks
|
||||||
|
* the IF/ENDIF nesting in each current nested loop level.
|
||||||
|
*/
|
||||||
|
int *if_depth_in_loop;
|
||||||
int loop_stack_depth;
|
int loop_stack_depth;
|
||||||
int loop_stack_array_size;
|
int loop_stack_array_size;
|
||||||
|
|
||||||
|
@ -1026,8 +1032,8 @@ struct brw_instruction *brw_DO(struct brw_compile *p,
|
||||||
|
|
||||||
struct brw_instruction *brw_WHILE(struct brw_compile *p);
|
struct brw_instruction *brw_WHILE(struct brw_compile *p);
|
||||||
|
|
||||||
struct brw_instruction *brw_BREAK(struct brw_compile *p, int pop_count);
|
struct brw_instruction *brw_BREAK(struct brw_compile *p);
|
||||||
struct brw_instruction *brw_CONT(struct brw_compile *p, int pop_count);
|
struct brw_instruction *brw_CONT(struct brw_compile *p);
|
||||||
struct brw_instruction *gen6_CONT(struct brw_compile *p);
|
struct brw_instruction *gen6_CONT(struct brw_compile *p);
|
||||||
/* Forward jumps:
|
/* Forward jumps:
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -918,10 +918,13 @@ push_loop_stack(struct brw_compile *p, struct brw_instruction *inst)
|
||||||
p->loop_stack_array_size *= 2;
|
p->loop_stack_array_size *= 2;
|
||||||
p->loop_stack = reralloc(p->mem_ctx, p->loop_stack, int,
|
p->loop_stack = reralloc(p->mem_ctx, p->loop_stack, int,
|
||||||
p->loop_stack_array_size);
|
p->loop_stack_array_size);
|
||||||
|
p->if_depth_in_loop = reralloc(p->mem_ctx, p->if_depth_in_loop, int,
|
||||||
|
p->loop_stack_array_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
p->loop_stack[p->loop_stack_depth] = inst - p->store;
|
p->loop_stack[p->loop_stack_depth] = inst - p->store;
|
||||||
p->loop_stack_depth++;
|
p->loop_stack_depth++;
|
||||||
|
p->if_depth_in_loop[p->loop_stack_depth] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct brw_instruction *
|
static struct brw_instruction *
|
||||||
|
@ -980,6 +983,7 @@ brw_IF(struct brw_compile *p, GLuint execute_size)
|
||||||
p->current->header.predicate_control = BRW_PREDICATE_NONE;
|
p->current->header.predicate_control = BRW_PREDICATE_NONE;
|
||||||
|
|
||||||
push_if_stack(p, insn);
|
push_if_stack(p, insn);
|
||||||
|
p->if_depth_in_loop[p->loop_stack_depth]++;
|
||||||
return insn;
|
return insn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1187,6 +1191,7 @@ brw_ENDIF(struct brw_compile *p)
|
||||||
struct brw_instruction *if_inst = NULL;
|
struct brw_instruction *if_inst = NULL;
|
||||||
|
|
||||||
/* Pop the IF and (optional) ELSE instructions from the stack */
|
/* Pop the IF and (optional) ELSE instructions from the stack */
|
||||||
|
p->if_depth_in_loop[p->loop_stack_depth]--;
|
||||||
p->if_stack_depth--;
|
p->if_stack_depth--;
|
||||||
if (p->if_stack[p->if_stack_depth]->header.opcode == BRW_OPCODE_ELSE) {
|
if (p->if_stack[p->if_stack_depth]->header.opcode == BRW_OPCODE_ELSE) {
|
||||||
else_inst = p->if_stack[p->if_stack_depth];
|
else_inst = p->if_stack[p->if_stack_depth];
|
||||||
|
@ -1245,7 +1250,7 @@ brw_ENDIF(struct brw_compile *p)
|
||||||
patch_IF_ELSE(p, if_inst, else_inst, insn);
|
patch_IF_ELSE(p, if_inst, else_inst, insn);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct brw_instruction *brw_BREAK(struct brw_compile *p, int pop_count)
|
struct brw_instruction *brw_BREAK(struct brw_compile *p)
|
||||||
{
|
{
|
||||||
struct intel_context *intel = &p->brw->intel;
|
struct intel_context *intel = &p->brw->intel;
|
||||||
struct brw_instruction *insn;
|
struct brw_instruction *insn;
|
||||||
|
@ -1260,7 +1265,7 @@ struct brw_instruction *brw_BREAK(struct brw_compile *p, int pop_count)
|
||||||
brw_set_src0(p, insn, brw_ip_reg());
|
brw_set_src0(p, insn, brw_ip_reg());
|
||||||
brw_set_src1(p, insn, brw_imm_d(0x0));
|
brw_set_src1(p, insn, brw_imm_d(0x0));
|
||||||
insn->bits3.if_else.pad0 = 0;
|
insn->bits3.if_else.pad0 = 0;
|
||||||
insn->bits3.if_else.pop_count = pop_count;
|
insn->bits3.if_else.pop_count = p->if_depth_in_loop[p->loop_stack_depth];
|
||||||
}
|
}
|
||||||
insn->header.compression_control = BRW_COMPRESSION_NONE;
|
insn->header.compression_control = BRW_COMPRESSION_NONE;
|
||||||
insn->header.execution_size = BRW_EXECUTE_8;
|
insn->header.execution_size = BRW_EXECUTE_8;
|
||||||
|
@ -1284,7 +1289,7 @@ struct brw_instruction *gen6_CONT(struct brw_compile *p)
|
||||||
return insn;
|
return insn;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct brw_instruction *brw_CONT(struct brw_compile *p, int pop_count)
|
struct brw_instruction *brw_CONT(struct brw_compile *p)
|
||||||
{
|
{
|
||||||
struct brw_instruction *insn;
|
struct brw_instruction *insn;
|
||||||
insn = next_insn(p, BRW_OPCODE_CONTINUE);
|
insn = next_insn(p, BRW_OPCODE_CONTINUE);
|
||||||
|
@ -1295,7 +1300,7 @@ struct brw_instruction *brw_CONT(struct brw_compile *p, int pop_count)
|
||||||
insn->header.execution_size = BRW_EXECUTE_8;
|
insn->header.execution_size = BRW_EXECUTE_8;
|
||||||
/* insn->header.mask_control = BRW_MASK_DISABLE; */
|
/* insn->header.mask_control = BRW_MASK_DISABLE; */
|
||||||
insn->bits3.if_else.pad0 = 0;
|
insn->bits3.if_else.pad0 = 0;
|
||||||
insn->bits3.if_else.pop_count = pop_count;
|
insn->bits3.if_else.pop_count = p->if_depth_in_loop[p->loop_stack_depth];
|
||||||
return insn;
|
return insn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -656,12 +656,6 @@ fs_visitor::generate_code()
|
||||||
const char *last_annotation_string = NULL;
|
const char *last_annotation_string = NULL;
|
||||||
ir_instruction *last_annotation_ir = NULL;
|
ir_instruction *last_annotation_ir = NULL;
|
||||||
|
|
||||||
int loop_stack_array_size = 16;
|
|
||||||
int loop_stack_depth = 0;
|
|
||||||
int *if_depth_in_loop =
|
|
||||||
rzalloc_array(this->mem_ctx, int, loop_stack_array_size);
|
|
||||||
|
|
||||||
|
|
||||||
if (unlikely(INTEL_DEBUG & DEBUG_WM)) {
|
if (unlikely(INTEL_DEBUG & DEBUG_WM)) {
|
||||||
printf("Native code for fragment shader %d (%d-wide dispatch):\n",
|
printf("Native code for fragment shader %d (%d-wide dispatch):\n",
|
||||||
prog->Name, c->dispatch_width);
|
prog->Name, c->dispatch_width);
|
||||||
|
@ -781,7 +775,6 @@ fs_visitor::generate_code()
|
||||||
} else {
|
} else {
|
||||||
brw_IF(p, c->dispatch_width == 16 ? BRW_EXECUTE_16 : BRW_EXECUTE_8);
|
brw_IF(p, c->dispatch_width == 16 ? BRW_EXECUTE_16 : BRW_EXECUTE_8);
|
||||||
}
|
}
|
||||||
if_depth_in_loop[loop_stack_depth]++;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BRW_OPCODE_ELSE:
|
case BRW_OPCODE_ELSE:
|
||||||
|
@ -789,22 +782,14 @@ fs_visitor::generate_code()
|
||||||
break;
|
break;
|
||||||
case BRW_OPCODE_ENDIF:
|
case BRW_OPCODE_ENDIF:
|
||||||
brw_ENDIF(p);
|
brw_ENDIF(p);
|
||||||
if_depth_in_loop[loop_stack_depth]--;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BRW_OPCODE_DO:
|
case BRW_OPCODE_DO:
|
||||||
brw_DO(p, BRW_EXECUTE_8);
|
brw_DO(p, BRW_EXECUTE_8);
|
||||||
loop_stack_depth++;
|
|
||||||
if (loop_stack_array_size <= loop_stack_depth) {
|
|
||||||
loop_stack_array_size *= 2;
|
|
||||||
if_depth_in_loop = reralloc(this->mem_ctx, if_depth_in_loop, int,
|
|
||||||
loop_stack_array_size);
|
|
||||||
}
|
|
||||||
if_depth_in_loop[loop_stack_depth] = 0;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BRW_OPCODE_BREAK:
|
case BRW_OPCODE_BREAK:
|
||||||
brw_BREAK(p, if_depth_in_loop[loop_stack_depth]);
|
brw_BREAK(p);
|
||||||
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
|
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
|
||||||
break;
|
break;
|
||||||
case BRW_OPCODE_CONTINUE:
|
case BRW_OPCODE_CONTINUE:
|
||||||
|
@ -812,13 +797,11 @@ fs_visitor::generate_code()
|
||||||
if (intel->gen >= 6)
|
if (intel->gen >= 6)
|
||||||
gen6_CONT(p);
|
gen6_CONT(p);
|
||||||
else
|
else
|
||||||
brw_CONT(p, if_depth_in_loop[loop_stack_depth]);
|
brw_CONT(p);
|
||||||
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
|
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BRW_OPCODE_WHILE:
|
case BRW_OPCODE_WHILE:
|
||||||
assert(loop_stack_depth > 0);
|
|
||||||
loop_stack_depth--;
|
|
||||||
brw_WHILE(p);
|
brw_WHILE(p);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -923,8 +906,6 @@ fs_visitor::generate_code()
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
ralloc_free(if_depth_in_loop);
|
|
||||||
|
|
||||||
brw_set_uip_jip(p);
|
brw_set_uip_jip(p);
|
||||||
|
|
||||||
/* OK, while the INTEL_DEBUG=wm above is very nice for debugging FS
|
/* OK, while the INTEL_DEBUG=wm above is very nice for debugging FS
|
||||||
|
|
|
@ -798,12 +798,6 @@ vec4_visitor::generate_code()
|
||||||
const char *last_annotation_string = NULL;
|
const char *last_annotation_string = NULL;
|
||||||
ir_instruction *last_annotation_ir = NULL;
|
ir_instruction *last_annotation_ir = NULL;
|
||||||
|
|
||||||
int loop_stack_array_size = 16;
|
|
||||||
int loop_stack_depth = 0;
|
|
||||||
int *if_depth_in_loop =
|
|
||||||
rzalloc_array(this->mem_ctx, int, loop_stack_array_size);
|
|
||||||
|
|
||||||
|
|
||||||
if (unlikely(INTEL_DEBUG & DEBUG_VS)) {
|
if (unlikely(INTEL_DEBUG & DEBUG_VS)) {
|
||||||
printf("Native code for vertex shader %d:\n", prog->Name);
|
printf("Native code for vertex shader %d:\n", prog->Name);
|
||||||
}
|
}
|
||||||
|
@ -917,7 +911,6 @@ vec4_visitor::generate_code()
|
||||||
struct brw_instruction *brw_inst = brw_IF(p, BRW_EXECUTE_8);
|
struct brw_instruction *brw_inst = brw_IF(p, BRW_EXECUTE_8);
|
||||||
brw_inst->header.predicate_control = inst->predicate;
|
brw_inst->header.predicate_control = inst->predicate;
|
||||||
}
|
}
|
||||||
if_depth_in_loop[loop_stack_depth]++;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BRW_OPCODE_ELSE:
|
case BRW_OPCODE_ELSE:
|
||||||
|
@ -925,22 +918,14 @@ vec4_visitor::generate_code()
|
||||||
break;
|
break;
|
||||||
case BRW_OPCODE_ENDIF:
|
case BRW_OPCODE_ENDIF:
|
||||||
brw_ENDIF(p);
|
brw_ENDIF(p);
|
||||||
if_depth_in_loop[loop_stack_depth]--;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BRW_OPCODE_DO:
|
case BRW_OPCODE_DO:
|
||||||
brw_DO(p, BRW_EXECUTE_8);
|
brw_DO(p, BRW_EXECUTE_8);
|
||||||
loop_stack_depth++;
|
|
||||||
if (loop_stack_array_size <= loop_stack_depth) {
|
|
||||||
loop_stack_array_size *= 2;
|
|
||||||
if_depth_in_loop = reralloc(this->mem_ctx, if_depth_in_loop, int,
|
|
||||||
loop_stack_array_size);
|
|
||||||
}
|
|
||||||
if_depth_in_loop[loop_stack_depth] = 0;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BRW_OPCODE_BREAK:
|
case BRW_OPCODE_BREAK:
|
||||||
brw_BREAK(p, if_depth_in_loop[loop_stack_depth]);
|
brw_BREAK(p);
|
||||||
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
|
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
|
||||||
break;
|
break;
|
||||||
case BRW_OPCODE_CONTINUE:
|
case BRW_OPCODE_CONTINUE:
|
||||||
|
@ -948,13 +933,11 @@ vec4_visitor::generate_code()
|
||||||
if (intel->gen >= 6)
|
if (intel->gen >= 6)
|
||||||
gen6_CONT(p);
|
gen6_CONT(p);
|
||||||
else
|
else
|
||||||
brw_CONT(p, if_depth_in_loop[loop_stack_depth]);
|
brw_CONT(p);
|
||||||
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
|
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BRW_OPCODE_WHILE:
|
case BRW_OPCODE_WHILE:
|
||||||
assert(loop_stack_depth > 0);
|
|
||||||
loop_stack_depth--;
|
|
||||||
brw_WHILE(p);
|
brw_WHILE(p);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -983,8 +966,6 @@ vec4_visitor::generate_code()
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
ralloc_free(if_depth_in_loop);
|
|
||||||
|
|
||||||
brw_set_uip_jip(p);
|
brw_set_uip_jip(p);
|
||||||
|
|
||||||
/* OK, while the INTEL_DEBUG=vs above is very nice for debugging VS
|
/* OK, while the INTEL_DEBUG=vs above is very nice for debugging VS
|
||||||
|
|
|
@ -1843,8 +1843,7 @@ void brw_old_vs_emit(struct brw_vs_compile *c )
|
||||||
struct brw_context *brw = p->brw;
|
struct brw_context *brw = p->brw;
|
||||||
struct intel_context *intel = &brw->intel;
|
struct intel_context *intel = &brw->intel;
|
||||||
const GLuint nr_insns = c->vp->program.Base.NumInstructions;
|
const GLuint nr_insns = c->vp->program.Base.NumInstructions;
|
||||||
GLuint insn, loop_depth = 0;
|
GLuint insn;
|
||||||
int if_depth_in_loop[MAX_LOOP_DEPTH];
|
|
||||||
const struct brw_indirect stack_index = brw_indirect(0, 0);
|
const struct brw_indirect stack_index = brw_indirect(0, 0);
|
||||||
GLuint index;
|
GLuint index;
|
||||||
GLuint file;
|
GLuint file;
|
||||||
|
@ -1858,7 +1857,6 @@ void brw_old_vs_emit(struct brw_vs_compile *c )
|
||||||
|
|
||||||
brw_set_compression_control(p, BRW_COMPRESSION_NONE);
|
brw_set_compression_control(p, BRW_COMPRESSION_NONE);
|
||||||
brw_set_access_mode(p, BRW_ALIGN_16);
|
brw_set_access_mode(p, BRW_ALIGN_16);
|
||||||
if_depth_in_loop[loop_depth] = 0;
|
|
||||||
|
|
||||||
brw_set_acc_write_control(p, 1);
|
brw_set_acc_write_control(p, 1);
|
||||||
|
|
||||||
|
@ -2080,7 +2078,6 @@ void brw_old_vs_emit(struct brw_vs_compile *c )
|
||||||
struct brw_instruction *if_inst = brw_IF(p, BRW_EXECUTE_8);
|
struct brw_instruction *if_inst = brw_IF(p, BRW_EXECUTE_8);
|
||||||
/* Note that brw_IF smashes the predicate_control field. */
|
/* Note that brw_IF smashes the predicate_control field. */
|
||||||
if_inst->header.predicate_control = get_predicate(inst);
|
if_inst->header.predicate_control = get_predicate(inst);
|
||||||
if_depth_in_loop[loop_depth]++;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case OPCODE_ELSE:
|
case OPCODE_ELSE:
|
||||||
|
@ -2090,17 +2087,14 @@ void brw_old_vs_emit(struct brw_vs_compile *c )
|
||||||
case OPCODE_ENDIF:
|
case OPCODE_ENDIF:
|
||||||
clear_current_const(c);
|
clear_current_const(c);
|
||||||
brw_ENDIF(p);
|
brw_ENDIF(p);
|
||||||
if_depth_in_loop[loop_depth]--;
|
|
||||||
break;
|
break;
|
||||||
case OPCODE_BGNLOOP:
|
case OPCODE_BGNLOOP:
|
||||||
clear_current_const(c);
|
clear_current_const(c);
|
||||||
brw_DO(p, BRW_EXECUTE_8);
|
brw_DO(p, BRW_EXECUTE_8);
|
||||||
loop_depth++;
|
|
||||||
if_depth_in_loop[loop_depth] = 0;
|
|
||||||
break;
|
break;
|
||||||
case OPCODE_BRK:
|
case OPCODE_BRK:
|
||||||
brw_set_predicate_control(p, get_predicate(inst));
|
brw_set_predicate_control(p, get_predicate(inst));
|
||||||
brw_BREAK(p, if_depth_in_loop[loop_depth]);
|
brw_BREAK(p);
|
||||||
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
|
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
|
||||||
break;
|
break;
|
||||||
case OPCODE_CONT:
|
case OPCODE_CONT:
|
||||||
|
@ -2108,14 +2102,13 @@ void brw_old_vs_emit(struct brw_vs_compile *c )
|
||||||
if (intel->gen >= 6) {
|
if (intel->gen >= 6) {
|
||||||
gen6_CONT(p);
|
gen6_CONT(p);
|
||||||
} else {
|
} else {
|
||||||
brw_CONT(p, if_depth_in_loop[loop_depth]);
|
brw_CONT(p);
|
||||||
}
|
}
|
||||||
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
|
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OPCODE_ENDLOOP:
|
case OPCODE_ENDLOOP:
|
||||||
clear_current_const(c);
|
clear_current_const(c);
|
||||||
loop_depth--;
|
|
||||||
brw_WHILE(p);
|
brw_WHILE(p);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue