Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – tendra.SVN – Blame – /branches/tendra5-amd64/src/installers/power/common/getregs.c – Rev 5

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
    Copyright (c) 1993 Open Software Foundation, Inc.
3
 
4
 
5
    All Rights Reserved
6
 
7
 
8
    Permission to use, copy, modify, and distribute this software
9
    and its documentation for any purpose and without fee is hereby
10
    granted, provided that the above copyright notice appears in all
11
    copies and that both the copyright notice and this permission
12
    notice appear in supporting documentation.
13
 
14
 
15
    OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING
16
    ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
17
    PARTICULAR PURPOSE.
18
 
19
 
20
    IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
21
    CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
22
    LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
23
    NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
24
    WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25
*/
26
 
27
/*
28
    		 Crown Copyright (c) 1997
29
 
30
    This TenDRA(r) Computer Program is subject to Copyright
31
    owned by the United Kingdom Secretary of State for Defence
32
    acting through the Defence Evaluation and Research Agency
33
    (DERA).  It is made available to Recipients with a
34
    royalty-free licence for its use, reproduction, transfer
35
    to other parties and amendment for any purpose not excluding
36
    product development provided that any such use et cetera
37
    shall be deemed to be acceptance of the following conditions:-
38
 
39
        (1) Its Recipients shall ensure that this Notice is
40
        reproduced upon any copies or amended versions of it;
41
 
42
        (2) Any amended version of it shall be clearly marked to
43
        show both the nature of and the organisation responsible
44
        for the relevant amendment or amendments;
45
 
46
        (3) Its onward transfer from a recipient to another
47
        party shall be deemed to be that party's acceptance of
48
        these conditions;
49
 
50
        (4) DERA gives no warranty or assurance as to its
51
        quality or suitability for any purpose and DERA accepts
52
        no liability whatsoever in relation to any use to which
53
        it may be put.
54
*/
55
 
56
 
57
 
58
/**********************************************************************
59
$Author: release $
60
$Date: 1998/02/04 15:48:47 $
61
$Revision: 1.2 $
62
$Log: getregs.c,v $
63
 * Revision 1.2  1998/02/04  15:48:47  release
64
 * Added OSF copyright message.
65
 *
66
 * Revision 1.1.1.1  1998/01/17  15:55:56  release
67
 * First version to be checked into rolling release.
68
 *
69
 * Revision 1.2  1996/10/04  16:01:04  pwe
70
 * add banners and mod for PWE ownership
71
 *
72
**********************************************************************/
73
 
74
 
75
/******************************************************************
76
		getregs.c
77
 
78
	Routines for choosing temporary registers. The next free
79
register is chosen cyclically from available t regs.
80
 
81
	The parameter is usually taken from a value of type space
82
(which has bits for fixed and floating regs).  A clear bit indicates
83
that the corresponding register is free for use.
84
 
85
******************************************************************/
86
 
87
#include "config.h"
88
#include "memtdf.h"
89
#include "codegen.h"
90
 
91
#include "myassert.h"
92
#include "comment.h"
93
 
94
#include "getregs.h"
95
 
96
 
97
 
98
/* next fixed reg to be allocated */
99
static int currentfix;
100
static long choosefix;
101
 
102
/* next float reg to be allocated */
103
static int currentfloat;
104
static long choosefloat;
105
 
106
 
107
/* reset getreg() and getfreg() back to start of sequence for proc 'tg' */
108
void settempregs PROTO_N ((tg)) PROTO_T (exp tg)
109
 
110
{
111
  currentfix = R_LAST_PARAM+1;/* R_11 it must be for parameters*/
112
  choosefix = RMASK(currentfix);
113
 
114
  currentfloat = FR_1;
115
 
116
  choosefloat = RMASK(currentfloat);
117
}
118
 
119
 
120
/* count how many free regs there are */
121
int freeregs PROTO_N ((rmask)) PROTO_T (long rmask)
122
{
123
  /* Free reg marked by 0 bit, count them */
124
  unsigned long bit = 1;
125
  int n = 0;
126
 
127
  while (bit != 0)
128
  {
129
    if ((rmask & bit) == 0)
130
      n++;
131
    bit <<= 1;
132
  }
133
  return n;
134
}
135
 
136
 
137
/* get a free temporary fixed pt reg */
138
int getreg PROTO_N ((fixed)) PROTO_T (long fixed)
139
{
140
  /*
141
   * Choose reg from set 'fixed'. Chosen in a cyclic order, to give good
142
   * chance for peep-hole optimiser finding something useful lying around. Bit
143
   * set in set 'fixed' means it is unavailable, we search for 0 bit.
144
   */
145
  int reg = -1;
146
  long start = choosefix;
147
 
148
  FULLCOMMENT3("getreg: from %#x, choosefix=%#x currentfix=%d", fixed, choosefix, currentfix);
149
 
150
  /* currentfix and choosefix are in step, one the reg number, one the mask */
151
  ASSERT(choosefix == RMASK(currentfix));
152
 
153
  for (;;)
154
  {
155
    if ((choosefix & fixed) == 0)
156
      reg = currentfix;
157
 
158
    ASSERT(reg != R_0);		/* R_0 not a fully functional reg, should never be in set */
159
    ASSERT(!IS_R_TMP(reg));	/* +++ R_TMP currently used as ad-hoc temp in
160
				 * various places */
161
 
162
    if (currentfix == R_LAST)
163
    {
164
      /* back to start */
165
      currentfix = R_FIRST;
166
      choosefix = RMASK(R_FIRST);
167
    }
168
    else
169
    {
170
      /* next reg */
171
      currentfix++;
172
      choosefix = choosefix << 1;
173
    }
174
 
175
    if (reg != -1)
176
    {
177
      FULLCOMMENT1("getreg: allocating %d", reg);
178
      ASSERT(IS_TREG(reg));
179
      return reg;
180
    }
181
 
182
    if (choosefix == start)
183
    {
184
      fail("getreg: too many regs required");
185
      return R_0;
186
    }
187
  }
188
}
189
 
190
 
191
 
192
/* get a free temporary floating reg */
193
int getfreg PROTO_N ((fl)) PROTO_T (long fl)
194
{
195
  /*
196
   * Choose reg from set 'fl'. Chosen in a cyclic order, to give good chance
197
   * for peep-hole optimiser finding something useful lying around. Bit set in
198
   * set 'float' means it is unavailable, we search for 0 bit.
199
   */
200
  int reg = -1;
201
  long start = choosefloat;
202
 
203
  FULLCOMMENT3("getfreg: from %#x, choosefloat=%#x currentfloat=%d", fl, choosefloat, currentfloat);
204
 
205
  /*
206
   * currentfloat and choosefloat are in step, one the reg number, one the
207
   * mask
208
   */
209
  ASSERT(choosefloat == RMASK(currentfloat));
210
 
211
  for (;;)
212
  {
213
    if ((choosefloat & fl) == 0)
214
      reg = currentfloat;
215
 
216
    if (currentfloat == R_FLT_LAST)
217
    {
218
      /* back to start */
219
      currentfloat = R_FLT_FIRST;
220
      choosefloat = RMASK(R_FLT_FIRST);
221
    }
222
    else
223
    {
224
      /* next reg */
225
      currentfloat++;
226
      choosefloat = choosefloat << 1;
227
    }
228
 
229
    if (reg != -1)
230
    {
231
      FULLCOMMENT1("getfreg: allocating %d", reg);
232
      ASSERT(IS_FLT_TREG(reg));
233
      return reg;
234
    }
235
 
236
    if (choosefloat == start)
237
    {
238
      fail("getfreg: too many float regs required");
239
      return 0;
240
    }
241
  }
242
}
243
 
244
 
245
 
246
/* return next branch unit cr reg to use */
247
int next_creg PROTO_Z ()
248
{
249
  /*
250
   * Cycle around cr 0,1,6,7.	+++ allocate as regs
251
   * cr3 & cr4 would require proc to save them.
252
   * cr4 & cr5 reserved for system use.
253
   */
254
  static int creg = 7;
255
 
256
  creg++;
257
 
258
  if (creg == 8)
259
    creg = 0;
260
  else if (creg == 2)
261
    creg = 6;
262
 
263
  return creg;
264
}