Pristine Ack-5.5
[Ack-5.5.git] / util / ego / cs / cs.h
1 /* $Id: cs.h,v 1.4 1994/06/24 10:21:43 ceriel Exp $ */
2 /*
3  * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
4  * See the copyright notice in the ACK home directory, in the file "Copyright".
5  */
6 typedef short           valnum;
7 typedef struct entity   *entity_p;
8 typedef struct avail    *avail_p;
9 typedef struct token    *token_p;
10 typedef struct occur    *occur_p;
11
12 struct token {
13         valnum  tk_vn;
14         offset  tk_size;
15         line_p  tk_lfirst;      /* Textually first instruction, involved
16                                  * in pushing this token.
17                                  */
18 };
19
20         /* We distinguish these entities. */
21 #define ENCONST         0
22 #define ENLOCAL         1
23 #define ENEXTERNAL      2
24 #define ENINDIR         3
25 #define ENOFFSETTED     4
26 #define ENALOCAL        5
27 #define ENAEXTERNAL     6
28 #define ENAOFFSETTED    7
29 #define ENALOCBASE      8
30 #define ENAARGBASE      9
31 #define ENPROC          10
32 #define ENFZER          11
33 #define ENARRELEM       12
34 #define ENLOCBASE       13
35 #define ENHEAPPTR       14
36 #define ENIGNMASK       15
37
38 struct entity {
39         valnum  en_vn;
40         bool    en_static;
41         byte    en_kind;                /* ENLOCAL, ENEXTERNAL, etc.    */
42         offset  en_size;
43         union {
44                 offset  en__val;        /* ENCONST.                     */
45                 offset  en__loc;        /* ENLOCAL, ENALOCAL.           */
46                 obj_p   en__ext;        /* ENEXTERNAL, ENAEXTERNAL.     */
47                 valnum  en__ind;        /* ENINDIR.                     */
48                 struct {
49                         valnum  en__base;
50                         offset  en__off;
51                 } en_offs;              /* ENOFFSETTED, ENAOFFSETTED.   */
52                 offset  en__levels;     /* ENALOCBASE, ENAARGBASE.      */
53                 proc_p  en__pro;        /* ENPROC.                      */
54                 struct {
55                         valnum  en__arbase;
56                         valnum  en__index;
57                         valnum  en__adesc;
58                 } en_arr;               /* ENARRELEM.                   */
59         } en_inf;
60 };
61
62         /* Macros to increase ease of use. */
63 #define en_val          en_inf.en__val
64 #define en_loc          en_inf.en__loc
65 #define en_ext          en_inf.en__ext
66 #define en_ind          en_inf.en__ind
67 #define en_base         en_inf.en_offs.en__base
68 #define en_off          en_inf.en_offs.en__off
69 #define en_levels       en_inf.en__levels
70 #define en_pro          en_inf.en__pro
71 #define en_arbase       en_inf.en_arr.en__arbase
72 #define en_index        en_inf.en_arr.en__index
73 #define en_adesc        en_inf.en_arr.en__adesc
74
75 struct occur {
76         line_p          oc_lfirst;  /* First instruction of expression. */
77         line_p          oc_llast;   /* Last one. */
78         bblock_p        oc_belongs; /* Basic block it belongs to. */
79 };
80             
81         /* We distinguish these groups of instructions. */
82 #define SIMPLE_LOAD     0
83 #define EXPENSIVE_LOAD  1
84 #define LOAD_ARRAY      2
85 #define STORE_DIRECT    3
86 #define STORE_INDIR     4
87 #define STORE_ARRAY     5
88 #define UNAIR_OP        6
89 #define BINAIR_OP       7
90 #define TERNAIR_OP      8
91 #define KILL_ENTITY     9
92 #define SIDE_EFFECTS    10
93 #define FIDDLE_STACK    11
94 #define IGNORE          12
95 #define HOPELESS        13
96 #define BBLOCK_END      14
97
98 struct avail {
99         avail_p av_before;      /* Ptr to earlier discovered expressions. */
100         byte    av_instr;       /* Operator instruction. */
101         offset  av_size;
102         line_p  av_found;       /* Line where expression is first found. */
103         lset    av_occurs;      /* Set of recurrences of expression. */
104         entity_p av_saveloc;    /* Local where result is put in. */
105         valnum  av_result;
106         union {
107                 valnum  av__operand;            /* EXPENSIVE_LOAD, UNAIR_OP. */
108                 struct {
109                         valnum  av__oleft;
110                         valnum  av__oright;
111                 } av_2;                         /* BINAIR_OP. */
112                 struct {
113                         valnum  av__ofirst;
114                         valnum  av__osecond;
115                         valnum  av__othird;
116                 } av_3;                         /* TERNAIR_OP. */
117         } av_o;
118 };
119
120         /* Macros to increase ease of use. */
121 #define av_operand      av_o.av__operand
122 #define av_oleft        av_o.av_2.av__oleft
123 #define av_oright       av_o.av_2.av__oright
124 #define av_ofirst       av_o.av_3.av__ofirst
125 #define av_osecond      av_o.av_3.av__osecond
126 #define av_othird       av_o.av_3.av__othird
127
128 extern int Scs; /* Number of optimizations found. */