summaryrefslogtreecommitdiff
path: root/compiler/cmm
diff options
context:
space:
mode:
authorÖmer Sinan Ağacan <omeragacan@gmail.com>2019-08-21 15:32:09 +0300
committerÖmer Sinan Ağacan <omeragacan@gmail.com>2019-08-28 12:51:12 +0300
commit1c7ec4499ffec5e6b9c97e7a5c8d31062d1e2822 (patch)
tree1cc732f1ab66b6c5963970b33f816e5bbd998edf /compiler/cmm
parentee2fad9e503ffdf61a086f721553aa3c502d1cb8 (diff)
downloadhaskell-1c7ec4499ffec5e6b9c97e7a5c8d31062d1e2822.tar.gz
Return results of Cmm streams in backends
This generalizes code generators (outputAsm, outputLlvm, outputC, and the call site codeOutput) so that they'll return the return values of the passed Cmm streams. This allows accumulating data during Cmm generation and returning it to the call site in HscMain. Previously the Cmm streams were assumed to return (), so the code generators returned () as well. This change is required by !1304 and !1530. Skipping CI as this was tested before and I only updated the commit message. [skip ci]
Diffstat (limited to 'compiler/cmm')
-rw-r--r--compiler/cmm/CmmInfo.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/compiler/cmm/CmmInfo.hs b/compiler/cmm/CmmInfo.hs
index 138e7aa8d8..60814f8039 100644
--- a/compiler/cmm/CmmInfo.hs
+++ b/compiler/cmm/CmmInfo.hs
@@ -67,16 +67,17 @@ mkEmptyContInfoTable info_lbl
, cit_srt = Nothing
, cit_clo = Nothing }
-cmmToRawCmm :: DynFlags -> Stream IO CmmGroup ()
- -> IO (Stream IO RawCmmGroup ())
+cmmToRawCmm :: DynFlags -> Stream IO CmmGroup a
+ -> IO (Stream IO RawCmmGroup a)
cmmToRawCmm dflags cmms
= do { uniqs <- mkSplitUniqSupply 'i'
- ; let do_one uniqs cmm =
+ ; let do_one :: UniqSupply -> [CmmDecl] -> IO (UniqSupply, [RawCmmDecl])
+ do_one uniqs cmm =
-- NB. strictness fixes a space leak. DO NOT REMOVE.
withTiming (return dflags) (text "Cmm -> Raw Cmm") forceRes $
case initUs uniqs $ concatMapM (mkInfoTable dflags) cmm of
(b,uniqs') -> return (uniqs',b)
- ; return (Stream.mapAccumL do_one uniqs cmms >> return ())
+ ; return (snd <$> Stream.mapAccumL_ do_one uniqs cmms)
}
where forceRes (uniqs, rawcmms) =