summaryrefslogtreecommitdiff
path: root/compiler/GHC/Cmm
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-03-11 17:41:51 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-04-29 17:29:44 -0400
commit1d03d8bef962e6789db44e8b6f2cfd9e34f3f5ad (patch)
treed77ec6ba70bc70e87e954ecb2f56cfa39d12159e /compiler/GHC/Cmm
parentc2541c49f162f1d03b0ae55f47b9c76cc96df76f (diff)
downloadhaskell-1d03d8bef962e6789db44e8b6f2cfd9e34f3f5ad.tar.gz
Replace (ptext .. sLit) with `text`
1. `text` is as efficient as `ptext . sLit` thanks to the rewrite rules 2. `text` is visually nicer than `ptext . sLit` 3. `ptext . sLit` encourages using one `ptext` for several `sLit` as in: ptext $ case xy of ... -> sLit ... ... -> sLit ... which may allocate SDoc's TextBeside constructors at runtime instead of sharing them into CAFs.
Diffstat (limited to 'compiler/GHC/Cmm')
-rw-r--r--compiler/GHC/Cmm/CLabel.hs52
-rw-r--r--compiler/GHC/Cmm/Ppr/Decl.hs22
-rw-r--r--compiler/GHC/Cmm/Type.hs21
3 files changed, 45 insertions, 50 deletions
diff --git a/compiler/GHC/Cmm/CLabel.hs b/compiler/GHC/Cmm/CLabel.hs
index 4d6c66066c..02d3f60ad6 100644
--- a/compiler/GHC/Cmm/CLabel.hs
+++ b/compiler/GHC/Cmm/CLabel.hs
@@ -1334,7 +1334,7 @@ pprCLabel !platform !sty lbl = -- see Note [Bangs in CLabel]
tempLabelPrefixOrUnderscore :: Platform -> SDoc
tempLabelPrefixOrUnderscore platform = case sty of
- AsmStyle -> ptext (asmTempLabelPrefix platform)
+ AsmStyle -> asmTempLabelPrefix platform
CStyle -> char '_'
@@ -1347,7 +1347,7 @@ pprCLabel !platform !sty lbl = -- see Note [Bangs in CLabel]
-> tempLabelPrefixOrUnderscore platform <> pprUniqueAlways u
AsmTempDerivedLabel l suf
- -> ptext (asmTempLabelPrefix platform)
+ -> asmTempLabelPrefix platform
<> case l of AsmTempLabel u -> pprUniqueAlways u
LocalBlockLabel u -> pprUniqueAlways u
_other -> pprCLabel platform sty l
@@ -1370,7 +1370,7 @@ pprCLabel !platform !sty lbl = -- see Note [Bangs in CLabel]
maybe_underscore $ text "dsp_" <> pprCLabel platform sty lbl <> text "_dsp"
StringLitLabel u
- -> maybe_underscore $ pprUniqueAlways u <> ptext (sLit "_str")
+ -> maybe_underscore $ pprUniqueAlways u <> text "_str"
ForeignLabel fs (Just sz) _ _
| AsmStyle <- sty
@@ -1389,7 +1389,7 @@ pprCLabel !platform !sty lbl = -- see Note [Bangs in CLabel]
isRandomGenerated = not (isExternalName name)
internalNamePrefix =
if isRandomGenerated
- then ptext (asmTempLabelPrefix platform)
+ then asmTempLabelPrefix platform
else empty
CStyle -> ppr name <> ppIdFlavor flavor
@@ -1400,38 +1400,38 @@ pprCLabel !platform !sty lbl = -- see Note [Bangs in CLabel]
-> maybe_underscore $ ftext str <> text "_fast"
RtsLabel (RtsSelectorInfoTable upd_reqd offset)
- -> maybe_underscore $ hcat [text "stg_sel_", text (show offset),
- ptext (if upd_reqd
- then (sLit "_upd_info")
- else (sLit "_noupd_info"))
+ -> maybe_underscore $ hcat [ text "stg_sel_", text (show offset)
+ , if upd_reqd
+ then text "_upd_info"
+ else text "_noupd_info"
]
RtsLabel (RtsSelectorEntry upd_reqd offset)
- -> maybe_underscore $ hcat [text "stg_sel_", text (show offset),
- ptext (if upd_reqd
- then (sLit "_upd_entry")
- else (sLit "_noupd_entry"))
+ -> maybe_underscore $ hcat [ text "stg_sel_", text (show offset)
+ , if upd_reqd
+ then text "_upd_entry"
+ else text "_noupd_entry"
]
RtsLabel (RtsApInfoTable upd_reqd arity)
- -> maybe_underscore $ hcat [text "stg_ap_", text (show arity),
- ptext (if upd_reqd
- then (sLit "_upd_info")
- else (sLit "_noupd_info"))
+ -> maybe_underscore $ hcat [ text "stg_ap_", text (show arity)
+ , if upd_reqd
+ then text "_upd_info"
+ else text "_noupd_info"
]
RtsLabel (RtsApEntry upd_reqd arity)
- -> maybe_underscore $ hcat [text "stg_ap_", text (show arity),
- ptext (if upd_reqd
- then (sLit "_upd_entry")
- else (sLit "_noupd_entry"))
+ -> maybe_underscore $ hcat [ text "stg_ap_", text (show arity)
+ , if upd_reqd
+ then text "_upd_entry"
+ else text "_noupd_entry"
]
RtsLabel (RtsPrimOp primop)
-> maybe_underscore $ text "stg_" <> ppr primop
RtsLabel (RtsSlowFastTickyCtr pat)
- -> maybe_underscore $ text "SLOW_CALL_fast_" <> text pat <> ptext (sLit "_ctr")
+ -> maybe_underscore $ text "SLOW_CALL_fast_" <> text pat <> text "_ctr"
LargeBitmapLabel u
-> maybe_underscore $ tempLabelPrefixOrUnderscore platform
@@ -1441,7 +1441,7 @@ pprCLabel !platform !sty lbl = -- see Note [Bangs in CLabel]
-- with a letter so the label will be legal assembly code.
HpcTicksLabel mod
- -> maybe_underscore $ text "_hpc_tickboxes_" <> ppr mod <> ptext (sLit "_hpc")
+ -> maybe_underscore $ text "_hpc_tickboxes_" <> ppr mod <> text "_hpc"
CC_Label cc -> maybe_underscore $ ppr cc
CCS_Label ccs -> maybe_underscore $ ppr ccs
@@ -1528,11 +1528,11 @@ instance Outputable ForeignLabelSource where
-- -----------------------------------------------------------------------------
-- Machine-dependent knowledge about labels.
-asmTempLabelPrefix :: Platform -> PtrString -- for formatting labels
+asmTempLabelPrefix :: Platform -> SDoc -- for formatting labels
asmTempLabelPrefix !platform = case platformOS platform of
- OSDarwin -> sLit "L"
- OSAIX -> sLit "__L" -- follow IBM XL C's convention
- _ -> sLit ".L"
+ OSDarwin -> text "L"
+ OSAIX -> text "__L" -- follow IBM XL C's convention
+ _ -> text ".L"
pprDynamicLinkerAsmLabel :: Platform -> DynamicLinkerLabelInfo -> SDoc -> SDoc
pprDynamicLinkerAsmLabel !platform dllInfo ppLbl =
diff --git a/compiler/GHC/Cmm/Ppr/Decl.hs b/compiler/GHC/Cmm/Ppr/Decl.hs
index 469ae66dbc..b6a2e1992e 100644
--- a/compiler/GHC/Cmm/Ppr/Decl.hs
+++ b/compiler/GHC/Cmm/Ppr/Decl.hs
@@ -51,7 +51,6 @@ import GHC.Cmm.Ppr.Expr
import GHC.Cmm
import GHC.Utils.Outputable
-import GHC.Data.FastString
import Data.List (intersperse)
@@ -160,15 +159,12 @@ pprSection platform (Section t suffix) =
section = text "section"
pprSectionType :: SectionType -> SDoc
-pprSectionType s = doubleQuotes (ptext t)
- where
- t = case s of
- Text -> sLit "text"
- Data -> sLit "data"
- ReadOnlyData -> sLit "readonly"
- ReadOnlyData16 -> sLit "readonly16"
- RelocatableReadOnlyData
- -> sLit "relreadonly"
- UninitialisedData -> sLit "uninitialised"
- CString -> sLit "cstring"
- OtherSection s' -> sLit s' -- Not actually a literal though.
+pprSectionType s = doubleQuotes $ case s of
+ Text -> text "text"
+ Data -> text "data"
+ ReadOnlyData -> text "readonly"
+ ReadOnlyData16 -> text "readonly16"
+ RelocatableReadOnlyData -> text "relreadonly"
+ UninitialisedData -> text "uninitialised"
+ CString -> text "cstring"
+ OtherSection s' -> text s'
diff --git a/compiler/GHC/Cmm/Type.hs b/compiler/GHC/Cmm/Type.hs
index 954fc5fe80..c7e2a4069b 100644
--- a/compiler/GHC/Cmm/Type.hs
+++ b/compiler/GHC/Cmm/Type.hs
@@ -33,7 +33,6 @@ where
import GHC.Prelude
import GHC.Platform
-import GHC.Data.FastString
import GHC.Utils.Outputable
import GHC.Utils.Panic
@@ -172,18 +171,18 @@ isFloat64 _other = False
-- Width
-----------------------------------------------------------------------------
-data Width = W8 | W16 | W32 | W64
- | W128
- | W256
- | W512
- deriving (Eq, Ord, Show)
+data Width
+ = W8
+ | W16
+ | W32
+ | W64
+ | W128
+ | W256
+ | W512
+ deriving (Eq, Ord, Show)
instance Outputable Width where
- ppr rep = ptext (mrStr rep)
-
-mrStr :: Width -> PtrString
-mrStr = sLit . show
-
+ ppr rep = text (show rep)
-------- Common Widths ------------
wordWidth :: Platform -> Width