Subversion Repositories tendra.SVN

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 7
Line -... Line 1...
-
 
1
/*
-
 
2
 * Copyright (c) 2002-2006 The TenDRA Project <http://www.tendra.org/>.
-
 
3
 * All rights reserved.
-
 
4
 *
-
 
5
 * Redistribution and use in source and binary forms, with or without
-
 
6
 * modification, are permitted provided that the following conditions are met:
-
 
7
 *
-
 
8
 * 1. Redistributions of source code must retain the above copyright notice,
-
 
9
 *    this list of conditions and the following disclaimer.
-
 
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
-
 
11
 *    this list of conditions and the following disclaimer in the documentation
-
 
12
 *    and/or other materials provided with the distribution.
-
 
13
 * 3. Neither the name of The TenDRA Project nor the names of its contributors
-
 
14
 *    may be used to endorse or promote products derived from this software
-
 
15
 *    without specific, prior written permission.
-
 
16
 *
-
 
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
-
 
18
 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-
 
19
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-
 
20
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
-
 
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-
 
22
 * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-
 
23
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-
 
24
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-
 
25
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-
 
26
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-
 
27
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
28
 *
-
 
29
 * $Id$
-
 
30
 */
1
/*
31
/*
2
    		 Crown Copyright (c) 1997
32
    		 Crown Copyright (c) 1997
3
 
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
Line 47... Line 77...
47
 *
77
 *
48
 * Revision 1.1  1995/04/06  10:44:05  currie
78
 * Revision 1.1  1995/04/06  10:44:05  currie
49
 * Initial revision
79
 * Initial revision
50
 *
80
 *
51
***********************************************************************/
81
***********************************************************************/
52
 
-
 
53
 
-
 
54
 
-
 
55
 
82
 
56
#include "config.h"
83
#include "config.h"
57
#include "common_types.h"
84
#include "common_types.h"
58
#include "installglob.h"
85
#include "installglob.h"
59
#include "exp.h"
86
#include "exp.h"
Line 78... Line 105...
78
/***********************************************************************
105
/***********************************************************************
79
  checkext examines the external definition e to see if it can be
106
  checkext examines the external definition e to see if it can be
80
  improved. It returns 1 if it makes a change, 0 otherwise.
107
  improved. It returns 1 if it makes a change, 0 otherwise.
81
 ***********************************************************************/
108
 ***********************************************************************/
82
 
109
 
83
void rec_inl
110
void
84
    PROTO_N ( (p) )
-
 
85
    PROTO_T ( exp p )
-
 
86
{
-
 
87
  if (pt(p) != nilexp)
-
 
88
    rec_inl(pt(p));
111
rec_inl(exp p)
89
 
-
 
90
  inline_exp (father (p));
-
 
91
  return;
-
 
92
}
-
 
93
 
-
 
94
void checkext
-
 
95
    PROTO_N ( (e) )
-
 
96
    PROTO_T ( exp e )
-
 
97
{
-
 
98
  exp def = son (e);
-
 
99
 
-
 
100
  if (no (e) == 0 || def == nilexp)
-
 
101
    return;			/* if it is not used or there is no
-
 
102
				   definition here, do nothing */
-
 
103
 
-
 
104
  if ((!PIC_code || brog(e)->dec_u.dec_val.dec_var == 0) && !isvar (e) &&
-
 
105
           (name (def) == val_tag || name (def) == real_tag
-
 
106
		|| name(def) == null_tag)) {
-
 
107
    while (pt (e) != nilexp) {
-
 
108
      /* substitute constants in */
-
 
109
      exp q = pt (e);
-
 
110
      if (bro(q) != nilexp) {/* can be nilexp for diags */
-
 
111
      	exp d = copy (def);
-
 
112
      	replace (q, d, nilexp);
-
 
113
      	kill_exp (q, q);
-
 
114
      }
-
 
115
      else pt(e) = pt(q);
-
 
116
    }
-
 
117
    return;
-
 
118
  };
-
 
119
 
-
 
120
  return;
-
 
121
}
-
 
122
 
-
 
123
 
-
 
124
void opt_all_exps
-
 
125
    PROTO_Z ()
-
 
126
{
112
{
-
 
113
	if (pt(p) != nilexp) {
-
 
114
		rec_inl(pt(p));
-
 
115
	}
-
 
116
 
-
 
117
	inline_exp(father(p));
-
 
118
	return;
-
 
119
}
-
 
120
 
-
 
121
 
-
 
122
void
-
 
123
checkext(exp e)
-
 
124
{
-
 
125
	exp def = son(e);
-
 
126
 
-
 
127
	/* if it is not used or there is no definition here, do nothing */
-
 
128
	if (no(e) == 0 || def == nilexp) {
-
 
129
		return;
-
 
130
	}
-
 
131
 
-
 
132
	if ((!PIC_code || brog(e)->dec_u.dec_val.dec_var == 0) && !isvar(e) &&
-
 
133
	    (name(def) == val_tag || name(def) == real_tag ||
-
 
134
	     name(def) == null_tag)) {
-
 
135
		while (pt(e) != nilexp) {
-
 
136
			/* substitute constants in */
-
 
137
			exp q = pt(e);
-
 
138
			if (bro(q) != nilexp) {
-
 
139
				/* can be nilexp for diags */
-
 
140
				exp d = copy(def);
-
 
141
				replace(q, d, nilexp);
-
 
142
				kill_exp(q, q);
-
 
143
			} else {
-
 
144
				pt(e) = pt(q);
-
 
145
			}
-
 
146
		}
-
 
147
		return;
-
 
148
	}
-
 
149
 
-
 
150
	return;
-
 
151
}
-
 
152
 
-
 
153
 
-
 
154
void
-
 
155
opt_all_exps(void)
-
 
156
{
127
  dec * my_def;
157
	dec *my_def;
128
 
158
 
129
#if 0
159
#if 0
130
  /* take constant expression out of loops */
160
	/* take constant expression out of loops */
131
  if (do_loopconsts)
161
	if (do_loopconsts)
132
    repeat_consts ();
162
		repeat_consts();
133
#endif
163
#endif
134
 
164
 
135
  if (do_unroll)
165
	if (do_unroll) {
136
    unroller();
166
		unroller();
-
 
167
	}
-
 
168
 
-
 
169
	my_def = top_def;
-
 
170
	while (my_def != (dec *)0) {
-
 
171
		exp crt_exp = my_def->dec_u.dec_val.dec_exp;
-
 
172
		checkext(crt_exp);
-
 
173
		glopt(my_def);
-
 
174
		my_def = my_def -> def_next;
-
 
175
	}
137
 
176
 
138
  my_def = top_def;
-
 
139
  while (my_def != (dec *) 0) {
-
 
140
    exp crt_exp = my_def -> dec_u.dec_val.dec_exp;
-
 
141
    checkext (crt_exp);
-
 
142
    glopt(my_def);
-
 
143
    my_def = my_def -> def_next;
-
 
144
  };
-
 
145
 
-
 
146
  normalised_inlining();
177
	normalised_inlining();
147
 
178
 
148
#if 1
179
#if 1
149
  /* take constant expression out of loops */
180
	/* take constant expression out of loops */
150
  if (do_loopconsts)
181
	if (do_loopconsts) {
151
    repeat_consts ();
182
		repeat_consts();
-
 
183
	}
152
#endif
184
#endif
153
 
185
 
154
  /* replace indexing on loop variable by incremented pointer access */
186
	/* replace indexing on loop variable by incremented pointer access */
155
  if (do_foralls)
187
	if (do_foralls) {
156
    forall_opt ();
188
		forall_opt();
157
 
189
	}
158
 
-
 
159
 
190
 
160
  return;
191
	return;
161
}
192
}