mescc: Use signed integer comparison.
* module/language/c99/compiler.mes (test->jump->info): * module/mes/as-i386.mes (i386:Xjump-le, i386:Xjump-g, i386:Xjump-l, i386:Xjump-ge): New functions. * module/mes/as-i386.scm: Export them. * scaffold/t.c (math_test): Test them. * tests/scm.test ("iota -1"): Enable for mesc.
This commit is contained in:
parent
66b53669f8
commit
ce55c198c0
|
@ -1079,10 +1079,17 @@
|
||||||
(jump-text body-length)))))))
|
(jump-text body-length)))))))
|
||||||
(lambda (o)
|
(lambda (o)
|
||||||
(pmatch o
|
(pmatch o
|
||||||
((le ,a ,b) ((jump i386:Xjump-ncz) o))
|
;; unsigned
|
||||||
((lt ,a ,b) ((jump i386:Xjump-nc) o))
|
;; ((le ,a ,b) ((jump i386:Xjump-ncz) o)) ; ja
|
||||||
((ge ,a ,b) ((jump i386:Xjump-ncz) o))
|
;; ((lt ,a ,b) ((jump i386:Xjump-nc) o)) ; jae
|
||||||
((gt ,a ,b) ((jump i386:Xjump-nc) o))
|
;; ((ge ,a ,b) ((jump i386:Xjump-ncz) o))
|
||||||
|
;; ((gt ,a ,b) ((jump i386:Xjump-nc) o))
|
||||||
|
|
||||||
|
((le ,a ,b) ((jump i386:Xjump-g) o))
|
||||||
|
((lt ,a ,b) ((jump i386:Xjump-ge) o))
|
||||||
|
((ge ,a ,b) ((jump i386:Xjump-g) o))
|
||||||
|
((gt ,a ,b) ((jump i386:Xjump-ge) o))
|
||||||
|
|
||||||
((ne ,a ,b) ((jump i386:Xjump-nz) o))
|
((ne ,a ,b) ((jump i386:Xjump-nz) o))
|
||||||
((eq ,a ,b) ((jump i386:Xjump-nz) o))
|
((eq ,a ,b) ((jump i386:Xjump-nz) o))
|
||||||
((not _) ((jump i386:Xjump-z) o))
|
((not _) ((jump i386:Xjump-z) o))
|
||||||
|
|
|
@ -342,10 +342,6 @@
|
||||||
barf)
|
barf)
|
||||||
`(#x72 ,(if (>= n 0) n (- n 2)))) ; jc <n>
|
`(#x72 ,(if (>= n 0) n (- n 2)))) ; jc <n>
|
||||||
|
|
||||||
(define (i386:Xjump-c n)
|
|
||||||
(or n urg:Xjump-c)
|
|
||||||
`(#x0f #x82 ,@(int->bv32 n))) ; jc <n>
|
|
||||||
|
|
||||||
(define (i386:jump-cz n)
|
(define (i386:jump-cz n)
|
||||||
(when (or (> n #x80) (< n #x-80))
|
(when (or (> n #x80) (< n #x-80))
|
||||||
(format (current-error-port) "JUMP n=~a\n" n)
|
(format (current-error-port) "JUMP n=~a\n" n)
|
||||||
|
@ -364,18 +360,46 @@
|
||||||
barf)
|
barf)
|
||||||
`(#x73 ,(if (>= n 0) n (- n 2)))) ; jnc <n>
|
`(#x73 ,(if (>= n 0) n (- n 2)))) ; jnc <n>
|
||||||
|
|
||||||
|
;; unsigned
|
||||||
(define (i386:Xjump-nc n)
|
(define (i386:Xjump-nc n)
|
||||||
(or n urg:Xjump-nc)
|
(or n urg:Xjump-nc)
|
||||||
`(#x0f #x83 ,@(int->bv32 n))) ; jnc <n>
|
`(#x0f #x83 ,@(int->bv32 n))) ; jnc <n>
|
||||||
|
|
||||||
(define (i386:Xjump-cz n)
|
;; unsigned
|
||||||
(or n urg:Xjump-cz)
|
|
||||||
`(#x0f #x86 ,@(int->bv32 n))) ; jbe <n>
|
|
||||||
|
|
||||||
(define (i386:Xjump-ncz n)
|
(define (i386:Xjump-ncz n)
|
||||||
(or n urg:Xjump-ncz)
|
(or n urg:Xjump-ncz)
|
||||||
`(#x0f #x87 ,@(int->bv32 n))) ; ja <n>
|
`(#x0f #x87 ,@(int->bv32 n))) ; ja <n>
|
||||||
|
|
||||||
|
;; unsigned
|
||||||
|
;; (define (i386:Xjump-c n)
|
||||||
|
;; (or n urg:Xjump-c)
|
||||||
|
;; `(#x0f #x82 ,@(int->bv32 n))) ; jc <n>
|
||||||
|
|
||||||
|
;; unsigned
|
||||||
|
;; (define (i386:Xjump-cz n)
|
||||||
|
;; (or n urg:Xjump-cz)
|
||||||
|
;; `(#x0f #x86 ,@(int->bv32 n))) ; jbe <n>
|
||||||
|
|
||||||
|
;; signed
|
||||||
|
(define (i386:Xjump-g n)
|
||||||
|
(or n urg:Xjump-g)
|
||||||
|
`(#x0f #x8f ,@(int->bv32 n))) ; jg/jnle <n>
|
||||||
|
|
||||||
|
;; signed
|
||||||
|
(define (i386:Xjump-ge n)
|
||||||
|
(or n urg:Xjump-ge)
|
||||||
|
`(#x0f #x8d ,@(int->bv32 n))) ; jge/jnl <n>
|
||||||
|
|
||||||
|
;; ;; signed
|
||||||
|
;; (define (i386:Xjump-l n)
|
||||||
|
;; (or n urg:Xjump-l)
|
||||||
|
;; `(#x0f #x8c ,@(int->bv32 n))) ; jl/jnge <n>
|
||||||
|
|
||||||
|
;; ;; signed
|
||||||
|
;; (define (i386:Xjump-le n)
|
||||||
|
;; (or n urg:Xjump-le)
|
||||||
|
;; `(#x0f #x8e ,@(int->bv32 n))) ; jle/jgn <n>
|
||||||
|
|
||||||
(define (i386:jump-z n)
|
(define (i386:jump-z n)
|
||||||
(when (or (> n #x80) (< n #x-80))
|
(when (or (> n #x80) (< n #x-80))
|
||||||
(format (current-error-port) "JUMP-z n=~a\n" n)
|
(format (current-error-port) "JUMP-z n=~a\n" n)
|
||||||
|
|
|
@ -120,14 +120,20 @@
|
||||||
|
|
||||||
;; long jump
|
;; long jump
|
||||||
i386:Xjump
|
i386:Xjump
|
||||||
i386:Xjump
|
;;i386:Xjump-c
|
||||||
i386:Xjump-c
|
;;i386:Xjump-cz
|
||||||
i386:Xjump-cz
|
|
||||||
i386:Xjump-nc
|
i386:Xjump-nc
|
||||||
i386:Xjump-ncz
|
i386:Xjump-ncz
|
||||||
|
|
||||||
i386:Xjump-nz
|
i386:Xjump-nz
|
||||||
i386:Xjump-z
|
i386:Xjump-z
|
||||||
|
|
||||||
|
i386:Xjump-g
|
||||||
|
i386:Xjump-ge
|
||||||
|
|
||||||
|
;; i386:Xjump-l
|
||||||
|
;; i386:Xjump-le
|
||||||
|
|
||||||
i386:XXjump
|
i386:XXjump
|
||||||
|
|
||||||
i386:accu+n
|
i386:accu+n
|
||||||
|
|
|
@ -1368,11 +1368,6 @@ less_p (SCM x) ///((name . "<") (arity . n))
|
||||||
while (x != cell_nil)
|
while (x != cell_nil)
|
||||||
{
|
{
|
||||||
assert (TYPE (car (x)) == TNUMBER);
|
assert (TYPE (car (x)) == TNUMBER);
|
||||||
#if __MESC__
|
|
||||||
//FIXME __GNUC__
|
|
||||||
if (n == INT_MIN);
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
if (VALUE (car (x)) <= n) return cell_f;
|
if (VALUE (car (x)) <= n) return cell_f;
|
||||||
n = VALUE (car (x));
|
n = VALUE (car (x));
|
||||||
x = cdr (x);
|
x = cdr (x);
|
||||||
|
|
24
scaffold/t.c
24
scaffold/t.c
|
@ -177,6 +177,30 @@ read_test ()
|
||||||
int
|
int
|
||||||
math_test ()
|
math_test ()
|
||||||
{
|
{
|
||||||
|
puts ("t: 0 < 0\n");
|
||||||
|
if (0 < 0) return 1;
|
||||||
|
|
||||||
|
puts ("t: 2 < 1\n");
|
||||||
|
if (2 < 1) return 1;
|
||||||
|
|
||||||
|
puts ("t: -1 < -2\n");
|
||||||
|
if (-1 < -2) return 1;
|
||||||
|
|
||||||
|
puts ("t: 0 < -1\n");
|
||||||
|
if (0 < -1) return 1;
|
||||||
|
|
||||||
|
puts ("t: 0 > 0\n");
|
||||||
|
if (0 > 0) return 1;
|
||||||
|
|
||||||
|
puts ("t: 1 > 2\n");
|
||||||
|
if (1 > 2) return 1;
|
||||||
|
|
||||||
|
puts ("t: -2 > -1\n");
|
||||||
|
if (-2 > -1) return 1;
|
||||||
|
|
||||||
|
puts ("t: -1 > 0\n");
|
||||||
|
if (-1 > 0) return 1;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
puts ("t: 4/2=");
|
puts ("t: 4/2=");
|
||||||
i = 4 / 2;
|
i = 4 / 2;
|
||||||
|
|
|
@ -122,9 +122,8 @@ exit $?
|
||||||
(pass-if-equal "iota 0"
|
(pass-if-equal "iota 0"
|
||||||
'() (iota 0))
|
'() (iota 0))
|
||||||
|
|
||||||
(if %mesc (display "***FIXME: MESCC skip iota -1")
|
(pass-if-equal "iota -1"
|
||||||
(pass-if-equal "iota -1"
|
'() (iota -1))
|
||||||
'() (iota -1)))
|
|
||||||
|
|
||||||
(pass-if "reverse" (sequal? (reverse '(1 2 3)) '(3 2 1)))
|
(pass-if "reverse" (sequal? (reverse '(1 2 3)) '(3 2 1)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue