Translations - break/continue
How do you deal with control flow wildcards like break and continue? Example:
int main () {
// This is a test
int i=5;
switch (i) {
case 0:
case 1:
case 2:
case 3:
case 4:
break;
case 5:
i=4;
case 6:
case 7:
case 8:
case 9:
default:;
}
pwhile (i > 0) {
if (i == 3) {
i -= 2;
continue;
}
printf ("i = %d\n",i--);
}
exit(0);
}
The breaks and continues in the "normal" loop are untouched:
switch (i)
{
case 0:
case 1:
case 2:
case 3:
case 4:
break;
case 5:
i=4;
case 6:
case 7:
case 8:
case 9:
default:
;
}
However, the continue in the speculative loop needs to be transformed into
an exit of the function:
while (1)
{
spec_eoi_label();
spec_start:
{
if ((!(i>0)))
spec_terminate_label();
{
if ((i==3))
{
i-=2;
spec_eoi_label();
}
printf("i = %d\n",i--);
}
}
}
spec_terminate_last:
spec_terminate:
return ;
}