Annotation of coherent/b/bin/c/h/cc1.h, revision 1.1

1.1     ! root        1: /*
        !             2:  * h/cc1.h
        !             3:  * Definitions, macros, structures and types
        !             4:  * used by the portable code generator (cc1).
        !             5:  */
        !             6: 
        !             7: #include <stdio.h>
        !             8: #include <setjmp.h>
        !             9: #ifdef   vax
        !            10: #include "INC$LIB:mch.h"
        !            11: #include "INC$LIB:host.h"
        !            12: #include "INC$LIB:cc1mch.h"
        !            13: #include "INC$LIB:ops.h"
        !            14: #include "INC$LIB:var.h"
        !            15: #include "INC$LIB:varmch.h"
        !            16: #include "INC$LIB:opcode.h"
        !            17: #include "INC$LIB:stream.h"
        !            18: #else
        !            19: #include "mch.h"
        !            20: #include "host.h"
        !            21: #include "cc1mch.h"
        !            22: #include "ops.h"
        !            23: #include "var.h"
        !            24: #include "varmch.h"
        !            25: #include "opcode.h"
        !            26: #include "stream.h"
        !            27: #endif
        !            28: 
        !            29: /*
        !            30:  * Table sizes, etc.
        !            31:  */
        !            32: #if    _I386
        !            33: #define        NSTORE  100                     /* # of entries in storelist */
        !            34: #else
        !            35: #define        NSTORE  20                      /* # of entries in storelist */
        !            36: #endif
        !            37: #define        NNSW    16                      /* Nested switches */
        !            38: #define        NTNODE  350                     /* Tree nodes */
        !            39: #define        NSHASH  64                      /* Symbol hash buckets */
        !            40: #define        SHMASK  077                     /* Mask for above */
        !            41: 
        !            42: /*
        !            43:  * This structure is used to
        !            44:  * buffer the case constants and the
        !            45:  * case labels.
        !            46:  */
        !            47: typedef        struct  cases   {
        !            48:        ival_t  c_val;                  /* Value */
        !            49:        int     c_lab;                  /* Label */
        !            50: }      CASES;
        !            51: 
        !            52: /*
        !            53:  * Code patterns.
        !            54:  * There is an array of these for
        !            55:  * most of the operators.
        !            56:  * The 'pat' table holds a pointer
        !            57:  * to the first one and the number
        !            58:  * of entries.
        !            59:  */
        !            60: typedef        struct  pat     {
        !            61:        INDEX   p_flag;                 /* Some flags */
        !            62:        INDEX   p_ntype;                /* Node type */
        !            63:        REGNAME p_ntemp;                /* Temp. spec. */
        !            64:        REGNAME p_ltemp;                /* Left. spec. */
        !            65:        REGNAME p_rtemp;                /* Right spec. */
        !            66:        REGNAME p_result;               /* Result spec. */
        !            67:        INDEX   p_lflag;                /* Flags for left subtree */
        !            68:        INDEX   p_ltype;                /* Types for left subtree */
        !            69:        INDEX   p_rflag;                /* Flags for right subtree */
        !            70:        INDEX   p_rtype;                /* Types for right subtree */
        !            71:        char    *p_macro;               /* The macro */
        !            72: #if !TINY
        !            73:        int     p_fname;                /* Pattern file name */
        !            74:        int     p_fline;                /* Pattern file line */
        !            75: #endif
        !            76: }      PAT;
        !            77: 
        !            78: /*
        !            79:  * Pattern index.
        !            80:  * The 'pat' table (one of these)
        !            81:  * is indexed by operator number to
        !            82:  * get the patterns for the op.
        !            83:  */
        !            84: typedef        struct  patx    {
        !            85:        PAT     *px_pp;                 /* Pointer to patterns */
        !            86:        int     px_npat;                /* # of patterns */
        !            87: }      PATX;
        !            88: 
        !            89: /* Flags */
        !            90: #define        PEFFECT ((PATFLAG)0x0001)       /* Effect */
        !            91: #define        PLVALUE ((PATFLAG)0x0002)       /* Lvalue load */
        !            92: #define        PRVALUE ((PATFLAG)0x0004)       /* Rvalue load */
        !            93: #define        PFNARG  ((PATFLAG)0x0008)       /* Function argument */
        !            94: #define        PEQ     ((PATFLAG)0x0010)       /* Conditionals */
        !            95: #define        PNE     ((PATFLAG)0x0020)
        !            96: #define        PGT     ((PATFLAG)0x0040)
        !            97: #define        PGE     ((PATFLAG)0x0080)
        !            98: #define        PLE     ((PATFLAG)0x0100)
        !            99: #define        PLT     ((PATFLAG)0x0200)
        !           100: #define        PUGT    ((PATFLAG)0x0400)
        !           101: #define        PUGE    ((PATFLAG)0x0800)
        !           102: #define        PULE    ((PATFLAG)0x1000)
        !           103: #define        PULT    ((PATFLAG)0x2000)
        !           104: 
        !           105: #define        P_SLT   ((PATFLAG)0x4000)       /* Share left temp */
        !           106: #define        P_SRT   ((PATFLAG)(unsigned)0x8000)     /* Share right temp */
        !           107: #define        P_SHR   (P_SLT|P_SRT)           /* Any share */
        !           108: 
        !           109: /*
        !           110:  * Macros.
        !           111:  */
        !           112: #define        M_ORG   200                     /* Origin of non opcodes */
        !           113: 
        !           114: #define        M_END   200                     /* End of macro */
        !           115: #define        M_OP0   201                     /* Op 0 */
        !           116: #define        M_OP1   202                     /* Op 1 */
        !           117: #define        M_OP2   203                     /* Op 2 */
        !           118: #define        M_AL    204                     /* Address, left */
        !           119: #define        M_AR    205                     /* Address, right */
        !           120: #define        M_RL    206                     /* Register, left */
        !           121: #define        M_RR    207                     /* Register, right */
        !           122: #define        M_R     208                     /* Temp. register */
        !           123: #define        M_HI    209                     /* Hi prefix */
        !           124: #define        M_LO    210                     /* Lo prefix */
        !           125: #define        M_EMASK 211                     /* Field extract mask */
        !           126: #define        M_LAB   212                     /* Label */
        !           127: #define        M_LAB0  213                     /* Generate label 0 */
        !           128: #define        M_LAB1  214                     /* Generate label 1 */
        !           129: #define        M_NSE   215                     /* No side effects prefix */
        !           130: #define        M_IFR   216                     /* If relational */
        !           131: #define        M_IFV   217                     /* If value */
        !           132: #define        M_CMASK 218                     /* Field clear mask */
        !           133: #define        M_SIZE  219                     /* Size */
        !           134: #define        M_BITL  220                     /* Extract bit # left  side */
        !           135: #define        M_BITR  221                     /* Extract bit # right side */
        !           136: #define        M_ENDIF 222                     /* End if */
        !           137: #define        M_DLAB0 223                     /* Define label 0 */
        !           138: #define        M_DLAB1 224                     /* Define label 1 */
        !           139: #define        M_ICON  225                     /* Ival_t constant */
        !           140: #define        M_REGNO 226                     /* Register */
        !           141: #define M_AN   227                     /* Address form of node */
        !           142: #define M_TOS  228                     /* Top of stack address */
        !           143: #define M_STAR 229                     /* Indirection on address */
        !           144: #define        M_GID   230                     /* Global name for calling routines */
        !           145: #define        M_IFE   231                     /* If effect */
        !           146: #define        M_REL0  232                     /* Rel. 0 */
        !           147: #define        M_REL1  233                     /* Rel. 1 */
        !           148: #define        M_LREL0 234                     /* Long rel. 0 */
        !           149: #define        M_LREL1 235                     /* Long rel. 1 */
        !           150: #define        M_LREL2 236                     /* Long rel. 2 */
        !           151: #define        M_CALL  237                     /* Call opcode */
        !           152: #define        M_LCON  238                     /* Lval_t constant */
        !           153: #define        M_TN    239                     /* Type of node op */
        !           154: #define        M_TR    240                     /* Type of right */
        !           155: #define        M_TL    241                     /* Type of left */
        !           156: #define        M_SSIZE 242                     /* Stack size */
        !           157: #define M_JMP1 243                     /* One byte jump */
        !           158: #define M_JMP2 244                     /* Two byte jump */
        !           159: #define M_JMPB 245                     /* One byte jump back relative */
        !           160: 
        !           161: /*
        !           162:  * Symbol structure.
        !           163:  */
        !           164: typedef        struct  sym     {
        !           165:        struct  sym     *s_fp;          /* Hash link */
        !           166:        char    s_id[];                 /* Name */
        !           167: }      SYM;
        !           168: 
        !           169: /*
        !           170:  * This is the tree node structure. All
        !           171:  * nodes are the same size; this makes it much easier
        !           172:  * for the modify phases to make a node of one type into a
        !           173:  * node of any other type. Note the use of fully qualified
        !           174:  * references into the structure; this makes the structure
        !           175:  * compile correctly under either Bell or UCB structure
        !           176:  * member rules. Noce names for the members is provided
        !           177:  * by the block of #define's at the end of the declaration.
        !           178:  */
        !           179: typedef        struct  tree    {
        !           180:        int     t_op;                   /* Operation */
        !           181:        TYPE    t_type;                 /* Type */
        !           182:        COST    t_cost;                 /* Cost of evaluation */
        !           183:        PAT     *t_patp;                /* Pattern */
        !           184:        int     t_size;                 /* Size */
        !           185:        FLAG    t_flag;                 /* Flags */
        !           186:        REGNAME t_treg;                 /* Temp reg */
        !           187:        REGNAME t_rreg;                 /* Result reg */
        !           188:        PREGSET t_used;                 /* Used */
        !           189:        union   {
        !           190:                struct  {
        !           191:                        struct  tree    *t_xlp;
        !           192:                        union   {
        !           193:                                struct  tree    *t_xrp;
        !           194:                                struct  {
        !           195:                                        char    t_xfw;
        !           196:                                        char    t_xfb;
        !           197:                                }       t_1;
        !           198:                        }       t_2;
        !           199:                }       t_3;
        !           200:                ival_t  t_xival;
        !           201:                lval_t  t_xlval;
        !           202:                dval_t  t_xdval;
        !           203:                struct  {
        !           204:                        sizeof_t t_xoffs;
        !           205:                        int     t_xseg;
        !           206:                        union   {
        !           207:                                int     t_xlab;
        !           208:                                SYM     *t_xsp;
        !           209:                        }       t_4;
        !           210:                }       t_5;
        !           211:                int     t_xreg;
        !           212:        }       t_6;
        !           213: }      TREE;
        !           214: 
        !           215: #define        t_lp    t_6.t_3.t_xlp           /* Left tree */
        !           216: #define        t_rp    t_6.t_3.t_2.t_xrp       /* Right tree */
        !           217: #define        t_width t_6.t_3.t_2.t_1.t_xfw   /* Width of field in bits */
        !           218: #define        t_base  t_6.t_3.t_2.t_1.t_xfb   /* Base bit */
        !           219: #define        t_ival  t_6.t_xival             /* ICON value */
        !           220: #define        t_lval  t_6.t_xlval             /* LCON value */
        !           221: #define        t_dval  t_6.t_xdval             /* DCON value */
        !           222: #define        t_offs  t_6.t_5.t_xoffs         /* Offset from label */
        !           223: #define t_seg  t_6.t_5.t_xseg          /* Segment of label */
        !           224: #define        t_label t_6.t_5.t_4.t_xlab      /* Local label */
        !           225: #define        t_sp    t_6.t_5.t_4.t_xsp       /* Global symbol */
        !           226: #define        t_reg   t_6.t_xreg              /* REG register number */
        !           227: 
        !           228: /*
        !           229:  * Register table.
        !           230:  */
        !           231: typedef        struct  reg     {
        !           232:        KIND    r_lvalue;               /* Kinds in lvalue sense */
        !           233:        KIND    r_rvalue;               /* Kinds in rvalue sense */
        !           234:        int     r_goal;                 /* Goal for TREG loading */
        !           235:        REGNAME r_enpair;               /* Enclosing pair name */
        !           236:        REGNAME r_hihalf;               /* Hi half */
        !           237:        REGNAME r_lohalf;               /* Lo half */
        !           238:        PREGSET r_phys;                 /* Physical regs */
        !           239: }      REGDESC;
        !           240: 
        !           241: /*
        !           242:  * Per type info.
        !           243:  */
        !           244: typedef        struct  pertype {
        !           245:        REGNAME p_frreg;                /* Function return reg */
        !           246:        char    p_frcxt;                /* Return context */
        !           247:        char    p_size;                 /* Size of temp, function arg */
        !           248:        char    p_incr;                 /* Real size */
        !           249:        TYPESET p_type;                 /* Match type bits */
        !           250:        KIND    p_kind;                 /* Kind of register needed */
        !           251:        KIND    p_pair;                 /* Kind for a pair */
        !           252: }      PERTYPE;
        !           253: 
        !           254: /*
        !           255:  * Contexts.
        !           256:  * Used to indicate the context of a computation.
        !           257:  * Passed to all (modify, selection, output) phases of
        !           258:  * the code generator. 
        !           259:  */
        !           260: #define        MEFFECT 0                       /* Effect only */
        !           261: #define        MLVALUE 1                       /* Left value context */
        !           262: #define        MRVALUE 2                       /* Right value context */
        !           263: #define        MFNARG  3                       /* Function argument */
        !           264: #define        MLADDR  4                       /* Address, left side */
        !           265: #define        MRADDR  5                       /* Address, right side */
        !           266: #define        MRETURN 6                       /* Return value of function */
        !           267: #define        MSWITCH 7                       /* Switch value */
        !           268: #define        MINIT   8                       /* Initialisor */
        !           269: #define        MFLOW   9                       /* Flow of control */
        !           270: #define        MPASSED 10                      /* For modify3.c tables */
        !           271: #define        MJUNK   11                      /* Ditto */
        !           272: #define        MHARD   12                      /* Ditto */
        !           273: #define        MEQ     13                      /* == */
        !           274: #define        MNE     14                      /* != */
        !           275: #define        MGT     15                      /* >  signed */
        !           276: #define        MGE     16                      /* >= signed */
        !           277: #define        MLE     17                      /* <= signed */
        !           278: #define        MLT     18                      /* <  signed */
        !           279: #define        MUGT    19                      /* >  unsigned */
        !           280: #define        MUGE    20                      /* >= unsigned */
        !           281: #define        MULE    21                      /* <= unsigned */
        !           282: #define        MULT    22                      /* <  unsigned */
        !           283: 
        !           284: /*
        !           285:  * Macros.
        !           286:  */
        !           287: #define        isleaf(x)       ((x) < MIOBASE)
        !           288: #define isbool(x)       (x==ANDAND || x==OROR || x==NOT || (x>=EQ && x<=ULT))
        !           289: #define snap(tp)       snaptree((tp), 0)
        !           290: #define isrelop(x)      ((x)>=EQ && (x)<=ULT)
        !           291: #define isurelop(x)     ((x)>=UGT && (x)<=ULT)
        !           292: #define        isncon(x)       ((x)<LID)
        !           293: #define iscon(x)        ((x)<LID || (x)==ADDR)
        !           294: #define        isconvert(op)   ((op)==CONVERT || (op)==CAST)
        !           295: #define        isrealreg(r)    ((r) < NRREG)
        !           296: #define        binit()         (curbusy = regbusy)
        !           297: #define        islvadr(pflag)  ((pflag&(T_ADR|T_LV))==(T_ADR|T_LV))
        !           298: #define        isrvadr(pflag)  ((pflag&(T_ADR|T_LV))==T_ADR)
        !           299: #define        isadr(flag)     ((flag&T_ADR) != 0)
        !           300: #define        isofs(flag)     ((flag&T_OFS) != 0)
        !           301: #define        isind(flag)     ((flag&T_INDIR) != 0)
        !           302: #define        ishlvadr(pflag) ((pflag&(T_ADR|T_LV|T_INDIR))==(T_ADR|T_LV))
        !           303: #define        isflow(op)      (op==NOT || op==ANDAND || op==OROR)
        !           304: 
        !           305: /*
        !           306:  * These bit packing macros are used
        !           307:  * to pack the subgoal table used by the
        !           308:  * leaf insert routines.
        !           309:  */
        !           310: #define        ndown(l,r)      (((l)<<5) | (r))
        !           311: #define        getri(n)        ((n)&037)
        !           312: #define        getli(n)        (((n)>>5)&037)
        !           313: 
        !           314: /*
        !           315:  * Functions and variables.
        !           316:  */
        !           317: /* Arrays. */
        !           318: #if    !YATC
        !           319: extern char    file[];
        !           320: extern FLAG    flagcache[];
        !           321: extern char    fliprel[];
        !           322: extern char    *gidcache[];
        !           323: extern SYM     *hash1[];
        !           324: extern char    id[];
        !           325: extern ival_t  ivalcache[];
        !           326: extern int     ldtab[];
        !           327: extern lval_t  lvalcache[];
        !           328: extern char    macros[];
        !           329: extern char    module[];
        !           330: #if    !TINY
        !           331: extern char    *namecache[];
        !           332: #endif
        !           333: extern unsigned char optab[][3];
        !           334: extern char    otherel[];
        !           335: extern PATFLAG patcache[];
        !           336: extern PATX    patx[];
        !           337: extern PERTYPE pertype[];
        !           338: extern REGDESC reg[];
        !           339: extern TREE    *storelist[];
        !           340: extern TYPESET typecache[];
        !           341: extern char    wtype[];
        !           342: 
        !           343: /* Functions. */
        !           344: extern TREE    *alocnode();
        !           345: extern int     amd();
        !           346: extern TREE    *basenode();
        !           347: extern lval_t  constcvt();
        !           348: extern TREE    *copynode();
        !           349: extern TREE    *findoffs();
        !           350: extern TREE    *fold1();
        !           351: extern TREE    *foldaddr();
        !           352: extern SYM     *gidpool();
        !           353: extern lval_t  grabnval();
        !           354: extern TREE    *gvalnode();
        !           355: extern TREE    *ivalnode();
        !           356: extern TREE    *leafnode();
        !           357: extern TREE    *leftnode();
        !           358: extern TREE    *lvalnode();
        !           359: extern TREE    *makenode();
        !           360: extern TREE    *modargs();
        !           361: extern TREE    *modcall();
        !           362: extern TREE    *modefld();
        !           363: extern TREE    *modfold();
        !           364: extern TREE    *modify();
        !           365: extern TREE    *modleaf();
        !           366: extern TREE    *modlfld();
        !           367: extern TREE    *modmul();
        !           368: extern TREE    *modoper();
        !           369: extern TREE    *modsasg();
        !           370: extern TREE    *modtree();
        !           371: extern TREE    *modtruth();
        !           372: extern TREE    *modxfun();
        !           373: extern TREE    *ripout();
        !           374: extern  int    snapf();
        !           375: extern TREE    *talloc();
        !           376: extern TREE    *tempnode();
        !           377: extern TREE    *treeget();
        !           378: extern TREE    *treeget1();
        !           379: 
        !           380: /* Variables. */
        !           381: #if    !TINY
        !           382: extern int     mflag;
        !           383: extern int     oflag;
        !           384: extern int     sflag;
        !           385: #endif
        !           386: extern CASES   *cases;
        !           387: extern PREGSET curbusy;
        !           388: extern ival_t  curtemp;
        !           389: extern PREGSET curxreg;
        !           390: extern int     labgen;
        !           391: extern int     line;
        !           392: extern ival_t  maxauto;
        !           393: extern PREGSET maxbusy;
        !           394: extern ival_t  maxtemp;
        !           395: extern int     nstorelist;
        !           396: extern FILE    *ofp;
        !           397: #endif
        !           398: #if    OVERLAID
        !           399: extern jmp_buf death;
        !           400: #endif
        !           401: extern FILE    *ifp;
        !           402: extern int     nerr;
        !           403: extern int     oldseg;
        !           404: extern char    *passname;
        !           405: 
        !           406: /* end of h/cc1.h */

unix.superglobalmegacorp.com

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