Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
GHC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex D
GHC
Commits
12372baa
Commit
12372baa
authored
Mar 25, 2016
by
Simon Peyton Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CorePrep: refactoring to reduce duplication
There's no functional change here, just tidying up
parent
356e5e03
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
28 deletions
+21
-28
compiler/coreSyn/CorePrep.hs
compiler/coreSyn/CorePrep.hs
+21
-28
No files found.
compiler/coreSyn/CorePrep.hs
View file @
12372baa
...
...
@@ -436,8 +436,6 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs
;
return
(
floats4
,
bndr'
,
rhs4
)
}
where
is_strict_or_unlifted
=
(
isStrictDmd
dmd
)
||
is_unlifted
platform
=
targetPlatform
(
cpe_dynFlags
env
)
arity
=
idArity
bndr
-- We must match this arity
...
...
@@ -445,14 +443,14 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs
---------------------
float_from_rhs
floats
rhs
|
isEmptyFloats
floats
=
return
(
emptyFloats
,
rhs
)
|
isTopLevel
top_lvl
=
float_top
floats
rhs
|
otherwise
=
float_nested
floats
rhs
|
isTopLevel
top_lvl
=
float_top
floats
rhs
|
otherwise
=
float_nested
floats
rhs
---------------------
float_nested
floats
rhs
|
wantFloatNested
is_rec
is_strict_or
_unlifted
floats
rhs
|
wantFloatNested
is_rec
dmd
is
_unlifted
floats
rhs
=
return
(
floats
,
rhs
)
|
otherwise
=
dont
_f
loat
floats
rhs
|
otherwise
=
dont
F
loat
floats
rhs
---------------------
float_top
floats
rhs
-- Urhgh! See Note [CafInfo and floating]
...
...
@@ -465,16 +463,17 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs
=
return
(
floats'
,
rhs'
)
|
otherwise
=
dont_float
floats
rhs
---------------------
dont_float
floats
rhs
-- Non-empty floats, but do not want to float from rhs
-- So wrap the rhs in the floats
-- But: rhs1 might have lambdas, and we can't
-- put them inside a wrapBinds
=
do
{
body
<-
rhsToBodyNF
rhs
;
return
(
emptyFloats
,
wrapBinds
floats
body
)
}
=
dontFloat
floats
rhs
dontFloat
::
Floats
->
CpeRhs
->
UniqSM
(
Floats
,
CpeBody
)
-- Non-empty floats, but do not want to float from rhs
-- So wrap the rhs in the floats
-- But: rhs1 might have lambdas, and we can't
-- put them inside a wrapBinds
dontFloat
floats1
rhs
=
do
{
(
floats2
,
body
)
<-
rhsToBody
rhs
;
return
(
emptyFloats
,
wrapBinds
floats1
$
wrapBinds
floats2
body
)
}
{- Note [Silly extra arguments]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
...
@@ -617,11 +616,6 @@ cpeBody env expr
;
(
floats2
,
body
)
<-
rhsToBody
rhs
;
return
(
floats1
`
appendFloats
`
floats2
,
body
)
}
--------
rhsToBodyNF
::
CpeRhs
->
UniqSM
CpeBody
rhsToBodyNF
rhs
=
do
{
(
floats
,
body
)
<-
rhsToBody
rhs
;
return
(
wrapBinds
floats
body
)
}
--------
rhsToBody
::
CpeRhs
->
UniqSM
(
Floats
,
CpeBody
)
-- Remove top level lambdas by let-binding
...
...
@@ -763,8 +757,7 @@ cpeArg env dmd arg arg_ty
=
do
{
(
floats1
,
arg1
)
<-
cpeRhsE
env
arg
-- arg1 can be a lambda
;
(
floats2
,
arg2
)
<-
if
want_float
floats1
arg1
then
return
(
floats1
,
arg1
)
else
do
{
body1
<-
rhsToBodyNF
arg1
;
return
(
emptyFloats
,
wrapBinds
floats1
body1
)
}
else
dontFloat
floats1
arg1
-- Else case: arg1 might have lambdas, and we can't
-- put them inside a wrapBinds
...
...
@@ -777,8 +770,7 @@ cpeArg env dmd arg arg_ty
;
return
(
addFloat
floats2
arg_float
,
varToCoreExpr
v
)
}
}
where
is_unlifted
=
isUnliftedType
arg_ty
is_strict
=
isStrictDmd
dmd
want_float
=
wantFloatNested
NonRecursive
(
is_strict
||
is_unlifted
)
want_float
=
wantFloatNested
NonRecursive
dmd
is_unlifted
{-
Note [Floating unlifted arguments]
...
...
@@ -1151,10 +1143,11 @@ canFloatFromNoCaf platform (Floats ok_to_spec fs) rhs
(
\
i
->
pprPanic
"rhsIsStatic"
(
integer
i
))
-- Integer literals should not show up
wantFloatNested
::
RecFlag
->
Bool
->
Floats
->
CpeRhs
->
Bool
wantFloatNested
is_rec
strict_or
_unlifted
floats
rhs
wantFloatNested
::
RecFlag
->
Demand
->
Bool
->
Floats
->
CpeRhs
->
Bool
wantFloatNested
is_rec
dmd
is
_unlifted
floats
rhs
=
isEmptyFloats
floats
||
strict_or_unlifted
||
isStrictDmd
dmd
||
is_unlifted
||
(
allLazyNested
is_rec
floats
&&
exprIsHNF
rhs
)
-- Why the test for allLazyNested?
-- v = f (x `divInt#` y)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment