From 57b60fc794a95bdea4388497e5752e6825af988d Mon Sep 17 00:00:00 2001 From: Janneke Nieuwenhuizen Date: Sun, 30 Jul 2023 09:51:08 +0200 Subject: [PATCH] HACK mescc: Consider truncate after each shift operation. XXX For every binop / binop* operation? We need tests? * module/mescc/compile.scm (expr->register): After lshift and rshift, use convert-r0. --- module/mescc/compile.scm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/module/mescc/compile.scm b/module/mescc/compile.scm index 06d5dc24..1b6dfc46 100644 --- a/module/mescc/compile.scm +++ b/module/mescc/compile.scm @@ -1215,8 +1215,14 @@ (append-text info (wrap-as (as info 'not-r))))) ((bitwise-or ,a ,b) ((binop->r info) a b 'r0-or-r1)) ((bitwise-xor ,a ,b) ((binop->r info) a b 'r0-xor-r1)) - ((lshift ,a ,b) ((binop->r info) a b 'r0<r info) a b 'r0>>r1)) + ((lshift ,a ,b) ;; FIXME for all binop/binop*? + (let* ((type-a (ast->type a info)) + (info ((binop->r info) a b 'r0<type a info)) + (info ((binop->r info) a b 'r0>>r1))) + (append-text info (convert-r0 info type-a)))) ((div ,a ,b) ((binop->r info) a b 'r0/r1 (signed? (ast->type a info))))