Add prototypes to functions in subr.c
Put the declarations in "data.h", because that header declares the types cost_t and token_p. Also #include <cgg_cg.h> from "data.h" to get types c3_p and set_p, and guard <cgg_cg.h> against multiple inclusion.
This commit is contained in:
parent
ba2a45180c
commit
909b0d5bf3
|
@ -4,6 +4,9 @@
|
|||
*/
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef __CGG_CG_H_INCLUDED
|
||||
#define __CGG_CG_H_INCLUDED
|
||||
|
||||
/* offsets of interesting fields in EM-pattern */
|
||||
|
||||
#define PO_HASH 0
|
||||
|
@ -165,3 +168,5 @@ typedef struct { /* one to one coercions */
|
|||
if ((a=((*(b)++)&BMASK)) >= 128) {\
|
||||
a = ((a-128)<<BSHIFT) | (*(b)++&BMASK); \
|
||||
}
|
||||
|
||||
#endif /* __CGG_CG_H_INCLUDED */
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
*/
|
||||
/* $Id$ */
|
||||
|
||||
#include <cgg_cg.h> /* set_p, c3_p */
|
||||
|
||||
typedef struct cost {
|
||||
short ct_space;
|
||||
short ct_time;
|
||||
|
@ -69,3 +71,20 @@ typedef struct {
|
|||
int rl_n; /* number in list */
|
||||
int rl_list[NREGS];
|
||||
} rl_t,*rl_p;
|
||||
|
||||
/* subr.c */
|
||||
int match(token_p, set_p, int);
|
||||
void instance(int, token_p);
|
||||
int eqtoken(token_p, token_p);
|
||||
int distance(int);
|
||||
unsigned costcalc(cost_t);
|
||||
int ssize(int);
|
||||
int tsize(token_p);
|
||||
void tref(token_p, int);
|
||||
int in_stack(int);
|
||||
#ifdef MAXSPLIT
|
||||
int split(token_p, int *, int, int);
|
||||
#endif
|
||||
unsigned docoerc(token_p, c3_p, int, int, int);
|
||||
unsigned stackupto(token_p, int, int);
|
||||
c3_p findcoerc(token_p, set_p);
|
||||
|
|
|
@ -4,6 +4,7 @@ static char rcsid[] = "$Id$";
|
|||
|
||||
#include "param.h"
|
||||
#include "tables.h"
|
||||
#include "types.h" /* byte, codegen */
|
||||
#include "mach.h"
|
||||
|
||||
/*
|
||||
|
@ -14,8 +15,7 @@ static char rcsid[] = "$Id$";
|
|||
*/
|
||||
|
||||
char *progname;
|
||||
extern char startupcode[];
|
||||
extern unsigned codegen();
|
||||
extern byte startupcode[]; /* codegen.c */
|
||||
int maxply=1;
|
||||
#ifndef NDEBUG
|
||||
int Debug=0;
|
||||
|
@ -25,6 +25,8 @@ char *strtdebug="";
|
|||
/* fillem.c */
|
||||
void in_init(char *);
|
||||
void in_start(void);
|
||||
/* subr.c */
|
||||
void itokcost(void);
|
||||
|
||||
main(argc,argv) char **argv; {
|
||||
register unsigned n;
|
||||
|
|
|
@ -26,7 +26,6 @@ move(tp1,tp2,ply,toplevel,maxcost) token_p tp1,tp2; unsigned maxcost; {
|
|||
register struct reginfo *rp;
|
||||
register byte *tdpb;
|
||||
int i;
|
||||
unsigned codegen();
|
||||
|
||||
if (eqtoken(tp1,tp2))
|
||||
return(0);
|
||||
|
@ -105,7 +104,6 @@ setcc(tp) token_p tp; {
|
|||
test(tp,ply,toplevel,maxcost) token_p tp; unsigned maxcost; {
|
||||
register test_p mp;
|
||||
unsigned t;
|
||||
unsigned codegen();
|
||||
|
||||
if (cocoreg.t_token!=0) {
|
||||
if (eqtoken(tp,&cocoreg))
|
||||
|
|
|
@ -24,10 +24,13 @@ static char rcsid[] = "$Id$";
|
|||
* Author: Hans van Staveren
|
||||
*/
|
||||
|
||||
unsigned codegen();
|
||||
static int from_stack(set_p);
|
||||
#ifdef TABLEDEBUG
|
||||
static void ruletrace(void);
|
||||
#endif
|
||||
|
||||
match(tp,tep,optexp) register token_p tp; register set_p tep; {
|
||||
register bitno;
|
||||
int match(token_p tp, set_p tep, int optexp) {
|
||||
int bitno;
|
||||
token_p ct;
|
||||
result_t result;
|
||||
|
||||
|
@ -52,11 +55,10 @@ match(tp,tep,optexp) register token_p tp; register set_p tep; {
|
|||
return(result.e_v.e_con);
|
||||
}
|
||||
|
||||
void
|
||||
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
|
||||
|
@ -70,7 +72,7 @@ instance(instno,token) register token_p token; {
|
|||
return;
|
||||
}
|
||||
inp= &tokeninstances[instno];
|
||||
switch(inp->in_which) {
|
||||
switch (inp->in_which) {
|
||||
default:
|
||||
assert(FALSE);
|
||||
case IN_COPY:
|
||||
|
@ -151,9 +153,8 @@ instance(instno,token) register token_p token; {
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
cinstance(instno,token,tp,regno) register token_p token,tp; {
|
||||
register inst_p inp;
|
||||
static void cinstance(int instno, token_p token, token_p tp, int regno) {
|
||||
inst_p inp;
|
||||
int i;
|
||||
#if MAXMEMBERS != 0
|
||||
struct reginfo *rp;
|
||||
|
@ -163,7 +164,7 @@ cinstance(instno,token,tp,regno) register token_p token,tp; {
|
|||
|
||||
assert(instno!=0);
|
||||
inp= &tokeninstances[instno];
|
||||
switch(inp->in_which) {
|
||||
switch (inp->in_which) {
|
||||
default:
|
||||
assert(FALSE);
|
||||
case IN_COPY:
|
||||
|
@ -249,9 +250,9 @@ 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);
|
||||
|
@ -285,10 +286,10 @@ 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;
|
||||
|
@ -301,7 +302,7 @@ distance(cindex) {
|
|||
getint(i,bp);
|
||||
}
|
||||
#endif
|
||||
switch( (*bp)&037 ) {
|
||||
switch ( (*bp)&037 ) {
|
||||
default:
|
||||
return(stackheight==0 ? 0 : 100);
|
||||
case DO_MATCH:
|
||||
|
@ -362,31 +363,29 @@ distance(cindex) {
|
|||
return(20-2*exact+fromstackneeded);
|
||||
}
|
||||
|
||||
extern set_t unstackset;
|
||||
extern set_t unstackset; /* tables.c */
|
||||
|
||||
int from_stack(s1)
|
||||
register set_p s1;
|
||||
{
|
||||
register set_p s2 = &unstackset;
|
||||
register int i;
|
||||
static int from_stack(set_p s1) {
|
||||
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; {
|
||||
extern unsigned cc1,cc2,cc3,cc4;
|
||||
unsigned costcalc(cost_t cost) {
|
||||
extern unsigned cc1,cc2,cc3,cc4; /* tables.c */
|
||||
|
||||
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);
|
||||
|
@ -394,12 +393,12 @@ tsize(tp) register token_p tp; {
|
|||
}
|
||||
|
||||
#ifdef MAXSPLIT
|
||||
instsize(tinstno,tp) token_p tp; {
|
||||
static int instsize(int tinstno, token_p tp) {
|
||||
inst_p inp;
|
||||
struct reginfo *rp;
|
||||
|
||||
inp = &tokeninstances[tinstno];
|
||||
switch(inp->in_which) {
|
||||
switch (inp->in_which) {
|
||||
default:
|
||||
assert(FALSE);
|
||||
case IN_COPY:
|
||||
|
@ -427,9 +426,9 @@ 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);
|
||||
|
@ -446,10 +445,10 @@ tref(tp,amount) register token_p tp; {
|
|||
restore it and check whether a certain register is present in the
|
||||
saved stack
|
||||
*/
|
||||
token_t aside[MAXSAVE] ;
|
||||
int aside_length = -1 ;
|
||||
static token_t aside[MAXSAVE] ;
|
||||
static int aside_length = -1 ;
|
||||
|
||||
save_stack(tp) register token_p tp ; {
|
||||
static void save_stack(token_p tp) {
|
||||
int i ;
|
||||
token_p tmp = &fakestack[stackheight - 1];
|
||||
|
||||
|
@ -467,10 +466,10 @@ 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) {
|
||||
|
@ -493,8 +492,8 @@ gotone:
|
|||
return 1 ;
|
||||
}
|
||||
|
||||
rest_stack() {
|
||||
register int i ;
|
||||
static void rest_stack(void) {
|
||||
int i ;
|
||||
|
||||
assert(aside_length!= -1);
|
||||
#ifndef NDEBUG
|
||||
|
@ -508,11 +507,11 @@ rest_stack() {
|
|||
}
|
||||
|
||||
#ifdef MAXSPLIT
|
||||
split(tp,ip,ply,toplevel) token_p tp; register int *ip; {
|
||||
register c2_p cp;
|
||||
int 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;
|
||||
|
@ -542,7 +541,7 @@ found:
|
|||
}
|
||||
#endif /* MAXSPLIT */
|
||||
|
||||
unsigned docoerc(tp,cp,ply,toplevel,forced) token_p tp; register c3_p cp; {
|
||||
unsigned docoerc(token_p tp, c3_p cp, int ply, int toplevel, int forced) {
|
||||
unsigned cost;
|
||||
int tpl; /* saved tokpatlen */
|
||||
|
||||
|
@ -556,7 +555,7 @@ 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 stackupto(token_p limit, int ply, int toplevel) {
|
||||
token_t savestack[MAXFSTACK];
|
||||
token_p stp;
|
||||
int i,diff;
|
||||
|
@ -620,7 +619,7 @@ unsigned stackupto(limit,ply,toplevel) token_p limit; {
|
|||
return(totalcost);
|
||||
}
|
||||
|
||||
c3_p findcoerc(tp,tep) token_p tp; set_p tep; {
|
||||
c3_p findcoerc(token_p tp, set_p tep) {
|
||||
register c3_p cp;
|
||||
token_t rtoken;
|
||||
register i;
|
||||
|
@ -657,8 +656,8 @@ c3_p findcoerc(tp,tep) token_p tp; set_p tep; {
|
|||
return(0); /* nothing found */
|
||||
}
|
||||
|
||||
itokcost() {
|
||||
register tkdef_p tdp;
|
||||
void itokcost(void) {
|
||||
tkdef_p tdp;
|
||||
|
||||
for(tdp=tokens+1;tdp->t_size!=0;tdp++)
|
||||
tdp->t_cost.ct_space = costcalc(tdp->t_cost);
|
||||
|
@ -695,8 +694,8 @@ void fatal(const char *s, ...) {
|
|||
|
||||
#ifdef TABLEDEBUG
|
||||
|
||||
ruletrace() {
|
||||
register i;
|
||||
static void ruletrace(void) {
|
||||
int i;
|
||||
extern int tablelines[MAXTDBUG];
|
||||
extern int ntableline;
|
||||
extern char *tablename;
|
||||
|
|
|
@ -29,6 +29,8 @@ typedef char * string;
|
|||
#define WRD_FMT "%ld"
|
||||
#endif /* WRD_FMT */
|
||||
|
||||
/* codegen.c */
|
||||
unsigned codegen(byte *, int, int, unsigned, int);
|
||||
/* compute.c */
|
||||
string mystrcpy(string);
|
||||
string tostring(word);
|
||||
|
|
Loading…
Reference in a new issue