[commit: ghc] wip/kavon-nosplit-llvm: stopping here to upgrade CmmCall's information (8eb6125)

git at git.haskell.org git at git.haskell.org
Tue Jun 27 09:15:15 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/kavon-nosplit-llvm
Link       : http://ghc.haskell.org/trac/ghc/changeset/8eb612516ea6386b1d98ebde2f0ffc8d2d1defe6/ghc

>---------------------------------------------------------------

commit 8eb612516ea6386b1d98ebde2f0ffc8d2d1defe6
Author: Kavon Farvardin <kavon at farvard.in>
Date:   Tue May 16 16:14:02 2017 +0100

    stopping here to upgrade CmmCall's information


>---------------------------------------------------------------

8eb612516ea6386b1d98ebde2f0ffc8d2d1defe6
 compiler/llvmGen/LlvmCodeGen/CodeGen.hs | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/compiler/llvmGen/LlvmCodeGen/CodeGen.hs b/compiler/llvmGen/LlvmCodeGen/CodeGen.hs
index 97042a6..65e5a1f 100644
--- a/compiler/llvmGen/LlvmCodeGen/CodeGen.hs
+++ b/compiler/llvmGen/LlvmCodeGen/CodeGen.hs
@@ -776,12 +776,18 @@ genNativeCall maybeCont (CmmLit (CmmLabel lbl)) live = do
     (stgRegs, stgStmts) <- funEpilogue live
     let retTy = getRetTy $ getVarType vf
     case maybeCont of
-        _ -> do -- native tail call
+        -- tail call to a known fun
+        Nothing -> do 
             (retV, s1) <- doExpr retTy $ Call TailCall vf stgRegs llvmStdFunAttrs
             let s2  = Return (Just retV)
             return (stmts `appOL` stgStmts `snocOL` s1 `snocOL` s2, top)
             
-        -- Just (cont, offset) -> panic "kavon, handle non-tail known calls."
+        -- non-tail call to a known fun
+        Just (cont, offset) -> do 
+            -- TODO add metadata to this StdCall with the offset and label name
+            (retV, s1) <- doExpr retTy $ Call StdCall vf stgRegs llvmStdFunAttrs
+            endStms <- doReturnTo cont retV
+            return (stmts `appOL` stgStmts `snocOL` s1 `appOL` endStms, top)
     
 -- Tail call to unknown function / address. TODO: check if the expr is P64[Sp] to gen a ret.
 genNativeCall _ expr live = do
@@ -804,6 +810,14 @@ genNativeCall _ expr live = do
     return (stmts `snocOL` s1 `appOL` stgStmts `snocOL` s2 `snocOL` s3,
             top)
             
+doReturnTo :: Label -> LlvmVar -> LlvmM (OrdList LlvmStatement)
+doReturnTo cont retV = panic "handleReturn"
+    -- TODO: we need to know the [GlobalReg] that are live in the continuation,
+    -- aka, what values did the call return?
+    -- todo: extract vals
+    -- todo store vals into reg allocas
+    -- emit a branch
+
 
 -- | CmmAssign operation
 --



More information about the ghc-commits mailing list