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
    Copyright (c) 1993 Open Software Foundation, Inc.
32
    Copyright (c) 1993 Open Software Foundation, Inc.
3
 
33
 
4
 
34
 
5
    All Rights Reserved
35
    All Rights Reserved
6
 
36
 
7
 
37
 
8
    Permission to use, copy, modify, and distribute this software
38
    Permission to use, copy, modify, and distribute this software
9
    and its documentation for any purpose and without fee is hereby
39
    and its documentation for any purpose and without fee is hereby
10
    granted, provided that the above copyright notice appears in all
40
    granted, provided that the above copyright notice appears in all
11
    copies and that both the copyright notice and this permission
41
    copies and that both the copyright notice and this permission
12
    notice appear in supporting documentation.
42
    notice appear in supporting documentation.
Line 14... Line 44...
14
 
44
 
15
    OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING
45
    OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING
16
    ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
46
    ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
17
    PARTICULAR PURPOSE.
47
    PARTICULAR PURPOSE.
18
 
48
 
19
 
49
 
20
    IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
50
    IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
21
    CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
51
    CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
22
    LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
52
    LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
23
    NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
53
    NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
24
    WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
54
    WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25
*/
55
*/
26
 
56
 
27
/*
57
/*
28
    		 Crown Copyright (c) 1997
58
    		 Crown Copyright (c) 1997
29
    
59
 
30
    This TenDRA(r) Computer Program is subject to Copyright
60
    This TenDRA(r) Computer Program is subject to Copyright
31
    owned by the United Kingdom Secretary of State for Defence
61
    owned by the United Kingdom Secretary of State for Defence
32
    acting through the Defence Evaluation and Research Agency
62
    acting through the Defence Evaluation and Research Agency
33
    (DERA).  It is made available to Recipients with a
63
    (DERA).  It is made available to Recipients with a
34
    royalty-free licence for its use, reproduction, transfer
64
    royalty-free licence for its use, reproduction, transfer
35
    to other parties and amendment for any purpose not excluding
65
    to other parties and amendment for any purpose not excluding
36
    product development provided that any such use et cetera
66
    product development provided that any such use et cetera
37
    shall be deemed to be acceptance of the following conditions:-
67
    shall be deemed to be acceptance of the following conditions:-
38
    
68
 
39
        (1) Its Recipients shall ensure that this Notice is
69
        (1) Its Recipients shall ensure that this Notice is
40
        reproduced upon any copies or amended versions of it;
70
        reproduced upon any copies or amended versions of it;
41
    
71
 
42
        (2) Any amended version of it shall be clearly marked to
72
        (2) Any amended version of it shall be clearly marked to
43
        show both the nature of and the organisation responsible
73
        show both the nature of and the organisation responsible
44
        for the relevant amendment or amendments;
74
        for the relevant amendment or amendments;
45
    
75
 
46
        (3) Its onward transfer from a recipient to another
76
        (3) Its onward transfer from a recipient to another
47
        party shall be deemed to be that party's acceptance of
77
        party shall be deemed to be that party's acceptance of
48
        these conditions;
78
        these conditions;
49
    
79
 
50
        (4) DERA gives no warranty or assurance as to its
80
        (4) DERA gives no warranty or assurance as to its
51
        quality or suitability for any purpose and DERA accepts
81
        quality or suitability for any purpose and DERA accepts
52
        no liability whatsoever in relation to any use to which
82
        no liability whatsoever in relation to any use to which
53
        it may be put.
83
        it may be put.
54
*/
84
*/
Line 93... Line 123...
93
 
123
 
94
static long nil_access_lab=0;
124
static long nil_access_lab=0;
95
static long overflow_lab=0;
125
static long overflow_lab=0;
96
static long stack_overflow_lab=0;
126
static long stack_overflow_lab=0;
97
 
127
 
98
void init_proc_errors PROTO_S ((exp));
128
void init_proc_errors(exp);
99
void output_error_labels PROTO_S ((void));
129
void output_error_labels(void);
100
long get_nil_access_lab PROTO_S ((void));
130
long get_nil_access_lab(void);
101
long get_overflow_lab PROTO_S ((void));
131
long get_overflow_lab(void);
102
long get_stack_overflow_lab PROTO_S ((void));
132
long get_stack_overflow_lab(void);
103
 
133
 
104
 
134
 
105
void test_signed PROTO_S ((int,long,long,long));
135
void test_signed(int,long,long,long);
106
void test_unsigned PROTO_S ((int,long,long));
136
void test_unsigned(int,long,long);
107
static long trap_label PROTO_S ((exp));
137
static long trap_label(exp);
108
static void do_exception PROTO_S ((int));
138
static void do_exception(int);
109
static void call_TDFhandler PROTO_S ((void));
139
static void call_TDFhandler(void);
110
 
140
 
111
 
141
 
112
/* integer error treatments */
142
/* integer error treatments */
113
int abs_error_treatment PROTO_S ((exp,space,where));
143
int abs_error_treatment(exp,space,where);
114
int chvar_error_treatment PROTO_S ((exp,space,where));
144
int chvar_error_treatment(exp,space,where);
115
void div_error_treatment PROTO_S ((int,int,exp));
145
void div_error_treatment(int,int,exp);
116
int minus_error_treatment PROTO_S ((exp,space,where));
146
int minus_error_treatment(exp,space,where);
117
int mult_error_treatment PROTO_S ((exp,space,where));
147
int mult_error_treatment(exp,space,where);
118
int plus_error_treatment PROTO_S ((exp,space,where));
148
int plus_error_treatment(exp,space,where);
119
int neg_error_treatment PROTO_S ((exp,space,where));
149
int neg_error_treatment(exp,space,where);
120
void rem_error_treatment PROTO_S ((int,int,exp));
150
void rem_error_treatment(int,int,exp);
121
void round_error_treatment PROTO_S ((exp *));
151
void round_error_treatment(exp *);
122
 
152
 
123
/* floating error treatments */
153
/* floating error treatments */
124
void chfl_error_treatment PROTO_S ((exp,int));
154
void chfl_error_treatment(exp,int);
125
void do_fmop_error_jump PROTO_S ((exp,int,int));
155
void do_fmop_error_jump(exp,int,int);
126
void do_fop_error_jump PROTO_S ((exp,int,int,int));
156
void do_fop_error_jump(exp,int,int,int);
127
 
157
 
128
 
158
 
129
/*
159
/*
130
 * init_proc_errors: initialises variables used
160
 * init_proc_errors: initialises variables used
131
 */
161
 */
132
void init_proc_errors PROTO_N ((e)) PROTO_T (exp e)
162
void init_proc_errors(exp e)
133
{
163
{
134
  /* clear the error code labels */
164
  /* clear the error code labels */
135
  nil_access_lab = 0;
165
  nil_access_lab = 0;
136
  overflow_lab = 0;
166
  overflow_lab = 0;
137
  stack_overflow_lab = 0;
167
  stack_overflow_lab = 0;
138
  
168
 
139
  if (proc_has_checkstack(e))
169
  if (proc_has_checkstack(e))
140
  {
170
  {
141
    baseoff b;
171
    baseoff b;
142
    int cr = next_creg();
172
    int cr = next_creg();
143
    long err_lab = get_stack_overflow_lab();
173
    long err_lab = get_stack_overflow_lab();
144
    
174
 
145
    b = find_tg("__TDFstacklim");
175
    b = find_tg("__TDFstacklim");
146
    ld_ins(i_l,b,R_TMP0);
176
    ld_ins(i_l,b,R_TMP0);
147
    cmp_rr_ins(i_cmp,R_SP,R_TMP0,cr);
177
    cmp_rr_ins(i_cmp,R_SP,R_TMP0,cr);
148
    long_bc_ins(i_blt,cr,err_lab,UNLIKELY_TO_JUMP);
178
    long_bc_ins(i_blt,cr,err_lab,UNLIKELY_TO_JUMP);
149
  }
179
  }
150
  return;
180
  return;
151
}
181
}
152
/*
182
/*
153
 * output_error_labels:
183
 * output_error_labels:
154
 * Sets up the labels at the end of the proc to handle
184
 * Sets up the labels at the end of the proc to handle
155
 * the three error codes
185
 * the three error codes
156
 */
186
 */
157
void output_error_labels PROTO_Z ()
187
void output_error_labels(void)
158
{
188
{
159
  if (nil_access_lab != 0)
189
  if (nil_access_lab != 0)
160
  {
190
  {
161
    set_label(nil_access_lab);
191
    set_label(nil_access_lab);
162
    do_exception(f_nil_access);
192
    do_exception(f_nil_access);
Line 177... Line 207...
177
/*
207
/*
178
 * get_nil_access_lab returns the label to jump to
208
 * get_nil_access_lab returns the label to jump to
179
 * when a nil_access error_code is created
209
 * when a nil_access error_code is created
180
 * or sets it if it is un-initialized
210
 * or sets it if it is un-initialized
181
 */
211
 */
182
long get_nil_access_lab PROTO_Z ()
212
long get_nil_access_lab(void)
183
{
213
{
184
  if (nil_access_lab == 0)
214
  if (nil_access_lab == 0)
185
  {
215
  {
186
    nil_access_lab = new_label();
216
    nil_access_lab = new_label();
187
  }
217
  }
Line 190... Line 220...
190
/*
220
/*
191
 * get_overflow_lab returns the label to jump to
221
 * get_overflow_lab returns the label to jump to
192
 * when an overflow error_code is created
222
 * when an overflow error_code is created
193
 * or sets it if it is un-initialized
223
 * or sets it if it is un-initialized
194
 */
224
 */
195
long get_overflow_lab PROTO_Z ()
225
long get_overflow_lab(void)
196
{
226
{
197
  if (overflow_lab == 0)
227
  if (overflow_lab == 0)
198
  {
228
  {
199
    overflow_lab = new_label();
229
    overflow_lab = new_label();
200
  }
230
  }
Line 203... Line 233...
203
/*
233
/*
204
 * get_stack_overflow_lab returns the label to jump to
234
 * get_stack_overflow_lab returns the label to jump to
205
 * when a stack_overflow error_code is created
235
 * when a stack_overflow error_code is created
206
 * or sets it if it is un-initialized
236
 * or sets it if it is un-initialized
207
 */
237
 */
208
long get_stack_overflow_lab PROTO_Z ()
238
long get_stack_overflow_lab(void)
209
{
239
{
210
  if (stack_overflow_lab == 0)
240
  if (stack_overflow_lab == 0)
211
  {
241
  {
212
    stack_overflow_lab = new_label();
242
    stack_overflow_lab = new_label();
213
  }
243
  }
Line 216... Line 246...
216
/*
246
/*
217
 * do_trap is called from make_code and branches to
247
 * do_trap is called from make_code and branches to
218
 * the corresponding error label depending on which
248
 * the corresponding error label depending on which
219
 * error code needs to be invoked
249
 * error code needs to be invoked
220
 */
250
 */
221
void do_trap PROTO_N ((e)) PROTO_T (exp e )
251
void do_trap(exp e)
222
{
252
{
223
  int err_code = no(e);
253
  int err_code = no(e);
224
  long err_lab;
254
  long err_lab;
225
  
255
 
226
  if (err_code == f_nil_access)
256
  if (err_code == f_nil_access)
227
  {
257
  {
228
    err_lab = get_nil_access_lab();
258
    err_lab = get_nil_access_lab();
229
  }
259
  }
230
  else if (err_code == f_overflow)
260
  else if (err_code == f_overflow)
Line 239... Line 269...
239
  {
269
  {
240
    fail("do_trap::Unknown error code");
270
    fail("do_trap::Unknown error code");
241
  }
271
  }
242
  uncond_ins(i_b,err_lab);
272
  uncond_ins(i_b,err_lab);
243
  clear_all();
273
  clear_all();
244
  return;
274
  return;
245
}
275
}
246
 
276
 
247
/*
277
/*
248
 * test_signed: tests whether a register lies
278
 * test_signed: tests whether a register lies
249
 * between two values and
279
 * between two values and
250
 * jumps to label if it does not 
280
 * jumps to label if it does not
251
 */
281
 */
252
void test_signed PROTO_N ((r,lower,upper,lab)) 
-
 
253
    PROTO_T (int r X long lower X long upper X long lab)
282
void test_signed(int r, long lower, long upper, long lab)
254
{
283
{
255
  int creg1=next_creg();
284
  int creg1=next_creg();
256
  int creg2=next_creg();
285
  int creg2=next_creg();
257
  cmp_ri_ins(i_cmp,r,lower,creg1);
286
  cmp_ri_ins(i_cmp,r,lower,creg1);
258
  long_bc_ins(i_blt,creg1,lab,UNLIKELY_TO_JUMP);
287
  long_bc_ins(i_blt,creg1,lab,UNLIKELY_TO_JUMP);
259
  cmp_ri_ins(i_cmp,r,upper,creg2);
288
  cmp_ri_ins(i_cmp,r,upper,creg2);
260
  long_bc_ins(i_bgt,creg2,lab,UNLIKELY_TO_JUMP);
289
  long_bc_ins(i_bgt,creg2,lab,UNLIKELY_TO_JUMP);
261
  return;
290
  return;
262
}
291
}
263
/*
292
/*
264
 * test_unsigned: tests whether a register is greater than an unsigned number
293
 * test_unsigned: tests whether a register is greater than an unsigned number
265
 */
294
 */
266
void test_unsigned PROTO_N ((r,maxval,lab)) PROTO_T (int r X long maxval X long lab)
295
void test_unsigned(int r, long maxval, long lab)
267
{
296
{
268
  int creg=next_creg();
297
  int creg=next_creg();
269
  cmp_ri_ins(i_cmpl,r,maxval,creg);
298
  cmp_ri_ins(i_cmpl,r,maxval,creg);
270
  long_bc_ins(i_bgt,creg,lab,UNLIKELY_TO_JUMP);
299
  long_bc_ins(i_bgt,creg,lab,UNLIKELY_TO_JUMP);
271
  return;
300
  return;
272
}
301
}
273
 
302
 
274
/*
303
/*
275
 * trap_label: Gives a label for the destination of the error
304
 * trap_label: Gives a label for the destination of the error
276
 */
305
 */
277
static long trap_label PROTO_N ((e)) PROTO_T (exp e)
306
static long trap_label(exp e)
278
{
307
{
279
  if (NO_ERROR_TREATMENT(e))
308
  if (NO_ERROR_TREATMENT(e))
280
  {
309
  {
281
    fail("No error treatment");
310
    fail("No error treatment");
282
    return 0;
311
    return 0;
283
  }
312
  }
Line 289... Line 318...
289
  {
318
  {
290
    /* Error jump to destination */
319
    /* Error jump to destination */
291
    return no(son(pt(e)));
320
    return no(son(pt(e)));
292
  }
321
  }
293
}
322
}
294
/* 
323
/*
295
 * Generates a call to the TDFhandler for exceptions
324
 * Generates a call to the TDFhandler for exceptions
296
 */
325
 */
297
static void do_exception PROTO_N ((ex)) PROTO_T (int ex)
326
static void do_exception(int ex)
298
{
327
{
299
  ld_const_ins(ex,R_FIRST_PARAM);/* __TDFhandler takes as its first parameter, the error code */
328
  ld_const_ins(ex,R_FIRST_PARAM);/* __TDFhandler takes as its first parameter, the error code */
300
  call_TDFhandler();
329
  call_TDFhandler();
301
  return;
330
  return;
302
}
331
}
303
static void call_TDFhandler PROTO_Z ()
332
static void call_TDFhandler(void)
304
{
333
{
305
  baseoff b;
334
  baseoff b;
306
  b = find_tg("__TDFhandler");
335
  b = find_tg("__TDFhandler");
307
  ld_ins(i_l,b,R_TMP0);
336
  ld_ins(i_l,b,R_TMP0);
308
  
337
 
309
  b.base = R_TMP0;
338
  b.base = R_TMP0;
310
  b.offset = 0;
339
  b.offset = 0;
311
  ld_ro_ins(i_l,b,R_TMP0);comment("Jump to error handler");
340
  ld_ro_ins(i_l,b,R_TMP0);comment("Jump to error handler");
312
  /* We don't come back from calling error handler */
341
  /* We don't come back from calling error handler */
313
  mt_ins(i_mtctr,R_TMP0);
342
  mt_ins(i_mtctr,R_TMP0);
Line 315... Line 344...
315
  return;
344
  return;
316
}
345
}
317
 
346
 
318
 
347
 
319
 
348
 
320
/*****************************/
349
/*****************************/
321
/*                           */
350
/*                           */
322
/* INTEGER  error treatments */
351
/* INTEGER  error treatments */
323
/*                           */
352
/*                           */
324
/*****************************/
353
/*****************************/
325
 
354
 
326
/*
355
/*
327
 * ABS
356
 * ABS
328
 */
357
 */
329
int abs_error_treatment PROTO_N ((e,sp,dest))
358
int abs_error_treatment(exp e, space sp, where dest)
330
    PROTO_T (exp e X space sp X where dest)
-
 
331
{
359
{
332
  int r = reg_operand(son(e),sp);
360
  int r = reg_operand(son(e),sp);
333
  int destr = regfrmdest(&dest,sp);
361
  int destr = regfrmdest(&dest,sp);
334
  long trap = trap_label(e);
362
  long trap = trap_label(e);
335
  ans aa;
363
  ans aa;
336
  int cr;
364
  int cr;
337
  space nsp;
365
  space nsp;
338
  nsp = guardreg(destr,sp);
366
  nsp = guardreg(destr,sp);
339
  switch(name(sh(e)))
367
  switch (name(sh(e)))
340
  {
368
  {
341
   case ucharhd:
369
   case ucharhd:
342
   case uwordhd:
370
   case uwordhd:
343
   case ulonghd:
371
   case ulonghd:
344
    break;
372
    break;
345
   case scharhd:	
373
   case scharhd:
346
    cr = next_creg();
374
    cr = next_creg();
347
    cmp_ri_ins(i_cmp,r,0xffffff80,cr);
375
    cmp_ri_ins(i_cmp,r,0xffffff80,cr);
348
    long_bc_ins(i_beq,cr,trap,UNLIKELY_TO_JUMP);
376
    long_bc_ins(i_beq,cr,trap,UNLIKELY_TO_JUMP);
349
    break;
377
    break;
350
   case swordhd:
378
   case swordhd:
351
    cr = next_creg();
379
    cr = next_creg();
352
    cmp_ri_ins(i_cmp,r,0xffff8000,cr);
380
    cmp_ri_ins(i_cmp,r,0xffff8000,cr);
353
    long_bc_ins(i_beq,cr,trap,UNLIKELY_TO_JUMP);
381
    long_bc_ins(i_beq,cr,trap,UNLIKELY_TO_JUMP);
354
    break;
382
    break;
355
   case slonghd:
383
   case slonghd:
356
    cr = next_creg();
384
    cr = next_creg();
357
    cmp_ri_ins(i_cmp,r,0x80000000,cr);
385
    cmp_ri_ins(i_cmp,r,0x80000000,cr);
358
    long_bc_ins(i_beq,cr,trap,UNLIKELY_TO_JUMP);
386
    long_bc_ins(i_beq,cr,trap,UNLIKELY_TO_JUMP);
359
    break;
387
    break;
360
   default:
388
   default:
361
    fail("Unknown Integer shape for abs_tag\n");
389
    fail("Unknown Integer shape for abs_tag\n");
362
  }
390
  }
363
  rr_ins(i_abs,r,destr);
391
  rr_ins(i_abs,r,destr);
364
  setregalt(aa,destr);
392
  setregalt(aa,destr);
365
  return move(aa,dest,nsp.fixed,1);
393
  return move(aa,dest,nsp.fixed,1);
366
}
394
}
367
 
395
 
368
/*
396
/*
369
 * CHVAR
397
 * CHVAR
370
 */
398
 */
371
int chvar_error_treatment PROTO_N ((e,sp,dest))
399
int chvar_error_treatment(exp e, space sp, where dest)
372
    PROTO_T (exp e X space sp X where dest)
-
 
373
{
400
{
374
  int r = reg_operand(son(e),sp);
401
  int r = reg_operand(son(e),sp);
375
  ans aa;
402
  ans aa;
376
  int new_shpe = name(sh(e));
403
  int new_shpe = name(sh(e));
377
  long trap = trap_label(e);
404
  long trap = trap_label(e);
378
  bool sgned = is_signed(sh(son(e)));
405
  bool sgned = is_signed(sh(son(e)));
379
  
406
 
380
  setregalt(aa,r);
407
  setregalt(aa,r);
381
  switch(new_shpe)		/* switch on the new shape */
408
  switch(new_shpe)		/* switch on the new shape */
382
  {
409
  {
383
   case scharhd:
410
   case scharhd:
384
    {
411
    {
385
      if(sgned)
412
      if (sgned)
386
      {
413
      {
387
	test_signed(r,-128,127,trap);
414
	test_signed(r,-128,127,trap);
388
      }
415
      }
389
      else
416
      else
390
      {
417
      {
391
	test_unsigned(r,127,trap);
418
	test_unsigned(r,127,trap);
392
      }
419
      }
393
      break;
420
      break;
394
    }
421
    }
395
   case ucharhd:
422
   case ucharhd:
396
    {
423
    {
397
      test_unsigned(r,255,trap);
424
      test_unsigned(r,255,trap);
398
    }
425
    }
399
    break;
426
    break;
400
   case swordhd:
427
   case swordhd:
401
    {
428
    {
402
      if(sgned)
429
      if (sgned)
403
      {
430
      {
404
	test_signed(r,-0x8000,0x7fff,trap);
431
	test_signed(r,-0x8000,0x7fff,trap);
405
      }
432
      }
406
      else
433
      else
407
      {
434
      {
Line 410... Line 437...
410
    }
437
    }
411
    break;
438
    break;
412
   case uwordhd:
439
   case uwordhd:
413
    {
440
    {
414
      test_unsigned(r,0xffff,trap);
441
      test_unsigned(r,0xffff,trap);
415
    }
442
    }
416
    break;
443
    break;
417
   case slonghd:
444
   case slonghd:
418
    if(!sgned)
445
    if (!sgned)
419
    {
446
    {
420
      test_unsigned(r,0x7fffffff,trap);
447
      test_unsigned(r,0x7fffffff,trap);
421
    }
448
    }
422
    break;
449
    break;
423
   case ulonghd:
450
   case ulonghd:
424
    if(sgned)
451
    if (sgned)
425
    {
452
    {
426
      test_unsigned(r,0x7fffffff,trap);
453
      test_unsigned(r,0x7fffffff,trap);
427
    }
454
    }
428
    break;
455
    break;
429
   default:
456
   default:
Line 432... Line 459...
432
  return move(aa,dest,sp.fixed,1);
459
  return move(aa,dest,sp.fixed,1);
433
}
460
}
434
/*
461
/*
435
 * DIV0,DIV1,DIV2
462
 * DIV0,DIV1,DIV2
436
 */
463
 */
437
void div_error_treatment PROTO_N ((l,r,e))
464
void div_error_treatment(int l, int r, exp e)
438
    PROTO_T (int l X int r X exp e )
-
 
439
{
465
{
440
  int creg  = next_creg();
466
  int creg  = next_creg();
441
  int creg2 = next_creg();
467
  int creg2 = next_creg();
442
  int creg3 = next_creg();
468
  int creg3 = next_creg();
443
  
469
 
444
  long trap = trap_label(e);
470
  long trap = trap_label(e);
445
  long lab ;
471
  long lab;
446
  
472
 
447
  long minus_infinity=0;
473
  long minus_infinity=0;
448
  
474
 
449
  /* First test for division by zero */
475
  /* First test for division by zero */
450
  cmp_ri_ins(i_cmp,r,0,creg);  
476
  cmp_ri_ins(i_cmp,r,0,creg);
451
  long_bc_ins(i_beq,creg,trap,UNLIKELY_TO_JUMP);
477
  long_bc_ins(i_beq,creg,trap,UNLIKELY_TO_JUMP);
452
  
478
 
453
  /* Test for -(infinity)/-1 for signed*/
479
  /* Test for -(infinity)/-1 for signed*/
454
  if (is_signed(sh(e)))
480
  if (is_signed(sh(e)))
455
  {
481
  {
456
    lab=new_label();
482
    lab=new_label();
457
    cmp_ri_ins(i_cmp,r,-1,creg2);
483
    cmp_ri_ins(i_cmp,r,-1,creg2);
458
    bc_ins(i_bne,creg2,lab,LIKELY_TO_JUMP);
484
    bc_ins(i_bne,creg2,lab,LIKELY_TO_JUMP);
459
    switch(name(sh(e)))
485
    switch (name(sh(e)))
460
    {
486
    {
461
     case slonghd:minus_infinity = 0x80000000;break;
487
     case slonghd:minus_infinity = 0x80000000;break;
462
     case swordhd:minus_infinity = 0xffff8000;break;
488
     case swordhd:minus_infinity = 0xffff8000;break;
463
     case scharhd:minus_infinity = 0xffffff80;break;
489
     case scharhd:minus_infinity = 0xffffff80;break;
464
     default:fail("Should not get here\n");
490
     default:fail("Should not get here\n");
Line 473... Line 499...
473
 
499
 
474
 
500
 
475
/*
501
/*
476
 * MINUS_TAG
502
 * MINUS_TAG
477
 */
503
 */
478
int minus_error_treatment PROTO_N ((e,sp,dest)) 
504
int minus_error_treatment(exp e, space sp, where dest)
479
    PROTO_T (exp e X space sp X where dest)
-
 
480
{
505
{
481
  int lhs_reg=reg_operand(son(e),sp);
506
  int lhs_reg=reg_operand(son(e),sp);
482
  int rhs_reg;
507
  int rhs_reg;
483
  int destr;
508
  int destr;
484
  long trap = trap_label(e);
509
  long trap = trap_label(e);
485
  ans aa;
510
  ans aa;
486
  rhs_reg=reg_operand(bro(son(e)),guardreg(lhs_reg,sp));
511
  rhs_reg=reg_operand(bro(son(e)),guardreg(lhs_reg,sp));
487
  destr=regfrmdest(&dest,sp);
512
  destr=regfrmdest(&dest,sp);
488
  setregalt(aa,destr);
513
  setregalt(aa,destr);
489
  /* Both sides evaluated lhs in lhs_reg ,rhs in rhs_reg*/
514
  /* Both sides evaluated lhs in lhs_reg ,rhs in rhs_reg*/
490
  switch(name(sh(e)))
515
  switch (name(sh(e)))
491
  {
516
  {
492
   case slonghd:
517
   case slonghd:
493
    {
518
    {
494
      rrr_ins(i_sfo,rhs_reg,lhs_reg,destr);
519
      rrr_ins(i_sfo,rhs_reg,lhs_reg,destr);
495
      mf_ins(i_mcrxr,0);
520
      mf_ins(i_mcrxr,0);
Line 508... Line 533...
508
      rrr_ins(i_sf,rhs_reg,lhs_reg,destr);
533
      rrr_ins(i_sf,rhs_reg,lhs_reg,destr);
509
      test_signed(destr,-0x8000,0x7fff,trap);
534
      test_signed(destr,-0x8000,0x7fff,trap);
510
      break;
535
      break;
511
    }
536
    }
512
   case uwordhd:
537
   case uwordhd:
513
    {
538
    {
514
      rrr_ins(i_sf,rhs_reg,lhs_reg,destr);
539
      rrr_ins(i_sf,rhs_reg,lhs_reg,destr);
515
      test_unsigned(destr,0xffff,trap);
540
      test_unsigned(destr,0xffff,trap);
516
      break;
541
      break;
517
    }
542
    }
518
   case scharhd:
543
   case scharhd:
Line 530... Line 555...
530
   default:
555
   default:
531
    fail("NOT integer in minus with o/f");
556
    fail("NOT integer in minus with o/f");
532
  }
557
  }
533
  return move(aa, dest, sp.fixed, 1);
558
  return move(aa, dest, sp.fixed, 1);
534
}
559
}
535
 
560
 
536
/*
561
/*
537
 * MULT_TAG
562
 * MULT_TAG
538
 */
563
 */
539
int mult_error_treatment PROTO_N ((e,sp,dest)) PROTO_T (exp e X space sp X where dest)
564
int mult_error_treatment(exp e, space sp, where dest)
540
{
565
{
541
  int lhs_reg=reg_operand(son(e),sp);
566
  int lhs_reg=reg_operand(son(e),sp);
542
  int rhs_reg;
567
  int rhs_reg;
543
  int destr;
568
  int destr;
544
  long trap = trap_label(e);
569
  long trap = trap_label(e);
Line 548... Line 573...
548
  rhs_reg=reg_operand(bro(son(e)),nsp);
573
  rhs_reg=reg_operand(bro(son(e)),nsp);
549
  nsp=guardreg(rhs_reg,nsp);
574
  nsp=guardreg(rhs_reg,nsp);
550
  destr=regfrmdest(&dest,sp);
575
  destr=regfrmdest(&dest,sp);
551
  setregalt(aa,destr);
576
  setregalt(aa,destr);
552
  /* Both sides evaluated lhs in lhs_reg,rhs in rhs_reg*/
577
  /* Both sides evaluated lhs in lhs_reg,rhs in rhs_reg*/
553
  switch(name(sh(e)))
578
  switch (name(sh(e)))
554
  {
579
  {
555
   case slonghd:
580
   case slonghd:
556
    {
581
    {
557
      rrr_ins(i_mulso,lhs_reg,rhs_reg,destr);
582
      rrr_ins(i_mulso,lhs_reg,rhs_reg,destr);
558
      /* This should set the SO and OV bits of XER both to 1 if there is
583
      /* This should set the SO and OV bits of XER both to 1 if there is
Line 562... Line 587...
562
      break;
587
      break;
563
    }
588
    }
564
   case ulonghd:
589
   case ulonghd:
565
    {
590
    {
566
      int creg=next_creg();
591
      int creg=next_creg();
567
      
592
 
568
      if(architecture==POWERPC_CODE)
593
      if (architecture==POWERPC_CODE)
569
      {
594
      {
570
	/* easy since we have mulhwu */
595
	/* easy since we have mulhwu */
571
	rrr_ins(i_mulhwu,lhs_reg,rhs_reg,R_TMP0);
596
	rrr_ins(i_mulhwu,lhs_reg,rhs_reg,R_TMP0);
572
      }
597
      }
573
      else
598
      else
Line 579... Line 604...
579
	int creg  = next_creg();
604
	int creg  = next_creg();
580
	int creg2 = next_creg();
605
	int creg2 = next_creg();
581
	int creg3 = next_creg();
606
	int creg3 = next_creg();
582
	nsp = guardreg(lhs_reg,sp);
607
	nsp = guardreg(lhs_reg,sp);
583
	nsp = guardreg(rhs_reg,nsp);
608
	nsp = guardreg(rhs_reg,nsp);
584
	
609
 
585
	tmp_reg=getreg(nsp.fixed);
610
	tmp_reg=getreg(nsp.fixed);
586
	ld_const_ins(0,tmp_reg);
611
	ld_const_ins(0,tmp_reg);
587
	cmp_ri_ins(i_cmp,lhs_reg,0,creg);
612
	cmp_ri_ins(i_cmp,lhs_reg,0,creg);
588
	bc_ins(i_bgt,creg,lab,LIKELY_TO_JUMP);
613
	bc_ins(i_bgt,creg,lab,LIKELY_TO_JUMP);
589
	mov_rr_ins(lhs_reg,tmp_reg);comment(NIL);
614
	mov_rr_ins(lhs_reg,tmp_reg);comment(NIL);
Line 595... Line 620...
595
	rir_ins(i_sl,tmp_reg,1,tmp_reg);
620
	rir_ins(i_sl,tmp_reg,1,tmp_reg);
596
	rrr_ins(i_mul,lhs_reg,rhs_reg,R_TMP0);
621
	rrr_ins(i_mul,lhs_reg,rhs_reg,R_TMP0);
597
	rrr_ins(i_a,R_TMP0,tmp_reg,tmp_reg);
622
	rrr_ins(i_a,R_TMP0,tmp_reg,tmp_reg);
598
	cmp_ri_ins(i_cmp,tmp_reg,0,creg3);
623
	cmp_ri_ins(i_cmp,tmp_reg,0,creg3);
599
	long_bc_ins(i_bne,creg3,trap,UNLIKELY_TO_JUMP);
624
	long_bc_ins(i_bne,creg3,trap,UNLIKELY_TO_JUMP);
600
	
625
 
601
      }
626
      }
602
      
627
 
603
      cmp_ri_ins(i_cmp,R_TMP0,0,creg);
628
      cmp_ri_ins(i_cmp,R_TMP0,0,creg);
604
      long_bc_ins(i_bne,creg,trap,UNLIKELY_TO_JUMP);
629
      long_bc_ins(i_bne,creg,trap,UNLIKELY_TO_JUMP);
605
      rrr_ins(i_muls,lhs_reg,rhs_reg,destr);
630
      rrr_ins(i_muls,lhs_reg,rhs_reg,destr);
606
      /* if the high part of the answer is non-zero branch to trap */
631
      /* if the high part of the answer is non-zero branch to trap */
607
      break;
632
      break;
608
    }
633
    }
609
   case swordhd:
634
   case swordhd:
610
    {
635
    {
611
      rrr_ins(i_muls,lhs_reg,rhs_reg,destr);
636
      rrr_ins(i_muls,lhs_reg,rhs_reg,destr);
612
      test_signed(destr,-0x8000,0x7fff,trap);
637
      test_signed(destr,-0x8000,0x7fff,trap);
613
      break;
638
      break;
614
    }
639
    }
615
   case uwordhd:
640
   case uwordhd:
616
    {
641
    {
617
      rrr_ins(i_muls,lhs_reg,rhs_reg,destr);
642
      rrr_ins(i_muls,lhs_reg,rhs_reg,destr);
618
      test_unsigned(destr,0xffff,trap);
643
      test_unsigned(destr,0xffff,trap);
619
      break;
644
      break;
620
    }
645
    }
621
   case scharhd:
646
   case scharhd:
622
    {
647
    {
623
      rrr_ins(i_muls,lhs_reg,rhs_reg,destr);
648
      rrr_ins(i_muls,lhs_reg,rhs_reg,destr);
624
      test_signed(destr, -128, 127, trap);
649
      test_signed(destr, -128, 127, trap);
625
      break;
650
      break;
626
    }
651
    }
627
   case ucharhd:
652
   case ucharhd:
628
    {
653
    {
629
      rrr_ins(i_muls,lhs_reg,rhs_reg,destr);
654
      rrr_ins(i_muls,lhs_reg,rhs_reg,destr);
630
      test_unsigned(destr, 255, trap);
655
      test_unsigned(destr, 255, trap);
631
      break;
656
      break;
632
    }
657
    }
633
   default:
658
   default:
634
    fail("NOT integer in mult with o/f");
659
    fail("NOT integer in mult with o/f");
635
  }
660
  }
636
  return move(aa, dest, nsp.fixed, 1);
661
  return move(aa, dest, nsp.fixed, 1);
637
}
662
}
638
 
663
 
639
/*
664
/*
640
 * PLUS_TAG
665
 * PLUS_TAG
641
 */
666
 */
642
int plus_error_treatment PROTO_N ((e,sp,dest)) 
667
int plus_error_treatment(exp e, space sp, where dest)
643
    PROTO_T (exp e X space sp X where dest )
-
 
644
{
668
{
645
  int lhs_reg=reg_operand(son(e),sp);
669
  int lhs_reg=reg_operand(son(e),sp);
646
  int rhs_reg;
670
  int rhs_reg;
647
  int destr;
671
  int destr;
648
  long trap = trap_label(e);
672
  long trap = trap_label(e);
649
  ans aa;
673
  ans aa;
650
  
674
 
651
  rhs_reg = reg_operand(bro(son(e)),guardreg(lhs_reg,sp));
675
  rhs_reg = reg_operand(bro(son(e)),guardreg(lhs_reg,sp));
652
  destr=regfrmdest(&dest,sp);
676
  destr=regfrmdest(&dest,sp);
653
  setregalt(aa,destr);
677
  setregalt(aa,destr);
654
  switch(name(sh(e)))
678
  switch (name(sh(e)))
655
  {
679
  {
656
   case slonghd:
680
   case slonghd:
657
    {
681
    {
658
      rrr_ins(i_ao,lhs_reg,rhs_reg,destr);
682
      rrr_ins(i_ao,lhs_reg,rhs_reg,destr);
659
      mf_ins(i_mcrxr,0);
683
      mf_ins(i_mcrxr,0);
660
      long_bc_ins(i_bgt,0,trap,UNLIKELY_TO_JUMP);
684
      long_bc_ins(i_bgt,0,trap,UNLIKELY_TO_JUMP);
661
      break;
685
      break;
662
 
686
 
663
    }
687
    }
664
   case ulonghd:
688
   case ulonghd:
665
    {
689
    {
666
      rrr_ins(i_ao,lhs_reg,rhs_reg,destr);
690
      rrr_ins(i_ao,lhs_reg,rhs_reg,destr);
667
      mf_ins(i_mcrxr,0);
691
      mf_ins(i_mcrxr,0);
668
      long_bc_ins(i_beq,0,trap,UNLIKELY_TO_JUMP);
692
      long_bc_ins(i_beq,0,trap,UNLIKELY_TO_JUMP);
669
      break;
693
      break;
670
    }
694
    }
Line 696... Line 720...
696
    fail("NOT integer shape in plus with overflow");
720
    fail("NOT integer shape in plus with overflow");
697
  }
721
  }
698
  return move(aa, dest, sp.fixed, 0);
722
  return move(aa, dest, sp.fixed, 0);
699
}
723
}
700
#if 0
724
#if 0
701
/* 
725
/*
702
 * ROUND
726
 * ROUND
703
 * This is now done in installl_fns.c 
727
 * This is now done in installl_fns.c
704
 */
728
 */
705
void round_error_treatment PROTO_N ((e)) PROTO_T (exp *e)
729
void round_error_treatment(exp *e)
706
{
730
{
707
  /* float --> int */
731
  /* float --> int */
708
  exp round = *e;
732
  exp round = *e;
709
  exp fl =son(*e);
733
  exp fl =son(*e);
710
  shape fl_shpe = sh(fl);
734
  shape fl_shpe = sh(fl);
Line 724... Line 748...
724
  exp zero1;
748
  exp zero1;
725
  exp zero2;
749
  exp zero2;
726
  exp seq1;
750
  exp seq1;
727
  exp seq2;
751
  exp seq2;
728
  exp cond;
752
  exp cond;
729
  
753
 
730
  ASSERT(shape_size(sh(round))==32);
754
  ASSERT(shape_size(sh(round)) ==32);
731
  if (name(sh(round))==ulonghd)
755
  if (name(sh(round)) ==ulonghd)
732
  {
756
  {
733
    lower_bound = me_u3(fl_shpe,me_shint(ulongsh,0)       ,float_tag);
757
    lower_bound = me_u3(fl_shpe,me_shint(ulongsh,0)      ,float_tag);
734
    upper_bound = me_u3(fl_shpe,me_shint(ulongsh,UINT_MAX),float_tag);
758
    upper_bound = me_u3(fl_shpe,me_shint(ulongsh,UINT_MAX),float_tag);
735
  }
759
  }
736
  else
760
  else
737
  {
761
  {
738
    lower_bound = me_u3(fl_shpe,me_shint(slongsh,INT_MIN),float_tag);
762
    lower_bound = me_u3(fl_shpe,me_shint(slongsh,INT_MIN),float_tag);
739
    upper_bound = me_u3(fl_shpe,me_shint(slongsh,INT_MAX),float_tag);
763
    upper_bound = me_u3(fl_shpe,me_shint(slongsh,INT_MAX),float_tag);
740
  }
764
  }
741
  switch(round_number(round))
765
  switch (round_number(round))
742
  {
766
  {
743
   case R2ZERO:/* -1+l < f < 1+u */
767
   case R2ZERO:/* -1+l < f < 1+u */
744
    {
768
    {
745
      lower_adjustment = me_u3(fl_shpe,me_shint(slongsh,-1),float_tag);
769
      lower_adjustment = me_u3(fl_shpe,me_shint(slongsh,-1),float_tag);
746
      upper_adjustment = me_u3(fl_shpe,me_shint(slongsh,1),float_tag);
770
      upper_adjustment = me_u3(fl_shpe,me_shint(slongsh,1),float_tag);
747
      lower_strict = 1;
771
      lower_strict = 1;
748
      upper_strict = 1;
772
      upper_strict = 1;
749
      break;
773
      break;
Line 752... Line 776...
752
   case R2NEAR:/* -0.5+l < f < 0.5+u */
776
   case R2NEAR:/* -0.5+l < f < 0.5+u */
753
    {
777
    {
754
      exp minus_one;
778
      exp minus_one;
755
      exp one;
779
      exp one;
756
      exp two;
780
      exp two;
757
      
781
 
758
      minus_one = me_u3(fl_shpe,me_shint(slongsh,-1),float_tag);
782
      minus_one = me_u3(fl_shpe,me_shint(slongsh,-1),float_tag);
759
      two = me_u3(fl_shpe,me_shint(slongsh,2),float_tag);
783
      two = me_u3(fl_shpe,me_shint(slongsh,2),float_tag);
760
      lower_adjustment = me_b3(fl_shpe,minus_one,two,fdiv_tag);
784
      lower_adjustment = me_b3(fl_shpe,minus_one,two,fdiv_tag);
761
      one = me_u3(fl_shpe,me_shint(slongsh,1),float_tag);
785
      one = me_u3(fl_shpe,me_shint(slongsh,1),float_tag);
762
      two = me_u3(fl_shpe,me_shint(slongsh,2),float_tag);
786
      two = me_u3(fl_shpe,me_shint(slongsh,2),float_tag);
763
      upper_adjustment = me_b3(fl_shpe,one,two,fdiv_tag);
787
      upper_adjustment = me_b3(fl_shpe,one,two,fdiv_tag);
764
      lower_strict = 1;
788
      lower_strict = 1;
765
      upper_strict = 1;
789
      upper_strict = 1;
766
      break;
790
      break;
767
    }
791
    }
768
    
792
 
769
   case R2PINF:/* -1 +l < f =< u */
793
   case R2PINF:/* -1 +l < f =< u */
770
    {
794
    {
771
      lower_adjustment = me_u3(fl_shpe,me_shint(slongsh,-1),float_tag);
795
      lower_adjustment = me_u3(fl_shpe,me_shint(slongsh,-1),float_tag);
772
      upper_adjustment = me_u3(fl_shpe,me_shint(slongsh,0),float_tag);
796
      upper_adjustment = me_u3(fl_shpe,me_shint(slongsh,0),float_tag);
773
      lower_strict = 1;
797
      lower_strict = 1;
774
      upper_strict = 0;
798
      upper_strict = 0;
775
      break;
799
      break;
776
    }
800
    }
777
    
801
 
778
   case R2NINF:/* l =< f < 1+u */
802
   case R2NINF:/* l =< f < 1+u */
779
    {
803
    {
780
      lower_adjustment = me_u3(fl_shpe,me_shint(slongsh,0),float_tag);
804
      lower_adjustment = me_u3(fl_shpe,me_shint(slongsh,0),float_tag);
781
      upper_adjustment = me_u3(fl_shpe,me_shint(slongsh,1),float_tag);
805
      upper_adjustment = me_u3(fl_shpe,me_shint(slongsh,1),float_tag);
782
      lower_strict = 0;
806
      lower_strict = 0;
783
      upper_strict = 1;
807
      upper_strict = 1;
784
      break;
808
      break;
785
    }
809
    }
786
  }
810
  }
787
  
811
 
788
  lower = me_b3(fl_shpe,lower_bound,lower_adjustment,fplus_tag);
812
  lower = me_b3(fl_shpe,lower_bound,lower_adjustment,fplus_tag);
789
  upper = me_b3(fl_shpe,upper_bound,upper_adjustment,fplus_tag);
813
  upper = me_b3(fl_shpe,upper_bound,upper_adjustment,fplus_tag);
790
  
814
 
791
  id = me_startid(fl_shpe,fl,0);/* start ident */
815
  id = me_startid(fl_shpe,fl,0);/* start ident */
792
  
816
 
793
  clear = getexp(f_bottom,nilexp,0,nilexp,nilexp,0,0,clear_tag);
817
  clear = getexp(f_bottom,nilexp,0,nilexp,nilexp,0,0,clear_tag);
794
 
818
 
795
  if(trap)
819
  if (trap)
796
  {
820
  {
797
    exp t = getexp(f_bottom,nilexp,0,nilexp,nilexp,0,f_overflow,trap_tag);
821
    exp t = getexp(f_bottom,nilexp,0,nilexp,nilexp,0,f_overflow,trap_tag);
798
    lab = me_b3(f_bottom,clear,t,labst_tag);
822
    lab = me_b3(f_bottom,clear,t,labst_tag);
799
  }
823
  }
800
  else
824
  else
801
  {
825
  {
802
    exp g = getexp(f_bottom,nilexp,0,nilexp,pt(round),0,0,goto_tag);
826
    exp g = getexp(f_bottom,nilexp,0,nilexp,pt(round),0,0,goto_tag);
803
    lab = me_b3(f_bottom,clear,g,labst_tag);
827
    lab = me_b3(f_bottom,clear,g,labst_tag);
804
  }
828
  }
805
  
829
 
806
 
830
 
807
  test_lower = me_q1(no_nat_option,
831
  test_lower = me_q1(no_nat_option,
808
		     lower_strict?f_greater_than:f_greater_than_or_equal,
832
		     lower_strict?f_greater_than:f_greater_than_or_equal,
809
		     &lab,
833
		     &lab,
810
		     me_obtain(id),
834
		     me_obtain(id),
Line 820... Line 844...
820
  seq1 = me_b3(sh(test_upper),zero1,test_upper,seq_tag);
844
  seq1 = me_b3(sh(test_upper),zero1,test_upper,seq_tag);
821
  cond = me_b3(f_top,seq1,lab,cond_tag);
845
  cond = me_b3(f_top,seq1,lab,cond_tag);
822
  zero2 = me_u3(f_top,cond,0);
846
  zero2 = me_u3(f_top,cond,0);
823
  seq2 = me_b3(fl_shpe,zero2,me_obtain(id),seq_tag);
847
  seq2 = me_b3(fl_shpe,zero2,me_obtain(id),seq_tag);
824
  id = me_complete_id(id,seq2);
848
  id = me_complete_id(id,seq2);
825
  
849
 
826
  seterrhandle(round,0);
850
  seterrhandle(round,0);
827
  
851
 
828
  setlast(id);
852
  setlast(id);
829
  bro(id) = round;
853
  bro(id) = round;
830
  son(round) = id;
854
  son(round) = id;
831
}
855
}
832
#endif
856
#endif
833
  
857
 
834
/*
858
/*
835
 * NEG
859
 * NEG
836
 */
860
 */
837
int neg_error_treatment PROTO_N ((e,sp,dest))
861
int neg_error_treatment(exp e, space sp, where dest)
838
    PROTO_T (exp e X space sp X where dest )
-
 
839
{
862
{
840
  int r = reg_operand(son(e),sp);
863
  int r = reg_operand(son(e),sp);
841
  int destr = regfrmdest(&dest,sp);
864
  int destr = regfrmdest(&dest,sp);
842
  long trap = trap_label(e);
865
  long trap = trap_label(e);
843
  ans aa;
866
  ans aa;
844
  int cr; 
867
  int cr;
845
  space nsp;
868
  space nsp;
846
  nsp = guardreg(destr,sp);
869
  nsp = guardreg(destr,sp);
847
 
870
 
848
  switch (name(sh(e)))
871
  switch (name(sh(e)))
849
  {
872
  {
850
   case ucharhd:
873
   case ucharhd:
851
   case uwordhd:
874
   case uwordhd:
852
   case ulonghd:
875
   case ulonghd:
853
    rr_ins(i_neg_cr,r,destr);
876
    rr_ins(i_neg_cr,r,destr);
854
    long_bc_ins(i_bne,CRF0,trap,LIKELY_TO_JUMP);
877
    long_bc_ins(i_bne,CRF0,trap,LIKELY_TO_JUMP);
Line 878... Line 901...
878
  return move(aa,dest,nsp.fixed,1);
901
  return move(aa,dest,nsp.fixed,1);
879
}
902
}
880
/*
903
/*
881
 * REM0,REM1,REM2
904
 * REM0,REM1,REM2
882
 */
905
 */
883
void rem_error_treatment PROTO_N ((l,r,e))
906
void rem_error_treatment(int l, int r, exp e)
884
    PROTO_T (int l X int r X exp e )
-
 
885
{
907
{
886
  int creg  = next_creg();
908
  int creg  = next_creg();
887
  long trap = trap_label(e);
909
  long trap = trap_label(e);
888
 
910
 
889
  cmp_ri_ins(i_cmp,r,0,creg);  
911
  cmp_ri_ins(i_cmp,r,0,creg);
890
  long_bc_ins(i_beq,creg,trap,UNLIKELY_TO_JUMP);
912
  long_bc_ins(i_beq,creg,trap,UNLIKELY_TO_JUMP);
891
  return;
913
  return;
892
}
914
}
893
 
915
 
894
/*****************************/
916
/*****************************/
895
/*                           */
917
/*                           */
896
/* FLOATING error treatments */
918
/* FLOATING error treatments */
897
/*                           */
919
/*                           */
898
/*****************************/
920
/*****************************/
899
void chfl_error_treatment PROTO_N ((e,f)) PROTO_T (exp e X int f)
921
void chfl_error_treatment(exp e, int f)
900
{
922
{
901
  long trap = trap_label(e);
923
  long trap = trap_label(e);
902
  
924
 
903
  ASSERT(name(e)==chfl_tag);
925
  ASSERT(name(e) ==chfl_tag);
904
  rrf_ins(i_frsp_cr,f,f);
926
  rrf_ins(i_frsp_cr,f,f);
905
  mcrfs_ins(CRF0,0);
927
  mcrfs_ins(CRF0,0);
906
  long_bc_ins(i_bso,CRF0,trap,UNLIKELY_TO_JUMP);
928
  long_bc_ins(i_bso,CRF0,trap,UNLIKELY_TO_JUMP);
907
  return;
929
  return;
908
}
930
}
909
 
931
 
910
 
932
 
911
void do_fmop_error_jump PROTO_N ((e,fs,fd)) 
933
void do_fmop_error_jump(exp e, int fs, int fd)
912
    PROTO_T (exp e X int fs X int fd )
-
 
913
{
934
{
914
  long trap = trap_label(e);
935
  long trap = trap_label(e);
915
  Instruction_P ins;
936
  Instruction_P ins;
916
 
937
 
917
  switch(name(e))
938
  switch (name(e))
918
  {
939
  {
919
   case fabs_tag:ins=i_fabs;break;
940
   case fabs_tag:ins=i_fabs;break;
920
   case fneg_tag:ins=i_fneg;break;
941
   case fneg_tag:ins=i_fneg;break;
921
   default:fail("Unknown error jump for fmop");break;
942
   default:fail("Unknown error jump for fmop");break;
922
  }
943
  }
923
  rrf_ins(ins,fs,fd);
944
  rrf_ins(ins,fs,fd);
924
  mcrfs_ins(CRF0,0);
945
  mcrfs_ins(CRF0,0);
925
  long_bc_ins(i_bso,CRF0,trap,UNLIKELY_TO_JUMP);
946
  long_bc_ins(i_bso,CRF0,trap,UNLIKELY_TO_JUMP);
926
  if(is_single_precision(sh(e)))
947
  if (is_single_precision(sh(e)))
927
  {
948
  {
928
    rrf_ins(i_frsp,fd,fd);
949
    rrf_ins(i_frsp,fd,fd);
929
    mcrfs_ins(CRF0,0);
950
    mcrfs_ins(CRF0,0);
930
    long_bc_ins(i_bso,CRF0,trap,UNLIKELY_TO_JUMP);
951
    long_bc_ins(i_bso,CRF0,trap,UNLIKELY_TO_JUMP);
931
  }
952
  }
932
  return;
953
  return;
933
}
954
}
934
void do_fop_error_jump PROTO_N ((e,fs1,fs2,fd)) 
955
void do_fop_error_jump(exp e, int fs1, int fs2, int fd)
935
    PROTO_T (exp e X int fs1 X int fs2 X int fd )
-
 
936
{
956
{
937
  long trap = trap_label(e);
957
  long trap = trap_label(e);
938
  Instruction_P ins;
958
  Instruction_P ins;
939
   
959
 
940
  switch (name(e))
960
  switch (name(e))
941
  {
961
  {
942
   case fplus_tag: ins = i_fa;break;
962
   case fplus_tag: ins = i_fa;break;
943
   case fminus_tag:ins = i_fs;break;
963
   case fminus_tag:ins = i_fs;break;
944
   case fmult_tag: ins = i_fm;break;
964
   case fmult_tag: ins = i_fm;break;
Line 946... Line 966...
946
   default:fail("Unknown error jump for fop");
966
   default:fail("Unknown error jump for fop");
947
  }
967
  }
948
  rrrf_ins(ins,fs1,fs2,fd);
968
  rrrf_ins(ins,fs1,fs2,fd);
949
  mcrfs_ins(CRF0,0);
969
  mcrfs_ins(CRF0,0);
950
  long_bc_ins(i_bso,CRF0,trap,UNLIKELY_TO_JUMP);
970
  long_bc_ins(i_bso,CRF0,trap,UNLIKELY_TO_JUMP);
951
  switch(name(e))
971
  switch (name(e))
952
  {
972
  {
953
    /* div by 0 */
973
    /* div by 0 */
954
   case fdiv_tag:
974
   case fdiv_tag:
955
    {
975
    {
956
      mcrfs_ins(CRF0,1);
976
      mcrfs_ins(CRF0,1);
957
      long_bc_ins(i_bgt,CRF0,trap,UNLIKELY_TO_JUMP);
977
      long_bc_ins(i_bgt,CRF0,trap,UNLIKELY_TO_JUMP);
958
    }
978
    }
959
  }
979
  }
960
  if(is_single_precision(sh(e)))
980
  if (is_single_precision(sh(e)))
961
  {
981
  {
962
    rrf_ins(i_frsp,fd,fd);
982
    rrf_ins(i_frsp,fd,fd);
963
    mcrfs_ins(CRF0,0);
983
    mcrfs_ins(CRF0,0);
964
    long_bc_ins(i_bso,CRF0,trap,UNLIKELY_TO_JUMP);
984
    long_bc_ins(i_bso,CRF0,trap,UNLIKELY_TO_JUMP);
965
  }
985
  }