diff options
author | Anders Magnusson <ragge@cvs.openbsd.org> | 2007-10-29 16:38:56 +0000 |
---|---|---|
committer | Anders Magnusson <ragge@cvs.openbsd.org> | 2007-10-29 16:38:56 +0000 |
commit | b87c6e323fd882c431b88a0e12952a63c8964e66 (patch) | |
tree | af57391fd48c28155802f36fb2ea65c1c4eebaf3 /usr.bin/pcc | |
parent | 56e3933feeb8837461d81ca78c8d8a138ff94cd2 (diff) |
From master repo:
> calls argument numbers are in registers, not bytes.
> If a jump is to the return label, emit ret insn instead.
> Add ADDROF table entry.
> Remove some unused entries.
> Do a Z call for emitted GOTOs.
> Only create constants for function names, they are called by name anyway.
Diffstat (limited to 'usr.bin/pcc')
-rw-r--r-- | usr.bin/pcc/vax/local.c | 15 | ||||
-rw-r--r-- | usr.bin/pcc/vax/local2.c | 43 | ||||
-rw-r--r-- | usr.bin/pcc/vax/table.c | 42 |
3 files changed, 46 insertions, 54 deletions
diff --git a/usr.bin/pcc/vax/local.c b/usr.bin/pcc/vax/local.c index 3ae5b4e4364..7f0c233f417 100644 --- a/usr.bin/pcc/vax/local.c +++ b/usr.bin/pcc/vax/local.c @@ -1,4 +1,4 @@ -/* $OpenBSD: local.c,v 1.2 2007/10/27 14:19:18 ragge Exp $ */ +/* $OpenBSD: local.c,v 1.3 2007/10/29 16:38:55 ragge Exp $ */ /* * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. * @@ -213,10 +213,17 @@ clocal(p) NODE *p; { return(p); } +/* + * Can we take & of a NAME? + */ int -andable( p ) NODE *p; { - return(1); /* all names can have & taken on them */ - } +andable(NODE *p) +{ + + if ((p->n_type & ~BTMASK) == FTN) + return 1; /* functions are called by name */ + return 0; /* Delay name reference to table, for PIC code generation */ +} void cendarg(){ /* at the end of the arguments of a ftn, set the automatic offset */ diff --git a/usr.bin/pcc/vax/local2.c b/usr.bin/pcc/vax/local2.c index 055b8c2a24d..c2f75258505 100644 --- a/usr.bin/pcc/vax/local2.c +++ b/usr.bin/pcc/vax/local2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: local2.c,v 1.2 2007/10/27 14:19:18 ragge Exp $ */ +/* $OpenBSD: local2.c,v 1.3 2007/10/29 16:38:55 ragge Exp $ */ /* * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. * @@ -40,8 +40,6 @@ static void prtype(NODE *n); static void acon(NODE *p); -# define BITMASK(n) ((1L<<n)-1) - /* * Print out the prolog assembler. * addto and regoff are already calculated. @@ -283,14 +281,10 @@ zzzcode( p, c ) register NODE *p; { } case 'C': /* num words pushed on arg stack */ - { - int pr = p->n_qual; - - if (p->n_op == STCALL || p->n_op == USTCALL) - pr += 4; - printf("$%d", pr); - break; - } + if (p->n_op == STCALL || p->n_op == USTCALL) + p->n_qual++; + printf("$%d", p->n_qual); + break; case 'D': /* INCR and DECR */ zzzcode(p->n_left, 'A'); @@ -332,6 +326,19 @@ zzzcode( p, c ) register NODE *p; { return; } + case 'J': /* jump or ret? */ + { + extern struct interpass_prolog *epp; + struct interpass *ip = + DLIST_PREV((struct interpass *)epp, qelem); + if (ip->type != IP_DEFLAB || + ip->ip_lbl != getlr(p, 'L')->n_lval) + expand(p, FOREFF, "jbr LL"); + else + printf("ret"); + } + break; + case 'L': /* type of left operand */ case 'R': /* type of right operand */ { @@ -920,7 +927,7 @@ myreader(struct interpass *ipole) } /* - * Return argument size in bytes. + * Return argument size in regs. */ static int argsiz(NODE *p) @@ -928,8 +935,8 @@ argsiz(NODE *p) TWORD t = p->n_type; if (t == STRTY || t == UNIONTY) - return p->n_stsize; - return szty(t) * (SZINT/SZCHAR); + return p->n_stsize/(SZINT/SZCHAR); + return szty(t); } /* @@ -990,13 +997,5 @@ COLORMAP(int c, int *r) int special(NODE *p, int shape) { - switch (shape) { - case SNCON: - if (p->n_name[0] != '\0') - return SRDIR; - break; - default: - comperr("special"); - } return SRNOPE; } diff --git a/usr.bin/pcc/vax/table.c b/usr.bin/pcc/vax/table.c index e70e4f11e16..534036f9d73 100644 --- a/usr.bin/pcc/vax/table.c +++ b/usr.bin/pcc/vax/table.c @@ -1,4 +1,4 @@ -/* $OpenBSD: table.c,v 1.2 2007/10/27 14:19:18 ragge Exp $ */ +/* $OpenBSD: table.c,v 1.3 2007/10/29 16:38:55 ragge Exp $ */ /* * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. * @@ -103,31 +103,11 @@ struct optab table[] = { NAREG|NASL, RESC1|RESCC, " cvtZRl AL,A1\n", }, -#if 0 -{ INIT, FOREFF, - SCON, TANY, - SANY, TWORD, - 0, RNOP, - " .long CL\n", }, - -{ INIT, FOREFF, - SCON, TANY, - SANY, TSHORT|TUSHORT, - 0, RNOP, - " .word CL\n", }, - -{ INIT, FOREFF, - SCON, TANY, - SANY, TCHAR|TUCHAR, - 0, RNOP, - " .byte CL\n", }, -#endif - { GOTO, FOREFF, SCON, TANY, SANY, TANY, 0, RNOP, - " jbr LL\n", }, + " ZJ\n", }, { GOTO, FOREFF, SAREG, TANY, @@ -149,6 +129,12 @@ struct optab table[] = { " subl2 ZT,sp\nZS", }, #endif +{ ADDROF, INAREG, + SNAME, TANY, + SAREG, TANY, + NAREG, RESC1, + " movab AL,A1\n", }, + { STASG, FOREFF, SNAME|SOREG, TANY, SCON|SAREG, TANY, @@ -269,6 +255,12 @@ struct optab table[] = { NAREG|NASL, RESC1, /* should be register 0 */ " calls $0,CL\n", }, +{ CALL, INAREG|FOREFF, + SAREG, TANY, + SANY, TANY, + NAREG|NASL, RESC1, /* should be 0 */ + " calls ZC,(AL)\n", }, + { UCALL, INAREG|FOREFF, SAREG, TANY, SANY, TWORD|TCHAR|TUCHAR|TSHORT|TUSHORT|TFLOAT|TDOUBLE, @@ -291,12 +283,6 @@ struct optab table[] = { * Function arguments */ { FUNARG, FOREFF, - SNCON, TWORD|TPOINT, - SANY, TWORD|TPOINT, - 0, RNULL, - " pushab AL\n" }, - -{ FUNARG, FOREFF, SCON|SAREG|SNAME|SOREG, TWORD|TPOINT, SANY, TWORD|TPOINT, 0, RNULL, |