Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.1
 
1.2
 
MAIN:ragge:20071026150641
 
code.c
_>3333  * POSSIBILITY OF SUCH DAMAGE.
 3434  */
 3535 
<>36 -# include "mfile1"
 37 -#include <a.out.h>
  36+# include "pass1.h"
3837 
<>39 -int proflg = 0/* are we generating profiling code? */
 40 -int strftn = 0/* is the current function one which returns a value */
 41 -int gdebug;
 42 -int fdefflag/* are we within a function definition ? */
 43 -char NULLNAME[8];
 44 -int labelno;
 45 -
 46 -branch( n ){
 47 -        /* output a branch to label n */
 48 -        /* exception is an ordinary function branching to retlab: then, return */
 49 -        if( n == retlab && !strftn ){
 50 -                printf( "       ret\n" );
 51 -                }
 52 -        else printf( "  jbr     L%d\n", n );
 53 -        }
 54 -
 55 -int lastloc = { -1 };
 56 -
5738 short log2tab[] = {0, 0, 1, 2, 2, 3, 3, 3, 3};
 5839 #define LOG2SZ 9
 5940 
<> 41+void
6042 defalign(n) {
 6143         /* cause the alignment to become a multiple of n */
 6244         n /= SZCHAR;
 6345         if( lastloc != PROG && n > 1 ) printf( "        .align  %d\n", n >= 0 && n < LOG2SZ ? log2tab[n] : 0 );
 6446         }
 6547 
<>66 -locctr( l ){
 67 -        register temp;
 68 -        /* l is PROG, ADATA, DATA, STRNG, ISTRNG, or STAB */
  48+/*
  49+ * output something to define the current position as label n
  50+ */
  51+void
  52+deflab1(int n)
  53+{
  54+        printf(LABFMT ":\n", n);
  55+}
6956 
<>70 -        if( l == lastloc ) return(l);
 71 -        temp = lastloc;
 72 -        lastloc = l;
 73 -        switch( l ){
 74 -
 75 -        case PROG:
 76 -                printf( "       .text\n" );
 77 -                psline();
 78 -                break;
 79 -
 80 -        case DATA:
 81 -        case ADATA:
 82 -                printf( "       .data\n" );
 83 -                break;
 84 -
 85 -        case STRNG:
 86 -                printf( "       .data   1\n" );
 87 -                break;
 88 -
 89 -        case ISTRNG:
 90 -                printf( "       .data   2\n" );
 91 -                break;
 92 -
 93 -        case STAB:
 94 -                printf( "       .stab\n" );
 95 -                break;
 96 -
 97 -        default:
 98 -                cerror( "illegal location counter" );
 99 -                }
 100 -
 101 -        return( temp );
 102 -        }
 103 -
 104 -deflab( n ){
 105 -        /* output something to define the current position as label n */
 106 -        printf( "L%d:\n", n );
 107 -        }
 108 -
 109 -int crslab = 10;
 110 -
 111 -getlab(){
 112 -        /* return a number usable for a label */
 113 -        return( ++crslab );
 114 -        }
 115 -
 116 -
 117 -int ent_mask[] = {
 118 -        0,0,0,0,0, 0xfc0, 0xf80, 0xf00, 0xe00, 0xc00, 0x800, 0};
 119 -
 120 -int reg_use = 11;
 121 -
  57+void
12258 efcode(){
 12359         /* code for the end of a function */
<> 60+        if (cftnsp->stype != STRTY+FTN && cftnsp->stype != UNIONTY+FTN)
  61+                return;
  62+        cerror("efcode");
12463 
<> 64+#ifdef notyet
12565         if( strftn ){  /* copy output (in R2) to caller */
 12666                 register NODE *l, *r;
 12767                 register struct symtab *p;
     
 !
13878                 i = getlab();   /* label for return area */
 13979                 printf("        .data\n" );
 14080                 printf("        .align  2\n" );
<>141 -                printf("L%d:    .space  %d\n", i, tsize(t, p->dimoff, p->sizoff)/SZCHAR );
  81+                deflab1(i);
  82+                printf("\t.space  %d\n", tsize(t, p->dimoff, p->sizoff)/SZCHAR);
14283                 printf("        .text\n" );
 14384                 psline();
<>144 -                printf("        movab   L%d,r1\n", i);
  85+                printf("        movab   " LABFMT ",r1\n", i);
14586 
 14687                 reached = 1;
 14788                 l = block( REG, NIL, NIL, PTR|t, p->dimoff, p->sizoff );
     
 !
15596                 l = buildtree( ASSIGN, l, r );
 15697                 l->op = FREE;
 15798                 ecomp( l->left );
<>158 -                printf( "       movab   L%d,r0\n", i );
  99+                printf( "       movab   " LABFMT ",r0\n", i );
159100                 /* turn off strftn flag, so return sequence will be generated */
 160101                 strftn = 0;
 161102                 }
     
 !
164105         reg_use = 11;
 165106         p2bend();
 166107         fdefflag = 0;
<> 108+#endif
167109         }
 168110 
<>169 -bfcode( a, n ) int a[]; {
 170 -        /* code for the beginning of a function; a is an array of
 171 -                indices in stab for the arguments; n is the number */
 172 -        register i;
 173 -        register temp;
 174 -        register struct symtab *p;
 175 -        int off;
 176 -        char *toreg();
  111+void
  112+bfcode(struct symtab **a, int n)
  113+{
  114+        int i;
177115 
<>178 -        locctr( PROG );
 179 -        p = &stab[curftn];
 180 -        printf( "       .align  1\n");
 181 -        defnam( p );
 182 -        temp = p->stype;
 183 -        temp = DECREF(temp);
 184 -        strftn = (temp==STRTY) || (temp==UNIONTY);
  116+        if (cftnsp->stype != STRTY+FTN && cftnsp->stype != UNIONTY+FTN)
  117+                return;
  118+        /* Function returns struct, adjust arg offset */
  119+        for (i = 0; i < n; i++)
  120+                a[i]->soffset += SZPOINT(INT);
  121+}
185122 
<>186 -        retlab = getlab();
 187 -
 188 -        /* routine prolog */
 189 -
 190 -        printf( "       .word   .R%d\n", ftnno);
 191 -        if (gdebug) {
 192 -                pstab(NULLNAME, N_SLINE);
 193 -                printf("0,%d,LL%d\n", lineno, labelno);
 194 -                printf("LL%d:\n", labelno++);
 195 -        }
 196 -        printf( "       subl2   $.F%d,sp\n", ftnno);
 197 -        if( proflg ) {  /* profile code */
 198 -                i = getlab();
 199 -                printf("        movab   L%d,r0\n", i);
 200 -                printf("        jsb     mcount\n");
 201 -                printf("        .data\n");
 202 -                printf("        .align  2\n");
 203 -                printf("L%d:    .long   0\n", i);
 204 -                printf("        .text\n");
 205 -                psline();
 206 -                }
 207 -
 208 -        off = ARGINIT;
 209 -
 210 -        for( i=0; i<n; ++i ){
 211 -                p = &stab[a[i]];
 212 -                if( p->sclass == REGISTER ){
 213 -                        temp = p->offset/* save register number */
 214 -                        p->sclass = PARAM/* forget that it is a register */
 215 -                        p->offset = NOOFFSET;
 216 -                        oalloc( p, &off );
 217 -/*tbl*/         printf( "       %s      %d(ap),r%d\n", toreg(p->stype), p->offset/SZCHAR, temp );
 218 -                        p->offset = temp/* remember register number */
 219 -                        p->sclass = REGISTER;   /* remember that it is a register */
 220 -                        }
 221 -                else {
 222 -                        if( oalloc( p, &off ) ) cerror( "bad argument" );
 223 -                        }
 224 -
 225 -                }
 226 -        fdefflag = 1;
 227 -        }
 228 -
  123+void
229124 bccode(){ /* called just before the first executable statment */
 230125                 /* by now, the automatics and register variables are allocated */
 231126         SETOFF( autooff, SZINT );
<> 127+#if 0
232128         /* set aside store area offset */
 233129         p2bbeg( autooff, regvar );
 234130         reg_use = (reg_use > regvar ? regvar : reg_use);
<> 131+#endif
235132         }
 236133 
<> 134+void
237135 ejobcode( flag ){
 238136         /* called just before final exit */
 239137         /* flag is 1 if errors, 0 if none */
 240138         }
 241139 
<> 140+void
  141+bjobcode()
  142+{
  143+}
  144+
  145+#if 0
242146 aobeg(){
 243147         /* called before removing automatics from stab */
 244148         }
     
 !
250154 aoend(){
 251155         /* called after removing all automatics from stab */
 252156         }
<> 157+#endif
253158 
<> 159+void
254160 defnam( p ) register struct symtab *p; {
 255161         /* define the current location as the name p->sname */
 256162 
 257163         if( p->sclass == EXTDEF ){
 258164                 printf( "       .globl  %s\n", exname( p->sname ) );
 259165                 }
<>260 -        if( p->sclass == STATIC && p->slevel>1 ) deflab( p->offset );
 261 -        else printf( "%s:\n", exname( p->sname ) );
  166+        printf( "%s:\n", exname( p->sname ) );
262167 
 263168         }
 264169 
<> 170+void
265171 bycode( t, i ){
 266172         /* put byte i+1 in a string */
 267173 
     
 !
278184                 }
 279185         }
 280186 
<> 187+void
281188 zecode( n ){
 282189         /* n integer words of zeros */
<>283 -        OFFSZ temp;
284190         if( n <= 0 ) return;
 285191         printf( "       .space  %d\n", (SZINT/SZCHAR)*n );
<>286 -        temp = n;
 287 -        inoff += temp*SZINT;
288192         }
 289193 
<> 194+int
290195 fldal( t ) unsigned t; { /* return the alignment of field of type t */
 291196         uerror( "illegal field type" );
 292197         return( ALINT );
 293198         }
 294199 
<> 200+void
295201 fldty( p ) struct symtab *p; { /* fix up type of field p */
 296202         ;
 297203         }
 298204 
<>299 -where(c){ /* print location of error  */
 300 -        /* c is either 'u', 'c', or 'w' */
 301 -        /* GCOS version */
 302 -        fprintf( stderr, "%s, line %d: ", ftitle, lineno );
 303 -        }
 304 -
 305 -
 306 -/* tbl - toreg() returns a pointer to a char string
 307 -                  which is the correct  "register move" for the passed type
  205+/* p points to an array of structures, each consisting
  206+ * of a constant value and a label.
  207+ * The first is >=0 if there is a default label;
  208+ * its value is the label number
  209+ * The entries p[1] to p[n] are the nontrivial cases
  210+ * XXX - fix genswitch.
308211  */
<>309 -struct type_move {TWORD fromtype; char tostrng[8];} toreg_strs[] =
 310 -        {
 311 -        CHAR, "cvtbl",
 312 -        SHORT, "cvtwl",
 313 -        INT, "movl",
 314 -        LONG, "movl",
 315 -        FLOAT, "movf",
 316 -        DOUBLE, "movd",
 317 -        UCHAR,  "movzbl",
 318 -        USHORT"movzwl",
 319 -        UNSIGNED,       "movl",
 320 -        ULONG,  "movl",
 321 -        -1, ""
 322 -        };
 323 -
 324 -char
 325 -*toreg(type)
 326 -        TWORD type;
  212+void
  213+genswitch(int num, struct swents **p, int n)
327214 {
<>328 -        struct type_move *p;
 329 -
 330 -        for ( p=toreg_strs; p->fromtype > 0; p++)
 331 -                if (p->fromtype == type) return(p->tostrng);
 332 -
 333 -        /* type not found, must be a pointer type */
 334 -        return("movl");
  215+        cerror("genswitch");
335216 }
<>336 -/* tbl */
337217 
<>338 -
 339 -main( argc, argv ) char *argv[]; {
 340 -        return(mainp1( argc, argv ));
 341 -        }
 342 -
  218+#ifdef notyet
343219 struct sw heapsw[SWITSZ];       /* heap for switches */
 344220 
 345221 genswitch(p,n) register struct sw *p;{
     
 !
362238 
 363239                 /* already in r0 */
 364240                 printf("        casel   r0,$%ld,$%ld\n", p[1].sval, range);
<>365 -                printf("L%d:\n", swlab);
  241+                deflab1(swlab);
366242                 for( i=1,j=p[1].sval; i<=n; j++) {
<>367 -                        printf("        .word   L%d-L%d\n", (j == p[i].sval ? ((j=p[i++].sval), p[i-1].slab) : dlab),
  243+                        printf("        .word   " LABFMT "-" LABFMT "\n",
  244+                            (j == p[i].sval ? ((j=p[i++].sval), p[i-1].slab) : dlab),
368245                                 swlab);
 369246                         }
 370247 
 371248                 if( p->slab >= 0 ) branch( dlab );
<>372 -                else printf("L%d:\n", dlab);
  249+                else deflab1(dlab);
373250                 return;
 374251 
 375252                 }
     
 !
384261                 if( p->slab >= 0 )
 385262                         branch( dlab );
 386263                 else
<>387 -                        printf("L%d:\n", dlab);
  264+                        deflab1(dlab);
388265                 return;
 389266         }
 390267 
     
 !
401278 
 402279                 printf( "       cmpl    r0,$" );
 403280                 printf( CONFMT, p[i].sval );
<>404 -                printf( "\n     jeql    L%d\n", p[i].slab );
  281+                printf( "\n     jeql    " LBLFMT "\n", p[i].slab );
405282                 }
 406283 
 407284         if( p->slab>=0 ) branch( p->slab );
     
 !
434311 
 435312         if( start > limit ) return;
 436313         printf("        cmpl    r0,$%d\n"heapsw[start].sval);
<>437 -        printf("        jeql    L%d\n", heapsw[start].slab);
  314+        printf("        jeql    " LBLFMT "\n", heapsw[start].slab);
438315         if( (2*start) > limit ) {
<>439 -                printf("        jbr     L%d\n", heapsw[0].slab);
  316+                printf("        jbr     " LBLFMT "\n", heapsw[0].slab);
440317                 return;
 441318         }
 442319         if( (2*start+1) <= limit ) {
 443320                 label = getlab();
<>444 -                printf("        jgtr    L%d\n", label);
  321+                printf("        jgtr    " LBLFMT "\n", label);
445322         } else
<>446 -                printf("        jgtr    L%d\n", heapsw[0].slab);
  323+                printf("        jgtr    " LBLFMT "\n", heapsw[0].slab);
447324         walkheap( 2*start, limit);
 448325         if( (2*start+1) <= limit ) {
<>449 -                printf("L%d:\n", label);
  326+                deflab1(label);
450327                 walkheap( 2*start+1, limit);
 451328         }
 452329 }
<_ 330+#endif
FishEye: Open Source License registered to PCC.
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-12-18 16:26 +0100