Commit f13f9fca authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

Merge branch 'master' of http://darcs.haskell.org/ghc

parents 735519b4 da15d0c5
module CmmCallConv ( module CmmCallConv (
ParamLocation(..), ParamLocation(..),
ArgumentFormat, assignArgumentsPos
assignArguments,
assignArgumentsPos,
argumentsSize,
) where ) where
#include "HsVersions.h" #include "HsVersions.h"
...@@ -21,25 +18,19 @@ import Outputable ...@@ -21,25 +18,19 @@ import Outputable
-- Calculate the 'GlobalReg' or stack locations for function call -- Calculate the 'GlobalReg' or stack locations for function call
-- parameters as used by the Cmm calling convention. -- parameters as used by the Cmm calling convention.
data ParamLocation a data ParamLocation
= RegisterParam GlobalReg = RegisterParam GlobalReg
| StackParam a | StackParam ByteOff
instance (Outputable a) => Outputable (ParamLocation a) where instance Outputable ParamLocation where
ppr (RegisterParam g) = ppr g ppr (RegisterParam g) = ppr g
ppr (StackParam p) = ppr p ppr (StackParam p) = ppr p
type ArgumentFormat a b = [(a, ParamLocation b)]
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 -- | JD: For the new stack story, I want arguments passed on the stack to manifest as
-- positive offsets in a CallArea, not negative offsets from the stack pointer. -- positive offsets in a CallArea, not negative offsets from the stack pointer.
-- Also, I want byte offsets, not word offsets. -- Also, I want byte offsets, not word offsets.
assignArgumentsPos :: (Outputable a) => Convention -> (a -> CmmType) -> [a] -> assignArgumentsPos :: Convention -> (a -> CmmType) -> [a] ->
ArgumentFormat a ByteOff [(a, ParamLocation)]
-- Given a list of arguments, and a function that tells their types, -- Given a list of arguments, and a function that tells their types,
-- return a list showing where each argument is passed -- return a list showing where each argument is passed
assignArgumentsPos conv arg_ty reps = assignments assignArgumentsPos conv arg_ty reps = assignments
...@@ -97,14 +88,6 @@ assignArgumentsPos conv arg_ty reps = assignments ...@@ -97,14 +88,6 @@ assignArgumentsPos conv arg_ty reps = assignments
size = (((widthInBytes w - 1) `div` wORD_SIZE) + 1) * wORD_SIZE size = (((widthInBytes w - 1) `div` wORD_SIZE) + 1) * wORD_SIZE
off' = offset + size off' = offset + size
argumentsSize :: (a -> CmmType) -> [a] -> WordOff
argumentsSize f reps = maximum (0 : map arg_top args)
where
args = assignArguments f reps
arg_top (_, StackParam offset) = -offset
arg_top (_, RegisterParam _) = 0
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- Local information about the registers available -- Local information about the registers available
......
...@@ -83,7 +83,7 @@ toZgraph fun_name g@(Old.ListGraph (Old.BasicBlock id ss : other_blocks)) = ...@@ -83,7 +83,7 @@ toZgraph fun_name g@(Old.ListGraph (Old.BasicBlock id ss : other_blocks)) =
strip_hints :: [Old.CmmHinted a] -> [a] strip_hints :: [Old.CmmHinted a] -> [a]
strip_hints = map Old.hintlessCmm strip_hints = map Old.hintlessCmm
convert_target :: Old.CmmCallTarget -> Old.HintedCmmFormals -> Old.HintedCmmActuals -> ForeignTarget convert_target :: Old.CmmCallTarget -> [Old.HintedCmmFormal] -> [Old.HintedCmmActual] -> ForeignTarget
convert_target (Old.CmmCallee e cc) ress args = ForeignTarget e (ForeignConvention cc (map Old.cmmHint args) (map Old.cmmHint ress)) convert_target (Old.CmmCallee e cc) ress args = ForeignTarget e (ForeignConvention cc (map Old.cmmHint args) (map Old.cmmHint ress))
convert_target (Old.CmmPrim op) _ress _args = PrimTarget op convert_target (Old.CmmPrim op) _ress _args = PrimTarget op
......
...@@ -10,7 +10,7 @@ module CmmDecl ( ...@@ -10,7 +10,7 @@ module CmmDecl (
GenCmm(..), GenCmmTop(..), GenCmm(..), GenCmmTop(..),
CmmInfoTable(..), HasStaticClosure, ClosureTypeInfo(..), ConstrDescription, CmmInfoTable(..), HasStaticClosure, ClosureTypeInfo(..), ConstrDescription,
ProfilingInfo(..), ClosureTypeTag, ProfilingInfo(..), ClosureTypeTag,
CmmActual, CmmActuals, CmmFormal, CmmFormals, ForeignHint(..), CmmActual, CmmFormal, ForeignHint(..),
CmmStatic(..), Section(..), CmmStatic(..), Section(..),
) where ) where
...@@ -114,8 +114,6 @@ type SelectorOffset = StgWord ...@@ -114,8 +114,6 @@ type SelectorOffset = StgWord
type CmmActual = CmmExpr type CmmActual = CmmExpr
type CmmFormal = LocalReg type CmmFormal = LocalReg
type CmmActuals = [CmmActual]
type CmmFormals = [CmmFormal]
data ForeignHint data ForeignHint
= NoHint | AddrHint | SignedHint = NoHint | AddrHint | SignedHint
......
...@@ -42,8 +42,8 @@ data CmmNode e x where ...@@ -42,8 +42,8 @@ data CmmNode e x where
-- Like a "fat machine instruction"; can occur -- Like a "fat machine instruction"; can occur
-- in the middle of a block -- in the middle of a block
ForeignTarget -> -- call target ForeignTarget -> -- call target
CmmFormals -> -- zero or more results [CmmFormal] -> -- zero or more results
CmmActuals -> -- zero or more arguments [CmmActual] -> -- zero or more arguments
CmmNode O O CmmNode O O
-- Semantics: kills only result regs; all other regs (both GlobalReg -- Semantics: kills only result regs; all other regs (both GlobalReg
-- and LocalReg) are preserved. But there is a current -- and LocalReg) are preserved. But there is a current
...@@ -105,8 +105,8 @@ data CmmNode e x where ...@@ -105,8 +105,8 @@ data CmmNode e x where
CmmForeignCall :: { -- A safe foreign call; see Note [Foreign calls] CmmForeignCall :: { -- A safe foreign call; see Note [Foreign calls]
-- Always the last node of a block -- Always the last node of a block
tgt :: ForeignTarget, -- call target and convention tgt :: ForeignTarget, -- call target and convention
res :: CmmFormals, -- zero or more results res :: [CmmFormal], -- zero or more results
args :: CmmActuals, -- zero or more arguments; see Note [Register parameter passing] args :: [CmmActual], -- zero or more arguments; see Note [Register parameter passing]
succ :: Label, -- Label of continuation succ :: Label, -- Label of continuation
updfr :: UpdFrameOffset, -- where the update frame is (for building infotable) updfr :: UpdFrameOffset, -- where the update frame is (for building infotable)
intrbl:: Bool -- whether or not the call is interruptible intrbl:: Bool -- whether or not the call is interruptible
......
...@@ -234,7 +234,7 @@ algorithm would be just as good, so that's what we do. ...@@ -234,7 +234,7 @@ algorithm would be just as good, so that's what we do.
-} -}
data Protocol = Protocol Convention CmmFormals Area data Protocol = Protocol Convention [CmmFormal] Area
deriving Eq deriving Eq
instance Outputable Protocol where instance Outputable Protocol where
ppr (Protocol c fs a) = text "Protocol" <+> ppr c <+> ppr fs <+> ppr a ppr (Protocol c fs a) = text "Protocol" <+> ppr c <+> ppr fs <+> ppr a
......
...@@ -289,6 +289,10 @@ boundedOrdLattice n = DataflowLattice n minBound f ...@@ -289,6 +289,10 @@ boundedOrdLattice n = DataflowLattice n minBound f
-- Custom node type we'll rewrite to. CmmAssign nodes to local -- Custom node type we'll rewrite to. CmmAssign nodes to local
-- registers are replaced with AssignLocal nodes. -- registers are replaced with AssignLocal nodes.
data WithRegUsage n e x where data WithRegUsage n e x where
-- Plain will not contain CmmAssign nodes immediately after
-- transformation, but as we rewrite assignments, we may have
-- assignments here: these are assignments that should not be
-- rewritten!
Plain :: n e x -> WithRegUsage n e x Plain :: n e x -> WithRegUsage n e x
AssignLocal :: LocalReg -> CmmExpr -> RegUsage -> WithRegUsage n O O AssignLocal :: LocalReg -> CmmExpr -> RegUsage -> WithRegUsage n O O
......
...@@ -119,25 +119,25 @@ mkAssign :: CmmReg -> CmmExpr -> CmmAGraph ...@@ -119,25 +119,25 @@ mkAssign :: CmmReg -> CmmExpr -> CmmAGraph
mkStore :: CmmExpr -> CmmExpr -> CmmAGraph mkStore :: CmmExpr -> CmmExpr -> CmmAGraph
---------- Calls ---------- Calls
mkCall :: CmmExpr -> (Convention, Convention) -> CmmFormals -> CmmActuals -> mkCall :: CmmExpr -> (Convention, Convention) -> [CmmFormal] -> [CmmActual] ->
UpdFrameOffset -> CmmAGraph UpdFrameOffset -> CmmAGraph
mkCmmCall :: CmmExpr -> CmmFormals -> CmmActuals -> mkCmmCall :: CmmExpr -> [CmmFormal] -> [CmmActual] ->
UpdFrameOffset -> CmmAGraph UpdFrameOffset -> CmmAGraph
-- Native C-- calling convention -- Native C-- calling convention
mkSafeCall :: ForeignTarget -> CmmFormals -> CmmActuals -> UpdFrameOffset -> Bool -> CmmAGraph mkSafeCall :: ForeignTarget -> [CmmFormal] -> [CmmActual] -> UpdFrameOffset -> Bool -> CmmAGraph
mkUnsafeCall :: ForeignTarget -> CmmFormals -> CmmActuals -> CmmAGraph mkUnsafeCall :: ForeignTarget -> [CmmFormal] -> [CmmActual] -> CmmAGraph
mkFinalCall :: CmmExpr -> CCallConv -> CmmActuals -> UpdFrameOffset -> CmmAGraph mkFinalCall :: CmmExpr -> CCallConv -> [CmmActual] -> UpdFrameOffset -> CmmAGraph
-- Never returns; like exit() or barf() -- Never returns; like exit() or barf()
---------- Control transfer ---------- Control transfer
mkJump :: CmmExpr -> CmmActuals -> UpdFrameOffset -> CmmAGraph mkJump :: CmmExpr -> [CmmActual] -> UpdFrameOffset -> CmmAGraph
mkDirectJump :: CmmExpr -> CmmActuals -> UpdFrameOffset -> CmmAGraph mkDirectJump :: CmmExpr -> [CmmActual] -> UpdFrameOffset -> CmmAGraph
mkJumpGC :: CmmExpr -> CmmActuals -> UpdFrameOffset -> CmmAGraph mkJumpGC :: CmmExpr -> [CmmActual] -> UpdFrameOffset -> CmmAGraph
mkForeignJump :: Convention -> CmmExpr -> CmmActuals -> UpdFrameOffset -> CmmAGraph mkForeignJump :: Convention -> CmmExpr -> [CmmActual] -> UpdFrameOffset -> CmmAGraph
mkCbranch :: CmmExpr -> BlockId -> BlockId -> CmmAGraph mkCbranch :: CmmExpr -> BlockId -> BlockId -> CmmAGraph
mkSwitch :: CmmExpr -> [Maybe BlockId] -> CmmAGraph mkSwitch :: CmmExpr -> [Maybe BlockId] -> CmmAGraph
mkReturn :: CmmExpr -> CmmActuals -> UpdFrameOffset -> CmmAGraph mkReturn :: CmmExpr -> [CmmActual] -> UpdFrameOffset -> CmmAGraph
mkReturnSimple :: CmmActuals -> UpdFrameOffset -> CmmAGraph mkReturnSimple :: [CmmActual] -> UpdFrameOffset -> CmmAGraph
mkBranch :: BlockId -> CmmAGraph mkBranch :: BlockId -> CmmAGraph
mkCmmIfThenElse :: CmmExpr -> CmmAGraph -> CmmAGraph -> CmmAGraph mkCmmIfThenElse :: CmmExpr -> CmmAGraph -> CmmAGraph -> CmmAGraph
...@@ -288,8 +288,8 @@ stackStubExpr w = CmmLit (CmmInt 0 w) ...@@ -288,8 +288,8 @@ stackStubExpr w = CmmLit (CmmInt 0 w)
-- the variables in their spill slots. -- the variables in their spill slots.
-- Therefore, for copying arguments and results, we provide different -- Therefore, for copying arguments and results, we provide different
-- functions to pass the arguments in an overflow area and to pass them in spill slots. -- functions to pass the arguments in an overflow area and to pass them in spill slots.
copyInOflow :: Convention -> Area -> CmmFormals -> (Int, CmmAGraph) copyInOflow :: Convention -> Area -> [CmmFormal] -> (Int, CmmAGraph)
copyInSlot :: Convention -> CmmFormals -> [CmmNode O O] copyInSlot :: Convention -> [CmmFormal] -> [CmmNode O O]
copyOutSlot :: Convention -> [LocalReg] -> [CmmNode O O] copyOutSlot :: Convention -> [LocalReg] -> [CmmNode O O]
copyInOflow conv area formals = (offset, catAGraphs $ map mkMiddle nodes) copyInOflow conv area formals = (offset, catAGraphs $ map mkMiddle nodes)
...@@ -298,7 +298,7 @@ copyInSlot c f = snd $ copyIn oneCopySlotI c (panic "no area for copying to slot ...@@ -298,7 +298,7 @@ copyInSlot c f = snd $ copyIn oneCopySlotI c (panic "no area for copying to slot
type SlotCopier = Area -> (LocalReg, ByteOff) -> (ByteOff, [CmmNode O O]) -> type SlotCopier = Area -> (LocalReg, ByteOff) -> (ByteOff, [CmmNode O O]) ->
(ByteOff, [CmmNode O O]) (ByteOff, [CmmNode O O])
type CopyIn = SlotCopier -> Convention -> Area -> CmmFormals -> (ByteOff, [CmmNode O O]) type CopyIn = SlotCopier -> Convention -> Area -> [CmmFormal] -> (ByteOff, [CmmNode O O])
-- Return the number of bytes used for copying arguments, as well as the -- Return the number of bytes used for copying arguments, as well as the
-- instructions to copy the arguments. -- instructions to copy the arguments.
...@@ -331,7 +331,7 @@ oneCopySlotI _ (reg, _) (n, ms) = ...@@ -331,7 +331,7 @@ oneCopySlotI _ (reg, _) (n, ms) =
-- Factoring out the common parts of the copyout functions yielded something -- Factoring out the common parts of the copyout functions yielded something
-- more complicated: -- more complicated:
copyOutOflow :: Convention -> Transfer -> Area -> CmmActuals -> UpdFrameOffset -> copyOutOflow :: Convention -> Transfer -> Area -> [CmmActual] -> UpdFrameOffset ->
(Int, CmmAGraph) (Int, CmmAGraph)
-- Generate code to move the actual parameters into the locations -- Generate code to move the actual parameters into the locations
-- required by the calling convention. This includes a store for the return address. -- required by the calling convention. This includes a store for the return address.
...@@ -355,7 +355,7 @@ copyOutOflow conv transfer area@(CallArea a) actuals updfr_off ...@@ -355,7 +355,7 @@ copyOutOflow conv transfer area@(CallArea a) actuals updfr_off
else ([], 0) else ([], 0)
Old -> ([], updfr_off) Old -> ([], updfr_off)
args :: [(CmmExpr, ParamLocation ByteOff)] -- The argument and where to put it args :: [(CmmExpr, ParamLocation)] -- The argument and where to put it
args = assignArgumentsPos conv cmmExprType actuals args = assignArgumentsPos conv cmmExprType actuals
args' = foldl adjust setRA args args' = foldl adjust setRA args
...@@ -372,10 +372,10 @@ copyOutSlot conv actuals = foldr co [] args ...@@ -372,10 +372,10 @@ copyOutSlot conv actuals = foldr co [] args
toExp r = CmmReg (CmmLocal r) toExp r = CmmReg (CmmLocal r)
args = assignArgumentsPos conv localRegType actuals args = assignArgumentsPos conv localRegType actuals
mkCallEntry :: Convention -> CmmFormals -> (Int, CmmAGraph) mkCallEntry :: Convention -> [CmmFormal] -> (Int, CmmAGraph)
mkCallEntry conv formals = copyInOflow conv (CallArea Old) formals mkCallEntry conv formals = copyInOflow conv (CallArea Old) formals
lastWithArgs :: Transfer -> Area -> Convention -> CmmActuals -> UpdFrameOffset -> lastWithArgs :: Transfer -> Area -> Convention -> [CmmActual] -> UpdFrameOffset ->
(ByteOff -> CmmAGraph) -> CmmAGraph (ByteOff -> CmmAGraph) -> CmmAGraph
lastWithArgs transfer area conv actuals updfr_off last = lastWithArgs transfer area conv actuals updfr_off last =
let (outArgs, copies) = copyOutOflow conv transfer area actuals updfr_off in let (outArgs, copies) = copyOutOflow conv transfer area actuals updfr_off in
......
...@@ -14,7 +14,7 @@ module OldCmm ( ...@@ -14,7 +14,7 @@ module OldCmm (
cmmMapGraphM, cmmTopMapGraphM, cmmMapGraphM, cmmTopMapGraphM,
GenBasicBlock(..), CmmBasicBlock, blockId, blockStmts, mapBlockStmts, GenBasicBlock(..), CmmBasicBlock, blockId, blockStmts, mapBlockStmts,
CmmStmt(..), CmmReturnInfo(..), CmmHinted(..), CmmStmt(..), CmmReturnInfo(..), CmmHinted(..),
HintedCmmFormal, HintedCmmFormals, HintedCmmActual, HintedCmmActuals, HintedCmmFormal, HintedCmmActual,
CmmSafety(..), CmmCallTarget(..), CmmSafety(..), CmmCallTarget(..),
module CmmDecl, module CmmDecl,
module CmmExpr, module CmmExpr,
...@@ -146,8 +146,8 @@ data CmmStmt -- Old-style ...@@ -146,8 +146,8 @@ data CmmStmt -- Old-style
| CmmCall -- A call (foreign, native or primitive), with | CmmCall -- A call (foreign, native or primitive), with
CmmCallTarget CmmCallTarget
HintedCmmFormals -- zero or more results [HintedCmmFormal] -- zero or more results
HintedCmmActuals -- zero or more arguments [HintedCmmActual] -- zero or more arguments
CmmSafety -- whether to build a continuation CmmSafety -- whether to build a continuation
CmmReturnInfo CmmReturnInfo
-- Some care is necessary when handling the arguments of these, see -- Some care is necessary when handling the arguments of these, see
...@@ -164,22 +164,20 @@ data CmmStmt -- Old-style ...@@ -164,22 +164,20 @@ data CmmStmt -- Old-style
-- Undefined outside range, and when there's a Nothing -- Undefined outside range, and when there's a Nothing
| CmmJump CmmExpr -- Jump to another C-- function, | CmmJump CmmExpr -- Jump to another C-- function,
HintedCmmActuals -- with these parameters. (parameters never used) [HintedCmmActual] -- with these parameters. (parameters never used)
| CmmReturn -- Return from a native C-- function, | CmmReturn -- Return from a native C-- function,
HintedCmmActuals -- with these return values. (parameters never used) [HintedCmmActual] -- with these return values. (parameters never used)
data CmmHinted a = CmmHinted { hintlessCmm :: a, cmmHint :: ForeignHint } data CmmHinted a = CmmHinted { hintlessCmm :: a, cmmHint :: ForeignHint }
deriving( Eq ) deriving( Eq )
type HintedCmmActuals = [HintedCmmActual]
type HintedCmmFormals = [HintedCmmFormal]
type HintedCmmFormal = CmmHinted CmmFormal type HintedCmmFormal = CmmHinted CmmFormal
type HintedCmmActual = CmmHinted CmmActual type HintedCmmActual = CmmHinted CmmActual
data CmmSafety = CmmUnsafe | CmmSafe C_SRT | CmmInterruptible data CmmSafety = CmmUnsafe | CmmSafe C_SRT | CmmInterruptible
-- | enable us to fold used registers over 'CmmActuals' and 'CmmFormals' -- | enable us to fold used registers over '[CmmActual]' and '[CmmFormal]'
instance UserOfLocalRegs CmmStmt where instance UserOfLocalRegs CmmStmt where
foldRegsUsed f (set::b) s = stmt s set foldRegsUsed f (set::b) s = stmt s set
where where
......
...@@ -78,8 +78,8 @@ cheapEqReg _ _ = False ...@@ -78,8 +78,8 @@ cheapEqReg _ _ = False
--------------------------------------------------- ---------------------------------------------------
loadArgsIntoTemps :: [Unique] loadArgsIntoTemps :: [Unique]
-> HintedCmmActuals -> [HintedCmmActual]
-> ([Unique], [CmmStmt], HintedCmmActuals) -> ([Unique], [CmmStmt], [HintedCmmActual])
loadArgsIntoTemps uniques [] = (uniques, [], []) loadArgsIntoTemps uniques [] = (uniques, [], [])
loadArgsIntoTemps uniques ((CmmHinted e hint):args) = loadArgsIntoTemps uniques ((CmmHinted e hint):args) =
(uniques'', (uniques'',
......
...@@ -266,7 +266,7 @@ pprStmt stmt = case stmt of ...@@ -266,7 +266,7 @@ pprStmt stmt = case stmt of
CmmJump lbl _params -> mkJMP_(pprExpr lbl) <> semi CmmJump lbl _params -> mkJMP_(pprExpr lbl) <> semi
CmmSwitch arg ids -> pprSwitch arg ids CmmSwitch arg ids -> pprSwitch arg ids
pprCFunType :: SDoc -> CCallConv -> HintedCmmFormals -> HintedCmmActuals -> SDoc pprCFunType :: SDoc -> CCallConv -> [HintedCmmFormal] -> [HintedCmmActual] -> SDoc
pprCFunType ppr_fn cconv ress args pprCFunType ppr_fn cconv ress args
= res_type ress <+> = res_type ress <+>
parens (text (ccallConvAttribute cconv) <> ppr_fn) <> parens (text (ccallConvAttribute cconv) <> ppr_fn) <>
...@@ -807,7 +807,7 @@ pprLocalReg (LocalReg uniq _) = char '_' <> ppr uniq ...@@ -807,7 +807,7 @@ pprLocalReg (LocalReg uniq _) = char '_' <> ppr uniq
-- ----------------------------------------------------------------------------- -- -----------------------------------------------------------------------------
-- Foreign Calls -- Foreign Calls
pprCall :: SDoc -> CCallConv -> HintedCmmFormals -> HintedCmmActuals -> CmmSafety pprCall :: SDoc -> CCallConv -> [HintedCmmFormal] -> [HintedCmmActual] -> CmmSafety
-> SDoc -> SDoc
pprCall ppr_fn cconv results args _ pprCall ppr_fn cconv results args _
......
More notes (June 11) 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 * Possible refactoring: Nuke AGraph in favour of
mkIfThenElse :: Expr -> Graph -> Graph -> FCode Graph mkIfThenElse :: Expr -> Graph -> Graph -> FCode Graph
or even or even
......
...@@ -43,7 +43,7 @@ import Control.Monad ...@@ -43,7 +43,7 @@ import Control.Monad
-- Code generation for Foreign Calls -- Code generation for Foreign Calls
cgForeignCall cgForeignCall
:: HintedCmmFormals -- where to put the results :: [HintedCmmFormal] -- where to put the results
-> ForeignCall -- the op -> ForeignCall -- the op
-> [StgArg] -- arguments -> [StgArg] -- arguments
-> StgLiveVars -- live vars, in case we need to save them -> StgLiveVars -- live vars, in case we need to save them
...@@ -64,7 +64,7 @@ cgForeignCall results fcall stg_args live ...@@ -64,7 +64,7 @@ cgForeignCall results fcall stg_args live
emitForeignCall emitForeignCall
:: HintedCmmFormals -- where to put the results :: [HintedCmmFormal] -- where to put the results
-> ForeignCall -- the op -> ForeignCall -- the op
-> [CmmHinted CmmExpr] -- arguments -> [CmmHinted CmmExpr] -- arguments
-> StgLiveVars -- live vars, in case we need to save them -> StgLiveVars -- live vars, in case we need to save them
...@@ -109,9 +109,12 @@ emitForeignCall results (CCall (CCallSpec target cconv safety)) args live ...@@ -109,9 +109,12 @@ emitForeignCall results (CCall (CCallSpec target cconv safety)) args live
-- alternative entry point, used by CmmParse -- alternative entry point, used by CmmParse
-- the new code generator has utility function emitCCall and emitPrimCall
-- which should be used instead of this (the equivalent emitForeignCall
-- is not presently exported.)
emitForeignCall' emitForeignCall'
:: Safety :: Safety
-> HintedCmmFormals -- where to put the results -> [HintedCmmFormal] -- where to put the results
-> CmmCallTarget -- the op -> CmmCallTarget -- the op
-> [CmmHinted CmmExpr] -- arguments -> [CmmHinted CmmExpr] -- arguments
-> Maybe [GlobalReg] -- live vars, in case we need to save them -> Maybe [GlobalReg] -- live vars, in case we need to save them
......
...@@ -53,7 +53,7 @@ import Outputable ...@@ -53,7 +53,7 @@ import Outputable
-- representation as a list of 'CmmAddr' is handled later -- representation as a list of 'CmmAddr' is handled later
-- in the pipeline by 'cmmToRawCmm'. -- in the pipeline by 'cmmToRawCmm'.
emitClosureCodeAndInfoTable :: ClosureInfo -> CmmFormals -> CgStmts -> Code emitClosureCodeAndInfoTable :: ClosureInfo -> [CmmFormal] -> CgStmts -> Code
emitClosureCodeAndInfoTable cl_info args body emitClosureCodeAndInfoTable cl_info args body
= do { blks <- cgStmtsToBlocks body = do { blks <- cgStmtsToBlocks body
; info <- mkCmmInfo cl_info ; info <- mkCmmInfo cl_info
...@@ -412,7 +412,7 @@ funInfoTable info_ptr ...@@ -412,7 +412,7 @@ funInfoTable info_ptr
emitInfoTableAndCode emitInfoTableAndCode
:: CLabel -- Label of entry or ret :: CLabel -- Label of entry or ret
-> CmmInfo -- ...the info table -> CmmInfo -- ...the info table
-> CmmFormals -- ...args -> [CmmFormal] -- ...args
-> [CmmBasicBlock] -- ...and body -> [CmmBasicBlock] -- ...and body
-> Code -> Code
......
...@@ -701,6 +701,8 @@ whenC :: Bool -> Code -> Code ...@@ -701,6 +701,8 @@ whenC :: Bool -> Code -> Code
whenC True code = code whenC True code = code
whenC False _ = nopC whenC False _ = nopC
-- Corresponds to 'emit' in new code generator with a smart constructor
-- from cmm/MkGraph.hs
stmtC :: CmmStmt -> Code stmtC :: CmmStmt -> Code
stmtC stmt = emitCgStmt (CgStmt stmt) stmtC stmt = emitCgStmt (CgStmt stmt)
...@@ -741,7 +743,7 @@ emitData sect lits ...@@ -741,7 +743,7 @@ emitData sect lits
where where
data_block = CmmData sect lits data_block = CmmData sect lits
emitProc :: CmmInfo -> CLabel -> CmmFormals -> [CmmBasicBlock] -> Code emitProc :: CmmInfo -> CLabel -> [CmmFormal] -> [CmmBasicBlock] -> Code
emitProc info lbl [] blocks emitProc info lbl [] blocks
= do { let proc_block = CmmProc info lbl (ListGraph blocks) = do { let proc_block = CmmProc info lbl (ListGraph blocks)
; state <- getState ; state <- getState
......
...@@ -35,7 +35,7 @@ import FastString ...@@ -35,7 +35,7 @@ import FastString
-- --------------------------------------------------------------------------- -- ---------------------------------------------------------------------------
-- Code generation for PrimOps -- Code generation for PrimOps
cgPrimOp :: CmmFormals -- where to put the results cgPrimOp :: [CmmFormal] -- where to put the results
-> PrimOp -- the op -> PrimOp -- the op
-> [StgArg] -- arguments -> [StgArg] -- arguments
-> StgLiveVars -- live vars, in case we need to save them -> StgLiveVars -- live vars, in case we need to save them
...@@ -47,7 +47,7 @@ cgPrimOp results op args live ...@@ -47,7 +47,7 @@ cgPrimOp results op args live
emitPrimOp results op non_void_args live emitPrimOp results op non_void_args live
emitPrimOp :: CmmFormals -- where to put the results emitPrimOp :: [CmmFormal] -- where to put the results
-> PrimOp -- the op -> PrimOp -- the op
-> [CmmExpr] -- arguments -> [CmmExpr] -- arguments
-> StgLiveVars -- live vars, in case we need to save them -> StgLiveVars -- live vars, in case we need to save them
...@@ -638,6 +638,13 @@ setInfo closure_ptr info_ptr = CmmStore closure_ptr info_ptr ...@@ -638,6 +638,13 @@ setInfo closure_ptr info_ptr = CmmStore closure_ptr info_ptr
-- ---------------------------------------------------------------------------- -- ----------------------------------------------------------------------------
-- Copying pointer arrays -- Copying pointer arrays
-- EZY: This code has an unusually high amount of assignTemp calls, seen
-- nowhere else in the code generator. This is mostly because these
-- "primitive" ops result in a surprisingly large amount of code. It
-- will likely be worthwhile to optimize what is emitted here, so that
-- our optimization passes don't waste time repeatedly optimizing the
-- same bits of code.
-- | Takes a source 'Array#', an offset in the source array, a -- | Takes a source 'Array#', an offset in the source array, a
-- destination 'MutableArray#', an offset into the destination array, -- destination 'MutableArray#', an offset into the destination array,
-- and the number of elements to copy. Copies the given number of -- and the number of elements to copy. Copies the given number of
......
...@@ -104,16 +104,16 @@ emitCCall hinted_results fn hinted_args ...@@ -104,16 +104,16 @@ emitCCall hinted_results fn hinted_args
fc = ForeignConvention CCallConv arg_hints result_hints fc = ForeignConvention CCallConv arg_hints result_hints
emitPrimCall :: CmmFormals -> CallishMachOp -> CmmActuals -> FCode () emitPrimCall :: [CmmFormal] -> CallishMachOp -> [CmmActual] -> FCode ()
emitPrimCall res op args emitPrimCall res op args
= emitForeignCall PlayRisky res (PrimTarget op) args NoC_SRT CmmMayReturn = emitForeignCall PlayRisky res (PrimTarget op) args NoC_SRT CmmMayReturn
-- alternative entry point, used by CmmParse -- alternative entry point, used by CmmParse
emitForeignCall emitForeignCall
:: Safety :: Safety
-> CmmFormals -- where to put the results -> [CmmFormal] -- where to put the results