mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-28 23:20:08 +01:00
ir_reader: Add initial loop support; doesn't yet support break/continue.
This commit is contained in:
parent
451381c220
commit
32b305207c
1 changed files with 30 additions and 0 deletions
|
|
@ -36,6 +36,7 @@ static ir_instruction *read_instruction(_mesa_glsl_parse_state *,
|
|||
s_expression *);
|
||||
static ir_variable *read_declaration(_mesa_glsl_parse_state *, s_list *);
|
||||
static ir_if *read_if(_mesa_glsl_parse_state *, s_list *);
|
||||
static ir_loop *read_loop(_mesa_glsl_parse_state *st, s_list *list);
|
||||
static ir_return *read_return(_mesa_glsl_parse_state *, s_list *);
|
||||
|
||||
static ir_rvalue *read_rvalue(_mesa_glsl_parse_state *, s_expression *);
|
||||
|
|
@ -184,6 +185,8 @@ read_instruction(_mesa_glsl_parse_state *st, s_expression *expr)
|
|||
inst = read_declaration(st, list);
|
||||
} else if (strcmp(tag->value(), "if") == 0) {
|
||||
inst = read_if(st, list);
|
||||
} else if (strcmp(tag->value(), "loop") == 0) {
|
||||
inst = read_loop(st, list);
|
||||
} else if (strcmp(tag->value(), "return") == 0) {
|
||||
inst = read_return(st, list);
|
||||
} else {
|
||||
|
|
@ -296,6 +299,33 @@ read_if(_mesa_glsl_parse_state *st, s_list *list)
|
|||
}
|
||||
|
||||
|
||||
static ir_loop *
|
||||
read_loop(_mesa_glsl_parse_state *st, s_list *list)
|
||||
{
|
||||
if (list->length() != 6) {
|
||||
ir_read_error(list, "expected (loop <counter> <from> <to> <increment> "
|
||||
"<body>)");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
s_expression *count_expr = (s_expression*) list->subexpressions.head->next;
|
||||
s_expression *from_expr = (s_expression*) count_expr->next;
|
||||
s_expression *to_expr = (s_expression*) from_expr->next;
|
||||
s_expression *inc_expr = (s_expression*) to_expr->next;
|
||||
s_expression *body_expr = (s_expression*) inc_expr->next;
|
||||
|
||||
// FINISHME: actually read the count/from/to fields.
|
||||
|
||||
ir_loop *loop = new ir_loop;
|
||||
read_instructions(st, &loop->body_instructions, body_expr);
|
||||
if (st->error) {
|
||||
delete loop;
|
||||
loop = NULL;
|
||||
}
|
||||
return loop;
|
||||
}
|
||||
|
||||
|
||||
static ir_return *
|
||||
read_return(_mesa_glsl_parse_state *st, s_list *list)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue