[commit: ghc] wip/kavon-nosplit-llvm: finally got the types the way I want them (9172e98)

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


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

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

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

commit 9172e98d75685cc7859ced813b04523df1f8b057
Author: Kavon Farvardin <kavon at farvard.in>
Date:   Wed Jun 7 15:11:03 2017 +0100

    finally got the types the way I want them


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

9172e98d75685cc7859ced813b04523df1f8b057
 compiler/llvmGen/LlvmCodeGen/Data.hs | 16 ++++++++++++++--
 compiler/llvmGen/LlvmMangler.hs      | 14 +++++++++++++-
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/compiler/llvmGen/LlvmCodeGen/Data.hs b/compiler/llvmGen/LlvmCodeGen/Data.hs
index 7be62d9..436438d 100644
--- a/compiler/llvmGen/LlvmCodeGen/Data.hs
+++ b/compiler/llvmGen/LlvmCodeGen/Data.hs
@@ -152,6 +152,18 @@ genStaticLit (CmmHighStackMark)
     = panic "genStaticLit: CmmHighStackMark unsupported!"
     
 
--- | Convert a CmmStatic into a byte string for the mangler
+-- | Convert a CmmStatic into a byte string for the LLVM mangler.
+-- The mangler will insert the ManglerStr representations of the
+-- CmmStatic at return points of a cpscall.
 cvtForMangler :: CmmStatics -> LlvmM ManglerStr
-cvtForMangler _ = error "implement cvtForMangler"
+cvtForMangler (Statics _ datum) =
+        mapM doStatic datum
+    where
+        doStatic :: CmmStatic -> LlvmM (B.ByteString -> B.ByteString)
+        doStatic (CmmStaticLit lit) = return $ \ _ -> B.pack "## todo"
+        
+        -- XXX these are not expected to appear at return points at the moment.
+        doStatic (CmmUninitialised _) = error "doStatic -- uninit unhandled"
+        doStatic (CmmString _) = error "doStatic -- string unhandled"
+        
+        
diff --git a/compiler/llvmGen/LlvmMangler.hs b/compiler/llvmGen/LlvmMangler.hs
index fc3b11e..63d7d41 100644
--- a/compiler/llvmGen/LlvmMangler.hs
+++ b/compiler/llvmGen/LlvmMangler.hs
@@ -23,7 +23,19 @@ import Compiler.Hoopl
 import Compiler.Hoopl.Internals ( uniqueToLbl )
 import Data.Maybe ( fromMaybe )
 
-type ManglerStr = B.ByteString
+-- note [mangler string func]
+-- A ManglerStr takes the name of the label it will be attached to,
+-- and returns the data that should appear before that label.
+-- We do this because some of the static data is of the form 
+--
+--      .quad  SRT_LAB-CUR_LABEL
+--
+-- and we do not have a name for CUR_LABEL until LLVM generates
+-- the assembly code for the function. The name for SRT_LAB 
+-- is only in the LLVM monad, so we need two stages to generate
+-- that line
+
+type ManglerStr = [B.ByteString -> B.ByteString]
 type ManglerInfo = Maybe (LabelMap ManglerStr)
 
 -- | Read in assembly file and process



More information about the ghc-commits mailing list