Quick Search:

View

Revision:
Expand:  
Changeset: MAIN:ragge:20060618101745

Diff

Diff from 1.1 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/pcc/pcc/arch/vax/local2.c

Annotated File View

ragge
1.1
1 /*      $Id: local2.c,v 1.1 2006/06/18 10:17:45 ragge Exp $     */
2 /*
3  * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * Redistributions of source code and documentation must retain the above
10  * copyright notice, this list of conditions and the following disclaimer.
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditionsand the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * All advertising materials mentioning features or use of this software
15  * must display the following acknowledgement:
16  *      This product includes software developed or owned by Caldera
17  *      International, Inc.
18  * Neither the name of Caldera International, Inc. nor the names of other
19  * contributors may be used to endorse or promote products derived from
20  * this software without specific prior written permission.
21  *
22  * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
23  * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
24  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED.  IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE
27  * FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OFLIABILITY, WHETHER IN CONTRACT,
31  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
33  * POSSIBILITY OF SUCH DAMAGE.
34  */
35
36 # include "mfile2"
37 # include "ctype.h"
38 /* a lot of the machine dependent parts of the second pass */
39
40 # define BITMASK(n) ((1L<<n)-1)
41
42 where(c){
43         fprintfstderr"%s, line %d: "filenamelineno );
44         }
45
46 lineidlfn ) char *fn; {
47         /* identify line l and file fn */
48         printf"#      line %d, file %s\n"lfn );
49         }
50
51 eobl2(){
52         OFFSZ spoff;    /* offset from stack pointer */
53
54         spoff = maxoff;
55         ifspoff >= AUTOINIT ) spoff -= AUTOINIT;
56         spoff /= SZCHAR;
57         SETOFF(spoff,4);
58         printf"       .set    .F%d,%Ld\n"ftnnospoff );
59         maxargs = -1;
60         }
61
62 struct hoptab { int opmaskchar * opstring; } ioptab[] = {
63
64         ASG PLUS"add",
65         ASG MINUS"sub",
66         ASG MUL"mul",
67         ASG DIV"div",
68         ASG OR"bis",
69         ASG ER"xor",
70         ASG AND"bic",
71         PLUS,   "add",
72         MINUS,  "sub",
73         MUL,    "mul",
74         DIV,    "div",
75         OR,     "bis",
76         ER,     "xor",
77         AND,    "bic",
78         -1""    };
79
80 hopcodefo ){
81         /* output the appropriate string from the above table */
82
83         register struct hoptab *q;
84
85         forq = ioptab;  q->opmask>=0; ++q ){
86                 ifq->opmask == o ){
87                         printf"%s"q->opstring );
88 /* tbl
89                         if( f == 'F' ) printf( "e" );
90                         else if( f == 'D' ) printf( "d" );
91    tbl */
92 /* tbl */
93                         switchf ) {
94                                 case 'L':
95                                 case 'W':
96                                 case 'B':
97                                 case 'D':
98                                 case 'F':
99                                         printf("%c"tolower(f));
100                                         break;
101
102                                 }
103 /* tbl */
104                         return;
105                         }
106                 }
107         cerror"no hoptab for %s"opst[o] );
108         }
109
110 char *
111 rnames[] = {  /* keyed to register number tokens */
112
113         "r0""r1",
114         "r2""r3""r4""r5",
115         "r6""r7""r8""r9""r10""r11",
116         "ap""fp""sp""pc",
117
118         };
119
120 int rstatus[] = {
121         SAREG|STAREGSAREG|STAREG,
122         SAREG|STAREGSAREG|STAREGSAREG|STAREGSAREG|STAREG,
123         SAREGSAREGSAREGSAREGSAREGSAREG,
124         SAREGSAREGSAREGSAREG,
125
126         };
127
128 tlen(pNODE *p;
129 {
130         switch(p->type) {
131                 case CHAR:
132                 case UCHAR:
133                         return(1);
134
135                 case SHORT:
136                 case USHORT:
137                         return(2);
138
139                 case DOUBLE:
140                         return(8);
141
142                 default:
143                         return(4);
144                 }
145 }
146
147 mixtypes(pqNODE *p, *q;
148 {
149         register tptq;
150
151         tp = p->type;
152         tq = q->type;
153
154         return( (tp==FLOAT || tp==DOUBLE) !=
155                 (tq==FLOAT || tq==DOUBLE) );
156 }
157
158 prtype(nNODE *n;
159 {
160         switch (n->type)
161                 {
162                 case DOUBLE:
163                         printf("d");
164                         return;
165
166                 case FLOAT:
167                         printf("f");
168                         return;
169
170                 case LONG:
171                 case ULONG:
172                 case INT:
173                 case UNSIGNED:
174                         printf("l");
175                         return;
176
177                 case SHORT:
178                 case USHORT:
179                         printf("w");
180                         return;
181
182                 case CHAR:
183                 case UCHAR:
184                         printf("b");
185                         return;
186
187                 default:
188                         if ( !ISPTRn->type ) ) cerror("zzzcode- bad type");
189                         else {
190                                 printf("l");
191                                 return;
192                                 }
193                 }
194 }
195
196 zzzcodepc ) register NODE *p; {
197         register m;
198         CONSZ val;
199         switchc ){
200
201         case 'N':  /* logical ops, turned into 0-1 */
202                 /* use register given by register 1 */
203                 cbgen0m=getlab(), 'I' );
204                 deflabp->label );
205                 printf"       clrl    %s\n"rnames[getlrp'1' )->rval] );
206                 deflabm );
207                 return;
208
209         case 'I':
210         case 'P':
211                 cbgenp->opp->labelc );
212                 return;
213
214         case 'A':
215                 {
216                 register NODE *l, *r;
217
218                 if (xdebugeprint(p0, &val, &val);
219                 r = getlr(p'R');
220                 if (optype(p->op) == LTYPE || p->op == UNARY MUL)
221                         {
222                         l = resc;
223                         l->type = (r->type==FLOAT || r->type==DOUBLE ? DOUBLE : INT);
224                         }
225                 else
226                         l = getlr(p'L');
227                 if (r->op == ICON  && r->name[0] == '\0')
228                         {
229                         if (r->lval == 0)
230                                 {
231                                 printf("clr");
232                                 prtype(l);
233                                 printf("        ");
234                                 adrput(l);
235                                 return;
236                                 }
237                         if (r->lval < 0 && r->lval >= -63)
238                                 {
239                                 printf("mneg");
240                                 prtype(l);
241                                 r->lval = -r->lval;
242                                 goto ops;
243                                 }
244                         r->type = (r->lval < 0 ?
245                                         (r->lval >= -128 ? CHAR
246                                         : (r->lval >= -32768 ? SHORT
247                                         : INT )) : r->type);
248                         r->type = (r->lval >= 0 ?
249                                         (r->lval <= 63 ? INT
250                                         : ( r->lval <= 127 ? CHAR
251                                         : (r->lval <= 255 ? UCHAR
252                                         : (r->lval <= 32767 ? SHORT
253                                         : (r->lval <= 65535 ? USHORT
254                                         : INT ))))) : r->type );
255                         }
256                 if (l->op == REG && l->type != FLOAT && l->type != DOUBLE)
257                         l->type = INT;
258                 if (!mixtypes(l,r))
259                         {
260                         if (tlen(l) == tlen(r))
261                                 {
262                                 printf("mov");
263                                 prtype(l);
264                                 goto ops;
265                                 }
266                         else if (tlen(l) > tlen(r) && ISUNSIGNED(r->type))
267                                 {
268                                 printf("movz");
269                                 }
270                         else
271                                 {
272                                 printf("cvt");
273                                 }
274                         }
275                 else
276                         {
277                         printf("cvt");
278                         }
279                 prtype(r);
280                 prtype(l);
281         ops:
282                 printf("        ");
283                 adrput(r);
284                 printf(",");
285                 adrput(l);
286                 return;
287                 }
288
289         case 'C':       /* num words pushed on arg stack */
290                 {
291                 extern int gc_numbytes;
292                 extern int xdebug;
293
294                 if (xdebugprintf("->%d<-",gc_numbytes);
295
296                 printf("$%d"gc_numbytes/(SZLONG/SZCHAR) );
297                 return;
298                 }
299
300         case 'D':       /* INCR and DECR */
301                 zzzcode(p->left'A');
302                 printf("\n      ");
303
304         case 'E':       /* INCR and DECR, FOREFF */
305                 if (p->right->lval == 1)
306                         {
307                         printf("%s", (p->op == INCR ? "inc" : "dec") );
308                         prtype(p->left);
309                         printf("        ");
310                         adrput(p->left);
311                         return;
312                         }
313                 printf("%s", (p->op == INCR ? "add" : "sub") );
314                 prtype(p->left);
315                 printf("2       ");
316                 adrput(p->right);
317                 printf(",");
318                 adrput(p->left);
319                 return;
320
321         case 'F':       /* register type of right operand */
322                 {
323                 register NODE *n;
324                 extern int xdebug;
325                 register int ty;
326
327                 n = getlrp'R' );
328                 ty = n->type;
329
330                 if (xdebugprintf("->%d<-"ty);
331
332                 if ( ty==DOUBLEprintf("d");
333                 else if ( ty==FLOAT ) printf("f");
334                 else printf("l");
335                 return;
336                 }
337
338         case 'L':       /* type of left operand */
339         case 'R':       /* type of right operand */
340                 {
341                 register NODE *n;
342                 extern int xdebug;
343
344                 n = getlr ( pc);
345                 if (xdebugprintf("->%d<-"n->type);
346
347                 prtype(n);
348                 return;
349                 }
350
351         case 'Z':       /* complement mask for bit instr */
352                 printf("$%Ld", ~p->right->lval);
353                 return;
354
355         case 'U':       /* 32 - n, for unsigned right shifts */
356                 printf("$%d"32 - p->right->lval );
357                 return;
358
359         case 'T':       /* rounded structure length for arguments */
360                 {
361                 int size;
362
363                 size = p->stsize;
364                 SETOFFsize4);
365                 printf("$%d"size);
366                 return;
367                 }
368
369         case 'S':  /* structure assignment */
370                 {
371                         register NODE *l, *r;
372                         register size;
373
374                         ifp->op == STASG ){
375                                 l = p->left;
376                                 r = p->right;
377
378                                 }
379                         else ifp->op == STARG ){  /* store an arg into a temporary */
380                                 l = getlrp'3' );
381                                 r = p->left;
382                                 }
383                         else cerror"STASG bad" );
384
385                         ifr->op == ICON ) r->op = NAME;
386                         else ifr->op == REG ) r->op = OREG;
387                         else ifr->op != OREG ) cerror"STASG-r" );
388
389                         size = p->stsize;
390
391                         ifsize <= 0 || size > 65535 )
392                                 cerror("structure size <0=0 or >65535");
393
394                         switch(size) {
395                                 case 1:
396                                         printf("        movb    ");
397                                         break;
398                                 case 2:
399                                         printf("        movw    ");
400                                         break;
401                                 case 4:
402                                         printf("        movl    ");
403                                         break;
404                                 case 8:
405                                         printf("        movq    ");
406                                         break;
407                                 default:
408                                         printf("        movc3   $%d,"size);
409                                         break;
410                         }
411                         adrput(r);
412                         printf(",");
413                         adrput(l);
414                         printf("\n");
415
416                         ifr->op == NAME ) r->op = ICON;
417                         else ifr->op == OREG ) r->op = REG;
418
419                         }
420                 break;
421
422         default:
423                 cerror"illegal zzzcode" );
424                 }
425         }
426
427 rmovertrst ){
428         printf"       %s      %s,%s\n",
429                 (t==FLOAT ? "movf" : (t==DOUBLE ? "movd" : "movl")),
430                 rnames[rs], rnames[rt] );
431         }
432
433 struct respref
434 respref[] = {
435         INTAREG|INTBREG,        INTAREG|INTBREG,
436         INAREG|INBREG,  INAREG|INBREG|SOREG|STARREG|STARNM|SNAME|SCON,
437         INTEMPINTEMP,
438         FORARGFORARG,
439         INTEMPINTAREG|INAREG|INTBREG|INBREG|SOREG|STARREG|STARNM,
440         0,      0 };
441
442 setregs(){ /* set up temporary registers */
443         fregs = 6;      /* tbl- 6 free regs on VAX (0-5) */
444         ;
445         }
446
447 szty(t){ /* size, in registers, needed to hold thing of type t */
448         return( (t==DOUBLE||t==FLOAT) ? 2 : 1 );
449         }
450
451 rewfldp ) NODE *p; {
452         return(1);
453         }
454
455 callreg(pNODE *p; {
456         returnR0 );
457         }
458
459 basep ) register NODE *p; {
460         register int o = p->op;
461
462         if( (o==ICON && p->name[0] != '\0')) return100 ); /* ie no base reg */
463         ifo==REG ) returnp->rval );
464     if( (o==PLUS || o==MINUS) && p->left->op == REG && p->right->op==ICON)
465                 returnp->left->rval );
466     ifo==OREG && !R2TEST(p->rval) && (p->type==INT || p->type==UNSIGNED || ISPTR(p->type)) )
467                 returnp->rval + 0200*1 );
468         ifo==INCR && p->left->op==REG ) returnp->left->rval + 0200*2 );
469         ifo==ASG MINUS && p->left->op==REGreturnp->left->rval + 0200*4 );
470         ifo==UNARY MUL && p->left->op==INCR && p->left->left->op==REG
471           && (p->type==INT || p->type==UNSIGNED || ISPTR(p->type)) )
472                 returnp->left->left->rval + 0200*(1+2) );
473         return( -1 );
474         }
475
476 offsetptyl ) register NODE *pint tyl; {
477
478         iftyl==1 && p->op==REG && (p->type==INT || p->type==UNSIGNED) ) returnp->rval );
479         if( (p->op==LS && p->left->op==REG && (p->left->type==INT || p->left->type==UNSIGNED) &&
480               (p->right->op==ICON && p->right->name[0]=='\0')
481               && (1<<p->right->lval)==tyl))
482                 returnp->left->rval );
483         return( -1 );
484         }
485
486 makeor2pqboregister NODE *p, *qregister int bo; {
487         register NODE *t;
488         register int i;
489         NODE *f;
490
491         p->op = OREG;
492         f = p->left;    /* have to free this subtree later */
493
494         /* init base */
495         switch (q->op) {
496                 case ICON:
497                 case REG:
498                 case OREG:
499                         t = q;
500                         break;
501
502                 case MINUS:
503                         q->right->lval = -q->right->lval;
504                 case PLUS:
505                         t = q->right;
506                         break;
507
508                 case INCR:
509                 case ASG MINUS:
510                         t = q->left;
511                         break;
512
513                 case UNARY MUL:
514                         t = q->left->left;
515                         break;
516
517                 default:
518                         cerror("illegal makeor2");
519         }
520
521         p->lval = t->lval;
522         for(i=0i<NCHNAM; ++i)
523                 p->name[i] = t->name[i];
524
525         /* init offset */
526         p->rval = R2PACK( (b & 0177), o, (b>>7) );
527
528         tfree(f);
529         return;
530         }
531
532 canaddrp ) NODE *p; {
533         register int o = p->op;
534
535         ifo==NAME || o==REG || o==ICON || o==OREG || (o==UNARY MUL && shumul(p->left)) ) return(1);
536         return(0);
537         }
538
539 shltypeop ) register NODE *p; {
540         returno== REG || o == NAME || o == ICON || o == OREG || ( o==UNARY MUL && shumul(p->left)) );
541         }
542
543 flshapep ) register NODE *p; {
544         returnp->op == REG || p->op == NAME || p->op == ICON ||
545                 (p->op == OREG && (!R2TEST(p->rval) || tlen(p) == 1)) );
546         }
547
548 shtempp ) register NODE *p; {
549         ifp->op == STARG ) p = p->left;
550         returnp->op==NAME || p->op ==ICON || p->op == OREG || (p->op==UNARY MUL && shumul(p->left)) );
551         }
552
553 shumulp ) register NODE *p; {
554         register o;
555         extern int xdebug;
556
557         if (xdebug) {
558                  printf("\nshumul:op=%d,lop=%d,rop=%d"p->opp->left->opp->right->op);
559                 printf(" prname=%s,plty=%d, prlval=%D\n"p->right->namep->left->typep->right->lval);
560                 }
561
562
563         o = p->op;
564         ifo == NAME || (o == OREG && !R2TEST(p->rval)) || o == ICON ) returnSTARNM );
565
566         if( ( o == INCR || o == ASG MINUS ) &&
567             ( p->left->op == REG && p->right->op == ICON ) &&
568             p->right->name[0] == '\0' )
569                 {
570                 switch (p->left->type)
571                         {
572                         case CHAR|PTR:
573                         case UCHAR|PTR:
574                                 o = 1;
575                                 break;
576
577                         case SHORT|PTR:
578                         case USHORT|PTR:
579                                 o = 2;
580                                 break;
581
582                         case INT|PTR:
583                         case UNSIGNED|PTR:
584                         case LONG|PTR:
585                         case ULONG|PTR:
586                         case FLOAT|PTR:
587                                 o = 4;
588                                 break;
589
590                         case DOUBLE|PTR:
591                                 o = 8;
592                                 break;
593
594                         default:
595                                 if ( ISPTR(p->left->type) ) {
596                                         o = 4;
597                                         break;
598                                         }
599                                 else return(0);
600                         }
601                 returnp->right->lval == o ? STARREG : 0);
602                 }
603
604         return0 );
605         }
606
607 adrconval ) CONSZ val; {
608         printf"$" );
609         printfCONFMTval );
610         }
611
612 conputp ) register NODE *p; {
613         switchp->op ){
614
615         case ICON:
616                 aconp );
617                 return;
618
619         case REG:
620                 printf"%s"rnames[p->rval] );
621                 return;
622
623         default:
624                 cerror"illegal conput" );
625                 }
626         }
627
628 insputp ) register NODE *p; {
629         cerror"insput" );
630         }
631
632 upputp ) register NODE *p; {
633         cerror"upput" );
634         }
635
636 adrputp ) register NODE *p; {
637         register int r;
638         /* output an address, with offsets, from p */
639
640         ifp->op == FLD ){
641                 p = p->left;
642                 }
643         switchp->op ){
644
645         case NAME:
646                 aconp );
647                 return;
648
649         case ICON:
650                 /* addressable value of the constant */
651                 printf"$" );
652                 aconp );
653                 return;
654
655         case REG:
656                 printf"%s"rnames[p->rval] );
657                 return;
658
659         case OREG:
660                 r = p->rval;
661                 ifR2TEST(r) ){ /* double indexing */
662                         register int flags;
663
664                         flags = R2UPK3(r);
665                         ifflags & 1 ) printf("*");
666                         ifflags & 4 ) printf("-");
667                         ifp->lval != 0 || p->name[0] != '\0' ) acon(p);
668                         ifR2UPK1(r) != 100printf"(%s)"rnames[R2UPK1(r)] );
669                         ifflags & 2 ) printf("+");
670                         printf"[%s]"rnames[R2UPK2(r)] );
671                         return;
672                         }
673                 ifr == AP ){  /* in the argument region */
674                         ifp->lval <= 0 || p->name[0] != '\0' ) werror"bad arg temp" );
675                         printfCONFMTp->lval );
676                         printf"(ap)" );
677                         return;
678                         }
679                 ifp->lval != 0 || p->name[0] != '\0'aconp );
680                 printf"(%s)"rnames[p->rval] );
681                 return;
682
683         case UNARY MUL:
684                 /* STARNM or STARREG found */
685                 iftshape(pSTARNM) ) {
686                         printf"*" );
687                         adrputp->left);
688                         }
689                 else {  /* STARREG - really auto inc or dec */
690                         register NODE *q;
691
692 /* tbl
693                         p = p->left;
694                         p->left->op = OREG;
695                         if( p->op == INCR ) {
696                                 adrput( p->left );
697                                 printf( "+" );
698                                 }
699                         else {
700                                 printf( "-" );
701                                 adrput( p->left );
702                                 }
703    tbl */
704                         printf("%c(%s)%c", (p->left->op==INCR ? '\0' : '-'),
705                                 rnames[p->left->left->rval], 
706                                 (p->left->op==INCR ? '+' : '\0') );
707                         p->op = OREG;
708                         p->rval = p->left->left->rval;
709                         q = p->left;
710                         p->lval = (p->left->op == INCR ? -p->left->right->lval : 0);
711                         p->name[0] = '\0';
712                         tfree(q);
713                 }
714                 return;
715
716         default:
717                 cerror"illegal address" );
718                 return;
719
720                 }
721
722         }
723
724 aconp ) register NODE *p; { /* print out a constant */
725
726         ifp->name[0] == '\0' ){
727                 printfCONFMTp->lval);
728                 }
729         else ifp->lval == 0 ) {
730                 printf"%.8s"p->name );
731                 }
732         else {
733                 printf"%.8s+"p->name );
734                 printfCONFMTp->lval );
735                 }
736         }
737
738 /*
739 aacon( p ) register NODE *p; { /* print out a constant */
740 /*
741
742         if( p->name[0] == '\0' ){
743                 printf( CONFMT, p->lval);
744                 return( 0 );
745                 }
746         else if( p->lval == 0 ) {
747                 printf( "$%.8s", p->name );
748                 return( 1 );
749                 }
750         else {
751                 printf( "$(" );
752                 printf( CONFMT, p->lval );
753                 printf( "+" );
754                 printf( "%.8s)", p->name );
755                 return(1);
756                 }
757         }
758  */
759
760 genscallpcookie ) register NODE *p; {
761         /* structure valued call */
762         returngencallpcookie ) );
763         }
764
765 /* tbl */
766 int gc_numbytes;
767 /* tbl */
768
769 gencallpcookie ) register NODE *p; {
770         /* generate the call given by p */
771         register NODE *p1, *ptemp;
772         register temptemp1;
773         register m;
774
775         ifp->right ) temp = argsizep->right );
776         else temp = 0;
777
778         ifp->op == STCALL || p->op == UNARY STCALL ){
779                 /* set aside room for structure return */
780
781                 ifp->stsize > temp ) temp1 = p->stsize;
782                 else temp1 = temp;
783                 }
784
785         iftemp > maxargs ) maxargs = temp;
786         SETOFF(temp1,4);
787
788         ifp->right ){ /* make temp node, put offset in, and generate args */
789                 ptemp = talloc();
790                 ptemp->op = OREG;
791                 ptemp->lval = -1;
792                 ptemp->rval = SP;
793                 ptemp->name[0] = '\0';
794                 ptemp->rall = NOPREF;
795                 ptemp->su = 0;
796                 genargsp->rightptemp );
797                 ptemp->op = FREE;
798                 }
799
800         p1 = p->left;
801         ifp1->op != ICON ){
802                 ifp1->op != REG ){
803                         ifp1->op != OREG || R2TEST(p1->rval) ){
804                                 ifp1->op != NAME ){
805                                         orderp1INAREG );
806                                         }
807                                 }
808                         }
809                 }
810
811 /*
812         if( p1->op == REG && p->rval == R5 ){
813                 cerror( "call register overwrite" );
814                 }
815  */
816 /* tbl
817         setup gc_numbytes so reference to ZC works */
818
819         gc_numbytes = temp;
820 /* tbl */
821
822         p->op = UNARY CALL;
823         m = matchpINTAREG|INTBREG );
824 /* tbl
825         switch( temp ) {
826         case 0:
827                 break;
828         case 2:
829                 printf( "       tst     (sp)+\n" );
830                 break;
831         case 4:
832                 printf( "       cmp     (sp)+,(sp)+\n" );
833                 break;
834         default:
835                 printf( "       add     $%d,sp\n", temp);
836                 }
837    tbl */
838         return(m != MDONE);
839         }
840
841 /* tbl */
842 char *
843 ccbranches[] = {
844         "       jeql    L%d\n",
845         "       jneq    L%d\n",
846         "       jleq    L%d\n",
847         "       jlss    L%d\n",
848         "       jgeq    L%d\n",
849         "       jgtr    L%d\n",
850         "       jlequ   L%d\n",
851         "       jlssu   L%d\n",
852         "       jgequ   L%d\n",
853         "       jgtru   L%d\n",
854         };
855 /* tbl */
856
857 cbgenolabmode ) { /*   printf conditional and unconditional branches */
858
859 /* tbl */
860         ifo == 0 ) printf"  jbr     L%d\n"lab );
861 /* tbl */
862         else {
863                 ifo > UGT ) cerror"bad conditional branch: %s"opst[o] );
864                 printfccbranches[o-EQ], lab );
865                 }
866         }
867
868 nextcookpcookie ) NODE *p; {
869         /* we have failed to match p with cookie; try another */
870         ifcookie == FORREW ) return0 );  /* hopeless! */
871         if( !(cookie&(INTAREG|INTBREG)) ) returnINTAREG|INTBREG );
872         if( !(cookie&INTEMP) && asgop(p->op) ) returnINTEMP|INAREG|INTAREG|INTBREG|INBREG );
873         returnFORREW );
874         }
875
876 lastchancepcook ) NODE *p; {
877         /* forget it! */
878         return(0);
879         }
880
881 optim2p ) register NODE *p; {
882         /* do local tree transformations and optimizations */
883
884         register NODE *r;
885
886         switchp->op ) {
887
888         case AND:
889                 /* commute L and R to eliminate compliments and constants */
890                 if( (p->left->op==ICON&&p->left->name[0]==0) || p->left->op==COMPL ) {
891                         r = p->left;
892                         p->left = p->right;
893                         p->right = r;
894                         }
895         case ASG AND:
896                 /* change meaning of AND to ~R&L - bic on pdp11 */
897                 r = p->right;
898                 ifr->op==ICON && r->name[0]==0 ) { /* compliment constant */
899                         r->lval = ~r->lval;
900                         }
901                 else ifr->op==COMPL ) { /* ~~A => A */
902                         r->op = FREE;
903                         p->right = r->left;
904                         }
905                 else { /* insert complement node */
906                         p->right = talloc();
907                         p->right->op = COMPL;
908                         p->right->rall = NOPREF;
909                         p->right->type = r->type;
910                         p->right->left = r;
911                         p->right->right = NULL;
912                         }
913                 break;
914
915                 }
916         }
917
918
919 # ifndef ONEPASS
920 mainargcargv ) char *argv[]; {
921         returnmainp2argcargv ) );
922         }
923 # endif
FishEye: Open Source License registered to PCC.
Your maintenance has expired. You can renew your license at http://www.atlassian.com/fisheye/renew
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-09-01 15:46 +0200