added stackheight message handling

This commit is contained in:
eck
1990-07-18 14:53:19 +00:00
parent 4320d836e1
commit 68ff00fd8b
28 changed files with 321 additions and 60 deletions

View File

@@ -38,7 +38,7 @@ int Xstackflag=0; /* set in coercions, moves, and tests. %1 means something
*/
struct varinfo *gen_inst(),*gen_move(),*gen_test(),*gen_preturn(),*gen_tlab();
struct varinfo *make_erase();
struct varinfo *gen_label(), *make_erase();
expr_t make_expr(),ident_expr(),subreg_expr(),tokm_expr(),all_expr();
expr_t perc_ident_expr(),sum_expr(),regvar_expr();
@@ -71,6 +71,7 @@ iocc_t iops[20];
%token TESTS
%token STACKINGRULES COERCIONS
%token INSTRUCTIONS
%token STACKHEIGHT FALLTHROUGH LABELDEF
%token PROC CALL EXAMPLE
%token FROM TO
%token TEST MOVE STACK RETURN
@@ -844,6 +845,8 @@ gen_instruction
{ $$ = gen_move($2,$4); }
| TEST tokeninstance
{ $$ = gen_test($2);}
| LABELDEF emarg
{ $$ = gen_label($2-1); use_shc++; }
| RETURN
{ $$ = gen_preturn(); }
;
@@ -1009,6 +1012,10 @@ expr
{ $$ = make_expr(TYPBOOL,EX_DEFINED,i_expr($3),0); }
| SAMESIGN '(' expr ',' expr ')'
{ $$ = make_expr(TYPBOOL,EX_SAMESIGN,i_expr($3),i_expr($5)); }
| STACKHEIGHT '(' emarg ')'
{ $$ = make_expr(TYPINT,EX_STACKHEIGHT,$3-1,0); }
| FALLTHROUGH '(' emarg ')'
{ $$ = make_expr(TYPBOOL,EX_FALLTHROUGH,$3-1,0); }
| SFIT '(' expr ',' expr ')'
{ $$ = make_expr(TYPBOOL,EX_SFIT,i_expr($3),i_expr($5)); }
| UFIT '(' expr ',' expr ')'

View File

@@ -110,6 +110,15 @@ struct varinfo *gen_test(from) iocc_t from; {
return(vp);
}
struct varinfo *gen_label(arg) int arg; {
register struct varinfo *vp;
NEW(vp,struct varinfo);
vp->vi_int[0] = INSLABDEF;
vp->vi_int[1] = arg;
return(vp);
}
struct varinfo *gen_preturn() {
register struct varinfo *vp;

View File

@@ -25,6 +25,7 @@ initemhash() {
for(i=0;i<=sp_lmnem-sp_fmnem;i++)
enter(em_mnem[i],i+sp_fmnem);
enter("lab", op_lab);
}
unsigned emhash(name) register char *name; {

View File

@@ -36,6 +36,7 @@ extern int maxmembers;
extern int regclass;
extern int maxtokensize;
extern int nprocargs, maxprocargs;
extern int use_shc;
extern char *mystrcpy();
extern char *myalloc();

View File

@@ -206,6 +206,3 @@ instalookup(insta,filled) inst_t insta; {
l_instances[i] = insta;
return(i);
}

View File

@@ -20,12 +20,14 @@ cost COST
defined DEFINED
exact EXACT
example EXAMPLE
fallthrough FALLTHROUGH
from FROM
gen GEN
highw HIGHW
inreg INREG
is_rom ISROM
kills KILLS
labeldef LABELDEF
leaving LEAVING
loww LOWW
move MOVE
@@ -41,6 +43,7 @@ reusing REUSING
rom ROM
samesign SAMESIGN
sfit SFIT
stackheight STACKHEIGHT
test TEST
to TO
ufit UFIT

View File

@@ -11,6 +11,7 @@ int code_in_c=1; /* put code in "tables.c" */
int tabledebug=0; /* do not generate code for table debugging */
#endif
int verbose=0; /* print all statistics */
int use_shc; /* use stackheight information */
char *c_file= "tables.c";
char *h_file= "tables.H";
char *cd_file= "code";
@@ -592,6 +593,8 @@ outdefs() {
}
if (tabledebug)
cdef("TABLEDEBUG",1);
if (use_shc)
cdef("USE_SHC",1);
}
outars() {
@@ -826,6 +829,12 @@ varinfo *kills,*allocates,*generates,*yields,*leaving;
codeint(vp->vi_int[1]);
codenl();
break;
case INSLABDEF:
cocono = 0;
code8(DO_LABDEF);
codeint(vp->vi_int[1]);
codenl();
break;
}
}
codecoco(cocono);

View File

@@ -48,3 +48,6 @@
#define NEXT(n,max,string) (n<max? n++ : tabovf(string))
#define NEW(x,y) x=(y*)myalloc(sizeof(*(x)))
#include <em_spec.h>
#define op_lab (sp_lmnem + 1)

View File

@@ -11,3 +11,4 @@
#define INSSETCC (-5)
#define INSERASE (-6)
#define INSREMOVE (-7)
#define INSLABDEF (-8)