Another batch...
This commit is contained in:
parent
36a59de862
commit
f6d58a0d04
@ -6,6 +6,10 @@
|
|||||||
static char rcsid[] = "$Id$";
|
static char rcsid[] = "$Id$";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if __STDC__
|
||||||
|
#include <stdarg.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* This program converts either human-readable or compact EM
|
/* This program converts either human-readable or compact EM
|
||||||
assembly code to calls of the procedure-interface.
|
assembly code to calls of the procedure-interface.
|
||||||
It must be linked with two libraries:
|
It must be linked with two libraries:
|
||||||
@ -16,6 +20,7 @@ static char rcsid[] = "$Id$";
|
|||||||
linked.
|
linked.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "em_pseu.h"
|
#include "em_pseu.h"
|
||||||
@ -26,15 +31,22 @@ static char rcsid[] = "$Id$";
|
|||||||
#include "em.h"
|
#include "em.h"
|
||||||
#include "em_comp.h"
|
#include "em_comp.h"
|
||||||
|
|
||||||
|
#if __STDC__
|
||||||
|
void error(char *fmt, ...);
|
||||||
|
void fatal(char *fmt, ...);
|
||||||
|
#else
|
||||||
|
void error();
|
||||||
|
void fatal();
|
||||||
|
#endif
|
||||||
|
|
||||||
char *filename; /* Name of input file */
|
char *filename; /* Name of input file */
|
||||||
int errors; /* Number of errors */
|
int errors; /* Number of errors */
|
||||||
extern char *C_error;
|
extern char *C_error;
|
||||||
|
|
||||||
main(argc,argv)
|
int main(int argc, char *argv[])
|
||||||
char **argv;
|
|
||||||
{
|
{
|
||||||
struct e_instr buf;
|
struct e_instr buf;
|
||||||
register struct e_instr *p = &buf;
|
struct e_instr *p = &buf;
|
||||||
|
|
||||||
if (argc >= 2) {
|
if (argc >= 2) {
|
||||||
filename = argv[1];
|
filename = argv[1];
|
||||||
@ -67,8 +79,45 @@ main(argc,argv)
|
|||||||
C_close();
|
C_close();
|
||||||
EM_close();
|
EM_close();
|
||||||
exit(errors);
|
exit(errors);
|
||||||
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if __STDC__
|
||||||
|
void error(char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
fprint(stderr,
|
||||||
|
"%s, line %d: ",
|
||||||
|
filename ? filename : "standard input",
|
||||||
|
EM_lineno);
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
vfprintf(stderr, fmt, ap);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
void fatal(char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
if (C_busy()) C_close();
|
||||||
|
|
||||||
|
fprint(stderr,
|
||||||
|
"%s, line %d: ",
|
||||||
|
filename ? filename : "standard input",
|
||||||
|
EM_lineno);
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
vfprintf(stderr, fmt, ap);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
#else /* __STDC__ */
|
||||||
|
|
||||||
/* VARARGS */
|
/* VARARGS */
|
||||||
error(s,a1,a2,a3,a4)
|
error(s,a1,a2,a3,a4)
|
||||||
char *s;
|
char *s;
|
||||||
@ -90,3 +139,4 @@ fatal(s,a1,a2,a3,a4)
|
|||||||
error(s,a1,a2,a3,a4);
|
error(s,a1,a2,a3,a4);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
#endif /* __STDC__ */
|
||||||
|
|||||||
@ -33,9 +33,10 @@ long szdata;
|
|||||||
long ptr7;
|
long ptr7;
|
||||||
long ptr8;
|
long ptr8;
|
||||||
|
|
||||||
main(argc, argv)
|
void esize(char *fname);
|
||||||
int argc;
|
void rd_close();
|
||||||
char *argv[];
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
printf("TPFCRE uref vers w/p text nproc szdata\n");
|
printf("TPFCRE uref vers w/p text nproc szdata\n");
|
||||||
|
|
||||||
@ -49,10 +50,10 @@ main(argc, argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
exit(0);
|
exit(0);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
esize(fname)
|
void esize(char *fname)
|
||||||
char *fname;
|
|
||||||
{
|
{
|
||||||
eof = 0;
|
eof = 0;
|
||||||
if (!rd_open(fname)) {
|
if (!rd_open(fname)) {
|
||||||
@ -91,15 +92,12 @@ esize(fname)
|
|||||||
|
|
||||||
#define btol(a) ((long)(((long) (a)) & 0xFF))
|
#define btol(a) ((long)(((long) (a)) & 0xFF))
|
||||||
|
|
||||||
int
|
int rd_open(char *load_file)
|
||||||
rd_open(load_file)
|
|
||||||
char *load_file;
|
|
||||||
{
|
{
|
||||||
return (load_fp = fopen(load_file, "r")) != NULL;
|
return (load_fp = fopen(load_file, "r")) != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int rd_byte()
|
||||||
rd_byte()
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -108,12 +106,10 @@ rd_byte()
|
|||||||
return (i);
|
return (i);
|
||||||
}
|
}
|
||||||
|
|
||||||
long
|
long rd_int(long n)
|
||||||
rd_int(n)
|
|
||||||
long n;
|
|
||||||
{
|
{
|
||||||
long l;
|
long l;
|
||||||
register int i;
|
int i;
|
||||||
|
|
||||||
l = btol(rd_byte());
|
l = btol(rd_byte());
|
||||||
for (i = 1; i < n; i++)
|
for (i = 1; i < n; i++)
|
||||||
@ -123,8 +119,7 @@ rd_int(n)
|
|||||||
|
|
||||||
#define rd_ptr() ((ptr) rd_int(psize))
|
#define rd_ptr() ((ptr) rd_int(psize))
|
||||||
|
|
||||||
int
|
int rd_header()
|
||||||
rd_header()
|
|
||||||
{
|
{
|
||||||
magic = rd_int(2L);
|
magic = rd_int(2L);
|
||||||
if (magic != MAGIC || eof)
|
if (magic != MAGIC || eof)
|
||||||
@ -150,7 +145,7 @@ rd_header()
|
|||||||
return !eof;
|
return !eof;
|
||||||
}
|
}
|
||||||
|
|
||||||
rd_close()
|
void rd_close()
|
||||||
{
|
{
|
||||||
fclose(load_fp);
|
fclose(load_fp);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,9 +24,12 @@ int nmoves;
|
|||||||
move_t l_moves[MAXMOVES];
|
move_t l_moves[MAXMOVES];
|
||||||
short posmoves[MAXREGS+MAXTOKENS][SETSIZE];
|
short posmoves[MAXREGS+MAXTOKENS][SETSIZE];
|
||||||
|
|
||||||
n_move(s1,e1,s2,e2,vi) struct varinfo *vi; {
|
void n_split(int ti, int be, struct varinfo *al, struct varinfo *ge, struct varinfo *rp, int n);
|
||||||
register move_p mp;
|
|
||||||
register i,j;
|
void n_move(int s1, int e1,int s2, int e2, struct varinfo *vi)
|
||||||
|
{
|
||||||
|
move_p mp;
|
||||||
|
int i,j;
|
||||||
|
|
||||||
NEXT(nmoves,MAXMOVES,"Moves");
|
NEXT(nmoves,MAXMOVES,"Moves");
|
||||||
mp = &l_moves[nmoves-1];
|
mp = &l_moves[nmoves-1];
|
||||||
@ -44,8 +47,9 @@ n_move(s1,e1,s2,e2,vi) struct varinfo *vi; {
|
|||||||
posmoves[i][j] |= l_sets[mp->m_set2].set_val[j];
|
posmoves[i][j] |= l_sets[mp->m_set2].set_val[j];
|
||||||
}
|
}
|
||||||
|
|
||||||
existmove(from,sp) iocc_t from; short *sp; {
|
int existmove(iocc_t from, short *sp)
|
||||||
register i;
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
for (i=0;i<MAXREGS+MAXTOKENS;i++)
|
for (i=0;i<MAXREGS+MAXTOKENS;i++)
|
||||||
if(BIT(from.in_set,i))
|
if(BIT(from.in_set,i))
|
||||||
@ -54,17 +58,19 @@ existmove(from,sp) iocc_t from; short *sp; {
|
|||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
existalmove(from,prpno) iocc_t from; {
|
int existalmove(iocc_t from, int prpno)
|
||||||
|
{
|
||||||
short s[SETSIZE];
|
short s[SETSIZE];
|
||||||
register i;
|
int i;
|
||||||
|
|
||||||
for (i=0;i<SETSIZE;i++)
|
for (i=0;i<SETSIZE;i++)
|
||||||
s[i] = i<SZOFSET(MAXREGS) ? l_props[prpno].pr_regset[i] : 0;
|
s[i] = i<SZOFSET(MAXREGS) ? l_props[prpno].pr_regset[i] : 0;
|
||||||
return(existmove(from,s));
|
return(existmove(from,s));
|
||||||
}
|
}
|
||||||
|
|
||||||
struct varinfo *gen_move(from,to) iocc_t from,to; {
|
struct varinfo *gen_move(iocc_t from, iocc_t to)
|
||||||
register struct varinfo *vp;
|
{
|
||||||
|
struct varinfo *vp;
|
||||||
|
|
||||||
if (existmove(from,to.in_set)==0) {
|
if (existmove(from,to.in_set)==0) {
|
||||||
error("No such move defined");
|
error("No such move defined");
|
||||||
@ -81,9 +87,10 @@ int ntests;
|
|||||||
test_t l_tests[MAXTESTS];
|
test_t l_tests[MAXTESTS];
|
||||||
short postests[SETSIZE];
|
short postests[SETSIZE];
|
||||||
|
|
||||||
n_test(s,e,vi) struct varinfo *vi; {
|
void n_test(int s, int e, struct varinfo *vi)
|
||||||
register test_p tp;
|
{
|
||||||
register i;
|
test_p tp;
|
||||||
|
int i;
|
||||||
|
|
||||||
NEXT(ntests,MAXTESTS,"Tests");
|
NEXT(ntests,MAXTESTS,"Tests");
|
||||||
tp = &l_tests[ntests-1];
|
tp = &l_tests[ntests-1];
|
||||||
@ -97,8 +104,9 @@ n_test(s,e,vi) struct varinfo *vi; {
|
|||||||
postests[i] |= l_sets[tp->t_set].set_val[i];
|
postests[i] |= l_sets[tp->t_set].set_val[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
struct varinfo *gen_test(from) iocc_t from; {
|
struct varinfo *gen_test(iocc_t from)
|
||||||
register struct varinfo *vp;
|
{
|
||||||
|
struct varinfo *vp;
|
||||||
|
|
||||||
if (!subset(from.in_set,postests,SETSIZE)) {
|
if (!subset(from.in_set,postests,SETSIZE)) {
|
||||||
error("No such test");
|
error("No such test");
|
||||||
@ -110,8 +118,9 @@ struct varinfo *gen_test(from) iocc_t from; {
|
|||||||
return(vp);
|
return(vp);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct varinfo *gen_label(arg) int arg; {
|
struct varinfo *gen_label(int arg)
|
||||||
register struct varinfo *vp;
|
{
|
||||||
|
struct varinfo *vp;
|
||||||
|
|
||||||
NEW(vp,struct varinfo);
|
NEW(vp,struct varinfo);
|
||||||
vp->vi_int[0] = INSLABDEF;
|
vp->vi_int[0] = INSLABDEF;
|
||||||
@ -119,18 +128,20 @@ struct varinfo *gen_label(arg) int arg; {
|
|||||||
return(vp);
|
return(vp);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct varinfo *gen_preturn() {
|
struct varinfo *gen_preturn()
|
||||||
register struct varinfo *vp;
|
{
|
||||||
|
struct varinfo *vp;
|
||||||
|
|
||||||
NEW(vp,struct varinfo);
|
NEW(vp,struct varinfo);
|
||||||
vp->vi_int[0] = INSPRETURN;
|
vp->vi_int[0] = INSPRETURN;
|
||||||
return(vp);
|
return(vp);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct varinfo *gen_tlab(n) {
|
struct varinfo *gen_tlab(int n)
|
||||||
register struct varinfo *vp;
|
{
|
||||||
|
struct varinfo *vp;
|
||||||
|
|
||||||
assert(n>=0 && n<=9);
|
assert((n>=0) && (n<=9));
|
||||||
NEW(vp,struct varinfo);
|
NEW(vp,struct varinfo);
|
||||||
vp->vi_int[0] = INSTLAB;
|
vp->vi_int[0] = INSTLAB;
|
||||||
vp->vi_int[1] = n;
|
vp->vi_int[1] = n;
|
||||||
@ -141,10 +152,11 @@ int nstacks;
|
|||||||
c1_t l_stacks[MAXSTACKS];
|
c1_t l_stacks[MAXSTACKS];
|
||||||
set_t ustackset,cstackset;
|
set_t ustackset,cstackset;
|
||||||
|
|
||||||
n_stack(s,e,p,vi) struct varinfo *vi; {
|
void n_stack(int s, int e, int p, struct varinfo *vi)
|
||||||
register c1_p c1p;
|
{
|
||||||
register short *sp;
|
c1_p c1p;
|
||||||
register i;
|
short *sp;
|
||||||
|
int i;
|
||||||
|
|
||||||
NEXT(nstacks,MAXSTACKS,"Stacks");
|
NEXT(nstacks,MAXSTACKS,"Stacks");
|
||||||
c1p= & l_stacks[nstacks-1];
|
c1p= & l_stacks[nstacks-1];
|
||||||
@ -162,9 +174,10 @@ n_stack(s,e,p,vi) struct varinfo *vi; {
|
|||||||
sp[i] |= l_sets[s].set_val[i];
|
sp[i] |= l_sets[s].set_val[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
checkstacking(sp) register short *sp; {
|
void checkstacking(short *sp)
|
||||||
register i;
|
{
|
||||||
register short *chkset;
|
int i;
|
||||||
|
short *chkset;
|
||||||
char *warn;
|
char *warn;
|
||||||
|
|
||||||
if (subset(sp,ustackset.set_val,SETSIZE))
|
if (subset(sp,ustackset.set_val,SETSIZE))
|
||||||
@ -186,10 +199,11 @@ set_t unstackset;
|
|||||||
|
|
||||||
/*VARARGS5*/
|
/*VARARGS5*/
|
||||||
|
|
||||||
n_coerc(ti,be,al,ge,rp,in) struct varinfo *al,*ge,*rp; iocc_t in; {
|
void n_coerc(int ti, int be, struct varinfo *al, struct varinfo *ge, struct varinfo *rp, iocc_t in)
|
||||||
register c3_p c3p;
|
{
|
||||||
register i;
|
c3_p c3p;
|
||||||
register struct varinfo *vi;
|
int i;
|
||||||
|
struct varinfo *vi;
|
||||||
|
|
||||||
if (ti!=0) {
|
if (ti!=0) {
|
||||||
for(i=0,vi=rp;vi!=0;vi=vi->vi_next,i++)
|
for(i=0,vi=rp;vi!=0;vi=vi->vi_next,i++)
|
||||||
@ -224,9 +238,9 @@ n_coerc(ti,be,al,ge,rp,in) struct varinfo *al,*ge,*rp; iocc_t in; {
|
|||||||
freevi(rp);
|
freevi(rp);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkunstacking(setno) {
|
void checkunstacking(int setno) {
|
||||||
register short *sp;
|
short *sp;
|
||||||
register i;
|
int i;
|
||||||
short hallset[SETSIZE];
|
short hallset[SETSIZE];
|
||||||
|
|
||||||
sp = l_sets[setno].set_val;
|
sp = l_sets[setno].set_val;
|
||||||
@ -238,10 +252,11 @@ checkunstacking(setno) {
|
|||||||
int nsplit,maxsplit;
|
int nsplit,maxsplit;
|
||||||
c2_t l_split[MAXSPLCOERC];
|
c2_t l_split[MAXSPLCOERC];
|
||||||
|
|
||||||
n_split(ti,be,al,ge,rp,n) struct varinfo *al,*ge,*rp; {
|
void n_split(int ti, int be, struct varinfo *al, struct varinfo *ge, struct varinfo *rp, int n)
|
||||||
register c2_p c2p;
|
{
|
||||||
register i;
|
c2_p c2p;
|
||||||
register struct varinfo *vi;
|
int i;
|
||||||
|
struct varinfo *vi;
|
||||||
|
|
||||||
NEXT(nsplit,MAXSPLCOERC,"Splitting coercions");
|
NEXT(nsplit,MAXSPLCOERC,"Splitting coercions");
|
||||||
c2p = &l_split[nsplit-1];
|
c2p = &l_split[nsplit-1];
|
||||||
|
|||||||
@ -11,7 +11,7 @@ g/^#/d
|
|||||||
.r tokendefs
|
.r tokendefs
|
||||||
a
|
a
|
||||||
|
|
||||||
enterkeyw() {
|
void enterkeyw() {
|
||||||
register symbol *sy_p;
|
register symbol *sy_p;
|
||||||
|
|
||||||
.
|
.
|
||||||
|
|||||||
@ -17,30 +17,35 @@ extern char em_mnem[][4];
|
|||||||
|
|
||||||
#define HASHSIZE (2*(sp_lmnem-sp_fmnem))
|
#define HASHSIZE (2*(sp_lmnem-sp_fmnem))
|
||||||
|
|
||||||
|
void enter(char *name, int value);
|
||||||
|
|
||||||
struct emhashmnem {
|
struct emhashmnem {
|
||||||
char h_name[3];
|
char h_name[3];
|
||||||
char h_value;
|
char h_value;
|
||||||
} emhashmnem[HASHSIZE];
|
} emhashmnem[HASHSIZE];
|
||||||
|
|
||||||
initemhash() {
|
void initemhash()
|
||||||
register i;
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
for(i=0;i<=sp_lmnem-sp_fmnem;i++)
|
for(i=0;i<=sp_lmnem-sp_fmnem;i++)
|
||||||
enter(em_mnem[i],i+sp_fmnem);
|
enter(em_mnem[i],i+sp_fmnem);
|
||||||
enter("lab", op_lab);
|
enter("lab", op_lab);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned emhash(name) register char *name; {
|
unsigned int emhash(char *name)
|
||||||
register unsigned sum;
|
{
|
||||||
register i;
|
unsigned int sum;
|
||||||
|
int i;
|
||||||
|
|
||||||
for (sum=i=0;*name;i+=3)
|
for (sum=i=0;*name;i+=3)
|
||||||
sum ^= (*name++)<<(i&07);
|
sum ^= (*name++)<<(i&07);
|
||||||
return(sum);
|
return(sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
enter(name,value) char *name; {
|
void enter(char *name, int value)
|
||||||
register unsigned h;
|
{
|
||||||
|
unsigned int h;
|
||||||
|
|
||||||
h=emhash(name)%HASHSIZE;
|
h=emhash(name)%HASHSIZE;
|
||||||
while (emhashmnem[h].h_name[0] != 0)
|
while (emhashmnem[h].h_name[0] != 0)
|
||||||
@ -49,8 +54,9 @@ enter(name,value) char *name; {
|
|||||||
emhashmnem[h].h_value = value;
|
emhashmnem[h].h_value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mlookup(name) char *name; {
|
int mlookup(char *name)
|
||||||
register unsigned h;
|
{
|
||||||
|
unsigned int h;
|
||||||
|
|
||||||
h = emhash(name)%HASHSIZE;
|
h = emhash(name)%HASHSIZE;
|
||||||
while (strncmp(emhashmnem[h].h_name,name,3) != 0 &&
|
while (strncmp(emhashmnem[h].h_name,name,3) != 0 &&
|
||||||
@ -61,8 +67,8 @@ int mlookup(name) char *name; {
|
|||||||
|
|
||||||
extern char em_flag[];
|
extern char em_flag[];
|
||||||
|
|
||||||
argtyp(mn) {
|
int argtyp(int mn)
|
||||||
|
{
|
||||||
switch(em_flag[mn-sp_fmnem]&EM_PAR) {
|
switch(em_flag[mn-sp_fmnem]&EM_PAR) {
|
||||||
case PAR_W:
|
case PAR_W:
|
||||||
case PAR_S:
|
case PAR_S:
|
||||||
|
|||||||
@ -6,17 +6,28 @@
|
|||||||
static char rcsid[]= "$Id$";
|
static char rcsid[]= "$Id$";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if __STDC__
|
||||||
|
#include <stdarg.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#if __STDC__
|
||||||
|
void error(char *fmt, ...);
|
||||||
|
#else
|
||||||
|
void error();
|
||||||
|
#endif
|
||||||
|
|
||||||
int nerrors=0;
|
int nerrors=0;
|
||||||
|
|
||||||
yyerror(s) char *s; {
|
void yyerror(char *s)
|
||||||
|
{
|
||||||
error("Parser gives %s",s);
|
error("Parser gives %s",s);
|
||||||
}
|
}
|
||||||
|
|
||||||
goodbye() {
|
void goodbye()
|
||||||
|
{
|
||||||
|
|
||||||
error("This was fatal, goodbye!");
|
error("This was fatal, goodbye!");
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
@ -24,6 +35,39 @@ goodbye() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if __STDC__
|
||||||
|
/*VARARGS1*/
|
||||||
|
void error(char *fmt, ...)
|
||||||
|
{
|
||||||
|
extern int lineno;
|
||||||
|
extern char *filename;
|
||||||
|
va_list ap;
|
||||||
|
fprintf(stderr,"\"%s\", line %d:",filename,lineno);
|
||||||
|
va_start(ap, fmt);
|
||||||
|
vfprintf(stderr, fmt, ap);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
va_end(ap);
|
||||||
|
nerrors++;
|
||||||
|
}
|
||||||
|
/*VARARGS1*/
|
||||||
|
void fatal(char *fmt, ...)
|
||||||
|
{
|
||||||
|
extern int lineno;
|
||||||
|
extern char *filename;
|
||||||
|
|
||||||
|
va_list ap;
|
||||||
|
fprintf(stderr,"\"%s\", line %d:",filename,lineno);
|
||||||
|
va_start(ap, fmt);
|
||||||
|
vfprintf(stderr, fmt, ap);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
va_end(ap);
|
||||||
|
nerrors++;
|
||||||
|
|
||||||
|
errorexit();
|
||||||
|
goodbye();
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
#else /* __STDC__ */
|
||||||
/*VARARGS1*/
|
/*VARARGS1*/
|
||||||
fatal(s,a,b,c,d) char *s; {
|
fatal(s,a,b,c,d) char *s; {
|
||||||
|
|
||||||
@ -43,17 +87,18 @@ error(s,a,b,c,d) char *s; {
|
|||||||
fprintf(stderr,"\n");
|
fprintf(stderr,"\n");
|
||||||
nerrors++;
|
nerrors++;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
badassertion(string,file,line) char *string,*file; {
|
void badassertion(char *string, char *file, int line)
|
||||||
|
{
|
||||||
fprintf(stderr,"\"%s\", line %d: Assertion failed \"%s\"\n",
|
fprintf(stderr,"\"%s\", line %d: Assertion failed \"%s\"\n",
|
||||||
file,line,string);
|
file,line,string);
|
||||||
goodbye();
|
goodbye();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
tabovf(string) char *string; {
|
void tabovf(char *string)
|
||||||
|
{
|
||||||
fatal("%s overflow",string);
|
fatal("%s overflow", string);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
static char rcsid[]= "$Id$";
|
static char rcsid[]= "$Id$";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "assert.h"
|
#include "assert.h"
|
||||||
@ -22,20 +23,24 @@ static char rcsid[]= "$Id$";
|
|||||||
|
|
||||||
extern set_t l_sets[];
|
extern set_t l_sets[];
|
||||||
|
|
||||||
i_expr(e) expr_t e; {
|
void subregset(short *sp, int subreg, short *regset);
|
||||||
|
|
||||||
|
int i_expr(expr_t e)
|
||||||
|
{
|
||||||
if (e.ex_typ != TYPINT)
|
if (e.ex_typ != TYPINT)
|
||||||
error("Expression should be integer");
|
error("Expression should be integer");
|
||||||
return(e.ex_index);
|
return(e.ex_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
b_expr(e) expr_t e; {
|
int b_expr(expr_t e)
|
||||||
|
{
|
||||||
if (e.ex_typ != TYPBOOL)
|
if (e.ex_typ != TYPBOOL)
|
||||||
error("Expression should be boolean");
|
error("Expression should be boolean");
|
||||||
return(e.ex_index);
|
return(e.ex_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t make_expr(type,operator,op1,op2) {
|
expr_t make_expr(int type, int operator, int op1, int op2)
|
||||||
|
{
|
||||||
expr_t result;
|
expr_t result;
|
||||||
|
|
||||||
result.ex_typ=type;
|
result.ex_typ=type;
|
||||||
@ -43,9 +48,10 @@ expr_t make_expr(type,operator,op1,op2) {
|
|||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t regno_expr(regno) {
|
expr_t regno_expr(int regno)
|
||||||
|
{
|
||||||
expr_t result;
|
expr_t result;
|
||||||
register i;
|
int i;
|
||||||
|
|
||||||
result.ex_typ = TYPREG;
|
result.ex_typ = TYPREG;
|
||||||
result.ex_index = ex_lookup(EX_REG,regno,0);
|
result.ex_index = ex_lookup(EX_REG,regno,0);
|
||||||
@ -55,8 +61,9 @@ expr_t regno_expr(regno) {
|
|||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t ident_expr(name) char *name; {
|
expr_t ident_expr(char *name)
|
||||||
register symbol *sy_p;
|
{
|
||||||
|
symbol *sy_p;
|
||||||
|
|
||||||
sy_p = lookup(name,symany,mustexist);
|
sy_p = lookup(name,symany,mustexist);
|
||||||
if (sy_p->sy_type==symconst)
|
if (sy_p->sy_type==symconst)
|
||||||
@ -70,7 +77,8 @@ expr_t ident_expr(name) char *name; {
|
|||||||
return(regno_expr(sy_p->sy_value.syv_regno));
|
return(regno_expr(sy_p->sy_value.syv_regno));
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t subreg_expr(tokarg,subreg) {
|
expr_t subreg_expr(int tokarg, int subreg)
|
||||||
|
{
|
||||||
expr_t result;
|
expr_t result;
|
||||||
|
|
||||||
result.ex_typ = TYPREG;
|
result.ex_typ = TYPREG;
|
||||||
@ -80,9 +88,10 @@ expr_t subreg_expr(tokarg,subreg) {
|
|||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
subregset(sp,subreg,regset) register short *sp; register short *regset; {
|
void subregset(short *sp, int subreg, short *regset)
|
||||||
register i;
|
{
|
||||||
register reginfo *rp;
|
int i;
|
||||||
|
reginfo *rp;
|
||||||
|
|
||||||
for (i=0;i<SZOFSET(MAXREGS);i++)
|
for (i=0;i<SZOFSET(MAXREGS);i++)
|
||||||
regset[i]=0;
|
regset[i]=0;
|
||||||
@ -101,10 +110,7 @@ subregset(sp,subreg,regset) register short *sp; register short *regset; {
|
|||||||
l_tokens[i-nregs]->tk_name);
|
l_tokens[i-nregs]->tk_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
membset(setno,name,regset,appearance,restyp,typp)
|
int membset(int setno, char *name, short *regset, char *appearance, int restyp, int *typp)
|
||||||
char *name,*appearance;
|
|
||||||
short *regset;
|
|
||||||
int *typp;
|
|
||||||
{
|
{
|
||||||
register short *sp;
|
register short *sp;
|
||||||
register token_p tp;
|
register token_p tp;
|
||||||
@ -164,7 +170,8 @@ int *typp;
|
|||||||
return(res_j == -1 ? 0 : res_j);
|
return(res_j == -1 ? 0 : res_j);
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t memb_expr(setno,name,appearance,tokarg) char *name,*appearance; {
|
expr_t memb_expr(int setno, char *name, char *appearance, int tokarg)
|
||||||
|
{
|
||||||
expr_t result;
|
expr_t result;
|
||||||
int res_j;
|
int res_j;
|
||||||
|
|
||||||
@ -173,7 +180,8 @@ expr_t memb_expr(setno,name,appearance,tokarg) char *name,*appearance; {
|
|||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t tokm_expr(tokarg,name) char *name; {
|
expr_t tokm_expr(int tokarg, char *name)
|
||||||
|
{
|
||||||
char app[100];
|
char app[100];
|
||||||
int tokarg1 = tokarg > 0 ? tokarg : 1;
|
int tokarg1 = tokarg > 0 ? tokarg : 1;
|
||||||
|
|
||||||
@ -181,17 +189,19 @@ expr_t tokm_expr(tokarg,name) char *name; {
|
|||||||
return(memb_expr(tokpatset[tokarg1-1],name,app,tokarg));
|
return(memb_expr(tokpatset[tokarg1-1],name,app,tokarg));
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t perc_ident_expr(name) char *name; {
|
expr_t perc_ident_expr(char *name)
|
||||||
|
{
|
||||||
char app[100];
|
char app[100];
|
||||||
|
|
||||||
sprintf(app,"%%%s",name);
|
sprintf(app,"%%%s",name);
|
||||||
return(memb_expr(cursetno,name,app,0));
|
return(memb_expr(cursetno,name,app,0));
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t all_expr(all_no,subreg) {
|
expr_t all_expr(int all_no, int subreg)
|
||||||
|
{
|
||||||
set_t localset;
|
set_t localset;
|
||||||
register i;
|
int i;
|
||||||
register short *sp;
|
short *sp;
|
||||||
expr_t result;
|
expr_t result;
|
||||||
|
|
||||||
sp = l_props[allreg[all_no]].pr_regset;
|
sp = l_props[allreg[all_no]].pr_regset;
|
||||||
@ -203,8 +213,8 @@ expr_t all_expr(all_no,subreg) {
|
|||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
eq2expr(e1,e2) expr_t e1,e2; {
|
int eq2expr(expr_t e1, expr_t e2)
|
||||||
|
{
|
||||||
if (e1.ex_typ != e2.ex_typ)
|
if (e1.ex_typ != e2.ex_typ)
|
||||||
error("Expressions around == should have equal type");
|
error("Expressions around == should have equal type");
|
||||||
switch (e1.ex_typ) {
|
switch (e1.ex_typ) {
|
||||||
@ -220,8 +230,8 @@ eq2expr(e1,e2) expr_t e1,e2; {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ne2expr(e1,e2) expr_t e1,e2; {
|
int ne2expr(expr_t e1, expr_t e2)
|
||||||
|
{
|
||||||
if (e1.ex_typ != e2.ex_typ)
|
if (e1.ex_typ != e2.ex_typ)
|
||||||
error("Expressions around != should have equal type");
|
error("Expressions around != should have equal type");
|
||||||
switch (e1.ex_typ) {
|
switch (e1.ex_typ) {
|
||||||
@ -237,7 +247,8 @@ ne2expr(e1,e2) expr_t e1,e2; {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t sum_expr(e1,e2) expr_t e1,e2; {
|
expr_t sum_expr(expr_t e1, expr_t e2)
|
||||||
|
{
|
||||||
int operator,op1,op2;
|
int operator,op1,op2;
|
||||||
expr_t result;
|
expr_t result;
|
||||||
|
|
||||||
@ -265,7 +276,8 @@ expr_t sum_expr(e1,e2) expr_t e1,e2; {
|
|||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t iextoaddr(e) expr_t e; {
|
expr_t iextoaddr(expr_t e)
|
||||||
|
{
|
||||||
expr_t result;
|
expr_t result;
|
||||||
|
|
||||||
result.ex_typ = TYPADDR;
|
result.ex_typ = TYPADDR;
|
||||||
@ -273,9 +285,10 @@ expr_t iextoaddr(e) expr_t e; {
|
|||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t regvar_expr(e,regtyp) expr_t e; {
|
expr_t regvar_expr(expr_t e, int regtyp)
|
||||||
|
{
|
||||||
expr_t result;
|
expr_t result;
|
||||||
register i;
|
int i;
|
||||||
|
|
||||||
result = make_expr(TYPREG,EX_REGVAR,i_expr(e),0);
|
result = make_expr(TYPREG,EX_REGVAR,i_expr(e),0);
|
||||||
for(i=0;i<SZOFSET(MAXREGS);i++)
|
for(i=0;i<SZOFSET(MAXREGS);i++)
|
||||||
@ -292,15 +305,16 @@ expr_t regvar_expr(e,regtyp) expr_t e; {
|
|||||||
node_t nodes[MAXNODES];
|
node_t nodes[MAXNODES];
|
||||||
int nnodes=0;
|
int nnodes=0;
|
||||||
|
|
||||||
initnodes() {
|
void initnodes()
|
||||||
|
{
|
||||||
nodes[0].ex_operator = EX_CON;
|
nodes[0].ex_operator = EX_CON;
|
||||||
nodes[0].ex_lnode = 0;
|
nodes[0].ex_lnode = 0;
|
||||||
nodes[0].ex_rnode = 0;
|
nodes[0].ex_rnode = 0;
|
||||||
nnodes++;
|
nnodes++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ex_lookup(operator,lnode,rnode) {
|
int ex_lookup(int operator, int lnode, int rnode)
|
||||||
|
{
|
||||||
register node_p p;
|
register node_p p;
|
||||||
|
|
||||||
for(p=nodes+1;p< &nodes[nnodes];p++) {
|
for(p=nodes+1;p< &nodes[nnodes];p++) {
|
||||||
|
|||||||
@ -3,6 +3,8 @@
|
|||||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||||
*/
|
*/
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
#ifndef UTIL_NCGG_EXTERN_H
|
||||||
|
#define UTIL_NCGG_EXTERN_H
|
||||||
|
|
||||||
extern int wordsize;
|
extern int wordsize;
|
||||||
extern int pointersize;
|
extern int pointersize;
|
||||||
@ -38,5 +40,7 @@ extern int maxtokensize;
|
|||||||
extern int nprocargs, maxprocargs;
|
extern int nprocargs, maxprocargs;
|
||||||
extern int use_tes;
|
extern int use_tes;
|
||||||
|
|
||||||
extern char *mystrcpy();
|
char *myalloc(int n);
|
||||||
extern char *myalloc();
|
char *mystrcpy(char *s);
|
||||||
|
|
||||||
|
#endif /* UTIL_NCGG_EXTERN_H */
|
||||||
@ -11,6 +11,8 @@ static char rcsid[]= "$Id$";
|
|||||||
#include "set.h"
|
#include "set.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void unite(short *sp, short *into);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file implements the marriage thesis from Hall.
|
* This file implements the marriage thesis from Hall.
|
||||||
* The thesis says that given a number, say N, of subsets from
|
* The thesis says that given a number, say N, of subsets from
|
||||||
@ -31,9 +33,10 @@ short hallsets[MAXHALL][SETSIZE];
|
|||||||
int nhallsets= -1;
|
int nhallsets= -1;
|
||||||
int hallfreq[MAXHALL][2];
|
int hallfreq[MAXHALL][2];
|
||||||
|
|
||||||
hallverbose() {
|
void hallverbose()
|
||||||
register i;
|
{
|
||||||
register max;
|
int i;
|
||||||
|
int max;
|
||||||
|
|
||||||
fprintf(stderr,"Table of hall frequencies\n # pre post\n");
|
fprintf(stderr,"Table of hall frequencies\n # pre post\n");
|
||||||
for (max=MAXHALL-1;hallfreq[max][0]==0 && hallfreq[max][1]==0;max--)
|
for (max=MAXHALL-1;hallfreq[max][0]==0 && hallfreq[max][1]==0;max--)
|
||||||
@ -42,14 +45,15 @@ hallverbose() {
|
|||||||
fprintf(stderr,"%3d%6d%6d\n",i,hallfreq[i][0],hallfreq[i][1]);
|
fprintf(stderr,"%3d%6d%6d\n",i,hallfreq[i][0],hallfreq[i][1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
inithall() {
|
void inithall()
|
||||||
|
{
|
||||||
assert(nhallsets == -1);
|
assert(nhallsets == -1);
|
||||||
nhallsets=0;
|
nhallsets=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
nexthall(sp) register short *sp; {
|
void nexthall(short *sp)
|
||||||
register i;
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
assert(nhallsets>=0);
|
assert(nhallsets>=0);
|
||||||
for(i=0;i<SETSIZE;i++)
|
for(i=0;i<SETSIZE;i++)
|
||||||
@ -57,8 +61,9 @@ nexthall(sp) register short *sp; {
|
|||||||
nhallsets++;
|
nhallsets++;
|
||||||
}
|
}
|
||||||
|
|
||||||
card(sp) register short *sp; {
|
int card(short *sp)
|
||||||
register sum,i;
|
{
|
||||||
|
int sum,i;
|
||||||
|
|
||||||
sum=0;
|
sum=0;
|
||||||
for(i=0;i<8*sizeof(short)*SETSIZE;i++)
|
for(i=0;i<8*sizeof(short)*SETSIZE;i++)
|
||||||
@ -67,15 +72,16 @@ card(sp) register short *sp; {
|
|||||||
return(sum);
|
return(sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkhall() {
|
void checkhall()
|
||||||
|
{
|
||||||
assert(nhallsets>=0);
|
assert(nhallsets>=0);
|
||||||
if (!hall())
|
if (!hall())
|
||||||
error("Hall says: \"You can't have those registers\"");
|
error("Hall says: \"You can't have those registers\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
hall() {
|
int hall()
|
||||||
register i,j,k;
|
{
|
||||||
|
int i,j,k;
|
||||||
int ok;
|
int ok;
|
||||||
|
|
||||||
hallfreq[nhallsets][0]++;
|
hallfreq[nhallsets][0]++;
|
||||||
@ -109,10 +115,11 @@ hall() {
|
|||||||
return(ok);
|
return(ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
recurhall(nhallsets,hallsets) short hallsets[][SETSIZE]; {
|
int recurhall(int nhallsets, short hallsets[][SETSIZE])
|
||||||
|
{
|
||||||
short copysets[MAXHALL][SETSIZE];
|
short copysets[MAXHALL][SETSIZE];
|
||||||
short setsum[SETSIZE];
|
short setsum[SETSIZE];
|
||||||
register i,j,k,ncopys;
|
int i,j,k,ncopys;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First check cardinality of union of all
|
* First check cardinality of union of all
|
||||||
@ -141,8 +148,9 @@ recurhall(nhallsets,hallsets) short hallsets[][SETSIZE]; {
|
|||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
unite(sp,into) register short *sp,*into; {
|
void unite(short *sp, short *into)
|
||||||
register i;
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
for(i=0;i<SETSIZE;i++)
|
for(i=0;i<SETSIZE;i++)
|
||||||
into[i] |= sp[i];
|
into[i] |= sp[i];
|
||||||
|
|||||||
@ -6,6 +6,8 @@
|
|||||||
static char rcsid[]= "$Id$";
|
static char rcsid[]= "$Id$";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "param.h"
|
#include "param.h"
|
||||||
#include "instruct.h"
|
#include "instruct.h"
|
||||||
#include "pseudo.h"
|
#include "pseudo.h"
|
||||||
@ -25,7 +27,8 @@ extern inst_t l_instances[];
|
|||||||
|
|
||||||
extern expr_t subreg_expr(),regno_expr();
|
extern expr_t subreg_expr(),regno_expr();
|
||||||
|
|
||||||
struct varinfo * setcoco(n) {
|
struct varinfo *setcoco(int n)
|
||||||
|
{
|
||||||
struct varinfo *vi;
|
struct varinfo *vi;
|
||||||
|
|
||||||
NEW(vi,struct varinfo);
|
NEW(vi,struct varinfo);
|
||||||
@ -35,7 +38,8 @@ struct varinfo * setcoco(n) {
|
|||||||
return(vi);
|
return(vi);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct varinfo * generase(n) {
|
struct varinfo *generase(int n)
|
||||||
|
{
|
||||||
struct varinfo *vi;
|
struct varinfo *vi;
|
||||||
|
|
||||||
NEW(vi,struct varinfo);
|
NEW(vi,struct varinfo);
|
||||||
@ -45,7 +49,8 @@ struct varinfo * generase(n) {
|
|||||||
return(vi);
|
return(vi);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct varinfo * genremove(n) {
|
struct varinfo *genremove(int n)
|
||||||
|
{
|
||||||
struct varinfo *vi;
|
struct varinfo *vi;
|
||||||
|
|
||||||
NEW(vi,struct varinfo);
|
NEW(vi,struct varinfo);
|
||||||
@ -55,9 +60,10 @@ struct varinfo * genremove(n) {
|
|||||||
return(vi);
|
return(vi);
|
||||||
}
|
}
|
||||||
|
|
||||||
onlyreg(argno) {
|
int onlyreg(int argno)
|
||||||
register bitno;
|
{
|
||||||
register short *sp;
|
int bitno;
|
||||||
|
short *sp;
|
||||||
|
|
||||||
if (! argno) argno++;
|
if (! argno) argno++;
|
||||||
sp = l_sets[tokpatset[argno-1]].set_val;
|
sp = l_sets[tokpatset[argno-1]].set_val;
|
||||||
@ -67,7 +73,8 @@ onlyreg(argno) {
|
|||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
makescratch(argno) {
|
void makescratch(int argno)
|
||||||
|
{
|
||||||
set_t s;
|
set_t s;
|
||||||
|
|
||||||
if (! argno) argno++;
|
if (! argno) argno++;
|
||||||
@ -78,12 +85,13 @@ makescratch(argno) {
|
|||||||
tokpatset[argno-1] = setlookup(s);
|
tokpatset[argno-1] = setlookup(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct varinfo *gen_inst(ident,star) char *ident; {
|
struct varinfo *gen_inst(char *ident, int star)
|
||||||
register struct varinfo *vi,*retval,*eravi;
|
{
|
||||||
register instr_p ip;
|
struct varinfo *vi,*retval,*eravi;
|
||||||
register struct operand *op;
|
instr_p ip;
|
||||||
register i;
|
struct operand *op;
|
||||||
register inst_p insta;
|
int i;
|
||||||
|
inst_p insta;
|
||||||
|
|
||||||
if (star && !inproc)
|
if (star && !inproc)
|
||||||
error("Variable instruction only allowed inside proc");
|
error("Variable instruction only allowed inside proc");
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
static char rcsid[]= "$Id$";
|
static char rcsid[]= "$Id$";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "assert.h"
|
#include "assert.h"
|
||||||
@ -25,12 +26,14 @@ extern set_t l_sets[];
|
|||||||
int narexpr;
|
int narexpr;
|
||||||
expr_t arexp[MAXATT];
|
expr_t arexp[MAXATT];
|
||||||
|
|
||||||
expr_t iextoaddr();
|
expr_t iextoaddr(expr_t e);
|
||||||
|
|
||||||
iocc_t subr_iocc(tokarg,subreg) {
|
|
||||||
|
iocc_t subr_iocc(int tokarg, int subreg)
|
||||||
|
{
|
||||||
inst_t insta;
|
inst_t insta;
|
||||||
iocc_t result;
|
iocc_t result;
|
||||||
register i;
|
int i;
|
||||||
|
|
||||||
insta.in_which = IN_COPY;
|
insta.in_which = IN_COPY;
|
||||||
insta.in_info[0] = tokarg;
|
insta.in_info[0] = tokarg;
|
||||||
@ -48,10 +51,11 @@ iocc_t subr_iocc(tokarg,subreg) {
|
|||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
iocc_t tokm_iocc(tokarg,ident) char *ident; {
|
iocc_t tokm_iocc(int tokarg, char *ident)
|
||||||
|
{
|
||||||
iocc_t result;
|
iocc_t result;
|
||||||
inst_t insta;
|
inst_t insta;
|
||||||
register i;
|
int i;
|
||||||
char app[100];
|
char app[100];
|
||||||
int dummy;
|
int dummy;
|
||||||
|
|
||||||
@ -67,10 +71,11 @@ iocc_t tokm_iocc(tokarg,ident) char *ident; {
|
|||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
iocc_t percident_iocc(ident) char *ident; {
|
iocc_t percident_iocc(char *ident)
|
||||||
|
{
|
||||||
iocc_t result;
|
iocc_t result;
|
||||||
inst_t insta;
|
inst_t insta;
|
||||||
register i;
|
int i;
|
||||||
char app[100];
|
char app[100];
|
||||||
int dummy;
|
int dummy;
|
||||||
|
|
||||||
@ -85,11 +90,12 @@ iocc_t percident_iocc(ident) char *ident; {
|
|||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
iocc_t ident_iocc(ident) char *ident; {
|
iocc_t ident_iocc(char *ident)
|
||||||
|
{
|
||||||
iocc_t result;
|
iocc_t result;
|
||||||
inst_t insta;
|
inst_t insta;
|
||||||
register i;
|
int i;
|
||||||
register symbol *sy_p;
|
symbol *sy_p;
|
||||||
|
|
||||||
for(i=0;i<SETSIZE;i++)
|
for(i=0;i<SETSIZE;i++)
|
||||||
result.in_set[i] = 0;
|
result.in_set[i] = 0;
|
||||||
@ -101,12 +107,13 @@ iocc_t ident_iocc(ident) char *ident; {
|
|||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
iocc_t all_iocc(all_no,subreg) {
|
iocc_t all_iocc(int all_no, int subreg)
|
||||||
|
{
|
||||||
iocc_t result;
|
iocc_t result;
|
||||||
inst_t insta;
|
inst_t insta;
|
||||||
register i;
|
int i;
|
||||||
set_t localset;
|
set_t localset;
|
||||||
register short *sp;
|
short *sp;
|
||||||
|
|
||||||
sp = l_props[allreg[all_no]].pr_regset;
|
sp = l_props[allreg[all_no]].pr_regset;
|
||||||
for (i=0;i<SETSIZE;i++)
|
for (i=0;i<SETSIZE;i++)
|
||||||
@ -121,12 +128,13 @@ iocc_t all_iocc(all_no,subreg) {
|
|||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
iocc_t descr_iocc(ident) char *ident; {
|
iocc_t descr_iocc(char *ident)
|
||||||
|
{
|
||||||
iocc_t result;
|
iocc_t result;
|
||||||
inst_t insta;
|
inst_t insta;
|
||||||
register symbol *sy_p;
|
symbol *sy_p;
|
||||||
register token_p tp;
|
token_p tp;
|
||||||
register i;
|
int i;
|
||||||
int typerr;
|
int typerr;
|
||||||
|
|
||||||
for(i=0;i<SETSIZE;i++)
|
for(i=0;i<SETSIZE;i++)
|
||||||
@ -156,10 +164,16 @@ iocc_t descr_iocc(ident) char *ident; {
|
|||||||
default: assert(0);
|
default: assert(0);
|
||||||
case TYPINT:
|
case TYPINT:
|
||||||
if (tp->tk_att[i].ta_type != -1)
|
if (tp->tk_att[i].ta_type != -1)
|
||||||
|
{
|
||||||
if (tp->tk_att[i].ta_type == -2)
|
if (tp->tk_att[i].ta_type == -2)
|
||||||
|
{
|
||||||
arexp[i] = iextoaddr(arexp[i]);
|
arexp[i] = iextoaddr(arexp[i]);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
typerr++;
|
typerr++;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case TYPBOOL:
|
case TYPBOOL:
|
||||||
typerr++; break;
|
typerr++; break;
|
||||||
@ -190,8 +204,9 @@ iocc_t descr_iocc(ident) char *ident; {
|
|||||||
int ninstances=1;
|
int ninstances=1;
|
||||||
inst_t l_instances[MAXINSTANCES];
|
inst_t l_instances[MAXINSTANCES];
|
||||||
|
|
||||||
instalookup(insta,filled) inst_t insta; {
|
int instalookup(inst_t insta, int filled)
|
||||||
register i,j;
|
{
|
||||||
|
int i,j;
|
||||||
|
|
||||||
for (j=filled;j<=MAXATT;j++)
|
for (j=filled;j<=MAXATT;j++)
|
||||||
insta.in_info[j] = 0;
|
insta.in_info[j] = 0;
|
||||||
|
|||||||
@ -6,19 +6,17 @@
|
|||||||
static char rcsid[]= "$Id$";
|
static char rcsid[]= "$Id$";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
#include "assert.h"
|
#include "assert.h"
|
||||||
#include "param.h"
|
#include "param.h"
|
||||||
#include "lookup.h"
|
#include "lookup.h"
|
||||||
|
#include "extern.h"
|
||||||
|
|
||||||
char *myalloc();
|
unsigned int hashvalue(char *s);
|
||||||
char *mystrcpy();
|
|
||||||
|
|
||||||
symbol dumsym; /* dummy to return in case of error */
|
symbol dumsym; /* dummy to return in case of error */
|
||||||
|
|
||||||
symbol *lookup(name,type,style)
|
symbol *lookup(char *name, symtype type, lookupstyle style)
|
||||||
char *name;
|
|
||||||
symtype type;
|
|
||||||
lookupstyle style;
|
|
||||||
{
|
{
|
||||||
symbol *sy_p,**sy_pp;
|
symbol *sy_p,**sy_pp;
|
||||||
|
|
||||||
@ -59,9 +57,10 @@ lookupstyle style;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hashvalue(s) register char *s; {
|
unsigned int hashvalue(char *s)
|
||||||
register unsigned sum=0;
|
{
|
||||||
register i;
|
unsigned int sum=0;
|
||||||
|
int i;
|
||||||
|
|
||||||
for(i=0;*s;s++,i=(i+3)&07)
|
for(i=0;*s;s++,i=(i+3)&07)
|
||||||
sum += *s<<i;
|
sum += *s<<i;
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||||
*/
|
*/
|
||||||
/* #define CODEDEBUG /* print readable code */
|
/* #define CODEDEBUG */ /* print readable code */
|
||||||
#ifdef CODEDEBUG
|
#ifdef CODEDEBUG
|
||||||
int code_in_c=0; /* put readable code in "code" */
|
int code_in_c=0; /* put readable code in "code" */
|
||||||
int tabledebug=1; /* generate code for table debugging */
|
int tabledebug=1; /* generate code for table debugging */
|
||||||
@ -66,22 +66,25 @@ int maxallreg=0;
|
|||||||
int maxregvars=0;
|
int maxregvars=0;
|
||||||
int setsize;
|
int setsize;
|
||||||
|
|
||||||
opnfile(f,s) FILE **f; char *s; {
|
void pat(int n);
|
||||||
|
void patbyte(int n);
|
||||||
|
void patshort(int n);
|
||||||
|
|
||||||
|
void opnfile(FILE **f, char *s)
|
||||||
|
{
|
||||||
if ((*f=fopen(s,"w"))==NULL)
|
if ((*f=fopen(s,"w"))==NULL)
|
||||||
fatal("Can't create %s",s);
|
fatal("Can't create %s",s);
|
||||||
}
|
}
|
||||||
|
|
||||||
unlfile(f,s) FILE *f; char *s; {
|
void unlfile(FILE *f, char *s)
|
||||||
|
{
|
||||||
if (f) fclose(f);
|
if (f) fclose(f);
|
||||||
if (unlink(s)<0)
|
if (unlink(s)<0)
|
||||||
error("%s incorrect, must be removed!!",s);
|
error("%s incorrect, must be removed!!",s);
|
||||||
}
|
}
|
||||||
|
|
||||||
initio() {
|
void initio()
|
||||||
extern char *myalloc();
|
{
|
||||||
|
|
||||||
opnfile(&ctable,c_file);
|
opnfile(&ctable,c_file);
|
||||||
opnfile(&htable,h_file);
|
opnfile(&htable,h_file);
|
||||||
if (code_in_c)
|
if (code_in_c)
|
||||||
@ -93,8 +96,8 @@ initio() {
|
|||||||
lineset = (short *) myalloc(SZOFSET(MAXSOURCELINES)*sizeof(short));
|
lineset = (short *) myalloc(SZOFSET(MAXSOURCELINES)*sizeof(short));
|
||||||
}
|
}
|
||||||
|
|
||||||
finishcode() {
|
void finishcode()
|
||||||
|
{
|
||||||
if (code_in_c)
|
if (code_in_c)
|
||||||
fprintf(ctable,"\n};\n\n");
|
fprintf(ctable,"\n};\n\n");
|
||||||
fprintf(ctable, "int allsetno = %d;\n", allsetno);
|
fprintf(ctable, "int allsetno = %d;\n", allsetno);
|
||||||
@ -112,8 +115,8 @@ finishcode() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
errorexit() {
|
void errorexit()
|
||||||
|
{
|
||||||
unlfile(ctable,c_file);
|
unlfile(ctable,c_file);
|
||||||
unlfile(htable,h_file);
|
unlfile(htable,h_file);
|
||||||
if (!code_in_c)
|
if (!code_in_c)
|
||||||
@ -126,12 +129,12 @@ errorexit() {
|
|||||||
#define code53(x,y) fprintf(code,"%s-%d","x",y)
|
#define code53(x,y) fprintf(code,"%s-%d","x",y)
|
||||||
#define codeint(x) fprintf(code," %d",x)
|
#define codeint(x) fprintf(code," %d",x)
|
||||||
#define codenl() fprintf(code,"\n")
|
#define codenl() fprintf(code,"\n")
|
||||||
#else
|
#else /* CODEDEBUG */
|
||||||
#define codenl()
|
#define codenl()
|
||||||
#define code8nl(x) code8(x)
|
#define code8nl(x) code8(x)
|
||||||
|
|
||||||
code8(x) {
|
void code8(int x)
|
||||||
|
{
|
||||||
codeindex++;
|
codeindex++;
|
||||||
if (code_in_c)
|
if (code_in_c)
|
||||||
fprintf(ctable,"%d,",x&0377);
|
fprintf(ctable,"%d,",x&0377);
|
||||||
@ -139,13 +142,13 @@ code8(x) {
|
|||||||
putc(x,code);
|
putc(x,code);
|
||||||
}
|
}
|
||||||
|
|
||||||
code53(x,y) {
|
void code53(int x, int y)
|
||||||
|
{
|
||||||
code8(x+(y<<5));
|
code8(x+(y<<5));
|
||||||
}
|
}
|
||||||
|
|
||||||
codeint(x) {
|
void codeint(int x)
|
||||||
|
{
|
||||||
assert(x>=0 && x<=32767);
|
assert(x>=0 && x<=32767);
|
||||||
if (x<128) {
|
if (x<128) {
|
||||||
code8(x);
|
code8(x);
|
||||||
@ -155,19 +158,21 @@ codeint(x) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif /* CODEDEBUG */
|
||||||
|
|
||||||
int prevind=0;
|
int prevind=0;
|
||||||
int npatbytes= -1;
|
int npatbytes= -1;
|
||||||
char pattern[MAXPATBYTES];
|
char pattern[MAXPATBYTES];
|
||||||
int pathash[256];
|
int pathash[256];
|
||||||
|
|
||||||
outpatterns() {
|
void outpatterns()
|
||||||
|
{
|
||||||
extern int npatterns;
|
extern int npatterns;
|
||||||
extern int patindex[];
|
extern int patindex[];
|
||||||
extern int empatlen;
|
extern int empatlen;
|
||||||
extern int emmnem[];
|
extern int emmnem[];
|
||||||
extern int empatexpr;
|
extern int empatexpr;
|
||||||
register i;
|
int i;
|
||||||
|
|
||||||
if (!inproc) {
|
if (!inproc) {
|
||||||
patbyte(0);
|
patbyte(0);
|
||||||
@ -190,8 +195,8 @@ outpatterns() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pat(n) {
|
void pat(int n)
|
||||||
|
{
|
||||||
assert(n>=0);
|
assert(n>=0);
|
||||||
if (n<128)
|
if (n<128)
|
||||||
patbyte(n);
|
patbyte(n);
|
||||||
@ -201,23 +206,24 @@ pat(n) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
patshort(n) {
|
void patshort(int n)
|
||||||
|
{
|
||||||
patbyte(n%256);
|
patbyte(n%256);
|
||||||
patbyte(n/256);
|
patbyte(n/256);
|
||||||
}
|
}
|
||||||
|
|
||||||
patbyte(n) {
|
void patbyte(int n)
|
||||||
|
{
|
||||||
NEXT(npatbytes, MAXPATBYTES, "Pattern bytes");
|
NEXT(npatbytes, MAXPATBYTES, "Pattern bytes");
|
||||||
pattern[npatbytes]=n;
|
pattern[npatbytes]=n;
|
||||||
}
|
}
|
||||||
|
|
||||||
hashpatterns() {
|
void hashpatterns()
|
||||||
|
{
|
||||||
short index;
|
short index;
|
||||||
register char *bp,*tp;
|
char *bp,*tp;
|
||||||
register short i;
|
short i;
|
||||||
unsigned short hashvalue;
|
short hashvalue;
|
||||||
int patlen;
|
int patlen;
|
||||||
|
|
||||||
index = prevind;
|
index = prevind;
|
||||||
@ -250,8 +256,8 @@ hashpatterns() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
outincludes() {
|
void outincludes()
|
||||||
|
{
|
||||||
fprintf(ctable,"#include \"param.h\"\n");
|
fprintf(ctable,"#include \"param.h\"\n");
|
||||||
fprintf(ctable,"#include \"tables.h\"\n");
|
fprintf(ctable,"#include \"tables.h\"\n");
|
||||||
fprintf(ctable,"#include \"types.h\"\n");
|
fprintf(ctable,"#include \"types.h\"\n");
|
||||||
@ -259,8 +265,9 @@ outincludes() {
|
|||||||
fprintf(ctable,"#include \"data.h\"\n");
|
fprintf(ctable,"#include \"data.h\"\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
outregs() {
|
void outregs()
|
||||||
register i,j,k;
|
{
|
||||||
|
int i,j,k;
|
||||||
short rset[SZOFSET(MAXREGS)];
|
short rset[SZOFSET(MAXREGS)];
|
||||||
short clashlist[MAXREGS*MAXREGS];
|
short clashlist[MAXREGS*MAXREGS];
|
||||||
int iclashlist = 0;
|
int iclashlist = 0;
|
||||||
@ -328,8 +335,9 @@ outregs() {
|
|||||||
fprintf(ctable, "0};\n\n");
|
fprintf(ctable, "0};\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
outregvars() {
|
void outregvars()
|
||||||
register i,j;
|
{
|
||||||
|
int i,j;
|
||||||
|
|
||||||
fprintf(htable,"#define REGVARS\n");
|
fprintf(htable,"#define REGVARS\n");
|
||||||
fprintf(ctable,"#include \"regvar.h\"\n");
|
fprintf(ctable,"#include \"regvar.h\"\n");
|
||||||
@ -365,8 +373,8 @@ outregvars() {
|
|||||||
fprintf(ctable,"};\n");
|
fprintf(ctable,"};\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
typeconv(n) {
|
int typeconv(int n)
|
||||||
|
{
|
||||||
if (n>=0) return(2);
|
if (n>=0) return(2);
|
||||||
if (n== -1) return(1);
|
if (n== -1) return(1);
|
||||||
if (n== -2) return(3);
|
if (n== -2) return(3);
|
||||||
@ -374,8 +382,7 @@ typeconv(n) {
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
outfmt(p)
|
void outfmt(char *p)
|
||||||
register char *p;
|
|
||||||
{
|
{
|
||||||
register int c;
|
register int c;
|
||||||
fprintf(ctable,"\"");
|
fprintf(ctable,"\"");
|
||||||
@ -390,9 +397,10 @@ register char *p;
|
|||||||
fprintf(ctable,"\"");
|
fprintf(ctable,"\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
outtokens() {
|
void outtokens()
|
||||||
register tokno,i;
|
{
|
||||||
register token_p tp;
|
int tokno,i;
|
||||||
|
token_p tp;
|
||||||
|
|
||||||
fprintf(ctable,"tkdef_t tokens[] = {{0},\n");
|
fprintf(ctable,"tkdef_t tokens[] = {{0},\n");
|
||||||
for (tokno=1;tokno<ntokens;tokno++) {
|
for (tokno=1;tokno<ntokens;tokno++) {
|
||||||
@ -409,8 +417,9 @@ outtokens() {
|
|||||||
fprintf(ctable,"{0}};\n\n");
|
fprintf(ctable,"{0}};\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
outenodes() {
|
void outenodes()
|
||||||
register node_p np;
|
{
|
||||||
|
node_p np;
|
||||||
extern node_t nodes[];
|
extern node_t nodes[];
|
||||||
extern int nnodes;
|
extern int nnodes;
|
||||||
|
|
||||||
@ -421,10 +430,11 @@ outenodes() {
|
|||||||
fprintf(ctable,"};\n\n");
|
fprintf(ctable,"};\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
outstrings() {
|
void outstrings()
|
||||||
register i;
|
{
|
||||||
register char *p;
|
int i;
|
||||||
register int c;
|
char *p;
|
||||||
|
int c;
|
||||||
extern char * filename;
|
extern char * filename;
|
||||||
|
|
||||||
if (tabledebug)
|
if (tabledebug)
|
||||||
@ -451,9 +461,10 @@ outstrings() {
|
|||||||
|
|
||||||
extern set_t unstackset;
|
extern set_t unstackset;
|
||||||
|
|
||||||
outsets() {
|
void outsets()
|
||||||
register i;
|
{
|
||||||
register set_p sp;
|
int i;
|
||||||
|
set_p sp;
|
||||||
|
|
||||||
fprintf(ctable,"set_t machsets[] = {\n");
|
fprintf(ctable,"set_t machsets[] = {\n");
|
||||||
for (sp=l_sets;sp< &l_sets[nsets]; sp++) {
|
for (sp=l_sets;sp< &l_sets[nsets]; sp++) {
|
||||||
@ -470,9 +481,10 @@ outsets() {
|
|||||||
fprintf(ctable,"}};\n\n");
|
fprintf(ctable,"}};\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
outinstances() {
|
void outinstances()
|
||||||
register inst_p ip;
|
{
|
||||||
register i;
|
inst_p ip;
|
||||||
|
int i;
|
||||||
|
|
||||||
fprintf(ctable,"inst_t tokeninstances[] = {\n");
|
fprintf(ctable,"inst_t tokeninstances[] = {\n");
|
||||||
for (ip=l_instances;ip< &l_instances[ninstances]; ip++) {
|
for (ip=l_instances;ip< &l_instances[ninstances]; ip++) {
|
||||||
@ -484,8 +496,9 @@ outinstances() {
|
|||||||
fprintf(ctable,"};\n\n");
|
fprintf(ctable,"};\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
outmoves() {
|
void outmoves()
|
||||||
register move_p mp;
|
{
|
||||||
|
move_p mp;
|
||||||
|
|
||||||
fprintf(ctable,"move_t moves[] = {\n");
|
fprintf(ctable,"move_t moves[] = {\n");
|
||||||
for (mp=l_moves; mp< &l_moves[nmoves]; mp++)
|
for (mp=l_moves; mp< &l_moves[nmoves]; mp++)
|
||||||
@ -496,8 +509,9 @@ outmoves() {
|
|||||||
fprintf(ctable,"{-1}\n};\n\n");
|
fprintf(ctable,"{-1}\n};\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
outtests() {
|
void outtests()
|
||||||
register test_p tp;
|
{
|
||||||
|
test_p tp;
|
||||||
|
|
||||||
fprintf(ctable,"test_t tests[] = {\n");
|
fprintf(ctable,"test_t tests[] = {\n");
|
||||||
for (tp=l_tests; tp< &l_tests[ntests]; tp++)
|
for (tp=l_tests; tp< &l_tests[ntests]; tp++)
|
||||||
@ -507,8 +521,9 @@ outtests() {
|
|||||||
fprintf(ctable,"{-1}\n};\n\n");
|
fprintf(ctable,"{-1}\n};\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
outstacks() {
|
void outstacks()
|
||||||
register c1_p cp;
|
{
|
||||||
|
c1_p cp;
|
||||||
|
|
||||||
fprintf(ctable,"c1_t c1coercs[] = {\n");
|
fprintf(ctable,"c1_t c1coercs[] = {\n");
|
||||||
for (cp=l_stacks; cp< &l_stacks[nstacks]; cp++)
|
for (cp=l_stacks; cp< &l_stacks[nstacks]; cp++)
|
||||||
@ -518,9 +533,10 @@ outstacks() {
|
|||||||
fprintf(ctable,"{-1}\n};\n\n");
|
fprintf(ctable,"{-1}\n};\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
outsplits() {
|
void outsplits()
|
||||||
register c2_p cp;
|
{
|
||||||
register i;
|
c2_p cp;
|
||||||
|
int i;
|
||||||
|
|
||||||
fprintf(ctable,"c2_t c2coercs[] = {\n");
|
fprintf(ctable,"c2_t c2coercs[] = {\n");
|
||||||
for (cp=l_split; cp< &l_split[nsplit]; cp++) {
|
for (cp=l_split; cp< &l_split[nsplit]; cp++) {
|
||||||
@ -533,8 +549,9 @@ outsplits() {
|
|||||||
fprintf(ctable,"{-1}\n};\n\n");
|
fprintf(ctable,"{-1}\n};\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
outcoercs() {
|
void outcoercs()
|
||||||
register c3_p cp;
|
{
|
||||||
|
c3_p cp;
|
||||||
|
|
||||||
fprintf(ctable,"c3_t c3coercs[] = {\n");
|
fprintf(ctable,"c3_t c3coercs[] = {\n");
|
||||||
for (cp=l_coercs; cp< &l_coercs[ncoercs]; cp++)
|
for (cp=l_coercs; cp< &l_coercs[ncoercs]; cp++)
|
||||||
@ -544,9 +561,10 @@ outcoercs() {
|
|||||||
fprintf(ctable,"{-1}\n};\n\n");
|
fprintf(ctable,"{-1}\n};\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
outproplists() {
|
void outproplists()
|
||||||
register propno;
|
{
|
||||||
register regno;
|
int propno;
|
||||||
|
int regno;
|
||||||
|
|
||||||
for(propno=0;propno<nprops;propno++) {
|
for(propno=0;propno<nprops;propno++) {
|
||||||
fprintf(ctable,"struct reginfo *rlist%d[] = {\n",propno);
|
fprintf(ctable,"struct reginfo *rlist%d[] = {\n",propno);
|
||||||
@ -561,28 +579,30 @@ outproplists() {
|
|||||||
fprintf(ctable,"};\n\n");
|
fprintf(ctable,"};\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
outconsts() {
|
void outconsts()
|
||||||
|
{
|
||||||
fprintf(ctable,"unsigned cc1 = %u;\n",fc1);
|
fprintf(ctable,"unsigned cc1 = %u;\n",fc1);
|
||||||
fprintf(ctable,"unsigned cc2 = %u;\n",fc2);
|
fprintf(ctable,"unsigned cc2 = %u;\n",fc2);
|
||||||
fprintf(ctable,"unsigned cc3 = %u;\n",fc3);
|
fprintf(ctable,"unsigned cc3 = %u;\n",fc3);
|
||||||
fprintf(ctable,"unsigned cc4 = %u;\n",fc4);
|
fprintf(ctable,"unsigned cc4 = %u;\n",fc4);
|
||||||
}
|
}
|
||||||
|
|
||||||
cdef(s,n) char *s; {
|
void cdef(char *s, int n)
|
||||||
|
{
|
||||||
fprintf(htable,"#define %s %d\n",s,n);
|
fprintf(htable,"#define %s %d\n",s,n);
|
||||||
}
|
}
|
||||||
|
|
||||||
passon(s) char *s; {
|
void passon(char *s)
|
||||||
|
{
|
||||||
char buf[32];
|
char buf[32];
|
||||||
|
|
||||||
sprintf(buf,"T%s",s);
|
sprintf(buf,"T%s",s);
|
||||||
cdef(buf,cmustbeset(s));
|
cdef(buf,cmustbeset(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
outdefs() {
|
void outdefs()
|
||||||
register symbol *sy_p;
|
{
|
||||||
|
symbol *sy_p;
|
||||||
extern int maxempatlen,maxrule;
|
extern int maxempatlen,maxrule;
|
||||||
char *wrdfmt;
|
char *wrdfmt;
|
||||||
|
|
||||||
@ -614,8 +634,9 @@ outdefs() {
|
|||||||
cdef("USE_TES",1);
|
cdef("USE_TES",1);
|
||||||
}
|
}
|
||||||
|
|
||||||
outars() {
|
void outars()
|
||||||
register i;
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
if (code_in_c)
|
if (code_in_c)
|
||||||
fprintf(htable,"#define CODEINC 1\n");
|
fprintf(htable,"#define CODEINC 1\n");
|
||||||
@ -635,8 +656,9 @@ outars() {
|
|||||||
fprintf(ctable,"};\n");
|
fprintf(ctable,"};\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
finishio() {
|
void finishio()
|
||||||
extern int nregs;
|
{
|
||||||
|
int nregs;
|
||||||
|
|
||||||
finishcode();
|
finishcode();
|
||||||
hashpatterns();
|
hashpatterns();
|
||||||
@ -662,8 +684,8 @@ finishio() {
|
|||||||
outars();
|
outars();
|
||||||
}
|
}
|
||||||
|
|
||||||
codecoco(cocono) {
|
void codecoco(cocono)
|
||||||
|
{
|
||||||
if (cocono== -1)
|
if (cocono== -1)
|
||||||
return;
|
return;
|
||||||
code8(DO_SETCC);
|
code8(DO_SETCC);
|
||||||
@ -671,13 +693,12 @@ codecoco(cocono) {
|
|||||||
codenl();
|
codenl();
|
||||||
}
|
}
|
||||||
|
|
||||||
dopattern(stackcoerc,kills,allocates,generates,yields,leaving)
|
void dopattern(int stackcoerc, varinfo *kills, varinfo *allocates, varinfo *generates, varinfo *yields, varinfo *leaving)
|
||||||
varinfo *kills,*allocates,*generates,*yields,*leaving;
|
|
||||||
{
|
{
|
||||||
register i;
|
int i;
|
||||||
int n,nops;
|
int n,nops;
|
||||||
register struct varinfo *vp,*vivp;
|
struct varinfo *vp,*vivp;
|
||||||
register instr_p instp;
|
instr_p instp;
|
||||||
int al,deal;
|
int al,deal;
|
||||||
int vil;
|
int vil;
|
||||||
int cocono= -1;
|
int cocono= -1;
|
||||||
@ -884,13 +905,14 @@ varinfo *kills,*allocates,*generates,*yields,*leaving;
|
|||||||
code8nl(DO_NEXTEM);
|
code8nl(DO_NEXTEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
used(resource,use,max) char *resource; {
|
void used(char *resource, int use, int max)
|
||||||
|
{
|
||||||
if (verbose || 4*use > 3*max)
|
if (verbose || 4*use > 3*max)
|
||||||
fprintf(stderr,"%s %d(%d)\n",resource,use,max);
|
fprintf(stderr,"%s %d(%d)\n",resource,use,max);
|
||||||
}
|
}
|
||||||
|
|
||||||
statistics() {
|
void statistics()
|
||||||
|
{
|
||||||
extern char *beg_sbrk,*sbrk();
|
extern char *beg_sbrk,*sbrk();
|
||||||
extern int nnodes, maxempatlen,maxrule;
|
extern int nnodes, maxempatlen,maxrule;
|
||||||
|
|
||||||
|
|||||||
@ -7,8 +7,7 @@
|
|||||||
static char rcsid2[]= "$Id$";
|
static char rcsid2[]= "$Id$";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char *mystrcpy();
|
#include "extern.h"
|
||||||
int myatoi();
|
|
||||||
|
|
||||||
int lineno=1;
|
int lineno=1;
|
||||||
extern char *filename;
|
extern char *filename;
|
||||||
@ -21,10 +20,10 @@ extern char *filename;
|
|||||||
do {
|
do {
|
||||||
while (c!='*') {
|
while (c!='*') {
|
||||||
c = input();
|
c = input();
|
||||||
if (c=='\n') lineno++;
|
if (c=='\n') lineno++;
|
||||||
}
|
}
|
||||||
c = input();
|
c = input();
|
||||||
if (c=='\n') lineno++;
|
if (c=='\n') lineno++;
|
||||||
} while (c!='/');
|
} while (c!='/');
|
||||||
}
|
}
|
||||||
^\#(line)?[ \t]*[0-9]+[ \t]+\".*\".*$ {
|
^\#(line)?[ \t]*[0-9]+[ \t]+\".*\".*$ {
|
||||||
@ -87,8 +86,8 @@ extern char *filename;
|
|||||||
%%
|
%%
|
||||||
int skipping=0;
|
int skipping=0;
|
||||||
|
|
||||||
yywrap() {
|
int yywrap()
|
||||||
|
{
|
||||||
if (skipping)
|
if (skipping)
|
||||||
fatal("EOF reached during error recovery");
|
fatal("EOF reached during error recovery");
|
||||||
return(1);
|
return(1);
|
||||||
@ -99,8 +98,9 @@ yywrap() {
|
|||||||
|
|
||||||
#define yytext_ptr yytext
|
#define yytext_ptr yytext
|
||||||
|
|
||||||
skipupto(tok,str) char *str; {
|
void skipupto(int tok, char *str)
|
||||||
register i;
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
skipping=1;
|
skipping=1;
|
||||||
while (yylex()!=tok)
|
while (yylex()!=tok)
|
||||||
|
|||||||
@ -17,9 +17,10 @@ static char rcsid[]= "$Id$";
|
|||||||
|
|
||||||
extern set_t l_sets[];
|
extern set_t l_sets[];
|
||||||
|
|
||||||
setlookup(s) set_t s; {
|
int setlookup(set_t s)
|
||||||
register set_p p;
|
{
|
||||||
register i;
|
set_p p;
|
||||||
|
int i;
|
||||||
int setno;
|
int setno;
|
||||||
|
|
||||||
for(p=l_sets;p<&l_sets[nsets];p++) {
|
for(p=l_sets;p<&l_sets[nsets];p++) {
|
||||||
@ -36,9 +37,10 @@ setlookup(s) set_t s; {
|
|||||||
return(setno);
|
return(setno);
|
||||||
}
|
}
|
||||||
|
|
||||||
make_std_sets() {
|
void make_std_sets()
|
||||||
|
{
|
||||||
set_t s;
|
set_t s;
|
||||||
register i;
|
int i;
|
||||||
|
|
||||||
for(i=0;i<SETSIZE;i++)
|
for(i=0;i<SETSIZE;i++)
|
||||||
s.set_val[i]=0;
|
s.set_val[i]=0;
|
||||||
@ -51,10 +53,11 @@ make_std_sets() {
|
|||||||
|
|
||||||
set_t emptyset;
|
set_t emptyset;
|
||||||
|
|
||||||
set_t ident_to_set(name) char *name; {
|
set_t ident_to_set(char *name)
|
||||||
register symbol *sy_p;
|
{
|
||||||
register i;
|
symbol *sy_p;
|
||||||
register struct propinfo *pp;
|
int i;
|
||||||
|
struct propinfo *pp;
|
||||||
int bitno;
|
int bitno;
|
||||||
set_t result;
|
set_t result;
|
||||||
|
|
||||||
@ -85,17 +88,15 @@ set_t ident_to_set(name) char *name; {
|
|||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static void checksize(set_p s)
|
||||||
checksize(s)
|
|
||||||
register set_p s;
|
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
register int size = -1;
|
int size = -1;
|
||||||
|
|
||||||
s->set_size = 0;
|
s->set_size = 0;
|
||||||
for (i = 1; i <= nregs; i++) {
|
for (i = 1; i <= nregs; i++) {
|
||||||
if (BIT(s->set_val, i)) {
|
if (BIT(s->set_val, i)) {
|
||||||
register int sz = l_regs[i].ri_size;
|
int sz = l_regs[i].ri_size;
|
||||||
|
|
||||||
if (size == -1) size = sz;
|
if (size == -1) size = sz;
|
||||||
else if (size != sz) return;
|
else if (size != sz) return;
|
||||||
@ -103,7 +104,7 @@ checksize(s)
|
|||||||
}
|
}
|
||||||
for (i = 1; i <= ntokens; i++) {
|
for (i = 1; i <= ntokens; i++) {
|
||||||
if (BIT(s->set_val, i+nregs)) {
|
if (BIT(s->set_val, i+nregs)) {
|
||||||
register int sz = l_tokens[i]->tk_size;
|
int sz = l_tokens[i]->tk_size;
|
||||||
if (size == -1) size = sz;
|
if (size == -1) size = sz;
|
||||||
else if (size != sz) return;
|
else if (size != sz) return;
|
||||||
}
|
}
|
||||||
@ -111,9 +112,10 @@ checksize(s)
|
|||||||
if (size != -1) s->set_size = size;
|
if (size != -1) s->set_size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_t setproduct(s1,s2) set_t s1,s2; {
|
set_t setproduct(set_t s1, set_t s2)
|
||||||
|
{
|
||||||
set_t result;
|
set_t result;
|
||||||
register i;
|
int i;
|
||||||
|
|
||||||
for(i=0;i<SETSIZE;i++)
|
for(i=0;i<SETSIZE;i++)
|
||||||
result.set_val[i] = s1.set_val[i] & s2.set_val[i];
|
result.set_val[i] = s1.set_val[i] & s2.set_val[i];
|
||||||
@ -121,9 +123,10 @@ set_t setproduct(s1,s2) set_t s1,s2; {
|
|||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_t setsum(s1,s2) set_t s1,s2; {
|
set_t setsum(set_t s1, set_t s2)
|
||||||
|
{
|
||||||
set_t result;
|
set_t result;
|
||||||
register i;
|
int i;
|
||||||
|
|
||||||
if (s1.set_size == s2.set_size)
|
if (s1.set_size == s2.set_size)
|
||||||
result.set_size = s1.set_size;
|
result.set_size = s1.set_size;
|
||||||
@ -134,9 +137,10 @@ set_t setsum(s1,s2) set_t s1,s2; {
|
|||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_t setdiff(s1,s2) set_t s1,s2; {
|
set_t setdiff(set_t s1, set_t s2)
|
||||||
|
{
|
||||||
set_t result;
|
set_t result;
|
||||||
register i;
|
int i;
|
||||||
|
|
||||||
for(i=0;i<SETSIZE;i++)
|
for(i=0;i<SETSIZE;i++)
|
||||||
result.set_val[i] = s1.set_val[i] & ~ s2.set_val[i];
|
result.set_val[i] = s1.set_val[i] & ~ s2.set_val[i];
|
||||||
|
|||||||
@ -6,14 +6,16 @@
|
|||||||
static char rcsid[]= "$Id$";
|
static char rcsid[]= "$Id$";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
#include "param.h"
|
#include "param.h"
|
||||||
|
#include "extern.h"
|
||||||
|
|
||||||
int nstrings=0;
|
int nstrings=0;
|
||||||
char *l_strings[MAXSTRINGS];
|
char *l_strings[MAXSTRINGS];
|
||||||
|
|
||||||
strlookup(str) char *str; {
|
int strlookup(char *str)
|
||||||
register i;
|
{
|
||||||
extern char *mystrcpy();
|
int i;
|
||||||
|
|
||||||
for(i=0;i<nstrings;i++)
|
for(i=0;i<nstrings;i++)
|
||||||
if (strcmp(str,l_strings[i])==0)
|
if (strcmp(str,l_strings[i])==0)
|
||||||
|
|||||||
132
util/ncgg/subr.c
132
util/ncgg/subr.c
@ -21,17 +21,20 @@ static char rcsid[]= "$Id$";
|
|||||||
#include <cgg_cg.h>
|
#include <cgg_cg.h>
|
||||||
#include "extern.h"
|
#include "extern.h"
|
||||||
|
|
||||||
n_proc(name) char *name; {
|
expr_t ident_expr(char *name);
|
||||||
register symbol *sy_p;
|
|
||||||
|
void n_proc(char *name)
|
||||||
|
{
|
||||||
|
symbol *sy_p;
|
||||||
extern int npatbytes;
|
extern int npatbytes;
|
||||||
|
|
||||||
sy_p = lookup(name,symproc,newsymbol);
|
sy_p = lookup(name,symproc,newsymbol);
|
||||||
sy_p->sy_value.syv_procoff = npatbytes + 1;
|
sy_p->sy_value.syv_procoff = npatbytes + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct varinfo *
|
struct varinfo *make_erase(char *name)
|
||||||
make_erase(name) char *name; {
|
{
|
||||||
expr_t e,ident_expr();
|
expr_t e;
|
||||||
struct varinfo *result;
|
struct varinfo *result;
|
||||||
|
|
||||||
e = ident_expr(name);
|
e = ident_expr(name);
|
||||||
@ -43,14 +46,11 @@ make_erase(name) char *name; {
|
|||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
n_instr(name,asname,oplist,eraselist,cost)
|
void n_instr(char *name, char *asname, operand *oplist, struct varinfo *eraselist, struct varinfo *cost)
|
||||||
char *name,*asname;
|
|
||||||
operand *oplist;
|
|
||||||
struct varinfo *eraselist,*cost;
|
|
||||||
{
|
{
|
||||||
register instrno;
|
int instrno;
|
||||||
register cc_count;
|
int cc_count;
|
||||||
register instr_p ip;
|
instr_p ip;
|
||||||
|
|
||||||
instrno = NEXT(ninstr,MAXINSTR,"Instructions");
|
instrno = NEXT(ninstr,MAXINSTR,"Instructions");
|
||||||
ip = &l_instr[instrno];
|
ip = &l_instr[instrno];
|
||||||
@ -80,20 +80,19 @@ struct varinfo *eraselist,*cost;
|
|||||||
error("No instruction can set condition codes more than once");
|
error("No instruction can set condition codes more than once");
|
||||||
}
|
}
|
||||||
|
|
||||||
n_set(name,number) char *name; {
|
void n_set(char *name, int number)
|
||||||
register symbol *sy_p;
|
{
|
||||||
|
symbol *sy_p;
|
||||||
|
|
||||||
sy_p = lookup(name,symset,newsymbol);
|
sy_p = lookup(name,symset,newsymbol);
|
||||||
sy_p->sy_value.syv_setno = number;
|
sy_p->sy_value.syv_setno = number;
|
||||||
}
|
}
|
||||||
|
|
||||||
n_tok(name,atts,size,cost,format)
|
void n_tok(char *name,struct varinfo *atts, int size, struct varinfo *cost, struct varinfo *format)
|
||||||
char *name;
|
|
||||||
struct varinfo *atts,*cost,*format;
|
|
||||||
{
|
{
|
||||||
register symbol *sy_p;
|
symbol *sy_p;
|
||||||
register token_p tp;
|
token_p tp;
|
||||||
register struct varinfo *vip;
|
struct varinfo *vip;
|
||||||
int i;
|
int i;
|
||||||
int tokno;
|
int tokno;
|
||||||
int thistokensize;
|
int thistokensize;
|
||||||
@ -149,9 +148,10 @@ struct varinfo *atts,*cost,*format;
|
|||||||
tp->tk_format = -1;
|
tp->tk_format = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkprintformat(n) {
|
void checkprintformat(int n)
|
||||||
register short *s;
|
{
|
||||||
register i;
|
short *s;
|
||||||
|
int i;
|
||||||
extern set_t l_sets[];
|
extern set_t l_sets[];
|
||||||
|
|
||||||
s= l_sets[n].set_val;
|
s= l_sets[n].set_val;
|
||||||
@ -161,9 +161,10 @@ checkprintformat(n) {
|
|||||||
l_tokens[i-nregs]->tk_name);
|
l_tokens[i-nregs]->tk_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
n_prop(name,size) char *name; int size; {
|
void n_prop(char *name, int size)
|
||||||
|
{
|
||||||
int propno;
|
int propno;
|
||||||
register symbol *sp;
|
symbol *sp;
|
||||||
|
|
||||||
propno = NEXT(nprops,MAXPROPS,"Properties");
|
propno = NEXT(nprops,MAXPROPS,"Properties");
|
||||||
sp = lookup(name,symprop,newsymbol);
|
sp = lookup(name,symprop,newsymbol);
|
||||||
@ -175,8 +176,8 @@ n_prop(name,size) char *name; int size; {
|
|||||||
l_props[propno].pr_size = size;
|
l_props[propno].pr_size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
prophall(n) {
|
void prophall(int n) {
|
||||||
register i;
|
int i;
|
||||||
short hallset[SETSIZE];
|
short hallset[SETSIZE];
|
||||||
|
|
||||||
if (n < 0) return;
|
if (n < 0) return;
|
||||||
@ -185,9 +186,10 @@ prophall(n) {
|
|||||||
nexthall(hallset);
|
nexthall(hallset);
|
||||||
}
|
}
|
||||||
|
|
||||||
n_reg(name,printstring,nmemb,member1,member2) char *name,*printstring; {
|
int n_reg(char *name, char *printstring, int nmemb, int member1, int member2)
|
||||||
register symbol *sy_p;
|
{
|
||||||
register reginfo *ri_p;
|
symbol *sy_p;
|
||||||
|
reginfo *ri_p;
|
||||||
int regno;
|
int regno;
|
||||||
|
|
||||||
sy_p = lookup(name,symreg,newsymbol);
|
sy_p = lookup(name,symreg,newsymbol);
|
||||||
@ -202,35 +204,38 @@ n_reg(name,printstring,nmemb,member1,member2) char *name,*printstring; {
|
|||||||
return(regno);
|
return(regno);
|
||||||
}
|
}
|
||||||
|
|
||||||
make_const() {
|
void make_const()
|
||||||
|
{
|
||||||
wordsize = cmustbeset("EM_WSIZE");
|
wordsize = cmustbeset("EM_WSIZE");
|
||||||
pointersize = cmustbeset("EM_PSIZE");
|
pointersize = cmustbeset("EM_PSIZE");
|
||||||
}
|
}
|
||||||
|
|
||||||
cmustbeset(ident) char *ident; {
|
int cmustbeset(char *ident)
|
||||||
|
{
|
||||||
return(lookup(ident,symconst,mustexist)->sy_value.syv_cstval);
|
return(lookup(ident,symconst,mustexist)->sy_value.syv_cstval);
|
||||||
}
|
}
|
||||||
|
|
||||||
n_const(ident,val) char *ident; {
|
void n_const(char *ident, int val)
|
||||||
register symbol *sy_p;
|
{
|
||||||
|
symbol *sy_p;
|
||||||
|
|
||||||
sy_p = lookup(ident,symconst,newsymbol);
|
sy_p = lookup(ident,symconst,newsymbol);
|
||||||
sy_p->sy_value.syv_cstval = val;
|
sy_p->sy_value.syv_cstval = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
n_sconst(ident,val) char *ident,*val; {
|
void n_sconst(char *ident, char *val)
|
||||||
register symbol *sy_p;
|
{
|
||||||
|
symbol *sy_p;
|
||||||
|
|
||||||
sy_p = lookup(ident,symsconst,newsymbol);
|
sy_p = lookup(ident,symsconst,newsymbol);
|
||||||
sy_p->sy_value.syv_stringno = strlookup(val);
|
sy_p->sy_value.syv_stringno = strlookup(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
regline(rl,pl,rv) varinfo *rl,*pl; {
|
void regline(varinfo *rl, varinfo *pl, int rv)
|
||||||
register varinfo *rrl,*rpl;
|
{
|
||||||
register short *sp;
|
varinfo *rrl,*rpl;
|
||||||
register reginfo *regp;
|
short *sp;
|
||||||
|
reginfo *regp;
|
||||||
int thissize;
|
int thissize;
|
||||||
int propno;
|
int propno;
|
||||||
|
|
||||||
@ -261,7 +266,7 @@ regline(rl,pl,rv) varinfo *rl,*pl; {
|
|||||||
if (nregvar[rv]==0)
|
if (nregvar[rv]==0)
|
||||||
rvsize[rv] = regp->ri_size;
|
rvsize[rv] = regp->ri_size;
|
||||||
else if (rvsize[rv]!=regp->ri_size)
|
else if (rvsize[rv]!=regp->ri_size)
|
||||||
error("All register variables of one type must have the same size");
|
error("All variables of one type must have the same size");
|
||||||
NEXT(nregvar[rv],MAXREGVAR,"Register variable");
|
NEXT(nregvar[rv],MAXREGVAR,"Register variable");
|
||||||
rvnumbers[rv][nregvar[rv]-1] = rrl->vi_int[0];
|
rvnumbers[rv][nregvar[rv]-1] = rrl->vi_int[0];
|
||||||
}
|
}
|
||||||
@ -269,8 +274,8 @@ regline(rl,pl,rv) varinfo *rl,*pl; {
|
|||||||
regclass++;
|
regclass++;
|
||||||
}
|
}
|
||||||
|
|
||||||
setallreg(vi) struct varinfo *vi; {
|
void setallreg(struct varinfo *vi)
|
||||||
|
{
|
||||||
nallreg=0;
|
nallreg=0;
|
||||||
for(;vi!=0;vi=vi->vi_next) {
|
for(;vi!=0;vi=vi->vi_next) {
|
||||||
if (vi->vi_int[0]<0)
|
if (vi->vi_int[0]<0)
|
||||||
@ -279,8 +284,9 @@ setallreg(vi) struct varinfo *vi; {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
freevi(vip) register struct varinfo *vip; {
|
void freevi(struct varinfo *vip)
|
||||||
register i;
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
if (vip==0)
|
if (vip==0)
|
||||||
return;
|
return;
|
||||||
@ -291,9 +297,10 @@ freevi(vip) register struct varinfo *vip; {
|
|||||||
free(vip);
|
free(vip);
|
||||||
}
|
}
|
||||||
|
|
||||||
int myatoi(s) register char *s; {
|
int myatoi(char *s)
|
||||||
register int base=10;
|
{
|
||||||
register sum=0;
|
int base=10;
|
||||||
|
int sum=0;
|
||||||
|
|
||||||
if (*s=='0') {
|
if (*s=='0') {
|
||||||
base = 8;
|
base = 8;
|
||||||
@ -341,17 +348,18 @@ int myatoi(s) register char *s; {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *mystrcpy(s) char *s; {
|
char *mystrcpy(char *s)
|
||||||
register char *p;
|
{
|
||||||
char *myalloc();
|
char *p;
|
||||||
|
|
||||||
p=myalloc(strlen(s)+1);
|
p=myalloc(strlen(s)+1);
|
||||||
strcpy(p,s);
|
strcpy(p,s);
|
||||||
return(p);
|
return(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *myalloc(n) register n; {
|
char *myalloc(int n)
|
||||||
register char *p,*result;
|
{
|
||||||
|
char *p,*result;
|
||||||
|
|
||||||
result=p=malloc(n);
|
result=p=malloc(n);
|
||||||
if (p== (char *) 0)
|
if (p== (char *) 0)
|
||||||
@ -360,16 +368,17 @@ char *myalloc(n) register n; {
|
|||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
chkincl(value,lwb,upb) {
|
int chkincl(int value, int lwb, int upb)
|
||||||
|
{
|
||||||
if (value<lwb || value>upb)
|
if (value<lwb || value>upb)
|
||||||
error("Number %d should have been between %d and %d",
|
error("Number %d should have been between %d and %d",
|
||||||
value,lwb,upb);
|
value,lwb,upb);
|
||||||
return(value);
|
return(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
subset(sp1,sp2,setsize) short *sp1,*sp2; {
|
int subset(short *sp1, short *sp2, int setsize)
|
||||||
register i;
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
for(i=0;i<setsize;i++)
|
for(i=0;i<setsize;i++)
|
||||||
if ( (sp1[i] | sp2[i]) != sp2[i])
|
if ( (sp1[i] | sp2[i]) != sp2[i])
|
||||||
@ -377,8 +386,9 @@ subset(sp1,sp2,setsize) short *sp1,*sp2; {
|
|||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
vilength(vip) register struct varinfo *vip; {
|
int vilength(struct varinfo *vip)
|
||||||
register l=0;
|
{
|
||||||
|
int l=0;
|
||||||
|
|
||||||
while(vip!=0) {
|
while(vip!=0) {
|
||||||
vip=vip->vi_next;
|
vip=vip->vi_next;
|
||||||
|
|||||||
113
util/opt/alloc.c
113
util/opt/alloc.c
@ -4,6 +4,7 @@ static char rcsid[] = "$Id$";
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include "param.h"
|
#include "param.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "tes.h"
|
#include "tes.h"
|
||||||
@ -22,7 +23,7 @@ static char rcsid[] = "$Id$";
|
|||||||
|
|
||||||
#ifdef USEMALLOC
|
#ifdef USEMALLOC
|
||||||
|
|
||||||
short * myalloc();
|
short *myalloc(int size);
|
||||||
|
|
||||||
#define newcore(size) myalloc(size)
|
#define newcore(size) myalloc(size)
|
||||||
#define oldcore(p,size) free(p)
|
#define oldcore(p,size) free(p)
|
||||||
@ -34,8 +35,8 @@ short * myalloc();
|
|||||||
|
|
||||||
#define CCHUNK 1024 /* number of shorts asked from system */
|
#define CCHUNK 1024 /* number of shorts asked from system */
|
||||||
|
|
||||||
short *newcore(),*freshcore();
|
short *newcore(int size);
|
||||||
extern char *sbrk();
|
//short *freshcore();
|
||||||
|
|
||||||
#ifdef COREDEBUG
|
#ifdef COREDEBUG
|
||||||
int shortsasked=0;
|
int shortsasked=0;
|
||||||
@ -83,6 +84,10 @@ int asizetab[] = {
|
|||||||
ABASE+sizeof(s_a_con),
|
ABASE+sizeof(s_a_con),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void oldline(line_p lnp);
|
||||||
|
void oldargb(argb_p abp);
|
||||||
|
void oldreg(reg_p rp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* alloc routines:
|
* alloc routines:
|
||||||
* Two parts:
|
* Two parts:
|
||||||
@ -94,9 +99,10 @@ int asizetab[] = {
|
|||||||
* PART 1
|
* PART 1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
line_p newline(optyp) int optyp; {
|
line_p newline(int optyp)
|
||||||
register line_p lnp;
|
{
|
||||||
register kind=optyp;
|
line_p lnp;
|
||||||
|
int kind=optyp;
|
||||||
|
|
||||||
if (kind>OPMINI)
|
if (kind>OPMINI)
|
||||||
kind = OPMINI;
|
kind = OPMINI;
|
||||||
@ -105,8 +111,9 @@ line_p newline(optyp) int optyp; {
|
|||||||
return(lnp);
|
return(lnp);
|
||||||
}
|
}
|
||||||
|
|
||||||
oldline(lnp) register line_p lnp; {
|
void oldline(line_p lnp)
|
||||||
register kind=lnp->l_optyp&BMASK;
|
{
|
||||||
|
int kind=lnp->l_optyp&BMASK;
|
||||||
|
|
||||||
if (kind>OPMINI)
|
if (kind>OPMINI)
|
||||||
kind = OPMINI;
|
kind = OPMINI;
|
||||||
@ -115,16 +122,18 @@ oldline(lnp) register line_p lnp; {
|
|||||||
oldcore((short *) lnp,lsizetab[kind]);
|
oldcore((short *) lnp,lsizetab[kind]);
|
||||||
}
|
}
|
||||||
|
|
||||||
arg_p newarg(kind) int kind; {
|
arg_p newarg(int kind)
|
||||||
register arg_p ap;
|
{
|
||||||
|
arg_p ap;
|
||||||
|
|
||||||
ap = (arg_p) newcore(asizetab[kind]);
|
ap = (arg_p) newcore(asizetab[kind]);
|
||||||
ap->a_typ = kind;
|
ap->a_typ = kind;
|
||||||
return(ap);
|
return(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
oldargs(ap) register arg_p ap; {
|
void ldargs(arg_p ap)
|
||||||
register arg_p next;
|
{
|
||||||
|
arg_p next;
|
||||||
|
|
||||||
while (ap != (arg_p) 0) {
|
while (ap != (arg_p) 0) {
|
||||||
next = ap->a_next;
|
next = ap->a_next;
|
||||||
@ -143,8 +152,9 @@ oldargs(ap) register arg_p ap; {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
oldargb(abp) register argb_p abp; {
|
void oldargb(argb_p abp)
|
||||||
register argb_p next;
|
{
|
||||||
|
argb_p next;
|
||||||
|
|
||||||
while (abp != (argb_p) 0) {
|
while (abp != (argb_p) 0) {
|
||||||
next = abp->ab_next;
|
next = abp->ab_next;
|
||||||
@ -153,13 +163,13 @@ oldargb(abp) register argb_p abp; {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reg_p newreg() {
|
reg_p newreg()
|
||||||
|
{
|
||||||
return((reg_p) newcore(sizeof(reg_t)));
|
return((reg_p) newcore(sizeof(reg_t)));
|
||||||
}
|
}
|
||||||
|
|
||||||
oldreg(rp) reg_p rp; {
|
void oldreg(reg_p rp)
|
||||||
|
{
|
||||||
oldcore((short *) rp,sizeof(reg_t));
|
oldcore((short *) rp,sizeof(reg_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,17 +178,18 @@ num_p newnum() {
|
|||||||
return((num_p) newcore(sizeof(num_t)));
|
return((num_p) newcore(sizeof(num_t)));
|
||||||
}
|
}
|
||||||
|
|
||||||
oldnum(lp) num_p lp; {
|
void oldnum(num_p lp)
|
||||||
|
{
|
||||||
oldcore((short *) lp,sizeof(num_t));
|
oldcore((short *) lp,sizeof(num_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
offset *newrom() {
|
offset *newrom()
|
||||||
|
{
|
||||||
return((offset *) newcore(MAXROM*sizeof(offset)));
|
return((offset *) newcore(MAXROM*sizeof(offset)));
|
||||||
}
|
}
|
||||||
|
|
||||||
sym_p newsym(len) int len; {
|
sym_p newsym(int len)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* sym_t includes a 2 character s_name at the end
|
* sym_t includes a 2 character s_name at the end
|
||||||
* extend this structure with len-2 characters
|
* extend this structure with len-2 characters
|
||||||
@ -186,8 +197,8 @@ sym_p newsym(len) int len; {
|
|||||||
return((sym_p) newcore(sizeof(sym_t) - 2 + len));
|
return((sym_p) newcore(sizeof(sym_t) - 2 + len));
|
||||||
}
|
}
|
||||||
|
|
||||||
argb_p newargb() {
|
argb_p newargb()
|
||||||
|
{
|
||||||
return((argb_p) newcore(sizeof(argb_t)));
|
return((argb_p) newcore(sizeof(argb_t)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,10 +219,11 @@ typedef struct coreblock {
|
|||||||
|
|
||||||
#define SINC (sizeof(core_t)/sizeof(short))
|
#define SINC (sizeof(core_t)/sizeof(short))
|
||||||
#ifdef COREDEBUG
|
#ifdef COREDEBUG
|
||||||
coreverbose() {
|
void coreverbose()
|
||||||
register size;
|
{
|
||||||
register short *p;
|
int size;
|
||||||
register sum;
|
short *p;
|
||||||
|
int sum;
|
||||||
|
|
||||||
sum = 0;
|
sum = 0;
|
||||||
for(size=1;size<MAXSHORT;size++)
|
for(size=1;size<MAXSHORT;size++)
|
||||||
@ -223,8 +235,9 @@ coreverbose() {
|
|||||||
|
|
||||||
#ifdef SEPID
|
#ifdef SEPID
|
||||||
|
|
||||||
compactcore() {
|
void compactcore()
|
||||||
register core_p corelist=0,tp,cl;
|
{
|
||||||
|
core_p corelist=0,tp,cl;
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
#ifdef COREDEBUG
|
#ifdef COREDEBUG
|
||||||
@ -271,9 +284,10 @@ compactcore() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
short *grabcore(size) int size; {
|
short *grabcore(int size)
|
||||||
register short *p;
|
{
|
||||||
register trysize;
|
short *p;
|
||||||
|
int trysize;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Desperate situation, can't get more core from system.
|
* Desperate situation, can't get more core from system.
|
||||||
@ -320,7 +334,8 @@ short *grabcore(size) int size; {
|
|||||||
}
|
}
|
||||||
#endif /* SEPID */
|
#endif /* SEPID */
|
||||||
|
|
||||||
short *newcore(size) int size; {
|
short *newcore(int size)
|
||||||
|
{
|
||||||
register short *p,*q;
|
register short *p,*q;
|
||||||
|
|
||||||
size = (size + sizeof(int) - 1) & ~(sizeof(int) - 1);
|
size = (size + sizeof(int) - 1) & ~(sizeof(int) - 1);
|
||||||
@ -350,8 +365,8 @@ short *newcore(size) int size; {
|
|||||||
* you can use these as substitutes
|
* you can use these as substitutes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *malloc(size) int size; {
|
char *malloc(int size)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* malloc(III) is called by stdio,
|
* malloc(III) is called by stdio,
|
||||||
* this routine is a substitute.
|
* this routine is a substitute.
|
||||||
@ -360,14 +375,16 @@ char *malloc(size) int size; {
|
|||||||
return( (char *) newcore(size));
|
return( (char *) newcore(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
free() {
|
void free(void *ptr)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
oldcore(p,size) short *p; int size; {
|
void oldcore(short *p, int size)
|
||||||
|
{
|
||||||
#ifdef CORECHECK
|
#ifdef CORECHECK
|
||||||
register short *cp;
|
short *cp;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
assert(size<2*MAXSHORT);
|
assert(size<2*MAXSHORT);
|
||||||
@ -382,8 +399,8 @@ oldcore(p,size) short *p; int size; {
|
|||||||
|
|
||||||
short *ccur,*cend;
|
short *ccur,*cend;
|
||||||
|
|
||||||
coreinit(p1,p2) short *p1,*p2; {
|
void coreinit(short *p1, short *p2)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* coreinit is called with the boundaries of a piece of
|
* coreinit is called with the boundaries of a piece of
|
||||||
* memory that can be used for starters.
|
* memory that can be used for starters.
|
||||||
@ -393,8 +410,9 @@ coreinit(p1,p2) short *p1,*p2; {
|
|||||||
cend = p2;
|
cend = p2;
|
||||||
}
|
}
|
||||||
|
|
||||||
short *freshcore(size) int size; {
|
short *freshcore(int size)
|
||||||
register short *temp;
|
{
|
||||||
|
short *temp;
|
||||||
static int cchunk=CCHUNK;
|
static int cchunk=CCHUNK;
|
||||||
|
|
||||||
while(&ccur[size/sizeof(short)] >= cend && cchunk>0) {
|
while(&ccur[size/sizeof(short)] >= cend && cchunk>0) {
|
||||||
@ -419,19 +437,20 @@ short *freshcore(size) int size; {
|
|||||||
|
|
||||||
#else /* USEMALLOC */
|
#else /* USEMALLOC */
|
||||||
|
|
||||||
coreinit() {
|
void coreinit() {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Empty function, no initialization needed
|
* Empty function, no initialization needed
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
short *myalloc(size) register size; {
|
short *myalloc(int size)
|
||||||
|
{
|
||||||
register short *p,*q;
|
register short *p,*q;
|
||||||
|
|
||||||
p = (short *)malloc(size);
|
p = (short *)malloc(size);
|
||||||
if (p == 0)
|
if (p == 0)
|
||||||
error("out of memory");
|
error("out of memory", NULL);
|
||||||
for(q=p;size>0;size -= sizeof(short))
|
for(q=p;size>0;size -= sizeof(short))
|
||||||
*q++ = 0;
|
*q++ = 0;
|
||||||
return(p);
|
return(p);
|
||||||
|
|||||||
@ -12,9 +12,11 @@ extern arg_p newarg();
|
|||||||
extern argb_p newargb();
|
extern argb_p newargb();
|
||||||
extern reg_p newreg();
|
extern reg_p newreg();
|
||||||
|
|
||||||
extern oldline();
|
|
||||||
extern oldloc();
|
|
||||||
extern oldreg();
|
void oldline(line_p lnp);
|
||||||
|
void oldargb(argb_p abp);
|
||||||
|
void oldreg(reg_p rp);
|
||||||
|
|
||||||
#define USEMALLOC /* if defined malloc() and free() are used */
|
#define USEMALLOC /* if defined malloc() and free() are used */
|
||||||
|
|
||||||
|
|||||||
@ -40,15 +40,14 @@ short curfrag = 3; /* see also peephole.c */
|
|||||||
offset rombuf[MAXROM];
|
offset rombuf[MAXROM];
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
extern offset aoff();
|
void backward()
|
||||||
|
{
|
||||||
backward() {
|
line_p lnp;
|
||||||
register line_p lnp;
|
|
||||||
line_p next;
|
line_p next;
|
||||||
register arg_p ap;
|
arg_p ap;
|
||||||
line_p i,p;
|
line_p i,p;
|
||||||
int n;
|
int n;
|
||||||
register sym_p sp;
|
sym_p sp;
|
||||||
|
|
||||||
i = p = (line_p) 0;
|
i = p = (line_p) 0;
|
||||||
curdtyp=0;
|
curdtyp=0;
|
||||||
|
|||||||
@ -20,10 +20,11 @@ static char rcsid[] = "$Id$";
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
cleanup() {
|
void cleanup()
|
||||||
|
{
|
||||||
FILE *infile;
|
FILE *infile;
|
||||||
register c;
|
int c;
|
||||||
register sym_p *spp,sp;
|
sym_p *spp,sp;
|
||||||
|
|
||||||
for (spp=symhash;spp< &symhash[NSYMHASH];spp++)
|
for (spp=symhash;spp< &symhash[NSYMHASH];spp++)
|
||||||
for (sp = *spp; sp != (sym_p) 0; sp = sp->s_next)
|
for (sp = *spp; sp != (sym_p) 0; sp = sp->s_next)
|
||||||
|
|||||||
@ -44,8 +44,12 @@ static char string[IDL+1]; /* temp store for names */
|
|||||||
|
|
||||||
#define readbyte getchar
|
#define readbyte getchar
|
||||||
|
|
||||||
short readshort() {
|
int inpseudo(short n);
|
||||||
register int l_byte, h_byte;
|
void tstinpro();
|
||||||
|
|
||||||
|
short readshort()
|
||||||
|
{
|
||||||
|
int l_byte, h_byte;
|
||||||
|
|
||||||
l_byte = readbyte();
|
l_byte = readbyte();
|
||||||
h_byte = readbyte();
|
h_byte = readbyte();
|
||||||
@ -54,9 +58,10 @@ short readshort() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LONGOFF
|
#ifdef LONGOFF
|
||||||
offset readoffset() {
|
offset readoffset()
|
||||||
register long l;
|
{
|
||||||
register int h_byte;
|
long l;
|
||||||
|
int h_byte;
|
||||||
|
|
||||||
l = readbyte();
|
l = readbyte();
|
||||||
l |= ((unsigned) readbyte())*256 ;
|
l |= ((unsigned) readbyte())*256 ;
|
||||||
@ -67,8 +72,8 @@ offset readoffset() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
draininput() {
|
void draininput()
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* called when MES ERR is encountered.
|
* called when MES ERR is encountered.
|
||||||
* Drain input in case it is a pipe.
|
* Drain input in case it is a pipe.
|
||||||
@ -78,8 +83,8 @@ draininput() {
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
short getint() {
|
short getint()
|
||||||
|
{
|
||||||
switch(table2()) {
|
switch(table2()) {
|
||||||
default: error("int expected");
|
default: error("int expected");
|
||||||
case CSTX1:
|
case CSTX1:
|
||||||
@ -87,8 +92,8 @@ short getint() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sym_p getsym(status) int status; {
|
sym_p getsym(int status)
|
||||||
|
{
|
||||||
switch(table2()) {
|
switch(table2()) {
|
||||||
default:
|
default:
|
||||||
error("symbol expected");
|
error("symbol expected");
|
||||||
@ -99,8 +104,8 @@ sym_p getsym(status) int status; {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
offset getoff() {
|
offset getoff()
|
||||||
|
{
|
||||||
switch (table2()) {
|
switch (table2()) {
|
||||||
default: error("offset expected");
|
default: error("offset expected");
|
||||||
case CSTX1:
|
case CSTX1:
|
||||||
@ -112,15 +117,16 @@ offset getoff() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
make_string(n) int n; {
|
void make_string(int n)
|
||||||
|
{
|
||||||
sprintf(string,".%u",n);
|
sprintf(string,".%u",n);
|
||||||
}
|
}
|
||||||
|
|
||||||
inident() {
|
void inident()
|
||||||
register n;
|
{
|
||||||
register char *p = string;
|
int n;
|
||||||
register c;
|
char *p = string;
|
||||||
|
int c;
|
||||||
|
|
||||||
n = getint();
|
n = getint();
|
||||||
while (n--) {
|
while (n--) {
|
||||||
@ -131,8 +137,8 @@ inident() {
|
|||||||
*p++ = 0;
|
*p++ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int table3(n) int n; {
|
int table3(int n)
|
||||||
|
{
|
||||||
switch (n) {
|
switch (n) {
|
||||||
case sp_ilb1: tabval = readbyte(); return(ILBX);
|
case sp_ilb1: tabval = readbyte(); return(ILBX);
|
||||||
case sp_ilb2: tabval = readshort(); return(ILBX);
|
case sp_ilb2: tabval = readshort(); return(ILBX);
|
||||||
@ -156,8 +162,9 @@ int table3(n) int n; {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int table1() {
|
int table1()
|
||||||
register n;
|
{
|
||||||
|
int n;
|
||||||
|
|
||||||
n = readbyte();
|
n = readbyte();
|
||||||
if (n == EOF)
|
if (n == EOF)
|
||||||
@ -177,8 +184,9 @@ int table1() {
|
|||||||
return(table3(n));
|
return(table3(n));
|
||||||
}
|
}
|
||||||
|
|
||||||
int table2() {
|
int table2()
|
||||||
register n;
|
{
|
||||||
|
int n;
|
||||||
|
|
||||||
n = readbyte();
|
n = readbyte();
|
||||||
if ((n < sp_fcst0 + sp_ncst0) && (n >= sp_fcst0)) {
|
if ((n < sp_fcst0 + sp_ncst0) && (n >= sp_fcst0)) {
|
||||||
@ -188,9 +196,10 @@ int table2() {
|
|||||||
return(table3(n));
|
return(table3(n));
|
||||||
}
|
}
|
||||||
|
|
||||||
getlines() {
|
void getlines()
|
||||||
register line_p lnp;
|
{
|
||||||
register instr;
|
line_p lnp;
|
||||||
|
int instr;
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
linecount++;
|
linecount++;
|
||||||
@ -296,8 +305,8 @@ getlines() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
argstring(length,abp) offset length; register argb_p abp; {
|
void argstring(offset length, argb_p abp)
|
||||||
|
{
|
||||||
while (length--) {
|
while (length--) {
|
||||||
if (abp->ab_index == NARGBYTES)
|
if (abp->ab_index == NARGBYTES)
|
||||||
abp = abp->ab_next = newargb();
|
abp = abp->ab_next = newargb();
|
||||||
@ -305,13 +314,13 @@ argstring(length,abp) offset length; register argb_p abp; {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
line_p arglist(n) int n; {
|
line_p arglist(int n)
|
||||||
|
{
|
||||||
line_p lnp;
|
line_p lnp;
|
||||||
register arg_p ap,*app;
|
arg_p ap,*app;
|
||||||
bool moretocome;
|
bool moretocome;
|
||||||
offset length;
|
offset length;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* creates an arglist with n elements
|
* creates an arglist with n elements
|
||||||
* if n == 0 the arglist is variable and terminated by sp_cend
|
* if n == 0 the arglist is variable and terminated by sp_cend
|
||||||
@ -385,8 +394,8 @@ line_p arglist(n) int n; {
|
|||||||
return(lnp);
|
return(lnp);
|
||||||
}
|
}
|
||||||
|
|
||||||
offset aoff(ap,n) register arg_p ap; {
|
offset aoff(arg_p ap, int n)
|
||||||
|
{
|
||||||
while (n>0) {
|
while (n>0) {
|
||||||
if (ap != (arg_p) 0)
|
if (ap != (arg_p) 0)
|
||||||
ap = ap->a_next;
|
ap = ap->a_next;
|
||||||
@ -399,7 +408,8 @@ offset aoff(ap,n) register arg_p ap; {
|
|||||||
return(ap->a_a.a_offset);
|
return(ap->a_a.a_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
int inpseudo(n) short n; {
|
int inpseudo(short n)
|
||||||
|
{
|
||||||
register line_p lnp,head,tail;
|
register line_p lnp,head,tail;
|
||||||
short n1,n2;
|
short n1,n2;
|
||||||
proinf savearea;
|
proinf savearea;
|
||||||
@ -542,8 +552,8 @@ int inpseudo(n) short n; {
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
tstinpro() {
|
void tstinpro()
|
||||||
|
{
|
||||||
if (prodepth==0)
|
if (prodepth==0)
|
||||||
error("This is not allowed outside a procedure");
|
error("This is not allowed outside a procedure");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,7 @@ struct sym {
|
|||||||
short s_flags;
|
short s_flags;
|
||||||
short s_frag;
|
short s_frag;
|
||||||
offset s_value;
|
offset s_value;
|
||||||
char s_name[2]; /* to be extended up to IDL */
|
char s_name[2 + IDL]; /* to be extended up to IDL */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* contents of .s_flags */
|
/* contents of .s_flags */
|
||||||
|
|||||||
@ -21,8 +21,11 @@ static char rcsid[] = "$Id$";
|
|||||||
/*
|
/*
|
||||||
* Main program for EM optimizer
|
* Main program for EM optimizer
|
||||||
*/
|
*/
|
||||||
|
void fileinit();
|
||||||
|
void flags(char *s);
|
||||||
|
|
||||||
main(argc,argv) int argc; char *argv[]; {
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
int somespace[STACKROOM];
|
int somespace[STACKROOM];
|
||||||
|
|
||||||
progname = argv[0];
|
progname = argv[0];
|
||||||
@ -42,8 +45,8 @@ main(argc,argv) int argc; char *argv[]; {
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
flags(s) register char *s; {
|
void flags(char *s)
|
||||||
|
{
|
||||||
for (s++;*s;s++)
|
for (s++;*s;s++)
|
||||||
switch(*s) {
|
switch(*s) {
|
||||||
case 'L': Lflag = TRUE; break;
|
case 'L': Lflag = TRUE; break;
|
||||||
@ -56,14 +59,13 @@ flags(s) register char *s; {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fileinit() {
|
void fileinit()
|
||||||
char *mktemp();
|
{
|
||||||
short readshort();
|
|
||||||
|
|
||||||
if (readshort() != (short) sp_magic)
|
if (readshort() != (short) sp_magic)
|
||||||
error("wrong input file");
|
error("wrong input file");
|
||||||
if (Lflag) {
|
if (Lflag) {
|
||||||
outfile = fopen(mktemp(template),"w");
|
mktemp(template);
|
||||||
|
outfile = fopen(template, "w");
|
||||||
if (outfile == NULL)
|
if (outfile == NULL)
|
||||||
error("can't create %s",template);
|
error("can't create %s",template);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -21,8 +21,15 @@ static char rcsid[] = "$Id$";
|
|||||||
* Author: Hans van Staveren
|
* Author: Hans van Staveren
|
||||||
*/
|
*/
|
||||||
|
|
||||||
process() {
|
void relabel();
|
||||||
|
void symknown();
|
||||||
|
void cleanlocals();
|
||||||
|
void checklocs();
|
||||||
|
void symvalue();
|
||||||
|
void do_tes();
|
||||||
|
|
||||||
|
void process()
|
||||||
|
{
|
||||||
if (wordsize == 0 || pointersize == 0)
|
if (wordsize == 0 || pointersize == 0)
|
||||||
error("No MES EMX encountered");
|
error("No MES EMX encountered");
|
||||||
backward(); /* reverse and cleanup list */
|
backward(); /* reverse and cleanup list */
|
||||||
@ -59,9 +66,10 @@ process() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
relabel() {
|
void relabel()
|
||||||
register num_p *npp,np,tp;
|
{
|
||||||
register num_p repl,ttp;
|
num_p *npp,np,tp;
|
||||||
|
num_p repl,ttp;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For each label find its final destination after crossjumping.
|
* For each label find its final destination after crossjumping.
|
||||||
@ -92,8 +100,9 @@ relabel() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
symknown() {
|
void symknown()
|
||||||
register sym_p *spp,sp;
|
{
|
||||||
|
sym_p *spp,sp;
|
||||||
|
|
||||||
for (spp = symhash; spp < &symhash[NSYMHASH]; spp++)
|
for (spp = symhash; spp < &symhash[NSYMHASH]; spp++)
|
||||||
for (sp = *spp; sp != (sym_p) 0; sp = sp->s_next)
|
for (sp = *spp; sp != (sym_p) 0; sp = sp->s_next)
|
||||||
@ -101,8 +110,9 @@ symknown() {
|
|||||||
sp->s_flags |= SYMKNOWN;
|
sp->s_flags |= SYMKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanlocals() {
|
void cleanlocals()
|
||||||
register num_p *npp,np,tp;
|
{
|
||||||
|
num_p *npp,np,tp;
|
||||||
|
|
||||||
for (npp = curpro.numhash; npp < &curpro.numhash[NNUMHASH]; npp++) {
|
for (npp = curpro.numhash; npp < &curpro.numhash[NNUMHASH]; npp++) {
|
||||||
np = *npp;
|
np = *npp;
|
||||||
@ -115,8 +125,9 @@ cleanlocals() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
checklocs() {
|
void checklocs()
|
||||||
register num_p *npp,np;
|
{
|
||||||
|
num_p *npp,np;
|
||||||
|
|
||||||
for (npp=curpro.numhash; npp < & curpro.numhash[NNUMHASH]; npp++)
|
for (npp=curpro.numhash; npp < & curpro.numhash[NNUMHASH]; npp++)
|
||||||
for (np = *npp; np != (num_p) 0; np=np->n_next)
|
for (np = *npp; np != (num_p) 0; np=np->n_next)
|
||||||
@ -125,17 +136,18 @@ checklocs() {
|
|||||||
(unsigned) np->n_number);
|
(unsigned) np->n_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
offset align(count,alignment) offset count,alignment; {
|
offset align(offset count, offset alignment)
|
||||||
|
{
|
||||||
assert(alignment==1||alignment==2||alignment==4);
|
assert(alignment==1||alignment==2||alignment==4);
|
||||||
return((count+alignment-1)&~(alignment-1));
|
return((count+alignment-1)&~(alignment-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
symvalue() {
|
void symvalue()
|
||||||
register line_p lp;
|
{
|
||||||
register sym_p sp;
|
line_p lp;
|
||||||
register arg_p ap;
|
sym_p sp;
|
||||||
register argb_p abp;
|
arg_p ap;
|
||||||
|
argb_p abp;
|
||||||
short curfrag = 0;
|
short curfrag = 0;
|
||||||
offset count;
|
offset count;
|
||||||
|
|
||||||
@ -189,9 +201,9 @@ symvalue() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
do_tes()
|
void do_tes()
|
||||||
{
|
{
|
||||||
register line_p insptr = instrs, oldlin = NULL, oldlin2 = NULL;
|
line_p insptr = instrs, oldlin = NULL, oldlin2 = NULL;
|
||||||
|
|
||||||
init_state();
|
init_state();
|
||||||
tes_pseudos();
|
tes_pseudos();
|
||||||
|
|||||||
@ -23,13 +23,25 @@ static char rcsid[] = "$Id$";
|
|||||||
*
|
*
|
||||||
* Author: Hans van Staveren
|
* Author: Hans van Staveren
|
||||||
*/
|
*/
|
||||||
|
void putargs(arg_p ap);
|
||||||
|
void putstr(argb_p abp);
|
||||||
|
void outdef(sym_p sp);
|
||||||
|
void outocc(sym_p sp);
|
||||||
|
void outinst(int m);
|
||||||
|
void outoff(offset off);
|
||||||
|
void outint(short i);
|
||||||
|
void outshort(short i);
|
||||||
|
void numlab(num_p np);
|
||||||
|
void outnum(num_p np);
|
||||||
|
void outsym(sym_p sp);
|
||||||
|
|
||||||
#define outbyte(b) putc(b,outfile)
|
#define outbyte(b) putc(b,outfile)
|
||||||
|
|
||||||
putlines(lnp) register line_p lnp; {
|
void putlines(line_p lnp)
|
||||||
register arg_p ap;
|
{
|
||||||
|
arg_p ap;
|
||||||
line_p temp;
|
line_p temp;
|
||||||
register instr;
|
int instr;
|
||||||
short curlin= -2;
|
short curlin= -2;
|
||||||
short thislin;
|
short thislin;
|
||||||
|
|
||||||
@ -187,8 +199,8 @@ processoperand:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
putargs(ap) register arg_p ap; {
|
void putargs(arg_p ap)
|
||||||
|
{
|
||||||
while (ap != (arg_p) 0) {
|
while (ap != (arg_p) 0) {
|
||||||
switch(ap->a_typ) {
|
switch(ap->a_typ) {
|
||||||
default:
|
default:
|
||||||
@ -228,9 +240,10 @@ putargs(ap) register arg_p ap; {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
putstr(abp) register argb_p abp; {
|
void putstr(argb_p abp)
|
||||||
register argb_p tbp;
|
{
|
||||||
register length;
|
argb_p tbp;
|
||||||
|
int length;
|
||||||
|
|
||||||
length = 0;
|
length = 0;
|
||||||
tbp = abp;
|
tbp = abp;
|
||||||
@ -246,8 +259,8 @@ putstr(abp) register argb_p abp; {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
outdef(sp) register sym_p sp; {
|
void outdef(sym_p sp)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* The surrounding If statement is removed to be friendly
|
* The surrounding If statement is removed to be friendly
|
||||||
* to Backend writers having to deal with assemblers
|
* to Backend writers having to deal with assemblers
|
||||||
@ -264,8 +277,8 @@ outdef(sp) register sym_p sp; {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
outocc(sp) register sym_p sp; {
|
void outocc(sym_p sp)
|
||||||
|
{
|
||||||
if ((sp->s_flags&SYMOUT)==0) {
|
if ((sp->s_flags&SYMOUT)==0) {
|
||||||
sp->s_flags |= SYMOUT;
|
sp->s_flags |= SYMOUT;
|
||||||
if ((sp->s_flags&SYMGLOBAL)==0) {
|
if ((sp->s_flags&SYMGLOBAL)==0) {
|
||||||
@ -275,7 +288,8 @@ outocc(sp) register sym_p sp; {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
outpro() {
|
void outpro()
|
||||||
|
{
|
||||||
|
|
||||||
outdef(curpro.symbol);
|
outdef(curpro.symbol);
|
||||||
outinst(ps_pro);
|
outinst(ps_pro);
|
||||||
@ -283,18 +297,19 @@ outpro() {
|
|||||||
outoff(curpro.localbytes);
|
outoff(curpro.localbytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
outend() {
|
void outend()
|
||||||
|
{
|
||||||
outinst(ps_end);
|
outinst(ps_end);
|
||||||
outoff(curpro.localbytes);
|
outoff(curpro.localbytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
outinst(m) {
|
void outinst(int m)
|
||||||
|
{
|
||||||
outbyte( (byte) m );
|
outbyte( (byte) m );
|
||||||
}
|
}
|
||||||
|
|
||||||
outoff(off) offset off; {
|
void outoff(offset off)
|
||||||
|
{
|
||||||
|
|
||||||
#ifdef LONGOFF
|
#ifdef LONGOFF
|
||||||
if ((short) off == off)
|
if ((short) off == off)
|
||||||
@ -309,8 +324,8 @@ outoff(off) offset off; {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
outint(i) short i; {
|
void outint(short i)
|
||||||
|
{
|
||||||
if (i>= -sp_zcst0 && i< sp_ncst0-sp_zcst0)
|
if (i>= -sp_zcst0 && i< sp_ncst0-sp_zcst0)
|
||||||
outbyte( (byte) (i+sp_zcst0+sp_fcst0) );
|
outbyte( (byte) (i+sp_zcst0+sp_fcst0) );
|
||||||
else {
|
else {
|
||||||
@ -319,22 +334,22 @@ outint(i) short i; {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
outshort(i) short i; {
|
void outshort(short i)
|
||||||
|
{
|
||||||
outbyte( (byte) (i&BMASK) );
|
outbyte( (byte) (i&BMASK) );
|
||||||
outbyte( (byte) (i>>8) );
|
outbyte( (byte) (i>>8) );
|
||||||
}
|
}
|
||||||
|
|
||||||
numlab(np) register num_p np; {
|
void numlab(num_p np)
|
||||||
|
{
|
||||||
if (np->n_number < sp_nilb0)
|
if (np->n_number < sp_nilb0)
|
||||||
outbyte( (byte) (np->n_number + sp_filb0) );
|
outbyte( (byte) (np->n_number + sp_filb0) );
|
||||||
else
|
else
|
||||||
outnum(np);
|
outnum(np);
|
||||||
}
|
}
|
||||||
|
|
||||||
outnum(np) register num_p np; {
|
void outnum(num_p np)
|
||||||
|
{
|
||||||
if(np->n_number<256) {
|
if(np->n_number<256) {
|
||||||
outbyte( (byte) sp_ilb1) ;
|
outbyte( (byte) sp_ilb1) ;
|
||||||
outbyte( (byte) (np->n_number) );
|
outbyte( (byte) (np->n_number) );
|
||||||
@ -344,10 +359,11 @@ outnum(np) register num_p np; {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
outsym(sp) register sym_p sp; {
|
void outsym(sym_p sp)
|
||||||
register byte *p;
|
{
|
||||||
register unsigned num;
|
byte *p;
|
||||||
|
unsigned int num;
|
||||||
|
warning("May do something nasty... (%s)", __func__);
|
||||||
if (sp->s_name[0] == '.') {
|
if (sp->s_name[0] == '.') {
|
||||||
num = atoi(&sp->s_name[1]);
|
num = atoi(&sp->s_name[1]);
|
||||||
if (num < 256) {
|
if (num < 256) {
|
||||||
@ -359,7 +375,7 @@ outsym(sp) register sym_p sp; {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
p= sp->s_name;
|
p= sp->s_name;
|
||||||
while (*p && p < &sp->s_name[IDL])
|
while ( (*p) && p < &sp->s_name[IDL] )
|
||||||
p++;
|
p++;
|
||||||
num = p - sp->s_name;
|
num = p - sp->s_name;
|
||||||
outbyte( (byte) (sp->s_flags&SYMPRO ? sp_pnam : sp_dnam) );
|
outbyte( (byte) (sp->s_flags&SYMPRO ? sp_pnam : sp_dnam) );
|
||||||
|
|||||||
@ -22,8 +22,8 @@ static char rcsid[] = "$Id$";
|
|||||||
|
|
||||||
|
|
||||||
/* VARARGS1 */
|
/* VARARGS1 */
|
||||||
error(s,a) char *s,*a; {
|
void error(char *s, char *a)
|
||||||
|
{
|
||||||
fprintf(stderr,"%s: error on line %u",progname,linecount);
|
fprintf(stderr,"%s: error on line %u",progname,linecount);
|
||||||
if (prodepth != 0)
|
if (prodepth != 0)
|
||||||
fprintf(stderr,"(%.*s)",IDL,curpro.symbol->s_name);
|
fprintf(stderr,"(%.*s)",IDL,curpro.symbol->s_name);
|
||||||
@ -37,16 +37,16 @@ error(s,a) char *s,*a; {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
badassertion(file,line) char *file; unsigned line; {
|
void badassertion(char *file, unsigned int line)
|
||||||
|
{
|
||||||
fprintf(stderr,"assertion failed file %s, line %u\n",file,line);
|
fprintf(stderr,"assertion failed file %s, line %u\n",file,line);
|
||||||
error("assertion");
|
error("assertion", NULL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DIAGOPT
|
#ifdef DIAGOPT
|
||||||
optim(n) {
|
void optim(int n)
|
||||||
|
{
|
||||||
fprintf(stderr,"Made optimization %d",n);
|
fprintf(stderr,"Made optimization %d",n);
|
||||||
if (prodepth)
|
if (prodepth)
|
||||||
fprintf(stderr," (%.*s)",IDL,curpro.symbol->s_name);
|
fprintf(stderr," (%.*s)",IDL,curpro.symbol->s_name);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user