[Git][ghc/ghc][wip/js-staging] Use GHCJS's signExtend/narrow

Sylvain Henry (@hsyl20) gitlab at gitlab.haskell.org
Tue Oct 4 15:30:36 UTC 2022



Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC


Commits:
6a0f68a6 by Sylvain Henry at 2022-10-04T17:33:52+02:00
Use GHCJS's signExtend/narrow

- - - - -


1 changed file:

- compiler/GHC/JS/Make.hs


Changes:

=====================================
compiler/GHC/JS/Make.hs
=====================================
@@ -483,13 +483,13 @@ mask8 x = BAnd x (Int 0xFF)
 mask16 :: JExpr -> JExpr
 mask16 x = BAnd x (Int 0xFFFF)
 
--- | Sign-extend a 8-bit value
+-- | Sign-extend/narrow a 8-bit value
 signExtend8 :: JExpr -> JExpr
-signExtend8 x = (BAnd x (Int 0xFF) `BXor` 0x80) `Sub` 0x80
+signExtend8 x = (BAnd x (Int 0x7F  )) `Sub` (BAnd x (Int 0x80))
 
--- | Sign-extend a 16-bit value
+-- | Sign-extend/narrow a 16-bit value
 signExtend16 :: JExpr -> JExpr
-signExtend16 x = (BAnd x (Int 0xFFFF) `BXor` 0x8000) `Sub` 0x8000
+signExtend16 x = (BAnd x (Int 0x7FFF)) `Sub` (BAnd x (Int 0x8000))
 
 -- | Select a property 'prop', from and object 'obj'
 --



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6a0f68a6836cccb6b549c13b0b6ce20e2cceccc5

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6a0f68a6836cccb6b549c13b0b6ce20e2cceccc5
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20221004/39ad4915/attachment-0001.html>


More information about the ghc-commits mailing list