Add initial support for 'goto' statements.

ispc now supports goto, but only under uniform control flow--i.e.
it must be possible for the compiler to statically determine that
all program instances will follow the goto.  An error is issued at
compile time if a goto is used when this is not the case.
This commit is contained in:
Matt Pharr
2012-01-05 12:20:44 -08:00
parent 48e9d4af39
commit 78c6d3c02f
20 changed files with 408 additions and 15 deletions

View File

@@ -224,7 +224,7 @@ struct ForeachDimension {
%type <declSpecs> declaration_specifiers
%type <stringVal> string_constant
%type <constCharPtr> struct_or_union_name enum_identifier
%type <constCharPtr> struct_or_union_name enum_identifier goto_identifier
%type <intVal> int_constant soa_width_specifier
%type <foreachDimension> foreach_dimension_specifier
@@ -1262,7 +1262,11 @@ statement
;
labeled_statement
: TOKEN_CASE constant_expression ':' statement
: goto_identifier ':' statement
{
$$ = new LabeledStmt($1, $3, @1);
}
| TOKEN_CASE constant_expression ':' statement
{ UNIMPLEMENTED; }
| TOKEN_DEFAULT ':' statement
{ UNIMPLEMENTED; }
@@ -1433,9 +1437,13 @@ iteration_statement
}
;
goto_identifier
: TOKEN_IDENTIFIER { $$ = yylval.stringVal->c_str(); }
;
jump_statement
: TOKEN_GOTO TOKEN_IDENTIFIER ';'
{ UNIMPLEMENTED; }
: TOKEN_GOTO goto_identifier ';'
{ $$ = new GotoStmt($2, @1, @2); }
| TOKEN_CONTINUE ';'
{ $$ = new ContinueStmt(false, @1); }
| TOKEN_BREAK ';'