1 /* $Id: types.h,v 1.8 1994/06/24 10:31:04 ceriel Exp $ */
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".
6 /* I N T E R N A L D A T A S T R U C T U R E S O F E G O */
9 /* This file contains the definitions of the global data types.
17 #define IDL 256 /* maximum identifier length */
22 typedef struct argbytes argb_t;
27 typedef short proc_id;
28 typedef short dblock_id;
29 typedef short block_id;
30 typedef short loop_id;
34 typedef struct dblock *dblock_p;
35 typedef struct obj *obj_p;
36 typedef struct proc *proc_p;
37 typedef struct loop *loop_p;
38 typedef struct change *change_p;
39 typedef struct use *use_p;
40 typedef struct bblock *bblock_p;
41 typedef struct line *line_p;
42 typedef struct arg *arg_p;
43 typedef struct argbytes *argb_p;
44 typedef struct elemholder *elem_p;
45 typedef struct elemholder *lset;
46 typedef struct bitvector *cset;
47 typedef elem_p Lindex;
49 typedef char *Lelem_t;
50 typedef short Celem_t;
52 typedef union pext_t *pext_p;
53 typedef union bext_t *bext_p;
54 typedef union lpext_t *lpext_p;
57 typedef struct call *call_p;
58 typedef struct formal *formal_p;
60 /* Used-Definition Analysis */
61 typedef struct local *local_p;
63 typedef struct cond_tab *cond_p;
70 /* A datablock is a block of global data, declared by means of
71 * a hol, bss, con or rom pseudo. The declaration may be in a file
72 * that is inaccessible to EGO, in which case the pseudo is unknown.
73 * Successive rom or con pseudos that are garanteed to be in the
74 * same fragment (according to the EM definition) share the
75 * same fragment number.
85 /* The following constants are used by the debugging tools: */
87 #define D_LAST DUNKNOWN
91 dblock_id d_id; /* unique integer */
92 byte d_pseudo; /* one of DHOL,DBSS,DROM,DCON,DUNKNOWN */
93 offset d_size; /* # bytes, -1 if unknown */
94 obj_p d_objlist; /* list of objects of the data block */
95 byte d_flags1; /* see below */
96 byte d_flags2; /* free to be used by phases */
97 arg_p d_values; /* values, in case of ROM */
98 short d_fragmnr; /* fragment number */
99 dblock_p d_next; /* link to next block */
103 #define DF_EXTERNAL 01 /* Is name visible outside its module? */
107 /* An object is a row of successive bytes in one datablock
108 * that are considered to be a whole. E.g. scalar variables,
109 * arrays, I/O buffers etc. are objects.
113 offset o_off; /* offset within the block */
114 offset o_size; /* size of the object, 0 if not known */
115 obj_id o_id; /* unique integer */
116 dblock_p o_dblock; /* backlink to data block */
117 short o_globnr; /* global variable number */
118 obj_p o_next; /* link */
125 proc_id p_id; /* unique integer */
126 short p_nrlabels; /* #instruction labels in the proc */
127 offset p_localbytes; /* #bytes for locals */
128 offset p_nrformals; /* #bytes for formals */
129 byte p_flags1; /* see below */
130 byte p_flags2; /* free to be used by phases */
131 bblock_p p_start; /* pointer to first basic block */
132 cset p_calling; /* set of all procs called by this one */
133 lset p_loops; /* information about loops */
134 change_p p_change; /* variables changed by this proc */
135 use_p p_use; /* variables used by this proc */
136 pext_p p_extend; /* pointer to any further information */
137 proc_p p_next; /* link */
143 call_p p_cals; /* candidate calls for in line expansion */
144 short p_size; /* length of proc (EM-instrs or bytes) */
145 formal_p p_formals; /* description of formals */
146 short p_nrcalled; /* # times proc is called (varying) */
147 long p_ccaddr; /* address of calcnt info on disk */
148 long p_laddr; /* address in EM-text file on disk */
149 short p_orglabels; /* original #labels before substitution */
150 offset p_orglocals; /* original #bytes for locals */
154 #define PF_EXTERNAL 01 /* proc is externally visible */
155 #define PF_BODYSEEN 02 /* body of proc is available as EM text */
156 #define PF_CALUNKNOWN 04 /* proc calls an unavailable procedure */
157 #define PF_ENVIRON 010 /* proc does a lxa or lxl */
158 #define PF_LPI 020 /* proc may be called indirect */
159 #define PF_CALINLOOP 040 /* proc ever called in a loop? (transitively) */
160 #define PF_GTO 0100 /* proc may be entered via GTO instruction */
162 #define CALLED_IN_LOOP(p) p->p_flags1 |= PF_CALINLOOP
163 #define IS_CALLED_IN_LOOP(p) (p->p_flags1 & PF_CALINLOOP)
164 #define IS_ENTERED_WITH_GTO(p) (p->p_flags1 & PF_GTO)
165 #define ENTERED_WITH_GTO(p) p->p_flags1 |= PF_GTO
166 #define BODY_KNOWN(p) (p->p_flags1 & (byte) PF_BODYSEEN)
172 loop_id lp_id; /* unique integer */
173 short lp_level; /* nesting level, 0=outermost loop,
174 * 1=loop within loop etc. */
175 bblock_p lp_entry; /* unique entry block of loop */
176 bblock_p lp_end; /* tail of back edge of natural loop */
177 lpext_p lp_extend; /* pointer to any further information */
189 lset lpx_blocks; /* basic blocks constituting the loop */
190 bblock_p lpx_header; /* header block, 0 if no one allocated yet */
191 bool lpx_done; /* TRUE if we've processed this loop */
192 line_p lpx_instr; /* current last instruction in header block*/
195 lset lpx_blocks; /* basic blocks constituting the loop */
196 bblock_p lpx_header; /* header block, 0 if no one allocated yet */
200 /* CHANGED/USED VARIABLES INFORMATION */
204 cset c_ext; /* external variables changed */
205 short c_flags; /* see below */
209 short u_flags; /* see below */
216 #define CHANGE_INDIR(p) (p->p_change->c_flags & CF_INDIR)
221 /* There are 2 set representations:
222 * - long (lset), which is essentially a list
223 * - compact (cset), which is essentially a bitvector
228 char *e_elem; /* pointer to the element */
229 elem_p e_next; /* link */
233 short v_size; /* # significant bits */
234 int v_bits[DYNAMIC];/* a row of bits */
242 /* Note that the b_succ and b_pred fields constitute the
248 block_id b_id; /* unique integer */
249 line_p b_start; /* pointer to first instruction */
250 lset b_succ; /* set of successor blocks */
251 lset b_pred; /* set of predecessor blocks */
252 bblock_p b_idom; /* immediate dominator */
253 lset b_loops; /* set of loops it is in */
254 short b_flags; /* see below */
255 bext_p b_extend; /* pointer to any further information */
256 bblock_p b_next; /* link to textually next block */
262 short bx_semi; /* dfs number of semi-dominator */
263 bblock_p bx_parent; /* parent in dfs spanning tree */
264 lset bx_bucket; /* set of vertices whose sdom is b */
265 bblock_p bx_ancestor; /* ancestor of b in forest, */
266 bblock_p bx_label; /* used by link/eval */
269 cset bx_gen; /* definition generated in b */
270 cset bx_kill; /* defs. outside b killed by b */
271 cset bx_in; /* defs. reaching beginning of b */
272 cset bx_out; /* defs. reaching end of b */
273 cset bx_cgen; /* generated copies */
274 cset bx_ckill; /* killed copies */
275 cset bx_cin; /* copies reaching begin of b */
276 cset bx_cout; /* copies reaching end of b */
277 cset bx_chgvars; /* variables changed by b */
280 cset bx_use; /* variables used before being defined */
281 cset bx_def; /* variables defined before being used */
282 cset bx_lin; /* variables live at entry of b */
283 cset bx_lout; /* variables live at exit of b */
286 short bx_begin; /* number of first instruction of block */
287 short bx_end; /* number of last instruction of block */
295 #define IS_STRONG(b) (b->b_flags&BF_STRONG)
296 #define IS_FIRM(b) (b->b_flags&BF_FIRM)
299 /* EM INSTRUCTIONS */
301 /* Kinds of operand types (l_optype field) */
312 /* The following constants are used by the debugging tools: */
313 #define OP_FIRST OPNO
314 #define OP_LAST OPLIST
320 line_p l_next; /* link */
321 byte l_instr; /* instruction */
322 byte l_optype; /* kind of operand, used as tag */
323 line_p l_prev; /* backlink to previous instruction */
325 short la_short; /* short: LOC 5 */
326 offset la_offset; /* offset: LDC 20 */
327 lab_id la_instrlab; /* label: BRA *10 */
328 obj_p la_obj; /* object: LOE X+2 */
329 proc_p la_proc; /* proc: CAL F3 */
330 arg_p la_arg; /* arguments: HOL 10,0,0 */
338 /* String representation of a constant, partitioned into
339 * pieces of NARGBYTES bytes.
343 #define ARGINSTRLAB 1
356 char ab_contents[NARGBYTES];
361 arg_p a_next; /* link */
362 short a_type; /* kind of argument */
364 offset a_offset; /* offset */
365 lab_id a_instrlab; /* instruction label */
366 proc_p a_proc; /* procedure */
367 obj_p a_obj; /* object */
368 argb_t a_string; /* string */
369 struct { /* int/unsigned/float constant */
370 short ac_length; /* size in bytes */
371 argb_t ac_con; /* its string repres. */
378 /* Macros to increase readability: */
380 #define INSTR(lnp) (lnp->l_instr & BMASK)
381 #define TYPE(lnp) lnp->l_optype
382 #define PREV(lnp) lnp->l_prev
383 #define SHORT(lnp) lnp->l_a.la_short
384 #define OFFSET(lnp) lnp->l_a.la_offset
385 #define INSTRLAB(lnp) lnp->l_a.la_instrlab
386 #define OBJ(lnp) lnp->l_a.la_obj
387 #define PROC(lnp) lnp->l_a.la_proc
388 #define ARG(lnp) lnp->l_a.la_arg
391 /* Data structures for Use-Definition and Live-Dead Analysis */
394 offset lc_off; /* offset of local in stackframe */
395 short lc_size; /* size of local in bytes */
396 short lc_flags; /* see below */
397 offset lc_score; /* score in register message, if regvar */
398 local_p lc_next; /* link, only used when building the list */
401 /* values of lc_flags */
404 /* Set when no ud-info for this local is maintained, e.g. when it is
405 * overlapped by another local.
407 #define LCF_REG 02 /* register variable */
408 #define LCF_LIVE 04 /* use by live-dead message generation */
412 short mc_cond; /* Denotes a condition e.g. FITBYTE */
413 short mc_tval; /* value for time optimization */
414 short mc_sval; /* value for space optimization */
415 short mc_dummy; /* allignment */