Subversion Repositories tendra.SVN

Rev

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

Rev 5 Rev 6
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
    		 Crown Copyright (c) 1997
32
    		 Crown Copyright (c) 1997
3
    
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
36
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
37
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
38
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
39
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
40
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
41
    shall be deemed to be acceptance of the following conditions:-
12
    
42
 
13
	(1) Its Recipients shall ensure that this Notice is
43
	(1) Its Recipients shall ensure that this Notice is
14
	reproduced upon any copies or amended versions of it;
44
	reproduced upon any copies or amended versions of it;
15
    
45
 
16
	(2) Any amended version of it shall be clearly marked to
46
	(2) Any amended version of it shall be clearly marked to
17
	show both the nature of and the organisation responsible
47
	show both the nature of and the organisation responsible
18
	for the relevant amendment or amendments;
48
	for the relevant amendment or amendments;
19
    
49
 
20
	(3) Its onward transfer from a recipient to another
50
	(3) Its onward transfer from a recipient to another
21
	party shall be deemed to be that party's acceptance of
51
	party shall be deemed to be that party's acceptance of
22
	these conditions;
52
	these conditions;
23
    
53
 
24
	(4) DERA gives no warranty or assurance as to its
54
	(4) DERA gives no warranty or assurance as to its
25
	quality or suitability for any purpose and DERA accepts
55
	quality or suitability for any purpose and DERA accepts
26
	no liability whatsoever in relation to any use to which
56
	no liability whatsoever in relation to any use to which
27
	it may be put.
57
	it may be put.
28
*/
58
*/
Line 37... Line 67...
37
 *    Fixed the comm_op register tracking bug in "oprators.c" and removed a
67
 *    Fixed the comm_op register tracking bug in "oprators.c" and removed a
38
 * few superfluous "#if 0"s.
68
 * few superfluous "#if 0"s.
39
 *
69
 *
40
 * Revision 1.19  1996/11/20  17:26:49  wfs
70
 * Revision 1.19  1996/11/20  17:26:49  wfs
41
 *    Fixed bug in makecode.c's case_tag involving unsigned control variable.
71
 *    Fixed bug in makecode.c's case_tag involving unsigned control variable.
42
 *
72
 *
43
 * Revision 1.18  1996/11/14  15:22:19  wfs
73
 * Revision 1.18  1996/11/14  15:22:19  wfs
44
 *    Fixed a bug in regexps.c which was common to most of the installers and
74
 *    Fixed a bug in regexps.c which was common to most of the installers and
45
 * has only just come to light due to PWE's work on powertrans. (There was
75
 * has only just come to light due to PWE's work on powertrans. (There was
46
 * previously only a patch.) Cosmetic changes to other files.
76
 * previously only a patch.) Cosmetic changes to other files.
47
 *
77
 *
48
 * Revision 1.17  1996/11/07  14:48:21  wfs
78
 * Revision 1.17  1996/11/07  14:48:21  wfs
49
 * A bug fix to "round_tag" - was clearing wrong freg. Cosmetic changes to
79
 * A bug fix to "round_tag" - was clearing wrong freg. Cosmetic changes to
50
 * "inst_fmt.c".
80
 * "inst_fmt.c".
51
 *
81
 *
52
 * Revision 1.16  1996/10/24  15:51:17  wfs
82
 * Revision 1.16  1996/10/24  15:51:17  wfs
53
 * Added "~alloc_size" special token. Minor change to alloca_tag - only need
83
 * Added "~alloc_size" special token. Minor change to alloca_tag - only need
54
 * one word for storage of pointer. Major change to round_tag (rounding to
84
 * one word for storage of pointer. Major change to round_tag (rounding to
55
 * unsigned chars) in the fix of avs bug.
85
 * unsigned chars) in the fix of avs bug.
56
 *
86
 *
Line 64... Line 94...
64
 * 64 bit int corrections.
94
 * 64 bit int corrections.
65
 *
95
 *
66
 * Revision 1.12  1996/03/14  17:21:02  wfs
96
 * Revision 1.12  1996/03/14  17:21:02  wfs
67
 * Bug in apply_general_tag case - when postlude_has_call(e) it was being
97
 * Bug in apply_general_tag case - when postlude_has_call(e) it was being
68
 * assumed there was at least one caller.
98
 * assumed there was at least one caller.
69
 *
99
 *
70
 * Revision 1.11  1996/02/14  17:19:15  wfs
100
 * Revision 1.11  1996/02/14  17:19:15  wfs
71
 * "next_caller_offset" and "next_callee_offset" have become special tokens
101
 * "next_caller_offset" and "next_callee_offset" have become special tokens
72
 * defined in "spec_tok.c". Bug fix to a "and_tag" optimization in
102
 * defined in "spec_tok.c". Bug fix to a "and_tag" optimization in
73
 * "oprators.c". A few bug fixes in "makecode.c" arising from the variable
103
 * "oprators.c". A few bug fixes in "makecode.c" arising from the variable
74
 * caller tests. "promote_pars" defined in "config.h".
104
 * caller tests. "promote_pars" defined in "config.h".
75
 *
105
 *
76
 * Revision 1.10  1996/01/22  17:25:57  wfs
106
 * Revision 1.10  1996/01/22  17:25:57  wfs
77
 * Bug fix to "make_stack_limit_tag".
107
 * Bug fix to "make_stack_limit_tag".
78
 *
108
 *
79
 * Revision 1.9  1996/01/17  13:50:57  wfs
109
 * Revision 1.9  1996/01/17  13:50:57  wfs
80
 * Another adjustment to "round_tag" - avoid "_U_Qfcnvfxt_dbl_to_sgl" if the
110
 * Another adjustment to "round_tag" - avoid "_U_Qfcnvfxt_dbl_to_sgl" if the
81
 * error_treatment is "continue".
111
 * error_treatment is "continue".
82
 *
112
 *
83
 * Revision 1.8  1996/01/15  10:26:46  wfs
113
 * Revision 1.8  1996/01/15  10:26:46  wfs
Line 109... Line 139...
109
 * (iii) Dynamic Initialization.
139
 * (iii) Dynamic Initialization.
110
 * (iv) Debugging of Exception Handling and Diagnostics.
140
 * (iv) Debugging of Exception Handling and Diagnostics.
111
 *
141
 *
112
 * Revision 5.17  1995/11/09  14:01:36  wfs
142
 * Revision 5.17  1995/11/09  14:01:36  wfs
113
 * Bugs fixed in "case same_callees_tag".
143
 * Bugs fixed in "case same_callees_tag".
114
 *
144
 *
115
 * Revision 5.16  1995/10/27  13:45:43  wfs
145
 * Revision 5.16  1995/10/27  13:45:43  wfs
116
 * Removed a few "#if 0"'s.
146
 * Removed a few "#if 0"'s.
117
 *
147
 *
118
 * Revision 5.15  1995/10/23  15:45:17  wfs
148
 * Revision 5.15  1995/10/23  15:45:17  wfs
119
 * A bug in the code responsible for moving parameters from the stack to
149
 * A bug in the code responsible for moving parameters from the stack to
Line 145... Line 175...
145
 * Cosmetic changes.
175
 * Cosmetic changes.
146
 *
176
 *
147
 * Revision 5.7  1995/09/26  11:10:38  wfs
177
 * Revision 5.7  1995/09/26  11:10:38  wfs
148
 * "long_jump.pl" bug fix. The stack pointer was not being properly
178
 * "long_jump.pl" bug fix. The stack pointer was not being properly
149
 * adjusted after an untidy return.
179
 * adjusted after an untidy return.
150
 *
180
 *
151
 * Revision 5.6  1995/09/25  13:10:06  wfs
181
 * Revision 5.6  1995/09/25  13:10:06  wfs
152
 * Added a "reset_tos()" after untidy calls in "Has_tos" procedures.
182
 * Added a "reset_tos()" after untidy calls in "Has_tos" procedures.
153
 *
183
 *
154
 * Revision 5.5  1995/09/25  10:35:38  wfs
184
 * Revision 5.5  1995/09/25  10:35:38  wfs
155
 * Fixed a bug in "round_tag" which was causing problems with "ghostscr
185
 * Fixed a bug in "round_tag" which was causing problems with "ghostscr
Line 169... Line 199...
169
 *
199
 *
170
 * Revision 5.0  1995/08/25  13:42:58  wfs
200
 * Revision 5.0  1995/08/25  13:42:58  wfs
171
 * Preperation for August 25 Glue release
201
 * Preperation for August 25 Glue release
172
 *
202
 *
173
 * Revision 3.4  1995/08/25  09:52:27  wfs
203
 * Revision 3.4  1995/08/25  09:52:27  wfs
174
 * Major revision. Many 3.1 and 4.0 constructs added.
204
 * Major revision. Many 3.1 and 4.0 constructs added.
175
 *
205
 *
176
 * Revision 3.4  1995/08/25  09:52:27  wfs
206
 * Revision 3.4  1995/08/25  09:52:27  wfs
177
 * Major revision. Many 3.1 and 4.0 constructs added.
207
 * Major revision. Many 3.1 and 4.0 constructs added.
178
 *
208
 *
179
 * Revision 3.1  95/04/10  16:27:14  16:27:14  wfs (William Simmonds)
209
 * Revision 3.1  95/04/10  16:27:14  16:27:14  wfs (William Simmonds)
180
 * Apr95 tape version.
210
 * Apr95 tape version.
181
 * 
211
 *
182
 * Revision 3.0  95/03/30  11:18:11  11:18:11  wfs (William Simmonds)
212
 * Revision 3.0  95/03/30  11:18:11  11:18:11  wfs (William Simmonds)
183
 * Mar95 tape version with CRCR95_178 bug fix.
213
 * Mar95 tape version with CRCR95_178 bug fix.
184
 * 
214
 *
185
 * Revision 2.0  95/03/15  15:28:02  15:28:02  wfs (William Simmonds)
215
 * Revision 2.0  95/03/15  15:28:02  15:28:02  wfs (William Simmonds)
186
 * spec 3.1 changes implemented, tests outstanding.
216
 * spec 3.1 changes implemented, tests outstanding.
187
 * 
217
 *
188
 * Revision 1.11  95/03/15  15:20:58  15:20:58  wfs (William Simmonds)
218
 * Revision 1.11  95/03/15  15:20:58  15:20:58  wfs (William Simmonds)
189
 * *** empty log message ***
219
 * *** empty log message ***
190
 * 
220
 *
191
 * Revision 1.10  95/02/22  11:30:29  11:30:29  wfs (William Simmonds)
221
 * Revision 1.10  95/02/22  11:30:29  11:30:29  wfs (William Simmonds)
192
 * Implemented last_local, local_free_all and local_free tags,
222
 * Implemented last_local, local_free_all and local_free tags,
193
 * 
223
 *
194
 * Revision 1.9  95/02/20  16:13:48  16:13:48  wfs (William Simmonds)
224
 * Revision 1.9  95/02/20  16:13:48  16:13:48  wfs (William Simmonds)
195
 * Implemented offset_pad_tag.
225
 * Implemented offset_pad_tag.
196
 * 
226
 *
197
 * Revision 1.8  95/02/10  11:47:25  11:47:25  wfs (William Simmonds)
227
 * Revision 1.8  95/02/10  11:47:25  11:47:25  wfs (William Simmonds)
198
 * Removed calls to evaluated() - initialising expressions are now
228
 * Removed calls to evaluated() - initialising expressions are now
199
 * stored in a linked list and written to outf after the procedure
229
 * stored in a linked list and written to outf after the procedure
200
 * body has been translated (c.f. translate_capsule).
230
 * body has been translated (c.f. translate_capsule).
201
 * 
231
 *
202
 * Revision 1.7  95/01/27  16:30:17  16:30:17  wfs (William Simmonds)
232
 * Revision 1.7  95/01/27  16:30:17  16:30:17  wfs (William Simmonds)
203
 * Rather primitive first attempt at implementing chvar_tag error_jump.
233
 * Rather primitive first attempt at implementing chvar_tag error_jump.
204
 * It should be refined.
234
 * It should be refined.
205
 * 
235
 *
206
 * Revision 1.6  95/01/25  15:36:10  15:36:10  wfs (William Simmonds)
236
 * Revision 1.6  95/01/25  15:36:10  15:36:10  wfs (William Simmonds)
207
 * Installed fabs_tag's and fneg_tag's error_jump.
237
 * Installed fabs_tag's and fneg_tag's error_jump.
208
 * 
238
 *
209
 * Revision 1.5  95/01/24  14:00:23  14:00:23  wfs (William Simmonds)
239
 * Revision 1.5  95/01/24  14:00:23  14:00:23  wfs (William Simmonds)
210
 * Implemented error_jump of abs_tag and neg_tag.
240
 * Implemented error_jump of abs_tag and neg_tag.
211
 * 
241
 *
212
 * Revision 1.4  95/01/23  18:52:49  18:52:49  wfs (William Simmonds)
242
 * Revision 1.4  95/01/23  18:52:49  18:52:49  wfs (William Simmonds)
213
 * Implemented error_jump of plus_tag and minus_tag.
243
 * Implemented error_jump of plus_tag and minus_tag.
214
 * 
244
 *
215
 * Revision 1.3  95/01/19  15:28:10  15:28:10  wfs (William Simmonds)
245
 * Revision 1.3  95/01/19  15:28:10  15:28:10  wfs (William Simmonds)
216
 * Dumped input registers on stack following find of a tdf vararg.
246
 * Dumped input registers on stack following find of a tdf vararg.
217
 * 
247
 *
218
 * Revision 1.2  95/01/17  17:26:26  17:26:26  wfs (William Simmonds)
248
 * Revision 1.2  95/01/17  17:26:26  17:26:26  wfs (William Simmonds)
219
 * Changed the take_out_of_line code, real_inverse_ntest[] had to
249
 * Changed the take_out_of_line code, real_inverse_ntest[] had to
220
 * be modified.
250
 * be modified.
221
 * 
251
 *
222
 * Revision 1.1  95/01/11  13:12:25  13:12:25  wfs (William Simmonds)
252
 * Revision 1.1  95/01/11  13:12:25  13:12:25  wfs (William Simmonds)
223
 * Initial revision
253
 * Initial revision
224
 * 
254
 *
225
*/
255
*/
226
 
256
 
227
 
257
 
228
#define HPPATRANS_CODE
258
#define HPPATRANS_CODE
229
#include "config.h"
259
#include "config.h"
Line 263... Line 293...
263
#include "hppadiags.h"
293
#include "hppadiags.h"
264
#include "translat.h"
294
#include "translat.h"
265
#include "frames.h"
295
#include "frames.h"
266
#include "out.h"
296
#include "out.h"
267
#include "makecode.h"
297
#include "makecode.h"
268
#include "extratags.h" 
298
#include "extratags.h"
269
#include "f64.h"
299
#include "f64.h"
270
#include "misc_c.h"
300
#include "misc_c.h"
271
#include "special.h"
301
#include "special.h"
272
#include "xalloc.h"
302
#include "xalloc.h"
273
#include "loc_signal.h"
303
#include "loc_signal.h"
274
 
304
 
275
#define outp fprintf
305
#define outp fprintf
276
#define isdbl(e) ( ( bool ) ( name ( e ) != shrealhd ) )
306
#define isdbl(e)((bool)(name(e)!= shrealhd))
277
 
307
 
278
int repeat_level;                 /* init by proc */
308
int repeat_level;                 /* init by proc */
279
outofline *odd_bits;             /* init by proc */
309
outofline *odd_bits;             /* init by proc */
280
int last_odd_bit;
310
int last_odd_bit;
281
int doing_odd_bits;
311
int doing_odd_bits;
Line 284... Line 314...
284
 
314
 
285
extern char export[128];
315
extern char export[128];
286
extern int leaf;
316
extern int leaf;
287
extern labexp current,first;
317
extern labexp current,first;
288
extern int RSCOPE_LEVEL,RSCOPE_LABEL;
318
extern int RSCOPE_LEVEL,RSCOPE_LABEL;
289
extern exp find_named_tg PROTO_S ((char *, shape));
319
extern exp find_named_tg(char *, shape);
290
extern baseoff find_tg PROTO_S ((char* s));
320
extern baseoff find_tg(char* s);
291
extern int reg_result PROTO_S ((shape));
321
extern int reg_result(shape);
292
 
322
 
293
#define GETREG( d, s )  ( discrim ( ( d ).answhere ) == inreg ?\
323
#define GETREG(d, s)(discrim((d).answhere) == inreg ?\
294
			  regalt ( ( d ).answhere ) :\
324
			  regalt((d).answhere):\
295
			  getreg ( ( s ).fixed ) )
325
			  getreg((s).fixed))
296
 
326
 
297
#define GETFREG( d, s ) ( discrim ( ( d ).answhere ) == infreg ?\
327
#define GETFREG(d, s)(discrim((d).answhere) == infreg ?\
298
			  regalt ( ( d ).answhere ) :\
328
			  regalt((d).answhere):\
299
			  getfreg ( ( s ).flt ) )
329
			  getfreg((s).flt))
300
 
330
 
301
#define TARGET( f ) ( main_globals[(-boff(son(f)).base)-1]->dec_u.dec_val.dec_id )
331
#define TARGET(f)(main_globals[(-boff(son(f)).base) -1] ->dec_u.dec_val.dec_id)
302
 
332
 
303
baseoff zero_exception_register
333
baseoff zero_exception_register
304
    PROTO_N ( (sp) )
-
 
305
    PROTO_T ( space sp )
334
(space sp)
306
{
335
{
307
   baseoff b;
336
   baseoff b;
308
   int r = getreg(sp.fixed);
337
   int r = getreg(sp.fixed);
309
   ld_ins(i_lo,0,mem_temp(0),r);    
338
   ld_ins(i_lo,0,mem_temp(0),r);
310
   b.base = r;  b.offset = 0;
339
   b.base = r;  b.offset = 0;
311
   st_ins(i_sw,GR0,b);
340
   st_ins(i_sw,GR0,b);
312
   ldf_ins(i_fldw,b,0);         
341
   ldf_ins(i_fldw,b,0);
313
   return b;
342
   return b;
314
}
343
}
315
 
344
 
316
void trap_handler
345
void trap_handler
317
    PROTO_N ( (b,trap,excep) )
-
 
318
    PROTO_T ( baseoff b X int trap X int excep )
346
(baseoff b, int trap, int excep)
319
{ 
347
{
320
   stf_ins(i_fstw,0,b);         
348
   stf_ins(i_fstw,0,b);
321
   ld_ins(i_lb,0,b,b.base);
349
   ld_ins(i_lb,0,b,b.base);
322
   ir_ins(i_ldi,fs_,empty_ltrl,excep,GR1);
350
   ir_ins(i_ldi,fs_,empty_ltrl,excep,GR1);
323
   rrr_ins(i_and,c_eq,b.base,GR1,0);
351
   rrr_ins(i_and,c_eq,b.base,GR1,0);
324
   ub_ins(cmplt_N,trap);
352
   ub_ins(cmplt_N,trap);
325
}
353
}
326
 
354
 
327
long trap_label
355
long trap_label
328
    PROTO_N ( (e) )
-
 
329
    PROTO_T ( exp e )
356
(exp e)
330
{
357
{
331
   if ( (errhandle(e)&3)==3 )
358
   if ((errhandle(e) &3) ==3)
332
   {
359
   {
333
      if ( aritherr_lab==0 )
360
      if (aritherr_lab==0)
334
	 aritherr_lab = new_label();
361
	 aritherr_lab = new_label();
335
      return aritherr_lab;
362
      return aritherr_lab;
336
   }
363
   }
337
   else
364
   else
338
      return no(son(pt(e))); 
365
      return no(son(pt(e)));
339
}
366
}
340
 
367
 
341
void reset_tos
368
void reset_tos
342
    PROTO_Z ()
369
(void)
343
{
370
{
344
   st_ins(i_sw,SP,SP_BOFF);
371
   st_ins(i_sw,SP,SP_BOFF);
345
}
372
}
346
 
373
 
347
void test_if_outside_of_var
374
void test_if_outside_of_var
348
    PROTO_N ( (v,r,trap) )
-
 
349
    PROTO_T ( unsigned char v X int r X int trap )
375
(unsigned char v, int r, int trap)
350
{
376
{
351
   if ( v==ucharhd)
377
   if (v==ucharhd)
352
   {
378
   {
353
      riir_ins(i_extru,c_,r,31,8,1);
379
      riir_ins(i_extru,c_,r,31,8,1);
354
      cj_ins(c_neq,1,r,trap);
380
      cj_ins(c_neq,1,r,trap);
355
   }
381
   }
356
   else
382
   else
Line 376... Line 402...
376
 
402
 
377
typedef struct postl_ {exp pl; struct postl_ * outer; } postl_chain;
403
typedef struct postl_ {exp pl; struct postl_ * outer; } postl_chain;
378
static postl_chain * old_pls;
404
static postl_chain * old_pls;
379
 
405
 
380
void update_plc
406
void update_plc
381
    PROTO_N ( (ch,ma) )
-
 
382
    PROTO_T ( postl_chain * ch X int ma )
407
(postl_chain * ch, int ma)
383
{
408
{
384
   while (ch != (postl_chain*)0) 
409
   while (ch != (postl_chain*)0)
385
   {
410
   {
386
      exp pl= ch->pl;
411
      exp pl= ch->pl;
387
      while ( name(pl)==ident_tag && name(son(pl))==caller_name_tag )
412
      while (name(pl) ==ident_tag && name(son(pl)) ==caller_name_tag)
388
      {
413
      {
389
	 no(pl) += ma;
414
	 no(pl) += ma;
390
	 pl = bro(son(pl));
415
	 pl = bro(son(pl));
391
      }
416
      }
392
      ch = ch->outer;
417
      ch = ch->outer;
393
   }
418
   }
394
}
419
}
395
 
420
 
396
 
421
 
397
/* ensure everywhere has a checknan() that needs one (cf. mips) */
422
/* ensure everywhere has a checknan() that needs one (cf. mips) */
398
void checknan 
423
void checknan
399
    PROTO_N ( ( e, fr ) )
-
 
400
    PROTO_T ( exp e X int fr )
424
(exp e, int fr)
401
{
425
{
402
#if 0
426
#if 0
403
  long trap = no(son(pt(e)));
427
  long trap = no(son(pt(e)));
404
  int t = (ABS_OF(fr) - 32) << 1;
428
  int t = (ABS_OF(fr) - 32) << 1;
405
 
429
 
Line 407... Line 431...
407
  fail("checknan");
431
  fail("checknan");
408
#endif
432
#endif
409
}
433
}
410
 
434
 
411
/* start of volatile use */
435
/* start of volatile use */
412
void setvolatile 
436
void setvolatile
413
    PROTO_Z ()
437
(void)
414
{
438
{
415
/*    outs(";\t.volatile\n" ) ;  */
439
/*    outs(";\t.volatile\n" ) ;  */
416
    return ;
440
    return;
417
}
441
}
418
 
442
 
419
/* end of volatile use */
443
/* end of volatile use */
420
void setnovolatile 
444
void setnovolatile
421
    PROTO_Z ()
445
(void)
422
{
446
{
423
/*    outs(";\t.nonvolatile\n" ) ;  */
447
/*    outs(";\t.nonvolatile\n" ) ;  */
424
    return ;
448
    return;
425
}
449
}
426
 
450
 
427
/* unsigned branch table */
451
/* unsigned branch table */
428
static CONST char *(usbranch_tab[]) =
452
static CONST char *(usbranch_tab[]) =
429
{
453
{
Line 436... Line 460...
436
   c_eq,
460
   c_eq,
437
};
461
};
438
 
462
 
439
 
463
 
440
 
464
 
441
#define usbranches(i) (usbranch_tab[i])
465
#define usbranches(i)(usbranch_tab[i])
442
 
466
 
443
/* signed branch table */
467
/* signed branch table */
444
CONST char *(sbranch_tab[]) =
468
CONST char *(sbranch_tab[]) =
445
{
469
{
446
   c_,  /* never branch (shouldn't be used) */
470
   c_,  /* never branch (shouldn't be used) */
Line 451... Line 475...
451
   c_neq,
475
   c_neq,
452
   c_eq,
476
   c_eq,
453
   c_TR,
477
   c_TR,
454
};
478
};
455
 
479
 
456
#define sbranches(i) (sbranch_tab[i])
480
#define sbranches(i)(sbranch_tab[i])
457
 
481
 
458
static CONST char *(fbranch_tab[]) =
482
static CONST char *(fbranch_tab[]) =
459
{
483
{
460
   c_,  /* never branch (shouldn't (be used) */
484
   c_,  /* never branch (shouldn't (be used) */
461
   c_g,
485
   c_g,
Line 464... Line 488...
464
   c_leq,
488
   c_leq,
465
   c_eq,
489
   c_eq,
466
   c_neq,
490
   c_neq,
467
};
491
};
468
 
492
 
469
#define fbranches(i) (fbranch_tab[i])
493
#define fbranches(i)(fbranch_tab[i])
470
 
494
 
471
/* used to invert TDF tests */
495
/* used to invert TDF tests */
472
long notbranch[]={7,4,3,2,1,6,5,0};
496
long notbranch[] ={7,4,3,2,1,6,5,0};
473
 
497
 
474
 
498
 
475
int bitsin
499
int bitsin
476
    PROTO_N ( (b) )
-
 
477
    PROTO_T ( long b )
500
(long b)
478
{
501
{
479
   /* counts the bits in b */
502
   /* counts the bits in b */
480
   int n = 0;
503
   int n = 0;
481
   long mask = 1;
504
   long mask = 1;
482
   for (; b != 0;)
505
   for (; b != 0;)
483
   {
506
   {
484
      n += ((b & mask) != 0) ? 1 : 0;
507
      n += ((b & mask)!= 0)? 1 : 0;
485
      b &= ~mask;
508
      b &= ~mask;
486
      mask = mask << 1;
509
      mask = mask << 1;
487
   }
510
   }
488
   return n;
511
   return n;
489
}
512
}
490
 
513
 
491
 
514
 
492
/* find the last test in sequence e which is a branch to second, if any, otherwise nil */
515
/* find the last test in sequence e which is a branch to second, if any, otherwise nil */
493
static exp testlast 
516
static exp testlast
494
    PROTO_N ( ( e, second ) )
-
 
495
    PROTO_T ( exp e X exp second )
517
(exp e, exp second)
496
{
518
{
497
  if (name(e) == test_tag && pt(e) == second)
519
  if (name(e) == test_tag && pt(e) == second)
498
  {
520
  {
499
    return (e);
521
    return(e);
500
  }
522
  }
501
  if (name(e) == seq_tag)
523
  if (name(e) == seq_tag)
502
  {
524
  {
503
    if (name(bro(son(e))) == test_tag && pt(bro(son(e))) == second)
525
    if (name(bro(son(e))) == test_tag && pt(bro(son(e))) == second)
504
    {
526
    {
Line 530... Line 552...
530
  }
552
  }
531
  return 0;
553
  return 0;
532
}
554
}
533
 
555
 
534
 
556
 
535
bool last_param 
557
bool last_param
536
    PROTO_N ( ( e ) )
-
 
537
    PROTO_T ( exp e )
558
(exp e)
538
{
559
{
539
  if (!isparam(e))
560
  if (!isparam(e))
540
    return 0;
561
    return 0;
541
  e = bro(son(e));
562
  e = bro(son(e));
542
aa:if (name(e) == ident_tag && isparam(e)
563
aa:if (name(e) == ident_tag && isparam(e)
543
			    && name(son(e)) != formal_callee_tag )
564
			    && name(son(e))!= formal_callee_tag)
544
    return 0;
565
    return 0;
545
  if (name(e) == diagnose_tag)
566
  if (name(e) == diagnose_tag)
546
  {
567
  {
547
    e = son(e);
568
    e = son(e);
548
    goto aa;
569
    goto aa;
Line 550... Line 571...
550
  return 1;
571
  return 1;
551
}
572
}
552
 
573
 
553
/* Does e, or components of e, contain a bitfield? */
574
/* Does e, or components of e, contain a bitfield? */
554
/* +++ should detect this earlier && record in props(e) once-and-for-all */
575
/* +++ should detect this earlier && record in props(e) once-and-for-all */
555
static int has_bitfield 
576
static int has_bitfield
556
    PROTO_N ( ( e ) )
-
 
557
    PROTO_T ( exp e )
577
(exp e)
558
{
578
{
559
  if (e == nilexp)
579
  if (e == nilexp)
560
    return 0;
580
    return 0;
561
  switch (name(e))
581
  switch (name(e))
562
  {
582
  {
Line 579... Line 599...
579
	e = bro(bro(e));	/* try next initialiser */
599
	e = bro(bro(e));	/* try next initialiser */
580
      }
600
      }
581
      /* NOTREACHED */
601
      /* NOTREACHED */
582
  default:
602
  default:
583
      return (ashof(sh(e)).ashalign == 1);	/* found bitfield */
603
      return (ashof(sh(e)).ashalign == 1);	/* found bitfield */
584
    }
604
    }
585
    /* NOTREACHED */
605
    /* NOTREACHED */
586
  }
606
  }
587
  /* NOTREACHED */
607
  /* NOTREACHED */
588
}
608
}
589
 
609
 
Line 591... Line 611...
591
 * the compound can be output correctly by eval().
611
 * the compound can be output correctly by eval().
592
 * Permanently undoes the needscan.c:scan() case val_tag:.
612
 * Permanently undoes the needscan.c:scan() case val_tag:.
593
 *
613
 *
594
 * NB must do this EXACTLY ONCE.
614
 * NB must do this EXACTLY ONCE.
595
 */
615
 */
596
static void fix_nonbitfield 
616
static void fix_nonbitfield
597
    PROTO_N ( ( e ) )
-
 
598
    PROTO_T ( exp e )
617
(exp e)
599
{
618
{
600
  if (name(e) == compound_tag)
619
  if (name(e) == compound_tag)
601
  {
620
  {
602
    e = son(e);
621
    e = son(e);
603
    while (1)
622
    while (1)
604
    {
623
    {
605
      if (name(e) == val_tag && name(sh(e)) == offsethd && al2(sh(e)) >= 8)
624
      if (name(e) == val_tag && name(sh(e)) == offsethd && al2(sh(e)) >= 8)
606
	  no(e) = no(e) << 3;	/* fix it */
625
	  no(e) = no(e) << 3;	/* fix it */
607
      
626
 
608
      fix_nonbitfield(bro(e));	/* recursively fix the rest of the struct */
627
      fix_nonbitfield(bro(e));	/* recursively fix the rest of the struct */
609
      
628
 
610
      if (last(bro(e)))
629
      if (last(bro(e)))
611
	  return;		/* all done */
630
	  return;		/* all done */
612
      
631
 
613
      e = bro(bro(e));	/* next pair */
632
      e = bro(bro(e));	/* next pair */
614
    }
633
    }
615
  }
634
  }
616
  return;
635
  return;
617
}
636
}
618
 
637
 
619
 
638
 
620
void restore_callees
639
void restore_callees
621
    PROTO_Z ()
640
(void)
622
{
641
{
623
   /*    Puts back on the stack those callees, if any, which were kept in
642
   /*    Puts back on the stack those callees, if any, which were kept in
624
   **  registers  **/
643
   **  registers  **/
625
  
644
 
626
   exp bdy = son(crt_proc);
645
   exp bdy = son(crt_proc);
627
   while( name(bdy)==dump_tag || name(bdy)==diagnose_tag )
646
   while (name(bdy) ==dump_tag || name(bdy) ==diagnose_tag)
628
       bdy = son(bdy);
647
       bdy = son(bdy);
629
   while (name(bdy)==ident_tag && isparam(bdy) && name(son(bdy)) !=formal_callee_tag )  
648
   while (name(bdy) ==ident_tag && isparam(bdy) && name(son(bdy))!=formal_callee_tag)
630
   {
649
   {
631
      bdy = bro(son(bdy));
650
      bdy = bro(son(bdy));
632
   }
651
   }
633
   while (name(bdy)==ident_tag && isparam(bdy) )  
652
   while (name(bdy) ==ident_tag && isparam(bdy))
634
   {
653
   {
635
      exp sbdy = son(bdy);
654
      exp sbdy = son(bdy);
636
      baseoff b;
655
      baseoff b;
637
      b.base = Has_vcallees ? FP : EP;
656
      b.base = Has_vcallees ? FP : EP;
638
      b.offset = (no(sbdy)-callees_offset)>>3;
657
      b.offset = (no(sbdy) -callees_offset) >>3;
639
      if (props(bdy) & infreg_bits)
658
      if (props(bdy) & infreg_bits)
640
      {
659
      {
641
      }
660
      }
642
      else
661
      else
643
      if (props(bdy)&inreg_bits)
662
      if (props(bdy) &inreg_bits)
644
      {
663
      {
645
	 st_ins(i_sw,no(bdy),b);
664
	 st_ins(i_sw,no(bdy),b);
646
      }
665
      }
647
      bdy = bro(sbdy);
666
      bdy = bro(sbdy);
648
   }
667
   }
649
}
668
}
650
 
669
 
651
 
670
 
652
exp find_ote
671
exp find_ote
653
    PROTO_N ( (e, n) )
-
 
654
    PROTO_T ( exp e X int n )
672
(exp e, int n)
655
{
673
{
656
   exp d = father(e);
674
   exp d = father(e);
657
   while ( name(d)!=apply_general_tag )
675
   while (name(d)!=apply_general_tag)
658
      d = father(d);
676
      d = father(d);
659
   d = son(bro(son(d))); /* list otagexps */
677
   d = son(bro(son(d))); /* list otagexps */
660
   while ( n !=0 )
678
   while (n !=0)
661
   {
679
   {
662
      d = bro(d);
680
      d = bro(d);
663
      n--;
681
      n--;
664
   }
682
   }
665
   assert( name(d)==caller_tag );
683
   assert(name(d) ==caller_tag);
666
   return d;
684
   return d;
667
}		
685
}
668
 
686
 
669
 
687
 
670
void do_exception
688
void do_exception
671
    PROTO_N ( (e) )
-
 
672
    PROTO_T ( int e )
689
(int e)
673
{
690
{
674
   baseoff b;
691
   baseoff b;
675
   ir_ins(i_ldi,fs_,"",e,ARG0);
692
   ir_ins(i_ldi,fs_,"",e,ARG0);
676
   b = boff( find_named_tg("__hppahandler",f_pointer(f_alignment(f_proc))));
693
   b = boff(find_named_tg("__hppahandler",f_pointer(f_alignment(f_proc))));
677
   ld_ins( i_lw, 1, b, GR22 ) ;
694
   ld_ins(i_lw, 1, b, GR22);
678
   call_millicode( MILLI_DYNCALL, RP, "", 1 );
695
   call_millicode(MILLI_DYNCALL, RP, "", 1);
679
}
696
}
680
 
697
 
681
space do_callers
698
space do_callers
682
    PROTO_N ( (list,sp,stub) )
-
 
683
    PROTO_T ( exp list X space sp X char *stub )
699
(exp list, space sp, char *stub)
684
{
700
{
685
   int off = 8<<5;
701
   int off = 8<<5;
686
   int fixpar,fltpar;
702
   int fixpar,fltpar;
687
   char s[16];
703
   char s[16];
688
   instore is;
704
   instore is;
689
   is.b.base = SP;
705
   is.b.base = SP;
690
   is.adval = 1;
706
   is.adval = 1;
691
   stub[0]='\t';
707
   stub[0] ='\t';
692
   stub[1]=0;
708
   stub[1] =0;
693
   for (;;)
709
   for (;;)
694
   {
710
   {
695
      /* Evaluate parameters in turn. */
711
      /* Evaluate parameters in turn. */
696
      where w;
712
      where w;
697
      ash ap;
713
      ash ap;
698
      int par_al;
714
      int par_al;
699
      int par_sz;
715
      int par_sz;
700
      exp par = (name(list)==caller_tag) ? son(list) : list;
716
      exp par = (name(list) ==caller_tag)? son(list): list;
701
      int hd = name(sh(list)) ;
717
      int hd = name(sh(list));
702
      ap = ashof(sh(list));
718
      ap = ashof(sh(list));
703
      w.ashwhere = ap;
719
      w.ashwhere = ap;
704
      par_sz = (ap.ashsize > 32) ? 64 : 32;
720
      par_sz = (ap.ashsize > 32)? 64 : 32;
705
      off+=par_sz;
721
      off+=par_sz;
706
      if ( par_sz==64 && !is_floating(name(sh(list))) && !valregable(sh(list)) )
722
      if (par_sz==64 && !is_floating(name(sh(list))) && !valregable(sh(list)))
707
	 par_al = 64;
723
	 par_al = 64;
708
      else
724
      else
709
	 par_al = (ap.ashalign < 32) ? 32 : ap.ashalign;
725
	 par_al = (ap.ashalign < 32)? 32 : ap.ashalign;
710
      off = rounder(off,par_al);
726
      off = rounder(off,par_al);
711
      is.b.offset = -(off>>3);
727
      is.b.offset = - (off>>3);
712
      if ( is_floating(hd) && off<(13<<5) )
728
      if (is_floating(hd) && off< (13<<5))
713
      {
729
      {
714
	 freg frg;
730
	 freg frg;
715
	 ans ansfr;
731
	 ans ansfr;
716
	 frg.fr = (fltpar = (off>>5)-5);
732
	 frg.fr = (fltpar = (off>>5) -5);
717
	 if ( hd==shrealhd )
733
	 if (hd==shrealhd)
718
	 {
734
	 {
719
	    frg.dble = 0;
735
	    frg.dble = 0;
720
	    sprintf(s,"ARGW%d=FR ",fltpar-4);
736
	    sprintf(s,"ARGW%d=FR ",fltpar-4);
721
	    strcat(stub,s);
737
	    strcat(stub,s);
722
	 }
738
	 }
723
	 else
739
	 else
724
	 {
740
	 {
725
	    frg.dble = 1;
741
	    frg.dble = 1;
726
	    if (off==(10<<5))
742
	    if (off== (10<<5))
727
	       strcat(stub,"ARGW0=FR ARGW1=FU ");
743
	       strcat(stub,"ARGW0=FR ARGW1=FU ");
728
	    else
744
	    else
729
	       strcat(stub,"ARGW2=FR ARGW3=FU ");
745
	       strcat(stub,"ARGW2=FR ARGW3=FU ");
730
	 }
746
	 }
731
	 setfregalt(ansfr,frg);
747
	 setfregalt(ansfr,frg);
Line 736... Line 752...
736
#if 1
752
#if 1
737
	 /*    This "#if" statement copies parameters passed in floating
753
	 /*    This "#if" statement copies parameters passed in floating
738
	 *   point registers to the corresponding fixed point registers. It
754
	 *   point registers to the corresponding fixed point registers. It
739
	 *   is neccessary to ensure that possible varargs are correctly
755
	 *   is neccessary to ensure that possible varargs are correctly
740
	 *   dumped on the stack.  */
756
	 *   dumped on the stack.  */
741
	 fixpar = ARG0+(off>>5)-9;
757
	 fixpar = ARG0+ (off>>5) -9;
742
	 if ( hd == shrealhd )
758
	 if (hd == shrealhd)
743
	 {
759
	 {
744
	    stf_ins(i_fstw,(frg.fr*3),is.b);
760
	    stf_ins(i_fstw,(frg.fr*3),is.b);
745
	    ld_ins(i_ldw,1,is.b,fixpar);
761
	    ld_ins(i_ldw,1,is.b,fixpar);
746
	    sp = guardreg(fixpar,sp);
762
	    sp = guardreg(fixpar,sp);
747
	 }
763
	 }
748
	 else
764
	 else
749
	 {
765
	 {
750
	    stf_ins(i_fstd,(frg.fr*3)+1,is.b);
766
	    stf_ins(i_fstd,(frg.fr*3) +1,is.b);
751
	    ld_ins(i_ldw,1,is.b,fixpar);
767
	    ld_ins(i_ldw,1,is.b,fixpar);
752
	    sp = guardreg(fixpar,sp);
768
	    sp = guardreg(fixpar,sp);
753
	    is.b.offset += 4;
769
	    is.b.offset += 4;
754
	    fixpar -= 1;
770
	    fixpar -= 1;
755
	    ld_ins(i_ldw,1,is.b,fixpar);
771
	    ld_ins(i_ldw,1,is.b,fixpar);
756
	    sp = guardreg(fixpar,sp);
772
	    sp = guardreg(fixpar,sp);
757
	 }
773
	 }
758
#endif
774
#endif
759
      }
775
      }
760
      else 
776
      else
761
      if ( valregable(sh(list)) && off<(13<<5) )
777
      if (valregable(sh(list)) && off< (13<<5))
762
      {
778
      {
763
	 ans ansr;
779
	 ans ansr;
764
	 setregalt(ansr,fixpar = ARG0+(off>>5)-9);
780
	 setregalt(ansr,fixpar = ARG0+ (off>>5) -9);
765
	 w.answhere = ansr;
781
	 w.answhere = ansr;
766
	 /* Evaluate parameter into fixed parameter register. */
782
	 /* Evaluate parameter into fixed parameter register. */
767
	 code_here(par,sp,w);
783
	 code_here(par,sp,w);
768
	 sp = guardreg(fixpar,sp);
784
	 sp = guardreg(fixpar,sp);
769
	 sprintf(s,"ARGW%d=GR ",fixpar-ARG0);
785
	 sprintf(s,"ARGW%d=GR ",fixpar-ARG0);
Line 771... Line 787...
771
      }
787
      }
772
      else
788
      else
773
      {
789
      {
774
	 /* Evaluate parameter into argument space on stack. */
790
	 /* Evaluate parameter into argument space on stack. */
775
#if 1
791
#if 1
776
	 if ( valregable(sh(list)) && ap.ashsize<32 )
792
	 if (valregable(sh(list)) && ap.ashsize<32)
777
	 {
793
	 {
778
 	     /*   Byte or 16bit scalar parameter - convert to integer.
794
 	     /*   Byte or 16bit scalar parameter - convert to integer.
779
	    *   We must expand source to a full word to conform to HP PA
795
	    *   We must expand source to a full word to conform to HP PA
780
	    *   conventions. We do this by loading into a reg. 
796
	    *   conventions. We do this by loading into a reg.
781
	     */
797
	     */
782
	    int r = reg_operand(par,sp);
798
	    int r = reg_operand(par,sp);
783
	    st_ins(i_sw,r,is.b);
799
	    st_ins(i_sw,r,is.b);
784
	 }
800
	 }
785
	 else
801
	 else
786
#endif
802
#endif
787
	 {
803
	 {
788
	    setinsalt(w.answhere,is);
804
	    setinsalt(w.answhere,is);
789
	    code_here(par,sp,w);
805
	    code_here(par,sp,w);
790
	    fixpar = ARG0+((-is.b.offset)>>2)-9;
806
	    fixpar = ARG0+ ((-is.b.offset) >>2) -9;
791
	    while(par_sz)
807
	    while (par_sz)
792
	    {
808
	    {
793
	       /*    Copy (parts of) compound paramater into vacant parameter
809
	       /*    Copy (parts of) compound paramater into vacant parameter
794
	       *   registers.  */
810
	       *   registers.  */
795
	       if (fixpar<ARG3+1)
811
	       if (fixpar<ARG3+1)
796
	       {
812
	       {
Line 803... Line 819...
803
	       is.b.offset+=4;
819
	       is.b.offset+=4;
804
	       par_sz-=32;
820
	       par_sz-=32;
805
	    }
821
	    }
806
	 }
822
	 }
807
      }
823
      }
808
      if ( name(list) == caller_tag ) 
824
      if (name(list) == caller_tag)
809
      {
825
      {
810
#if 1    
826
#if 1
811
	 if (shape_size(sh(list))<32 && valregable(sh(list)))
827
	 if (shape_size(sh(list)) <32 && valregable(sh(list)))
812
	    no(list) = off-32+shape_size(sh(list));
828
	    no(list) = off-32+shape_size(sh(list));
813
	 else
829
	 else
814
#endif
830
#endif
815
	    no(list) = off;
831
	    no(list) = off;
816
      }
832
      }
Line 820... Line 836...
820
	 list = bro(list);
836
	 list = bro(list);
821
   }
837
   }
822
   /* End "for" */
838
   /* End "for" */
823
}
839
}
824
 
840
 
825
 
841
 
826
void do_callee_list
842
void do_callee_list
827
    PROTO_N ( ( e, sp ) )
-
 
828
    PROTO_T ( exp e X space sp )
843
(exp e, space sp)
829
{
844
{
830
   long disp = 18<<5;
845
   long disp = 18<<5;
831
   if (no(e)!= 0)
846
   if (no(e)!= 0)
832
   {
847
   {
833
      exp list = son(e);
848
      exp list = son(e);
834
      where w;
849
      where w;
835
      ash ap;
850
      ash ap;
836
      instore is;
851
      instore is;
837
      is.b.base = SP;
852
      is.b.base = SP;
838
      is.adval = 1;
853
      is.adval = 1;
839
      for(;;)
854
      for (;;)
840
      {
855
      {
841
	 ap = ashof(sh(list));
856
	 ap = ashof(sh(list));
842
	 disp = rounder(disp, ap.ashalign);
857
	 disp = rounder(disp, ap.ashalign);
843
	 is.b.offset = disp>>3;
858
	 is.b.offset = disp>>3;
844
	 w.ashwhere = ap;
859
	 w.ashwhere = ap;
845
	 setinsalt(w.answhere, is);
860
	 setinsalt(w.answhere, is);
846
    	 code_here(list,sp,w);
861
    	 code_here(list,sp,w);
847
	 disp = rounder(disp+ap.ashsize,32);
862
	 disp = rounder(disp+ap.ashsize,32);
848
    	 if (last(list)) break;
863
    	 if (last(list))break;
849
	 list = bro(list);
864
	 list = bro(list);
850
      }
865
      }
851
   }
866
   }
852
}
867
}
853
 
868
 
854
 
869
 
855
void load_reg
870
void load_reg
856
    PROTO_N ( (e,r,sp) )
-
 
857
    PROTO_T ( exp e X int r X space sp )
871
(exp e, int r, space sp)
858
{
872
{
859
   where w;
873
   where w;
860
   w.ashwhere = ashof(sh(e));
874
   w.ashwhere = ashof(sh(e));
861
   setregalt(w.answhere,r);
875
   setregalt(w.answhere,r);
862
   code_here(e,sp,w);
876
   code_here(e,sp,w);
Line 866... Line 880...
866
/*
880
/*
867
 * Produce code for expression e, putting its result in dest using t-regs
881
 * Produce code for expression e, putting its result in dest using t-regs
868
 * given by sp. If non-zero, exitlab is the label of where the code is to
882
 * given by sp. If non-zero, exitlab is the label of where the code is to
869
 * continue.
883
 * continue.
870
 */
884
 */
871
makeans make_code 
885
makeans make_code
872
    PROTO_N ( ( e, sp, dest, exitlab ) )
-
 
873
    PROTO_T ( exp e X space sp X where dest X int exitlab )
886
(exp e, space sp, where dest, int exitlab)
874
{
887
{
875
  long constval=0;
888
  long constval=0;
876
  makeans mka;
889
  makeans mka;
877
  FULLCOMMENT3("make_code: %s,\t%s,\tprops=%#x",
890
  FULLCOMMENT3("make_code: %s,\t%s,\tprops=%#x",
878
	       (int)SH_NAME(name(sh(e))), (int)TAG_NAME(name(e)), props(e));
891
	      (int)SH_NAME(name(sh(e))), (int)TAG_NAME(name(e)), props(e));
879
  FULLCOMMENT3("           space=(%ld,%ld) (%s)", sp.fixed, sp.flt, (int)ANSDISCRIM_NAME( discrim ( dest.answhere ) ));
892
  FULLCOMMENT3("           space= (%ld,%ld) (%s)", sp.fixed, sp.flt,(int)ANSDISCRIM_NAME(discrim(dest.answhere)));
880
 
893
 
881
 tailrecurse:
894
 tailrecurse:
882
  mka.lab = exitlab;
895
  mka.lab = exitlab;
883
  mka.regmove = NOREG;
896
  mka.regmove = NOREG;
884
 
897
 
Line 896... Line 909...
896
  case env_size_tag:
909
  case env_size_tag:
897
  {
910
  {
898
     exp tg = son(son(e));
911
     exp tg = son(son(e));
899
     procrec * pr = &procrecs[no(son(tg))];
912
     procrec * pr = &procrecs[no(son(tg))];
900
     constval = (pr->frame_sz+0) >> 3;
913
     constval = (pr->frame_sz+0) >> 3;
901
     goto moveconst;         		    		
914
     goto moveconst;
902
  }	
915
  }
903
 
916
 
904
 
917
 
905
  case proc_tag: case general_proc_tag:
918
  case proc_tag: case general_proc_tag:
906
  {
919
  {
907
     crt_proc = e;
920
     crt_proc = e;
908
     old_pls = (postl_chain*)0;
921
     old_pls = (postl_chain*)0;
909
     return make_proc_tag_code(e, sp, dest, exitlab);
922
     return make_proc_tag_code(e, sp, dest, exitlab);
910
  }
923
  }
911
 
924
 
912
 
925
 
913
  case untidy_return_tag:
926
  case untidy_return_tag:
914
#if 1
927
#if 1
915
  case return_to_label_tag:
928
  case return_to_label_tag:
916
#endif
929
#endif
917
  case res_tag:
930
  case res_tag:
918
  {		
931
  {
919
     /* procedure result */
932
     /* procedure result */
920
     return make_res_tag_code(e,sp,dest,exitlab);
933
     return make_res_tag_code(e,sp,dest,exitlab);
921
  }
934
  }
922
 
935
 
923
  case tail_call_tag:
936
  case tail_call_tag:
Line 926... Line 939...
926
     exp cees = bro(fn);
939
     exp cees = bro(fn);
927
     bool glob = is_fn_glob(fn);
940
     bool glob = is_fn_glob(fn);
928
     exp bdy = son(crt_proc);
941
     exp bdy = son(crt_proc);
929
     space nsp;
942
     space nsp;
930
     nsp = sp;
943
     nsp = sp;
931
 
944
 
932
     if ( name(cees) == make_callee_list_tag )
945
     if (name(cees) == make_callee_list_tag)
933
     { 
946
     {
934
	do_callee_list( cees, sp );
947
	do_callee_list(cees, sp);
935
     }
948
     }
936
     else
949
     else
937
     if ( name(cees) == make_dynamic_callee_tag )
950
     if (name(cees) == make_dynamic_callee_tag)
938
     {
951
     {
939
	baseoff b;
952
	baseoff b;
940
	int r;
953
	int r;
941
	if ( Has_fp )
954
	if (Has_fp)
942
	{
955
	{
943
	   b.base = FP; b.offset = 68;
956
	   b.base = FP; b.offset = 68;
944
	}
957
	}
945
	else
958
	else
946
	{
959
	{
947
	   b.base = SP; b.offset = -(frame_sz>>3) + 68;
960
	   b.base = SP; b.offset = - (frame_sz>>3) + 68;
948
	}
961
	}
949
    	r = getreg(nsp.fixed);
962
    	r = getreg(nsp.fixed);
950
    	load_reg(son(cees),r,nsp);
963
    	load_reg(son(cees),r,nsp);
951
	st_ins(i_sw,r,b);
964
	st_ins(i_sw,r,b);
952
	b.offset -= 4;
965
	b.offset -= 4;
Line 954... Line 967...
954
    	load_reg(bro(son(cees)),r,nsp);
967
    	load_reg(bro(son(cees)),r,nsp);
955
	st_ins(i_sw,r,b);  /*     NB The sum of the callee sizes has been
968
	st_ins(i_sw,r,b);  /*     NB The sum of the callee sizes has been
956
			   **  put on the stack.  **/
969
			   **  put on the stack.  **/
957
     }
970
     }
958
     else
971
     else
959
     if ( name(cees) == same_callees_tag )
972
     if (name(cees) == same_callees_tag)
960
     {
973
     {
961
	restore_callees();
974
	restore_callees();
962
     }
975
     }
963
     if ( !glob )
976
     if (!glob)
964
     { 
977
     {
965
	 int r = getreg(nsp.fixed); 
978
	 int r = getreg(nsp.fixed);
966
	 load_reg( fn, r, nsp ) ;
979
	 load_reg(fn, r, nsp);
967
	 st_ins( i_sw, r, mem_temp(0) ) ;
980
	 st_ins(i_sw, r, mem_temp(0));
968
     }
981
     }
969
 
982
 
970
     /**  Move the callers to the correct place if neccessary.  **/
983
     /**  Move the callers to the correct place if neccessary.  **/
971
     bdy = son(crt_proc);
984
     bdy = son(crt_proc);
972
     while( name(bdy) == dump_tag || name(bdy) == diagnose_tag )
985
     while (name(bdy) == dump_tag || name(bdy) == diagnose_tag)
973
	bdy = son(bdy);
986
	bdy = son(bdy);
974
     while( name(bdy) == ident_tag && isparam(bdy) 
987
     while (name(bdy) == ident_tag && isparam(bdy)
975
		 	           && name(son(bdy)) != formal_callee_tag )
988
		 	           && name(son(bdy))!= formal_callee_tag)
976
     {
989
     {
977
      	exp sbdy = son(bdy);
990
      	exp sbdy = son(bdy);
978
	int pr =  props(sbdy) ;
991
	int pr =  props(sbdy);
979
#if 0
992
#if 0
980
	if ( pt(bdy) == nilexp && !diagnose )
993
	if (pt(bdy) == nilexp && !diagnose)
981
	{
994
	{
982
	   /**  Parameter never used.  **/
995
	   /**  Parameter never used.  **/
983
	}
996
	}
984
	else 
997
	else
985
#endif
998
#endif
986
	if ( pr == 0 && (props(bdy)&inanyreg) != 0 )
999
	if (pr == 0 && (props(bdy) &inanyreg)!= 0)
987
	{
1000
	{
988
	   /*    Parameter is passed on stack, but is kept in reg given by
1001
	   /*    Parameter is passed on stack, but is kept in reg given by
989
	   **  no(bdy).  **/
1002
	   **  no(bdy).  **/
990
	   if (isvar(bdy))
1003
	   if (isvar(bdy))
991
	   {
1004
	   {
992
	      baseoff b;
1005
	      baseoff b;
993
	      b.base = SP;
1006
	      b.base = SP;
994
	      b.offset = -((no(sbdy)+params_offset)>>3);
1007
	      b.offset = - ((no(sbdy) +params_offset) >>3);
995
	      if (is_floating(name(sh(sbdy))))
1008
	      if (is_floating(name(sh(sbdy))))
996
	      {	
1009
	      {
997
		 /**  Cannot occur whilst floats are kept on the stack.  **/
1010
		 /**  Cannot occur whilst floats are kept on the stack.  **/
998
	      }
1011
	      }
999
	      else
1012
	      else
1000
	      {
1013
	      {
1001
		 st_ins(i_sw,no(bdy),b);
1014
		 st_ins(i_sw,no(bdy),b);
1002
	      }
1015
	      }
1003
	   }
1016
	   }
1004
	}
1017
	}
1005
	else
1018
	else
1006
	if ( pr && (props(bdy)&inanyreg) == 0 )
1019
	if (pr && (props(bdy) &inanyreg) == 0)
1007
	{
1020
	{
1008
	   /**  Parameter is passed in reg, but is kept on stack.  **/ 
1021
	   /**  Parameter is passed in reg, but is kept on stack.  **/
1009
	   if (Has_no_vcallers)
1022
	   if (Has_no_vcallers)
1010
	   {
1023
	   {
1011
	      baseoff stkpos;
1024
	      baseoff stkpos;
1012
	      int off,sz = shape_size(sh(sbdy));
1025
	      int off,sz = shape_size(sh(sbdy));
1013
	      off = -((no(sbdy)+params_offset)>>3);
1026
	      off = - ((no(sbdy) +params_offset) >>3);
1014
	      stkpos.base = Has_vcallees ? FP : EP;
1027
	      stkpos.base = Has_vcallees ? FP : EP;
1015
	      stkpos.offset = off;
1028
	      stkpos.offset = off;
1016
	      if (is_floating(name(sh(sbdy))))
1029
	      if (is_floating(name(sh(sbdy))))
1017
	      {	
1030
	      {
1018
		 ldf_ins( sz == 64 ? i_fldd : i_fldw, stkpos, pr ) ;
1031
		 ldf_ins(sz == 64 ? i_fldd : i_fldw, stkpos, pr);
1019
	      }
1032
	      }
1020
	      else 
1033
	      else
1021
	      {
1034
	      {
1022
		 ld_ins( i_lw, 1, stkpos, pr ) ;
1035
		 ld_ins(i_lw, 1, stkpos, pr);
1023
		 if ( sz > 32 )
1036
		 if (sz > 32)
1024
		 {
1037
		 {
1025
		    /*    Parameter must be a compound passed by value with
1038
		    /*    Parameter must be a compound passed by value with
1026
		    **  sz<=64, load the second half into register.  **/
1039
		    **  sz<=64, load the second half into register.  **/
1027
		    stkpos.offset+=4;
1040
		    stkpos.offset+=4;
1028
		    ld_ins( i_lw, 1, stkpos, pr-1 ) ;
1041
		    ld_ins(i_lw, 1, stkpos, pr-1);
1029
		 }
1042
		 }
1030
	      }
1043
	      }
1031
	   }
1044
	   }
1032
	}
1045
	}
1033
	else 
1046
	else
1034
	if ( pr != 0 && props(sbdy) != no(bdy) )
1047
	if (pr != 0 && props(sbdy)!= no(bdy))
1035
	{
1048
	{
1036
	   /*    Parameter is passed in a different register to that which
1049
	   /*    Parameter is passed in a different register to that which
1037
	   **  it is kept in.  **/
1050
	   **  it is kept in.  **/
1038
	   if ( is_floating( name(sh(sbdy))) )
1051
	   if (is_floating(name(sh(sbdy))))
1039
	   {
1052
	   {
1040
	      /**  Cannot occur whilst floats are kept on the stack.  **/
1053
	      /**  Cannot occur whilst floats are kept on the stack.  **/
1041
	   }
1054
	   }
1042
	   else 
1055
	   else
1043
	   {
1056
	   {
1044
	      if (Has_no_vcallers)
1057
	      if (Has_no_vcallers)
1045
		 rr_ins( i_copy, no(bdy), pr ) ;
1058
		 rr_ins(i_copy, no(bdy), pr);
1046
	      else
1059
	      else
1047
	      {
1060
	      {
1048
		 baseoff b;
1061
		 baseoff b;
1049
		 b.base = Has_vcallees ? FP : EP;
1062
		 b.base = Has_vcallees ? FP : EP;
1050
		 b.offset = -((((pr-GR26)<<3)+params_offset)>>3);
1063
		 b.offset = - ((((pr-GR26) <<3) +params_offset) >>3);
1051
		 st_ins(i_sw,no(bdy),b);
1064
		 st_ins(i_sw,no(bdy),b);
1052
	      }
1065
	      }
1053
	   }	
1066
	   }
1054
	}
1067
	}
1055
	bdy = bro(sbdy);
1068
	bdy = bro(sbdy);
1056
     }        
1069
     }
1057
     if ( !Has_no_vcallers )
1070
     if (!Has_no_vcallers)
1058
     {
1071
     {
1059
	int r;
1072
	int r;
1060
	baseoff b;
1073
	baseoff b;
1061
	b.base = Has_vcallees ? FP : EP;
1074
	b.base = Has_vcallees ? FP : EP;
1062
	b.offset = -36;
1075
	b.offset = -36;
1063
	for (r=GR26;r<=GR23;r++)
1076
	for (r=GR26;r<=GR23;r++)
1064
	{
1077
	{
1065
	   ld_ins( i_lw, 1, b, r ) ;
1078
	   ld_ins(i_lw, 1, b, r);
1066
	   b.offset-=4;
1079
	   b.offset-=4;
1067
	}
1080
	}
1068
     }
1081
     }
1069
 
1082
 
1070
     if ( !glob )
1083
     if (!glob)
1071
     {
1084
     {
1072
	ld_ins( i_ldw, 1, mem_temp(0), GR22 ) ;
1085
	ld_ins(i_ldw, 1, mem_temp(0), GR22);
1073
     }
1086
     }
1074
     if ( name(cees) == make_callee_list_tag )
1087
     if (name(cees) == make_callee_list_tag)
1075
     {
1088
     {
1076
       	/** Copy callees from top of stack. **/
1089
       	/** Copy callees from top of stack. **/
1077
	int i ;
1090
	int i;
1078
	baseoff b ;
1091
	baseoff b;
1079
	b.offset = -(frame_sz>>3) ;
1092
	b.offset = - (frame_sz>>3);
1080
	if ( !Has_fp )
1093
	if (!Has_fp)
1081
	{
1094
	{
1082
	   b.base = (Has_vsp ? EP : SP) ;
1095
	   b.base = (Has_vsp ? EP : SP);
1083
	   ld_ins(i_lo,0,b,T4);
1096
	   ld_ins(i_lo,0,b,T4);
1084
	}
1097
	}
1085
	if ( call_has_vcallees(cees) ) 
1098
	if (call_has_vcallees(cees))
1086
	{
1099
	{
1087
	   /**  Store the callee size.  **/
1100
	   /**  Store the callee size.  **/
1088
	   ir_ins( i_ldi, fs_, empty_ltrl, no(cees) >> 3, GR1 ) ;
1101
	   ir_ins(i_ldi, fs_, empty_ltrl, no(cees) >> 3, GR1);
1089
	   st_ir_ins( i_stw, cmplt_, GR1, fs_, empty_ltrl, 64,                                       Has_fp ? FP : T4 ) ; 
1102
	   st_ir_ins(i_stw, cmplt_, GR1, fs_, empty_ltrl, 64,                                       Has_fp ? FP : T4);
1090
	}
1103
	}
1091
       	for( i = 0 ; i < (no(cees) >> 3) ; i += 4 )
1104
       	for (i = 0; i < (no(cees) >> 3); i += 4)
1092
	{
1105
	{
1093
	   b.base = SP ;
1106
	   b.base = SP;
1094
       	   b.offset = i + (18 << 2) ;
1107
       	   b.offset = i + (18 << 2);
1095
	   ld_ins( i_lw, 0, b, T3 ) ;
1108
	   ld_ins(i_lw, 0, b, T3);
1096
	   b.base = Has_fp ? FP : T4;
1109
	   b.base = Has_fp ? FP : T4;
1097
       	   st_ins( i_sw, T3, b ) ;
1110
       	   st_ins(i_sw, T3, b);
1098
       	}
1111
       	}
1099
    	/* 
1112
    	/*
1100
    	**	sp + 72 + 0  ->  sp -(frame size) + 72 + 0
1113
    	**	sp + 72 + 0  ->  sp -(frame size) + 72 + 0
1101
    	**	sp + 72 + 4  ->  sp -(frame size) + 72 + 4
1114
    	**	sp + 72 + 4  ->  sp -(frame size) + 72 + 4
1102
    	**	sp + 72 + 8  ->  sp -(frame size) + 72 + 8
1115
    	**	sp + 72 + 8  ->  sp -(frame size) + 72 + 8
1103
    	**                     ....     
1116
    	**                     ....
1104
    	**                     ....     
1117
    	**                     ....
1105
    	*/
1118
    	*/
1106
	if ( Has_fp )
1119
	if (Has_fp)
1107
	{
1120
	{
1108
	   rr_ins( i_copy, FP, SP ) ;
1121
	   rr_ins(i_copy, FP, SP);
1109
	}
1122
	}
1110
	else
1123
	else
1111
	{
1124
	{
1112
	   rr_ins( i_copy, T4, SP ) ;
1125
	   rr_ins(i_copy, T4, SP);
1113
	}
1126
	}
1114
     }
1127
     }
1115
     else
1128
     else
1116
     if ( name(cees) == make_dynamic_callee_tag )
1129
     if (name(cees) == make_dynamic_callee_tag)
1117
     {
1130
     {
1118
	int lb,le;
1131
	int lb,le;
1119
	baseoff b;
1132
	baseoff b;
1120
 
1133
 
1121
	if ( Has_fp )
1134
	if (Has_fp)
1122
	   rr_ins( i_copy, FP, SP ) ;
1135
	   rr_ins(i_copy, FP, SP);
1123
	else
1136
	else
1124
	{
1137
	{
1125
	   b.offset = - (frame_sz>>3);
1138
	   b.offset = - (frame_sz>>3);
1126
	   b.base = ( Has_vsp ? EP : SP ) ;
1139
	   b.base = (Has_vsp ? EP : SP);
1127
	   ld_ins( i_lo, 0, b, SP ) ;
1140
	   ld_ins(i_lo, 0, b, SP);
1128
	}
1141
	}
1129
	b.base = SP;  b.offset = 68;
1142
	b.base = SP;  b.offset = 68;
1130
 
1143
 
1131
	ld_ins(i_lw,0,b,T2);
1144
	ld_ins(i_lw,0,b,T2);
1132
	/**  T2 = pointer to the bytes constituting the dynamic callees. **/
1145
	/**  T2 = pointer to the bytes constituting the dynamic callees. **/
1133
	b.offset-=4;
1146
	b.offset-=4;
1134
	ld_ins(i_lw,0,b,T3);
1147
	ld_ins(i_lw,0,b,T3);
1135
	/**  T3 = number of bytes constituting the dynamic callees.  **/
1148
	/**  T3 = number of bytes constituting the dynamic callees.  **/
1136
 
1149
 
1137
	lb = new_label();
1150
	lb = new_label();
1138
	le = new_label();
1151
	le = new_label();
1139
	cj_ins( c_eq, 0, T3, le ) ;
1152
	cj_ins(c_eq, 0, T3, le);
1140
	rrr_ins( i_add, c_, T2, T3, T4 ) ;
1153
	rrr_ins(i_add, c_, T2, T3, T4);
1141
	ld_ir_ins( i_ldo, cmplt_, fs_, empty_ltrl, 18<<2, SP, T3) ;   
1154
	ld_ir_ins(i_ldo, cmplt_, fs_, empty_ltrl, 18<<2, SP, T3);
1142
	outlab("L$$",lb) ;
1155
	outlab("L$$",lb);
1143
	ld_ir_ins( i_ldbs, cmplt_MA, fs_, empty_ltrl, 1, T2, GR1 ) ;
1156
	ld_ir_ins(i_ldbs, cmplt_MA, fs_, empty_ltrl, 1, T2, GR1);
1144
	comb_ins( c_l, T2, T4, lb ) ;
1157
	comb_ins(c_l, T2, T4, lb);
1145
	st_ir_ins( i_stbs, cmplt_MA, GR1, fs_, empty_ltrl, 1, T3 ) ;
1158
	st_ir_ins(i_stbs, cmplt_MA, GR1, fs_, empty_ltrl, 1, T3);
1146
	outlab("L$$",le);
1159
	outlab("L$$",le);
1147
     }
1160
     }
1148
     else
1161
     else
1149
     {
1162
     {
1150
	if ( Has_fp )
1163
	if (Has_fp)
1151
	   rr_ins( i_copy, FP, SP ) ;
1164
	   rr_ins(i_copy, FP, SP);
1152
	else
1165
	else
1153
	{
1166
	{
1154
	   baseoff b;
1167
	   baseoff b;
1155
	   b.offset = -(frame_sz>>3);
1168
	   b.offset = - (frame_sz>>3);
1156
	   b.base = ( Has_vsp ? EP : SP ) ;
1169
	   b.base = (Has_vsp ? EP : SP);
1157
	   ld_ins( i_lo, 0, b, SP ) ;
1170
	   ld_ins(i_lo, 0, b, SP);
1158
	}
1171
	}
1159
	if ( name(cees) == same_callees_tag && call_has_vcallees(cees)                     && !Has_vcallees )
1172
	if (name(cees) == same_callees_tag && call_has_vcallees(cees)                    && !Has_vcallees)
1160
	{
1173
	{
1161
	      /*  We must store the sum of the callee sizes - it hasn't
1174
	      /*  We must store the sum of the callee sizes - it hasn't
1162
	      **  yet been done.  **/
1175
	      **  yet been done.  **/
1163
	      ir_ins( i_ldi, fs_, empty_ltrl, no(cees) >> 3, GR1 ) ;
1176
	      ir_ins(i_ldi, fs_, empty_ltrl, no(cees) >> 3, GR1);
1164
	      st_ir_ins( i_stw, cmplt_, GR1, fs_, empty_ltrl, 64, SP );
1177
	      st_ir_ins(i_stw, cmplt_, GR1, fs_, empty_ltrl, 64, SP);
1165
	}
1178
	}
1166
 
1179
 
1167
     }
1180
     }
1168
     restore_sregs();  /**  Restore s-regs.  **/
1181
     restore_sregs();  /**  Restore s-regs.  **/
1169
     ld_ir_ins( i_ldw, cmplt_, fs_, empty_ltrl, -20, SP, RP ) ;
1182
     ld_ir_ins(i_ldw, cmplt_, fs_, empty_ltrl, -20, SP, RP);
1170
     if ( glob )
1183
     if (glob)
1171
     {
1184
     {
1172
	call_ins(cmplt_, TARGET(fn), 0, "");
1185
	call_ins(cmplt_, TARGET(fn), 0, "");
1173
     }
1186
     }
1174
     else
1187
     else
1175
     {
1188
     {
1176
	call_millicode(MILLI_DYNCALL, 0, "", 1);
1189
	call_millicode(MILLI_DYNCALL, 0, "", 1);
1177
     }
1190
     }
1178
     return mka;
1191
     return mka;
1179
  }
1192
  }
1180
	  
1193
 
1181
 
1194
 
1182
  case apply_tag:		/* procedure call */
1195
  case apply_tag:		/* procedure call */
1183
  {
1196
  {
1184
     exp fn = son(e);
1197
     exp fn = son(e);
1185
     exp par = bro(fn);
1198
     exp par = bro(fn);
1186
     int hda = name(sh(e));
1199
     int hda = name(sh(e));
1187
     int special;
1200
     int special;
1188
     space nsp;
1201
     space nsp;
1189
     int void_result = (name(sh(e))==tophd);
1202
     int void_result = (name(sh(e)) ==tophd);
1190
     int reg_res = reg_result(sh(e));
1203
     int reg_res = reg_result(sh(e));
1191
     makeans mka;
1204
     makeans mka;
1192
     exp dad = father(e);
1205
     exp dad = father(e);
1193
     bool tlrecurse = RSCOPE_LEVEL==0 && (name(dad)==res_tag) && props(dad);
1206
     bool tlrecurse = RSCOPE_LEVEL==0 && (name(dad) ==res_tag) && props(dad);
1194
     char stub[128];  /* relocation stub */
1207
     char stub[128];  /* relocation stub */
1195
     nsp = sp ;
1208
     nsp = sp;
1196
     stub[0]='\t';
1209
     stub[0] ='\t';
1197
     stub[1]='\0';
1210
     stub[1] ='\0';
1198
 
1211
 
1199
     mka.lab = exitlab;
1212
     mka.lab = exitlab;
1200
     mka.regmove = NOREG;
1213
     mka.regmove = NOREG;
1201
 
1214
 
1202
     /* first see if it is a special to be handled inline */
1215
     /* first see if it is a special to be handled inline */
Line 1207... Line 1220...
1207
     }
1220
     }
1208
 
1221
 
1209
     if (!last(fn))
1222
     if (!last(fn))
1210
	nsp = do_callers(par,sp,stub);
1223
	nsp = do_callers(par,sp,stub);
1211
 
1224
 
1212
     if (!reg_res && !void_result && shape_size(sh(e))>64)
1225
     if (!reg_res && !void_result && shape_size(sh(e)) >64)
1213
     {
1226
     {
1214
	/* structure or union result, address passed in %r28 (=RET0) */
1227
	/* structure or union result, address passed in %r28 (=RET0) */
1215
	instore is;
1228
	instore is;
1216
	assert(discrim (dest.answhere) == notinreg);
1229
	assert(discrim(dest.answhere) == notinreg);
1217
	/* struct must be in memory */
1230
	/* struct must be in memory */
1218
	is = insalt(dest.answhere);
1231
	is = insalt(dest.answhere);
1219
	if (is.adval)
1232
	if (is.adval)
1220
	{
1233
	{
1221
	   /* generate address of dest */
1234
	   /* generate address of dest */
1222
	   if (IS_FIXREG(is.b.base))
1235
	   if (IS_FIXREG(is.b.base))
1223
	      ld_ins(i_lo,SIGNED,is.b,RET0);
1236
	      ld_ins(i_lo,SIGNED,is.b,RET0);
1224
	   else
1237
	   else
1225
 	      set_ins("",is.b,RET0);   
1238
 	      set_ins("",is.b,RET0);
1226
	}
1239
	}
1227
	else
1240
	else
1228
	   ld_ins(i_lw,SIGNED,is.b,RET0);
1241
	   ld_ins(i_lw,SIGNED,is.b,RET0);
1229
	nsp = guardreg(RET0,nsp);
1242
	nsp = guardreg(RET0,nsp);
1230
     }
1243
     }
Line 1245... Line 1258...
1245
     {
1258
     {
1246
	reg_operand_here(fn,nsp,GR22);
1259
	reg_operand_here(fn,nsp,GR22);
1247
	call_millicode(MILLI_DYNCALL,RP,stub,1);
1260
	call_millicode(MILLI_DYNCALL,RP,stub,1);
1248
     }
1261
     }
1249
 
1262
 
1250
     if (!reg_res && !void_result && (shape_size(sh(e))<65))
1263
     if (!reg_res && !void_result && (shape_size(sh(e)) <65))
1251
     {
1264
     {
1252
	/* 64 bit structure or union result returned in RET0 and RET1 */
1265
	/* 64 bit structure or union result returned in RET0 and RET1 */
1253
	instore is;
1266
	instore is;
1254
	is = insalt(dest.answhere);
1267
	is = insalt(dest.answhere);
1255
	if (is.adval)
1268
	if (is.adval)
Line 1265... Line 1278...
1265
	   b.base=GR1;
1278
	   b.base=GR1;
1266
	   b.offset=0;
1279
	   b.offset=0;
1267
	   st_ins(i_sw,RET0,b);
1280
	   st_ins(i_sw,RET0,b);
1268
	   b.offset+=4;
1281
	   b.offset+=4;
1269
	   st_ins(i_sw,RET1,b);
1282
	   st_ins(i_sw,RET1,b);
1270
	}
1283
	}
1271
     }
1284
     }
1272
 
1285
 
1273
     clear_all();
1286
     clear_all();
1274
 
1287
 
1275
     if (reg_res)
1288
     if (reg_res)
1276
     {
1289
     {
1277
	ans aa;
1290
	ans aa;
Line 1285... Line 1298...
1285
	   /* move floating point result of application to destination */
1298
	   /* move floating point result of application to destination */
1286
	}
1299
	}
1287
	else
1300
	else
1288
	{
1301
	{
1289
	   setregalt(aa,RET0);
1302
	   setregalt(aa,RET0);
1290
	   if ( discrim(dest.answhere)==inreg )
1303
	   if (discrim(dest.answhere) ==inreg)
1291
	   {
1304
	   {
1292
	      int r = regalt(dest.answhere);
1305
	      int r = regalt(dest.answhere);
1293
	      if ( r!=RET0 && r!=GR0 )
1306
	      if (r!=RET0 && r!=GR0)
1294
	      {
1307
	      {
1295
		 /* Move from RET0 */
1308
		 /* Move from RET0 */
1296
		 move(aa,dest,sp.fixed,1);
1309
		 move(aa,dest,sp.fixed,1);
1297
	      }
1310
	      }
1298
	      mka.regmove = RET0;
1311
	      mka.regmove = RET0;
1299
	   }
1312
	   }
1300
	   else
1313
	   else
1301
	   {
1314
	   {
1302
	      /* dest not inreg */
1315
	      /* dest not inreg */
1303
	      move(aa,dest,sp.fixed,1);
1316
	      move(aa,dest,sp.fixed,1);
1304
	   }
1317
	   }
Line 1313... Line 1326...
1313
      exp cers = bro(fn);
1326
      exp cers = bro(fn);
1314
      exp cees = bro(cers);
1327
      exp cees = bro(cers);
1315
      exp pl = bro(cees);
1328
      exp pl = bro(cees);
1316
      space nsp;
1329
      space nsp;
1317
      char stub[128];  /* relocation stub */
1330
      char stub[128];  /* relocation stub */
1318
      stub[0]='\t';
1331
      stub[0] ='\t';
1319
      stub[1]='\0';
1332
      stub[1] ='\0';
1320
    	  
1333
 
1321
      if (no(cers) !=0)
1334
      if (no(cers)!=0)
1322
	 nsp = do_callers(son(cers),sp,stub);
1335
	 nsp = do_callers(son(cers),sp,stub);
1323
      else
1336
      else
1324
	 nsp = sp;
1337
	 nsp = sp;
1325
 
1338
 
1326
      (void) make_code(cees,nsp,nowhere,0);
1339
     (void)make_code(cees,nsp,nowhere,0);
1327
    	  
1340
 
1328
      if (!reg_result(sh(e)) && name(sh(e))!=tophd && shape_size(sh(e))>64)
1341
      if (!reg_result(sh(e)) && name(sh(e))!=tophd && shape_size(sh(e)) >64)
1329
      {
1342
      {
1330
	 /* Must be a structure or union result, pass address in RET0 */
1343
	 /* Must be a structure or union result, pass address in RET0 */
1331
	 instore is;
1344
	 instore is;
1332
	 assert(discrim (dest.answhere) == notinreg);
1345
	 assert(discrim(dest.answhere) == notinreg);
1333
	 /* struct must be in memory */
1346
	 /* struct must be in memory */
1334
	 is = insalt(dest.answhere);
1347
	 is = insalt(dest.answhere);
1335
	 if (is.adval)
1348
	 if (is.adval)
1336
	 {
1349
	 {
1337
	    /* generate address of dest */
1350
	    /* generate address of dest */
1338
	    if (IS_FIXREG(is.b.base))
1351
	    if (IS_FIXREG(is.b.base))
1339
	       ld_ins(i_lo,SIGNED,is.b,RET0);
1352
	       ld_ins(i_lo,SIGNED,is.b,RET0);
1340
	    else
1353
	    else
1341
 	       set_ins("",is.b,RET0);   
1354
 	       set_ins("",is.b,RET0);
1342
	 }
1355
	 }
1343
	 else
1356
	 else
1344
	    ld_ins(i_lw,SIGNED,is.b,RET0);
1357
	    ld_ins(i_lw,SIGNED,is.b,RET0);
1345
	 nsp = guardreg(RET0,nsp);
1358
	 nsp = guardreg(RET0,nsp);
1346
      }
1359
      }
1347
 
1360
 
1348
      if (is_fn_glob(fn))
1361
      if (is_fn_glob(fn))
1349
      { 
1362
      {
1350
	 call_ins(cmplt_,TARGET(fn),RP,stub);  
1363
	 call_ins(cmplt_,TARGET(fn),RP,stub);
1351
      } 
1364
      }
1352
      else
1365
      else
1353
      {
1366
      {
1354
	 reg_operand_here(fn,nsp,GR22);
1367
	 reg_operand_here(fn,nsp,GR22);
1355
	 call_millicode(MILLI_DYNCALL,RP,stub,1);
1368
	 call_millicode(MILLI_DYNCALL,RP,stub,1);
1356
      }
1369
      }
Line 1362... Line 1375...
1362
	 if (is_floating(hda))
1375
	 if (is_floating(hda))
1363
	 {
1376
	 {
1364
	    freg frg;
1377
	    freg frg;
1365
	    frg.fr = R_FR4;
1378
	    frg.fr = R_FR4;
1366
	    frg.dble = (hda != shrealhd);
1379
	    frg.dble = (hda != shrealhd);
1367
	    setfregalt (aa, frg);
1380
	    setfregalt(aa, frg);
1368
	    move (aa, dest, sp.fixed, 1);
1381
	    move(aa, dest, sp.fixed, 1);
1369
	    /* move floating point result of application to destination */
1382
	    /* move floating point result of application to destination */
1370
	 }
1383
	 }
1371
	 else
1384
	 else
1372
	 {
1385
	 {
1373
	    setregalt (aa, RET0);
1386
	    setregalt(aa, RET0);
1374
	    mka.regmove = RET0;
1387
	    mka.regmove = RET0;
1375
	    move (aa, dest, sp.fixed, 1);
1388
	    move(aa, dest, sp.fixed, 1);
1376
	    /* move fixed point result of application to destination */
1389
	    /* move fixed point result of application to destination */
1377
	 }
1390
	 }
1378
      }
1391
      }
1379
      else
1392
      else
1380
      if (name(sh(e))!=tophd && (shape_size(sh(e))<65))
1393
      if (name(sh(e))!=tophd && (shape_size(sh(e)) <65))
1381
      {
1394
      {
1382
	 /* 64 bit structure or union result returned in RET0 and RET1 */
1395
	 /* 64 bit structure or union result returned in RET0 and RET1 */
1383
	 instore is;
1396
	 instore is;
1384
	 is = insalt(dest.answhere);
1397
	 is = insalt(dest.answhere);
1385
	 if (discrim(dest.answhere)==inreg && dest.answhere.val.regans==GR0)
1398
	 if (discrim(dest.answhere) ==inreg && dest.answhere.val.regans==GR0)
1386
	 {
1399
	 {
1387
	    /* dest is nowhere, do nothing */
1400
	    /* dest is nowhere, do nothing */
1388
	 }
1401
	 }
1389
	 else if (is.adval)
1402
	 else if (is.adval)
1390
	 {
1403
	 {
Line 1401... Line 1414...
1401
	    st_ins(i_sw,RET0,b);
1414
	    st_ins(i_sw,RET0,b);
1402
	    b.offset+=4;
1415
	    b.offset+=4;
1403
	    st_ins(i_sw,RET1,b);
1416
	    st_ins(i_sw,RET1,b);
1404
	 }
1417
	 }
1405
      }
1418
      }
1406
      if ( call_is_untidy(cees) )
1419
      if (call_is_untidy(cees))
1407
      {
1420
      {
1408
	 int ma = (max_args+511)&(~511);
1421
	 int ma = (max_args+511) & (~511);
1409
	 ld_ir_ins(i_ldo,cmplt_,fs_,empty_ltrl,(ma>>3),SP,SP);
1422
	 ld_ir_ins(i_ldo,cmplt_,fs_,empty_ltrl,(ma>>3),SP,SP);
1410
	 if (Has_tos)
1423
	 if (Has_tos)
1411
	    reset_tos();
1424
	    reset_tos();
1412
	 if (PIC_code)
1425
	 if (PIC_code)
1413
	    st_ir_ins(i_stw,cmplt_,GR5,fs_,empty_ltrl,-32,SP);
1426
	    st_ir_ins(i_stw,cmplt_,GR5,fs_,empty_ltrl,-32,SP);
Line 1415... Line 1428...
1415
      else
1428
      else
1416
      if (postlude_has_call(e))
1429
      if (postlude_has_call(e))
1417
      {
1430
      {
1418
	 exp x = son(cers);
1431
	 exp x = son(cers);
1419
	 postl_chain p;
1432
	 postl_chain p;
1420
	 int ma = (max_args+511)&(~511);
1433
	 int ma = (max_args+511) & (~511);
1421
	 for(;x!=nilexp;)
1434
	 for (;x!=nilexp;)
1422
	 {
1435
	 {
1423
	    if (name(x)==caller_tag) 
1436
	    if (name(x) ==caller_tag)
1424
	    {
1437
	    {
1425
	       no(x) += ma;
1438
	       no(x) += ma;
1426
	    }      
1439
	    }
1427
	    if ( last(x) )
1440
	    if (last(x))
1428
	       break;
1441
	       break;
1429
	    else
1442
	    else
1430
	       x = bro(x);
1443
	       x = bro(x);
1431
	 }
1444
	 }
1432
	 mka.regmove = NOREG;
1445
	 mka.regmove = NOREG;
1433
	 update_plc(old_pls,ma);
1446
	 update_plc(old_pls,ma);
1434
	 p.pl = pl;
1447
	 p.pl = pl;
1435
	 p.outer = old_pls;
1448
	 p.outer = old_pls;
1436
	 old_pls = &p;
1449
	 old_pls = &p;
1437
	 ld_ir_ins(i_ldo,cmplt_,fs_,empty_ltrl,ma>>3,SP,SP);
1450
	 ld_ir_ins(i_ldo,cmplt_,fs_,empty_ltrl,ma>>3,SP,SP);
1438
	 (void) make_code(pl, sp, nowhere, 0);
1451
	(void)make_code(pl, sp, nowhere, 0);
1439
	 ld_ir_ins(i_ldo,cmplt_,fs_,empty_ltrl,-(ma>>3),SP,SP);
1452
	 ld_ir_ins(i_ldo,cmplt_,fs_,empty_ltrl,- (ma>>3),SP,SP);
1440
	 old_pls = p.outer;
1453
	 old_pls = p.outer;
1441
	 update_plc(old_pls,-ma);
1454
	 update_plc(old_pls,-ma);
1442
      }
1455
      }
1443
      else
1456
      else
1444
	 (void) make_code(pl, sp, nowhere, 0);
1457
	(void)make_code(pl, sp, nowhere, 0);
1445
      return mka;
1458
      return mka;
1446
  }
1459
  }
1447
    
1460
 
1448
 
1461
 
1449
  case caller_name_tag:
1462
  case caller_name_tag:
1450
  {
1463
  {
1451
     return mka;
1464
     return mka;
1452
  }
1465
  }
1453
 
1466
 
1454
  case caller_tag:
1467
  case caller_tag:
1455
  {
1468
  {
1456
     e = son(e); goto tailrecurse;
1469
     e = son(e); goto tailrecurse;
1457
  }
1470
  }
1458
 
1471
 
1459
 
1472
 
1460
  case make_callee_list_tag:
1473
  case make_callee_list_tag:
1461
  {
1474
  {
1462
     bool vc = call_has_vcallees(e);
1475
     bool vc = call_has_vcallees(e);
1463
     do_callee_list( e, sp );    
1476
     do_callee_list(e, sp);
1464
     if (vc)
1477
     if (vc)
1465
     {
1478
     {
1466
	 ir_ins(i_ldi,fs_,empty_ltrl,no(e)>>3,GR1);
1479
	 ir_ins(i_ldi,fs_,empty_ltrl,no(e) >>3,GR1);
1467
	 st_ir_ins(i_stw,cmplt_,GR1,fs_,empty_ltrl,64,SP);
1480
	 st_ir_ins(i_stw,cmplt_,GR1,fs_,empty_ltrl,64,SP);
1468
     }
1481
     }
1469
     return mka;
1482
     return mka;
1470
  }
1483
  }
1471
 
1484
 
Line 1482... Line 1495...
1482
	ld_ir_ins(i_ldw,cmplt_,fs_,empty_ltrl,64,FP,T4);
1495
	ld_ir_ins(i_ldw,cmplt_,fs_,empty_ltrl,64,FP,T4);
1483
	comb_ins(c_eq,0,T4,endl);
1496
	comb_ins(c_eq,0,T4,endl);
1484
	if (vc)
1497
	if (vc)
1485
	{
1498
	{
1486
	   st_ir_ins(i_stw,cmplt_,T4,fs_,empty_ltrl,64,SP);
1499
	   st_ir_ins(i_stw,cmplt_,T4,fs_,empty_ltrl,64,SP);
1487
	}
1500
	}
1488
	else
1501
	else
1489
	{
1502
	{
1490
	   z_ins(i_nop);
1503
	   z_ins(i_nop);
1491
	}
1504
	}
1492
	/*
1505
	/*
Line 1498... Line 1511...
1498
	outlab("L$$",startl);
1511
	outlab("L$$",startl);
1499
	ld_ir_ins(i_ldbs,cmplt_MA,fs_,empty_ltrl,1,T3,GR1);
1512
	ld_ir_ins(i_ldbs,cmplt_MA,fs_,empty_ltrl,1,T3,GR1);
1500
	comb_ins(c_l,T3,T4,startl);
1513
	comb_ins(c_l,T3,T4,startl);
1501
	st_ir_ins(i_stbs,cmplt_MA,GR1,fs_,empty_ltrl,1,T2);
1514
	st_ir_ins(i_stbs,cmplt_MA,GR1,fs_,empty_ltrl,1,T2);
1502
	outlab("L$$",endl);
1515
	outlab("L$$",endl);
1503
     }
1516
     }
1504
     else
1517
     else
1505
     {
1518
     {
1506
	int csz = (callee_sz>>3);
1519
	int csz = (callee_sz>>3);
1507
	if (csz)
1520
	if (csz)
1508
	{
1521
	{
1509
	   int co = -(callees_offset>>3);
1522
	   int co = - (callees_offset>>3);
1510
	   imm_to_r(csz,T4);
1523
	   imm_to_r(csz,T4);
1511
	   if (vc)
1524
	   if (vc)
1512
	   {
1525
	   {
1513
	      st_ir_ins(i_stw,cmplt_,T4,fs_,empty_ltrl,64,SP);
1526
	      st_ir_ins(i_stw,cmplt_,T4,fs_,empty_ltrl,64,SP);
1514
	   }
1527
	   }
1515
	   if (csz<17)
1528
	   if (csz<17)
1516
	   {
1529
	   {
1517
	       /*  16 or fewer bytes to move - may as well move them word
1530
	       /*  16 or fewer bytes to move - may as well move them word
1518
		   by word then finish off byte by byte.  */
1531
		   by word then finish off byte by byte.  */
1519
	      int nw = csz&(~3);
1532
	      int nw = csz& (~3);
1520
	      int o,base,off;
1533
	      int o,base,off;
1521
	      if (SIMM14(co))
1534
	      if (SIMM14(co))
1522
	      {
1535
	      {
1523
		 base = EP;
1536
		 base = EP;
1524
		 off = co;
1537
		 off = co;
1525
	      }
1538
	      }
1526
	      else
1539
	      else
1527
	      {
1540
	      {
1528
		 ir_ins(i_addil,fs_L,empty_ltrl,co,EP);
1541
		 ir_ins(i_addil,fs_L,empty_ltrl,co,EP);
1529
		 ld_ir_ins(i_ldo,cmplt_,fs_R,empty_ltrl,co,GR1,T3);
1542
		 ld_ir_ins(i_ldo,cmplt_,fs_R,empty_ltrl,co,GR1,T3);
1530
		 base = T3;
1543
		 base = T3;
1531
		 off = 0;
1544
		 off = 0;
1532
	      }
1545
	      }
1533
	      for(o=0;o<nw;o+=4)
1546
	      for (o=0;o<nw;o+=4)
1534
	      {
1547
	      {
1535
		 ld_ir_ins(i_ldw,cmplt_,fs_,empty_ltrl,off+o,base,GR1);
1548
		 ld_ir_ins(i_ldw,cmplt_,fs_,empty_ltrl,off+o,base,GR1);
1536
		 st_ir_ins(i_stw,cmplt_,GR1,fs_,empty_ltrl,72+o,SP);
1549
		 st_ir_ins(i_stw,cmplt_,GR1,fs_,empty_ltrl,72+o,SP);
1537
	      }
1550
	      }
1538
	      for(;o<csz;o++)
1551
	      for (;o<csz;o++)
1539
	      {
1552
	      {
1540
		 ld_ir_ins(i_ldb,cmplt_,fs_,empty_ltrl,off+o,base,GR1);
1553
		 ld_ir_ins(i_ldb,cmplt_,fs_,empty_ltrl,off+o,base,GR1);
1541
		 st_ir_ins(i_stb,cmplt_,GR1,fs_,empty_ltrl,72+o,SP);
1554
		 st_ir_ins(i_stb,cmplt_,GR1,fs_,empty_ltrl,72+o,SP);
1542
	      }
1555
	      }
1543
	   }
1556
	   }
Line 1559... Line 1572...
1559
	     outlab("L$$",startl);
1572
	     outlab("L$$",startl);
1560
	     ld_ir_ins(i_ldbs,cmplt_MA,fs_,empty_ltrl,1,T3,GR1);
1573
	     ld_ir_ins(i_ldbs,cmplt_MA,fs_,empty_ltrl,1,T3,GR1);
1561
	     comb_ins(c_l,T3,T4,startl);
1574
	     comb_ins(c_l,T3,T4,startl);
1562
	     st_ir_ins(i_stbs,cmplt_MA,GR1,fs_,empty_ltrl,1,T2);
1575
	     st_ir_ins(i_stbs,cmplt_MA,GR1,fs_,empty_ltrl,1,T2);
1563
	   }
1576
	   }
1564
	}
1577
	}
1565
	else
1578
	else
1566
	if (vc)
1579
	if (vc)
1567
	{
1580
	{
1568
	   st_ir_ins(i_stw,cmplt_,0,fs_,empty_ltrl,64,SP);
1581
	   st_ir_ins(i_stw,cmplt_,0,fs_,empty_ltrl,64,SP);
1569
	}
1582
	}
1570
     }
1583
     }
1571
     return mka;
1584
     return mka;
1572
  }	
1585
  }
1573
 
1586
 
1574
 
1587
 
1575
    case make_dynamic_callee_tag:
1588
    case make_dynamic_callee_tag:
1576
    {
1589
    {
1577
       /* vc = call_has_vcallees(e);  it should do!  */
1590
       /* vc = call_has_vcallees(e);  it should do!  */
Line 1593... Line 1606...
1593
       lb = new_label();
1606
       lb = new_label();
1594
       le = new_label();
1607
       le = new_label();
1595
       st_ir_ins(i_stw,cmplt_,szr,fs_,empty_ltrl,64,SP);
1608
       st_ir_ins(i_stw,cmplt_,szr,fs_,empty_ltrl,64,SP);
1596
       cj_ins(c_eq,0,szr,le);
1609
       cj_ins(c_eq,0,szr,le);
1597
       rrr_ins(i_add,c_,lower,szr,upper);  /*  `upper' is where we stop  */
1610
       rrr_ins(i_add,c_,lower,szr,upper);  /*  `upper' is where we stop  */
1598
       ld_ir_ins(i_ldo,cmplt_,fs_,empty_ltrl,18<<2,SP,szr);   
1611
       ld_ir_ins(i_ldo,cmplt_,fs_,empty_ltrl,18<<2,SP,szr);
1599
       outlab("L$$",lb);
1612
       outlab("L$$",lb);
1600
       ld_ir_ins(i_ldbs,cmplt_MA,fs_,empty_ltrl,1,lower,GR1);
1613
       ld_ir_ins(i_ldbs,cmplt_MA,fs_,empty_ltrl,1,lower,GR1);
1601
       comb_ins(c_l,lower,upper,lb);
1614
       comb_ins(c_l,lower,upper,lb);
1602
       st_ir_ins(i_stbs,cmplt_MA,GR1,fs_,empty_ltrl,1,szr);
1615
       st_ir_ins(i_stbs,cmplt_MA,GR1,fs_,empty_ltrl,1,szr);
1603
       outlab("L$$",le);
1616
       outlab("L$$",le);
Line 1611... Line 1624...
1611
     where placew;
1624
     where placew;
1612
     int r = NOREG;
1625
     int r = NOREG;
1613
     bool remember = 0;
1626
     bool remember = 0;
1614
     exp se = son(e);
1627
     exp se = son(e);
1615
 
1628
 
1616
     if ( props(e) & defer_bit )
1629
     if (props(e) & defer_bit)
1617
     {
1630
     {
1618
 	return make_code(bro(se), sp, dest, exitlab);
1631
 	return make_code(bro(se), sp, dest, exitlab);
1619
     }
1632
     }
1620
     if ( se == nilexp )
1633
     if (se == nilexp)
1621
     {
1634
     {
1622
	/*  Historical - unused tags are now removed cleanly  */
1635
	/*  Historical - unused tags are now removed cleanly  */
1623
	placew = nowhere;
1636
	placew = nowhere;
1624
     }
1637
     }
1625
     else
1638
     else
1626
     if ( name(son(e)) == caller_name_tag )
1639
     if (name(son(e)) == caller_name_tag)
1627
     {
1640
     {
1628
	/* the ident of a caller in a postlude */
1641
	/* the ident of a caller in a postlude */
1629
	exp ote = find_ote(e,no(son(e)));
1642
	exp ote = find_ote(e,no(son(e)));
1630
       	no(e) = no(ote);
1643
       	no(e) = no(ote);
1631
	placew = nowhere;
1644
	placew = nowhere;
1632
     }
1645
     }
1633
     else
1646
     else
1634
     {
1647
     {
1635
	ash a ;
1648
	ash a;
1636
	int n = no(e);
1649
	int n = no(e);
1637
	a = ashof(sh(se));
1650
	a = ashof(sh(se));
1638
	if ( props(e) & inreg_bits )
1651
	if (props(e) & inreg_bits)
1639
	{
1652
	{
1640
	   /* tag is to be found in a fixed pt reg */
1653
	   /* tag is to be found in a fixed pt reg */
1641
	   if ( n == 0 )
1654
	   if (n == 0)
1642
	   {
1655
	   {
1643
 	      /*  We need to allocate a fixed t-reg  */
1656
 	      /*  We need to allocate a fixed t-reg  */
1644
	      int s = sp.fixed;
1657
	      int s = sp.fixed;
1645
	      if ( props(e) & notparreg )
1658
	      if (props(e) & notparreg)
1646
	      {
1659
	      {
1647
		 s |= PARAM_TREGS;
1660
		 s |= PARAM_TREGS;
1648
	      }
1661
	      }
1649
	      if (props(e)&notresreg)
1662
	      if (props(e) &notresreg)
1650
	      {
1663
	      {
1651
		 s |= RMASK(RET0);
1664
		 s |= RMASK(RET0);
1652
	      }
1665
	      }
1653
	      n = getreg(s);
1666
	      n = getreg(s);
1654
	      no(e) = n;
1667
	      no(e) = n;
1655
	   }
1668
	   }
1656
	   else
1669
	   else
1657
	   if ( n == RET0 )
1670
	   if (n == RET0)
1658
	   {
1671
	   {
1659
	      /* use result reg optimisation */
1672
	      /* use result reg optimisation */
1660
 	      assert(!(props(e) & notparreg));
1673
 	      assert(!(props(e) & notparreg));
1661
	      (void) needreg(RET0, sp);	/* just as an error check */
1674
	      (void) needreg(RET0, sp);	/* just as an error check */
1662
	   }
1675
	   }
Line 1665... Line 1678...
1665
	      assert(IS_SREG(n));
1678
	      assert(IS_SREG(n));
1666
	   }
1679
	   }
1667
	   setregalt(placew.answhere, n);
1680
	   setregalt(placew.answhere, n);
1668
	}
1681
	}
1669
	else
1682
	else
1670
	if ( props(e) & infreg_bits )
1683
	if (props(e) & infreg_bits)
1671
	{
1684
	{
1672
	   /* tag in some float reg */
1685
	   /* tag in some float reg */
1673
	   freg frg;
1686
	   freg frg;
1674
	   if ( n == 0 )
1687
	   if (n == 0)
1675
	   {
1688
	   {
1676
	      /*
1689
	      /*
1677
	       * if it hasn't been already allocated into a s-reg
1690
	       * if it hasn't been already allocated into a s-reg
1678
	       * allocate tag into float-reg ...
1691
	       * allocate tag into float-reg ...
1679
	       */
1692
	       */
1680
	      int s = sp.flt;
1693
	      int s = sp.flt;
1681
	      if ( props(e) & notparreg )
1694
	      if (props(e) & notparreg)
1682
		 s |= PARAM_FLT_TREGS;	
1695
		 s |= PARAM_FLT_TREGS;
1683
	      n = getfreg(s);
1696
	      n = getfreg(s);
1684
	      no(e) = n;
1697
	      no(e) = n;
1685
	   }
1698
	   }
1686
	   else
1699
	   else
1687
	   if ( n == R_DEFER_FR4 )
1700
	   if (n == R_DEFER_FR4)
1688
	   {
1701
	   {
1689
	      n = R_FR4;
1702
	      n = R_FR4;
1690
	      no(e) = R_FR4;
1703
	      no(e) = R_FR4;
1691
	   }
1704
	   }
1692
	   else
1705
	   else
Line 1695... Line 1708...
1695
	   }
1708
	   }
1696
	   frg.fr = n;
1709
	   frg.fr = n;
1697
	   frg.dble = (a.ashsize==64 ? 1 : 0);
1710
	   frg.dble = (a.ashsize==64 ? 1 : 0);
1698
	   setfregalt(placew.answhere, frg);
1711
	   setfregalt(placew.answhere, frg);
1699
	}
1712
	}
1700
	else 
1713
	else
1701
	if ( isparam(e) )
1714
	if (isparam(e))
1702
	{
1715
	{
1703
 	   instore is;
1716
 	   instore is;
1704
	   long n = no(se);  /* bit disp of param */
1717
	   long n = no(se);  /* bit disp of param */
1705
	   if ( name(son(e)) != formal_callee_tag )
1718
	   if (name(son(e))!= formal_callee_tag)
1706
	   {
1719
	   {
1707
	      /**  A caller parameter kept on the stack.  **/
1720
	      /**  A caller parameter kept on the stack.  **/
1708
    	      is.adval = 1;
1721
    	      is.adval = 1;
1709
	      is.b.base = GR17;
1722
	      is.b.base = GR17;
1710
	      is.b.offset = -((n+params_offset)>>3);
1723
	      is.b.offset = - ((n+params_offset) >>3);
1711
	      setinsalt(placew.answhere, is);
1724
	      setinsalt(placew.answhere, is);
1712
	      no(e) = n * 2 + GR17;
1725
	      no(e) = n * 2 + GR17;
1713
	      remember = 1;
1726
	      remember = 1;
1714
	      if ( (last_param(e) && (!Has_no_vcallers ||
1727
	      if ((last_param(e) && (!Has_no_vcallers ||
1715
				      (isvis(e) && props(se)!=0))) ||
1728
				     (isvis(e) && props(se)!=0))) ||
1716
		   a.ashsize==0 )
1729
		   a.ashsize==0)
1717
	      {
1730
	      {
1718
 	         /*  possible varargs, dump remaining param regs on stack */
1731
 	         /*  possible varargs, dump remaining param regs on stack */
1719
		 int i = n >> 5; /* next offset */
1732
		 int i = n >> 5; /* next offset */
1720
		 int off =- (params_offset>>3)-(i<<2);
1733
		 int off =- (params_offset>>3) - (i<<2);
1721
		 i--;
1734
		 i--;
1722
		 while (i<4)
1735
		 while (i<4)
1723
		 {
1736
		 {
1724
		    st_ir_ins(i_stw,cmplt_,ARG0+i,fs_,empty_ltrl,off, Has_vcallees ? FP : EP);
1737
		    st_ir_ins(i_stw,cmplt_,ARG0+i,fs_,empty_ltrl,off, Has_vcallees ? FP : EP);
1725
		    strcat(export,i==0 ? ",ARGW0=GR" : i==1 ? ",ARGW1=GR" : i==2 ? ",ARGW2=GR" : ",ARGW3=GR");
1738
		    strcat(export,i==0 ? ",ARGW0=GR" : i==1 ? ",ARGW1=GR" : i==2 ? ",ARGW2=GR" : ",ARGW3=GR");
1726
		    off-=4;
1739
		    off-=4;
1727
		    i++;	
1740
		    i++;
1728
		 }
1741
		 }
1729
	      }
1742
	      }
1730
	   }
1743
	   }
1731
	   else
1744
	   else
1732
	   {
1745
	   {
Line 1744... Line 1757...
1744
 	   /* A local living on the stack */
1757
 	   /* A local living on the stack */
1745
	   instore is;
1758
	   instore is;
1746
	   is.b = boff(e);
1759
	   is.b = boff(e);
1747
	   is.adval = 1;
1760
	   is.adval = 1;
1748
#if USE_BITAD
1761
#if USE_BITAD
1749
	   if ( a.ashalign != 1 )
1762
	   if (a.ashalign != 1)
1750
	   {
1763
	   {
1751
	      setinsalt(placew.answhere, is);
1764
	      setinsalt(placew.answhere, is);
1752
	      remember = 1;
1765
	      remember = 1;
1753
	   }
1766
	   }
1754
	   else
1767
	   else
Line 1758... Line 1771...
1758
	   }
1771
	   }
1759
#else
1772
#else
1760
	   setinsalt(placew.answhere, is);
1773
	   setinsalt(placew.answhere, is);
1761
	   remember = 1;
1774
	   remember = 1;
1762
#endif
1775
#endif
1763
	}  
1776
	}
1764
	placew.ashwhere = a;
1777
	placew.ashwhere = a;
1765
     }
1778
     }
1766
     if ( isparam(e) )
1779
     if (isparam(e))
1767
     {
1780
     {
1768
	if ( name(se) != formal_callee_tag )
1781
	if (name(se)!= formal_callee_tag)
1769
	{
1782
	{
1770
	   int off,sz = shape_size(sh(se));
1783
	   int off,sz = shape_size(sh(se));
1771
	   baseoff stkpos;
1784
	   baseoff stkpos;
1772
	   int n = no(se);
1785
	   int n = no(se);
1773
	   int pr = props(se); /* (pr == 0) ? (on stack) : (input reg) */
1786
	   int pr = props(se); /* (pr == 0) ? (on stack) : (input reg) */
1774
	   stkpos.base = Has_vcallees ? FP : EP;
1787
	   stkpos.base = Has_vcallees ? FP : EP;
1775
	   off = -((n+params_offset)>>3);
1788
	   off = - ((n+params_offset) >>3);
1776
	   stkpos.offset = off;
1789
	   stkpos.offset = off;
1777
#if 0
1790
#if 0
1778
	   if ( pt(e)==nilexp && !diagnose )
1791
	   if (pt(e) ==nilexp && !diagnose)
1779
	   {
1792
	   {
1780
	      /* parameter never used */
1793
	      /* parameter never used */
1781
	   }
1794
	   }
1782
	   else
1795
	   else
1783
#endif
1796
#endif
1784
	   if ( pr && ( props(e) & inanyreg ) == 0 )
1797
	   if (pr && (props(e) & inanyreg) == 0)
1785
	   {
1798
	   {
1786
	      /* param in reg pr, move to stack */
1799
	      /* param in reg pr, move to stack */
1787
	      if (is_floating(name(sh(se))))
1800
	      if (is_floating(name(sh(se))))
1788
		 stf_ins(sz==64 ? i_fstd : i_fstw,pr,stkpos);
1801
		 stf_ins(sz==64 ? i_fstd : i_fstw,pr,stkpos);
1789
	      else
1802
	      else
Line 1801... Line 1814...
1801
		    st_ins(i_sw,pr,stkpos);
1814
		    st_ins(i_sw,pr,stkpos);
1802
		    stkpos.offset+=4;
1815
		    stkpos.offset+=4;
1803
		    st_ins(i_sw,pr-1,stkpos);
1816
		    st_ins(i_sw,pr-1,stkpos);
1804
		 }
1817
		 }
1805
	      }
1818
	      }
1806
	      if ( name(sh(se)) != cpdhd && name(sh(se)) != nofhd )
1819
	      if (name(sh(se))!= cpdhd && name(sh(se))!= nofhd)
1807
		 remember = 0;
1820
		 remember = 0;
1808
	    }
1821
	    }
1809
	    else
1822
	    else
1810
	    if ( pr==0 && (props(e)&inanyreg)!=0 )
1823
	    if (pr==0 && (props(e) &inanyreg)!=0)
1811
	    {
1824
	    {
1812
	       /* param on stack, move to reg */
1825
	       /* param on stack, move to reg */
1813
	       int d = no(e);
1826
	       int d = no(e);
1814
	       if (sz==8)
1827
	       if (sz==8)
1815
		  ld_ins(i_lb,1,stkpos,d);
1828
		  ld_ins(i_lb,1,stkpos,d);
Line 1821... Line 1834...
1821
		  ld_ins(i_lw,1,stkpos,d);
1834
		  ld_ins(i_lw,1,stkpos,d);
1822
	       remember = 1;
1835
	       remember = 1;
1823
	       r = d;
1836
	       r = d;
1824
	    }
1837
	    }
1825
	    else
1838
	    else
1826
	    if ( pr && pr!=no(e) )
1839
	    if (pr && pr!=no(e))
1827
	    {
1840
	    {
1828
	       /* param passed in reg=pr, move to different reg=no(e) */
1841
	       /* param passed in reg=pr, move to different reg=no(e) */
1829
	       int d = no(e);
1842
	       int d = no(e);
1830
	       rr_ins(i_copy,pr,d);
1843
	       rr_ins(i_copy,pr,d);
1831
	       remember = 1;
1844
	       remember = 1;
1832
	       r = d;
1845
	       r = d;
1833
	    }
1846
	    }
1834
	 }
1847
	 }
1835
	 else
1848
	 else
1836
	 {
1849
	 {
1837
	    if ( props(e) & inanyreg )
1850
	    if (props(e) & inanyreg)
1838
	    {
1851
	    {
1839
	       /* A callee parameter passed on stack but kept in register */
1852
	       /* A callee parameter passed on stack but kept in register */
1840
	       instore is;
1853
	       instore is;
1841
	       ans aa;
1854
	       ans aa;
1842
	       is.b.base = Has_vcallees ? FP : EP;
1855
	       is.b.base = Has_vcallees ? FP : EP;
1843
	       is.b.offset = (no(se)-callees_offset)>>3;
1856
	       is.b.offset = (no(se) -callees_offset) >>3;
1844
	       is.adval = 0;
1857
	       is.adval = 0;
1845
	       setinsalt(aa,is);
1858
	       setinsalt(aa,is);
1846
	       move(aa,placew,sp.fixed,is_signed(sh(se)));
1859
	       move(aa,placew,sp.fixed,is_signed(sh(se)));
1847
	    }
1860
	    }
1848
	 }
1861
	 }
Line 1850... Line 1863...
1850
      else
1863
      else
1851
      {
1864
      {
1852
	 r = code_here(son(e), sp, placew);
1865
	 r = code_here(son(e), sp, placew);
1853
      }
1866
      }
1854
 
1867
 
1855
      if (remember && r != NOREG && pt(e) != nilexp && eq_sze(sh(son(e)), sh(pt(e))))
1868
      if (remember && r != NOREG && pt(e)!= nilexp && eq_sze(sh(son(e)), sh(pt(e))))
1856
      {
1869
      {
1857
 	 /*  Temporarily in a register, track it to optimise future access  */
1870
 	 /*  Temporarily in a register, track it to optimise future access  */
1858
 	 if (isvar(e))
1871
 	 if (isvar(e))
1859
	 {
1872
	 {
1860
	    keepcont(pt(e), r);
1873
	    keepcont(pt(e), r);
Line 1866... Line 1879...
1866
      }
1879
      }
1867
 
1880
 
1868
      /* and evaluate the body of the declaration */
1881
      /* and evaluate the body of the declaration */
1869
      mka = make_code(bro(son(e)), guard(placew, sp), dest, exitlab);
1882
      mka = make_code(bro(son(e)), guard(placew, sp), dest, exitlab);
1870
      return mka;
1883
      return mka;
1871
  } 
1884
  }
1872
  /* ENDS ident_tag */
1885
  /* ENDS ident_tag */
1873
 
1886
 
1874
/*****************************************************************************/
1887
/*****************************************************************************/
1875
 
1888
 
1876
  case seq_tag:
1889
  case seq_tag:
1877
  {
1890
  {
1878
     exp t = son(son(e));
1891
     exp t = son(son(e));
1879
     for (;;)
1892
     for (;;)
1880
     {
1893
     {
1881
	exp next = (last(t)) ? (bro(son(e))) : bro(t);
1894
	exp next = (last(t))?(bro(son(e))): bro(t);
1882
	if ( name(next) == goto_tag )	/* gotos end sequences */
1895
	if ( name(next) == goto_tag )	/* gotos end sequences */
1883
	{
1896
	{
1884
 	   make_code(t, sp, nowhere, no(son(pt(next))));
1897
 	   make_code(t, sp, nowhere, no(son(pt(next))));
1885
	}
1898
	}
1886
	else
1899
	else
1887
	{
1900
	{
1888
	   code_here(t, sp, nowhere);
1901
	   code_here(t, sp, nowhere);
1889
	}
1902
	}
1890
	if ( last(t) )
1903
	if (last(t))
1891
	{
1904
	{
1892
	   return make_code(bro(son(e)), sp, dest, exitlab);
1905
	   return make_code(bro(son(e)), sp, dest, exitlab);
1893
	}
1906
	}
1894
	t = bro(t);
1907
	t = bro(t);
1895
     }
1908
     }
1896
  }
1909
  }
1897
  /*  ENDS seq_tag  */
1910
  /*  ENDS seq_tag  */
1898
 
1911
 
1899
/*****************************************************************************/
1912
/*****************************************************************************/
1900
 
1913
 
1901
  case cond_tag:
1914
  case cond_tag:
1902
  {
1915
  {
1903
     exp first = son(e);
1916
     exp first = son(e);
1904
     exp alt = bro(son(e));
1917
     exp alt = bro(son(e));
1905
     exp test;
1918
     exp test;
1906
     exp record;	 /* jump record for alt */
1919
     exp record;	 /* jump record for alt */
1907
     exp jr = nilexp;   /* jump record for end of construction */
1920
     exp jr = nilexp;   /* jump record for end of construction */
1908
 
1921
 
1909
     if ( discrim(dest.answhere) == insomereg )
1922
     if (discrim(dest.answhere) == insomereg)
1910
     {
1923
     {
1911
	/* must make choice of register to contain answer to cond */
1924
	/* must make choice of register to contain answer to cond */
1912
	int *sr = someregalt(dest.answhere);
1925
	int *sr = someregalt(dest.answhere);
1913
	if (*sr != -1)
1926
	if (*sr != -1)
1914
	   fail("somereg *2");
1927
	   fail("somereg *2");
1915
	*sr = getreg(sp.fixed);
1928
	*sr = getreg(sp.fixed);
1916
	setregalt(dest.answhere, *sr);
1929
	setregalt(dest.answhere, *sr);
1917
     }
1930
     }
1918
     if ( name(first)==goto_tag && pt(first)==alt )
1931
     if (name(first) ==goto_tag && pt(first) ==alt)
1919
     {
1932
     {
1920
	/* first is goto alt */
1933
	/* first is goto alt */
1921
	no(son(alt)) = 0;
1934
	no(son(alt)) = 0;
1922
	return make_code(alt, sp, dest, exitlab);
1935
	return make_code(alt, sp, dest, exitlab);
1923
     }
1936
     }
1924
#if 1 
1937
#if 1
1925
     /*  "take_out_of_line" stuff  */
1938
     /*  "take_out_of_line" stuff  */
1926
     if ( name(bro(son(alt))) == top_tag && !diagnose )
1939
     if (name(bro(son(alt))) == top_tag && !diagnose)
1927
     {
1940
     {
1928
	int extract = take_out_of_line(first, alt, repeat_level > 0, 1.0);
1941
	int extract = take_out_of_line(first, alt, repeat_level > 0, 1.0);
1929
	if ( extract )
1942
	if (extract)
1930
	{
1943
	{
1931
	   static ntest real_inverse_ntest[] = {
1944
	   static ntest real_inverse_ntest[] = {
1932
		0, 4, 3, 2, 1, 6, 5, 0, 0, 0, 0, 0, 0, 0, 0
1945
		0, 4, 3, 2, 1, 6, 5, 0, 0, 0, 0, 0, 0, 0, 0
1933
	   };
1946
	   };
1934
	   exp t = son(son(first));
1947
	   exp t = son(son(first));
1935
	   exp p, s, z;
1948
	   exp p, s, z;
1936
	   int test_n;
1949
	   int test_n;
1937
	   shape sha;
1950
	   shape sha;
1938
	   outofline * rec;
1951
	   outofline * rec;
1939
	   exp tst = (is_tester(t, 0)) ? t : bro(son(t));
1952
	   exp tst = (is_tester(t, 0))? t : bro(son(t));
1940
	   record = getexp(f_bottom, nilexp, 0, nilexp, nilexp,0, 0, 0);
1953
	   record = getexp(f_bottom, nilexp, 0, nilexp, nilexp,0, 0, 0);
1941
	   if (pt(son(alt)) != nilexp)
1954
	   if (pt(son(alt))!= nilexp)
1942
	      ptno(record) = ptno(pt(son(alt)));
1955
	      ptno(record) = ptno(pt(son(alt)));
1943
	   else
1956
	   else
1944
	      ptno(record) = new_label();
1957
	      ptno(record) = new_label();
1945
	   jr = getexp(f_bottom, nilexp, 0, nilexp, nilexp, 0, 0, 0);
1958
	   jr = getexp(f_bottom, nilexp, 0, nilexp, nilexp, 0, 0, 0);
1946
	   ptno(jr) = new_label();
1959
	   ptno(jr) = new_label();
Line 1948... Line 1961...
1948
	   rec = (outofline*)xmalloc(sizeof(outofline));
1961
	   rec = (outofline*)xmalloc(sizeof(outofline));
1949
	   rec->next = odd_bits;
1962
	   rec->next = odd_bits;
1950
	   odd_bits = rec;
1963
	   odd_bits = rec;
1951
 	   rec->dest = dest;
1964
 	   rec->dest = dest;
1952
	   rec->labno = new_label();	/* label for outofline body */
1965
	   rec->labno = new_label();	/* label for outofline body */
1953
	   if ( last(t) )
1966
	   if (last(t))
1954
	      first = bro(son(first));
1967
	      first = bro(son(first));
1955
	   else
1968
	   else
1956
	      son(son(first)) = bro(son(son(first)));
1969
	      son(son(first)) = bro(son(son(first)));
1957
	   rec->body = first;
1970
	   rec->body = first;
1958
	   rec->sp=sp;
1971
	   rec->sp=sp;
1959
	       rec->jr=jr;
1972
	       rec->jr=jr;
1960
	   pt(son(alt)) = record;
1973
	   pt(son(alt)) = record;
1961
	   test_n = (int)test_number(tst);
1974
	   test_n = (int)test_number(tst);
1962
	   if ( name(sha) < shrealhd || name(sha) > doublehd )
1975
	   if (name(sha) < shrealhd || name(sha) > doublehd)
1963
	      test_n = (int)int_inverse_ntest[test_n];
1976
	      test_n = (int)int_inverse_ntest[test_n];
1964
	   else
1977
	   else
1965
	      test_n = (int)real_inverse_ntest[test_n];
1978
	      test_n = (int)real_inverse_ntest[test_n];
1966
	   settest_number(tst, test_n);
1979
	   settest_number(tst, test_n);
1967
	   z = getexp (f_bottom, nilexp, 0, nilexp, nilexp, 0, 0, 0);
1980
	   z = getexp(f_bottom, nilexp, 0, nilexp, nilexp, 0, 0, 0);
1968
	   ptno(z) = rec->labno;/* z->ptf.l */
1981
	   ptno(z) = rec->labno;/* z->ptf.l */
1969
	   s = getexp(sha, nilexp, 0, nilexp, z, 0, 0, 0);
1982
	   s = getexp(sha, nilexp, 0, nilexp, z, 0, 0, 0);
1970
	   no(s) = rec->labno;
1983
	   no(s) = rec->labno;
1971
	   p = getexp(sha, nilexp, 0, s, nilexp, 0, 0, 0);
1984
	   p = getexp(sha, nilexp, 0, s, nilexp, 0, 0, 0);
1972
	   pt(tst) = p;
1985
	   pt(tst) = p;
1973
  	   mka = make_code(t,sp,dest,0);
1986
  	   mka = make_code(t,sp,dest,0);
1974
	   if ( name(sh(first)) != bothd )
1987
	   if (name(sh(first))!= bothd)
1975
	   {
1988
	   {
1976
	      outlab("L$$",ptno(jr));
1989
	      outlab("L$$",ptno(jr));
1977
	      clear_all();
1990
	      clear_all();
1978
	   };	  
1991
	   };
1979
	   return mka;
1992
	   return mka;
1980
	};
1993
	};
1981
     };
1994
     };
1982
#endif
1995
#endif
1983
 
1996
 
1984
     if ( name(first) == goto_tag && pt(first) == alt )
1997
     if (name(first) == goto_tag && pt(first) == alt)
1985
     {
1998
     {
1986
	/* first is goto alt */
1999
	/* first is goto alt */
1987
	no(son(alt)) = 0;
2000
	no(son(alt)) = 0;
1988
	return make_code(alt, sp, dest, exitlab);
2001
	return make_code(alt, sp, dest, exitlab);
1989
     }
2002
     }
1990
     else
2003
     else
1991
     if ( name(alt) == labst_tag && name(bro(son(alt))) == top_tag )
2004
     if (name(alt) == labst_tag && name(bro(son(alt))) == top_tag)
1992
     {
2005
     {
1993
	/* alt is empty */
2006
	/* alt is empty */
1994
	int endl = (exitlab == 0) ? new_label() : exitlab;
2007
	int endl = (exitlab == 0)? new_label(): exitlab;
1995
	no(son(alt)) = endl;
2008
	no(son(alt)) = endl;
1996
	make_code(first, sp, dest, endl);
2009
	make_code(first, sp, dest, endl);
1997
	mka.lab = endl;
2010
	mka.lab = endl;
1998
	return mka;
2011
	return mka;
1999
     }
2012
     }
2000
     else
2013
     else
2001
     if ( name(alt) == labst_tag && name(bro(son(alt))) == goto_tag )
2014
     if (name(alt) == labst_tag && name(bro(son(alt))) == goto_tag)
2002
     {
2015
     {
2003
	/* alt is goto */
2016
	/* alt is goto */
2004
	exp g = bro(son(alt));
2017
	exp g = bro(son(alt));
2005
	no(son(alt)) = no(son(pt(g)));
2018
	no(son(alt)) = no(son(pt(g)));
2006
	return make_code(first, sp, dest, exitlab);
2019
	return make_code(first, sp, dest, exitlab);
2007
     }
2020
     }
2008
 
2021
 
2009
     if ( ( test = testlast(first, alt) ) ) /* I mean it */
2022
     if ( ( test = testlast(first, alt) ) ) /* I mean it */
2010
     {
2023
     {
2011
	/* effectively an empty then part */
2024
	/* effectively an empty then part */
2012
	int l = (exitlab != 0) ? exitlab : new_label();
2025
	int l = (exitlab != 0)? exitlab : new_label();
2013
	bool rev = IsRev(test);
2026
	bool rev = IsRev(test);
2014
	ptno(test) = -l;  /* make test jump to exitlab - see test_tag: */
2027
	ptno(test) = -l;  /* make test jump to exitlab - see test_tag: */
2015
	props(test) = notbranch[props(test)];
2028
	props(test) = notbranch[props(test)];
2016
	if (rev)
2029
	if (rev)
2017
	{
2030
	{
Line 2027... Line 2040...
2027
     else
2040
     else
2028
     {
2041
     {
2029
	int fl, l;
2042
	int fl, l;
2030
	no(son(alt)) = new_label();
2043
	no(son(alt)) = new_label();
2031
	fl = make_code(first, sp, dest, exitlab).lab;
2044
	fl = make_code(first, sp, dest, exitlab).lab;
2032
 	l = (fl != 0) ? fl : ((exitlab != 0) ? exitlab : new_label());
2045
 	l = (fl != 0)? fl :((exitlab != 0)? exitlab : new_label());
2033
	ub_ins(cmplt_,l);
2046
	ub_ins(cmplt_,l);
2034
	clear_all();
2047
	clear_all();
2035
	make_code(alt, sp, dest, l);
2048
	make_code(alt, sp, dest, l);
2036
	mka.lab = l;
2049
	mka.lab = l;
2037
	return mka;
2050
	return mka;
Line 2041... Line 2054...
2041
 
2054
 
2042
/*****************************************************************************/
2055
/*****************************************************************************/
2043
 
2056
 
2044
  case labst_tag:
2057
  case labst_tag:
2045
  {
2058
  {
2046
     if ( no(son(e)) != 0 )
2059
     if (no(son(e))!= 0)
2047
     {
2060
     {
2048
	clear_all();
2061
	clear_all();
2049
	outlab("L$$",no(son(e)));
2062
	outlab("L$$",no(son(e)));
2050
     }
2063
     }
2051
     if ( is_loaded_lv(e) && No_S )
2064
     if (is_loaded_lv(e) && No_S)
2052
     {
2065
     {
2053
	/* Could be the target of a long_jump - we must reset SP and FP */
2066
	/* Could be the target of a long_jump - we must reset SP and FP */
2054
	if (Has_tos)
2067
	if (Has_tos)
2055
	   ld_ins(i_lw,1,SP_BOFF,SP);
2068
	   ld_ins(i_lw,1,SP_BOFF,SP);
2056
	else
2069
	else
Line 2059... Line 2072...
2059
	   ld_ins(i_lw,1,FP_BOFF,FP);
2072
	   ld_ins(i_lw,1,FP_BOFF,FP);
2060
	if (PIC_code)
2073
	if (PIC_code)
2061
	{
2074
	{
2062
	   ld_ir_ins(i_ldw,cmplt_,fs_R,empty_ltrl,-32,SP,GR19);
2075
	   ld_ir_ins(i_ldw,cmplt_,fs_R,empty_ltrl,-32,SP,GR19);
2063
	   if (!leaf)
2076
	   if (!leaf)
2064
	   {
2077
	   {
2065
	      rr_ins(i_copy,GR19,GR5);
2078
	      rr_ins(i_copy,GR19,GR5);
2066
	   }
2079
	   }
2067
	}
2080
	}
2068
     }		
2081
     }
2069
     return make_code(bro(son(e)), sp, dest, exitlab);
2082
     return make_code(bro(son(e)), sp, dest, exitlab);
2070
  }				
2083
  }
2071
  /*  ENDS labst_tag  */
2084
  /*  ENDS labst_tag  */
2072
 
2085
 
2073
/*****************************************************************************/
2086
/*****************************************************************************/
2074
 
2087
 
2075
  case rep_tag:
2088
  case rep_tag:
Line 2087... Line 2100...
2087
  /*  ENDS rep_tag  */
2100
  /*  ENDS rep_tag  */
2088
 
2101
 
2089
/*****************************************************************************/
2102
/*****************************************************************************/
2090
 
2103
 
2091
  case goto_lv_tag:
2104
  case goto_lv_tag:
2092
  {
2105
  {
2093
     int r = reg_operand(son(e),sp);
2106
     int r = reg_operand(son(e),sp);
2094
     extj_reg_ins(i_bv,r);
2107
     extj_reg_ins(i_bv,r);
2095
     z_ins(i_nop);
2108
     z_ins(i_nop);
2096
     clear_all();
2109
     clear_all();
2097
     return mka;
2110
     return mka;
2098
  }
2111
  }
2099
  /*  ENDS goto_lv_tag  */
2112
  /*  ENDS goto_lv_tag  */
2100
    
2113
 
2101
/*****************************************************************************/
2114
/*****************************************************************************/
2102
 
2115
 
2103
  case goto_tag:
2116
  case goto_tag:
2104
  {
2117
  {
2105
     int lab = no(son(pt(e)));
2118
     int lab = no(son(pt(e)));
2106
     assert(lab >= 100);
2119
     assert(lab >= 100);
Line 2108... Line 2121...
2108
     /* if (lab != exitlab) */
2121
     /* if (lab != exitlab) */
2109
     {
2122
     {
2110
	ub_ins(cmplt_,lab);
2123
	ub_ins(cmplt_,lab);
2111
     }
2124
     }
2112
     return mka;
2125
     return mka;
2113
  }				
2126
  }
2114
  /*  ENDS goto_tag  */
2127
  /*  ENDS goto_tag  */
2115
 
2128
 
2116
/*****************************************************************************/
2129
/*****************************************************************************/
2117
 
2130
 
2118
  case absbool_tag:
2131
  case absbool_tag:
2119
  {
2132
  {
2120
     fail("make_code: absbool_tag not used on HPPA");
2133
     fail("make_code: absbool_tag not used on HPPA");
2121
     /* NOTREACHED */
2134
     /* NOTREACHED */
2122
  }
2135
  }
2123
  /*  ENDS absbool_tag  */
2136
  /*  ENDS absbool_tag  */
2124
 
2137
 
Line 2126... Line 2139...
2126
 
2139
 
2127
  case test_tag:
2140
  case test_tag:
2128
  {
2141
  {
2129
     exp l = son(e);
2142
     exp l = son(e);
2130
     exp r = bro(l);
2143
     exp r = bro(l);
2131
     int lab = (ptno(e) < 0) ? -ptno(e) : no(son(pt(e)));
2144
     int lab = (ptno(e) < 0)? -ptno(e): no(son(pt(e)));
2132
     /* see frig in cond_tag */
2145
     /* see frig in cond_tag */
2133
     shape shl = sh(l);
2146
     shape shl = sh(l);
2134
     CONST char *branch;
2147
     CONST char *branch;
2135
     int n = (int) test_number(e);	/* could have Rev bit in props */
2148
     int n = (int) test_number(e);	/* could have Rev bit in props */
2136
 
2149
 
2137
#if use_long_double
2150
#if use_long_double
2138
     if ( name(sh(l)) == doublehd )
2151
     if (name(sh(l)) == doublehd)
2139
     {
2152
     {
2140
	quad_op( e, sp, dest );
2153
	quad_op(e, sp, dest);
2141
	cj_ins(c_eq,0,RET0,lab);
2154
	cj_ins(c_eq,0,RET0,lab);
2142
	return(mka);
2155
	return(mka);
2143
     }
2156
     }
2144
#endif
2157
#endif
2145
 
2158
 
2146
     if ( is_floating(name(sh(l))) )
2159
     if (is_floating(name(sh(l))))
2147
     {
2160
     {
2148
	/* float test */
2161
	/* float test */
2149
	bool dble = ( (name(shl)==shrealhd) ? 0 : 1 );
2162
	bool dble = ((name(shl) ==shrealhd)? 0 : 1);
2150
	int a1;
2163
	int a1;
2151
	CONST char *branch = fbranches(n);
2164
	CONST char *branch = fbranches(n);
2152
	/* choose branch and compare instructions */
2165
	/* choose branch and compare instructions */
2153
	int a2;
2166
	int a2;
2154
	space nsp;
2167
	space nsp;
2155
	if ( IsRev(e) )
2168
	if (IsRev(e))
2156
	{
2169
	{
2157
 	   a2 = freg_operand(r, sp, getfreg(sp.flt));
2170
 	   a2 = freg_operand(r, sp, getfreg(sp.flt));
2158
	   nsp = guardfreg(a2, sp);
2171
	   nsp = guardfreg(a2, sp);
2159
	   a1 = freg_operand(l, nsp, getfreg(nsp.flt));
2172
	   a1 = freg_operand(l, nsp, getfreg(nsp.flt));
2160
	}
2173
	}
Line 2163... Line 2176...
2163
	   a1 = freg_operand(l, sp, getfreg(sp.flt));
2176
	   a1 = freg_operand(l, sp, getfreg(sp.flt));
2164
	   nsp = guardfreg(a1, sp);
2177
	   nsp = guardfreg(a1, sp);
2165
	   a2 = freg_operand(r, nsp, getfreg(nsp.flt));
2178
	   a2 = freg_operand(r, nsp, getfreg(nsp.flt));
2166
	}
2179
	}
2167
	if (dble)
2180
	if (dble)
2168
	   cmp_rrf_ins(i_fcmp,f_dbl,branch,(3*a1+1),(3*a2+1));
2181
	   cmp_rrf_ins(i_fcmp,f_dbl,branch,(3*a1+1), (3*a2+1));
2169
	else
2182
	else
2170
	   cmp_rrf_ins(i_fcmp,f_sgl,branch,(3*a1),(3*a2));
2183
	   cmp_rrf_ins(i_fcmp,f_sgl,branch,(3*a1), (3*a2));
2171
	z_ins(i_ftest);
2184
	z_ins(i_ftest);
2172
	ub_ins(cmplt_,lab);
2185
	ub_ins(cmplt_,lab);
2173
	return mka;
2186
	return mka;
2174
     }				/* end float test */
2187
     }				/* end float test */
2175
     else
2188
     else
2176
     {
2189
     {
2177
			     /* int test */
2190
			     /* int test */
2178
	int a1;
2191
	int a1;
2179
	int a2;
2192
	int a2;
2180
	bool unsgn;
2193
	bool unsgn;
2181
	if ( name(l) == val_tag )
2194
	if (name(l) == val_tag)
2182
	{			
2195
	{
2183
	   /* put literal operand on right */
2196
	   /* put literal operand on right */
2184
	   exp temp = l;
2197
	   exp temp = l;
2185
 	   l = r;
2198
 	   l = r;
2186
	   r = temp;
2199
	   r = temp;
2187
	   if ( n <= 2 )
2200
	   if (n <= 2)
2188
 	     n += 2;
2201
 	     n += 2;
2189
	   else 
2202
	   else
2190
	   if ( n <= 4 )
2203
	   if (n <= 4)
2191
 	     n -= 2;
2204
 	     n -= 2;
2192
	}
2205
	}
2193
 
2206
 
2194
	/* choose branch instruction */
2207
	/* choose branch instruction */
2195
	unsgn = (bool)(!is_signed(shl) && name(shl)!=ptrhd);
2208
	unsgn = (bool)(!is_signed(shl) && name(shl)!=ptrhd);
2196
	branch = unsgn ? usbranches(n) : sbranches(n);
2209
	branch = unsgn ? usbranches(n): sbranches(n);
2197
 
2210
 
2198
	/* Generally, anding with an immediate requires 2 instructions. But,
2211
	/* Generally, anding with an immediate requires 2 instructions. But,
2199
	   if the and is only being compared to 0, we may be able to get by
2212
	   if the and is only being compared to 0, we may be able to get by
2200
	   with one instruction */
2213
	   with one instruction */
2201
	if ( name(l) == and_tag && name(r)==val_tag && no(r)==0 &&
2214
	if (name(l) == and_tag && name(r) ==val_tag && no(r) ==0 &&
2202
	    ( branch == c_eq || branch == c_neq ) && !( unsgn && (n==2 || n==3) ) )
2215
	   (branch == c_eq || branch == c_neq) && !(unsgn && (n==2 || n==3)))
2203
	{
2216
	{
2204
	   exp sonl = son(l);
2217
	   exp sonl = son(l);
2205
	   exp bsonl = bro(sonl);
2218
	   exp bsonl = bro(sonl);
2206
	   if ( name(bsonl) == val_tag )
2219
	   if (name(bsonl) == val_tag)
2207
	   {
2220
	   {
2208
	      int v = no(bsonl);
2221
	      int v = no(bsonl);
2209
	      if ( IS_POW2(v) ) 
2222
	      if (IS_POW2(v))
2210
	      {
2223
	      {
2211
		 /* We can branch on bit */
2224
		 /* We can branch on bit */
2212
 
2225
 
2213
		 /* Which bit, b, to branch on ? */
2226
		 /* Which bit, b, to branch on ? */
2214
		 int b=0;
2227
		 int b=0;
2215
		 while ( (v & (1<<b)) == 0 ) b++; 
2228
		 while ((v & (1<<b)) == 0)b++;
2216
		 b=31-b;
2229
		 b=31-b;
2217
		 a1 = reg_operand(sonl,sp);
2230
		 a1 = reg_operand(sonl,sp);
2218
		 if (OPTIM)
2231
		 if (OPTIM)
2219
		 {
2232
		 {
2220
		    bb_in(branch==c_eq ? bit_is_0 : bit_is_1,a1,b,lab);
2233
		    bb_in(branch==c_eq ? bit_is_0 : bit_is_1,a1,b,lab);
2221
		 }
2234
		 }
2222
		 else
2235
		 else
2223
		 {
2236
		 {
2224
		    riir_ins(i_extru,branch==c_eq ? c_OD : c_EV,a1,b,1,0);
2237
		    riir_ins(i_extru,branch==c_eq ? c_OD : c_EV,a1,b,1,0);
2225
		    ub_ins(cmplt_N,lab);
2238
		    ub_ins(cmplt_N,lab);
2226
		 }
2239
		 }
Line 2228... Line 2241...
2228
	      }
2241
	      }
2229
	      else
2242
	      else
2230
	      {
2243
	      {
2231
		 /* v = 00..0011..1100..00 or v = 11..1100..0011..11 ? */
2244
		 /* v = 00..0011..1100..00 or v = 11..1100..0011..11 ? */
2232
		 int pos = 0, len, next, m;
2245
		 int pos = 0, len, next, m;
2233
		 if ( v & 1 )
2246
		 if (v & 1)
2234
		    m = ~v;
2247
		    m = ~v;
2235
		 else
2248
		 else
2236
		    m = v;
2249
		    m = v;
2237
		 while ( pos < 32 && (m & (1<<pos))==0 ) pos++;
2250
		 while (pos < 32 && (m & (1<<pos)) ==0)pos++;
2238
		 len = pos;
2251
		 len = pos;
2239
		 while ( len < 32 && (m & (1<<len)) ) len++;
2252
		 while (len < 32 && (m & (1<<len)))len++;
2240
		 next = len;
2253
		 next = len;
2241
		 len -= pos;
2254
		 len -= pos;
2242
		 pos = 31-pos;
2255
		 pos = 31-pos;
2243
		 while ( next < 32 && (m & (1<<next))==0 ) next++;
2256
		 while (next < 32 && (m & (1<<next)) ==0)next++;
2244
		 if ( next == 32 )
2257
		 if (next == 32)
2245
		 {
2258
		 {
2246
		    int d;
2259
		    int d;
2247
		    space nsp;
2260
		    space nsp;
2248
		    a1 = reg_operand(sonl,sp);
2261
		    a1 = reg_operand(sonl,sp);
2249
		    nsp = guardreg(a1,sp);
2262
		    nsp = guardreg(a1,sp);
2250
		    d = getreg(nsp.fixed);
2263
		    d = getreg(nsp.fixed);
2251
		    if ( v&1 )
2264
		    if (v&1)
2252
		    {
2265
		    {
2253
		       /* 2 instructions! Is this worth implementing ? */
2266
		       /* 2 instructions! Is this worth implementing ? */
2254
		       rr_ins(i_copy,a1,d);
2267
		       rr_ins(i_copy,a1,d);
2255
		       iiir_ins(i_depi,c_,0,pos,len,d);
2268
		       iiir_ins(i_depi,c_,0,pos,len,d);
2256
		    }
2269
		    }
Line 2258... Line 2271...
2258
		       riir_ins(i_extru,c_,a1,pos,len,d);
2271
		       riir_ins(i_extru,c_,a1,pos,len,d);
2259
		    cij_ins(branch,0,d,lab);
2272
		    cij_ins(branch,0,d,lab);
2260
		    return mka;
2273
		    return mka;
2261
		 }
2274
		 }
2262
	      }
2275
	      }
2263
	   }
2276
	   }
2264
	}
2277
	}
2265
 
2278
 
2266
	a1 = reg_operand(l, sp);
2279
	a1 = reg_operand(l, sp);
2267
	if ( name(r) == val_tag )
2280
	if (name(r) == val_tag)
2268
	{
2281
	{
2269
	   if ( unsgn && (no(r)==0) && (n==2 || n==3) )
2282
	   if (unsgn && (no(r) ==0) && (n==2 || n==3))
2270
	   {
2283
	   {
2271
	      if ( n==3 )
2284
	      if (n==3)
2272
		 ub_ins(cmplt_,lab);
2285
		 ub_ins(cmplt_,lab);
2273
	   }
2286
	   }
2274
	   else
2287
	   else
2275
	      cij_ins(branch,no(r),a1,lab);
2288
	      cij_ins(branch,no(r),a1,lab);
2276
	}
2289
	}
2277
	else
2290
	else
2278
	{
2291
	{
2279
 	   space nsp;
2292
 	   space nsp;
2280
 	   nsp = guardreg(a1, sp);
2293
 	   nsp = guardreg(a1, sp);
2281
 	   a2 = reg_operand(r, nsp);
2294
 	   a2 = reg_operand(r, nsp);
2282
 	   if ( (n != 5) && (n !=6) )
2295
 	   if ((n != 5) && (n !=6))
2283
	   {
2296
	   {
2284
	      if ( (name(l) == cont_tag) && (name(son(l)) == name_tag) &&
2297
	      if ((name(l) == cont_tag) && (name(son(l)) == name_tag) &&
2285
		  isse_opt(son(son(l))) )
2298
		  isse_opt(son(son(l))))
2286
		 riir_ins(i_extrs,c_, a1,31,shape_size(sh(l)),a1);
2299
		 riir_ins(i_extrs,c_, a1,31,shape_size(sh(l)),a1);
2287
	      if ( (name(r) == cont_tag) && (name(son(r)) == name_tag) &&
2300
	      if ((name(r) == cont_tag) && (name(son(r)) == name_tag) &&
2288
		   isse_opt(son(son(r))) )
2301
		   isse_opt(son(son(r))))
2289
		 riir_ins(i_extrs,c_, a2,31,shape_size(sh(r)),a2);
2302
		 riir_ins(i_extrs,c_, a2,31,shape_size(sh(r)),a2);
2290
	   }
2303
	   }
2291
	   cj_ins(branch,a2,a1,lab);
2304
	   cj_ins(branch,a2,a1,lab);
2292
	}
2305
	}
2293
	return mka;
2306
	return mka;
2294
     }				
2307
     }
2295
  }				
2308
  }
2296
  /*  ENDS test_tag  */
2309
  /*  ENDS test_tag  */
2297
 
2310
 
2298
/*****************************************************************************/
2311
/*****************************************************************************/
2299
 
2312
 
2300
  case ass_tag:
2313
  case ass_tag:
Line 2307... Line 2320...
2307
     int contreg = NOREG;
2320
     int contreg = NOREG;
2308
     int hdrhs = name(sh(rhs));
2321
     int hdrhs = name(sh(rhs));
2309
     bool is_float = is_floating(hdrhs);
2322
     bool is_float = is_floating(hdrhs);
2310
 
2323
 
2311
#if use_long_double
2324
#if use_long_double
2312
     if ( hdrhs == doublehd )
2325
     if (hdrhs == doublehd)
2313
	is_float = 0 ;
2326
	is_float = 0;
2314
#endif
2327
#endif
2315
 
2328
 
2316
     /* +++ lose chvar_tag on rhs if no result, remember to invalidate reg */
2329
     /* +++ lose chvar_tag on rhs if no result, remember to invalidate reg */
2317
     /* +++ remove name(e)==ass_tag tests now assbits_tag has gone */
2330
     /* +++ remove name(e)==ass_tag tests now assbits_tag has gone */
2318
 
2331
 
2319
     if ( name(e) == assvol_tag )
2332
     if (name(e) == assvol_tag)
2320
     {
2333
     {
2321
 
2334
 
2322
	/* Assign to volatile location. Disable register-location tracing. */
2335
	/* Assign to volatile location. Disable register-location tracing. */
2323
	/* Disable peep-hole optimisation  */
2336
	/* Disable peep-hole optimisation  */
2324
	comment("make_code: Assign to volatile");
2337
	comment("make_code: Assign to volatile");
2325
	clear_all();
2338
	clear_all();
2326
	setvolatile();
2339
	setvolatile();
2327
     }
2340
     }
2328
 
2341
 
2329
     if ( name(e) == ass_tag &&
2342
     if (name(e) == ass_tag &&
2330
	  (name(rhs) == apply_tag || is_muldivrem_call(rhs)) &&
2343
	 (name(rhs) == apply_tag || is_muldivrem_call(rhs)) &&
2331
	  ((is_float) || valregable(sh(rhs))) )
2344
	 ((is_float) || valregable(sh(rhs))))
2332
      {
2345
      {
2333
	 where apply_res;
2346
	 where apply_res;
2334
	 /* set up apply_res */
2347
	 /* set up apply_res */
2335
	 if (is_float)
2348
	 if (is_float)
2336
	 {
2349
	 {
Line 2361... Line 2374...
2361
#if USE_BITAD
2374
#if USE_BITAD
2362
      if (assdest.ashwhere.ashalign == 1)
2375
      if (assdest.ashwhere.ashalign == 1)
2363
      {
2376
      {
2364
 	 /* assignment of a bitfield, get address in proper form */
2377
 	 /* assignment of a bitfield, get address in proper form */
2365
	 instore is;
2378
	 instore is;
2366
	 switch ( discrim(assdest.answhere) )
2379
	 switch (discrim(assdest.answhere))
2367
	 {
2380
	 {
2368
	    case inreg:
2381
	    case inreg:
2369
	    {
2382
	    {
2370
	       is.b.base = regalt(assdest.answhere);
2383
	       is.b.base = regalt(assdest.answhere);
2371
	       is.b.offset = 0;
2384
	       is.b.offset = 0;
Line 2373... Line 2386...
2373
	       break;
2386
	       break;
2374
	    }
2387
	    }
2375
	    case notinreg:
2388
	    case notinreg:
2376
	    {
2389
	    {
2377
	       is = insalt(assdest.answhere);
2390
	       is = insalt(assdest.answhere);
2378
	       if ( !is.adval )
2391
	       if (!is.adval)
2379
	       {
2392
	       {
2380
		  int r = getreg(nsp.fixed);
2393
		  int r = getreg(nsp.fixed);
2381
		  ld_ins(i_lw,1,is.b,r);
2394
		  ld_ins(i_lw,1,is.b,r);
2382
		  nsp = guardreg(r, nsp);
2395
		  nsp = guardreg(r, nsp);
2383
		  is.adval = 1;
2396
		  is.adval = 1;
Line 2398... Line 2411...
2398
	}
2411
	}
2399
	setbitadalt(assdest.answhere, is);
2412
	setbitadalt(assdest.answhere, is);
2400
     }
2413
     }
2401
     else
2414
     else
2402
#endif
2415
#endif
2403
     if ( name(e) == ass_tag &&
2416
     if (name(e) == ass_tag &&
2404
	  discrim(assdest.answhere) == notinreg &&
2417
	  discrim(assdest.answhere) == notinreg &&
2405
	  assdest.ashwhere.ashsize == assdest.ashwhere.ashalign )
2418
	  assdest.ashwhere.ashsize == assdest.ashwhere.ashalign)
2406
     {
2419
     {
2407
	instore is;
2420
	instore is;
2408
	is = insalt(assdest.answhere);
2421
	is = insalt(assdest.answhere);
2409
	if ( !is.adval )
2422
	if (!is.adval)
2410
	{			/* this is an indirect assignment, so make it
2423
	{			/* this is an indirect assignment, so make it
2411
				 * direct by loading pointer into reg  (and
2424
				 * direct by loading pointer into reg  (and
2412
				 * remember it) */
2425
				 * remember it) */
2413
	   int r = getreg(nsp.fixed);
2426
	   int r = getreg(nsp.fixed);
2414
	   ld_ins(i_lw,1,is.b,r);
2427
	   ld_ins(i_lw,1,is.b,r);
Line 2419... Line 2432...
2419
	   setinsalt(assdest.answhere, is);
2432
	   setinsalt(assdest.answhere, is);
2420
	   keepexp(lhs, assdest.answhere);
2433
	   keepexp(lhs, assdest.answhere);
2421
	}
2434
	}
2422
     }
2435
     }
2423
#if 1
2436
#if 1
2424
     if ( name(e) == ass_tag && is_float && discrim(assdest.answhere) == notinreg )
2437
     if (name(e) == ass_tag && is_float && discrim(assdest.answhere) == notinreg)
2425
     {
2438
     {
2426
	/*
2439
	/*
2427
	 * Ensure floating point values assigned using floating point regs so
2440
	 * Ensure floating point values assigned using floating point regs so
2428
	 * floating point reg tracking works better. move() uses fixed regs
2441
	 * floating point reg tracking works better. move() uses fixed regs
2429
	 * for mem to mem, so must pre-load to floating point reg.
2442
	 * for mem to mem, so must pre-load to floating point reg.
Line 2443... Line 2456...
2443
     }
2456
     }
2444
#endif
2457
#endif
2445
     /* evaluate source into assignment destination .... */
2458
     /* evaluate source into assignment destination .... */
2446
     contreg = code_here(rhs, nsp, assdest);
2459
     contreg = code_here(rhs, nsp, assdest);
2447
     /* ... and move it into dest - could use assignment as value */
2460
     /* ... and move it into dest - could use assignment as value */
2448
     switch ( discrim ( assdest.answhere ) )
2461
     switch (discrim(assdest.answhere))
2449
     {
2462
     {
2450
	case inreg:
2463
	case inreg:
2451
	{
2464
	{
2452
	   int a = regalt(assdest.answhere);
2465
	   int a = regalt(assdest.answhere);
2453
	   keepreg(rhs, a);
2466
	   keepreg(rhs, a);
Line 2475... Line 2488...
2475
	case notinreg:
2488
	case notinreg:
2476
#if USE_BITAD
2489
#if USE_BITAD
2477
	case bitad:
2490
	case bitad:
2478
#endif
2491
#endif
2479
	{
2492
	{
2480
	   if ( contreg != NOREG && name(e) == ass_tag )
2493
	   if (contreg != NOREG && name(e) == ass_tag)
2481
	   {
2494
	   {
2482
	      ans aa;
2495
	      ans aa;
2483
	      space nnsp;
2496
	      space nnsp;
2484
	      if ( contreg > 0 && contreg < 31 )
2497
	      if (contreg > 0 && contreg < 31)
2485
	      {
2498
	      {
2486
		 setregalt(aa, contreg);
2499
		 setregalt(aa, contreg);
2487
		 nnsp = guardreg(contreg, sp);
2500
		 nnsp = guardreg(contreg, sp);
2488
	      }
2501
	      }
2489
	      else
2502
	      else
Line 2492... Line 2505...
2492
		 frg.fr = ABS_OF(contreg) - 32;
2505
		 frg.fr = ABS_OF(contreg) - 32;
2493
		 frg.dble = (contreg < 0);
2506
		 frg.dble = (contreg < 0);
2494
		 nnsp = nsp;
2507
		 nnsp = nsp;
2495
		 setfregalt(aa, frg);
2508
		 setfregalt(aa, frg);
2496
	      }
2509
	      }
2497
	      (void) move(aa, dest, nnsp.fixed, 1);
2510
	     (void)move(aa, dest, nnsp.fixed, 1);
2498
	      /* forget register dependencies on destination */
2511
	      /* forget register dependencies on destination */
2499
	      clear_dep_reg(lhs);
2512
	      clear_dep_reg(lhs);
2500
	      /* remember that dest contains source, provided that it is not
2513
	      /* remember that dest contains source, provided that it is not
2501
	      * dependent on it */
2514
	      * dependent on it */
2502
	      if ( name(lhs)==name_tag )
2515
	      if (name(lhs) ==name_tag)
2503
	      {
2516
	      {
2504
		 exp dc = son(lhs);
2517
		 exp dc = son(lhs);
2505
		 if ( son(dc)!=nilexp )
2518
		 if (son(dc)!=nilexp)
2506
		    dc = son(dc);
2519
		    dc = son(dc);
2507
		 if ( shape_size(sh(dc))==shape_size(sh(rhs)) )
2520
		 if (shape_size(sh(dc)) ==shape_size(sh(rhs)))
2508
		    keepcont(lhs,contreg);
2521
		    keepcont(lhs,contreg);
2509
	      }
2522
	      }
2510
	      else
2523
	      else
2511
	      if ( !dependson(lhs,0,lhs) )
2524
	      if (!dependson(lhs,0,lhs))
2512
		 keepcont(lhs,contreg);
2525
		 keepcont(lhs,contreg);
2513
	      return (mka);
2526
	      return(mka);
2514
	   }
2527
	   }
2515
	   clear_dep_reg(lhs);
2528
	   clear_dep_reg(lhs);
2516
	   /* forget register dependencies on destination */
2529
	   /* forget register dependencies on destination */
2517
	   move(assdest.answhere, dest, nsp.fixed, 1);
2530
	   move(assdest.answhere, dest, nsp.fixed, 1);
2518
	   break;
2531
	   break;
Line 2522... Line 2535...
2522
	   clear_dep_reg(lhs);
2535
	   clear_dep_reg(lhs);
2523
	   /* forget register dependencies on destination */
2536
	   /* forget register dependencies on destination */
2524
	   move(assdest.answhere, dest, guard(assdest, sp).fixed, 1);
2537
	   move(assdest.answhere, dest, guard(assdest, sp).fixed, 1);
2525
	}
2538
	}
2526
	default:;
2539
	default:;
2527
	
2540
 
2528
     }				/* end sw on answhere */
2541
     }				/* end sw on answhere */
2529
     if (name(e) == assvol_tag)
2542
     if (name(e) == assvol_tag)
2530
	setnovolatile();
2543
	setnovolatile();
2531
     return mka;
2544
     return mka;
2532
  }
2545
  }
Line 2542... Line 2555...
2542
     instore str;
2555
     instore str;
2543
     int r;
2556
     int r;
2544
 
2557
 
2545
      /*  Initialse bitfield by constructing an appropriate constant. */
2558
      /*  Initialse bitfield by constructing an appropriate constant. */
2546
     /* Other compounds are initialised from register values below   */
2559
     /* Other compounds are initialised from register values below   */
2547
     if ( has_bitfield(e) )
2560
     if (has_bitfield(e))
2548
     {
2561
     {
2549
	instore isa;
2562
	instore isa;
2550
	ans aa;
2563
	ans aa;
2551
	labexp next;
2564
	labexp next;
2552
 
2565
 
2553
	/* word-align bitfields for ease of access */
2566
	/* word-align bitfields for ease of access */
2554
	if (dest.ashwhere.ashalign < 32)
2567
	if (dest.ashwhere.ashalign < 32)
2555
	    dest.ashwhere.ashalign =32;
2568
	    dest.ashwhere.ashalign =32;
2556
 
2569
 
2557
	/* generate constant value... */
2570
	/* generate constant value... */
2558
	fix_nonbitfield(e);	/* Ensure all offsets are BIT-offsets. */
2571
	fix_nonbitfield(e);	/* Ensure all offsets are BIT-offsets. */
2559
	next = (labexp) malloc( sizeof(struct labexp_t) );
2572
	next = (labexp)malloc(sizeof(struct labexp_t));
2560
	next->e = e;
2573
	next->e = e;
2561
	next->lab = next_data_lab();
2574
	next->lab = next_data_lab();
2562
	next->next = (labexp) 0;
2575
	next->next = (labexp)0;
2563
	current->next = next;
2576
	current->next = next;
2564
	current = next;
2577
	current = next;
2565
	isa.adval = 0;
2578
	isa.adval = 0;
2566
	isa.b.offset = 0;
2579
	isa.b.offset = 0;
2567
	isa.b.base = next->lab;
2580
	isa.b.base = next->lab;
Line 2570... Line 2583...
2570
	mka.regmove = move(aa, dest, sp.fixed, 1);
2583
	mka.regmove = move(aa, dest, sp.fixed, 1);
2571
	return mka;
2584
	return mka;
2572
     }
2585
     }
2573
 
2586
 
2574
     nsp = sp;
2587
     nsp = sp;
2575
     switch ( discrim(dest.answhere) )
2588
     switch (discrim(dest.answhere))
2576
     {
2589
     {
2577
	case notinreg:
2590
	case notinreg:
2578
	{
2591
	{
2579
	   str = insalt(dest.answhere);	/* it should be !! */
2592
	   str = insalt(dest.answhere);	/* it should be !! */
2580
	   if ( !str.adval )
2593
	   if (!str.adval)
2581
	   {
2594
	   {
2582
	      int r = getreg(sp.fixed);
2595
	      int r = getreg(sp.fixed);
2583
	      nsp = guardreg(r, sp);
2596
	      nsp = guardreg(r, sp);
2584
	      ld_ins(i_lw,1,str.b,r);
2597
	      ld_ins(i_lw,1,str.b,r);
2585
	      str.adval = 1;
2598
	      str.adval = 1;
Line 2595... Line 2608...
2595
 	      assert(name(t) == val_tag && al2(sh(t)) >= 8); /* offset in bits */
2608
 	      assert(name(t) == val_tag && al2(sh(t)) >= 8); /* offset in bits */
2596
	      setinsalt(newdest.answhere, newis);
2609
	      setinsalt(newdest.answhere, newis);
2597
	      newdest.ashwhere = ashof(sh(bro(t)));
2610
	      newdest.ashwhere = ashof(sh(bro(t)));
2598
	      assert(ashof(bro(t)).ashalign != 1); /* stray bitfield */
2611
	      assert(ashof(bro(t)).ashalign != 1); /* stray bitfield */
2599
	      code_here(bro(t), nsp, newdest);
2612
	      code_here(bro(t), nsp, newdest);
2600
	      if ( last(bro(t)) )
2613
	      if (last(bro(t)))
2601
		 return mka;
2614
		 return mka;
2602
	      t = bro(bro(t));
2615
	      t = bro(bro(t));
2603
	   }
2616
	   }
2604
	}
2617
	}
2605
	case insomereg:
2618
	case insomereg:
2606
	{
2619
	{
2607
	   int *sr = someregalt(dest.answhere);
2620
	   int *sr = someregalt(dest.answhere);
2608
  	   if ( *sr != -1 )
2621
  	   if (*sr != -1)
2609
	      failer("Somereg *2");
2622
	      failer("Somereg *2");
2610
 	   *sr = getreg(sp.fixed);
2623
 	   *sr = getreg(sp.fixed);
2611
	   setregalt(dest.answhere, *sr);
2624
	   setregalt(dest.answhere, *sr);
2612
	   /* ,... */
2625
	   /* ,... */
2613
       }
2626
       }
2614
       case inreg:
2627
       case inreg:
2615
       {
2628
       {
2616
	  code_here(bro(t), sp, dest);
2629
	  code_here(bro(t), sp, dest);
2617
	  r = regalt(dest.answhere);
2630
	  r = regalt(dest.answhere);
2618
	  assert(name(t) == val_tag);
2631
	  assert(name(t) == val_tag);
2619
	  if ( no(t) != 0 )
2632
	  if (no(t)!= 0)
2620
	     rrir_ins(i_shd,c_,r,0,32-(((al2(sh(t)) >= 8) ? (no(t) << 3) : no(t))),r);
2633
	     rrir_ins(i_shd,c_,r,0,32- (((al2(sh(t)) >= 8)?(no(t) << 3): no(t))),r);
2621
	  nsp = guardreg(r, sp);
2634
	  nsp = guardreg(r, sp);
2622
	  while ( !last(bro(t)) )
2635
	  while (!last(bro(t)))
2623
	  {
2636
	  {
2624
	     int z;
2637
	     int z;
2625
 	     t = bro(bro(t));
2638
 	     t = bro(bro(t));
2626
	     assert(name(t) == val_tag);
2639
	     assert(name(t) == val_tag);
2627
	     z = reg_operand(bro(t), nsp);
2640
	     z = reg_operand(bro(t), nsp);
2628
	     if (no(t) != 0)
2641
	     if (no(t)!= 0)
2629
		rrir_ins(i_shd,c_,z,0,32-(((al2(sh(t)) >= 8) ? (no(t) << 3) : no(t))),z);
2642
		rrir_ins(i_shd,c_,z,0,32- (((al2(sh(t)) >= 8)?(no(t) << 3): no(t))),z);
2630
	     rrr_ins(i_or,c_,r,z,r);
2643
	     rrr_ins(i_or,c_,r,z,r);
2631
	  }
2644
	  }
2632
	  return mka;
2645
	  return mka;
2633
       }
2646
       }
2634
       case insomefreg:
2647
       case insomefreg:
2635
       {
2648
       {
2636
	  somefreg sfr;
2649
	  somefreg sfr;
2637
	  freg fr;
2650
	  freg fr;
2638
   	  sfr = somefregalt(dest.answhere);
2651
   	  sfr = somefregalt(dest.answhere);
2639
	  if ( *sfr.fr != -1 )
2652
	  if (*sfr.fr != -1)
2640
	     failer ("Somefreg *2");
2653
	     failer("Somefreg *2");
2641
	  *sfr.fr = getfreg(sp.flt);
2654
	  *sfr.fr = getfreg(sp.flt);
2642
	  fr.fr = *sfr.fr;
2655
	  fr.fr = *sfr.fr;
2643
	  fr.dble = sfr.dble;
2656
	  fr.dble = sfr.dble;
2644
	  setfregalt(dest.answhere, fr);
2657
	  setfregalt(dest.answhere, fr);
2645
       }             		
2658
       }
2646
       case infreg:
2659
       case infreg:
2647
       {
2660
       {
2648
	  code_here(bro(t), sp, dest);
2661
	  code_here(bro(t), sp, dest);
2649
	  if (!last(bro(t)) || name(t)!=val_tag || no(t) !=0)
2662
	  if (!last(bro(t)) || name(t)!=val_tag || no(t)!=0)
2650
	     failer("No Tuples in freg");
2663
	     failer("No Tuples in freg");
2651
	  return mka;
2664
	  return mka;
2652
       }
2665
       }
2653
       default:;
2666
       default:;
2654
    }
2667
    }
2655
 
2668
 
2656
  }	
2669
  }
2657
  /*  ENDS compound_tag  */
2670
  /*  ENDS compound_tag  */
2658
 
2671
 
2659
/*****************************************************************************/
2672
/*****************************************************************************/
2660
 
2673
 
2661
  case nof_tag:
2674
  case nof_tag:
2662
  case concatnof_tag:
2675
  case concatnof_tag:
2663
  {
2676
  {
2664
     exp t = son(e);
2677
     exp t = son(e);
2665
     space nsp;
2678
     space nsp;
2666
     instore str;
2679
     instore str;
2667
     int r, disp = 0;
2680
     int r, disp = 0;
2668
#if 1
2681
#if 1
2669
     if( t==nilexp )
2682
     if (t==nilexp)
2670
	return mka;
2683
	return mka;
2671
#endif
2684
#endif
2672
     nsp = sp;
2685
     nsp = sp;
2673
     switch ( discrim(dest.answhere) )
2686
     switch (discrim(dest.answhere))
2674
     {
2687
     {
2675
	case notinreg:
2688
	case notinreg:
2676
	{
2689
	{
2677
	   str = insalt(dest.answhere);	/* it should be !! */
2690
	   str = insalt(dest.answhere);	/* it should be !! */
2678
	   if ( !str.adval )
2691
	   if (!str.adval)
2679
	   {
2692
	   {
2680
	      int r = getreg(sp.fixed);
2693
	      int r = getreg(sp.fixed);
2681
	      nsp = guardreg(r, sp);
2694
	      nsp = guardreg(r, sp);
2682
 	      ld_ins(i_lw,1,str.b,r);
2695
 	      ld_ins(i_lw,1,str.b,r);
2683
	      str.adval = 1;
2696
	      str.adval = 1;
Line 2691... Line 2704...
2691
 	      newis = str;
2704
 	      newis = str;
2692
	      newis.b.offset += disp;
2705
	      newis.b.offset += disp;
2693
	      setinsalt(newdest.answhere, newis);
2706
	      setinsalt(newdest.answhere, newis);
2694
	      newdest.ashwhere = ashof(sh(t));
2707
	      newdest.ashwhere = ashof(sh(t));
2695
	      code_here(t, nsp, newdest);
2708
	      code_here(t, nsp, newdest);
2696
	      if ( last(t) )
2709
	      if (last(t))
2697
 	         return mka;
2710
 	         return mka;
2698
	      disp += (rounder(shape_size(sh(t)), shape_align(sh(bro(t)))) >> 3);
2711
	      disp += (rounder(shape_size(sh(t)), shape_align(sh(bro(t)))) >> 3);
2699
	      t = bro(t);
2712
	      t = bro(t);
2700
	   }
2713
	   }
2701
	}
2714
	}
Line 2739... Line 2752...
2739
     space nsp;
2752
     space nsp;
2740
     instore str;
2753
     instore str;
2741
     int i, r, disp = 0;
2754
     int i, r, disp = 0;
2742
 
2755
 
2743
     nsp = sp;
2756
     nsp = sp;
2744
     switch ( discrim(dest.answhere) )
2757
     switch (discrim(dest.answhere))
2745
     {
2758
     {
2746
	case notinreg:
2759
	case notinreg:
2747
	{
2760
	{
2748
	   str = insalt(dest.answhere);	/* it should be !! */
2761
	   str = insalt(dest.answhere);	/* it should be !! */
2749
	   if (!str.adval)
2762
	   if (!str.adval)
Line 2753... Line 2766...
2753
	      ld_ins(i_lw,1,str.b,r);
2766
	      ld_ins(i_lw,1,str.b,r);
2754
	      str.adval = 1;
2767
	      str.adval = 1;
2755
	      str.b.base = r;
2768
	      str.b.base = r;
2756
	      str.b.offset = 0;
2769
	      str.b.offset = 0;
2757
	   }
2770
	   }
2758
	   for ( i = 1; i <= no(e); i++ )
2771
	   for (i = 1; i <= no(e); i++)
2759
	   {
2772
	   {
2760
	      where newdest;
2773
	      where newdest;
2761
	      instore newis;
2774
	      instore newis;
2762
	      newis = str;
2775
	      newis = str;
2763
	      newis.b.offset += disp;
2776
	      newis.b.offset += disp;
Line 2769... Line 2782...
2769
	   return mka;
2782
	   return mka;
2770
	}
2783
	}
2771
	case insomereg:
2784
	case insomereg:
2772
	{
2785
	{
2773
	   int *sr = someregalt(dest.answhere);
2786
	   int *sr = someregalt(dest.answhere);
2774
 	   if ( *sr != -1 )
2787
 	   if (*sr != -1)
2775
 	      failer("Somereg *2");
2788
 	      failer("Somereg *2");
2776
	   *sr = getreg(sp.fixed);
2789
	   *sr = getreg(sp.fixed);
2777
	   setregalt(dest.answhere, *sr);
2790
	   setregalt(dest.answhere, *sr);
2778
	   /* ,... */
2791
	   /* ,... */
2779
	}
2792
	}
2780
	case inreg:
2793
	case inreg:
2781
	{
2794
	{
2782
	   code_here(t, sp, dest);
2795
	   code_here(t, sp, dest);
2783
	   r = regalt(dest.answhere);
2796
	   r = regalt(dest.answhere);
2784
	   nsp = guardreg(r, sp);
2797
	   nsp = guardreg(r, sp);
2785
	   for ( i = 1; i <= no(e); i++ )
2798
	   for (i = 1; i <= no(e); i++)
2786
	   {
2799
	   {
2787
	      int z;
2800
	      int z;
2788
 	      disp += rounder(shape_size(sh(t)), shape_align(sh(t)));
2801
 	      disp += rounder(shape_size(sh(t)), shape_align(sh(t)));
2789
	      z = reg_operand(t, nsp);
2802
	      z = reg_operand(t, nsp);
2790
	      rrir_ins(i_shd,c_,z,0,32-disp,z);
2803
	      rrir_ins(i_shd,c_,z,0,32-disp,z);
Line 2795... Line 2808...
2795
	default:
2808
	default:
2796
	  failer("No Tuples in freg");
2809
	  failer("No Tuples in freg");
2797
     }
2810
     }
2798
   }
2811
   }
2799
   /*  ENDS ncopies_tag  */
2812
   /*  ENDS ncopies_tag  */
2800
 
2813
 
2801
/*****************************************************************************/
2814
/*****************************************************************************/
2802
 
2815
 
2803
    case diagnose_tag :
2816
    case diagnose_tag:
2804
    {
2817
    {
2805
       /* Diagnostics */
2818
       /* Diagnostics */
2806
       diag_info *d = dno(e);
2819
       diag_info *d = dno(e);
2807
       stab_begin(d,0,e);
2820
       stab_begin(d,0,e);
2808
       mka = make_code(son(e),sp,dest,exitlab);
2821
       mka = make_code(son(e),sp,dest,exitlab);
2809
       stab_end(d,e);
2822
       stab_end(d,e);
2810
       return (mka);
2823
       return(mka);
2811
    }
2824
    }
2812
    /*  ENDS diagnose_tag  */
2825
    /*  ENDS diagnose_tag  */
2813
 
2826
 
2814
/*****************************************************************************/
2827
/*****************************************************************************/
2815
 
2828
 
2816
  case solve_tag:
2829
  case solve_tag:
2817
  {
2830
  {
2818
     exp m = bro(son(e));
2831
     exp m = bro(son(e));
2819
     int l = exitlab;
2832
     int l = exitlab;
2820
 
2833
 
2821
     if ( discrim(dest.answhere) == insomereg )
2834
     if (discrim(dest.answhere) == insomereg)
2822
     {
2835
     {
2823
	int *sr = someregalt(dest.answhere);
2836
	int *sr = someregalt(dest.answhere);
2824
	if (*sr != -1)
2837
	if (*sr != -1)
2825
 	   fail("somereg *2");
2838
 	   fail("somereg *2");
2826
	*sr = getreg(sp.fixed);
2839
	*sr = getreg(sp.fixed);
2827
	setregalt(dest.answhere, *sr);
2840
	setregalt(dest.answhere, *sr);
2828
     }
2841
     }
2829
 
2842
 
2830
     /* set up all the labels in the component labst_tags */
2843
     /* set up all the labels in the component labst_tags */
2831
     for (;;)
2844
     for (;;)
2832
     {
2845
     {
2833
	no(son(m)) = new_label();
2846
	no(son(m)) = new_label();
Line 2839... Line 2852...
2839
 
2852
 
2840
     /* evaluate all the component statements */
2853
     /* evaluate all the component statements */
2841
     for (;;)
2854
     for (;;)
2842
     {
2855
     {
2843
	int fl = make_code(m, sp, dest, l).lab;
2856
	int fl = make_code(m, sp, dest, l).lab;
2844
 
2857
 
2845
	clear_all();
2858
	clear_all();
2846
	if ( fl != 0 )
2859
	if (fl != 0)
2847
	   l = fl;
2860
	   l = fl;
2848
 
2861
 
2849
	if ( !last(m) )
2862
	if (!last(m))
2850
	{
2863
	{
2851
 	   /* jump to end of solve */
2864
 	   /* jump to end of solve */
2852
	   if ( l == 0 )
2865
	   if (l == 0)
2853
	      l = new_label();
2866
	      l = new_label();
2854
	   if (name(sh(m)) != bothd)
2867
	   if (name(sh(m))!= bothd)
2855
	   {
2868
	   {
2856
	      ub_ins(cmplt_,l);
2869
	      ub_ins(cmplt_,l);
2857
	   }
2870
	   }
2858
	}
2871
	}
2859
	if ( last(m) )
2872
	if (last(m))
2860
	{
2873
	{
2861
	   mka.lab = l;
2874
	   mka.lab = l;
2862
	   return mka;
2875
	   return mka;
2863
	};
2876
	};
2864
	m = bro(m);
2877
	m = bro(m);
Line 2879... Line 2892...
2879
     long u = 0x80000000;
2892
     long u = 0x80000000;
2880
 
2893
 
2881
     unsigned long approx_range;  /* max(u-l, 0x7fffffff) avoiding overflow */
2894
     unsigned long approx_range;  /* max(u-l, 0x7fffffff) avoiding overflow */
2882
     bool use_jump_vector;
2895
     bool use_jump_vector;
2883
     l = no(zt);
2896
     l = no(zt);
2884
     for(n = 1;;n++)
2897
     for (n = 1;;n++)
2885
     {
2898
     {
2886
	/* calculate crude criterion for using jump vector or branches */
2899
	/* calculate crude criterion for using jump vector or branches */
2887
	if ( u + 1 != no(zt) && son(zt) != nilexp)
2900
	if (u + 1 != no(zt) && son(zt)!= nilexp)
2888
	   n++;
2901
	   n++;
2889
	if (last(zt))
2902
	if (last(zt))
2890
	{
2903
	{
2891
	   u = (son(zt) != nilexp) ? no(son(zt)) : no(zt);
2904
	   u = (son(zt)!= nilexp)? no(son(zt)): no(zt);
2892
	   break;
2905
	   break;
2893
	}
2906
	}
2894
	if ( son(zt) != nilexp )
2907
	if (son(zt)!= nilexp)
2895
	{
2908
	{
2896
	   u = no(son(zt));
2909
	   u = no(son(zt));
2897
	}
2910
	}
2898
	else
2911
	else
2899
	{
2912
	{
2900
	   if ( u + 1 == no(zt) )
2913
	   if (u + 1 == no(zt))
2901
	      u += 1;
2914
	      u += 1;
2902
	}
2915
	}
2903
	zt = bro(zt);
2916
	zt = bro(zt);
2904
     }
2917
     }
2905
     /* 
2918
     /*
2906
     *    Now l is lowest controlling value, u is highest, and n is number of
2919
     *    Now l is lowest controlling value, u is highest, and n is number of
2907
      *   cases
2920
      *   cases
2908
       */
2921
       */
2909
     if ( u - l < 0 )
2922
     if (u - l < 0)
2910
	approx_range = 0x7fffffff;  /* u-l overflowed into -ve, use huge */
2923
	approx_range = 0x7fffffff;  /* u-l overflowed into -ve, use huge */
2911
     else
2924
     else
2912
	approx_range = u - l;
2925
	approx_range = u - l;
2913
     if ( approx_range < 16 )
2926
     if (approx_range < 16)
2914
     {
2927
     {
2915
	/* small jump vector needed, decide on instuctions executed only */
2928
	/* small jump vector needed, decide on instuctions executed only */
2916
 
2929
 
2917
	unsigned jump_vector_cnt = ((l >= 0 && l <= 4) ? 8 : 9);
2930
	unsigned jump_vector_cnt = ((l >= 0 && l <= 4)? 8 : 9);
2918
	unsigned cmp_jmp_step_cnt = 2 + (!SIMM13(l)) + (!SIMM13(u));
2931
	unsigned cmp_jmp_step_cnt = 2 + (!SIMM13(l)) + (!SIMM13(u));
2919
 
2932
 
2920
	/* cmp & jmp, delay slot filled plus possibly load of large consts */
2933
	/* cmp & jmp, delay slot filled plus possibly load of large consts */
2921
	/* +++ assume default used as often as case, is this good? */
2934
	/* +++ assume default used as often as case, is this good? */
2922
	unsigned default_weight = 1;	/* likelyhood of default against
2935
	unsigned default_weight = 1;	/* likelyhood of default against
Line 2939... Line 2952...
2939
	/*
2952
	/*
2940
	 * space-time product criterion for jump vector instead of tests and
2953
	 * space-time product criterion for jump vector instead of tests and
2941
	 * branches
2954
	 * branches
2942
	 */
2955
	 */
2943
	unsigned long range_factor = approx_range + 9;
2956
	unsigned long range_factor = approx_range + 9;
2944
	unsigned long n_factor = ((unsigned long) n * n) / 2;
2957
	unsigned long n_factor = ((unsigned long)n * n) / 2;
2945
 
2958
 
2946
	use_jump_vector = range_factor <= n_factor;
2959
	use_jump_vector = range_factor <= n_factor;
2947
 
2960
 
2948
     }
2961
     }
2949
 
2962
 
2950
     assert(l <= u);
2963
     assert(l <= u);
2951
     assert(n >= 0);
2964
     assert(n >= 0);
2952
 
2965
 
2953
     if ( use_jump_vector )
2966
     if (use_jump_vector)
2954
     {
2967
     {
2955
	/* use jump vector, 8/9 insts overhead */
2968
	/* use jump vector, 8/9 insts overhead */
2956
	int endlab = new_label();
2969
	int endlab = new_label();
2957
	int veclab = 0;
2970
	int veclab = 0;
2958
	char zeroveclab[16];
2971
	char zeroveclab[16];
2959
	int mr = getreg(sp.fixed);
2972
	int mr = getreg(sp.fixed);
2960
	zeroveclab[0] = 0;
2973
	zeroveclab[0] = 0;
2961
	if (!PIC_code)
2974
	if (!PIC_code)
2962
	{
2975
	{
2963
	   veclab = next_data_lab();
2976
	   veclab = next_data_lab();
2964
	   sprintf(zeroveclab, "LD$%ld", (long)veclab);
2977
	   sprintf(zeroveclab, "LD$%ld",(long)veclab);
2965
	}
2978
	}
2966
	if ( l >= 0 && l <= 4 )
2979
	if (l >= 0 && l <= 4)
2967
	{
2980
	{
2968
	   /* between 0 and 4 dummy table entries used to avoid subtract */
2981
	   /* between 0 and 4 dummy table entries used to avoid subtract */
2969
	   cij_ins(c_lu,u,r,endlab);
2982
	   cij_ins(c_lu,u,r,endlab);
2970
 	   n = 0;
2983
 	   n = 0;
2971
	   if (PIC_code)
2984
	   if (PIC_code)
Line 2982... Line 2995...
2982
	   ld_rr_ins(i_ldwx,cmplt_S,r,GR1,GR1);
2995
	   ld_rr_ins(i_ldwx,cmplt_S,r,GR1,GR1);
2983
	}
2996
	}
2984
	else
2997
	else
2985
	{
2998
	{
2986
	   /* subtract to index jump vector */
2999
	   /* subtract to index jump vector */
2987
	   if SIMM11( -l )
3000
	   if SIMM11(-l)
2988
	      irr_ins(i_addi,c_,fs_,-l,r,mr);
3001
	      irr_ins(i_addi,c_,fs_,-l,r,mr);
2989
	   else
3002
	   else
2990
	   {
3003
	   {
2991
	      ir_ins(i_addil,fs_L,empty_ltrl,-l,r);
3004
	      ir_ins(i_addil,fs_L,empty_ltrl,-l,r);
2992
	      ld_ir_ins(i_ldo,cmplt_,fs_R,empty_ltrl,-l,GR1,mr);
3005
	      ld_ir_ins(i_ldo,cmplt_,fs_R,empty_ltrl,-l,GR1,mr);
Line 3015... Line 3028...
3015
	if (!PIC_code)
3028
	if (!PIC_code)
3016
	   outlab("LD$",veclab);
3029
	   outlab("LD$",veclab);
3017
   	for (;;)
3030
   	for (;;)
3018
	{
3031
	{
3019
	   char labl[48];
3032
	   char labl[48];
3020
	   for (; no(z) > n; n++ )
3033
	   for (; no(z) > n; n++)
3021
	   {
3034
	   {
3022
	      sprintf(labl,"L$$%d",endlab);
3035
	      sprintf(labl,"L$$%d",endlab);
3023
	      out_directive(".WORD",labl);
3036
	      out_directive(".WORD",labl);
3024
	   }
3037
	   }
3025
	   u = (son(z) == nilexp) ? n : no(son(z));
3038
	   u = (son(z) == nilexp)? n : no(son(z));
3026
	   for (; n <= u; n++ )
3039
	   for (; n <= u; n++)
3027
	   {
3040
	   {
3028
	      sprintf(labl,"L$$%d",no(son(pt(z))));
3041
	      sprintf(labl,"L$$%d",no(son(pt(z))));
3029
	      out_directive(".WORD",labl);
3042
	      out_directive(".WORD",labl);
3030
	   }
3043
	   }
3031
	   if (last(z))
3044
	   if (last(z))
Line 3042... Line 3055...
3042
	*    Use branches - tests are already ordered
3055
	*    Use branches - tests are already ordered
3043
	 */
3056
	 */
3044
	int over = 0;
3057
	int over = 0;
3045
	mm lims;
3058
	mm lims;
3046
	lims = maxmin(sh(son(e)));
3059
	lims = maxmin(sh(son(e)));
3047
	if ( is_signed(sh(son(e))) )
3060
	if (is_signed(sh(son(e))))
3048
	{
3061
	{
3049
	   long u,l;
3062
	   long u,l;
3050
	   for (;;)
3063
	   for (;;)
3051
	   {
3064
	   {
3052
	      int lab = no(son(pt(z)));
3065
	      int lab = no(son(pt(z)));
3053
	      l = no(z);
3066
	      l = no(z);
3054
	      if ( son(z) == nilexp )
3067
	      if (son(z) == nilexp)
3055
	      {
3068
	      {
3056
 	         /* only single test required */
3069
 	         /* only single test required */
3057
		 cij_ins(c_eq,l,r,lab);
3070
		 cij_ins(c_eq,l,r,lab);
3058
		 if ( l == lims.maxi )
3071
		 if (l == lims.maxi)
3059
		    lims.maxi -= 1;
3072
		    lims.maxi -= 1;
3060
		 else
3073
		 else
3061
		 if ( l == lims.mini )
3074
		 if (l == lims.mini)
3062
		    lims.mini += 1;
3075
		    lims.mini += 1;
3063
	      }
3076
	      }
3064
	      else
3077
	      else
3065
	      if ( u = no(son(z)), l > lims.mini )
3078
	      if (u = no(son(z)), l > lims.mini)
3066
	      {
3079
	      {
3067
		 if ( u >= lims.maxi )
3080
		 if (u >= lims.maxi)
3068
		 {
3081
		 {
3069
		    cij_ins(c_leq,l,r,lab);
3082
		    cij_ins(c_leq,l,r,lab);
3070
		    lims.maxi = l - 1;
3083
		    lims.maxi = l - 1;
3071
		 }
3084
		 }
3072
		 else
3085
		 else
3073
		 {
3086
		 {
3074
		    if ( over == 0 )
3087
		    if (over == 0)
3075
		       over = new_label();
3088
		       over = new_label();
3076
		    cij_ins(c_g,l,r,over);
3089
		    cij_ins(c_g,l,r,over);
3077
		    cij_ins(c_geq,u,r,lab);
3090
		    cij_ins(c_geq,u,r,lab);
3078
		    lims.mini = u + 1;
3091
		    lims.mini = u + 1;
3079
		 }
3092
		 }
3080
	      }
3093
	      }
3081
	      else 
3094
	      else
3082
	      if ( u < lims.maxi )
3095
	      if (u < lims.maxi)
3083
	      {
3096
	      {
3084
		 cij_ins(c_geq,u,r,lab);
3097
		 cij_ins(c_geq,u,r,lab);
3085
		 lims.mini = u + 1;
3098
		 lims.mini = u + 1;
3086
	      }
3099
	      }
3087
	      else
3100
	      else
3088
	      {
3101
	      {
3089
		 ub_ins(cmplt_,lab);
3102
		 ub_ins(cmplt_,lab);
3090
	      }
3103
	      }
3091
	      if ( last(z) )
3104
	      if (last(z))
3092
	      {
3105
	      {
3093
		 if ( over != 0 )
3106
		 if (over != 0)
3094
		 {
3107
		 {
3095
		    clear_all();
3108
		    clear_all();
3096
		    outlab("L$$",over);
3109
		    outlab("L$$",over);
3097
		 }
3110
		 }
3098
		 return mka;
3111
		 return mka;
Line 3107... Line 3120...
3107
	   mini = (unsigned)lims.mini;
3120
	   mini = (unsigned)lims.mini;
3108
	   for (;;)
3121
	   for (;;)
3109
	   {
3122
	   {
3110
	      int lab = no(son(pt(z)));
3123
	      int lab = no(son(pt(z)));
3111
	      l = no(z);
3124
	      l = no(z);
3112
	      if ( son(z) == nilexp )
3125
	      if (son(z) == nilexp)
3113
	      {
3126
	      {
3114
		 /* only single test required */
3127
		 /* only single test required */
3115
		 cij_ins(c_eq,l,r,lab);
3128
		 cij_ins(c_eq,l,r,lab);
3116
		 if (l == maxi)
3129
		 if (l == maxi)
3117
		   maxi -= 1;
3130
		   maxi -= 1;
3118
		 else
3131
		 else
3119
		 if (l == mini)
3132
		 if (l == mini)
3120
		    mini += 1;
3133
		    mini += 1;
3121
	      }
3134
	      }
3122
	      else
3135
	      else
3123
	      if ( u = no(son(z)), l > mini )
3136
	      if (u = no(son(z)), l > mini)
3124
	      {
3137
	      {
3125
		 if ( u >= maxi) 
3138
		 if (u >= maxi)
3126
		 {
3139
		 {
3127
		    cij_ins(c_lequ,l,r,lab);
3140
		    cij_ins(c_lequ,l,r,lab);
3128
		    maxi = l - 1;
3141
		    maxi = l - 1;
3129
		 }
3142
		 }
3130
		 else
3143
		 else
3131
		 {
3144
		 {
3132
		    if ( over == 0 )
3145
		    if (over == 0)
3133
		    {
3146
		    {
3134
		       over = new_label();
3147
		       over = new_label();
3135
		    }
3148
		    }
3136
		    cij_ins(c_gu,l,r,over);
3149
		    cij_ins(c_gu,l,r,over);
3137
		    cij_ins(c_gequ,u,r,lab);
3150
		    cij_ins(c_gequ,u,r,lab);
3138
		    mini = u + 1;
3151
		    mini = u + 1;
3139
		 }
3152
		 }
3140
	      }
3153
	      }
3141
	      else
3154
	      else
3142
	      if ( u < maxi ) 
3155
	      if (u < maxi)
3143
	      {
3156
	      {
3144
		 cij_ins(c_gequ,u,r,lab);
3157
		 cij_ins(c_gequ,u,r,lab);
3145
		 mini = u + 1;
3158
		 mini = u + 1;
3146
	      }
3159
	      }
3147
	      else
3160
	      else
3148
	      {
3161
	      {
3149
		 ub_ins(cmplt_,lab);
3162
		 ub_ins(cmplt_,lab);
3150
 	      }
3163
 	      }
3151
	      if ( last(z) )
3164
	      if (last(z))
3152
	      {
3165
	      {
3153
		 if ( over != 0 )
3166
		 if (over != 0)
3154
		 {
3167
		 {
3155
		    clear_all();
3168
		    clear_all();
3156
		    outlab("L$$",over);
3169
		    outlab("L$$",over);
3157
		 }
3170
		 }
3158
		 return mka;
3171
		 return mka;
Line 3181... Line 3194...
3181
	space nsp;
3194
	space nsp;
3182
	l = reg_operand(son(e),sp);
3195
	l = reg_operand(son(e),sp);
3183
	nsp = guardreg(l,sp);
3196
	nsp = guardreg(l,sp);
3184
	r = reg_operand(bro(son(e)),guardreg(l,sp));
3197
	r = reg_operand(bro(son(e)),guardreg(l,sp));
3185
	nsp = guardreg(r,sp);
3198
	nsp = guardreg(r,sp);
3186
	if ( discrim(dest.answhere)!=inreg || (d=regalt((dest).answhere))==0 )
3199
	if (discrim(dest.answhere)!=inreg || (d=regalt((dest).answhere)) ==0)
3187
	   d = getreg(nsp.fixed);
3200
	   d = getreg(nsp.fixed);
3188
	if (shape_size(sh(e))==32)
3201
	if (shape_size(sh(e)) ==32)
3189
	{
3202
	{
3190
	   rrr_ins(i_add,is_signed(sh(e)) ? c_NSV : c_NUV,l,r,d);
3203
	   rrr_ins(i_add,is_signed(sh(e))? c_NSV : c_NUV,l,r,d);
3191
	   ub_ins(cmplt_N,trap);
3204
	   ub_ins(cmplt_N,trap);
3192
	}
3205
	}
3193
	else
3206
	else
3194
	{
3207
	{
3195
	   rrr_ins(i_add,c_,l,r,d);
3208
	   rrr_ins(i_add,c_,l,r,d);
Line 3210... Line 3223...
3210
/*****************************************************************************/
3223
/*****************************************************************************/
3211
 
3224
 
3212
  case offset_pad_tag:
3225
  case offset_pad_tag:
3213
  {
3226
  {
3214
     int r,o;
3227
     int r,o;
3215
     ans aa;
3228
     ans aa;
3216
     space nsp;
3229
     space nsp;
3217
     if ( (al2(sh(son(e))) < al2(sh(e))) || (al1_of(sh(e))->al.al_val.al_frame & 4)!=0 )
3230
     if ((al2(sh(son(e))) < al2(sh(e))) || (al1_of(sh(e)) ->al.al_val.al_frame & 4)!=0)
3218
     {
3231
     {
3219
	int al = (al2(sh(son(e)))==1) ? al2(sh(e)) : (al2(sh(e))/8);
3232
	int al = (al2(sh(son(e))) ==1)? al2(sh(e)):(al2(sh(e)) /8);
3220
	r = GETREG(dest,sp);
3233
	r = GETREG(dest,sp);
3221
	o = reg_operand(son(e),sp); 
3234
	o = reg_operand(son(e),sp);
3222
	if ((al1_of(sh(e))->al.al_val.al_frame & 4)==0)
3235
	if ((al1_of(sh(e)) ->al.al_val.al_frame & 4) ==0)
3223
	{
3236
	{
3224
	   irr_ins(i_addi,c_,fs_,al-1,o,r);
3237
	   irr_ins(i_addi,c_,fs_,al-1,o,r);
3225
	   logical_op(i_and,-al,r,r);
3238
	   logical_op(i_and,-al,r,r);
3226
	}
3239
	}
3227
	else
3240
	else
3228
	   logical_op(i_and,-al,o,r);
3241
	   logical_op(i_and,-al,o,r);
3229
	if ( al2(sh(son(e)))==1 )
3242
	if (al2(sh(son(e))) ==1)
3230
	{
3243
	{
3231
	   /*   Operand is bit-offset, byte-offset required.   */
3244
	   /*   Operand is bit-offset, byte-offset required.   */
3232
	   riir_ins(i_extrs,c_,r,28,29,r);
3245
	   riir_ins(i_extrs,c_,r,28,29,r);
3233
	}
3246
	}
3234
     }
3247
     }
3235
     else
3248
     else
3236
     {
3249
     {
3237
	if ( al2(sh(e))!=1 || al2(sh(son(e)))==1 )
3250
	if (al2(sh(e))!=1 || al2(sh(son(e))) ==1)
3238
	{
3251
	{
3239
	   /*   Already aligned correctly, whether as bit or byte-offset.   */
3252
	   /*   Already aligned correctly, whether as bit or byte-offset.   */
3240
	   e = son(e);
3253
	   e = son(e);
3241
	   goto tailrecurse;
3254
	   goto tailrecurse;
3242
	}
3255
	}
Line 3248... Line 3261...
3248
     nsp = guardreg(r,sp);
3261
     nsp = guardreg(r,sp);
3249
     mka.regmove = move(aa,dest,nsp.fixed,0);
3262
     mka.regmove = move(aa,dest,nsp.fixed,0);
3250
     return mka;
3263
     return mka;
3251
  }
3264
  }
3252
  /*  ENDS offset_pad_tag  */
3265
  /*  ENDS offset_pad_tag  */
3253
 
3266
 
3254
/*****************************************************************************/
3267
/*****************************************************************************/
3255
 
3268
 
3256
  case locptr_tag:
3269
  case locptr_tag:
3257
  {
3270
  {
3258
     int ansr = GETREG(dest,sp);
3271
     int ansr = GETREG(dest,sp);
3259
     int pr = reg_operand(son(e),sp);
3272
     int pr = reg_operand(son(e),sp);
3260
     space nsp;
3273
     space nsp;
Line 3271... Line 3284...
3271
 
3284
 
3272
/*****************************************************************************/
3285
/*****************************************************************************/
3273
 
3286
 
3274
  case chvar_tag:
3287
  case chvar_tag:
3275
  {
3288
  {
3276
      /* 
3289
      /*
3277
       *   Change integer variety.
3290
       *   Change integer variety.
3278
       */
3291
       */
3279
      exp arg = son(e); 		/* source of chvar, adjusted below */
3292
      exp arg = son(e); 		/* source of chvar, adjusted below */
3280
      int size_e = shape_size(sh(e));  /* shape of result */
3293
      int size_e = shape_size(sh(e));  /* shape of result */
3281
      int to = (int) name(sh(e));     /* to hd */
3294
      int to = (int) name(sh(e));     /* to hd */
Line 3284... Line 3297...
3284
      bool inmem_dest;
3297
      bool inmem_dest;
3285
      space nsp;
3298
      space nsp;
3286
       /*
3299
       /*
3287
       *   For a series of chvar_tags, do large to small in one go.
3300
       *   For a series of chvar_tags, do large to small in one go.
3288
      */
3301
      */
3289
      while (name(arg) == chvar_tag && shape_size(sh(arg)) >= size_e )
3302
      while (name(arg) == chvar_tag && shape_size(sh(arg)) >= size_e)
3290
      {
3303
      {
3291
  	 arg = son(arg);
3304
  	 arg = son(arg);
3292
      }
3305
      }
3293
      from = (int) name(sh(arg));
3306
      from = (int)name(sh(arg));
3294
#if 1
3307
#if 1
3295
      if (from == bitfhd)
3308
      if (from == bitfhd)
3296
      {
3309
      {
3297
	 switch (shape_size(sh(arg)))
3310
	 switch (shape_size(sh(arg)))
3298
	 {
3311
	 {
3299
	     case 8:
3312
	     case 8:
3300
		sh(arg) = is_signed(sh(arg)) ? scharsh : ucharsh;
3313
		sh(arg) = is_signed(sh(arg))? scharsh : ucharsh;
3301
		from = name(sh(arg));
3314
		from = name(sh(arg));
3302
		break;
3315
		break;
3303
	     case 16:
3316
	     case 16:
3304
		sh(arg) = is_signed(sh(arg)) ? swordsh : uwordsh;
3317
		sh(arg) = is_signed(sh(arg))? swordsh : uwordsh;
3305
		from = name(sh(arg));
3318
		from = name(sh(arg));
3306
		break;
3319
		break;
3307
	     case 32:
3320
	     case 32:
3308
		sh(arg) = is_signed(sh(arg)) ? slongsh : ulongsh;
3321
		sh(arg) = is_signed(sh(arg))? slongsh : ulongsh;
3309
		from = name(sh(arg));
3322
		from = name(sh(arg));
3310
		break;
3323
		break;
3311
	 }
3324
	 }
3312
      }
3325
      }
3313
 
3326
 
3314
      if (to == bitfhd)
3327
      if (to == bitfhd)
3315
      {
3328
      {
3316
	 switch (shape_size(sh(e)))
3329
	 switch (shape_size(sh(e)))
3317
	 {
3330
	 {
3318
	     case 8:
3331
	     case 8:
3319
		sh(e) = is_signed(sh(e)) ? scharsh : ucharsh;
3332
		sh(e) = is_signed(sh(e))? scharsh : ucharsh;
3320
		to = name (sh(e));
3333
		to = name(sh(e));
3321
		break;
3334
		break;
3322
	     case 16:
3335
	     case 16:
3323
		sh(e) = is_signed(sh(e)) ? swordsh : uwordsh;
3336
		sh(e) = is_signed(sh(e))? swordsh : uwordsh;
3324
		to = name (sh(e));
3337
		to = name(sh(e));
3325
		break;
3338
		break;
3326
	     case 32:
3339
	     case 32:
3327
		sh(e) = is_signed(sh(e)) ? slongsh : ulongsh;
3340
		sh(e) = is_signed(sh(e))? slongsh : ulongsh;
3328
		to = name (sh(e));
3341
		to = name(sh(e));
3329
		break;
3342
		break;
3330
	  }
3343
	  }
3331
      }
3344
      }
3332
#endif
3345
#endif
3333
      /*
3346
      /*
3334
       *   Small to large conversions.
3347
       *   Small to large conversions.
3335
       */
3348
       */
3336
      if ( from == to || ( to == uwordhd && from == ucharhd ) ||
3349
      if (from == to || (to == uwordhd && from == ucharhd) ||
3337
	   ( to == ulonghd && ( from == ucharhd || from == uwordhd ) ) ||
3350
	  (to == ulonghd && (from == ucharhd || from == uwordhd)) ||
3338
	   ( to == swordhd && ( from == scharhd || from == ucharhd ) ) ||
3351
	  (to == swordhd && (from == scharhd || from == ucharhd)) ||
3339
	   ( to == slonghd && from != ulonghd ) )
3352
	  (to == slonghd && from != ulonghd))
3340
      {
3353
      {
3341
	 ans aa;
3354
	 ans aa;
3342
	 if ( discrim(dest.answhere)==inreg )
3355
	 if (discrim(dest.answhere) ==inreg)
3343
	 {
3356
	 {
3344
	    sreg = regalt(dest.answhere);
3357
	    sreg = regalt(dest.answhere);
3345
	    reg_operand_here(arg, sp, sreg);
3358
	    reg_operand_here(arg, sp, sreg);
3346
	 }
3359
	 }
3347
	 else
3360
	 else
Line 3354... Line 3367...
3354
      }
3367
      }
3355
 
3368
 
3356
      sreg = reg_operand(arg,sp);
3369
      sreg = reg_operand(arg,sp);
3357
      nsp = guardreg(sreg,sp);
3370
      nsp = guardreg(sreg,sp);
3358
 
3371
 
3359
      if ( !optop(e) )
3372
      if (!optop(e))
3360
      {
3373
      {
3361
	 bool signf = is_signed(sh(arg));
3374
	 bool signf = is_signed(sh(arg));
3362
	 bool signt = is_signed(sh(e));
3375
	 bool signt = is_signed(sh(e));
3363
	 int trap = trap_label(e);
3376
	 int trap = trap_label(e);
3364
	 if ( signf )
3377
	 if (signf)
3365
	 {
3378
	 {
3366
	    if ( signt )
3379
	    if (signt)
3367
	    {
3380
	    {
3368
	       if ( to == scharhd )
3381
	       if (to == scharhd)
3369
		  riir_ins(i_extrs,c_,sreg,31,8,GR1);
3382
		  riir_ins(i_extrs,c_,sreg,31,8,GR1);
3370
	       else
3383
	       else
3371
	       if ( to == swordhd )
3384
	       if (to == swordhd)
3372
		  riir_ins(i_extrs,c_,sreg,31,16,GR1);
3385
		  riir_ins(i_extrs,c_,sreg,31,16,GR1);
3373
	       cj_ins(c_neq,sreg,GR1,trap);
3386
	       cj_ins(c_neq,sreg,GR1,trap);
3374
	    }
3387
	    }
3375
	    else
3388
	    else
3376
	    {
3389
	    {
3377
	       if ( from == scharhd )
3390
	       if (from == scharhd)
3378
	       {
3391
	       {
3379
		  if (OPTIM)
3392
		  if (OPTIM)
3380
		     bb_in(bit_is_1,sreg,24,trap);
3393
		     bb_in(bit_is_1,sreg,24,trap);
3381
		  else
3394
		  else
3382
		  {
3395
		  {
3383
		     riir_ins(i_extru,c_eq,sreg,24,1,0);
3396
		     riir_ins(i_extru,c_eq,sreg,24,1,0);
3384
		     ub_ins(cmplt_,trap);
3397
		     ub_ins(cmplt_,trap);
3385
		  }
3398
		  }
3386
	       }
3399
	       }
3387
	       else
3400
	       else
3388
	       if ( from == swordhd )
3401
	       if (from == swordhd)
3389
	       {
3402
	       {
3390
		  if ( to == ucharhd )
3403
		  if (to == ucharhd)
3391
		  {
3404
		  {
3392
		     riir_ins(i_extru,c_eq,sreg,23,24,0);
3405
		     riir_ins(i_extru,c_eq,sreg,23,24,0);
3393
		     ub_ins(cmplt_,trap);
3406
		     ub_ins(cmplt_,trap);
3394
		  }
3407
		  }
3395
		  else
3408
		  else
3396
		  {
3409
		  {
3397
		     if (OPTIM)
3410
		     if (OPTIM)
3398
			bb_in(bit_is_1,sreg,16,trap);
3411
			bb_in(bit_is_1,sreg,16,trap);
3399
		     else
3412
		     else
3400
		     {
3413
		     {
3401
			riir_ins(i_extru,c_eq,sreg,16,1,0);
3414
			riir_ins(i_extru,c_eq,sreg,16,1,0);
3402
			ub_ins(cmplt_,trap);
3415
			ub_ins(cmplt_,trap);
3403
		     }
3416
		     }
3404
		  }
3417
		  }
3405
	       }
3418
	       }
3406
	       else
3419
	       else
3407
	       {
3420
	       {
3408
		  if ( to == ucharhd )
3421
		  if (to == ucharhd)
3409
		  {
3422
		  {
3410
		     riir_ins(i_extru,c_eq,sreg,23,24,0);
3423
		     riir_ins(i_extru,c_eq,sreg,23,24,0);
3411
		     ub_ins(cmplt_,trap);
3424
		     ub_ins(cmplt_,trap);
3412
		  }
3425
		  }
3413
		  else
3426
		  else
3414
		  if ( to == uwordhd )
3427
		  if (to == uwordhd)
3415
		  {
3428
		  {
3416
		     riir_ins(i_extru,c_eq,sreg,15,16,0);
3429
		     riir_ins(i_extru,c_eq,sreg,15,16,0);
3417
		     ub_ins(cmplt_,trap);
3430
		     ub_ins(cmplt_,trap);
3418
		  }
3431
		  }
3419
		  else
3432
		  else
3420
		  {
3433
		  {
Line 3423... Line 3436...
3423
		     else
3436
		     else
3424
		     {
3437
		     {
3425
			riir_ins(i_extru,c_eq,sreg,0,1,0);
3438
			riir_ins(i_extru,c_eq,sreg,0,1,0);
3426
			ub_ins(cmplt_,trap);
3439
			ub_ins(cmplt_,trap);
3427
		     }
3440
		     }
3428
		  }
3441
		  }
3429
	       }
3442
	       }
3430
	    }
3443
	    }
3431
	 }
3444
	 }
3432
	 else
3445
	 else
3433
	 {
3446
	 {
3434
	    if ( signt )
3447
	    if (signt)
3435
	    {
3448
	    {
3436
	       if ( to == scharhd )
3449
	       if (to == scharhd)
3437
	       {
3450
	       {
3438
		  riir_ins(i_extru,c_eq,sreg,24,25,0);
3451
		  riir_ins(i_extru,c_eq,sreg,24,25,0);
3439
		  ub_ins(cmplt_,trap);
3452
		  ub_ins(cmplt_,trap);
3440
	       }
3453
	       }
3441
	       else
3454
	       else
3442
	       if ( to == swordhd )
3455
	       if (to == swordhd)
3443
	       {
3456
	       {
3444
		  riir_ins(i_extru,c_eq,sreg,16,17,0);
3457
		  riir_ins(i_extru,c_eq,sreg,16,17,0);
3445
		  ub_ins(cmplt_,trap);
3458
		  ub_ins(cmplt_,trap);
3446
	       }
3459
	       }
3447
	       else
3460
	       else
Line 3455... Line 3468...
3455
		  }
3468
		  }
3456
	       }
3469
	       }
3457
	    }
3470
	    }
3458
	    else
3471
	    else
3459
	    {
3472
	    {
3460
	       if ( to == ucharhd )
3473
	       if (to == ucharhd)
3461
		  riir_ins(i_extru,c_,sreg,31,8,GR1);
3474
		  riir_ins(i_extru,c_,sreg,31,8,GR1);
3462
	       else
3475
	       else
3463
		  riir_ins(i_extru,c_,sreg,31,16,GR1);
3476
		  riir_ins(i_extru,c_,sreg,31,16,GR1);
3464
	       cj_ins(c_neq,sreg,GR1,trap);
3477
	       cj_ins(c_neq,sreg,GR1,trap);
3465
	    }
3478
	    }
Line 3483... Line 3496...
3483
	    *dr = dreg;
3496
	    *dr = dreg;
3484
	    inmem_dest = 0;
3497
	    inmem_dest = 0;
3485
	    break;
3498
	    break;
3486
	 }
3499
	 }
3487
	 default:
3500
	 default:
3488
	 {
3501
	 {
3489
	    dreg = getreg(sp.fixed);
3502
	    dreg = getreg(sp.fixed);
3490
	    inmem_dest = 1;
3503
	    inmem_dest = 1;
3491
	    break;
3504
	    break;
3492
	 }
3505
	 }
3493
      }
3506
      }
3494
      if (inmem_dest && size_e <= shape_size(sh(arg)))
3507
      if (inmem_dest && size_e <= shape_size(sh(arg)))
3495
      {
3508
      {
3496
 	 /* going to smaller sized memory, store will truncate */
3509
 	 /* going to smaller sized memory, store will truncate */
3497
	 ans aa;
3510
	 ans aa;
3498
	 setregalt(aa, sreg);
3511
	 setregalt(aa, sreg);
3499
	 (void) move(aa, dest, nsp.fixed, 1);
3512
	(void)move(aa, dest, nsp.fixed, 1);
3500
      }
3513
      }
3501
      else
3514
      else
3502
      {
3515
      {
3503
	 /* from != to */
3516
	 /* from != to */
3504
 
3517
 
3505
	 /* Shorten type if needed */
3518
	 /* Shorten type if needed */
3506
	 if ( to==ucharhd )
3519
	 if (to==ucharhd)
3507
	 {
3520
	 {
3508
	    if (dreg==sreg)
3521
	    if (dreg==sreg)
3509
	       riir_ins(i_dep,c_,0,23,24,dreg);
3522
	       riir_ins(i_dep,c_,0,23,24,dreg);
3510
	    else
3523
	    else
3511
	       riir_ins(i_zdep,c_,sreg,31,8,dreg);
3524
	       riir_ins(i_zdep,c_,sreg,31,8,dreg);
3512
	 }
3525
	 }
3513
	 else
3526
	 else
3514
	 if ( to==scharhd )
3527
	 if (to==scharhd)
3515
	 {
3528
	 {
3516
	    riir_ins(i_extrs,c_,sreg,31,8,dreg);
3529
	    riir_ins(i_extrs,c_,sreg,31,8,dreg);
3517
	 }
3530
	 }
3518
	 else
3531
	 else
3519
	 if ( to==uwordhd )
3532
	 if (to==uwordhd)
3520
	 {
3533
	 {
3521
	    if ( from!=ucharhd )
3534
	    if (from!=ucharhd)
3522
	    {
3535
	    {
3523
	       if ( dreg==sreg )
3536
	       if (dreg==sreg)
3524
		  riir_ins(i_dep,c_,0,15,16,dreg);
3537
		  riir_ins(i_dep,c_,0,15,16,dreg);
3525
	       else
3538
	       else
3526
		  riir_ins(i_zdep,c_,sreg,31,16,dreg);
3539
		  riir_ins(i_zdep,c_,sreg,31,16,dreg);
3527
	    }
3540
	    }
3528
	    else
3541
	    else
3529
	    if ( sreg!=dreg )
3542
	    if (sreg!=dreg)
3530
	       rr_ins(i_copy,sreg,dreg);
3543
	       rr_ins(i_copy,sreg,dreg);
3531
	 }
3544
	 }
3532
	 else
3545
	 else
3533
	 if ( to == swordhd )
3546
	 if (to == swordhd)
3534
	 {
3547
	 {
3535
	    if ( from!=scharhd && from!=ucharhd )
3548
	    if (from!=scharhd && from!=ucharhd)
3536
	    {
3549
	    {
3537
	       riir_ins(i_extrs,c_,sreg,31,16,dreg);
3550
	       riir_ins(i_extrs,c_,sreg,31,16,dreg);
3538
	    }
3551
	    }
3539
	    else
3552
	    else
3540
	    if ( sreg!=dreg )
3553
	    if (sreg!=dreg)
3541
	       rr_ins(i_copy,sreg,dreg);
3554
	       rr_ins(i_copy,sreg,dreg);
3542
	 }
3555
	 }
3543
	 else
3556
	 else
3544
	 {
3557
	 {
3545
	    if ( sreg!=dreg )
3558
	    if (sreg!=dreg)
3546
	       rr_ins(i_copy,sreg,dreg);
3559
	       rr_ins(i_copy,sreg,dreg);
3547
	 }
3560
	 }
3548
	 if (inmem_dest)
3561
	 if (inmem_dest)
3549
	 {
3562
	 {
3550
	    ans aa;
3563
	    ans aa;
Line 3555... Line 3568...
3555
	 {
3568
	 {
3556
	    mka.regmove = dreg;
3569
	    mka.regmove = dreg;
3557
	 }
3570
	 }
3558
      }
3571
      }
3559
      return mka;
3572
      return mka;
3560
   }			
3573
   }
3561
   /*  ENDS chvar_tag  */
3574
   /*  ENDS chvar_tag  */
3562
 
3575
 
3563
/*****************************************************************************/
3576
/*****************************************************************************/
3564
 
3577
 
3565
  case minus_tag:
3578
  case minus_tag:
3566
  case offset_subtract_tag:
3579
  case offset_subtract_tag:
3567
  {
3580
  {
3568
     if (optop(e))
3581
     if (optop(e))
3569
     {
3582
     {
3570
	mka.regmove = non_comm_op(e, sp, dest, i_sub);
3583
	mka.regmove = non_comm_op(e, sp, dest, i_sub);
3571
     }
3584
     }
3572
     else
3585
     else
3573
     {
3586
     {
3574
	/* error_jump to "trap" on overflow */
3587
	/* error_jump to "trap" on overflow */
3575
	int trap = trap_label(e);
3588
	int trap = trap_label(e);
3576
	int l,r,d;
3589
	int l,r,d;
Line 3578... Line 3591...
3578
	int us = !is_signed(sh(e));
3591
	int us = !is_signed(sh(e));
3579
	l = reg_operand(son(e),sp);
3592
	l = reg_operand(son(e),sp);
3580
	nsp = guardreg(l,sp);
3593
	nsp = guardreg(l,sp);
3581
	r = reg_operand(bro(son(e)),guardreg(l,sp));
3594
	r = reg_operand(bro(son(e)),guardreg(l,sp));
3582
	nsp = guardreg(r,sp);
3595
	nsp = guardreg(r,sp);
3583
	if ( discrim(dest.answhere)!=inreg || (d=regalt((dest).answhere))==0 )
3596
	if (discrim(dest.answhere)!=inreg || (d=regalt((dest).answhere)) ==0)
3584
	   d = getreg(nsp.fixed);
3597
	   d = getreg(nsp.fixed);
3585
	if ( us || shape_size(sh(e))==32 )
3598
	if (us || shape_size(sh(e)) ==32)
3586
	{
3599
	{
3587
	   rrr_ins(i_sub,us ? c_gequ : c_NSV,l,r,d);
3600
	   rrr_ins(i_sub,us ? c_gequ : c_NSV,l,r,d);
3588
	   ub_ins(cmplt_N,trap);
3601
	   ub_ins(cmplt_N,trap);
3589
	}
3602
	}
3590
	else
3603
	else
Line 3600... Line 3613...
3600
	}
3613
	}
3601
	mka.regmove=d;
3614
	mka.regmove=d;
3602
     }
3615
     }
3603
     return mka;
3616
     return mka;
3604
  }
3617
  }
3605
  /*  ENDS minus_tag and  
3618
  /*  ENDS minus_tag and
3606
	   offset_subtract_tag  */
3619
	   offset_subtract_tag  */
3607
 
3620
 
3608
/*****************************************************************************/
3621
/*****************************************************************************/
3609
 
3622
 
3610
  case mult_tag:
3623
  case mult_tag:
3611
  case offset_mult_tag:
3624
  case offset_mult_tag:
3612
  {
3625
  {
3613
     bool sgned = is_signed(sh(e));
3626
     bool sgned = is_signed(sh(e));
3614
     if (optop(e))
3627
     if (optop(e))
3615
     {
3628
     {
3616
	FULLCOMMENT2("mult_tag: name(sh(e))=%d sgned=%d", name(sh(e)), sgned);
3629
	FULLCOMMENT2("mult_tag: name(sh(e)) =%d sgned=%d", name(sh(e)), sgned);
3617
	mka.regmove = do_mul_comm_op(e, sp, dest, sgned);
3630
	mka.regmove = do_mul_comm_op(e, sp, dest, sgned);
3618
	return mka;
3631
	return mka;
3619
     }
3632
     }
3620
     else
3633
     else
3621
     {
3634
     {
Line 3645... Line 3658...
3645
	   rrr_ins(i_xor,c_,ARG0,ARG1,ARG2);
3658
	   rrr_ins(i_xor,c_,ARG0,ARG1,ARG2);
3646
	   rrr_ins(i_comclr,c_geq,ARG0,0,0);
3659
	   rrr_ins(i_comclr,c_geq,ARG0,0,0);
3647
	   rrr_ins(i_sub,c_,0,ARG0,ARG0);
3660
	   rrr_ins(i_sub,c_,0,ARG0,ARG0);
3648
	   rrr_ins(i_comclr,c_geq,ARG1,0,0);
3661
	   rrr_ins(i_comclr,c_geq,ARG1,0,0);
3649
	   rrr_ins(i_sub,c_,0,ARG1,ARG1);
3662
	   rrr_ins(i_sub,c_,0,ARG1,ARG1);
3650
	   st_ins(i_sw,ARG1,b);     
3663
	   st_ins(i_sw,ARG1,b);
3651
	   b.offset = 0;
3664
	   b.offset = 0;
3652
	   st_ins(i_sw,ARG0,b);     
3665
	   st_ins(i_sw,ARG0,b);
3653
	   ldf_ins(i_fldd,b,13);
3666
	   ldf_ins(i_fldd,b,13);
3654
	   rrrf_ins(i_xmpyu,f_,12,14,13);
3667
	   rrrf_ins(i_xmpyu,f_,12,14,13);
3655
	   cmp_rrf_ins(i_fcmp,f_sgl,c_eq,12,0);       
3668
	   cmp_rrf_ins(i_fcmp,f_sgl,c_eq,12,0);
3656
	   z_ins(i_ftest);
3669
	   z_ins(i_ftest);
3657
	   ub_ins(cmplt_N,trap);
3670
	   ub_ins(cmplt_N,trap);
3658
	   stf_ins(i_fstw,14,b);
3671
	   stf_ins(i_fstw,14,b);
3659
	   ld_ins(i_lw,1,b,RET0);
3672
	   ld_ins(i_lw,1,b,RET0);
3660
	   rrr_ins(i_comclr,c_geq,ARG2,0,0);
3673
	   rrr_ins(i_comclr,c_geq,ARG2,0,0);
3661
	   rrr_ins(i_sub,c_,0,RET0,RET0);
3674
	   rrr_ins(i_sub,c_,0,RET0,RET0);
3662
	   rrr_ins(i_xor,c_geq,RET0,ARG2,0);
3675
	   rrr_ins(i_xor,c_geq,RET0,ARG2,0);
3663
	   ub_ins(cmplt_N,trap);
3676
	   ub_ins(cmplt_N,trap);
3664
	   outlab("L$$",end);
3677
	   outlab("L$$",end);
3665
	}
3678
	}
3666
	else
3679
	else
3667
	{
3680
	{
3668
	   ld_ins(i_lo,1,b,GR1);
3681
	   ld_ins(i_lo,1,b,GR1);
3669
	   b.base = GR1;
3682
	   b.base = GR1;
3670
	   b.offset = 4;
3683
	   b.offset = 4;
3671
	   st_ins(i_sw,ARG1,b);     
3684
	   st_ins(i_sw,ARG1,b);
3672
	   b.offset = 0;
3685
	   b.offset = 0;
3673
	   st_ins(i_sw,ARG0,b);     
3686
	   st_ins(i_sw,ARG0,b);
3674
	   ldf_ins(i_fldd,b,13);
3687
	   ldf_ins(i_fldd,b,13);
3675
	   rrrf_ins(i_xmpyu,f_,12,14,13);
3688
	   rrrf_ins(i_xmpyu,f_,12,14,13);
3676
	   cmp_rrf_ins(i_fcmp,f_sgl,c_eq,12,0);       
3689
	   cmp_rrf_ins(i_fcmp,f_sgl,c_eq,12,0);
3677
	   z_ins(i_ftest);
3690
	   z_ins(i_ftest);
3678
	   ub_ins(cmplt_N,trap);
3691
	   ub_ins(cmplt_N,trap);
3679
	   stf_ins(i_fstw,14,b);
3692
	   stf_ins(i_fstw,14,b);
3680
	   ld_ins(i_lw,1,b,RET0);
3693
	   ld_ins(i_lw,1,b,RET0);
3681
	}
3694
	}
3682
	test_if_outside_of_var(name(sh(e)),RET0,trap);
3695
	test_if_outside_of_var(name(sh(e)),RET0,trap);
3683
	setregalt(aa,RET0);
3696
	setregalt(aa,RET0);
3684
	mka.regmove = move(aa, dest, nsp.fixed, 0);
3697
	mka.regmove = move(aa, dest, nsp.fixed, 0);
3685
	clear_t_regs();
3698
	clear_t_regs();
3686
	return mka;          	
3699
	return mka;
3687
     }
3700
     }
3688
  }				
3701
  }
3689
  /*  ENDS mult_tag and
3702
  /*  ENDS mult_tag and
3690
	   offset_mult_tag  */
3703
	   offset_mult_tag  */
3691
 
3704
 
3692
/*****************************************************************************/
3705
/*****************************************************************************/
3693
 
3706
 
Line 3762... Line 3775...
3762
	if (d==0 && !(optop(e)))
3775
	if (d==0 && !(optop(e)))
3763
	   d = getreg(sp.fixed);
3776
	   d = getreg(sp.fixed);
3764
	reg_operand_here(son(e),sp,d);
3777
	reg_operand_here(son(e),sp,d);
3765
	if (sz==32)
3778
	if (sz==32)
3766
	{
3779
	{
3767
	   cj_ins(c_geq,d,0,lab);        
3780
	   cj_ins(c_geq,d,0,lab);
3768
	   rrr_ins(i_sub,c_NSV,0,d,d);
3781
	   rrr_ins(i_sub,c_NSV,0,d,d);
3769
	   ub_ins(cmplt_N,trap);
3782
	   ub_ins(cmplt_N,trap);
3770
	   outlab("L$$",lab);
3783
	   outlab("L$$",lab);
3771
	}
3784
	}
3772
	else
3785
	else
3773
	{
3786
	{
3774
	   cj_ins(c_geq,d,0,lab);        
3787
	   cj_ins(c_geq,d,0,lab);
3775
	   if (sz==16)
3788
	   if (sz==16)
3776
	      iiir_ins(i_zdepi,c_,-1,16,17,GR1);
3789
	      iiir_ins(i_zdepi,c_,-1,16,17,GR1);
3777
	   else
3790
	   else
3778
	      iiir_ins(i_zdepi,c_,-1,24,25,GR1);
3791
	      iiir_ins(i_zdepi,c_,-1,24,25,GR1);
3779
	   cj_ins(c_eq,d,GR1,trap);
3792
	   cj_ins(c_eq,d,GR1,trap);
Line 3790... Line 3803...
3790
  /*  ENDS abs_tag  */
3803
  /*  ENDS abs_tag  */
3791
 
3804
 
3792
/*****************************************************************************/
3805
/*****************************************************************************/
3793
 
3806
 
3794
  case max_tag:
3807
  case max_tag:
3795
  case min_tag: 
3808
  case min_tag:
3796
  case offset_max_tag: 
3809
  case offset_max_tag:
3797
  {
3810
  {
3798
     int a,d;
3811
     int a,d;
3799
     ans aa;
3812
     ans aa;
3800
     space nsp;
3813
     space nsp;
3801
     ins_p cond;
3814
     ins_p cond;
3802
     exp l = son(e);
3815
     exp l = son(e);
3803
     exp r = bro(son(e));
3816
     exp r = bro(son(e));
3804
     int nshl = name(sh(l));
3817
     int nshl = name(sh(l));
3805
     if  ( discrim(dest.answhere)==inreg )
3818
     if (discrim(dest.answhere) ==inreg)
3806
	 d = regalt(dest.answhere);
3819
	 d = regalt(dest.answhere);
3807
     else
3820
     else
3808
	 d = getreg(sp.fixed);
3821
	 d = getreg(sp.fixed);
3809
     nsp = guardreg(d,sp);
3822
     nsp = guardreg(d,sp);
3810
     a = reg_operand(l,nsp);
3823
     a = reg_operand(l,nsp);
3811
     if ( nshl==scharhd || nshl==swordhd || nshl==slonghd || nshl==offsethd) 
3824
     if (nshl==scharhd || nshl==swordhd || nshl==slonghd || nshl==offsethd)
3812
	cond = ( name(e)==min_tag ? c_geq : c_leq );
3825
	cond = (name(e) ==min_tag ? c_geq : c_leq);
3813
     else
3826
     else
3814
	cond = ( name(e)==min_tag ? c_gequ : c_lequ );
3827
	cond = (name(e) ==min_tag ? c_gequ : c_lequ);
3815
     if ( name(r)==val_tag && SIMM11(no(r)) )
3828
     if (name(r) ==val_tag && SIMM11(no(r)))
3816
     {
3829
     {
3817
	int n=no(r);
3830
	int n=no(r);
3818
	rr_ins(i_copy,a,d);
3831
	rr_ins(i_copy,a,d);
3819
	irr_ins(i_comiclr,cond,fs_,n,a,0);
3832
	irr_ins(i_comiclr,cond,fs_,n,a,0);
3820
	ir_ins(i_ldi,fs_,empty_ltrl,n,d);
3833
	ir_ins(i_ldi,fs_,empty_ltrl,n,d);
Line 3829... Line 3842...
3829
	rr_ins(i_copy,b,d);
3842
	rr_ins(i_copy,b,d);
3830
     }
3843
     }
3831
     setregalt(aa, d);
3844
     setregalt(aa, d);
3832
     mka.regmove = move(aa, dest, sp.fixed, 1);
3845
     mka.regmove = move(aa, dest, sp.fixed, 1);
3833
     return mka;
3846
     return mka;
3834
  } 
3847
  }
3835
  /*  ENDS max_tag,
3848
  /*  ENDS max_tag,
3836
	   min_tag and
3849
	   min_tag and
3837
	   offset_max_tag  */
3850
	   offset_max_tag  */
3838
 
3851
 
3839
/*****************************************************************************/
3852
/*****************************************************************************/
Line 3842... Line 3855...
3842
  {
3855
  {
3843
     int d;
3856
     int d;
3844
     ans a;
3857
     ans a;
3845
     space nsp;
3858
     space nsp;
3846
     char label_name[32];
3859
     char label_name[32];
3847
     if (discrim(dest.answhere)==inreg)
3860
     if (discrim(dest.answhere) ==inreg)
3848
	d = regalt(dest.answhere);
3861
	d = regalt(dest.answhere);
3849
     else
3862
     else
3850
	d = getreg(sp.fixed);
3863
	d = getreg(sp.fixed);
3851
     sprintf(label_name,"L$$%d",no(son(pt(e))));
3864
     sprintf(label_name,"L$$%d",no(son(pt(e))));
3852
     if (PIC_code)
3865
     if (PIC_code)
3853
     {
3866
     {
3854
	int n = next_PIC_pcrel_lab(); 
3867
	int n = next_PIC_pcrel_lab();
3855
	char s[64];
3868
	char s[64];
3856
	sprintf(s,"%s-$PIC_pcrel$%d",label_name,n);
3869
	sprintf(s,"%s-$PIC_pcrel$%d",label_name,n);
3857
	bl_in(cmplt_,".+8",GR1);
3870
	bl_in(cmplt_,".+8",GR1);
3858
	iiir_ins(i_depi,c_,0,31,2,GR1);
3871
	iiir_ins(i_depi,c_,0,31,2,GR1);
3859
	outlab("$PIC_pcrel$",n);
3872
	outlab("$PIC_pcrel$",n);
3860
	ir_ins(i_addil,fs_L,s,0,GR1);     
3873
	ir_ins(i_addil,fs_L,s,0,GR1);
3861
	ld_ir_ins(i_ldo,cmplt_,fs_R,s,0,GR1,d);
3874
	ld_ir_ins(i_ldo,cmplt_,fs_R,s,0,GR1,d);
3862
     }
3875
     }
3863
     else
3876
     else
3864
     {
3877
     {
3865
	ir_ins(i_ldil,fs_L,label_name,0,d);
3878
	ir_ins(i_ldil,fs_L,label_name,0,d);
3866
	ld_ir_ins(i_ldo,cmplt_,fs_R,label_name,0,d,d); 
3879
	ld_ir_ins(i_ldo,cmplt_,fs_R,label_name,0,d,d);
3867
     }
3880
     }
3868
     setregalt(a, d);
3881
     setregalt(a, d);
3869
     nsp=guardreg(d,sp);
3882
     nsp=guardreg(d,sp);
3870
     move(a, dest, nsp.fixed, 0);
3883
     move(a, dest, nsp.fixed, 0);
3871
     mka.regmove = d; 
3884
     mka.regmove = d;
3872
     return mka;
3885
     return mka;
3873
  }
3886
  }
3874
 
3887
 
3875
 
3888
 
3876
  case long_jump_tag:
3889
  case long_jump_tag:
3877
  {
3890
  {
3878
     int envr = reg_operand(son(e),sp);    
3891
     int envr = reg_operand(son(e),sp);
3879
     int lab = reg_operand(bro(son(e)), guardreg(envr,sp));
3892
     int lab = reg_operand(bro(son(e)), guardreg(envr,sp));
3880
     extj_reg_ins(i_bv,lab);
3893
     extj_reg_ins(i_bv,lab);
3881
     rr_ins(i_copy,envr,GR4); /* GR4==EP in the enviroment we're jumping to */
3894
     rr_ins(i_copy,envr,GR4); /* GR4==EP in the enviroment we're jumping to */
3882
     return mka;
3895
     return mka;
3883
  }
3896
  }
Line 3901... Line 3914...
3901
     {
3914
     {
3902
	/* error_jump to "trap" on overflow */
3915
	/* error_jump to "trap" on overflow */
3903
	int trap = trap_label(e);
3916
	int trap = trap_label(e);
3904
	int d = GETREG(dest,sp);
3917
	int d = GETREG(dest,sp);
3905
	int us = !is_signed(sh(e));
3918
	int us = !is_signed(sh(e));
3906
	if ( d==0 )
3919
	if (d==0)
3907
	   d = getreg(sp.fixed);
3920
	   d = getreg(sp.fixed);
3908
	reg_operand_here(son(e),sp,d);
3921
	reg_operand_here(son(e),sp,d);
3909
	if ( us || shape_size(sh(e))==32 )
3922
	if (us || shape_size(sh(e)) ==32)
3910
	{
3923
	{
3911
	   rrr_ins(i_sub,us ? c_gequ : c_NSV,0,d,d);
3924
	   rrr_ins(i_sub,us ? c_gequ : c_NSV,0,d,d);
3912
	   ub_ins(cmplt_N,trap);
3925
	   ub_ins(cmplt_N,trap);
3913
	}
3926
	}
3914
	else
3927
	else
Line 3940... Line 3953...
3940
      space nsp;
3953
      space nsp;
3941
      bool sgned = is_signed(sh(e));
3954
      bool sgned = is_signed(sh(e));
3942
      int sz = shape_size(sh(e));
3955
      int sz = shape_size(sh(e));
3943
      a = getreg(sp.fixed);
3956
      a = getreg(sp.fixed);
3944
 
3957
 
3945
      if (name(b)==val_tag)
3958
      if (name(b) ==val_tag)
3946
      {
3959
      {
3947
	 int n = no(b)&(sz-1);
3960
	 int n = no(b) & (sz-1);
3948
	 reg_operand_here(s,sp,a);
3961
	 reg_operand_here(s,sp,a);
3949
	 nsp = guardreg(a, sp);
3962
	 nsp = guardreg(a, sp);
3950
	 d = GETREG(dest,nsp);
3963
	 d = GETREG(dest,nsp);
3951
	 if (n==0)
3964
	 if (n==0)
3952
	 {
3965
	 {
3953
	    if (a!=d)
3966
	    if (a!=d)
3954
	       rr_ins(i_copy,a,d);
3967
	       rr_ins(i_copy,a,d);
3955
	 }
3968
	 }
3956
	 else
3969
	 else
3957
	 {
3970
	 {
3958
	    if (name(e)==shr_tag)
3971
	    if (name(e) ==shr_tag)
3959
	       riir_ins(sgned ? i_extrs : i_extru,c_,a,31-n,sz-n,d);
3972
	       riir_ins(sgned ? i_extrs : i_extru,c_,a,31-n,sz-n,d);
3960
	    else
3973
	    else
3961
	       rrir_ins(i_shd,c_,a,0,32-n,d);
3974
	       rrir_ins(i_shd,c_,a,0,32-n,d);
3962
	 }
3975
	 }
3963
      }
3976
      }
3964
      else
3977
      else
3965
      {
3978
      {
3966
	 int ar;
3979
	 int ar;
3967
	 if ( name(s)==val_tag && SIMM5(no(s)) && name(e)==shl_tag )
3980
	 if (name(s) ==val_tag && SIMM5(no(s)) && name(e) ==shl_tag)
3968
	 {
3981
	 {
3969
	    int n = no(s);
3982
	    int n = no(s);
3970
	    nsp = sp;
3983
	    nsp = sp;
3971
	    d = GETREG(dest,nsp);
3984
	    d = GETREG(dest,nsp);
3972
	    ar = reg_operand(b, nsp);
3985
	    ar = reg_operand(b, nsp);
Line 3979... Line 3992...
3979
	 {
3992
	 {
3980
	    reg_operand_here(s,sp,a);
3993
	    reg_operand_here(s,sp,a);
3981
	    nsp = guardreg(a, sp);
3994
	    nsp = guardreg(a, sp);
3982
	    d = GETREG(dest,nsp);
3995
	    d = GETREG(dest,nsp);
3983
	    ar = reg_operand(b, nsp);
3996
	    ar = reg_operand(b, nsp);
3984
	    if (name(e)==shr_tag)
3997
	    if (name(e) ==shr_tag)
3985
	    {
3998
	    {
3986
	       if (sgned)
3999
	       if (sgned)
3987
	       {
4000
	       {
3988
		  /* sole variable arithmetic shift right */
4001
		  /* sole variable arithmetic shift right */
3989
		  irr_ins(i_subi,c_,fs_,31,ar,GR1);
4002
		  irr_ins(i_subi,c_,fs_,31,ar,GR1);
Line 4004... Line 4017...
4004
	       {
4017
	       {
4005
		   irr_ins(i_subi,c_gequ,fs_,31,ar,GR1);
4018
		   irr_ins(i_subi,c_gequ,fs_,31,ar,GR1);
4006
		   rr_ins(i_copy,0,d);
4019
		   rr_ins(i_copy,0,d);
4007
		   r_ins(i_mtsar,GR1);
4020
		   r_ins(i_mtsar,GR1);
4008
		   rir_ins(i_zvdep,c_,d,32,d);
4021
		   rir_ins(i_zvdep,c_,d,32,d);
4009
	       } 
4022
	       }
4010
	       else
4023
	       else
4011
	       {
4024
	       {
4012
		  irr_ins(i_subi,c_lu,fs_,31,ar,GR1);
4025
		  irr_ins(i_subi,c_lu,fs_,31,ar,GR1);
4013
		  r_ins(i_mtsar,GR1);
4026
		  r_ins(i_mtsar,GR1);
4014
		  irr_ins(i_comiclr,c_lu,fs_,31,GR1,d);
4027
		  irr_ins(i_comiclr,c_lu,fs_,31,GR1,d);
4015
		  rir_ins(i_zvdep,c_,a,32,d);
4028
		  rir_ins(i_zvdep,c_,a,32,d);
4016
	       }
4029
	       }
4017
	    }
4030
	    }
4018
	 }
4031
	 }
4019
       }
4032
       }
4020
       if ( !optop(e) && name(e)==shl_tag && sz<32 )
4033
       if (!optop(e) && name(e) ==shl_tag && sz<32)
4021
       {
4034
       {
4022
	  int trap = trap_label(e);
4035
	  int trap = trap_label(e);
4023
	  riir_ins(i_extru,c_eq,d,31-sz,32-sz,0);
4036
	  riir_ins(i_extru,c_eq,d,31-sz,32-sz,0);
4024
	  ub_ins(cmplt_,trap);
4037
	  ub_ins(cmplt_,trap);
4025
       }
4038
       }
Line 4030... Line 4043...
4030
 
4043
 
4031
    }				/* end shl, shr */
4044
    }				/* end shl, shr */
4032
 
4045
 
4033
  case minptr_tag:
4046
  case minptr_tag:
4034
    {
4047
    {
4035
      mka.regmove = non_comm_op( e, sp, dest, i_sub );
4048
      mka.regmove = non_comm_op(e, sp, dest, i_sub);
4036
      return mka;
4049
      return mka;
4037
    }
4050
    }
4038
 
4051
 
4039
  case make_stack_limit_tag:
4052
  case make_stack_limit_tag:
4040
    {
4053
    {
4041
      mka.regmove = comm_op( e, sp, dest, i_add );
4054
      mka.regmove = comm_op(e, sp, dest, i_add);
4042
      return mka;
4055
      return mka;
4043
    }
4056
    }
4044
 
4057
 
4045
  case fplus_tag:
4058
  case fplus_tag:
4046
    {
4059
    {
4047
      mka.regmove = fop( e, sp, dest, i_fadd );
4060
      mka.regmove = fop(e, sp, dest, i_fadd);
4048
      return mka;
4061
      return mka;
4049
    }
4062
    }
4050
 
4063
 
4051
  case fminus_tag:
4064
  case fminus_tag:
4052
    {
4065
    {
4053
      mka.regmove = fop( e, sp, dest, i_fsub );
4066
      mka.regmove = fop(e, sp, dest, i_fsub);
4054
      return mka;
4067
      return mka;
4055
    }
4068
    }
4056
 
4069
 
4057
  case fmult_tag:
4070
  case fmult_tag:
4058
    {
4071
    {
4059
      mka.regmove = fop( e, sp, dest, i_fmpy );
4072
      mka.regmove = fop(e, sp, dest, i_fmpy);
4060
      return mka;
4073
      return mka;
4061
    }
4074
    }
4062
 
4075
 
4063
  case fdiv_tag:
4076
  case fdiv_tag:
4064
    {
4077
    {
4065
      mka.regmove = fop( e, sp, dest, i_fdiv );
4078
      mka.regmove = fop(e, sp, dest, i_fdiv);
4066
      return mka;
4079
      return mka;
4067
    }
4080
    }
4068
 
4081
 
4069
  case fneg_tag:
4082
  case fneg_tag:
4070
  {
4083
  {
4071
     int a1,r1;
4084
     int a1,r1;
4072
     int dble = (name(sh(e))==shrealhd ? 0 : 1);
4085
     int dble = (name(sh(e)) ==shrealhd ? 0 : 1);
4073
     freg frg;
4086
     freg frg;
4074
     baseoff b;
4087
     baseoff b;
4075
 
4088
 
4076
#if use_long_double
4089
#if use_long_double
4077
     if ( name(sh(e)) == doublehd )
4090
     if (name(sh(e)) == doublehd)
4078
     {
4091
     {
4079
	quad_op( e, sp, dest );
4092
	quad_op(e, sp, dest);
4080
	return(mka) ;
4093
	return(mka);
4081
     }
4094
     }
4082
#endif
4095
#endif
4083
 
4096
 
4084
     r1 = getfreg(sp.flt);
4097
     r1 = getfreg(sp.flt);
4085
     a1 = freg_operand(son(e), sp, r1);
4098
     a1 = freg_operand(son(e), sp, r1);
4086
 
4099
 
4087
     if (!optop(e))
4100
     if (!optop(e))
4088
     {
4101
     {
4089
	b = zero_exception_register(sp);
4102
	b = zero_exception_register(sp);
4090
     }
4103
     }
4091
     if ( discrim(dest.answhere)==infreg ) 
4104
     if (discrim(dest.answhere) ==infreg)
4092
     {
4105
     {
4093
	frg = fregalt(dest.answhere);
4106
	frg = fregalt(dest.answhere);
4094
	clear_freg(frg.fr<<1);
4107
	clear_freg(frg.fr<<1);
4095
	if (dble)
4108
	if (dble)
4096
	{
4109
	{
4097
	   rrrf_ins(i_fsub,f_dbl,1,3*a1+1,3*(frg.fr)+1);
4110
	   rrrf_ins(i_fsub,f_dbl,1,3*a1+1,3*(frg.fr) +1);
4098
	   clear_freg((frg.fr<<1)+1);
4111
	   clear_freg((frg.fr<<1) +1);
4099
	}
4112
	}
4100
	else
4113
	else
4101
	   rrrf_ins(i_fsub,f_sgl,0,3*a1,3*(frg.fr));
4114
	   rrrf_ins(i_fsub,f_sgl,0,3*a1,3*(frg.fr));
4102
	if (!optop(e))
4115
	if (!optop(e))
4103
	{
4116
	{
4104
	   trap_handler(b,trap_label(e),(OVERFLOW|UNDERFLOW));
4117
	   trap_handler(b,trap_label(e), (OVERFLOW|UNDERFLOW));
4105
	}
4118
	}
4106
     }
4119
     }
4107
     else
4120
     else
4108
     {
4121
     {
4109
	ans aa;
4122
	ans aa;
Line 4112... Line 4125...
4112
	setfregalt(aa, frg);
4125
	setfregalt(aa, frg);
4113
	clear_freg(r1<<1);
4126
	clear_freg(r1<<1);
4114
	if (dble)
4127
	if (dble)
4115
	{
4128
	{
4116
	   rrrf_ins(i_fsub,f_dbl,1,3*a1+1,3*r1+1);
4129
	   rrrf_ins(i_fsub,f_dbl,1,3*a1+1,3*r1+1);
4117
	   clear_freg((r1<<1)+1);
4130
	   clear_freg((r1<<1) +1);
4118
	}
4131
	}
4119
	else
4132
	else
4120
	   rrrf_ins(i_fsub,f_sgl,0,3*a1,3*r1);
4133
	   rrrf_ins(i_fsub,f_sgl,0,3*a1,3*r1);
4121
	if (!optop(e))
4134
	if (!optop(e))
4122
	{
4135
	{
4123
	   trap_handler(b,trap_label(e),(OVERFLOW|UNDERFLOW));
4136
	   trap_handler(b,trap_label(e), (OVERFLOW|UNDERFLOW));
4124
	}
4137
	}
4125
	move(aa,dest,sp.fixed,1);
4138
	move(aa,dest,sp.fixed,1);
4126
     }
4139
     }
4127
 
4140
 
4128
     mka.regmove = (dble ? -(frg.fr + 32) : (frg.fr + 32));
4141
     mka.regmove = (dble ? - (frg.fr + 32):(frg.fr + 32));
4129
     if (!optop(e))
4142
     if (!optop(e))
4130
       checknan(e, mka.regmove);
4143
       checknan(e, mka.regmove);
4131
     return mka;
4144
     return mka;
4132
  }
4145
  }
4133
  
4146
 
4134
  case fabs_tag:
4147
  case fabs_tag:
4135
    {
4148
    {
4136
      freg frg;
4149
      freg frg;
4137
      int a1,r1;
4150
      int a1,r1;
4138
      bool dble;
4151
      bool dble;
4139
      baseoff b;
4152
      baseoff b;
4140
 
4153
 
4141
#if use_long_double
4154
#if use_long_double
4142
      if ( name(sh(e)) == doublehd )
4155
      if (name(sh(e)) == doublehd)
4143
      {
4156
      {
4144
	 quad_op ( e, sp, dest );
4157
	 quad_op(e, sp, dest);
4145
	 return(mka) ;
4158
	 return(mka);
4146
      }
4159
      }
4147
#endif
4160
#endif
4148
 
4161
 
4149
      r1 = getfreg(sp.flt);
4162
      r1 = getfreg(sp.flt);
4150
      a1 = freg_operand(son(e), sp, r1);
4163
      a1 = freg_operand(son(e), sp, r1);
4151
      dble = isdbl(sh(e));
4164
      dble = isdbl(sh(e));
4152
 
4165
 
4153
      if (!optop(e))
4166
      if (!optop(e))
4154
      {
4167
      {
4155
	 b = zero_exception_register(sp);
4168
	 b = zero_exception_register(sp);
4156
      }
4169
      }
4157
      switch ( discrim ( dest.answhere ) )
4170
      switch (discrim(dest.answhere))
4158
      {
4171
      {
4159
      case infreg:
4172
      case infreg:
4160
	{
4173
	{
4161
	  frg = fregalt(dest.answhere);
4174
	  frg = fregalt(dest.answhere);
4162
	  clear_freg(frg.fr<<1);
4175
	  clear_freg(frg.fr<<1);
4163
	  if (dble)
4176
	  if (dble)
4164
	  {
4177
	  {
4165
	     rrf_ins(i_fabs,f_dbl,"",3*a1+1,3*(frg.fr)+1);
4178
	     rrf_ins(i_fabs,f_dbl,"",3*a1+1,3*(frg.fr) +1);
4166
	     clear_freg((frg.fr<<1)+1);
4179
	     clear_freg((frg.fr<<1) +1);
4167
	  }
4180
	  }
4168
	  else
4181
	  else
4169
	     rrf_ins(i_fabs,f_sgl,"",3*a1,3*(frg.fr));
4182
	     rrf_ins(i_fabs,f_sgl,"",3*a1,3*(frg.fr));
4170
	  if (!optop(e))
4183
	  if (!optop(e))
4171
	  {
4184
	  {
4172
	     trap_handler(b,trap_label(e),OVERFLOW|UNDERFLOW);
4185
	     trap_handler(b,trap_label(e),OVERFLOW|UNDERFLOW);
Line 4183... Line 4196...
4183
	  setfregalt(aa, frg);
4196
	  setfregalt(aa, frg);
4184
	  clear_freg(r1<<1);
4197
	  clear_freg(r1<<1);
4185
	  if (dble)
4198
	  if (dble)
4186
	  {
4199
	  {
4187
	     rrf_ins(i_fabs,f_dbl,"",3*a1+1,3*r1+1);
4200
	     rrf_ins(i_fabs,f_dbl,"",3*a1+1,3*r1+1);
4188
	     clear_freg((r1<<1)+1);
4201
	     clear_freg((r1<<1) +1);
4189
	  }
4202
	  }
4190
	  else
4203
	  else
4191
	     rrf_ins(i_fabs,f_sgl,"",3*a1,3*r1);
4204
	     rrf_ins(i_fabs,f_sgl,"",3*a1,3*r1);
4192
	  if (!optop(e))
4205
	  if (!optop(e))
4193
	  {
4206
	  {
Line 4195... Line 4208...
4195
	  }
4208
	  }
4196
	  move(aa, dest, sp.fixed, 1);
4209
	  move(aa, dest, sp.fixed, 1);
4197
	}
4210
	}
4198
      }
4211
      }
4199
 
4212
 
4200
      mka.regmove = (dble ? -(frg.fr + 32) : (frg.fr + 32));
4213
      mka.regmove = (dble ? - (frg.fr + 32):(frg.fr + 32));
4201
      if (!optop(e))
4214
      if (!optop(e))
4202
	checknan(e, mka.regmove);
4215
	checknan(e, mka.regmove);
4203
      return mka;
4216
      return mka;
4204
    }
4217
    }
4205
 
4218
 
4206
  case float_tag:
4219
  case float_tag:
4207
    {
4220
    {
4208
      exp in = son(e);
4221
      exp in = son(e);
4209
      where w;
4222
      where w;
4210
      int f = ( discrim ( dest.answhere )  == infreg)
4223
      int f = (discrim(dest.answhere) == infreg)
4211
      ? regalt(dest.answhere)	/* cheat */
4224
      ? regalt(dest.answhere)	/* cheat */
4212
      : getfreg(sp.flt);
4225
      : getfreg(sp.flt);
4213
      freg frg;
4226
      freg frg;
4214
      ans aa;
4227
      ans aa;
4215
      ash ain ;
4228
      ash ain;
4216
      int from ;
4229
      int from;
4217
      bool from_sgned  ;
4230
      bool from_sgned ;
4218
 
4231
 
4219
      ain = ashof(sh(in));
4232
      ain = ashof(sh(in));
4220
      from = name(sh(in));
4233
      from = name(sh(in));
4221
      from_sgned = is_signed(sh(in));
4234
      from_sgned = is_signed(sh(in));
4222
 
4235
 
4223
      /*
4236
      /*
4224
       *   error_jump would be superfluous.
4237
       *   error_jump would be superfluous.
4225
       */
4238
       */
4226
 
4239
 
4227
#if use_long_double
4240
#if use_long_double
4228
      if ( name(sh(e))==doublehd ) 
4241
      if (name(sh(e)) ==doublehd)
4229
      {
4242
      {
4230
	 quad_op( e, sp, dest );
4243
	 quad_op(e, sp, dest);
4231
	 return(mka) ;
4244
	 return(mka);
4232
      }
4245
      }
4233
#endif
4246
#endif
4234
 
4247
 
4235
 
4248
 
4236
      frg.fr = f;
4249
      frg.fr = f;
4237
      frg.dble = isdbl( sh(e) );
4250
      frg.dble = isdbl(sh(e));
4238
 
4251
 
4239
      if (ain.ashsize == 32 && !from_sgned)
4252
      if (ain.ashsize == 32 && !from_sgned)
4240
      {
4253
      {
4241
 
4254
 
4242
	/*
4255
	/*
Line 4246... Line 4259...
4246
	 */
4259
	 */
4247
 
4260
 
4248
	int r = reg_operand(in, sp);
4261
	int r = reg_operand(in, sp);
4249
 
4262
 
4250
	st_ins(i_sw, r, mem_temp(0));
4263
	st_ins(i_sw, r, mem_temp(0));
4251
	ldf_ins(i_fldw, mem_temp(0), (3*f)+2);
4264
	ldf_ins(i_fldw, mem_temp(0), (3*f) +2);
4252
	rrf_ins(i_fcpy,f_sgl,"",0,3*f+1);
4265
	rrf_ins(i_fcpy,f_sgl,"",0,3*f+1);
4253
	if (name(sh(e))==shrealhd)
4266
	if (name(sh(e)) ==shrealhd)
4254
	   rrf_ins(i_fcnvxf,f_dbl,f_sgl,3*f+1,3*f);
4267
	   rrf_ins(i_fcnvxf,f_dbl,f_sgl,3*f+1,3*f);
4255
	else
4268
	else
4256
	   rrf_ins(i_fcnvxf,f_dbl,f_dbl,3*f+1,3*f+1);
4269
	   rrf_ins(i_fcnvxf,f_dbl,f_dbl,3*f+1,3*f+1);
4257
 
4270
 
4258
      }
4271
      }
Line 4265... Line 4278...
4265
	fint.fr = f;
4278
	fint.fr = f;
4266
	fint.dble = 0;
4279
	fint.dble = 0;
4267
	setfregalt(w.answhere, fint);
4280
	setfregalt(w.answhere, fint);
4268
	w.ashwhere = ashof(sh(in));
4281
	w.ashwhere = ashof(sh(in));
4269
	code_here(in, sp, w);
4282
	code_here(in, sp, w);
4270
	if (name(sh(e))==shrealhd)
4283
	if (name(sh(e)) ==shrealhd)
4271
	   rrf_ins(i_fcnvxf,f_sgl,f_sgl,3*f,3*f);
4284
	   rrf_ins(i_fcnvxf,f_sgl,f_sgl,3*f,3*f);
4272
	else
4285
	else
4273
	   rrf_ins(i_fcnvxf,f_sgl,f_dbl,3*f,3*f+1);
4286
	   rrf_ins(i_fcnvxf,f_sgl,f_dbl,3*f,3*f+1);
4274
      }
4287
      }
4275
      else
4288
      else
Line 4278... Line 4291...
4278
	int r = reg_operand(in, sp);
4291
	int r = reg_operand(in, sp);
4279
 
4292
 
4280
	/* store and load to move to float reg */
4293
	/* store and load to move to float reg */
4281
	st_ins(i_sw, r, mem_temp(0));
4294
	st_ins(i_sw, r, mem_temp(0));
4282
	ldf_ins(i_fldw,mem_temp(0),3*f);
4295
	ldf_ins(i_fldw,mem_temp(0),3*f);
4283
	if (name(sh(e))==shrealhd)
4296
	if (name(sh(e)) ==shrealhd)
4284
	   rrf_ins(i_fcnvxf,f_sgl,f_sgl,3*f,3*f);
4297
	   rrf_ins(i_fcnvxf,f_sgl,f_sgl,3*f,3*f);
4285
	else
4298
	else
4286
	   rrf_ins(i_fcnvxf,f_sgl,f_dbl,3*f,3*f+1);
4299
	   rrf_ins(i_fcnvxf,f_sgl,f_dbl,3*f,3*f+1);
4287
      }
4300
      }
4288
 
4301
 
4289
      setfregalt(aa, frg);
4302
      setfregalt(aa, frg);
4290
      move(aa, dest, sp.fixed, 1);
4303
      move(aa, dest, sp.fixed, 1);
4291
      mka.regmove = ((frg.dble) ? -(f + 32) : (f + 32));
4304
      mka.regmove = ((frg.dble)? - (f + 32):(f + 32));
4292
      return mka;
4305
      return mka;
4293
    }
4306
    }
4294
 
4307
 
4295
  case chfl_tag:
4308
  case chfl_tag:
4296
    {
4309
    {
4297
      int to = name(sh(e));
4310
      int to = name(sh(e));
4298
      int from = name(sh(son(e)));
4311
      int from = name(sh(son(e)));
4299
      bool dto = isdbl( sh(e) );
4312
      bool dto = isdbl(sh(e));
4300
      bool dfrom = isdbl( sh(son(e)) );
4313
      bool dfrom = isdbl(sh(son(e)));
4301
      freg frg;
4314
      freg frg;
4302
      ans aa;
4315
      ans aa;
4303
      where w;
4316
      where w;
4304
      baseoff b;
4317
      baseoff b;
4305
#if use_long_double
4318
#if use_long_double
4306
      if ( to==doublehd )
4319
      if (to==doublehd)
4307
      {
4320
      {
4308
	 if ( from==doublehd )
4321
	 if (from==doublehd)
4309
	 {
4322
	 {
4310
	    /* no change in representation */
4323
	    /* no change in representation */
4311
	    return ( make_code(son(e),sp,dest,exitlab) ) ;
4324
	    return(make_code(son(e),sp,dest,exitlab));
4312
	 }
4325
	 }
4313
	 quad_op( e, sp, dest ) ;
4326
	 quad_op(e, sp, dest);
4314
	 return ( mka ) ;
4327
	 return(mka);
4315
      }
4328
      }
4316
      else 
4329
      else
4317
      if ( from==doublehd )
4330
      if (from==doublehd)
4318
      {
4331
      {
4319
	 quad_op( e, sp, dest ) ;
4332
	 quad_op(e, sp, dest);
4320
	 frg.fr = 4 ;
4333
	 frg.fr = 4;
4321
	 frg.dble = dto;
4334
	 frg.dble = dto;
4322
	 setfregalt(aa,frg) ;
4335
	 setfregalt(aa,frg);
4323
       	 (void) move(aa,dest,sp.fixed,1) ;
4336
       	(void)move(aa,dest,sp.fixed,1);
4324
	 return (mka) ;
4337
	 return(mka);
4325
      }
4338
      }
4326
#endif
4339
#endif
4327
      if (!dto && !dfrom)
4340
      if (!dto && !dfrom)
4328
      {
4341
      {
4329
	 /* no change in representation */
4342
	 /* no change in representation */
4330
	 if (!optop(e))
4343
	 if (!optop(e))
4331
	 {
4344
	 {
4332
	    b = zero_exception_register(sp);
4345
	    b = zero_exception_register(sp);
4333
	 }
4346
	 }
4334
	 return make_code(son(e), sp, dest, exitlab);
4347
	 return make_code(son(e), sp, dest, exitlab);
4335
      }
4348
      }
4336
      else
4349
      else
4337
      {
4350
      {
4338
	if ( discrim ( dest.answhere )  == infreg)
4351
	if (discrim(dest.answhere) == infreg)
4339
	{
4352
	{
4340
	  frg = fregalt(dest.answhere);
4353
	  frg = fregalt(dest.answhere);
4341
	}
4354
	}
4342
	else
4355
	else
4343
	{
4356
	{
Line 4351... Line 4364...
4351
	if (!optop(e))
4364
	if (!optop(e))
4352
	{
4365
	{
4353
	   b = zero_exception_register(sp);
4366
	   b = zero_exception_register(sp);
4354
	}
4367
	}
4355
	if (dfrom)
4368
	if (dfrom)
4356
	   rrf_ins(i_fcnvff,f_dbl,f_sgl,3*(frg.fr)+1,3*(frg.fr));
4369
	   rrf_ins(i_fcnvff,f_dbl,f_sgl,3*(frg.fr) +1,3*(frg.fr));
4357
	else
4370
	else
4358
	   rrf_ins(i_fcnvff,f_sgl,f_dbl,3*(frg.fr),3*(frg.fr)+1);
4371
	   rrf_ins(i_fcnvff,f_sgl,f_dbl,3*(frg.fr),3*(frg.fr) +1);
4359
	if (!optop(e))
4372
	if (!optop(e))
4360
	{
4373
	{
4361
	   trap_handler(b,trap_label(e),(OVERFLOW|UNDERFLOW));
4374
	   trap_handler(b,trap_label(e), (OVERFLOW|UNDERFLOW));
4362
	}
4375
	}
4363
	frg.dble = dto;
4376
	frg.dble = dto;
4364
	setfregalt(aa, frg);
4377
	setfregalt(aa, frg);
4365
	move(aa, dest, sp.fixed, 1);
4378
	move(aa, dest, sp.fixed, 1);
4366
	mka.regmove = ((frg.dble) ? -(frg.fr + 32) : (frg.fr + 32));
4379
	mka.regmove = ((frg.dble)? - (frg.fr + 32):(frg.fr + 32));
4367
	return mka;
4380
	return mka;
4368
      }
4381
      }
4369
    }
4382
    }
4370
 
4383
 
4371
  case and_tag:
4384
  case and_tag:
Line 4377... Line 4390...
4377
 
4390
 
4378
      /* +++ enable this optimisation for big-endian */
4391
      /* +++ enable this optimisation for big-endian */
4379
      if (last(l) && name(l) == val_tag && (no(l) == 255 || no(l) == 0xffff)
4392
      if (last(l) && name(l) == val_tag && (no(l) == 255 || no(l) == 0xffff)
4380
	  && ((name(r) == name_tag && regofval(r) == R_NO_REG)
4393
	  && ((name(r) == name_tag && regofval(r) == R_NO_REG)
4381
	      || (name(r) == cont_tag &&
4394
	      || (name(r) == cont_tag &&
4382
		  (name(son(r)) != name_tag
4395
		 (name(son(r))!= name_tag
4383
		   || regofval(son(r)) > 0
4396
		   || regofval(son(r)) > 0
4384
		   )
-
 
4385
		  )
4397
		  )
-
 
4398
		 )
4386
	      )
4399
	     )
4387
	  && (aa = iskept(r), ( discrim ( aa )  == inreg && regalt(aa) == 0))
4400
	  && (aa = iskept(r), (discrim(aa) == inreg && regalt(aa) == 0))
4388
	)
4401
	)
4389
      {				/* can use load short instructions */
4402
      {				/* can use load short instructions */
4390
	where w;
4403
	where w;
4391
	int dsize = dest.ashwhere.ashsize;
4404
	int dsize = dest.ashwhere.ashsize;
4392
	int asize = (no(l) == 255) ? 8 : 16;
4405
	int asize = (no(l) == 255)? 8 : 16;
4393
 
4406
 
4394
	w = locate(r, sp, sh(r), 0);
4407
	w = locate(r, sp, sh(r), 0);
4395
	if ( discrim ( w.answhere )  == notinreg
4408
	if (discrim(w.answhere) == notinreg
4396
	    &&  discrim ( dest.answhere )  == notinreg && no(l) == 0xffff)
4409
	    &&  discrim(dest.answhere) == notinreg && no(l) == 0xffff)
4397
	{
4410
	{
4398
	  instore isw;
4411
	  instore isw;
4399
	  instore isd;
4412
	  instore isd;
4400
 
4413
 
4401
	  isw = insalt(w.answhere);
4414
	  isw = insalt(w.answhere);
Line 4459... Line 4472...
4459
      }
4472
      }
4460
 
4473
 
4461
#if DO_INDEXED_LOADS
4474
#if DO_INDEXED_LOADS
4462
      /* see if an indexed shift load is appropriate */
4475
      /* see if an indexed shift load is appropriate */
4463
 
4476
 
4464
      if (name(e)==cont_tag)
4477
      if (name(e) ==cont_tag)
4465
      {
4478
      {
4466
	 exp sone,p,o;
4479
	 exp sone,p,o;
4467
	 bool sgned=is_signed(sh(e));
4480
	 bool sgned=is_signed(sh(e));
4468
	 int dr,ashsize;
4481
	 int dr,ashsize;
4469
	 ans aa;
4482
	 ans aa;
4470
	 ash ashe;
4483
	 ash ashe;
4471
	 int is_float = is_floating(name(sh(e)));
4484
	 int is_float = is_floating(name(sh(e)));
4472
	 ashe=ashof(sh(e));
4485
	 ashe=ashof(sh(e));
4473
	 ashsize=ashe.ashsize;
4486
	 ashsize=ashe.ashsize;
4474
	 if ( name(son(e))==reff_tag && !no(son(e)) )
4487
	 if (name(son(e)) ==reff_tag && !no(son(e)))
4475
	    sone = son(son(e));
4488
	    sone = son(son(e));
4476
	 else
4489
	 else
4477
	    sone = son(e);
4490
	    sone = son(e);
4478
	 if (son(sone)!=(exp)0)
4491
	 if (son(sone)!= (exp)0)
4479
	 {
4492
	 {
4480
	    if (name(son(sone))==offset_mult_tag)
4493
	    if (name(son(sone)) ==offset_mult_tag)
4481
	    {
4494
	    {
4482
	       o=son(sone);   /* an offset ? */
4495
	       o=son(sone);   /* an offset ? */
4483
	       p=bro(o);     /* a pointer ? */
4496
	       p=bro(o);     /* a pointer ? */
4484
	    }
4497
	    }
4485
	    else
4498
	    else
4486
	    {
4499
	    {
4487
	       p=son(sone);   /* a pointer ? */
4500
	       p=son(sone);   /* a pointer ? */
4488
	       o=bro(p);     /* an offset ? */
4501
	       o=bro(p);     /* an offset ? */
4489
	    }
4502
	    }
4490
	    if ( name(sone) == addptr_tag && name(o)==offset_mult_tag
4503
	    if (name(sone) == addptr_tag && name(o) ==offset_mult_tag
4491
				          && name(bro(son(o)))==val_tag )
4504
				          && name(bro(son(o))) ==val_tag)
4492
	    { 
4505
	    {
4493
	       long shift;
4506
	       long shift;
4494
	       shift=no(bro(son(o)));
4507
	       shift=no(bro(son(o)));
4495
	       if ( ashe.ashalign==ashsize &&
4508
	       if (ashe.ashalign==ashsize &&
4496
		    ((ashsize==16 && (shift==2 || shift==0)) ||
4509
		   ((ashsize==16 && (shift==2 || shift==0)) ||
4497
		     (ashsize==32 && (shift==4 || shift==0)) ||
4510
		    (ashsize==32 && (shift==4 || shift==0)) ||
4498
		     (ashsize==64 && is_float && (shift==8 || shift==0))) )
4511
		    (ashsize==64 && is_float && (shift==8 || shift==0))))
4499
	       {
4512
	       {
4500
		  space nsp;
4513
		  space nsp;
4501
		  int lhs,rhs;
4514
		  int lhs,rhs;
4502
		  CONST char *cmplt;
4515
		  CONST char *cmplt;
4503
		  if (son(sone)->commuted)
4516
		  if (son(sone) ->commuted)
4504
		  {
4517
		  {
4505
		     lhs = reg_operand(son(o),sp);
4518
		     lhs = reg_operand(son(o),sp);
4506
		     nsp = guardreg(lhs,sp);
4519
		     nsp = guardreg(lhs,sp);
4507
		     rhs = reg_operand(p,nsp);
4520
		     rhs = reg_operand(p,nsp);
4508
		  }
4521
		  }
4509
		  else
4522
		  else
4510
		  {
4523
		  {
4511
		     rhs = reg_operand(p,sp);
4524
		     rhs = reg_operand(p,sp);
4512
		     nsp = guardreg(rhs,sp);
4525
		     nsp = guardreg(rhs,sp);
4513
		     lhs = reg_operand(son(o),nsp);
4526
		     lhs = reg_operand(son(o),nsp);
4514
		  }            
4527
		  }
4515
		  /* register rhs contains the evaluation of pointer
4528
		  /* register rhs contains the evaluation of pointer
4516
		     operand of addptr */
4529
		     operand of addptr */
4517
		  cmplt = ( shift==0 ? cmplt_ : cmplt_S );
4530
		  cmplt = (shift==0 ? cmplt_ : cmplt_S);
4518
		  if (is_float)
4531
		  if (is_float)
4519
  	          {
4532
  	          {
4520
		     freg dfreg;
4533
		     freg dfreg;
4521
  	             if ( discrim ( dest.answhere )  == infreg)
4534
  	             if (discrim(dest.answhere) == infreg)
4522
			dfreg = fregalt(dest.answhere);
4535
			dfreg = fregalt(dest.answhere);
4523
		     else
4536
		     else
4524
			dfreg.fr = getfreg(sp.flt);
4537
			dfreg.fr = getfreg(sp.flt);
4525
 
4538
 
4526
		     dfreg.dble = (ashsize==64);
4539
		     dfreg.dble = (ashsize==64);
4527
 
4540
 
4528
		     if (dfreg.dble)
4541
		     if (dfreg.dble)
4529
			ldf_rr_ins(i_flddx,cmplt,lhs,rhs,(3*dfreg.fr)+1);
4542
			ldf_rr_ins(i_flddx,cmplt,lhs,rhs,(3*dfreg.fr) +1);
4530
		     else
4543
		     else
4531
			ldf_rr_ins(i_fldwx,cmplt,lhs,rhs,3*dfreg.fr);
4544
			ldf_rr_ins(i_fldwx,cmplt,lhs,rhs,3*dfreg.fr);
4532
	    	     setfregalt(aa, dfreg);
4545
	    	     setfregalt(aa, dfreg);
4533
		  }
4546
		  }
4534
		  else
4547
		  else
4535
		  {              
4548
		  {
4536
		     dr = ( discrim ( dest.answhere )  == inreg) ? dest.answhere.val.regans : getreg(guardreg(lhs,nsp).fixed);
4549
		     dr = (discrim(dest.answhere) == inreg)? dest.answhere.val.regans : getreg(guardreg(lhs,nsp).fixed);
4537
		     if (ashsize==32)
4550
		     if (ashsize==32)
4538
			ld_rr_ins(i_ldwx,cmplt,lhs,rhs,dr);
4551
			ld_rr_ins(i_ldwx,cmplt,lhs,rhs,dr);
4539
		     else 
4552
		     else
4540
		     {
4553
		     {
4541
			ld_rr_ins(i_ldhx,cmplt,lhs,rhs,dr);
4554
			ld_rr_ins(i_ldhx,cmplt,lhs,rhs,dr);
4542
			if (sgned)
4555
			if (sgned)
4543
			   riir_ins(i_extrs,c_,dr,31,16,dr);
4556
			   riir_ins(i_extrs,c_,dr,31,16,dr);
4544
		     }
4557
		     }
Line 4557... Line 4570...
4557
#if DO_INDEXED_LOADS
4570
#if DO_INDEXED_LOADS
4558
#ifndef NO_REGREG_LOADS
4571
#ifndef NO_REGREG_LOADS
4559
   {
4572
   {
4560
      exp addptr_sons = son(son(e));
4573
      exp addptr_sons = son(son(e));
4561
      /* see if we can use reg(reg) addressing for this load */
4574
      /* see if we can use reg(reg) addressing for this load */
4562
      if ( name(son(e))==addptr_tag )
4575
      if (name(son(e)) ==addptr_tag)
4563
      {
4576
      {
4564
	 ash ashe ;
4577
	 ash ashe;
4565
	 int ashsize ;
4578
	 int ashsize;
4566
	 bool is_float = is_floating(name(sh(e)));
4579
	 bool is_float = is_floating(name(sh(e)));
4567
	 ashe = ashof(sh(e));
4580
	 ashe = ashof(sh(e));
4568
	 ashsize = ashe.ashsize;
4581
	 ashsize = ashe.ashsize;
4569
	 if (last(bro(addptr_sons)) && ashe.ashalign==ashsize &&
4582
	 if (last(bro(addptr_sons)) && ashe.ashalign==ashsize &&
4570
	     (ashsize==8 || ashsize==16 || ashsize==32 || is_float))
4583
	    (ashsize==8 || ashsize==16 || ashsize==32 || is_float))
4571
	 {
4584
	 {
4572
	    int lhsreg;
4585
	    int lhsreg;
4573
	    int rhsreg;
4586
	    int rhsreg;
4574
	    bool sgned = ((ashsize >= 32) || is_signed(sh(e)));
4587
	    bool sgned = ((ashsize >= 32) || is_signed(sh(e)));
4575
	    ans aa;
4588
	    ans aa;
Line 4577... Line 4590...
4577
	    {
4590
	    {
4578
	       /* offset register */
4591
	       /* offset register */
4579
	       lhsreg = reg_operand(addptr_sons, sp);
4592
	       lhsreg = reg_operand(addptr_sons, sp);
4580
	       /* base register */
4593
	       /* base register */
4581
	       rhsreg = reg_operand(bro(addptr_sons), guardreg(lhsreg, sp));
4594
	       rhsreg = reg_operand(bro(addptr_sons), guardreg(lhsreg, sp));
4582
	    }
4595
	    }
4583
	    else
4596
	    else
4584
	    {
4597
	    {
4585
	       /* base register */
4598
	       /* base register */
4586
	       rhsreg = reg_operand(addptr_sons, sp);
4599
	       rhsreg = reg_operand(addptr_sons, sp);
4587
	       /* offset register */
4600
	       /* offset register */
4588
	       lhsreg = reg_operand(bro(addptr_sons), guardreg(rhsreg, sp));
4601
	       lhsreg = reg_operand(bro(addptr_sons), guardreg(rhsreg, sp));
4589
	    }
4602
	    }
4590
 	    if (is_float)
4603
 	    if (is_float)
4591
	    {
4604
	    {
4592
	       freg dfreg;
4605
	       freg dfreg;
4593
	       if ( discrim ( dest.answhere )  == infreg)
4606
	       if (discrim(dest.answhere) == infreg)
4594
		  dfreg = fregalt(dest.answhere);
4607
		  dfreg = fregalt(dest.answhere);
4595
	       else
4608
	       else
4596
		  dfreg.fr = getfreg(sp.flt);
4609
		  dfreg.fr = getfreg(sp.flt);
4597
 	       dfreg.dble = (ashsize==64);
4610
 	       dfreg.dble = (ashsize==64);
4598
	       if (ashsize==32)
4611
	       if (ashsize==32)
4599
		  ldf_rr_ins(i_fldwx,cmplt_,lhsreg,rhsreg,3*dfreg.fr);
4612
		  ldf_rr_ins(i_fldwx,cmplt_,lhsreg,rhsreg,3*dfreg.fr);
4600
	       else
4613
	       else
4601
		  ldf_rr_ins(i_flddx,cmplt_,lhsreg,rhsreg,(3*dfreg.fr)+1);
4614
		  ldf_rr_ins(i_flddx,cmplt_,lhsreg,rhsreg,(3*dfreg.fr) +1);
4602
	       setfregalt(aa, dfreg);
4615
	       setfregalt(aa, dfreg);
4603
	    }
4616
	    }
4604
	    else
4617
	    else
4605
	    {
4618
	    {
4606
	       int dreg = ( discrim(dest.answhere)==inreg) ? dest.answhere.val.regans : getreg(sp.fixed);
4619
	       int dreg = (discrim(dest.answhere) ==inreg)? dest.answhere.val.regans : getreg(sp.fixed);
4607
 
4620
 
4608
	       if (ashsize==8)
4621
	       if (ashsize==8)
4609
	       {
4622
	       {
4610
		  ld_rr_ins(i_ldbx,cmplt_,lhsreg,rhsreg,dreg);
4623
		  ld_rr_ins(i_ldbx,cmplt_,lhsreg,rhsreg,dreg);
4611
		  if (sgned)
4624
		  if (sgned)
Line 4618... Line 4631...
4618
		     riir_ins(i_extrs,c_,dreg,31,16,dreg);
4631
		     riir_ins(i_extrs,c_,dreg,31,16,dreg);
4619
	       }
4632
	       }
4620
	       else
4633
	       else
4621
		  ld_rr_ins(i_ldwx,cmplt_,lhsreg,rhsreg,dreg);
4634
		  ld_rr_ins(i_ldwx,cmplt_,lhsreg,rhsreg,dreg);
4622
	       setregalt(aa, dreg);
4635
	       setregalt(aa, dreg);
4623
	    }
4636
	    }
4624
	    mka.regmove = move(aa, dest, sp.fixed, sgned);
4637
	    mka.regmove = move(aa, dest, sp.fixed, sgned);
4625
	    if (name(e) == contvol_tag)
4638
	    if (name(e) == contvol_tag)
4626
	    {
4639
	    {
4627
	       mka.regmove = NOREG;
4640
	       mka.regmove = NOREG;
4628
	       setnovolatile();
4641
	       setnovolatile();
4629
	    }
4642
	    }
4630
	    return mka;
4643
	    return mka;
4631
	 } 
4644
	 }
4632
      }
4645
      }
4633
   }
4646
   }
4634
#endif /* NO_REGREG_LOADS */
4647
#endif /* NO_REGREG_LOADS */
4635
#endif
4648
#endif
4636
  }
4649
  }
Line 4643... Line 4656...
4643
  case subptr_tag:
4656
  case subptr_tag:
4644
    {
4657
    {
4645
 
4658
 
4646
      where w;
4659
      where w;
4647
      bool sgned;
4660
      bool sgned;
4648
      int dr = (discrim(dest.answhere)==inreg) ? dest.answhere.val.regans : 0;
4661
      int dr = (discrim(dest.answhere) ==inreg)? dest.answhere.val.regans : 0;
4649
      if (name(e) == contvol_tag)
4662
      if (name(e) == contvol_tag)
4650
      {
4663
      {
4651
	clear_all();
4664
	clear_all();
4652
	setvolatile();
4665
	setvolatile();
4653
      }
4666
      }
4654
      w = locate(e, sp, sh(e), dr);	/* address of arg */
4667
      w = locate(e, sp, sh(e), dr);	/* address of arg */
4655
      sgned = ((w.ashwhere.ashsize >= 32) || ((is_signed(sh(e))) ? 1 : 0));
4668
      sgned = ((w.ashwhere.ashsize >= 32) || ((is_signed(sh(e)))? 1 : 0));
4656
      /* +++ load real into float reg, move uses fixed reg */
4669
      /* +++ load real into float reg, move uses fixed reg */
4657
      mka.regmove = move(w.answhere, dest, (guard(w, sp)).fixed, sgned);
4670
      mka.regmove = move(w.answhere, dest,(guard(w, sp)).fixed, sgned);
4658
      if (name(e) == contvol_tag)
4671
      if (name(e) == contvol_tag)
4659
      {
4672
      {
4660
	setnovolatile();
4673
	setnovolatile();
4661
	mka.regmove = NOREG;
4674
	mka.regmove = NOREG;
4662
      }
4675
      }
Line 4671... Line 4684...
4671
     instore isa;
4684
     instore isa;
4672
     ans aa;
4685
     ans aa;
4673
     bool sgned = ((ashof(sh(e)).ashsize >= 32) || is_signed(sh(e)));
4686
     bool sgned = ((ashof(sh(e)).ashsize >= 32) || is_signed(sh(e)));
4674
     labexp next;
4687
     labexp next;
4675
      /* place constant in appropriate data segment */
4688
      /* place constant in appropriate data segment */
4676
     next  = (labexp) malloc( sizeof(struct labexp_t) );
4689
     next  = (labexp)malloc(sizeof(struct labexp_t));
4677
     next->e = e;
4690
     next->e = e;
4678
     next->lab = next_data_lab();
4691
     next->lab = next_data_lab();
4679
     next->next = (labexp) 0;
4692
     next->next = (labexp)0;
4680
     current->next = next;
4693
     current->next = next;
4681
     current = next;
4694
     current = next;
4682
     isa.adval = 0;
4695
     isa.adval = 0;
4683
     isa.b.offset = 0;
4696
     isa.b.offset = 0;
4684
     isa.b.base = next->lab;
4697
     isa.b.base = next->lab;
Line 4688... Line 4701...
4688
  }				/* end eval */
4701
  }				/* end eval */
4689
 
4702
 
4690
  case val_tag:
4703
  case val_tag:
4691
    {
4704
    {
4692
      comment1("make_code val_tag: no(e) = %d", no(e));
4705
      comment1("make_code val_tag: no(e) = %d", no(e));
4693
      if ( shape_size(sh(e))>32 ) 
4706
      if (shape_size(sh(e)) >32)
4694
      {
4707
      {
4695
	 flt64 t;
4708
	 flt64 t;
4696
	 int ov;
4709
	 int ov;
4697
	 int r = getreg(sp.fixed);
4710
	 int r = getreg(sp.fixed);
4698
	 space nsp;
4711
	 space nsp;
4699
	 int big;
4712
	 int big;
4700
	 unsigned int small;
4713
	 unsigned int small;
4701
	 ans aa;
4714
	 ans aa;
4702
	 if ( discrim(dest.answhere)!=notinreg )
4715
	 if (discrim(dest.answhere)!=notinreg)
4703
	    return mka;
4716
	    return mka;
4704
	 if (isbigval(e))
4717
	 if (isbigval(e))
4705
	 {
4718
	 {
4706
	    t = flt_to_f64(no(e),0,&ov);
4719
	    t = flt_to_f64(no(e),0,&ov);
4707
	 }
4720
	 }
4708
	 else
4721
	 else
4709
	 {
4722
	 {
4710
	    t.big = (is_signed(sh(e)) && no(e)<0)?-1:0;
4723
	    t.big = (is_signed(sh(e)) && no(e) <0)?-1:0;
4711
	    t.small = no(e);
4724
	    t.small = no(e);
4712
	 }
4725
	 }
4713
	 nsp = guardreg(r,sp);
4726
	 nsp = guardreg(r,sp);
4714
	 big = t.big;
4727
	 big = t.big;
4715
	 imm_to_r(big,r);
4728
	 imm_to_r(big,r);
Line 4719... Line 4732...
4719
	 move(aa,dest,nsp.fixed,1);
4732
	 move(aa,dest,nsp.fixed,1);
4720
	 small = t.small;
4733
	 small = t.small;
4721
	 imm_to_r(small,r);
4734
	 imm_to_r(small,r);
4722
	 dest.answhere.val.instoreans.b.offset+=4;
4735
	 dest.answhere.val.instoreans.b.offset+=4;
4723
	 move(aa,dest,nsp.fixed,1);
4736
	 move(aa,dest,nsp.fixed,1);
4724
	 return mka; 	
4737
	 return mka;
4725
      }
4738
      }
4726
      if (no(e) == 0)
4739
      if (no(e) == 0)
4727
      {
4740
      {
4728
	goto null_tag_case;
4741
	goto null_tag_case;
4729
      }
4742
      }
4730
      else
4743
      else
4731
      {
4744
      {
4732
	ash a;
4745
	ash a;
4733
 
4746
 
4734
	a = ashof(sh(e));
4747
	a = ashof(sh(e));
4735
	if (a.ashsize == 32 || is_signed(sh(e))==0)
4748
	if (a.ashsize == 32 || is_signed(sh(e)) ==0)
4736
 	   constval = no(e);
4749
 	   constval = no(e);
4737
	else if (a.ashsize == 8)
4750
	else if (a.ashsize == 8)
4738
	{
4751
	{
4739
	  constval = no(e) & 255;
4752
	  constval = no(e) & 255;
4740
	  constval -= (constval & 128) << 1;
4753
	  constval -= (constval & 128) << 1;
Line 4745... Line 4758...
4745
	  constval -= (constval & 32768) << 1;
4758
	  constval -= (constval & 32768) << 1;
4746
	}
4759
	}
4747
	comment1("make_code val_tag: constval = %d", constval);
4760
	comment1("make_code val_tag: constval = %d", constval);
4748
	goto moveconst;
4761
	goto moveconst;
4749
      }
4762
      }
4750
    }
4763
    }
4751
 
4764
 
4752
  case top_tag:
4765
  case top_tag:
4753
  case prof_tag:
4766
  case prof_tag:
4754
  case clear_tag:
4767
  case clear_tag:
4755
  {
4768
  {
4756
     /* Do nothing */
4769
     /* Do nothing */
4757
     if ( discrim(dest.answhere)==insomereg)
4770
     if (discrim(dest.answhere) ==insomereg)
4758
     {
4771
     {
4759
	int *sr = someregalt(dest.answhere);
4772
	int *sr = someregalt(dest.answhere);
4760
	if (*sr!=-1)
4773
	if (*sr!=-1)
4761
	   fail ( "Illegal register" );
4774
	   fail("Illegal register");
4762
	*sr = GR0 ;
4775
	*sr = GR0;
4763
     }
4776
     }
4764
     return mka;
4777
     return mka;
4765
  }
4778
  }
4766
 
4779
 
4767
  case null_tag:
4780
  case null_tag:
Line 4790... Line 4803...
4790
  }
4803
  }
4791
  /*  ENDS last_local_tag  */
4804
  /*  ENDS last_local_tag  */
4792
 
4805
 
4793
 
4806
 
4794
  case local_free_tag:
4807
  case local_free_tag:
4795
  {
4808
  {
4796
     exp s = son(e);
4809
     exp s = son(e);
4797
     int r = reg_operand(s,sp);
4810
     int r = reg_operand(s,sp);
4798
     int maxargbytes = max_args>>3;
4811
     int maxargbytes = max_args>>3;
4799
     if (SIMM14(maxargbytes))
4812
     if (SIMM14(maxargbytes))
4800
	ld_ir_ins(i_ldo,cmplt_,fs_,empty_ltrl,maxargbytes,r,SP);
4813
	ld_ir_ins(i_ldo,cmplt_,fs_,empty_ltrl,maxargbytes,r,SP);
Line 4806... Line 4819...
4806
     if (Has_tos)
4819
     if (Has_tos)
4807
	reset_tos();
4820
	reset_tos();
4808
     return mka;
4821
     return mka;
4809
  }
4822
  }
4810
  /*  ENDS local_free  */
4823
  /*  ENDS local_free  */
4811
 
4824
 
4812
 
4825
 
4813
  case local_free_all_tag:
4826
  case local_free_all_tag:
4814
  {
4827
  {
4815
     if (Has_vsp)
4828
     if (Has_vsp)
4816
     {
4829
     {
4817
	rr_ins(i_copy,EP,SP);
4830
	rr_ins(i_copy,EP,SP);
4818
	if (Has_tos)
4831
	if (Has_tos)
4819
	   reset_tos();
4832
	   reset_tos();
4820
     }
4833
     }
4821
     return mka;
4834
     return mka;
4822
  }      
4835
  }
4823
 
4836
 
4824
  case current_env_tag:
4837
  case current_env_tag:
4825
  {
4838
  {
4826
     int r = GETREG(dest,sp);
4839
     int r = GETREG(dest,sp);
4827
     ans aa;
4840
     ans aa;
4828
     rr_ins(i_copy,EP,r);
4841
     rr_ins(i_copy,EP,r);
4829
     setregalt(aa, r);
4842
     setregalt(aa, r);
4830
     mka.regmove = move(aa, dest, sp.fixed, 1);
4843
     mka.regmove = move(aa, dest, sp.fixed, 1);
4831
     return mka;
4844
     return mka;
4832
  } 
4845
  }
4833
 
4846
 
4834
  case env_offset_tag: case general_env_offset_tag:
4847
  case env_offset_tag: case general_env_offset_tag:
4835
  {
4848
  {
4836
     constval = frame_offset(son(e));
4849
     constval = frame_offset(son(e));
4837
     goto moveconst;
4850
     goto moveconst;
4838
  }  
4851
  }
-
 
4852
 
4839
 
4853
 
4840
  
-
 
4841
  case set_stack_limit_tag:
4854
  case set_stack_limit_tag:
4842
  {
4855
  {
4843
     baseoff b ;
4856
     baseoff b;
4844
     int r = reg_operand( son(e), sp );
4857
     int r = reg_operand(son(e), sp);
4845
     exp stl = find_named_tg("__TDFstacklim",
4858
     exp stl = find_named_tg("__TDFstacklim",
4846
			     f_pointer(f_alignment(f_proc)));
4859
			     f_pointer(f_alignment(f_proc)));
4847
     setvar(stl);
4860
     setvar(stl);
4848
     b = boff(stl);
4861
     b = boff(stl);
4849
     st_ins(i_sw,r,b);
4862
     st_ins(i_sw,r,b);
Line 4865... Line 4878...
4865
     return mka;
4878
     return mka;
4866
  }
4879
  }
4867
 
4880
 
4868
  case trap_tag:
4881
  case trap_tag:
4869
  {
4882
  {
4870
     if ( no(e) == f_overflow )
4883
     if (no(e) == f_overflow)
4871
     {
4884
     {
4872
	do_exception( SIGFPE );
4885
	do_exception(SIGFPE);
4873
     }
4886
     }
4874
     else
4887
     else
4875
     if ( no(e) == f_nil_access )
4888
     if (no(e) == f_nil_access)
4876
     {
4889
     {
4877
	do_exception( SIGSEGV );
4890
	do_exception(SIGSEGV);
4878
     }
4891
     }
4879
     else
4892
     else
4880
     {
4893
     {
4881
	do_exception(SIGUSR1);
4894
	do_exception(SIGUSR1);
4882
     }
4895
     }
4883
     return mka;
4896
     return mka;
4884
  }	
4897
  }
4885
 
4898
 
4886
  case round_tag:
4899
  case round_tag:
4887
  {
4900
  {
4888
      /*
4901
      /*
4889
      *   Floating point variety to integer variety conversion.
4902
      *   Floating point variety to integer variety conversion.
Line 4894... Line 4907...
4894
     ans aa;
4907
     ans aa;
4895
     int s;
4908
     int s;
4896
     baseoff b;
4909
     baseoff b;
4897
     space nsp;
4910
     space nsp;
4898
     int us = !(is_signed(sh(e)));
4911
     int us = !(is_signed(sh(e)));
4899
     int rm = (int) round_number(e); 
4912
     int rm = (int)round_number(e);
4900
     unsigned char nm = name(sh(e));
4913
     unsigned char nm = name(sh(e));
4901
     int inmem = (discrim(dest.answhere)==notinreg);
4914
     int inmem = (discrim(dest.answhere) ==notinreg);
4902
     int trap=0;
4915
     int trap=0;
4903
     int br;
4916
     int br;
4904
     nsp = sp;
4917
     nsp = sp;
4905
     if (!optop(e))
4918
     if (!optop(e))
4906
	trap = trap_label(e);
4919
	trap = trap_label(e);
Line 4908... Line 4921...
4908
      *   rm = 0 = nearest, rm = 1 = smaller, rm = 2 = larger, rm = 3 = to zero
4921
      *   rm = 0 = nearest, rm = 1 = smaller, rm = 2 = larger, rm = 3 = to zero
4909
       */
4922
       */
4910
     if (r==0 && !optop(e))
4923
     if (r==0 && !optop(e))
4911
     {
4924
     {
4912
	r = getreg(sp.fixed);
4925
	r = getreg(sp.fixed);
4913
	nsp = guardreg( r, sp );
4926
	nsp = guardreg(r, sp);
4914
     }
4927
     }
4915
     a = ashof(sh(son(e)));
4928
     a = ashof(sh(son(e)));
4916
     s = shape_size(sh(son(e)));
4929
     s = shape_size(sh(son(e)));
4917
     if ( name(sh(son(e)))==doublehd && use_long_double )
4930
     if (name(sh(son(e))) ==doublehd && use_long_double)
4918
     {
4931
     {
4919
	if ( rm==3 && errhandle(e)<2 )  /* can't risk calling
4932
	if ( rm==3 && errhandle(e)<2 )  /* can't risk calling
4920
				        *  "_U_Qfcnvfxt_dbl_to_sgl" if
4933
				        *  "_U_Qfcnvfxt_dbl_to_sgl" if
4921
				        *  error_treatment is continue
4934
				        *  error_treatment is continue
4922
				         */ 
4935
				         */
4923
	{
4936
	{
4924
     	   quad_op( e, nsp, dest) ;
4937
     	   quad_op(e, nsp, dest);
4925
	   if ( nm == ucharhd && !inmem )
4938
	   if (nm == ucharhd && !inmem)
4926
	      riir_ins(i_dep,c_,0,23,24,RET0);
4939
	      riir_ins(i_dep,c_,0,23,24,RET0);
4927
	   else
4940
	   else
4928
	   if ( nm == scharhd )
4941
	   if (nm == scharhd)
4929
	      riir_ins(i_extrs,c_,RET0,31,8,RET0);
4942
	      riir_ins(i_extrs,c_,RET0,31,8,RET0);
4930
	   else
4943
	   else
4931
	   if ( nm == uwordhd && !inmem )
4944
	   if (nm == uwordhd && !inmem)
4932
	      riir_ins(i_dep,c_,0,15,16,RET0);
4945
	      riir_ins(i_dep,c_,0,15,16,RET0);
4933
	   else
4946
	   else
4934
	   if ( nm == swordhd )
4947
	   if (nm == swordhd)
4935
	      riir_ins(i_extrs,c_,RET0,31,16,RET0);
4948
	      riir_ins(i_extrs,c_,RET0,31,16,RET0);
4936
	   setregalt(aa, RET0);
4949
	   setregalt(aa, RET0);
4937
	   mka.regmove = move(aa, dest, nsp.fixed, 1);
4950
	   mka.regmove = move(aa, dest, nsp.fixed, 1);
4938
	   if (inmem)
4951
	   if (inmem)
4939
	      mka.regmove = NOREG;
4952
	      mka.regmove = NOREG;
4940
	   return mka;
4953
	   return mka;
4941
	}
4954
	}
4942
	else
4955
	else
4943
	{
4956
	{
4944
	   /*  Convert to double putting result in %fr4  */   
4957
	   /*  Convert to double putting result in %fr4  */
4945
      	   quad_op( e, nsp, dest) ;
4958
      	   quad_op(e, nsp, dest);
4946
	   f1.fr = 4;
4959
	   f1.fr = 4;
4947
	   /* and treat as a double..  */
4960
	   /* and treat as a double..  */
4948
	}
4961
	}
4949
     }
4962
     }
4950
     else
4963
     else
Line 4952... Line 4965...
4952
	f1.fr = freg_operand(son(e),nsp,getfreg(nsp.flt));
4965
	f1.fr = freg_operand(son(e),nsp,getfreg(nsp.flt));
4953
     }
4966
     }
4954
     b = mem_temp(0);
4967
     b = mem_temp(0);
4955
     br = getreg(nsp.fixed);
4968
     br = getreg(nsp.fixed);
4956
     ld_ins(i_lo,0,b,br);
4969
     ld_ins(i_lo,0,b,br);
4957
     b.base = br; b.offset = 0;        
4970
     b.base = br; b.offset = 0;
4958
     if (!optop(e) && us && (shape_size(sh(e))<=32))
4971
     if (!optop(e) && us && (shape_size(sh(e)) <=32))
4959
     {
4972
     {
4960
	f2.fr = getfreg(guardfreg(f1.fr,nsp).flt);
4973
	f2.fr = getfreg(guardfreg(f1.fr,nsp).flt);
4961
	rrf_ins(i_fcpy,f_dbl,"",(R_FR0*3)+1,(3*f2.fr)+1);
4974
	rrf_ins(i_fcpy,f_dbl,"",(R_FR0*3) +1,(3*f2.fr) +1);
4962
     }
4975
     }
4963
     else
4976
     else
4964
	f2.fr = f1.fr;
4977
	f2.fr = f1.fr;
4965
     if ( rm < 3 )
4978
     if (rm < 3)
4966
     {
4979
     {
4967
	if ( rm > 0 )
4980
	if (rm > 0)
4968
	{
4981
	{
4969
	   /* Set rounding mode bits in floating point status register      */
4982
	   /* Set rounding mode bits in floating point status register      */
4970
	   if ( rm == 1 )
4983
	   if (rm == 1)
4971
	      iiir_ins(i_zdepi,c_,-1,22,2,r);
4984
	      iiir_ins(i_zdepi,c_,-1,22,2,r);
4972
	   else
4985
	   else
4973
	      iiir_ins(i_zdepi,c_,-1,21,1,r);
4986
	      iiir_ins(i_zdepi,c_,-1,21,1,r);
4974
	   st_ins(i_sw,r,b);
4987
	   st_ins(i_sw,r,b);
4975
	   ldf_ins(i_fldw,b,0);  /*  n.b. this zeros the exception register  */
4988
	   ldf_ins(i_fldw,b,0);  /*  n.b. this zeros the exception register  */
4976
	}
4989
	}
4977
	/* Round and convert. */
4990
	/* Round and convert. */
4978
	if (us)
4991
	if (us)
4979
	{
4992
	{
4980
	   if ( s > 32 )
4993
	   if (s > 32)
4981
	   {
4994
	   {
4982
	      rrf_ins(i_fcnvfx,f_dbl,f_dbl,(f1.fr*3)+1,(f2.fr*3)+1);
4995
	      rrf_ins(i_fcnvfx,f_dbl,f_dbl,(f1.fr*3) +1,(f2.fr*3) +1);
4983
	   }
4996
	   }
4984
	   else
4997
	   else
4985
	   {
4998
	   {
4986
	      rrf_ins(i_fcnvfx,f_sgl,f_dbl,(f1.fr*3)+1,(f2.fr*3)+1);
4999
	      rrf_ins(i_fcnvfx,f_sgl,f_dbl,(f1.fr*3) +1,(f2.fr*3) +1);
4987
	   }
5000
	   }
4988
	}
5001
	}
4989
	else if ( s > 32 )
5002
	else if (s > 32)
4990
	{
5003
	{
4991
	   rrf_ins(i_fcnvfx,f_dbl,f_sgl,(f1.fr*3)+1,(f2.fr*3)+2);
5004
	   rrf_ins(i_fcnvfx,f_dbl,f_sgl,(f1.fr*3) +1,(f2.fr*3) +2);
4992
	}
5005
	}
4993
	else
5006
	else
4994
	   rrf_ins(i_fcnvfx,f_sgl,f_sgl,(f1.fr*3)+1,(f2.fr*3)+2);
5007
	   rrf_ins(i_fcnvfx,f_sgl,f_sgl,(f1.fr*3) +1,(f2.fr*3) +2);
4995
	if (!optop(e) && !us)
5008
	if (!optop(e) && !us)
4996
	   stf_ins(i_fstd,1,b);
5009
	   stf_ins(i_fstd,1,b);
4997
	if ( rm > 0 )
5010
	if (rm > 0)
4998
	{
5011
	{
4999
	   /*
5012
	   /*
5000
	   *   Reset rounding mode to rm = nearest (without corrupting
5013
	   *   Reset rounding mode to rm = nearest (without corrupting
5001
	   *   the exception register data)
5014
	   *   the exception register data)
5002
	    */
5015
	    */
Line 5007... Line 5020...
5007
	   b.offset = 0;
5020
	   b.offset = 0;
5008
	}
5021
	}
5009
     }
5022
     }
5010
     else
5023
     else
5011
     {
5024
     {
5012
	if ( (!optop(e)) && (!us) )
5025
	if ((!optop(e)) && (!us))
5013
	{
5026
	{
5014
	   /*  Zero exception register  */          
5027
	   /*  Zero exception register  */
5015
	   st_ins(i_sw,GR0,b);
5028
	   st_ins(i_sw,GR0,b);
5016
	   ldf_ins(i_fldw,b,0);         
5029
	   ldf_ins(i_fldw,b,0);
5017
	}
5030
	}
5018
	if (us)
5031
	if (us)
5019
	{
5032
	{
5020
	   if ( s > 32 )
5033
	   if (s > 32)
5021
	   {
5034
	   {
5022
	      rrf_ins(i_fcnvfxt,f_dbl,f_dbl,(f1.fr*3)+1,(f2.fr*3)+1);
5035
	      rrf_ins(i_fcnvfxt,f_dbl,f_dbl,(f1.fr*3) +1,(f2.fr*3) +1);
5023
	   }
5036
	   }
5024
	   else
5037
	   else
5025
	   {
5038
	   {
5026
	      rrf_ins(i_fcnvfxt,f_sgl,f_dbl,(f1.fr*3)+1,(f2.fr*3)+1);
5039
	      rrf_ins(i_fcnvfxt,f_sgl,f_dbl,(f1.fr*3) +1,(f2.fr*3) +1);
5027
	   }
5040
	   }
5028
	}
5041
	}
5029
	else if ( s > 32 )
5042
	else if (s > 32)
5030
	{
5043
	{
5031
	   rrf_ins(i_fcnvfxt,f_dbl,f_sgl,(f1.fr*3)+1,(f2.fr*3)+2);
5044
	   rrf_ins(i_fcnvfxt,f_dbl,f_sgl,(f1.fr*3) +1,(f2.fr*3) +2);
5032
	}
5045
	}
5033
	else
5046
	else
5034
	   rrf_ins(i_fcnvfxt,f_sgl,f_sgl,(f1.fr*3)+1,(f2.fr*3)+2);
5047
	   rrf_ins(i_fcnvfxt,f_sgl,f_sgl,(f1.fr*3) +1,(f2.fr*3) +2);
5035
	if ( (!optop(e)) && (!us) )
5048
	if ((!optop(e)) && (!us))
5036
	   stf_ins(i_fstd,1,b);
5049
	   stf_ins(i_fstd,1,b);
5037
     }
5050
     }
5038
     if (!optop(e))
5051
     if (!optop(e))
5039
     {
5052
     {
5040
	if (us)
5053
	if (us)
5041
	{
5054
	{
5042
	   stf_ins(i_fstd,(f2.fr*3)+1,b);
5055
	   stf_ins(i_fstd,(f2.fr*3) +1,b);
5043
	   ld_ins(i_lw,1,b,r);
5056
	   ld_ins(i_lw,1,b,r);
5044
	   cj_ins(c_neq,r,0,trap);
5057
	   cj_ins(c_neq,r,0,trap);
5045
	   b.offset=4;
5058
	   b.offset=4;
5046
	}
5059
	}
5047
	else
5060
	else
5048
	{
5061
	{
5049
	   /* 
5062
	   /*
5050
	   *   If the unimplemented flag in the exception 
5063
	   *   If the unimplemented flag in the exception
5051
	   *   register was set, then jump to trap.
5064
	   *   register was set, then jump to trap.
5052
	    */
5065
	    */
5053
	   ld_ins(i_lw,0,b,r);
5066
	   ld_ins(i_lw,0,b,r);
5054
	   imm_to_r(64,GR1);
5067
	   imm_to_r(64,GR1);
5055
	   rrr_ins(i_and,c_eq,r,GR1,0);
5068
	   rrr_ins(i_and,c_eq,r,GR1,0);
5056
	   ub_ins(cmplt_N,trap);
5069
	   ub_ins(cmplt_N,trap);
5057
	   stf_ins(i_fstw,(f2.fr*3)+2,b);
5070
	   stf_ins(i_fstw,(f2.fr*3) +2,b);
5058
	}
5071
	}
5059
	ld_ins(i_lw,1,b,r);
5072
	ld_ins(i_lw,1,b,r);
5060
	test_if_outside_of_var(nm,r,trap);
5073
	test_if_outside_of_var(nm,r,trap);
5061
	if ( nm!=slonghd && nm!=ulonghd )
5074
	if (nm!=slonghd && nm!=ulonghd)
5062
	   rr_ins(i_copy,GR1,r);
5075
	   rr_ins(i_copy,GR1,r);
5063
     }
5076
     }
5064
     else
5077
     else
5065
     {
5078
     {
5066
	stf_ins(i_fstw,(f2.fr*3)+2,b);
5079
	stf_ins(i_fstw,(f2.fr*3) +2,b);
5067
	/*   Load and shorten to type if needed.   */
5080
	/*   Load and shorten to type if needed.   */
5068
	if ( nm == ucharhd )
5081
	if (nm == ucharhd)
5069
	{
5082
	{
5070
	   b.offset += 3;
5083
	   b.offset += 3;
5071
	   ld_ins(i_lb,0,b,r);
5084
	   ld_ins(i_lb,0,b,r);
5072
	}
5085
	}
5073
	else
5086
	else
5074
	if ( nm == scharhd )
5087
	if (nm == scharhd)
5075
	{
5088
	{
5076
	   ld_ins(i_lw,1,b,r);
5089
	   ld_ins(i_lw,1,b,r);
5077
	   riir_ins(i_extrs,c_,r,31,8,r);
5090
	   riir_ins(i_extrs,c_,r,31,8,r);
5078
	}
5091
	}
5079
	else
5092
	else
5080
	if ( nm == uwordhd )
5093
	if (nm == uwordhd)
5081
	{
5094
	{
5082
	   b.offset += 2;
5095
	   b.offset += 2;
5083
	   ld_ins(i_lh,0,b,r);
5096
	   ld_ins(i_lh,0,b,r);
5084
	}
5097
	}
5085
	else
5098
	else
5086
	if ( nm == swordhd )
5099
	if (nm == swordhd)
5087
	{
5100
	{
5088
	   ld_ins(i_lw,1,b,r);
5101
	   ld_ins(i_lw,1,b,r);
5089
	   riir_ins(i_extrs,c_,r,31,16,r);
5102
	   riir_ins(i_extrs,c_,r,31,16,r);
5090
	}
5103
	}
5091
	else
5104
	else
Line 5102... Line 5115...
5102
      int r;
5115
      int r;
5103
      int size_res = shape_size(sh(e));
5116
      int size_res = shape_size(sh(e));
5104
      int size_op = shape_size(sh(son(e)));
5117
      int size_op = shape_size(sh(son(e)));
5105
      ans aa;
5118
      ans aa;
5106
      space nsp;
5119
      space nsp;
5107
      
5120
 
5108
      r = reg_operand(son(e), sp);
5121
      r = reg_operand(son(e), sp);
5109
      
5122
 
5110
      comment1("make_code int_to_bitf_tag: size=%d", size_res);
5123
      comment1("make_code int_to_bitf_tag: size=%d", size_res);
5111
      
5124
 
5112
      /* maybe this not needed if going to memory +++ */
5125
      /* maybe this not needed if going to memory +++ */
5113
      if (size_res != size_op && size_res != 32)
5126
      if (size_res != size_op && size_res != 32)
5114
      {
5127
      {
5115
	int destr;
5128
	int destr;
5116
	
5129
 
5117
	switch ( discrim ( dest.answhere ) )
5130
	switch (discrim(dest.answhere))
5118
	{
5131
	{
5119
      case inreg:
5132
      case inreg:
5120
      {
5133
      {
5121
	destr = regalt(dest.answhere);
5134
	destr = regalt(dest.answhere);
5122
	break;
5135
	break;
5123
      }
5136
      }
5124
  default:
5137
  default:
5125
  {
5138
  {
5126
    destr = getreg(sp.fixed);
5139
    destr = getreg(sp.fixed);
5127
  }
5140
  }
5128
    }
5141
    }
5129
	
5142
 
5130
	if (r==destr)
5143
	if (r==destr)
5131
	   riir_ins(i_dep,c_,0,31-size_res,32-size_res,destr);
5144
	   riir_ins(i_dep,c_,0,31-size_res,32-size_res,destr);
5132
	else
5145
	else
5133
	   riir_ins(i_zdep,c_,r,31,size_res,destr);
5146
	   riir_ins(i_zdep,c_,r,31,size_res,destr);
5134
	r = destr;
5147
	r = destr;
5135
      }
5148
      }
5136
      
5149
 
5137
      /* r is appropriately truncated operand */
5150
      /* r is appropriately truncated operand */
5138
      
5151
 
5139
      nsp = guardreg(r, sp);
5152
      nsp = guardreg(r, sp);
5140
      setregalt(aa, r);
5153
      setregalt(aa, r);
5141
      move(aa, dest, nsp.fixed, 0);
5154
      move(aa, dest, nsp.fixed, 0);
5142
      return mka;
5155
      return mka;
5143
    }
5156
    }
Line 5149... Line 5162...
5149
      where w;
5162
      where w;
5150
      bool src_sgned = is_signed(sh(son(e)));
5163
      bool src_sgned = is_signed(sh(son(e)));
5151
      bool target_sgned = is_signed(sh(e));
5164
      bool target_sgned = is_signed(sh(e));
5152
 
5165
 
5153
      a = ashof(sh(son(e)));
5166
      a = ashof(sh(son(e)));
5154
      switch ( discrim ( dest.answhere ) )
5167
      switch (discrim(dest.answhere))
5155
      {
5168
      {
5156
      case inreg:
5169
      case inreg:
5157
	{
5170
	{
5158
	  r = regalt(dest.answhere);
5171
	  r = regalt(dest.answhere);
5159
	  break;
5172
	  break;
Line 5217... Line 5230...
5217
  {
5230
  {
5218
     /* Grow stack frame by n bytes and then grab n bytes */
5231
     /* Grow stack frame by n bytes and then grab n bytes */
5219
     exp s=son(e);
5232
     exp s=son(e);
5220
     int maxargbytes=max_args>>3;
5233
     int maxargbytes=max_args>>3;
5221
     ans aa;
5234
     ans aa;
5222
     int r = GETREG( dest, sp );
5235
     int r = GETREG(dest, sp);
5223
     baseoff b;
5236
     baseoff b;
5224
     int n,t;
5237
     int n,t;
5225
     if ( name(s)==val_tag )  /* n is a constant */
5238
     if ( name(s)==val_tag )  /* n is a constant */
5226
     {
5239
     {
5227
	n = no(s);
5240
	n = no(s);
Line 5236... Line 5249...
5236
	if (n != 0)
5249
	if (n != 0)
5237
	{
5250
	{
5238
	   /* alloca(n) = %sp - maxargbytes */
5251
	   /* alloca(n) = %sp - maxargbytes */
5239
	   b.base = SP; b.offset = -maxargbytes;
5252
	   b.base = SP; b.offset = -maxargbytes;
5240
	   ld_ins(i_lo,0,b,r);
5253
	   ld_ins(i_lo,0,b,r);
5241
	   /* grow stack frame, i.e. %sp -> %sp + n */             
5254
	   /* grow stack frame, i.e. %sp -> %sp + n */
5242
	   b.offset = n;
5255
	   b.offset = n;
5243
	   ld_ins( i_lo, 0, b, SP );
5256
	   ld_ins(i_lo, 0, b, SP);
5244
	}
5257
	}
5245
     }
5258
     }
5246
     else
5259
     else
5247
     {
5260
     {
5248
	space nsp;
5261
	space nsp;
5249
	nsp = guardreg( r, sp );
5262
	nsp = guardreg(r, sp);
5250
	n = reg_operand(s, sp);
5263
	n = reg_operand(s, sp);
5251
	t = getreg( nsp.fixed );   
5264
	t = getreg(nsp.fixed);
5252
	/* adjust n so that stack stays 64 byte aligned */
5265
	/* adjust n so that stack stays 64 byte aligned */
5253
	if (Has_ll)
5266
	if (Has_ll)
5254
	   ld_ir_ins(i_ldo,cmplt_,fs_,empty_ltrl,67,n,t);
5267
	   ld_ir_ins(i_ldo,cmplt_,fs_,empty_ltrl,67,n,t);
5255
	else
5268
	else
5256
	   ld_ir_ins(i_ldo,cmplt_,fs_,empty_ltrl,63,n,t);
5269
	   ld_ir_ins(i_ldo,cmplt_,fs_,empty_ltrl,63,n,t);
Line 5260... Line 5273...
5260
	b.base = SP;
5273
	b.base = SP;
5261
	b.offset = -maxargbytes;
5274
	b.offset = -maxargbytes;
5262
	ld_ins(i_lo,0,b,r);
5275
	ld_ins(i_lo,0,b,r);
5263
	/* %sp -> %sp + n */
5276
	/* %sp -> %sp + n */
5264
	rrr_ins(i_add,c_,SP,t,SP);
5277
	rrr_ins(i_add,c_,SP,t,SP);
5265
     }
5278
     }
5266
     if ( checkalloc(e) )
5279
     if (checkalloc(e))
5267
     {
5280
     {
5268
	exp stl = find_named_tg("__TDFstacklim",
5281
	exp stl = find_named_tg("__TDFstacklim",
5269
	 	            f_pointer(f_alignment(f_proc)));
5282
	 	            f_pointer(f_alignment(f_proc)));
5270
	setvar( stl );
5283
	setvar(stl);
5271
	b = boff( stl );
5284
	b = boff(stl);
5272
	ld_ins(i_lw,1,b,GR1);
5285
	ld_ins(i_lw,1,b,GR1);
5273
	if ( stackerr_lab==0 )
5286
	if (stackerr_lab==0)
5274
	{
5287
	{
5275
	   stackerr_lab = new_label();
5288
	   stackerr_lab = new_label();
5276
	}
5289
	}
5277
	cj_ins(c_g,SP,GR1,stackerr_lab);
5290
	cj_ins(c_g,SP,GR1,stackerr_lab);
5278
     }
5291
     }
Line 5286... Line 5299...
5286
	baseoff b;
5299
	baseoff b;
5287
	b.base = SP;
5300
	b.base = SP;
5288
	b.offset = -maxargbytes -4;
5301
	b.offset = -maxargbytes -4;
5289
	st_ins(i_sw,r,b);
5302
	st_ins(i_sw,r,b);
5290
     }
5303
     }
5291
     return (mka);
5304
     return(mka);
5292
  }
5305
  }
5293
 
5306
 
5294
  case movecont_tag:
5307
  case movecont_tag:
5295
  {
5308
  {
5296
     exp szarg = bro(bro(son(e)));
5309
     exp szarg = bro(bro(son(e)));
5297
     int dr, sr, sz, szr, mr,alt=0,lab;	
5310
     int dr, sr, sz, szr, mr,alt=0,lab;
5298
     int finish = new_label();
5311
     int finish = new_label();
5299
     space nsp;
5312
     space nsp;
5300
     where w;
5313
     where w;
5301
     nsp = sp;
5314
     nsp = sp;
5302
     w.ashwhere = ashof(sh(bro(bro(son(e)))));
5315
     w.ashwhere = ashof(sh(bro(bro(son(e)))));
5303
     if (0 && name(szarg)==val_tag)
5316
     if (0 && name(szarg) ==val_tag)
5304
     {
5317
     {
5305
	sz = evalexp(szarg);
5318
	sz = evalexp(szarg);
5306
	if (sz==0)
5319
	if (sz==0)
5307
	   return mka;
5320
	   return mka;
5308
	else
5321
	else
Line 5310... Line 5323...
5310
	{
5323
	{
5311
	   imm_to_r(sz,szr);
5324
	   imm_to_r(sz,szr);
5312
	}
5325
	}
5313
     }
5326
     }
5314
     else
5327
     else
5315
     {
5328
     {
5316
	szr = getreg(sp.fixed);
5329
	szr = getreg(sp.fixed);
5317
	setregalt(w.answhere, szr);
5330
	setregalt(w.answhere, szr);
5318
	make_code(szarg, sp, w, 0);
5331
	make_code(szarg, sp, w, 0);
5319
	nsp = guardreg(szr, sp);
5332
	nsp = guardreg(szr, sp);
5320
	if (name(szarg)==val_tag)
5333
	if (name(szarg) ==val_tag)
5321
	{
5334
	{
5322
	   if (no(szarg)==0) 
5335
	   if (no(szarg) ==0)
5323
	      return mka; 
5336
	      return mka;
5324
	}
5337
	}
5325
	else
5338
	else
5326
	   cj_ins(c_eq,0,szr,finish);
5339
	   cj_ins(c_eq,0,szr,finish);
5327
     }
5340
     }
5328
     sr = getreg(nsp.fixed);
5341
     sr = getreg(nsp.fixed);
Line 5338... Line 5351...
5338
     mr = getreg(nsp.fixed);
5351
     mr = getreg(nsp.fixed);
5339
     if (!isnooverlap(e))
5352
     if (!isnooverlap(e))
5340
     {
5353
     {
5341
	alt = new_label();
5354
	alt = new_label();
5342
	cj_ins(c_l,sr,dr,alt);
5355
	cj_ins(c_l,sr,dr,alt);
5343
     }   
5356
     }
5344
     /*  No overlap or dr<sr  */
5357
     /*  No overlap or dr<sr  */
5345
     lab = new_label();
5358
     lab = new_label();
5346
     if (0 && name(szarg)==val_tag)
5359
     if (0 && name(szarg) ==val_tag)
5347
     {
5360
     {
5348
	if (SIMM14(sz))
5361
	if (SIMM14(sz))
5349
	   ld_ir_ins(i_ldo,cmplt_,fs_,empty_ltrl,sz,sr,mr);
5362
	   ld_ir_ins(i_ldo,cmplt_,fs_,empty_ltrl,sz,sr,mr);
5350
	else
5363
	else
5351
	{
5364
	{
Line 5354... Line 5367...
5354
	   {
5367
	   {
5355
	      ir_ins(i_addil,fs_L,empty_ltrl,sz,sr);
5368
	      ir_ins(i_addil,fs_L,empty_ltrl,sz,sr);
5356
	      ld_ir_ins(i_ldo,cmplt_,fs_R,empty_ltrl,sz,sr,mr);
5369
	      ld_ir_ins(i_ldo,cmplt_,fs_R,empty_ltrl,sz,sr,mr);
5357
	   }
5370
	   }
5358
	   else
5371
	   else
5359
	      rrr_ins(i_add,c_,szr,sr,mr);               
5372
	      rrr_ins(i_add,c_,szr,sr,mr);
5360
	}
5373
	}
5361
     }
5374
     }
5362
     else
5375
     else
5363
     {
5376
     {
5364
	rrr_ins(i_add,c_,szr,sr,mr);
5377
	rrr_ins(i_add,c_,szr,sr,mr);
Line 5372... Line 5385...
5372
	/* Overlap or dr>sr */
5385
	/* Overlap or dr>sr */
5373
	ub_ins(cmplt_N,finish);
5386
	ub_ins(cmplt_N,finish);
5374
	outlab("L$$",alt);
5387
	outlab("L$$",alt);
5375
	lab = new_label();
5388
	lab = new_label();
5376
	rr_ins(i_copy,sr,mr);
5389
	rr_ins(i_copy,sr,mr);
5377
	if (0 && name(szarg)==val_tag && SIMM14(sz))
5390
	if (0 && name(szarg) ==val_tag && SIMM14(sz))
5378
	{
5391
	{
5379
	      ld_ir_ins(i_ldo,cmplt_,fs_,empty_ltrl,sz,sr,sr);
5392
	      ld_ir_ins(i_ldo,cmplt_,fs_,empty_ltrl,sz,sr,sr);
5380
	      ld_ir_ins(i_ldo,cmplt_,fs_,empty_ltrl,sz,dr,dr);
5393
	      ld_ir_ins(i_ldo,cmplt_,fs_,empty_ltrl,sz,dr,dr);
5381
	}
5394
	}
5382
	else
5395
	else
Line 5405... Line 5418...
5405
  assert(0);			/* should have return/goto from switch */
5418
  assert(0);			/* should have return/goto from switch */
5406
 
5419
 
5407
  moveconst:
5420
  moveconst:
5408
  {
5421
  {
5409
     int r;
5422
     int r;
5410
     if ( discrim(dest.answhere)==inreg )
5423
     if (discrim(dest.answhere) ==inreg)
5411
     {
5424
     {
5412
	r = regalt(dest.answhere);
5425
	r = regalt(dest.answhere);
5413
	imm_to_r(constval,r);
5426
	imm_to_r(constval,r);
5414
     }
5427
     }
5415
     else
5428
     else