| ... | 
... | 
@@ -238,88 +238,9 @@ | 
| 
238
 | 
238
 | 
     (inst xor r y x)
 
 | 
| 
239
 | 
239
 | 
     (inst sub r y)))
 
 | 
| 
240
 | 
240
 | 
 
 
 | 
| 
241
 | 
 
 | 
-;;; Special case fixnum + and - that trap on overflow.  Useful when we
 
 | 
| 
242
 | 
 
 | 
-;;; don't know that the output type is a fixnum.
 
 | 
| 
243
 | 
 
 | 
-
 
 | 
| 
244
 | 
 
 | 
-;;; I (toy@rtp.ericsson.se) took these out.  They don't seem to be
 
 | 
| 
245
 | 
 
 | 
-;;; used anywhere at all.
 
 | 
| 
246
 | 
 
 | 
-#+nil
 
 | 
| 
247
 | 
 
 | 
-(progn
 
 | 
| 
248
 | 
 
 | 
-(define-vop (+/fixnum fast-+/fixnum=>fixnum)
 
 | 
| 
249
 | 
 
 | 
-  (:policy :safe)
 
 | 
| 
250
 | 
 
 | 
-  (:results (r :scs (any-reg descriptor-reg)))
 
 | 
| 
251
 | 
 
 | 
-  (:result-types tagged-num)
 
 | 
| 
252
 | 
 
 | 
-  (:note _N"safe inline fixnum arithmetic")
 
 | 
| 
253
 | 
 
 | 
-  (:generator 4
 
 | 
| 
254
 | 
 
 | 
-    (inst taddcctv r x y)))
 
 | 
| 
255
 | 
 
 | 
-
 
 | 
| 
256
 | 
 
 | 
-(define-vop (+-c/fixnum fast-+-c/fixnum=>fixnum)
 
 | 
| 
257
 | 
 
 | 
-  (:policy :safe)
 
 | 
| 
258
 | 
 
 | 
-  (:results (r :scs (any-reg descriptor-reg)))
 
 | 
| 
259
 | 
 
 | 
-  (:result-types tagged-num)
 
 | 
| 
260
 | 
 
 | 
-  (:note _N"safe inline fixnum arithmetic")
 
 | 
| 
261
 | 
 
 | 
-  (:generator 3
 
 | 
| 
262
 | 
 
 | 
-    (inst taddcctv r x (fixnumize y))))
 
 | 
| 
263
 | 
 
 | 
-
 
 | 
| 
264
 | 
 
 | 
-(define-vop (-/fixnum fast--/fixnum=>fixnum)
 
 | 
| 
265
 | 
 
 | 
-  (:policy :safe)
 
 | 
| 
266
 | 
 
 | 
-  (:results (r :scs (any-reg descriptor-reg)))
 
 | 
| 
267
 | 
 
 | 
-  (:result-types tagged-num)
 
 | 
| 
268
 | 
 
 | 
-  (:note _N"safe inline fixnum arithmetic")
 
 | 
| 
269
 | 
 
 | 
-  (:generator 4
 
 | 
| 
270
 | 
 
 | 
-    (inst tsubcctv r x y)))
 
 | 
| 
271
 | 
 
 | 
-
 
 | 
| 
272
 | 
 
 | 
-(define-vop (--c/fixnum fast---c/fixnum=>fixnum)
 
 | 
| 
273
 | 
 
 | 
-  (:policy :safe)
 
 | 
| 
274
 | 
 
 | 
-  (:results (r :scs (any-reg descriptor-reg)))
 
 | 
| 
275
 | 
 
 | 
-  (:result-types tagged-num)
 
 | 
| 
276
 | 
 
 | 
-  (:note _N"safe inline fixnum arithmetic")
 
 | 
| 
277
 | 
 
 | 
-  (:generator 3
 
 | 
| 
278
 | 
 
 | 
-    (inst tsubcctv r x (fixnumize y))))
 
 | 
| 
279
 | 
 
 | 
-
 
 | 
| 
280
 | 
 
 | 
-)
 
 | 
| 
281
 | 
 
 | 
-
 
 | 
| 
282
 | 
241
 | 
 ;;; Truncate
 
 | 
| 
283
 | 
242
 | 
 
 
 | 
| 
284
 | 
 
 | 
-;; This doesn't work for some reason.
 
 | 
| 
285
 | 
 
 | 
-#+nil
 
 | 
| 
286
 | 
 
 | 
-(define-vop (fast-v8-truncate/fixnum=>fixnum fast-safe-arith-op)
 
 | 
| 
287
 | 
 
 | 
-  (:translate truncate)
 
 | 
| 
288
 | 
 
 | 
-  (:args (x :scs (any-reg))
 
 | 
| 
289
 | 
 
 | 
-	 (y :scs (any-reg)))
 
 | 
| 
290
 | 
 
 | 
-  (:arg-types tagged-num tagged-num)
 
 | 
| 
291
 | 
 
 | 
-  (:results (quo :scs (any-reg))
 
 | 
| 
292
 | 
 
 | 
-	    (rem :scs (any-reg)))
 
 | 
| 
293
 | 
 
 | 
-  (:result-types tagged-num tagged-num)
 
 | 
| 
294
 | 
 
 | 
-  (:note _N"inline fixnum arithmetic")
 
 | 
| 
295
 | 
 
 | 
-  (:temporary (:scs (any-reg) :target quo) q)
 
 | 
| 
296
 | 
 
 | 
-  (:temporary (:scs (any-reg)) r)
 
 | 
| 
297
 | 
 
 | 
-  (:temporary (:scs (signed-reg)) y-int)
 
 | 
| 
298
 | 
 
 | 
-  (:vop-var vop)
 
 | 
| 
299
 | 
 
 | 
-  (:save-p :compute-only)
 
 | 
| 
300
 | 
 
 | 
-  (:guard (or (backend-featurep :sparc-v8)
 
 | 
| 
301
 | 
 
 | 
-	      (and (backend-featurep :sparc-v9)
 
 | 
| 
302
 | 
 
 | 
-		   (not (backend-featurep :sparc-64)))))
 
 | 
| 
303
 | 
 
 | 
-  (:generator 12
 
 | 
| 
304
 | 
 
 | 
-    (let ((zero (generate-error-code vop division-by-zero-error x y)))
 
 | 
| 
305
 | 
 
 | 
-      (inst cmp y zero-tn)
 
 | 
| 
306
 | 
 
 | 
-      (inst b :eq zero)
 
 | 
| 
307
 | 
 
 | 
-      ;; Extend the sign of X into the Y register
 
 | 
| 
308
 | 
 
 | 
-        (inst sra r x 31)
 
 | 
| 
309
 | 
 
 | 
-      (inst wry r)
 
 | 
| 
310
 | 
 
 | 
-      ;; Remove tag bits so Q and R will be tagged correctly.
 
 | 
| 
311
 | 
 
 | 
-      (inst sra y-int y fixnum-tag-bits)
 
 | 
| 
312
 | 
 
 | 
-      (inst nop)
 
 | 
| 
313
 | 
 
 | 
-      (inst nop)
 
 | 
| 
314
 | 
 
 | 
-
 
 | 
| 
315
 | 
 
 | 
-      (inst sdiv q x y-int)		; Q is tagged.
 
 | 
| 
316
 | 
 
 | 
-      ;; We have the quotient so we need to compute the remainder
 
 | 
| 
317
 | 
 
 | 
-      (inst smul r q y-int)		; R is tagged
 
 | 
| 
318
 | 
 
 | 
-      (inst sub rem x r)
 
 | 
| 
319
 | 
 
 | 
-      (unless (location= quo q)
 
 | 
| 
320
 | 
 
 | 
-	(move quo q)))))
 
 | 
| 
321
 | 
 
 | 
-
 
 | 
| 
322
 | 
 
 | 
-(define-vop (fast-v8-truncate/signed=>signed fast-safe-arith-op)
 
 | 
| 
 
 | 
243
 | 
+(define-vop (fast-truncate/signed=>signed fast-safe-arith-op)
 
 | 
| 
323
 | 
244
 | 
   (:translate truncate)
 
 | 
| 
324
 | 
245
 | 
   (:args (x :scs (signed-reg))
 
 | 
| 
325
 | 
246
 | 
 	 (y :scs (signed-reg)))
 
 | 
| ... | 
... | 
@@ -332,29 +253,21 @@ | 
| 
332
 | 
253
 | 
   (:temporary (:scs (signed-reg)) r)
 
 | 
| 
333
 | 
254
 | 
   (:vop-var vop)
 
 | 
| 
334
 | 
255
 | 
   (:save-p :compute-only)
 
 | 
| 
335
 | 
 
 | 
-  (:guard (or (backend-featurep :sparc-v8)
 
 | 
| 
336
 | 
 
 | 
-	      (and (backend-featurep :sparc-v9)
 
 | 
| 
337
 | 
 
 | 
-		   (not (backend-featurep :sparc-64)))))
 
 | 
| 
338
 | 
256
 | 
   (:generator 12
 
 | 
| 
339
 | 
257
 | 
     (emit-not-implemented)
 
 | 
| 
340
 | 
258
 | 
     (let ((zero (generate-error-code vop division-by-zero-error x y)))
 
 | 
| 
341
 | 
259
 | 
       (inst cmp y zero-tn)
 
 | 
| 
342
 | 
 
 | 
-      (inst b :eq zero #+sparc-v9 :pn)
 
 | 
| 
343
 | 
 
 | 
-      ;; Extend the sign of X into the Y register
 
 | 
| 
344
 | 
 
 | 
-        (inst sra r x 31)
 
 | 
| 
345
 | 
 
 | 
-      (inst wry r)
 
 | 
| 
346
 | 
 
 | 
-      (inst nop)
 
 | 
| 
347
 | 
 
 | 
-      (inst nop)
 
 | 
| 
 
 | 
260
 | 
+      (inst b :eq zero :pn)
 
 | 
| 
348
 | 
261
 | 
       (inst nop)
 
 | 
| 
349
 | 
262
 | 
 
 
 | 
| 
350
 | 
 
 | 
-      (inst sdiv q x y)
 
 | 
| 
 
 | 
263
 | 
+      (inst sdivx q x y)
 
 | 
| 
351
 | 
264
 | 
       ;; We have the quotient so we need to compue the remainder
 
 | 
| 
352
 | 
 
 | 
-      (inst smul r q y)		; rem
 
 | 
| 
 
 | 
265
 | 
+      (inst mulx r q y)		; rem
 
 | 
| 
353
 | 
266
 | 
       (inst sub rem x r)
 
 | 
| 
354
 | 
267
 | 
       (unless (location= quo q)
 
 | 
| 
355
 | 
268
 | 
 	(move quo q)))))
 
 | 
| 
356
 | 
269
 | 
 
 
 | 
| 
357
 | 
 
 | 
-(define-vop (fast-v8-truncate/unsigned=>unsigned fast-safe-arith-op)
 
 | 
| 
 
 | 
270
 | 
+(define-vop (fast-truncate/unsigned=>unsigned fast-safe-arith-op)
 
 | 
| 
358
 | 
271
 | 
   (:translate truncate)
 
 | 
| 
359
 | 
272
 | 
   (:args (x :scs (unsigned-reg))
 
 | 
| 
360
 | 
273
 | 
 	 (y :scs (unsigned-reg)))
 
 | 
| ... | 
... | 
@@ -367,105 +280,13 @@ | 
| 
367
 | 
280
 | 
   (:temporary (:scs (unsigned-reg)) r)
 
 | 
| 
368
 | 
281
 | 
   (:vop-var vop)
 
 | 
| 
369
 | 
282
 | 
   (:save-p :compute-only)
 
 | 
| 
370
 | 
 
 | 
-  (:guard (or (backend-featurep :sparc-v8)
 
 | 
| 
371
 | 
 
 | 
-	      (and (backend-featurep :sparc-v9)
 
 | 
| 
372
 | 
 
 | 
-		   (not (backend-featurep :sparc-64)))))
 
 | 
| 
373
 | 
 
 | 
-  (:generator 8
 
 | 
| 
374
 | 
 
 | 
-    (emit-not-implemented)
 
 | 
| 
375
 | 
 
 | 
-    (let ((zero (generate-error-code vop division-by-zero-error x y)))
 
 | 
| 
376
 | 
 
 | 
-      (inst cmp y zero-tn)
 
 | 
| 
377
 | 
 
 | 
-      (inst b :eq zero #+sparc-v9 :pn)
 
 | 
| 
378
 | 
 
 | 
-        (inst wry zero-tn)		; Clear out high part
 
 | 
| 
379
 | 
 
 | 
-      (inst nop)
 
 | 
| 
380
 | 
 
 | 
-      (inst nop)
 
 | 
| 
381
 | 
 
 | 
-      (inst nop)
 
 | 
| 
382
 | 
 
 | 
-      
 
 | 
| 
383
 | 
 
 | 
-      (inst udiv q x y)
 
 | 
| 
384
 | 
 
 | 
-      ;; Compute remainder
 
 | 
| 
385
 | 
 
 | 
-      (inst umul r q y)
 
 | 
| 
386
 | 
 
 | 
-      (inst sub rem x r)
 
 | 
| 
387
 | 
 
 | 
-      (unless (location= quo q)
 
 | 
| 
388
 | 
 
 | 
-	(inst move quo q)))))
 
 | 
| 
389
 | 
 
 | 
-
 
 | 
| 
390
 | 
 
 | 
-(define-vop (fast-v9-truncate/signed=>signed fast-safe-arith-op)
 
 | 
| 
391
 | 
 
 | 
-  (:translate truncate)
 
 | 
| 
392
 | 
 
 | 
-  (:args (x :scs (signed-reg))
 
 | 
| 
393
 | 
 
 | 
-	 (y :scs (signed-reg)))
 
 | 
| 
394
 | 
 
 | 
-  (:arg-types signed-num signed-num)
 
 | 
| 
395
 | 
 
 | 
-  (:results (quo :scs (signed-reg))
 
 | 
| 
396
 | 
 
 | 
-	    (rem :scs (signed-reg)))
 
 | 
| 
397
 | 
 
 | 
-  (:result-types signed-num signed-num)
 
 | 
| 
398
 | 
 
 | 
-  (:note _N"inline (signed-byte 32) arithmetic")
 
 | 
| 
399
 | 
 
 | 
-  (:temporary (:scs (signed-reg) :target quo) q)
 
 | 
| 
400
 | 
 
 | 
-  (:temporary (:scs (signed-reg)) r)
 
 | 
| 
401
 | 
 
 | 
-  (:vop-var vop)
 
 | 
| 
402
 | 
 
 | 
-  (:save-p :compute-only)
 
 | 
| 
403
 | 
 
 | 
-  (:guard (backend-featurep :sparc-64))
 
 | 
| 
404
 | 
283
 | 
   (:generator 8
 
 | 
| 
405
 | 
284
 | 
     (emit-not-implemented)
 
 | 
| 
406
 | 
285
 | 
     (let ((zero (generate-error-code vop division-by-zero-error x y)))
 
 | 
| 
407
 | 
286
 | 
       (inst cmp y zero-tn)
 
 | 
| 
408
 | 
287
 | 
       (inst b :eq zero :pn)
 
 | 
| 
409
 | 
 
 | 
-      ;; Sign extend the numbers, just in case.
 
 | 
| 
410
 | 
 
 | 
-        (inst signx x)
 
 | 
| 
411
 | 
 
 | 
-      (inst signx y)
 
 | 
| 
412
 | 
 
 | 
-      (inst sdivx q x y)
 
 | 
| 
413
 | 
 
 | 
-      ;; Compute remainder
 
 | 
| 
414
 | 
 
 | 
-      (inst mulx r q y)
 
 | 
| 
415
 | 
 
 | 
-      (inst sub rem x r)
 
 | 
| 
416
 | 
 
 | 
-      (unless (location= quo q)
 
 | 
| 
417
 | 
 
 | 
-	(inst move quo q)))))
 
 | 
| 
418
 | 
 
 | 
-
 
 | 
| 
419
 | 
 
 | 
-#+nil
 
 | 
| 
420
 | 
 
 | 
-(define-vop (fast-v9-truncate/signed64=>signed64 fast-safe-arith-op)
 
 | 
| 
421
 | 
 
 | 
-  (:translate truncate)
 
 | 
| 
422
 | 
 
 | 
-  (:args (x :scs (signed64-reg))
 
 | 
| 
423
 | 
 
 | 
-	 (y :scs (signed64-reg)))
 
 | 
| 
424
 | 
 
 | 
-  (:arg-types signed64-num signed64-num)
 
 | 
| 
425
 | 
 
 | 
-  (:results (quo :scs (signed64-reg))
 
 | 
| 
426
 | 
 
 | 
-	    (rem :scs (signed64-reg)))
 
 | 
| 
427
 | 
 
 | 
-  (:result-types signed64-num signed64-num)
 
 | 
| 
428
 | 
 
 | 
-  (:note _N"inline (signed-byte 32) arithmetic")
 
 | 
| 
429
 | 
 
 | 
-  (:temporary (:scs (signed64-reg) :target quo) q)
 
 | 
| 
430
 | 
 
 | 
-  (:temporary (:scs (signed64-reg)) r)
 
 | 
| 
431
 | 
 
 | 
-  (:vop-var vop)
 
 | 
| 
432
 | 
 
 | 
-  (:save-p :compute-only)
 
 | 
| 
433
 | 
 
 | 
-  (:guard (backend-featurep :sparc-v9))
 
 | 
| 
434
 | 
 
 | 
-  (:generator 8
 
 | 
| 
435
 | 
 
 | 
-    (let ((zero (generate-error-code vop division-by-zero-error x y)))
 
 | 
| 
436
 | 
 
 | 
-      (inst cmp y zero-tn)
 
 | 
| 
437
 | 
 
 | 
-      (inst b :eq zero :pn :xcc)
 
 | 
| 
438
 | 
288
 | 
       (inst nop)
 
 | 
| 
439
 | 
 
 | 
-
 
 | 
| 
440
 | 
 
 | 
-      (inst sdivx q x y)
 
 | 
| 
441
 | 
 
 | 
-      ;; Compute remainder
 
 | 
| 
442
 | 
 
 | 
-      (inst mulx r q y)
 
 | 
| 
443
 | 
 
 | 
-      (inst sub rem x r)
 
 | 
| 
444
 | 
 
 | 
-      (unless (location= quo q)
 
 | 
| 
445
 | 
 
 | 
-	(inst move quo q)))))
 
 | 
| 
446
 | 
 
 | 
-
 
 | 
| 
447
 | 
 
 | 
-(define-vop (fast-v9-truncate/unsigned=>unsigned fast-safe-arith-op)
 
 | 
| 
448
 | 
 
 | 
-  (:translate truncate)
 
 | 
| 
449
 | 
 
 | 
-  (:args (x :scs (unsigned-reg))
 
 | 
| 
450
 | 
 
 | 
-	 (y :scs (unsigned-reg)))
 
 | 
| 
451
 | 
 
 | 
-  (:arg-types unsigned-num unsigned-num)
 
 | 
| 
452
 | 
 
 | 
-  (:results (quo :scs (unsigned-reg))
 
 | 
| 
453
 | 
 
 | 
-	    (rem :scs (unsigned-reg)))
 
 | 
| 
454
 | 
 
 | 
-  (:result-types unsigned-num unsigned-num)
 
 | 
| 
455
 | 
 
 | 
-  (:note _N"inline (unsigned-byte 32) arithmetic")
 
 | 
| 
456
 | 
 
 | 
-  (:temporary (:scs (unsigned-reg) :target quo) q)
 
 | 
| 
457
 | 
 
 | 
-  (:temporary (:scs (unsigned-reg)) r)
 
 | 
| 
458
 | 
 
 | 
-  (:vop-var vop)
 
 | 
| 
459
 | 
 
 | 
-  (:save-p :compute-only)
 
 | 
| 
460
 | 
 
 | 
-  (:guard (backend-featurep :sparc-64))
 
 | 
| 
461
 | 
 
 | 
-  (:generator 8
 
 | 
| 
462
 | 
 
 | 
-    (emit-not-implemented)
 
 | 
| 
463
 | 
 
 | 
-    (let ((zero (generate-error-code vop division-by-zero-error x y)))
 
 | 
| 
464
 | 
 
 | 
-      (inst cmp y zero-tn)
 
 | 
| 
465
 | 
 
 | 
-      (inst b :eq zero :pn)
 
 | 
| 
466
 | 
 
 | 
-      ;; Zap the higher 32 bits, just in case
 
 | 
| 
467
 | 
 
 | 
-        (inst clruw x)
 
 | 
| 
468
 | 
 
 | 
-      (inst clruw y)
 
 | 
| 
 
 | 
289
 | 
+      
 
 | 
| 
469
 | 
290
 | 
       (inst udivx q x y)
 
 | 
| 
470
 | 
291
 | 
       ;; Compute remainder
 
 | 
| 
471
 | 
292
 | 
       (inst mulx r q y)
 
 | 
| ... | 
... | 
@@ -473,6 +294,7 @@ | 
| 
473
 | 
294
 | 
       (unless (location= quo q)
 
 | 
| 
474
 | 
295
 | 
 	(inst move quo q)))))
 
 | 
| 
475
 | 
296
 | 
 
 
 | 
| 
 
 | 
297
 | 
+
 
 | 
| 
476
 | 
298
 | 
 ;;; Shifting
 
 | 
| 
477
 | 
299
 | 
 
 
 | 
| 
478
 | 
300
 | 
 (define-vop (fast-ash/signed=>signed)
 
 |