* Added $fl=, $fl<, $fl>, $fl<=, $fl>= primops.
This commit is contained in:
		
							parent
							
								
									d4facf79d3
								
							
						
					
					
						commit
						3f3767800d
					
				
							
								
								
									
										
											BIN
										
									
								
								src/ikarus.boot
								
								
								
								
							
							
						
						
									
										
											BIN
										
									
								
								src/ikarus.boot
								
								
								
								
							
										
											Binary file not shown.
										
									
								
							|  | @ -496,6 +496,11 @@ | ||||||
|       [(and (xmmreg? dst) (or (xmmreg? src) (mem? src))) |       [(and (xmmreg? dst) (or (xmmreg? src) (mem? src))) | ||||||
|        (CODE #xF2 (CODE #x0F ((CODE/digit #x5E dst) src ac)))] |        (CODE #xF2 (CODE #x0F ((CODE/digit #x5E dst) src ac)))] | ||||||
|       [else (error who "invalid ~s" instr)])]  |       [else (error who "invalid ~s" instr)])]  | ||||||
|  |    [(ucomisd src dst) | ||||||
|  |     (cond | ||||||
|  |       [(and (xmmreg? dst) (or (xmmreg? src) (mem? src))) | ||||||
|  |        (CODE #x66 (CODE #x0F ((CODE/digit #x2E dst) src ac)))] | ||||||
|  |       [else (error who "invalid ~s" instr)])] | ||||||
|    [(addl src dst) |    [(addl src dst) | ||||||
|     (cond    |     (cond    | ||||||
|       [(and (imm8? src) (reg? dst))  |       [(and (imm8? src) (reg? dst))  | ||||||
|  |  | ||||||
|  | @ -338,19 +338,6 @@ | ||||||
|     (binary/ (exact->inexact ($ratnum-n x))  |     (binary/ (exact->inexact ($ratnum-n x))  | ||||||
|              (exact->inexact ($ratnum-d x)))) |              (exact->inexact ($ratnum-d x)))) | ||||||
| 
 | 
 | ||||||
|   #; |  | ||||||
|   (begin |  | ||||||
|     (define ($fl+ x y) |  | ||||||
|       (foreign-call "ikrt_fl_plus" x y)) |  | ||||||
|     (define ($fl- x y) |  | ||||||
|       (foreign-call "ikrt_fl_minus" x y)) |  | ||||||
|     (define ($fl* x y) |  | ||||||
|       (foreign-call "ikrt_fl_times" x y)) |  | ||||||
|     (define ($fl/ x y) |  | ||||||
|       (foreign-call "ikrt_fl_div" x y))) |  | ||||||
|    |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|   (define binary+ |   (define binary+ | ||||||
|     (lambda (x y) |     (lambda (x y) | ||||||
|       (cond |       (cond | ||||||
|  | @ -1187,16 +1174,18 @@ | ||||||
|          (define-syntax bnfl?  |          (define-syntax bnfl?  | ||||||
|            (syntax-rules () [(_ x y) (fl? (bignum->flonum x) y)])))])) |            (syntax-rules () [(_ x y) (fl? (bignum->flonum x) y)])))])) | ||||||
| 
 | 
 | ||||||
|   (define-syntax $fl= |  ;;;  #; | ||||||
|     (syntax-rules () [(_ x y) (foreign-call "ikrt_fl_equal" x y)])) |  ;;; (begin | ||||||
|   (define-syntax $fl< |  ;;;   (define-syntax $fl= | ||||||
|     (syntax-rules () [(_ x y) (foreign-call "ikrt_fl_less" x y)])) |  ;;;     (syntax-rules () [(_ x y) (foreign-call "ikrt_fl_equal" x y)])) | ||||||
|   (define-syntax $fl<= |  ;;;   (define-syntax $fl< | ||||||
|     (syntax-rules () [(_ x y) (foreign-call "ikrt_fl_less_or_equal" x y)])) |  ;;;     (syntax-rules () [(_ x y) (foreign-call "ikrt_fl_less" x y)])) | ||||||
|   (define-syntax $fl> |  ;;;   (define-syntax $fl<= | ||||||
|     (syntax-rules () [(_ x y) (foreign-call "ikrt_fl_less" y x)])) |  ;;;     (syntax-rules () [(_ x y) (foreign-call "ikrt_fl_less_or_equal" x y)])) | ||||||
|   (define-syntax $fl>= |  ;;;   (define-syntax $fl> | ||||||
|     (syntax-rules () [(_ x y) (foreign-call "ikrt_fl_less_or_equal" y x)])) |  ;;;     (syntax-rules () [(_ x y) (foreign-call "ikrt_fl_less" y x)])) | ||||||
|  |  ;;;   (define-syntax $fl>= | ||||||
|  |  ;;;     (syntax-rules () [(_ x y) (foreign-call "ikrt_fl_less_or_equal" y x)]))) | ||||||
| 
 | 
 | ||||||
|   (define-syntax define-flcmp |   (define-syntax define-flcmp | ||||||
|     (syntax-rules () |     (syntax-rules () | ||||||
|  |  | ||||||
|  | @ -470,7 +470,6 @@ | ||||||
|       [(bind lhs* rhs* e) |       [(bind lhs* rhs* e) | ||||||
|        (do-bind lhs* rhs* (P e))] |        (do-bind lhs* rhs* (P e))] | ||||||
|       [(primcall op rands) |       [(primcall op rands) | ||||||
|                 (unless (pair? rands) (error 'car "ha ~s" x)) |  | ||||||
|        (let ([a (car rands)] [b (cadr rands)]) |        (let ([a (car rands)] [b (cadr rands)]) | ||||||
|          (cond |          (cond | ||||||
|            [(and (constant? a) (constant? b)) |            [(and (constant? a) (constant? b)) | ||||||
|  | @ -2208,6 +2207,13 @@ | ||||||
|         [(seq e0 e1) (make-seq (E e0) (P e1))] |         [(seq e0 e1) (make-seq (E e0) (P e1))] | ||||||
|         [(asm-instr op a b)  |         [(asm-instr op a b)  | ||||||
|          (cond |          (cond | ||||||
|  |            [(memq op '(fl:= fl:< fl:<= fl:> fl:>=))  | ||||||
|  |             (if (mem? a)  | ||||||
|  |                 (let ([u (mku)]) | ||||||
|  |                   (make-seq  | ||||||
|  |                     (E (make-asm-instr 'move u a)) | ||||||
|  |                     (make-asm-instr op u b))) | ||||||
|  |                 x)] | ||||||
|            [(and (mem? a) (mem? b))  |            [(and (mem? a) (mem? b))  | ||||||
|             (let ([u (mku)]) |             (let ([u (mku)]) | ||||||
|               (make-seq |               (make-seq | ||||||
|  | @ -2527,13 +2533,17 @@ | ||||||
|          (define (notop x) |          (define (notop x) | ||||||
|            (cond |            (cond | ||||||
|              [(assq x '([= !=] [!= =] [< >=] [<= >] [> <=] [>= <] |              [(assq x '([= !=] [!= =] [< >=] [<= >] [> <=] [>= <] | ||||||
|                         [u< u>=] [u<= u>] [u> u<=] [u>= u<])) |                         [u< u>=] [u<= u>] [u> u<=] [u>= u<] | ||||||
|  |                         [fl:= fl:!=] [fl:!= fl:=]  | ||||||
|  |                         [fl:< fl:>=] [fl:<= fl:>] [fl:> fl:<=] [fl:>= fl:<])) | ||||||
|               => cadr] |               => cadr] | ||||||
|              [else (error who "invalid op ~s" x)])) |              [else (error who "invalid op ~s" x)])) | ||||||
|          (define (jmpname x) |          (define (jmpname x) | ||||||
|            (cond |            (cond | ||||||
|              [(assq x '([= je] [!= jne] [< jl] [<= jle] [> jg] [>= jge] |              [(assq x '([= je] [!= jne] [< jl] [<= jle] [> jg] [>= jge] | ||||||
|                         [u< jb] [u<= jbe] [u> ja] [u>= jae])) |                         [u< jb] [u<= jbe] [u> ja] [u>= jae] | ||||||
|  |                         [fl:= je] [fl:!= jne] | ||||||
|  |                         [fl:< jl] [fl:> jg] [fl:<= jle] [fl:>= jge])) | ||||||
|               => cadr] |               => cadr] | ||||||
|              [else (error who "invalid jmpname ~s" x)])) |              [else (error who "invalid jmpname ~s" x)])) | ||||||
|          (define (revjmpname x) |          (define (revjmpname x) | ||||||
|  | @ -2544,6 +2554,10 @@ | ||||||
|              [else (error who "invalid jmpname ~s" x)])) |              [else (error who "invalid jmpname ~s" x)])) | ||||||
|          (define (cmp op a0 a1 lab ac) |          (define (cmp op a0 a1 lab ac) | ||||||
|            (cond |            (cond | ||||||
|  |              [(memq op '(fl:= fl:!= fl:< fl:<= fl:> fl:>=)) | ||||||
|  |               (list* `(ucomisd ,(R (make-disp a0 a1)) xmm0) | ||||||
|  |                      `(,(jmpname op) ,lab) | ||||||
|  |                      ac)] | ||||||
|              [(or (symbol? a0) (constant? a1)) |              [(or (symbol? a0) (constant? a1)) | ||||||
|               (list* `(cmpl ,(R a1) ,(R a0)) |               (list* `(cmpl ,(R a1) ,(R a0)) | ||||||
|                      `(,(jmpname op) ,lab) |                      `(,(jmpname op) ,lab) | ||||||
|  |  | ||||||
|  | @ -607,6 +607,11 @@ | ||||||
|     [$fl-                           $flonums] |     [$fl-                           $flonums] | ||||||
|     [$fl*                           $flonums] |     [$fl*                           $flonums] | ||||||
|     [$fl/                           $flonums] |     [$fl/                           $flonums] | ||||||
|  |     [$fl=                           $flonums] | ||||||
|  |     [$fl<                           $flonums] | ||||||
|  |     [$fl<=                           $flonums] | ||||||
|  |     [$fl>                           $flonums] | ||||||
|  |     [$fl>=                           $flonums] | ||||||
| 
 | 
 | ||||||
|     [$make-bignum       $bignums] |     [$make-bignum       $bignums] | ||||||
|     [$bignum-positive?  $bignums] |     [$bignum-positive?  $bignums] | ||||||
|  |  | ||||||
|  | @ -729,6 +729,11 @@ | ||||||
|      (prm 'fl:store x (K (- disp-flonum-data vector-tag))) |      (prm 'fl:store x (K (- disp-flonum-data vector-tag))) | ||||||
|      x)) |      x)) | ||||||
| 
 | 
 | ||||||
|  | (define ($flcmp-aux op fl0 fl1) | ||||||
|  |   (make-seq  | ||||||
|  |     (prm 'fl:load (T fl0) (K (- disp-flonum-data vector-tag))) | ||||||
|  |     (prm op (T fl1) (K (- disp-flonum-data vector-tag))))) | ||||||
|  | 
 | ||||||
| (define-primop flonum? safe | (define-primop flonum? safe | ||||||
|   [(P x) (sec-tag-test (T x) vector-mask vector-tag #f flonum-tag)] |   [(P x) (sec-tag-test (T x) vector-mask vector-tag #f flonum-tag)] | ||||||
|   [(E x) (nop)]) |   [(E x) (nop)]) | ||||||
|  | @ -777,6 +782,17 @@ | ||||||
| (define-primop $fl/ unsafe | (define-primop $fl/ unsafe | ||||||
|   [(V x y) ($flop-aux 'fl:div! x y)]) |   [(V x y) ($flop-aux 'fl:div! x y)]) | ||||||
| 
 | 
 | ||||||
|  | (define-primop $fl= unsafe | ||||||
|  |   [(P x y) ($flcmp-aux 'fl:= x y)]) | ||||||
|  | (define-primop $fl< unsafe | ||||||
|  |   [(P x y) ($flcmp-aux 'fl:< x y)]) | ||||||
|  | (define-primop $fl<= unsafe | ||||||
|  |   [(P x y) ($flcmp-aux 'fl:<= x y)]) | ||||||
|  | (define-primop $fl> unsafe | ||||||
|  |   [(P x y) ($flcmp-aux 'fl:> x y)]) | ||||||
|  | (define-primop $fl>= unsafe | ||||||
|  |   [(P x y) ($flcmp-aux 'fl:>= x y)]) | ||||||
|  | 
 | ||||||
| /section) | /section) | ||||||
| 
 | 
 | ||||||
| (section ;;; ratnums | (section ;;; ratnums | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Abdulaziz Ghuloum
						Abdulaziz Ghuloum