mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-01-19 06:40:49 +00:00
Move the output block of a loop to after the loop, otherwise IR dumps looks just messy... note that this is merely a cosmetic change
This commit is contained in:
parent
6b52c66d11
commit
2f92dedb4c
1 changed files with 12 additions and 0 deletions
12
ast.c
12
ast.c
|
@ -939,6 +939,9 @@ bool ast_loop_codegen(ast_loop *self, ast_function *func, bool lvalue, ir_value
|
|||
ir_block *bincrement, *end_bincrement;
|
||||
ir_block *bout, *bin;
|
||||
|
||||
/* let's at least move the outgoing block to the end */
|
||||
size_t bout_id;
|
||||
|
||||
/* 'break' and 'continue' need to be able to find the right blocks */
|
||||
ir_block *bcontinue = NULL;
|
||||
ir_block *bbreak = NULL;
|
||||
|
@ -1014,6 +1017,7 @@ bool ast_loop_codegen(ast_loop *self, ast_function *func, bool lvalue, ir_value
|
|||
bpostcond = end_bpostcond = NULL;
|
||||
}
|
||||
|
||||
bout_id = func->ir_func->blocks_count;
|
||||
bout = ir_function_create_block(func->ir_func, ast_function_label(func, "after_loop"));
|
||||
if (!bout)
|
||||
return false;
|
||||
|
@ -1135,5 +1139,13 @@ bool ast_loop_codegen(ast_loop *self, ast_function *func, bool lvalue, ir_value
|
|||
return false;
|
||||
}
|
||||
|
||||
/* Move 'bout' to the end */
|
||||
if (!ir_function_blocks_remove(func->ir_func, bout_id) ||
|
||||
!ir_function_blocks_add(func->ir_func, bout))
|
||||
{
|
||||
ir_block_delete(bout);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue