summaryrefslogtreecommitdiff
path: root/testsuite/tests
diff options
context:
space:
mode:
authorKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2022-10-13 19:47:27 -0500
committerKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2022-11-11 19:18:39 +0100
commit3c37d30b07fc85fe09452f4ce250aec42cb1d2e4 (patch)
treea5e36e0e66d1c221ed2d018b5c5c7fd82943f38c /testsuite/tests
parentd0c691b6110b11a43d5ea2685d17bc001d2298da (diff)
downloadhaskell-3c37d30b07fc85fe09452f4ce250aec42cb1d2e4.tar.gz
Use a more efficient printer for code generation (#21853)
The changes in `GHC.Utils.Outputable` are the bulk of the patch and drive the rest. The types `HLine` and `HDoc` in Outputable can be used instead of `SDoc` and support printing directly to a handle with `bPutHDoc`. See Note [SDoc versus HDoc] and Note [HLine versus HDoc]. The classes `IsLine` and `IsDoc` are used to make the existing code polymorphic over `HLine`/`HDoc` and `SDoc`. This is done for X86, PPC, AArch64, DWARF and dependencies (printing module names, labels etc.). Co-authored-by: Alexis King <lexi.lambda@gmail.com> Metric Decrease: CoOpt_Read ManyAlternatives ManyConstructors T10421 T12425 T12707 T13035 T13056 T13253 T13379 T18140 T18282 T18698a T18698b T1969 T20049 T21839c T21839r T3064 T3294 T4801 T5321FD T5321Fun T5631 T6048 T783 T9198 T9233
Diffstat (limited to 'testsuite/tests')
-rw-r--r--testsuite/tests/hiefile/should_run/TestUtils.hs7
1 files changed, 6 insertions, 1 deletions
diff --git a/testsuite/tests/hiefile/should_run/TestUtils.hs b/testsuite/tests/hiefile/should_run/TestUtils.hs
index ec5d75e73f..5ba0a3dc58 100644
--- a/testsuite/tests/hiefile/should_run/TestUtils.hs
+++ b/testsuite/tests/hiefile/should_run/TestUtils.hs
@@ -2,6 +2,7 @@ module TestUtils
( readTestHie
, render
, text
+ , SDoc
, DynFlags
, module GHC.Iface.Ext.Types
, module GHC.Iface.Ext.Utils
@@ -13,7 +14,8 @@ import GHC.Types.Name.Cache
import GHC.Types.SrcLoc
import GHC.Types.Unique.Supply
import GHC.Types.Name
-import GHC.Utils.Outputable ( Outputable, renderWithContext, ppr, defaultUserStyle, text)
+import GHC.Utils.Outputable ( Outputable, renderWithContext, ppr, defaultUserStyle, SDoc )
+import qualified GHC.Utils.Outputable as O
import GHC.Iface.Ext.Binary
import GHC.Iface.Ext.Types
import GHC.Iface.Ext.Utils
@@ -39,3 +41,6 @@ readTestHie fp = do
render :: Outputable a => DynFlags -> a -> String
render df = renderWithContext (initSDocContext df defaultUserStyle) . ppr
+
+text :: String -> SDoc
+text = O.text -- SDoc-only version