Subversion Repositories tendra.SVN

Rev

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

Rev 2 Rev 7
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
    Copyright (c) 1993 Open Software Foundation, Inc.
32
    Copyright (c) 1993 Open Software Foundation, Inc.
3
 
33
 
4
 
34
 
5
    All Rights Reserved
35
    All Rights Reserved
6
 
36
 
7
 
37
 
8
    Permission to use, copy, modify, and distribute this software
38
    Permission to use, copy, modify, and distribute this software
9
    and its documentation for any purpose and without fee is hereby
39
    and its documentation for any purpose and without fee is hereby
10
    granted, provided that the above copyright notice appears in all
40
    granted, provided that the above copyright notice appears in all
11
    copies and that both the copyright notice and this permission
41
    copies and that both the copyright notice and this permission
12
    notice appear in supporting documentation.
42
    notice appear in supporting documentation.
Line 14... Line 44...
14
 
44
 
15
    OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING
45
    OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING
16
    ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
46
    ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
17
    PARTICULAR PURPOSE.
47
    PARTICULAR PURPOSE.
18
 
48
 
19
 
49
 
20
    IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
50
    IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
21
    CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
51
    CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
22
    LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
52
    LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
23
    NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
53
    NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
24
    WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
54
    WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25
*/
55
*/
26
 
56
 
27
/*
57
/*
28
    		 Crown Copyright (c) 1997
58
    		 Crown Copyright (c) 1997
29
    
59
 
30
    This TenDRA(r) Computer Program is subject to Copyright
60
    This TenDRA(r) Computer Program is subject to Copyright
31
    owned by the United Kingdom Secretary of State for Defence
61
    owned by the United Kingdom Secretary of State for Defence
32
    acting through the Defence Evaluation and Research Agency
62
    acting through the Defence Evaluation and Research Agency
33
    (DERA).  It is made available to Recipients with a
63
    (DERA).  It is made available to Recipients with a
34
    royalty-free licence for its use, reproduction, transfer
64
    royalty-free licence for its use, reproduction, transfer
35
    to other parties and amendment for any purpose not excluding
65
    to other parties and amendment for any purpose not excluding
36
    product development provided that any such use et cetera
66
    product development provided that any such use et cetera
37
    shall be deemed to be acceptance of the following conditions:-
67
    shall be deemed to be acceptance of the following conditions:-
38
    
68
 
39
        (1) Its Recipients shall ensure that this Notice is
69
        (1) Its Recipients shall ensure that this Notice is
40
        reproduced upon any copies or amended versions of it;
70
        reproduced upon any copies or amended versions of it;
41
    
71
 
42
        (2) Any amended version of it shall be clearly marked to
72
        (2) Any amended version of it shall be clearly marked to
43
        show both the nature of and the organisation responsible
73
        show both the nature of and the organisation responsible
44
        for the relevant amendment or amendments;
74
        for the relevant amendment or amendments;
45
    
75
 
46
        (3) Its onward transfer from a recipient to another
76
        (3) Its onward transfer from a recipient to another
47
        party shall be deemed to be that party's acceptance of
77
        party shall be deemed to be that party's acceptance of
48
        these conditions;
78
        these conditions;
49
    
79
 
50
        (4) DERA gives no warranty or assurance as to its
80
        (4) DERA gives no warranty or assurance as to its
51
        quality or suitability for any purpose and DERA accepts
81
        quality or suitability for any purpose and DERA accepts
52
        no liability whatsoever in relation to any use to which
82
        no liability whatsoever in relation to any use to which
53
        it may be put.
83
        it may be put.
54
*/
84
*/
Line 110... Line 140...
110
 
140
 
111
 
141
 
112
TREG fixed_array[13];
142
TREG fixed_array[13];
113
TREG float_array[14];
143
TREG float_array[14];
114
 
144
 
115
static void do_fixed_params PROTO_S ((void));
145
static void do_fixed_params(void);
116
static void do_float_params PROTO_S ((void));
146
static void do_float_params(void);
117
static void copy_fixed PROTO_S ((int));
147
static void copy_fixed(int);
118
static void copy_float PROTO_S ((int));
148
static void copy_float(int);
119
static void clear_fixed PROTO_S ((void));
149
static void clear_fixed(void);
120
static void clear_float PROTO_S ((void));
150
static void clear_float(void);
121
static void set_fixed PROTO_S ((exp,int,int));
151
static void set_fixed(exp,int,int);
122
static void set_float PROTO_S ((exp,int,int));
152
static void set_float(exp,int,int);
123
static int getspare PROTO_S ((long));
153
static int getspare(long);
124
void track_fixed PROTO_S ((int,exp));
154
void track_fixed(int,exp);
125
void track_float PROTO_S ((int,exp));
155
void track_float(int,exp);
126
static int end_param;
156
static int end_param;
127
 
157
 
128
void output_parameters PROTO_N ((e)) PROTO_T (exp e)
158
void output_parameters(exp e)
129
{
159
{
130
  exp par;
160
  exp par;
131
 
161
 
132
  if (name(e)==general_proc_tag)
162
  if (name(e) ==general_proc_tag)
133
  {
163
  {
134
    end_param = GENERAL_PROC_PARAM_REGS + R_FIRST_PARAM - 1;
164
    end_param = GENERAL_PROC_PARAM_REGS + R_FIRST_PARAM - 1;
135
  }
165
  }
136
  else
166
  else
137
  {
167
  {
138
    end_param = PROC_PARAM_REGS + R_FIRST_PARAM - 1;
168
    end_param = PROC_PARAM_REGS + R_FIRST_PARAM - 1;
139
  }
169
  }
140
  
170
 
141
  /* Outputs the code for the parameters */
171
  /* Outputs the code for the parameters */
142
  fixedfree = PROC_TREGS;
172
  fixedfree = PROC_TREGS;
143
  floatfree = PROC_FLT_TREGS;
173
  floatfree = PROC_FLT_TREGS;
144
  clear_fixed();
174
  clear_fixed();
145
  clear_float();
175
  clear_float();
146
  
176
 
147
  par = son(e);
177
  par = son(e);
148
  
178
 
149
  for(;;)
179
  for (;;)
150
  {
180
  {
151
    int param_reg;
181
    int param_reg;
152
    exp init_exp;
182
    exp init_exp;
153
    int param_size;
183
    int param_size;
154
    int param_align;
184
    int param_align;
155
    int param_offset;
185
    int param_offset;
156
    bool is_float ;
186
    bool is_float;
157
    bool src_in_reg;
187
    bool src_in_reg;
158
    bool dest_in_reg;
188
    bool dest_in_reg;
159
    baseoff stackpos;
189
    baseoff stackpos;
160
    where dest;
190
    where dest;
161
    
191
 
162
    if ((!isparam(par)) ||
192
    if ((!isparam(par)) ||
163
	(name(par)!=ident_tag) ||
193
	(name(par)!=ident_tag) ||
164
	(name(son(par))==formal_callee_tag))
194
	(name(son(par)) ==formal_callee_tag))
165
      break;
195
      break;
166
 
196
 
167
    init_exp = son(par);
197
    init_exp = son(par);
168
    is_float = is_floating(name(sh(init_exp)));
198
    is_float = is_floating(name(sh(init_exp)));
169
    param_reg = props(init_exp);
199
    param_reg = props(init_exp);
170
    param_size = shape_size(sh(init_exp));
200
    param_size = shape_size(sh(init_exp));
171
    param_align = shape_align(sh(init_exp));
201
    param_align = shape_align(sh(init_exp));
172
    param_offset = no(init_exp)>>3;
202
    param_offset = no(init_exp) >>3;
173
    src_in_reg = param_reg !=0;
203
    src_in_reg = param_reg !=0;
174
    dest_in_reg = (props(par) & inanyreg)!=0;
204
    dest_in_reg = (props(par) & inanyreg)!=0;
175
 
205
 
176
    
206
 
177
    if (src_in_reg==1)
207
    if (src_in_reg==1)
178
    {
208
    {
179
      if(is_float)
209
      if (is_float)
180
      {
210
      {
181
	p_float_params++;
211
	p_float_params++;
182
      }
212
      }
183
      else
213
      else
184
      {
214
      {
185
	p_fixed_params++;
215
	p_fixed_params++;
186
      }
216
      }
187
    }
217
    }
188
 
218
 
189
    stackpos=boff_location(ENCODE_FOR_BOFF(param_offset,INPUT_CALLER_PARAMETER));    
219
    stackpos=boff_location(ENCODE_FOR_BOFF(param_offset,INPUT_CALLER_PARAMETER));
190
 
220
 
191
      
221
 
192
    clearvarargparam(par);
222
    clearvarargparam(par);
193
    
223
 
194
    if (dest_in_reg==0 
224
    if (dest_in_reg==0
195
	&& !p_has_no_vcallers 
225
	&& !p_has_no_vcallers
196
	&& isvis(par)
226
	&& isvis(par)
197
	&& props(init_exp)!=0 
227
	&& props(init_exp)!=0
198
	&& last_caller_param(par))
228
	&& last_caller_param(par))
199
    {
229
    {
200
      /* VARARGS */
230
      /* VARARGS */
201
      int last_size;
231
      int last_size;
202
      int pr;
232
      int pr;
203
      baseoff v;
233
      baseoff v;
204
      v = stackpos;
234
      v = stackpos;
205
 
235
 
206
      setvarargparam(par);
236
      setvarargparam(par);
207
      
237
 
208
      if (param_size == 0)
238
      if (param_size == 0)
209
      {
239
      {
210
	/* void from <varargs.h> */
240
	/* void from <varargs.h> */
211
	param_size = 32;
241
	param_size = 32;
212
	param_align = 32;
242
	param_align = 32;
213
      }
243
      }
214
      
244
 
215
      last_size = param_size;
245
      last_size = param_size;
216
      pr = R_FIRST_PARAM + ALIGNNEXT(no(init_exp) + last_size, 32) / 32;
246
      pr = R_FIRST_PARAM + ALIGNNEXT(no(init_exp) + last_size, 32) / 32;
217
      
247
 
218
      v.offset += ALIGNNEXT(last_size, 32) / 8;
248
      v.offset += ALIGNNEXT(last_size, 32) / 8;
219
      /* now word align to allow for non word aligned last param */
249
      /* now word align to allow for non word aligned last param */
220
      v.offset &= ~3;
250
      v.offset &= ~3;
221
      suspected_varargs = 1;
251
      suspected_varargs = 1;
222
      saved_varargs_offset = v.offset;
252
      saved_varargs_offset = v.offset;
Line 225... Line 255...
225
      {
255
      {
226
	st_ro_ins(i_st, pr, v);comment("varargs save all param regs");
256
	st_ro_ins(i_st, pr, v);comment("varargs save all param regs");
227
	pr++;
257
	pr++;
228
	v.offset += 4;
258
	v.offset += 4;
229
      }
259
      }
230
    }    
260
    }
231
    /* Set up dest */
261
    /* Set up dest */
232
    if (dest_in_reg==1)
262
    if (dest_in_reg==1)
233
    {
263
    {
234
      setregalt(dest.answhere,no(par));
264
      setregalt(dest.answhere,no(par));
235
    }
265
    }
236
    else
266
    else
237
    {
267
    {
238
      instore is;
268
      instore is;
Line 240... Line 270...
240
      is.adval = 1;
270
      is.adval = 1;
241
      setinsalt(dest.answhere,is);
271
      setinsalt(dest.answhere,is);
242
    }
272
    }
243
    dest.ashwhere.ashsize  = param_size;
273
    dest.ashwhere.ashsize  = param_size;
244
    dest.ashwhere.ashalign = param_align;
274
    dest.ashwhere.ashalign = param_align;
245
    
275
 
246
 
276
 
247
    /* Work out how the parameter is passed and where it will live */
277
    /* Work out how the parameter is passed and where it will live */
248
    if (src_in_reg==0 && dest_in_reg==1) 
278
    if (src_in_reg==0 && dest_in_reg==1)
249
    {
279
    {
250
      /* STACK  --->  REGISTER */
280
      /* STACK  --->  REGISTER */
251
      /* Use move for consistency */
281
      /* Use move for consistency */
252
      ans a;
282
      ans a;
253
      instore is;
283
      instore is;
Line 264... Line 294...
264
      {
294
      {
265
	/* Whole or part of struct passed in param t-regs */
295
	/* Whole or part of struct passed in param t-regs */
266
	int last_st_reg;
296
	int last_st_reg;
267
	int r;
297
	int r;
268
 
298
 
269
	last_st_reg = param_reg + (ALIGNNEXT(param_size, 32)/32) - 1;
299
	last_st_reg = param_reg + (ALIGNNEXT(param_size, 32) /32) - 1;
270
	if (last_st_reg > end_param)
300
	if (last_st_reg > end_param)
271
	{
301
	{
272
	  last_st_reg = end_param;
302
	  last_st_reg = end_param;
273
	}
303
	}
274
	for (r = param_reg; r <= last_st_reg; r++)
304
	for (r = param_reg; r <= last_st_reg; r++)
275
	{
305
	{
276
	  st_ro_ins(i_st, r, stackpos);comment("copy param struct onto stack");
306
	  st_ro_ins(i_st, r, stackpos);comment("copy param struct onto stack");
277
	  stackpos.offset += 4;
307
	  stackpos.offset += 4;
278
	}
308
	}
279
	p_fixed_params +=(last_st_reg - param_reg);
309
	p_fixed_params += (last_st_reg - param_reg);
280
      }
310
      }
281
      else
311
      else
282
      {
312
      {
283
	ans a;
313
	ans a;
284
	freg fr;
314
	freg fr;
285
	
315
 
286
	if(is_float)
316
	if (is_float)
287
	{
317
	{
288
	  fr.dble = is_double_precision((sh(init_exp)));
318
	  fr.dble = is_double_precision((sh(init_exp)));
289
	  fr.fr = param_reg;
319
	  fr.fr = param_reg;
290
	  setfregalt(a,fr);
320
	  setfregalt(a,fr);
291
	}
321
	}
292
	else
322
	else
293
	{
323
	{
294
	  setregalt( a, param_reg);
324
	  setregalt(a, param_reg);
295
	}
325
	}
296
	move(a,dest,PROC_TREGS|PARAM_TREGS,0);
326
	move(a,dest,PROC_TREGS|PARAM_TREGS,0);
297
      }
327
      }
298
    }
328
    }
299
    else if(src_in_reg==1 && dest_in_reg==1)
329
    else if (src_in_reg==1 && dest_in_reg==1)
300
    {
330
    {
301
      /* REGISTER  --->  REGISTER */
331
      /* REGISTER  --->  REGISTER */
302
      int dest_reg = no(par);
332
      int dest_reg = no(par);
303
      ASSERT(dest_reg!=0);/* This is now set up in needscan*/
333
      ASSERT(dest_reg!=0);/* This is now set up in needscan*/
304
      if ((props(par) & inreg_bits)!=0)
334
      if ((props(par) & inreg_bits)!=0)
Line 306... Line 336...
306
	if (IS_SREG(dest_reg))
336
	if (IS_SREG(dest_reg))
307
	{
337
	{
308
	  /* FIXED REGISTER --> FIXED S-REG */
338
	  /* FIXED REGISTER --> FIXED S-REG */
309
	  mov_rr_ins(param_reg , dest_reg);comment("copy param into an s-reg");
339
	  mov_rr_ins(param_reg , dest_reg);comment("copy param into an s-reg");
310
	  track_fixed(param_reg,par);
340
	  track_fixed(param_reg,par);
311
	}
341
	}
312
	else
342
	else
313
	{
343
	{
314
	  /* FIXED REGISTER --> FIXED T-REG */
344
	  /* FIXED REGISTER --> FIXED T-REG */
315
	  set_fixed(par,param_reg ,  dest_reg);
345
	  set_fixed(par,param_reg ,  dest_reg);
316
	}
346
	}
317
      }
347
      }
318
      else
348
      else
319
      {
349
      {
320
	if (IS_FLT_SREG(dest_reg))
350
	if (IS_FLT_SREG(dest_reg))
321
	{
351
	{
322
	  /* FLOAT REGISTER --> FLOAT S-REG */
352
	  /* FLOAT REGISTER --> FLOAT S-REG */
323
	  rrf_ins(i_fmr,param_reg , dest_reg );
353
	  rrf_ins(i_fmr,param_reg , dest_reg);
324
	  track_float(param_reg,par);
354
	  track_float(param_reg,par);
325
	}
355
	}
326
	else
356
	else
327
	{
357
	{
328
	  /* FLOAT REGISTER --> FLOAT T-REG */
358
	  /* FLOAT REGISTER --> FLOAT T-REG */
Line 334... Line 364...
334
    {
364
    {
335
      /* LIVES IN PLACE ON STACK */
365
      /* LIVES IN PLACE ON STACK */
336
    }
366
    }
337
 
367
 
338
    par = bro(son(par));
368
    par = bro(son(par));
339
  }
369
  }
340
  do_fixed_params();
370
  do_fixed_params();
341
  do_float_params();
371
  do_float_params();
342
  return;
372
  return;
343
}
373
}
344
 
374
 
345
 
375
 
346
static void do_fixed_params PROTO_Z ()
376
static void do_fixed_params(void)
347
{
377
{
348
  int r;
378
  int r;
349
 
379
 
350
  spare_fixed = getspare(fixedfree) ;
380
  spare_fixed = getspare(fixedfree);
351
  copying_fixed = spare_fixed;
381
  copying_fixed = spare_fixed;
352
  copy_fixed(spare_fixed);
382
  copy_fixed(spare_fixed);
353
  
383
 
354
  for(r=R_FIRST_PARAM;r<=end_param;r++)
384
  for (r=R_FIRST_PARAM;r<=end_param;r++)
355
  {
385
  {
356
    remember = 0;
386
    remember = 0;
357
    copying_fixed = r;
387
    copying_fixed = r;
358
    copy_fixed(r);
388
    copy_fixed(r);
359
    if (remember==1)
389
    if (remember==1)
360
    {
390
    {
361
      mov_rr_ins( spare_fixed , copying_fixed );comment("move param to its new reg");
391
      mov_rr_ins(spare_fixed , copying_fixed);comment("move param to its new reg");
362
      track_fixed( spare_fixed , fixed_array[copying_fixed].par);
392
      track_fixed(spare_fixed , fixed_array[copying_fixed].par);
363
    }
393
    }
364
  }
394
  }
365
  return;
395
  return;
366
}  
396
}
367
static void do_float_params PROTO_Z ()
397
static void do_float_params(void)
368
{
398
{
369
  int r;
399
  int r;
370
  
400
 
371
  spare_float = getspare(floatfree);
401
  spare_float = getspare(floatfree);
372
  copying_float = spare_float;
402
  copying_float = spare_float;
373
  copy_float(spare_float);
403
  copy_float(spare_float);
374
  
404
 
375
  for(r=FR_FIRST_PARAM;r<=FR_LAST_PARAM;r++)
405
  for (r=FR_FIRST_PARAM;r<=FR_LAST_PARAM;r++)
376
  {
406
  {
377
    remember = 0;
407
    remember = 0;
378
    copying_float = r;
408
    copying_float = r;
379
    copy_float(r);
409
    copy_float(r);
380
    if (remember==1)
410
    if (remember==1)
Line 382... Line 412...
382
      rrf_ins(i_fmr,spare_float,copying_float);
412
      rrf_ins(i_fmr,spare_float,copying_float);
383
      track_float(spare_float,float_array[copying_float].par);
413
      track_float(spare_float,float_array[copying_float].par);
384
    }
414
    }
385
  }
415
  }
386
  return;
416
  return;
387
} 
417
}
388
static void copy_fixed PROTO_N ((reg)) PROTO_T (int reg)
418
static void copy_fixed(int reg)
389
{
419
{
390
  if(fixed_array[reg].copied==1)
420
  if (fixed_array[reg].copied==1)
391
  {
421
  {
392
    return;
422
    return;
393
  }
423
  }
394
  if(fixed_array[reg].dest==reg)
424
  if (fixed_array[reg].dest==reg)
395
  {
425
  {
396
    fixed_array[reg].copied=1;
426
    fixed_array[reg].copied=1;
397
    return;
427
    return;
398
  }
428
  }
399
  if(fixed_array[reg].dest==copying_fixed)
429
  if (fixed_array[reg].dest==copying_fixed)
400
  {
430
  {
401
    /* We have gone round in a loop */
431
    /* We have gone round in a loop */
402
    remember = 1;
432
    remember = 1;
403
    mov_rr_ins(reg,spare_fixed);comment("copy param reg to new location");
433
    mov_rr_ins(reg,spare_fixed);comment("copy param reg to new location");
404
    fixed_array[reg].copied=1;
434
    fixed_array[reg].copied=1;
405
    return;
435
    return;
406
  }
436
  }
407
  copy_fixed(fixed_array[reg].dest);
437
  copy_fixed(fixed_array[reg].dest);
408
  mov_rr_ins(reg,fixed_array[reg].dest);comment("copy param reg to new reg");
438
  mov_rr_ins(reg,fixed_array[reg].dest);comment("copy param reg to new reg");
409
  track_fixed(reg,fixed_array[reg].par);
439
  track_fixed(reg,fixed_array[reg].par);
410
  fixed_array[reg].copied=1;
440
  fixed_array[reg].copied=1;
411
  return;
441
  return;
412
}
442
}
413
static void copy_float PROTO_N ((reg)) PROTO_T (int reg)
443
static void copy_float(int reg)
414
{
444
{
415
  if(float_array[reg].copied==1)
445
  if (float_array[reg].copied==1)
416
  {
446
  {
417
    return;
447
    return;
418
  }
448
  }
419
  if(float_array[reg].dest==reg)
449
  if (float_array[reg].dest==reg)
420
  {
450
  {
421
    float_array[reg].copied=1;
451
    float_array[reg].copied=1;
422
    return;
452
    return;
423
  }
453
  }
424
  if(float_array[reg].dest==copying_float)
454
  if (float_array[reg].dest==copying_float)
425
  {
455
  {
426
    /* We have gone round in a loop */
456
    /* We have gone round in a loop */
427
    remember = 1;
457
    remember = 1;
428
    rrf_ins(i_fmr,reg,spare_float);
458
    rrf_ins(i_fmr,reg,spare_float);
429
    float_array[reg].copied=1;
459
    float_array[reg].copied=1;
Line 431... Line 461...
431
  }
461
  }
432
  copy_float(float_array[reg].dest);
462
  copy_float(float_array[reg].dest);
433
  rrf_ins(i_fmr,reg,float_array[reg].dest);
463
  rrf_ins(i_fmr,reg,float_array[reg].dest);
434
  track_float(reg,float_array[reg].par);
464
  track_float(reg,float_array[reg].par);
435
  float_array[reg].copied=1;
465
  float_array[reg].copied=1;
436
  return;
466
  return;
437
} 
467
}
438
 
468
 
439
 
469
 
440
 
470
 
441
static void clear_fixed PROTO_Z ()
471
static void clear_fixed(void)
442
{
472
{
443
  int r;
473
  int r;
444
  for(r=0;r<=12;r++)
474
  for (r=0;r<=12;r++)
445
  {
475
  {
446
    fixed_array[r].par = nilexp;
476
    fixed_array[r].par = nilexp;
447
    fixed_array[r].dest = 0;
477
    fixed_array[r].dest = 0;
448
    fixed_array[r].copied = 1;
478
    fixed_array[r].copied = 1;
449
  }
479
  }
450
  return;
480
  return;
451
}
481
}
452
static void clear_float PROTO_Z ()
482
static void clear_float(void)
453
{
483
{
454
  int r;
484
  int r;
455
  for (r=0;r<=13;r++)
485
  for (r=0;r<=13;r++)
456
  {
486
  {
457
    float_array[r].par = nilexp;
487
    float_array[r].par = nilexp;
458
    float_array[r].dest = 0;
488
    float_array[r].dest = 0;
459
    float_array[r].copied = 1;
489
    float_array[r].copied = 1;
460
  }
490
  }
461
  return;
491
  return;
462
}
492
}
463
 
493
 
464
static void set_fixed PROTO_N ((p,from,to)) PROTO_T (exp p X int from X int to )
494
static void set_fixed(exp p, int from, int to)
465
{
495
{
466
  ASSERT(IS_PARAM_REG(from));
496
  ASSERT(IS_PARAM_REG(from));
467
  ASSERT(IS_TREG(to));
497
  ASSERT(IS_TREG(to));
468
  ASSERT(to!=R_TMP0);
498
  ASSERT(to!=R_TMP0);
469
  fixed_array[from].par = p;
499
  fixed_array[from].par = p;
470
  fixed_array[from].dest = to;
500
  fixed_array[from].dest = to;
471
  fixed_array[from].copied = 0;
501
  fixed_array[from].copied = 0;
472
  fixedfree |= RMASK(to);
502
  fixedfree |= RMASK(to);
473
}
503
}
474
static void set_float PROTO_N ((p,from,to)) PROTO_T (exp p X int from X int to )
504
static void set_float(exp p, int from, int to)
475
{
505
{
476
  ASSERT(IS_FLT_PARAM_REG(from));
506
  ASSERT(IS_FLT_PARAM_REG(from));
477
  ASSERT(IS_FLT_TREG(to));
507
  ASSERT(IS_FLT_TREG(to));
478
  float_array[from].par = p;
508
  float_array[from].par = p;
479
  float_array[from].dest = to;
509
  float_array[from].dest = to;
480
  float_array[from].copied = 0;
510
  float_array[from].copied = 0;
481
  floatfree |= RMASK(to);
511
  floatfree |= RMASK(to);
482
}
512
}
483
static int getspare PROTO_N ((s)) PROTO_T (long s)
513
static int getspare(long s)
484
{
514
{
485
  int r;
515
  int r;
486
  for(r=0;r<=31;r++)
516
  for (r=0;r<=31;r++)
487
  {
517
  {
488
    if ((s & RMASK(r))==0)
518
    if ((s & RMASK(r)) ==0)
489
    {
519
    {
490
      return r;
520
      return r;
491
    }
521
    }
492
  }
522
  }
493
  fail("getspare failed");
523
  fail("getspare failed");
494
  return 100;
524
  return 100;
495
}
525
}
496
 
526
 
497
void track_fixed PROTO_N ((reg,id)) PROTO_T (int reg X exp id)
527
void track_fixed(int reg, exp id)
498
{
528
{
499
  exp def = son(id);
529
  exp def = son(id);
500
  
530
 
501
  if(pt(id)!=nilexp && keep_eq_size(sh(def),sh(pt(id))))
531
  if (pt(id)!=nilexp && keep_eq_size(sh(def),sh(pt(id))))
502
  {
532
  {
503
    if(isvar(id))
533
    if (isvar(id))
504
    {
534
    {
505
      keepcont(pt(id),reg);
535
      keepcont(pt(id),reg);
506
    } 
536
    }
507
    else
537
    else
508
    {
538
    {
509
      keepreg(pt(id),reg);
539
      keepreg(pt(id),reg);
510
    }
540
    }
511
  }
541
  }
512
  return;
542
  return;
513
}
543
}
514
 
544
 
515
void track_float PROTO_N ((reg,id)) PROTO_T (int reg X exp id)
545
void track_float(int reg, exp id)
516
{
546
{
517
  return;
547
  return;
518
}
548
}