From c2a990768d8ff2a3c626951292ff511305be9a10 Mon Sep 17 00:00:00 2001 From: keie Date: Fri, 1 Mar 1985 16:20:13 +0000 Subject: [PATCH] The top of the stack, which is set aside for certain coercions is now saved with special routines. This allows RREMOVE to check for registers. --- mach/proto/ncg/subr.c | 91 ++++++++++++++++++++++++++++++------------- 1 file changed, 64 insertions(+), 27 deletions(-) diff --git a/mach/proto/ncg/subr.c b/mach/proto/ncg/subr.c index b04086d57..4f3f25e66 100644 --- a/mach/proto/ncg/subr.c +++ b/mach/proto/ncg/subr.c @@ -392,6 +392,66 @@ tref(tp,amount) register token_p tp; { } #define MAXSAVE 10 +/* A few routines to save the top of the current stack, + restore it and check whether a certain register is present in the + saved stack +*/ +token_t aside[MAXSAVE] ; +int aside_length = -1 ; + +save_stack(tp) register token_p tp ; { + int i ; + + aside_length = &fakestack[stackheight-1] -tp; + assert(aside_length<=MAXSAVE); +#ifndef NDEBUG + if (aside_length!=0 && Debug>1) + fprintf(stderr,"Saving %d items from fakestack\n",aside_length); +#endif + for (i=1;i<=aside_length;i++) + aside[i-1] = tp[i]; + stackheight -= aside_length; +} + +in_stack(reg) { + register token_p tp ; + register i ; + register tkdef_p tdp ; + + for ( i=0, tp=aside ; it_token==-1) { + if(tp->t_att[0].ar==reg) + goto gotone ; + } else { + tdp = &tokens[tp->t_token]; + for(i=0;it_type[i]==EV_REG && + tp->t_att[i].ar==reg) + goto gotone ; + } + return 0 ; +gotone: +#ifndef NDEBUG + if ( Debug>2 ) + fprintf(stderr,"Register %d present on non-visible stack\n", + reg ) ; +#endif + return 1 ; +} + +rest_stack() { + register int i ; + + assert(aside_length!= -1); +#ifndef NDEBUG + if (aside_length!=0 && Debug>1) + fprintf(stderr,"Restoring %d items to fakestack(%d)\n", + aside_length,stackheight); +#endif + for (i=0;ic2_nsplit-1c2_codep],ply,toplevel,MAXINT,0); tokpatlen = tpl; - for (i=0;ic2_nsplit); } #endif MAXSPLIT unsigned docoerc(tp,cp,ply,toplevel,forced) token_p tp; register c3_p cp; { - token_t savestack[MAXSAVE]; - token_p stp; - register int i,diff; unsigned cost; int tpl; /* saved tokpatlen */ - stp = &fakestack[stackheight-1]; - diff = stp -tp; - assert(diff<=MAXSAVE); -#ifndef NDEBUG - if (diff!=0 && Debug>1) - fprintf(stderr,"Saving %d items from fakestack\n",diff); -#endif - for (i=1;i<=diff;i++) - savestack[i-1] = tp[i]; - stackheight -= diff; + save_stack(tp) ; tpl = tokpatlen; tokpatlen = 1; cost = codegen(&coderules[cp->c3_codep],ply,toplevel,MAXINT,forced); tokpatlen = tpl; -#ifndef NDEBUG - if (diff!=0 && Debug>1) - fprintf(stderr,"Restoring %d items to fakestack(%d)\n",diff,stackheight); -#endif - for (i=0;i