[project @ 2001-04-03 15:36:44 by sewardj]
[ghc-hetmet.git] / ghc / compiler / absCSyn / PprAbsC.lhs
index 5eb0cc1..e022656 100644 (file)
@@ -43,11 +43,11 @@ import FiniteMap    ( addToFM, emptyFM, lookupFM, FiniteMap )
 import Literal         ( Literal(..) )
 import TyCon           ( tyConDataCons )
 import Name            ( NamedThing(..) )
-import DataCon         ( DataCon{-instance NamedThing-}, dataConWrapId )
+import DataCon         ( dataConWrapId )
 import Maybes          ( maybeToBool, catMaybes )
-import PrimOp          ( primOpNeedsWrapper, pprPrimOp, pprCCallOp, 
+import PrimOp          ( primOpNeedsWrapper, pprCCallOp, 
                          PrimOp(..), CCall(..), CCallTarget(..), isDynamicTarget )
-import PrimRep         ( isFloatingRep, PrimRep(..), getPrimRepSize, showPrimRep )
+import PrimRep         ( isFloatingRep, PrimRep(..), getPrimRepSize )
 import SMRep           ( pprSMRep )
 import Unique          ( pprUnique, Unique{-instance NamedThing-} )
 import UniqSet         ( emptyUniqSet, elementOfUniqSet,
@@ -60,7 +60,6 @@ import GlaExts
 import Util            ( nOfThem )
 
 import ST
-import MutableArray
 
 infixr 9 `thenTE`
 \end{code}
@@ -240,7 +239,7 @@ pprAbsC stmt@(COpStmt results op args vol_regs) _
        the_op
   where
     ppr_op_call results args
-      = hcat [ pprPrimOp op, lparen,
+      = hcat [ ppr op, lparen,
        hcat (punctuate comma (map ppr_op_result results)),
        if null results || null args then empty else comma,
        hcat (punctuate comma (map pprAmode args)),
@@ -334,14 +333,14 @@ pprAbsC stmt@(CCallTypedef is_tdef (CCall op_str is_asm may_gc cconv) results ar
      ccall_res_ty = 
        case non_void_results of
           []       -> ptext SLIT("void")
-         [amode]  -> text (showPrimRep (getAmodeRep amode))
+         [amode]  -> ppr (getAmodeRep amode)
          _        -> panic "pprAbsC{CCallTypedef}: ccall_res_ty"
 
      ccall_decl_ty_args 
        | is_tdef   = tail ccall_arg_tys
        | otherwise = ccall_arg_tys
 
-     ccall_arg_tys      = map (text.showPrimRep.getAmodeRep) non_void_args
+     ccall_arg_tys      = map (ppr . getAmodeRep) non_void_args
 
       -- the first argument will be the "I/O world" token (a VoidRep)
       -- all others should be non-void
@@ -419,16 +418,18 @@ pprAbsC stmt@(CStaticClosure closure_lbl cl_info cost_centre amodes) _
       where 
        rep = getAmodeRep item
 
-    padding_wds =
-       if not (closureUpdReqd cl_info) then
-           []
-       else
-           case max 0 (mIN_UPD_SIZE - length amodes) of { still_needed ->
-           nOfThem still_needed (mkIntCLit 0) } -- a bunch of 0s
+    upd_reqd = closureUpdReqd cl_info
 
+    padding_wds
+       | not upd_reqd = []
+       | otherwise    = case max 0 (mIN_UPD_SIZE - length amodes) of { still_needed ->
+                        nOfThem still_needed (mkIntCLit 0) } -- a bunch of 0s
+
+       -- always have a static link field, it's used to save the closure's
+       -- info pointer when we're reverting CAFs (see comment in Storage.c)
     static_link_field
-       | staticClosureNeedsLink cl_info = [mkIntCLit 0]
-       | otherwise                      = []
+       | upd_reqd || staticClosureNeedsLink cl_info = [mkIntCLit 0]
+       | otherwise                                  = []
 
 pprAbsC stmt@(CClosureInfoAndCode cl_info slow maybe_fast cl_descr) _
   = vcat [
@@ -648,9 +649,6 @@ pp_basic_restores = ptext SLIT("CALLER_RESTORE_SYSTEM")
 \end{code}
 
 \begin{code}
-has_srt (_, NoSRT) = False
-has_srt _ = True
-
 pp_srt_info srt = 
     case srt of
        (lbl, NoSRT) ->