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/src/installers/alpha/common/getregs.c – Rev 2

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
/* 	$Id: getregs.c,v 1.1.1.1 1998/01/17 15:56:00 release Exp $	 */
32
 
33
#ifndef lint
34
static char vcid[] = "$Id: getregs.c,v 1.1.1.1 1998/01/17 15:56:00 release Exp $";
35
#endif /* lint */
36
 
37
/*
38
  getregs.c
39
*/
40
 
41
/*
42
$Log: getregs.c,v $
43
 * Revision 1.1.1.1  1998/01/17  15:56:00  release
44
 * First version to be checked into rolling release.
45
 *
46
 * Revision 1.6  1995/11/13  12:43:05  john
47
 * Changed register allocation
48
 *
49
 * Revision 1.5  1995/10/27  12:42:28  john
50
 * changed to allow use of result reg
51
 *
52
 * Revision 1.4  1995/08/04  15:50:27  john
53
 * Minor change
54
 *
55
 * Revision 1.3  1995/07/27  10:08:04  john
56
 * Fix to choosefix
57
 *
58
 * Revision 1.2  1995/05/16  10:48:58  john
59
 * Cosmetic changes
60
 *
61
 * Revision 1.1.1.1  1995/03/23  10:39:09  john
62
 * Entered into CVS
63
 *
64
 * Revision 1.6  1995/01/12  15:07:53  john
65
 * Changed error reporting
66
 *
67
*/
68
 
69
 
70
#include "config.h"
71
#include "common_types.h"
72
#include "procrectypes.h"
73
#include "exptypes.h"
74
#include "procrecs.h"
75
#include "expmacs.h"
76
#include "exp.h"
77
#include "regexps.h"
78
#include "tags.h"
79
#include "expmacs.h"
80
#include "bitsmacs.h"
81
#include "fail.h"
82
#include "getregs.h"
83
 
84
static int useable_fixed;
85
static int useable_float;
86
 
87
#define for1  0x002	
88
#define for2  0x004
89
#define for8  0x100	/* bit pattern for $8,  bit 9 is set */
90
#define for10 0x400	/* bit pattern for $10, bit 11 set */
91
#define for11 0x800
92
#define for15 0x8000	/* bit pattern for $15, bit 16 is set */
93
#define for24 0x1000000		/* etc ... */
94
#define for25 0x2000000
95
 
96
#define for0  0x1
97
#define for4  0x10
98
#define for5  0x20
99
#define for9  0x200
100
 
101
 
102
static int regs_corrupted_by_div = (1<<23)|(1<<24)|(1<<25)|(1<<27);
103
 
104
 
105
 
106
int  choosefix = for1;		/* first fixed reg to be allocated */
107
int  choosefloat = for1;	/* first float reg to be allocated */
108
 
109
int   currentfix = 1;
110
int   currentfloat = 1;
111
static int   maxfixed;
112
static int   maxfloat = 31;	/* dubious */
113
 
114
/* 
115
   tg is a proc. settempregs sets up useable_fixed etc depending 
116
   on how the proc treats its parameters; if they are destined for
117
   store or s-registers we can use some of the parameter registers 
118
*/
119
void settempregs
120
    PROTO_N ( ( tg ) )
121
    PROTO_T ( exp tg )
122
{
123
  procrec * pr = &procrecs[no(tg)];
124
  bool leaf = ((pr->needsproc).propsneeds & anyproccall)==0;
125
  exp stg = son(tg);
126
  currentfix = 1;
127
  currentfloat = 1;
128
  choosefix = for1;
129
  choosefloat = for1;
130
  useable_fixed = 0x03ff01ff;	/* leaves out parameter registers */
131
  useable_float = 0x7fc0fc00;
132
  if(has_machine_division(tg)){
133
    useable_fixed &= ~regs_corrupted_by_div;
134
  }
135
  if (leaf) {
136
    maxfixed=31;
137
  }
138
  else maxfixed = 31;
139
 
140
  while (name(stg)==ident_tag && isparam(stg)) {
141
    if ((props(stg) & inreg_bits) !=0 ) {
142
      useable_fixed &= ~ (1<<no(stg));
143
    }
144
    else
145
      if ((props(stg) & infreg_bits) != 0) {
146
	useable_float &= ~(1<<no(stg));
147
      }
148
    stg = bro(son(stg));
149
  }
150
  return;
151
}
152
 
153
/*
154
  Gets a free temporary fixed point register.  The int fixed masks 
155
  out registers which are not available.
156
*/
157
int getreg
158
    PROTO_N ( ( fixed ) )
159
    PROTO_T ( int32 fixed )
160
{
161
  int reg=-1;
162
  int start = choosefix;
163
  bool out_of_regs=0;
164
  for(;(!out_of_regs)&&(reg==-1);){
165
    if(currentfix>=maxfixed){
166
      currentfix=1;
167
      choosefix=for1;
168
    }
169
    else{
170
      currentfix++;
171
      choosefix<<=1;
172
    }
173
    if(!(choosefix&fixed) && (choosefix&useable_fixed)){
174
      reg = currentfix;
175
    }
176
    out_of_regs = (reg==-1)&&(choosefix==start);
177
  }
178
  if(out_of_regs){
179
    alphafail(OUT_OF_TREGS);
180
  }
181
  clear_reg(reg);
182
  return reg;
183
}
184
 
185
 
186
/*
187
  Get a free temporary floating point register.
188
*/
189
int getfreg
190
    PROTO_N ( ( fl ) )
191
    PROTO_T ( int fl )
192
{
193
  int freg=-1;
194
  int start = choosefloat;
195
  bool out_of_regs=0;
196
  for(;(!out_of_regs)&&(freg==-1);){
197
    if(currentfloat>=maxfloat){
198
      currentfloat=10;
199
      choosefloat=for10;
200
    }
201
    else{
202
      currentfloat++;
203
      choosefloat<<=1;
204
    }
205
    if(!(choosefloat&fl) && (choosefloat&useable_float)){
206
      freg = currentfloat;
207
    }
208
    out_of_regs = (freg==-1)&&(choosefloat==start);
209
  }
210
  if(out_of_regs){
211
    alphafail(OUT_OF_F_TREGS);
212
  }
213
  return freg;
214
}
215
 
216
 
217