Subversion Repositories tendra.SVN

Rev

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

Rev 5 Rev 6
Line -... Line 1...
-
 
1
/*
-
 
2
 * Copyright (c) 2002-2005 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 61... Line 91...
61
#include "bitsmacs.h"
91
#include "bitsmacs.h"
62
#include "basicread.h"
92
#include "basicread.h"
63
#include "frames.h"
93
#include "frames.h"
64
#include "new_code.h"
94
#include "new_code.h"
65
 
95
 
66
extern exp father PROTO_S ((exp));
96
extern exp father(exp);
67
extern  procrec * procrecs;
97
extern  procrec * procrecs;
68
 
98
 
69
bool Has_fp = 0;
99
bool Has_fp = 0;
70
 
100
 
71
bool Has_tos = 0;
101
bool Has_tos = 0;
Line 79... Line 109...
79
 
109
 
80
long callee_size;
110
long callee_size;
81
 
111
 
82
 
112
 
83
void setframe_flags
113
void setframe_flags
84
    PROTO_N ( (e, leaf) )
-
 
85
    PROTO_T ( exp e X bool leaf )
114
(exp e, bool leaf)
86
{
115
{
87
      /* e is proc_tag */
116
      /* e is proc_tag */
88
 
117
 
89
      No_S = (!leaf && (name(e)!=general_proc_tag || !proc_has_nolongj(e))
118
      No_S = (!leaf && (name(e)!=general_proc_tag || !proc_has_nolongj(e))
90
		&& proc_uses_crt_env(e)
119
		&& proc_uses_crt_env(e)
91
      			&& proc_has_lv(e) );
120
      			&& proc_has_lv(e));
92
      Has_fp = (No_S || proc_has_alloca(e) || name(e) == general_proc_tag);
121
      Has_fp = (No_S || proc_has_alloca(e) || name(e) == general_proc_tag);
93
 
122
 
94
      Has_tos = (No_S && proc_has_alloca(e));
123
      Has_tos = (No_S && proc_has_alloca(e));
95
      Has_vcallees = (name(e)==general_proc_tag && proc_has_vcallees(e));
124
      Has_vcallees = (name(e) ==general_proc_tag && proc_has_vcallees(e));
96
      Has_no_vcallers = (name(e) == proc_tag || !proc_has_vcallers(e));
125
      Has_no_vcallers = (name(e) == proc_tag || !proc_has_vcallers(e));
97
 
126
 
98
#ifdef Try_No_S
127
#ifdef Try_No_S
99
	No_S = 1;
128
	No_S = 1;
100
#endif
129
#endif
Line 105... Line 134...
105
	Has_tos = 1;
134
	Has_tos = 1;
106
#endif
135
#endif
107
}
136
}
108
 
137
 
109
void setframe_info
138
void setframe_info
110
    PROTO_N ( (e) )
-
 
111
    PROTO_T ( exp e )
139
(exp e)
112
{
140
{
113
	procrec * pr = & procrecs[no(e)];
141
	procrec * pr = & procrecs[no(e)];
114
	needs * ndpr = & pr->needsproc;
142
	needs * ndpr = & pr->needsproc;
115
	spacereq *sppr = & pr->spacereqproc;
143
	spacereq *sppr = & pr->spacereqproc;
116
	long pprops = (ndpr->propsneeds);
144
	long pprops = (ndpr->propsneeds);
Line 126... Line 154...
126
	ma = (ma + 32) & ~63;	/* put on 64 bit boundaries */
154
	ma = (ma + 32) & ~63;	/* put on 64 bit boundaries */
127
 
155
 
128
	pr->max_args = ma;
156
	pr->max_args = ma;
129
 
157
 
130
	pr->fixdump = (No_S)?0x40ff0000 :((sppr->fixdump) << 16);
158
	pr->fixdump = (No_S)?0x40ff0000 :((sppr->fixdump) << 16);
131
	if (!leaf ) {
159
	if (!leaf) {
132
	  pr->fixdump |= 1 << 31;
160
	  pr->fixdump |= 1 << 31;
133
	}	/* space for link */
161
	}	/* space for link */
134
 
162
 
135
        if (Has_fp) {
163
        if (Has_fp) {
136
		pr->fixdump &= ~(1<<30);
164
		pr->fixdump &= ~(1<<30);
137
		/* frame pointer will be preserved by call or prelude ?!*/
165
		/* frame pointer will be preserved by call or prelude ?!*/
138
        }
166
        }
139
 
167
 
140
	pr->floatdump = (No_S)?0xffc00000 :((sppr->fltdump) << 20);
168
	pr->floatdump = (No_S)?0xffc00000 :((sppr->fltdump) << 20);
141
 
169
 
142
	nofixdump = bitsin (pr->fixdump);
170
	nofixdump = bitsin(pr->fixdump);
143
	/* no of fixed s-regs to be dumped */
171
	/* no of fixed s-regs to be dumped */
144
		ma += (nofixdump + bitsin(pr->floatdump))*32;
172
		ma += (nofixdump + bitsin(pr->floatdump))*32;
145
	ma = (ma + 32) & ~63;
173
	ma = (ma + 32) & ~63;
146
	/* include space for dumped s-regs */
174
	/* include space for dumped s-regs */
147
 
175
 
Line 158... Line 186...
158
	/* the byte displacement from $sp to dump float s-regs... */
186
	/* the byte displacement from $sp to dump float s-regs... */
159
 
187
 
160
}
188
}
161
 
189
 
162
long frame_offset
190
long frame_offset
163
    PROTO_N ( (id) )
-
 
164
    PROTO_T ( exp id )
191
(exp id)
165
{
192
{
166
	exp p;
193
	exp p;
167
	procrec * pr;
194
	procrec * pr;
168
	int  x = no (id);
195
	int  x = no(id);
169
    	int  b = x & 0x3f;
196
    	int  b = x & 0x3f;
170
    	int lo; int fs; int cs;
197
    	int lo; int fs; int cs;
171
 
198
 
172
	Assert(name(id) == ident_tag);
199
	Assert(name(id) == ident_tag);
173
	for (p = father(id); (name(p)!=proc_tag && name(p) !=
200
	for (p = father(id);(name(p)!=proc_tag && name(p)!=
174
		general_proc_tag); p = father(p));
201
		general_proc_tag); p = father(p));
175
	pr = & procrecs[no(p)];
202
	pr = & procrecs[no(p)];
176
 
203
 
177
	lo = pr->locals_offset>>3;
204
	lo = pr->locals_offset>>3;
178
	fs = pr->frame_size>>3;
205
	fs = pr->frame_size>>3;
179
	cs = pr->callee_size>>3;
206
	cs = pr->callee_size>>3;
180
 
207
 
181
 
208
 
182
	if (b==29 || b == 30) {
209
	if (b==29 || b == 30) {
183
		return ( ((x - b) >> 4) +lo -(fs+cs));
210
		return(((x - b) >> 4) +lo - (fs+cs));
184
	}
211
	}
185
	else
212
	else
186
	if (b==local_reg) {
213
	if (b==local_reg) {
187
	 	return ( ((x - b) >> 4) +lo -fs);
214
	 	return(((x - b) >> 4) +lo -fs);
188
	}
215
	}
189
	else {
216
	else {
190
		/* may not be allocated yet */
217
		/* may not be allocated yet */
191
 
218
 
192
           bool Has_vcallees = (name(p)==general_proc_tag &&
219
           bool Has_vcallees = (name(p) ==general_proc_tag &&
193
           					proc_has_vcallees(p));
220
           					proc_has_vcallees(p));
194
           int n = no(son(id))>>3;
221
           int n = no(son(id)) >>3;
195
           if (isparam(id) && name(son(id))!=formal_callee_tag) {
222
           if (isparam(id) && name(son(id))!=formal_callee_tag) {
196
           	return n;
223
           	return n;
197
           }
224
           }
198
           else
225
           else
199
	   if (isparam(id) && name(son(id))==formal_callee_tag) {
226
	   if (isparam(id) && name(son(id)) ==formal_callee_tag) {
200
           	return  ((Has_vcallees)? n:(cs-n));
227
           	return ((Has_vcallees)? n:(cs-n));
201
           }
228
           }
202
           else { failer("Wrong env_offset"); return 0; }
229
           else { failer("Wrong env_offset"); return 0; }
203
       }
230
       }
204
}
231
}