From: Wolfgang (Blub) Bumiller Date: Fri, 4 May 2012 08:01:38 +0000 (+0200) Subject: Move the output block of a loop to after the loop, otherwise IR dumps looks just... X-Git-Tag: 0.1-rc1~489^2~6 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2f92dedb4c00bc2c107b91433f8e5c7284d77967;p=xonotic%2Fgmqcc.git 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 --- diff --git a/ast.c b/ast.c index c965947..e796215 100644 --- a/ast.c +++ b/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; }