diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2020-09-18 11:44:44 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-09-23 20:43:48 -0400 |
commit | 667d63558a694e12974ace723b553950f6080365 (patch) | |
tree | 50167bdcff894b1ca9ca96a8ad73fe20a883d245 /compiler/GHC/CmmToLlvm | |
parent | d7385f7077c6258c2a76ae51b4ea80f6fa9c7015 (diff) | |
download | haskell-667d63558a694e12974ace723b553950f6080365.tar.gz |
Refactor CLabel pretty-printing
* Don't depend on the selected backend to know if we print Asm or C
labels: we already have PprStyle to determine this. Moreover even when
a native backend is used (NCG, LLVM) we may want to C headers
containing pretty-printed labels, so it wasn't a good predicate
anyway.
* Make pretty-printing code clearer and avoid partiality
Diffstat (limited to 'compiler/GHC/CmmToLlvm')
-rw-r--r-- | compiler/GHC/CmmToLlvm/Base.hs | 6 | ||||
-rw-r--r-- | compiler/GHC/CmmToLlvm/CodeGen.hs | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/compiler/GHC/CmmToLlvm/Base.hs b/compiler/GHC/CmmToLlvm/Base.hs index d7667bb073..43eaab424e 100644 --- a/compiler/GHC/CmmToLlvm/Base.hs +++ b/compiler/GHC/CmmToLlvm/Base.hs @@ -435,7 +435,7 @@ renderLlvm sdoc = do -- Write to output dflags <- getDynFlags out <- getEnv envOutput - let ctx = initSDocContext dflags (Outp.mkCodeStyle Outp.CStyle) + let ctx = initSDocContext dflags (Outp.PprCode Outp.CStyle) liftIO $ Outp.bufLeftRenderSDoc ctx out sdoc -- Dump, if requested @@ -497,9 +497,9 @@ strCLabel_llvm :: CLabel -> LlvmM LMString strCLabel_llvm lbl = do dflags <- getDynFlags platform <- getPlatform - let sdoc = pprCLabel_LLVM platform lbl + let sdoc = pprCLabel platform CStyle lbl str = Outp.renderWithContext - (initSDocContext dflags (Outp.mkCodeStyle Outp.CStyle)) + (initSDocContext dflags (Outp.PprCode Outp.CStyle)) sdoc return (fsLit str) diff --git a/compiler/GHC/CmmToLlvm/CodeGen.hs b/compiler/GHC/CmmToLlvm/CodeGen.hs index 34d0353681..78f22e5710 100644 --- a/compiler/GHC/CmmToLlvm/CodeGen.hs +++ b/compiler/GHC/CmmToLlvm/CodeGen.hs @@ -1565,7 +1565,7 @@ genMachOp_slow opt op [x, y] = case op of else do -- Error. Continue anyway so we can debug the generated ll file. dflags <- getDynFlags - let style = mkCodeStyle CStyle + let style = PprCode CStyle toString doc = renderWithContext (initSDocContext dflags style) doc cmmToStr = (lines . toString . PprCmm.pprExpr platform) statement $ Comment $ map fsLit $ cmmToStr x |