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 41... Line 71...
41
 *    Fixed the comm_op register tracking bug in "oprators.c" and removed a
71
 *    Fixed the comm_op register tracking bug in "oprators.c" and removed a
42
 * few superfluous "#if 0"s.
72
 * few superfluous "#if 0"s.
43
 *
73
 *
44
 * Revision 1.7  1996/08/30  09:02:30  wfs
74
 * Revision 1.7  1996/08/30  09:02:30  wfs
45
 * Various fixes of bugs arising from avs and pl_tdf tests.
75
 * Various fixes of bugs arising from avs and pl_tdf tests.
46
 *
76
 *
47
 * Revision 1.6  1996/02/15  10:09:40  wfs
77
 * Revision 1.6  1996/02/15  10:09:40  wfs
48
 * Incorrect decrement - which I introduced in last bug fix - removed.
78
 * Incorrect decrement - which I introduced in last bug fix - removed.
49
 *
79
 *
50
 * Revision 1.5  1996/02/14  17:19:20  wfs
80
 * Revision 1.5  1996/02/14  17:19:20  wfs
51
 * "next_caller_offset" and "next_callee_offset" have become special tokens
81
 * "next_caller_offset" and "next_callee_offset" have become special tokens
Line 97... Line 127...
97
 * Revision 3.4  1995/08/25  10:19:50  wfs
127
 * Revision 3.4  1995/08/25  10:19:50  wfs
98
 * Register synonyms changed
128
 * Register synonyms changed
99
 *
129
 *
100
 * Revision 3.1  95/04/10  16:27:38  16:27:38  wfs (William Simmonds)
130
 * Revision 3.1  95/04/10  16:27:38  16:27:38  wfs (William Simmonds)
101
 * Apr95 tape version.
131
 * Apr95 tape version.
102
 * 
132
 *
103
 * Revision 3.0  95/03/30  11:18:31  11:18:31  wfs (William Simmonds)
133
 * Revision 3.0  95/03/30  11:18:31  11:18:31  wfs (William Simmonds)
104
 * Mar95 tape version with CRCR95_178 bug fix.
134
 * Mar95 tape version with CRCR95_178 bug fix.
105
 * 
135
 *
106
 * Revision 2.0  95/03/15  15:28:22  15:28:22  wfs (William Simmonds)
136
 * Revision 2.0  95/03/15  15:28:22  15:28:22  wfs (William Simmonds)
107
 * spec 3.1 changes implemented, tests outstanding.
137
 * spec 3.1 changes implemented, tests outstanding.
108
 * 
138
 *
109
 * Revision 1.7  95/02/10  11:41:20  11:41:20  wfs (William Simmonds)
139
 * Revision 1.7  95/02/10  11:41:20  11:41:20  wfs (William Simmonds)
110
 * Removed call to evaluated() - initialising expressions are now
140
 * Removed call to evaluated() - initialising expressions are now
111
 * stored in a linked list and written to outf after the procedure
141
 * stored in a linked list and written to outf after the procedure
112
 * body has been translated (c.f. translate_capsule).
142
 * body has been translated (c.f. translate_capsule).
113
 * 
143
 *
114
 * Revision 1.6  95/01/25  13:37:44  13:37:44  wfs (William Simmonds)
144
 * Revision 1.6  95/01/25  13:37:44  13:37:44  wfs (William Simmonds)
115
 * Refined error_jump of float plus, minus, mult, div.
145
 * Refined error_jump of float plus, minus, mult, div.
116
 * 
146
 *
117
 * Revision 1.5  95/01/25  10:31:56  10:31:56  wfs (William Simmonds)
147
 * Revision 1.5  95/01/25  10:31:56  10:31:56  wfs (William Simmonds)
118
 * First attempt at installing error_jump in the float plus, minus, mult
148
 * First attempt at installing error_jump in the float plus, minus, mult
119
 * and div tags.
149
 * and div tags.
120
 * 
150
 *
121
 * Revision 1.4  95/01/23  18:58:04  18:58:04  wfs (William Simmonds)
151
 * Revision 1.4  95/01/23  18:58:04  18:58:04  wfs (William Simmonds)
122
 * Cosmetic changes to do_comm and non_comm_op.
152
 * Cosmetic changes to do_comm and non_comm_op.
123
 * 
153
 *
124
 * Revision 1.3  95/01/17  17:30:00  17:30:00  wfs (William Simmonds)
154
 * Revision 1.3  95/01/17  17:30:00  17:30:00  wfs (William Simmonds)
125
 * Changed name of an included header file.
155
 * Changed name of an included header file.
126
 * 
156
 *
127
 * Revision 1.2  95/01/12  11:27:16  11:27:16  wfs (William Simmonds)
157
 * Revision 1.2  95/01/12  11:27:16  11:27:16  wfs (William Simmonds)
128
 * Corrected bug in `logical_op' which was causing hppatrans
158
 * Corrected bug in `logical_op' which was causing hppatrans
129
 * to fail to bootstrap.
159
 * to fail to bootstrap.
130
 * 
160
 *
131
 * Revision 1.1  95/01/11  13:14:24  13:14:24  wfs (William Simmonds)
161
 * Revision 1.1  95/01/11  13:14:24  13:14:24  wfs (William Simmonds)
132
 * Initial revision
162
 * Initial revision
133
 * 
163
 *
134
*/
164
*/
135
 
165
 
136
 
166
 
137
#define HPPATRANS_CODE
167
#define HPPATRANS_CODE
138
#include "config.h"
168
#include "config.h"
Line 151... Line 181...
151
#include "myassert.h"
181
#include "myassert.h"
152
#include "labels.h"
182
#include "labels.h"
153
#include "frames.h"
183
#include "frames.h"
154
#include "oprators.h"
184
#include "oprators.h"
155
 
185
 
156
#define isdbl(e) ( ( bool ) ( name ( e ) != shrealhd ) )
186
#define isdbl(e)((bool)(name(e)!= shrealhd))
157
 
187
 
158
 
188
 
159
#if use_long_double
189
#if use_long_double
160
#include "externs.h"
190
#include "externs.h"
161
#include "install_fns.h"
191
#include "install_fns.h"
Line 168... Line 198...
168
#include "proc.h"
198
#include "proc.h"
169
#include "basicread.h"
199
#include "basicread.h"
170
#include "inst_fmt.h"
200
#include "inst_fmt.h"
171
#endif
201
#endif
172
 
202
 
173
extern long trap_label PROTO_S ((exp));
203
extern long trap_label(exp);
174
extern void trap_handler PROTO_S ((baseoff,int,int));
204
extern void trap_handler(baseoff,int,int);
175
extern baseoff zero_exception_register PROTO_S ((space));
205
extern baseoff zero_exception_register(space);
176
extern labexp current,first;
206
extern labexp current,first;
177
 
207
 
178
 
208
 
179
int long_double_0 = 0;
209
int long_double_0 = 0;
180
 
210
 
181
/* corrects possible overflows of chars and shorts in reg r */
211
/* corrects possible overflows of chars and shorts in reg r */
182
void tidyshort 
212
void tidyshort
183
    PROTO_N ( ( r, s ) )
-
 
184
    PROTO_T ( int r X shape s )
213
(int r, shape s)
185
{
214
{
186
  if (name(s) == ucharhd)
215
  if (name(s) == ucharhd)
187
     riir_ins(i_dep,c_,0,23,24,r);
216
     riir_ins(i_dep,c_,0,23,24,r);
188
  else if (name(s) == uwordhd)
217
  else if (name(s) == uwordhd)
189
     riir_ins(i_dep,c_,0,15,16,r);
218
     riir_ins(i_dep,c_,0,15,16,r);
Line 193... Line 222...
193
 /*
222
 /*
194
  * given a list of expressions seq which contains one whose value is in
223
  * given a list of expressions seq which contains one whose value is in
195
  * register reg, removes that exp from seq and delivers 1; otherwise delivers
224
  * register reg, removes that exp from seq and delivers 1; otherwise delivers
196
  * 0
225
  * 0
197
  */
226
  */
198
bool regremoved 
227
bool regremoved
199
    PROTO_N ( ( seq, reg ) )
-
 
200
    PROTO_T ( exp * seq X int reg )
228
(exp * seq, int reg)
201
{
229
{
202
  exp s = *seq;
230
  exp s = *seq;
203
  exp t = bro(s);
231
  exp t = bro(s);
204
 
232
 
205
  if (ABS_OF(regofval(s)) == reg)
233
  if (ABS_OF(regofval(s)) == reg)
206
  {
234
  {
207
    (*seq) = t;
235
   (*seq) = t;
208
    return 1;
236
    return 1;
209
  }
237
  }
210
  for (;;)
238
  for (;;)
211
  {
239
  {
212
    if (ABS_OF(regofval(t)) == reg)
240
    if (ABS_OF(regofval(t)) == reg)
Line 229... Line 257...
229
 
257
 
230
/*
258
/*
231
 *   logical operation, lop, with operands immediate, i, and register, r
259
 *   logical operation, lop, with operands immediate, i, and register, r
232
 */
260
 */
233
void logical_op
261
void logical_op
234
    PROTO_N ( (lop,i,r,d) )
-
 
235
    PROTO_T ( CONST char *lop X long i X int r X int d )
262
(CONST char *lop, long i, int r, int d)
236
{
263
{
237
   int t;
264
   int t;
238
   if (r==d)
265
   if (r==d)
239
      t=GR1; 
266
      t=GR1;
240
   else
267
   else
241
      t=d;
268
      t=d;
242
   if (lop==i_and && i==-1)
269
   if (lop==i_and && i==-1)
243
   {
270
   {
244
      if (r!=d)
271
      if (r!=d)
245
	 rr_ins(i_copy,r,d);
272
	 rr_ins(i_copy,r,d);
246
      return;
273
      return;
247
   }
274
   }
248
   else if ( lop==i_and && IS_POW2((i+1)))
275
   else if (lop==i_and && IS_POW2((i+1)))
249
   {
276
   {
250
      int p=0;
277
      int p=0;
251
      while ( i & (1<<p) ) p++;
278
      while (i & (1<<p))p++;
252
      if (r==d)
279
      if (r==d)
253
	 iiir_ins(i_depi,c_,0,31-p,32-p,d);
280
	 iiir_ins(i_depi,c_,0,31-p,32-p,d);
254
      else
281
      else
255
	 riir_ins(i_extru,c_,r,31,p,d);
282
	 riir_ins(i_extru,c_,r,31,p,d);
256
      return;
283
      return;
257
   }
284
   }
258
   else if ( lop==i_and && IS_POW2((-i)) )
285
   else if (lop==i_and && IS_POW2((-i)))
259
   {
286
   {
260
      int p=0;
287
      int p=0;
261
      while ( (i & (1<<p))==0 ) p++;
288
      while ((i & (1<<p)) ==0)p++;
262
      if (r!=d)
289
      if (r!=d)
263
	 rr_ins(i_copy,r,d);
290
	 rr_ins(i_copy,r,d);
264
      iiir_ins(i_depi,c_,0,31,p,d);
291
      iiir_ins(i_depi,c_,0,31,p,d);
265
      return;
292
      return;
266
   }
293
   }
267
   else if ( lop==i_or )
294
   else if (lop==i_or)
268
   {
295
   {
269
      if (r==0)
296
      if (r==0)
270
      {
297
      {
271
	 imm_to_r(i,d);
298
	 imm_to_r(i,d);
272
	 return;
299
	 return;
273
      }
300
      }
274
      else 
301
      else
275
      if (i==-1)
302
      if (i==-1)
276
      {
303
      {
277
	 ir_ins(i_ldi,fs_,"",-1,d);
304
	 ir_ins(i_ldi,fs_,"",-1,d);
278
	 return;
305
	 return;
279
      }
306
      }
280
      else
307
      else
281
      {
308
      {
282
	 int j=0;
309
	 int j=0;
283
	 unsigned int p=i;
310
	 unsigned int p=i;
284
	 while ( (p & (1<<j))==0 ) j++;
311
	 while ((p & (1<<j)) ==0)j++;
285
	 p=p>>j;
312
	 p=p>>j;
286
	 if (((p+1)&p)==0)
313
	 if (((p+1) &p) ==0)
287
	 {
314
	 {
288
	    int k=0;
315
	    int k=0;
289
	    while ( p & (1<<k) ) k++;
316
	    while (p & (1<<k))k++;
290
	    if (r!=d)
317
	    if (r!=d)
291
	       rr_ins(i_copy,r,d);
318
	       rr_ins(i_copy,r,d);
292
	    iiir_ins(i_depi,c_,-1,31-j,k,d);
319
	    iiir_ins(i_depi,c_,-1,31-j,k,d);
293
	    return;
320
	    return;
294
	 }
321
	 }
Line 304... Line 331...
304
   {
331
   {
305
      ir_ins(i_ldi,fs_,"",~i,t);
332
      ir_ins(i_ldi,fs_,"",~i,t);
306
      rrr_ins(i_andcm,c_,r,t,d);
333
      rrr_ins(i_andcm,c_,r,t,d);
307
   }
334
   }
308
   else
335
   else
309
   if ( ((i&(i+1))==0) && lop==i_and)
336
   if (((i& (i+1)) ==0) && lop==i_and)
310
   {
337
   {
311
       unsigned long ui = i;
338
       unsigned long ui = i;
312
       int nbits=0;
339
       int nbits=0;
313
       while (ui != 0)
340
       while (ui != 0)
314
       {
341
       {
Line 328... Line 355...
328
 
355
 
329
 /*
356
 /*
330
  * evaluates the fixed operation seq1 rins seq 2 rins...., into reg final,
357
  * evaluates the fixed operation seq1 rins seq 2 rins...., into reg final,
331
  * using sp as free t-regs
358
  * using sp as free t-regs
332
  */
359
  */
333
void do_comm 
360
void do_comm
334
    PROTO_N ( ( seq, sp, final, rins ) )
-
 
335
    PROTO_T ( exp seq X space sp X int final X ins_p rins )
361
(exp seq, space sp, int final, ins_p rins)
336
{
362
{
337
  int r = 0;
363
  int r = 0;
338
  space nsp;
364
  space nsp;
339
  int a1;
365
  int a1;
340
  int a2;
366
  int a2;
341
  exp next = bro(seq);
367
  exp next = bro(seq);
342
 
368
 
343
  if ( name(seq)==not_tag &&
369
  if (name(seq) ==not_tag &&
344
       last(next) &&
370
       last(next) &&
345
       rins==i_and &&
371
       rins==i_and &&
346
       name(next)!=val_tag )
372
       name(next)!=val_tag)
347
  {
373
  {
348
     a1=reg_operand(son(seq), sp);
374
     a1=reg_operand(son(seq), sp);
349
     nsp = guardreg(a1, sp);
375
     nsp = guardreg(a1, sp);
350
     a2=reg_operand(next, nsp);
376
     a2=reg_operand(next, nsp);
351
     rrr_ins(i_andcm,c_,a2,a1,final);
377
     rrr_ins(i_andcm,c_,a2,a1,final);
352
     return;
378
     return;
353
  }
379
  }
354
 
380
 
355
  if ( name(next)==not_tag &&
381
  if (name(next) ==not_tag &&
356
      last(next) && 
382
      last(next) &&
357
      rins==i_and &&
383
      rins==i_and &&
358
      name(seq)!=val_tag )
384
      name(seq)!=val_tag)
359
  {
385
  {
360
     a1=reg_operand(seq, sp);
386
     a1=reg_operand(seq, sp);
361
     nsp = guardreg(a1, sp);
387
     nsp = guardreg(a1, sp);
362
     a2=reg_operand(son(next), nsp);
388
     a2=reg_operand(son(next), nsp);
363
     rrr_ins(i_andcm,c_,a1,a2,final);
389
     rrr_ins(i_andcm,c_,a1,a2,final);
364
     return;
390
     return;
365
  }
391
  }
366
 
392
 
367
  if ( name(next)==val_tag &&
393
  if (name(next) ==val_tag &&
368
       last(next) &&
394
       last(next) &&
369
       rins==i_and &&
395
       rins==i_and &&
370
       name(seq)==shr_tag )
396
       name(seq) ==shr_tag)
371
  {
397
  {
372
     exp shift=bro(son(seq));
398
     exp shift=bro(son(seq));
373
     if (name(shift)==val_tag)
399
     if (name(shift) ==val_tag)
374
     { 
400
     {
375
	int n,s;
401
	int n,s;
376
	n=no(next);
402
	n=no(next);
377
	s=no(shift);
403
	s=no(shift);
378
	if ( IS_POW2((n+1)) )
404
	if (IS_POW2((n+1)))
379
	{
405
	{
380
	   int p=0;
406
	   int p=0;
381
	   a1=reg_operand(son(seq), sp);
407
	   a1=reg_operand(son(seq), sp);
382
	   while ( n & (1<<p) ) p++;
408
	   while (n & (1<<p))p++;
383
	   if ( p > (32-s) )
409
	   if (p > (32-s))
384
	      p = 32-s;
410
	      p = 32-s;
385
	   riir_ins(i_extru,c_,a1,31-s,p,final);
411
	   riir_ins(i_extru,c_,a1,31-s,p,final);
386
	   return;
412
	   return;
387
	}
413
	}
388
     }
414
     }
389
  }
415
  }
390
 
416
 
391
 
417
 
392
  /* evaluate 1st operand into a1 */
418
  /* evaluate 1st operand into a1 */
393
  
419
 
394
  if ( name(seq)==cont_tag && name(bro(seq))==val_tag && last(bro(seq))
420
  if (name(seq) ==cont_tag && name(bro(seq)) ==val_tag && last(bro(seq))
395
       && !(props(son(seq)) & inreg_bits) )
421
       && !(props(son(seq)) & inreg_bits))
396
  {
422
  {
397
     reg_operand_here(seq, sp, final);
423
     reg_operand_here(seq, sp, final);
398
     a1 = final;
424
     a1 = final;
399
  }
425
  }
400
  else
426
  else
401
     a1 = reg_operand(seq, sp);
427
     a1 = reg_operand(seq, sp);
402
 
428
 
403
  if ( name(father(seq))==make_stack_limit_tag )
429
  if (name(father(seq)) ==make_stack_limit_tag)
404
  {
430
  {
405
     baseoff b;
431
     baseoff b;
406
     b.offset = FP_BOFF.offset;
432
     b.offset = FP_BOFF.offset;
407
     b.base = a1;
433
     b.base = a1;
408
     ld_ins(i_lw,0,b,b.base);
434
     ld_ins(i_lw,0,b,b.base);
Line 423... Line 449...
423
	      ld_ir_ins(i_ldo,cmplt_,fs_,empty_ltrl,n,a1,final);
449
	      ld_ir_ins(i_ldo,cmplt_,fs_,empty_ltrl,n,a1,final);
424
	   else
450
	   else
425
	   {
451
	   {
426
	      ir_ins(i_addil,fs_L,empty_ltrl,n,a1);
452
	      ir_ins(i_addil,fs_L,empty_ltrl,n,a1);
427
	      ld_ir_ins(i_ldo,cmplt_,fs_R,empty_ltrl,n,GR1,final);
453
	      ld_ir_ins(i_ldo,cmplt_,fs_R,empty_ltrl,n,GR1,final);
428
	   }
454
	   }
429
	}
455
	}
430
	else
456
	else
431
	   logical_op(rins,n,a1,final);
457
	   logical_op(rins,n,a1,final);
432
	return;
458
	return;
433
      }
459
      }
Line 473... Line 499...
473
}
499
}
474
 
500
 
475
 
501
 
476
 
502
 
477
/* evaluate commutative operation rrins given by e into d, using sp to get t-regs */
503
/* evaluate commutative operation rrins given by e into d, using sp to get t-regs */
478
int comm_op 
504
int comm_op
479
    PROTO_N ( ( e, sp, d, rrins ) )
-
 
480
    PROTO_T ( exp e X space sp X where d X ins_p rrins )
505
(exp e, space sp, where d, ins_p rrins)
481
{
506
{
482
  CONST char *rins = rrins;
507
  CONST char *rins = rrins;
483
 
508
 
484
  switch (discrim ( d.answhere ))
509
  switch (discrim(d.answhere))
485
  {
510
  {
486
  case inreg:
511
  case inreg:
487
    {
512
    {
488
      int dest = regalt(d.answhere);
513
      int dest = regalt(d.answhere);
489
      bool usesdest = regremoved(&son(e), dest);
514
      bool usesdest = regremoved(&son(e), dest);
Line 494... Line 519...
494
       * before possible use as an operand ....
519
       * before possible use as an operand ....
495
       */
520
       */
496
      if (usesdest && last(seq))
521
      if (usesdest && last(seq))
497
      {
522
      {
498
	/* used, but there is only one other operand */
523
	/* used, but there is only one other operand */
499
	if (name(seq)==val_tag)
524
	if (name(seq) ==val_tag)
500
	{
525
	{
501
	   int n = no(seq);
526
	   int n = no(seq);
502
	   if (rrins==i_add)
527
	   if (rrins==i_add)
503
	   {
528
	   {
504
	      if (SIMM14(n))
529
	      if (SIMM14(n))
Line 545... Line 570...
545
      space nsp;
570
      space nsp;
546
      bool rok = 1;
571
      bool rok = 1;
547
      setregalt(a, r);
572
      setregalt(a, r);
548
      do_comm(son(e), sp, r, rins);
573
      do_comm(son(e), sp, r, rins);
549
      /* evaluate the expression into r ... */
574
      /* evaluate the expression into r ... */
550
      if (discrim(d.answhere) != notinreg)
575
      if (discrim(d.answhere)!= notinreg)
551
      {
576
      {
552
	 if (optop(e))
577
	 if (optop(e))
553
	    tidyshort(r, sh(e));
578
	    tidyshort(r, sh(e));
554
      }
579
      }
555
      else
580
      else
556
	 rok = shape_size(sh(e))==32;
581
	 rok = shape_size(sh(e)) ==32;
557
      nsp = guardreg(r, sp);
582
      nsp = guardreg(r, sp);
558
      move(a, d, nsp.fixed, 1);
583
      move(a, d, nsp.fixed, 1);
559
      /* ... and move into a */
584
      /* ... and move into a */
560
      return ((rok)?r:NOREG);
585
      return((rok)?r:NOREG);
561
    }				/* notinreg */
586
    }				/* notinreg */
562
  }				/* end switch */
587
  }				/* end switch */
563
}
588
}
564
 
589
 
565
 
590
 
566
 
591
 
567
int non_comm_op 
592
int non_comm_op
568
    PROTO_N ( ( e, sp, dest, rins ) )
-
 
569
    PROTO_T ( exp e X space sp X where dest X ins_p rins )
593
(exp e, space sp, where dest, ins_p rins)
570
 /* evalate binary operation e with rins into dest */
594
 /* evalate binary operation e with rins into dest */
571
{
595
{
572
   exp l = son(e);
596
   exp l = son(e);
573
   exp r = bro(l);
597
   exp r = bro(l);
574
   int a1 = reg_operand(l, sp);
598
   int a1 = reg_operand(l, sp);
Line 576... Line 600...
576
   int a2;
600
   int a2;
577
   CONST char *ins;
601
   CONST char *ins;
578
   ins=rins;
602
   ins=rins;
579
   nsp = guardreg(a1, sp);
603
   nsp = guardreg(a1, sp);
580
   a2 = reg_operand(r, nsp);
604
   a2 = reg_operand(r, nsp);
581
   if (discrim( dest.answhere )==inreg)
605
   if (discrim(dest.answhere) ==inreg)
582
   {
606
   {
583
      int d = regalt(dest.answhere);
607
      int d = regalt(dest.answhere);
584
      rrr_ins(ins,c_,a1,a2,d);
608
      rrr_ins(ins,c_,a1,a2,d);
585
      if (optop(e))
609
      if (optop(e))
586
	 tidyshort(d, sh(e));
610
	 tidyshort(d, sh(e));
587
      return d;
611
      return d;
Line 591... Line 615...
591
      /* destination elsewhere */
615
      /* destination elsewhere */
592
      ans a;
616
      ans a;
593
      int r1 = getreg(nsp.fixed);
617
      int r1 = getreg(nsp.fixed);
594
      setregalt(a, r1);
618
      setregalt(a, r1);
595
      rrr_ins(ins,c_,a1,a2,r1);
619
      rrr_ins(ins,c_,a1,a2,r1);
596
      if (optop(e))
620
      if (optop(e))
597
	 tidyshort(r1, sh(e));
621
	 tidyshort(r1, sh(e));
598
      nsp = guardreg(r1, sp);
622
      nsp = guardreg(r1, sp);
599
      move(a, dest, nsp.fixed, 1);
623
      move(a, dest, nsp.fixed, 1);
600
      return r1;
624
      return r1;
601
   }
625
   }
602
}
626
}
603
 
627
 
604
int monop 
628
int monop
605
    PROTO_N ( ( e, sp, dest, ins ) )
-
 
606
    PROTO_T ( exp e X space sp X where dest X ins_p ins )
629
(exp e, space sp, where dest, ins_p ins)
607
 /* evaluate fixed monadic operation e using ins into dest */
630
 /* evaluate fixed monadic operation e using ins into dest */
608
{
631
{
609
   int r1 = getreg(sp.fixed);
632
   int r1 = getreg(sp.fixed);
610
   int a1 = reg_operand(son(e), sp);
633
   int a1 = reg_operand(son(e), sp);
611
 
634
 
612
   /* operand in reg a1 */
635
   /* operand in reg a1 */
613
   space nsp;
636
   space nsp;
614
 
637
 
615
   if ( discrim(dest.answhere) == inreg )
638
   if (discrim(dest.answhere) == inreg)
616
   {
639
   {
617
      /* destination in register */
640
      /* destination in register */
618
      int d = regalt(dest.answhere);
641
      int d = regalt(dest.answhere);
619
      if (ins==i_subi)
642
      if (ins==i_subi)
620
	 rrr_ins(i_sub,c_,0,a1,d);
643
	 rrr_ins(i_sub,c_,0,a1,d);
621
      else
644
      else
622
      if (ins==i_sub)
645
      if (ins==i_sub)
623
	 rrr_ins(i_sub,c_,0,a1,d);
646
	 rrr_ins(i_sub,c_,0,a1,d);
624
      else
647
      else
625
	 rrr_ins(i_uaddcm,c_,0,a1,d);
648
	 rrr_ins(i_uaddcm,c_,0,a1,d);
626
      if (optop(e))
649
      if (optop(e))
627
	 tidyshort(d,sh(e));
650
	 tidyshort(d,sh(e));
628
      return d;
651
      return d;
629
   }
652
   }
630
   else
653
   else
631
   {
654
   {
632
      /* destination elsewhere */
655
      /* destination elsewhere */
633
      ans a;
656
      ans a;
634
      setregalt(a, r1);
657
      setregalt(a, r1);
Line 650... Line 673...
650
 
673
 
651
#if use_long_double
674
#if use_long_double
652
 
675
 
653
/*
676
/*
654
    GET THE ADDRESS OF A LONG DOUBLE
677
    GET THE ADDRESS OF A LONG DOUBLE
655
*/
678
*/
656
static void quad_addr
679
static void quad_addr
657
    PROTO_N ( (e,r,sp) )
-
 
658
    PROTO_T ( exp e X int r X space sp )
680
(exp e, int r, space sp)
659
{
681
{
660
    instore is ;
682
    instore is;
661
    if (name(e)==real_tag)
683
    if (name(e) ==real_tag)
662
    {
684
    {
663
	labexp next;
685
	labexp next;
664
	next  = (labexp) malloc( sizeof(struct labexp_t) );
686
	next  = (labexp)malloc(sizeof(struct labexp_t));
665
	next->e = e;
687
	next->e = e;
666
	next->lab = next_data_lab();
688
	next->lab = next_data_lab();
667
	next->next = (labexp) 0;
689
	next->next = (labexp)0;
668
	current->next = next;
690
	current->next = next;
669
	current = next;
691
	current = next;
670
	is.adval = 0;
692
	is.adval = 0;
671
	is.b.offset = 0;
693
	is.b.offset = 0;
672
	is.b.base = next->lab;
694
	is.b.base = next->lab;
673
    }
695
    }
674
    else
696
    else
675
    {
697
    {
676
       where w ;
698
       where w;
677
       w=locate1(e,sp,sh(e),0) ;
699
       w=locate1(e,sp,sh(e),0);
678
       if (discrim(w.answhere)!=notinreg) 
700
       if (discrim(w.answhere)!=notinreg)
679
	  failer ("Illegal expression in quad_addr");
701
	  failer("Illegal expression in quad_addr");
680
       is=insalt(w.answhere) ;
702
       is=insalt(w.answhere);
681
    }
703
    }
682
    if (is.adval)
704
    if (is.adval)
683
    {
705
    {
684
	failer("Illegal expression in quad_addr") ;
706
	failer("Illegal expression in quad_addr");
685
    }
707
    }
686
    if (IS_FIXREG(is.b.base))
708
    if (IS_FIXREG(is.b.base))
687
    {
709
    {
688
       if (is.b.offset==0)
710
       if (is.b.offset==0)
689
       {
711
       {
690
	  if (is.b.base!=r)
712
	  if (is.b.base!=r)
691
	     rr_ins(i_copy,is.b.base,r) ;
713
	     rr_ins(i_copy,is.b.base,r);
692
       }
714
       }
693
       else
715
       else
694
	  ld_ins(i_lo,1,is.b,r) ;
716
	  ld_ins(i_lo,1,is.b,r);
695
    }
717
    }
696
    else
718
    else
697
       set_ins("",is.b,r) ;
719
       set_ins("",is.b,r);
698
    return ;
720
    return;
699
}
721
}
700
 
722
 
701
 
723
 
702
/*
724
/*
703
    LONG DOUBLE LIBRARY
725
    LONG DOUBLE LIBRARY
704
*/
726
*/
705
 
727
 
706
static struct {
728
static struct {
707
		  CONST char proc_name[32] ;
729
		  CONST char proc_name[32];
708
		  bool called ;
730
		  bool called;
709
	      } long_double_lib [ 14 ] =
731
	      } long_double_lib[14] =
710
	      {
732
	      {
711
		  { "_U_Qfcmp", 0 },
733
		  { "_U_Qfcmp", 0 },
712
		  { "_U_Qfadd", 0 },
734
		  { "_U_Qfadd", 0 },
713
		  { "_U_Qfsub", 0 },
735
		  { "_U_Qfsub", 0 },
714
		  { "_U_Qfmpy", 0 },
736
		  { "_U_Qfmpy", 0 },
Line 720... Line 742...
720
		  { "_U_Qfcnvff_quad_to_dbl", 0 },
742
		  { "_U_Qfcnvff_quad_to_dbl", 0 },
721
		  { "_U_Qfcnvff_quad_to_sgl", 0 },
743
		  { "_U_Qfcnvff_quad_to_sgl", 0 },
722
		  { "_U_Qfabs", 0 },
744
		  { "_U_Qfabs", 0 },
723
		  { "_U_Qfcnvfxt_quad_to_sgl", 0 },
745
		  { "_U_Qfcnvfxt_quad_to_sgl", 0 },
724
		  { "_U_Qfrnd", 0 }
746
		  { "_U_Qfrnd", 0 }
725
	      } ;
747
	      };
726
 
748
 
727
 
749
 
728
void import_long_double_lib
750
void import_long_double_lib
729
    PROTO_Z ()
751
(void)
730
{
752
{
731
   int n;
753
   int n;
732
   for(n=0; n<14; n++)
754
   for (n=0; n<14; n++)
733
      if ( long_double_lib[n].called )
755
      if (long_double_lib[n].called)
734
	 fprintf(outf,"\t.IMPORT\t%s,CODE\n",long_double_lib[n].proc_name);
756
	 fprintf(outf,"\t.IMPORT\t%s,CODE\n",long_double_lib[n].proc_name);
735
   if (long_double_0)
757
   if (long_double_0)
736
   {
758
   {
737
      outnl();
759
      outnl();
738
      outs("\t.DATA\n");
760
      outs("\t.DATA\n");
Line 746... Line 768...
746
 
768
 
747
/*
769
/*
748
    DO A QUAD FLOAT OPERATION
770
    DO A QUAD FLOAT OPERATION
749
*/
771
*/
750
void quad_op
772
void quad_op
751
    PROTO_N ( ( e, sp, dest ) )
-
 
752
    PROTO_T ( exp e X space sp X where dest )
773
(exp e, space sp, where dest)
753
{
774
{
754
   char *s=0,*stub=0;
775
   char *s=0,*stub=0;
755
   bool quad_ret = 1 ;
776
   bool quad_ret = 1;
756
 
777
 
757
   switch ( name(e) )
778
   switch (name(e))
758
   {
779
   {
759
      case test_tag:
780
      case test_tag:
760
      {
781
      {
761
	 /* Quad comparisons */
782
	 /* Quad comparisons */
762
	 exp l,r;
783
	 exp l,r;
763
	 int tn;
784
	 int tn;
764
	 quad_ret = 0 ;
785
	 quad_ret = 0;
765
	 s = "_U_Qfcmp";
786
	 s = "_U_Qfcmp";
766
	 stub = "ARGW0=GR,ARGW1=GR,ARGW2=GR";
787
	 stub = "ARGW0=GR,ARGW1=GR,ARGW2=GR";
767
	 long_double_lib[0].called=1;
788
	 long_double_lib[0].called=1;
768
	 sp = guardreg(ARG2,sp);
789
	 sp = guardreg(ARG2,sp);
769
	 tn = (int)test_number(e);
790
	 tn = (int)test_number(e);
770
	 if ( tn < 1 || tn > 6 )
791
	 if (tn < 1 || tn > 6)
771
	 {
792
	 {
772
	    fail ( "Illegal floating-point test" ) ;
793
	    fail("Illegal floating-point test");
773
	 }
794
	 }
774
	 ir_ins(i_ldi, fs_, empty_ltrl, tn==1 ? 17 : tn==2 ? 21 : tn==3 ? 9 : tn==4 ? 13 : tn==5 ? 4 : 25,               ARG2);
795
	 ir_ins(i_ldi, fs_, empty_ltrl, tn==1 ? 17 : tn==2 ? 21 : tn==3 ? 9 : tn==4 ? 13 : tn==5 ? 4 : 25,               ARG2);
775
	 if ( IsRev(e) )
796
	 if (IsRev(e))
776
	 {
797
	 {
777
	    r = son(e);
798
	    r = son(e);
778
	    l = bro(r);
799
	    l = bro(r);
779
	 }
800
	 }
780
	 else
801
	 else
781
	 {
802
	 {
782
	    l = son(e);
803
	    l = son(e);
783
	    r = bro(l);
804
	    r = bro(l);
784
	 }
805
	 }
785
	 quad_addr(l,ARG0,sp) ;
806
	 quad_addr(l,ARG0,sp);
786
	 sp = guardreg(ARG0,sp) ;
807
	 sp = guardreg(ARG0,sp);
787
	 quad_addr(r,ARG1,sp) ;
808
	 quad_addr(r,ARG1,sp);
788
	 break;
809
	 break;
789
      }
810
      }
790
      case fneg_tag : 
811
      case fneg_tag:
791
      {
812
      {
792
	 baseoff b;
813
	 baseoff b;
793
	 b.base=0; b.offset=0;
814
	 b.base=0; b.offset=0;
794
	 s = "_U_Qfsub" ;
815
	 s = "_U_Qfsub";
795
	 long_double_lib[2].called=1;
816
	 long_double_lib[2].called=1;
796
	 set_ins("$qfp_lit_sym$",b,ARG0);
817
	 set_ins("$qfp_lit_sym$",b,ARG0);
797
	 sp = guardreg(ARG0,sp);
818
	 sp = guardreg(ARG0,sp);
798
	 quad_addr(son(e),ARG1,sp) ;
819
	 quad_addr(son(e),ARG1,sp);
799
	 sp = guardreg(ARG1,sp);
820
	 sp = guardreg(ARG1,sp);
800
	 stub = "ARGW0=GR,ARGW1=GR";
821
	 stub = "ARGW0=GR,ARGW1=GR";
801
	 long_double_0 = 1;
822
	 long_double_0 = 1;
802
	 break ;
823
	 break;
803
      }
824
      }
804
      case fabs_tag :
825
      case fabs_tag:
805
      {
826
      {
806
	 s = "_U_Qfabs" ;
827
	 s = "_U_Qfabs";
807
	 long_double_lib[11].called=1;
828
	 long_double_lib[11].called=1;
808
	 stub = "ARGW0=GR";
829
	 stub = "ARGW0=GR";
809
	 quad_addr(son(e),ARG0,sp) ;
830
	 quad_addr(son(e),ARG0,sp);
810
	 break ;
831
	 break;
811
      }
832
      }
812
      case chfl_tag :
833
      case chfl_tag:
813
      {
834
      {
814
 	 ans aa ;
835
 	 ans aa;
815
	 where w ;
836
	 where w;
816
	 freg frg ;
837
	 freg frg;
817
	 exp l;
838
	 exp l;
818
	 if ( name(sh(e)) == doublehd )
839
	 if (name(sh(e)) == doublehd)
819
	 {
840
	 {
820
	    baseoff b;
841
	    baseoff b;
821
	    b.base=SP;
842
	    b.base=SP;
822
	    l = son(e);
843
	    l = son(e);
823
	    if ( name(sh(l)) == doublehd )
844
	    if (name(sh(l)) == doublehd)
824
	       return;
845
	       return;
825
	    else 
846
	    else
826
	    if  (name(sh(l))==realhd)
847
	    if (name(sh(l)) ==realhd)
827
	    {
848
	    {
828
	       s = "_U_Qfcnvff_dbl_to_quad" ;
849
	       s = "_U_Qfcnvff_dbl_to_quad";
829
	       long_double_lib[5].called=1;
850
	       long_double_lib[5].called=1;
830
	       frg.dble=1;
851
	       frg.dble=1;
831
	       frg.fr=5;
852
	       frg.fr=5;
832
	       stub = "ARGW0=FR,ARGW1=FU";
853
	       stub = "ARGW0=FR,ARGW1=FU";
833
	    }
854
	    }
834
	    else
855
	    else
835
	    {
856
	    {
836
	       s = "_U_Qfcnvff_sgl_to_quad" ;
857
	       s = "_U_Qfcnvff_sgl_to_quad";
837
	       long_double_lib[6].called=1;
858
	       long_double_lib[6].called=1;
838
	       frg.dble=0;
859
	       frg.dble=0;
839
	       frg.fr=4;
860
	       frg.fr=4;
840
	       stub = "ARGW0=FR";
861
	       stub = "ARGW0=FR";
841
	    }
862
	    }
842
	    setfregalt ( aa, frg ) ;
863
	    setfregalt(aa, frg);
843
	    w.answhere = aa ;
864
	    w.answhere = aa;
844
	    w.ashwhere = ashof (sh(l)) ;
865
	    w.ashwhere = ashof(sh(l));
845
	    code_here(l,sp,w);
866
	    code_here(l,sp,w);
846
	    if (frg.dble)
867
	    if (frg.dble)
847
	    {
868
	    {
848
	       b.offset=-40;
869
	       b.offset=-40;
849
	       stf_ins(i_fstd,(5*3)+1,b);
870
	       stf_ins(i_fstd,(5*3) +1,b);
850
	       ld_ins(i_ldw,1,b,ARG1);
871
	       ld_ins(i_ldw,1,b,ARG1);
851
	       b.offset+=4;
872
	       b.offset+=4;
852
	       ld_ins(i_ldw,1,b,ARG0);
873
	       ld_ins(i_ldw,1,b,ARG0);
853
	    }
874
	    }
854
	    else
875
	    else
855
	    {
876
	    {
856
	       b.offset=-36;
877
	       b.offset=-36;
857
	       stf_ins(i_fstw,(4*3)+0,b);
878
	       stf_ins(i_fstw,(4*3) +0,b);
858
	       ld_ins(i_ldw,1,b,ARG0);
879
	       ld_ins(i_ldw,1,b,ARG0);
859
	    }
880
	    }
860
	 }
881
	 }
861
	 else
882
	 else
862
	 {
883
	 {
863
	    if ( isdbl(sh(e)) )
884
	    if (isdbl(sh(e)))
864
	    {
885
	    {
865
	       s = "_U_Qfcnvff_quad_to_dbl";
886
	       s = "_U_Qfcnvff_quad_to_dbl";
866
	       long_double_lib[9].called=1;
887
	       long_double_lib[9].called=1;
867
	    }
888
	    }
868
	    else
889
	    else
Line 870... Line 891...
870
	       s = "_U_Qfcnvff_quad_to_sgl";
891
	       s = "_U_Qfcnvff_quad_to_sgl";
871
	       long_double_lib[10].called=1;
892
	       long_double_lib[10].called=1;
872
	    }
893
	    }
873
	    stub = "ARGW0=GR";
894
	    stub = "ARGW0=GR";
874
	    quad_ret = 0;
895
	    quad_ret = 0;
875
	    quad_addr(son(e),ARG0,sp) ;
896
	    quad_addr(son(e),ARG0,sp);
876
	 }
897
	 }
877
	 break ;
898
	 break;
878
      }
899
      }
879
      case float_tag :
900
      case float_tag:
880
      {
901
      {
881
	 exp l = son(e);
902
	 exp l = son(e);
882
	 reg_operand_here(l,sp,ARG0);
903
	 reg_operand_here(l,sp,ARG0);
883
	 sp = guardreg(ARG0,sp);
904
	 sp = guardreg(ARG0,sp);
884
	 if ( name(sh(l))==ulonghd )
905
	 if (name(sh(l)) ==ulonghd)
885
	 {
906
	 {
886
	    rr_ins(i_copy,0,ARG1);
907
	    rr_ins(i_copy,0,ARG1);
887
	    long_double_lib[7].called=1;
908
	    long_double_lib[7].called=1;
888
	    s = "_U_Qfcnvxf_dbl_to_quad" ;
909
	    s = "_U_Qfcnvxf_dbl_to_quad";
889
	    stub = "ARGW0=GR,ARGW1=GR";
910
	    stub = "ARGW0=GR,ARGW1=GR";
890
	 }
911
	 }
891
	 else
912
	 else
892
	 {
913
	 {
893
	    s = "_U_Qfcnvxf_sgl_to_quad" ;
914
	    s = "_U_Qfcnvxf_sgl_to_quad";
894
	    long_double_lib[8].called=1;
915
	    long_double_lib[8].called=1;
895
	    stub = "ARGW0=GR";
916
	    stub = "ARGW0=GR";
896
	 }
917
	 }
897
	 break ;
918
	 break;
898
      }
919
      }
899
      case round_tag :
920
      case round_tag:
900
      {
921
      {
901
	 if ( round_number(e)==3 && errhandle(e)<2 )
922
	 if (round_number(e) ==3 && errhandle(e) <2)
902
	 {
923
	 {
903
	    s = "_U_Qfcnvfxt_quad_to_sgl";
924
	    s = "_U_Qfcnvfxt_quad_to_sgl";
904
	    long_double_lib[12].called=1;
925
	    long_double_lib[12].called=1;
905
	 }
926
	 }
906
	 else
927
	 else
Line 908... Line 929...
908
	    s = "_U_Qfcnvff_quad_to_dbl";
929
	    s = "_U_Qfcnvff_quad_to_dbl";
909
	    long_double_lib[9].called=1;
930
	    long_double_lib[9].called=1;
910
	 }
931
	 }
911
	 stub = "ARGW0=GR";
932
	 stub = "ARGW0=GR";
912
	 quad_ret = 0;
933
	 quad_ret = 0;
913
	 quad_addr(son(e),ARG0,sp) ;
934
	 quad_addr(son(e),ARG0,sp);
914
	 break;
935
	 break;
915
      }
936
      }
916
#if 0
937
#if 0
917
      /* Binary operations */
938
      /* Binary operations */
918
      {
939
      {
919
	 stub = "ARGW0=GR,ARGW1=GR";
940
	 stub = "ARGW0=GR,ARGW1=GR";
920
	 break ;
941
	 break;
921
      }
942
      }
922
#endif
943
#endif
923
      case fplus_tag :
944
      case fplus_tag:
924
      case fminus_tag : 
945
      case fminus_tag:
925
      case fmult_tag :
946
      case fmult_tag:
926
      case fdiv_tag :
947
      case fdiv_tag:
927
      {
948
      {
928
	 exp l,r;
949
	 exp l,r;
929
	 if ( name(e) == fplus_tag )
950
	 if (name(e) == fplus_tag)
930
	 {
951
	 {
931
	    s = "_U_Qfadd" ;
952
	    s = "_U_Qfadd";
932
	    long_double_lib[1].called=1;
953
	    long_double_lib[1].called=1;
933
	 }
954
	 }
934
	 else
955
	 else
935
	 if ( name(e) == fminus_tag )
956
	 if (name(e) == fminus_tag)
936
	 {
957
	 {
937
	   s = "_U_Qfsub" ; 
958
	   s = "_U_Qfsub";
938
	   long_double_lib[2].called=1;
959
	   long_double_lib[2].called=1;
939
	 }
960
	 }
940
	 else
961
	 else
941
	 if ( name(e) == fmult_tag )
962
	 if (name(e) == fmult_tag)
942
	 {
963
	 {
943
	    s = "_U_Qfmpy" ; 
964
	    s = "_U_Qfmpy";
944
	    long_double_lib[3].called=1;
965
	    long_double_lib[3].called=1;
945
	 }
966
	 }
946
	 else
967
	 else
947
	 {
968
	 {
948
	    s = "_U_Qfdiv" ;
969
	    s = "_U_Qfdiv";
949
	    long_double_lib[4].called=1;
970
	    long_double_lib[4].called=1;
950
	 }
971
	 }
951
	 stub = "ARGW0=GR,ARGW1=GR";
972
	 stub = "ARGW0=GR,ARGW1=GR";
952
	 if ( IsRev(e) )
973
	 if (IsRev(e))
953
	 {
974
	 {
954
	    r = son(e);
975
	    r = son(e);
955
	    l = bro(r);
976
	    l = bro(r);
956
	 }
977
	 }
957
	 else
978
	 else
958
	 {
979
	 {
959
	    l = son(e);
980
	    l = son(e);
960
	    r = bro(l);
981
	    r = bro(l);
961
	 }
982
	 }
962
	 quad_addr(l,ARG0,sp) ;
983
	 quad_addr(l,ARG0,sp);
963
	 sp = guardreg(ARG0,sp) ;
984
	 sp = guardreg(ARG0,sp);
964
	 quad_addr(r,ARG1,sp) ;
985
	 quad_addr(r,ARG1,sp);
965
	 break ;
986
	 break;
966
      }
987
      }
967
      default :
988
      default :
968
	fail ( "Illegal floating-point operation" ) ;
989
	fail("Illegal floating-point operation");
969
   }
990
   }
970
   if (quad_ret)
991
   if (quad_ret)
971
   {
992
   {
972
      instore is ;
993
      instore is;
973
      is = insalt(dest.answhere);
994
      is = insalt(dest.answhere);
974
      if (discrim(dest.answhere)!=notinreg)
995
      if (discrim(dest.answhere)!=notinreg)
975
	  failer("Illegal expression in quad_op");
996
	  failer("Illegal expression in quad_op");
976
      if (is.adval)
997
      if (is.adval)
977
      {
998
      {
978
	 if (IS_FIXREG(is.b.base))
999
	 if (IS_FIXREG(is.b.base))
979
	 {
1000
	 {
980
	    if (is.b.offset==0)
1001
	    if (is.b.offset==0)
981
	       rr_ins(i_copy,is.b.base,RET0) ;
1002
	       rr_ins(i_copy,is.b.base,RET0);
982
	    else
1003
	    else
983
	       ld_ins(i_lo,1,is.b,RET0) ;
1004
	       ld_ins(i_lo,1,is.b,RET0);
984
	 } 
1005
	 }
985
	 else
1006
	 else
986
	    set_ins("",is.b,RET0) ;
1007
	    set_ins("",is.b,RET0);
987
      }
1008
      }
988
      else
1009
      else
989
	 ld_ins(i_lw,1,is.b,RET0) ;
1010
	 ld_ins(i_lw,1,is.b,RET0);
990
   }
1011
   }
991
   /* ..and make call */
1012
   /* ..and make call */
992
   call_ins(cmplt_,s,RP,stub) ;
1013
   call_ins(cmplt_,s,RP,stub);
993
#if 1
1014
#if 1
994
   if (!optop(e) && name(e)!=test_tag)
1015
   if (!optop(e) && name(e)!=test_tag)
995
   {
1016
   {
996
      int trap = trap_label(e);
1017
      int trap = trap_label(e);
997
      baseoff b;
1018
      baseoff b;
998
      int end;
1019
      int end;
999
      if (quad_ret)
1020
      if (quad_ret)
1000
      {
1021
      {
1001
	 instore is ;
1022
	 instore is;
1002
	 end=new_label();
1023
	 end=new_label();
1003
	 is = insalt(dest.answhere);
1024
	 is = insalt(dest.answhere);
1004
	 if (discrim(dest.answhere)!=notinreg)
1025
	 if (discrim(dest.answhere)!=notinreg)
1005
	    failer("Illegal expression in quad_op");
1026
	    failer("Illegal expression in quad_op");
1006
	 if (is.adval)
1027
	 if (is.adval)
1007
	 {
1028
	 {
1008
	    if (IS_FIXREG(is.b.base))
1029
	    if (IS_FIXREG(is.b.base))
1009
	    {
1030
	    {
1010
	       if (is.b.offset==0)
1031
	       if (is.b.offset==0)
1011
		  rr_ins(i_copy,is.b.base,RET0) ;
1032
		  rr_ins(i_copy,is.b.base,RET0);
1012
	       else
1033
	       else
1013
		  ld_ins(i_lo,1,is.b,RET0) ;
1034
		  ld_ins(i_lo,1,is.b,RET0);
1014
	    } 
1035
	    }
1015
	    else
1036
	    else
1016
	       set_ins("",is.b,RET0) ;
1037
	       set_ins("",is.b,RET0);
1017
	 }
1038
	 }
1018
	 else
1039
	 else
1019
	    ld_ins(i_lw,1,is.b,RET0) ;
1040
	    ld_ins(i_lw,1,is.b,RET0);
1020
	 b.base =  RET0; b.offset = 4;
1041
	 b.base =  RET0; b.offset = 4;
1021
	 ld_ins(i_lw,1,b,T3);
1042
	 ld_ins(i_lw,1,b,T3);
1022
	 cj_ins( c_neq, 0, T3, end ) ;         
1043
	 cj_ins(c_neq, 0, T3, end);
1023
	 b.offset+=4;
1044
	 b.offset+=4;
1024
	 ld_ins(i_lw,1,b,T3);
1045
	 ld_ins(i_lw,1,b,T3);
1025
	 cj_ins( c_neq, 0, T3, end ) ;         
1046
	 cj_ins(c_neq, 0, T3, end);
1026
	 b.offset+=4;
1047
	 b.offset+=4;
1027
	 ld_ins(i_lw,1,b,T3);
1048
	 ld_ins(i_lw,1,b,T3);
1028
	 cj_ins( c_neq, 0, T3, end ) ;         
1049
	 cj_ins(c_neq, 0, T3, end);
1029
	 b.offset=0;
1050
	 b.offset=0;
1030
	 ld_ins(i_lw,1,b,T3);
1051
	 ld_ins(i_lw,1,b,T3);
1031
	 imm_to_r(2147418112,T4);
1052
	 imm_to_r(2147418112,T4);
1032
	 cj_ins( c_eq, T4, T3, trap ) ;         
1053
	 cj_ins(c_eq, T4, T3, trap);
1033
	 imm_to_r(-65536,T4);
1054
	 imm_to_r(-65536,T4);
1034
	 cj_ins( c_eq, T4, T3, trap ) ;         
1055
	 cj_ins(c_eq, T4, T3, trap);
1035
	 outlab("L$$",end);
1056
	 outlab("L$$",end);
1036
      }
1057
      }
1037
      else
1058
      else
1038
      if ( name(e) == chfl_tag )
1059
      if (name(e) == chfl_tag)
1039
      {
1060
      {
1040
	 if ( isdbl(sh(e)) )
1061
	 if (isdbl(sh(e)))
1041
	 {
1062
	 {
1042
	    baseoff b;
1063
	    baseoff b;
1043
	    b = mem_temp(0);
1064
	    b = mem_temp(0);
1044
	    end = new_label();
1065
	    end = new_label();
1045
	    stf_ins(i_fstd,3*4+1,b);
1066
	    stf_ins(i_fstd,3*4+1,b);
1046
	    b.offset+=4;
1067
	    b.offset+=4;
1047
	    ld_ins(i_lw,1,b,T3);
1068
	    ld_ins(i_lw,1,b,T3);
1048
	    cj_ins( c_neq, 0, T3, end ) ;         
1069
	    cj_ins(c_neq, 0, T3, end);
1049
	    b.offset-=4;
1070
	    b.offset-=4;
1050
	    ld_ins(i_lw,1,b,T3);
1071
	    ld_ins(i_lw,1,b,T3);
1051
	    imm_to_r(2146435072,T4);
1072
	    imm_to_r(2146435072,T4);
1052
	    cj_ins( c_eq, T4, T3, trap ) ;         
1073
	    cj_ins(c_eq, T4, T3, trap);
1053
	    imm_to_r(-1048576,T4);
1074
	    imm_to_r(-1048576,T4);
1054
	    cj_ins( c_eq, T4, T3, trap ) ;         
1075
	    cj_ins(c_eq, T4, T3, trap);
1055
	    outlab("L$$",end);
1076
	    outlab("L$$",end);
1056
	 }
1077
	 }
1057
	 else
1078
	 else
1058
	 {
1079
	 {
1059
	    baseoff b;
1080
	    baseoff b;
1060
	    b = mem_temp(0);
1081
	    b = mem_temp(0);
1061
	    stf_ins(i_fstw,3*4,b);
1082
	    stf_ins(i_fstw,3*4,b);
1062
	    ld_ins(i_lw,1,b,T3);
1083
	    ld_ins(i_lw,1,b,T3);
1063
	    imm_to_r(2139095040,T4);
1084
	    imm_to_r(2139095040,T4);
1064
	    cj_ins( c_eq, T4, T3, trap ) ;         
1085
	    cj_ins(c_eq, T4, T3, trap);
1065
	    imm_to_r(-8388608,T4);
1086
	    imm_to_r(-8388608,T4);
1066
	    cj_ins( c_eq, T4, T3, trap ) ;         
1087
	    cj_ins(c_eq, T4, T3, trap);
1067
	 }
1088
	 }
1068
      }
1089
      }
1069
   }
1090
   }
1070
#endif
1091
#endif
1071
   clear_t_regs() ;
1092
   clear_t_regs();
1072
   return ;
1093
   return;
1073
}
1094
}
1074
 
1095
 
1075
#endif
1096
#endif
1076
 
1097
 
1077
 
1098
 
1078
int fop
1099
int fop
1079
    PROTO_N ( (e, sp, dest, ins) )
-
 
1080
    PROTO_T ( exp e X space sp X where dest X ins_p ins )
1100
(exp e, space sp, where dest, ins_p ins)
1081
{
1101
{
1082
   /* Evaluate floating dyadic operation e using ins into dest. If
1102
   /* Evaluate floating dyadic operation e using ins into dest. If
1083
      !optop(e), then we have two fixed point registers at our disposal */
1103
      !optop(e), then we have two fixed point registers at our disposal */
1084
   exp l = son(e);
1104
   exp l = son(e);
1085
   exp r = bro(l);
1105
   exp r = bro(l);
Line 1088... Line 1108...
1088
   freg fr;
1108
   freg fr;
1089
   ans aa;
1109
   ans aa;
1090
   baseoff b;
1110
   baseoff b;
1091
 
1111
 
1092
#if use_long_double
1112
#if use_long_double
1093
   if (name(sh(e))==doublehd)
1113
   if (name(sh(e)) ==doublehd)
1094
   {
1114
   {
1095
      /* i.e. quads */
1115
      /* i.e. quads */
1096
      quad_op( e, sp, dest );
1116
      quad_op(e, sp, dest);
1097
      return (NOREG) ;
1117
      return(NOREG);
1098
   }
1118
   }
1099
#endif
1119
#endif
1100
 
1120
 
1101
 
1121
 
1102
   dble=( name(sh(e))==realhd ? 1 : 0 );
1122
   dble= (name(sh(e)) ==realhd ? 1 : 0);
1103
   if (IsRev(e))
1123
   if (IsRev(e))
1104
   {
1124
   {
1105
      a2 = freg_operand(r, sp, getfreg(sp.flt));
1125
      a2 = freg_operand(r, sp, getfreg(sp.flt));
1106
      nsp = guardfreg(a2, sp);
1126
      nsp = guardfreg(a2, sp);
1107
      a1 = freg_operand(l, nsp, getfreg(nsp.flt));
1127
      a1 = freg_operand(l, nsp, getfreg(nsp.flt));
Line 1110... Line 1130...
1110
   {
1130
   {
1111
      a1 = freg_operand(l, sp, getfreg(sp.flt));
1131
      a1 = freg_operand(l, sp, getfreg(sp.flt));
1112
      nsp = guardfreg(a1, sp);
1132
      nsp = guardfreg(a1, sp);
1113
      a2 = freg_operand(r, nsp, getfreg(nsp.flt));
1133
      a2 = freg_operand(r, nsp, getfreg(nsp.flt));
1114
   }
1134
   }
1115
   if ( (discrim(dest.answhere)) == infreg )
1135
   if ((discrim(dest.answhere)) == infreg)
1116
      fr = fregalt(dest.answhere);
1136
      fr = fregalt(dest.answhere);
1117
   else
1137
   else
1118
   {
1138
   {
1119
      fr.fr = getfreg(nsp.flt);
1139
      fr.fr = getfreg(nsp.flt);
1120
      fr.dble = (dest.ashwhere.ashsize == 64) ? 1 : 0;
1140
      fr.dble = (dest.ashwhere.ashsize == 64)? 1 : 0;
1121
      setfregalt(aa, fr);
1141
      setfregalt(aa, fr);
1122
   }
1142
   }
1123
   if (!optop(e))
1143
   if (!optop(e))
1124
   {
1144
   {
1125
      b = zero_exception_register(nsp);
1145
      b = zero_exception_register(nsp);
1126
   }
1146
   }
1127
   if (dble)
1147
   if (dble)
1128
      rrrf_ins(ins,f_dbl,(3*a1)+1,(3*a2)+1,(3*fr.fr)+1);
1148
      rrrf_ins(ins,f_dbl,(3*a1) +1,(3*a2) +1,(3*fr.fr) +1);
1129
   else
1149
   else
1130
      rrrf_ins(ins,f_sgl,3*a1,3*a2,3*fr.fr);
1150
      rrrf_ins(ins,f_sgl,3*a1,3*a2,3*fr.fr);
1131
   if (!optop(e))
1151
   if (!optop(e))
1132
   {
1152
   {
1133
      trap_handler(b,trap_label(e),EXCEPTION_CODE);
1153
      trap_handler(b,trap_label(e),EXCEPTION_CODE);
1134
   }
1154
   }
1135
   if ( (discrim(dest.answhere)) != infreg )
1155
   if ((discrim(dest.answhere))!= infreg)
1136
      move(aa, dest, sp.fixed, 1);
1156
      move(aa, dest, sp.fixed, 1);
1137
   return ( dble ? -(fr.fr + 32) : (fr.fr + 32) );
1157
   return(dble ? - (fr.fr + 32):(fr.fr + 32));
1138
}
1158
}