|
@@ -1,9 +1,12 @@
|
|
|
-#ifndef NORCSID
|
|
|
-static char rcsid[] = "$Id$";
|
|
|
-#endif
|
|
|
-
|
|
|
+/*
|
|
|
+ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
|
+ *
|
|
|
+ * Author: Hans van Staveren
|
|
|
+ */
|
|
|
#include <stdlib.h>
|
|
|
#include <stdio.h>
|
|
|
+#include <string.h>
|
|
|
#include "assert.h"
|
|
|
#include "param.h"
|
|
|
#include "tables.h"
|
|
@@ -12,19 +15,17 @@ static char rcsid[] = "$Id$";
|
|
|
#include "data.h"
|
|
|
#include "result.h"
|
|
|
#include "extern.h"
|
|
|
-
|
|
|
-/*
|
|
|
- * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
- * See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
|
- *
|
|
|
- * Author: Hans van Staveren
|
|
|
- */
|
|
|
-
|
|
|
-string myalloc();
|
|
|
-unsigned codegen();
|
|
|
-
|
|
|
-match(tp,tep,optexp) register token_p tp; register set_p tep; {
|
|
|
- register bitno;
|
|
|
+#include "utils.h"
|
|
|
+#include "compute.h"
|
|
|
+#include "reg.h"
|
|
|
+#include "regvar.h"
|
|
|
+#include "codegen.h"
|
|
|
+#include "salloc.h"
|
|
|
+#include "subr.h"
|
|
|
+
|
|
|
+int match(token_p tp, set_p tep, int optexp)
|
|
|
+{
|
|
|
+ int bitno;
|
|
|
token_p ct;
|
|
|
result_t result;
|
|
|
|
|
@@ -49,10 +50,11 @@ match(tp,tep,optexp) register token_p tp; register set_p tep; {
|
|
|
return(result.e_v.e_con);
|
|
|
}
|
|
|
|
|
|
-instance(instno,token) register token_p token; {
|
|
|
- register inst_p inp;
|
|
|
+void instance(int instno, token_p token)
|
|
|
+{
|
|
|
+ inst_p inp;
|
|
|
int i;
|
|
|
- register token_p tp;
|
|
|
+ token_p tp;
|
|
|
#if MAXMEMBERS != 0
|
|
|
struct reginfo *rp;
|
|
|
#endif
|
|
@@ -145,8 +147,9 @@ instance(instno,token) register token_p token; {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-cinstance(instno,token,tp,regno) register token_p token,tp; {
|
|
|
- register inst_p inp;
|
|
|
+void cinstance(int instno,token_p token, token_p tp, int regno)
|
|
|
+{
|
|
|
+ inst_p inp;
|
|
|
int i;
|
|
|
#if MAXMEMBERS != 0
|
|
|
struct reginfo *rp;
|
|
@@ -240,9 +243,10 @@ cinstance(instno,token,tp,regno) register token_p token,tp; {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-eqtoken(tp1,tp2) token_p tp1,tp2; {
|
|
|
- register i;
|
|
|
- register tkdef_p tdp;
|
|
|
+int eqtoken(token_p tp1, token_p tp2)
|
|
|
+{
|
|
|
+ int i;
|
|
|
+ tkdef_p tdp;
|
|
|
|
|
|
if (tp1->t_token!=tp2->t_token)
|
|
|
return(0);
|
|
@@ -276,10 +280,11 @@ eqtoken(tp1,tp2) token_p tp1,tp2; {
|
|
|
return(1);
|
|
|
}
|
|
|
|
|
|
-distance(cindex) {
|
|
|
- register char *bp;
|
|
|
- register i;
|
|
|
- register token_p tp;
|
|
|
+int distance(int cindex)
|
|
|
+{
|
|
|
+ char *bp;
|
|
|
+ int i;
|
|
|
+ token_p tp;
|
|
|
int tokexp,tpl;
|
|
|
int expsize,toksize,exact;
|
|
|
int xsekt=0;
|
|
@@ -355,37 +360,38 @@ distance(cindex) {
|
|
|
|
|
|
extern set_t unstackset;
|
|
|
|
|
|
-int from_stack(s1)
|
|
|
- register set_p s1;
|
|
|
+int from_stack(set_p s1)
|
|
|
{
|
|
|
- register set_p s2 = &unstackset;
|
|
|
- register int i;
|
|
|
+ set_p s2 = &unstackset;
|
|
|
+ int i;
|
|
|
for (i = 0; i < SETSIZE; i++) {
|
|
|
if ((s1->set_val[i] & s2->set_val[i]) != 0) return 1;
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-unsigned costcalc(cost) cost_t cost; {
|
|
|
+unsigned int costcalc(cost_t cost)
|
|
|
+{
|
|
|
extern unsigned cc1,cc2,cc3,cc4;
|
|
|
|
|
|
return(cost.ct_space*cc1/cc2 + cost.ct_time*cc3/cc4);
|
|
|
}
|
|
|
|
|
|
-ssize(tokexpno) {
|
|
|
-
|
|
|
+int ssize(int tokexpno)
|
|
|
+{
|
|
|
return(machsets[tokexpno].set_size);
|
|
|
}
|
|
|
|
|
|
-tsize(tp) register token_p tp; {
|
|
|
-
|
|
|
+int tsize(token_p tp)
|
|
|
+{
|
|
|
if (tp->t_token==-1)
|
|
|
return(machregs[tp->t_att[0].ar].r_size);
|
|
|
return(tokens[tp->t_token].t_size);
|
|
|
}
|
|
|
|
|
|
#ifdef MAXSPLIT
|
|
|
-instsize(tinstno,tp) token_p tp; {
|
|
|
+int instsize(int tinstno, token_p tp)
|
|
|
+{
|
|
|
inst_p inp;
|
|
|
struct reginfo *rp;
|
|
|
|
|
@@ -418,9 +424,10 @@ instsize(tinstno,tp) token_p tp; {
|
|
|
}
|
|
|
#endif /* MAXSPLIT */
|
|
|
|
|
|
-tref(tp,amount) register token_p tp; {
|
|
|
- register i;
|
|
|
- register byte *tdpb;
|
|
|
+void tref(token_p tp, int amount)
|
|
|
+{
|
|
|
+ int i;
|
|
|
+ byte *tdpb;
|
|
|
|
|
|
if (tp->t_token==-1)
|
|
|
chrefcount(tp->t_att[0].ar,amount,FALSE);
|
|
@@ -440,7 +447,8 @@ tref(tp,amount) register token_p tp; {
|
|
|
token_t aside[MAXSAVE] ;
|
|
|
int aside_length = -1 ;
|
|
|
|
|
|
-save_stack(tp) register token_p tp ; {
|
|
|
+void save_stack(token_p tp)
|
|
|
+{
|
|
|
int i ;
|
|
|
token_p tmp = &fakestack[stackheight - 1];
|
|
|
|
|
@@ -458,10 +466,11 @@ save_stack(tp) register token_p tp ; {
|
|
|
stackheight -= aside_length;
|
|
|
}
|
|
|
|
|
|
-in_stack(reg) {
|
|
|
- register token_p tp ;
|
|
|
- register i ;
|
|
|
- register tkdef_p tdp ;
|
|
|
+int in_stack(int reg)
|
|
|
+{
|
|
|
+ token_p tp ;
|
|
|
+ int i ;
|
|
|
+ tkdef_p tdp ;
|
|
|
|
|
|
for ( i=0, tp=aside ; i<aside_length ; i++, tp++ )
|
|
|
if (tp->t_token==-1) {
|
|
@@ -484,8 +493,9 @@ gotone:
|
|
|
return 1 ;
|
|
|
}
|
|
|
|
|
|
-rest_stack() {
|
|
|
- register int i ;
|
|
|
+void rest_stack()
|
|
|
+{
|
|
|
+ int i ;
|
|
|
|
|
|
assert(aside_length!= -1);
|
|
|
#ifndef NDEBUG
|
|
@@ -499,11 +509,12 @@ rest_stack() {
|
|
|
}
|
|
|
|
|
|
#ifdef MAXSPLIT
|
|
|
-split(tp,ip,ply,toplevel) token_p tp; register int *ip; {
|
|
|
- register c2_p cp;
|
|
|
+voir split(token_p tp, int *ip, int ply, int toplevel)
|
|
|
+{
|
|
|
+ c2_p cp;
|
|
|
token_t savestack[MAXSAVE];
|
|
|
int ok;
|
|
|
- register i;
|
|
|
+ int i;
|
|
|
int diff;
|
|
|
token_p stp;
|
|
|
int tpl;
|
|
@@ -533,8 +544,9 @@ found:
|
|
|
}
|
|
|
#endif /* MAXSPLIT */
|
|
|
|
|
|
-unsigned docoerc(tp,cp,ply,toplevel,forced) token_p tp; register c3_p cp; {
|
|
|
- unsigned cost;
|
|
|
+unsigned int docoerc(token_p tp, c3_p cp, int ply, int toplevel, int forced)
|
|
|
+{
|
|
|
+ unsigned int cost;
|
|
|
int tpl; /* saved tokpatlen */
|
|
|
|
|
|
save_stack(tp) ;
|
|
@@ -547,16 +559,17 @@ unsigned docoerc(tp,cp,ply,toplevel,forced) token_p tp; register c3_p cp; {
|
|
|
return(cost);
|
|
|
}
|
|
|
|
|
|
-unsigned stackupto(limit,ply,toplevel) token_p limit; {
|
|
|
+unsigned int stackupto(token_p limit, int ply, int toplevel)
|
|
|
+{
|
|
|
token_t savestack[MAXFSTACK];
|
|
|
token_p stp;
|
|
|
int i,diff;
|
|
|
int tpl; /* saved tokpatlen */
|
|
|
int nareg; /* saved nareg */
|
|
|
int areg[MAXALLREG];
|
|
|
- register c1_p cp;
|
|
|
- register token_p tp;
|
|
|
- unsigned totalcost=0;
|
|
|
+ c1_p cp;
|
|
|
+ token_p tp;
|
|
|
+ int totalcost=0;
|
|
|
struct reginfo *rp,**rpp;
|
|
|
|
|
|
for (tp=fakestack;tp<=limit;limit--) {
|
|
@@ -611,11 +624,12 @@ unsigned stackupto(limit,ply,toplevel) token_p limit; {
|
|
|
return(totalcost);
|
|
|
}
|
|
|
|
|
|
-c3_p findcoerc(tp,tep) token_p tp; set_p tep; {
|
|
|
- register c3_p cp;
|
|
|
+c3_p findcoerc(token_p tp, set_p tep)
|
|
|
+{
|
|
|
+ c3_p cp;
|
|
|
token_t rtoken;
|
|
|
- register i;
|
|
|
- register struct reginfo **rpp;
|
|
|
+ int i;
|
|
|
+ struct reginfo **rpp;
|
|
|
|
|
|
for (cp=c3coercs;cp->c3_texpno>=0; cp++) {
|
|
|
if (tp!=(token_p) 0) {
|
|
@@ -648,63 +662,10 @@ c3_p findcoerc(tp,tep) token_p tp; set_p tep; {
|
|
|
return(0); /* nothing found */
|
|
|
}
|
|
|
|
|
|
-itokcost() {
|
|
|
- register tkdef_p tdp;
|
|
|
+void itokcost()
|
|
|
+{
|
|
|
+ tkdef_p tdp;
|
|
|
|
|
|
for(tdp=tokens+1;tdp->t_size!=0;tdp++)
|
|
|
tdp->t_cost.ct_space = costcalc(tdp->t_cost);
|
|
|
}
|
|
|
-
|
|
|
-/*VARARGS1*/
|
|
|
-error(s,a1,a2,a3,a4,a5,a6,a7,a8) char *s; {
|
|
|
-
|
|
|
- fprintf(stderr,"Error: ");
|
|
|
- fprintf(stderr,s,a1,a2,a3,a4,a5,a6,a7,a8);
|
|
|
- fprintf(stderr,"\n");
|
|
|
-#ifdef TABLEDEBUG
|
|
|
- ruletrace();
|
|
|
-#endif
|
|
|
- out_finish();
|
|
|
- exit(-1);
|
|
|
-}
|
|
|
-
|
|
|
-/*VARARGS1*/
|
|
|
-fatal(s,a1,a2,a3,a4,a5,a6,a7,a8) char *s; {
|
|
|
-
|
|
|
- fprintf(stderr,"Fatal: ");
|
|
|
- fprintf(stderr,s,a1,a2,a3,a4,a5,a6,a7,a8);
|
|
|
- fprintf(stderr,"\n");
|
|
|
-#ifdef TABLEDEBUG
|
|
|
- ruletrace();
|
|
|
-#endif
|
|
|
- out_finish();
|
|
|
- abort();
|
|
|
- exit(-1);
|
|
|
-}
|
|
|
-
|
|
|
-#ifdef TABLEDEBUG
|
|
|
-
|
|
|
-ruletrace() {
|
|
|
- register i;
|
|
|
- extern int tablelines[MAXTDBUG];
|
|
|
- extern int ntableline;
|
|
|
- extern char *tablename;
|
|
|
-
|
|
|
- fprintf(stderr,"Last code rules used\n");
|
|
|
- i=ntableline-1;
|
|
|
- while(i!=ntableline) {
|
|
|
- if (i<0)
|
|
|
- i += MAXTDBUG;
|
|
|
- if (tablelines[i]!=0)
|
|
|
- fprintf(stderr,"\%d: \"%s\", line %d\n",i,tablename,tablelines[i]);
|
|
|
- i--;
|
|
|
- }
|
|
|
-}
|
|
|
-#endif
|
|
|
-
|
|
|
-#ifndef NDEBUG
|
|
|
-badassertion(asstr,file,line) char *asstr, *file; {
|
|
|
-
|
|
|
- fatal("\"%s\", line %d:Assertion \"%s\" failed",file,line,asstr);
|
|
|
-}
|
|
|
-#endif
|