diff options
author | Michael D. Adams <t-madams@microsoft.com> | 2007-06-28 08:25:43 +0000 |
---|---|---|
committer | Michael D. Adams <t-madams@microsoft.com> | 2007-06-28 08:25:43 +0000 |
commit | 81285ec475e94ef93d2ac59386d48cb333da2c96 (patch) | |
tree | 24690976f6da38cc5da0843f0f7b47da7f7d2b62 /compiler/cmm/CmmCallConv.hs | |
parent | 61c73ae30a45d558815cf21272d13f2fa260519f (diff) | |
download | haskell-81285ec475e94ef93d2ac59386d48cb333da2c96.tar.gz |
Comment and formatting updates for the CPS pass
Diffstat (limited to 'compiler/cmm/CmmCallConv.hs')
-rw-r--r-- | compiler/cmm/CmmCallConv.hs | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/compiler/cmm/CmmCallConv.hs b/compiler/cmm/CmmCallConv.hs index ee16fe95c1..86a27b55f7 100644 --- a/compiler/cmm/CmmCallConv.hs +++ b/compiler/cmm/CmmCallConv.hs @@ -1,7 +1,6 @@ module CmmCallConv ( ParamLocation(..), ArgumentFormat, - assignRegs, assignArguments, ) where @@ -15,26 +14,35 @@ import Constants import StaticFlags (opt_Unregisterised) import Panic +-- Calculate the 'GlobalReg' or stack locations for function call +-- parameters as used by the Cmm calling convention. + data ParamLocation = RegisterParam GlobalReg | StackParam WordOff -assignRegs :: [LocalReg] -> ArgumentFormat LocalReg -assignRegs regs = assignRegs' regs 0 availRegs - where - assignRegs' (r:rs) offset availRegs = (r,assignment):assignRegs' rs new_offset remaining - where - (assignment, new_offset, remaining) = assign_reg (localRegRep r) offset availRegs +type ArgumentFormat a = [(a, ParamLocation)] assignArguments :: (a -> MachRep) -> [a] -> ArgumentFormat a assignArguments f reps = assignArguments' reps 0 availRegs where assignArguments' [] offset availRegs = [] - assignArguments' (r:rs) offset availRegs = (r,assignment):assignArguments' rs new_offset remaining + assignArguments' (r:rs) offset availRegs = + (r,assignment):assignArguments' rs new_offset remaining where - (assignment, new_offset, remaining) = assign_reg (f r) offset availRegs + (assignment, new_offset, remaining) = + assign_reg (f r) offset availRegs -type ArgumentFormat a = [(a, ParamLocation)] +argumentsSize :: (a -> MachRep) -> [a] -> WordOff +argumentsSize f reps = maximum (0 : map arg_top args) + where + args = assignArguments f reps + + arg_top (a, StackParam offset) = -offset + arg_top (_, RegisterParam _) = 0 + +----------------------------------------------------------------------------- +-- Local information about the registers available type AvailRegs = ( [GlobalReg] -- available vanilla regs. , [GlobalReg] -- floats @@ -65,7 +73,8 @@ availRegs = (regList VanillaReg useVanillaRegs, regList f max = map f [1 .. max] slot_size :: LocalReg -> Int -slot_size reg = ((machRepByteWidth (localRegRep reg) - 1) `div` wORD_SIZE) + 1 +slot_size reg = + ((machRepByteWidth (localRegRep reg) - 1) `div` wORD_SIZE) + 1 slot_size' :: MachRep -> Int slot_size' reg = ((machRepByteWidth reg - 1) `div` wORD_SIZE) + 1 |