exec_list *const ir = shProg->_LinkedShaders[MESA_SHADER_VERTEX]->ir;
unsigned current_index = 0;
- foreach_list(node, ir) {
- const ir_variable *const var = ((ir_instruction *) node)->as_variable();
+ foreach_in_list(ir_instruction, node, ir) {
+ const ir_variable *const var = node->as_variable();
if (!is_active_attrib(var))
continue;
return -1;
exec_list *ir = shProg->_LinkedShaders[MESA_SHADER_VERTEX]->ir;
- foreach_list(node, ir) {
- const ir_variable *const var = ((ir_instruction *) node)->as_variable();
+ foreach_in_list(ir_instruction, node, ir) {
+ const ir_variable *const var = node->as_variable();
/* The extra check against VERT_ATTRIB_GENERIC0 is because
* glGetAttribLocation cannot be used on "conventional" attributes.
exec_list *const ir = shProg->_LinkedShaders[MESA_SHADER_VERTEX]->ir;
unsigned i = 0;
- foreach_list(node, ir) {
- const ir_variable *const var = ((ir_instruction *) node)->as_variable();
+ foreach_in_list(ir_instruction, node, ir) {
+ const ir_variable *const var = node->as_variable();
if (!is_active_attrib(var))
continue;
exec_list *const ir = shProg->_LinkedShaders[MESA_SHADER_VERTEX]->ir;
size_t longest = 0;
- foreach_list(node, ir) {
- const ir_variable *const var = ((ir_instruction *) node)->as_variable();
+ foreach_in_list(ir_instruction, node, ir) {
+ const ir_variable *const var = node->as_variable();
if (var == NULL
|| var->data.mode != ir_var_shader_in
return -1;
exec_list *ir = shProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->ir;
- foreach_list(node, ir) {
- const ir_variable *const var = ((ir_instruction *) node)->as_variable();
+ foreach_in_list(ir_instruction, node, ir) {
+ const ir_variable *const var = node->as_variable();
/* The extra check against FRAG_RESULT_DATA0 is because
* glGetFragDataLocation cannot be used on "conventional" attributes.
return -1;
exec_list *ir = shProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->ir;
- foreach_list(node, ir) {
- const ir_variable *const var = ((ir_instruction *) node)->as_variable();
+ foreach_in_list(ir_instruction, node, ir) {
+ const ir_variable *const var = node->as_variable();
/* The extra check against FRAG_RESULT_DATA0 is because
* glGetFragDataLocation cannot be used on "conventional" attributes.
variable_storage *
ir_to_mesa_visitor::find_variable_storage(const ir_variable *var)
{
- variable_storage *entry;
-
- foreach_list(node, &this->variables) {
- entry = (variable_storage *) node;
-
+ foreach_in_list(variable_storage, entry, &this->variables) {
if (entry->var == var)
return entry;
}
assert(sig);
- foreach_list(node, &sig->body) {
- ir_instruction *ir = (ir_instruction *) node;
-
+ foreach_in_list(ir_instruction, ir, &sig->body) {
ir->accept(this);
}
}
src_reg temp_base = get_temp(ir->type);
dst_reg temp = dst_reg(temp_base);
- foreach_list(node, &ir->components) {
- ir_constant *field_value = (ir_constant *) node;
+ foreach_in_list(ir_constant, field_value, &ir->components) {
int size = type_size(field_value->type);
assert(size > 0);
mesa_instructions[loop_stack[loop_stack_pos]].BranchTarget = i;
break;
case OPCODE_CAL:
- foreach_list(n, &v->function_signatures) {
- function_entry *entry = (function_entry *) n;
-
+ foreach_in_list(function_entry, entry, &v->function_signatures) {
if (entry->sig_id == mesa_instructions[i].BranchTarget) {
mesa_instructions[i].BranchTarget = entry->inst;
break;
{
add_uniform_to_shader add(shader_program, params, sh->Stage);
- foreach_list(node, sh->ir) {
- ir_variable *var = ((ir_instruction *) node)->as_variable();
+ foreach_in_list(ir_instruction, node, sh->ir) {
+ ir_variable *var = node->as_variable();
if ((var == NULL) || (var->data.mode != ir_var_uniform)
|| var->is_in_uniform_block() || (strncmp(var->name, "gl_", 3) == 0))
int *acp_level = rzalloc_array(mem_ctx, int, this->next_temp * 4);
int level = 0;
- foreach_list(node, &this->instructions) {
- ir_to_mesa_instruction *inst = (ir_to_mesa_instruction *) node;
-
+ foreach_in_list(ir_to_mesa_instruction, inst, &this->instructions) {
assert(inst->dst.file != PROGRAM_TEMPORARY
|| inst->dst.index < this->next_temp);
prog->NumTemporaries = v.next_temp;
int num_instructions = 0;
- foreach_list(node, &v.instructions) {
+ foreach_in_list(ir_instruction, node, &v.instructions) {
num_instructions++;
}
*/
mesa_inst = mesa_instructions;
i = 0;
- foreach_list(node, &v.instructions) {
- const ir_to_mesa_instruction *inst = (ir_to_mesa_instruction *) node;
-
+ foreach_in_list(const ir_to_mesa_instruction, inst, &v.instructions) {
mesa_inst->Opcode = inst->op;
mesa_inst->CondUpdate = inst->cond_update;
if (inst->saturate)
/* Search immediate storage to see if we already have an identical
* immediate that we can use instead of adding a duplicate entry.
*/
- foreach_list(node, &this->immediates) {
- entry = (immediate_storage *) node;
-
+ foreach_in_list(immediate_storage, entry, &this->immediates) {
if (entry->size == size &&
entry->type == datatype &&
!memcmp(entry->values, values, size * sizeof(gl_constant_value))) {
glsl_to_tgsi_visitor::find_variable_storage(ir_variable *var)
{
- variable_storage *entry;
-
- foreach_list(node, &this->variables) {
- entry = (variable_storage *) node;
-
+ foreach_in_list(variable_storage, entry, &this->variables) {
if (entry->var == var)
return entry;
}
assert(sig);
- foreach_list(node, &sig->body) {
- ir_instruction *ir = (ir_instruction *) node;
-
+ foreach_in_list(ir_instruction, ir, &sig->body) {
ir->accept(this);
}
}
st_src_reg temp_base = get_temp(ir->type);
st_dst_reg temp = st_dst_reg(temp_base);
- foreach_list(node, &ir->components) {
- ir_constant *field_value = (ir_constant *) node;
+ foreach_in_list(ir_constant, field_value, &ir->components) {
int size = type_size(field_value->type);
assert(size > 0);
entry->bgn_inst = NULL;
/* Allocate storage for all the parameters. */
- foreach_list(node, &sig->parameters) {
- ir_variable *param = (ir_variable *) node;
+ foreach_in_list(ir_variable, param, &sig->parameters) {
variable_storage *storage;
storage = find_variable_storage(param);
{
v->samplers_used = 0;
- foreach_list(node, &v->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
-
+ foreach_in_list(glsl_to_tgsi_instruction, inst, &v->instructions) {
if (is_tex_instruction(inst->op)) {
v->samplers_used |= 1 << inst->sampler;
memset(tempWrites, 0, sizeof(unsigned) * MAX_TEMPS);
memset(outputWrites, 0, sizeof(outputWrites));
- foreach_list(node, &this->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
+ foreach_in_list(glsl_to_tgsi_instruction, inst, &this->instructions) {
unsigned prevWriteMask = 0;
/* Give up if we encounter relative addressing or flow control. */
void
glsl_to_tgsi_visitor::rename_temp_register(int index, int new_index)
{
- foreach_list(node, &this->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
+ foreach_in_list(glsl_to_tgsi_instruction, inst, &this->instructions) {
unsigned j;
for (j=0; j < num_inst_src_regs(inst->op); j++) {
int loop_start = -1; /* index of the first active BGNLOOP (if any) */
unsigned i = 0, j;
- foreach_list(node, &this->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
-
+ foreach_in_list(glsl_to_tgsi_instruction, inst, &this->instructions) {
for (j=0; j < num_inst_src_regs(inst->op); j++) {
if (inst->src[j].file == PROGRAM_TEMPORARY &&
inst->src[j].index == index) {
int loop_start = -1; /* index of the first active BGNLOOP (if any) */
int i = 0;
- foreach_list(node, &this->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
-
+ foreach_in_list(glsl_to_tgsi_instruction, inst, &this->instructions) {
if (inst->dst.file == PROGRAM_TEMPORARY && inst->dst.index == index) {
return (depth == 0) ? i : loop_start;
}
int last = -1; /* index of last instruction that reads the temporary */
unsigned i = 0, j;
- foreach_list(node, &this->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
-
+ foreach_in_list(glsl_to_tgsi_instruction, inst, &this->instructions) {
for (j=0; j < num_inst_src_regs(inst->op); j++) {
if (inst->src[j].file == PROGRAM_TEMPORARY &&
inst->src[j].index == index) {
int last = -1; /* index of last instruction that writes to the temporary */
int i = 0;
- foreach_list(node, &this->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
-
+ foreach_in_list(glsl_to_tgsi_instruction, inst, &this->instructions) {
if (inst->dst.file == PROGRAM_TEMPORARY && inst->dst.index == index)
last = (depth == 0) ? i : -2;
int *acp_level = rzalloc_array(mem_ctx, int, this->next_temp * 4);
int level = 0;
- foreach_list(node, &this->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
-
+ foreach_in_list(glsl_to_tgsi_instruction, inst, &this->instructions) {
assert(inst->dst.file != PROGRAM_TEMPORARY
|| inst->dst.index < this->next_temp);
int level = 0;
int removed = 0;
- foreach_list(node, &this->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
-
+ foreach_in_list(glsl_to_tgsi_instruction, inst, &this->instructions) {
assert(inst->dst.file != PROGRAM_TEMPORARY
|| inst->dst.index < this->next_temp);
/* Now copy the instructions from the original glsl_to_tgsi_visitor into the
* new visitor. */
- foreach_list(node, &original->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
+ foreach_in_list(glsl_to_tgsi_instruction, inst, &original->instructions) {
glsl_to_tgsi_instruction *newinst;
st_src_reg src_regs[3];
/* Now copy the instructions from the original glsl_to_tgsi_visitor into the
* new visitor. */
- foreach_list(node, &original->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
+ foreach_in_list(glsl_to_tgsi_instruction, inst, &original->instructions) {
glsl_to_tgsi_instruction *newinst;
st_src_reg src_regs[3];
goto out;
}
i = 0;
- foreach_list(node, &program->immediates) {
- immediate_storage *imm = (immediate_storage *) node;
+ foreach_in_list(immediate_storage, imm, &program->immediates) {
assert(i < program->num_immediates);
t->immediates[i++] = emit_immediate(t, imm->values, imm->type, imm->size);
}
/* Emit each instruction in turn:
*/
- foreach_list(n, &program->instructions) {
+ foreach_in_list(glsl_to_tgsi_instruction, inst, &program->instructions) {
set_insn_start(t, ureg_get_instruction_number(ureg));
- compile_tgsi_instruction(t, (glsl_to_tgsi_instruction *) n, clamp_color);
+ compile_tgsi_instruction(t, inst, clamp_color);
}
/* Fix up all emitted labels:
do {
progress = GL_FALSE;
- foreach_list(node, &v->function_signatures) {
- function_entry *entry = (function_entry *) node;
-
+ foreach_in_list(function_entry, entry, &v->function_signatures) {
if (!entry->bgn_inst) {
v->current_function = entry;