Skip to content

Commit 2aebadf

Browse files
Remove the GET_NAME macro
1 parent 7c724e3 commit 2aebadf

4 files changed

Lines changed: 17 additions & 19 deletions

File tree

src/Fusion/Plugin/Common.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
#if MIN_VERSION_ghc(9,0,0)
22
#define UNIQ_FM UniqFM Name [Fuse]
3-
#define GET_NAME getName
43
#define FMAP_SND fmap snd $
54
#else
65
#define UNIQ_FM UniqFM [Fuse]
7-
#define GET_NAME getName
86
#define FMAP_SND
97
#endif
108

src/Fusion/Plugin/Common.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ altsContainsAnn _ _ [] = Nothing
193193
altsContainsAnn _ _ ((ALT_CONSTR(DEFAULT,_,_)):[]) =
194194
debug 2 "Case trivial default" Nothing
195195
altsContainsAnn dflags isInteresting (bndr@(ALT_CONSTR(DataAlt dcon,_,_)):_) =
196-
let name = GET_NAME $ dataConTyCon dcon
196+
let name = getName $ dataConTyCon dcon
197197
mesg = "Case DataAlt type " ++ showWithUnique dflags name
198198
in if isInteresting name
199199
then debug 2 (mesg ++ " annotated") (Just bndr)
@@ -359,7 +359,7 @@ binderAnnKeys b = nm : [base | Just base <- [DL.stripPrefix "$w" nm]]
359359

360360
where
361361

362-
nm = getOccString (GET_NAME b)
362+
nm = getOccString (getName b)
363363

364364
-- | The source-level display name of a binder: its occurrence name with any
365365
-- @$w@ worker prefix stripped. The worker/wrapper transformation renames an
@@ -370,7 +370,7 @@ binderDisplayName b = fromMaybe nm (DL.stripPrefix "$w" nm)
370370

371371
where
372372

373-
nm = getOccString (GET_NAME b)
373+
nm = getOccString (getName b)
374374

375375
-------------------------------------------------------------------------------
376376
-- Transitive closure of a binding

src/Fusion/Plugin/Fuse.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ letBndrsThatAreCases dflags anns bind = goLet [] bind
264264
needInlineTyCon :: CoreBind -> UNIQ_FM -> TyCon -> InlineNeed ()
265265
needInlineTyCon parent anns tycon =
266266
let parentBndr = getNonRecBinder parent
267-
in case lookupUFM anns (GET_NAME tycon) of
267+
in case lookupUFM anns (getName tycon) of
268268
Just _ | hasNoInlineBinder parentBndr -> InlineBlockedByNoInline tycon
269269
Just _ | not (hasInlineBinder parentBndr) -> InlineNeeded ()
270270
_ -> InlineNotNeeded
@@ -353,23 +353,23 @@ constructingBinders anns bind = goLet [] bind
353353
-- unchanged if the binder is not annotated.
354354
augmentFuseTypes :: UNIQ_FM -> FUSE_TYPES_FM -> CoreBndr -> CoreM (UNIQ_FM)
355355
augmentFuseTypes anns fuseTypesAnns b =
356-
case Map.lookup (getOccString (GET_NAME b)) fuseTypesAnns of
356+
case Map.lookup (getOccString (getName b)) fuseTypesAnns of
357357
Nothing -> return anns
358358
Just (FuseTypes ns) -> do
359359
names <- resolveTHNames ns
360360
return $ plusUFM anns (listToUFM (map (\n -> (n, [Fuse])) names))
361361

362362
removeFuseTypes :: UNIQ_FM -> NO_FUSE_TYPES_FM -> CoreBndr -> CoreM (UNIQ_FM)
363363
removeFuseTypes anns noFuseTypesAnns b =
364-
case Map.lookup (getOccString (GET_NAME b)) noFuseTypesAnns of
364+
case Map.lookup (getOccString (getName b)) noFuseTypesAnns of
365365
Nothing -> return anns
366366
Just (NoFuseTypes ns) -> do
367367
names <- resolveTHNames ns
368368
return $ delListFromUFM anns names
369369

370370
removeFuse :: UNIQ_FM -> NO_FUSE_FM -> CoreBndr -> UNIQ_FM
371371
removeFuse anns noFuseAnns b =
372-
case Map.lookup (getOccString (GET_NAME b)) noFuseAnns of
372+
case Map.lookup (getOccString (getName b)) noFuseAnns of
373373
Nothing -> anns
374374
Just NoFuse -> emptyUFM
375375

src/Fusion/Plugin/Inspect.hs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ containsAnns dflags isInteresting bind =
120120
-- type) -- otherwise e.g. `case s of _ -> ...` with `s
121121
-- :: SPEC` would go unreported.
122122
case tyConAppTyConPicky_maybe (varType caseBndr) of
123-
Just tycon | isInteresting (GET_NAME tycon) ->
123+
Just tycon | isInteresting (getName tycon) ->
124124
[(parents, CaseScrut caseBndr)]
125125
_ -> []
126126
in hit ++ binders
@@ -139,7 +139,7 @@ containsAnns dflags isInteresting bind =
139139
hit = case fun of
140140
Var i
141141
| Just dcon <- isDataConId_maybe i
142-
, isInteresting (GET_NAME (dataConTyCon dcon)) ->
142+
, isInteresting (getName (dataConTyCon dcon)) ->
143143
[(parents, Constr i)]
144144
_ -> []
145145
in hit ++ go parents fun ++ concatMap (go parents) args
@@ -149,7 +149,7 @@ containsAnns dflags isInteresting bind =
149149
-- Check if the Var is of the type of a data constructor of interest
150150
go parents (Var i) =
151151
case tyConAppTyConPicky_maybe (varType i) of
152-
Just tycon | isInteresting (GET_NAME tycon) ->
152+
Just tycon | isInteresting (getName tycon) ->
153153
[(parents, Constr i)]
154154
_ -> []
155155

@@ -166,11 +166,11 @@ containsAnns dflags isInteresting bind =
166166

167167
contextTyConName :: Context -> Maybe Name
168168
contextTyConName (CaseAlt (ALT_CONSTR(DataAlt dcon,_,_))) =
169-
Just (GET_NAME $ dataConTyCon dcon)
169+
Just (getName $ dataConTyCon dcon)
170170
contextTyConName (CaseAlt _) = Nothing
171171
contextTyConName (CaseScrut bndr) =
172-
GET_NAME <$> tyConAppTyConPicky_maybe (varType bndr)
173-
contextTyConName (Constr con) = GET_NAME <$> constrTyCon con
172+
getName <$> tyConAppTyConPicky_maybe (varType bndr)
173+
contextTyConName (Constr con) = getName <$> constrTyCon con
174174

175175
-- | Like 'contextTyConName' but yields the fully-qualified @Module.Type@ name
176176
-- (via 'qualifiedTyConName') used in reports rather than the raw 'Name'.
@@ -444,7 +444,7 @@ reportInspected dflags reportMode anns pmAnns allocAnns allBinds (NonRec b _)
444444
stale = filter (`notElem` present) allowed
445445
unless (null stale) $
446446
putMsgS $ "fusion-plugin: "
447-
++ getOccString (GET_NAME b)
447+
++ getOccString (getName b)
448448
++ ": redundant " ++ label
449449
++ " entries (safe to remove): ["
450450
++ DL.intercalate ", " (map qualifiedName stale)
@@ -453,7 +453,7 @@ reportInspected dflags reportMode anns pmAnns allocAnns allBinds (NonRec b _)
453453
terse ni results =
454454
let names = DL.nub (mapMaybe (contextQualifiedName . snd) results)
455455
in putMsgS $ "fusion-plugin: "
456-
++ getOccString (GET_NAME b)
456+
++ getOccString (getName b)
457457
++ ": found " ++ niForbidLabel ni ++ " ["
458458
++ DL.intercalate ", " names ++ "]"
459459

@@ -576,7 +576,7 @@ reportInspectedClasses dflags reportMode classAnns allBinds (NonRec b _) =
576576
report _ hits =
577577
let names = DL.nub (map qualifiedTyConName hits)
578578
in putMsgS $ "fusion-plugin: "
579-
++ getOccString (GET_NAME b)
579+
++ getOccString (getName b)
580580
++ ": found forbidden type classes ["
581581
++ DL.intercalate ", " names ++ "]"
582582

@@ -588,7 +588,7 @@ reportInspectedClasses dflags reportMode classAnns allBinds (NonRec b _) =
588588
stale = filter (`notElem` present) allowed
589589
unless (null stale) $
590590
putMsgS $ "fusion-plugin: "
591-
++ getOccString (GET_NAME b)
591+
++ getOccString (getName b)
592592
++ ": redundant PermitTypeClasses entries (safe to remove): ["
593593
++ DL.intercalate ", " (map qualifiedName stale) ++ "]"
594594
warnStalePermitted _ _ = return ()

0 commit comments

Comments
 (0)