Annotation of coherent/d/bin/cc/c/h/cc2.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Header file for the 'direct-to-bits' code generator and optimizer.
                      3:  * This contains all of the machine independent data structures and macros. 
                      4:  * Definitions dealing with the object code are in another file.
                      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:ops.h"
                     13: #include "INC$LIB:var.h"
                     14: #include "INC$LIB:varmch.h"
                     15: #include "INC$LIB:opcode.h"
                     16: #include "INC$LIB:cc2mch.h"
                     17: #include "INC$LIB:stream.h"
                     18: #else
                     19: #include "mch.h"
                     20: #include "host.h"
                     21: #include "ops.h"
                     22: #include "var.h"
                     23: #include "varmch.h"
                     24: #include "opcode.h"
                     25: #include "cc2mch.h"
                     26: #include "stream.h"
                     27: #endif
                     28: 
                     29: /*
                     30:  * Table sizes.
                     31:  */
                     32: #define        NADDR   5                       /* # of address fields */
                     33: #define        NSHASH  64                      /* Symbol hash buckets */
                     34: #define        SHMASK  077                     /* Mask for hashing into above */
                     35: 
                     36: /*
                     37:  * An array of these structures, indexed by compiler segment identifier,
                     38:  * keeps track of the current location in each segment.
                     39:  * The values of "dot" and "size" are not correct for the current segment.
                     40:  */
                     41: typedef        struct  seg     {
                     42:        ADDRESS s_dot;                  /* Current location */
                     43:        ADDRESS s_mseek;                /* Base in memory */
                     44:        long    s_dseek;                /* Base in file */
                     45: }      SEG;
                     46: 
                     47: /*
                     48:  * Every symbol in the assembler symbol table looks like this.
                     49:  * Local and global symbols live in the same table.
                     50:  * A flag bit "S_LABNO" tells which variant is in use.
                     51:  */
                     52: typedef        struct  sym     {
                     53:        struct  sym     *s_fp;          /* Link */
                     54:        ADDRESS         s_value;        /* Offset into segment */
                     55:        char            s_seg;          /* Segment # */
                     56:        char            s_flag;         /* Flags */
                     57:        int             s_data;         /* Data, depends on variant */
                     58:        int             s_type;
                     59:        char            s_id[];         /* Name + null */
                     60: }      SYM;
                     61: 
                     62: #define        s_labno s_data                  /* Local label # */
                     63: #define        s_ref   s_data                  /* Globl reference # */
                     64: 
                     65: #define        S_GBL   01                      /* Global */
                     66: #define        S_LABNO 02                      /* Has labno, not id */
                     67: #define        S_DEF   04                      /* Defined */
                     68: #define        S_NFL   010                     /* Not local to function */
                     69: #define        S_PUT   020                     /* Debug item present */
                     70: 
                     71: /*
                     72:  * This structure is used to hold the address field of a machine instruction.
                     73:  * It assumes the rather weak linker model.
                     74:  */
                     75: typedef        struct  afield  {
                     76:        short   a_mode;                 /* Address mode */
                     77:        SYM     *a_sp;                  /* Symbol table pointer */
                     78:        ADDRESS a_value;                /* Offset */
                     79: }      AFIELD;
                     80: 
                     81: /*
                     82:  * When a function is read into memory,
                     83:  * it is represented as a doubly linked list of these structures.
                     84:  * The 'i_type' field tells which variant is used.
                     85:  */
                     86: typedef        struct  INS     {
                     87:        struct  INS     *i_fp;          /* Link forward */
                     88:        struct  INS     *i_bp;          /* Link back */
                     89:        int             i_type;         /* Node type */
                     90:        union {
                     91:                int i_data[2];          /* Variant areas #1 and #2 */
                     92:                sizeof_t i_data3;
                     93:        } i_var;
                     94:        SYM             *i_sp;          /* Symbol */
                     95:        ADDRESS         i_pc;           /* Location */
                     96:        char            i_data4;        /* Variant area #3 */
                     97:        struct  INS     *i_ip;          /* Label link */
                     98:        short           i_rel;          /* JUMP relation code */        
                     99:        AFIELD          i_af[];         /* Addresses */
                    100: }      INS;
                    101: 
                    102: /* Variant data resolution */
                    103: #define i_data1        i_var.i_data[0]
                    104: #define i_data2 i_var.i_data[1]
                    105: 
                    106: /* Variant #1 */
                    107: #define        i_seg   i_data1                 /* Segment identifier */
                    108: #define        i_len   i_var.i_data3           /* BLOCK length */
                    109: #define        i_line  i_data1                 /* LINE number */
                    110: #define        i_align i_data1                 /* ALIGN information */
                    111: #define        i_labno i_data1                 /* LLABEL or JUMP label number */
                    112: #define        i_op    i_data1                 /* CODE opcode */
                    113: 
                    114: /* Variant #2 */
                    115: #define        i_refc  i_data2                 /* Ref. count for labels */
                    116: #define        i_pcseg i_data2                 /* Segment for code */
                    117: 
                    118: /* Variant #3 */
                    119: #define        i_naddr i_data4                 /* # of i_af entries */
                    120: #define        i_long  i_data4                 /* Long jump flag */
                    121: 
                    122: /*
                    123:  * A table of these structures is indexed by opcode number
                    124:  * (obtained from the 'opcode.h' header file).
                    125:  * Each element holds information needed to assemble the instruction
                    126:  * into either ascii assembler or binary code.
                    127:  */
                    128: typedef        struct  opinfo  {
                    129:        char    op_naddr;               /* # of addresses */
                    130:        char    op_flag;                /* Flags */
                    131:        short   op_opcode;              /* Op code */
                    132:        short   op_style;               /* Style, used by formatter */
                    133: }      OPINFO;
                    134: 
                    135: #define        OP_JUMP 01                      /* Some kind of jump */
                    136: #define        OP_DD   02                      /* Some kind of data pseudo-op */
                    137: 
                    138: /*
                    139:  * Functions and externals.
                    140:  */
                    141: extern SYM     *hash2[];
                    142: extern INS     *getcode();
                    143: extern SYM     *glookup();
                    144: extern char    id[];
                    145: extern SYM     *llookup();
                    146: extern ADDRESS dot;
                    147: extern int     dotseg;
                    148: extern SEG     seg[];
                    149: extern FILE    *ofp;
                    150: extern FILE    *ifp;
                    151: extern OPINFO  opinfo[];
                    152: extern INS     ins;
                    153: extern INS     *newi();
                    154: extern INS     *newn();
                    155: extern int     line;
                    156: extern INS     *getins();
                    157: extern int     changes;
                    158: extern int     nlabdel;
                    159: extern INS     *deleteins();
                    160: extern int     ndead;
                    161: extern int     nbrbr;
                    162: extern int     ncbrbr;
                    163: extern int     nexbr;
                    164: extern int     nbrnext;
                    165: extern int     nxjump;
                    166: extern int     ncomseq;
                    167: extern int     nsimplify;
                    168: extern int     nuseless;
                    169: #if !TINY
                    170: extern int     vflag;
                    171: extern int     xflag;
                    172: #endif
                    173: extern char    file[];
                    174: extern char    module[];
                    175: extern int     nerr;
                    176: extern char    *passname;
                    177: extern int     labgen;
                    178: 
                    179: #if OVERLAID
                    180: extern jmp_buf death;
                    181: #endif

unix.superglobalmegacorp.com

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