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:56:05 $
34
$Revision: 1.1.1.1 $
35
$Log: frames.c,v $
36
 * Revision 1.1.1.1  1998/01/17  15:56:05  release
37
 * First version to be checked into rolling release.
38
 *
39
 * Revision 1.6  1995/09/26  09:05:02  currie
40
 * Has_no_vcallers condition wrong
41
 *
42
 * Revision 1.4  1995/09/12  10:59:21  currie
43
 * gcc pedanttry
44
 *
45
 * Revision 1.3  1995/06/28  12:15:22  currie
46
 * New make_stack_limit etc
47
 *
48
 * Revision 1.2  1995/05/05  08:12:52  currie
49
 * initial_value + signtures
50
 *
51
 * Revision 1.1  1995/04/13  09:08:06  currie
52
 * Initial revision
53
 *
54
***********************************************************************/
55
 
56
#include "config.h"
57
#include "common_types.h"
58
#include "procrectypes.h"
59
#include "expmacs.h"
60
#include "tags.h"
61
#include "bitsmacs.h"
62
#include "basicread.h"
63
#include "frames.h"
64
#include "new_code.h"
65
 
66
extern exp father PROTO_S ((exp));
67
extern  procrec * procrecs;
68
 
69
bool Has_fp = 0;
70
 
71
bool Has_tos = 0;
72
 
73
bool No_S = 0;
74
 
75
bool Has_vcallees = 0;
76
bool Has_no_vcallers = 0;
77
 
78
int local_reg = 23;
79
 
80
long callee_size;
81
 
82
 
83
void setframe_flags
84
    PROTO_N ( (e, leaf) )
85
    PROTO_T ( exp e X bool leaf )
86
{
87
      /* e is proc_tag */
88
 
89
      No_S = (!leaf && (name(e)!=general_proc_tag || !proc_has_nolongj(e))
90
		&& proc_uses_crt_env(e)
91
      			&& proc_has_lv(e) );
92
      Has_fp = (No_S || proc_has_alloca(e) || name(e) == general_proc_tag);
93
 
94
      Has_tos = (No_S && proc_has_alloca(e));
95
      Has_vcallees = (name(e)==general_proc_tag && proc_has_vcallees(e));
96
      Has_no_vcallers = (name(e) == proc_tag || !proc_has_vcallers(e));
97
 
98
#ifdef Try_No_S
99
	No_S = 1;
100
#endif
101
#ifdef Try_Has_fp
102
	Has_fp = !leaf;
103
#endif
104
#ifdef Try_Has_tos
105
	Has_tos = 1;
106
#endif
107
}
108
 
109
void setframe_info
110
    PROTO_N ( (e) )
111
    PROTO_T ( exp e )
112
{
113
	procrec * pr = & procrecs[no(e)];
114
	needs * ndpr = & pr->needsproc;
115
	spacereq *sppr = & pr->spacereqproc;
116
	long pprops = (ndpr->propsneeds);
117
	bool leaf = (pprops & anyproccall) == 0;
118
	long ma = ndpr->maxargs;	/* maxargs of proc body in bits */
119
	long st = sppr->stack;	/* space for locals in bits */
120
	int nofixdump;
121
 
122
	setframe_flags(e, leaf);
123
 
124
	if (!leaf && ma <128) ma = 128;	/* required by printf etc!!?? */
125
	st = (st + 32) & ~63;
126
	ma = (ma + 32) & ~63;	/* put on 64 bit boundaries */
127
 
128
	pr->max_args = ma;
129
 
130
	pr->fixdump = (No_S)?0x40ff0000 :((sppr->fixdump) << 16);
131
	if (!leaf ) {
132
	  pr->fixdump |= 1 << 31;
133
	}	/* space for link */
134
 
135
        if (Has_fp) {
136
		pr->fixdump &= ~(1<<30);
137
		/* frame pointer will be preserved by call or prelude ?!*/
138
        }
139
 
140
	pr->floatdump = (No_S)?0xffc00000 :((sppr->fltdump) << 20);
141
 
142
	nofixdump = bitsin (pr->fixdump);
143
	/* no of fixed s-regs to be dumped */
144
		ma += (nofixdump + bitsin(pr->floatdump))*32;
145
	ma = (ma + 32) & ~63;
146
	/* include space for dumped s-regs */
147
 
148
	pr->locals_offset = ma;	/* the offset to first local in bits from
149
				   $sp */
150
	pr->frame_size = ma + st;	/* the frame size for this proc in bits */
151
 
152
 
153
	st = pr->frame_size >> 3;
154
	ma = ma >> 3;
155
	pr->dumpstart = ma;		/* the byte displacement from $sp to dump
156
				   fixed s-regs */
157
	pr->fldumpstart = ma - 4 * nofixdump;
158
	/* the byte displacement from $sp to dump float s-regs... */
159
 
160
}
161
 
162
long frame_offset
163
    PROTO_N ( (id) )
164
    PROTO_T ( exp id )
165
{
166
	exp p;
167
	procrec * pr;
168
	int  x = no (id);
169
    	int  b = x & 0x3f;
170
    	int lo; int fs; int cs;
171
 
172
	Assert(name(id) == ident_tag);
173
	for (p = father(id); (name(p)!=proc_tag && name(p) !=
174
		general_proc_tag); p = father(p));
175
	pr = & procrecs[no(p)];
176
 
177
	lo = pr->locals_offset>>3;
178
	fs = pr->frame_size>>3;
179
	cs = pr->callee_size>>3;
180
 
181
 
182
	if (b==29 || b == 30) {
183
		return ( ((x - b) >> 4) +lo -(fs+cs));
184
	}
185
	else
186
	if (b==local_reg) {
187
	 	return ( ((x - b) >> 4) +lo -fs);
188
	}
189
	else {
190
		/* may not be allocated yet */
191
 
192
           bool Has_vcallees = (name(p)==general_proc_tag &&
193
           					proc_has_vcallees(p));
194
           int n = no(son(id))>>3;
195
           if (isparam(id) && name(son(id))!=formal_callee_tag) {
196
           	return n;
197
           }
198
           else
199
	   if (isparam(id) && name(son(id))==formal_callee_tag) {
200
           	return  ((Has_vcallees)? n:(cs-n));
201
           }
202
           else { failer("Wrong env_offset"); return 0; }
203
       }
204
}