mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-23 20:33:05 +00:00
What was I thinking... fixing loop's jump creation so it doesn't try creating multiple jumps... this code is also much more readable
This commit is contained in:
parent
c670a8d278
commit
73749db6b4
1 changed files with 20 additions and 21 deletions
41
ast.c
41
ast.c
|
@ -949,6 +949,8 @@ bool ast_loop_codegen(ast_loop *self, ast_function *func, bool lvalue, ir_value
|
||||||
ir_block *old_bcontinue;
|
ir_block *old_bcontinue;
|
||||||
ir_block *old_bbreak;
|
ir_block *old_bbreak;
|
||||||
|
|
||||||
|
ir_block *btemp;
|
||||||
|
|
||||||
(void)lvalue;
|
(void)lvalue;
|
||||||
(void)out;
|
(void)out;
|
||||||
|
|
||||||
|
@ -1081,14 +1083,13 @@ bool ast_loop_codegen(ast_loop *self, ast_function *func, bool lvalue, ir_value
|
||||||
|
|
||||||
/* Now all blocks are in place */
|
/* Now all blocks are in place */
|
||||||
/* From 'bin' we jump to whatever comes first */
|
/* From 'bin' we jump to whatever comes first */
|
||||||
if (bprecond && !ir_block_create_jump(bin, bprecond))
|
if (bprecond) tmpblock = bprecond;
|
||||||
return false;
|
else if (bbody) tmpblock = bbody;
|
||||||
else if (bbody && !ir_block_create_jump(bin, bbody))
|
else if (bpostcond) tmpblock = bpostcond;
|
||||||
return false;
|
else tmpblock = bout;
|
||||||
else if (bpostcond && !ir_block_create_jump(bin, bpostcond))
|
if (!ir_block_create_jump(bin, tmpblock))
|
||||||
return false;
|
|
||||||
else if ( !ir_block_create_jump(bin, bout))
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* From precond */
|
/* From precond */
|
||||||
if (bprecond)
|
if (bprecond)
|
||||||
|
@ -1106,27 +1107,25 @@ bool ast_loop_codegen(ast_loop *self, ast_function *func, bool lvalue, ir_value
|
||||||
/* from body */
|
/* from body */
|
||||||
if (bbody)
|
if (bbody)
|
||||||
{
|
{
|
||||||
if (bincrement && !ir_block_create_jump(end_bbody, bincrement))
|
if (bincrement) tmpblock = bincrement;
|
||||||
return false;
|
else if (bpostcond) tmpblock = bpostcond;
|
||||||
else if (bpostcond && !ir_block_create_jump(end_bbody, bpostcond))
|
else if (bprecond) tmpblock = bprecond;
|
||||||
return false;
|
else tmpblock = bout;
|
||||||
else if (bprecond && !ir_block_create_jump(end_bbody, bprecond))
|
if (!ir_block_create_jump(end_bbody, tmpblock))
|
||||||
return false;
|
|
||||||
else if (!ir_block_create_jump(end_bbody, bout))
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* from increment */
|
/* from increment */
|
||||||
if (bincrement)
|
if (bincrement)
|
||||||
{
|
{
|
||||||
if (bpostcond && !ir_block_create_jump(end_bincrement, bpostcond))
|
if (bpostcond) tmpblock = bpostcond;
|
||||||
return false;
|
else if (bprecond) tmpblock = bprecond;
|
||||||
else if (bprecond && !ir_block_create_jump(end_bincrement, bprecond))
|
else if (bbody) tmpblock = bbody;
|
||||||
return false;
|
else tmpblock = bout;
|
||||||
else if (bbody && !ir_block_create_jump(end_bincrement, bbody))
|
if (!ir_block_create_jump(end_bincrement, tmpblock))
|
||||||
return false;
|
|
||||||
else if (!ir_block_create_jump(end_bincrement, bout))
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* from postcond */
|
/* from postcond */
|
||||||
|
|
Loading…
Reference in a new issue