+static void F_RestoreRegVars (Function* F)
+/* Restore the register variables for the local function if there are any. */
+{
+ const SymEntry* Sym;
+
+ /* If we don't have register variables in this function, bail out early */
+ if (F->RegOffs == RegisterSpace) {
+ return;
+ }
+
+ /* Save the accumulator if needed */
+ if (!F_HasVoidReturn (F)) {
+ g_save (CF_CHAR | CF_FORCECHAR);
+ }
+
+ /* Get the first symbol from the function symbol table */
+ Sym = F->FuncEntry->V.F.Func->SymTab->SymHead;
+
+ /* Walk through all symbols checking for register variables */
+ while (Sym) {
+ if (SymIsRegVar (Sym)) {
+
+ /* Check for more than one variable */
+ int Offs = Sym->V.R.SaveOffs;
+ unsigned Bytes = CheckedSizeOf (Sym->Type);
+
+ while (1) {
+
+ /* Find next register variable */
+ const SymEntry* NextSym = Sym->NextSym;
+ while (NextSym && !SymIsRegVar (NextSym)) {
+ NextSym = NextSym->NextSym;
+ }
+
+ /* If we have a next one, compare the stack offsets */
+ if (NextSym) {
+
+ /* We have a following register variable. 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;
+
+ } else {
+ break;
+ }
+ }
+
+ /* Restore the memory range */
+ g_restore_regvars (Offs, Sym->V.R.RegOffs, Bytes);
+
+ }
+
+ /* Check next symbol */
+ Sym = Sym->NextSym;
+ }
+
+ /* Restore the accumulator if needed */
+ if (!F_HasVoidReturn (F)) {
+ g_restore (CF_CHAR | CF_FORCECHAR);
+ }
+}
+
+
+