+ (FL_MSB_AT_LOW_ADDRESS ? 1 : 0))
#ifndef USE_FLT
-static int
-float_cst(str, sz, buf)
- char *str, *buf;
- int sz;
+static int float_cst(char *str, int sz, char *buf)
{
int i;
char *p;
#include <ctype.h>
#include <flt_arith.h>
-int
-float_cst(str, sz, buf)
- char *str, *buf;
- int sz;
+int float_cst(char *str, int sz, char *buf)
{
int overflow = 0;
flt_arith e;
#endif /* USE_FLT */
#ifdef CODE_GENERATOR
-con_float()
+void con_float()
{
char buf[8];
int rval = float_cst(str, (int)argval, buf);
#endif /* CODE_GENERATOR */
#ifdef CODE_EXPANDER
-con_float(str, argval)
- char *str;
- arith argval;
+void con_float(char *str, arith argval)
{
char buf[8];
int rval = float_cst(str, (int)argval, buf);
*
*/
-#ifndef NORCSID
-static char rcs_m[]= "$Id$" ;
-static char rcs_mh[]= ID_MH ;
-#endif
-
/*
* machine dependent back end routines for the Intel 8086
*/
-con_part(sz,w) register sz; word w; {
-
+void con_part(int sz, word w)
+{
while (part_size % sz)
part_size++;
if (part_size == TEM_WSIZE)
part_size += sz;
}
-con_mult(sz) word sz; {
+void con_mult(word sz)
+{
long l;
if (sz != 4)
full lbytes;
#endif
-prolog(nlocals) full nlocals; {
-
+void prolog(full nlocals)
+{
fputs("\tpush\tbp\n\tmov\tbp,sp\n", codefile);
#ifdef REGVARS
lbytes = nlocals;
long di_off;
int firstreg;
-regscore(off, size, typ, score, totyp)
- long off;
+int regscore(long off, int size, int typ, int score, int totyp)
{
if (size != 2) return -1;
score -= 1;
return score;
}
-i_regsave()
+void i_regsave()
{
si_off = -1;
di_off = -1;
firstreg = 0;
}
-f_regsave()
+void f_regsave()
{
if (si_off != di_off) {
if (di_off == -lbytes) lbytes -= 2;
fprintf(codefile, "mov si,%ld(bp)\n", si_off);
}
-regsave(regstr, off, size)
- char *regstr;
- long off;
+void regsave(char *regstr, long off, int size)
{
if (strcmp(regstr, "si") == 0) {
if (! firstreg) firstreg = -1;
}
}
-regreturn()
+void regreturn()
{
if (firstreg == 1) {
if (si_off != -1) fputs("jmp .sdret\n", codefile);
}
#endif /* REGVARS */
-mes(type) word type ; {
+void mes(word type)
+{
int argt ;
switch ( (int)type ) {
*/
/* $Id$ */
+#ifndef MACH_PROTO_NCG_ASSERT_H
+#define MACH_PROTO_NCG_ASSERT_H
+
#ifndef NDEBUG
#define assert(x) if(!(x)) badassertion("x",__FILE__,__LINE__)
#else
#define assert(x) /* nothing */
#endif
+
+#endif /* MACH_PROTO_NCG_ASSERT_H */
\ No newline at end of file
-#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 "assert.h"
#include "param.h"
#include "tables.h"
#include "state.h"
#include "equiv.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
- */
+#include "codegen.h"
+#include "utils.h"
+#include "salloc.h"
+#include "subr.h"
+#include "nextem.h"
+#include "fillem.h"
+#include "reg.h"
+#include "move.h"
+#include "gencode.h"
+#include "compute.h"
+#include "codegen.h"
+#include "mach_dep.h"
#define ALLOW_NEXTEM /* code generator is allowed new try of NEXTEM
in exceptional cases */
byte startupcode[] = { DO_NEXTEM };
-byte *nextem();
-unsigned costcalc();
-unsigned docoerc();
-unsigned stackupto();
-string tostring();
-string ad2str();
-
#ifdef NDEBUG
#define DEBUG(string)
#else
char *set_flag;
#endif
-unsigned codegen(codep,ply,toplevel,costlimit,forced) byte *codep; unsigned costlimit; {
+unsigned codegen(byte *codep, int ply, int toplevel, unsigned int costlimit, int forced)
+{
#ifndef NDEBUG
byte *origcp=codep;
static int level=0;
byte *bp;
int n;
unsigned mindistance,dist;
- register i;
+ int i;
int cindex;
int npos,pos[MAXRULE];
unsigned mincost,t;
case DO_XXMATCH:
DEBUG("XXMATCH");
case DO_XMATCH: {
- register i;
+ int i;
int temp;
DEBUG("XMATCH");
break; /* match already checked by distance() */
}
case DO_MATCH: {
- register i;
+ int i;
int j;
unsigned mincost,t;
token_p tp;
token_p regtp[MAXCREG];
c3_p regcp[MAXCREG];
rl_p regls[MAXCREG];
- c3_p cp,findcoerc();
+ c3_p cp;
#ifdef MAXSPLIT
int sret;
#endif
int stackpad = 0;
- struct perm *tup,*ntup,*besttup,*tuples();
+ struct perm *tup,*ntup,*besttup;
DEBUG("MATCH");
tokpatlen=(codep[-1]>>5)&07;
}
case DO_KILLREG:
case DO_RREMOVE: { /* register remove */
- register i;
+ int i;
int nodeno;
token_p tp;
tkdef_p tdp;
break;
}
case DO_DEALLOCATE: {
- register i;
+ int i;
tkdef_p tdp;
int tinstno;
token_t token;
break;
}
case DO_ALLOCATE: {
- register i;
+ int i;
int j;
int tinstno;
int npos,npos2,pos[NREGS],pos2[NREGS];
if (!forced) {
do {
npos=exactmatch=0;
- for(rpp=reglist[propno];rp= *rpp; rpp++)
+ for(rpp=reglist[propno] ; (rp= *rpp) ; rpp++)
if (getrefcount((int)(rp-machregs), FALSE)==0) {
pos[npos++] = rp-machregs;
if (eqtoken(&rp->r_contents,&token))
break;
}
case DO_INSTR: {
- register i;
+ int i;
int n;
int tinstno;
token_t token;
break;
}
case DO_TOKREPLACE: {
- register i;
+ int i;
int tinstno;
int repllen;
token_t reptoken[MAXREPLLEN];
break;
}
case DO_EMREPLACE: {
- register i;
+ int i;
int j;
int nodeno;
result_t result[MAXEMREPLLEN];
return(totalcost);
}
-readcodebytes() {
+void readcodebytes()
+{
#ifndef CODEINC
- register fd;
+ int fd;
extern int ncodebytes;
if ((fd=open("code",0))<0) {
}
#ifdef TABLEDEBUG
-initlset(f) char *f; {
- extern char *myalloc();
-
+void initlset(char *f)
+{
set_flag = f;
if ((set_fd=open(f+1,2))<0)
error("Can't open %s rw",f+1);
read(set_fd,set_val,set_size);
}
-termlset() {
-
+void termlset()
+{
if (set_fd) {
lseek(set_fd,(long) sizeof(int),0);
write(set_fd,set_val,set_size);
close(set_fd);
if (set_flag[0]=='u') {
- register i;
+ int i;
fprintf(stderr,"Unused code rules:\n\n");
for(i=0;i<8*set_size;i++)
--- /dev/null
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+#ifndef MACH_PROTO_NCG_CODEGEN_H
+#define MACH_PROTO_NCG_CODEGEN_H
+
+/* mach/proto/ncg/codegen.c */
+unsigned codegen(byte *codep, int ply, int toplevel, unsigned int costlimit, int forced);
+void readcodebytes(void);
+
+#ifdef TABLEDEBUG
+void initlset(char *f);
+void termlset();
+#endif
+
+#endif /* MACH_PROTO_NCG_CODEGEN_H */
+
-#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 "result.h"
#include "glosym.h"
#include "extern.h"
+#include "salloc.h"
+#include "utils.h"
+#include "regvar.h"
#ifdef USE_TES
#include "label.h"
#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 "compute.h"
#define LLEAF 01
#define LDEF 02
LLDEF, /* EX_TOSTRING */
LLDEF, /* EX_UMINUS */
0, /* EX_REG */
- 0, /* EX_LOWW */
- 0, /* EX_HIGHW */
- LLDEF, /* EX_INREG */
- LLDEF, /* EX_REGVAR */
- LLDEF|RLDEF, /* EX_OR */
- LLDEF|RLDEF, /* EX_XOR */
- LLDEF|RLDEF, /* EX_AND */
- 0, /* EX_ISROM */
+ 0, /* EX_LOWW */
+ 0, /* EX_HIGHW */
+ LLDEF, /* EX_INREG */
+ LLDEF, /* EX_REGVAR */
+ LLDEF|RLDEF, /* EX_OR */
+ LLDEF|RLDEF, /* EX_XOR */
+ LLDEF|RLDEF, /* EX_AND */
+ 0, /* EX_ISROM */
#ifdef USE_TES
- 0, /* EX_TOPELTSIZE */
- 0, /* EX_FALLTHROUGH */
+ 0, /* EX_TOPELTSIZE */
+ 0, /* EX_FALLTHROUGH */
#endif
};
-string salloc(),strcpy(),strcat();
-
-string mycat(s1,s2) register string s1,s2; {
- register string s;
+string mycat(string s1, string s2)
+{
+ string s;
if (s1==0 || *s1=='\0') return(s2);
if (s2==0 || *s2=='\0') return(s1);
return(s);
}
-string mystrcpy(s) register string s; {
- register string r;
+string mystrcpy(string s)
+{
+ string r;
r=salloc(strlen(s));
strcpy(r,s);
char digstr[21][15];
-string tostring(n) register word n; {
+string tostring(word n)
+{
char buf[25];
if (n>=-20 && n<=20 && (n&1)==0) {
return(mystrcpy(buf));
}
-compute(node, presult) register node_p node; register result_t *presult; {
+void compute(node_p node, result_t *presult)
+{
result_t leaf1,leaf2;
- register token_p tp;
+ token_p tp;
int desc;
long mask,tmp;
int i,tmpreg;
--- /dev/null
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+#ifndef MACH_PROTO_NCG_COMPUTE_H
+#define MACH_PROTO_NCG_COMPUTE_H
+
+/* mach/proto/ncg/compute.c */
+string mycat(string s1, string s2);
+string mystrcpy(string s);
+string tostring(long n);
+void compute(node_p node, result_t *presult);
+
+#endif /* MACH_PROTO_NCG_COMPUTE_H */
+
*/
/* $Id$ */
+#ifndef MACH_PROTO_NCG_DATA_H
+#define MACH_PROTO_NCG_DATA_H
+
typedef struct cost {
short ct_space;
short ct_time;
int rl_n; /* number in list */
int rl_list[NREGS];
} rl_t,*rl_p;
+
+#endif /* MACH_PROTO_NCG_DATA_H */
\ No newline at end of file
-#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 "assert.h"
-#include "equiv.h"
#include "param.h"
#include "tables.h"
#include "types.h"
#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
- */
-
-extern string myalloc();
+#include "salloc.h"
+#include "reg.h"
+#include "subr.h"
+#include "utils.h"
+#include "equiv.h"
int rar[MAXCREG];
rl_p *lar;
int regclass[NREGS];
struct perm *perms;
-struct perm *
-tuples(regls,nregneeded) rl_p *regls; {
+struct perm *tuples(rl_p *regls, int nregneeded)
+{
int class=0;
- register i,j;
- register struct reginfo *rp;
+ int i,j;
+ struct reginfo *rp;
/*
* First compute equivalence classes of registers.
return(perms);
}
-permute(index) {
- register struct perm *pp;
- register rl_p rlp;
- register i,j;
+void permute(int index)
+{
+ struct perm *pp;
+ rl_p rlp;
+ int i,j;
if (index == maxindex) {
for (pp=perms; pp != 0; pp=pp->p_next) {
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* $Id$ */
+#ifndef MACH_PROTO_NCG_EQUIV_H
+#define MACH_PROTO_NCG_EQUIV_H
#define MAXCREG 4
struct perm *p_next;
int p_rar[MAXCREG];
};
+
+struct perm *tuples(rl_p *regls, int nregneeded);
+void permute(int index);
+
+#endif /* MACH_PROTO_NCG_EQUIV_H */
\ No newline at end of file
*/
/* $Id$ */
+#ifndef MACH_PROTO_NCG_EXTERN_H
+#define MACH_PROTO_NCG_EXTERN_H
+
extern int maxply; /* amount of lookahead allowed */
extern int stackheight; /* # of tokens on fakestack */
extern token_t fakestack[]; /* fakestack itself */
extern int nregvar[]; /* # of register variables per type */
extern int *rvnumbers[]; /* lists of numbers */
#endif
+
+#endif /* MACH_PROTO_NCG_EXTERN_H */
\ No newline at end of file
-#ifndef NORCSID
-static char rcsid2[] = "$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 <cgg_cg.h>
#include "data.h"
#include "result.h"
+#include "salloc.h"
+#include "utils.h"
#ifdef REGVARS
#include "regvar.h"
#include <em_reg.h>
#endif
+#include "fillem.h"
+#include "gencode.h"
+#include "glosym.h"
+#include "label.h"
+#include "reg.h"
+#include "mach_dep.h"
+#include "compute.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
- */
-
#ifndef newplb /* retrofit for older mach.h */
#define newplb newilb
#endif
#ifdef fmt_id
#ifdef id_first
-It is an error to define both fmt_id and id_first.
-Read the documentation.
+#error It is an error to define both fmt_id and id_first. Read the documentation.
#endif
#endif
#ifdef fmt_ilb
#ifdef ilb_fmt
-It is an error to define both fmt_ilb and ilb_fmt.
-Read the documentation.
+#error It is an error to define both fmt_ilb and ilb_fmt. Read the documentation.
#endif
#endif
#define SEGROM 2
#define SEGBSS 3
-long con();
-
#define get8() getc(emfile)
FILE *emfile;
extern FILE *codefile;
-extern FILE *freopen();
int nextispseu,savetab1;
int opcode;
extern char em_flag[];
extern short em_ptyp[];
-extern double atof();
/* Own version of atol that continues computing on overflow.
We don't know that about the ANSI C one.
*/
-long our_atol(s)
-register char *s;
+long our_atol(char *s)
{
- register long total = 0;
- register unsigned digit;
+ long total = 0;
+ unsigned digit;
int minus = 0;
while (*s == ' ' || *s == '\t') s++;
#define sp_cstx sp_cst2
-string tostring();
-string holstr();
-string strarg();
-string mystrcpy();
-string myalloc();
-long get32();
-
-in_init(filename) char *filename; {
-
+void in_init(char *filename)
+{
emfile = stdin;
if (filename && (emfile=freopen(filename,"r",stdin))==NULL)
error("Can't open %s",filename);
str = myalloc(maxstrsiz=256);
}
-in_start() {
+void in_start()
+{
#ifdef modhead
fprintf(codefile,"%s",modhead) ;
#endif
}
-in_finish() {
+void in_finish()
+{
}
-fillemlines() {
- register int t,i;
- register struct emline *lp;
+void fillemlines()
+{
+ int t,i;
+ struct emline *lp;
while ((emlines+nemlines)-emp<MAXEMLINES-5) {
assert(nemlines<MAXEMLINES);
}
}
-dopseudo() {
- register b,t;
- register full n;
- register long save;
+void dopseudo() {
+ int b,t;
+ full n;
+ long save;
word romcont[MAXROM+1];
int nromwords;
int rombit,rommask;
- unsigned stackupto();
if (nextispseu==0 || nemlines>0)
error("No table entry for %d",emlines[0].em_instr);
return(argtyp);
}
-int table1() {
- register i;
+int table1()
+{
+ int i;
i = get8();
if (i < sp_fmnem+sp_nmnem && i >= sp_fmnem) {
return(table3(i));
}
-int table2() {
- register i;
+int table2()
+{
+ int i;
i = get8();
if (i < sp_fcst0+sp_ncst0 && i >= sp_fcst0) {
return(table3(i));
}
-int table3(i) {
+int table3(int i)
+{
word consiz;
switch(i) {
return(i);
}
-int get16() {
- register int l_byte, h_byte;
+int get16()
+{
+ int l_byte, h_byte;
l_byte = get8();
h_byte = get8();
return l_byte | (h_byte*256) ;
}
-long get32() {
- register long l;
- register int h_byte;
+long get32()
+{
+ long l;
+ int h_byte;
l = get8();
l |= ((unsigned) get8())*256 ;
return l | (h_byte*256L*256*256L) ;
}
-getstring() {
- register char *p;
- register n;
+void getstring()
+{
+ char *p;
+ int n;
getarg(cst_ptyp);
if (argval < 0)
*p++ = '\0';
}
-char *strarg(t) {
- register char *p;
+char *strarg(int t)
+{
+ char *p;
switch (t) {
case sp_ilb1:
return(mystrcpy(argstr));
}
-bss(n,t,b) full n; {
- register long s = 0;
+void bss(full n, int t, int b)
+{
+ long s = 0;
if (n % TEM_WSIZE)
fatal("bad BSS size");
fatal("bad BSS initializer");
}
-long con(t) {
- register i;
+long con(int t)
+{
+ int i;
strarg(t);
switch (t) {
}
assert(FALSE);
/* NOTREACHED */
+ return 0;
}
extern char *segname[];
-swtxt() {
+void swtxt()
+{
switchseg(SEGTXT);
}
-switchseg(s) {
-
+void switchseg(int s)
+{
if (s == curseg)
return;
part_flush();
fprintf(codefile,"%s\n",segname[s]);
}
-savelab() {
- register char *p,*q;
+void savelab()
+{
+ char *p,*q;
part_flush();
if (labstr[0]) {
}
p = argstr;
q = labstr;
- while (*q++ = *p++)
+ while ( (*q++ = *p++) )
;
}
-dumplab() {
-
+void dumplab()
+{
if (labstr[0] == 0)
return;
assert(part_size == 0);
labstr[0] = 0;
}
-xdumplab() {
-
+void xdumplab()
+{
if (labstr[0] == 0)
return;
assert(part_size == 0);
newdlb(labstr);
}
-part_flush() {
-
+void part_flush()
+{
/*
* Each new data fragment and each data label starts at
* a new target machine word
part_word = 0;
}
-string holstr(n) word n; {
-
+string holstr(word n)
+{
sprintf(str,hol_off,n,holno);
return(mystrcpy(str));
}
--- /dev/null
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+#ifndef MACH_PROTO_NCG_FILLEM_H
+#define MACH_PROTO_NCG_FILLEM_H
+
+/* mach/proto/ncg/fillem.c */
+long our_atol(char *s);
+void in_init(char *filename);
+void in_start(void);
+void in_finish(void);
+void fillemlines(void);
+void dopseudo(void);
+int getarg(int typset);
+int table1(void);
+int table2(void);
+int table3(int i);
+int get16(void);
+long get32(void);
+void getstring(void);
+char *strarg(int t);
+void bss(int n, int t, int b);
+long con(int t);
+void swtxt(void);
+void switchseg(int s);
+void savelab(void);
+void dumplab(void);
+void xdumplab(void);
+void part_flush(void);
+string holstr(long n);
+
+#endif /* MACH_PROTO_NCG_FILLEM_H */
+
-#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 "assert.h"
+#include <unistd.h>
#include <stdio.h>
#include "param.h"
#include "tables.h"
#include "data.h"
#include "result.h"
#include "extern.h"
+#include "compute.h"
+#include "utils.h"
+#include "gencode.h"
#ifdef USE_TES
#include "mach.h"
#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
- */
-
-string mystrcpy();
-
FILE *codefile;
-extern FILE *freopen();
-
-out_init(filename) char *filename; {
+void out_init(char *filename)
+{
#ifndef NDEBUG
static char stderrbuff[BUFSIZ];
#endif
}
-out_finish() {
-
+void out_finish()
+{
#ifndef NDEBUG
if (Debug)
fflush(stderr);
#endif
}
-tstoutput() {
-
+void tstoutput()
+{
if (ferror(codefile))
error("Write error on output");
}
-genstr(stringno) {
-
+void genstr(int stringno)
+{
fputs(codestrings[stringno],codefile);
}
-string ad2str(ad) addr_t ad; {
+string ad2str(addr_t ad)
+{
static char buf[100];
if (ad.ea_str==0)
return(mystrcpy(buf));
}
-praddr(ad) addr_t ad; {
-
+void praddr(addr_t ad)
+{
if (ad.ea_str==0 || *(ad.ea_str) == '\0')
fprintf(codefile,WRD_FMT,ad.ea_off);
else {
}
}
-gennl() {
+void gennl()
+{
putc('\n',codefile);
}
-prtoken(tp,leadingchar) token_p tp; {
- register c;
- register char *code;
- register tkdef_p tdp;
+void prtoken(token_p tp, int leadingchar)
+{
+ int c;
+ char *code;
+ tkdef_p tdp;
putc(leadingchar,codefile);
if (tp->t_token == -1) {
}
#ifdef USE_TES
-printlabel(labnum)
-int labnum;
+void printlabel(int labnum)
{
newilb(dollar[labnum].e_v.e_addr.ea_str);
}
--- /dev/null
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+#ifndef MACH_PROTO_NCG_GENCODE_H
+#define MACH_PROTO_NCG_GENCODE_H
+
+/* mach/proto/ncg/gencode.c */
+void out_init(char *filename);
+void out_finish(void);
+void tstoutput(void);
+void genstr(int stringno);
+string ad2str(addr_t ad);
+void praddr(addr_t ad);
+void gennl(void);
+void prtoken(token_p tp, int leadingchar);
+void printlabel(int labnum);
+
+#endif /* MACH_PROTO_NCG_GENCODE_H */
+
-#ifndef NORCSID
-static char rcsid[] = "$Id$";
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include "param.h"
-#include "tables.h"
-#include "types.h"
-#include "glosym.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
*/
-
-extern string myalloc();
+#include <stdlib.h>
+#include <string.h>
+#include "param.h"
+#include "tables.h"
+#include "types.h"
+#include "glosym.h"
+#include "salloc.h"
+#include "glosym.h"
glosym_p glolist= (glosym_p) 0;
-enterglo(name,romp) string name; word *romp; {
- register glosym_p gp;
- register i;
+void enterglo(string name, word *romp)
+{
+ glosym_p gp;
+ int i;
gp = (glosym_p) myalloc(sizeof *gp);
gp->gl_next = glolist;
glolist = gp;
}
-glosym_p lookglo(name) string name; {
- register glosym_p gp;
+glosym_p lookglo(string name)
+{
+ glosym_p gp;
for (gp=glolist;gp != (glosym_p) 0; gp=gp->gl_next)
if (strcmp(gp->gl_name,name)==0)
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* $Id$ */
+#ifndef MACH_PROTO_NCG_GLOSYM_H
+#define MACH_PROTO_NCG_GLOSYM_H
typedef struct glosym {
struct glosym *gl_next;
word gl_rom[MAXROM+1];
} glosym_t,*glosym_p;
-glosym_p lookglo();
+void enterglo(string name, word *romp);
+glosym_p lookglo(string name);
+
+#endif /* MACH_PROTO_NCG_GLOSYM_H */
\ No newline at end of file
#include "types.h"
#include "param.h"
#include "label.h"
+#include "salloc.h"
+#include "utils.h"
+#include "label.h"
static label_p label_list = (label_p)0;
-extern char *myalloc();
-add_label(num, height, flth)
+void add_label(int num, int height, int flth)
{
- register label_p lbl = (label_p)0;
+ label_p lbl = (label_p)0;
if (height <= 0) return;
if (flth != TRUE && flth != FALSE)
label_list = lbl;
}
-label_p get_label(num)
-register word num;
+label_p get_label(word num)
{
- register label_p tmp = label_list;
+ label_p tmp = label_list;
while (tmp != (label_p)0) {
if (tmp->lb_number == num) return tmp;
return (label_p)0;
}
-kill_labels()
+void kill_labels()
{
label_p tmp;
*
* Author: Hans van Eck.
*/
+#ifndef MACH_PROTO_NCG_LABEL_H
+#define MACH_PROTO_NCG_LABEL_H
typedef struct label *label_p;
short lb_fallthrough;
};
-extern label_p get_label();
+void add_label(int num, int height, int flth);
+label_p get_label(word num);
+void kill_labels();
+
+#endif /* MACH_PROTO_NCG_LABEL_H */
\ No newline at end of file
--- /dev/null
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+#ifndef MACH_PROTO_NCG_MACH_DEP_H
+#define MACH_PROTO_NCG_MACH_DEP_H
+
+/* Function prototypes that must be exported by specific machines */
+void regreturn(void);
+void mes(word type);
+void prolog(full nlocals);
+void con_part(int sz, word w);
+void con_mult(word sz);
+void con_float(void);
+int regscore(long off, int size, int typ, int score, int totyp);
+void i_regsave();
+void f_regsave();
+void regsave(char *regstr, long off, int size);
+void regreturn();
+
+#endif /* MACH_PROTO_NCG_MACH_DEP_H */
-#ifndef NORCSID
-static char rcsid[] = "$Id$";
-#endif
-
-#include "param.h"
-#include "tables.h"
-#include "mach.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
*/
+#include <stdlib.h>
+#include "mach.h"
+#include "param.h"
+#include "tables.h"
+#include "types.h"
+#include "param.h"
+#include "data.h"
+#include <cgg_cg.h>
+#include "tables.h"
+#include "mach.h"
+#include "fillem.h"
+#include "gencode.h"
+#include "codegen.h"
+#include "subr.h"
+#include "utils.h"
char *progname;
extern char startupcode[];
-extern unsigned codegen();
int maxply=1;
#ifndef NDEBUG
int Debug=0;
char *strtdebug="";
#endif
-main(argc,argv) char **argv; {
- register unsigned n;
+static unsigned int ggd(unsigned int a, unsigned int b)
+{
+ unsigned int c;
+
+ do {
+ c = a%b; a=b; b=c;
+ } while (c!=0);
+ return(a);
+}
+
+int main(int argc, char *argv[])
+{
+ unsigned n;
extern unsigned cc1,cc2,cc3,cc4;
- unsigned ggd();
progname = argv[0];
while (--argc && **++argv == '-') {
codegen(startupcode,maxply,TRUE,MAXINT,0);
error("Bombed out of codegen");
}
-
-unsigned ggd(a,b) register unsigned a,b; {
- register unsigned c;
-
- do {
- c = a%b; a=b; b=c;
- } while (c!=0);
- return(a);
-}
-#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 "assert.h"
#include "param.h"
#include "tables.h"
#include "data.h"
#include "result.h"
#include "extern.h"
+#include "subr.h"
+#include "reg.h"
+#include "utils.h"
+#include "codegen.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
- */
+#include "move.h"
-move(tp1,tp2,ply,toplevel,maxcost) token_p tp1,tp2; unsigned maxcost; {
- register move_p mp;
- unsigned t;
- register struct reginfo *rp;
- register byte *tdpb;
+int move(token_p tp1, token_p tp2, int ply, int toplevel, unsigned int maxcost)
+{
+ move_p mp;
+ unsigned int t;
+ struct reginfo *rp;
+ byte *tdpb;
int i;
- unsigned codegen();
if (eqtoken(tp1,tp2))
return(0);
#define cocoreg machregs[0].r_contents
-setcc(tp) token_p tp; {
-
+void setcc(token_p tp)
+{
cocoreg = *tp;
}
-test(tp,ply,toplevel,maxcost) token_p tp; unsigned maxcost; {
- register test_p mp;
- unsigned t;
- unsigned codegen();
+int test(token_p tp, int ply, int toplevel, unsigned int maxcost)
+{
+ test_p mp;
+ unsigned int t;
if (cocoreg.t_token!=0) {
if (eqtoken(tp,&cocoreg))
--- /dev/null
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+#ifndef MACH_PROTO_NCG_MOVE_H
+#define MACH_PROTO_NCG_MOVE_H
+
+/* mach/proto/ncg/move.c */
+int move(token_p tp1, token_p tp2, int ply, int toplevel, unsigned int maxcost);
+void setcc(token_p tp);
+int test(token_p tp, int ply, int toplevel, unsigned int maxcost);
+
+#endif /* MACH_PROTO_NCG_MOVE_H */
+
-#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 <em_spec.h>
#include <em_flag.h>
#include "assert.h"
#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
- */
+#include "compute.h"
+#include "fillem.h"
+#include "nextem.h"
#ifndef NDEBUG
#include <stdio.h>
extern char em_mnem[][4];
#endif
-byte *trypat(bp,len) register byte *bp; {
- register patlen,i;
+byte *trypat(byte *bp, int len)
+{
+ int patlen,i;
result_t result;
getint(patlen,bp);
extern char em_flag[];
-argtyp(mn) {
-
+int argtyp(int mn)
+{
switch(em_flag[mn-sp_fmnem]&EM_PAR) {
case PAR_W:
case PAR_S:
}
}
-byte *nextem(toplevel) {
- register i;
+byte *nextem(int toplevel)
+{
+ int i;
short hash[3];
- register byte *bp;
+ byte *bp;
byte *cp;
int index;
- register struct emline *ep;
+ struct emline *ep;
if (toplevel) {
if (nemlines && emp>emlines) {
--- /dev/null
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+#ifndef MACH_PROTO_NCG_NEXTEM_H
+#define MACH_PROTO_NCG_NEXTEM_H
+
+/* mach/proto/ncg/nextem.c */
+byte *trypat(byte *bp, int len);
+int argtyp(int mn);
+byte *nextem(int toplevel);
+
+#endif /* MACH_PROTO_NCG_NEXTEM_H */
+
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* $Id$ */
+#ifndef MACH_PROTO_NCG_PARAM_H
+#define MACH_PROTO_NCG_PARAM_H
#define BMASK 0377
#define BSHIFT 8
#define MAXEMLINES 20
#define MAXFSTACK 20
#define MAXTDBUG 32
+
+#endif /* MACH_PROTO_NCG_PARAM_H */
\ No newline at end of file
cfile_with_tables (d.."state.c"),
cfile_with_tables (d.."subr.c"),
cfile_with_tables (d.."var.c"),
+ cfile_with_tables (d.."utils.c"),
cfile {
ith { make_tables, i = 1 },
-#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 "assert.h"
#include "param.h"
#include "tables.h"
#include "data.h"
#include "result.h"
#include "extern.h"
+#include "utils.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
- */
+#include "reg.h"
-chrefcount(regno,amount,tflag) {
- register struct reginfo *rp;
+void chrefcount(int regno, int amount, int tflag)
+{
+ struct reginfo *rp;
#if MAXMEMBERS != 0
- register i, tmp;
+ int i, tmp;
#endif
rp= &machregs[regno];
#endif
}
-getrefcount(regno, tflag) {
- register struct reginfo *rp;
+int getrefcount(int regno, int tflag)
+{
+ struct reginfo *rp;
#if MAXMEMBERS != 0
- register i,maxcount, tmp;
+ int i,maxcount, tmp;
#endif
rp= &machregs[regno];
}
return(maxcount);
}
+ return 0;
#endif
}
-erasereg(regno) {
- register struct reginfo *rp = &machregs[regno];
- register int i;
- register byte *tdpb;
+void erasereg(int regno)
+{
+ struct reginfo *rp = &machregs[regno];
+ int i;
+ byte *tdpb;
#if MAXMEMBERS==0
rp->r_contents.t_token = 0;
}
#else
extern short clashlist[];
- register short *sp = &clashlist[rp->r_iclash];
+ short *sp = &clashlist[rp->r_iclash];
rp->r_contents.t_token = 0;
while (*sp) {
#endif
}
-cleanregs() {
- register struct reginfo *rp;
- register i;
+void cleanregs()
+{
+ struct reginfo *rp;
+ int i;
for (rp=machregs;rp<machregs+NREGS;rp++) {
rp->r_contents.t_token = 0;
}
#ifndef NDEBUG
-inctcount(regno) {
- register struct reginfo *rp;
- register i;
+void inctcount(int regno)
+{
+ struct reginfo *rp;
+ int i;
rp = &machregs[regno];
#if MAXMEMBERS!=0
#endif
}
-chkregs() {
- register struct reginfo *rp;
- register token_p tp;
- register byte *tdpb;
+void chkregs()
+{
+ struct reginfo *rp;
+ token_p tp;
+ byte *tdpb;
int i;
for (rp=machregs+1;rp<machregs+NREGS;rp++) {
--- /dev/null
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+#ifndef MACH_PROTO_NCG_REG_H
+#define MACH_PROTO_NCG_REG_H
+
+/* mach/proto/ncg/reg.c */
+void chrefcount(int regno, int amount, int tflag);
+int getrefcount(int regno, int tflag);
+void erasereg(int regno);
+void cleanregs(void);
+void inctcount(int regno);
+void chkregs(void);
+
+#endif /* MACH_PROTO_NCG_REG_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
+ */
#include "assert.h"
#include "param.h"
#include "tables.h"
#ifdef REGVARS
-#ifndef NORCSID
-static char rcsid[] = "$Id$";
-#endif
-
#include "types.h"
#include <cgg_cg.h>
#include "data.h"
#include <em_reg.h>
#include "result.h"
#include "extern.h"
+#include "utils.h"
+#include "salloc.h"
+#include "reg.h"
+#include "fillem.h"
+#include "mach_dep.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
- */
-extern string myalloc();
struct regvar *rvlist;
-struct regvar *
-linkreg(of,sz,tp,sc) long of; {
- register struct regvar *rvlp;
+struct regvar *linkreg(long of, int sz, int tp, int sc)
+{
+ struct regvar *rvlp;
rvlp= (struct regvar *) myalloc(sizeof *rvlp);
rvlp->rv_next = rvlist;
return(rvlp);
}
-tryreg(rvlp,typ) register struct regvar *rvlp; {
+void tryreg(struct regvar *rvlp, int typ)
+{
int score;
- register i;
- register struct regassigned *ra;
+ int i;
+ struct regassigned *ra;
struct regvar *save;
if (typ != reg_any && nregvar[typ]!=0) {
}
}
-fixregvars(saveall) {
- register struct regvar *rv;
- register rvtyp,i;
-
+void fixregvars(int saveall)
+{
+ struct regvar *rv;
+ int rvtyp,i;
+
swtxt();
i_regsave(); /* machine dependent initialization */
for (rvtyp=reg_any;rvtyp<=reg_float;rvtyp++) {
f_regsave();
}
-isregvar(off) long off; {
- register struct regvar *rvlp;
+int isregvar(long off)
+{
+ struct regvar *rvlp;
for(rvlp=rvlist;rvlp!=0;rvlp=rvlp->rv_next)
if(rvlp->rv_off == off)
return(-1);
}
-isregtyp(off) long off; {
- register struct regvar *rvlp;
+int isregtyp(long off)
+{
+ struct regvar *rvlp;
for(rvlp=rvlist;rvlp!=0;rvlp=rvlp->rv_next)
if(rvlp->rv_off == off)
return(-1);
}
-unlinkregs() {
- register struct regvar *rvlp,*t;
- register struct regassigned *ra;
+void unlinkregs()
+{
+ struct regvar *rvlp,*t;
+ struct regassigned *ra;
int rvtyp,i;
for(rvlp=rvlist;rvlp!=0;rvlp=t) {
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* $Id$ */
+#ifndef MACH_PROTO_NCG_REGVAR_H
+#define MACH_PROTO_NCG_REGVAR_H
struct regvar {
struct regvar *rv_next;
extern struct regvar *rvlist;
extern int nregvar[];
extern struct regassigned *regassigned[];
+
+struct regvar *linkreg(long of, int sz, int tp, int sc);
+void tryreg(struct regvar *rvlp, int typ);
+void fixregvars(int saveall);
+int isregvar(long off);
+int isregtyp(long off);
+void unlinkregs();
+
+#endif /* MACH_PROTO_NCG_REGVAR_H */
\ No newline at end of file
*/
/* $Id$ */
+#ifndef MACH_PROTO_NCG_RESULT_H
+#define MACH_PROTO_NCG_RESULT_H
+
struct result {
int e_typ; /* EV_INT,EV_REG,EV_STR */
union {
#define EV_ADDR 3
typedef struct result result_t;
+
+#endif /* MACH_PROTO_NCG_RESULT_H */
\ No newline at end of file
-#ifndef NORCSID
-static char rcsid[] = "$Id$";
-#endif
-
-#include <stdlib.h>
-#include "assert.h"
-#include "param.h"
-#include "tables.h"
-#include "types.h"
-#include <cgg_cg.h>
-#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".
* Call salloc(size) to get room for string.
* Every now and then call garbage_collect() from toplevel.
*/
+#include <stdlib.h>
+#include "assert.h"
+#include "param.h"
+#include "tables.h"
+#include "types.h"
+#include <cgg_cg.h>
+#include "data.h"
+#include "result.h"
+#include "extern.h"
+#include "utils.h"
+
+#include "salloc.h"
#define MAXSTAB 1500
#define THRESHOLD 200
char *stab[MAXSTAB];
int nstab=0;
-string myalloc(size) {
- register string p;
+string myalloc(int size)
+{
+ string p;
p = (string) malloc((unsigned)size);
if (p==0)
return(p);
}
-myfree(p) string p; {
-
+void myfree(string p)
+{
free(p);
}
-popstr(nnstab) {
- register i;
+void popstr(int nnstab)
+{
+ int i;
for (i=nnstab;i<nstab;i++)
myfree(stab[i]);
nstab = nnstab;
}
-char *salloc(size) {
- register char *p;
+char *salloc(int size)
+{
+ char *p;
if (nstab==MAXSTAB)
fatal("String table overflow");
return(p);
}
-compar(p1,p2) char **p1,**p2; {
-
+int compar(const void *vp1, const void *vp2)
+{
+ char **p1 = (char **)vp1;
+ char **p2 = (char **)vp2;
assert(*p1 != *p2);
if (*p1 < *p2)
return(-1);
return(1);
}
-garbage_collect() {
- register i;
+void garbage_collect()
+{
+ int i;
struct emline *emlp;
token_p tp;
tkdef_p tdp;
struct reginfo *rp;
- register char **fillp,**scanp;
+ char **fillp,**scanp;
char used[MAXSTAB]; /* could be bitarray */
if (nstab<THRESHOLD)
nstab = fillp-stab;
}
-chkstr(str,used) string str; char used[]; {
- register low,middle,high;
+void chkstr(string str, char used[])
+{
+ int low,middle,high;
low=0; high=nstab-1;
while (high>low) {
--- /dev/null
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+#ifndef MACH_PROTO_NCG_SALLOC_H
+#define MACH_PROTO_NCG_SALLOC_H
+
+/* mach/proto/ncg/salloc.c */
+string myalloc(int size);
+void myfree(string p);
+void popstr(int nnstab);
+char *salloc(int size);
+int compar(const void *vp1, const void *vp2);
+void garbage_collect(void);
+void chkstr(string str, char used[]);
+
+#endif /* MACH_PROTO_NCG_SALLOC_H */
+
-#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 "assert.h"
#include "param.h"
#include "tables.h"
#include "result.h"
#include "state.h"
#include "extern.h"
+#include "salloc.h"
+#include "utils.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
- */
+#include "state.h"
extern int nstab; /* salloc.c */
-savestatus(sp) register state_p sp; {
-
+void savestatus(state_p sp)
+{
sp->st_sh = stackheight;
bmove((short *)fakestack,(short *)sp->st_fs,stackheight*sizeof(token_t));
sp->st_na = nallreg;
sp->st_ns = nstab;
}
-restorestatus(sp) register state_p sp; {
-
+void restorestatus(state_p sp)
+{
stackheight = sp->st_sh;
bmove((short *)sp->st_fs,(short *)fakestack,stackheight*sizeof(token_t));
nallreg = sp->st_na;
popstr(sp->st_ns);
}
-bmove(from,to,nbytes) register short *from,*to; register nbytes; {
-
+void bmove(short *from, short *to, int nbytes)
+{
if (nbytes<=0)
return;
assert(sizeof(short)==2 && (nbytes&1)==0);
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* $Id$ */
+#ifndef MACH_PROTO_NCG_STATE_H
+#define MACH_PROTO_NCG_STATE_H
typedef struct state {
struct state *st_next; /* for linked list */
int st_tl; /* tokpatlen */
int st_ns; /* nstab */
} state_t,*state_p;
+
+void savestatus(state_p sp);
+void restorestatus(state_p sp);
+void bmove(short *from, short *to, int nbytes);
+
+#endif /* MACH_PROTO_NCG_STATE_H */
\ No newline at end of file
-#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"
#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;
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
}
}
-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;
}
}
-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);
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;
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;
}
#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);
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];
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) {
return 1 ;
}
-rest_stack() {
- register int i ;
+void rest_stack()
+{
+ int i ;
assert(aside_length!= -1);
#ifndef NDEBUG
}
#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;
}
#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) ;
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--) {
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) {
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
--- /dev/null
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+#ifndef MACH_PROTO_NCG_SUBR_H
+#define MACH_PROTO_NCG_SUBR_H
+
+/* mach/proto/ncg/subr.c */
+int match(token_p tp, set_p tep, int optexp);
+void instance(int instno, token_p token);
+void cinstance(int instno, token_p token, token_p tp, int regno);
+int eqtoken(token_p tp1, token_p tp2);
+int distance(int cindex);
+int from_stack(set_p s1);
+unsigned int costcalc(cost_t cost);
+int ssize(int tokexpno);
+int tsize(token_p p);
+void tref(token_p tp, int amount);
+void save_stack(token_p tp);
+int in_stack(int reg);
+void rest_stack(void);
+unsigned int docoerc(token_p tp, c3_p cp, int ply, int toplevel, int forced);
+unsigned int stackupto(token_p limit, int ply, int toplevel);
+c3_p findcoerc(token_p tp, set_p tep);
+void itokcost(void);
+
+#endif /* MACH_PROTO_NCG_SUBR_H */
+
*/
/* $Id$ */
+#ifndef MACH_PROTO_NCG_TYPES_H
+#define MACH_PROTO_NCG_TYPES_H
+
#ifndef TEM_WSIZE
-TEM_WSIZE should be defined at this point
+#warning TEM_WSIZE should be defined at this point
#endif
#ifndef TEM_PSIZE
-TEM_PSIZE should be defined at this point
+#warning TEM_PSIZE should be defined at this point
#endif
#if TEM_WSIZE>4 || TEM_PSIZE>4
-Implementation will not be correct unless a long integer
-has more then 4 bytes of precision.
+#error Implementation will not be correct unless a long integer has more then 4 bytes of precision.
#endif
typedef char byte;
#if TEM_WSIZE>2 || TEM_PSIZE>2
#define full long
#else
-#define full int
+#define full int
#endif
#define word long
#ifndef WRD_FMT
#define WRD_FMT "%ld"
#endif /* WRD_FMT */
+
+#endif /* MACH_PROTO_NCG_TYPES_H */
\ No newline at end of file
--- /dev/null
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ *
+ * Author: Manoel Trapier
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include "param.h"
+#include "tables.h"
+#include "types.h"
+#include "data.h"
+
+#include "gencode.h"
+
+#include "utils.h"
+
+#ifdef TABLEDEBUG
+static void ruletrace();
+#endif
+
+/*VARARGS1*/
+void error(char *s, ...)
+{
+ va_list ap;
+ fprintf(stderr,"Error: ");
+ va_start(ap, s);
+ vfprintf(stderr, s, ap);
+ va_end(ap);
+ fprintf(stderr,"\n");
+#ifdef TABLEDEBUG
+ ruletrace();
+#endif
+ out_finish();
+ exit(-1);
+}
+
+/*VARARGS1*/
+void fatal(char *s, ...)
+{
+ va_list ap;
+ fprintf(stderr,"Fatal: ");
+ va_start(ap, s);
+ vfprintf(stderr, s, ap);
+ va_end(ap);
+ fprintf(stderr,"\n");
+#ifdef TABLEDEBUG
+ ruletrace();
+#endif
+ out_finish();
+ abort();
+ exit(-1);
+}
+
+#ifdef TABLEDEBUG
+static void ruletrace()
+{
+ int 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
+void badassertion(char *asstr, char *file, int line)
+{
+ fatal("\"%s\", line %d:Assertion \"%s\" failed", file, line, asstr);
+}
+#endif
--- /dev/null
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+#ifndef MACH_PROTO_NCG_UTILS_H
+#define MACH_PROTO_NCG_UTILS_H
+
+/* mach/proto/ncg/utils.c */
+void error(char *s, ...);
+void fatal(char *s, ...);
+void badassertion(char *asstr, char *file, int line);
+
+#endif /* MACH_PROTO_NCG_UTILS_H */
+
-#ifndef NORCSID
-static char rcsid[] = "$Id$";
-#endif
-
-#include "param.h"
-#include "tables.h"
-#include "types.h"
-#include <cgg_cg.h>
-#include "data.h"
-#include "result.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
*/
+#include "param.h"
+#include "tables.h"
+#include "types.h"
+#include <cgg_cg.h>
+#include "data.h"
+#include "result.h"
int stackheight = 0;
token_t fakestack[MAXFSTACK];