Annotation of 42BSD/usr.bin/f77/src/f77pass1/vax.c, revision 1.1.1.1

1.1       root        1: #include "defs.h"
                      2: 
                      3: #ifdef SDB
                      4: #      include <a.out.h>
                      5: extern int types2[];
                      6: #      ifndef N_SO
                      7: #              include <stab.h>
                      8: #      endif
                      9: #endif
                     10: 
                     11: #include "pccdefs.h"
                     12: 
                     13: 
                     14: /*
                     15:        VAX-11/780 - SPECIFIC ROUTINES
                     16: */
                     17: 
                     18: 
                     19: int maxregvar = MAXREGVAR;
                     20: int regnum[] =  { 10, 9, 8, 7, 6 } ;
                     21: static int regmask[] = { 0x800, 0xc00, 0xe00, 0xf00, 0xf80, 0xfc0 };
                     22: 
                     23: 
                     24: 
                     25: ftnint intcon[14] =
                     26:        { 2, 2, 2, 2,
                     27:          15, 31, 24, 56,
                     28:          -128, -128, 127, 127,
                     29:          32767, 2147483647 };
                     30: 
                     31: #if HERE == VAX
                     32:        /* then put in constants in octal */
                     33: long realcon[6][2] =
                     34:        {
                     35:                { 0200, 0 },
                     36:                { 0200, 0 },
                     37:                { 037777677777, 0 },
                     38:                { 037777677777, 037777777777 },
                     39:                { 032200, 0 },
                     40:                { 022200, 0 }
                     41:        };
                     42: #else
                     43: double realcon[6] =
                     44:        {
                     45:        2.9387358771e-39,
                     46:        2.938735877055718800e-39
                     47:        1.7014117332e+38,
                     48:        1.701411834604692250e+38
                     49:        5.960464e-8,
                     50:        1.38777878078144567e-17,
                     51:        };
                     52: #endif
                     53: 
                     54: 
                     55: 
                     56: 
                     57: prsave(proflab)
                     58: int proflab;
                     59: {
                     60: if(profileflag)
                     61:        {
                     62:        fprintf(asmfile, "L%d:\t.space\t4\n", proflab);
                     63:        p2pi("\tmovab\tL%d,r0", proflab);
                     64:        p2pass("\tjsb\tmcount");
                     65:        }
                     66: p2pi("\tsubl2\t$LF%d,sp", procno);
                     67: }
                     68: 
                     69: 
                     70: 
                     71: goret(type)
                     72: int type;
                     73: {
                     74: p2pass("\tret");
                     75: }
                     76: 
                     77: 
                     78: 
                     79: 
                     80: /*
                     81:  * move argument slot arg1 (relative to ap)
                     82:  * to slot arg2 (relative to ARGREG)
                     83:  */
                     84: 
                     85: mvarg(type, arg1, arg2)
                     86: int type, arg1, arg2;
                     87: {
                     88: p2pij("\tmovl\t%d(ap),%d(fp)", arg1+ARGOFFSET, arg2+argloc);
                     89: }
                     90: 
                     91: 
                     92: 
                     93: 
                     94: prlabel(fp, k)
                     95: FILEP fp;
                     96: int k;
                     97: {
                     98: fprintf(fp, "L%d:\n", k);
                     99: }
                    100: 
                    101: 
                    102: 
                    103: prconi(fp, type, n)
                    104: FILEP fp;
                    105: int type;
                    106: ftnint n;
                    107: {
                    108: fprintf(fp, "\t%s\t%ld\n", (type==TYSHORT ? ".word" : ".long"), n);
                    109: }
                    110: 
                    111: 
                    112: 
                    113: prcona(fp, a)
                    114: FILEP fp;
                    115: ftnint a;
                    116: {
                    117: fprintf(fp, "\t.long\tL%ld\n", a);
                    118: }
                    119: 
                    120: 
                    121: 
                    122: #ifndef vax
                    123: prconr(fp, type, x)
                    124: FILEP fp;
                    125: int type;
                    126: float x;
                    127: {
                    128: fprintf(fp, "\t%s\t0f%e\n", (type==TYREAL ? ".float" : ".double"), x);
                    129: }
                    130: #endif
                    131: 
                    132: #ifdef vax
                    133: prconr(fp, type, x)
                    134: FILEP fp;
                    135: int type;
                    136: double x;
                    137: {
                    138: /* non-portable cheat to preserve bit patterns */
                    139: union { double xd; long int xl[2]; } cheat;
                    140: cheat.xd = x;
                    141: if(type == TYREAL)
                    142:        {float y = x; fprintf(fp, "\t.long\t0x%X\n", *(long *) &y); }
                    143: else
                    144:        fprintf(fp, "\t.long\t0x%X,0x%X\n", cheat.xl[0], cheat.xl[1]);
                    145: }
                    146: #endif
                    147: 
                    148: 
                    149: 
                    150: praddr(fp, stg, varno, offset)
                    151: FILE *fp;
                    152: int stg, varno;
                    153: ftnint offset;
                    154: {
                    155: char *memname();
                    156: 
                    157: if(stg == STGNULL)
                    158:        fprintf(fp, "\t.long\t0\n");
                    159: else
                    160:        {
                    161:        fprintf(fp, "\t.long\t%s", memname(stg,varno));
                    162:        if(offset)
                    163:                fprintf(fp, "+%ld", offset);
                    164:        fprintf(fp, "\n");
                    165:        }
                    166: }
                    167: 
                    168: 
                    169: 
                    170: 
                    171: preven(k)
                    172: int k;
                    173: {
                    174: register int lg;
                    175: 
                    176: if(k > 4)
                    177:        lg = 3;
                    178: else if(k > 2)
                    179:        lg = 2;
                    180: else if(k > 1)
                    181:        lg = 1;
                    182: else
                    183:        return;
                    184: fprintf(asmfile, "\t.align\t%d\n", lg);
                    185: }
                    186: 
                    187: 
                    188: 
                    189: 
                    190: pralign(k)
                    191: int k;
                    192: {
                    193:   register int lg;
                    194: 
                    195:   if (k > 4)
                    196:     lg = 3;
                    197:   else if (k > 2)
                    198:     lg = 2;
                    199:   else if (k > 1)
                    200:     lg = 1;
                    201:   else
                    202:     return;
                    203: 
                    204:   fprintf(initfile, "\t.align\t%d\n", lg);
                    205:   return;
                    206: }
                    207: 
                    208: 
                    209: 
                    210: vaxgoto(index, nlab, labs)
                    211: expptr index;
                    212: register int nlab;
                    213: struct Labelblock *labs[];
                    214: {
                    215: register int i;
                    216: register int arrlab;
                    217: 
                    218: putforce(TYINT, index);
                    219: p2pi("\tcasel\tr0,$1,$%d", nlab-1);
                    220: p2pi("L%d:", arrlab = newlabel() );
                    221: for(i = 0; i< nlab ; ++i)
                    222:        if( labs[i] )
                    223:                p2pij("\t.word\tL%d-L%d", labs[i]->labelno, arrlab);
                    224: }
                    225: 
                    226: 
                    227: prarif(p, neg, zer, pos)
                    228: expptr p;
                    229: int neg, zer, pos;
                    230: {
                    231: int type;
                    232: 
                    233: type = p->headblock.vtype;
                    234: putforce(type, p);
                    235: if(type == TYLONG)
                    236:        p2pass("\ttstl\tr0");
                    237: else if (type == TYSHORT)
                    238:        p2pass("\ttstw\tr0");
                    239: else
                    240:        p2pass("\ttstd\tr0");
                    241: p2pi("\tjlss\tL%d", neg);
                    242: p2pi("\tjeql\tL%d", zer);
                    243: p2pi("\tjbr\tL%d", pos);
                    244: }
                    245: 
                    246: 
                    247: 
                    248: 
                    249: char *memname(stg, mem)
                    250: int stg, mem;
                    251: {
                    252: static char s[20];
                    253: 
                    254: switch(stg)
                    255:        {
                    256:        case STGCOMMON:
                    257:        case STGEXT:
                    258:                sprintf(s, "_%s", varstr(XL, extsymtab[mem].extname) );
                    259:                break;
                    260: 
                    261:        case STGBSS:
                    262:        case STGINIT:
                    263:                sprintf(s, "v.%d", mem);
                    264:                break;
                    265: 
                    266:        case STGCONST:
                    267:                sprintf(s, "L%d", mem);
                    268:                break;
                    269: 
                    270:        case STGEQUIV:
                    271:                sprintf(s, "q.%d", mem+eqvstart);
                    272:                break;
                    273: 
                    274:        default:
                    275:                badstg("memname", stg);
                    276:        }
                    277: return(s);
                    278: }
                    279: 
                    280: 
                    281: 
                    282: 
                    283: prlocvar(s, len)
                    284: char *s;
                    285: ftnint len;
                    286: {
                    287: fprintf(asmfile, "\t.lcomm\t%s,%ld\n", s, len);
                    288: }
                    289: 
                    290: 
                    291: 
                    292: 
                    293: char *
                    294: packbytes(cp)
                    295: register Constp cp;
                    296: {
                    297:   static char shrt[2];
                    298:   static char lng[4];
                    299:   static char quad[8];
                    300:   static char oct[16];
                    301: 
                    302:   register int type;
                    303:   register int *ip, *jp;
                    304: 
                    305:   switch (cp->vtype)
                    306:     {
                    307:     case TYSHORT:
                    308:       *((short *) shrt) = (short) cp->const.ci;
                    309:       return (shrt);
                    310: 
                    311:     case TYLONG:
                    312:     case TYLOGICAL:
                    313:     case TYREAL:
                    314:       *((int *) lng) = cp->const.ci;
                    315:       return (lng);
                    316: 
                    317:     case TYDREAL:
                    318:       ip = (int *) quad;
                    319:       jp = (int *) &(cp->const.cd[0]);
                    320:       ip[0] = jp[0];
                    321:       ip[1] = jp[1];
                    322:       return (quad);
                    323: 
                    324:     case TYCOMPLEX:
                    325:       ip = (int *) quad;
                    326:       jp = (int *) &(cp->const.cd[0]);
                    327:       ip[0] = jp[0];
                    328:       ip[1] = jp[2];
                    329:       return (quad);
                    330: 
                    331:     case TYDCOMPLEX:
                    332:       ip = (int *) oct;
                    333:       jp = (int *) &(cp->const.cd[0]);
                    334:       *ip++ = *jp++;
                    335:       *ip++ = *jp++;
                    336:       *ip++ = *jp++;
                    337:       *ip = *jp;
                    338:       return (oct);
                    339: 
                    340:     default:
                    341:       badtype("packbytes", cp->vtype);
                    342:     }
                    343: }
                    344: 
                    345: 
                    346: 
                    347: 
                    348: prsdata(s, len)
                    349: register char *s;
                    350: register int len;
                    351: {
                    352:   static char *longfmt = "\t.long\t0x%x\n";
                    353:   static char *wordfmt = "\t.word\t0x%x\n";
                    354:   static char *bytefmt = "\t.byte\t0x%x\n";
                    355: 
                    356:   register int i;
                    357: 
                    358:   i = 0;
                    359:   if ((len - i) >= 4)
                    360:     {
                    361:       fprintf(initfile, longfmt, *((int *) s));
                    362:       i += 4;
                    363:     }
                    364:   if ((len - i) >= 2)
                    365:     {
                    366:       fprintf(initfile, wordfmt, 0xffff & (*((short *) (s + i))));
                    367:       i += 2;
                    368:     }
                    369:   if ((len - i) > 0)
                    370:     fprintf(initfile,bytefmt, 0xff & s[i]);
                    371: 
                    372:   return;
                    373: }
                    374: 
                    375: 
                    376: 
                    377: prquad(s)
                    378: char *s;
                    379: {
                    380:   static char *quadfmt1 = "\t.quad\t0x%x\n";
                    381:   static char *quadfmt2 = "\t.quad\t0x%x%08x\n";
                    382: 
                    383:   if ( *((int *) (s + 4)) == 0 )
                    384:     fprintf(initfile, quadfmt1, *((int *) s));
                    385:   else
                    386:     fprintf(initfile, quadfmt2, *((int *) (s + 4)), *((int *) s));
                    387: 
                    388:   return;
                    389: }
                    390: 
                    391: 
                    392: 
                    393: #ifdef NOTDEF
                    394: 
                    395: /*  The code for generating .fill directives has been      */
                    396: /*  ifdefed out because of bugs in the UCB VAX assembler.  */
                    397: /*  If those bugs are ever fixed (and it seems unlikely),  */
                    398: /*  the NOTDEF's should be replaced by UCBVAXASM.          */
                    399: 
                    400: 
                    401: prfill(n, s)
                    402: int n;
                    403: register char *s;
                    404: {
                    405:   static char *fillfmt1 = "\t.fill\t%d,8,0x%x\n";
                    406:   static char *fillfmt2 = "\t.fill\t%d,8,0x%x%08x\n";
                    407: 
                    408:   if (*((int *) (s + 4)) == 0)
                    409:     fprintf(initfile, fillfmt1, n, *((int *) s));
                    410:   else
                    411:     fprintf(initfile, fillfmt2, n, *((int *) (s + 4)), *((int *) s));
                    412: 
                    413:   return;
                    414: }
                    415: 
                    416: #endif
                    417: 
                    418: 
                    419: 
                    420: prext(ep)
                    421: register struct Extsym *ep;
                    422: {
                    423:   static char *globlfmt = "\t.globl\t_%s\n";
                    424:   static char *commfmt = "\t.comm\t_%s,%ld\n";
                    425:   static char *spacefmt = "\t.space\t%d\n";
                    426:   static char *align2fmt = "\t.align\t2\n";
                    427:   static char *labelfmt = "_%s:\n";
                    428: 
                    429:   static char *seekerror = "seek error on tmp file";
                    430:   static char *readerror = "read error on tmp file";
                    431: 
                    432:   char *tag;
                    433:   register int leng;
                    434:   long pos;
                    435:   register int i;
                    436:   char oldvalue[8];
                    437:   char newvalue[8];
                    438:   register int n;
                    439:   register int repl;
                    440: 
                    441:   tag = varstr(XL, ep->extname);
                    442:   leng = ep->maxleng;
                    443: 
                    444:   if (leng == 0)
                    445:     {
                    446:       fprintf(asmfile, globlfmt, tag);
                    447:       return;
                    448:     }
                    449: 
                    450:   if (ep->init == NO)
                    451:     {
                    452:       fprintf(asmfile, commfmt, tag, leng);
                    453:       return;
                    454:     }
                    455: 
                    456:   fprintf(asmfile, globlfmt, tag);
                    457:   fprintf(initfile, align2fmt);
                    458:   fprintf(initfile, labelfmt, tag);
                    459: 
                    460:   pos = lseek(cdatafile, ep->initoffset, 0);
                    461:   if (pos == -1)
                    462:     {
                    463:       err(seekerror);
                    464:       done(1);
                    465:     }
                    466: 
                    467:   *((int *) oldvalue) = 0;
                    468:   *((int *) (oldvalue + 4)) = 0;
                    469:   n = read(cdatafile, oldvalue, 8);
                    470:   if (n < 0)
                    471:     {
                    472:       err(readerror);
                    473:       done(1);
                    474:     }
                    475: 
                    476:   if (leng <= 8)
                    477:     {
                    478:       i = leng;
                    479:       while (i > 0 && oldvalue[--i] == '\0') /* SKIP */;
                    480:       if (oldvalue[i] == '\0')
                    481:        fprintf(initfile, spacefmt, leng);
                    482:       else if (leng == 8)
                    483:        prquad(oldvalue);
                    484:       else
                    485:        prsdata(oldvalue, leng);
                    486: 
                    487:       return;
                    488:     }
                    489: 
                    490:   repl = 1;
                    491:   leng -= 8;
                    492: 
                    493:   while (leng >= 8)
                    494:     {
                    495:       *((int *) newvalue) = 0;
                    496:       *((int *) (newvalue + 4)) = 0;
                    497: 
                    498:       n = read(cdatafile, newvalue, 8);
                    499:       if (n < 0)
                    500:        {
                    501:          err(readerror);
                    502:          done(1);
                    503:        }
                    504: 
                    505:       leng -= 8;
                    506: 
                    507:       if (*((int *) oldvalue) == *((int *) newvalue)
                    508:          && *((int *) (oldvalue + 4)) == *((int *) (newvalue + 4)))
                    509:        repl++;
                    510:       else
                    511:        {
                    512:          if (*((int *) oldvalue) == 0
                    513:              && *((int *) (oldvalue + 4)) == 0)
                    514:            fprintf(initfile, spacefmt, 8*repl);
                    515:          else if (repl == 1)
                    516:            prquad(oldvalue);
                    517:          else
                    518: #ifdef NOTDEF
                    519:            prfill(repl, oldvalue);
                    520: #else
                    521:            {
                    522:              while (repl-- > 0)
                    523:                prquad(oldvalue);
                    524:            }
                    525: #endif
                    526:          *((int *) oldvalue) = *((int *) newvalue);
                    527:          *((int *) (oldvalue + 4)) = *((int *) (newvalue + 4));
                    528:          repl = 1;
                    529:        }
                    530:     }
                    531: 
                    532:   *((int *) newvalue) = 0;
                    533:   *((int *) (newvalue + 4)) = 0;
                    534: 
                    535:   if (leng > 0)
                    536:     {
                    537:       n = read(cdatafile, newvalue, leng);
                    538:       if (n < 0)
                    539:        {
                    540:          err(readerror);
                    541:          done(1);
                    542:        }
                    543:     }
                    544: 
                    545:   if (*((int *) (oldvalue + 4)) == 0
                    546:       && *((int *) oldvalue) == 0
                    547:       && *((int *) (newvalue + 4)) == 0
                    548:       && *((int *) newvalue) == 0)
                    549:     {
                    550:       fprintf(initfile, spacefmt, 8*repl + leng);
                    551:       return;
                    552:     }
                    553: 
                    554:   if (*((int *) (oldvalue + 4)) == 0
                    555:       && *((int *) oldvalue) == 0)
                    556:     fprintf(initfile, spacefmt, 8*repl);
                    557:   else if (repl == 1)
                    558:     prquad(oldvalue);
                    559:   else
                    560: #ifdef NOTDEF
                    561:     prfill(repl, oldvalue);
                    562: #else
                    563:     {
                    564:       while (repl-- > 0)
                    565:        prquad(oldvalue);
                    566:     }
                    567: #endif
                    568: 
                    569:   prsdata(newvalue, leng);
                    570: 
                    571:   return;
                    572: }
                    573: 
                    574: 
                    575: 
                    576: prlocdata(sname, leng, type, initoffset, inlcomm)
                    577: char *sname;
                    578: ftnint leng;
                    579: int type;
                    580: long initoffset;
                    581: char *inlcomm;
                    582: {
                    583:   static char *seekerror = "seek error on tmp file";
                    584:   static char *readerror = "read error on tmp file";
                    585: 
                    586:   static char *labelfmt = "%s:\n";
                    587:   static char *spacefmt = "\t.space\t%d\n";
                    588: 
                    589:   register int k;
                    590:   register int i;
                    591:   register int repl;
                    592:   register int first;
                    593:   register long pos;
                    594:   register long n;
                    595:   char oldvalue[8];
                    596:   char newvalue[8];
                    597: 
                    598:   *inlcomm = NO;
                    599: 
                    600:   k = leng;
                    601:   first = YES;
                    602: 
                    603:   pos = lseek(vdatafile, initoffset, 0);
                    604:   if (pos == -1)
                    605:     {
                    606:       err(seekerror);
                    607:       done(1);
                    608:     }
                    609: 
                    610:   *((int *) oldvalue) = 0;
                    611:   *((int *) (oldvalue + 4)) = 0;
                    612:   n = read(vdatafile, oldvalue, 8);
                    613:   if (n < 0)
                    614:     {
                    615:       err(readerror);
                    616:       done(1);
                    617:     }
                    618: 
                    619:   if (k <= 8)
                    620:     {
                    621:       i = k;
                    622:       while (i > 0 && oldvalue[--i] == '\0')
                    623:        /*  SKIP  */ ;
                    624:       if (oldvalue[i] == '\0')
                    625:        {
                    626:          if (SMALLVAR(leng))
                    627:            {
                    628:              pralign(typealign[type]);
                    629:              fprintf(initfile, labelfmt, sname);
                    630:              fprintf(initfile, spacefmt, leng);
                    631:            }
                    632:          else
                    633:            {
                    634:              preven(ALIDOUBLE);
                    635:              prlocvar(sname, leng);
                    636:              *inlcomm = YES;
                    637:            }
                    638:        }
                    639:       else
                    640:        {
                    641:          fprintf(initfile, labelfmt, sname);
                    642:          if (leng == 8)
                    643:            prquad(oldvalue);
                    644:          else
                    645:            prsdata(oldvalue, leng);
                    646:        }
                    647:       return;
                    648:     }
                    649: 
                    650:   repl = 1;
                    651:   k -= 8;
                    652: 
                    653:   while (k >=8)
                    654:     {
                    655:       *((int *) newvalue) = 0;
                    656:       *((int *) (newvalue + 4)) = 0;
                    657: 
                    658:       n = read(vdatafile, newvalue, 8);
                    659:       if (n < 0)
                    660:        {
                    661:          err(readerror);
                    662:          done(1);
                    663:        }
                    664: 
                    665:       k -= 8;
                    666: 
                    667:       if (*((int *) oldvalue) == *((int *) newvalue)
                    668:          && *((int *) (oldvalue + 4)) == *((int *) (newvalue + 4)))
                    669:        repl++;
                    670:       else
                    671:        {
                    672:          if (first == YES)
                    673:            {
                    674:              pralign(typealign[type]);
                    675:              fprintf(initfile, labelfmt, sname);
                    676:              first = NO;
                    677:            }
                    678: 
                    679:          if (*((int *) oldvalue) == 0
                    680:              && *((int *) (oldvalue + 4)) == 0)
                    681:            fprintf(initfile, spacefmt, 8*repl);
                    682:          else
                    683:            {
                    684:              while (repl-- > 0)
                    685:                prquad(oldvalue);
                    686:            }
                    687:          *((int *) oldvalue) = *((int *) newvalue);
                    688:          *((int *) (oldvalue + 4)) = *((int *) (newvalue + 4));
                    689:          repl = 1;
                    690:        }
                    691:     }
                    692: 
                    693:   *((int *) newvalue) = 0;
                    694:   *((int *) (newvalue + 4)) = 0;
                    695: 
                    696:   if (k > 0)
                    697:     {
                    698:       n = read(vdatafile, newvalue, k);
                    699:       if (n < 0)
                    700:        {
                    701:          err(readerror);
                    702:          done(1);
                    703:        }
                    704:     }
                    705: 
                    706:   if (*((int *) (oldvalue + 4)) == 0
                    707:       && *((int *) oldvalue) == 0
                    708:       && *((int *) (newvalue + 4)) == 0
                    709:       && *((int *) newvalue) == 0)
                    710:     {
                    711:       if (first == YES && !SMALLVAR(leng))
                    712:        {
                    713:          prlocvar(sname, leng);
                    714:          *inlcomm = YES;
                    715:        }
                    716:       else
                    717:        {
                    718:          if (first == YES)
                    719:            {
                    720:              pralign(typealign[type]);
                    721:              fprintf(initfile, labelfmt, sname);
                    722:            }
                    723:          fprintf(initfile, spacefmt, 8*repl + k);
                    724:        }
                    725:       return;
                    726:     }
                    727: 
                    728:   if (first == YES)    
                    729:     {
                    730:       pralign(typealign[type]);
                    731:       fprintf(initfile, labelfmt, sname);
                    732:     }
                    733: 
                    734:   if (*((int *) (oldvalue + 4)) == 0
                    735:       && *((int *) oldvalue) == 0)
                    736:     fprintf(initfile, spacefmt, 8*repl);
                    737:   else
                    738:     {
                    739:       while (repl-- > 0)
                    740:        prquad(oldvalue);
                    741:     }
                    742: 
                    743:   prsdata(newvalue, k);
                    744: 
                    745:   return;
                    746: }
                    747:            
                    748: 
                    749: 
                    750: 
                    751: prendproc()
                    752: {
                    753: }
                    754: 
                    755: 
                    756: 
                    757: 
                    758: prtail()
                    759: {
                    760: }
                    761: 
                    762: 
                    763: 
                    764: 
                    765: 
                    766: prolog(ep, argvec)
                    767: struct Entrypoint *ep;
                    768: Addrp  argvec;
                    769: {
                    770: int i, argslot, proflab;
                    771: int size;
                    772: register chainp p;
                    773: register Namep q;
                    774: register struct Dimblock *dp;
                    775: expptr tp;
                    776: 
                    777: p2pass("\t.align\t1");
                    778: 
                    779: 
                    780: if(procclass == CLMAIN) {
                    781:        if(fudgelabel)
                    782:                {
                    783:                if(ep->entryname) {
                    784:                        p2ps("_%s:",  varstr(XL, ep->entryname->extname));
                    785:                        p2pi("\t.word\tLWM%d", procno);
                    786:                }
                    787:                putlabel(fudgelabel);
                    788:                fudgelabel = 0;
                    789:                fixlwm();
                    790:                }
                    791:        else
                    792:                {
                    793:                p2pass( "_MAIN_:" );
                    794:                if(ep->entryname == NULL)
                    795:                        p2pi("\t.word\tLWM%d", procno);
                    796:                }
                    797: 
                    798: } else if(ep->entryname)
                    799:        if(fudgelabel)
                    800:                {
                    801:                putlabel(fudgelabel);
                    802:                fudgelabel = 0;
                    803:                fixlwm();
                    804:                }
                    805:        else
                    806:                {
                    807:                p2ps("_%s:",  varstr(XL, ep->entryname->extname));
                    808:                p2pi("\t.word\tLWM%d", procno);
                    809:                prsave(newlabel());
                    810:                }
                    811: 
                    812: if(procclass == CLBLOCK)
                    813:        return;
                    814: if (anylocals == YES)
                    815:        {
                    816:        char buff[30];
                    817:        sprintf(buff, "\tmovl\t$v.%d,r11", bsslabel);
                    818:        p2pass(buff);
                    819:        }
                    820: if(argvec)
                    821:        {
                    822:        if (argvec->tag != TADDR) badtag ("prolog",argvec->tag);
                    823:        argloc = argvec->memoffset->constblock.const.ci + SZINT;
                    824:                        /* first slot holds count */
                    825:        if(proctype == TYCHAR)
                    826:                {
                    827:                mvarg(TYADDR, 0, chslot);
                    828:                mvarg(TYLENG, SZADDR, chlgslot);
                    829:                argslot = SZADDR + SZLENG;
                    830:                }
                    831:        else if( ISCOMPLEX(proctype) )
                    832:                {
                    833:                mvarg(TYADDR, 0, cxslot);
                    834:                argslot = SZADDR;
                    835:                }
                    836:        else
                    837:                argslot = 0;
                    838: 
                    839:        for(p = ep->arglist ; p ; p =p->nextp)
                    840:                {
                    841:                q = (Namep) (p->datap);
                    842:                mvarg(TYADDR, argslot, q->vardesc.varno);
                    843:                argslot += SZADDR;
                    844:                }
                    845:        for(p = ep->arglist ; p ; p = p->nextp)
                    846:                {
                    847:                q = (Namep) (p->datap);
                    848:                if(q->vtype==TYCHAR && q->vclass!=CLPROC)
                    849:                        {
                    850:                        if(q->vleng && ! ISCONST(q->vleng) )
                    851:                                mvarg(TYLENG, argslot,
                    852:                                        q->vleng->addrblock.memno);
                    853:                        argslot += SZLENG;
                    854:                        }
                    855:                }
                    856:        p2pi("\taddl3\t$%d,fp,ap", argloc-ARGOFFSET);
                    857:        p2pi("\tmovl\t$%d,(ap)\n", lastargslot/SZADDR);
                    858:        }
                    859: 
                    860: for(p = ep->arglist ; p ; p = p->nextp)
                    861:        {
                    862:        q = (Namep) (p->datap);
                    863:        if(dp = q->vdim)
                    864:                {
                    865:                for(i = 0 ; i < dp->ndim ; ++i)
                    866:                        if(dp->dims[i].dimexpr)
                    867:                                puteq( fixtype(cpexpr(dp->dims[i].dimsize)),
                    868:                                        fixtype(cpexpr(dp->dims[i].dimexpr)));
                    869: #ifdef SDB
                    870:                 if(sdbflag) {
                    871:                for(i = 0 ; i < dp->ndim ; ++i) {
                    872:                        if(dp->dims[i].lbaddr)
                    873:                                puteq( fixtype(cpexpr(dp->dims[i].lbaddr)),
                    874:                                        fixtype(cpexpr(dp->dims[i].lb)));
                    875:                        if(dp->dims[i].ubaddr)
                    876:                                puteq( fixtype(cpexpr(dp->dims[i].ubaddr)),
                    877:                                        fixtype(cpexpr(dp->dims[i].ub)));
                    878:                    
                    879:                                                 }
                    880:                             }
                    881: #endif
                    882:                size = typesize[ q->vtype ];
                    883:                if(q->vtype == TYCHAR)
                    884:                        if( ISICON(q->vleng) )
                    885:                                size *= q->vleng->constblock.const.ci;
                    886:                        else
                    887:                                size = -1;
                    888: 
                    889:                /* on VAX, get more efficient subscripting if subscripts
                    890:                   have zero-base, so fudge the argument pointers for arrays.
                    891:                   Not done if array bounds are being checked.
                    892:                */
                    893:                if(dp->basexpr)
                    894:                        puteq(  cpexpr(fixtype(dp->baseoffset)),
                    895:                                cpexpr(fixtype(dp->basexpr)));
                    896: #ifdef SDB
                    897:                if( (! checksubs) && (! sdbflag) )
                    898: #else
                    899:                if(! checksubs)
                    900: #endif
                    901:                        {
                    902:                        if(dp->basexpr)
                    903:                                {
                    904:                                if(size > 0)
                    905:                                        tp = (expptr) ICON(size);
                    906:                                else
                    907:                                        tp = (expptr) cpexpr(q->vleng);
                    908:                                putforce(TYINT,
                    909:                                        fixtype( mkexpr(OPSTAR, tp,
                    910:                                                cpexpr(dp->baseoffset)) ));
                    911:                                p2pi("\tsubl2\tr0,%d(ap)",
                    912:                                        p->datap->nameblock.vardesc.varno +
                    913:                                                ARGOFFSET);
                    914:                                }
                    915:                        else if(dp->baseoffset->constblock.const.ci != 0)
                    916:                                {
                    917:                                char buff[25];
                    918:                                if(size > 0)
                    919:                                        {
                    920:                                        sprintf(buff, "\tsubl2\t$%ld,%d(ap)",
                    921:                                                dp->baseoffset->constblock.const.ci * size,
                    922:                                                p->datap->nameblock.vardesc.varno +
                    923:                                                        ARGOFFSET);
                    924:                                        }
                    925:                                else    {
                    926:                                        putforce(TYINT, mkexpr(OPSTAR, cpexpr(dp->baseoffset),
                    927:                                                cpexpr(q->vleng) ));
                    928:                                        sprintf(buff, "\tsubl2\tr0,%d(ap)",
                    929:                                                p->datap->nameblock.vardesc.varno +
                    930:                                                        ARGOFFSET);
                    931:                                        }
                    932:                                p2pass(buff);
                    933:                                }
                    934:                        }
                    935:                }
                    936:        }
                    937: 
                    938: if(typeaddr)
                    939:        puteq( cpexpr(typeaddr), mkaddcon(ep->typelabel) );
                    940: /* replace to avoid long jump problem
                    941: putgoto(ep->entrylabel);
                    942: */
                    943: p2pi("\tjmp\tL%d", ep->entrylabel);
                    944: }
                    945: 
                    946: fixlwm()
                    947: {
                    948:        extern lwmno;
                    949:        if (lwmno == procno)
                    950:                return;
                    951:        fprintf(asmfile, "\t.set\tLWM%d,0x%x\n",
                    952:                procno, regmask[highregvar]);
                    953:        lwmno = procno;
                    954: }
                    955: 
                    956: 
                    957: prhead(fp)
                    958: FILEP fp;
                    959: {
                    960: #if FAMILY==PCC
                    961:        p2triple(P2LBRACKET, ARGREG-highregvar, procno);
                    962:        p2word( (long) (BITSPERCHAR*autoleng) );
                    963:        p2flush();
                    964: #endif
                    965: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.