mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-10 01:16:18 +00:00
use left recursion instead of right recursion to avoid memory exhausted issue when compiling large source files
This commit is contained in:
parent
dea75a6935
commit
db8aedc745
@ -122,6 +122,7 @@ struct brw_program_instruction {
|
||||
*/
|
||||
struct brw_program {
|
||||
struct brw_program_instruction *first;
|
||||
struct brw_program_instruction *last;
|
||||
};
|
||||
|
||||
extern struct brw_program compiled_program;
|
||||
|
@ -174,16 +174,15 @@ ROOT: instrseq
|
||||
label: STRING COLON
|
||||
;
|
||||
|
||||
instrseq: instruction SEMICOLON instrseq
|
||||
instrseq: instrseq instruction SEMICOLON
|
||||
{
|
||||
struct brw_program_instruction *list_entry =
|
||||
calloc(sizeof(struct brw_program_instruction), 1);
|
||||
list_entry->instruction = $1;
|
||||
|
||||
list_entry->next = $3.first;
|
||||
$3.first = list_entry;
|
||||
|
||||
$$ = $3;
|
||||
list_entry->instruction = $2;
|
||||
list_entry->next = NULL;
|
||||
$1.last->next = list_entry;
|
||||
$1.last = list_entry;
|
||||
$$ = $1;
|
||||
}
|
||||
| instruction SEMICOLON
|
||||
{
|
||||
@ -194,16 +193,30 @@ instrseq: instruction SEMICOLON instrseq
|
||||
list_entry->next = NULL;
|
||||
|
||||
$$.first = list_entry;
|
||||
$$.last = list_entry;
|
||||
}
|
||||
| label instrseq
|
||||
| instrseq label
|
||||
{
|
||||
struct brw_program_instruction *list_entry =
|
||||
calloc(sizeof(struct brw_program_instruction), 1);
|
||||
list_entry->string = strdup($2);
|
||||
list_entry->islabel = 1;
|
||||
list_entry->next = NULL;
|
||||
$1.last->next = list_entry;
|
||||
$1.last = list_entry;
|
||||
$$ = $1;
|
||||
}
|
||||
| label
|
||||
{
|
||||
struct brw_program_instruction *list_entry =
|
||||
calloc(sizeof(struct brw_program_instruction), 1);
|
||||
list_entry->string = strdup($1);
|
||||
list_entry->islabel = 1;
|
||||
list_entry->next = $2.first;
|
||||
$2.first = list_entry;
|
||||
$$ = $2;
|
||||
|
||||
list_entry->next = NULL;
|
||||
|
||||
$$.first = list_entry;
|
||||
$$.last = list_entry;
|
||||
}
|
||||
| error SEMICOLON instrseq
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user