1 /* $Id: sr_aux.c,v 1.5 1994/06/24 10:32: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 /* S T R E N G T H R E D U C T I O N
15 #include "../share/types.h"
17 #include "../share/debug.h"
18 #include "../share/global.h"
19 #include "../share/lset.h"
20 #include "../share/aux.h"
24 #define INSIDE_LOOP(b,lp) Lis_elem(b,lp->LP_BLOCKS)
27 bool is_loopconst(lnp,vars)
33 assert(TYPE(lnp) == OPSHORT || TYPE(lnp) == OPOFFSET);
34 if (!is_regvar(off_set(lnp))) return FALSE;
35 for (i = Lfirst(vars); i != (Lindex) 0; i = Lnext(i,vars)) {
36 if (same_local(Lelem(i),lnp)) {
37 return FALSE; /* variable was changed */
44 bool is_caddress(lnp,vars)
46 lset vars; /* variables changed in loop */
48 /* See if lnp is a single instruction (i.e. without arguments)
49 * that pushes a loop-invariant entity of size pointer-size (ps)
53 if (lnp == (line_p) 0) return FALSE;
59 return ps == ws && is_loopconst(lnp,vars);
61 return ps == 2*ws && is_loopconst(lnp,vars);
70 STATIC arg_p find_arg(n,list)
74 /* Find the n-th element of the list */
77 if (list == (arg_p) 0) break;
87 /* lnp is an instruction that loads the address of an array
88 * descriptor. Find the size of the elements of the array.
89 * If this size cannot be determined (e.g. the descriptor may
90 * not be in a rom) then return UNKNOWN_SIZE.
96 assert (lnp != (line_p) 0);
97 if (INSTR(lnp) == op_lae) {
98 d = OBJ(lnp)->o_dblock; /* datablock */
99 if (d->d_pseudo == DROM &&
100 (v = find_arg(3,d->d_values)) != (arg_p) 0 &&
101 v->a_type == ARGOFF) {
102 return (int) v->a_a.a_offset;
110 concatenate(list1,list2)
113 /* Append list2 to the end of list1. list1 may not be empty. */
117 assert(list1 != (line_p) 0);
118 for (l =list1; l->l_next != (line_p) 0; l = l->l_next);