mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 00:30:13 +01:00
glsl: Make ir_reader able to read plain (return) statements.
Previously ir_reader was only able to handle return of non-void. This patch is necessary in order to allow optimization passes to be tested in isolation. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
parent
5fb79fc69f
commit
f4830be938
1 changed files with 13 additions and 11 deletions
|
|
@ -482,19 +482,21 @@ ir_reader::read_return(s_expression *expr)
|
|||
{
|
||||
s_expression *s_retval;
|
||||
|
||||
s_pattern pat[] = { "return", s_retval};
|
||||
if (!MATCH(expr, pat)) {
|
||||
ir_read_error(expr, "expected (return <rvalue>)");
|
||||
s_pattern return_value_pat[] = { "return", s_retval};
|
||||
s_pattern return_void_pat[] = { "return" };
|
||||
if (MATCH(expr, return_value_pat)) {
|
||||
ir_rvalue *retval = read_rvalue(s_retval);
|
||||
if (retval == NULL) {
|
||||
ir_read_error(NULL, "when reading return value");
|
||||
return NULL;
|
||||
}
|
||||
return new(mem_ctx) ir_return(retval);
|
||||
} else if (MATCH(expr, return_void_pat)) {
|
||||
return new(mem_ctx) ir_return;
|
||||
} else {
|
||||
ir_read_error(expr, "expected (return <rvalue>) or (return)");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ir_rvalue *retval = read_rvalue(s_retval);
|
||||
if (retval == NULL) {
|
||||
ir_read_error(NULL, "when reading return value");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return new(mem_ctx) ir_return(retval);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue