diff options
author | Anders Magnusson <ragge@cvs.openbsd.org> | 2007-10-23 18:43:01 +0000 |
---|---|---|
committer | Anders Magnusson <ragge@cvs.openbsd.org> | 2007-10-23 18:43:01 +0000 |
commit | 62dc01380e92e90afcbb823f11321e091881b8bf (patch) | |
tree | dee04c54bb6e9d6c1d6c8c7ae508038a8152daa9 | |
parent | 531f93d52e92963f99b6ec1ba197d432e0182cd7 (diff) |
Fixes from master repo:
> Fix FLD node type for code generation, so that it is useful again for
> architectures with bitfield instructions, like vax and hppa :-)
-rw-r--r-- | usr.bin/pcc/mip/match.c | 37 | ||||
-rw-r--r-- | usr.bin/pcc/mip/reader.c | 3 |
2 files changed, 16 insertions, 24 deletions
diff --git a/usr.bin/pcc/mip/match.c b/usr.bin/pcc/mip/match.c index 9a1b83bfff6..acac648d6bd 100644 --- a/usr.bin/pcc/mip/match.c +++ b/usr.bin/pcc/mip/match.c @@ -1,4 +1,4 @@ -/* $OpenBSD: match.c,v 1.2 2007/09/15 22:04:39 ray Exp $ */ +/* $OpenBSD: match.c,v 1.3 2007/10/23 18:43:00 ragge Exp $ */ /* * Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se). * All rights reserved. @@ -68,8 +68,6 @@ void prttype(int t); void setclass(int tmp, int class); int getclass(int tmp); -int fldsz, fldshf; - int s2debug = 0; extern char *ltyp[], *rtyp[]; @@ -154,22 +152,8 @@ tshape(NODE *p, int shape) break; case FLD: - if (shape & SFLD) { - int sh; - - if ((sh = flshape(p->n_left)) == SRNOPE) - return sh; - /* it is a FIELD shape; make side-effects */ - /* XXX - this will not work for multi-matches */ - o = p->n_rval; - fldsz = UPKFSZ(o); -# ifdef RTOLBYTES - fldshf = UPKFOFF(o); -# else - fldshf = SZINT - fldsz - UPKFOFF(o); -# endif - return sh; - } + if (shape & SFLD) + return flshape(p->n_left); break; case CCODES: @@ -264,6 +248,13 @@ ttype(TWORD t, int tword) return(0); } +#define FLDSZ(x) UPKFSZ(x) +#ifdef RTOLBYTES +#define FLDSHF(x) UPKFOFF(x) +#else +#define FLDSHF(x) (SZINT - FLDSZ(x) - UPKFOFF(x)) +#endif + /* * generate code by interpreting table entry */ @@ -288,19 +279,19 @@ expand(NODE *p, int cookie, char *cp) continue; case 'S': /* field size */ - printf( "%d", fldsz ); + printf("%d", FLDSZ(p->n_rval)); continue; case 'H': /* field shift */ - printf( "%d", fldshf ); + printf("%d", FLDSHF(p->n_rval)); continue; case 'M': /* field mask */ case 'N': /* complement of field mask */ val = 1; - val <<= fldsz; + val <<= FLDSZ(p->n_rval); --val; - val <<= fldshf; + val <<= FLDSHF(p->n_rval); adrcon( *cp=='M' ? val : ~val ); continue; diff --git a/usr.bin/pcc/mip/reader.c b/usr.bin/pcc/mip/reader.c index a413d36c734..8ea4e1af50c 100644 --- a/usr.bin/pcc/mip/reader.c +++ b/usr.bin/pcc/mip/reader.c @@ -1,4 +1,4 @@ -/* $OpenBSD: reader.c,v 1.6 2007/10/23 13:53:58 otto Exp $ */ +/* $OpenBSD: reader.c,v 1.7 2007/10/23 18:43:00 ragge Exp $ */ /* * Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se). * All rights reserved. @@ -430,6 +430,7 @@ again: switch (o = p->n_op) { geninsn(p1->n_right, FOREFF); geninsn(p1, FOREFF); /* FALLTHROUGH */ + case FLD: case COMPL: case UMINUS: case PCONV: |