Initial revision
This commit is contained in:
parent
c89acc55c7
commit
94e069fde1
104
lib/vax4/sedf
Normal file
104
lib/vax4/sedf
Normal file
|
@ -0,0 +1,104 @@
|
|||
# $Header$
|
||||
/movab/ {
|
||||
s/movab 1(\(.*\)),\1$/incl \1/
|
||||
s/movab -1(\(.*\)),\1$/decl \1/
|
||||
s/movab \([0-9]*\)(\(.*\)),\2$/addl2 $\1,\2/
|
||||
s/movab -\([0-9]*\)(\(.*\)),\2$/subl2 $\1,\2/
|
||||
s/movab 0(\(.*\)) \[\(.*\)\],\1$/addl2 \2,\1/
|
||||
s/movab 0(\(.*\)) \[\(.*\)\],\2$/addl2 \1,\2/
|
||||
}
|
||||
/$0/ {
|
||||
s/movz[bw]\([wl]\) $0,/clr\1 /
|
||||
s/mov\([bwl]\) $0,/clr\1 /
|
||||
s/cvt[bw]\([wl]\) $0,/clr\1 /
|
||||
}
|
||||
/add/ {
|
||||
s/\(add[fdlw]\)3 \(.*\),\(.*\),\3$/\12 \2,\3/
|
||||
s/\(add[fdlw]\)3 \(.*\),\(.*\),\2$/\12 \3,\2/
|
||||
s/add\([wl]\)2 \$-\([0-9]*\),/sub\12 $\2,/
|
||||
s/add\([wl]\)3 \$-\([0-9]*\),/sub\13 $\2,/
|
||||
s/add\([wl]\)3 \(.*\),\$-\([0-9]*\),/sub\13 $\3,\2,/
|
||||
}
|
||||
/mul/ {
|
||||
s/\(mul[fdlw]\)3 \(.*\),\(.*\),\3$/\12 \2,\3/
|
||||
s/\(mul[fdlw]\)3 \(.*\),\(.*\),\2$/\12 \3,\2/
|
||||
}
|
||||
/sub/ {
|
||||
s/\(sub[fdlw]\)3 \(.*\),\(.*\),\3$/\12 \2,\3/
|
||||
s/sub\([wl]\)2 \$-\([0-9]*\),/add\12 $\2,/
|
||||
s/sub\([wl]\)3 \$-\([0-9]*\),/add\13 $\2,/
|
||||
}
|
||||
/div/s/\(div[fdlw]\)3 \(.*\),\(.*\),\3$/\12 \2,\3/
|
||||
/bi/s/\(bi[cs][lw]\)3 \(.*\),\(.*\),\3$/\12 \2,\3/
|
||||
/bis/s/\(bis[lw]\)3 \(.*\),\(.*\),\2$/\12 \3,\2/
|
||||
/xor/ {
|
||||
s/\(xor[lw]\)3 \(.*\),\(.*\),\3$/\12 \2,\3/
|
||||
s/\(xor[lw]\)3 \(.*\),\(.*\),\2$/\12 \3,\2/
|
||||
}
|
||||
/$1/ {
|
||||
s/add\([wl]\)2 \$1,/inc\1 /
|
||||
s/sub\([wl]\)2 \$1,/dec\1 /
|
||||
}
|
||||
/$-1/ {
|
||||
s/add\([wl]\)2 \$-1,/dec\1 /
|
||||
s/sub\([wl]\)2 \$-1,/inc\1 /
|
||||
}
|
||||
/cmp[bwl].*$0/ {
|
||||
N
|
||||
s/cmp\([bwl]\) \(.*\),$0$/tst\1 \2/
|
||||
s/cmp\([bwl]\) $0,\(.*\)\njneq/tst\1 \2\
|
||||
jneq/
|
||||
s/cmp\([bwl]\) $0,\(.*\)\njeql/tst\1 \2\
|
||||
jeql/
|
||||
s/cmp\([bwl]\) $0,\(.*\)\njgtr/tst\1 \2\
|
||||
jlss/
|
||||
s/cmp\([bwl]\) $0,\(.*\)\njlss/tst\1 \2\
|
||||
jgtr/
|
||||
s/cmp\([bwl]\) $0,\(.*\)\njgeq/tst\1 \2\
|
||||
jleq/
|
||||
s/cmp\([bwl]\) $0,\(.*\)\njleq/tst\1 \2\
|
||||
jgeq/
|
||||
P
|
||||
D
|
||||
}
|
||||
/(sp)+/ {
|
||||
N
|
||||
s/movl (sp)+,\(.*\)\npushl \1$/movl (sp),\1/
|
||||
s/tst[wl] (sp)+\nmovl fp,sp$/movl fp,sp/
|
||||
s/tst\([wl]\) (sp)+\nmov\1 \(.*\),-(sp)/mov\1 \2,(sp)/
|
||||
s/tst\([wl]\) (sp)+\nclr\1 -(sp)/clr\1 (sp)/
|
||||
s/tst\([wl]\) (sp)+\nmovzb\1 \(.*\),-(sp)/movzb\1 \2,(sp)/
|
||||
s/tst\([wl]\) (sp)+\ncvtb\1 \(.*\),-(sp)/cvtb\1 \2,(sp)/
|
||||
s/tst\([wl]\) (sp)+\ntst\1 \(.*\)$/mov\1 \2,(sp)+/
|
||||
s/tstl (sp)+\npushl \(.*\)$/movl \1,(sp)/
|
||||
s/tstl (sp)+\npusha\([bwlq]\) \(.*\)$/mova\1 \2,(sp)/
|
||||
P
|
||||
D
|
||||
}
|
||||
/^addl2 .*,sp/ {
|
||||
N
|
||||
s/addl2 .*,sp\nmovl fp,sp$/movl fp,sp/
|
||||
s/^addl2 $6,sp\nmovw \(.*\),-(sp)/tstl (sp)+\
|
||||
movw \1,(sp)/
|
||||
s/^addl2 $6,sp\nclrw -(sp)/tstl (sp)+\
|
||||
clrw (sp)/
|
||||
s/^addl2 $8,sp\nmovq \(.*\),-(sp)/movq \1,(sp)/
|
||||
P
|
||||
D
|
||||
}
|
||||
/clrw -(sp)/ {
|
||||
N
|
||||
s/clrw -(sp)\nmovw \($[0-9]*\),-(sp)/pushl \1/
|
||||
s/clrw -(sp)\nmnegw $\([0-9]*\),-(sp)/movzwl $-\1,-(sp)/
|
||||
s/clrw -(sp)\nmovw \(.*\),-(sp)/movzwl \1,-(sp)/
|
||||
s/clrw -(sp)\ncvtbw \(\$[0-9]*\),-(sp)/pushl \1/
|
||||
s/clrw -(sp)\ncvtbw \(\$.*\),-(sp)/movzwl \1,-(sp)/
|
||||
P
|
||||
D
|
||||
}
|
||||
/mov/ {
|
||||
N
|
||||
s/mov\([wl]\) \(.*\),\(.*\)\ntst\1 \3$/mov\1 \2,\3/
|
||||
P
|
||||
D
|
||||
}
|
8
mach/vax4/cg/READ_ME
Normal file
8
mach/vax4/cg/READ_ME
Normal file
|
@ -0,0 +1,8 @@
|
|||
--------- $Header$ --------
|
||||
The file "table" is too large. The "cgg" program cannot generate
|
||||
"tables.h" and "tables.c" on a PDP 11/44.
|
||||
Therefore the distribution includes two files "tables1.c" and "tables1.h",
|
||||
which you can copy to "tables.c" and "tables.h".
|
||||
Make sure "tables.c" and "tables.h" are newer than "table",
|
||||
before trying again. They also must be newer than the "cgg" program
|
||||
(../../../lib/cgg).
|
270
mach/vax4/cg/mach.c
Normal file
270
mach/vax4/cg/mach.c
Normal file
|
@ -0,0 +1,270 @@
|
|||
#ifndef NORCSID
|
||||
static char rcsid[] = "$Header$";
|
||||
#endif
|
||||
/*
|
||||
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
*
|
||||
* This product is part of the Amsterdam Compiler Kit.
|
||||
*
|
||||
* Permission to use, sell, duplicate or disclose this software must be
|
||||
* obtained in writing. Requests for such permissions may be sent to
|
||||
*
|
||||
* Dr. Andrew S. Tanenbaum
|
||||
* Wiskundig Seminarium
|
||||
* Vrije Universiteit
|
||||
* Postbox 7161
|
||||
* 1007 MC Amsterdam
|
||||
* The Netherlands
|
||||
*
|
||||
*/
|
||||
|
||||
/* Machine dependent back end routines for the VAX using 4-byte words
|
||||
*/
|
||||
|
||||
con_part(sz,w) register sz; word w; {
|
||||
|
||||
/* Byte order: | 3 | 2 | 1 | 0 | */
|
||||
|
||||
/* Align new bytes on boundary of its on size. */
|
||||
while (part_size % sz) part_size++;
|
||||
|
||||
if (part_size == EM_WSIZE)
|
||||
part_flush();
|
||||
if (sz == 1 || sz == 2) {
|
||||
/* Smaller than a machineword. */
|
||||
w &= (sz == 1 ? 0xFF : 0xFFFF);
|
||||
w <<= 8 * part_size;
|
||||
part_word |= w;
|
||||
} else {
|
||||
assert(sz == 4);
|
||||
part_word = w;
|
||||
}
|
||||
part_size += sz;
|
||||
} /* con_part */
|
||||
|
||||
con_mult(sz) word sz; {
|
||||
|
||||
if (sz != 4)
|
||||
fatal("bad icon/ucon size");
|
||||
fprintf(codefile,".long\t%s\n",str);
|
||||
}
|
||||
|
||||
mes(mesno) word mesno ; {
|
||||
while (getarg(any_ptyp) != sp_cend );
|
||||
}
|
||||
|
||||
con_float() {
|
||||
|
||||
/* Insert a dot at the right position, if it is not present,
|
||||
* to make the floating point constant acceptable to the assembler.
|
||||
*/
|
||||
register char * c;
|
||||
extern char * index();
|
||||
|
||||
if (argval != 4 && argval != 8)
|
||||
fatal("bad fcon size");
|
||||
if (argval == 8)
|
||||
fprintf(codefile,".double\t0d");
|
||||
else fprintf(codefile,".float\t0f");
|
||||
|
||||
if (index(str,'.') != (char *) 0) {
|
||||
fprintf(codefile,"%s\n",str);
|
||||
|
||||
/* There must be a dot after the `e' or - if the `e' is not present -
|
||||
* at the end.
|
||||
*/
|
||||
} else if ((c = index(str,'e')) != (char *) 0) {
|
||||
*c++ = '\0';
|
||||
fprintf(codefile,"%s.e%s\n",str,c--);
|
||||
*c = 'e';
|
||||
} else fprintf(codefile,"%s.\n",str);
|
||||
} /* con_float */
|
||||
|
||||
#ifndef REGVARS
|
||||
prolog(nlocals) full nlocals; {
|
||||
|
||||
fprintf(codefile,"\tpushl\tfp\n\tmovl\tsp,fp\n");
|
||||
if (nlocals == 0)
|
||||
return;
|
||||
if (nlocals == 4)
|
||||
fprintf(codefile,"\tclrl\t-(sp)\n");
|
||||
else if (nlocals == 8)
|
||||
fprintf(codefile,"\tclrq\t-(sp)\n");
|
||||
else
|
||||
fprintf(codefile,"\tsubl2\t$%ld,sp\n",nlocals);
|
||||
}
|
||||
|
||||
#endif REGVARS
|
||||
|
||||
char *segname[] = {
|
||||
".text", /* SEGTXT */
|
||||
".data", /* SEGCON */
|
||||
".data", /* SEGROM */
|
||||
".data" /* SEGBSS */
|
||||
};
|
||||
|
||||
#ifdef REGVARS
|
||||
int EM_BSIZE; /* Difference between AB and LB. */
|
||||
static int nlocals; /* Number of local variables. */
|
||||
|
||||
#define NR_REG 8 /* Number of registers. */
|
||||
#define FIRST_REG 4
|
||||
#define LAST_REG (FIRST_REG + NR_REG - 1)
|
||||
|
||||
prolog(n) { /* Save number of locals. */
|
||||
nlocals = n;
|
||||
}
|
||||
|
||||
/*
|
||||
* Structure to store information about the registers to be stored.
|
||||
*/
|
||||
static struct s_reg {
|
||||
char * sr_str; /* Name of register used. */
|
||||
long sr_off; /* Offset from LB. */
|
||||
int sr_size;/* Size in bytes. */
|
||||
} a_reg[NR_REG + 1], *p_reg;
|
||||
|
||||
i_regsave() { /* Initialize saving of registers. */
|
||||
EM_BSIZE = 0;
|
||||
p_reg = a_reg;
|
||||
}
|
||||
|
||||
regsave(str, off, size) char * str; long off; int size; {
|
||||
|
||||
/* Called for each register to be saved. */
|
||||
|
||||
p_reg->sr_str = str;
|
||||
p_reg->sr_off = off;
|
||||
(p_reg++)->sr_size = size;
|
||||
fprintf(codefile,
|
||||
"\t# Local %ld, size %d, to register %s\n",
|
||||
off, size, str
|
||||
);
|
||||
}
|
||||
|
||||
f_regsave() {
|
||||
|
||||
register struct s_reg * p;
|
||||
register int mask;
|
||||
register int i;
|
||||
register int count;
|
||||
|
||||
mask = 0;
|
||||
count = p_reg - a_reg;
|
||||
for (p = a_reg; p < p_reg; p++) {
|
||||
/* For each register to be saved, set a bit in the
|
||||
* mask corresponding to its number.
|
||||
*/
|
||||
i = atoi(p->sr_str + 1);
|
||||
if (p->sr_size <= 4)
|
||||
mask |= (1 << i);
|
||||
else {
|
||||
mask |= (3 << i);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Generate code to save registers. */
|
||||
if (count > 2)
|
||||
fprintf(codefile, "pushr\t$%d\n", mask);
|
||||
else
|
||||
for (i = FIRST_REG; i <= LAST_REG; i++) {
|
||||
/* For all registers that can be used,
|
||||
* see if it must be saved, and do that as cheap
|
||||
* as possible.
|
||||
*/
|
||||
if (((mask >> i) & 03) == 03) {
|
||||
fprintf(codefile, "movq\tr%d,-(sp)\n",i);
|
||||
break;
|
||||
} else if ((1 << i) & mask) {
|
||||
if (count == 1)
|
||||
fprintf(codefile,"pushl\tr%d\n",i);
|
||||
else
|
||||
fprintf(codefile,"pushr\t$%d\n",mask);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Save a word indicating which registers were saved.
|
||||
* The count uniquely specifies which registers were saved, because
|
||||
* registers are always allocated consecutively within a class,
|
||||
* starting from FIRST_REG. I only have one class.
|
||||
*/
|
||||
fprintf(codefile, "pushl\t$%d\n", count);
|
||||
|
||||
/* Compute AB - LB. */
|
||||
EM_BSIZE = 4 * count + 12;
|
||||
|
||||
/* Now finish the procedure prolog. */
|
||||
fprintf(codefile, "pushl\tfp\nmovl\tsp,fp\n");
|
||||
|
||||
/* Emit code to initialize parameters in registers. */
|
||||
for (p = a_reg; p < p_reg; p++) {
|
||||
if (p->sr_off >= 0) {
|
||||
if (p->sr_size == 4) {
|
||||
fprintf(codefile,
|
||||
"movl\t%ld(fp),%s\n",
|
||||
p->sr_off + EM_BSIZE, p->sr_str
|
||||
);
|
||||
} else if (p->sr_size == 8) {
|
||||
fprintf(codefile,
|
||||
"movq\t%ld(fp),%s\n",
|
||||
p->sr_off + EM_BSIZE, p->sr_str
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Generate room for locals. */
|
||||
if (nlocals == 0)
|
||||
return;
|
||||
if (nlocals == 4)
|
||||
fprintf(codefile,"clrl\t-(sp)\n");
|
||||
else if (nlocals == 8)
|
||||
fprintf(codefile,"clrq\t-(sp)\n");
|
||||
else
|
||||
fprintf(codefile,"subl2\t$%ld,sp\n",nlocals);
|
||||
|
||||
} /* f_regsave */
|
||||
|
||||
regreturn() {
|
||||
|
||||
fprintf(codefile, "jmp\t.return\n");
|
||||
} /* regreturn */
|
||||
|
||||
regscore(off, size, typ, score, totyp) long off; {
|
||||
|
||||
register int i;
|
||||
|
||||
i = score; /* Local/parameter is used score times. */
|
||||
|
||||
/* If the offset doesn't fit in a byte, word-offset is used,
|
||||
* which is one byte more expensive.
|
||||
*/
|
||||
if (off > 109 || off < -128) i *= 2; /* Word offset. */
|
||||
|
||||
/* 109: guestimate. We don't know AB -LB yet.
|
||||
* 109 is the number if there are two registervariables.
|
||||
*/
|
||||
|
||||
/* Compute cost of initialization for parameters. */
|
||||
if (off > 109)
|
||||
i -= 5;
|
||||
else if (off >= 0)
|
||||
i -= 4;
|
||||
|
||||
if (typ == reg_pointer)
|
||||
i += score; /* Sometimes saves an instruction. */
|
||||
else if (typ == reg_loop)
|
||||
i += 5;
|
||||
|
||||
i -= 2; /* Cost of save. */
|
||||
|
||||
/* Actually the first registers are more expensive, but then
|
||||
* the following registers are cheaper.
|
||||
*/
|
||||
|
||||
return (i);
|
||||
} /* regscore */
|
||||
|
||||
#endif REGVARS
|
23
mach/vax4/cg/mach.h
Normal file
23
mach/vax4/cg/mach.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
/* $Header$ */
|
||||
#define ex_ap(x) fprintf(codefile,".globl\t%s\n",x)
|
||||
#define in_ap(x) /* nothing */
|
||||
|
||||
#define newilb(x) fprintf(codefile,"%s:\n",x)
|
||||
#define newdlb(x) fprintf(codefile,"%s:\n",x)
|
||||
#define dlbdlb(s1,s2) fprintf(codefile,"%s = %s\n",s1,s2)
|
||||
#define newlbss(x,f) fprintf(codefile,"%s:.space\t%ld\n",x,f)
|
||||
|
||||
#define cst_fmt "$%ld"
|
||||
#define off_fmt "%ld"
|
||||
#define ilb_fmt "I%03x%04x"
|
||||
#define dlb_fmt "_%d"
|
||||
#define hol_fmt "hol%d"
|
||||
|
||||
#define hol_off "%ld+hol%d"
|
||||
|
||||
#define con_cst(w) fprintf(codefile,".long\t%ld\n",w)
|
||||
#define con_ilb(x) fprintf(codefile,".long\t%s\n",x)
|
||||
#define con_dlb(x) fprintf(codefile,".long\t%s\n",x)
|
||||
|
||||
#define id_first '_'
|
||||
#define BSS_INIT 0
|
4016
mach/vax4/cg/table
Normal file
4016
mach/vax4/cg/table
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue