[Git][ghc/ghc][wip/dump-c] Implement -ddump-c-backend argument

Ben Gamari gitlab at gitlab.haskell.org
Fri Nov 20 22:35:53 UTC 2020



Ben Gamari pushed to branch wip/dump-c at Glasgow Haskell Compiler / GHC


Commits:
612b4f9a by Ben Gamari at 2020-11-20T17:35:46-05:00
Implement -ddump-c-backend argument

To dump output of the C backend.

- - - - -


4 changed files:

- compiler/GHC/Driver/CodeOutput.hs
- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Driver/Session.hs
- docs/users_guide/debugging.rst


Changes:

=====================================
compiler/GHC/Driver/CodeOutput.hs
=====================================
@@ -138,7 +138,13 @@ outputC dflags filenm cmm_stream packages =
       hPutStr h ("/* GHC_PACKAGES " ++ unwords pkg_names ++ "\n*/\n")
       hPutStr h "#include \"Stg.h\"\n"
       let platform = targetPlatform dflags
-          writeC = printForC dflags h . cmmToC platform
+          writeC cmm = do
+            let doc = cmmToC platform cmm
+            dumpIfSet_dyn dflags Opt_D_dump_c_backend
+                          "C backend output"
+                          FormatC
+                          doc
+            printForC dflags h doc
       Stream.consume cmm_stream writeC
 
 {-


=====================================
compiler/GHC/Driver/Flags.hs
=====================================
@@ -49,6 +49,7 @@ data DumpFlag
    | Opt_D_dump_asm_conflicts
    | Opt_D_dump_asm_stats
    | Opt_D_dump_asm_expanded
+   | Opt_D_dump_c_backend
    | Opt_D_dump_llvm
    | Opt_D_dump_core_stats
    | Opt_D_dump_deriv


=====================================
compiler/GHC/Driver/Session.hs
=====================================
@@ -2551,6 +2551,8 @@ dynamic_flags_deps = [
         (setDumpFlag Opt_D_dump_asm_expanded)
   , make_ord_flag defGhcFlag "ddump-llvm"
         (NoArg $ setObjBackend LLVM >> setDumpFlag' Opt_D_dump_llvm)
+  , make_ord_flag defGhcFlag "ddump-c-backend"
+        (NoArg $ setDumpFlag' Opt_D_dump_c_backend)
   , make_ord_flag defGhcFlag "ddump-deriv"
         (setDumpFlag Opt_D_dump_deriv)
   , make_ord_flag defGhcFlag "ddump-ds"


=====================================
docs/users_guide/debugging.rst
=====================================
@@ -547,6 +547,15 @@ LLVM code generator
 
     LLVM code from the :ref:`LLVM code generator <llvm-code-gen>`
 
+C code generator
+~~~~~~~~~~~~~~~~
+
+.. ghc-flag:: -ddump-c-backend
+    :shortdesc: Dump C code produced by the C (unregisterised) backend.
+    :type: dynamic
+
+    :shortdesc: Dump C code produced by the C (unregisterised) backend.
+
 Native code generator
 ~~~~~~~~~~~~~~~~~~~~~
 



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

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/612b4f9a296cf6634a3e85ab16befe1435f64fc6
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/20201120/f7ebbe1c/attachment-0001.html>


More information about the ghc-commits mailing list