diff options
author | Anders Magnusson <ragge@cvs.openbsd.org> | 2007-10-27 14:19:19 +0000 |
---|---|---|
committer | Anders Magnusson <ragge@cvs.openbsd.org> | 2007-10-27 14:19:19 +0000 |
commit | cd027e447d6f34dc32245f4acaf6d85d13a82c60 (patch) | |
tree | f219ce32ef15189242c88cffe906eccd267558e9 /usr.bin | |
parent | e9f2a8ad1729f365ec11025263c742f0f93090ef (diff) |
Sync with master repo: At least compiles now.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/pcc/vax/code.c | 262 | ||||
-rw-r--r-- | usr.bin/pcc/vax/local.c | 563 | ||||
-rw-r--r-- | usr.bin/pcc/vax/local2.c | 659 | ||||
-rw-r--r-- | usr.bin/pcc/vax/macdefs.h | 136 | ||||
-rw-r--r-- | usr.bin/pcc/vax/order.c | 191 | ||||
-rw-r--r-- | usr.bin/pcc/vax/table.c | 507 |
6 files changed, 1217 insertions, 1101 deletions
diff --git a/usr.bin/pcc/vax/code.c b/usr.bin/pcc/vax/code.c index 341129a307a..61bd661771b 100644 --- a/usr.bin/pcc/vax/code.c +++ b/usr.bin/pcc/vax/code.c @@ -1,4 +1,4 @@ -/* $OpenBSD: code.c,v 1.1 2007/10/07 17:58:52 otto Exp $ */ +/* $OpenBSD: code.c,v 1.2 2007/10/27 14:19:18 ragge Exp $ */ /* * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. * @@ -33,95 +33,35 @@ * POSSIBILITY OF SUCH DAMAGE. */ -# include "mfile1" -#include <a.out.h> - -int proflg = 0; /* are we generating profiling code? */ -int strftn = 0; /* is the current function one which returns a value */ -int gdebug; -int fdefflag; /* are we within a function definition ? */ -char NULLNAME[8]; -int labelno; - -branch( n ){ - /* output a branch to label n */ - /* exception is an ordinary function branching to retlab: then, return */ - if( n == retlab && !strftn ){ - printf( " ret\n" ); - } - else printf( " jbr L%d\n", n ); - } - -int lastloc = { -1 }; +# include "pass1.h" short log2tab[] = {0, 0, 1, 2, 2, 3, 3, 3, 3}; #define LOG2SZ 9 +void defalign(n) { /* cause the alignment to become a multiple of n */ n /= SZCHAR; if( lastloc != PROG && n > 1 ) printf( " .align %d\n", n >= 0 && n < LOG2SZ ? log2tab[n] : 0 ); } -locctr( l ){ - register temp; - /* l is PROG, ADATA, DATA, STRNG, ISTRNG, or STAB */ - - if( l == lastloc ) return(l); - temp = lastloc; - lastloc = l; - switch( l ){ - - case PROG: - printf( " .text\n" ); - psline(); - break; - - case DATA: - case ADATA: - printf( " .data\n" ); - break; - - case STRNG: - printf( " .data 1\n" ); - break; - - case ISTRNG: - printf( " .data 2\n" ); - break; - - case STAB: - printf( " .stab\n" ); - break; - - default: - cerror( "illegal location counter" ); - } - - return( temp ); - } - -deflab( n ){ - /* output something to define the current position as label n */ - printf( "L%d:\n", n ); - } - -int crslab = 10; - -getlab(){ - /* return a number usable for a label */ - return( ++crslab ); - } - - -int ent_mask[] = { - 0,0,0,0,0, 0xfc0, 0xf80, 0xf00, 0xe00, 0xc00, 0x800, 0}; - -int reg_use = 11; +/* + * output something to define the current position as label n + */ +void +deflab1(int n) +{ + printf(LABFMT ":\n", n); +} +void efcode(){ /* code for the end of a function */ + if (cftnsp->stype != STRTY+FTN && cftnsp->stype != UNIONTY+FTN) + return; + cerror("efcode"); +#ifdef notyet if( strftn ){ /* copy output (in R2) to caller */ register NODE *l, *r; register struct symtab *p; @@ -138,10 +78,11 @@ efcode(){ i = getlab(); /* label for return area */ printf(" .data\n" ); printf(" .align 2\n" ); - printf("L%d: .space %d\n", i, tsize(t, p->dimoff, p->sizoff)/SZCHAR ); + deflab1(i); + printf("\t.space %d\n", tsize(t, p->dimoff, p->sizoff)/SZCHAR); printf(" .text\n" ); psline(); - printf(" movab L%d,r1\n", i); + printf(" movab " LABFMT ",r1\n", i); reached = 1; l = block( REG, NIL, NIL, PTR|t, p->dimoff, p->sizoff ); @@ -155,7 +96,7 @@ efcode(){ l = buildtree( ASSIGN, l, r ); l->op = FREE; ecomp( l->left ); - printf( " movab L%d,r0\n", i ); + printf( " movab " LABFMT ",r0\n", i ); /* turn off strftn flag, so return sequence will be generated */ strftn = 0; } @@ -164,81 +105,44 @@ efcode(){ reg_use = 11; p2bend(); fdefflag = 0; +#endif } -bfcode( a, n ) int a[]; { - /* code for the beginning of a function; a is an array of - indices in stab for the arguments; n is the number */ - register i; - register temp; - register struct symtab *p; - int off; - char *toreg(); - - locctr( PROG ); - p = &stab[curftn]; - printf( " .align 1\n"); - defnam( p ); - temp = p->stype; - temp = DECREF(temp); - strftn = (temp==STRTY) || (temp==UNIONTY); - - retlab = getlab(); - - /* routine prolog */ - - printf( " .word .R%d\n", ftnno); - if (gdebug) { - pstab(NULLNAME, N_SLINE); - printf("0,%d,LL%d\n", lineno, labelno); - printf("LL%d:\n", labelno++); - } - printf( " subl2 $.F%d,sp\n", ftnno); - if( proflg ) { /* profile code */ - i = getlab(); - printf(" movab L%d,r0\n", i); - printf(" jsb mcount\n"); - printf(" .data\n"); - printf(" .align 2\n"); - printf("L%d: .long 0\n", i); - printf(" .text\n"); - psline(); - } - - off = ARGINIT; - - for( i=0; i<n; ++i ){ - p = &stab[a[i]]; - if( p->sclass == REGISTER ){ - temp = p->offset; /* save register number */ - p->sclass = PARAM; /* forget that it is a register */ - p->offset = NOOFFSET; - oalloc( p, &off ); -/*tbl*/ printf( " %s %d(ap),r%d\n", toreg(p->stype), p->offset/SZCHAR, temp ); - p->offset = temp; /* remember register number */ - p->sclass = REGISTER; /* remember that it is a register */ - } - else { - if( oalloc( p, &off ) ) cerror( "bad argument" ); - } +void +bfcode(struct symtab **a, int n) +{ + int i; - } - fdefflag = 1; - } + if (cftnsp->stype != STRTY+FTN && cftnsp->stype != UNIONTY+FTN) + return; + /* Function returns struct, adjust arg offset */ + for (i = 0; i < n; i++) + a[i]->soffset += SZPOINT(INT); +} +void bccode(){ /* called just before the first executable statment */ /* by now, the automatics and register variables are allocated */ SETOFF( autooff, SZINT ); +#if 0 /* set aside store area offset */ p2bbeg( autooff, regvar ); reg_use = (reg_use > regvar ? regvar : reg_use); +#endif } +void ejobcode( flag ){ /* called just before final exit */ /* flag is 1 if errors, 0 if none */ } +void +bjobcode() +{ +} + +#if 0 aobeg(){ /* called before removing automatics from stab */ } @@ -250,18 +154,20 @@ aocode(p) struct symtab *p; { aoend(){ /* called after removing all automatics from stab */ } +#endif +void defnam( p ) register struct symtab *p; { /* define the current location as the name p->sname */ if( p->sclass == EXTDEF ){ printf( " .globl %s\n", exname( p->sname ) ); } - if( p->sclass == STATIC && p->slevel>1 ) deflab( p->offset ); - else printf( "%s:\n", exname( p->sname ) ); + printf( "%s:\n", exname( p->sname ) ); } +void bycode( t, i ){ /* put byte i+1 in a string */ @@ -278,68 +184,38 @@ bycode( t, i ){ } } +void zecode( n ){ /* n integer words of zeros */ - OFFSZ temp; if( n <= 0 ) return; printf( " .space %d\n", (SZINT/SZCHAR)*n ); - temp = n; - inoff += temp*SZINT; } +int fldal( t ) unsigned t; { /* return the alignment of field of type t */ uerror( "illegal field type" ); return( ALINT ); } +void fldty( p ) struct symtab *p; { /* fix up type of field p */ ; } -where(c){ /* print location of error */ - /* c is either 'u', 'c', or 'w' */ - /* GCOS version */ - fprintf( stderr, "%s, line %d: ", ftitle, lineno ); - } - - -/* tbl - toreg() returns a pointer to a char string - which is the correct "register move" for the passed type +/* p points to an array of structures, each consisting + * of a constant value and a label. + * The first is >=0 if there is a default label; + * its value is the label number + * The entries p[1] to p[n] are the nontrivial cases + * XXX - fix genswitch. */ -struct type_move {TWORD fromtype; char tostrng[8];} toreg_strs[] = - { - CHAR, "cvtbl", - SHORT, "cvtwl", - INT, "movl", - LONG, "movl", - FLOAT, "movf", - DOUBLE, "movd", - UCHAR, "movzbl", - USHORT, "movzwl", - UNSIGNED, "movl", - ULONG, "movl", - -1, "" - }; - -char -*toreg(type) - TWORD type; +void +genswitch(int num, struct swents **p, int n) { - struct type_move *p; - - for ( p=toreg_strs; p->fromtype > 0; p++) - if (p->fromtype == type) return(p->tostrng); - - /* type not found, must be a pointer type */ - return("movl"); + cerror("genswitch"); } -/* tbl */ - - -main( argc, argv ) char *argv[]; { - return(mainp1( argc, argv )); - } +#ifdef notyet struct sw heapsw[SWITSZ]; /* heap for switches */ genswitch(p,n) register struct sw *p;{ @@ -362,14 +238,15 @@ genswitch(p,n) register struct sw *p;{ /* already in r0 */ printf(" casel r0,$%ld,$%ld\n", p[1].sval, range); - printf("L%d:\n", swlab); + deflab1(swlab); for( i=1,j=p[1].sval; i<=n; j++) { - printf(" .word L%d-L%d\n", (j == p[i].sval ? ((j=p[i++].sval), p[i-1].slab) : dlab), + printf(" .word " LABFMT "-" LABFMT "\n", + (j == p[i].sval ? ((j=p[i++].sval), p[i-1].slab) : dlab), swlab); } if( p->slab >= 0 ) branch( dlab ); - else printf("L%d:\n", dlab); + else deflab1(dlab); return; } @@ -384,7 +261,7 @@ genswitch(p,n) register struct sw *p;{ if( p->slab >= 0 ) branch( dlab ); else - printf("L%d:\n", dlab); + deflab1(dlab); return; } @@ -401,7 +278,7 @@ genswitch(p,n) register struct sw *p;{ printf( " cmpl r0,$" ); printf( CONFMT, p[i].sval ); - printf( "\n jeql L%d\n", p[i].slab ); + printf( "\n jeql " LBLFMT "\n", p[i].slab ); } if( p->slab>=0 ) branch( p->slab ); @@ -434,19 +311,20 @@ walkheap(start, limit) if( start > limit ) return; printf(" cmpl r0,$%d\n", heapsw[start].sval); - printf(" jeql L%d\n", heapsw[start].slab); + printf(" jeql " LBLFMT "\n", heapsw[start].slab); if( (2*start) > limit ) { - printf(" jbr L%d\n", heapsw[0].slab); + printf(" jbr " LBLFMT "\n", heapsw[0].slab); return; } if( (2*start+1) <= limit ) { label = getlab(); - printf(" jgtr L%d\n", label); + printf(" jgtr " LBLFMT "\n", label); } else - printf(" jgtr L%d\n", heapsw[0].slab); + printf(" jgtr " LBLFMT "\n", heapsw[0].slab); walkheap( 2*start, limit); if( (2*start+1) <= limit ) { - printf("L%d:\n", label); + deflab1(label); walkheap( 2*start+1, limit); } } +#endif diff --git a/usr.bin/pcc/vax/local.c b/usr.bin/pcc/vax/local.c index dfdfbcd1458..3ae5b4e4364 100644 --- a/usr.bin/pcc/vax/local.c +++ b/usr.bin/pcc/vax/local.c @@ -1,4 +1,4 @@ -/* $OpenBSD: local.c,v 1.1 2007/10/07 17:58:52 otto Exp $ */ +/* $OpenBSD: local.c,v 1.2 2007/10/27 14:19:18 ragge Exp $ */ /* * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. * @@ -13,7 +13,7 @@ * documentation and/or other materials provided with the distribution. * All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed or owned by Caldera + * This product includes software developed or owned by Caldera * International, Inc. * Neither the name of Caldera International, Inc. nor the names of other * contributors may be used to endorse or promote products derived from @@ -23,7 +23,7 @@ * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE + * DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE * FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) @@ -33,10 +33,11 @@ * POSSIBILITY OF SUCH DAMAGE. */ -# include "mfile1" +# include "pass1.h" /* this file contains code which is dependent on the target machine */ +#if 0 NODE * cast( p, t ) register NODE *p; TWORD t; { /* cast node p to type t */ @@ -46,6 +47,7 @@ cast( p, t ) register NODE *p; TWORD t; { p->op = FREE; return( p->right ); } +#endif NODE * clocal(p) NODE *p; { @@ -64,39 +66,36 @@ clocal(p) NODE *p; { register struct symtab *q; register NODE *r; - register o; - register m, ml; + register int o; + register int m, ml; - switch( o = p->op ){ + switch( o = p->n_op ){ case NAME: - if( p->rval < 0 ) { /* already processed; ignore... */ + if((q = p->n_sp) == 0 ) { /* already processed; ignore... */ return(p); } - q = &stab[p->rval]; switch( q->sclass ){ case AUTO: case PARAM: /* fake up a structure reference */ r = block( REG, NIL, NIL, PTR+STRTY, 0, 0 ); - r->lval = 0; - r->rval = (q->sclass==AUTO?STKREG:ARGREG); + r->n_lval = 0; + r->n_rval = (q->sclass==AUTO?STKREG:ARGREG); p = stref( block( STREF, r, p, 0, 0, 0 ) ); break; - case ULABEL: - case LABEL: case STATIC: if( q->slevel == 0 ) break; - p->lval = 0; - p->rval = -q->offset; + p->n_lval = 0; + p->n_rval = -q->soffset; break; case REGISTER: - p->op = REG; - p->lval = 0; - p->rval = q->offset; + p->n_op = REG; + p->n_lval = 0; + p->n_rval = q->soffset; break; } @@ -104,51 +103,52 @@ clocal(p) NODE *p; { case PCONV: /* do pointer conversions for char and longs */ - ml = p->left->type; - if( ( ml==CHAR || ml==UCHAR || ml==SHORT || ml==USHORT ) && p->left->op != ICON ) break; + ml = p->n_left->n_type; + if( ( ml==CHAR || ml==UCHAR || ml==SHORT || ml==USHORT ) && p->n_left->n_op != ICON ) break; /* pointers all have the same representation; the type is inherited */ inherit: - p->left->type = p->type; - p->left->cdim = p->cdim; - p->left->csiz = p->csiz; - p->op = FREE; - return( p->left ); + p->n_left->n_type = p->n_type; + p->n_left->n_df = p->n_df; + p->n_left->n_sue = p->n_sue; + r = p->n_left; + nfree(p); + return( r ); case SCONV: - m = (p->type == FLOAT || p->type == DOUBLE ); - ml = (p->left->type == FLOAT || p->left->type == DOUBLE ); + m = (p->n_type == FLOAT || p->n_type == DOUBLE ); + ml = (p->n_left->n_type == FLOAT || p->n_left->n_type == DOUBLE ); if( m != ml ) break; /* now, look for conversions downwards */ - m = p->type; - ml = p->left->type; - if( p->left->op == ICON ){ /* simulate the conversion here */ + m = p->n_type; + ml = p->n_left->n_type; + if( p->n_left->n_op == ICON ){ /* simulate the conversion here */ CONSZ val; - val = p->left->lval; + val = p->n_left->n_lval; switch( m ){ case CHAR: - p->left->lval = (char) val; + p->n_left->n_lval = (char) val; break; case UCHAR: - p->left->lval = val & 0XFF; + p->n_left->n_lval = val & 0XFF; break; case USHORT: - p->left->lval = val & 0XFFFFL; + p->n_left->n_lval = val & 0XFFFFL; break; case SHORT: - p->left->lval = (short)val; + p->n_left->n_lval = (short)val; break; case UNSIGNED: - p->left->lval = val & 0xFFFFFFFFL; + p->n_left->n_lval = val & 0xFFFFFFFFL; break; case INT: - p->left->lval = (int)val; + p->n_left->n_lval = (int)val; break; } - p->left->type = m; + p->n_left->n_type = m; } else { /* meaningful ones are conversion of int to char, int to short, @@ -162,49 +162,75 @@ clocal(p) NODE *p; { } /* clobber conversion */ - if( tlen(p) == tlen(p->left) ) goto inherit; - p->op = FREE; - return( p->left ); /* conversion gets clobbered */ + if( tlen(p) == tlen(p->n_left) ) goto inherit; + r = p->n_left; + nfree(p); + return( r ); /* conversion gets clobbered */ case PVCONV: case PMCONV: - if( p->right->op != ICON ) cerror( "bad conversion", 0); - p->op = FREE; - return( buildtree( o==PMCONV?MUL:DIV, p->left, p->right ) ); + if( p->n_right->n_op != ICON ) cerror( "bad conversion", 0); + r = buildtree( o==PMCONV?MUL:DIV, p->n_left, p->n_right); + nfree(p); + return r; case RS: - case ASG RS: + case RSEQ: /* convert >> to << with negative shift count */ /* only if type of left operand is not unsigned */ - if( ISUNSIGNED(p->left->type) ) break; - p->right = buildtree( UNARY MINUS, p->right, NIL ); - if( p->op == RS ) p->op = LS; - else p->op = ASG LS; + if( ISUNSIGNED(p->n_left->n_type) ) break; + p->n_right = buildtree( UMINUS, p->n_right, NIL ); + if( p->n_op == RS ) p->n_op = LS; + else p->n_op = LSEQ; + break; + + case FORCE: + p->n_op = ASSIGN; + p->n_right = p->n_left; + p->n_left = block(REG, NIL, NIL, p->n_type, 0, MKSUE(INT)); + p->n_left->n_rval = p->n_left->n_type == BOOL ? + RETREG(CHAR) : RETREG(p->n_type); break; + case STCALL: + case CALL: + /* Fix function call arguments. On vax, just add funarg */ + for (r = p->n_right; r->n_op == CM; r = r->n_left) { + if (r->n_right->n_op != STARG && + r->n_right->n_op != FUNARG) + r->n_right = block(FUNARG, r->n_right, NIL, + r->n_right->n_type, r->n_right->n_df, + r->n_right->n_sue); } + if (r->n_op != STARG && r->n_op != FUNARG) { + NODE *l = talloc(); + *l = *r; + r->n_op = FUNARG; r->n_left = l; r->n_type = l->n_type; + } + break; + } return(p); - } +} +int andable( p ) NODE *p; { return(1); /* all names can have & taken on them */ } - + +void cendarg(){ /* at the end of the arguments of a ftn, set the automatic offset */ autooff = AUTOINIT; } +int cisreg( t ) TWORD t; { /* is an automatic variable of type t OK for a register variable */ - - if( t==INT || t==UNSIGNED || t==LONG || t==ULONG /* tbl */ - || t==CHAR || t==UCHAR || t==SHORT || t==USHORT /* tbl */ - || ISPTR(t)) return(1); /* tbl */ - return(0); + return(1); /* all are now */ } NODE * -offcon( off, t, d, s ) OFFSZ off; TWORD t; { +offcon(OFFSZ off, TWORD t, union dimfun *d, struct suedef *sue) +{ /* return a node, for structure references, which is suitable for being added to a pointer of type t, in order to be off bits offset @@ -216,85 +242,85 @@ offcon( off, t, d, s ) OFFSZ off; TWORD t; { /* in general they are necessary for offcon, but not on H'well */ p = bcon(0); - p->lval = off/SZCHAR; + p->n_lval = off/SZCHAR; return(p); } +void +spalloc(NODE *t, NODE *p, OFFSZ off) +{ + cerror("spalloc"); +} -incode( p, sz ) register NODE *p; { - - /* generate initialization code for assigning a constant c - to a field of width sz */ - /* we assume that the proper alignment has been obtained */ - /* inoff is updated to have the proper final value */ - /* we also assume sz < SZINT */ +static int inbits, inval; - inoff += sz; - if (sz>SZSHORT) - printf(" .long %d:%d\n", sz, p->lval); - else if (sz>SZCHAR) - printf(" .word %d:%d\n", sz, p->lval); - else - printf(" .byte %d:%d\n", sz, p->lval); +/* + * set fsz bits in sequence to zero. + */ +void +zbits(OFFSZ off, int fsz) +{ + int m; + + if (idebug) + printf("zbits off %lld, fsz %d inbits %d\n", off, fsz, inbits); + if ((m = (inbits % SZCHAR))) { + m = SZCHAR - m; + if (fsz < m) { + inbits += fsz; + return; + } else { + fsz -= m; + printf("\t.byte %d\n", inval); + inval = inbits = 0; + } } - -fincode( d, sz ) double d; { - /* output code to initialize space of size sz to the value d */ - /* the proper alignment has been obtained */ - /* inoff is updated to have the proper final value */ - /* on the target machine, write it out in octal! */ - - - printf(" %s 0%c%.20e\n", sz == SZDOUBLE ? ".double" : ".float", - sz == SZDOUBLE ? 'd' : 'f', d); - inoff += sz; + if (fsz >= SZCHAR) { + printf("\t.space %d\n", fsz/SZCHAR); + fsz -= (fsz/SZCHAR) * SZCHAR; } - -cinit( p, sz ) NODE *p; { - /* arrange for the initialization of p into a space of - size sz */ - /* the proper alignment has been opbtained */ - /* inoff is updated to have the proper final value */ - ecode( p ); - inoff += sz; + if (fsz) { + inval = 0; + inbits = fsz; } +} -vfdzero( n ){ /* define n bits of zeros in a vfd */ - register i; - - if( n <= 0 ) return; - - inoff += n; - i = n; - while (i>=SZCHAR) { - printf(" .byte 0\n"); - i -= SZCHAR; +/* + * Initialize a bitfield. + */ +void +infld(CONSZ off, int fsz, CONSZ val) +{ + if (idebug) + printf("infld off %lld, fsz %d, val %lld inbits %d\n", + off, fsz, val, inbits); + val &= ((CONSZ)1 << fsz)-1; + while (fsz + inbits >= SZCHAR) { + inval |= (val << inbits); + printf("\t.byte %d\n", inval & 255); + fsz -= (SZCHAR - inbits); + val >>= (SZCHAR - inbits); + inval = inbits = 0; } - if (i) printf(" .byte %d:0\n", i); + if (fsz) { + inval |= (val << inbits); + inbits += fsz; } +} char * exname( p ) char *p; { /* make a name look like an external name in the local machine */ - - static char text[NCHNAM+1]; - - register i; - - text[0] = '_'; - for( i=1; *p&&i<NCHNAM; ++i ){ - text[i] = *p++; - } - - text[i] = '\0'; - text[NCHNAM] = '\0'; /* truncate */ - - return( text ); + /* vad is elf now */ + if (p == NULL) + return ""; + return( p ); } -ctype( type ){ /* map types which are not defined on the local machine */ +TWORD +ctype(TWORD type ){ /* map types which are not defined on the local machine */ switch( BTYPE(type) ){ case LONG: @@ -303,226 +329,133 @@ ctype( type ){ /* map types which are not defined on the local machine */ case ULONG: MODTYPE(type,UNSIGNED); + break; + + case LDOUBLE: /* for now */ + MODTYPE(type,DOUBLE); } return( type ); } -noinit( t ) { /* curid is a variable which is defined but - is not initialized (and not a function ); - This routine returns the stroage class for an uninitialized declaration */ - - return(EXTERN); +void +calldec(NODE *p, NODE *q) +{ +} - } +void +extdec(struct symtab *q) +{ +} -commdec( id ){ /* make a common declaration for id, if reasonable */ - register struct symtab *q; - OFFSZ off, tsize(); +void +commdec( struct symtab *q ){ /* make a common declaration for id, if reasonable */ + OFFSZ off; - q = &stab[id]; printf( " .comm %s,", exname( q->sname ) ); - off = tsize( q->stype, q->dimoff, q->sizoff ); + off = tsize( q->stype, q->sdf, q->ssue ); printf( CONFMT, off/SZCHAR ); printf( "\n" ); } -isitlong( cb, ce ){ /* is lastcon to be long or short */ - /* cb is the first character of the representation, ce the last */ - - if( ce == 'l' || ce == 'L' || - lastcon >= (1L << (SZINT-1) ) ) return (1); - return(0); - } - - -isitfloat( s ) char *s; { - double atof(); - dcon = atof(s); - return( FCON ); - } - -ecode( p ) NODE *p; { - - /* walk the tree and write out the nodes.. */ - - if( nerrors ) return; - p2tree( p ); - p2compile( p ); - } - -#include "a.out.h" -int ddebug; -int gdebug; - - -outstab(p) -struct symtab *p; { - register TWORD ptype; - register char *pname; - register char pclass; - register int poffset; +/* make a local common declaration for id, if reasonable */ +void +lcommdec(struct symtab *q) +{ + int off; + + off = tsize(q->stype, q->sdf, q->ssue); + off = (off+(SZCHAR-1))/SZCHAR; + if (q->slevel == 0) +#ifdef GCC_COMPAT + printf(" .lcomm %s,0%o\n", gcc_findname(q), off); +#else + printf(" .lcomm %s,0%o\n", exname(q->sname), off); +#endif + else + printf(" .lcomm " LABFMT ",0%o\n", q->soffset, off); +} - if (!gdebug) return; - ptype = p->stype; - pname = p->sname; - pclass = p->sclass; - poffset = p->offset; +static char *loctbl[] = { "text", "data", "section .rodata", "section .rodata" }; - if (ISFTN(ptype)) { - return; - } - - switch (pclass) { - - case AUTO: - pstab(pname, N_LSYM); - printf("0,%d,%d\n", ptype, (-poffset)/SZCHAR); - poffs(p); - return; - - case EXTDEF: - case EXTERN: - pstab(pname, N_GSYM); - printf("0,%d,0\n", ptype); - poffs(p); - return; - - case STATIC: - pstab(pname, N_STSYM); - if (p->slevel > 1) { - printf("0,%d,L%d\n", ptype, poffset); - } else { - printf("0,%d,%s\n", ptype, exname(pname)); - } - poffs(p); - return; - - case REGISTER: - pstab(pname, N_RSYM); - printf("0,%d,%d\n", ptype, poffset); - poffs(p); - return; - - case MOS: - case MOU: - pstab(pname, N_SSYM); - printf("0,%d,%d\n", ptype, poffset/SZCHAR); - poffs(p); - return; - - case PARAM: - /* parameter stab entries are processed in dclargs() */ +void +setloc1(int locc) +{ + if (locc == lastloc) return; - - default: - if (ddebug) printf(" No .stab for %.8s\n", pname); - } + lastloc = locc; + printf(" .%s\n", loctbl[locc]); } -pstab(name, type) -char *name; -int type; { - register int i; - register char c; - if (!gdebug) return; - printf(" .stab "); - for(i=0; i<8; i++) - if (c = name[i]) printf("'%c,", c); - else printf("0,"); - printf("0%o,", type); -} +/* + * print out a constant node, may be associated with a label. + * Do not free the node after use. + * off is bit offset from the beginning of the aggregate + * fsz is the number of bits this is referring to + * XXX - floating point constants may be wrong if cross-compiling. + */ +void +ninval(CONSZ off, int fsz, NODE *p) +{ + union { float f; double d; long double l; int i[3]; } u; + struct symtab *q; + TWORD t; -poffs(p) -register struct symtab *p; { - int s; - if (!gdebug) return; - if ((s = dimtab[p->sizoff]/SZCHAR) > 1) { - pstab(p->sname, N_LENG); - printf("1,0,%d\n", s); - } -} + t = p->n_type; + if (t > BTMASK) + t = INT; /* pointer */ -char NULLNAME[8]; -int labelno; -int fdefflag; - -psline() { - static int lastlineno; - register char *cp, *cq; - register int i; - - if (!gdebug) return; - - cq = ititle; - cp = ftitle; - - while ( *cq ) if ( *cp++ != *cq++ ) goto neq; - if ( *cp == '\0' ) goto eq; - -neq: for (i=0; i<100; i++) - ititle[i] = '\0'; - cp = ftitle; - cq = ititle; - while ( *cp ) - *cq++ = *cp++; - *cq = '\0'; - *--cq = '\0'; - for ( cp = ititle+1; *(cp-1); cp += 8 ) { - pstab(cp, N_SOL); - if (gdebug) printf("0,0,LL%d\n", labelno); - } - *cq = '"'; - printf("LL%d:\n", labelno++); + if (p->n_op != ICON && p->n_op != FCON) + cerror("ninval: init node not constant"); -eq: if (lineno == lastlineno) return; - lastlineno = lineno; + if (p->n_op == ICON && p->n_sp != NULL && DEUNSIGN(t) != INT) + uerror("element not constant"); - if (fdefflag) { - pstab(NULLNAME, N_SLINE); - printf("0,%d,LL%d\n", lineno, labelno); - printf("LL%d:\n", labelno++); + switch (t) { + case LONGLONG: + case ULONGLONG: + printf("\t.long 0x%x", (int)p->n_lval); + printf("\t.long 0x%x", (int)(p->n_lval >> 32)); + break; + case INT: + case UNSIGNED: + printf("\t.long 0x%x", (int)p->n_lval); + if ((q = p->n_sp) != NULL) { + if ((q->sclass == STATIC && q->slevel > 0) || + q->sclass == ILABEL) { + printf("+" LABFMT, q->soffset); + } else + printf("+%s", exname(q->sname)); } + printf("\n"); + break; + case SHORT: + case USHORT: + printf("\t.short 0x%x\n", (int)p->n_lval & 0xffff); + break; + case BOOL: + if (p->n_lval > 1) + p->n_lval = p->n_lval != 0; + /* FALLTHROUGH */ + case CHAR: + case UCHAR: + printf("\t.byte %d\n", (int)p->n_lval & 0xff); + break; + case LDOUBLE: + u.i[2] = 0; + u.l = (long double)p->n_dcon; + printf("\t.long\t0x%x,0x%x,0x%x\n", u.i[0], u.i[1], u.i[2]); + break; + case DOUBLE: + u.d = (double)p->n_dcon; + printf("\t.long\t0x%x,0x%x\n", u.i[0], u.i[1]); + break; + case FLOAT: + u.f = (float)p->n_dcon; + printf("\t.long\t0x%x\n", u.i[0]); + break; + default: + cerror("ninval"); } - -plcstab(level) { - if (!gdebug) return; - pstab(NULLNAME, N_LBRAC); - printf("0,%d,LL%d\n", level, labelno); - printf("LL%d:\n", labelno++); - } - -prcstab(level) { - if (!gdebug) return; - pstab(NULLNAME, N_RBRAC); - printf("0,%d,LL%d\n", level, labelno); - printf("LL%d:\n", labelno++); - } - -pfstab(sname) -char *sname; { - if (!gdebug) return; - pstab(sname, N_FUN); - printf("0,%d,_%.7s\n", lineno, sname); -} -#ifndef ONEPASS -tlen(p) NODE *p; -{ - switch(p->type) { - case CHAR: - case UCHAR: - return(1); - - case SHORT: - case USHORT: - return(2); - - case DOUBLE: - return(8); - - default: - return(4); - } - } -#endif +} diff --git a/usr.bin/pcc/vax/local2.c b/usr.bin/pcc/vax/local2.c index ecc75bb11df..055b8c2a24d 100644 --- a/usr.bin/pcc/vax/local2.c +++ b/usr.bin/pcc/vax/local2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: local2.c,v 1.1 2007/10/07 17:58:52 otto Exp $ */ +/* $OpenBSD: local2.c,v 1.2 2007/10/27 14:19:18 ragge Exp $ */ /* * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. * @@ -33,50 +33,56 @@ * POSSIBILITY OF SUCH DAMAGE. */ -# include "mfile2" +# include "pass2.h" # include "ctype.h" /* a lot of the machine dependent parts of the second pass */ -# define BITMASK(n) ((1L<<n)-1) - -where(c){ - fprintf( stderr, "%s, line %d: ", filename, lineno ); - } +static void prtype(NODE *n); +static void acon(NODE *p); -lineid( l, fn ) char *fn; { - /* identify line l and file fn */ - printf( "# line %d, file %s\n", l, fn ); - } +# define BITMASK(n) ((1L<<n)-1) -eobl2(){ - OFFSZ spoff; /* offset from stack pointer */ +/* + * Print out the prolog assembler. + * addto and regoff are already calculated. + */ +void +prologue(struct interpass_prolog *ipp) +{ + if (ipp->ipp_vis) + printf(" .globl %s\n", ipp->ipp_name); + printf(" .align 4\n"); + printf("%s:\n", ipp->ipp_name); + printf(" .word 0x%x\n", ipp->ipp_regs); + if (p2maxautooff) + printf(" subl2 $%d,%%sp\n", p2maxautooff); +} - spoff = maxoff; - if( spoff >= AUTOINIT ) spoff -= AUTOINIT; - spoff /= SZCHAR; - SETOFF(spoff,4); - printf( " .set .F%d,%Ld\n", ftnno, spoff ); - maxargs = -1; - } +/* + * Called after all instructions in a function are emitted. + * Generates code for epilog here. + */ +void +eoftn(struct interpass_prolog *ipp) +{ + if (ipp->ipp_ip.ip_lbl == 0) + return; /* no code needs to be generated */ + printf(" ret\n"); +} struct hoptab { int opmask; char * opstring; } ioptab[] = { - ASG PLUS, "add", - ASG MINUS, "sub", - ASG MUL, "mul", - ASG DIV, "div", - ASG OR, "bis", - ASG ER, "xor", - ASG AND, "bic", - PLUS, "add", - MINUS, "sub", - MUL, "mul", - DIV, "div", - OR, "bis", - ER, "xor", - AND, "bic", - -1, "" }; - + { PLUS, "add", }, + { MINUS, "sub", }, + { MUL, "mul", }, + { DIV, "div", }, + { OR, "bis", }, + { ER, "xor", }, + { AND, "bic", }, + { -1, "" }, +}; + +void hopcode( f, o ){ /* output the appropriate string from the above table */ @@ -110,24 +116,18 @@ hopcode( f, o ){ char * rnames[] = { /* keyed to register number tokens */ - "r0", "r1", - "r2", "r3", "r4", "r5", + "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "ap", "fp", "sp", "pc", - - }; - -int rstatus[] = { - SAREG|STAREG, SAREG|STAREG, - SAREG|STAREG, SAREG|STAREG, SAREG|STAREG, SAREG|STAREG, - SAREG, SAREG, SAREG, SAREG, SAREG, SAREG, - SAREG, SAREG, SAREG, SAREG, - + /* The concatenated regs has the name of the lowest */ + "r0", "r1", "r2", "r3", "r4", "r5", + "r6", "r7", "r8", "r9", "r10" }; +int tlen(p) NODE *p; { - switch(p->type) { + switch(p->n_type) { case CHAR: case UCHAR: return(1); @@ -137,6 +137,9 @@ tlen(p) NODE *p; return(2); case DOUBLE: + case LDOUBLE: + case LONGLONG: + case ULONGLONG: return(8); default: @@ -144,20 +147,22 @@ tlen(p) NODE *p; } } -mixtypes(p, q) NODE *p, *q; +static int +mixtypes(NODE *p, NODE *q) { - register tp, tq; + TWORD tp, tq; - tp = p->type; - tq = q->type; + tp = p->n_type; + tq = q->n_type; return( (tp==FLOAT || tp==DOUBLE) != (tq==FLOAT || tq==DOUBLE) ); } -prtype(n) NODE *n; +void +prtype(NODE *n) { - switch (n->type) + switch (n->n_type) { case DOUBLE: printf("d"); @@ -185,7 +190,7 @@ prtype(n) NODE *n; return; default: - if ( !ISPTR( n->type ) ) cerror("zzzcode- bad type"); + if ( !ISPTR( n->n_type ) ) cerror("zzzcode- bad type"); else { printf("l"); return; @@ -193,68 +198,59 @@ prtype(n) NODE *n; } } +void zzzcode( p, c ) register NODE *p; { - register m; - CONSZ val; + int m; + int val; switch( c ){ case 'N': /* logical ops, turned into 0-1 */ /* use register given by register 1 */ - cbgen( 0, m=getlab(), 'I' ); - deflab( p->label ); - printf( " clrl %s\n", rnames[getlr( p, '1' )->rval] ); + cbgen( 0, m=getlab()); + deflab( p->n_label ); + printf( " clrl %s\n", rnames[getlr( p, '1' )->n_rval] ); deflab( m ); return; - case 'I': - case 'P': - cbgen( p->op, p->label, c ); - return; - case 'A': { register NODE *l, *r; - if (xdebug) eprint(p, 0, &val, &val); + if (xdebug) e2print(p, 0, &val, &val); r = getlr(p, 'R'); - if (optype(p->op) == LTYPE || p->op == UNARY MUL) - { + if (optype(p->n_op) == LTYPE || p->n_op == UMUL) { l = resc; - l->type = (r->type==FLOAT || r->type==DOUBLE ? DOUBLE : INT); - } - else + l->n_type = (r->n_type==FLOAT || r->n_type==DOUBLE ? DOUBLE : INT); + } else l = getlr(p, 'L'); - if (r->op == ICON && r->name[0] == '\0') - { - if (r->lval == 0) - { + if (r->n_op == ICON && r->n_name[0] == '\0') { + if (r->n_lval == 0) { printf("clr"); prtype(l); printf(" "); - adrput(l); + adrput(stdout, l); return; - } - if (r->lval < 0 && r->lval >= -63) - { + } + if (r->n_lval < 0 && r->n_lval >= -63) { printf("mneg"); prtype(l); - r->lval = -r->lval; + r->n_lval = -r->n_lval; goto ops; - } - r->type = (r->lval < 0 ? - (r->lval >= -128 ? CHAR - : (r->lval >= -32768 ? SHORT - : INT )) : r->type); - r->type = (r->lval >= 0 ? - (r->lval <= 63 ? INT - : ( r->lval <= 127 ? CHAR - : (r->lval <= 255 ? UCHAR - : (r->lval <= 32767 ? SHORT - : (r->lval <= 65535 ? USHORT - : INT ))))) : r->type ); } - if (l->op == REG && l->type != FLOAT && l->type != DOUBLE) - l->type = INT; + r->n_type = (r->n_lval < 0 ? + (r->n_lval >= -128 ? CHAR + : (r->n_lval >= -32768 ? SHORT + : INT )) : r->n_type); + r->n_type = (r->n_lval >= 0 ? + (r->n_lval <= 63 ? INT + : ( r->n_lval <= 127 ? CHAR + : (r->n_lval <= 255 ? UCHAR + : (r->n_lval <= 32767 ? SHORT + : (r->n_lval <= 65535 ? USHORT + : INT ))))) : r->n_type ); + } + if (l->n_op == REG && l->n_type != FLOAT && l->n_type != DOUBLE) + l->n_type = INT; if (!mixtypes(l,r)) { if (tlen(l) == tlen(r)) @@ -263,7 +259,7 @@ zzzcode( p, c ) register NODE *p; { prtype(l); goto ops; } - else if (tlen(l) > tlen(r) && ISUNSIGNED(r->type)) + else if (tlen(l) > tlen(r) && ISUNSIGNED(r->n_type)) { printf("movz"); } @@ -280,43 +276,44 @@ zzzcode( p, c ) register NODE *p; { prtype(l); ops: printf(" "); - adrput(r); + adrput(stdout, r); printf(","); - adrput(l); + adrput(stdout, l); return; } case 'C': /* num words pushed on arg stack */ { - extern int gc_numbytes; - extern int xdebug; - - if (xdebug) printf("->%d<-",gc_numbytes); + int pr = p->n_qual; - printf("$%d", gc_numbytes/(SZLONG/SZCHAR) ); - return; + if (p->n_op == STCALL || p->n_op == USTCALL) + pr += 4; + printf("$%d", pr); + break; } case 'D': /* INCR and DECR */ - zzzcode(p->left, 'A'); + zzzcode(p->n_left, 'A'); printf("\n "); +#if 0 case 'E': /* INCR and DECR, FOREFF */ - if (p->right->lval == 1) + if (p->n_right->n_lval == 1) { - printf("%s", (p->op == INCR ? "inc" : "dec") ); - prtype(p->left); + printf("%s", (p->n_op == INCR ? "inc" : "dec") ); + prtype(p->n_left); printf(" "); - adrput(p->left); + adrput(stdout, p->n_left); return; } - printf("%s", (p->op == INCR ? "add" : "sub") ); - prtype(p->left); + printf("%s", (p->n_op == INCR ? "add" : "sub") ); + prtype(p->n_left); printf("2 "); - adrput(p->right); + adrput(stdout, p->n_right); printf(","); - adrput(p->left); + adrput(p->n_left); return; +#endif case 'F': /* register type of right operand */ { @@ -325,7 +322,7 @@ zzzcode( p, c ) register NODE *p; { register int ty; n = getlr( p, 'R' ); - ty = n->type; + ty = n->n_type; if (xdebug) printf("->%d<-", ty); @@ -342,25 +339,25 @@ zzzcode( p, c ) register NODE *p; { extern int xdebug; n = getlr ( p, c); - if (xdebug) printf("->%d<-", n->type); + if (xdebug) printf("->%d<-", n->n_type); prtype(n); return; } case 'Z': /* complement mask for bit instr */ - printf("$%Ld", ~p->right->lval); + printf("$%Ld", ~p->n_right->n_lval); return; case 'U': /* 32 - n, for unsigned right shifts */ - printf("$%d", 32 - p->right->lval ); + printf("$" CONFMT, 32 - p->n_right->n_lval ); return; case 'T': /* rounded structure length for arguments */ { int size; - size = p->stsize; + size = p->n_stsize; SETOFF( size, 4); printf("$%d", size); return; @@ -369,24 +366,25 @@ zzzcode( p, c ) register NODE *p; { case 'S': /* structure assignment */ { register NODE *l, *r; - register size; + register int size; - if( p->op == STASG ){ - l = p->left; - r = p->right; + l = r = NULL; /* XXX gcc */ + if( p->n_op == STASG ){ + l = p->n_left; + r = p->n_right; } - else if( p->op == STARG ){ /* store an arg into a temporary */ + else if( p->n_op == STARG ){ /* store an arg into a temporary */ l = getlr( p, '3' ); - r = p->left; + r = p->n_left; } else cerror( "STASG bad" ); - if( r->op == ICON ) r->op = NAME; - else if( r->op == REG ) r->op = OREG; - else if( r->op != OREG ) cerror( "STASG-r" ); + if( r->n_op == ICON ) r->n_op = NAME; + else if( r->n_op == REG ) r->n_op = OREG; + else if( r->n_op != OREG ) cerror( "STASG-r" ); - size = p->stsize; + size = p->n_stsize; if( size <= 0 || size > 65535 ) cerror("structure size <0=0 or >65535"); @@ -408,37 +406,30 @@ zzzcode( p, c ) register NODE *p; { printf(" movc3 $%d,", size); break; } - adrput(r); + adrput(stdout, r); printf(","); - adrput(l); + adrput(stdout, l); printf("\n"); - if( r->op == NAME ) r->op = ICON; - else if( r->op == OREG ) r->op = REG; + if( r->n_op == NAME ) r->n_op = ICON; + else if( r->n_op == OREG ) r->n_op = REG; } break; default: - cerror( "illegal zzzcode" ); + comperr("illegal zzzcode '%c'", c); } } -rmove( rt, rs, t ){ +void +rmove( int rt,int rs, TWORD t ){ printf( " %s %s,%s\n", (t==FLOAT ? "movf" : (t==DOUBLE ? "movd" : "movl")), rnames[rs], rnames[rt] ); } -struct respref -respref[] = { - INTAREG|INTBREG, INTAREG|INTBREG, - INAREG|INBREG, INAREG|INBREG|SOREG|STARREG|STARNM|SNAME|SCON, - INTEMP, INTEMP, - FORARG, FORARG, - INTEMP, INTAREG|INAREG|INTBREG|INBREG|SOREG|STARREG|STARNM, - 0, 0 }; - +#if 0 setregs(){ /* set up temporary registers */ fregs = 6; /* tbl- 6 free regs on VAX (0-5) */ ; @@ -447,11 +438,14 @@ setregs(){ /* set up temporary registers */ szty(t){ /* size, in registers, needed to hold thing of type t */ return( (t==DOUBLE||t==FLOAT) ? 2 : 1 ); } +#endif +int rewfld( p ) NODE *p; { return(1); } +#if 0 callreg(p) NODE *p; { return( R0 ); } @@ -482,17 +476,19 @@ offset( p, tyl ) register NODE *p; int tyl; { return( p->left->rval ); return( -1 ); } +#endif +#if 0 +void makeor2( p, q, b, o) register NODE *p, *q; register int b, o; { register NODE *t; - register int i; NODE *f; - p->op = OREG; - f = p->left; /* have to free this subtree later */ + p->n_op = OREG; + f = p->n_left; /* have to free this subtree later */ /* init base */ - switch (q->op) { + switch (q->n_op) { case ICON: case REG: case OREG: @@ -500,74 +496,75 @@ makeor2( p, q, b, o) register NODE *p, *q; register int b, o; { break; case MINUS: - q->right->lval = -q->right->lval; + q->n_right->n_lval = -q->n_right->n_lval; case PLUS: - t = q->right; - break; - - case INCR: - case ASG MINUS: - t = q->left; + t = q->n_right; break; - case UNARY MUL: - t = q->left->left; + case UMUL: + t = q->n_left->n_left; break; default: cerror("illegal makeor2"); + t = NULL; /* XXX gcc */ } - p->lval = t->lval; - for(i=0; i<NCHNAM; ++i) - p->name[i] = t->name[i]; + p->n_lval = t->n_lval; + p->n_name = t->n_name; /* init offset */ - p->rval = R2PACK( (b & 0177), o, (b>>7) ); + p->n_rval = R2PACK( (b & 0177), o, (b>>7) ); tfree(f); return; } +int canaddr( p ) NODE *p; { - register int o = p->op; + register int o = p->n_op; - if( o==NAME || o==REG || o==ICON || o==OREG || (o==UNARY MUL && shumul(p->left)) ) return(1); + if( o==NAME || o==REG || o==ICON || o==OREG || (o==UMUL && shumul(p->n_left)) ) return(1); return(0); } shltype( o, p ) register NODE *p; { - return( o== REG || o == NAME || o == ICON || o == OREG || ( o==UNARY MUL && shumul(p->left)) ); + return( o== REG || o == NAME || o == ICON || o == OREG || ( o==UMUL && shumul(p->n_left)) ); } +#endif +int flshape( p ) register NODE *p; { - return( p->op == REG || p->op == NAME || p->op == ICON || - (p->op == OREG && (!R2TEST(p->rval) || tlen(p) == 1)) ); + return( p->n_op == REG || p->n_op == NAME || p->n_op == ICON || + (p->n_op == OREG && (!R2TEST(p->n_rval) || tlen(p) == 1)) ); } +int shtemp( p ) register NODE *p; { - if( p->op == STARG ) p = p->left; - return( p->op==NAME || p->op ==ICON || p->op == OREG || (p->op==UNARY MUL && shumul(p->left)) ); + if( p->n_op == STARG ) p = p->n_left; + return( p->n_op==NAME || p->n_op ==ICON || p->n_op == OREG || (p->n_op==UMUL && shumul(p->n_left)) ); } +int shumul( p ) register NODE *p; { - register o; + register int o; extern int xdebug; if (xdebug) { - printf("\nshumul:op=%d,lop=%d,rop=%d", p->op, p->left->op, p->right->op); - printf(" prname=%s,plty=%d, prlval=%D\n", p->right->name, p->left->type, p->right->lval); + printf("\nshumul:op=%d,lop=%d,rop=%d", p->n_op, p->n_left->n_op, p->n_right->n_op); + printf(" prname=%s,plty=%d, prlval=%lld\n", p->n_right->n_name, p->n_left->n_type, p->n_right->n_lval); } - o = p->op; - if( o == NAME || (o == OREG && !R2TEST(p->rval)) || o == ICON ) return( STARNM ); + o = p->n_op; + if( o == NAME || (o == OREG && !R2TEST(p->n_rval)) || o == ICON ) return( STARNM ); +#ifdef notyet if( ( o == INCR || o == ASG MINUS ) && - ( p->left->op == REG && p->right->op == ICON ) && - p->right->name[0] == '\0' ) + ( p->n_left->n_op == REG && p->n_right->n_op == ICON ) && + p->n_right->n_name[0] == '\0' ) { - switch (p->left->type) + switch (p->n_left->n_type) { case CHAR|PTR: case UCHAR|PTR: @@ -592,32 +589,36 @@ shumul( p ) register NODE *p; { break; default: - if ( ISPTR(p->left->type) ) { + if ( ISPTR(p->n_left->n_type) ) { o = 4; break; } else return(0); } - return( p->right->lval == o ? STARREG : 0); + return( p->n_right->n_lval == o ? STARREG : 0); } +#endif return( 0 ); } +void adrcon( val ) CONSZ val; { printf( "$" ); printf( CONFMT, val ); } -conput( p ) register NODE *p; { - switch( p->op ){ +void +conput(FILE *fp, NODE *p) +{ + switch( p->n_op ){ case ICON: acon( p ); return; case REG: - printf( "%s", rnames[p->rval] ); + printf( "%s", rnames[p->n_rval] ); return; default: @@ -625,22 +626,26 @@ conput( p ) register NODE *p; { } } +void insput( p ) register NODE *p; { cerror( "insput" ); } -upput( p ) register NODE *p; { +void +upput( p , size) register NODE *p; { cerror( "upput" ); } -adrput( p ) register NODE *p; { +void +adrput(FILE *fp, NODE *p) +{ register int r; /* output an address, with offsets, from p */ - if( p->op == FLD ){ - p = p->left; + if( p->n_op == FLD ){ + p = p->n_left; } - switch( p->op ){ + switch( p->n_op ){ case NAME: acon( p ); @@ -648,67 +653,79 @@ adrput( p ) register NODE *p; { case ICON: /* addressable value of the constant */ - printf( "$" ); - acon( p ); + if (p->n_name[0] == '\0') /* uses xxxab */ + printf("$"); + acon(p); return; case REG: - printf( "%s", rnames[p->rval] ); + printf( "%s", rnames[p->n_rval] ); return; case OREG: - r = p->rval; + r = p->n_rval; if( R2TEST(r) ){ /* double indexing */ register int flags; flags = R2UPK3(r); if( flags & 1 ) printf("*"); if( flags & 4 ) printf("-"); - if( p->lval != 0 || p->name[0] != '\0' ) acon(p); + if( p->n_lval != 0 || p->n_name[0] != '\0' ) acon(p); if( R2UPK1(r) != 100) printf( "(%s)", rnames[R2UPK1(r)] ); if( flags & 2 ) printf("+"); printf( "[%s]", rnames[R2UPK2(r)] ); return; } if( r == AP ){ /* in the argument region */ - if( p->lval <= 0 || p->name[0] != '\0' ) werror( "bad arg temp" ); - printf( CONFMT, p->lval ); + if( p->n_lval <= 0 || p->n_name[0] != '\0' ) werror( "bad arg temp" ); + printf( CONFMT, p->n_lval ); printf( "(ap)" ); return; } - if( p->lval != 0 || p->name[0] != '\0') acon( p ); - printf( "(%s)", rnames[p->rval] ); + if( p->n_lval != 0 || p->n_name[0] != '\0') acon( p ); + printf( "(%s)", rnames[p->n_rval] ); return; - case UNARY MUL: + case UMUL: /* STARNM or STARREG found */ if( tshape(p, STARNM) ) { printf( "*" ); - adrput( p->left); + adrput(0, p->n_left); } else { /* STARREG - really auto inc or dec */ register NODE *q; /* tbl - p = p->left; - p->left->op = OREG; - if( p->op == INCR ) { - adrput( p->left ); + p = p->n_left; + p->n_left->n_op = OREG; + if( p->n_op == INCR ) { + adrput( p->n_left ); printf( "+" ); } else { printf( "-" ); - adrput( p->left ); + adrput( p->n_left ); } tbl */ - printf("%c(%s)%c", (p->left->op==INCR ? '\0' : '-'), - rnames[p->left->left->rval], - (p->left->op==INCR ? '+' : '\0') ); - p->op = OREG; - p->rval = p->left->left->rval; - q = p->left; - p->lval = (p->left->op == INCR ? -p->left->right->lval : 0); - p->name[0] = '\0'; +#ifdef notyet + printf("%c(%s)%c", (p->n_left->n_op==INCR ? '\0' : '-'), + rnames[p->n_left->n_left->n_rval], + (p->n_left->n_op==INCR ? '+' : '\0') ); +#else + printf("%c(%s)%c", '-', + rnames[p->n_left->n_left->n_rval], + '\0' ); +#endif + p->n_op = OREG; + p->n_rval = p->n_left->n_left->n_rval; + q = p->n_left; +#ifdef notyet + + p->n_lval = (p->n_left->n_op == INCR ? -p->n_left->n_right->n_lval : 0); +#else + p->n_lval = 0; +#endif + p->n_name[0] = '\0'; tfree(q); } return; @@ -716,47 +733,28 @@ adrput( p ) register NODE *p; { default: cerror( "illegal address" ); return; - - } - } -acon( p ) register NODE *p; { /* print out a constant */ - - if( p->name[0] == '\0' ){ - printf( CONFMT, p->lval); - } - else if( p->lval == 0 ) { - printf( "%.8s", p->name ); - } - else { - printf( "%.8s+", p->name ); - printf( CONFMT, p->lval ); - } - } +} /* -aacon( p ) register NODE *p; { /* print out a constant */ -/* + * print out a constant + */ +void +acon(NODE *p) +{ - if( p->name[0] == '\0' ){ - printf( CONFMT, p->lval); - return( 0 ); - } - else if( p->lval == 0 ) { - printf( "$%.8s", p->name ); - return( 1 ); - } - else { - printf( "$(" ); - printf( CONFMT, p->lval ); - printf( "+" ); - printf( "%.8s)", p->name ); - return(1); - } + if (p->n_name[0] == '\0') { + printf(CONFMT, p->n_lval); + } else if( p->n_lval == 0 ) { + printf("%s", p->n_name); + } else { + printf("%s+", p->n_name); + printf(CONFMT, p->n_lval); } - */ +} +#if 0 genscall( p, cookie ) register NODE *p; { /* structure valued call */ return( gencall( p, cookie ) ); @@ -794,7 +792,7 @@ gencall( p, cookie ) register NODE *p; { ptemp->rall = NOPREF; ptemp->su = 0; genargs( p->right, ptemp ); - ptemp->op = FREE; + nfree(ptemp); } p1 = p->left; @@ -837,64 +835,58 @@ gencall( p, cookie ) register NODE *p; { tbl */ return(m != MDONE); } +#endif -/* tbl */ -char * +static char * ccbranches[] = { - " jeql L%d\n", - " jneq L%d\n", - " jleq L%d\n", - " jlss L%d\n", - " jgeq L%d\n", - " jgtr L%d\n", - " jlequ L%d\n", - " jlssu L%d\n", - " jgequ L%d\n", - " jgtru L%d\n", - }; -/* tbl */ - -cbgen( o, lab, mode ) { /* printf conditional and unconditional branches */ - -/* tbl */ - if( o == 0 ) printf( " jbr L%d\n", lab ); -/* tbl */ - else { - if( o > UGT ) cerror( "bad conditional branch: %s", opst[o] ); - printf( ccbranches[o-EQ], lab ); - } - } + "jeql", + "jneq", + "jleq", + "jlss", + "jgeq", + "jgtr", + "jlequ", + "jlssu", + "jgequ", + "jgtru", +}; -nextcook( p, cookie ) NODE *p; { - /* we have failed to match p with cookie; try another */ - if( cookie == FORREW ) return( 0 ); /* hopeless! */ - if( !(cookie&(INTAREG|INTBREG)) ) return( INTAREG|INTBREG ); - if( !(cookie&INTEMP) && asgop(p->op) ) return( INTEMP|INAREG|INTAREG|INTBREG|INBREG ); - return( FORREW ); - } +/* + * printf conditional and unconditional branches + */ +void +cbgen(int o, int lab) +{ -lastchance( p, cook ) NODE *p; { - /* forget it! */ - return(0); + if (o == 0) { + printf(" jbr " LABFMT "\n", lab); + } else { + if (o > UGT) + comperr("bad conditional branch: %s", opst[o]); + printf("\t%s\t" LABFMT "\n", ccbranches[o-EQ], lab); } +} -optim2( p ) register NODE *p; { +static void +optim2(NODE *p) +{ /* do local tree transformations and optimizations */ register NODE *r; - switch( p->op ) { + switch( p->n_op ) { case AND: /* commute L and R to eliminate compliments and constants */ - if( (p->left->op==ICON&&p->left->name[0]==0) || p->left->op==COMPL ) { - r = p->left; - p->left = p->right; - p->right = r; + if( (p->n_left->n_op==ICON&&p->n_left->n_name[0]==0) || p->n_left->n_op==COMPL ) { + r = p->n_left; + p->n_left = p->n_right; + p->n_right = r; } +#if 0 case ASG AND: /* change meaning of AND to ~R&L - bic on pdp11 */ - r = p->right; + r = p->n_right; if( r->op==ICON && r->name[0]==0 ) { /* compliment constant */ r->lval = ~r->lval; } @@ -911,13 +903,100 @@ optim2( p ) register NODE *p; { p->right->right = NULL; } break; - +#endif } } +void +myreader(struct interpass *ipole) +{ + struct interpass *ip; -# ifndef ONEPASS -main( argc, argv ) char *argv[]; { - return( mainp2( argc, argv ) ); + DLIST_FOREACH(ip, ipole, qelem) { + if (ip->type != IP_NODE) + continue; + walkf(ip->ip_node, optim2); } -# endif +} + +/* + * Return argument size in bytes. + */ +static int +argsiz(NODE *p) +{ + TWORD t = p->n_type; + + if (t == STRTY || t == UNIONTY) + return p->n_stsize; + return szty(t) * (SZINT/SZCHAR); +} + +/* + * Last chance to do something before calling a function. + */ +void +lastcall(NODE *p) +{ + NODE *op = p; + int size = 0; + + /* Calculate argument sizes */ + p->n_qual = 0; + if (p->n_op != CALL && p->n_op != FORTCALL && p->n_op != STCALL) + return; + for (p = p->n_right; p->n_op == CM; p = p->n_left) + size += argsiz(p->n_right); + size += argsiz(p); + op->n_qual = size; /* XXX */ +} + +/* + * Return a class suitable for a specific type. + */ +int +gclass(TWORD t) +{ + return (szty(t) == 2 ? CLASSB : CLASSA); +} + +/* + * For class c, find worst-case displacement of the number of + * registers in the array r[] indexed by class. + */ +int +COLORMAP(int c, int *r) +{ + int num; + + switch (c) { + case CLASSA: + /* there are 12 classa, so min 6 classb are needed to block */ + num = r[CLASSB] * 2; + num += r[CLASSA]; + return num < 12; + case CLASSB: + /* 6 classa may block all classb */ + num = r[CLASSB] + r[CLASSA]; + return num < 6; + } + comperr("COLORMAP"); + return 0; /* XXX gcc */ +} + +/* + * Special shapes. + */ +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/macdefs.h b/usr.bin/pcc/vax/macdefs.h index cb0a1116e79..068bb17720f 100644 --- a/usr.bin/pcc/vax/macdefs.h +++ b/usr.bin/pcc/vax/macdefs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: macdefs.h,v 1.1 2007/10/07 17:58:52 otto Exp $ */ +/* $OpenBSD: macdefs.h,v 1.2 2007/10/27 14:19:18 ragge Exp $ */ /* * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. * @@ -38,33 +38,66 @@ # define ARGINIT 32 # define AUTOINIT 0 # define SZCHAR 8 +# define SZBOOL 8 # define SZINT 32 # define SZFLOAT 32 # define SZDOUBLE 64 +# define SZLDOUBLE 64 /* XXX use longer? */ # define SZLONG 32 +# define SZLONGLONG 64 # define SZSHORT 16 -# define SZPOINT 32 +# define SZPOINT(t) 32 # define ALCHAR 8 +# define ALBOOL 8 # define ALINT 32 # define ALFLOAT 32 # define ALDOUBLE 32 +# define ALLDOUBLE 32 # define ALLONG 32 +# define ALLONGLONG 32 # define ALSHORT 16 # define ALPOINT 32 # define ALSTRUCT 8 # define ALSTACK 32 +/* + * Min/max values. + */ +#define MIN_CHAR -128 +#define MAX_CHAR 127 +#define MAX_UCHAR 255 +#define MIN_SHORT -32768 +#define MAX_SHORT 32767 +#define MAX_USHORT 65535 +#define MIN_INT (-0x7fffffff-1) +#define MAX_INT 0x7fffffff +#define MAX_UNSIGNED 0xffffffff +#define MIN_LONG MIN_INT +#define MAX_LONG MAX_INT +#define MAX_ULONG MAX_UNSIGNED +#define MIN_LONGLONG 0x8000000000000000LL +#define MAX_LONGLONG 0x7fffffffffffffffLL +#define MAX_ULONGLONG 0xffffffffffffffffULL + +/* Default char is signed */ +#undef CHAR_UNSIGNED +#define BOOL_TYPE CHAR /* what used to store _Bool */ +#define WCHAR_TYPE INT /* what used to store wchar_t */ + /* size in which constants are converted */ /* should be long if feasable */ -# define CONSZ long -# define CONFMT "%Ld" +typedef long long CONSZ; +typedef unsigned long long U_CONSZ; + +# define CONFMT "%lld" +# define LABFMT ".L%d" +# define STABLBL ".LL%d" /* size in which offsets are kept * should be large enough to cover address space in bits */ - -# define OFFSZ long +typedef long long OFFSZ; /* character set macro */ @@ -79,11 +112,6 @@ # define MAXRVAR 11 # define MINRVAR 6 -# define MAXREGS MAXRVAR - - /* various standard pieces of code are used */ -# define STDPRTREE -# define LABFMT "L%d" /* show stack grows negatively */ #define BACKAUTO @@ -130,6 +158,22 @@ /* floating registers */ /* there are no floating point registers on the VAX */ + /* but there are concatenated regs */ + /* we call them XR? */ +#define XR0 16 +#define XR1 17 +#define XR2 18 +#define XR3 19 +#define XR4 20 +#define XR5 21 +#define XR6 22 +#define XR7 23 +#define XR8 24 +#define XR9 25 +#define XR10 26 + + + extern int fregs; extern int maxargs; @@ -142,7 +186,7 @@ extern int maxargs; # define TMPREG FP -# define R2REGS /* permit double indexing */ +//# define R2REGS /* permit double indexing */ # define STOARG(p) /* just evaluate the arguments, and be done with it... */ # define STOFARG(p) @@ -151,6 +195,68 @@ extern int maxargs; # define NESTCALL -# define MYREADER(p) walkf(p, optim2) -int optim2(void); -# define special(a, b) 0 +# define MYREADER(p) myreader(p) + +/* + * Register allocator stuff. + * The register allocator sees this as 16 general regs (AREGs) + * and 11 64-bit concatenated regs. (BREGs) + */ +#define MAXREGS 033 /* 27 registers */ + +#define RSTATUS \ + SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, \ + SAREG|TEMPREG, SAREG|TEMPREG, SAREG|PERMREG, SAREG|PERMREG, \ + SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG, \ + 0, 0, 0, 0, /* do not care about ap, fp, sp or pc */ \ + SBREG, SBREG, SBREG, SBREG, SBREG, SBREG, SBREG, SBREG, \ + SBREG, SBREG, SBREG, + +#define ROVERLAP \ + { XR0, -1 }, \ + { XR0, XR1, -1 }, \ + { XR1, XR2, -1 }, \ + { XR2, XR3, -1 }, \ + { XR3, XR4, -1 }, \ + { XR4, XR5, -1 }, \ + { XR5, XR6, -1 }, \ + { XR6, XR7, -1 }, \ + { XR7, XR8, -1 }, \ + { XR8, XR9, -1 }, \ + { XR9, XR10, -1 }, \ + { XR10, -1 }, \ + { -1 }, \ + { -1 }, \ + { -1 }, \ + { -1 }, \ + { R0, R1, XR1, -1 }, \ + { R1, R2, XR0, XR2, -1 }, \ + { R2, R3, XR1, XR3, -1 }, \ + { R3, R4, XR2, XR4, -1 }, \ + { R4, R5, XR3, XR5, -1 }, \ + { R5, R6, XR4, XR6, -1 }, \ + { R6, R7, XR5, XR7, -1 }, \ + { R7, R8, XR6, XR8, -1 }, \ + { R8, R9, XR7, XR9, -1 }, \ + { R9, R10, XR8, XR10, -1 }, \ + { R10, R11, XR9, -1 }, + +#define NUMCLASS 2 /* highest number of reg classes used */ + +/* size, in registers, needed to hold thing of type t */ +#define szty(t) (((t) == DOUBLE || (t) == LDOUBLE || (t) == FLOAT || \ + (t) == LONGLONG || (t) == ULONGLONG) ? 2 : 1) +#define FPREG FP /* frame pointer */ + +#define DECRA(x,y) (((x) >> (y*6)) & 63) /* decode encoded regs */ +#define ENCRD(x) (x) /* Encode dest reg in n_reg */ +#define ENCRA1(x) ((x) << 6) /* A1 */ +#define ENCRA2(x) ((x) << 12) /* A2 */ +#define ENCRA(x,y) ((x) << (6+y*6)) /* encode regs in int */ + +#define PCLASS(p) (szty(p->n_type) == 2 ? SBREG : SAREG) +#define RETREG(x) (szty(x) == 2 ? XR0 : R0) +#define GCLASS(x) (x < XR0 ? CLASSA : CLASSB) +int COLORMAP(int c, int *r); + +#define SNCON (MAXSPECIAL+1) /* named constand */ diff --git a/usr.bin/pcc/vax/order.c b/usr.bin/pcc/vax/order.c index ace2babe5ee..c691772eb5c 100644 --- a/usr.bin/pcc/vax/order.c +++ b/usr.bin/pcc/vax/order.c @@ -1,4 +1,4 @@ -/* $OpenBSD: order.c,v 1.1 2007/10/07 17:58:52 otto Exp $ */ +/* $OpenBSD: order.c,v 1.2 2007/10/27 14:19:18 ragge Exp $ */ /* * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. * @@ -33,10 +33,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -# include "mfile2" +# include "pass2.h" + +int canaddr(NODE *); int maxargs = { -1 }; +#if 0 stoasg( p, o ) register NODE *p; { /* should the assignment op p be stored, given that it lies as the right operand of o @@ -46,13 +49,16 @@ stoasg( p, o ) register NODE *p; { if( o==UNARY MUL && p->left->op == REG && !isbreg(p->left->rval) ) SETSTO(p,INAREG); */ } +#endif +int deltest( p ) register NODE *p; { /* should we delay the INCR or DECR operation p */ - p = p->left; - return( p->op == REG || p->op == NAME || p->op == OREG ); + p = p->n_left; + return( p->n_op == REG || p->n_op == NAME || p->n_op == OREG ); } +#if 0 autoincr( p ) NODE *p; { register NODE *q = p->left, *r; @@ -91,18 +97,22 @@ mkadrs(p) register NODE *p; { } } } +#endif -notoff( t, r, off, cp) CONSZ off; char *cp; { +int +notoff(TWORD t, int r, CONSZ off, char *cp) +{ /* is it legal to make an OREG or NAME entry which has an - /* offset of off, (from a register of r), if the - /* resulting thing had type t */ + * offset of off, (from a register of r), if the + * resulting thing had type t */ -/* if( r == R0 ) return( 1 ); /* NO */ +/* if( r == R0 ) return( 1 ); / * NO */ return(0); /* YES */ } # define max(x,y) ((x)<(y)?(y):(x)) +#if 0 sucomp( p ) register NODE *p; { /* set the su field in the node to the sethi-ullman @@ -281,96 +291,108 @@ rallo( p, down ) NODE *p; { if( ty == BITYPE ) rallo( p->right, down2 ); } - -offstar( p ) register NODE *p; { - if( p->op == PLUS ) { - if( p->left->su == fregs ) { - order( p->left, INTAREG|INAREG ); +#endif + +void +offstar( p, s ) register NODE *p; { +comperr("offstar"); +#if 0 + if( p->n_op == PLUS ) { + if( p->n_left->n_su == fregs ) { + order( p->n_left, INAREG ); return; - } else if( p->right->su == fregs ) { - order( p->right, INTAREG|INAREG ); + } else if( p->n_right->n_su == fregs ) { + order( p->n_right, INAREG ); return; } - if( p->left->op==LS && - (p->left->left->op!=REG || tlen(p->left->left)!=sizeof(int) ) ) { - order( p->left->left, INTAREG|INAREG ); + if( p->n_left->n_op==LS && + (p->n_left->n_left->n_op!=REG || tlen(p->n_left->n_left)!=sizeof(int) ) ) { + order( p->n_left->n_left, INAREG ); return; } - if( p->right->op==LS && - (p->right->left->op!=REG || tlen(p->right->left)!=sizeof(int) ) ) { - order( p->right->left, INTAREG|INAREG ); + if( p->n_right->n_op==LS && + (p->n_right->n_left->n_op!=REG || tlen(p->n_right->n_left)!=sizeof(int) ) ) { + order( p->n_right->n_left, INAREG ); return; } - if( p->type == (PTR|CHAR) || p->type == (PTR|UCHAR) ) { - if( p->left->op!=REG || tlen(p->left)!=sizeof(int) ) { - order( p->left, INTAREG|INAREG ); + if( p->n_type == (PTR|CHAR) || p->n_type == (PTR|UCHAR) ) { + if( p->n_left->n_op!=REG || tlen(p->n_left)!=sizeof(int) ) { + order( p->n_left, INAREG ); return; } - else if( p->right->op!=REG || tlen(p->right)!=sizeof(int) ) { - order(p->right, INTAREG|INAREG); + else if( p->n_right->n_op!=REG || tlen(p->n_right)!=sizeof(int) ) { + order(p->n_right, INAREG); return; } } } - if( p->op == PLUS || p->op == MINUS ){ - if( p->right->op == ICON ){ - p = p->left; - order( p , INTAREG|INAREG); + if( p->n_op == PLUS || p->n_op == MINUS ){ + if( p->n_right->n_op == ICON ){ + p = p->n_left; + order( p , INAREG); return; } } - if( p->op == UNARY MUL && !canaddr(p) ) { - offstar( p->left ); + if( p->n_op == UMUL && !canaddr(p) ) { + offstar( p->n_left, 0 ); return; } - order( p, INTAREG|INAREG ); + order( p, INAREG ); +#endif } +int setincr( p ) NODE *p; { return( 0 ); /* for the moment, don't bother */ } +int setbin( p ) register NODE *p; { - register ro, rt; - rt = p->right->type; - ro = p->right->op; +#if 0 + register int ro, rt; + + rt = p->n_right->n_type; + ro = p->n_right->n_op; - if( canaddr( p->left ) && !canaddr( p->right ) ) { /* address rhs */ - if( ro == UNARY MUL ) { - offstar( p->right->left ); + if( canaddr( p->n_left ) && !canaddr( p->n_right ) ) { /* address rhs */ + if( ro == UMUL ) { + offstar( p->n_right->n_left, 0 ); return(1); } else { - order( p->right, INAREG|INTAREG|SOREG ); + order( p->n_right, INAREG|SOREG ); return(1); } } - if( !istnode( p->left) ) { /* try putting LHS into a reg */ -/* order( p->left, logop(p->op)?(INAREG|INBREG|INTAREG|INTBREG|SOREG):(INTAREG|INTBREG|SOREG) );*/ - order( p->left, INAREG|INTAREG|INBREG|INTBREG|SOREG ); + if( !istnode( p->n_left) ) { /* try putting LHS into a reg */ +/* order( p->n_left, logop(p->n_op)?(INAREG|INBREG|INTAREG|INTBREG|SOREG):(INTAREG|INTBREG|SOREG) );*/ + order( p->n_left, INAREG|INTAREG|INBREG|INTBREG|SOREG ); return(1); } else if( ro == UNARY MUL && rt != CHAR && rt != UCHAR ){ - offstar( p->right->left ); + offstar( p->n_right->n_left ); return(1); } else if( rt == CHAR || rt == UCHAR || rt == SHORT || rt == USHORT || (ro != REG && ro != NAME && ro != OREG && ro != ICON ) ){ - order( p->right, INAREG|INBREG ); + order( p->n_right, INAREG|INBREG ); return(1); } /* - else if( logop(p->op) && rt==USHORT ){ /* must get rhs into register */ + else if( logop(p->n_op) && rt==USHORT ){ / * must get rhs into register */ /* - order( p->right, INAREG ); + order( p->n_right, INAREG ); return( 1 ); } */ +#endif return(0); } +#if 0 +int setstr( p ) register NODE *p; { /* structure assignment */ if( p->right->op != REG ){ order( p->right, INTAREG ); @@ -384,19 +406,23 @@ setstr( p ) register NODE *p; { /* structure assignment */ } return( 0 ); } +#endif + +int +setasg( p, s ) register NODE *p; { -setasg( p ) register NODE *p; { +#if 0 /* setup for assignment operator */ - if( !canaddr(p->right) ) { - if( p->right->op == UNARY MUL ) - offstar(p->right->left); + if( !canaddr(p->n_right) ) { + if( p->n_right->n_op == UNARY MUL ) + offstar(p->n_right->n_left); else - order( p->right, INAREG|INBREG|SOREG ); + order( p->n_right, INAREG|INBREG|SOREG ); return(1); } - if( p->left->op == UNARY MUL ) { - offstar( p->left->left ); + if( p->n_left->n_op == UMUL ) { + offstar( p->n_left->n_left ); return(1); } if( p->left->op == FLD && p->left->left->op == UNARY MUL ){ @@ -409,9 +435,20 @@ setasg( p ) register NODE *p; { return(1); } /* end of FLD patch */ +#endif return(0); } +/* setup for unary operator */ +int +setuni(NODE *p, int cookie) +{ + return 0; +} + + +#if 0 +int setasop( p ) register NODE *p; { /* setup for =ops */ register rt, ro; @@ -457,17 +494,15 @@ setasop( p ) register NODE *p; { } cerror( "illegal setasop" ); } +#endif -int crslab = 9999; /* Honeywell */ - -getlab(){ - return( crslab-- ); - } - -deflab( l ){ - printf( "L%d:\n", l ); - } +void +deflab(int l) +{ + printf(LABFMT ":\n", l); +} +#if 0 genargs( p, ptemp ) register NODE *p, *ptemp; { register NODE *pasg; register align; @@ -488,7 +523,7 @@ genargs( p, ptemp ) register NODE *p, *ptemp; { size = p->stsize; align = p->stalign; - /* ptemp->lval = (ptemp->lval/align)*align; /* SETOFF for negative numbers */ + /* ptemp->lval = (ptemp->lval/align)*align; / * SETOFF for negative numbers */ ptemp->lval = 0; /* all moves to (sp) */ p->op = STASG; @@ -531,3 +566,31 @@ argsize( p ) register NODE *p; { return( t+4 ); } } +#endif + +/* + * Special handling of some instruction register allocation. + */ +struct rspecial * +nspecial(struct optab *q) +{ + comperr("nspecial"); + return NULL; +} + +/* + * Set evaluation order of a binary node if it differs from default. + */ +int +setorder(NODE *p) +{ + return 0; /* nothing differs on vax */ +} + +/* + * Do the actual conversion of offstar-found OREGs into real OREGs. + */ +void +myormake(NODE *q) +{ +} diff --git a/usr.bin/pcc/vax/table.c b/usr.bin/pcc/vax/table.c index bc4083a373d..e70e4f11e16 100644 --- a/usr.bin/pcc/vax/table.c +++ b/usr.bin/pcc/vax/table.c @@ -1,4 +1,4 @@ -/* $OpenBSD: table.c,v 1.1 2007/10/07 17:58:52 otto Exp $ */ +/* $OpenBSD: table.c,v 1.2 2007/10/27 14:19:18 ragge Exp $ */ /* * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. * @@ -33,7 +33,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -# include "mfile2" +# include "pass2.h" # define WPTR TPTRTO|TINT|TLONG|TFLOAT|TDOUBLE|TPOINT|TUNSIGNED|TULONG # define AWD SNAME|SOREG|SCON|STARNM|STARREG @@ -43,610 +43,667 @@ # define ANYFIXED ANYSIGNED|ANYUSIGNED # define TWORD TINT|TUNSIGNED|TPOINT|TLONG|TULONG /* tbl */ +# define TBREG TLONGLONG|TULONGLONG|TDOUBLE struct optab table[] = { +/* First entry must be an empty entry */ +{ -1, FOREFF, SANY, TANY, SANY, TANY, 0, 0, "", }, -PCONV, INAREG|INTAREG, +{ PCONV, INAREG|INAREG, SAREG|AWD, TCHAR|TSHORT, SANY, TPOINT, NAREG|NASL, RESC1, - " cvtZLl AL,A1\n", + " cvtZLl AL,A1\n", }, -PCONV, INAREG|INTAREG, +{ PCONV, INAREG|INAREG, SAREG|AWD, TUCHAR|TUSHORT, SANY, TPOINT, NAREG|NASL, RESC1, - " movzZLl AL,A1\n", + " movzZLl AL,A1\n", }, -SCONV, INTAREG|FORCC, +{ SCONV, INBREG|FORCC, SAREG, TDOUBLE, SANY, TDOUBLE, 0, RLEFT, - "", + "", }, -SCONV, INTAREG|FORCC, +{ SCONV, INBREG|FORCC, SAREG|AWD, TANY, SANY, TFLOAT|TDOUBLE, NAREG|NASL, RESC1|RESCC, - " cvtZLd AL,A1\n", + " cvtZLd AL,A1\n", }, -SCONV, INTAREG|FORCC, +{ SCONV, INAREG|FORCC, SAREG|AWD, TFLOAT|TDOUBLE, SANY, ANYFIXED, NAREG|NASL, RESC1|RESCC, - " cvtZLZF AL,A1\n", + " cvtZLZF AL,A1\n", }, -SCONV, INTAREG|FORCC, +{ SCONV, INAREG|FORCC, SAREG|SNAME|SCON|STARNM, TANY, SANY, ANYUSIGNED, NAREG|NASL, RESC1|RESCC, - " movzZRl AL,A1\n", + " movzZRl AL,A1\n", }, -SCONV, INTAREG|FORCC, +{ SCONV, INAREG|FORCC, SSOREG, TANY, SANY, ANYUSIGNED, NAREG|NASL, RESC1|RESCC, - " movzZRl AL,A1\n", + " movzZRl AL,A1\n", }, -SCONV, INTAREG|FORCC, +{ SCONV, INAREG|FORCC, SAREG|SNAME|SCON|STARNM, TANY, SANY, TANY, NAREG|NASL, RESC1|RESCC, - " cvtZRl AL,A1\n", + " cvtZRl AL,A1\n", }, -SCONV, INTAREG|FORCC, +{ SCONV, INAREG|FORCC, SSOREG, TANY, SANY, TANY, NAREG|NASL, RESC1|RESCC, - " cvtZRl AL,A1\n", + " cvtZRl AL,A1\n", }, - -INIT, FOREFF, +#if 0 +{ INIT, FOREFF, SCON, TANY, SANY, TWORD, 0, RNOP, - " .long CL\n", + " .long CL\n", }, -INIT, FOREFF, +{ INIT, FOREFF, SCON, TANY, SANY, TSHORT|TUSHORT, 0, RNOP, - " .word CL\n", + " .word CL\n", }, -INIT, FOREFF, +{ INIT, FOREFF, SCON, TANY, SANY, TCHAR|TUCHAR, 0, RNOP, - " .byte CL\n", - - /* for the use of fortran only */ + " .byte CL\n", }, +#endif -GOTO, FOREFF, +{ GOTO, FOREFF, SCON, TANY, SANY, TANY, 0, RNOP, - " jbr CL\n", + " jbr LL\n", }, -GOTO, FOREFF, +{ GOTO, FOREFF, SAREG, TANY, SANY, TANY, 0, RNOP, - " jmp (AL)\n", + " jmp (AL)\n", }, -STARG, INTEMP, +{ STARG, INTEMP, SCON|SAREG, TANY, SANY, TANY, NTEMP+2*NAREG, RESC3, - "ZS", + "ZS", }, -STASG, FORARG, +#if 0 +{ STASG, FORARG, SNAME|SOREG, TANY, SCON|SAREG, TANY, 0, RNULL, - " subl2 ZT,sp\nZS", + " subl2 ZT,sp\nZS", }, +#endif -STASG, FOREFF, +{ STASG, FOREFF, SNAME|SOREG, TANY, SCON|SAREG, TANY, 0, RNOP, - "ZS", + "ZS", }, -STASG, INAREG, +{ STASG, INAREG, SNAME|SOREG, TANY, SCON, TANY, NAREG, RESC1, - "ZS movl AR,A1\n", + "ZS movl AR,A1\n", }, -STASG, INAREG, +{ STASG, INAREG, SNAME|SOREG, TANY, SAREG, TANY, 0, RRIGHT, - " pushl AR\nZS movl (sp)+,AR\n", + " pushl AR\nZS movl (sp)+,AR\n", }, -FLD, INAREG|INTAREG, +{ FLD, INAREG|INAREG, SANY, TANY, SFLD, ANYSIGNED, NAREG|NASR, RESC1, - " extv H,S,AR,A1\n", + " extv H,S,AR,A1\n", }, -FLD, INAREG|INTAREG, +{ FLD, INAREG|INAREG, SANY, TANY, SFLD, ANYUSIGNED, NAREG|NASR, RESC1, - " extzv H,S,AR,A1\n", + " extzv H,S,AR,A1\n", }, -FLD, FORARG, +#if 0 +{ FLD, FORARG, SANY, TANY, SFLD, ANYSIGNED, 0, RNULL, - " extv H,S,AR,-(sp)\n", + " extv H,S,AR,-(sp)\n", }, -FLD, FORARG, +{ FLD, FORARG, SANY, TANY, SFLD, ANYUSIGNED, 0, RNULL, - " extzv H,S,AR,-(sp)\n", + " extzv H,S,AR,-(sp)\n", }, +#endif -OPLOG, FORCC, +{ OPLOG, FORCC, SAREG|AWD, TWORD, SAREG|AWD, TWORD, 0, RESCC, - " cmpl AL,AR\nZP", + " cmpl AL,AR\n", }, -OPLOG, FORCC, +{ OPLOG, FORCC, SAREG|AWD, TSHORT|TUSHORT, SAREG|AWD, TSHORT|TUSHORT, 0, RESCC, - " cmpw AL,AR\nZP", + " cmpw AL,AR\n", }, -OPLOG, FORCC, +{ OPLOG, FORCC, SAREG|AWD, TCHAR|TUCHAR, SAREG|AWD, TCHAR|TUCHAR, 0, RESCC, - " cmpb AL,AR\nZP", + " cmpb AL,AR\n", }, -OPLOG, FORCC, +{ OPLOG, FORCC, SAREG|AWD, TSHORT|TUSHORT, SSCON, TANY, 0, RESCC, - " cmpw AL,AR\nZP", + " cmpw AL,AR\n", }, -OPLOG, FORCC, +{ OPLOG, FORCC, SAREG|AWD, TCHAR|TUCHAR, SCCON, TANY, 0, RESCC, - " cmpb AL,AR\nZP", + " cmpb AL,AR\n", }, -OPLOG, FORCC, +{ OPLOG, FORCC, SAREG|AWD, TDOUBLE, SAREG|AWD, TDOUBLE, 0, RESCC, - " cmpd AL,AR\nZP", + " cmpd AL,AR\n", }, -OPLOG, FORCC, +{ OPLOG, FORCC, SAREG|AWD, TFLOAT|TDOUBLE, SAREG|AWD, TFLOAT|TDOUBLE, 0, RESCC, - " cmpf AL,AR\nZP", + " cmpf AL,AR\n", }, -CCODES, INAREG|INTAREG, +{ CCODES, INAREG|INAREG, SANY, TANY, SANY, TANY, NAREG, RESC1, - " movl $1,A1\nZN", + " movl $1,A1\nZN", }, + +/* + * Subroutine calls. + */ -UNARY CALL, INTAREG, +{ CALL, FOREFF, SCON, TANY, - SANY, TWORD|TCHAR|TUCHAR|TSHORT|TUSHORT|TFLOAT|TDOUBLE, + SANY, TANY, + 0, 0, + " calls ZC,CL\n", }, + +{ UCALL, FOREFF, + SCON, TANY, + SANY, TANY, + 0, 0, + " calls $0,CL\n", }, + +{ CALL, INAREG, + SCON, TANY, + SANY, TANY, NAREG|NASL, RESC1, /* should be register 0 */ - " calls ZC,CL\n", + " calls ZC,CL\n", }, -UNARY CALL, INTAREG, +{ UCALL, INAREG, + SCON, TANY, + SANY, TANY, + NAREG|NASL, RESC1, /* should be register 0 */ + " calls $0,CL\n", }, + +{ UCALL, INAREG|FOREFF, SAREG, TANY, SANY, TWORD|TCHAR|TUCHAR|TSHORT|TUSHORT|TFLOAT|TDOUBLE, NAREG|NASL, RESC1, /* should be 0 */ - " calls ZC,(AL)\n", + " calls ZC,(AL)\n", }, -UNARY CALL, INAREG|INTAREG, +{ UCALL, INAREG|FOREFF, SNAME, TANY, SANY, TANY, NAREG|NASL, RESC1, /* really reg 0 */ - " calls ZC,*AL\n", + " calls ZC,*AL\n", }, -UNARY CALL, INAREG|INTAREG, +{ UCALL, INAREG|FOREFF, SSOREG, TANY, SANY, TANY, NAREG|NASL, RESC1, /* really reg 0 */ - " calls ZC,*AL\n", + " calls ZC,*AL\n", }, + +/* + * Function arguments + */ +{ FUNARG, FOREFF, + SNCON, TWORD|TPOINT, + SANY, TWORD|TPOINT, + 0, RNULL, + " pushab AL\n" }, -ASG RS, INAREG|FOREFF|FORCC, +{ FUNARG, FOREFF, + SCON|SAREG|SNAME|SOREG, TWORD|TPOINT, + SANY, TWORD|TPOINT, + 0, RNULL, + " pushl AL\n" }, + +#if 0 +{ ASG RS, INAREG|FOREFF|FORCC, SAREG, TWORD, SCON, TINT, 0, RLEFT|RESCC, - " extzv AR,ZU,AL,AL\n", + " extzv AR,ZU,AL,AL\n", }, -ASG RS, INAREG|FOREFF|FORCC, +{ ASG RS, INAREG|FOREFF|FORCC, SAREG, TWORD, SAREG, ANYFIXED, NAREG, RLEFT|RESCC, - " subl3 AR,$32,A1\n extzv AR,A1,AL,AL\n", + " subl3 AR,$32,A1\n extzv AR,A1,AL,AL\n", }, -ASG RS, INAREG|FOREFF|FORCC, +{ ASG RS, INAREG|FOREFF|FORCC, SAREG, TWORD, SAREG|AWD, TWORD, NAREG, RLEFT|RESCC, - " subl3 AR,$32,A1\n extzv AR,A1,AL,AL\n", + " subl3 AR,$32,A1\n extzv AR,A1,AL,AL\n", }, +#endif -RS, INAREG|INTAREG|FORCC, +{ RS, INAREG|INAREG|FORCC, SAREG, TWORD, SCON, TINT, NAREG|NASL, RESC1|RESCC, - " extzv AR,ZU,AL,A1\n", + " extzv AR,ZU,AL,A1\n", }, -ASG LS, INAREG|FOREFF|FORCC, +#if 0 +{ ASG LS, INAREG|FOREFF|FORCC, SAREG|AWD, TWORD, SAREG|AWD, ANYSIGNED|ANYUSIGNED, 0, RLEFT|RESCC, - " ashl AR,AL,AL\n", + " ashl AR,AL,AL\n", }, +#endif -LS, INAREG|INTAREG|FORCC, +{ LS, INAREG|INAREG|FORCC, SAREG|AWD, TWORD, SAREG|AWD, ANYSIGNED|ANYUSIGNED, NAREG|NASL|NASR, RESC1|RESCC, - " ashl AR,AL,A1\n", + " ashl AR,AL,A1\n", }, -INCR, FOREFF, +#if 0 +{ INCR, FOREFF, SAREG|AWD, TANY, SANY, TANY, 0, RLEFT, - " ZE\n", + " ZE\n", }, -DECR, FOREFF, +{ DECR, FOREFF, SAREG|AWD, TANY, SCON, TANY, 0, RLEFT, - " ZE\n", + " ZE\n", }, -INCR, INAREG|INTAREG, +{ INCR, INAREG|INAREG, SAREG|AWD, TANY, SCON, TANY, NAREG, RESC1, - " ZD\n", + " ZD\n", }, -DECR, INAREG|INTAREG, +{ DECR, INAREG|INAREG, SAREG|AWD, TANY, SCON, TANY, NAREG, RESC1, - " ZD\n", + " ZD\n", }, +#endif + +{ ASSIGN, INBREG|FOREFF, + SBREG|AWD, TBREG, + SBREG|AWD, TBREG, + 0, RDEST, + " movq AR,AL\n", }, -ASSIGN, INAREG|FOREFF|FORCC, +{ ASSIGN, INAREG|FOREFF|FORCC, SAREG|AWD, TANY, SAREG|AWD, TANY, - 0, RLEFT|RRIGHT|RESCC, - " ZA\n", + 0, RDEST|RESCC, + " ZA\n", }, -ASSIGN, INAREG|FOREFF|FORCC, +{ ASSIGN, INAREG|FOREFF|FORCC, SFLD, TANY, SAREG|AWD, TWORD, - 0, RRIGHT|RESCC, - " insv AR,H,S,AL\n", + 0, RDEST|RESCC, + " insv AR,H,S,AL\n", }, -ASSIGN, INAREG|FOREFF|FORCC, +{ ASSIGN, INAREG|FOREFF|FORCC, SAREG|AWD, TWORD, SFLD, ANYSIGNED, - 0, RLEFT|RESCC, - " extv H,S,AR,AL\n", + 0, RDEST|RESCC, + " extv H,S,AR,AL\n", }, -ASSIGN, INAREG|FOREFF|FORCC, +{ ASSIGN, INAREG|FOREFF|FORCC, SAREG|AWD, TWORD, SFLD, ANYUSIGNED, - 0, RLEFT|RESCC, - " extzv H,S,AR,AL\n", + 0, RDEST|RESCC, + " extzv H,S,AR,AL\n", }, /* dummy UNARY MUL entry to get U* to possibly match OPLTYPE */ -UNARY MUL, FOREFF, +{ UMUL, FOREFF, SCC, TANY, SCC, TANY, 0, RNULL, - " HELP HELP HELP\n", + " HELP HELP HELP\n", }, -REG, FORARG, +#if 0 +{ REG, FORARG, SANY, TANY, SAREG, TDOUBLE|TFLOAT, 0, RNULL, - " movZR AR,-(sp)\n", + " movZR AR,-(sp)\n", }, +#endif -REG, INTEMP, +{ REG, INTEMP, SANY, TANY, SAREG, TDOUBLE, 2*NTEMP, RESC1, - " movd AR,A1\n", + " movd AR,A1\n", }, -REG, INTEMP, +{ REG, INTEMP, SANY, TANY, SAREG, TANY, NTEMP, RESC1, - " movZF AR,A1\n", + " movZF AR,A1\n", }, -OPLEAF, FOREFF, +{ OPLEAF, FOREFF, SANY, TANY, SAREG|AWD, TANY, 0, RLEFT, - "", + "", }, -OPLTYPE, INAREG|INTAREG, +{ OPLTYPE, INAREG|INAREG, SANY, TANY, SANY, TFLOAT|TDOUBLE, 2*NAREG|NASR, RESC1, - " ZA\n", + " ZA\n", }, -OPLTYPE, INAREG|INTAREG, +{ OPLTYPE, INAREG|INAREG, SANY, TANY, SANY, TANY, NAREG|NASR, RESC1, - " ZA\n", + " ZA\n", }, -OPLTYPE, FORCC, +{ OPLTYPE, FORCC, SANY, TANY, SANY, TANY, 0, RESCC, - " tstZR AR\n", + " tstZR AR\n", }, -OPLTYPE, FORARG, +#if 0 +{ OPLTYPE, FORARG, SANY, TANY, SANY, TWORD, 0, RNULL, - " pushl AR\n", + " pushl AR\n", }, -OPLTYPE, FORARG, +{ OPLTYPE, FORARG, SANY, TANY, SANY, TCHAR|TSHORT, 0, RNULL, - " cvtZRl AR,-(sp)\n", + " cvtZRl AR,-(sp)\n", }, -OPLTYPE, FORARG, +{ OPLTYPE, FORARG, SANY, TANY, SANY, TUCHAR|TUSHORT, 0, RNULL, - " movzZRl AR,-(sp)\n", + " movzZRl AR,-(sp)\n", }, -OPLTYPE, FORARG, +{ OPLTYPE, FORARG, SANY, TANY, SANY, TDOUBLE, 0, RNULL, - " movd AR,-(sp)\n", + " movd AR,-(sp)\n", }, -OPLTYPE, FORARG, +{ OPLTYPE, FORARG, SANY, TANY, SANY, TFLOAT, 0, RNULL, - " cvtfd AR,-(sp)\n", + " cvtfd AR,-(sp)\n", }, +#endif -UNARY MINUS, INTAREG|FORCC, +{ UMINUS, INAREG|FORCC, SAREG|AWD, TINT|TUNSIGNED|TLONG|TULONG|TDOUBLE, SANY, TANY, NAREG|NASL, RESC1|RESCC, - " mnegZL AL,A1\n", + " mnegZL AL,A1\n", }, -COMPL, INTAREG|FORCC, +{ COMPL, INAREG|FORCC, SAREG|AWD, TINT|TUNSIGNED, SANY, TANY, NAREG|NASL, RESC1|RESCC, - " mcomZL AL,A1\n", + " mcomZL AL,A1\n", }, -COMPL, INTAREG|FORCC, +{ COMPL, INAREG|FORCC, SAREG|AWD, ANYSIGNED|ANYUSIGNED, SANY, TANY, NAREG|NASL, RESC1|RESCC, - " cvtZLl AL,A1\n mcoml A1,A1\n", + " cvtZLl AL,A1\n mcoml A1,A1\n", }, -AND, FORCC, +{ AND, FORCC, SAREG|AWD, TWORD, SCON, TWORD, 0, RESCC, - " bitl ZZ,AL\n", + " bitl ZZ,AL\n", }, -AND, FORCC, +{ AND, FORCC, SAREG|AWD, TSHORT|TUSHORT, SSCON, TWORD, 0, RESCC, - " bitw ZZ,AL\n", + " bitw ZZ,AL\n", }, -AND, FORCC, +{ AND, FORCC, SAREG|AWD, TCHAR|TUCHAR, SCCON, TWORD, 0, RESCC, - " bitb ZZ,AL\n", + " bitb ZZ,AL\n", }, -ASG AND, INAREG|FOREFF|FORCC, +#if 0 +{ ASG AND, INAREG|FOREFF|FORCC, SAREG, ANYFIXED, SCON, TWORD, 0, RLEFT|RESCC, - " bicl2 AR,AL\n", + " bicl2 AR,AL\n", }, -ASG OPMUL, INAREG|FOREFF|FORCC, +{ ASG OPMUL, INAREG|FOREFF|FORCC, SAREG|AWD, TINT|TUNSIGNED|TLONG|TULONG, SAREG|AWD, TINT|TUNSIGNED|TLONG|TULONG, 0, RLEFT|RESCC, - " OL2 AR,AL\n", + " OL2 AR,AL\n", }, +#endif -OPMUL, INAREG|INTAREG|FORCC, - STAREG, TINT|TUNSIGNED|TLONG|TULONG, +{ OPMUL, INAREG|INAREG|FORCC, + SAREG, TINT|TUNSIGNED|TLONG|TULONG, SAREG|AWD, TINT|TUNSIGNED|TLONG|TULONG, 0, RLEFT|RESCC, - " OL2 AR,AL\n", + " OL2 AR,AL\n", }, -OPMUL, INAREG|INTAREG|FORCC, +{ OPMUL, INAREG|INAREG|FORCC, SAREG|AWD, TINT|TUNSIGNED|TLONG|TULONG, SAREG|AWD, TINT|TUNSIGNED|TLONG|TULONG, NAREG|NASL|NASR, RESC1|RESCC, - " OL3 AR,AL,A1\n", + " OL3 AR,AL,A1\n", }, -ASG MOD, INAREG|INTAREG|FOREFF|FORCC, +#if 0 +{ ASG MOD, INAREG|INAREG|FOREFF|FORCC, SAREG, TINT|TUNSIGNED|TLONG|TULONG, SAREG|AWD, TINT|TUNSIGNED|TLONG|TULONG, NAREG, RLEFT|RESCC, - " divl3 AR,AL,A1\n mull2 AR,A1\n subl2 A1,AL\n", + " divl3 AR,AL,A1\n mull2 AR,A1\n subl2 A1,AL\n", }, +#endif -MOD, INAREG|INTAREG, +{ MOD, INAREG|INAREG, SAREG|AWD, TINT|TUNSIGNED|TLONG|TULONG, SAREG|AWD, TINT|TUNSIGNED|TLONG|TULONG, NAREG, RESC1, - " divl3 AR,AL,A1\n mull2 AR,A1\n subl3 A1,AL,A1\n", + " divl3 AR,AL,A1\n mull2 AR,A1\n subl3 A1,AL,A1\n", }, -ASG PLUS, INAREG|FOREFF|FORCC, +#if 0 +{ ASG PLUS, INAREG|FOREFF|FORCC, SAREG|AWD, ANYSIGNED|ANYUSIGNED, SONE, TINT|TLONG, 0, RLEFT|RESCC, - " incZL AL\n", + " incZL AL\n", }, -ASG MINUS, INAREG|FOREFF|FORCC, +{ ASG MINUS, INAREG|FOREFF|FORCC, SAREG|AWD, ANYSIGNED|ANYUSIGNED, SONE, TINT|TLONG, 0, RLEFT|RESCC, - " decZL AL\n", + " decZL AL\n", }, +#endif -PLUS, INAREG|INTAREG|FORCC, - STAREG, ANYFIXED, +{ PLUS, INAREG|INAREG|FORCC, + SAREG, ANYFIXED, SONE, TWORD, 0, RLEFT|RESCC, - " incZL AL\n", + " incZL AL\n", }, -MINUS, INAREG|INTAREG|FORCC, - STAREG, ANYFIXED, +{ MINUS, INAREG|INAREG|FORCC, + SAREG, ANYFIXED, SONE, TWORD, 0, RLEFT|RESCC, - " decZL AL\n", + " decZL AL\n", }, -ASG OPSIMP, INAREG|FOREFF|FORCC, +#if 0 +{ ASG OPSIMP, INAREG|FOREFF|FORCC, SAREG|AWD, TWORD, SAREG|AWD, TWORD, 0, RLEFT|RESCC, - " OL2 AR,AL\n", + " OL2 AR,AL\n", }, -ASG OPSIMP, INAREG|FOREFF|FORCC, +{ ASG OPSIMP, INAREG|FOREFF|FORCC, AWD, TSHORT|TUSHORT, SAREG|AWD, TSHORT|TUSHORT, 0, RLEFT|RESCC, - " OW2 AR,AL\n", + " OW2 AR,AL\n", }, -ASG OPSIMP, INAREG|FOREFF|FORCC, +{ ASG OPSIMP, INAREG|FOREFF|FORCC, AWD, TSHORT|TUSHORT, SSCON, TWORD, 0, RLEFT|RESCC, - " OW2 AR,AL\n", + " OW2 AR,AL\n", }, -ASG OPSIMP, INAREG|FOREFF|FORCC, +{ ASG OPSIMP, INAREG|FOREFF|FORCC, AWD, TCHAR|TUCHAR, SAREG|AWD, TCHAR|TUCHAR, 0, RLEFT|RESCC, - " OB2 AR,AL\n", + " OB2 AR,AL\n", }, -ASG OPSIMP, INAREG|FOREFF|FORCC, +{ ASG OPSIMP, INAREG|FOREFF|FORCC, AWD, TCHAR|TUCHAR, SCCON, TWORD, 0, RLEFT|RESCC, - " OB2 AR,AL\n", + " OB2 AR,AL\n", }, +#endif -OPSIMP, INAREG|INTAREG|FORCC, - STAREG, ANYFIXED, +{ OPSIMP, INAREG|INAREG|FORCC, + SAREG, ANYFIXED, SAREG|AWD, TWORD, 0, RLEFT|RESCC, - " OL2 AR,AL\n", + " OL2 AR,AL\n", }, -OPSIMP, INAREG|INTAREG|FORCC, +{ OPSIMP, INAREG|INAREG|FORCC, SAREG|AWD, TWORD, SAREG|AWD, TWORD, NAREG|NASL|NASR, RESC1|RESCC, - " OL3 AR,AL,A1\n", + " OL3 AR,AL,A1\n", }, -ASG OPFLOAT, INAREG|FOREFF|FORCC, +#if 0 +{ ASG OPFLOAT, INAREG|FOREFF|FORCC, SAREG|AWD, TDOUBLE, SAREG|AWD, TDOUBLE, 0, RLEFT|RESCC, - " OD2 AR,AL\n", + " OD2 AR,AL\n", }, -ASG OPFLOAT, INAREG|FOREFF|FORCC, +{ ASG OPFLOAT, INAREG|FOREFF|FORCC, SAREG|AWD, TFLOAT, SAREG|AWD, TFLOAT, 0, RLEFT|RESCC, - " OF2 AR,AL\n", + " OF2 AR,AL\n", }, -ASG OPFLOAT, INAREG|FOREFF|FORCC, +{ ASG OPFLOAT, INAREG|FOREFF|FORCC, SAREG|AWD, TDOUBLE, SAREG|AWD, TFLOAT, NAREG|NASR, RLEFT|RESCC, - " cvtfd AR,A1\n OD2 A1,AL\n", + " cvtfd AR,A1\n OD2 A1,AL\n", }, -ASG OPFLOAT, INAREG|INTAREG|FOREFF|FORCC, +{ ASG OPFLOAT, INAREG|INAREG|FOREFF|FORCC, SAREG|AWD, TFLOAT, SAREG|AWD, TDOUBLE, NAREG, RLEFT|RESC1|RESCC, - " cvtfd AL,A1\n OD2 AR,A1\n cvtdf A1,AL\n", + " cvtfd AL,A1\n OD2 AR,A1\n cvtdf A1,AL\n", }, +#endif -OPFLOAT, INAREG|INTAREG|FORCC, - STAREG, TDOUBLE, +{ OPFLOAT, INAREG|INAREG|FORCC, + SAREG, TDOUBLE, SAREG|AWD, TDOUBLE, 0, RLEFT|RESCC, - " OD2 AR,AL\n", + " OD2 AR,AL\n", }, -OPFLOAT, INAREG|INTAREG|FORCC, +{ OPFLOAT, INAREG|INAREG|FORCC, SAREG|AWD, TDOUBLE, SAREG|AWD, TDOUBLE, NAREG|NASL|NASR, RESC1|RESCC, - " OD3 AR,AL,A1\n", + " OD3 AR,AL,A1\n", }, -OPFLOAT, INAREG|INTAREG|FORCC, +{ OPFLOAT, INAREG|INAREG|FORCC, SAREG|AWD, TFLOAT, SAREG|AWD, TDOUBLE, NAREG|NASL, RESC1|RESCC, - " cvtfd AL,A1\n OD2 AR,A1\n", + " cvtfd AL,A1\n OD2 AR,A1\n", }, -OPFLOAT, INAREG|INTAREG|FORCC, +{ OPFLOAT, INAREG|INAREG|FORCC, SAREG|AWD, TDOUBLE, SAREG|AWD, TFLOAT, NAREG|NASR, RESC1|RESCC, - " cvtfd AR,A1\n OD3 A1,AL,A1\n", + " cvtfd AR,A1\n OD3 A1,AL,A1\n", }, -OPFLOAT, INAREG|INTAREG|FORCC, +{ OPFLOAT, INAREG|INAREG|FORCC, SAREG|AWD, TFLOAT, SAREG|AWD, TFLOAT, NAREG|NASL|NASR, RESC1|RESCC, - " OF3 AR,AL,A1\n cvtfd A1,A1\n", + " OF3 AR,AL,A1\n cvtfd A1,A1\n", }, /* Default actions for hard trees ... */ # define DF(x) FORREW,SANY,TANY,SANY,TANY,REWRITE,x,"" -UNARY MUL, DF( UNARY MUL ), - -INCR, DF(INCR), +{ UMUL, DF( UMUL ), }, -DECR, DF(INCR), +{ ASSIGN, DF(ASSIGN), }, -ASSIGN, DF(ASSIGN), +{ STASG, DF(STASG), }, -STASG, DF(STASG), +{ OPLEAF, DF(NAME), }, -OPLEAF, DF(NAME), - -OPLOG, FORCC, +{ OPLOG, FORCC, SANY, TANY, SANY, TANY, REWRITE, BITYPE, - "", - -OPLOG, DF(NOT), - -COMOP, DF(COMOP), - -INIT, DF(INIT), - -OPUNARY, DF(UNARY MINUS), - + "", }, -ASG OPANY, DF(ASG PLUS), +{ OPUNARY, DF(UMINUS), }, -OPANY, DF(BITYPE), +{ OPANY, DF(BITYPE), }, -FREE, FREE, FREE, FREE, FREE, FREE, FREE, FREE, "help; I'm in trouble\n" }; +{ FREE, FREE, FREE, FREE, FREE, FREE, FREE, FREE, "help; I'm in trouble\n" } +}; |