BSD 4_3_Net_2 release
[unix-history] / usr / src / usr.bin / pascal / src / p2put.c
index b6d324d..b793a05 100644 (file)
@@ -1,6 +1,39 @@
-/* Copyright (c) 1979 Regents of the University of California */
-
-static char sccsid[] = "@(#)p2put.c 1.12 %G%";
+/*-
+ * Copyright (c) 1980 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 THE REGENTS OR CONTRIBUTORS 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)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)p2put.c    5.5 (Berkeley) 4/16/91";
+#endif /* not lint */
 
     /*
      * functions to help pi put out
 
     /*
      * functions to help pi put out
@@ -12,17 +45,10 @@ static      char sccsid[] = "@(#)p2put.c 1.12 %G%";
 #ifdef PC
 #include       "0.h"
 #include       "objfmt.h"
 #ifdef PC
 #include       "0.h"
 #include       "objfmt.h"
-#include       "pcops.h"
+#include       <pcc.h>
 #include       "pc.h"
 #include       "align.h"
 #include       "pc.h"
 #include       "align.h"
-
-    /*
-     * mash into f77's format
-     * lovely, isn't it?
-     */
-#define                TOF77( fop,val,rest )   ( ( ( (rest) & 0177777 ) << 16 ) \
-                                       | ( ( (val) & 0377 ) << 8 )      \
-                                       | ( (fop) & 0377 ) )
+#include       "tmps.h"
 \f
     /*
      * emits an ftext operator and a string to the pcstream
 \f
     /*
      * emits an ftext operator and a string to the pcstream
@@ -34,10 +60,10 @@ puttext( string )
 
        if ( !CGENNING )
            return;
 
        if ( !CGENNING )
            return;
-       p2word( TOF77( P2FTEXT , length , 0 ) );
+       p2word( PCCM_TRIPLE( PCCF_FTEXT , length , 0 ) );
 #      ifdef DEBUG
            if ( opt( 'k' ) ) {
 #      ifdef DEBUG
            if ( opt( 'k' ) ) {
-               fprintf( stdout , "P2FTEXT | %3d | 0    " , length );
+               fprintf( stdout , "PCCF_FTEXT | %3d | 0 " , length );
            }
 #      endif
        p2string( string );
            }
 #      endif
        p2string( string );
@@ -57,7 +83,7 @@ str4len( string )
      * none of arg1 .. arg5 need be present.
      * and you can add more if you need them.
      */
      * none of arg1 .. arg5 need be present.
      * and you can add more if you need them.
      */
-    /* VARARGS */
+/* VARARGS */
 putprintf( format , incomplete , arg1 , arg2 , arg3 , arg4 , arg5 )
     char       *format;
     int                incomplete;
 putprintf( format , incomplete , arg1 , arg2 , arg3 , arg4 , arg5 )
     char       *format;
     int                incomplete;
@@ -80,40 +106,49 @@ putprintf( format , incomplete , arg1 , arg2 , arg3 , arg4 , arg5 )
     /*
      * emit a left bracket operator to pcstream
      * with function number, the maximum temp register, and total local bytes
     /*
      * emit a left bracket operator to pcstream
      * with function number, the maximum temp register, and total local bytes
-     * until i figure out how to use them, regs 0 .. 11 are free.
-     * one idea for one reg is to save the display pointer on block entry
      */
      */
-putlbracket( ftnno , localbytes )
-    int        ftnno;
-    int        localbytes;
-    {
-#      define  MAXTP2REG       11
-
-       p2word( TOF77( P2FLBRAC , MAXTP2REG , ftnno ) );
-       p2word( roundup(BITSPERBYTE * localbytes, BITSPERBYTE * A_STACK));
-#      ifdef DEBUG
-           if ( opt( 'k' ) ) {
-               fprintf( stdout
-                       , "P2FLBRAC | %3d | %d  " , MAXTP2REG , ftnno );
-               fprintf( stdout , "%d\n"
-                       , BITSPERBYTE * localbytes );
-           }
-#      endif
-    }
+putlbracket(ftnno, sizesp)
+    int                ftnno;
+    struct om  *sizesp;
+{
+    int        maxtempreg;     
+    int        alignedframesize;
+
+#   if defined(vax) || defined(tahoe)
+       maxtempreg = sizesp->curtmps.next_avail[REG_GENERAL];
+#   endif vax || tahoe
+#   ifdef mc68000
+           /*
+            *  this is how /lib/f1 wants it.
+            */
+       maxtempreg =    (sizesp->curtmps.next_avail[REG_ADDR] << 4)
+                     | (sizesp->curtmps.next_avail[REG_DATA]);
+#   endif mc68000
+    alignedframesize = roundup((int)(BITSPERBYTE * -sizesp->curtmps.om_off),
+       (long)(BITSPERBYTE * A_STACK));
+    p2word( PCCM_TRIPLE( PCCF_FLBRAC , maxtempreg , ftnno ) );
+    p2word(alignedframesize);
+#   ifdef DEBUG
+       if ( opt( 'k' ) ) {
+           fprintf(stdout, "PCCF_FLBRAC | %3d | %d     %d\n",
+               maxtempreg, ftnno, alignedframesize);
+       }
+#   endif
+}
 
     /*
      * emit a right bracket operator
 
     /*
      * emit a right bracket operator
-     * which for the binary (fortran) interface
+     * which for the binary interface
      * forces the stack allocate and register mask
      */
 putrbracket( ftnno )
     int        ftnno;
     {
 
      * forces the stack allocate and register mask
      */
 putrbracket( ftnno )
     int        ftnno;
     {
 
-       p2word( TOF77( P2FRBRAC , 0 , ftnno ) );
+       p2word( PCCM_TRIPLE( PCCF_FRBRAC , 0 , ftnno ) );
 #      ifdef DEBUG
            if ( opt( 'k' ) ) {
 #      ifdef DEBUG
            if ( opt( 'k' ) ) {
-               fprintf( stdout , "P2FRBRAC |   0 | %d\n" , ftnno );
+               fprintf( stdout , "PCCF_FRBRAC |   0 | %d\n" , ftnno );
            }
 #      endif
     }
            }
 #      endif
     }
@@ -124,10 +159,10 @@ putrbracket( ftnno )
 puteof()
     {
        
 puteof()
     {
        
-       p2word( P2FEOF );
+       p2word( PCCF_FEOF );
 #      ifdef DEBUG
            if ( opt( 'k' ) ) {
 #      ifdef DEBUG
            if ( opt( 'k' ) ) {
-               fprintf( stdout , "P2FEOF\n" );
+               fprintf( stdout , "PCCF_FEOF\n" );
            }
 #      endif
     }
            }
 #      endif
     }
@@ -146,10 +181,10 @@ putdot( filename , line )
        if ( line < 0 ) {
            line = -line;
        }
        if ( line < 0 ) {
            line = -line;
        }
-       p2word( TOF77( P2FEXPR , length , line ) );
+       p2word( PCCM_TRIPLE( PCCF_FEXPR , length , line ) );
 #      ifdef DEBUG
            if ( opt( 'k' ) ) {
 #      ifdef DEBUG
            if ( opt( 'k' ) ) {
-               fprintf( stdout , "P2FEXPR | %3d | %d   " , length , line );
+               fprintf( stdout , "PCCF_FEXPR | %3d | %d        " , length , line );
            }
 #      endif
        p2string( filename );
            }
 #      endif
        p2string( filename );
@@ -170,12 +205,12 @@ putleaf( op , lval , rval , type , name )
        switch ( op ) {
            default:
                panic( "[putleaf]" );
        switch ( op ) {
            default:
                panic( "[putleaf]" );
-           case P2ICON:
-               p2word( TOF77( P2ICON , name != NIL , type ) );
+           case PCC_ICON:
+               p2word( PCCM_TRIPLE( PCC_ICON , name != NIL , type ) );
                p2word( lval );
 #              ifdef DEBUG
                    if ( opt( 'k' ) ) {
                p2word( lval );
 #              ifdef DEBUG
                    if ( opt( 'k' ) ) {
-                       fprintf( stdout , "P2ICON | %3d | 0x%x  " 
+                       fprintf( stdout , "PCC_ICON | %3d | 0x%x        " 
                               , name != NIL , type );
                        fprintf( stdout , "%d\n" , lval );
                    }
                               , name != NIL , type );
                        fprintf( stdout , "%d\n" , lval );
                    }
@@ -183,13 +218,13 @@ putleaf( op , lval , rval , type , name )
                if ( name )
                    p2name( name );
                break;
                if ( name )
                    p2name( name );
                break;
-           case P2NAME:
-               p2word( TOF77( P2NAME , lval != 0 , type ) );
+           case PCC_NAME:
+               p2word( PCCM_TRIPLE( PCC_NAME , lval != 0 , type ) );
                if ( lval ) 
                    p2word( lval );
 #              ifdef DEBUG
                    if ( opt( 'k' ) ) {
                if ( lval ) 
                    p2word( lval );
 #              ifdef DEBUG
                    if ( opt( 'k' ) ) {
-                       fprintf( stdout , "P2NAME | %3d | 0x%x  " 
+                       fprintf( stdout , "PCC_NAME | %3d | 0x%x        " 
                               , lval != 0 , type );
                        if ( lval )
                            fprintf( stdout , "%d       " , lval );
                               , lval != 0 , type );
                        if ( lval )
                            fprintf( stdout , "%d       " , lval );
@@ -197,11 +232,11 @@ putleaf( op , lval , rval , type , name )
 #              endif
                p2name( name );
                break;
 #              endif
                p2name( name );
                break;
-           case P2REG:
-               p2word( TOF77( P2REG , rval , type ) );
+           case PCC_REG:
+               p2word( PCCM_TRIPLE( PCC_REG , rval , type ) );
 #              ifdef DEBUG
                    if ( opt( 'k' ) ) {
 #              ifdef DEBUG
                    if ( opt( 'k' ) ) {
-                       fprintf( stdout , "P2REG | %3d | 0x%x\n" ,
+                       fprintf( stdout , "PCC_REG | %3d | 0x%x\n" ,
                                rval , type );
                    }
 #              endif
                                rval , type );
                    }
 #              endif
@@ -223,7 +258,6 @@ putRV( name , level , offset , other_flags , type )
     {
        char    extname[ BUFSIZ ];
        char    *printname;
     {
        char    extname[ BUFSIZ ];
        char    *printname;
-       int     regnumber;
 
        if ( !CGENNING )
            return;
 
        if ( !CGENNING )
            return;
@@ -231,10 +265,10 @@ putRV( name , level , offset , other_flags , type )
            if ( ( offset < 0 ) || ( offset > P2FP ) ) {
                panic( "putRV regvar" );
            }
            if ( ( offset < 0 ) || ( offset > P2FP ) ) {
                panic( "putRV regvar" );
            }
-           putleaf( P2REG , 0 , offset , type , 0 );
+           putleaf( PCC_REG , 0 , offset , type , (char *) 0 );
            return;
        }
            return;
        }
-       if ( whereis( level , offset , other_flags ) == GLOBALVAR ) {
+       if ( whereis( offset , other_flags ) == GLOBALVAR ) {
            if ( name != 0 ) {
                if ( name[0] != '_' ) {
                        sprintf( extname , EXTFORMAT , name );
            if ( name != 0 ) {
                if ( name[0] != '_' ) {
                        sprintf( extname , EXTFORMAT , name );
@@ -242,14 +276,14 @@ putRV( name , level , offset , other_flags , type )
                } else {
                        printname = name;
                }
                } else {
                        printname = name;
                }
-               putleaf( P2NAME , offset , 0 , type , printname );
+               putleaf( PCC_NAME , offset , 0 , type , printname );
                return;
            } else {
                panic( "putRV no name" );
            }
        }
        putLV( name , level , offset , other_flags , type );
                return;
            } else {
                panic( "putRV no name" );
            }
        }
        putLV( name , level , offset , other_flags , type );
-       putop( P2UNARY P2MUL , type );
+       putop( PCCOM_UNARY PCC_MUL , type );
     }
 
     /*
     }
 
     /*
@@ -273,7 +307,7 @@ putLV( name , level , offset , other_flags , type )
     if ( other_flags & NREGVAR ) {
        panic( "putLV regvar" );
     }
     if ( other_flags & NREGVAR ) {
        panic( "putLV regvar" );
     }
-    switch ( whereis( level , offset , other_flags ) ) {
+    switch ( whereis( offset , other_flags ) ) {
        case GLOBALVAR:
            if ( ( name != 0 ) ) {
                if ( name[0] != '_' ) {
        case GLOBALVAR:
            if ( ( name != 0 ) ) {
                if ( name[0] != '_' ) {
@@ -282,7 +316,7 @@ putLV( name , level , offset , other_flags , type )
                } else {
                        printname = name;
                }
                } else {
                        printname = name;
                }
-               putleaf( P2ICON , offset , 0 , ADDTYPE( type , P2PTR )
+               putleaf( PCC_ICON , offset , 0 , PCCM_ADDTYPE( type , PCCTM_PTR )
                        , printname );
                return;
            } else {
                        , printname );
                return;
            } else {
@@ -290,36 +324,36 @@ putLV( name , level , offset , other_flags , type )
            }
        case PARAMVAR:
            if ( level == cbn ) {
            }
        case PARAMVAR:
            if ( level == cbn ) {
-               putleaf( P2REG , 0 , P2AP , ADDTYPE( type , P2PTR ) , 0 );
+               putleaf( PCC_REG, 0, P2AP, PCCM_ADDTYPE( type , PCCTM_PTR ), (char *) 0 );
            } else {
            } else {
-               putleaf( P2NAME , (level * sizeof(struct dispsave)) + AP_OFFSET
-                   , 0 , P2PTR | P2CHAR , DISPLAYNAME );
+               putleaf( PCC_NAME , (level * sizeof(struct dispsave)) + AP_OFFSET
+                   , 0 , PCCTM_PTR | PCCT_CHAR , DISPLAYNAME );
                parts[ level ] |= NONLOCALVAR;
            }
                parts[ level ] |= NONLOCALVAR;
            }
-           putleaf( P2ICON , offset , 0 , P2INT , 0 );
-           putop( P2PLUS , P2PTR | P2CHAR );
+           putleaf( PCC_ICON , offset , 0 , PCCT_INT , (char *) 0 );
+           putop( PCC_PLUS , PCCTM_PTR | PCCT_CHAR );
            break;
        case LOCALVAR:
            if ( level == cbn ) {
            break;
        case LOCALVAR:
            if ( level == cbn ) {
-               putleaf( P2REG , 0 , P2FP , ADDTYPE( type , P2PTR ) , 0 );
+               putleaf( PCC_REG, 0, P2FP, PCCM_ADDTYPE( type , PCCTM_PTR ), (char *) 0 );
            } else {
            } else {
-               putleaf( P2NAME , (level * sizeof(struct dispsave)) + FP_OFFSET
-                   , 0 , P2PTR | P2CHAR , DISPLAYNAME );
+               putleaf( PCC_NAME , (level * sizeof(struct dispsave)) + FP_OFFSET
+                   , 0 , PCCTM_PTR | PCCT_CHAR , DISPLAYNAME );
                parts[ level ] |= NONLOCALVAR;
            }
                parts[ level ] |= NONLOCALVAR;
            }
-           putleaf( P2ICON , -offset , 0 , P2INT , 0 );
-           putop( P2MINUS , P2PTR | P2CHAR );
+           putleaf( PCC_ICON , -offset , 0 , PCCT_INT , (char *) 0 );
+           putop( PCC_MINUS , PCCTM_PTR | PCCT_CHAR );
            break;
        case NAMEDLOCALVAR:
            if ( level == cbn ) {
            break;
        case NAMEDLOCALVAR:
            if ( level == cbn ) {
-               putleaf( P2REG , 0 , P2FP , ADDTYPE( type , P2PTR ) , 0 );
+               putleaf( PCC_REG, 0, P2FP, PCCM_ADDTYPE( type , PCCTM_PTR ), (char *) 0 );
            } else {
            } else {
-               putleaf( P2NAME , (level * sizeof(struct dispsave)) + FP_OFFSET
-                   , 0 , P2PTR | P2CHAR , DISPLAYNAME );
+               putleaf( PCC_NAME , (level * sizeof(struct dispsave)) + FP_OFFSET
+                   , 0 , PCCTM_PTR | PCCT_CHAR , DISPLAYNAME );
                parts[ level ] |= NONLOCALVAR;
            }
                parts[ level ] |= NONLOCALVAR;
            }
-           putleaf( P2ICON , 0 , 0 , P2INT , name );
-           putop( P2MINUS , P2PTR | P2CHAR );
+           putleaf( PCC_ICON , 0 , 0 , PCCT_INT , name );
+           putop( PCC_MINUS , PCCTM_PTR | PCCT_CHAR );
            break;
     }
     return;
            break;
     }
     return;
@@ -328,12 +362,12 @@ putLV( name , level , offset , other_flags , type )
     /*
      * put out a floating point constant leaf node
      * the constant is declared in aligned data space
     /*
      * put out a floating point constant leaf node
      * the constant is declared in aligned data space
-     * and a P2NAME leaf put out for it
+     * and a PCC_NAME leaf put out for it
      */
 putCON8( val )
     double     val;
     {
      */
 putCON8( val )
     double     val;
     {
-       int     label;
+       char    *label;
        char    name[ BUFSIZ ];
 
        if ( !CGENNING )
        char    name[ BUFSIZ ];
 
        if ( !CGENNING )
@@ -341,16 +375,16 @@ putCON8( val )
        label = getlab();
        putprintf( "    .data" , 0 );
        aligndot(A_DOUBLE);
        label = getlab();
        putprintf( "    .data" , 0 );
        aligndot(A_DOUBLE);
-       putlab( label );
-#      ifdef vax
+       (void) putlab( label );
+#      if defined(vax) || defined(tahoe)
            putprintf( "        .double 0d%.20e" , 0 , val );
            putprintf( "        .double 0d%.20e" , 0 , val );
-#      endif vax
+#      endif vax || tahoe
 #      ifdef mc68000
            putprintf( "        .long   0x%x,0x%x", 0, val);
 #      endif mc68000
        putprintf( "    .text" , 0 );
        sprintf( name , PREFIXFORMAT , LABELPREFIX , label );
 #      ifdef mc68000
            putprintf( "        .long   0x%x,0x%x", 0, val);
 #      endif mc68000
        putprintf( "    .text" , 0 );
        sprintf( name , PREFIXFORMAT , LABELPREFIX , label );
-       putleaf( P2NAME , 0 , 0 , P2DOUBLE , name );
+       putleaf( PCC_NAME , 0 , 0 , PCCT_DOUBLE , name );
     }
 
        /*
     }
 
        /*
@@ -364,7 +398,7 @@ putCONG( string , length , required )
     int                required;
     {
        char    name[ BUFSIZ ];
     int                required;
     {
        char    name[ BUFSIZ ];
-       int     label;
+       char    *label;
        char    *cp;
        int     pad;
        int     others;
        char    *cp;
        int     pad;
        int     others;
@@ -374,7 +408,7 @@ putCONG( string , length , required )
        putprintf( "    .data" , 0 );
        aligndot(A_STRUCT);
        label = getlab();
        putprintf( "    .data" , 0 );
        aligndot(A_STRUCT);
        label = getlab();
-       putlab( label );
+       (void) putlab( label );
        cp = string;
        while ( *cp ) {
            putprintf( "        .byte   0%o" , 1 , *cp ++ );
        cp = string;
        while ( *cp ) {
            putprintf( "        .byte   0%o" , 1 , *cp ++ );
@@ -395,9 +429,9 @@ putCONG( string , length , required )
        putprintf( "    .text"  , 0 );
        sprintf( name , PREFIXFORMAT , LABELPREFIX , label );
        if ( required == RREQ ) {
        putprintf( "    .text"  , 0 );
        sprintf( name , PREFIXFORMAT , LABELPREFIX , label );
        if ( required == RREQ ) {
-           putleaf( P2NAME , 0 , 0 , P2ARY | P2CHAR , name );
+           putleaf( PCC_NAME , 0 , 0 , PCCTM_ARY | PCCT_CHAR , name );
        } else {
        } else {
-           putleaf( P2ICON , 0 , 0 , P2PTR | P2CHAR , name );
+           putleaf( PCC_ICON , 0 , 0 , PCCTM_PTR | PCCT_CHAR , name );
        }
     }
 
        }
     }
 
@@ -424,6 +458,7 @@ putCONG( string , length , required )
 #define        MAXQUALS        6
 int
 p2type( np )
 #define        MAXQUALS        6
 int
 p2type( np )
+    struct nl  *np;
 {
 
     return typerecur( np , 0 );
 {
 
     return typerecur( np , 0 );
@@ -434,31 +469,33 @@ typerecur( np , quals )
     {
        
        if ( np == NIL || quals > MAXQUALS ) {
     {
        
        if ( np == NIL || quals > MAXQUALS ) {
-           return P2UNDEF;
+           return PCCT_UNDEF;
        }
        switch ( np -> class ) {
            case SCAL :
            case RANGE :
        }
        switch ( np -> class ) {
            case SCAL :
            case RANGE :
+           case CRANGE :
                if ( np -> type == ( nl + TDOUBLE ) ) {
                if ( np -> type == ( nl + TDOUBLE ) ) {
-                   return P2DOUBLE;
+                   return PCCT_DOUBLE;
                }
                switch ( bytes( np -> range[0] , np -> range[1] ) ) {
                    case 1:
                }
                switch ( bytes( np -> range[0] , np -> range[1] ) ) {
                    case 1:
-                       return P2CHAR;
+                       return PCCT_CHAR;
                    case 2:
                    case 2:
-                       return P2SHORT;
+                       return PCCT_SHORT;
                    case 4:
                    case 4:
-                       return P2INT;
+                       return PCCT_INT;
                    default:
                        panic( "p2type int" );
                    default:
                        panic( "p2type int" );
+                       /* NOTREACHED */
                }
            case STR :
                }
            case STR :
-               return ( P2ARY | P2CHAR );
+               return ( PCCTM_ARY | PCCT_CHAR );
            case RECORD :
            case SET :
            case RECORD :
            case SET :
-               return P2STRTY;
+               return PCCT_STRTY;
            case FILET :
            case FILET :
-               return ( P2PTR | P2STRTY );
+               return ( PCCTM_PTR | PCCT_STRTY );
            case CONST :
            case VAR :
            case FIELD :
            case CONST :
            case VAR :
            case FIELD :
@@ -466,58 +503,46 @@ typerecur( np , quals )
            case TYPE :
                switch ( nloff( np ) ) {
                    case TNIL :
            case TYPE :
                switch ( nloff( np ) ) {
                    case TNIL :
-                       return ( P2PTR | P2UNDEF );
+                       return ( PCCTM_PTR | PCCT_UNDEF );
                    case TSTR :
                    case TSTR :
-                       return ( P2ARY | P2CHAR );
+                       return ( PCCTM_ARY | PCCT_CHAR );
                    case TSET :
                    case TSET :
-                       return P2STRTY;
+                       return PCCT_STRTY;
                    default :
                        return ( p2type( np -> type ) );
                }
            case REF:
            case WITHPTR:
            case PTR :
                    default :
                        return ( p2type( np -> type ) );
                }
            case REF:
            case WITHPTR:
            case PTR :
-               return ADDTYPE( typerecur( np -> type , quals + 1 ) , P2PTR );
+               return PCCM_ADDTYPE( typerecur( np -> type , quals + 1 ) , PCCTM_PTR );
            case ARRAY :
            case ARRAY :
-               return ADDTYPE( typerecur( np -> type , quals + 1 ) , P2ARY );
+               return PCCM_ADDTYPE( typerecur( np -> type , quals + 1 ) , PCCTM_ARY );
            case FUNC :
                    /*
                     * functions are really pointers to functions
                     * which return their underlying type.
                     */
            case FUNC :
                    /*
                     * functions are really pointers to functions
                     * which return their underlying type.
                     */
-               return ADDTYPE( ADDTYPE( typerecur( np -> type , quals + 2 ) ,
-                                       P2FTN ) , P2PTR );
+               return PCCM_ADDTYPE( PCCM_ADDTYPE( typerecur( np -> type , quals + 2 ) ,
+                                       PCCTM_FTN ) , PCCTM_PTR );
            case PROC :
                    /*
                     * procedures are pointers to functions 
                     * which return integers (whether you look at them or not)
                     */
            case PROC :
                    /*
                     * procedures are pointers to functions 
                     * which return integers (whether you look at them or not)
                     */
-               return ADDTYPE( ADDTYPE( P2INT , P2FTN ) , P2PTR );
+               return PCCM_ADDTYPE( PCCM_ADDTYPE( PCCT_INT , PCCTM_FTN ) , PCCTM_PTR );
            case FFUNC :
            case FPROC :
                    /*
                     *  formal procedures and functions are pointers
                     *  to structures which describe their environment.
                     */
            case FFUNC :
            case FPROC :
                    /*
                     *  formal procedures and functions are pointers
                     *  to structures which describe their environment.
                     */
-               return ( P2PTR | P2STRTY );
+               return ( PCCTM_PTR | PCCT_STRTY );
            default :
                panic( "p2type" );
            default :
                panic( "p2type" );
+               /* NOTREACHED */
        }
     }
 
        }
     }
 
-    /*
-     * add a most significant type modifier to a type
-     */
-long
-addtype( underlying , mtype )
-    long       underlying;
-    long       mtype;
-    {
-       return ( ( ( underlying & ~P2BASETYPE ) << P2TYPESHIFT )
-              | mtype
-              | ( underlying & P2BASETYPE ) );
-    }
-\f
     /*
      * put a typed operator to the pcstream
      */
     /*
      * put a typed operator to the pcstream
      */
@@ -525,15 +550,15 @@ putop( op , type )
     int                op;
     int                type;
     {
     int                op;
     int                type;
     {
-       extern char     *p2opnames[];
+       extern char     *p2opname();
        
        if ( !CGENNING )
            return;
        
        if ( !CGENNING )
            return;
-       p2word( TOF77( op , 0 , type ) );
+       p2word( PCCM_TRIPLE( op , 0 , type ) );
 #      ifdef DEBUG
            if ( opt( 'k' ) ) {
                fprintf( stdout , "%s (%d) |   0 | 0x%x\n"
 #      ifdef DEBUG
            if ( opt( 'k' ) ) {
                fprintf( stdout , "%s (%d) |   0 | 0x%x\n"
-                       , p2opnames[ op ] , op , type );
+                       , p2opname( op ) , op , type );
            }
 #      endif
     }
            }
 #      endif
     }
@@ -549,17 +574,17 @@ putstrop( op , type , size , alignment )
     int        size;
     int        alignment;
     {
     int        size;
     int        alignment;
     {
-       extern char     *p2opnames[];
+       extern char     *p2opname();
        
        if ( !CGENNING )
            return;
        
        if ( !CGENNING )
            return;
-       p2word( TOF77( op , 0 , type ) );
+       p2word( PCCM_TRIPLE( op , 0 , type ) );
        p2word( size );
        p2word( alignment );
 #      ifdef DEBUG
            if ( opt( 'k' ) ) {
                fprintf( stdout , "%s (%d) |   0 | 0x%x %d %d\n"
        p2word( size );
        p2word( alignment );
 #      ifdef DEBUG
            if ( opt( 'k' ) ) {
                fprintf( stdout , "%s (%d) |   0 | 0x%x %d %d\n"
-                       , p2opnames[ op ] , op , type , size , alignment );
+                       , p2opname( op ) , op , type , size , alignment );
            }
 #      endif
     }
            }
 #      endif
     }
@@ -567,120 +592,93 @@ putstrop( op , type , size , alignment )
     /*
      * the string names of p2ops
      */
     /*
      * the string names of p2ops
      */
-char   *p2opnames[] = {
-       "",
-       "P2UNDEFINED",          /* 1 */
-       "P2NAME",               /* 2 */
-       "P2STRING",             /* 3 */
-       "P2ICON",               /* 4 */
-       "P2FCON",               /* 5 */
-       "P2PLUS",               /* 6 */
-       "",
-       "P2MINUS",              /* 8            also unary == P2NEG */
-       "",
-       "P2NEG",
-       "P2MUL",                /* 11           also unary == P2INDIRECT */
-       "",
-       "P2INDIRECT",
-       "P2AND",                /* 14           also unary == P2ADDROF */
-       "",
-       "P2ADDROF",
-       "P2OR",                 /* 17 */
-       "",
-       "P2ER",                 /* 19 */
-       "",
-       "P2QUEST",              /* 21 */
-       "P2COLON",              /* 22 */
-       "P2ANDAND",             /* 23 */
-       "P2OROR",               /* 24 */
-       "",                     /* 25 */
-       "",                     /* 26 */
-       "",                     /* 27 */
-       "",                     /* 28 */
-       "",                     /* 29 */
-       "",                     /* 30 */
-       "",                     /* 31 */
-       "",                     /* 32 */
-       "",                     /* 33 */
-       "",                     /* 34 */
-       "",                     /* 35 */
-       "",                     /* 36 */
-       "",                     /* 37 */
-       "",                     /* 38 */
-       "",                     /* 39 */
-       "",                     /* 40 */
-       "",                     /* 41 */
-       "",                     /* 42 */
-       "",                     /* 43 */
-       "",                     /* 44 */
-       "",                     /* 45 */
-       "",                     /* 46 */
-       "",                     /* 47 */
-       "",                     /* 48 */
-       "",                     /* 49 */
-       "",                     /* 50 */
-       "",                     /* 51 */
-       "",                     /* 52 */
-       "",                     /* 53 */
-       "",                     /* 54 */
-       "",                     /* 55 */
-       "P2LISTOP",             /* 56 */
-       "",
-       "P2ASSIGN",             /* 58 */
-       "P2COMOP",              /* 59 */
-       "P2DIV",                /* 60 */
-       "",
-       "P2MOD",                /* 62 */
-       "",
-       "P2LS",                 /* 64 */
-       "",
-       "P2RS",                 /* 66 */
-       "",
-       "P2DOT",                /* 68 */
-       "P2STREF",              /* 69 */
-       "P2CALL",               /* 70           also unary */
-       "",
-       "P2UNARYCALL",
-       "P2FORTCALL",           /* 73           also unary */
-       "",
-       "P2UNARYFORTCALL",
-       "P2NOT",                /* 76 */
-       "P2COMPL",              /* 77 */
-       "P2INCR",               /* 78 */
-       "P2DECR",               /* 79 */
-       "P2EQ",                 /* 80 */
-       "P2NE",                 /* 81 */
-       "P2LE",                 /* 82 */
-       "P2LT",                 /* 83 */
-       "P2GE",                 /* 84 */
-       "P2GT",                 /* 85 */
-       "P2ULE",                /* 86 */
-       "P2ULT",                /* 87 */
-       "P2UGE",                /* 88 */
-       "P2UGT",                /* 89 */
-       "P2SETBIT",             /* 90 */
-       "P2TESTBIT",            /* 91 */
-       "P2RESETBIT",           /* 92 */
-       "P2ARS",                /* 93 */
-       "P2REG",                /* 94 */
-       "P2OREG",               /* 95 */
-       "P2CCODES",             /* 96 */
-       "P2FREE",               /* 97 */
-       "P2STASG",              /* 98 */
-       "P2STARG",              /* 99 */
-       "P2STCALL",             /* 100          also unary */
-       "",
-       "P2UNARYSTCALL",
-       "P2FLD",                /* 103 */
-       "P2SCONV",              /* 104 */
-       "P2PCONV",              /* 105 */
-       "P2PMCONV",             /* 106 */
-       "P2PVCONV",             /* 107 */
-       "P2FORCE",              /* 108 */
-       "P2CBRANCH",            /* 109 */
-       "P2INIT",               /* 110 */
-       "P2CAST",               /* 111 */
+
+struct p2op {
+    int op;
+    char *name;
+};
+
+static struct p2op     p2opnames[] = {
+       PCC_ERROR, "PCC_ERROR",
+       PCC_NAME, "PCC_NAME",
+       PCC_STRING, "PCC_STRING",
+       PCC_ICON, "PCC_ICON",
+       PCC_FCON, "PCC_FCON",
+       PCC_PLUS, "PCC_PLUS",
+       PCC_MINUS, "PCC_MINUS",
+       PCC_UMINUS, "PCC_UMINUS",
+       PCC_MUL, "PCC_MUL",
+       PCC_DEREF, "PCC_DEREF",
+       PCC_AND, "PCC_AND",
+       PCC_ADDROF, "PCC_ADDROF",
+       PCC_OR, "PCC_OR",
+       PCC_ER, "PCC_ER",
+       PCC_QUEST, "PCC_QUEST",
+       PCC_COLON, "PCC_COLON",
+       PCC_ANDAND, "PCC_ANDAND",
+       PCC_OROR, "PCC_OROR",
+       PCC_CM, "PCC_CM",
+       PCC_ASSIGN, "PCC_ASSIGN",
+       PCC_COMOP, "PCC_COMOP",
+       PCC_DIV, "PCC_DIV",
+       PCC_MOD, "PCC_MOD",
+       PCC_LS, "PCC_LS",
+       PCC_RS, "PCC_RS",
+       PCC_DOT, "PCC_DOT",
+       PCC_STREF, "PCC_STREF",
+       PCC_CALL, "PCC_CALL",
+       PCC_UCALL, "PCC_UCALL",
+       PCC_FORTCALL, "PCC_FORTCALL",
+       PCC_UFORTCALL, "PCC_UFORTCALL",
+       PCC_NOT, "PCC_NOT",
+       PCC_COMPL, "PCC_COMPL",
+       PCC_INCR, "PCC_INCR",
+       PCC_DECR, "PCC_DECR",
+       PCC_EQ, "PCC_EQ",
+       PCC_NE, "PCC_NE",
+       PCC_LE, "PCC_LE",
+       PCC_LT, "PCC_LT",
+       PCC_GE, "PCC_GE",
+       PCC_GT, "PCC_GT",
+       PCC_ULE, "PCC_ULE",
+       PCC_ULT, "PCC_ULT",
+       PCC_UGE, "PCC_UGE",
+       PCC_UGT, "PCC_UGT",
+       PCC_REG, "PCC_REG",
+       PCC_OREG, "PCC_OREG",
+       PCC_CCODES, "PCC_CCODES",
+       PCC_FREE, "PCC_FREE",
+       PCC_STASG, "PCC_STASG",
+       PCC_STARG, "PCC_STARG",
+       PCC_STCALL, "PCC_STCALL",
+       PCC_USTCALL, "PCC_USTCALL",
+       PCC_FLD, "PCC_FLD",
+       PCC_SCONV, "PCC_SCONV",
+       PCC_PCONV, "PCC_PCONV",
+       PCC_PMCONV, "PCC_PMCONV",
+       PCC_PVCONV, "PCC_PVCONV",
+       PCC_FORCE, "PCC_FORCE",
+       PCC_CBRANCH, "PCC_CBRANCH",
+       PCC_INIT, "PCC_INIT",
+       PCC_CAST, "PCC_CAST",
+       -1, ""
     };
     };
+
+char *
+p2opname( op )
+    register int       op;
+    {
+       static char             *p2map[PCC_MAXOP+1];
+       static bool             mapready = FALSE;
+       register struct p2op    *pp;
+
+       if ( mapready == FALSE ) {
+           for ( pp = p2opnames; pp->op >= 0; pp++ )
+               p2map[ pp->op ] = pp->name;
+           mapready = TRUE;
+       }
+       return ( p2map[ op ] ? p2map[ op ] : "unknown" );
+    }
 \f
     /*
      * low level routines
 \f
     /*
      * low level routines
@@ -690,7 +688,7 @@ char        *p2opnames[] = {
      * puts a long word on the pcstream
      */
 p2word( word )
      * puts a long word on the pcstream
      */
 p2word( word )
-    long       word;
+    int                word;
     {
 
        putw( word , pcstream );
     {
 
        putw( word , pcstream );
@@ -765,10 +763,10 @@ printjbr( prefix , label )
     long       label;
     {
 
     long       label;
     {
 
-#      ifdef vax
+#      if defined(vax) || defined(tahoe)
            putprintf( "        jbr     " , 1 );
            putprintf( PREFIXFORMAT , 0 , prefix , label );
            putprintf( "        jbr     " , 1 );
            putprintf( PREFIXFORMAT , 0 , prefix , label );
-#      endif vax
+#      endif vax || tahoe
 #      ifdef mc68000
            putprintf( "        jra     " , 1 );
            putprintf( PREFIXFORMAT , 0 , prefix , label );
 #      ifdef mc68000
            putprintf( "        jra     " , 1 );
            putprintf( PREFIXFORMAT , 0 , prefix , label );
@@ -778,7 +776,8 @@ printjbr( prefix , label )
     /*
      * another version of put to catch calls to put
      */
     /*
      * another version of put to catch calls to put
      */
-put( arg1 , arg2 )
+/* VARARGS */
+put()
     {
 
        panic("put()");
     {
 
        panic("put()");