Renamed the language libraries and runtimes to have more

conventional names.
This commit is contained in:
dtrg
2007-02-26 22:36:56 +00:00
685 changed files with 45807 additions and 137 deletions

24
util/LLgen/src/assert.h Normal file
View File

@@ -0,0 +1,24 @@
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*
*/
/*
* L L G E N
*
* An Extended LL(1) Parser Generator
*
* Author : Ceriel J.H. Jacobs
*/
/*
* assert.h $Header$
* an assertion macro
*/
#ifndef NDEBUG
#define assert(x) if(!(x)) badassertion("x",__FILE__,__LINE__)
#else
#define assert(x) /* nothing */
#endif

31
util/LLgen/src/tunable.h Normal file
View File

@@ -0,0 +1,31 @@
/*
* (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
*
*/
/*
* L L G E N
*
* An Extended LL(1) Parser Generator
*
* Author : Ceriel J.H. Jacobs
*/
/*
* tunable.h $Header$
* Tunable constants
*/
# define LTEXTSZ 51 /* size of token */

75
util/ack/Makefile Normal file
View File

@@ -0,0 +1,75 @@
# $Header$
EMHOME=../..
HFILES=ack.h list.h trans.h data.h dmach.h grows.h
DSRC=list.c data.c main.c scan.c svars.c trans.c util.c rmach.c run.c grows.c\
files.c
ISRC=dmach.c intable.c
OBJ=list.o data.o main.o scan.o svars.o trans.o util.o rmach.o run.o \
dmach.o intable.o grows.o files.o
ACKDIR=$(EMHOME)/lib
FE=fe
INTABLES=pdp
LNTABLES=acc apc abc ocm m2 vax4 i86 i386 m68k2 m68k4 pmds pmds4 mantra \
m68020 z8000 em22 em24 em44 6500 6800 6805 6809 i80 ns s2650 z80 \
sun3 sun2 xenix3 minix minixST
INCLUDES=-I$(EMHOME)/h
CFLAGS=-O $(INCLUDES)
LDFLAGS=
BINDIR=$(EMHOME)/bin
MANDIR=$(EMHOME)/man
MODDIR=$(EMHOME)/modules/lib
head: ack ack.1
install: ack ack.1
rm -f $(BINDIR)/ack
cp ack $(BINDIR)/ack
-cd $(BINDIR) ; \
for i in $(INTABLES) $(LNTABLES) ; do rm -f $$i ; ln ack $$i ; done
rm -f $(MANDIR)/ack.1
cp ack.1 $(MANDIR)/ack.1
cmp: ack ack.1
-cmp ack $(BINDIR)/ack
-cmp ack.1 $(MANDIR)/ack.1
ack.1: ack.1.X
-sh -c 'tbl < ack.1.X > ack.1'
-sh -c 'if test -s ack.1 ; then : ; else cp ack.1.X ack.1 ; fi'
clean:
-rm -f *.old *.o ack ack.1
ack: $(OBJ)
$(CC) $(LDFLAGS) -o ack $(OBJ) $(MODDIR)/libstring.a
grows.o files.o list.o run.o \
data.o main.o scan.o trans.o rmach.o util.o : ack.h list.h
files.o data.o main.o scan.o run.o trans.o rmach.o: trans.h data.h
files.o rmach.o trans.o grows.c : grows.h
rmach.c: dmach.h
files.o main.o rmach.o : $(EMHOME)/h/em_path.h
main.o : $(EMHOME)/h/local.h
svars.o: ack.h
dmach.c intable.c: mktables dmach.h
: mktables $(ACKDIR) # $(FE) $(INTABLES)
mktables $(ACKDIR)
mktables: mktables.c
$(CC) -o mktables mktables.c
pr:
@pr Makefile $(HFILES) $(DSRC)
opr:
make pr | opr
lint: $(ISRC)
lint -hbx $(INCLUDES) $(DSRC) $(ISRC)

212
util/ack/malloc.c Normal file
View File

@@ -0,0 +1,212 @@
/*
* (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"
#ifdef DEBUG
#define ASSERT(p) if(!(p))botch("p");else
botch(s)
char *s;
{
printf("malloc/free botched: %s\n",s);
abort();
}
#else
#define ASSERT(p)
#endif
#ifndef NORCSID
static char rcs_id[] = "$Header$" ;
#endif
/* avoid break bug */
#ifdef pdp11
#define GRANULE 64
#else
#define GRANULE 0
#endif
/* C storage allocator
* circular first-fit strategy
* works with noncontiguous, but monotonically linked, arena
* each block is preceded by a ptr to the (pointer of)
* the next following block
* blocks are exact number of words long
* aligned to the data type requirements of ALIGN
* pointers to blocks must have BUSY bit 0
* bit in ptr is 1 for busy, 0 for idle
* gaps in arena are merely noted as busy blocks
* last block of arena (pointed to by alloct) is empty and
* has a pointer to first
* idle blocks are coalesced during space search
*
* a different implementation may need to redefine
* ALIGN, NALIGN, BLOCK, BUSY, INT
* where INT is integer type to which a pointer can be cast
*/
#define INT int
#define ALIGN int
#define NALIGN 1
#define WORD sizeof(union store)
#define BLOCK 1024 /* a multiple of WORD*/
#define BUSY 1
#define NULL 0
#define testbusy(p) ((INT)(p)&BUSY)
#define setbusy(p) (union store *)((INT)(p)|BUSY)
#define clearbusy(p) (union store *)((INT)(p)&~BUSY)
union store { union store *ptr;
ALIGN dummy[NALIGN];
int calloc; /*calloc clears an array of integers*/
};
static union store allocs[2]; /*initial arena*/
static union store *allocp; /*search ptr*/
static union store *alloct; /*arena top*/
static union store *allocx; /*for benefit of realloc*/
char *sbrk();
char *
malloc(nbytes)
unsigned nbytes;
{
register union store *p, *q;
register nw;
static temp; /*coroutines assume no auto*/
if(allocs[0].ptr==0) { /*first time*/
allocs[0].ptr = setbusy(&allocs[1]);
allocs[1].ptr = setbusy(&allocs[0]);
alloct = &allocs[1];
allocp = &allocs[0];
}
nw = (nbytes+WORD+WORD-1)/WORD;
ASSERT(allocp>=allocs && allocp<=alloct);
ASSERT(allock());
for(p=allocp; ; ) {
for(temp=0; ; ) {
if(!testbusy(p->ptr)) {
while(!testbusy((q=p->ptr)->ptr)) {
ASSERT(q>p&&q<alloct);
p->ptr = q->ptr;
}
if(q>=p+nw && p+nw>=p)
goto found;
}
q = p;
p = clearbusy(p->ptr);
if(p>q)
ASSERT(p<=alloct);
else if(q!=alloct || p!=allocs) {
ASSERT(q==alloct&&p==allocs);
return(NULL);
} else if(++temp>1)
break;
}
temp = ((nw+BLOCK/WORD)/(BLOCK/WORD))*(BLOCK/WORD);
q = (union store *)sbrk(0);
if(q+temp+GRANULE < q) {
return(NULL);
}
q = (union store *)sbrk(temp*WORD);
if((INT)q == -1) {
return(NULL);
}
ASSERT(q>alloct);
alloct->ptr = q;
if(q!=alloct+1)
alloct->ptr = setbusy(alloct->ptr);
alloct = q->ptr = q+temp-1;
alloct->ptr = setbusy(allocs);
}
found:
allocp = p + nw;
ASSERT(allocp<=alloct);
if(q>allocp) {
allocx = allocp->ptr;
allocp->ptr = p->ptr;
}
p->ptr = setbusy(allocp);
return((char *)(p+1));
}
/* freeing strategy tuned for LIFO allocation
*/
free(ap)
register char *ap;
{
register union store *p = (union store *)ap;
ASSERT(p>clearbusy(allocs[1].ptr)&&p<=alloct);
ASSERT(allock());
allocp = --p;
ASSERT(testbusy(p->ptr));
p->ptr = clearbusy(p->ptr);
ASSERT(p->ptr > allocp && p->ptr <= alloct);
}
/* realloc(p, nbytes) reallocates a block obtained from malloc()
* and freed since last call of malloc()
* to have new size nbytes, and old content
* returns new location, or 0 on failure
*/
char *
realloc(p, nbytes)
register union store *p;
unsigned nbytes;
{
register union store *q;
union store *s, *t;
register unsigned nw;
unsigned onw;
if(testbusy(p[-1].ptr))
free((char *)p);
onw = p[-1].ptr - p;
q = (union store *)malloc(nbytes);
if(q==NULL || q==p)
return((char *)q);
s = p;
t = q;
nw = (nbytes+WORD-1)/WORD;
if(nw<onw)
onw = nw;
while(onw--!=0)
*t++ = *s++;
if(q<p && q+nw>=p)
(q+(q+nw-p))->ptr = allocx;
return((char *)q);
}
#ifdef DEBUG
allock()
{
#ifdef DEBUG
register union store *p;
int x;
x = 0;
for(p= &allocs[0]; clearbusy(p->ptr) > p; p=clearbusy(p->ptr)) {
if(p==allocp)
x++;
}
ASSERT(p==alloct);
return(x==1|p==allocp);
#else
return(1);
#endif
}
#endif

39
util/amisc/Makefile Normal file
View File

@@ -0,0 +1,39 @@
EM = ../..
BINDIR = $(EM)/bin
MANDIR = $(EM)/man
LIBDIR = $(EM)/modules/lib
h = $(EM)/h
LDFLAGS =
CFLAGS = $(LDFLAGS) -O -I$h
ALL = anm asize astrip
OFILES = anm.o asize.o astrip.o
CFILES = anm.c asize.c astrip.c
LIBS = $(LIBDIR)/libobject.a
all: $(ALL)
anm: anm.c
$(CC) $(CFLAGS) -o anm anm.c $(LIBS)
asize: asize.c
$(CC) $(CFLAGS) -o asize asize.c $(LIBS)
astrip: astrip.c
$(CC) $(CFLAGS) -o astrip astrip.c $(LIBS)
#not installed:
ashow: ashow.c
$(CC) $(CFLAGS) -o ashow ashow.c $(LIBS)
install: all
for i in $(ALL); do rm -f $(BINDIR)/$$i; cp $$i $(BINDIR)/$$i; done
for i in anm.1 asize.1 astrip.1; do rm -f $(MANDIR)/$$i; cp $$i $(MANDIR)/$$i; done
cmp: all
-for i in $(ALL); do cmp $$i $(BINDIR)/$$i; done
-for i in anm.1 astrip.1 asize.1 ; do cmp $$i $(MANDIR)/$$i; done
clean: ; rm -f $(ALL) $(OFILES)
pr:
@pr `pwd`/Makefile `pwd`/anm.c `pwd`/astrip.c `pwd`/asize.c
opr:
make pr | opr

50
util/arch/Makefile Normal file
View File

@@ -0,0 +1,50 @@
EMHOME = ../..
EMH = $(EMHOME)/h
EMBIN = $(EMHOME)/bin
LIB = $(EMHOME)/modules/lib
LIBS = $(LIB)/libobject.a $(LIB)/libprint.a \
$(LIB)/libstring.a $(LIB)/libsystem.a
CFLAGS=-O -I$(EMH) -DDISTRIBUTION
LDFLAGS =
all: arch aal
arch: arch.o
$(CC) $(LDFLAGS) -o arch arch.o $(LIBS)
aal: aal.o
$(CC) $(LDFLAGS) -o aal aal.o $(LIBS)
arch.o: $(EMH)/arch.h archiver.c
$(CC) $(CFLAGS) -c archiver.c
mv archiver.o arch.o
aal.o: $(EMH)/arch.h archiver.c $(EMH)/ranlib.h $(EMH)/out.h
$(CC) -DAAL $(CFLAGS) -c archiver.c
mv archiver.o aal.o
clean:
rm -f aal arch *.o *.old
install : all
rm -f $(EMBIN)/arch $(EMBIN)/aal
cp aal $(EMBIN)/aal
cp arch $(EMBIN)/arch
rm -f $(EMHOME)/man/arch.1 $(EMHOME)/man/aal.1 $(EMHOME)/man/arch.5
cp aal.1 $(EMHOME)/man/aal.1
cp arch.1 $(EMHOME)/man/arch.1
cp arch.5 $(EMHOME)/man/arch.5
cmp : all
-cmp aal $(EMBIN)/aal
-cmp arch $(EMBIN)/arch
-cmp aal.1 $(EMHOME)/man/aal.1
-cmp arch.1 $(EMHOME)/man/arch.1
-cmp arch.5 $(EMHOME)/man/arch.5
opr:
make pr ^ opr
pr:
@pr Makefile archiver.c

76
util/ass/Makefile Normal file
View File

@@ -0,0 +1,76 @@
# $Header$
d=../..
l=$d/lib
h=$d/h
m=$d/man
ASS_PATH=$l/em_ass
CFLAGS=-O -I$d/h
all: ass
clean:
-rm -f ass *.o maktab *.old asstb.c
install : all
rm -f $(ASS_PATH)
cp ass $(ASS_PATH)
rm -f $m/em_ass.6
cp em_ass.6 $m/em_ass.6
cmp : all
-cmp ass $(ASS_PATH)
-cmp em_ass.6 $m/em_ass.6
lint: ass00.c ass30.c ass40.c ass50.c ass60.c ass70.c \
ass80.c assci.c assda.c assrl.c asstb.c asscm.c
lint -hpvbx \
ass00.c ass30.c ass40.c ass50.c ass60.c ass70.c \
ass80.c assci.c assda.c assrl.c asstb.c asscm.c
ass: ass00.o ass30.o ass40.o ass50.o ass60.o ass70.o \
ass80.o assci.o assda.o assrl.o asstb.o asscm.o \
$l/em_data.a
$(CC) $(CFLAGS) -o ass \
ass00.o ass30.o ass40.o ass50.o ass60.o ass70.o \
ass80.o assci.o assda.o assrl.o asstb.o asscm.o \
$l/em_data.a
ass00.o ass40.o ass60.o ass70.o ass80.o assrl.o: \
$h/local.h $h/em_spec.h $h/as_spec.h \
$h/em_flag.h $h/arch.h ass00.h assex.h
assci.o: $h/local.h $h/em_spec.h $h/as_spec.h \
$h/em_flag.h $h/em_mes.h $h/em_pseu.h \
$h/em_ptyp.h $h/arch.h ass00.h assex.h
ass30.o ass50.o : \
$h/local.h $h/em_spec.h $h/as_spec.h \
$h/em_flag.h ip_spec.h ass00.h assex.h
ass80.o: $h/em_path.h
assda.o: $h/local.h $h/em_spec.h $h/as_spec.h \
$h/em_flag.h $h/arch.h ass00.h
asscm.o: ass00.h
asstb.o: asstb.c
asstb.c: maktab $d/etc/ip_spec.t
maktab $d/etc/ip_spec.t asstb.c
maktab: maktab.c $h/em_spec.h ip_spec.h $h/em_flag.h \
$l/em_data.a
$(CC) -O -o maktab maktab.c $l/em_data.a
asprint: asprint.p
apc -w -o asprint asprint.p
opr:
make pr ^ opr
pr:
@(pr ass00.h assex.h ip_spec.h ass?0.c ass[rcd]?.c \
maktab.c)

40
util/ass/ip_spec.h Normal file
View File

@@ -0,0 +1,40 @@
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* Contents of flags used when describing interpreter opcodes */
#define RCS_IP "$Header$"
#define OPTYPE 07 /* type field in flag */
#define OPMINI 0 /* m MINI */
#define OPSHORT 1 /* s SHORT */
#define OPNO 2 /* - No operand */
#define OP8 3 /* 1 1-byte signed operand */
#define OP16 4 /* 2 2-byte signed operand */
#define OP32 5 /* 4 4-byte signed operand */
#define OP64 6 /* 8 8-byte signed operand */
#define OP16U 7 /* u 2-byte unsigned operand */
#define OPESC 010 /* e escaped opcode */
#define OPWORD 020 /* w operand is word multiple */
#define OPNZ 040 /* o operand starts at 1 ( or wordsize if w-flag) */
#define OPRANGE 0300 /* Range of operands: Positive, negative, both */
#define OP_BOTH 0000 /* the default */
#define OP_POS 0100 /* p Positive (>=0) operands only */
#define OP_NEG 0200 /* n Negative (<0) operands only */
struct opform {
char i_opcode ; /* the opcode number */
char i_flag ; /* the flag byte */
char i_low ; /* the interpreter first opcode */
char i_num ; /* the number of shorts/minis (optional) */
};
/* Escape indicators */
#define ESC 254 /* To escape group */
#define ESC_L 255 /* To 32 and 64 bit operands */

82
util/byacc/Makefile Normal file
View File

@@ -0,0 +1,82 @@
EMHOME = ../..
DEST = $(EMHOME)/bin
MAN = $(EMHOME)/man
HDRS = defs.h
CFLAGS = -O -Dvoid=int
LDFLAGS =
LIBS =
LINKER = cc
OBJS = closure.o \
error.o \
lalr.o \
lr0.o \
main.o \
mkpar.o \
output.o \
reader.o \
skeleton.o \
symtab.o \
verbose.o \
warshall.o
PRINT = pr -f -l88
PROGRAM = yacc
SRCS = closure.c \
error.c \
lalr.c \
lr0.c \
main.c \
mkpar.c \
output.c \
reader.c \
skeleton.c \
symtab.c \
verbose.c \
warshall.c
all: $(PROGRAM)
$(PROGRAM): $(OBJS) $(LIBS)
@echo -n "Loading $(PROGRAM) ... "
@$(LINKER) $(LDFLAGS) -o $(PROGRAM) $(OBJS) $(LIBS)
@echo "done"
clean:; @rm -f $(OBJS) $(PROGRAM)
index:; @ctags -wx $(HDRS) $(SRCS)
install: $(PROGRAM)
@echo Installing $(PROGRAM) in $(DEST)
cp $(PROGRAM) $(DEST)/$(PROGRAM)
cp manpage $(MAN)/yacc.1
listing:; @$(PRINT) Makefile $(HDRS) $(SRCS) | lpr
lint:; @lint $(SRCS)
program: $(PROGRAM)
tags: $(HDRS) $(SRCS); @ctags $(HDRS) $(SRCS)
###
closure.o: defs.h
error.o: defs.h
lalr.o: defs.h
lr0.o: defs.h
main.o: defs.h
mkpar.o: defs.h
output.o: defs.h
reader.o: defs.h
skeleton.o: defs.h
symtab.o: defs.h
verbose.o: defs.h
warshall.o: defs.h

View File

@@ -0,0 +1,33 @@
EM=../../../..
CEGLIB = $(EM)/lib/ceg
PARLIB = $(CEGLIB)/EM_parser
LIB = $(PARLIB)/as_EM_pars
OFILES = dist.o error.o
HFILES = arg_type.h em_decl.h em_parser.h
IFILES = -I$(EM)/h -I$(EM)/modules/h
CC = cc
.c.o :
$(CC) $(IFILES) -c $<
all : $(OFILES)
install: all
-mkdir $(CEGLIB)
-mkdir $(PARLIB)
-mkdir $(LIB)
cp $(OFILES) $(HFILES) $(LIB)
cmp: all
for i in $(OFILES) $(HFILES) ; do cmp $$i $(LIB)/$$i ; done
clean:
rm -f *.o
pr:
@pr Makefile arg_type.h dist.c em_decl.h em_parser.h error.c
opr:
make pr | opr

View File

@@ -0,0 +1,44 @@
EM=../../../..
CEGLIB = $(EM)/lib/ceg
PARLIB = $(CEGLIB)/EM_parser
OBJLIB = $(PARLIB)/obj_EM_pars
ASLIB = $(PARLIB)/as_EM_pars
GFILES = pars.g
OFILES = pars.o Lpars.o scan.o mylex.o default.o C_instr2.o help.o eval.o\
action.o
IFILES = -I$(EM)/h -I$(EM)/modules/h
CC = cc
CFLAGS = $(IFILES)
all : dummy
make $(OFILES)
dummy : $(GFILES)
LLgen $(LLOPT) $(GFILES)
touch dummy
install: all
-mkdir $(CEGLIB)
-mkdir $(PARLIB)
-mkdir $(OBJLIB)
-mkdir $(ASLIB)
cp $(OFILES) $(ASLIB)
for i in $(OFILES) ; do rm -f $(OBJLIB)/$$i ; done
for i in $(OFILES) ; do ln $(ASLIB)/$$i $(OBJLIB)/$$i ; done
cmp: all
for i in $(OFILES) ; do cmp $$i $(ASLIB)/$$i ; done
clean:
rm -f *.o dummy Lpars.[ch] pars.c
pr:
@pr Makefile C_instr2.c action.c arg_type.h decl.h default.c \
em_parser.h eval.c help.c mylex.c pars.g scan.c
opr:
make pr | opr
Lpars.o : Lpars.h decl.h
pars.o : Lpars.h decl.h

View File

@@ -0,0 +1,33 @@
EM=../../../..
CEGLIB = $(EM)/lib/ceg
PARLIB = $(CEGLIB)/EM_parser
LIB = $(PARLIB)/obj_EM_pars
OFILES = dist.o
HFILES = arg_type.h em_parser.h
IFILES = -I$(EM)/h -I$(EM)/modules/h
CC = cc
.c.o :
$(CC) $(IFILES) -c $<
all : $(OFILES)
install: all
-mkdir $(CEGLIB)
-mkdir $(PARLIB)
-mkdir $(LIB)
cp $(OFILES) $(HFILES) $(LIB)
cmp: all
for i in $(OFILES) $(HFILES) ; do cmp $$i $(LIB)/$$i ; done
clean:
rm -f *.o
pr:
@pr Makefile arg_type.h dist.c em_parser.h
opr:
make pr | opr

View File

@@ -0,0 +1,59 @@
EM=../../..
CEGLIB = $(EM)/lib/ceg
GFILES = pars.g
OFILES = pars.o Lpars.o lex.yy.o help.o conversion.o
IFILES = -I$(EM)/h -I$(EM)/modules/h
LIBS = $(EM)/modules/lib/liballoc.a\
$(EM)/modules/lib/libprint.a\
$(EM)/modules/lib/libstring.a\
$(EM)/modules/lib/libsystem.a
CC = cc
CFLAGS = -O
LEXLIB = -ll
.c.o :
$(CC) $(CFLAGS) $(IFILES) -c $<
all: as_parser eval/eval
as_parser: dummy
make $(OFILES)
$(CC) -o as_parser $(OFILES) $(LIBS) $(LEXLIB)
eval/eval:
( cd eval ; make eval )
install: all
-mkdir $(CEGLIB)
-mkdir $(CEGLIB)/as_parser
-mkdir $(CEGLIB)/as_parser/eval
cp as_parser $(CEGLIB)/as_parser/as_parser
cp eval/eval $(CEGLIB)/as_parser/eval/eval
cp as_parser.h $(CEGLIB)/as_parser/as_parser.h
cmp: all
-cmp as_parser $(CEGLIB)/as_parser/as_parser
-cmp eval/eval $(CEGLIB)/as_parser/eval/eval
-cmp as_parser.h $(CEGLIB)/as_parser/as_parser.h
pr:
@pr Makefile as_parser.h const.h conversion.c decl.h help.c pars.g table.l eval/Makefile eval/eval.c eval/states.h
opr:
make pr | opr
clean:
rm -f as_parser *.o lex.yy.c Lpars.[ch] pars.c dummy eval/*.o eval/eval
lex.yy.c : table.l
lex table.l
dummy : $(GFILES)
LLgen $(LLOPT) $(GFILES)
touch dummy
Lpars.o : Lpars.h decl.h
pars.o : Lpars.h decl.h
Lpars.o : Lpars.h decl.h
lex.yy.o : Lpars.h decl.h

View File

@@ -0,0 +1,7 @@
CC = cc
CFLAGS = -O
eval: eval.o
$(CC) $(CFLAGS) -o eval eval.o
eval.o : states.h

View File

@@ -0,0 +1,29 @@
EM=../../..
CEG = $(EM)/lib/ceg
ASS = $(CEG)/assemble
ASLIST = assemble.c block_as.c
OBJLIST = assemble.c block_as.c const.h
all:
install:
-mkdir $(CEG)
-mkdir $(ASS)
-mkdir $(ASS)/as_assemble
-mkdir $(ASS)/obj_assemble
for i in $(ASLIST) ; do cp as_assemble/$$i $(ASS)/as_assemble/$$i ; done
for i in $(OBJLIST) ; do cp obj_assemble/$$i $(ASS)/obj_assemble/$$i ; done
cmp:
-for i in $(ASLIST) ; do cp as_assemble/$$i $(ASS)/as_assemble/$$i ; done
-for i in $(OBJLIST) ; do cp obj_assemble/$$i $(ASS)/obj_assemble/$$i ; done
pr:
@for i in $(ASLIST) ; do pr as_assemble/$$i ; done
@for i in $(OBJLIST) ; do pr obj_assemble/$$i ; done
opr:
make pr | opr
clean:

39
util/ceg/ce_back/Makefile Normal file
View File

@@ -0,0 +1,39 @@
EM=../../..
CEG = $(EM)/lib/ceg
BACK = $(CEG)/ce_back
ASLIST = Makefile back.h bottom.c bss.c con1.c con2.c con4.c \
do_close.c do_open.c end_back.c gen1.c gen2.c gen4.c header.h \
init_back.c reloc1.c reloc2.c reloc4.c rom1.c rom2.c rom4.c \
set_global.c set_local.c switchseg.c symboldef.c text1.c \
text2.c text4.c
OBJLIST = Makefile back.h con2.c con4.c data.c data.h do_close.c do_open.c \
end_back.c extnd.c gen1.c gen2.c gen4.c hash.h header.h \
init_back.c label.c memory.c misc.c output.c \
reloc1.c reloc2.c reloc4.c relocation.c rom2.c rom4.c \
set_global.c set_local.c switchseg.c symboldef.c symtable.c \
text2.c text4.c common.c
all:
install:
-mkdir $(CEG)
-mkdir $(BACK)
-mkdir $(BACK)/as_back
-mkdir $(BACK)/obj_back
for i in $(ASLIST) ; do cp as_back/$$i $(BACK)/as_back/$$i ; done
for i in $(OBJLIST) ; do cp obj_back/$$i $(BACK)/obj_back/$$i ; done
cmp:
-for i in $(ASLIST) ; do cmp as_back/$$i $(BACK)/as_back/$$i ; done
-for i in $(OBJLIST) ; do cmp obj_back/$$i $(BACK)/obj_back/$$i ; done
pr:
@for i in $(ASLIST) ; do pr as_back/$$i ; done
@for i in $(OBJLIST) ; do pr obj_back/$$i ; done
opr:
make pr | opr
clean:

View File

@@ -0,0 +1,96 @@
EM=../../../..
CEG=$(EM)/lib/ceg
SOURCE=$(CEG)/ce_back/as_back
CC = cc
CFLAGS = -O
IDIRS=-I.\
-I..\
-I$(EM)/h\
-I$(EM)/modules/h
LIBS=$(EM)/modules/lib/object.a\
$(EM)/modules/lib/libstring.a\
$(EM)/modules/lib/libprint.a\
$(EM)/modules/lib/libsystem.a
all : bottom.o con1.o con2.o con4.o end_back.o gen1.o gen2.o\
gen4.o init_back.o reloc1.o reloc2.o reloc4.o bss.o\
rom1.o rom2.o rom4.o set_global.o set_local.o switchseg.o symboldef.o \
do_open.o do_close.o text1.o text2.o text4.o
bottom.o : ../mach.h back.h header.h $(SOURCE)/bottom.c
$(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/bottom.c
bss.o : ../mach.h back.h header.h $(SOURCE)/bss.c
$(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/bss.c
text1.o : ../mach.h back.h header.h $(SOURCE)/text1.c
$(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/text1.c
text2.o : ../mach.h back.h header.h $(SOURCE)/text2.c
$(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/text2.c
text4.o : ../mach.h back.h header.h $(SOURCE)/text4.c
$(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/text4.c
con1.o : ../mach.h back.h header.h $(SOURCE)/con1.c
$(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/con1.c
con2.o : ../mach.h back.h header.h $(SOURCE)/con2.c
$(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/con2.c
con4.o : ../mach.h back.h header.h $(SOURCE)/con4.c
$(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/con4.c
do_open.o : back.h header.h ../mach.h $(SOURCE)/do_open.c
$(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/do_open.c
do_close.o : back.h header.h ../mach.h $(SOURCE)/do_close.c
$(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/do_close.c
gen1.o : back.h header.h ../mach.h $(SOURCE)/gen1.c
$(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/gen1.c
gen2.o : back.h header.h ../mach.h $(SOURCE)/gen2.c
$(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/gen2.c
gen4.o : back.h header.h ../mach.h $(SOURCE)/gen4.c
$(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/gen4.c
init_back.o : header.h back.h ../mach.h $(SOURCE)/init_back.c
$(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/init_back.c
end_back.o : header.h back.h ../mach.h $(SOURCE)/end_back.c
$(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/end_back.c
reloc1.o : back.h header.h ../mach.h $(SOURCE)/reloc1.c
$(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/reloc1.c
reloc2.o : back.h header.h ../mach.h $(SOURCE)/reloc2.c
$(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/reloc2.c
reloc4.o : back.h header.h ../mach.h $(SOURCE)/reloc4.c
$(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/reloc4.c
rom1.o : back.h header.h ../mach.h $(SOURCE)/rom1.c
$(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/rom1.c
rom2.o : back.h header.h ../mach.h $(SOURCE)/rom2.c
$(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/rom2.c
rom4.o : back.h header.h ../mach.h $(SOURCE)/rom4.c
$(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/rom4.c
set_global.o : header.h back.h ../mach.h $(SOURCE)/set_global.c
$(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/set_global.c
set_local.o : header.h back.h ../mach.h $(SOURCE)/set_local.c
$(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/set_local.c
switchseg.o : header.h back.h ../mach.h $(SOURCE)/switchseg.c
$(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/switchseg.c
symboldef.o : header.h back.h ../mach.h $(SOURCE)/symboldef.c
$(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/symboldef.c

View File

@@ -0,0 +1,2 @@
#define TRUE 1
#define FALSE 0

View File

@@ -0,0 +1,107 @@
EM=../../../..
CEG=$(EM)/lib/ceg
SOURCE=$(CEG)/ce_back/obj_back
CC = cc
CFLAGS = -O
IDIRS=-I.\
-I..\
-I$(EM)/h\
-I$(EM)/modules/h
LIBS=$(EM)/modules/lib/*.a
all : data.o con2.o con4.o relocation.o end_back.o gen1.o gen2.o\
gen4.o init_back.o output.o reloc1.o reloc2.o reloc4.o\
rom2.o rom4.o set_global.o set_local.o switchseg.o symboldef.o text2.o\
text4.o do_open.o do_close.o memory.o label.o misc.o extnd.o symtable.o\
common.o
data.o : data.h back.h header.h $(SOURCE)/data.c
$(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/data.c
memory.o :data.h back.h header.h $(SOURCE)/memory.c
$(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/memory.c
con2.o : data.h back.h header.h $(SOURCE)/con2.c
$(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/con2.c
con4.o : data.h back.h header.h $(SOURCE)/con4.c
$(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/con4.c
relocation.o : data.h back.h ../mach.h $(SOURCE)/relocation.c
$(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/relocation.c
do_open.o : data.h back.h ../mach.h $(SOURCE)/do_open.c
$(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/do_open.c
do_close.o : data.h back.h ../mach.h $(SOURCE)/do_close.c
$(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/do_close.c
gen1.o : data.h back.h header.h $(SOURCE)/gen1.c
$(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/gen1.c
gen2.o : data.h back.h header.h $(SOURCE)/gen2.c
$(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/gen2.c
gen4.o : data.h back.h header.h $(SOURCE)/gen4.c
$(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/gen4.c
init_back.o : data.h back.h ../mach.h $(SOURCE)/init_back.c
$(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/init_back.c
end_back.o : data.h back.h ../mach.h $(SOURCE)/end_back.c
$(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/end_back.c
output.o : data.h back.h ../mach.h $(SOURCE)/output.c
$(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/output.c
reloc1.o : data.h back.h header.h $(SOURCE)/reloc1.c
$(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/reloc1.c
reloc2.o : data.h back.h header.h $(SOURCE)/reloc2.c
$(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/reloc2.c
reloc4.o : data.h back.h header.h $(SOURCE)/reloc4.c
$(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/reloc4.c
rom2.o : data.h back.h header.h $(SOURCE)/rom2.c
$(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/rom2.c
rom4.o : data.h back.h header.h $(SOURCE)/rom4.c
$(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/rom4.c
set_global.o : data.h back.h ../mach.h $(SOURCE)/set_global.c
$(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/set_global.c
set_local.o : data.h back.h ../mach.h $(SOURCE)/set_local.c
$(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/set_local.c
switchseg.o : data.h back.h ../mach.h $(SOURCE)/switchseg.c
$(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/switchseg.c
symboldef.o : data.h back.h ../mach.h $(SOURCE)/symboldef.c
$(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/symboldef.c
text2.o : data.h back.h ../mach.h $(SOURCE)/text2.c
$(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/text2.c
text4.o : data.h back.h ../mach.h $(SOURCE)/text4.c
$(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/text4.c
symtable.o : data.h back.h ../mach.h $(SOURCE)/symtable.c
$(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/symtable.c
extnd.o : data.h back.h ../mach.h $(SOURCE)/extnd.c
$(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/extnd.c
misc.o : data.h back.h ../mach.h $(SOURCE)/misc.c
$(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/misc.c
label.o : data.h back.h ../mach.h $(SOURCE)/label.c
$(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/label.c
common.o : data.h back.h ../mach.h $(SOURCE)/common.c
$(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/common.c

View File

@@ -0,0 +1,28 @@
#include <system.h>
#include "data.h"
#include <varargs.h>
/* Mysprint() stores the string directly in the string_arae. This saves
* a copy action. It is assumed that the strings stored in the string-table
* are never longer than MAXSTRLEN bytes.
*/
#define MAXSTRLEN 1024
/*VARARGS*/
int mysprint(va_alist)
va_dcl
{
char *fmt;
va_list args;
int retval;
va_start(args);
fmt = va_arg(args, char *);
while (string + MAXSTRLEN - string_area > size_string)
mem_string();
retval = _format(string, fmt, args);
string[retval] = '\0';
va_end(args);
return retval;
}

View File

@@ -0,0 +1,62 @@
EM = ../../..
CEGLIB = $(EM)/lib/ceg
DEF = $(CEGLIB)/defaults
MessageList = C_cst.c C_dlb.c C_dnam.c C_fcon.c C_icon.c C_ilb.c C_mes_begin.c \
C_mes_end.c C_pnam.c C_scon.c C_ucon.c
NotimplList = not_impl.c not_impl_table
PseudoList = C_busy.c C_close.c C_df_dlb.c C_df_dnam.c C_df_ilb.c C_end.c \
C_end_narg.c C_exa_dlb.c C_exa_dnam.c C_exp.c C_ina_dlb.c \
C_ina_dnam.c C_init.c C_inp.c C_magic.c C_open.c C_pro.c \
C_pro_narg.c C_insertpart.c
StorageList = C_bss_cst.c C_bss_dlb.c C_bss_dnam.c C_bss_ilb.c C_bss_pnam.c \
C_con_cst.c C_con_dlb.c C_con_dnam.c C_con_ilb.c C_con_pnam.c \
C_con_scon.c C_hol_cst.c C_hol_dlb.c C_hol_dnam.c C_hol_ilb.c \
C_hol_pnam.c C_rom_cst.c C_rom_dlb.c C_rom_dnam.c C_rom_ilb.c \
C_rom_pnam.c C_rom_scon.c
all: C_out.c
clean:
rm -f C_out.c C_mnem C_mnem_narg
install: all
-mkdir $(CEGLIB)
-mkdir $(DEF)
-mkdir $(DEF)/message
-mkdir $(DEF)/not_impl
-mkdir $(DEF)/pseudo
-mkdir $(DEF)/storage
cp pseudo_vars.c $(DEF)
cp EM_vars.c $(DEF)
for i in $(MessageList) ; do cp message/$$i $(DEF)/message/$$i ; done
for i in $(NotimplList) ; do cp not_impl/$$i $(DEF)/not_impl/$$i ; done
for i in $(PseudoList) ; do cp pseudo/$$i $(DEF)/pseudo/$$i ; done
for i in $(StorageList) ; do cp storage/$$i $(DEF)/storage/$$i ; done
cp C_out.c $(DEF)/C_out.c
cmp:
-cmp pseudo_vars.c $(DEF)/pseudo_vars.c
-cmp EM_vars.c $(DEF)/EM_vars.c
-for i in $(MessageList) ; do cmp message/$$i $(DEF)/message/$$i ; done
-for i in $(NotimplList) ; do cmp not_impl/$$i $(DEF)/not_impl/$$i ; done
-for i in $(PseudoList) ; do cmp pseudo/$$i $(DEF)/pseudo/$$i ; done
-for i in $(StorageList) ; do cmp storage/$$i $(DEF)/storage/$$i ; done
-cmp C_out.c $(DEF)/C_out.c
pr:
@for i in $(MessageList) ; do pr message/$$i ; done
@for i in $(NotimplList) ; do pr not_impl/$$i ; done
@for i in $(PseudoList) ; do pr pseudo/$$i ; done
@for i in $(StorageList) ; do pr storage/$$i ; done
opr:
make pr | opr
C_out.c: C_out_skel.c C_mnem C_mnem_narg mk_C_out
mk_C_out > C_out.c
C_mnem: m_C_mnem argtype
sh m_C_mnem > C_mnem
C_mnem_narg: m_C_mnem_na argtype
sh m_C_mnem_na > C_mnem_narg

23
util/ceg/util/Makefile Normal file
View File

@@ -0,0 +1,23 @@
EM = ../../..
CEGLIB = $(EM)/lib/ceg
UTIL = $(CEGLIB)/util
UtilList = make_asobj make_own make_back make_ce make_ceg_as make_ceg_obj
all:
install:
-mkdir $(CEGLIB)
-mkdir $(UTIL)
cp $(UtilList) $(UTIL)
cp install_ceg update_ceg $(EM)/bin
cmp:
for i in $(UtilList) ; do cmp $$i $(UTIL)/$$i ; done
clean:
pr:
@pr $(UtilList)
opr:
make pr | opr

View File

@@ -0,0 +1,13 @@
list=
for i in *.c
do
b=`basename $i .c`
if test ! -f $b.o
then
>$b.o
list="$list $i"
fi
done
: my SUN is too fast ...
sleep 2
touch $list

68
util/ceg/util/make_as Normal file
View File

@@ -0,0 +1,68 @@
EM = ../../../..
CEG = $(EM)/lib/ceg
Em = $(CEG)/EM_parser/as_EM_pars
ASMAIN = $(CEG)/assemble/as_assemble
BACK = $(CEG)/ce_back
AS = $(CEG)/as_parser
DEF = $(CEG)/defaults
CC = cc
AR = ar
LEXLIB = -ll
IFILES = -I. -I.. -I$(AS) -I$(Em) -I$(EM)/h -I$(EM)/modules/h -I../back
CFLAGS = -O $(IFILES)
CEG_LIBS = $(EM)/modules/lib/liballoc.a\
$(EM)/modules/lib/libprint.a\
$(EM)/modules/lib/libstring.a\
$(EM)/modules/lib/libsystem.a
.c.o: mach.h back.a
cd ce ; $(CC) -c $(CFLAGS) ../$*.c ; cd ..
all: back.a ce.a
install: all
../../install ce.a
../../install back.a
cmp: all
-../../compare ce.a
-../../compare back.a
clean:
rm -rf ce back ceg ce.a back.a Out
dclean:
rm -rf ce back ceg Out
ce.a : ce/dummy
$(AR) r ce.a ce/*.o
-sh -c 'ranlib ce.a'
ce/dummy : ce/dummy1 mach.h back.a
cd ce;$(CC) -c $(CFLAGS) *.c; touch dummy ; cd ..
ce/dummy1: ceg/ceg EM_table mach.h back.a
-mkdir ce
-ln mach.c ce/mach.c
cd ce; ../ceg/ceg -l < $(DEF)/not_impl/not_impl_table ; cp $(DEF)/*.c . ; cp $(DEF)/*/*.c . ; cd ..
cd ce; $(EM)/lib/cpp -P ../EM_table | ../ceg/ceg -l ; cd ..
touch ce/dummy1
ceg/as_lib.a:
-mkdir ceg
cd ceg; cp $(ASMAIN)/* . ; $(CC) -c $(IFILES) *.c; $(AR) r as_lib.a *.o ; cd ..
-sh -c 'ranlib ceg/as_lib.a'
back.a: mach.h
-mkdir back
cd back;cp $(BACK)/as_back/*h . ; cp $(BACK)/as_back/Makefile . ; make ; cd ..
$(AR) r back.a back/*o
-sh -c 'ranlib back.a'
ceg/ceg : ceg/as_lib.a # $(Em)/em_parser
cd ceg; $(CC) -o ceg $(Em)/*.o as_lib.a $(CEG_LIBS) $(LEXLIB) ; cd ..

31
util/ceg/util/make_ceg_as Normal file
View File

@@ -0,0 +1,31 @@
EM = ../../../..
CEG = $(EM)/lib/ceg
Em = $(CEG)/EM_parser/as_EM_pars
ASMAIN = $(CEG)/assemble/as_assemble
AS = $(CEG)/as_parser
DEF = $(CEG)/defaults
AR = ar
CC = cc
LEXLIB = -ll
IFILES = -I. -I.. -I$(AS) -I$(Em) -I$(EM)/h -I$(EM)/modules/h -I../back
CFLAGS = -O $(IFILES)
CEG_LIBS = $(EM)/modules/lib/liballoc.a\
$(EM)/modules/lib/libprint.a\
$(EM)/modules/lib/libstring.a\
$(EM)/modules/lib/libsystem.a
all: ceg/ceg
ceg/ceg: ceg/as_lib.a
cd ceg ; $(CC) -o ceg $(Em)/*.o as_lib.a $(CEG_LIBS) $(LEXLIB) ; cd ..
ceg/as_lib.a:
-mkdir ceg
cd ceg ; cp $(CEG)/util/make_ceg_as Makefile ; cd ..
cd ceg ; cp $(ASMAIN)/* . ; $(CC) -c $(CFLAGS) *.c; $(AR) r as_lib.a *.o ; cd ..
-sh -c 'ranlib ceg/as_lib.a'

View File

@@ -0,0 +1,44 @@
EM = ../../../..
CEG = $(EM)/lib/ceg
Em = $(CEG)/EM_parser/obj_EM_pars
ASMAIN = $(CEG)/assemble/obj_assemble
AS = $(CEG)/as_parser
EVAL = $(CEG)/as_parser/eval
DEF = $(CEG)/defaults
AR = ar
CC = cc
LEXLIB = -ll
IFILES = -I. -I.. -I$(AS) -I$(Em) -I$(EM)/h -I$(EM)/modules/h -I../back
CFLAGS = -O $(IFILES)
CEG_LIBS = $(EM)/modules/lib/liballoc.a\
$(EM)/modules/lib/libprint.a\
$(EM)/modules/lib/libstring.a\
$(EM)/modules/lib/libsystem.a
all: ceg/ceg
ceg/ceg : ceg/as_lib.a ceg/as_instr.o ceg/eval_as.o
cd ceg ; $(CC) -o ceg $(Em)/*.o as_instr.o eval_as.o as_lib.a $(CEG_LIBS) $(LEXLIB) ; cd ..
ceg/as_lib.a:
-mkdir ceg
cd ceg ; cp $(CEG)/util/make_ceg_obj Makefile ; cd ..
cd ceg ; cp $(ASMAIN)/* . ; $(CC) -c $(CFLAGS) *.c; $(AR) r as_lib.a *.o ; cd ..
-sh -c 'ranlib ceg/as_lib.a'
ceg/eval_as.o : ceg/eval_as.c as.h # $(AS)/as_parser.h $(Em)/arg_type.h
cd ceg ; $(CC) -c $(CFLAGS) eval_as.c ; cd ..
ceg/eval_as.c : as.c # $(EVAL)/eval
cd ceg ; $(EVAL)/eval < ../as.c > eval_as.c ; cd ..
ceg/as_instr.o : as.h ceg/as_lib.a ceg/as_instr.c
cd ceg ; $(CC) -c $(CFLAGS) as_instr.c ; cd ..
ceg/as_instr.c : as_table # $(AS)/as_parser
cd ceg ; $(EM)/lib/cpp -P ../as_table | $(AS)/as_parser > as_instr.c ; cd ..

78
util/ceg/util/make_obj Normal file
View File

@@ -0,0 +1,78 @@
EM = ../../../..
CEG = $(EM)/lib/ceg
Em = $(CEG)/EM_parser/obj_EM_pars
ASMAIN = $(CEG)/assemble/obj_assemble
BACK = $(CEG)/ce_back
AS = $(CEG)/as_parser
EVAL = $(CEG)/as_parser/eval
DEF = $(CEG)/defaults
AR = ar
CC = cc
LEXLIB = -ll
IFILES = -I. -I.. -I$(AS) -I$(Em) -I$(EM)/h -I$(EM)/modules/h -I../back
CEG_LIBS = $(EM)/modules/lib/liballoc.a\
$(EM)/modules/lib/libprint.a\
$(EM)/modules/lib/libstring.a\
$(EM)/modules/lib/libsystem.a
CFLAGS = -O $(IFILES)
.c.o: mach.h back.a
cd ce ; $(CC) -c $(CFLAGS) ../$*.c ; cd ..
all: back.a ce.a
install: all
../../install ce.a
../../install back.a
cmp: all
-../../compare ce.a
-../../compare back.a
clean:
rm -rf ce back ceg ce.a back.a Out
ce.a : ce/dummy
$(AR) r ce.a ce/*.o
-sh -c 'ranlib ce.a'
ce/dummy : ce/dummy1 mach.h back.a
cd ce;$(CC) -c $(CFLAGS) *.c; touch dummy ; cd ..
ce/dummy1: ceg/ceg EM_table mach.h back.a
-mkdir ce
-ln mach.c ce/mach.c
cd ce; ../ceg/ceg -l < $(DEF)/not_impl/not_impl_table ; cp $(DEF)/*.c . ; cp $(DEF)/*/*.c . ; cd ..
cd ce; $(EM)/lib/cpp -P ../EM_table | ../ceg/ceg -l ; cd ..
touch ce/dummy1
back.a: mach.h
-mkdir back
cd back;cp $(BACK)/obj_back/*h . ; cp $(BACK)/obj_back/Makefile . ; make; cd ..
$(AR) r back.a back/*o;
-sh -c 'ranlib back.a'
ceg/ceg : ceg/as_lib.a ceg/as_instr.o ceg/eval_as.o # $(Em)/em_parser
cd ceg; $(CC) -o ceg $(Em)/*.o as_instr.o eval_as.o as_lib.a $(CEG_LIBS) $(LEXLIB) ; cd ..
ceg/as_lib.a:
-mkdir ceg
cd ceg; cp $(ASMAIN)/* . ; $(CC) -c $(IFILES) *.c; $(AR) r as_lib.a *.o ; touch dummy ; cd ..
-sh -c 'ranlib ceg/as_lib.a'
ceg/eval_as.o : ceg/eval_as.c as.h # $(AS)/as_parser.h $(Em)/arg_type.h
cd ceg;$(CC) -c $(IFILES) eval_as.c ; cd ..
ceg/eval_as.c : as.c # $(EVAL)/eval
cd ceg; $(EVAL)/eval < ../as.c > eval_as.c ; cd ..
ceg/as_instr.o : as.h ceg/dummy ceg/as_instr.c
cd ceg;$(CC) -c $(IFILES) as_instr.c ; cd ..
ceg/as_instr.c : as_table # $(AS)/as_parser
cd ceg; $(EM)/lib/cpp -P ../as_table| $(AS)/as_parser > as_instr.c ; cd ..

1
util/ceg/util/preproc Normal file
View File

@@ -0,0 +1 @@
../../../../lib/cpp $@ | sed "/^#/d"

28
util/ceg/util/update Normal file
View File

@@ -0,0 +1,28 @@
make -f ce_makefile ceg/ceg
for i
do
case $i in
ALL) make -f ce_makefile EM_instr ce.a;
exit 0;;
*.o) make -f ce_makefile ce/$i;
ar r ce.a $i;;
*..) ( cd ce; ../../../../lib/cpp ../EM_table| sed "/^#/d"| ../ceg/ceg -c $i);
F=`basename $i ..`;
U="_dnam"
V="_dlb"
make -f ce_makefile ce/$F.o ce/$F$U.o ce/"$F$V.o";
echo ar r ce.a ce/$F.o ce/"$F$U.o" ce/"$F$V.o";
ar r ce.a ce/$F.o ce/$F$U.o ce/"$F$U.o";;
*) ( cd ce; ../../../../lib/cpp ../EM_table| sed "/^#/d"| ../ceg/ceg -c $i);
make -f ce_makefile ce/$i.o;
echo ar r ce.a ce/$i.o;
ar r ce.a ce/$i.o;;
esac
done
echo ranlib ce.a
ranlib ce.a

34
util/cgg/Makefile Normal file
View File

@@ -0,0 +1,34 @@
# $Header$
PREFLAGS=-I../../h
CFLAGS=$(PREFLAGS)
LDFLAGS=
LINTOPTS=-hbxac $(PREFLAGS)
LIBS=../../lib/em_data.a
# LEXLIB is system dependent, try -ll or -lln first
LEXLIB = -lln
cgg: bootgram.o main.o bootlex.o
$(CC) $(LDFLAGS) bootgram.o main.o bootlex.o $(LIBS) $(LEXLIB) -o cgg
bootgram.c: bootgram.y
@echo expect 1 shift/reduce conflict
yacc -d bootgram.y
mv y.tab.c bootgram.c
install: cgg
cp cgg ../../lib/cgg
cmp: cgg
cmp cgg ../../lib/cgg
lint: bootgram.c main.c bootlex.c
lint $(LINTOPTS) bootgram.c main.c bootlex.c
clean:
rm -f *.o bootgram.c bootlex.c cgg y.tab.h
bootgram.o: booth.h
bootgram.o: ../../h/cg_pattern.h
bootlex.o: booth.h
bootlex.o: ../../h/cg_pattern.h
main.o: booth.h
main.o: ../../h/cg_pattern.h

52
util/cmisc/Makefile Normal file
View File

@@ -0,0 +1,52 @@
EM = ../..
EMBIN = $(EM)/bin
EMMAN = $(EM)/man
CFLAGS = -O
LDFLAGS =
all: mkdep cid cclash prid tabgen
install: all
rm -f $(EMBIN)/mkdep $(EMBIN)/cid $(EMBIN)/cclash $(EMBIN)/prid \
$(EMBIN)/tabgen
cp mkdep cid cclash prid tabgen $(EMBIN)
rm -f $(EMMAN)/mkdep.1 $(EMMAN)/cid.1 $(EMMAN)/cclash.1 \
$(EMMAN)/prid.1 $(EMMAN)/tabgen.1
cp mkdep.1 cid.1 cclash.1 prid.1 tabgen.1 $(EMMAN)
cmp: all
-cmp mkdep $(EMBIN)/mkdep
-cmp cid $(EMBIN)/cid
-cmp cclash $(EMBIN)/cclash
-cmp prid $(EMBIN)/prid
-cmp tabgen $(EMBIN)/tabgen
-cmp mkdep.1 $(EMMAN)/mkdep.1
-cmp cid.1 $(EMMAN)/cid.1
-cmp cclash.1 $(EMMAN)/cclash.1
-cmp prid.1 $(EMMAN)/prid.1
-cmp tabgen.1 $(EMMAN)/tabgen.1
clean:
rm -f *.o mkdep cid cclash prid tabgen
pr:
@pr `pwd`/Makefile `pwd`/mkdep.c `pwd`/cclash.c `pwd`/cid.c \
`pwd`/prid.c `pwd`/GCIPM.c `pwd`/tabgen.c
opr:
make pr | opr
mkdep: mkdep.o
$(CC) $(LDFLAGS) -o mkdep mkdep.o
tabgen: tabgen.o
$(CC) $(LDFLAGS) -o tabgen tabgen.o
cid: cid.o GCIPM.o
$(CC) $(LDFLAGS) -o cid cid.o GCIPM.o
cclash: cclash.o GCIPM.o
$(CC) $(LDFLAGS) -o cclash cclash.o GCIPM.o
prid: prid.o GCIPM.o
$(CC) $(LDFLAGS) -o prid prid.o GCIPM.o

8
util/cpp/Version.c Normal file
View File

@@ -0,0 +1,8 @@
/* $Header$ */
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef lint
static char Version[] = "ACK C preprocessor Version 1.3";
#endif lint

321
util/cpp/chtab.c Normal file
View File

@@ -0,0 +1,321 @@
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/*
chtab - character table generator
Author: Erik Baalbergen (..tjalk!erikb)
Modified by Ceriel Jacobs
*/
#include <stdio.h>
static char *RcsId = "$Header$";
#define MAXBUF 256
#define TABSIZE 257
#define COMCOM '-'
#define FILECOM '%'
int InputForm = 'c';
char OutputForm[MAXBUF] = "%s,\n";
char *Table[TABSIZE];
char *Name;
char *ProgCall;
int signedch = 0;
char *OutputName;
char *chroffsetfile = "charoffset.h";
main(argc, argv)
char *argv[];
{
char c = 0200;
int i = c;
if (i < 0) signedch = 1;
ProgCall = *argv++;
argc--;
while (argc-- > 0) {
if (**argv == COMCOM) {
option(*argv++);
}
else {
process(*argv++, InputForm);
}
}
MkCharIndex();
exit(0);
}
MkCharIndex()
{
FILE *fp;
if ((fp = fopen(chroffsetfile, "w")) == NULL) {
fprintf(stderr, "%s: cannot write file %s\n", ProgCall, chroffsetfile);
exit(1);
}
if (signedch) {
fputs("#define CharOffset 128\n", fp);
}
else fputs("#define CharOffset 0\n", fp);
fclose(fp);
}
char *
Salloc(s)
char *s;
{
char *malloc();
char *ns = malloc(strlen(s) + 1);
if (ns) {
strcpy(ns, s);
}
return ns;
}
option(str)
char *str;
{
/* note that *str indicates the source of the option:
either COMCOM (from command line) or FILECOM (from a file).
*/
switch (*++str) {
case ' ': /* command */
case '\t':
case '\0':
break;
case 'I':
InputForm = *++str;
break;
case 'f':
if (*++str == '\0') {
fprintf(stderr, "%s: -f: name expected\n", ProgCall);
exit(1);
}
DoFile(str);
break;
case 'F':
sprintf(OutputForm, "%s\n", ++str);
break;
case 'T':
printf("%s\n", ++str);
break;
case 'p':
PrintTable();
break;
case 'C':
ClearTable();
break;
case 'H':
if (*++str == '\0') {
fprintf(stderr, "%s: -H: name expected\n", ProgCall);
}
else chroffsetfile = ++str;
break;
default:
fprintf(stderr, "%s: bad option -%s\n", ProgCall, str);
}
}
ClearTable()
{
register i;
for (i = 0; i < TABSIZE; i++) {
Table[i] = 0;
}
}
PrintTable()
{
register i;
for (i = 0; i < TABSIZE; i++) {
if (Table[i]) {
printf(OutputForm, Table[i]);
}
else {
printf(OutputForm, "0");
}
}
}
process(str, format)
char *str;
{
char *cstr = str;
char *Name = cstr; /* overwrite original string! */
/* strip of the entry name
*/
while (*str && *str != ':') {
if (*str == '\\') {
++str;
}
*cstr++ = *str++;
}
if (*str != ':') {
fprintf(stderr, "%s: bad specification: \"%s\", ignored\n",
ProgCall, Name);
return 0;
}
*cstr = '\0';
str++;
switch (format) {
case 'c':
return c_proc(str, Name);
default:
fprintf(stderr, "%s: bad input format\n", ProgCall);
}
return 0;
}
c_proc(str, Name)
char *str;
char *Name;
{
int ch, ch2;
int quoted();
char *name = Salloc(Name);
while (*str) {
if (*str == '\\') {
ch = quoted(&str);
}
else {
ch = *str++;
}
if (*str == '-') {
if (*++str == '\\') {
ch2 = quoted(&str);
}
else {
if (ch2 = *str++);
else str--;
}
if (ch > ch2) {
fprintf(stderr, "%s: bad range\n", ProgCall);
return 0;
}
#define ind(X) (signedch?(X>=128?X-128:X+128):X)
while (ch <= ch2) {
Table[ind(ch)] = name;
ch++;
}
}
else {
if (ch >= 0 && ch <= 255)
Table[ind(ch)] = name;
}
}
Table[256] = Table[0];
return 1;
}
int
quoted(pstr)
char **pstr;
{
register int ch;
register int i;
register char *str = *pstr;
if ((*++str >= '0') && (*str <= '9')) {
ch = 0;
for (i = 0; i < 3; i++) {
ch = 8 * ch + (*str - '0');
if (*++str < '0' || *str > '9')
break;
}
}
else {
switch (*str++) {
case 'n':
ch = '\n';
break;
case 't':
ch = '\t';
break;
case 'b':
ch = '\b';
break;
case 'r':
ch = '\r';
break;
case 'f':
ch = '\f';
break;
default :
ch = *str;
}
}
*pstr = str;
return ch & 0377;
}
int
stoi(str)
char *str;
{
register i = 0;
while (*str >= '0' && *str <= '9') {
i = i * 10 + *str++ - '0';
}
return i;
}
char *
getline(s, n, fp)
char *s;
FILE *fp;
{
register c = getc(fp);
char *str = s;
while (n--) {
if (c == EOF) {
return NULL;
}
else
if (c == '\n') {
*str++ = '\0';
return s;
}
*str++ = c;
c = getc(fp);
}
s[n - 1] = '\0';
return s;
}
#define BUFSIZE 1024
DoFile(name)
char *name;
{
char text[BUFSIZE];
FILE *fp;
if ((fp = fopen(name, "r")) == NULL) {
fprintf(stderr, "%s: cannot read file %s\n", ProgCall, name);
exit(1);
}
while (getline(text, BUFSIZE, fp) != NULL) {
if (text[0] == FILECOM) {
option(text);
}
else {
process(text, InputForm);
}
}
}

40
util/data/Makefile Normal file
View File

@@ -0,0 +1,40 @@
# $Header$
d=../..
h=$d/h
l=$d/lib
AR=ar
SUF=o
LIBSUF=a
OBJ=em_mnem.$(SUF) em_pseu.$(SUF) em_flag.$(SUF) em_ptyp.$(SUF)
DATA_PATH=em_data.$(LIBSUF)
CFLAGS=-O -I$h $(COPT)
.SUFFIXES: .$(SUF)
.c.$(SUF):
$(CC) -c $(CFLAGS) $*.c
$(DATA_PATH): $(OBJ)
$(AR) rv $(DATA_PATH) $(OBJ)
-sh -c 'ranlib $(DATA_PATH)'
em_flag.$(SUF): $h/em_flag.h
em_ptyp.$(SUF): $h/em_flag.h $h/em_ptyp.h
install : $(DATA_PATH)
-cmp -s $(DATA_PATH) $l/$(DATA_PATH) || { cp $(DATA_PATH) $l/$(DATA_PATH) ; sh -c 'ranlib $l/$(DATA_PATH)' ; }
cmp : $(DATA_PATH)
-cmp $(DATA_PATH) $l/$(DATA_PATH)
clean:
rm -f $(OBJ) $(DATA_PATH) *.old
opr:
make pr ^ opr
pr:
@pr Makefile em_mnem.c em_pseu.c em_flag.c em_ptyp.c

79
util/ego/bo/Makefile Normal file
View File

@@ -0,0 +1,79 @@
EMHOME=../../..
EMH=$(EMHOME)/h
EMLIB=$(EMHOME)/lib
SHR=../share
LDFLAGS=
CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH)
CFLAGS=$(CPPFLAGS) -O
LINTFLAGS=-hbu
CFILES=\
bo.c
OFILES=\
bo.o
HFILES=
PRFILES=\
$(CFILES) $(HFILES) Makefile
SHARE_OFILES=\
$(SHR)/get.o $(SHR)/put.o $(SHR)/alloc.o $(SHR)/global.o $(SHR)/debug.o \
$(SHR)/files.o $(SHR)/map.o $(SHR)/lset.o $(SHR)/cset.o $(SHR)/aux.o \
$(SHR)/stack_chg.o $(SHR)/go.o
SHARE_MFILES=\
$(SHR)/get.m $(SHR)/put.m $(SHR)/alloc.m $(SHR)/global.m $(SHR)/debug.m \
$(SHR)/files.m $(SHR)/map.m $(SHR)/lset.m $(SHR)/cset.m $(SHR)/aux.m \
$(SHR)/stack_chg.m $(SHR)/go.m
all: bo
bo: $(OFILES)
$(CC) -o bo $(LDFLAGS) $(OFILES) $(SHARE_OFILES) $(EMLIB)/em_data.a
bo_ack: $(CFILES) $(SHARE_MFILES)
$(CC) -c.o $(CFLAGS) $(CFILES) $(SHARE_MFILES)
$(CC) -o bo -.c $(LDFLAGS) bo.o $(EMLIB)/em_data.a
install: all
../install bo
cmp: all
-../compare bo
pr:
@pr $(PRFILES)
opr:
make pr | opr
clean:
rm -f bo *.o Out out nohup.out
lint:
lint $(LINTFLAGS) $(CPPFLAGS) $(CFILES)
print: $(PRFILES)
@pr $?
@touch print
depend:
$(SHR)/makedepend
# the next lines are generated automatically
# AUTOAUTOAUTOAUTOAUTOAUTO
bo.o: ../share/alloc.h
bo.o: ../share/aux.h
bo.o: ../share/debug.h
bo.o: ../share/def.h
bo.o: ../share/files.h
bo.o: ../share/get.h
bo.o: ../share/global.h
bo.o: ../share/go.h
bo.o: ../share/lset.h
bo.o: ../share/map.h
bo.o: ../share/put.h
bo.o: ../share/types.h

82
util/ego/ca/Makefile Normal file
View File

@@ -0,0 +1,82 @@
EMHOME=../../..
EMH=$(EMHOME)/h
EMLIB=$(EMHOME)/lib
SHR=../share
LDFLAGS=
CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH)
CFLAGS=$(CPPFLAGS) -O
LINTFLAGS=-hbu
CFILES=\
ca.c ca_put.c
OFILES=\
ca.o ca_put.o
HFILES=\
ca.h ca_put.h
PRFILES=\
$(CFILES) $(HFILES) Makefile
SHARE_OFILES=\
$(SHR)/get.o $(SHR)/alloc.o $(SHR)/global.o $(SHR)/aux.o $(SHR)/debug.o \
$(SHR)/lset.o $(SHR)/cset.o $(SHR)/files.o $(SHR)/map.o
SHARE_MFILES=\
$(SHR)/get.m $(SHR)/alloc.m $(SHR)/global.m $(SHR)/aux.m $(SHR)/debug.m \
$(SHR)/lset.m $(SHR)/cset.m $(SHR)/files.m $(SHR)/map.m
all: ca
ca: $(OFILES)
$(CC) -o ca $(LDFLAGS) $(OFILES) $(SHARE_OFILES) $(EMLIB)/em_data.a
ca_ack: $(CFILES) $(SHARE_MFILES)
$(CC) -c.o $(CFLAGS) $(CFILES) $(SHARE_MFILES)
$(CC) -o ca -.c $(LDFLAGS) ca.o $(EMLIB)/em_data.a
install: all
../install ca
cmp: all
-../compare ca
pr:
@pr $(PRFILES)
opr:
make pr | opr
clean:
rm -f ca *.o Out out nohup.out
lint:
lint $(LINTFLAGS) $(CPPFLAGS) $(CFILES)
print: $(PRFILES)
@pr $?
@touch print
depend:
$(SHR)/makedepend
# the next lines are generated automatically
# AUTOAUTOAUTOAUTOAUTOAUTO
ca.o: ../share/alloc.h
ca.o: ../share/debug.h
ca.o: ../share/files.h
ca.o: ../share/get.h
ca.o: ../share/global.h
ca.o: ../share/lset.h
ca.o: ../share/map.h
ca.o: ../share/types.h
ca.o: ca.h
ca.o: ca_put.h
ca_put.o: ../share/alloc.h
ca_put.o: ../share/debug.h
ca_put.o: ../share/def.h
ca_put.o: ../share/map.h
ca_put.o: ../share/types.h
ca_put.o: ca.h

102
util/ego/cf/Makefile Normal file
View File

@@ -0,0 +1,102 @@
EMHOME=../../..
EMH=$(EMHOME)/h
EMLIB=$(EMHOME)/lib
SHR=../share
LDFLAGS=
CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH)
CFLAGS=$(CPPFLAGS) -O
LINTFLAGS=-hbu
CFILES=\
cf.c cf_succ.c cf_idom.c cf_loop.c
OFILES=\
cf.o cf_idom.o cf_loop.o cf_succ.o
HFILES=\
cf.h cf_succ.h cf_idom.h cf_loop.h
PRFILES=\
$(CFILES) $(HFILES) Makefile
SHARE_OFILES=\
$(SHR)/get.o $(SHR)/put.o $(SHR)/alloc.o $(SHR)/global.o \
$(SHR)/debug.o $(SHR)/files.o $(SHR)/map.o $(SHR)/lset.o \
$(SHR)/cset.o $(SHR)/aux.o
SHARE_MFILES=\
$(SHR)/get.m $(SHR)/put.m $(SHR)/alloc.m $(SHR)/global.m \
$(SHR)/debug.m $(SHR)/files.m $(SHR)/map.m $(SHR)/lset.m \
$(SHR)/cset.m $(SHR)/aux.m
all: cf
cf: $(OFILES)
$(CC) -o cf $(LDFLAGS) $(OFILES) $(SHARE_OFILES) $(EMLIB)/em_data.a
cf_ack: $(CFILES) $(SHARE_MFILES)
$(CC) -c.o $(CFLAGS) $(CFILES) $(SHARE_MFILES)
$(CC) -o cf -.c $(LDFLAGS) cf.o $(EMLIB)/em_data.a
install: all
../install cf
cmp: all
-../compare cf
pr:
@pr $(PRFILES)
opr:
make pr | opr
clean:
rm -f cf *.o Out out nohup.out
lint:
lint $(LINTFLAGS) $(CPPFLAGS) $(CFILES)
print: $(PRFILES)
@pr $?
@touch print
depend:
$(SHR)/makedepend
# the next lines are generated automatically
# AUTOAUTOAUTOAUTOAUTOAUTO
cf.o: ../share/alloc.h
cf.o: ../share/cset.h
cf.o: ../share/debug.h
cf.o: ../share/def.h
cf.o: ../share/files.h
cf.o: ../share/get.h
cf.o: ../share/global.h
cf.o: ../share/lset.h
cf.o: ../share/map.h
cf.o: ../share/put.h
cf.o: ../share/types.h
cf.o: cf.h
cf.o: cf_idom.h
cf.o: cf_loop.h
cf.o: cf_succ.h
cf_idom.o: ../share/alloc.h
cf_idom.o: ../share/debug.h
cf_idom.o: ../share/lset.h
cf_idom.o: ../share/types.h
cf_idom.o: cf.h
cf_loop.o: ../share/alloc.h
cf_loop.o: ../share/aux.h
cf_loop.o: ../share/debug.h
cf_loop.o: ../share/lset.h
cf_loop.o: ../share/types.h
cf_loop.o: cf.h
cf_succ.o: ../share/cset.h
cf_succ.o: ../share/debug.h
cf_succ.o: ../share/def.h
cf_succ.o: ../share/global.h
cf_succ.o: ../share/lset.h
cf_succ.o: ../share/map.h
cf_succ.o: ../share/types.h
cf_succ.o: cf.h

80
util/ego/cj/Makefile Normal file
View File

@@ -0,0 +1,80 @@
EMHOME=../../..
EMH=$(EMHOME)/h
EMLIB=$(EMHOME)/lib
SHR=../share
LDFLAGS=
CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH)
CFLAGS=$(CPPFLAGS) -O
LINTFLAGS=-hbu
CFILES=\
cj.c
OFILES=\
cj.o
HFILES=
PRFILES=\
$(CFILES) $(HFILES) Makefile
SHARE_OFILES=\
$(SHR)/get.o $(SHR)/put.o $(SHR)/alloc.o $(SHR)/global.o $(SHR)/debug.o \
$(SHR)/files.o $(SHR)/map.o $(SHR)/lset.o $(SHR)/cset.o $(SHR)/aux.o \
$(SHR)/stack_chg.o $(SHR)/go.o
SHARE_MFILES=\
$(SHR)/get.m $(SHR)/put.m $(SHR)/alloc.m $(SHR)/global.m $(SHR)/debug.m \
$(SHR)/files.m $(SHR)/map.m $(SHR)/lset.m $(SHR)/cset.m $(SHR)/aux.m $(SHR)/stack_chg.m $(SHR)/go.m
all: cj
cj: $(OFILES)
$(CC) -o \
cj $(LDFLAGS) $(OFILES) $(SHARE_OFILES) $(EMLIB)/em_data.a
cj_ack: $(CFILES) $(SHARE_MFILES)
$(CC) -c.o $(CFLAGS) $(CFILES) $(SHARE_MFILES)
$(CC) -o cj -.c $(LDFLAGS) cj.o $(EMLIB)/em_data.a
install: all
../install cj
cmp: all
-../compare cj
pr:
@pr $(PRFILES)
opr:
make pr | opr
clean:
rm -f cj *.o Out out nohup.out
lint:
lint $(LINTFLAGS) $(CPPFLAGS) $(CFILES)
print: $(PRFILES)
@pr $?
@touch print
depend:
$(SHR)/makedepend
# the next lines are generated automatically
# AUTOAUTOAUTOAUTOAUTOAUTO
cj.o: ../share/alloc.h
cj.o: ../share/aux.h
cj.o: ../share/debug.h
cj.o: ../share/def.h
cj.o: ../share/files.h
cj.o: ../share/get.h
cj.o: ../share/global.h
cj.o: ../share/go.h
cj.o: ../share/lset.h
cj.o: ../share/map.h
cj.o: ../share/put.h
cj.o: ../share/stack_chg.h
cj.o: ../share/types.h

6
util/ego/compare Executable file
View File

@@ -0,0 +1,6 @@
case $# in
1) DEST="$1" ;;
2) DEST="$2" ;;
*) echo $0 [source] destination ;;
esac
cmp "$1" ../../../lib/ego/$DEST

190
util/ego/cs/Makefile Normal file
View File

@@ -0,0 +1,190 @@
EMHOME=../../..
EMH=$(EMHOME)/h
EMLIB=$(EMHOME)/lib
SHR=../share
LDFLAGS=
CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH)
CFLAGS=$(CPPFLAGS) -O
LINTFLAGS=-hbu
CFILES=\
cs.c cs_alloc.c cs_aux.c cs_avail.c cs_debug.c cs_elim.c \
cs_entity.c cs_kill.c cs_partit.c cs_profit.c cs_getent.c \
cs_stack.c cs_vnm.c
OFILES=\
cs.o cs_alloc.o cs_aux.o cs_avail.o cs_debug.o cs_elim.o \
cs_entity.o cs_kill.o cs_partit.o cs_profit.o cs_getent.o \
cs_stack.o cs_vnm.o
HFILES=\
cs.h cs_alloc.h cs_aux.h cs_avail.h cs_debug.h cs_elim.h \
cs_entity.h cs_kill.h cs_partit.h cs_profit.h cs_getent.h \
cs_stack.h cs_vnm.h
PRFILES=\
$(CFILES) $(HFILES) Makefile
SHARE_OFILES=\
$(SHR)/get.o $(SHR)/put.o $(SHR)/alloc.o $(SHR)/global.o $(SHR)/debug.o\
$(SHR)/files.o $(SHR)/map.o $(SHR)/lset.o $(SHR)/cset.o $(SHR)/aux.o\
$(SHR)/go.o
SHARE_MFILES=\
$(SHR)/get.m $(SHR)/put.m $(SHR)/alloc.m $(SHR)/global.m $(SHR)/debug.m\
$(SHR)/files.m $(SHR)/map.m $(SHR)/lset.m $(SHR)/cset.m $(SHR)/aux.m\
$(SHR)/go.m
all: cs
cs: $(OFILES)
$(CC) -o cs $(LDFLAGS) $(OFILES) $(SHARE_OFILES) $(EMLIB)/em_data.a
cs_ack: $(CFILES) $(SHARE_MFILES)
$(CC) -c.o $(CFLAGS) $(CFILES) $(SHARE_MFILES)
$(CC) -o cs -.c $(LDFLAGS) cs.o $(EMLIB)/em_data.a
install: all
../install cs
cmp: all
-../compare cs
pr:
@pr $(PRFILES)
opr:
make pr | opr
clean:
rm -f cs *.o Out out nohup.out
lint:
lint $(LINTFLAGS) $(CPPFLAGS) $(CFILES)
print: $(PRFILES)
@pr $?
@touch print
depend:
$(SHR)/makedepend
# the next lines are generated automatically
# AUTOAUTOAUTOAUTOAUTOAUTO
cs.o: ../share/debug.h
cs.o: ../share/go.h
cs.o: ../share/lset.h
cs.o: ../share/types.h
cs.o: cs.h
cs.o: cs_aux.h
cs.o: cs_avail.h
cs.o: cs_debug.h
cs.o: cs_elim.h
cs.o: cs_entity.h
cs.o: cs_profit.h
cs.o: cs_stack.h
cs.o: cs_vnm.h
cs_alloc.o: ../share/alloc.h
cs_alloc.o: ../share/types.h
cs_alloc.o: cs.h
cs_aux.o: ../share/aux.h
cs_aux.o: ../share/debug.h
cs_aux.o: ../share/global.h
cs_aux.o: ../share/lset.h
cs_aux.o: ../share/types.h
cs_aux.o: cs.h
cs_aux.o: cs_entity.h
cs_avail.o: ../share/aux.h
cs_avail.o: ../share/debug.h
cs_avail.o: ../share/global.h
cs_avail.o: ../share/lset.h
cs_avail.o: ../share/types.h
cs_avail.o: cs.h
cs_avail.o: cs_alloc.h
cs_avail.o: cs_aux.h
cs_avail.o: cs_debug.h
cs_avail.o: cs_getent.h
cs_debug.o: ../share/debug.h
cs_debug.o: ../share/lset.h
cs_debug.o: ../share/types.h
cs_debug.o: cs.h
cs_debug.o: cs_aux.h
cs_debug.o: cs_avail.h
cs_debug.o: cs_entity.h
cs_elim.o: ../share/alloc.h
cs_elim.o: ../share/aux.h
cs_elim.o: ../share/debug.h
cs_elim.o: ../share/global.h
cs_elim.o: ../share/lset.h
cs_elim.o: ../share/types.h
cs_elim.o: cs.h
cs_elim.o: cs_alloc.h
cs_elim.o: cs_aux.h
cs_elim.o: cs_avail.h
cs_elim.o: cs_debug.h
cs_elim.o: cs_partit.h
cs_elim.o: cs_profit.h
cs_entity.o: ../share/debug.h
cs_entity.o: ../share/global.h
cs_entity.o: ../share/lset.h
cs_entity.o: ../share/types.h
cs_entity.o: cs.h
cs_entity.o: cs_alloc.h
cs_entity.o: cs_aux.h
cs_getent.o: ../share/aux.h
cs_getent.o: ../share/debug.h
cs_getent.o: ../share/global.h
cs_getent.o: ../share/types.h
cs_getent.o: cs.h
cs_getent.o: cs_aux.h
cs_getent.o: cs_entity.h
cs_getent.o: cs_stack.h
cs_kill.o: ../share/aux.h
cs_kill.o: ../share/cset.h
cs_kill.o: ../share/debug.h
cs_kill.o: ../share/global.h
cs_kill.o: ../share/lset.h
cs_kill.o: ../share/map.h
cs_kill.o: ../share/types.h
cs_kill.o: cs.h
cs_kill.o: cs_aux.h
cs_kill.o: cs_avail.h
cs_kill.o: cs_debug.h
cs_kill.o: cs_entity.h
cs_partit.o: ../share/aux.h
cs_partit.o: ../share/debug.h
cs_partit.o: ../share/global.h
cs_partit.o: ../share/types.h
cs_partit.o: cs.h
cs_partit.o: cs_stack.h
cs_profit.o: ../share/aux.h
cs_profit.o: ../share/cset.h
cs_profit.o: ../share/debug.h
cs_profit.o: ../share/global.h
cs_profit.o: ../share/lset.h
cs_profit.o: ../share/types.h
cs_profit.o: cs.h
cs_profit.o: cs_aux.h
cs_profit.o: cs_avail.h
cs_profit.o: cs_debug.h
cs_profit.o: cs_partit.h
cs_stack.o: ../share/aux.h
cs_stack.o: ../share/debug.h
cs_stack.o: ../share/global.h
cs_stack.o: ../share/types.h
cs_stack.o: cs.h
cs_stack.o: cs_aux.h
cs_vnm.o: ../share/aux.h
cs_vnm.o: ../share/debug.h
cs_vnm.o: ../share/global.h
cs_vnm.o: ../share/types.h
cs_vnm.o: cs.h
cs_vnm.o: cs_alloc.h
cs_vnm.o: cs_aux.h
cs_vnm.o: cs_avail.h
cs_vnm.o: cs_entity.h
cs_vnm.o: cs_getent.h
cs_vnm.o: cs_kill.h
cs_vnm.o: cs_partit.h
cs_vnm.o: cs_stack.h

66
util/ego/descr/Makefile Normal file
View File

@@ -0,0 +1,66 @@
EMHOME=../../..
EMH=$(EMHOME)/h
EMLIB=$(EMHOME)/lib
SHARE=../share
CPP=$(EMLIB)/cpp
LDFLAGS=
CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH)
CFLAGS=$(CPPFLAGS) -O
LINTFLAGS=-hbu
SOURCES = i86.descr m68k2.descr pdp.descr vax4.descr m68k4.descr m68020.descr \
em22.descr em24.descr em44.descr
TARGETS = i86descr m68k2descr vax4descr pdpdescr m68k4descr m68020descr \
em22descr em24descr em44descr
PRFILES = Makefile descr.sed $(SOURCES)
all: $(TARGETS)
install: all
for i in $(TARGETS) ; do ../install $$i ; done
cmp: all
-for i in $(TARGETS) ; do ../compare $$i ; done
pr:
@pr $(PRFILES)
opr:
make pr | opr
clean:
rm -f $(TARGETS) *.o Out out nohup.out
i86descr: i86.descr descr.sed
$(CPP) -P -I$(EMH) i86.descr | sed -f descr.sed > i86descr
pdpdescr: pdp.descr descr.sed
$(CPP) -P -I$(EMH) pdp.descr | sed -f descr.sed > pdpdescr
m68k2descr: m68k2.descr descr.sed
$(CPP) -P -I$(EMH) m68k2.descr | sed -f descr.sed > m68k2descr
m68k4descr: m68k4.descr descr.sed
$(CPP) -P -I$(EMH) m68k4.descr | sed -f descr.sed > m68k4descr
m68020descr: m68020.descr descr.sed
$(CPP) -P -I$(EMH) m68020.descr | sed -f descr.sed > m68020descr
vax4descr: vax4.descr descr.sed
$(CPP) -P -I$(EMH) vax4.descr | sed -f descr.sed > vax4descr
em22descr: em22.descr descr.sed
$(CPP) -P -I$(EMH) em22.descr | sed -f descr.sed > em22descr
em24descr: em24.descr descr.sed
$(CPP) -P -I$(EMH) em24.descr | sed -f descr.sed > em24descr
em44descr: em44.descr descr.sed
$(CPP) -P -I$(EMH) em44.descr | sed -f descr.sed > em44descr
sparcdescr: sparc.descr descr.sed
$(CPP) -P -I$(EMH) sparc.descr | sed -f descr.sed > sparcdescr

117
util/ego/descr/vax2.descr Normal file
View File

@@ -0,0 +1,117 @@
wordsize: 2
pointersize: 4
%%RA
general registers: 3
address registers: 4
floating point registers: 0
register score parameters:
local variable:
(2 cases)
pointer,pointer
(2 sizes)
fitbyte -> (5,2)
default -> (4,3)
general,general
(2 sizes)
fitbyte -> (3,1)
default -> (2,2)
address of local variable:
(2 cases)
pointer,pointer
(2 sizes)
fitbyte -> (0,1)
default -> (0,2)
general,pointer
(2 sizes)
fitbyte -> (0,1)
default -> (0,2)
constant:
(3 sizes)
in_0_63 -> (0,0)
fitbyte -> (0,1)
default -> (1,2)
double constant:
(1 size)
default -> (-1,-1)
address of global variable:
(1 size)
default -> (2,4)
address of procedure:
(1 size)
default -> (2,4)
opening cost parameters:
local variable:
(2 cases)
pointer
(2 sizes)
fitbyte -> (10,4)
default -> (9,5)
general
(2 sizes)
fitbyte -> (8,4)
default -> (7,5)
address of local variable:
(2 cases)
pointer
(2 sizes)
fitbyte -> (0,4)
default -> (0,5)
general
(2 sizes)
fitbyte -> (0,4)
general -> (0,5)
constant:
(3 sizes)
in_0_63 -> (4,2)
fitbyte -> (5,3)
default -> (6,4)
double constant:
(1 size)
default -> (1000,1000)
address of global variable:
(1 size)
default -> (6,7)
address of procedure:
(1 size)
default -> (6,7)
register save costs:
(9 cases)
0 -> (0,0)
1 -> (1,0)
2 -> (2,0)
3 -> (3,0)
4 -> (4,0)
5 -> (5,0)
6 -> (6,0)
7 -> (7,0)
0 -> (0,0)
%%UD
access costs of global variables:
(1 size)
default -> (7,4)
access costs of local variables:
(2 sizes)
fitbyte -> (3,1)
default -> (2,2)
%%SR
overflow harmful?: no
array bound harmful?: no
%%CS
#include "../../../h/em_mnem.h"
first time then space:
addressing modes: op_adp op_lof op_ldf op_loi op_dch op_lpb -1
op_adp op_lof op_ldf op_loi op_dch op_lpb -1
cheap operations: op_cii op_cui op_cfi op_ciu op_cff op_cuu op_cif
op_cmi op_cmf op_cmu op_cms op_cmp -1
op_cii op_cui op_cfi op_ciu op_cff op_cuu op_cif
op_cmi op_cmf op_cmu op_cms op_cmp -1
lexical tresholds: 1 1
indirection limit: 8
do sli if index?: no no
forbidden operators: -1 -1
%%SP
global stack pollution allowed?: yes

36
util/ego/em_ego/Makefile Normal file
View File

@@ -0,0 +1,36 @@
EMHOME=../../..
EMH=$(EMHOME)/h
EMLIB=$(EMHOME)/lib
MODLIB=$(EMHOME)/modules/lib
MODH=$(EMHOME)/modules/h
SHARE=../share
MODS=$(MODLIB)/libprint.a $(MODLIB)/libstring.a $(MODLIB)/libsystem.a
LDFLAGS=
CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) -I$(MODH)
CFLAGS=$(CPPFLAGS) -O
LINTFLAGS=-hbu
all: em_ego
em_ego: em_ego.o
$(CC) $(LDFLAGS) -o em_ego em_ego.o $(MODS)
install: all
rm -f $(EMLIB)/em_ego
cp em_ego $(EMLIB)/em_ego
cmp: all
-cmp em_ego $(EMLIB)/em_ego
pr:
@pr em_ego.c
opr:
make pr | opr
lint:
lint $(LINTFLAGS) $(CPPFLAGS) em_ego.c
clean:
rm -f *.o em_ego

91
util/ego/em_ego/em_ego Executable file
View File

@@ -0,0 +1,91 @@
TMP=/usr/tmp/ego
DDUMP=$TMP.dd.$$
PDUMP=$TMP.pd.$$
PHASES=''
FLAGS=''
LEVEL=xxx
EM=$1
KEEPTEMPS=no
shift
while :
do
case $# in
0) break ;;
esac
A="$1"
shift
case $A in
*.m|*.ma) ICARG="$ICARG $A"; continue;;
-P) OPT="$1"; shift; continue;;
-IL) PHASES="$PHASES il cf caopt ic cf " ; continue;;
-CS) PHASES="$PHASES cs " ; continue;;
-SR) PHASES="$PHASES sr " ; continue;;
-UD) PHASES="$PHASES ud " ; continue;;
-LV) PHASES="$PHASES lv " ; continue;;
-RA) PHASES="$PHASES ra " ; continue;;
-SP) PHASES="$PHASES sp " ; continue;;
-BO) PHASES="$PHASES bo " ; continue;;
-CJ) PHASES="$PHASES cj " ; continue;;
-O*) LEVEL=$A ; continue;;
-t) KEEPTEMPS=yes ; continue;;
-*) FLAGS="$FLAGS $A"; continue;;
esac
done
if test "$PHASES"
then :
else
case $LEVEL in
-O2|-O|xxx)PHASES='cj bo sp ' ;;
-O3) PHASES='cs sr cj bo sp ud lv ra ' ;;
*) PHASES='il cf caopt ic cf cs sr cj bo sp ud lv ra ' ;;
esac
fi
TMPOPT=$TMP.o.$$
PASSES="ic cf $PHASES ca"
OUTFILES="$PDUMP $DDUMP"
FILES="$OUTFILES $TMPOPT"
c=1
if test "$ICARG"
then :
else
exit 0
fi
for i in $PASSES
do INFILES=$OUTFILES
OUTFILES="$TMP.p.$c.$$ $TMP.d.$c.$$ $TMP.l.$c.$$ $TMP.b.$c.$$"
FILES="$FILES $OUTFILES"
if [ $KEEPTEMPS = no ]
then
trap "rm -f $FILES; exit 1" 0 1 2 15
fi
case $i in
ic) $OPT/ic $INFILES - - $OUTFILES $ICARG || exit 1
;;
ca) $OPT/ca $INFILES $PDUMP $DDUMP - - || exit 1
;;
caopt) rm -f $TMPOPT
$OPT/ca $INFILES $PDUMP $DDUMP - - | $EM/lib/em_opt2 > $TMPOPT || exit 1
ICARG=$TMPOPT
OUTFILES="$PDUMP $DDUMP"
if [ $KEEPTEMPS = no ]
then
rm -f $INFILES $PDUMP $DDUMP
fi
;;
*) $OPT/$i $INFILES $OUTFILES $FLAGS || exit 1
if [ $KEEPTEMPS = no ]
then
rm -f $INFILES
fi
;;
esac
c=`expr $c + 1`
done
if [ $KEEPTEMPS = no ]
then
rm -f $FILES
fi
trap 0
exit 0

110
util/ego/ic/Makefile Normal file
View File

@@ -0,0 +1,110 @@
EMHOME=../../..
EMH=$(EMHOME)/h
EMLIB=$(EMHOME)/lib
SHR=../share
LDFLAGS=
CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH)
CFLAGS=$(CPPFLAGS) -O
LINTFLAGS=-hbu
CFILES=\
ic.c ic_aux.c ic_lib.c ic_lookup.c ic_io.c
OFILES=\
ic.o ic_aux.o ic_lookup.o ic_io.o ic_lib.o
HFILES=\
ic.h ic_aux.h ic_lib.h ic_lookup.h ic_io.h
PRFILES=\
$(CFILES) $(HFILES) Makefile
SHARE_OFILES=\
$(SHR)/put.o $(SHR)/alloc.o $(SHR)/global.o $(SHR)/debug.o \
$(SHR)/files.o $(SHR)/map.o $(SHR)/lset.o $(SHR)/cset.o $(SHR)/aux.o
SHARE_MFILES=\
$(SHR)/put.m $(SHR)/alloc.m $(SHR)/global.m $(SHR)/debug.m \
$(SHR)/files.m $(SHR)/map.m $(SHR)/lset.m $(SHR)/cset.m $(SHR)/aux.m
all: ic
ic: $(OFILES)
$(CC) -o ic $(LDFLAGS) $(OFILES) $(SHARE_OFILES) $(EMLIB)/em_data.a
ic_ack: $(CFILES) $(SHARE_MFILES)
$(CC) -c.o $(CFLAGS) $(CFILES) $(SHARE_MFILES)
$(CC) -o ic -.c $(LDFLAGS) ic.o $(EMLIB)/em_data.a
install: all
../install ic
cmp: all
-../compare ic
clean:
rm -f *.o ic Out out nohup.out
lint:
lint $(LINTFLAGS) $(CPPFLAGS) $(CFILES)
print: $(PRFILES)
@pr $?
@touch print
pr:
@pr $(PRFILES)
opr:
make pr | opr
depend:
$(SHR)/makedepend
# the next lines are generated automatically
# AUTOAUTOAUTOAUTOAUTOAUTO
ic.o: ../share/alloc.h
ic.o: ../share/aux.h
ic.o: ../share/debug.h
ic.o: ../share/def.h
ic.o: ../share/files.h
ic.o: ../share/global.h
ic.o: ../share/map.h
ic.o: ../share/put.h
ic.o: ../share/types.h
ic.o: ic.h
ic.o: ic_aux.h
ic.o: ic_io.h
ic.o: ic_lib.h
ic.o: ic_lookup.h
ic_aux.o: ../share/alloc.h
ic_aux.o: ../share/aux.h
ic_aux.o: ../share/debug.h
ic_aux.o: ../share/def.h
ic_aux.o: ../share/global.h
ic_aux.o: ../share/types.h
ic_aux.o: ic.h
ic_aux.o: ic_aux.h
ic_aux.o: ic_io.h
ic_aux.o: ic_lookup.h
ic_io.o: ../share/alloc.h
ic_io.o: ../share/debug.h
ic_io.o: ../share/types.h
ic_io.o: ic.h
ic_io.o: ic_io.h
ic_io.o: ic_lookup.h
ic_lib.o: ../share/debug.h
ic_lib.o: ../share/files.h
ic_lib.o: ../share/global.h
ic_lib.o: ../share/types.h
ic_lib.o: ic.h
ic_lib.o: ic_io.h
ic_lib.o: ic_lib.h
ic_lib.o: ic_lookup.h
ic_lookup.o: ../share/alloc.h
ic_lookup.o: ../share/debug.h
ic_lookup.o: ../share/map.h
ic_lookup.o: ../share/types.h
ic_lookup.o: ic.h
ic_lookup.o: ic_lookup.h

175
util/ego/il/Makefile Normal file
View File

@@ -0,0 +1,175 @@
EMHOME=../../..
EMH=$(EMHOME)/h
EMLIB=$(EMHOME)/lib
SHR=../share
LDFLAGS=
CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH)
CFLAGS=$(CPPFLAGS) -O
LINTFLAGS=-hbu
CFILES=\
il.c il1_anal.c il1_cal.c il1_formal.c il1_aux.c il2_aux.c \
il3_subst.c il3_change.c il3_aux.c il_aux.c
OFILES=\
il.o il1_anal.o il1_cal.o il1_formal.o il1_aux.o il2_aux.o \
il3_change.o il3_subst.o il3_aux.o il_aux.o
HFILES=\
il.h il1_anal.h il1_cal.h il1_formal.h il1_aux.h il2_aux.h \
il3_subst.h il3_change.h il3_aux.h il_aux.h
PRFILES=\
$(CFILES) $(HFILES) Makefile
SHARE_OFILES=\
$(SHR)/get.o $(SHR)/put.o $(SHR)/alloc.o $(SHR)/global.o $(SHR)/debug.o \
$(SHR)/files.o $(SHR)/map.o $(SHR)/lset.o $(SHR)/cset.o $(SHR)/parser.o \
$(SHR)/aux.o $(SHR)/go.o
SHARE_MFILES=\
$(SHR)/get.m $(SHR)/put.m $(SHR)/alloc.m $(SHR)/global.m $(SHR)/debug.m \
$(SHR)/files.m $(SHR)/map.m $(SHR)/lset.m $(SHR)/cset.m $(SHR)/parser.m \
$(SHR)/aux.m $(SHR)/go.m
all: il
il: $(OFILES)
$(CC) -o il $(LDFLAGS) $(OFILES) $(SHARE_OFILES) $(EMLIB)/em_data.a
il_ack: $(CFILES) $(SHARE_MFILES)
$(CC) -c.o $(CFLAGS) $(CFILES) $(SHARE_MFILES)
$(CC) -o il -.c $(LDFLAGS) il.o $(EMLIB)/em_data.a
install: all
../install il
cmp: all
-../compare il
pr:
@pr $(PRFILES)
opr:
make pr | opr
clean:
rm -f il *.o Out out nohup.out
lint:
lint $(LINTFLAGS) $(CPPFLAGS) $(CFILES)
print: $(PRFILES)
@pr $?
@touch print
depend:
$(SHR)/makedepend
# the next lines are generated automatically
# AUTOAUTOAUTOAUTOAUTOAUTO
il.o: ../share/alloc.h
il.o: ../share/debug.h
il.o: ../share/files.h
il.o: ../share/get.h
il.o: ../share/global.h
il.o: ../share/go.h
il.o: ../share/lset.h
il.o: ../share/map.h
il.o: ../share/put.h
il.o: ../share/types.h
il.o: il.h
il.o: il1_anal.h
il.o: il2_aux.h
il.o: il3_subst.h
il.o: il_aux.h
il1_anal.o: ../share/alloc.h
il1_anal.o: ../share/aux.h
il1_anal.o: ../share/debug.h
il1_anal.o: ../share/global.h
il1_anal.o: ../share/lset.h
il1_anal.o: ../share/put.h
il1_anal.o: ../share/types.h
il1_anal.o: il.h
il1_anal.o: il1_anal.h
il1_anal.o: il1_aux.h
il1_anal.o: il1_cal.h
il1_anal.o: il1_formal.h
il1_anal.o: il_aux.h
il1_aux.o: ../share/alloc.h
il1_aux.o: ../share/debug.h
il1_aux.o: ../share/global.h
il1_aux.o: ../share/lset.h
il1_aux.o: ../share/types.h
il1_aux.o: il.h
il1_aux.o: il1_aux.h
il1_aux.o: il_aux.h
il1_cal.o: ../share/alloc.h
il1_cal.o: ../share/debug.h
il1_cal.o: ../share/global.h
il1_cal.o: ../share/lset.h
il1_cal.o: ../share/parser.h
il1_cal.o: ../share/types.h
il1_cal.o: il.h
il1_cal.o: il1_aux.h
il1_cal.o: il1_cal.h
il1_formal.o: ../share/alloc.h
il1_formal.o: ../share/debug.h
il1_formal.o: ../share/global.h
il1_formal.o: ../share/lset.h
il1_formal.o: ../share/types.h
il1_formal.o: il.h
il1_formal.o: il1_aux.h
il1_formal.o: il1_formal.h
il2_aux.o: ../share/alloc.h
il2_aux.o: ../share/aux.h
il2_aux.o: ../share/debug.h
il2_aux.o: ../share/get.h
il2_aux.o: ../share/global.h
il2_aux.o: ../share/lset.h
il2_aux.o: ../share/types.h
il2_aux.o: il.h
il2_aux.o: il2_aux.h
il2_aux.o: il_aux.h
il3_aux.o: ../share/alloc.h
il3_aux.o: ../share/debug.h
il3_aux.o: ../share/global.h
il3_aux.o: ../share/types.h
il3_aux.o: il.h
il3_aux.o: il3_aux.h
il3_aux.o: il_aux.h
il3_change.o: ../share/alloc.h
il3_change.o: ../share/aux.h
il3_change.o: ../share/debug.h
il3_change.o: ../share/def.h
il3_change.o: ../share/get.h
il3_change.o: ../share/global.h
il3_change.o: ../share/lset.h
il3_change.o: ../share/put.h
il3_change.o: ../share/types.h
il3_change.o: il.h
il3_change.o: il3_aux.h
il3_change.o: il3_change.h
il3_change.o: il_aux.h
il3_subst.o: ../share/alloc.h
il3_subst.o: ../share/debug.h
il3_subst.o: ../share/get.h
il3_subst.o: ../share/global.h
il3_subst.o: ../share/lset.h
il3_subst.o: ../share/types.h
il3_subst.o: il.h
il3_subst.o: il3_aux.h
il3_subst.o: il3_change.h
il3_subst.o: il3_subst.h
il3_subst.o: il_aux.h
il_aux.o: ../share/alloc.h
il_aux.o: ../share/debug.h
il_aux.o: ../share/get.h
il_aux.o: ../share/global.h
il_aux.o: ../share/lset.h
il_aux.o: ../share/map.h
il_aux.o: ../share/put.h
il_aux.o: ../share/types.h
il_aux.o: il.h
il_aux.o: il_aux.h

16
util/ego/install Executable file
View File

@@ -0,0 +1,16 @@
case $# in
1) DEST="$1" ;;
2) DEST="$2" ;;
*) echo $0 [source] destination ;;
esac
mkdir ../../../lib/ego > /dev/null 2>&1
if cp "$1" ../../../lib/ego/$DEST >/dev/null 2>&1 ||
{ rm -f ../../../lib/ego/$DEST >/dev/null 2>&1 &&
cp "$1" ../../../lib/ego/$DEST >/dev/null 2>&1
}
then
exit 0
else
echo Sorry, can not create "lib/ego/$DEST".
exit 1
fi

85
util/ego/lv/Makefile Normal file
View File

@@ -0,0 +1,85 @@
EMHOME=../../..
EMH=$(EMHOME)/h
EMLIB=$(EMHOME)/lib
SHR=../share
LDFLAGS=
CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH)
CFLAGS=$(CPPFLAGS) -O
LINTFLAGS=-hbu
CFILES=\
lv.c
OFILES=\
lv.o
HFILES=\
lv.h
PRFILES=\
$(CFILES) $(HFILES) Makefile
SHARE_OFILES=\
$(SHR)/get.o $(SHR)/aux.o $(SHR)/put.o $(SHR)/map.o $(SHR)/alloc.o \
$(SHR)/global.o $(SHR)/debug.o $(SHR)/lset.o $(SHR)/cset.o $(SHR)/parser.o \
$(SHR)/files.o $(SHR)/locals.o $(SHR)/init_glob.o $(SHR)/go.o
SHARE_MFILES=\
$(SHR)/get.m $(SHR)/aux.m $(SHR)/put.m $(SHR)/map.m $(SHR)/alloc.m \
$(SHR)/global.m $(SHR)/debug.m $(SHR)/lset.m $(SHR)/cset.m $(SHR)/parser.m \
$(SHR)/files.m $(SHR)/locals.m $(SHR)/init_glob.m $(SHR)/go.m
all: lv
lv: $(OFILES)
$(CC) -o lv $(LDFLAGS) $(OFILES) $(SHARE_OFILES) $(EMLIB)/em_data.a
lv_ack: $(CFILES) $(SHARE_MFILES)
$(CC) -c.o $(CFLAGS) $(CFILES) $(SHARE_MFILES)
$(CC) -o lv -.c $(LDFLAGS) lv.o $(EMLIB)/em_data.a
install: all
../install lv
cmp: all
-../compare lv
pr:
@pr $(PRFILES)
opr:
make pr | opr
clean:
rm -f lv *.o Out out nohup.out
lint:
lint $(LINTFLAGS) $(CPPFLAGS) $(CFILES)
print: $(PRFILES)
@pr $?
@touch print
depend:
$(SHR)/makedepend
# the next lines are generated automatically
# AUTOAUTOAUTOAUTOAUTOAUTO
lv.o: ../share/alloc.h
lv.o: ../share/aux.h
lv.o: ../share/cset.h
lv.o: ../share/debug.h
lv.o: ../share/def.h
lv.o: ../share/files.h
lv.o: ../share/get.h
lv.o: ../share/global.h
lv.o: ../share/go.h
lv.o: ../share/init_glob.h
lv.o: ../share/locals.h
lv.o: ../share/lset.h
lv.o: ../share/map.h
lv.o: ../share/parser.h
lv.o: ../share/put.h
lv.o: ../share/types.h
lv.o: lv.h

173
util/ego/ra/Makefile Normal file
View File

@@ -0,0 +1,173 @@
EMHOME=../../..
EMH=$(EMHOME)/h
EMLIB=$(EMHOME)/lib
SHR=../share
LDFLAGS=
CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH)
CFLAGS=$(CPPFLAGS) -O
LINTFLAGS=-hbu
CFILES=\
ra.c ra_items.c ra_lifet.c ra_allocl.c ra_profits.c \
ra_interv.c ra_pack.c ra_xform.c ra_aux.c
OFILES=\
ra.o ra_items.o ra_lifet.o ra_allocl.o ra_profits.o \
ra_interv.o ra_pack.o ra_xform.o ra_aux.o
HFILES=\
ra.h ra_items.h ra_lifet.h ra_allocl.h ra_profits.h \
ra_interv.h ra_pack.h ra_xform.h ra_aux.h
PRFILES=\
$(CFILES) $(HFILES) Makefile
SHARE_OFILES=\
$(SHR)/aux.o $(SHR)/get.o $(SHR)/put.o $(SHR)/alloc.o $(SHR)/global.o \
$(SHR)/debug.o $(SHR)/files.o $(SHR)/map.o $(SHR)/lset.o $(SHR)/cset.o \
$(SHR)/go.o
SHARE_MFILES=\
$(SHR)/aux.m $(SHR)/get.m $(SHR)/put.m $(SHR)/alloc.m $(SHR)/global.m \
$(SHR)/debug.m $(SHR)/files.m $(SHR)/map.m $(SHR)/lset.m $(SHR)/cset.m \
$(SHR)/go.m
all: ra
ra: $(OFILES)
$(CC) -o ra $(LDFLAGS) $(OFILES) $(SHARE_OFILES) $(EMLIB)/em_data.a
ra_ack: $(CFILES) $(SHARE_MFILES)
$(CC) -c.o $(CFLAGS) $(CFILES) $(SHARE_MFILES)
$(CC) -o ra -.c $(LDFLAGS) ra.o $(EMLIB)/em_data.a
itemtab.h: itemtab.src makeitems $(EMH)/em_mnem.h
makeitems $(EMH)/em_mnem.h itemtab.src > itemtab.h
makeitems: makeitems.c
$(CC) -o makeitems makeitems.c
install: all
../install ra
cmp: all
-../compare ra
pr:
@pr $(PRFILES)
opr:
make pr | opr
clean:
rm -f ra makeitems itemtab.h *.o Out out nohup.out
lint:
lint $(LINTFLAGS) $(CPPFLAGS) $(CFILES)
print: $(PRFILES)
@pr $?
@touch print
depend:
$(SHR)/makedepend
# the next lines are generated automatically
# AUTOAUTOAUTOAUTOAUTOAUTO
ra.o: ../share/alloc.h
ra.o: ../share/debug.h
ra.o: ../share/files.h
ra.o: ../share/get.h
ra.o: ../share/global.h
ra.o: ../share/go.h
ra.o: ../share/lset.h
ra.o: ../share/map.h
ra.o: ../share/put.h
ra.o: ../share/types.h
ra.o: ra.h
ra.o: ra_allocl.h
ra.o: ra_items.h
ra.o: ra_pack.h
ra.o: ra_profits.h
ra.o: ra_xform.h
ra_allocl.o: ../share/alloc.h
ra_allocl.o: ../share/aux.h
ra_allocl.o: ../share/cset.h
ra_allocl.o: ../share/debug.h
ra_allocl.o: ../share/def.h
ra_allocl.o: ../share/global.h
ra_allocl.o: ../share/lset.h
ra_allocl.o: ../share/map.h
ra_allocl.o: ../share/types.h
ra_allocl.o: ra.h
ra_allocl.o: ra_allocl.h
ra_allocl.o: ra_aux.h
ra_allocl.o: ra_interv.h
ra_allocl.o: ra_items.h
ra_aux.o: ../share/alloc.h
ra_aux.o: ../share/debug.h
ra_aux.o: ../share/def.h
ra_aux.o: ../share/global.h
ra_aux.o: ../share/lset.h
ra_aux.o: ../share/types.h
ra_aux.o: ra.h
ra_aux.o: ra_aux.h
ra_interv.o: ../share/alloc.h
ra_interv.o: ../share/debug.h
ra_interv.o: ../share/global.h
ra_interv.o: ../share/lset.h
ra_interv.o: ../share/types.h
ra_interv.o: ra.h
ra_interv.o: ra_interv.h
ra_items.o: ../share/alloc.h
ra_items.o: ../share/aux.h
ra_items.o: ../share/debug.h
ra_items.o: ../share/def.h
ra_items.o: ../share/global.h
ra_items.o: ../share/lset.h
ra_items.o: ../share/types.h
ra_items.o: itemtab.h
ra_items.o: ra.h
ra_items.o: ra_aux.h
ra_items.o: ra_items.h
ra_lifet.o: ../share/alloc.h
ra_lifet.o: ../share/aux.h
ra_lifet.o: ../share/debug.h
ra_lifet.o: ../share/def.h
ra_lifet.o: ../share/global.h
ra_lifet.o: ../share/lset.h
ra_lifet.o: ../share/types.h
ra_lifet.o: ra.h
ra_lifet.o: ra_aux.h
ra_lifet.o: ra_items.h
ra_lifet.o: ra_lifet.h
ra_pack.o: ../share/alloc.h
ra_pack.o: ../share/aux.h
ra_pack.o: ../share/cset.h
ra_pack.o: ../share/debug.h
ra_pack.o: ../share/def.h
ra_pack.o: ../share/global.h
ra_pack.o: ../share/lset.h
ra_pack.o: ../share/types.h
ra_pack.o: ra.h
ra_pack.o: ra_aux.h
ra_pack.o: ra_interv.h
ra_profits.o: ../share/debug.h
ra_profits.o: ../share/global.h
ra_profits.o: ../share/lset.h
ra_profits.o: ../share/types.h
ra_profits.o: ra.h
ra_profits.o: ra_aux.h
ra_profits.o: ra_profits.h
ra_xform.o: ../share/alloc.h
ra_xform.o: ../share/aux.h
ra_xform.o: ../share/debug.h
ra_xform.o: ../share/def.h
ra_xform.o: ../share/global.h
ra_xform.o: ../share/lset.h
ra_xform.o: ../share/types.h
ra_xform.o: ra.h
ra_xform.o: ra_interv.h
ra_xform.o: ra_items.h
ra_xform.o: ra_xform.h

11
util/ego/share/makedepend Executable file
View File

@@ -0,0 +1,11 @@
for file in *.c
do ofile=`basename $file .c`.o
grep '^# *include.*"' $file|sed "s/.*\"\(.*\)\".*/$ofile: \1/"
done | sort -u >depend
ed - Makefile <<'!'
/AUTOAUTOAUTO/+,$d
$r depend
w
q
!
rm depend

10
util/ego/share/makewlen.c Normal file
View File

@@ -0,0 +1,10 @@
/* $Header$ */
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
main()
{
printf("#define WORDLENGTH %d\n",sizeof(int) * 8);
exit(0);
}

79
util/ego/sp/Makefile Normal file
View File

@@ -0,0 +1,79 @@
EMHOME=../../..
EMH=$(EMHOME)/h
EMLIB=$(EMHOME)/lib
SHR=../share
LDFLAGS=
CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH)
CFLAGS=$(CPPFLAGS) -O
LINTFLAGS=-hbu
CFILES=\
sp.c
OFILES=\
sp.o
HFILES=
PRFILES=\
$(CFILES) $(HFILES) Makefile
SHARE_OFILES=\
$(SHR)/get.o $(SHR)/put.o $(SHR)/alloc.o $(SHR)/global.o $(SHR)/debug.o \
$(SHR)/files.o $(SHR)/map.o $(SHR)/lset.o $(SHR)/cset.o $(SHR)/aux.o \
$(SHR)/stack_chg.o $(SHR)/go.o
SHARE_MFILES=\
$(SHR)/get.m $(SHR)/put.m $(SHR)/alloc.m $(SHR)/global.m $(SHR)/debug.m \
$(SHR)/files.m $(SHR)/map.m $(SHR)/lset.m $(SHR)/cset.m $(SHR)/aux.m \
$(SHR)/stack_chg.m $(SHR)/go.m
all: sp
sp: $(OFILES)
$(CC) -o sp $(LDFLAGS) $(OFILES) $(SHARE_OFILES) $(EMLIB)/em_data.a
sp_ack: $(CFILES) $(SHARE_MFILES)
$(CC) -c.o $(CFLAGS) $(CFILES) $(SHARE_MFILES)
$(CC) -o sp -.c $(LDFLAGS) sp.o $(EMLIB)/em_data.a
install: all
../install sp
cmp: all
-../compare sp
pr:
@pr $(PRFILES)
opr:
make pr | opr
clean:
rm -f sp *.o Out out nohup.out
lint:
lint $(LINTFLAGS) $(CPPFLAGS) $(CFILES)
print: $(PRFILES)
@pr $?
@touch print
depend:
$(SHR)/makedepend
# the next lines are generated automatically
# AUTOAUTOAUTOAUTOAUTOAUTO
sp.o: ../share/alloc.h
sp.o: ../share/aux.h
sp.o: ../share/debug.h
sp.o: ../share/files.h
sp.o: ../share/get.h
sp.o: ../share/global.h
sp.o: ../share/go.h
sp.o: ../share/lset.h
sp.o: ../share/map.h
sp.o: ../share/put.h
sp.o: ../share/stack_chg.h
sp.o: ../share/types.h

142
util/ego/sr/Makefile Normal file
View File

@@ -0,0 +1,142 @@
EMHOME=../../..
EMH=$(EMHOME)/h
EMLIB=$(EMHOME)/lib
SHR=../share
LDFLAGS=
CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH)
CFLAGS=$(CPPFLAGS) -O
LINTFLAGS=-hbu
CFILES=\
sr.c sr_iv.c sr_reduce.c sr_cand.c sr_xform.c sr_expr.c sr_aux.c
OFILES=\
sr.o sr_expr.o sr_reduce.o sr_iv.o sr_cand.o sr_xform.o sr_aux.o
HFILES=\
sr.h sr_iv.h sr_reduce.h sr_cand.h sr_xform.h sr_expr.h sr_aux.h
PRFILES=\
$(CFILES) $(HFILES) Makefile
SHARE_OFILES=\
$(SHR)/get.o $(SHR)/put.o $(SHR)/alloc.o $(SHR)/global.o $(SHR)/debug.o \
$(SHR)/files.o $(SHR)/map.o $(SHR)/lset.o $(SHR)/cset.o $(SHR)/aux.o \
$(SHR)/go.o
SHARE_MFILES=\
$(SHR)/get.m $(SHR)/put.m $(SHR)/alloc.m $(SHR)/global.m $(SHR)/debug.m \
$(SHR)/files.m $(SHR)/map.m $(SHR)/lset.m $(SHR)/cset.m $(SHR)/aux.m \
$(SHR)/go.m
all: sr
sr: $(OFILES)
$(CC) -o sr $(LDFLAGS) $(OFILES) $(SHARE_OFILES) $(EMLIB)/em_data.a
sr_ack: $(CFILES) $(SHARE_MFILES)
$(CC) -c.o $(CFLAGS) $(CFILES) $(SHARE_MFILES)
$(CC) -o sr -.c $(LDFLAGS) sr.o $(EMLIB)/em_data.a
install: all
../install sr
cmp: all
-../compare sr
pr:
@pr $(PRFILES)
opr:
make pr | opr
clean:
rm -f sr *.o Out out nohup.out
lint:
lint $(LINTFLAGS) $(CPPFLAGS) $(CFILES)
print: $(PRFILES)
@pr $?
@touch print
depend:
$(SHR)/makedepend
# the next lines are generated automatically
# AUTOAUTOAUTOAUTOAUTOAUTO
sr.o: ../share/alloc.h
sr.o: ../share/aux.h
sr.o: ../share/debug.h
sr.o: ../share/files.h
sr.o: ../share/get.h
sr.o: ../share/global.h
sr.o: ../share/go.h
sr.o: ../share/lset.h
sr.o: ../share/map.h
sr.o: ../share/put.h
sr.o: ../share/types.h
sr.o: sr.h
sr.o: sr_aux.h
sr.o: sr_iv.h
sr_aux.o: ../share/aux.h
sr_aux.o: ../share/debug.h
sr_aux.o: ../share/global.h
sr_aux.o: ../share/lset.h
sr_aux.o: ../share/types.h
sr_aux.o: sr.h
sr_aux.o: sr_aux.h
sr_aux.o: sr_xform.h
sr_cand.o: ../share/aux.h
sr_cand.o: ../share/cset.h
sr_cand.o: ../share/debug.h
sr_cand.o: ../share/global.h
sr_cand.o: ../share/lset.h
sr_cand.o: ../share/map.h
sr_cand.o: ../share/types.h
sr_cand.o: sr.h
sr_cand.o: sr_aux.h
sr_cand.o: sr_cand.h
sr_expr.o: ../share/aux.h
sr_expr.o: ../share/debug.h
sr_expr.o: ../share/global.h
sr_expr.o: ../share/lset.h
sr_expr.o: ../share/types.h
sr_expr.o: sr.h
sr_expr.o: sr_aux.h
sr_expr.o: sr_iv.h
sr_iv.o: ../share/alloc.h
sr_iv.o: ../share/aux.h
sr_iv.o: ../share/cset.h
sr_iv.o: ../share/debug.h
sr_iv.o: ../share/global.h
sr_iv.o: ../share/lset.h
sr_iv.o: ../share/types.h
sr_iv.o: sr.h
sr_iv.o: sr_aux.h
sr_iv.o: sr_cand.h
sr_iv.o: sr_iv.h
sr_reduce.o: ../share/alloc.h
sr_reduce.o: ../share/aux.h
sr_reduce.o: ../share/debug.h
sr_reduce.o: ../share/def.h
sr_reduce.o: ../share/global.h
sr_reduce.o: ../share/lset.h
sr_reduce.o: ../share/types.h
sr_reduce.o: sr.h
sr_reduce.o: sr_aux.h
sr_reduce.o: sr_expr.h
sr_reduce.o: sr_reduce.h
sr_reduce.o: sr_xform.h
sr_xform.o: ../share/alloc.h
sr_xform.o: ../share/aux.h
sr_xform.o: ../share/debug.h
sr_xform.o: ../share/def.h
sr_xform.o: ../share/get.h
sr_xform.o: ../share/global.h
sr_xform.o: ../share/lset.h
sr_xform.o: ../share/types.h
sr_xform.o: sr.h
sr_xform.o: sr_aux.h
sr_xform.o: sr_xform.h

136
util/ego/ud/Makefile Normal file
View File

@@ -0,0 +1,136 @@
EMHOME=../../..
EMH=$(EMHOME)/h
EMLIB=$(EMHOME)/lib
SHR=../share
LDFLAGS=
CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH)
CFLAGS=$(CPPFLAGS) -O
LINTFLAGS=-hbu
CFILES=\
ud.c ud_defs.c ud_const.c ud_copy.c ud_aux.c
OFILES=\
ud.o ud_const.o ud_copy.o ud_aux.o ud_defs.o
HFILES=\
ud.h ud_defs.h ud_const.h ud_copy.h ud_aux.h
PRFILES=\
$(CFILES) $(HFILES) Makefile
SHARE_OFILES=\
$(SHR)/get.o $(SHR)/put.o $(SHR)/map.o $(SHR)/alloc.o $(SHR)/global.o \
$(SHR)/debug.o $(SHR)/lset.o $(SHR)/cset.o $(SHR)/files.o $(SHR)/aux.o \
$(SHR)/locals.o $(SHR)/init_glob.o $(SHR)/go.o
SHARE_MFILES=\
$(SHR)/get.m $(SHR)/put.m $(SHR)/map.m $(SHR)/alloc.m $(SHR)/global.m \
$(SHR)/debug.m $(SHR)/lset.m $(SHR)/cset.m $(SHR)/files.m $(SHR)/aux.m \
$(SHR)/locals.m $(SHR)/init_glob.m $(SHR)/go.m
all: ud
ud: $(OFILES)
$(CC) -o ud $(LDFLAGS) $(OFILES) $(SHARE_OFILES) $(EMLIB)/em_data.a
ud_ack: $(CFILES) $(SHARE_MFILES)
$(CC) -c.o $(CFLAGS) $(CFILES) $(SHARE_MFILES)
$(CC) -o ud -.c $(LDFLAGS) ud.o $(EMLIB)/em_data.a
install: all
../install ud
cmp: all
-../compare ud
pr:
@pr $(PRFILES)
opr:
make pr | opr
clean:
rm -f ud *.o Out out nohup.out
lint:
lint $(LINTFLAGS) $(CPPFLAGS) $(CFILES)
print: $(PRFILES)
@pr $?
@touch print
depend:
$(SHR)/makedepend
# the next lines are generated automatically
# AUTOAUTOAUTOAUTOAUTOAUTO
ud.o: ../share/alloc.h
ud.o: ../share/aux.h
ud.o: ../share/cset.h
ud.o: ../share/debug.h
ud.o: ../share/def.h
ud.o: ../share/files.h
ud.o: ../share/get.h
ud.o: ../share/global.h
ud.o: ../share/go.h
ud.o: ../share/init_glob.h
ud.o: ../share/locals.h
ud.o: ../share/lset.h
ud.o: ../share/map.h
ud.o: ../share/put.h
ud.o: ../share/types.h
ud.o: ud.h
ud.o: ud_const.h
ud.o: ud_copy.h
ud.o: ud_defs.h
ud_aux.o: ../share/alloc.h
ud_aux.o: ../share/aux.h
ud_aux.o: ../share/cset.h
ud_aux.o: ../share/debug.h
ud_aux.o: ../share/def.h
ud_aux.o: ../share/global.h
ud_aux.o: ../share/locals.h
ud_aux.o: ../share/lset.h
ud_aux.o: ../share/types.h
ud_aux.o: ud.h
ud_aux.o: ud_defs.h
ud_const.o: ../share/alloc.h
ud_const.o: ../share/aux.h
ud_const.o: ../share/cset.h
ud_const.o: ../share/debug.h
ud_const.o: ../share/def.h
ud_const.o: ../share/global.h
ud_const.o: ../share/locals.h
ud_const.o: ../share/lset.h
ud_const.o: ../share/types.h
ud_const.o: ud.h
ud_const.o: ud_aux.h
ud_const.o: ud_const.h
ud_const.o: ud_defs.h
ud_copy.o: ../share/alloc.h
ud_copy.o: ../share/aux.h
ud_copy.o: ../share/cset.h
ud_copy.o: ../share/debug.h
ud_copy.o: ../share/def.h
ud_copy.o: ../share/global.h
ud_copy.o: ../share/locals.h
ud_copy.o: ../share/lset.h
ud_copy.o: ../share/types.h
ud_copy.o: ../ud/ud_defs.h
ud_copy.o: ud.h
ud_copy.o: ud_aux.h
ud_copy.o: ud_const.h
ud_copy.o: ud_copy.h
ud_defs.o: ../share/alloc.h
ud_defs.o: ../share/aux.h
ud_defs.o: ../share/cset.h
ud_defs.o: ../share/debug.h
ud_defs.o: ../share/global.h
ud_defs.o: ../share/locals.h
ud_defs.o: ../share/lset.h
ud_defs.o: ../share/map.h
ud_defs.o: ../share/types.h
ud_defs.o: ud.h
ud_defs.o: ud_defs.h

23
util/ego/ud/ud_locals.h Normal file
View File

@@ -0,0 +1,23 @@
/* $Header$ */
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* U S E - D E F I N I T I O N A N A L Y S I S
*
* U D _ L O C A L S . H
*/
extern local_p *locals; /* table of locals, index is local-number */
extern short nrlocals; /* number of locals for which we keep ud-info */
extern make_localtab(); /* (proc_p p)
* Analyse the text of procedure p to determine
* which local variable p has. Make a table of
* these variables ('locals') and count them
* ('nrlocals'). Also collect register messages.
*/
extern var_nr(); /* (line_p l; short *nr_out;bool *found_out)
* Compute the 'variable number' of the
* variable referenced by EM instruction l.
*/

158
util/flex/makefile Normal file
View File

@@ -0,0 +1,158 @@
# Note: this is a modified version of Makefile, for ACK installation. The
# original flex makefile has a capital M (Makefile).
EMHOME = ../..
# make file for "flex" tool
# Porting considerations:
#
# For System V Unix machines, add -DUSG to CFLAGS (if it's not
# automatically defined)
# For Vax/VMS, add "-DVMS -DUSG" to CFLAGS.
# For MS-DOS, add "-DMS_DOS -DUSG" to CFLAGS. Create \tmp if not present.
# You will also want to rename flex.skel to something with a three
# character extension, change SKELETON_FILE below appropriately,
# See MSDOS.notes for more info.
# For Amiga, add "-DAMIGA -DUSG" to CFLAGS.
# For SCO Unix, add "-DSCO_UNIX" to CFLAGS.
#
# For C compilers which don't know about "void", add -Dvoid=int to CFLAGS.
#
# If your C compiler is ANSI standard but does not include the <stdlib.h>
# header file (some installations of gcc have this problem), then add
# -DDONT_HAVE_STDLIB_H to CFLAGS.
#
# By default, flex will be configured to generate 8-bit scanners only
# if the -8 flag is given. If you want it to always generate 8-bit
# scanners, add "-DDEFAULT_CSIZE=256" to CFLAGS. Note that doing
# so will double the size of all uncompressed scanners.
#
# If on your system you have trouble building flex due to 8-bit
# character problems, remove the -8 from FLEX_FLAGS and the
# "#define FLEX_8_BIT_CHARS" from the beginning of flexdef.h.
# the first time around use "make first_flex"
# Installation targeting. Files will be installed under the tree rooted
# at DESTDIR. User commands will be installed in BINDIR, library files
# in LIBDIR (which will be created if necessary), auxiliary files in
# AUXDIR, manual pages will be installed in MANDIR with extension MANEXT.
# Raw, unformatted troff source will be installed if INSTALLMAN=man, nroff
# preformatted versions will be installed if INSTALLMAN=cat.
DESTDIR =
BINDIR = $(EMHOME)/bin
AUXDIR = $(EMHOME)/lib/flex
MANDIR = $(EMHOME)/man
MANEXT = 1
INSTALLMAN = man
# MAKE = make
SKELETON_FILE = \"`cd $(AUXDIR); pwd`/flex.skel\"
SKELFLAGS = -DDEFAULT_SKELETON_FILE=$(SKELETON_FILE)
CFLAGS = -O -Dvoid=int -DACK_MOD
LDFLAGS = -s
COMPRESSION =
FLEX_FLAGS = -ist8 -Sflex.skel
# which "flex" to use to generate scan.c from scan.l
FLEX = ./flex
# CC = cc
AR = ar
RANLIB = ranlib
FLEXOBJS = \
ccl.o \
dfa.o \
ecs.o \
gen.o \
main.o \
misc.o \
nfa.o \
parse.o \
scan.o \
sym.o \
tblcmp.o \
yylex.o
FLEX_C_SOURCES = \
ccl.c \
dfa.c \
ecs.c \
gen.c \
main.c \
misc.c \
nfa.c \
parse.c \
scan.c \
sym.c \
tblcmp.c \
yylex.c
all : flex
flex : $(FLEXOBJS)
$(CC) $(CFLAGS) -o flex $(LDFLAGS) $(FLEXOBJS)
first_flex:
cp initscan.c scan.c
$(MAKE) $(MFLAGS) flex
parse.h parse.c : parse.y
$(YACC) -d parse.y
@mv y.tab.c parse.c
@mv y.tab.h parse.h
scan.c : scan.l
$(FLEX) $(FLEX_FLAGS) $(COMPRESSION) scan.l >scan.c
scan.o : scan.c parse.h flexdef.h
main.o : main.c flexdef.h
-mkdir $(AUXDIR)
$(CC) $(CFLAGS) -c $(SKELFLAGS) main.c
ccl.o : ccl.c flexdef.h
dfa.o : dfa.c flexdef.h
ecs.o : ecs.c flexdef.h
gen.o : gen.c flexdef.h
misc.o : misc.c flexdef.h
nfa.o : nfa.c flexdef.h
parse.o : parse.c flexdef.h
sym.o : sym.c flexdef.h
tblcmp.o : tblcmp.c flexdef.h
yylex.o : yylex.c flexdef.h
lint : $(FLEX_C_SOURCES)
lint $(FLEX_C_SOURCES) > flex.lint
install: first_flex flex.skel
rm -f $(BINDIR)flex
cp flex $(BINDIR)/flex
cp flex.skel $(AUXDIR)/flex.skel
cp flex.1 $(MANDIR)/flex.1
cp flexdoc.1 $(MANDIR)/flexdoc.1
clean :
rm -f core errs flex *.o parse.c *.lint parse.h tags
tags :
ctags $(FLEX_C_SOURCES)
test : flex
./flex $(FLEX_FLAGS) $(COMPRESSION) scan.l | diff scan.c -
bigtest :
rm -f scan.c ; $(MAKE) COMPRESSION="-C" test
rm -f scan.c ; $(MAKE) COMPRESSION="-Ce" test
rm -f scan.c ; $(MAKE) COMPRESSION="-Cm" test
rm -f scan.c ; $(MAKE) COMPRESSION="-Cfe" test
rm -f scan.c ; $(MAKE) COMPRESSION="-CFe" test
rm -f scan.c ; $(MAKE) COMPRESSION="-Cf" test
rm -f scan.c ; $(MAKE) COMPRESSION="-CF" test
rm -f scan.c ; $(MAKE)

127
util/grind/Amakefile Normal file
View File

@@ -0,0 +1,127 @@
AMAKELIB = { . , /usr/local/lib/amake } ;
%include std-amake.amk ;
%include ack-defs.amk ;
%include cc_hh_tools.amk ;
%include tok_tools.amk ;
%include op_tools.amk ;
%include char_tools.amk ;
%default grind ;
%declare tokenname.c [
gen_tokens,
cc-dest = symbol2str.c,
LL-dest = tokenfile.g
];
CMD_LLSRC = {
tokenname.c,
commands.g
} ;
CSRC = {
main.c,
list.c,
tree.c,
expr.c,
position.c,
idf.c,
run.c,
symbol.c,
print.c,
type.c,
rd.c,
do_comm.c,
modula-2.c,
pascal.c,
c.c
} ;
HSRC = {
tokenname.h,
operator.h,
class.h,
position.h,
idf.h,
message.h,
avl.h,
scope.h,
langdep.h,
sizes.h,
token.h,
expr.h,
rd.h
} ;
HHSRC = {
file.hh,
type.hh,
symbol.hh,
tree.hh,
avl.cc,
scope.cc,
itemlist.cc,
langdep.cc
} ;
LIBRARIES = {
$EMHOME/modules/lib/libassert.a,
$EMHOME/modules/lib/liballoc.a,
$EMHOME/modules/lib/malloc.o,
$EMHOME/modules/lib/libstring.a,
$EMHOME/modules/lib/libobject.a,
$EMHOME/modules/lib/libsystem.a
} ;
DBFLAGS = { -O, -DDEBUG } ;
PROFFLAGS = { } ;
LDFLAGS = {
-Bstatic,
$PROFFLAGS,
$DBFLAGS
} ;
INCLUDES = {
-I$EMHOME/modules/h,
-I$EMHOME/modules/pkg,
-I$EMHOME/h
} ;
CFLAGS = {
$INCLUDES,
$PROFFLAGS,
$DBFLAGS
} ;
DBS_LLTARGETS = {
db_symtab.c,
DBSpars.c,
DBSpars.h
} ;
DBS_LLSRC = {
db_symtab.g
} ;
%cluster {
%targets $DBS_LLTARGETS ;
%sources $DBS_LLSRC ;
%use LLgen(prefix => DBS) ;
} ;
LINTFLAGS = {
$INCLUDES
} ;
%cluster {
%targets lint.out[type = lint-output];
%sources $CSRC + $CMD_LLSRC + $DBS_LLTARGETS + $HHSRC + char.ct + operators.ot ;
%use lint(realdest => lint.out) ;
} ;
%cluster {
%targets grind[type = program];
%sources $CSRC + $CMD_LLSRC + $DBS_LLTARGETS + $HHSRC + char.ct + operators.ot ;
} ;

39
util/grind/LLgen.amk Normal file
View File

@@ -0,0 +1,39 @@
# LLgen: LL(1) parser generator
# variables: LLGEN, LLFLAGS
# tool definition for the new version of LLgen that allows for more than
# one parser in one program. Unfortunately, for historical reasons there
# is no proper default prefix for LLgen-generated files (LL.output versus
# Lpars.[ch]). If LLgen would generate LLpars.[ch] instead of Lpars.[ch],
# we could have a default value for prefix of 'LL', which would make
# things a bit more simple.
%instance deftypesuffix(LLgen-src, '%.g') ;
%include ack-defs.amk;
%if (%not defined(LLGEN), {
LLGEN = $EMHOME/bin/LLgen;
});
%if (%not defined(LLFLAGS), {
LLFLAGS = {};
});
%tool LLgen (
verbose: %boolean => %false;
flags: %string %list => $LLFLAGS;
prefix: %string => '';
src: %in %list [type = LLgen-src];
parser: %out %list [type = C-src]
=> match($src) + if($prefix == '', Lpars.c, $prefix'pars.c');
tokens: %out [type = C-incl, compare]
=> if($prefix == '', Lpars.h, $prefix'pars.h');
diagn: %out [type = text]
=> if($prefix == '', LL.output, $prefix.output) %conform $verbose;
cmd: %in [type = command] => $LLGEN;
)
{
exec($cmd, args => if($verbose, {'-vvv'}, {}) + $flags + $src);
echo({'LLgen ', $src, ' done'});
};

5
util/grind/ack-defs.amk Normal file
View File

@@ -0,0 +1,5 @@
# definition of EMHOME
%if (%not defined(EMHOME), {
EMHOME = /usr/proj/em/Work;
});

View File

@@ -0,0 +1,43 @@
%instance deftypesuffix(hh-src, '%.hh') ;
%instance deftypesuffix(cc-src, '%.cc') ;
ALLOCD = make.allocd;
NEXT = make.next;
%tool allochd (
hhsrc: %in [type = hh-src, persistent];
hsrc: %out [type = C-incl] => match($hhsrc);
prog: %in [type = command] => $ALLOCD;
)
{
exec($prog, stdin => $hhsrc, stdout => $hsrc);
echo({$hsrc ,'created'});
};
%tool alloccd (
ccsrc: %in [type = cc-src, persistent];
csrc: %out [type = C-src] => match($ccsrc);
prog: %in [type = command] => $ALLOCD;
)
{
exec($prog, stdin => $ccsrc, stdout => $csrc);
echo({$csrc ,'created'});
};
# Possibly there's only one type of { cc-src, hh-src } available,
# so introduce a new attribute.
%derive f[cc-or-hh-src] %when get($f, type) == cc-src
%or get($f, type) == hh-src;
%tool mknext (
cchhsrc: %in %list [cc-or-hh-src];
next: %out [type = C-src] => next.c;
prog: %in [type = command] => $NEXT;
)
{
exec($prog, args => $cchhsrc, stdout => $next);
echo({$next ,'created'});
};

24
util/grind/char_tools.amk Normal file
View File

@@ -0,0 +1,24 @@
# tabgen: tool definition for character table generator
# variables: TABGEN, CHTAB
%include ack-defs.amk;
%if (%not defined(TABGEN), {
TABGEN = $EMHOME/bin/tabgen;
});
%if (%not defined(CHTAB), {
CHTAB = chtab.c;
});
%instance deftypesuffix(char_tab, '%.ct');
%tool gen_tab (
chtab: %in [type = char_tab];
cfile: %out [type = C-src] => $CHTAB;
mktab: %in [type = command] => $TABGEN;
)
{
exec($mktab, args => '-f' $chtab, stdout => $cfile);
echo({$cfile, 'created'});
};

709
util/grind/dbx_string.g Normal file
View File

@@ -0,0 +1,709 @@
/* $Header$
Grammar of a string of a debugger symbol table entry.
*/
{
#include <out.h>
#include <alloc.h>
#include "type.h"
#include "symbol.h"
#include "scope.h"
#include "class.h"
#include "idf.h"
extern char *strindex();
extern long str2long();
extern double atof();
extern int saw_code;
extern long pointer_size;
static char *DbxPtr; /* current pointer in DBX string */
static int AllowName; /* set if NAME legal at this point */
static long ival;
static double fval;
static char *strval;
static int last_index[2];
static struct outname *currnam;
static struct literal *get_literal_space();
static struct fields *get_field_space();
static end_field();
static char *string_val();
}
%start DbxParser, debugger_string;
%prefix DBS;
%lexical DBSlex;
%onerror DBSonerror;
%token INTEGER, REAL, STRING, NAME;
debugger_string
{ register p_symbol s;
char *str;
p_type tmp = 0;
}
:
name(&str)
[ /* constant name */
{ s = NewSymbol(str, CurrentScope, CONST, currnam); }
'c' const_name(s)
| /* type name */
{ s = NewSymbol(str, CurrentScope, TYPE, currnam); }
't' type_name(&(s->sy_type), s)
{ if (! s->sy_type->ty_sym) s->sy_type->ty_sym = s;
if ((s->sy_type->ty_class == T_ENUM ||
s->sy_type->ty_class == T_SUBRANGE) &&
currnam->on_desc != 0) {
s->sy_type->ty_size = currnam->on_desc;
}
}
| /* tag name (only C?) */
{ s = NewSymbol(str, CurrentScope, TAG, currnam); }
'T' type_name(&(s->sy_type), s)
{ if (! s->sy_type->ty_sym) s->sy_type->ty_sym = s;
if (s->sy_type->ty_class != T_CROSS) {
resolve_cross(s->sy_type);
}
}
| /* end scope */
'E' INTEGER
{ close_scope(); }
| /* module begin */
{ s = NewSymbol(str, CurrentScope, MODULE, currnam); }
'M' INTEGER
{ open_scope(s, 1);
s->sy_name.nm_scope = CurrentScope;
CurrentScope->sc_start = currnam->on_valu;
CurrentScope->sc_proclevel = currnam->on_desc;
add_scope_addr(CurrentScope);
}
| /* external procedure */
{ s = NewSymbol(str, FileScope, PROC, currnam); }
'P' routine(s)
| /* private procedure */
{ s = NewSymbol(str, CurrentScope, PROC, currnam); }
'Q' routine(s)
| /* external function */
{ s = NewSymbol(str, FileScope, FUNCTION, currnam); }
'F' function(s)
| /* private function */
{ s = NewSymbol(str, CurrentScope, FUNCTION, currnam); }
'f' function(s)
| /* global variable, external */
/* maybe we already know it; but we need
the type information anyway for other
types.
*/
{ s = Lookup(findidf(str), FileScope, VAR);
if (s) {
tmp = s->sy_type;
s->sy_type = 0;
} else s = NewSymbol(str, FileScope, VAR, currnam);
}
'G' type(&(s->sy_type), (int *) 0, s)
{ if (tmp) s->sy_type = tmp; }
| /* static variable */
{ s = NewSymbol(str, CurrentScope, VAR, currnam); }
'S' type(&(s->sy_type), (int *) 0, s)
| /* static variable, local scope */
{ s = NewSymbol(str, CurrentScope, VAR, currnam); }
'V' type(&(s->sy_type), (int *) 0, s)
| /* register variable */
{ s = NewSymbol(str, CurrentScope, REGVAR, currnam); }
'r' type(&(s->sy_type), (int *) 0, s)
| /* value parameter */
{ s = NewSymbol(str, CurrentScope, LOCVAR, currnam); }
'p' type(&(s->sy_type), (int *) 0, s)
{ add_param_type('p', s); }
| /* value parameter but address passed */
{ s = NewSymbol(str, CurrentScope, VARPAR, currnam); }
'i' type(&(s->sy_type), (int *) 0, s)
{ add_param_type('i', s); }
| /* variable parameter */
{ s = NewSymbol(str, CurrentScope, VARPAR, currnam); }
'v' type(&(s->sy_type), (int *) 0, s)
{ add_param_type('v', s); }
| /* local variable */
{ s = NewSymbol(str, CurrentScope, LOCVAR, currnam); }
type_name(&(s->sy_type), s)
| /* function result in Pascal; ignore ??? */
{ s = NewSymbol(str, CurrentScope, LOCVAR, currnam); }
'X' type_name(&(s->sy_type), s)
]
';'?
;
name(char **s;)
:
/* anything up to a ':' */
NAME { *s = strval; }
;
const_name(p_symbol cst;)
{ int type_index[2];
long iconst;
register char *p;
}
:
'='
[
/*
'b' integer_const(&(cst->sy_const.co_ival)) /* boolean */
/* |
*/
'c' integer_const(&(cst->sy_const.co_ival)) /* character */
{ cst->sy_type = char_type; }
|
'i' integer_const(&(cst->sy_const.co_ival)) /* integer */
{ cst->sy_type = long_type; }
|
'r' real_const(&(cst->sy_const.co_rval)) /* real */
{ cst->sy_type = double_type; }
|
's' string_const /* string */
{ cst->sy_const.co_sval = string_val(strval);
cst->sy_type = string_type;
}
|
'e' type_index(type_index) ',' integer_const(&(cst->sy_const.co_ival))
/* enumeration constant;
* enumeration type, value
*/
{ cst->sy_type = *tp_lookup(type_index); }
|
'S' type_index(type_index)
{ cst->sy_type = *tp_lookup(type_index);
cst->sy_const.co_setval = p =
Malloc((unsigned) cst->sy_type->ty_size);
}
[ ',' integer_const(&iconst)
{ *p++ = iconst; }
]+
/* set constant:
* settype, values of the bytes
* in the set.
*/
]
;
integer_const(long *iconst;)
{ int sign = 0; }
:
[ '+' | '-' { sign = 1; } ]?
INTEGER { *iconst = sign ? -ival : ival; }
;
real_const(double *f;)
{ int sign = 0; }
:
[ '+' | '-' { sign = 1; } ]?
REAL { *f = sign ? fval : -fval; }
;
string_const
:
STRING /* has SINGLE quotes! */
;
type_name(p_type *t; p_symbol sy;)
{ int type_index[2]; p_type *p; }
:
type_index(type_index) { p = tp_lookup(type_index); }
[
{ if (*p && (*p)->ty_class != 0 &&
(*p)->ty_class != T_CROSS) {
error("Redefining (%d,%d) %d",
type_index[0],
type_index[1],
(*p)->ty_class);
}
}
'='
type(p, type_index, sy)
|
]
{ if (*p == 0) *p = new_type();
*t = *p;
}
;
type_index(int *type_index;)
:
[
INTEGER { type_index[0] = 0; type_index[1] = ival; }
|
'(' INTEGER { type_index[0] = ival; }
',' INTEGER { type_index[1] = ival; }
')'
]
{ last_index[0] = type_index[0];
last_index[1] = type_index[1];
}
;
function(p_symbol p;)
:
{ p->sy_type = new_type();
p->sy_type->ty_class = T_PROCEDURE;
p->sy_type->ty_size = pointer_size;
}
type(&(p->sy_type->ty_retval), (int *) 0, (p_symbol) 0)
{ if (CurrentScope != FileScope &&
saw_code) {
/* if saw_code is not set, it is a nested
procedure
*/
close_scope();
}
saw_code = 0;
open_scope(p, 1);
p->sy_name.nm_scope = CurrentScope;
CurrentScope->sc_start = currnam->on_valu;
add_scope_addr(CurrentScope);
CurrentScope->sc_proclevel = currnam->on_desc;
}
;
routine(p_symbol p;)
:
{ p->sy_type = new_type();
p->sy_type->ty_class = T_PROCEDURE;
p->sy_type->ty_size = pointer_size;
if (CurrentScope != FileScope &&
saw_code) {
/* if saw_code is not set, it is a nested
procedure
*/
close_scope();
}
saw_code = 0;
open_scope(p, 1);
p->sy_name.nm_scope = CurrentScope;
CurrentScope->sc_start = currnam->on_valu;
add_scope_addr(CurrentScope);
CurrentScope->sc_proclevel = currnam->on_desc;
}
INTEGER ';'
type(&(p->sy_type->ty_retval), (int *) 0, (p_symbol) 0)
;
type(p_type *ptp; int *type_index; p_symbol sy;)
{ register p_type tp = *ptp ? *ptp : new_type();
p_type t1 = 0, t2 = 0;
long ic1, ic2;
int A_used = 0;
int tclass;
int tp_index[2];
char *str;
}
:
[
/* type cross reference */
/* these are used in C for references to a struct, union or
* enum that has not been declared (yet)
*/
'x'
[ 's' /* struct */
{ tclass = T_STRUCT; }
| 'u' /* union */
{ tclass = T_UNION; }
| 'e' /* enum */
{ tclass = T_ENUM; }
]
{ AllowName = 1; }
name(&str)
{ sy = Lookfromscope(str2idf(str,0),TAG,CurrentScope);
if (sy &&
(sy->sy_type->ty_class == tclass ||
sy->sy_type->ty_class == T_CROSS)) {
if (tp != *ptp) free_type(tp);
tp = sy->sy_type;
}
else {
tp->ty_class = T_CROSS;
tp->ty_size = tclass;
sy = NewSymbol(str, CurrentScope, TAG, (struct outname *) 0);
sy->sy_type = tp;
}
}
|
/* subrange */
/* the integer_const's represent the lower and the upper bound.
* A subrange type defined as subrange of itself is an integer type.
* If the second integer_const == 0, but the first is not, we
* have a floating point type with size equal to the first
* integer_const.
* Upperbound -1 means unsigned int or unsigned long.
*/
'r' type_index(tp_index) ';'
[ 'A' integer_const(&ic1) { A_used = 1; }
| integer_const(&ic1)
]
';'
[ 'A' integer_const(&ic2) { A_used |= 2; }
| integer_const(&ic2)
]
{ if (tp != *ptp) free_type(tp);
tp = subrange_type(A_used,
tp_index,
ic1,
ic2,
type_index);
}
|
/* array; first type is bound type, next type
* is element type
*/
'a' type(&t1, (int *) 0, (p_symbol) 0) ';' type(&t2, (int *) 0, (p_symbol) 0)
{ if (tp != *ptp) free_type(tp);
tp = array_type(t1, t2);
}
|
/* structure type */
's' { tp->ty_class = T_STRUCT; }
structure_type(tp, sy)
|
/* union type */
'u' { tp->ty_class = T_UNION; }
structure_type(tp, sy)
|
/* enumeration type */
'e' { tp->ty_class = T_ENUM; }
enum_type(tp)
|
/* pointer type */
'*' { tp->ty_class = T_POINTER;
tp->ty_size = pointer_size;
}
type(&(tp->ty_ptrto), (int *) 0, (p_symbol) 0)
|
/* function type */
'f' { tp->ty_class = T_PROCEDURE;
tp->ty_size = pointer_size;
}
type(&(tp->ty_retval), (int *) 0, (p_symbol) 0)
/*
[ %prefer
',' param_list(tp)
|
]
*/
|
/* procedure type */
'Q' { tp->ty_class = T_PROCEDURE;
tp->ty_size = pointer_size;
}
type(&(tp->ty_retval), (int *) 0, (p_symbol) 0)
',' param_list(tp)
|
/* another procedure type */
'p' { tp->ty_class = T_PROCEDURE;
tp->ty_size = pointer_size;
tp->ty_retval = void_type;
}
param_list(tp)
|
/* set type */
/* the first integer_const represents the size in bytes,
* the second one represents the low bound
*/
'S' { tp->ty_class = T_SET; }
type(&(tp->ty_setbase), (int *) 0, (p_symbol) 0) ';'
[
integer_const(&(tp->ty_size)) ';'
integer_const(&(tp->ty_setlow)) ';'
|
{ set_bounds(tp); }
]
|
/* file type of Pascal */
'L' { tp->ty_class = T_FILE; }
type(&(tp->ty_fileof), (int *) 0, (p_symbol) 0)
|
type_name(ptp, (p_symbol) 0)
{ if (type_index &&
(*ptp)->ty_class == 0 &&
type_index[0] == last_index[0] &&
type_index[1] == last_index[1]) {
**ptp = *void_type;
if (*ptp != tp) free_type(tp);
}
tp = *ptp;
}
]
{ if (*ptp && *ptp != tp) **ptp = *tp;
else *ptp = tp;
}
;
structure_type(register p_type tp; p_symbol sy;)
{ register struct fields *fldp;
char *str;
}
:
integer_const(&(tp->ty_size)) /* size in bytes */
{ open_scope(sy, 0);
if (sy) sy->sy_name.nm_scope = CurrentScope;
}
[
name(&str) { fldp = get_field_space(tp, str); }
type(&(fldp->fld_type), (int *) 0, (p_symbol) 0) ','
integer_const(&(fldp->fld_pos)) ',' /* offset in bits */
integer_const(&(fldp->fld_bitsize)) ';' /* size in bits */
]*
';' { end_field(tp);
close_scope();
}
;
enum_type(register p_type tp;)
{ register struct literal *litp;
long maxval = 0;
register p_symbol s;
}
:
[ { litp = get_literal_space(tp); }
name(&(litp->lit_name))
integer_const(&(litp->lit_val)) ','
{ if (maxval < litp->lit_val) maxval = litp->lit_val;
AllowName = 1;
s = NewSymbol(litp->lit_name, CurrentScope, CONST, (struct outname *) 0);
s->sy_const.co_ival = litp->lit_val;
s->sy_type = tp;
}
]*
';' { end_literal(tp, maxval); }
;
param_list(p_type t;)
{ register struct param *p;
long iconst;
}
:
integer_const(&iconst) ';' /* number of parameters */
{ t->ty_nparams = iconst;
t->ty_params = p = (struct param *)
Malloc((unsigned)(t->ty_nparams * sizeof(struct param)));
}
[
[ 'p' { p->par_kind = 'p'; }
| 'v' { p->par_kind = 'v'; }
| 'i' { p->par_kind = 'i'; }
]
type(&(p->par_type), (int *) 0, (p_symbol) 0) ';'
{ t->ty_nbparams +=
param_size(p->par_type, p->par_kind);
p++;
}
]*
;
{
static char *dbx_string;
static char *DbxOldPtr;
struct outname *
DbxString(n)
struct outname *n;
{
currnam = n;
DbxPtr = n->on_mptr;
dbx_string = DbxPtr;
AllowName = 1;
DbxParser();
return currnam;
}
/*ARGSUSED*/
DBSmessage(n)
{
fatal("error in Dbx string \"%s\", DbxPtr = \"%s\", DbxOldPtr = \"%s\"",
dbx_string,
DbxPtr,
DbxOldPtr);
}
DBSonerror(tk, p)
int *p;
{
DbxPtr = DbxOldPtr;
/* ??? if (DBSsymb < 0) {
while (*p && *p != ';') p++;
if (*p) DbxPtr = ";";
return;
}
*/
if (! tk) {
while (*p && *p != NAME) p++;
if (*p) {
AllowName = 1;
}
}
else if (tk == NAME) AllowName = 1;
}
DBSlex()
{
register char *cp = DbxPtr;
int allow_name = AllowName;
register int c;
AllowName = 0;
DbxOldPtr = cp;
c = *cp;
if (c == '\\' && *(cp+1) == '\0') {
currnam++;
cp = currnam->on_mptr;
DbxOldPtr = cp;
c = *cp;
}
if (! c) {
DbxPtr = cp;
return -1;
}
if ((! allow_name && is_token(c)) || c == ';') {
DbxPtr = cp+1;
return c;
}
if (is_dig(c)) {
int retval = INTEGER;
while (++cp, is_dig(*cp)) /* nothing */;
c = *cp;
if (c == '.') {
retval = REAL;
while (++cp, is_dig(*cp)) /* nothing */;
c = *cp;
}
if (c == 'e' || c == 'E') {
char *oldcp = cp;
cp++;
c = *cp;
if (c == '-' || c == '+') {
cp++;
c = *cp;
}
if (is_dig(c)) {
retval = REAL;
while (++cp, is_dig(*cp)) /* nothing */;
}
else cp = oldcp;
}
c = *cp;
*cp = 0;
if (retval == INTEGER) {
ival = str2long(DbxOldPtr, 10);
}
else {
fval = atof(DbxOldPtr);
}
*cp = c;
DbxPtr = cp;
return retval;
}
if (c == '\'') {
cp++;
strval = cp;
while ((c = *cp) && c != '\'') {
if (c == '\\') cp++; /* backslash escapes next character */
if (!(c = *cp)) break; /* but not a null byte */
cp++;
}
if (! c) DBSmessage(0); /* no return */
*cp = 0;
DbxPtr = cp + 1;
return STRING;
}
strval = cp;
while ((c = *cp) && c != ':' && c != ',') cp++;
DbxPtr = *cp ? cp+1 : cp;
*cp = 0;
return NAME;
}
static struct fields *
get_field_space(tp, s)
register p_type tp;
char *s;
{
register struct fields *p;
p_symbol sy;
if (! (tp->ty_nfields & 07)) {
tp->ty_fields = (struct fields *)
Realloc((char *) tp->ty_fields,
(tp->ty_nfields+8)*sizeof(struct fields));
}
p = &tp->ty_fields[tp->ty_nfields++];
p->fld_name = s;
p->fld_type = 0;
sy = NewSymbol(s, CurrentScope, FIELD, currnam);
sy->sy_field = p;
return p;
}
static
end_field(tp)
register p_type tp;
{
tp->ty_fields = (struct fields *)
Realloc((char *) tp->ty_fields,
tp->ty_nfields * sizeof(struct fields));
}
static struct literal *
get_literal_space(tp)
register p_type tp;
{
if (! (tp->ty_nenums & 07)) {
tp->ty_literals = (struct literal *)
Realloc((char *) tp->ty_literals,
(tp->ty_nenums+8)*sizeof(struct literal));
}
return &tp->ty_literals[tp->ty_nenums++];
}
static char *
string_val(s)
char *s;
{
register char *ns = s, *os = s;
register unsigned int i = 1;
for (;;) {
if (!*os) break;
i++;
if (*os == '\\') {
os++;
*ns++ = *os++;
}
else *ns++ = *os++;
}
*ns = '\0';
return Salloc(s, i);
}
}

194
util/grind/dbxread.c Normal file
View File

@@ -0,0 +1,194 @@
/* $Header$
Read the symbol table from an ACK a.out format file.
*/
#include <stb.h>
#include <alloc.h>
#include <assert.h>
#include "position.h"
#include "file.h"
#include "symbol.h"
#include "idf.h"
#include "scope.h"
#include "rd.h"
extern char *strindex();
extern struct outname *DbxString();
int saw_code = 0;
static char *AckStrings; /* ACK a.out string table */
static struct outname *AckNames; /* ACK a.out symbol table entries */
static unsigned int NAckNames; /* Number of ACK symbol table entries */
static struct outname *EndAckNames; /* &AckNames[NAckNames] */
/* Read the symbol table from file 'f', which is supposed to be an
ACK a.out format file. Offer DBX strings to the DBX string parser.
*/
int
DbxRead(f)
char *f;
{
struct outhead h;
register struct outname *n;
register struct outname *line_file = 0;
long OffsetStrings;
int had_lbrac = 0;
/* Open file, read header, and check magic word */
if (! rd_open(f)) {
fatal("%s: could not open", f);
}
rd_ohead(&h);
if (BADMAGIC(h) && h.oh_magic != O_CONVERTED) {
fatal("%s: not an object file", f);
}
/* Allocate space for name table and read it */
AckNames = (struct outname *)
Malloc((unsigned)(sizeof(struct outname) * h.oh_nname));
AckStrings = Malloc((unsigned) h.oh_nchar);
rd_name(AckNames, h.oh_nname);
rd_string(AckStrings, h.oh_nchar);
/* Adjust file offsets in name table to point at strings */
OffsetStrings = OFF_CHAR(h);
NAckNames = h.oh_nname;
EndAckNames = &AckNames[h.oh_nname];
for (n = EndAckNames; --n >= AckNames;) {
if (n->on_foff) {
if ((unsigned)(n->on_foff - OffsetStrings) >= h.oh_nchar) {
fatal("%s: error in object file", f);
}
n->on_mptr = AckStrings + (n->on_foff - OffsetStrings);
}
else n->on_mptr = 0;
}
/* Offer strings to the DBX string parser if they contain a ':'.
Also offer filename-line number information to add_position_addr().
Here, the order may be important.
*/
for (n = &AckNames[0]; n < EndAckNames; n++) {
int tp = n->on_type >> 8;
register p_symbol sym;
if (tp & (S_STB >> 8)) {
switch(tp) {
#ifdef N_BINCL
case N_BINCL:
n->on_valu = (long) line_file;
line_file = n;
break;
case N_EINCL:
if (line_file) {
line_file = (struct outname *) line_file->on_valu;
}
break;
#endif
case N_SO:
if (n->on_mptr[strlen(n->on_mptr)-1] == '/') {
/* another N_SO follows ... */
break;
}
while (CurrentScope != PervasiveScope) {
close_scope();
}
saw_code = 0;
sym = add_file(n->on_mptr);
if (! listfile) newfile(sym->sy_idf);
open_scope(sym, 0);
sym->sy_file->f_scope = CurrentScope;
FileScope = CurrentScope;
clean_tp_tab();
/* fall through */
case N_SOL:
if (! line_file) line_file = n;
else line_file->on_mptr = n->on_mptr;
break;
case N_MAIN:
newfile(FileScope->sc_definedby->sy_idf);
break;
case N_SLINE:
assert(line_file);
if (! saw_code && !CurrentScope->sc_bp_opp) {
CurrentScope->sc_bp_opp = n->on_valu;
if (! CurrentScope->sc_start) {
CurrentScope->sc_start = n->on_valu;
if (CurrentScope->sc_has_activation_record) {
add_scope_addr(CurrentScope);
}
}
}
saw_code = 1;
add_position_addr(line_file->on_mptr, n);
break;
case N_LBRAC: /* block, desc = nesting level */
if (had_lbrac) {
open_scope((p_symbol) 0, 0);
saw_code = 0;
}
else {
register p_scope sc =
get_scope_from_addr(n->on_valu);
if (!sc || sc->sc_bp_opp) {
had_lbrac = 1;
}
else CurrentScope = sc;
}
break;
#ifdef N_SCOPE
case N_SCOPE:
if (n->on_mptr && strindex(n->on_mptr, ':')) {
n = DbxString(n);
}
break;
#endif
case N_RBRAC: /* end block, desc = nesting level */
had_lbrac = 0;
if (CurrentScope != FileScope) close_scope();
saw_code = 0;
break;
case N_FUN: /* function, value = address */
case N_GSYM: /* global variable */
case N_STSYM: /* data, static, value = address */
case N_LCSYM: /* bss, static, value = address */
case N_RSYM: /* register var, value = reg number */
case N_SSYM: /* struct/union el, value = offset */
case N_PSYM: /* parameter, value = offset from AP */
case N_LSYM: /* local sym, value = offset from FP */
if (had_lbrac) {
open_scope((p_symbol) 0, 0);
saw_code = 0;
had_lbrac = 0;
}
if (n->on_mptr && strindex(n->on_mptr, ':')) {
n = DbxString(n);
}
break;
default:
/*
if (n->on_mptr && (n->on_type&S_TYP) >= S_MIN) {
struct idf *id = str2idf(n->on_mptr, 0);
sym = new_symbol();
sym->sy_next = id->id_def;
id->id_def = sym;
sym->sy_class = SYMENTRY;
sym->sy_onam = *n;
sym->sy_idf = id;
}
*/
break;
}
}
}
close_scope();
add_position_addr((char *) 0, (struct outname *) 0);
clean_tp_tab();
rd_close();
return (h.oh_magic == O_CONVERTED);
}

341
util/grind/default.c Normal file
View File

@@ -0,0 +1,341 @@
/* $Header$ */
/* Language dependant support; this one is default */
#include <stdio.h>
#include <alloc.h>
#include "position.h"
#include "class.h"
#include "langdep.h"
#include "Lpars.h"
#include "idf.h"
#include "token.h"
#include "expr.h"
#include "tree.h"
#include "operator.h"
extern FILE *db_out, *db_in;
extern int
get_name();
extern double
atof();
static int
print_string(),
get_number(),
get_string(),
get_token(),
print_op(),
op_prio();
static long
array_elsize();
static struct langdep def = {
0,
"%ld",
"0%lo",
"0x%lX",
"%lu",
"0x%lX",
"%g",
"'\\%o'",
"[",
"]",
"(",
")",
"{",
"}",
print_string,
array_elsize,
op_prio,
get_string,
get_name,
get_number,
get_token,
print_op
};
struct langdep *def_dep = &def;
static int
print_string(s, len)
char *s;
int len;
{
register char *str = s;
int delim = '\'';
while (*str) {
if (*str++ == '\'') delim = '"';
}
fprintf(db_out, "%c%.*s%c", delim, len, s, delim);
}
extern long int_size;
static long
array_elsize(size)
long size;
{
if (! (int_size % size)) return size;
if (! (size % int_size)) return size;
return ((size + int_size - 1) / int_size) * int_size;
}
/*ARGSUSED*/
static int
op_prio(op)
int op;
{
return 1;
}
static int
val_in_base(c, base)
register int c;
{
return is_dig(c)
? c - '0'
: base != 16
? -1
: is_hex(c)
? (c - 'a' + 10) & 017
: -1;
}
static int
get_number(c)
register int c;
{
char buf[512+1];
register int base = 10;
register char *p = &buf[0];
register long val = 0;
register int val_c;
if (c == '0') {
/* check if next char is an 'x' or an 'X' */
c = getc(db_in);
if (c == 'x' || c == 'X') {
base = 16;
c = getc(db_in);
}
else base = 8;
}
while (val_c = val_in_base(c, base), val_c >= 0) {
val = val * base + val_c;
if (p - buf < 512) *p++ = c;
c = getc(db_in);
}
if (base == 16 || !((c == '.' || c == 'e' || c == 'E'))) {
ungetc(c, db_in);
tok.ival = val;
return INTEGER;
}
if (c == '.') {
if (p - buf < 512) *p++ = c;
c = getc(db_in);
}
while (is_dig(c)) {
if (p - buf < 512) *p++ = c;
c = getc(db_in);
}
if (c == 'e' || c == 'E') {
if (p - buf < 512) *p++ = c;
c = getc(db_in);
if (c == '+' || c == '-') {
if (p - buf < 512) *p++ = c;
c = getc(db_in);
}
if (! is_dig(c)) {
error("malformed floating constant");
}
while (is_dig(c)) {
if (p - buf < 512) *p++ = c;
c = getc(db_in);
}
}
ungetc(c, db_in);
*p++ = 0;
if (p == &buf[512+1]) {
error("floating point constant too long");
}
tok.fval = atof(buf);
return REAL;
}
static int
get_token(c)
register int c;
{
switch(c) {
case '`':
case ':':
case ',':
return c;
case '.':
return get_number(c);
default:
error("illegal character 0%o", c);
return LLlex();
}
}
static int
quoted(ch)
int ch;
{
/* quoted() replaces an escaped character sequence by the
character meant.
*/
/* first char after backslash already in ch */
if (!is_oct(ch)) { /* a quoted char */
switch (ch) {
case 'n':
ch = '\n';
break;
case 't':
ch = '\t';
break;
case 'b':
ch = '\b';
break;
case 'r':
ch = '\r';
break;
case 'f':
ch = '\f';
break;
}
}
else { /* a quoted octal */
register int oct = 0, cnt = 0;
do {
oct = oct*8 + (ch-'0');
ch = getc(db_in);
} while (is_oct(ch) && ++cnt < 3);
ungetc(ch, db_in);
ch = oct;
}
return ch&0377;
}
static int
get_string(c)
int c;
{
register int ch;
char buf[512];
register int len = 0;
while (ch = getc(db_in), ch != c) {
if (ch == '\n') {
error("newline in string");
break;
}
if (ch == '\\') {
ch = getc(db_in);
ch = quoted(ch);
}
buf[len++] = ch;
}
buf[len++] = 0;
tok.str = Salloc(buf, (unsigned) len);
return STRING;
}
static int
print_op(p)
p_tree p;
{
switch(p->t_oper) {
case OP_UNOP:
switch(p->t_whichoper) {
case E_MIN:
fputs("-", db_out);
print_node(p->t_args[0], 0);
break;
case E_PLUS:
fputs("+", db_out);
print_node(p->t_args[0], 0);
break;
case E_NOT:
fputs("~", db_out);
print_node(p->t_args[0], 0);
break;
case E_DEREF:
fputs("*", db_out);
print_node(p->t_args[0], 0);
break;
}
break;
case OP_BINOP:
fputs("(", db_out);
print_node(p->t_args[0], 0);
switch(p->t_whichoper) {
case E_AND:
fputs("&&", db_out);
break;
case E_OR:
fputs("||", db_out);
break;
case E_ZDIV:
fputs("/", db_out);
break;
case E_ZMOD:
fputs("%", db_out);
break;
case E_DIV:
fputs(" div ", db_out);
break;
case E_MOD:
fputs(" mod ", db_out);
break;
case E_IN:
fputs(" in ", db_out);
break;
case E_PLUS:
fputs("+", db_out);
break;
case E_MIN:
fputs("-", db_out);
break;
case E_MUL:
fputs("*", db_out);
break;
case E_EQUAL:
fputs("==", db_out);
break;
case E_NOTEQUAL:
fputs("!=", db_out);
break;
case E_LTEQUAL:
fputs("<=", db_out);
break;
case E_GTEQUAL:
fputs(">=", db_out);
break;
case E_LT:
fputs("<", db_out);
break;
case E_GT:
fputs(">", db_out);
break;
case E_SELECT:
fputs(".", db_out);
break;
}
print_node(p->t_args[1], 0);
fputs(")", db_out);
break;
}
}

88
util/grind/dump.c Normal file
View File

@@ -0,0 +1,88 @@
/* $Header$ */
#include <assert.h>
#include <alloc.h>
#include "operator.h"
#include "position.h"
#include "tree.h"
#include "message.h"
#include "type.h"
#include "expr.h"
extern long pointer_size;
extern p_tree get_from_item_list();
struct dump {
char *globals, *stack;
struct message_hdr mglobal, mstack;
struct dump *next;
};
static struct dump *last_dump;
/* dumping and restoring of child process.
*/
do_dump(p)
p_tree p;
{
struct dump *d = (struct dump *) malloc(sizeof(struct dump));
if (! d) {
error("could not allocate enough memory");
return;
}
if (! get_dump(&d->mglobal, &d->globals, &d->mstack, &d->stack)) {
free((char *) d);
return;
}
p->t_args[0] = (struct tree *) d;
p->t_address = (t_addr) get_int(d->mglobal.m_buf+PC_OFF*pointer_size, pointer_size, T_UNSIGNED);
add_to_item_list(p);
d->next = last_dump;
last_dump = d;
}
/* dumping and restoring of child process.
*/
do_restore(p)
p_tree p;
{
struct dump *d;
if (p->t_args[0]) {
p = get_from_item_list((int) p->t_args[0]->t_ival);
if (!p || p->t_oper != OP_DUMP) {
error("no such dump");
return;
}
d = (struct dump *) p->t_args[0];
}
else d = last_dump;
if (! d) {
error("no dumps");
return;
}
if (! put_dump(&d->mglobal, d->globals, &d->mstack, d->stack)) {
}
do_items();
}
free_dump(p)
p_tree p;
{
struct dump *d = (struct dump *) p->t_args[0];
free(d->globals);
free(d->stack);
if (d == last_dump) last_dump = d->next;
else {
register struct dump *d1 = last_dump;
while (d1->next != d) d1 = d1->next;
d1->next = d->next;
}
free((char *) d);
}

14
util/grind/op_tools.amk Normal file
View File

@@ -0,0 +1,14 @@
MAKE_OPS = make.ops;
%instance deftypesuffix(op_tab, '%.ot');
%tool gen_ops (
ops: %in [type = op_tab];
cfile: %out [type = C-src] => ops.c;
hfile: %out [type = C-incl] => ops.h;
mkops: %in [type = command] => $MAKE_OPS;
)
{
exec($mkops, args => $ops);
echo({$cfile, 'and', $hfile, 'created'});
};

10
util/grind/sizes.h Normal file
View File

@@ -0,0 +1,10 @@
/* $Header$ */
/* For the time being ... */
#define SZ_INT 4
#define SZ_SHORT 2
#define SZ_POINTER 4
#define SZ_LONG 4
#define SZ_FLOAT 4
#define SZ_DOUBLE 8

15
util/grind/tok_tools.amk Normal file
View File

@@ -0,0 +1,15 @@
MAKE_TOKFILE = make.tokfile;
MAKE_TOKCASE = make.tokcase;
%tool gen_tokens (
csrc: %in [type = C-src, gen_tokens, persistent];
tokfile: %out [type = LLgen-src] => get($csrc, LL-dest);
symbols: %out [type = C-src] => get($csrc, cc-dest);
mktok: %in [type = command] => $MAKE_TOKFILE;
mkcase: %in [type = command] => $MAKE_TOKCASE;
)
{
exec($mktok, stdin => $csrc, stdout => $tokfile);
exec($mkcase, stdin => $csrc, stdout => $symbols);
echo({$tokfile, 'and', $symbols, 'created'});
};

182
util/grind/value.c Normal file
View File

@@ -0,0 +1,182 @@
/* $Header$ */
#include <alloc.h>
#include <assert.h>
#include "position.h"
#include "scope.h"
#include "idf.h"
#include "symbol.h"
#include "type.h"
#include "message.h"
#include "langdep.h"
#include "expr.h"
int stack_offset; /* for up and down commands */
extern long pointer_size;
extern t_addr *get_EM_regs();
extern char *memcpy();
/* Get the address of the object indicated by sym.
Return 0 on failure,
address on success.
*psize will contain size of object.
*/
t_addr
get_addr(sym, psize)
register p_symbol sym;
long *psize;
{
p_type tp = sym->sy_type;
long size = tp->ty_size;
t_addr *EM_regs;
int i;
p_scope sc, symsc;
*psize = size;
switch(sym->sy_class) {
case VAR:
/* exists if child exists; nm_value contains addres */
return (t_addr) sym->sy_name.nm_value;
case VARPAR:
case LOCVAR:
/* first find the stack frame in which it resides */
symsc = base_scope(sym->sy_scope);
/* now symsc contains the scope where the storage for sym is
allocated. Now find it on the stack of child.
*/
i = stack_offset;
for (;;) {
sc = 0;
if (! (EM_regs = get_EM_regs(i++))) {
return 0;
}
if (! EM_regs[1]) {
error("%s not available", sym->sy_idf->id_text);
return 0;
}
sc = base_scope(get_scope_from_addr(EM_regs[2]));
if (! sc || sc->sc_start > EM_regs[2]) {
error("%s not available", sym->sy_idf->id_text);
sc = 0;
return 0;
}
if (sc == symsc) break; /* found it */
}
if (sym->sy_class == LOCVAR) {
/* Either local variable or value parameter */
return EM_regs[sym->sy_name.nm_value < 0 ? 0 : 1] +
(t_addr) sym->sy_name.nm_value;
}
/* If we get here, we have a var parameter. Get the parameters
of the current procedure invocation.
*/
{
p_type proctype = sc->sc_definedby->sy_type;
t_addr a;
char *AB;
size = proctype->ty_nbparams;
if (has_static_link(sc)) size += pointer_size;
AB = malloc((unsigned) size);
if (! AB) {
error("could not allocate enough memory");
break;
}
if (! get_bytes(size, EM_regs[1], AB)) {
break;
}
if ((size = tp->ty_size) == 0) {
size = compute_size(tp, AB);
*psize = size;
}
a = (t_addr) get_int(AB+sym->sy_name.nm_value, pointer_size, T_UNSIGNED);
free(AB);
return a;
}
default:
error("%s is not a variable", sym->sy_idf->id_text);
break;
}
return 0;
}
/* Get the value of the symbol indicated by sym.
Return 0 on failure,
1 on success.
On success, 'buf' contains the value, and 'size' contains the size.
For 'buf', storage is allocated by malloc; this storage must
be freed by caller (I don't like this any more than you do, but caller
does not know sizes).
*/
int
get_value(sym, buf, psize)
register p_symbol sym;
char **buf;
long *psize;
{
p_type tp = sym->sy_type;
int retval = 0;
t_addr a;
long size = tp->ty_size;
*buf = 0;
switch(sym->sy_class) {
case CONST:
*buf = malloc((unsigned) size);
if (! *buf) {
error("could not allocate enough memory");
break;
}
switch(tp->ty_class) {
case T_REAL:
put_real(*buf, size, sym->sy_const.co_rval);
break;
case T_INTEGER:
case T_SUBRANGE:
case T_UNSIGNED:
case T_ENUM:
put_int(*buf, size, sym->sy_const.co_ival);
break;
case T_SET:
memcpy(*buf, sym->sy_const.co_setval, (int) size);
break;
case T_STRING:
memcpy(*buf, sym->sy_const.co_sval, (int) size);
break;
default:
fatal("strange constant");
}
retval = 1;
break;
case VAR:
case VARPAR:
case LOCVAR:
a = get_addr(sym, psize);
if (a) {
size = *psize;
*buf = malloc((unsigned) size);
if (! *buf) {
error("could not allocate enough memory");
break;
}
if (get_bytes(size, a, *buf)) {
retval = 1;
}
}
break;
}
if (retval == 0) {
if (*buf) free(*buf);
*buf = 0;
*psize = 0;
}
else *psize = size;
return retval;
}

175
util/int/Makefile Normal file
View File

@@ -0,0 +1,175 @@
# $Header$
EM = ../..# # EM tree
CC = cc# # C comp used for compiling the interpreter
CFLAGS = -O# # passed to C compiler
LFLAGS = # # passed to loader
IDIRS = -I$(EM)/h# # passed to C compiler and lint
LINT = lint# # lint to be used
LINTFLAGS = -h# # passed to lint
INT = ./int# # name of resulting interpreter
IP_SPEC = $(EM)/etc/ip_spec.t
TRAPS = $(EM)/etc/traps
APP_A = $(EM)/doc/int/appA # to be moved later
SRC = alloc.c core.c data.c do_array.c do_branch.c do_comp.c do_conv.c \
do_fpar.c do_incdec.c do_intar.c do_load.c do_logic.c do_misc.c \
do_proc.c do_ptrar.c do_sets.c do_store.c do_unsar.c dump.c \
disassemble.c fra.c global.c init.c io.c log.c m_ioctl.c m_sigtrp.c \
main.c moncalls.c monstruct.c proctab.c read.c rsb.c segment.c \
stack.c switch.c tally.c text.c trap.c warn.c
OBJ = alloc.o core.o data.o do_array.o do_branch.o do_comp.o do_conv.o \
do_fpar.o do_incdec.o do_intar.o do_load.o do_logic.o do_misc.o \
do_proc.o do_ptrar.o do_sets.o do_store.o do_unsar.o dump.o \
disassemble.o fra.o global.o init.o io.o log.o m_ioctl.o m_sigtrp.o \
main.o moncalls.o monstruct.o proctab.o read.o rsb.o segment.o \
stack.o switch.o tally.o text.o trap.o warn.o
HDR = alloc.h fra.h global.h linfil.h log.h mem.h memdirect.h monstruct.h \
opcode.h proctab.h read.h rsb.h shadow.h text.h trap.h \
logging.h debug.h nofloat.h segcheck.h sysidf.h v7ioctl.h \
e.out.h# should be in $(EM)/h or so, or in $(EM/h/em_abs.h
.SUFFIXES: .o
.c.o:
$(CC) $(CFLAGS) $(IDIRS) -c $<
# Main entries
all: test
install: $(INT)
cp $(INT) $(EM)/bin/int
cp int.1 $(EM)/man/int.1
cmp: $(INT)
-cmp $(INT) $(EM)/bin/int
-cmp int.1 $(EM)/man/int.1
test: $(INT) test/awa.em22 test/awa.em24 test/awa.em44
@rm -f int.mess
-echo 3 5 7 2 -1 | time $(INT) test/awa.em22
cat int.mess
@rm -f int.mess
-echo 3 5 7 2 -1 | time $(INT) test/awa.em24
cat int.mess
@rm -f int.mess
-echo 3 5 7 2 -1 | time $(INT) test/awa.em44
cat int.mess
$(INT): $(OBJ) Makefile
$(CC) $(LFLAGS) -o $(INT) $(OBJ)
@size $(INT)
# Generated files
trap_msg: M.trap_msg $(TRAPS)
M.trap_msg $(TRAPS)
warn_msg: M.warn_msg $(APP_A)
M.warn_msg $(APP_A)
warn.h: M.warn_h $(APP_A)
M.warn_h $(APP_A)
switch/DoCases:
(cd switch; make DoCases)
switch/PrCases:
(cd switch; make PrCases)
test/awa.em22:
(cd test; make awa.em22)
test/awa.em24:
(cd test; make awa.em24)
test/awa.em44:
(cd test; make awa.em44)
# Auxiliary entries
lint: $(SRC) trap_msg warn_msg warn.h switch/DoCases switch/PrCases
$(LINT) $(LINTFLAGS) $(IDIRS) $(SRC) -lc
tags: $(HDR) $(SRC)
ctags $(HDR) $(SRC)
MFILES = M.trap_msg M.warn_h M.warn_msg
ALL = READ_ME Makefile $(MFILES) $(HDR) $(SRC)
DISTR = $(ALL) int.1 switch test
print:
@pr $(ALL)
pr: print
opr:
make pr | opr
distr: .distr
(cd switch; make distr)
(cd test; make distr)
.distr: Makefile
echo $(DISTR) | tr ' ' '\012' >.distr
clean:
rm -f core mon.out int.mess int.log int.core int.tally \
trap_msg warn_msg warn.h tags print \
$(OBJ) $(INT)
(cd switch; make clean)
(cd test; make clean)
bare: clean
(cd switch; make bare)
#----------------------------------------------------------------
alloc.o: alloc.h debug.h global.h
core.o: fra.h global.h logging.h shadow.h
data.o: alloc.h global.h log.h logging.h mem.h memdirect.h nofloat.h shadow.h trap.h warn.h
disassemble.o: alloc.h global.h memdirect.h opcode.h proctab.h switch/PrCases
do_array.o: fra.h global.h log.h logging.h mem.h text.h trap.h
do_branch.o: fra.h global.h log.h logging.h mem.h text.h trap.h warn.h
do_comp.o: fra.h global.h log.h logging.h mem.h nofloat.h shadow.h text.h trap.h warn.h
do_conv.o: fra.h global.h log.h logging.h mem.h nofloat.h text.h trap.h warn.h
do_fpar.o: fra.h global.h log.h logging.h mem.h nofloat.h text.h trap.h warn.h
do_incdec.o: fra.h global.h log.h logging.h mem.h nofloat.h text.h trap.h warn.h
do_intar.o: fra.h global.h log.h logging.h mem.h text.h trap.h warn.h
do_load.o: fra.h global.h log.h logging.h mem.h rsb.h text.h trap.h warn.h
do_logic.o: fra.h global.h log.h logging.h mem.h shadow.h text.h trap.h warn.h
do_misc.o: fra.h global.h linfil.h log.h logging.h mem.h memdirect.h read.h rsb.h shadow.h text.h trap.h warn.h
do_proc.o: fra.h global.h linfil.h log.h logging.h mem.h memdirect.h proctab.h rsb.h shadow.h text.h trap.h warn.h
do_ptrar.o: fra.h global.h log.h logging.h mem.h segcheck.h text.h trap.h warn.h
do_sets.o: fra.h global.h log.h logging.h mem.h text.h trap.h
do_store.o: fra.h global.h log.h logging.h mem.h text.h trap.h warn.h
do_unsar.o: fra.h global.h log.h logging.h mem.h text.h trap.h warn.h
dump.o: fra.h global.h linfil.h log.h logging.h mem.h memdirect.h proctab.h rsb.h shadow.h text.h
fra.o: alloc.h fra.h global.h logging.h mem.h shadow.h
global.o: global.h
init.o: alloc.h global.h log.h logging.h mem.h read.h shadow.h trap.h warn.h
io.o: global.h linfil.h logging.h mem.h
log.o: global.h linfil.h logging.h
m_ioctl.o: global.h mem.h sysidf.h v7ioctl.h warn.h
m_sigtrp.o: global.h log.h logging.h trap.h warn.h
main.o: e.out.h global.h log.h logging.h nofloat.h opcode.h read.h rsb.h text.h trap.h warn.h
moncalls.o: alloc.h global.h log.h logging.h mem.h shadow.h sysidf.h trap.h warn.h
monstruct.o: global.h mem.h monstruct.h sysidf.h v7ioctl.h
proctab.o: alloc.h global.h log.h logging.h proctab.h
read.o: e.out.h global.h log.h logging.h mem.h nofloat.h read.h shadow.h text.h warn.h
rsb.o: global.h linfil.h logging.h mem.h proctab.h rsb.h shadow.h warn.h
segment.o: alloc.h global.h mem.h segcheck.h
stack.o: alloc.h global.h log.h logging.h mem.h memdirect.h nofloat.h rsb.h shadow.h trap.h warn.h
switch.o: global.h opcode.h switch/DoCases text.h trap.h warn.h
tally.o: alloc.h global.h linfil.h
text.o: alloc.h global.h proctab.h read.h text.h trap.h warn.h
trap.o: fra.h global.h linfil.h log.h logging.h mem.h rsb.h shadow.h trap.h trap_msg warn.h
warn.o: alloc.h global.h linfil.h log.h logging.h warn.h warn_msg

54
util/int/switch/Makefile Normal file
View File

@@ -0,0 +1,54 @@
# $Header$
EM = ../../..
IP_SPEC = $(EM)/etc/ip_spec.t
CFLAGS = -I$(EM)
SRC = mkiswitch.c mkswitch.c
OBJ = mkiswitch.o mkswitch.o
mkiswitch: mkiswitch.o
$(CC) -o mkiswitch mkiswitch.o $(EM)/lib/em_data.a
mkswitch: mkswitch.o
$(CC) -o mkswitch mkswitch.o
DoCases: mkiswitch $(IP_SPEC)
mkiswitch Do $(IP_SPEC) DoCases
wc DoCases
PrCases: mkswitch $(IP_SPEC)
mkswitch Pr $(IP_SPEC) PrCases
wc PrCases
lint:
lint $(SRC)
distr: .distr
.distr: Makefile
echo READ_ME Makefile $(SRC) | tr ' ' '\012' >.distr
.SUFFIXES: .o
.c.o:
$(CC) $(CFLAGS) -c $<
clean: # NOT the cases files !
rm -f a.out core $(OBJ) mkswitch mkiswitch
bare: clean
rm -f DoCases PrCases
all: mkswitch
install:
echo "Nothing to install"
cmp:
echo "Nothing to compare"
pr:
@pr READ_ME Makefile $(SRC)
opr:
make pr | opr

34
util/int/test/Makefile Normal file
View File

@@ -0,0 +1,34 @@
# $Header$
EM = ../../..# # EM tree
.SUFFIXES: .em22 .em24 .em44
.c.em22:
$(EM)/bin/em22 $*.c -o $*.em22
.p.em22:
$(EM)/bin/em22 $*.p -o $*.em22
.c.em24:
$(EM)/bin/em24 $*.c -o $*.em24
.p.em24:
$(EM)/bin/em24 $*.p -o $*.em24
.c.em44:
$(EM)/bin/em44 $*.c -o $*.em44
.p.em44:
$(EM)/bin/em44 $*.p -o $*.em44
clean:
rm -f e.out core mon.out int.mess int.log int.core int.tally \
*.k *.m *.o *.s *.em?? a.out
distr: .distr
.distr:
echo *.[cp] Makefile READ_ME | tr ' ' '\012' > .distr
all install cmp pr opr:

103
util/led/Makefile Normal file
View File

@@ -0,0 +1,103 @@
#
# Author: L.J. Bekema @ VU Informatica, Amsterdam
#
# Definitions for the making programs.
EMHOME = ../..
LIBDIR= $(EMHOME)/lib
MODLIBDIR = $(EMHOME)/modules/lib
PREFLAGS= -I$(EMHOME)/h -DNDEBUG -DNASSERT
CFLAGS = $(PREFLAGS) -O
LDFLAGS =
LDLIBS = $(MODLIBDIR)/libstring.a $(MODLIBDIR)/libobject.a
LINTFLAGS=-phbxa $(PREFLAGS)
PR = pr
PRFLAGS =
# Some convenient macro definitions.
CFILES = archive.c error.c extract.c finish.c main.c memory.c\
output.c read.c relocate.c save.c scan.c sym.c write.c
HFILES = assert.h const.h debug.h defs.h memory.h orig.h scan.h
OFILES = archive.o error.o extract.o finish.o main.o memory.o\
output.o read.o relocate.o save.o scan.o sym.o write.o
# Things that can be made.
led: $(OFILES)
$(CC) $(LDFLAGS) $(OFILES) $(LDLIBS) -o led
install:led
rm -f $(LIBDIR)/em_led $(EMHOME)/man/led.6 $(EMHOME)/man/ack.out.5
cp led $(LIBDIR)/em_led
cp led.6 $(EMHOME)/man/led.6
cp ack.out.5 $(EMHOME)/man/ack.out.5
cmp: led
cmp led $(LIBDIR)/em_led
lint:
lint $(LINTFLAGS) $(CFILES)
pr: $(CFILES) $(HFILES) mach.c
$(PR) $(PRFLAGS) $?
@touch pr
opr:
make pr | opr
clean:
rm -f Out *.o led nohup.out
depend:
makedepend $(CFILES)
# The next lines are generated automatically.
# AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO
archive.o: const.h
archive.o: debug.h
archive.o: defs.h
archive.o: memory.h
error.o: const.h
extract.o: const.h
extract.o: debug.h
extract.o: defs.h
extract.o: memory.h
extract.o: orig.h
extract.o: scan.h
finish.o: const.h
finish.o: defs.h
finish.o: memory.h
finish.o: orig.h
finish.o: scan.h
main.o: const.h
main.o: debug.h
main.o: defs.h
main.o: memory.h
main.o: orig.h
memory.o: assert.h
memory.o: const.h
memory.o: debug.h
memory.o: mach.c
memory.o: memory.h
output.o: const.h
output.o: memory.h
read.o: assert.h
read.o: const.h
relocate.o: const.h
relocate.o: debug.h
relocate.o: defs.h
relocate.o: orig.h
save.o: assert.h
save.o: const.h
save.o: memory.h
scan.o: assert.h
scan.o: const.h
scan.o: memory.h
scan.o: scan.h
sym.o: const.h
sym.o: memory.h
write.o: assert.h
write.o: const.h
write.o: memory.h
write.o: orig.h

600
util/led/READ_ME Normal file
View File

@@ -0,0 +1,600 @@
You may want to change mach.c in this directory.
Archives MUST have a table of contents. Arch in subdirectory arch
automatically makes one when you change an archive.
Several changes in the assembler were needed to have it generate the
necessary output.
A contextual diff follows. You can apply them as follows:
patch -d /usr/em/philips/mach/68000/as < READ_ME
*** comm0.h.old Thu Dec 6 16:18:39 1984
--- comm0.h Thu Dec 6 17:49:51 1984
***************
*** 213,218
/*
* extra type bits out of S_ETC, internal use only
* S_COM:
* - symbols declared by .comm
* S_VAR:
--- 213,219 -----
/*
* extra type bits out of S_ETC, internal use only
+ #ifndef DUK
* S_COM:
* - symbols declared by .comm
#endif DUK
***************
*** 215,220
* extra type bits out of S_ETC, internal use only
* S_COM:
* - symbols declared by .comm
* S_VAR:
* - type not known at end of PASS_1 (S_VAR|S_UND)
* - value not known at end of PASS_2 (S_VAR|S_ABS)
--- 216,222 -----
#ifndef DUK
* S_COM:
* - symbols declared by .comm
+ #endif DUK
* S_VAR:
* - type not known at end of PASS_1 (S_VAR|S_UND)
* - value not known at end of PASS_2 (S_VAR|S_ABS)
***************
*** 221,226
* S_DOT:
* - dot expression
*/
#define S_COM 0x0100
#define S_VAR 0x0200
#define S_DOT 0x0400
--- 223,229 -----
* S_DOT:
* - dot expression
*/
+ #ifndef DUK
#define S_COM 0x0100
#endif DUK
#define S_VAR 0x0200
***************
*** 222,227
* - dot expression
*/
#define S_COM 0x0100
#define S_VAR 0x0200
#define S_DOT 0x0400
/* should be tested by preprocessor
--- 225,231 -----
*/
#ifndef DUK
#define S_COM 0x0100
+ #endif DUK
#define S_VAR 0x0200
#define S_DOT 0x0400
/* should be tested by preprocessor
*** comm2.y.old Thu Dec 6 16:19:07 1984
--- comm2.y Thu Dec 6 16:02:19 1984
***************
*** 229,234
{
#ifdef RELOCATION
if (rflag != 0 && PASS_RELO)
newrelo($1.typ, (int)$<y_word>0);
#endif
emitx($1.val, (int)$<y_word>0);
--- 229,239 -----
{
#ifdef RELOCATION
if (rflag != 0 && PASS_RELO)
+ #ifdef DUK
+ newrelo($1.typ,
+ (int)$<y_word>0 | RELBR | RELWR
+ );
+ #else DUK
newrelo($1.typ, (int)$<y_word>0);
#endif DUK
#endif
***************
*** 230,235
#ifdef RELOCATION
if (rflag != 0 && PASS_RELO)
newrelo($1.typ, (int)$<y_word>0);
#endif
emitx($1.val, (int)$<y_word>0);
}
--- 235,241 -----
);
#else DUK
newrelo($1.typ, (int)$<y_word>0);
+ #endif DUK
#endif
emitx($1.val, (int)$<y_word>0);
}
***************
*** 237,242
{
#ifdef RELOCATION
if (rflag != 0 && PASS_RELO)
newrelo($3.typ, (int)$<y_word>0);
#endif
emitx($3.val, (int)$<y_word>0);
--- 243,253 -----
{
#ifdef RELOCATION
if (rflag != 0 && PASS_RELO)
+ #ifdef DUK
+ newrelo($3.typ,
+ (int)$<y_word>0 | RELBR | RELWR
+ );
+ #else DUK
newrelo($3.typ, (int)$<y_word>0);
#endif DUK
#endif
***************
*** 238,243
#ifdef RELOCATION
if (rflag != 0 && PASS_RELO)
newrelo($3.typ, (int)$<y_word>0);
#endif
emitx($3.val, (int)$<y_word>0);
}
--- 249,255 -----
);
#else DUK
newrelo($3.typ, (int)$<y_word>0);
+ #endif DUK
#endif
emitx($3.val, (int)$<y_word>0);
}
*** comm3.c.old Wed Jul 11 09:22:24 1984
--- comm3.c Fri Dec 7 13:06:26 1984
***************
*** 11,16
struct outhead outhead = {
O_MAGIC, O_STAMP, 0
#ifdef BYTES_REVERSED
| HF_BREV
#endif
--- 11,17 -----
struct outhead outhead = {
O_MAGIC, O_STAMP, 0
+ #ifndef DUK
#ifdef BYTES_REVERSED
| HF_BREV
#endif
***************
*** 17,22
#ifdef WORDS_REVERSED
| HF_WREV
#endif
};
#include "y.tab.h"
--- 18,24 -----
#ifdef WORDS_REVERSED
| HF_WREV
#endif
+ #endif DUK
};
#include "y.tab.h"
*** comm5.c.old Thu Dec 6 16:19:40 1984
--- comm5.c Thu Oct 11 14:03:27 1984
***************
*** 162,167
#endif
case STRING:
p = stringbuf;
*p++ = n = getc(tempfile); break;
case OP_EQ:
case OP_NE:
--- 162,172 -----
#endif
case STRING:
p = stringbuf;
+ #ifdef DUK
+ *p++ = n = getc(tempfile);
+ p[n] = '\0';
+ break;
+ #else DUK
*p++ = n = getc(tempfile); break;
#endif DUK
case OP_EQ:
***************
*** 163,168
case STRING:
p = stringbuf;
*p++ = n = getc(tempfile); break;
case OP_EQ:
case OP_NE:
case OP_LE:
--- 168,174 -----
break;
#else DUK
*p++ = n = getc(tempfile); break;
+ #endif DUK
case OP_EQ:
case OP_NE:
case OP_LE:
***************
*** 354,359
break;
if (c == '\\')
c = inescape();
if (p >= &stringbuf[STRINGMAX])
fatal("string buffer overflow");
*p++ = c;
--- 360,368 -----
break;
if (c == '\\')
c = inescape();
+ #ifdef DUK
+ if (p >= &stringbuf[STRINGMAX - 1])
+ #else DUK
if (p >= &stringbuf[STRINGMAX])
#endif DUK
fatal("string buffer overflow");
***************
*** 355,360
if (c == '\\')
c = inescape();
if (p >= &stringbuf[STRINGMAX])
fatal("string buffer overflow");
*p++ = c;
}
--- 364,370 -----
if (p >= &stringbuf[STRINGMAX - 1])
#else DUK
if (p >= &stringbuf[STRINGMAX])
+ #endif DUK
fatal("string buffer overflow");
*p++ = c;
}
***************
*** 359,364
*p++ = c;
}
stringbuf[0] = p - stringbuf - 1;
return(STRING);
}
--- 369,377 -----
*p++ = c;
}
stringbuf[0] = p - stringbuf - 1;
+ #ifdef DUK
+ *p = '\0';
+ #endif DUK
return(STRING);
}
*** comm6.c.old Thu Dec 6 16:20:22 1984
--- comm6.c Wed Oct 3 15:59:31 1984
***************
*** 106,111
sp = &sect[typ - S_MIN];
sp->s_item = ip;
sp->s_lign = ALIGNSECT;
ip->i_type = typ | S_EXT;
ip->i_valu = 0;
} else if (typ >= S_MIN) {
--- 106,114 -----
sp = &sect[typ - S_MIN];
sp->s_item = ip;
sp->s_lign = ALIGNSECT;
+ #ifdef DUK
+ ip->i_type = typ;
+ #else DUK
ip->i_type = typ | S_EXT;
#endif DUK
ip->i_valu = 0;
***************
*** 107,112
sp->s_item = ip;
sp->s_lign = ALIGNSECT;
ip->i_type = typ | S_EXT;
ip->i_valu = 0;
} else if (typ >= S_MIN) {
sp = &sect[typ - S_MIN];
--- 110,116 -----
ip->i_type = typ;
#else DUK
ip->i_type = typ | S_EXT;
+ #endif DUK
ip->i_valu = 0;
} else if (typ >= S_MIN) {
sp = &sect[typ - S_MIN];
***************
*** 180,185
* for possible relocation
*/
ip->i_valu = outhead.oh_nname;
newsymb(ip->i_name, S_EXT|DOTTYP, (short)0, val);
#endif
}
--- 184,192 -----
* for possible relocation
*/
ip->i_valu = outhead.oh_nname;
+ #ifdef DUK
+ newsymb(ip->i_name, S_COM|S_EXT|DOTTYP, (short)0, val);
+ #else DUK
newsymb(ip->i_name, S_EXT|DOTTYP, (short)0, val);
#endif DUK
#endif
***************
*** 181,186
*/
ip->i_valu = outhead.oh_nname;
newsymb(ip->i_name, S_EXT|DOTTYP, (short)0, val);
#endif
}
--- 188,194 -----
newsymb(ip->i_name, S_COM|S_EXT|DOTTYP, (short)0, val);
#else DUK
newsymb(ip->i_name, S_EXT|DOTTYP, (short)0, val);
+ #endif DUK
#endif
}
***************
*** 255,260
short s;
{
struct outrelo outrelo;
if (rflag == 0)
return;
--- 263,271 -----
short s;
{
struct outrelo outrelo;
+ #ifdef DUK
+ int iscomm;
+ #endif DUK
if (rflag == 0)
return;
***************
*** 272,277
* b=a
* a: .data2 0
*/
s &= ~S_COM;
if ((n & RELPC) == 0 && s == S_ABS)
return;
--- 283,291 -----
* b=a
* a: .data2 0
*/
+ #ifdef DUK
+ iscomm = s & S_COM;
+ #endif DUK
s &= ~S_COM;
if ((n & RELPC) == 0 && s == S_ABS)
return;
***************
*** 285,290
outrelo.or_type = (char)n;
outrelo.or_sect = (char)DOTTYP;
#ifndef ASLD
if (s == S_UND) {
assert(relonami != 0);
outrelo.or_nami = relonami-1;
--- 299,307 -----
outrelo.or_type = (char)n;
outrelo.or_sect = (char)DOTTYP;
#ifndef ASLD
+ #ifdef DUK
+ if (s == S_UND || iscomm) {
+ #else DUK
if (s == S_UND) {
#endif DUK
assert(relonami != 0);
***************
*** 286,291
outrelo.or_sect = (char)DOTTYP;
#ifndef ASLD
if (s == S_UND) {
assert(relonami != 0);
outrelo.or_nami = relonami-1;
relonami = 0;
--- 303,309 -----
if (s == S_UND || iscomm) {
#else DUK
if (s == S_UND) {
+ #endif DUK
assert(relonami != 0);
outrelo.or_nami = relonami-1;
relonami = 0;
*** comm7.c.old Thu Dec 6 16:20:50 1984
--- comm7.c Wed Oct 3 16:35:31 1984
***************
*** 19,24
return(ip->i_valu);
return(ip->i_valu + sect[typ].s_base);
#else
if ((ip->i_type & S_TYP) == S_UND) {
if (pass == PASS_3) {
if (relonami != 0)
--- 19,27 -----
return(ip->i_valu);
return(ip->i_valu + sect[typ].s_base);
#else
+ #ifdef DUK
+ if ((ip->i_type & S_TYP) == S_UND || (ip->i_type & S_COM)) {
+ #else DUK
if ((ip->i_type & S_TYP) == S_UND) {
#endif DUK
if (pass == PASS_3) {
***************
*** 20,25
return(ip->i_valu + sect[typ].s_base);
#else
if ((ip->i_type & S_TYP) == S_UND) {
if (pass == PASS_3) {
if (relonami != 0)
serror("relocation error");
--- 23,29 -----
if ((ip->i_type & S_TYP) == S_UND || (ip->i_type & S_COM)) {
#else DUK
if ((ip->i_type & S_TYP) == S_UND) {
+ #endif DUK
if (pass == PASS_3) {
if (relonami != 0)
serror("relocation error");
*** mach0.c.old Thu Dec 6 16:21:11 1984
--- mach0.c Fri Sep 14 14:15:54 1984
***************
*** 1,3
/* @(#)mach0.c 1.5 */
/*
* Motorola 68000/68010 options
--- 1,4 -----
+ #define DUK
/* @(#)mach0.c 1.5 */
/*
* Motorola 68000/68010 options
*** mach4.c.old Thu Dec 6 16:21:30 1984
--- mach4.c Thu Dec 6 16:05:00 1984
***************
*** 21,26
fit(fitw($4.val));
emit2($1 | $2);
#ifdef RELOCATION
newrelo($4.typ, RELPC|RELO2);
#endif
emit2(loww($4.val));
--- 21,29 -----
fit(fitw($4.val));
emit2($1 | $2);
#ifdef RELOCATION
+ #ifdef DUK
+ newrelo($4.typ, RELPC|RELO2|RELBR|RELWR);
+ #else DUK
newrelo($4.typ, RELPC|RELO2);
#endif DUK
#endif
***************
*** 22,27
emit2($1 | $2);
#ifdef RELOCATION
newrelo($4.typ, RELPC|RELO2);
#endif
emit2(loww($4.val));
}
--- 25,31 -----
newrelo($4.typ, RELPC|RELO2|RELBR|RELWR);
#else DUK
newrelo($4.typ, RELPC|RELO2);
+ #endif DUK
#endif
emit2(loww($4.val));
}
*** mach5.c.old Thu Dec 6 16:21:54 1984
--- mach5.c Thu Dec 6 16:07:05 1984
***************
*** 37,42
#ifdef RELOCATION
RELOMOVE(relonami, rel_1);
if (flag & ~0xFF)
newrelo(exp_1.typ, flag>>8);
#endif
if (flag & PUTL)
--- 37,45 -----
#ifdef RELOCATION
RELOMOVE(relonami, rel_1);
if (flag & ~0xFF)
+ #ifdef DUK
+ newrelo(exp_1.typ, (flag>>8) | RELBR | RELWR);
+ #else DUK
newrelo(exp_1.typ, flag>>8);
#endif DUK
#endif
***************
*** 38,43
RELOMOVE(relonami, rel_1);
if (flag & ~0xFF)
newrelo(exp_1.typ, flag>>8);
#endif
if (flag & PUTL)
emit4(exp_1.val);
--- 41,47 -----
newrelo(exp_1.typ, (flag>>8) | RELBR | RELWR);
#else DUK
newrelo(exp_1.typ, flag>>8);
+ #endif DUK
#endif
if (flag & PUTL)
emit4(exp_1.val);
***************
*** 357,362
fit(fitw(exp.val));
emit2(opc);
#ifdef RELOCATION
newrelo(exp.typ, RELPC|RELO2);
#endif
emit2(loww(exp.val));
--- 361,369 -----
fit(fitw(exp.val));
emit2(opc);
#ifdef RELOCATION
+ #ifdef DUK
+ newrelo(exp.typ, RELPC|RELO2|RELBR|RELWR);
+ #else DUK
newrelo(exp.typ, RELPC|RELO2);
#endif DUK
#endif
***************
*** 358,363
emit2(opc);
#ifdef RELOCATION
newrelo(exp.typ, RELPC|RELO2);
#endif
emit2(loww(exp.val));
}
--- 365,371 -----
newrelo(exp.typ, RELPC|RELO2|RELBR|RELWR);
#else DUK
newrelo(exp.typ, RELPC|RELO2);
+ #endif DUK
#endif
emit2(loww(exp.val));
}

90
util/led/byte_order.c Normal file
View File

@@ -0,0 +1,90 @@
#ifndef lint
static char rcsid[] = "$Header$";
#endif lint
#include "const.h"
#include "assert.h"
bool bytes_reversed = FALSE;
bool words_reversed = FALSE;
/*
* Determine the byte/word order in shorts/longs, assuming the size of a short
* is 2 chars, and the size of a long is 4 chars. Not all theoretical
* possibilities are tested; only bytes reversed and/or words reversed.
*/
determine_ordering()
{
short s;
long l;
register char *cp;
register short *sp;
cp = (char *)&s;
cp[0] = 0x01; cp[1] = 0x02;
if (s != 0x01 + (0x02 << 8))
bytes_reversed = TRUE;
sp = (short *)&l;
sp[0] = 0x0001; sp[1] = 0x0002;
if (l != 0x0001 + (0x0002L << 16))
words_reversed = TRUE;
}
/*
* `Format' is a string of digits indicating how many bytes must be taken
* from `buf' to form an integer of some type. E.g. if the digit is '2', two
* bytes are taken to form a short.
*/
swap(buf, format)
register char *buf;
register char *format;
{
register char savebyte;
while (*format) {
switch (*format++) {
case '1':
buf += 1;
break;
case '2':
if (bytes_reversed) {
savebyte = buf[0];
buf[0] = buf[1];
buf[1] = savebyte;
}
buf += 2;
break;
case '4':
/*
* Written out to save recursive calls.
*/
if (bytes_reversed && words_reversed) {
savebyte = buf[0];
buf[0] = buf[3];
buf[3] = savebyte;
savebyte = buf[1];
buf[1] = buf[2];
buf[2] = savebyte;
} else if (bytes_reversed) {
savebyte = buf[0];
buf[0] = buf[1];
buf[1] = savebyte;
savebyte = buf[2];
buf[2] = buf[3];
buf[3] = savebyte;
} else if (words_reversed) {
savebyte = buf[0];
buf[0] = buf[2];
buf[2] = savebyte;
savebyte = buf[1];
buf[1] = buf[3];
buf[3] = savebyte;
}
buf += 4;
break;
default:
assert(FALSE);
break;
}
}
}

23
util/led/makedepend Executable file
View File

@@ -0,0 +1,23 @@
: 'Without arguments, this program clears the dependencies between'
: '.o files and included files in Makefile.'
: 'With arguments, it replaces the dependencies between the .o files'
: 'resulting from the argument files, and the included files in Makefile.'
: 'Makefile must contain a line with on it the pattern AUTOAUTOAUTO.'
: 'WARNING: a temporary file is created in the current directory.'
: 'It is however rather unlikely that this file already exists'
grep -s AUTOAUTOAUTO Makefile || {
echo "Makefile has wrong format." 1>&2
exit 1
}
for file do
ofile=`echo $file | sed 's/.$/o/'`
grep '^# *include.*"' $file | sed "s/.*\"\(.*\)\".*/$ofile: \1/"
done | sort -u > @@**##$$
echo "Non-empty line." >> Makefile
ed - Makefile <<'!'
/AUTOAUTOAUTO/+,$d
w
q
!
cat @@**##$$ >> Makefile
rm -f @@**##$$

62
util/misc/Makefile Normal file
View File

@@ -0,0 +1,62 @@
# $Header$
EMHOME=../..
h=$(EMHOME)/h
l=$(EMHOME)/lib
ml=$(EMHOME)/modules/lib
mh=$(EMHOME)/modules/h
DEC_PATH=decode
ENC_PATH=encode
DATA_PATH=$l/em_data.a
DECLIBS=$(ml)/libread_emkV.a $(ml)/libeme.a $(ml)/liballoc.a $(ml)/libprint.a $(ml)/libstring.a \
$(ml)/libsystem.a
ENCLIBS=$(ml)/libread_emeV.a $(ml)/libemk.a $(ml)/liballoc.a $(ml)/libprint.a $(ml)/libstring.a \
$(ml)/libsystem.a
HFILES=$h/em_mnem.h $h/em_spec.h $h/em_pseu.h $h/em_flag.h $h/em_ptyp.h \
$h/em_mes.h $(mh)/em.h $(mh)/em_comp.h
CFLAGS=-O -I$(mh) -I$h
LDFLAGS =
all: $(DEC_PATH) $(ENC_PATH) esize
$(DEC_PATH): decode.o $(DATA_PATH)
$(CC) $(LDFLAGS) -o $(DEC_PATH) decode.o $(DECLIBS) $(DATA_PATH)
$(ENC_PATH): encode.o $(DATA_PATH)
$(CC) $(LDFLAGS) -o $(ENC_PATH) encode.o $(ENCLIBS) $(DATA_PATH)
esize: esize.o
$(CC) -o esize esize.o
convert.o: $(HFILES)
encode.o: convert.o
cp convert.o encode.o
decode.o: convert.o
cp convert.o decode.o
clean:
rm -f $(DEC_PATH) $(ENC_PATH) esize *.o *.old
install : all
rm -f $l/em_$(DEC_PATH) $l/em_$(ENC_PATH) $(EMHOME)/bin/esize $(EMHOME)/man/em_decode.6 $(EMHOME)/man/esize.1
cp $(DEC_PATH) $l/em_$(DEC_PATH)
cp $(ENC_PATH) $l/em_$(ENC_PATH)
cp esize $(EMHOME)/bin/esize
cp em_decode.6 $(EMHOME)/man/em_decode.6
cp esize.1 $(EMHOME)/man/esize.1
cmp : all
-cmp $(DEC_PATH) $l/em_$(DEC_PATH)
-cmp $(ENC_PATH) $l/em_$(ENC_PATH)
-cmp esize $(EMHOME)/bin/esize
-cmp em_decode.6 $(EMHOME)/man/em_decode.6
-cmp esize.1 $(EMHOME)/man/esize.1
opr:
make pr ^ opr
pr:
@pr -n Makefile convert.c esize.c

499
util/misc/decode.c Normal file
View File

@@ -0,0 +1,499 @@
/*
* (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
*
*/
#ifndef NORCSID
static char rcsid[] = "$Header$";
#endif
/*
* Decode compact EM assembly language
*
* Author: Johan Stevenson, Vrije Universiteit, Amsterdam
*/
#include <stdio.h>
#include <assert.h>
#include <ctype.h>
#include <em_spec.h>
#include <em_pseu.h>
#include <em_flag.h>
#include <em_ptyp.h>
#include <em_mes.h>
#define get8() ((unsigned)getchar())
#define check(x) if (!(x)) fail_check()
#define MAXSTR 256
/*
* global variables
*/
int opcode;
int offtyp;
long argval;
int dlbval;
char string[MAXSTR];
int strsiz;
int wsize;
int psize;
int lineno;
int argnum;
int errors;
char *progname;
char *filename;
long wordmask[] = { /* allowed bits in a word */
0x00000000,
0x000000FF,
0x0000FFFF,
0x00000000,
0xFFFFFFFF
};
long sizemask[] = { /* allowed bits in multiples of 'wsize' */
0x00000000,
0x7FFFFFFF,
0x7FFFFFFE,
0x00000000,
0x7FFFFFFC
};
/*
* external tables
*/
extern char em_flag[];
extern short em_ptyp[];
extern char em_mnem[][4];
extern char em_pseu[][4];
/*
* routines
*/
int get16();
long get32();
main(argc,argv) char **argv; {
progname = argv[0];
if (argc >= 2) {
filename = argv[1];
if (freopen(argv[1],"r",stdin) == NULL)
fatal("can't open %s",argv[1]);
}
if (argc >= 3)
if (freopen(argv[2],"w",stdout) == NULL)
fatal("can't create %s",argv[2]);
if (get16() != sp_magic)
fatal("bad magic word");
/* In System III the array is called _ctype[] without the trailing '_' */
(_ctype_+1)['_'] = (_ctype_+1)['a'];
while (nextline())
;
return(errors ? -1 : 0);
}
/* ----- copy ----- */
int nextline() {
register t;
lineno++;
argnum = 1;
switch (t = table1()) {
case EOF:
return(0);
case sp_fmnem:
instr();
break;
case sp_fpseu:
pseudo();
break;
case sp_ilb1:
case sp_ilb2:
argnum = 0;
putarg(sp_cst2);
break;
case sp_dlb1:
case sp_dlb2:
case sp_dnam:
argnum = 0;
putarg(t);
break;
default:
error("unknown opcode %d",t);
}
putchar('\n');
return(1);
}
instr() {
register i,j,t;
register long l;
i = opcode - sp_fmnem;
printf(" %s",em_mnem[i]);
j = em_flag[i] & EM_PAR;
if (j == PAR_NO)
return;
t = em_ptyp[j];
t = getarg(t);
/*
* range checking
*/
switch (j) {
case PAR_N:
check(argval >= 0);
break;
case PAR_G:
if (t != sp_cst2 && t != sp_cst4)
break;
check(argval >= 0);
/* fall through */
case PAR_L:
l = argval >= 0 ? argval : -argval;
check((l & ~wordmask[psize]) == 0);
break;
case PAR_W:
if (t == sp_cend)
break;
check((argval & ~wordmask[wsize]) == 0);
/* fall through */
case PAR_S:
check(argval != 0);
/* fall through */
case PAR_Z:
check((argval & ~sizemask[wsize]) == 0);
break;
case PAR_O:
check(argval != 0);
check((argval & ~sizemask[wsize])==0 || (wsize % argval)==0);
break;
case PAR_B:
t = sp_ilb2;
break;
case PAR_R:
check(argval >= 0 && argval <= 2);
break;
}
putarg(t);
}
pseudo() {
register i,t;
i = opcode;
printf(" %s",em_pseu[i - sp_fpseu]);
switch (i) {
case ps_bss:
case ps_hol:
putarg(getarg(cst_ptyp));
putarg(getarg(val_ptyp));
putarg(getarg(ptyp(sp_cst2)));
check(argval==0 || argval==1);
break;
case ps_rom:
case ps_con:
putarg(getarg(val_ptyp));
while ((t = getarg(any_ptyp)) != sp_cend)
putarg(t);
break;
case ps_mes:
putarg(getarg(ptyp(sp_cst2)));
if (argval == ms_emx) {
putarg(getarg(ptyp(sp_cst2)));
check(argval > 0 && argval <= 4);
wsize = (int) argval;
putarg(getarg(ptyp(sp_cst2)));
check(argval > 0 && argval <= 4);
psize = (int) argval;
}
while ((t = getarg(any_ptyp)) != sp_cend)
putarg(t);
break;
case ps_exa:
case ps_ina:
putarg(getarg(sym_ptyp));
break;
case ps_exp:
case ps_inp:
putarg(getarg(ptyp(sp_pnam)));
break;
case ps_exc:
putarg(getarg(ptyp(sp_cst2)));
putarg(getarg(ptyp(sp_cst2)));
break;
case ps_pro:
putarg(getarg(ptyp(sp_pnam)));
putarg(getarg(cst_ptyp|ptyp(sp_cend)));
break;
case ps_end:
putarg(getarg(cst_ptyp|ptyp(sp_cend)));
break;
default:
error("bad pseudo %d",i);
}
}
/* ----- input ----- */
int getarg(typset) {
register t,argtyp;
argtyp = t = table2();
if (t == EOF)
fatal("unexpected EOF");
t -= sp_fspec;
assert(t >= 0 && t < 16);
t = 1 << t;
if ((typset & t) == 0)
error("bad argument type %d",argtyp);
return(argtyp);
}
int table1() {
register i;
i = get8();
if (i < sp_fmnem+sp_nmnem && i >= sp_fmnem) {
opcode = i;
return(sp_fmnem);
}
if (i < sp_fpseu+sp_npseu && i >= sp_fpseu) {
opcode = i;
return(sp_fpseu);
}
if (i < sp_filb0+sp_nilb0 && i >= sp_filb0) {
argval = i - sp_filb0;
return(sp_ilb2);
}
return(table3(i));
}
int table2() {
register i;
i = get8();
if (i < sp_fcst0+sp_ncst0 && i >= sp_fcst0) {
argval = i - sp_zcst0;
return(sp_cst2);
}
return(table3(i));
}
int table3(i) {
long consiz;
switch(i) {
case sp_ilb1:
argval = get8();
break;
case sp_dlb1:
dlbval = get8();
break;
case sp_dlb2:
dlbval = get16();
if ( dlbval<0 ) {
error("illegal data label .%d",dlbval);
dlbval=0 ;
}
break;
case sp_cst2:
argval = get16();
break;
case sp_ilb2:
argval = get16();
if ( argval<0 ) {
error("illegal instruction label %ld",argval);
argval=0 ;
}
break;
case sp_cst4:
argval = get32();
break;
case sp_dnam:
case sp_pnam:
getstring(1);
break;
case sp_scon:
getstring(0);
break;
case sp_doff:
offtyp = getarg(sym_ptyp);
getarg(cst_ptyp);
break;
case sp_icon:
case sp_ucon:
case sp_fcon:
getarg(cst_ptyp);
consiz = (long) argval;
getstring(0);
argval = consiz;
break;
}
return(i);
}
int get16() {
register int l_byte, h_byte;
l_byte = get8();
h_byte = get8();
if ( h_byte>=128 ) h_byte -= 256 ;
return l_byte | (h_byte*256) ;
}
long get32() {
register long l;
register int h_byte;
l = get8(); l |= (unsigned)get8()*256 ; l |= get8()*256L*256L ;
h_byte = get8() ;
if ( h_byte>=128 ) h_byte -= 256 ;
return l | (h_byte*256L*256*256L) ;
}
getstring(ident) {
register char *p;
register n;
getarg(cst_ptyp);
if (argval < 0 || argval > MAXSTR)
fatal("string/identifier too long");
strsiz = n = argval;
p = string;
while (--n >= 0)
*p++ = get8();
if (ident) {
if (!isascii(string[0]) || !isalpha(string[0])) {
identerror();
return;
}
for (n=strsiz,p=string+1;--n>0;p++)
if (!isascii(*p) || !isalnum(*p)) {
identerror();
return;
}
}
}
/* ----- output ----- */
putarg(t) {
if (argnum != 0)
putchar(argnum == 1 ? ' ' : ',');
argnum++;
puttyp(t);
}
puttyp(t) {
switch (t) {
case sp_ilb1:
case sp_ilb2:
printf("*%d",(int) argval);
break;
case sp_dlb1:
case sp_dlb2:
printf(".%d",dlbval);
break;
case sp_dnam:
putstr(0,0);
break;
case sp_cst2:
case sp_cst4:
printf("%ld",argval);
break;
case sp_doff:
puttyp(offtyp);
if (argval >= 0) putchar('+');
printf("%ld",argval);
break;
case sp_pnam:
putstr('$',0);
break;
case sp_scon:
putstr('\'','\'');
break;
case sp_icon:
putstr(0,'I');
printf("%ld",argval);
break;
case sp_ucon:
putstr(0,'U');
printf("%ld",argval);
break;
case sp_fcon:
putstr(0,'F');
printf("%ld",argval);
break;
case sp_cend:
putchar('?');
break;
}
}
putstr(c,c2) register c; {
register char *p;
if (c)
putchar(c);
p = string;
while (--strsiz >= 0) {
c = *p++ & 0377;
if (c >= 040 && c < 0177) {
if (c == '\'' || c == '\\')
putchar('\\');
putchar(c);
} else
printf("\\%03o",c);
}
if (c2)
putchar(c2);
}
/* ----- error handling ----- */
fail_check() {
error("argument range error");
}
identerror() {
error("'%s' is not a correct identifier",string);
}
/* VARARGS */
error(s,a1,a2,a3,a4) char *s; {
fprintf(stderr,
"%s: line %d: ",
filename ? filename : progname,
lineno);
fprintf(stderr,s,a1,a2,a3,a4);
fprintf(stderr,"\n");
errors++;
}
/* VARARGS */
fatal(s,a1,a2,a3,a4) char *s; {
error(s,a1,a2,a3,a4);
exit(-1);
}

761
util/misc/encode.c Normal file
View File

@@ -0,0 +1,761 @@
/*
* (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
*
*/
#ifndef NORCSID
static char rcsid[] = "$Header$";
#endif
/*
* Encode to compact EM assembly language
*
* Author: Johan Stevenson, Vrije Universiteit, Amsterdam
*/
#include <stdio.h>
#include <ctype.h>
#include <assert.h>
#include <setjmp.h>
#include <em_spec.h>
#include <em_pseu.h>
#include <em_flag.h>
#include <em_ptyp.h>
#include <em_mes.h>
#define put8(x) putchar(x)
#define check(x) if (!(x)) fail_check()
#define fit16i(x) ((x) >= 0xFFFF8000 && (x) <= 0x00007FFF)
#define fit8u(x) ((x) >= 0 && (x) <= 0xFF)
#define MAXSTR 256
#define HSIZE 256
#define EMPTY (EOF-1)
/*
* global variables
*/
int opcode;
int offtyp;
long argval;
int dlbval;
char string[MAXSTR];
int strsiz;
int wsize;
int psize;
int lineno;
int argnum;
int errors;
char *progname;
char *filename = "INPUT";
long wordmask[] = { /* allowed bits in a word */
0x00000000,
0x000000FF,
0x0000FFFF,
0x00000000,
0xFFFFFFFF
};
long sizemask[] = { /* allowed bits in multiples of 'wsize' */
0x00000000,
0x7FFFFFFF,
0x7FFFFFFE,
0x00000000,
0x7FFFFFFC
};
int peekc = EMPTY;
int hashtab[HSIZE];
jmp_buf recover;
/*
* external tables
*/
extern char em_flag[];
extern short em_ptyp[];
extern char em_mnem[][4];
extern char em_pseu[][4];
int main(argc,argv) char **argv; {
progname = argv[0];
if (argc >= 2) {
filename = argv[1];
if (freopen(filename,"r",stdin) == NULL)
fatal("can't open %s",filename);
}
if (argc >= 3)
if (freopen(argv[2],"w",stdout) == NULL)
fatal("can't create %s",argv[2]);
init();
put16(sp_magic);
setjmp(recover);
while (nextline())
;
return(errors ? -1 : 0);
}
/* ----- copy ----- */
int nextline() {
register c,i;
lineno++;
argnum = 1;
c = nextchar();
if (c == EOF)
return(0);
if (isspace(c) && c != '\n') {
c = nospace();
if (isalpha(c)) {
inmnem(c);
if (opcode <= sp_lmnem)
instr();
else
pseudo();
} else
peekc = c;
} else if (c == '#') {
line_line();
} else {
peekc = c;
i = gettyp(sym_ptyp | ptyp(sp_cst2) | ptyp(sp_cend));
switch (i) {
case sp_cst2:
i = (int) argval;
if (i >= 0 && i < sp_nilb0)
put8(i + sp_filb0);
else
putarg(sp_ilb2);
break;
case sp_dlb2:
case sp_dnam:
putarg(i);
break;
case sp_cend:
break;
}
}
if (nospace() != '\n')
syntax("end of line expected");
return(1);
}
instr() {
register i,j,t;
register long l;
i = opcode;
put8(i);
i -= sp_fmnem;
j = em_flag[i] & EM_PAR;
if (j == PAR_NO)
return;
t = em_ptyp[j];
if (j == PAR_B)
t = ptyp(sp_ilb2);
t = getarg(t);
/*
* range checking
*/
switch (j) {
case PAR_N:
check(argval >= 0);
break;
case PAR_G:
if (t != sp_cst2 && t != sp_cst4)
break;
check(argval >= 0);
/* fall through */
case PAR_L:
l = argval >= 0 ? argval : -argval;
check((l & ~wordmask[psize]) == 0);
break;
case PAR_W:
if (t == sp_cend)
break;
check((argval & ~wordmask[wsize]) == 0);
/* fall through */
case PAR_S:
check(argval != 0);
/* fall through */
case PAR_Z:
check((argval & ~sizemask[wsize]) == 0);
break;
case PAR_O:
check(argval != 0);
check((argval & ~sizemask[wsize])==0 || (wsize % argval)==0);
break;
case PAR_B:
t = sp_cst2;
break;
case PAR_R:
check(argval >= 0 && argval <= 2);
break;
}
putarg(t);
}
pseudo() {
register i,t;
i = opcode;
put8(i);
switch (i) {
case ps_bss:
case ps_hol:
putarg(getarg(cst_ptyp));
putarg(getarg(val_ptyp));
putarg(getarg(ptyp(sp_cst2)));
check(argval==0 || argval==1);
break;
case ps_rom:
case ps_con:
putarg(getarg(val_ptyp));
do
putarg(t = getarg(any_ptyp));
while (t != sp_cend);
break;
case ps_mes:
putarg(getarg(ptyp(sp_cst2)));
if (argval == ms_emx) {
putarg(getarg(ptyp(sp_cst2)));
check(argval > 0 && argval <= 4);
wsize = (int) argval;
putarg(getarg(ptyp(sp_cst2)));
check(argval > 0 && argval <= 4);
psize = (int) argval;
}
do
putarg(t = getarg(any_ptyp));
while (t != sp_cend);
break;
case ps_exa:
case ps_ina:
putarg(getarg(sym_ptyp));
break;
case ps_exp:
case ps_inp:
putarg(getarg(ptyp(sp_pnam)));
break;
case ps_exc:
putarg(getarg(ptyp(sp_cst2)));
putarg(getarg(ptyp(sp_cst2)));
break;
case ps_pro:
putarg(getarg(ptyp(sp_pnam)));
putarg(getarg(cst_ptyp|ptyp(sp_cend)));
break;
case ps_end:
putarg(getarg(cst_ptyp|ptyp(sp_cend)));
break;
default:
syntax("bad pseudo %d",i);
}
}
/* ----- input ----- */
int getarg(typset) {
register c;
if (argnum != 1) {
c = nospace();
if (c != ',') {
if (c != '\n')
syntax("comma expected");
peekc = c;
}
}
argnum++;
return(gettyp(typset));
}
int gettyp(typset) {
register c,t,sp;
c = nospace();
if (c == '\n') {
peekc = c;
sp = sp_cend;
} else if (isdigit(c) || c == '+' || c == '-' || c == '(') {
sp = inexpr1(c);
if (sp == sp_cst4 && fit16i(argval))
sp = sp_cst2;
} else if (isalpha(c)) {
inname(c);
sp = offsetted(sp_dnam);
} else if (c == '.') {
in15u();
dlbval = (int) argval;
sp = offsetted(sp_dlb2);
} else if (c == '*') {
in15u();
sp = sp_ilb2;
} else if (c == '$') {
inname(nextchar());
sp = sp_pnam;
} else if (c == '"' || c == '\'') {
sp = instring(c);
} else if (c == '?') {
sp = sp_cend;
} else
syntax("operand expected");
t = sp - sp_fspec;
assert(t >= 0 && t < 16);
t = 1 << t;
if ((typset & t) == 0)
error("bad argument type %d",sp);
return(sp);
}
int offsetted(sp) {
register c;
c = nospace();
if (c == '+' || c == '-') {
gettyp(cst_ptyp);
if (c == '-')
argval = -argval;
offtyp = sp;
return(sp_doff);
}
peekc = c;
return(sp);
}
inname(c) register c; {
register char *p;
if (isalpha(c) == 0)
syntax("letter expected");
p = string;
do {
if (p < &string[MAXSTR-1])
*p++ = c;
c = nextchar();
} while (isalnum(c));
peekc = c;
*p = '\0';
strsiz = p - string;
}
int inmnem(c) register c; {
register unsigned h;
register i;
inname(c);
h = hash(string);
for (;;) {
h++;
h %= HSIZE;
i = hashtab[h];
if (i == 0)
syntax("bad mnemonic");
if (i <= sp_lmnem) {
assert(i >= sp_fmnem);
if (strcmp(string,em_mnem[i - sp_fmnem]) != 0)
continue;
return(opcode = i);
}
assert(i <= sp_lpseu && i >= sp_fpseu);
if (strcmp(string,em_pseu[i - sp_fpseu]) != 0)
continue;
return(opcode = i);
}
}
int inexpr1(c) register c; {
long left;
if ((c = inexpr2(c)) != sp_cst4)
return(c);
for (;;) {
c = nospace();
if (c != '+' && c != '-') {
peekc = c;
break;
}
left = argval;
if (inexpr2(nospace()) != sp_cst4)
syntax("term expected");
if (c == '+')
argval += left;
else
argval = left - argval;
}
return(sp_cst4);
}
int inexpr2(c) register c; {
long left;
if ((c = inexpr3(c)) != sp_cst4)
return(c);
for (;;) {
c = nospace();
if (c != '*' && c != '/' && c != '%') {
peekc = c;
break;
}
left = argval;
if (inexpr3(nospace()) != sp_cst4)
syntax("factor expected");
if (c == '*')
argval *= left;
else if (c == '/')
argval = left / argval;
else
argval = left % argval;
}
return(sp_cst4);
}
inexpr3(c) register c; {
if (c == '(') {
if (inexpr1(nospace()) != sp_cst4)
syntax("expression expected");
if (nospace() != ')')
syntax("')' expected");
return(sp_cst4);
}
return(innumber(c));
}
int innumber(c) register c; {
register char *p;
register n;
int expsign;
static char numstr[MAXSTR];
long atol();
p = numstr;
expsign = 0;
if (c == '+' || c == '-') {
if (c == '-')
*p++ = c;
c = nextchar();
}
if (isdigit(c) == 0)
syntax("digit expected");
n = sp_cst4;
for (;;) {
if (p >= &numstr[MAXSTR-1])
fatal("number too long");
*p++ = c;
c = nextchar();
if (c == '.' || c == 'e' || c == 'E') {
expsign = c != '.';
n = sp_fcon;
continue;
}
if (expsign) {
expsign = 0;
if (c == '+' || c == '-')
continue;
}
if (isdigit(c) == 0)
break;
}
peekc = c;
*p = '\0';
c = nospace();
if (n == sp_fcon && c != 'F')
syntax("'F' expected");
if (c == 'I' || c == 'U' || c == 'F')
return(incon(numstr,c));
peekc = c;
argval = atol(numstr);
return(sp_cst4);
}
in15u() {
if (innumber(nextchar()) != sp_cst4)
syntax("integer expected");
check((argval & ~077777) == 0);
}
int incon(p,c) register char *p; {
register char *q;
q = string;
while (*q++ = *p++)
;
strsiz = q - string - 1;
gettyp(cst_ptyp);
return(c == 'I' ? sp_icon : (c == 'U' ? sp_ucon : sp_fcon));
}
int instring(termc) {
register char *p;
register c;
p = string;
for (;;) {
c = nextchar();
if (c == '\n' || c == EOF) {
peekc = c;
syntax("non-terminated string");
}
if (c == termc) {
if (termc == '"')
*p++ = '\0';
break;
}
if (c == '\\')
c = inescape();
if (p >= &string[MAXSTR-1])
fatal("string too long");
*p++ = c;
}
strsiz = p - string;
return(sp_scon);
}
int inescape() {
register c,j,r;
c = nextchar();
if (c >= '0' && c <= '7') {
r = c - '0';
for (j = 0; j < 2; j++) {
c = nextchar();
if (c < '0' || c > '7') {
peekc = c;
return(r);
}
r <<= 3;
r += (c - '0');
}
return(r);
}
switch (c) {
case 'b': return('\b');
case 'f': return('\f');
case 'n': return('\n');
case 'r': return('\r');
case 't': return('\t');
}
return(c);
}
int nospace() {
register c;
do
c = nextchar();
while (isspace(c) && c != '\n');
if (c == ';')
do
c = nextchar();
while (c != '\n' && c != EOF);
return(c);
}
int nextchar() {
register c;
if (peekc != EMPTY) {
c = peekc;
peekc = EMPTY;
return(c);
}
c = getchar();
if (isascii(c) == 0 && c != EOF)
fatal("non-ascii char");
return(c);
}
line_line() {
register char *p,*q;
static char filebuff[MAXSTR+1];
gettyp(ptyp(sp_cst2));
lineno = (int) (argval-1);
gettyp(ptyp(sp_scon));
p = string;
q = filebuff;
while (--strsiz >= 0)
*q++ = *p++;
*q = '\0';
filename = filebuff;
}
init() {
register i;
for (i = sp_fmnem; i <= sp_lmnem; i++)
pre_hash(i,em_mnem[i - sp_fmnem]);
for (i = sp_fpseu; i <= sp_lpseu; i++)
pre_hash(i,em_pseu[i - sp_fpseu]);
/* treat '_' as letter */
/* In System III the array is called _ctype[] without the trailing '_' */
(_ctype_+1)['_'] = (_ctype_+1)['a'];
}
pre_hash(i,s) char *s; {
register unsigned h;
assert(i != 0);
h = hash(s);
for (;;) {
h++;
h %= HSIZE;
if (hashtab[h] == 0) {
hashtab[h] = i;
return;
}
}
}
int hash(s) register char *s; {
register h;
h = 0;
while (*s) {
h <<= 1;
h += *s++;
}
return(h);
}
/* ----- output ----- */
putarg(sp) register sp; {
register i;
switch (sp) {
case sp_ilb2:
i = (int) argval;
if (fit8u(i)) {
put8(sp_ilb1);
put8(i);
break;
}
put8(sp);
put16(i);
break;
case sp_dlb2:
i = dlbval;
if (fit8u(i)) {
put8(sp_dlb1);
put8(i);
break;
}
put8(sp);
put16(i);
break;
case sp_cst2:
case sp_cst4:
if (fit16i(argval) == 0) {
put8(sp_cst4);
put32(argval);
break;
}
i = (int) argval;
if (i >= -sp_zcst0 && i < sp_ncst0 - sp_zcst0) {
put8(i + sp_zcst0 + sp_fcst0);
break;
}
put8(sp_cst2);
put16(i);
break;
case sp_doff:
put8(sp);
putarg(offtyp);
putarg(sp_cst4);
break;
case sp_dnam:
case sp_pnam:
case sp_scon:
put8(sp);
putstr();
break;
case sp_icon:
case sp_ucon:
case sp_fcon:
put8(sp);
putarg(sp_cst4);
putstr();
break;
case sp_cend:
put8(sp);
break;
}
}
putstr() {
register char *p;
long consiz;
consiz = argval;
argval = strsiz;
putarg(sp_cst4);
argval = consiz;
p = string;
while (--strsiz >= 0)
put8(*p++);
}
put16(w) int w; {
put8(w);
put8(w >> 8);
}
put32(f) long f; {
put16((int) f);
put16((int)(f >> 16));
}
/* ----- error handling ----- */
fail_check() {
error("argument range error");
}
/* VARARGS */
error(s,a1,a2,a3,a4) char *s; {
fprintf(stderr,"%s: line %d: ", filename, lineno);
fprintf(stderr,s,a1,a2,a3,a4);
fprintf(stderr,"\n");
errors++;
}
/* VARARGS */
fatal(s,a1,a2,a3,a4) char *s; {
error(s,a1,a2,a3,a4);
exit(-1);
}
/* VARARGS */
syntax(s,a1,a2,a3,a4) char *s; {
register c;
error(s,a1,a2,a3,a4);
do
c = nextchar();
while (c != '\n' && c != EOF);
longjmp(recover);
}

181
util/ncgg/Makefile Normal file
View File

@@ -0,0 +1,181 @@
# $Header$
CFILES=cgg.c subr.c main.c coerc.c enterkeyw.c error.c emlookup.c expr.c instruct.c iocc.c lookup.c output.c set.c strlookup.c var.c hall.c
OFILES=cgg.o subr.o main.o coerc.o enterkeyw.o error.o emlookup.o expr.o instruct.o iocc.o lookup.o set.o strlookup.o var.o hall.o
SOURCES=*.h cgg.y scan.l cvtkeywords keywords coerc.c emlookup.c error.c expr.c hall.c instruct.c iocc.c lookup.c main.c output.c set.c strlookup.c subr.c var.c
EMHOME=../..
EMH=$(EMHOME)/h
MANDIR=$(EMHOME)/man
INCLUDES=-I$(EMH)
CFLAGS=-O $(INCLUDES)
YFLAGS=-v -d
LDFLAGS=
LEXLIB=-ll
cgg: cgg.o $(OFILES) output.o
$(CC) $(LDFLAGS) $(OFILES) output.o $(EMHOME)/lib/em_data.a $(LEXLIB) -o cgg
install: cgg
rm -f $(EMHOME)/lib/ncgg
cp cgg $(EMHOME)/lib/ncgg
rm -f $(MANDIR)/ncgg.6
cp ncgg.6 $(MANDIR)/ncgg.6
cmp: cgg
-cmp cgg $(EMHOME)/lib/ncgg
-cmp ncgg.6 $(MANDIR)/ncgg.6
debugcgg: cgg.o $(OFILES) debugoutput.o
$(CC) $(LDFLAGS) $(OFILES) debugoutput.o $(EMHOME)/lib/em_data.a -ll -o cgg
cgg.o: scan.c
enterkeyw.c: cvtkeywords keywords y.tab.h
cvtkeywords keywords
debugoutput.o: debugoutput.c
$(CC) $(CFLAGS) -DCODEDEBUG -c debugoutput.c
debugoutput.c: output.c
cp output.c debugoutput.c
lint: $(CFILES)
lint $(INCLUDES) $(CFILES)
touch lint
clean:
rm -f cgg.c scan.c y.output y.tab.h enterkeyw.c
rm -f $(OFILES) output.o debugoutput.o cgg lint
pr:
pr $(SOURCES)
opr:
-make pr|opr
depend:
makedepend
cgg.o: $(EMH)/cgg_cg.h
coerc.o: $(EMH)/cgg_cg.h
debugoutput.o: $(EMH)/cgg_cg.h
expr.o: $(EMH)/cgg_cg.h
instruct.o: $(EMH)/cgg_cg.h
iocc.o: $(EMH)/cgg_cg.h
output.o: $(EMH)/cgg_cg.h
set.o: $(EMH)/cgg_cg.h
subr.o: $(EMH)/cgg_cg.h
var.o: $(EMH)/cgg_cg.h
# AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO
cgg.o: expr.h
cgg.o: extern.h
cgg.o: instruct.h
cgg.o: iocc.h
cgg.o: lookup.h
cgg.o: param.h
cgg.o: scan.c
cgg.o: set.h
cgg.o: varinfo.h
coerc.o: assert.h
coerc.o: extern.h
coerc.o: iocc.h
coerc.o: param.h
coerc.o: property.h
coerc.o: pseudo.h
coerc.o: reg.h
coerc.o: set.h
coerc.o: token.h
coerc.o: varinfo.h
debugoutput.o: assert.h
debugoutput.o: extern.h
debugoutput.o: instruct.h
debugoutput.o: lookup.h
debugoutput.o: param.h
debugoutput.o: property.h
debugoutput.o: pseudo.h
debugoutput.o: reg.h
debugoutput.o: regvar.h
debugoutput.o: set.h
debugoutput.o: token.h
debugoutput.o: varinfo.h
emlookup.o: expr.h
emlookup.o: param.h
enterkeyw.o: lookup.h
expr.o: assert.h
expr.o: expr.h
expr.o: extern.h
expr.o: lookup.h
expr.o: param.h
expr.o: property.h
expr.o: reg.h
expr.o: regvar.h
expr.o: set.h
expr.o: token.h
hall.o: assert.h
hall.o: param.h
hall.o: set.h
instruct.o: expr.h
instruct.o: extern.h
instruct.o: instruct.h
instruct.o: iocc.h
instruct.o: param.h
instruct.o: pseudo.h
instruct.o: set.h
instruct.o: varinfo.h
iocc.o: assert.h
iocc.o: expr.h
iocc.o: extern.h
iocc.o: iocc.h
iocc.o: lookup.h
iocc.o: param.h
iocc.o: property.h
iocc.o: regvar.h
iocc.o: set.h
iocc.o: token.h
lookup.o: assert.h
lookup.o: lookup.h
lookup.o: param.h
output.o: assert.h
output.o: extern.h
output.o: instruct.h
output.o: lookup.h
output.o: param.h
output.o: property.h
output.o: pseudo.h
output.o: reg.h
output.o: regvar.h
output.o: set.h
output.o: token.h
output.o: varinfo.h
scan.o: stdio.h
set.o: extern.h
set.o: lookup.h
set.o: param.h
set.o: property.h
set.o: reg.h
set.o: set.h
set.o: token.h
strlookup.o: param.h
subr.o: expr.h
subr.o: extern.h
subr.o: instruct.h
subr.o: lookup.h
subr.o: param.h
subr.o: property.h
subr.o: reg.h
subr.o: regvar.h
subr.o: set.h
subr.o: token.h
subr.o: varinfo.h
tables.o: data.h
tables.o: param.h
tables.o: tables.h
tables.o: types.h
var.o: instruct.h
var.o: lookup.h
var.o: param.h
var.o: property.h
var.o: reg.h
var.o: set.h
var.o: token.h

15
util/ncgg/makedepend Executable file
View File

@@ -0,0 +1,15 @@
: '$Header$'
for extension in c y
do
for file in *.$extension
do ofile=`basename $file .$extension`.o
grep '^# *include.*"' $file|sed "s/.*\"\(.*\)\".*/$ofile: \1/"
done
done | sort -u >depend
ed - Makefile <<'!'
/AUTOAUTOAUTO/+,$d
$r depend
w
q
!
rm -f depend

228
util/opt/Makefile Normal file
View File

@@ -0,0 +1,228 @@
# $Header$
EMHOME=../..
CFILES=main.c getline.c lookup.c var.c process.c backward.c util.c \
alloc.c putline.c cleanup.c peephole.c flow.c reg.c tes.c \
pop_push.c
OFILES=main.o getline.o lookup.o var.o process.o backward.o util.o\
alloc.o putline.o cleanup.o peephole.o flow.o tes.o pop_push.o
ONOGLOB=regnoglob.o
OGLOB=regglob.o
LIBS=$(EMHOME)/lib/em_data.a
CFLAGS=-O -DNDEBUG -I$(EMHOME)/h
LDFLAGS=
LINT=lint
OPR=opr
PROPTS=
CPP=$(EMHOME)/lib/cpp
# LEXLIB is implementation dependent, try -ll or -lln first
LEXLIB=-ll
all: opt opt2
opt: $(OFILES) $(ONOGLOB) pattern.o $(LIBS)
$(CC) $(LDFLAGS) $(CFLAGS) $(OFILES) $(ONOGLOB) pattern.o $(LIBS) -o opt
opt2: $(OFILES) $(OGLOB) pattern.o $(LIBS)
$(CC) $(LDFLAGS) $(CFLAGS) $(OFILES) $(OGLOB) pattern.o $(LIBS) -o opt2
test: opt testopt
testopt
cmp: all
-cmp opt $(EMHOME)/lib/em_opt
-cmp opt2 $(EMHOME)/lib/em_opt2
-cmp em_opt.6 $(EMHOME)/man/em_opt.6
install:all
-size opt $(EMHOME)/lib/em_opt
rm -f $(EMHOME)/lib/em_opt
cp opt $(EMHOME)/lib/em_opt
-size opt2 $(EMHOME)/lib/em_opt2
rm -f $(EMHOME)/lib/em_opt2
cp opt2 $(EMHOME)/lib/em_opt2
rm -f $(EMHOME)/man/em_opt.6
cp em_opt.6 $(EMHOME)/man/em_opt.6
pattern.c: patterns mktab
$(CPP) patterns | mktab > pattern.c
mktab: mktab.o $(LIBS)
$(CC) $(CFLAGS) mktab.o $(LIBS) $(LEXLIB) -o mktab
mktab.o: scan.c optim.h param.h pattern.h types.h
pop_push.c pop_push.h: $(EMHOME)/etc/em_table pop_push.awk
awk -f pop_push.awk < $(EMHOME)/etc/em_table > pop_push.c
depend: pattern.c
sed '/^#AUTOAUTO/,$$d' Makefile >Makefile.new
echo '#AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO' >> Makefile.new
cp reg.c regglob.c
cp reg.c regnoglob.c
mkdep $(CFILES) pattern.c regglob.c regnoglob.c | sed 's/\.c:/.o:/' >> Makefile.new
rm -f regglob.c regnoglob.c
mv Makefile Makefile.old
mv Makefile.new Makefile
lint: $(CFILES) pattern.c
$(LINT) $(CFLAGS) $(CFILES) pattern.c>lint 2>&1
printall:
-pr $(PROPTS) Makefile -n *.h `ls $(CFILES)` mktab.y scan.l patterns|$(OPR)
touch print
print: Makefile *.h $(CFILES) mktab.y scan.l patterns
-pr $(PROPTS) -n $? | $(OPR)
touch print
opr:
make pr | $(OPR)
pr:
@pr $(PROPTS) -n Makefile *.h $(CFILES) mktab.y scan.l patterns
clean:
rm -f *.o opt mktab mktab.c scan.c pattern.c opt2 Out \
pop_push.c pop_push.h
regnoglob.o: reg.c
$(CC) $(CFLAGS) -c reg.c
mv reg.o regnoglob.o
regglob.o: reg.c
$(CC) $(CFLAGS) -c -DGLOBAL_OPT reg.c
mv reg.o regglob.o
# the next lines are generated automatically
#AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO
main.o: alloc.h
main.o: ext.h
main.o: param.h
main.o: tes.h
main.o: types.h
getline.o: alloc.h
getline.o: ext.h
getline.o: line.h
getline.o: lookup.h
getline.o: param.h
getline.o: proinf.h
getline.o: tes.h
getline.o: types.h
lookup.o: alloc.h
lookup.o: lookup.h
lookup.o: param.h
lookup.o: proinf.h
lookup.o: tes.h
lookup.o: types.h
var.o: lookup.h
var.o: param.h
var.o: proinf.h
var.o: tes.h
var.o: types.h
process.o: alloc.h
process.o: assert.h
process.o: ext.h
process.o: line.h
process.o: lookup.h
process.o: param.h
process.o: proinf.h
process.o: tes.h
process.o: types.h
backward.o: alloc.h
backward.o: assert.h
backward.o: ext.h
backward.o: line.h
backward.o: lookup.h
backward.o: param.h
backward.o: proinf.h
backward.o: tes.h
backward.o: types.h
util.o: assert.h
util.o: ext.h
util.o: lookup.h
util.o: optim.h
util.o: param.h
util.o: proinf.h
util.o: tes.h
util.o: types.h
alloc.o: alloc.h
alloc.o: assert.h
alloc.o: line.h
alloc.o: lookup.h
alloc.o: param.h
alloc.o: proinf.h
alloc.o: tes.h
alloc.o: types.h
putline.o: alloc.h
putline.o: assert.h
putline.o: ext.h
putline.o: line.h
putline.o: lookup.h
putline.o: optim.h
putline.o: param.h
putline.o: proinf.h
putline.o: tes.h
putline.o: types.h
cleanup.o: assert.h
cleanup.o: ext.h
cleanup.o: lookup.h
cleanup.o: param.h
cleanup.o: types.h
peephole.o: alloc.h
peephole.o: assert.h
peephole.o: ext.h
peephole.o: line.h
peephole.o: lookup.h
peephole.o: optim.h
peephole.o: param.h
peephole.o: pattern.h
peephole.o: proinf.h
peephole.o: tes.h
peephole.o: types.h
flow.o: alloc.h
flow.o: ext.h
flow.o: line.h
flow.o: optim.h
flow.o: param.h
flow.o: proinf.h
flow.o: tes.h
flow.o: types.h
reg.o: alloc.h
reg.o: assert.h
reg.o: ext.h
reg.o: line.h
reg.o: param.h
reg.o: proinf.h
reg.o: tes.h
reg.o: types.h
tes.o: alloc.h
tes.o: assert.h
tes.o: ext.h
tes.o: line.h
tes.o: param.h
tes.o: pop_push.h
tes.o: proinf.h
tes.o: tes.h
tes.o: types.h
pop_push.o: pop_push.h
pattern.o: param.h
pattern.o: pattern.h
pattern.o: types.h
regglob.o: alloc.h
regglob.o: assert.h
regglob.o: ext.h
regglob.o: line.h
regglob.o: param.h
regglob.o: proinf.h
regglob.o: tes.h
regglob.o: types.h
regnoglob.o: alloc.h
regnoglob.o: assert.h
regnoglob.o: ext.h
regnoglob.o: line.h
regnoglob.o: param.h
regnoglob.o: proinf.h
regnoglob.o: tes.h
regnoglob.o: types.h

15
util/opt/makedepend Executable file
View File

@@ -0,0 +1,15 @@
: '$Header$'
for extension in c y
do
for file in *.$extension
do ofile=`basename $file .$extension`.o
grep '^# *include.*"' $file|sed "s/.*\"\(.*\)\".*/$ofile: \1/"
done
done | sort -u >depend
ed - Makefile <<'!'
/AUTOAUTOAUTO/+,$d
$r depend
w
q
!
rm -f depend

226
util/opt/shc.c Normal file
View File

@@ -0,0 +1,226 @@
/*
* This file contains the main part of the stackheight computation phase.
*
* Author: Hans van Eck.
*/
#include <stdio.h>
#include <em_spec.h>
#include <em_mnem.h>
#include <em_pseu.h>
#include "param.h"
#include "assert.h"
#include "types.h"
#include "shc.h"
#include "alloc.h"
#include "proinf.h"
#include "line.h"
#include "ext.h"
#include "pop_push.h"
extern char *pop_push[];
extern char flow_tab[];
#define NON_CONTINUABLE(i) (flow_tab[i]&JUMP)
#define ISABRANCH(i) (flow_tab[i]&HASLABEL)
#define ISCONDBRANCH(i) (flow_tab[i]&CONDBRA)
lblst_p est_list = NULL;
#define INSTR(lnp) (lnp->l_instr & BMASK)
#define TYPE(lnp) lnp->l_optyp
#define PREV(lnp) lnp->l_prev
#define SHORT(lnp) lnp->l_a.la_short
#define MINI(lnp) ((lnp->l_optyp & BMASK) - Z_OPMINI)
#define IS_MINI(lnp) (lnp->l_optyp >= OPMINI)
#define IS_LOC(l) (l!=(line_p) 0 && INSTR(l)==op_loc && IS_MINI(l))
int state;
static int stack_height = 0;
init_state()
{
stack_height = 0;
change_state(KNOWN);
est_list = NULL;
}
shc_pseudos()
{
register line_p lp;
for (lp = pseudos; lp != (line_p)0; lp = lp->l_next) {
switch(INSTR(lp)) {
case ps_con:
case ps_rom:
if (lp->l_optyp == OPLIST) {
register arg_p ap = lp->l_a.la_arg;
while (ap != (arg_p) 0) {
if (ap->a_typ == ARGNUM) {
assign_label(ap->a_a.a_np->n_repl);
}
ap = ap->a_next;
}
} else if (lp->l_optyp == OPNUMLAB)
assign_label(lp->l_a.la_np->n_repl);
}
}
}
shc_instr(lnp)
line_p lnp;
{
char *s;
register instr = INSTR(lnp);
register int mult, arg, argdef;
line_p x = PREV(lnp);
line_p y = (x == (line_p) 0 ? (line_p) 0 : PREV(x));
if (state == NO_STACK_MES) return;
if ( instr == op_lab) {
do_inst_label(lnp);
return;
}
if (instr < sp_fmnem || instr > sp_lmnem) {
return;
}
if(state == NOTREACHED) return; /* What else ? */
s = pop_push[instr];
if (*s != '0')
while (*s != '\0') {
if (*s++ == '-') mult = -1;
else mult = 1;
if (TYPE(lnp) == OPSHORT) {
arg = SHORT(lnp);
if (arg < wordsize) arg = wordsize;
argdef = TRUE;
} else if (IS_MINI(lnp)) {
arg = MINI(lnp);
if (arg > 0 && arg < wordsize) arg = wordsize;
if (arg < 0 && -arg < wordsize) arg = -wordsize;
argdef = TRUE;
} else argdef = FALSE;
switch (*s++) {
case 'w': stack_height += mult * wordsize; break;
case 'd': stack_height += mult * wordsize * 2; break;
case 'p': stack_height += mult * pointersize; break;
case 'a':
if (argdef == FALSE || instr == op_ass) {
change_state(NO_STACK_MES);
return;
}
stack_height += mult * arg;
break;
case 'x':
if (IS_LOC(x)) {
arg = MINI(x);
if (arg < wordsize) arg = wordsize;
stack_height += mult * arg;
break;
}
change_state(NO_STACK_MES);
return;
case 'y':
if (IS_LOC(y)) {
arg = MINI(y);
if (arg < wordsize) arg = wordsize;
stack_height += mult * arg;
break;
}
change_state(NO_STACK_MES);
return;
case '?':
/* Actually, the effect of a ret on the stack is
* known, but it has a '?' anyway. I think this
* should be changed in ~etc/em_table
*/
if (instr == op_ret)
break;
change_state(NO_STACK_MES);
return;
default:
assert(FALSE);
}
}
if (ISABRANCH(instr)) do_inst_label(lnp);
if (NON_CONTINUABLE(instr)) change_state(NOTREACHED);
}
change_state(mode)
int mode;
{
state = mode;
if (mode != KNOWN) stack_height = 0;
}
delete_labels()
{
register lblst_p tmp;
while ((tmp = est_list) != NULL) {
est_list = est_list->ll_next;
oldlblst(tmp);
}
}
inst_old_label(lst_elt)
register lblst_p lst_elt;
{
if (state != NOTREACHED) {
if (stack_height < 0 || lst_elt->ll_height != stack_height) {
change_state(NO_STACK_MES);
}
} else { /* after a label */
stack_height = lst_elt->ll_height;
}
}
inst_new_label(label)
register num_p label;
{
register lblst_p lst_elt;
lst_elt = newlblst();
lst_elt->ll_next = est_list;
lst_elt->ll_num = label;
lst_elt->ll_height = stack_height;
est_list = lst_elt;
label->n_lst_elt = lst_elt;
label->n_flags |= NUMSET;
}
assign_label(label)
num_p label;
{
if (label->n_flags & NUMSET)
inst_old_label(label->n_lst_elt);
else inst_new_label(label);
}
do_inst_label(lnp) /* (re-)install a label */
line_p lnp;
{
num_p label = lnp->l_a.la_np->n_repl;
int instr = INSTR(lnp);
assign_label(label);
if (instr == op_lab) {
if (state == NOTREACHED) {
label->n_lst_elt->ll_fallthrough = FALSE;
} else {
label->n_lst_elt->ll_fallthrough = TRUE;
}
} else if (ISCONDBRANCH(instr)) { /* conditional branch */
label->n_flags |= NUMCOND;
}
if (state != NO_STACK_MES) change_state(KNOWN);
}

20
util/opt/shc.h Normal file
View File

@@ -0,0 +1,20 @@
/*
* Author: Hans van Eck.
*/
typedef struct label_list *lblst_p;
struct label_list {
lblst_p ll_next; /* pointer to next label in the list */
num_p ll_num; /* pointer to label definition */
short ll_height; /* the height of the stack at this label */
char ll_fallthrough; /* is the label reached by fallthrough ? */
};
typedef struct label_list lblst_t;
extern lblst_p est_list;
extern int state;
#define KNOWN 1
#define NOTREACHED 2
#define NO_STACK_MES 3

17
util/shf/Makefile Normal file
View File

@@ -0,0 +1,17 @@
# $Header$
install:
-rm -f ../../bin/march
cp march.sh ../../bin/march
clean:
@echo always clean
cmp:
cmp march.sh ../../bin/march
opr:
make pr|opr
pr:
pr march.sh

40
util/topgen/Makefile Normal file
View File

@@ -0,0 +1,40 @@
EM = ../..
CFLAGS = -O
SOURCE = token.h symtab.h misc.h tunable.h main.c topgen.g LLlex.c symtab.c pattern.c hash.c
CFILES = main.c topgen.c Lpars.c LLlex.c symtab.c pattern.c hash.c
OFILES = main.o topgen.o Lpars.o LLlex.o symtab.o pattern.o hash.o
all: parser
@make topgen
cmp: all
cmp topgen $(EM)/lib/topgen
install: all
cp topgen $(EM)/lib/topgen
clean:
rm -f topgen *.o Lpars.c Lpars.h topgen.c parser
parser: topgen.g
$(EM)/bin/LLgen topgen.g
touch parser
topgen.o: token.h Lpars.h symtab.h misc.h
Lpars.o: Lpars.h
LLlex.o: token.h Lpars.h tunable.h
symtab.o: symtab.h
hash.o: misc.h
pattern.o: misc.h symtab.h
topgen: $(OFILES)
$(CC) $(OFILES) -o topgen
lint: parser
lint $(CFILES)
pr:
@pr $(SOURCE) Makefile
opr:
make pr ^ opr