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 |
|
|
|
33 |
/*
|
|
|
34 |
VERSION INFORMATION
|
|
|
35 |
===================
|
|
|
36 |
|
|
|
37 |
--------------------------------------------------------------------------
|
|
|
38 |
$Header: /u/g/release/CVSROOT/Source/src/installers/sparc/common/getregs.c,v 1.1.1.1 1998/01/17 15:55:54 release Exp $
|
|
|
39 |
--------------------------------------------------------------------------
|
|
|
40 |
$Log: getregs.c,v $
|
|
|
41 |
* Revision 1.1.1.1 1998/01/17 15:55:54 release
|
|
|
42 |
* First version to be checked into rolling release.
|
|
|
43 |
*
|
|
|
44 |
* Revision 1.4 1997/08/23 13:53:43 pwe
|
|
|
45 |
* initial ANDF-DE
|
|
|
46 |
*
|
|
|
47 |
* Revision 1.3 1996/09/18 12:03:33 pwe
|
|
|
48 |
* fixed PIC_code
|
|
|
49 |
*
|
|
|
50 |
* Revision 1.2 1995/05/26 12:58:14 john
|
|
|
51 |
* Reformatting
|
|
|
52 |
*
|
|
|
53 |
* Revision 1.1.1.1 1995/03/13 10:18:36 john
|
|
|
54 |
* Entered into CVS
|
|
|
55 |
*
|
|
|
56 |
* Revision 1.2 1994/07/07 16:11:33 djch
|
|
|
57 |
* Jul94 tape
|
|
|
58 |
*
|
|
|
59 |
* Revision 1.2 1994/07/07 16:11:33 djch
|
|
|
60 |
* Jul94 tape
|
|
|
61 |
*
|
|
|
62 |
* Revision 1.1 1994/05/03 14:49:35 djch
|
|
|
63 |
* Initial revision
|
|
|
64 |
*
|
|
|
65 |
* Revision 1.3 93/08/27 11:25:51 11:25:51 ra (Robert Andrews)
|
|
|
66 |
* Tell lint that settempregs doesn't use its argument.
|
|
|
67 |
*
|
|
|
68 |
* Revision 1.2 93/07/12 15:13:35 15:13:35 ra (Robert Andrews)
|
|
|
69 |
* Reformatted.
|
|
|
70 |
*
|
|
|
71 |
* Revision 1.1 93/06/24 14:58:20 14:58:20 ra (Robert Andrews)
|
|
|
72 |
* Initial revision
|
|
|
73 |
*
|
|
|
74 |
--------------------------------------------------------------------------
|
|
|
75 |
*/
|
|
|
76 |
|
|
|
77 |
|
|
|
78 |
#define SPARCTRANS_CODE
|
|
|
79 |
/*
|
|
|
80 |
Routines for choosing temporary registers.
|
|
|
81 |
*/
|
|
|
82 |
#include "config.h"
|
|
|
83 |
#include "common_types.h"
|
|
|
84 |
#include "myassert.h"
|
|
|
85 |
#include "regmacs.h"
|
|
|
86 |
#include "proctypes.h"
|
|
|
87 |
#include "exptypes.h"
|
|
|
88 |
#include "procrec.h"
|
|
|
89 |
#include "expmacs.h"
|
|
|
90 |
#include "exp.h"
|
|
|
91 |
#include "addrtypes.h"
|
|
|
92 |
#include "regexps.h"
|
|
|
93 |
#include "tags.h"
|
|
|
94 |
#include "expmacs.h"
|
|
|
95 |
#include "bitsmacs.h"
|
|
|
96 |
#include "getregs.h"
|
|
|
97 |
|
|
|
98 |
|
|
|
99 |
/*
|
|
|
100 |
THE NEXT FIXED REGISTER TO BE ALLOCATED
|
|
|
101 |
*/
|
|
|
102 |
|
|
|
103 |
static int currentfix = R_FIRST ;
|
|
|
104 |
static long choosefix = RMASK ( R_FIRST ) ;
|
|
|
105 |
|
|
|
106 |
|
|
|
107 |
/*
|
|
|
108 |
THE NEXT FLOATING REGISTER TO BE ALLOCATED
|
|
|
109 |
*/
|
|
|
110 |
|
|
|
111 |
static int currentfloat = R_FLT_FIRST ;
|
|
|
112 |
static long choosefloat = RMASK ( R_FLT_FIRST ) ;
|
|
|
113 |
|
|
|
114 |
|
|
|
115 |
/*
|
|
|
116 |
INITIALIZE REGISTER ALLOCATION VARIABLES
|
|
|
117 |
|
|
|
118 |
This is called at the start of each procedure.
|
|
|
119 |
*/
|
|
|
120 |
|
|
|
121 |
void settempregs
|
|
|
122 |
PROTO_N ( ( tg ) )
|
|
|
123 |
PROTO_T ( exp tg ){
|
|
|
124 |
currentfix = R_O0 ;
|
|
|
125 |
choosefix = RMASK ( currentfix ) ;
|
|
|
126 |
currentfloat = 1 ;
|
|
|
127 |
choosefloat = RMASK ( currentfloat ) ;
|
|
|
128 |
return ;
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
|
|
|
132 |
/*
|
|
|
133 |
GET THE NEXT FREE TEMPORARY FIXED REGISTER
|
|
|
134 |
|
|
|
135 |
The argument fixed gives the bitmask of all the unavailable registers.
|
|
|
136 |
Avoid R_O7 until last, so it's available for PIC_code case.
|
|
|
137 |
*/
|
|
|
138 |
|
|
|
139 |
int getreg
|
|
|
140 |
PROTO_N ( ( fixed ) )
|
|
|
141 |
PROTO_T ( long fixed ){
|
|
|
142 |
int reg = -1 ;
|
|
|
143 |
long start = choosefix ;
|
|
|
144 |
assert ( choosefix == RMASK ( currentfix ) ) ;
|
|
|
145 |
for ( ; ; ) {
|
|
|
146 |
/* Check if register is free */
|
|
|
147 |
if ( ( choosefix & fixed ) == 0 && currentfix != R_O7) reg = currentfix ;
|
|
|
148 |
|
|
|
149 |
/* Work out the next register (cyclic) */
|
|
|
150 |
if ( currentfix == R_LAST ) {
|
|
|
151 |
currentfix = R_FIRST ;
|
|
|
152 |
choosefix = RMASK ( R_FIRST ) ;
|
|
|
153 |
}
|
|
|
154 |
else {
|
|
|
155 |
currentfix++ ;
|
|
|
156 |
choosefix = choosefix << 1 ;
|
|
|
157 |
}
|
|
|
158 |
if ( reg != -1 ) {
|
|
|
159 |
/* Register found */
|
|
|
160 |
assert ( IS_TREG ( reg ) ) ;
|
|
|
161 |
assert ( reg != R_G0 ) ; /* %g0 is always 0 */
|
|
|
162 |
assert ( reg != R_G1 ) ; /* %g1 is used for other purposes */
|
|
|
163 |
return ( reg ) ;
|
|
|
164 |
}
|
|
|
165 |
if ( choosefix == start ) {
|
|
|
166 |
/* Back where we started */
|
|
|
167 |
if ( (fixed & RMASK (R_O7)) == 0 ) {
|
|
|
168 |
return (R_O7);
|
|
|
169 |
}
|
|
|
170 |
fail ( "Can't allocate temporary register" ) ;
|
|
|
171 |
return ( R_G1 ) ;
|
|
|
172 |
}
|
|
|
173 |
}
|
|
|
174 |
/* NOT REACHED */
|
|
|
175 |
}
|
|
|
176 |
|
|
|
177 |
|
|
|
178 |
/*
|
|
|
179 |
GET THE NEXT FREE TEMPORARY FLOATING REGISTER
|
|
|
180 |
|
|
|
181 |
The argument fl gives the bitmask of all the unavailable registers.
|
|
|
182 |
*/
|
|
|
183 |
|
|
|
184 |
int getfreg
|
|
|
185 |
PROTO_N ( ( fl ) )
|
|
|
186 |
PROTO_T ( long fl ){
|
|
|
187 |
int reg = -1 ;
|
|
|
188 |
long start = choosefloat ;
|
|
|
189 |
assert ( choosefloat == RMASK ( currentfloat ) ) ;
|
|
|
190 |
for ( ; ; ) {
|
|
|
191 |
/* Check if register is free */
|
|
|
192 |
if ( ( choosefloat & fl ) == 0 ) reg = currentfloat ;
|
|
|
193 |
|
|
|
194 |
/* Work out the next register (cyclic) */
|
|
|
195 |
if ( currentfloat == R_FLT_LAST ) {
|
|
|
196 |
currentfloat = R_FLT_FIRST ;
|
|
|
197 |
choosefloat = RMASK ( R_FLT_FIRST ) ;
|
|
|
198 |
}
|
|
|
199 |
else {
|
|
|
200 |
currentfloat++ ;
|
|
|
201 |
choosefloat = choosefloat << 1 ;
|
|
|
202 |
}
|
|
|
203 |
if ( reg != -1 ) {
|
|
|
204 |
/* Register found */
|
|
|
205 |
assert ( IS_FLT_TREG ( reg ) ) ;
|
|
|
206 |
return ( reg ) ;
|
|
|
207 |
}
|
|
|
208 |
if ( choosefloat == start ) {
|
|
|
209 |
fail ( "Can't allocate temporary floating register" ) ;
|
|
|
210 |
return ( 0 ) ;
|
|
|
211 |
}
|
|
|
212 |
}
|
|
|
213 |
/* NOT REACHED */
|
|
|
214 |
}
|