[Git][ghc/ghc][wip/T23576] Add condIntCode for 64-bit ints on i386

Jaro Reinders (@Noughtmare) gitlab at gitlab.haskell.org
Mon Jul 3 12:10:24 UTC 2023



Jaro Reinders pushed to branch wip/T23576 at Glasgow Haskell Compiler / GHC


Commits:
d5dc807f by Jaro Reinders at 2023-07-03T14:10:17+02:00
Add condIntCode for 64-bit ints on i386

- - - - -


1 changed file:

- compiler/GHC/CmmToAsm/X86/CodeGen.hs


Changes:

=====================================
compiler/GHC/CmmToAsm/X86/CodeGen.hs
=====================================
@@ -1500,10 +1500,7 @@ getAmode e = do
          , is_label lit
          -> return (Amode (AddrBaseIndex EABaseRip EAIndexNone (litToImm lit)) nilOL)
 
-      CmmLit lit
-         | is32BitLit platform lit
-         -> return (Amode (ImmAddr (litToImm lit) 0) nilOL)
-
+      CmmLit litsnoc
       -- Literal with offsets too big (> 32 bits) fails during the linking phase
       -- (#15570). We already handled valid literals above so we don't have to
       -- test anything here.
@@ -1807,6 +1804,23 @@ condIntCode cond x y = do platform <- getPlatform
 
 condIntCode' :: Platform -> Cond -> CmmExpr -> CmmExpr -> NatM CondCode
 
+-- Larger-than-native (64-bit ops on 32-bit platforms)
+condIntCode' platform cond x y
+  | target32Bit platform && isWord64 (cmmExprType platform x) = do
+  RegCode64 code1 r1hi r1lo <- iselExpr64 x
+  RegCode64 code2 r2hi r2lo <- iselExpr64 y
+  tmp <- getNewRegNat II32
+  let
+        code = code1 `appOL`
+               code2 `appOL`
+               toOL [ MOV II32 (OpReg r2lo) (OpReg tmp),
+                      CMP II32 (OpReg tmp) (OpReg r1lo),
+                      MOV II32 (OpReg r2hi) (OpReg tmp),
+                      SBB II32 (OpReg r1hi) (OpReg tmp)
+                    ]
+                  
+  return (CondCode False cond code)
+
 -- memory vs immediate
 condIntCode' platform cond (CmmLoad x pk _) (CmmLit lit)
  | is32BitLit platform lit = do



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

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d5dc807f65948ffd95d19236acd393cdcc59b86c
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/20230703/bba7a6c9/attachment-0001.html>


More information about the ghc-commits mailing list