Compare commits
214 Commits
unlabeled-
...
hs
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6555bf6893 | ||
|
|
bd796849ef | ||
|
|
9afbc0ad32 | ||
|
|
a5c07a52b4 | ||
|
|
43c97f0d41 | ||
|
|
24eeca9474 | ||
|
|
7eef0e0b59 | ||
|
|
9d03cb68c7 | ||
|
|
d89d5770b1 | ||
|
|
f6d9a497eb | ||
|
|
bac12b0c46 | ||
|
|
e13ebaad9e | ||
|
|
315806b282 | ||
|
|
43de6c3b78 | ||
|
|
0ec009bde2 | ||
|
|
0f8a2d3a39 | ||
|
|
b5402db333 | ||
|
|
4f5c40c608 | ||
|
|
2055a65cae | ||
|
|
ed6a7245bd | ||
|
|
2cd6c03840 | ||
|
|
c38d1013cb | ||
|
|
6da013b55a | ||
|
|
e3eae54592 | ||
|
|
7cc3184392 | ||
|
|
952ba464cc | ||
|
|
08b7ec6600 | ||
|
|
f918aa20fe | ||
|
|
54bac1caaf | ||
|
|
504da3a54d | ||
|
|
36cca2b9c7 | ||
|
|
6f8a00ee5c | ||
|
|
ca275f5d22 | ||
|
|
150c8164af | ||
|
|
70975146a1 | ||
|
|
962cc80686 | ||
|
|
f6ecbec936 | ||
|
|
8128e3d82d | ||
|
|
ea86ccd217 | ||
|
|
045ccfaeba | ||
|
|
a6b69be622 | ||
|
|
50d77d903a | ||
|
|
cbf6d06de2 | ||
|
|
bb0ff814f6 | ||
|
|
f80b30bdbb | ||
|
|
7f6105c294 | ||
|
|
1f59bd7223 | ||
|
|
8f7669b247 | ||
|
|
f950163854 | ||
|
|
38b8391594 | ||
|
|
e88fe13466 | ||
|
|
e29ef2395a | ||
|
|
546bcee023 | ||
|
|
a9beb24998 | ||
|
|
96da898a4a | ||
|
|
a69b503ad0 | ||
|
|
5fd55904ec | ||
|
|
195c808f88 | ||
|
|
50e3b4fe4a | ||
|
|
f366afdae1 | ||
|
|
c08fe56b97 | ||
|
|
ed3db93f56 | ||
|
|
71dc6af5a8 | ||
|
|
cfdc2ce05f | ||
|
|
845c92825a | ||
|
|
3adba1b759 | ||
|
|
ea6c20f5d1 | ||
|
|
d99b36abf8 | ||
|
|
93693877be | ||
|
|
2aa5c6b7d9 | ||
|
|
bbc3cb33cc | ||
|
|
77ebfceac5 | ||
|
|
3d10bd6e59 | ||
|
|
03a31cf3fc | ||
|
|
81267df9ad | ||
|
|
113cf23e0f | ||
|
|
3154365fff | ||
|
|
e006f1ec29 | ||
|
|
1c36c470db | ||
|
|
1da13e49e1 | ||
|
|
f077a39568 | ||
|
|
6474db065f | ||
|
|
10b16f7c76 | ||
|
|
1ff6c3236f | ||
|
|
19b13e8e4f | ||
|
|
e5d1aebbae | ||
|
|
b23de46c3a | ||
|
|
9bdd1abf9a | ||
|
|
6180399964 | ||
|
|
db0822fa37 | ||
|
|
11026ace27 | ||
|
|
76281fa307 | ||
|
|
dbcebe6e4c | ||
|
|
8a4d834bc6 | ||
|
|
925701dc62 | ||
|
|
385d7ffbd8 | ||
|
|
e1c24cb475 | ||
|
|
964976ff0b | ||
|
|
4eea24fe69 | ||
|
|
811bc78f04 | ||
|
|
b07af506d6 | ||
|
|
5e97bff353 | ||
|
|
c001aa20d7 | ||
|
|
61da47ea52 | ||
|
|
d6a3a26314 | ||
|
|
eca6c1f306 | ||
|
|
189e577315 | ||
|
|
8b9ebd989f | ||
|
|
182f3ee338 | ||
|
|
8707eb1715 | ||
|
|
9935b1fc88 | ||
|
|
06249087bd | ||
|
|
5e3c08728c | ||
|
|
f54556ac0f | ||
|
|
1a0102783f | ||
|
|
1e5056bcc0 | ||
|
|
96e8152f11 | ||
|
|
7683ff7d03 | ||
|
|
309ed81674 | ||
|
|
badfdeb5db | ||
|
|
ea793ccff5 | ||
|
|
3c037725e9 | ||
|
|
b28024573a | ||
|
|
320c575b54 | ||
|
|
1e806d2a28 | ||
|
|
18d72ffde3 | ||
|
|
53c19368d5 | ||
|
|
fa6f4b86e3 | ||
|
|
0f199294ae | ||
|
|
ff6056a6b6 | ||
|
|
92c1e38b42 | ||
|
|
8bbb3ddca7 | ||
|
|
8fef858ce8 | ||
|
|
39428d2028 | ||
|
|
e5895a2768 | ||
|
|
250f0df7f7 | ||
|
|
85c15fca29 | ||
|
|
3422e2338c | ||
|
|
e92ac2c6d3 | ||
|
|
35fbddd030 | ||
|
|
c65b0f7044 | ||
|
|
84fca60378 | ||
|
|
7c5508ddbd | ||
|
|
d33e4ac474 | ||
|
|
0a4d372056 | ||
|
|
f98fe503a0 | ||
|
|
4410480e32 | ||
|
|
97b50be407 | ||
|
|
f3d3393af3 | ||
|
|
32f55c5462 | ||
|
|
42c556cc1f | ||
|
|
edcf39e999 | ||
|
|
ac940fe687 | ||
|
|
a618660635 | ||
|
|
965a2fa352 | ||
|
|
d8238383ca | ||
|
|
f33edd402e | ||
|
|
a4f3d3c503 | ||
|
|
d1994a651b | ||
|
|
ba79fb2a37 | ||
|
|
743bbb551f | ||
|
|
df7b70c37e | ||
|
|
58170d17d2 | ||
|
|
b758fc47aa | ||
|
|
d608d58ad1 | ||
|
|
cb1d7f7e96 | ||
|
|
0ae1957f80 | ||
|
|
3671970cc5 | ||
|
|
463090c3a4 | ||
|
|
e1666e49b0 | ||
|
|
3d2f1d3690 | ||
|
|
06a8899eec | ||
|
|
3565805b63 | ||
|
|
207bd9dcf7 | ||
|
|
e2482166f7 | ||
|
|
af88eafe02 | ||
|
|
8f9fb0ad77 | ||
|
|
8a6604f224 | ||
|
|
6c021a0800 | ||
|
|
2eeeba3225 | ||
|
|
c79d077c3f | ||
|
|
6a1228a5cd | ||
|
|
b2d4b9d42d | ||
|
|
60b6d9c00d | ||
|
|
00a6b2f4c6 | ||
|
|
0a797a2688 | ||
|
|
2e3eb2f103 | ||
|
|
5ce6138a58 | ||
|
|
82d0bd9091 | ||
|
|
e1466b3e09 | ||
|
|
51243ce443 | ||
|
|
c6790d4142 | ||
|
|
9a91288da9 | ||
|
|
79d76cf153 | ||
|
|
2a026953ff | ||
|
|
fb9cd1ed17 | ||
|
|
3efa053ae7 | ||
|
|
f5b641009b | ||
|
|
f3f3069f54 | ||
|
|
ef3aa6fa57 | ||
|
|
380aa1515e | ||
|
|
2af94af5c6 | ||
|
|
af55840493 | ||
|
|
3afc39c1ea | ||
|
|
abde37e1fc | ||
|
|
a8ee954405 | ||
|
|
dc3874ad9d | ||
|
|
c74da38c3d | ||
|
|
f13d0d6c3e | ||
|
|
0c1ac8e7dd | ||
|
|
580b5f5d7f | ||
|
|
1568cd2dbc | ||
|
|
05aa585c9a | ||
|
|
80c6a9c771 |
256
mach/pdp/cg/mach.c
Normal file
256
mach/pdp/cg/mach.c
Normal file
@@ -0,0 +1,256 @@
|
||||
#ifndef NORCSID
|
||||
static char rcsid[] = "$Header$";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
*
|
||||
* This product is part of the Amsterdam Compiler Kit.
|
||||
*
|
||||
* Permission to use, sell, duplicate or disclose this software must be
|
||||
* obtained in writing. Requests for such permissions may be sent to
|
||||
*
|
||||
* Dr. Andrew S. Tanenbaum
|
||||
* Wiskundig Seminarium
|
||||
* Vrije Universiteit
|
||||
* Postbox 7161
|
||||
* 1007 MC Amsterdam
|
||||
* The Netherlands
|
||||
*
|
||||
* Author: Hans van Staveren
|
||||
*/
|
||||
|
||||
/*
|
||||
* machine dependent back end routines for the PDP-11
|
||||
*/
|
||||
|
||||
static char procnam[40] ;
|
||||
|
||||
/* #define REGPATCH /* save all registers in markblock */
|
||||
|
||||
con_part(sz,w) register sz; word w; {
|
||||
|
||||
while (part_size % sz)
|
||||
part_size++;
|
||||
if (part_size == TEM_WSIZE)
|
||||
part_flush();
|
||||
if (sz == 1) {
|
||||
w &= 0xFF;
|
||||
if (part_size)
|
||||
w <<= 8;
|
||||
part_word |= w;
|
||||
} else {
|
||||
assert(sz == 2);
|
||||
part_word = w;
|
||||
}
|
||||
part_size += sz;
|
||||
}
|
||||
|
||||
con_mult(sz) word sz; {
|
||||
long l;
|
||||
|
||||
if (sz != 4)
|
||||
fatal("bad icon/ucon size");
|
||||
#ifdef ACK_ASS
|
||||
fprintf(codefile,".long %s\n",str);
|
||||
#else
|
||||
l = atol(str);
|
||||
fprintf(codefile,"\t%o;%o\n",(int)(l>>16),(int)l);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* The next function is difficult to do when not running on a PDP 11 or VAX
|
||||
* The strategy followed is to assume the code generator is running on a PDP 11
|
||||
* unless the ACK_ASS define is on.
|
||||
* In the last case floating point constants are simply not handled
|
||||
*/
|
||||
|
||||
con_float() {
|
||||
#ifdef ACK_ASS
|
||||
static int been_here;
|
||||
|
||||
if (argval != 4 && argval != 8)
|
||||
fatal("bad fcon size");
|
||||
fprintf(codefile,".long\t");
|
||||
if (argval == 8)
|
||||
fprintf(codefile,"F_DUM,");
|
||||
fprintf(codefile,"F_DUM\n");
|
||||
if ( !been_here++)
|
||||
fprintf(stderr,"Warning : dummy float-constant(s)\n");
|
||||
#else
|
||||
double f;
|
||||
register short *p,i;
|
||||
|
||||
if (argval != 4 && argval != 8)
|
||||
fatal("bad fcon size");
|
||||
f = atof(str);
|
||||
p = (short *) &f;
|
||||
i = *p++;
|
||||
if (argval == 8) {
|
||||
fprintf(codefile,"\t%o;%o;",i,*p++);
|
||||
i = *p++;
|
||||
}
|
||||
fprintf(codefile,"\t%o;%o\n",i,*p++);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef REGVARS
|
||||
|
||||
char Rstring[10];
|
||||
full lbytes;
|
||||
struct regadm {
|
||||
char *ra_str;
|
||||
long ra_off;
|
||||
} regadm[2];
|
||||
int n_regvars;
|
||||
|
||||
regscore(off,size,typ,score,totyp) long off; {
|
||||
|
||||
if (size != 2)
|
||||
return(-1);
|
||||
score -= 1; /* allow for save/restore */
|
||||
if (off>=0)
|
||||
score -= 2;
|
||||
if (typ==reg_pointer)
|
||||
score *= 17;
|
||||
else if (typ==reg_loop)
|
||||
score = 10*score+50; /* Guestimate */
|
||||
else
|
||||
score *= 10;
|
||||
return(score); /* estimated # of words of profit */
|
||||
}
|
||||
|
||||
i_regsave() {
|
||||
|
||||
Rstring[0] = 0;
|
||||
n_regvars=0;
|
||||
}
|
||||
|
||||
f_regsave() {
|
||||
register i;
|
||||
|
||||
if (n_regvars==0 || lbytes==0) {
|
||||
#ifdef REGPATCH
|
||||
fprintf(codefile,"mov r2,-(sp)\nmov r4,-(sp)\n");
|
||||
#endif
|
||||
fprintf(codefile,"mov r5,-(sp)\nmov sp,r5\n");
|
||||
if (lbytes == 2)
|
||||
fprintf(codefile,"tst -(sp)\n");
|
||||
else if (lbytes!=0)
|
||||
fprintf(codefile,"sub $0%o,sp\n",lbytes);
|
||||
for (i=0;i<n_regvars;i++)
|
||||
fprintf(codefile,"mov %s,-(sp)\n",regadm[i].ra_str);
|
||||
} else {
|
||||
if (lbytes>6) {
|
||||
fprintf(codefile,"mov $0%o,r0\n",lbytes);
|
||||
fprintf(codefile,"jsr r5,PR%s\n",Rstring);
|
||||
} else {
|
||||
fprintf(codefile,"jsr r5,PR%d%s\n",lbytes,Rstring);
|
||||
}
|
||||
}
|
||||
for (i=0;i<n_regvars;i++) {
|
||||
if (regadm[i].ra_off>=0)
|
||||
fprintf(codefile,"mov 0%lo(r5),%s\n",regadm[i].ra_off,
|
||||
regadm[i].ra_str);
|
||||
/* generate equates for access to registers */
|
||||
fprintf(codefile,"~%s%s=%ld.\n",regadm[i].ra_str+1, procnam,
|
||||
regadm[i].ra_off) ;
|
||||
}
|
||||
}
|
||||
|
||||
regsave(regstr,off,size) char *regstr; long off; {
|
||||
|
||||
fprintf(codefile,"%c Local %ld into %s\n",COMMENTCHAR,off,regstr);
|
||||
/* commented away
|
||||
#ifndef REGPATCH
|
||||
fprintf(codefile,"mov %s,-(sp)\n",regstr);
|
||||
#endif
|
||||
strcat(Rstring,regstr);
|
||||
if (off>=0)
|
||||
fprintf(codefile,"mov 0%lo(r5),%s\n",off,regstr);
|
||||
end of commented away */
|
||||
|
||||
strcat(Rstring,regstr);
|
||||
regadm[n_regvars].ra_str = regstr;
|
||||
regadm[n_regvars].ra_off = off;
|
||||
n_regvars++;
|
||||
}
|
||||
|
||||
regreturn() {
|
||||
|
||||
#ifdef REGPATCH
|
||||
fprintf(codefile,"jmp eret\n");
|
||||
#else
|
||||
fprintf(codefile,"jmp RT%s\n",Rstring);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
doplb(name) char *name ; {
|
||||
register char *p, *q ;
|
||||
p=procnam, q=name ;
|
||||
while ( *p++ = *q++ ) ;
|
||||
fprintf(codefile,"%s:\n",name) ;
|
||||
}
|
||||
|
||||
prolog(nlocals) full nlocals; {
|
||||
|
||||
#ifndef REGVARS
|
||||
#ifdef REGPATCH
|
||||
fprintf(codefile,"mov r2,-(sp)\nmov r4,-(sp)\n");
|
||||
#endif
|
||||
fprintf(codefile,"mov r5,-(sp)\nmov sp,r5\n");
|
||||
if (nlocals == 0)
|
||||
return;
|
||||
if (nlocals == 2)
|
||||
fprintf(codefile,"tst -(sp)\n");
|
||||
else
|
||||
fprintf(codefile,"sub $0%o,sp\n",nlocals);
|
||||
#else
|
||||
lbytes = nlocals;
|
||||
#endif
|
||||
}
|
||||
|
||||
dlbdlb(as,ls) string as,ls; {
|
||||
|
||||
if (strlen(as)+strlen(ls)+2<sizeof(labstr)) {
|
||||
strcat(ls,":");
|
||||
strcat(ls,as);
|
||||
} else
|
||||
fatal("too many consecutive labels");
|
||||
}
|
||||
|
||||
mes(type) word type; {
|
||||
int argt ;
|
||||
|
||||
switch ( (int)type ) {
|
||||
case ms_ext :
|
||||
for (;;) {
|
||||
switch ( argt=getarg(
|
||||
ptyp(sp_cend)|ptyp(sp_pnam)|sym_ptyp) ) {
|
||||
case sp_cend :
|
||||
return ;
|
||||
default:
|
||||
strarg(argt) ;
|
||||
#ifdef ACK_ASS
|
||||
fprintf(codefile,".define %s\n",argstr) ;
|
||||
#else
|
||||
fprintf(codefile,".globl %s\n",argstr) ;
|
||||
#endif
|
||||
break ;
|
||||
}
|
||||
}
|
||||
default :
|
||||
while ( getarg(any_ptyp) != sp_cend ) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
char *segname[] = {
|
||||
".text", /* SEGTXT */
|
||||
".data", /* SEGCON */
|
||||
".data", /* SEGROM */
|
||||
".bss" /* SEGBSS */
|
||||
};
|
||||
46
mach/pdp/cg/mach.h
Normal file
46
mach/pdp/cg/mach.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/* $Header$ */
|
||||
|
||||
/* The next define switches between codegeneration for an ACK assembler
|
||||
* or for the standard UNIX V7 assembler.
|
||||
* If on code is generated for the ACK assembler.
|
||||
*/
|
||||
/* #define ACK_ASS /* code for ACK assembler */
|
||||
|
||||
#ifdef ACK_ASS
|
||||
#define COMMENTCHAR '!'
|
||||
#define ex_ap(y) fprintf(codefile,".extern %s\n",y)
|
||||
#else
|
||||
#define COMMENTCHAR '/'
|
||||
#define ex_ap(y) fprintf(codefile,".globl %s\n",y)
|
||||
#endif
|
||||
#define in_ap(y) /* nothing */
|
||||
|
||||
#define newplb(x) doplb(x)
|
||||
#define newilb(x) fprintf(codefile,"%s:\n",x)
|
||||
#define newdlb(x) fprintf(codefile,"%s:\n",x)
|
||||
#ifdef ACK_ASS
|
||||
#define newlbss(l,x) fprintf(codefile,"%s:.space 0%o\n",l,x);
|
||||
#else
|
||||
#define newlbss(l,x) fprintf(codefile,"%s:.=.+0%o\n",l,x);
|
||||
#endif
|
||||
|
||||
#define cst_fmt "$0%o"
|
||||
#define off_fmt "0%o"
|
||||
#define ilb_fmt "I%03x%x"
|
||||
#define dlb_fmt "_%d"
|
||||
#define hol_fmt "hol%d"
|
||||
|
||||
#define hol_off "0%o+hol%d"
|
||||
|
||||
#ifdef ACK_ASS
|
||||
#define con_cst(x) fprintf(codefile,".short 0%o\n",x)
|
||||
#define con_ilb(x) fprintf(codefile,".short %s\n",x)
|
||||
#define con_dlb(x) fprintf(codefile,".short %s\n",x)
|
||||
#else
|
||||
#define con_cst(x) fprintf(codefile,"0%o\n",x)
|
||||
#define con_ilb(x) fprintf(codefile,"%s\n",x)
|
||||
#define con_dlb(x) fprintf(codefile,"%s\n",x)
|
||||
#endif
|
||||
|
||||
#define id_first '_'
|
||||
#define BSS_INIT 0
|
||||
2852
mach/pdp/cg/table
Normal file
2852
mach/pdp/cg/table
Normal file
File diff suppressed because it is too large
Load Diff
303
util/ack/rmach.c
303
util/ack/rmach.c
@@ -1,303 +0,0 @@
|
||||
/*
|
||||
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
*
|
||||
* This product is part of the Amsterdam Compiler Kit.
|
||||
*
|
||||
* Permission to use, sell, duplicate or disclose this software must be
|
||||
* obtained in writing. Requests for such permissions may be sent to
|
||||
*
|
||||
* Dr. Andrew S. Tanenbaum
|
||||
* Wiskundig Seminarium
|
||||
* Vrije Universiteit
|
||||
* Postbox 7161
|
||||
* 1007 MC Amsterdam
|
||||
* The Netherlands
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ack.h"
|
||||
#include "../../h/em_path.h"
|
||||
#include "list.h"
|
||||
#include "trans.h"
|
||||
#include "grows.h"
|
||||
#include "dmach.h"
|
||||
#include "data.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/************************************************************************/
|
||||
/* */
|
||||
/* Read machine definitions and transformations */
|
||||
/* */
|
||||
/************************************************************************/
|
||||
|
||||
#define COMMENT '#'
|
||||
|
||||
#define VAR "var"
|
||||
#define PASS "name"
|
||||
#define IN "from"
|
||||
#define OUT "to"
|
||||
#define PROG "program"
|
||||
#define MAPF "mapflag"
|
||||
#define ARGS "args"
|
||||
#define PROP "prop"
|
||||
#define RUNT "rts"
|
||||
#define NEEDT "need"
|
||||
#define END "end"
|
||||
|
||||
extern growstring scanb();
|
||||
extern growstring scanvars();
|
||||
|
||||
int getline() ;
|
||||
int getinchar() ;
|
||||
static char *ty_name ;
|
||||
static char *bol ;
|
||||
|
||||
|
||||
static char *inname ;
|
||||
|
||||
setlist(name) char *name ; {
|
||||
/* Name is sought in the internal tables,
|
||||
if not present, the a file of that name is sought
|
||||
in first the current and then the EM Lib directory
|
||||
*/
|
||||
|
||||
inname=name ;
|
||||
open_in(name) ;
|
||||
while ( getline() ) {
|
||||
if ( strcmp(VAR,ty_name)==0 ) {
|
||||
doassign(bol,(char *)0,0) ;
|
||||
} else
|
||||
if ( strcmp(PASS,ty_name)==0 ) {
|
||||
intrf() ;
|
||||
} else
|
||||
error("unknown keyword %s",ty_name) ;
|
||||
}
|
||||
close_in();
|
||||
#ifdef DEBUG
|
||||
if ( debug>=3 ) vprint("End %s\n",name) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
intrf() {
|
||||
register trf *new ;
|
||||
register char *ptr ;
|
||||
growstring bline, vline ;
|
||||
int twice ;
|
||||
|
||||
new= (trf *)getcore(sizeof *new) ;
|
||||
new->t_name= keeps(bol) ;
|
||||
for (;;) {
|
||||
if ( !getline() ) {
|
||||
fuerror("unexpected EOF on %s",inname) ;
|
||||
}
|
||||
twice= NO ;
|
||||
if ( strcmp(ty_name,IN)==0 ) {
|
||||
if ( new->t_in ) twice=YES ;
|
||||
new->t_in= keeps(bol);
|
||||
} else
|
||||
if ( strcmp(ty_name,OUT)==0 ) {
|
||||
if ( new->t_out ) twice=YES ;
|
||||
new->t_out= keeps(bol);
|
||||
} else
|
||||
if ( strcmp(ty_name,PROG)==0 ) {
|
||||
if ( new->t_prog ) twice=YES ;
|
||||
bline= scanb(bol); /* Scan for \ */
|
||||
vline= scanvars(gr_start(bline)); /* Scan for {} */
|
||||
gr_throw(&bline);
|
||||
new->t_prog= gr_final(&vline);
|
||||
clr_noscan(new->t_prog);
|
||||
} else
|
||||
if ( strcmp(ty_name,MAPF)==0 ) {
|
||||
/* First read the mapflags line
|
||||
and scan for backslashes */
|
||||
bline= scanb(bol) ;
|
||||
l_add(&new->t_mapf,gr_final(&bline)) ;
|
||||
} else
|
||||
if ( strcmp(ty_name,ARGS)==0 ) {
|
||||
if ( new->t_argd ) twice=YES ;
|
||||
bline= scanb(bol) ;
|
||||
new->t_argd= keeps(gr_start(bline)) ;
|
||||
gr_throw(&bline) ;
|
||||
} else
|
||||
if ( strcmp(ty_name,PROP)==0 ) {
|
||||
for ( ptr=bol ; *ptr ; ptr++ ) {
|
||||
switch( *ptr ) {
|
||||
case C_IN: new->t_stdin= YES ; break ;
|
||||
case C_OUT: new->t_stdout= YES ; break ;
|
||||
case 'P': new->t_isprep= YES ; break ;
|
||||
case 'p': new->t_prep= YES ; break ;
|
||||
case 'm': new->t_prep= MAYBE ; break ;
|
||||
case 'O': new->t_optim= YES ; break ;
|
||||
case 'C': new->t_combine= YES ; break ;
|
||||
default :
|
||||
error("Unkown option %c in %s for %s",
|
||||
*ptr,new->t_name,inname) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
} else
|
||||
if ( strcmp(ty_name,RUNT)==0 ) {
|
||||
if ( new->t_rts ) twice=YES ;
|
||||
new->t_rts= keeps(bol) ;
|
||||
} else
|
||||
if ( strcmp(ty_name,NEEDT)==0 ) {
|
||||
if ( new->t_needed ) twice=YES ;
|
||||
new->t_needed= keeps(bol) ;
|
||||
} else
|
||||
if ( strcmp(ty_name,END)==0 ) {
|
||||
break ;
|
||||
} else {
|
||||
fuerror("illegal keyword %s %s",ty_name,bol);
|
||||
}
|
||||
if ( twice ) {
|
||||
werror("%s: specified twice for %s",
|
||||
ty_name, new->t_name) ;
|
||||
}
|
||||
}
|
||||
if ( ! ( new->t_name && new->t_out && new->t_prog ) ) {
|
||||
fuerror("insufficient specification for %s in %s",
|
||||
new->t_name,inname) ;
|
||||
}
|
||||
if ( ! new->t_argd ) new->t_argd="" ;
|
||||
#ifdef DEBUG
|
||||
if ( debug>=3 ) {
|
||||
register list_elem *elem ;
|
||||
vprint("%s: from %s to %s '%s'\n",
|
||||
new->t_name,new->t_in,new->t_out,new->t_prog) ;
|
||||
vprint("\targs: ") ; prns(new->t_argd) ;
|
||||
scanlist( l_first(new->t_mapf), elem ) {
|
||||
vprint("\t%s\n",l_content(*elem)) ;
|
||||
}
|
||||
if ( new->t_rts ) vprint("\trts: %s\n",new->t_rts) ;
|
||||
if ( new->t_needed ) vprint("\tneeded: %s\n",new->t_needed) ;
|
||||
}
|
||||
#endif
|
||||
l_add(&tr_list,(char *)new) ;
|
||||
}
|
||||
|
||||
/************************** IO from core or file *******************/
|
||||
|
||||
static int incore ;
|
||||
static growstring rline ;
|
||||
static FILE *infile ;
|
||||
static char *inptr ;
|
||||
|
||||
open_in(name) register char *name ; {
|
||||
register dmach *cmac ;
|
||||
|
||||
gr_init(&rline) ;
|
||||
for ( cmac= massoc ; cmac->ma_index!= -1 ; cmac++ ) {
|
||||
if ( strcmp(name,cmac->ma_name)==0 ) {
|
||||
incore=YES ;
|
||||
inptr= &intable[cmac->ma_index] ;
|
||||
return ;
|
||||
}
|
||||
}
|
||||
/* Not in core */
|
||||
incore= NO ;
|
||||
#ifdef NEW
|
||||
gr_cat(&rline,EM_DIR) ;
|
||||
gr_cat(&rline,"/lib/n_ack/") ;
|
||||
#else
|
||||
gr_cat(&rline,ACK_DIR); gr_cat(&rline,"/") ;
|
||||
#endif
|
||||
gr_cat(&rline,name) ;
|
||||
infile= fopen(gr_start(rline),"r") ;
|
||||
#ifdef NEW
|
||||
if ( !infile ) {
|
||||
/* Try to read EM_DIR/lib/MACH/plan */
|
||||
gr_throw(&rline) ;
|
||||
gr_cat(&rline,EM_DIR) ;
|
||||
gr_cat(&rline,"/lib/") ; gr_cat(&rline,name) ;
|
||||
gr_cat(&rline,"/plan") ;
|
||||
infile= fopen(gr_start(rline),"r") ;
|
||||
}
|
||||
#endif
|
||||
if ( !infile ) {
|
||||
infile= fopen(name,"r") ;
|
||||
}
|
||||
if ( infile==NULL ) {
|
||||
fuerror("Cannot find description for %s",name) ;
|
||||
}
|
||||
}
|
||||
|
||||
close_in() {
|
||||
if ( !incore ) fclose(infile) ;
|
||||
gr_throw(&rline) ;
|
||||
}
|
||||
|
||||
char *readline() {
|
||||
/* Get a line from the input,
|
||||
return 0 if at end,
|
||||
The line is stored in a volatile buffer,
|
||||
a pointer to the line is returned.
|
||||
*/
|
||||
register int nchar ;
|
||||
enum { BOL, ESCAPE, SKIPPING, MOL } state = BOL ;
|
||||
|
||||
gr_throw(&rline) ;
|
||||
for (;;) {
|
||||
nchar= getinchar() ;
|
||||
if ( nchar==EOF ) {
|
||||
if ( state!=BOL ) {
|
||||
werror("incomplete line in %s", inname) ;
|
||||
}
|
||||
return 0 ;
|
||||
}
|
||||
if ( state==SKIPPING ) {
|
||||
if ( nchar=='\n' ) {
|
||||
state= MOL ;
|
||||
} else {
|
||||
continue ;
|
||||
}
|
||||
}
|
||||
if ( state==ESCAPE ) {
|
||||
switch( nchar ) {
|
||||
case '\n' :
|
||||
break ;
|
||||
default :
|
||||
gr_add(&rline,BSLASH) ;
|
||||
case COMMENT :
|
||||
case BSLASH :
|
||||
gr_add(&rline,nchar) ;
|
||||
break ;
|
||||
}
|
||||
state= MOL ;
|
||||
continue ;
|
||||
}
|
||||
switch ( nchar ) {
|
||||
case '\n' : gr_add(&rline,0) ;
|
||||
return gr_start(rline) ;
|
||||
case COMMENT : state= SKIPPING ;
|
||||
break ;
|
||||
case BSLASH : state= ESCAPE ;
|
||||
break ;
|
||||
default : gr_add(&rline,nchar) ;
|
||||
state= MOL ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int getinchar() {
|
||||
if ( incore ) {
|
||||
if ( *inptr==0 ) return EOF ;
|
||||
return *inptr++ ;
|
||||
}
|
||||
return getc(infile) ;
|
||||
}
|
||||
|
||||
int getline() {
|
||||
register char *c_ptr ;
|
||||
|
||||
do {
|
||||
if ( (c_ptr=readline())==(char *)0 ) return 0 ;
|
||||
ty_name= skipblank(c_ptr) ;
|
||||
} while ( *ty_name==0 ) ;
|
||||
c_ptr= firstblank(ty_name) ;
|
||||
if ( *c_ptr ) {
|
||||
*c_ptr++ =0 ;
|
||||
c_ptr= skipblank(c_ptr) ;
|
||||
}
|
||||
bol= c_ptr ;
|
||||
return 1 ;
|
||||
}
|
||||
Reference in New Issue
Block a user