-void RestoreRegVars (int HaveResult)
-/* Restore the register variables for the local function if there are any.
- * The parameter tells us if there is a return value in ax, in that case,
- * the accumulator must be saved across the restore.
- */
-{
- unsigned I, J;
- int Bytes, Offs;
-
- /* If we don't have register variables in this function, bail out early */
- if (RegSymCount == 0) {
- return;
- }
-
- /* Save the accumulator if needed */
- if (!F_HasVoidReturn (CurrentFunc) && HaveResult) {
- g_save (CF_CHAR | CF_FORCECHAR);
- }
-
- /* Walk through all variables. If there are several variables in a row
- * (that is, with increasing stack offset), restore them in one chunk.
- */
- I = 0;
- while (I < RegSymCount) {
-
- /* Check for more than one variable */
- const SymEntry* Sym = RegSyms[I];
- Offs = Sym->V.R.SaveOffs;
- Bytes = CheckedSizeOf (Sym->Type);
- J = I+1;
-
- while (J < RegSymCount) {
-
- /* Get the next symbol */
- const SymEntry* NextSym = RegSyms [J];
-
- /* Get the size */
- int Size = CheckedSizeOf (NextSym->Type);
-
- /* Adjacent variable? */
- if (NextSym->V.R.SaveOffs + Size != Offs) {
- /* No */
- break;
- }
-
- /* Adjacent variable */
- Bytes += Size;
- Offs -= Size;
- Sym = NextSym;
- ++J;
- }
-
- /* Restore the memory range */
- g_restore_regvars (Offs, Sym->V.R.RegOffs, Bytes);
-
- /* Next round */
- I = J;
- }
-
- /* Restore the accumulator if needed */
- if (!F_HasVoidReturn (CurrentFunc) && HaveResult) {
- g_restore (CF_CHAR | CF_FORCECHAR);
- }
-}
-
-
-