From 1d6d648866da9e7754859c48235f8009b8c130fd Mon Sep 17 00:00:00 2001 From: Sylvain Henry Date: Tue, 1 Sep 2020 15:06:18 +0200 Subject: Don't rely on CLabel's Outputable instance in CmmToC This is in preparation of the removal of sdocWithDynFlags (#10143), hence of the refactoring of CLabel's Outputable instance. --- compiler/GHC/Cmm/CLabel.hs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'compiler/GHC/Cmm/CLabel.hs') diff --git a/compiler/GHC/Cmm/CLabel.hs b/compiler/GHC/Cmm/CLabel.hs index 2782da2ea4..c8f39b80ef 100644 --- a/compiler/GHC/Cmm/CLabel.hs +++ b/compiler/GHC/Cmm/CLabel.hs @@ -108,7 +108,7 @@ module GHC.Cmm.CLabel ( -- * Conversions toClosureLbl, toSlowEntryLbl, toEntryLbl, toInfoLbl, hasHaskellName, - pprCLabel, pprCLabel_LLVM, pprCLabel_NCG, + pprCLabel, pprCLabel_LLVM, pprCLabel_NCG, pprCLabel_ViaC, isInfoTableLabel, isConInfoTableLabel, isIdLabel, isTickyLabel @@ -1218,11 +1218,15 @@ pprCLabel bcknd platform lbl = case bcknd of NCG -> pprCLabel_NCG platform lbl LLVM -> pprCLabel_LLVM platform lbl + ViaC -> pprCLabel_ViaC platform lbl _ -> pprCLabel_other platform lbl pprCLabel_LLVM :: Platform -> CLabel -> SDoc pprCLabel_LLVM = pprCLabel_NCG +pprCLabel_ViaC :: Platform -> CLabel -> SDoc +pprCLabel_ViaC = pprCLabel_other + pprCLabel_NCG :: Platform -> CLabel -> SDoc pprCLabel_NCG platform lbl = getPprStyle $ \sty -> let @@ -1348,7 +1352,13 @@ pprCLabel_common platform = \case (ForeignLabel str _ _ _) -> ftext str - (IdLabel name _cafs flavor) -> internalNamePrefix platform name <> ppr name <> ppIdFlavor flavor + (IdLabel name _cafs flavor) -> internalNamePrefix <> ppr name <> ppIdFlavor flavor + where + isRandomGenerated = not (isExternalName name) + internalNamePrefix = getPprStyle $ \ sty -> + if asmStyle sty && isRandomGenerated + then ptext (asmTempLabelPrefix platform) + else empty (CC_Label cc) -> ppr cc (CCS_Label ccs) -> ppr ccs @@ -1389,15 +1399,6 @@ instance Outputable ForeignLabelSource where ForeignLabelInThisPackage -> parens $ text "this package" ForeignLabelInExternalPackage -> parens $ text "external package" -internalNamePrefix :: Platform -> Name -> SDoc -internalNamePrefix platform name = getPprStyle $ \ sty -> - if asmStyle sty && isRandomGenerated then - ptext (asmTempLabelPrefix platform) - else - empty - where - isRandomGenerated = not $ isExternalName name - tempLabelPrefixOrUnderscore :: Platform -> SDoc tempLabelPrefixOrUnderscore platform = getPprStyle $ \ sty -> -- cgit v1.2.1