Subversion Repositories tendra.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
2
    		 Crown Copyright (c) 1997
3
 
4
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
12
 
13
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
15
 
16
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
19
 
20
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
22
        these conditions;
23
 
24
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
27
        it may be put.
28
*/
29
 
30
 
31
/**********************************************************************
32
$Author: release $
33
$Date: 1998/01/17 15:55:47 $
34
$Revision: 1.1.1.1 $
35
$Log: global_opt.c,v $
36
 * Revision 1.1.1.1  1998/01/17  15:55:47  release
37
 * First version to be checked into rolling release.
38
 *
39
 * Revision 1.4  1995/09/27  12:39:23  currie
40
 * Peters PIC code
41
 *
42
 * Revision 1.3  1995/09/19  11:51:45  currie
43
 * Changed name of init fn +gcc static bug
44
 *
45
 * Revision 1.2  1995/06/09  08:37:40  currie
46
 * loose name tag with diags
47
 *
48
 * Revision 1.1  1995/04/06  10:44:05  currie
49
 * Initial revision
50
 *
51
***********************************************************************/
52
 
53
 
54
 
55
 
56
#include "config.h"
57
#include "common_types.h"
58
#include "installglob.h"
59
#include "exp.h"
60
#include "expmacs.h"
61
#include "tags.h"
62
#include "check.h"
63
#include "flags.h"
64
#include "check_id.h"
65
#include "const.h"
66
#include "foralls.h"
67
#include "shapemacs.h"
68
#include "glopt.h"
69
#include "inline.h"
70
#include "global_opt.h"
71
#include "inl_norm.h"
72
#include "unroll.h"
73
 
74
 
75
/* PROCEDURES */
76
 
77
 
78
/***********************************************************************
79
  checkext examines the external definition e to see if it can be
80
  improved. It returns 1 if it makes a change, 0 otherwise.
81
 ***********************************************************************/
82
 
83
void rec_inl
84
    PROTO_N ( (p) )
85
    PROTO_T ( exp p )
86
{
87
  if (pt(p) != nilexp)
88
    rec_inl(pt(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
{
127
  dec * my_def;
128
 
129
#if 0
130
  /* take constant expression out of loops */
131
  if (do_loopconsts)
132
    repeat_consts ();
133
#endif
134
 
135
  if (do_unroll)
136
    unroller();
137
 
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();
147
 
148
#if 1
149
  /* take constant expression out of loops */
150
  if (do_loopconsts)
151
    repeat_consts ();
152
#endif
153
 
154
  /* replace indexing on loop variable by incremented pointer access */
155
  if (do_foralls)
156
    forall_opt ();
157
 
158
 
159
 
160
  return;
161
}