Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Glasgow Haskell Compiler
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
Shayne Fletcher
Glasgow Haskell Compiler
Commits
d25676a6
Commit
d25676a6
authored
Jun 10, 2011
by
Simon Peyton Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Comments, layout and cmm-notes
...all to do with the new codgen path
parent
75f9f355
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
19 deletions
+68
-19
compiler/cmm/CmmCallConv.hs
compiler/cmm/CmmCallConv.hs
+3
-1
compiler/cmm/MkGraph.hs
compiler/cmm/MkGraph.hs
+27
-18
compiler/cmm/cmm-notes
compiler/cmm/cmm-notes
+38
-0
No files found.
compiler/cmm/CmmCallConv.hs
View file @
d25676a6
...
...
@@ -31,8 +31,8 @@ instance (Outputable a) => Outputable (ParamLocation a) where
type
ArgumentFormat
a
b
=
[(
a
,
ParamLocation
b
)]
-- Stack parameters are returned as word offsets.
assignArguments
::
(
a
->
CmmType
)
->
[
a
]
->
ArgumentFormat
a
WordOff
-- Stack parameters are returned as word offsets.
assignArguments
_
_
=
panic
"assignArguments only used in dead codegen"
-- assignments
-- | JD: For the new stack story, I want arguments passed on the stack to manifest as
...
...
@@ -40,6 +40,8 @@ assignArguments _ _ = panic "assignArguments only used in dead codegen" -- assig
-- Also, I want byte offsets, not word offsets.
assignArgumentsPos
::
(
Outputable
a
)
=>
Convention
->
(
a
->
CmmType
)
->
[
a
]
->
ArgumentFormat
a
ByteOff
-- Given a list of arguments, and a function that tells their types,
-- return a list showing where each argument is passed
assignArgumentsPos
conv
arg_ty
reps
=
assignments
where
-- The calling conventions (CgCallConv.hs) are complicated, to say the least
regs
=
case
(
reps
,
conv
)
of
...
...
compiler/cmm/MkGraph.hs
View file @
d25676a6
...
...
@@ -290,8 +290,6 @@ stackStubExpr w = CmmLit (CmmInt 0 w)
-- functions to pass the arguments in an overflow area and to pass them in spill slots.
copyInOflow
::
Convention
->
Area
->
CmmFormals
->
(
Int
,
CmmAGraph
)
copyInSlot
::
Convention
->
CmmFormals
->
[
CmmNode
O
O
]
copyOutOflow
::
Convention
->
Transfer
->
Area
->
CmmActuals
->
UpdFrameOffset
->
(
Int
,
CmmAGraph
)
copyOutSlot
::
Convention
->
[
LocalReg
]
->
[
CmmNode
O
O
]
copyInOflow
conv
area
formals
=
(
offset
,
catAGraphs
$
map
mkMiddle
nodes
)
...
...
@@ -333,26 +331,37 @@ oneCopySlotI _ (reg, _) (n, ms) =
-- Factoring out the common parts of the copyout functions yielded something
-- more complicated:
copyOutOflow
::
Convention
->
Transfer
->
Area
->
CmmActuals
->
UpdFrameOffset
->
(
Int
,
CmmAGraph
)
-- Generate code to move the actual parameters into the locations
-- required by the calling convention. This includes a store for the return address.
--
-- The argument layout function ignores the pointer to the info table, so we slot that
-- in here. When copying-out to a young area, we set the info table for return
-- and adjust the offsets of the other parameters.
-- If this is a call instruction, we adjust the offsets of the other parameters.
copyOutOflow
conv
transfer
area
@
(
CallArea
a
)
actuals
updfr_off
=
foldr
co
(
init_offset
,
emptyAGraph
)
args'
where
co
(
v
,
RegisterParam
r
)
(
n
,
ms
)
=
(
n
,
mkAssign
(
CmmGlobal
r
)
v
<*>
ms
)
co
(
v
,
StackParam
off
)
(
n
,
ms
)
=
(
max
n
off
,
mkStore
(
CmmStackSlot
area
off
)
v
<*>
ms
)
(
setRA
,
init_offset
)
=
case
a
of
Young
id
->
id
`
seq
`
-- set RA if making a call
if
transfer
==
Call
then
([(
CmmLit
(
CmmBlock
id
),
StackParam
init_offset
)],
widthInBytes
wordWidth
)
else
(
[]
,
0
)
Old
->
(
[]
,
updfr_off
)
args
=
assignArgumentsPos
conv
cmmExprType
actuals
args'
=
foldl
adjust
setRA
args
where
adjust
rst
(
v
,
StackParam
off
)
=
(
v
,
StackParam
(
off
+
init_offset
))
:
rst
adjust
rst
x
@
(
_
,
RegisterParam
_
)
=
x
:
rst
copyOutOflow
conv
transfer
area
@
(
CallArea
a
)
actuals
updfr_off
=
foldr
co
(
init_offset
,
emptyAGraph
)
args'
where
co
(
v
,
RegisterParam
r
)
(
n
,
ms
)
=
(
n
,
mkAssign
(
CmmGlobal
r
)
v
<*>
ms
)
co
(
v
,
StackParam
off
)
(
n
,
ms
)
=
(
max
n
off
,
mkStore
(
CmmStackSlot
area
off
)
v
<*>
ms
)
(
setRA
,
init_offset
)
=
case
a
of
Young
id
->
id
`
seq
`
-- Generate a store instruction for
-- the return address if making a call
if
transfer
==
Call
then
([(
CmmLit
(
CmmBlock
id
),
StackParam
init_offset
)],
widthInBytes
wordWidth
)
else
(
[]
,
0
)
Old
->
(
[]
,
updfr_off
)
args
::
[(
CmmExpr
,
ParamLocation
ByteOff
)]
-- The argument and where to put it
args
=
assignArgumentsPos
conv
cmmExprType
actuals
args'
=
foldl
adjust
setRA
args
where
adjust
rst
(
v
,
StackParam
off
)
=
(
v
,
StackParam
(
off
+
init_offset
))
:
rst
adjust
rst
x
@
(
_
,
RegisterParam
_
)
=
x
:
rst
copyOutOflow
_
_
(
RegSlot
_
)
_
_
=
panic
"cannot copy arguments into a register slot"
-- Args passed only in registers and stack slots; no overflow space.
...
...
compiler/cmm/cmm-notes
View file @
d25676a6
More notes (June 11)
~~~~~~~~~~~~~~~~~~~~
* Kill dead code assignArguments, argumentsSize in CmmCallConv.
Bake in ByteOff to ParamLocation and ArgumentFormat
CmmActuals -> [CmmActual] similary CmmFormals
* Possible refactoring: Nuke AGraph in favour of
mkIfThenElse :: Expr -> Graph -> Graph -> FCode Graph
or even
mkIfThenElse :: HasUniques m => Expr -> Graph -> Graph -> m Graph
(Remmber that the .cmm file parser must use this function)
or parameterise FCode over its envt; the CgState part seem useful for both
* Move top and tail calls to runCmmContFlowOpts from HscMain to CmmCps.cpsTop
(and rename the latter!)
* "Remove redundant reloads" in CmmSpillReload should be redundant; since
insertLateReloads is now gone, every reload is reloading a live variable.
Test and nuke.
* Sink and inline S(RegSlot(x)) = e in precisely the same way that we
sink and inline x = e
* Stack layout is very like register assignment: find non-conflicting assigments.
In particular we can use colouring or linear scan (etc).
We'd fine-grain interference (on a word by word basis) to get maximum overlap.
But that may make very big interference graphs. So linear scan might be
more attactive.
NB: linear scan does on-the-fly live range splitting.
* When stubbing dead slots be careful not to write into an area that
overlaps with an area that's in use. So stubbing needs to *follow*
stack layout.
More notes (May 11)
~~~~~~~~~~~~~~~~~~~
In CmmNode, consider spliting CmmCall into two: call and jump
...
...
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