diff options
| author | Xavier ASUS <xavi92psx@gmail.com> | 2019-10-30 00:23:41 +0100 |
|---|---|---|
| committer | Xavier ASUS <xavi92psx@gmail.com> | 2019-10-30 00:23:41 +0100 |
| commit | 1dcefbf527e52315abfe3b4871272b3fd9bb0f4b (patch) | |
| tree | f3b150b25e460fd7480fc1fe82a35a4d2235a1cc | |
| parent | 7c4ae5853b472f0a2bb1dd049a818ab8346c5cff (diff) | |
_Noreturn-qualified functions now do not generate any ret/iret instruction
| -rw-r--r-- | src/stm8/gen.c | 52 |
1 files changed, 31 insertions, 21 deletions
diff --git a/src/stm8/gen.c b/src/stm8/gen.c index e910ece..0d89633 100644 --- a/src/stm8/gen.c +++ b/src/stm8/gen.c @@ -3464,39 +3464,49 @@ genEndFunction (iCode *ic) return; } - /* adjust the stack for the function */ - if (sym->stack) - adjustStack (sym->stack, retsize != 1, retsize != 2 && retsize != 4, retsize != 4); - - wassertl (!G.stack.pushed, "Unbalanced stack."); - - if (IFFUNC_ISCRITICAL (sym->type)) - genEndCritical (NULL); - - if (IFFUNC_ISISR (sym->type)) + if (IFFUNC_ISNORETURN (OP_SYMBOL (IC_LEFT (ic))->type)) { + D (emit2 (";", "C11 noreturn function.")); /* if debug then send end of function */ if (options.debug && currFunc && !regalloc_dry_run) debugFile->writeEndFunction (currFunc, ic, 1); - - emit2 ("iret", ""); - cost (1, 11); } else { - /* if debug then send end of function */ - if (options.debug && currFunc && !regalloc_dry_run) - debugFile->writeEndFunction (currFunc, ic, 1); + /* adjust the stack for the function */ + if (sym->stack) + adjustStack (sym->stack, retsize != 1, retsize != 2 && retsize != 4, retsize != 4); - if (options.model == MODEL_LARGE) + wassertl (!G.stack.pushed, "Unbalanced stack."); + + if (IFFUNC_ISCRITICAL (sym->type)) + genEndCritical (NULL); + + if (IFFUNC_ISISR (sym->type)) { - emit2 ("retf", ""); - cost (1, 5); + /* if debug then send end of function */ + if (options.debug && currFunc && !regalloc_dry_run) + debugFile->writeEndFunction (currFunc, ic, 1); + + emit2 ("iret", ""); + cost (1, 11); } else { - emit2 ("ret", ""); - cost (1, 4); + /* if debug then send end of function */ + if (options.debug && currFunc && !regalloc_dry_run) + debugFile->writeEndFunction (currFunc, ic, 1); + + if (options.model == MODEL_LARGE) + { + emit2 ("retf", ""); + cost (1, 5); + } + else + { + emit2 ("ret", ""); + cost (1, 4); + } } } } |
