Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
GHC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gesh
GHC
Commits
b854aa77
Commit
b854aa77
authored
27 years ago
by
sof
Browse files
Options
Downloads
Patches
Plain Diff
[project @ 1998-03-13 20:53:02 by sof]
Equip all locally bound names with new uniques
parent
605ed32b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ghc/compiler/stgSyn/CoreToStg.lhs
+48
-7
48 additions, 7 deletions
ghc/compiler/stgSyn/CoreToStg.lhs
with
48 additions
and
7 deletions
ghc/compiler/stgSyn/CoreToStg.lhs
+
48
−
7
View file @
b854aa77
...
...
@@ -21,7 +21,7 @@ import Bag ( emptyBag, unitBag, unionBags, unionManyBags, bagToList )
import CoreUtils ( coreExprType )
import CostCentre ( noCostCentre )
import Id ( mkSysLocal, idType, isBottomingId,
externallyVisibleId,
externallyVisibleId,
mkIdWithNewUniq,
nullIdEnv, addOneToIdEnv, lookupIdEnv, growIdEnvList,
IdEnv, GenId{-instance NamedThing-}, Id
...
...
@@ -79,6 +79,11 @@ Because we're going to come across ``boring'' bindings like
environment, so we can just replace all occurrences of \tr{x}
with \tr{y}.
March 98: We also use this environment to give all locally bound
Names new unique ids, since the code generator assumes that binders
are unique across a module. (Simplifier doesn't maintain this
invariant any longer.)
\begin{code}
type StgEnv = IdEnv StgArg
\end{code}
...
...
@@ -144,8 +149,20 @@ coreBindToStg env (NonRec binder rhs)
where
new_env = addOneToIdEnv env binder (StgConArg con_id)
other -> -- Non-trivial RHS, so don't augment envt
returnUs ([StgNonRec binder stg_rhs], env)
other -> -- Non-trivial RHS
mkUniqueBinder env binder `thenUs` \ (new_env, new_binder) ->
returnUs ([StgNonRec new_binder stg_rhs], new_env)
where
mkUniqueBinder env binder
| externallyVisibleId binder = returnUs (env, binder)
| otherwise =
-- local binder, give it a new unique Id.
newUniqueLocalId binder `thenUs` \ binder' ->
let
new_env = addOneToIdEnv env binder (StgVarArg binder')
in
returnUs (new_env, binder')
coreBindToStg env (Rec pairs)
= -- NB: *** WE DO NOT CHECK FOR TRIV_BINDS in REC BIND ****
...
...
@@ -153,8 +170,9 @@ coreBindToStg env (Rec pairs)
let
(binders, rhss) = unzip pairs
in
mapUs (coreRhsToStg env) rhss `thenUs` \ stg_rhss ->
returnUs ([StgRec (binders `zip` stg_rhss)], env)
newLocalIds env True{-maybe externally visible-} binders `thenUs` \ (binders', env') ->
mapUs (coreRhsToStg env') rhss `thenUs` \ stg_rhss ->
returnUs ([StgRec (binders' `zip` stg_rhss)], env')
\end{code}
...
...
@@ -250,7 +268,8 @@ coreExprToStg env expr@(Lam _ _)
= let
(_, binders, body) = collectBinders expr
in
coreExprToStg env body `thenUs` \ stg_body ->
newLocalIds env False{-all local-} binders `thenUs` \ (binders', env') ->
coreExprToStg env' body `thenUs` \ stg_body ->
if null binders then -- it was all type/usage binders; tossed
returnUs stg_body
...
...
@@ -262,7 +281,7 @@ coreExprToStg env expr@(Lam _ _)
stgArgOcc
bOGUS_FVs
ReEntrant -- binders is non-empty
binders
binders
'
stg_body))
(StgApp (StgVarArg var) [] bOGUS_LVs))
\end{code}
...
...
@@ -413,6 +432,28 @@ newStgVar ty
returnUs (mkSysLocal SLIT("stg") uniq ty noSrcLoc)
\end{code}
\begin{code}
newUniqueLocalId :: Id -> UniqSM Id
newUniqueLocalId i =
getUnique `thenUs` \ uniq ->
returnUs (mkIdWithNewUniq i uniq)
newLocalIds :: StgEnv -> Bool -> [Id] -> UniqSM ([Id], StgEnv)
newLocalIds env maybe_visible [] = returnUs ([], env)
newLocalIds env maybe_visible (i:is)
| maybe_visible && externallyVisibleId i =
newLocalIds env maybe_visible is `thenUs` \ (is', env') ->
returnUs (i:is', env')
| otherwise =
newUniqueLocalId i `thenUs` \ i' ->
let
new_env = addOneToIdEnv env i (StgVarArg i')
in
newLocalIds new_env maybe_visible is `thenUs` \ (is', env') ->
returnUs (i':is', env')
\end{code}
\begin{code}
mkStgLets :: [StgBinding]
-> StgExpr -- body of let
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment