mescc: Only use signed division when numerator is signed.
Currently, sign-extension (CLTD vs XOR EDX) and signed division (IDIV vs DIV) selected by setting "signed?". See, module/mescc/x86/as.scm. Possibly we need a signed? based on numerator and denominator, and add a extend-sign? based on the signedness of the numerator? * module/mescc/compile.scm (expr->register): Base "signed?" strictly on signedness of numerator.
This commit is contained in:
parent
fac6a873f7
commit
348dcbcbd7
|
@ -1218,9 +1218,9 @@
|
||||||
((rshift ,a ,b) ((binop->r info) a b 'r0>>r1))
|
((rshift ,a ,b) ((binop->r info) a b 'r0>>r1))
|
||||||
((div ,a ,b)
|
((div ,a ,b)
|
||||||
((binop->r info) a b 'r0/r1
|
((binop->r info) a b 'r0/r1
|
||||||
(or (signed? (ast->type a info)) (signed? (ast->type b info)))))
|
(signed? (ast->type a info))))
|
||||||
((mod ,a ,b) ((binop->r info) a b 'r0%r1
|
((mod ,a ,b) ((binop->r info) a b 'r0%r1
|
||||||
(or (signed? (ast->type a info)) (signed? (ast->type b info)))))
|
(signed? (ast->type a info))))
|
||||||
((mul ,a ,b) ((binop->r info) a b 'r0*r1))
|
((mul ,a ,b) ((binop->r info) a b 'r0*r1))
|
||||||
|
|
||||||
((not ,expr)
|
((not ,expr)
|
||||||
|
@ -1361,7 +1361,7 @@
|
||||||
info)))
|
info)))
|
||||||
(info (expr->register a info))
|
(info (expr->register a info))
|
||||||
(info (append-text info (wrap-as (as info 'swap-r0-r1))))
|
(info (append-text info (wrap-as (as info 'swap-r0-r1))))
|
||||||
(signed? (or (signed? type) (signed? type-b)))
|
(signed? (signed? type))
|
||||||
(info (append-text info (cond ((equal? op "+=") (wrap-as (as info 'r0+r1)))
|
(info (append-text info (cond ((equal? op "+=") (wrap-as (as info 'r0+r1)))
|
||||||
((equal? op "-=") (wrap-as (as info 'r0-r1)))
|
((equal? op "-=") (wrap-as (as info 'r0-r1)))
|
||||||
((equal? op "*=") (wrap-as (as info 'r0*r1)))
|
((equal? op "*=") (wrap-as (as info 'r0*r1)))
|
||||||
|
|
Loading…
Reference in a new issue