[project @ 1999-06-24 13:04:13 by simonmar]
[ghc-hetmet.git] / ghc / compiler / nativeGen / AbsCStixGen.lhs
index d692cdb..e4c1968 100644 (file)
@@ -23,7 +23,8 @@ import SMRep          ( fixedItblSize,
 import Constants       ( mIN_UPD_SIZE )
 import CLabel           ( CLabel, mkReturnInfoLabel, mkReturnPtLabel )
 import ClosureInfo     ( infoTableLabelFromCI, entryLabelFromCI,
-                         fastLabelFromCI, closureUpdReqd
+                         fastLabelFromCI, closureUpdReqd,
+                         staticClosureNeedsLink
                        )
 import Const           ( Literal(..) )
 import Maybes          ( maybeToBool )
@@ -97,7 +98,7 @@ Here we handle top-level things, like @CCodeBlock@s and
                         LvSmall _ -> rET_SMALL
                         LvLarge _ -> rET_BIG
 
- gentopcode stmt@(CClosureInfoAndCode cl_info slow Nothing _ _)
+ gentopcode stmt@(CClosureInfoAndCode cl_info slow Nothing _)
 
   | slow_is_empty
   = genCodeInfoTable stmt              `thenUs` \ itbl ->
@@ -112,7 +113,7 @@ Here we handle top-level things, like @CCodeBlock@s and
     slow_is_empty = not (maybeToBool (nonemptyAbsC slow))
     slow_lbl = entryLabelFromCI cl_info
 
- gentopcode stmt@(CClosureInfoAndCode cl_info slow (Just fast) _ _) =
+ gentopcode stmt@(CClosureInfoAndCode cl_info slow (Just fast) _) =
  -- ToDo: what if this is empty? ------------------------^^^^
     genCodeInfoTable stmt              `thenUs` \ itbl ->
     gencode slow                       `thenUs` \ slow_code ->
@@ -167,26 +168,30 @@ Here we handle top-level things, like @CCodeBlock@s and
     -> UniqSM StixTreeList
  -}
  genCodeStaticClosure (CStaticClosure _ cl_info cost_centre amodes)
-  = returnUs (\xs -> table : xs)
+  = returnUs (\xs -> table ++ xs)
   where
-    table = StData PtrRep (StCLbl info_lbl : body)
-    info_lbl = infoTableLabelFromCI cl_info
+    table = StData PtrRep [StCLbl (infoTableLabelFromCI cl_info)] : 
+           map (\amode -> StData (getAmodeRep amode) [a2stix amode]) amodes ++
+           [StData PtrRep (padding_wds ++ static_link)]
 
     -- always at least one padding word: this is the static link field
     -- for the garbage collector.
-    body = if closureUpdReqd cl_info then
-               take (1 + max mIN_UPD_SIZE (length amodes')) (amodes' ++ zeros)
-          else
-               amodes' ++ [StInt 0]
+    padding_wds = if closureUpdReqd cl_info then
+                       take (max 0 (mIN_UPD_SIZE - length amodes)) zeros
+                 else
+                       []
 
-    zeros = StInt 0 : zeros
+    static_link | staticClosureNeedsLink cl_info = [StInt 0]
+               | otherwise                      = []
 
-    amodes' = map amodeZeroVoid amodes
+    zeros = StInt 0 : zeros
 
+    {- needed??? --SDM
        -- Watch out for VoidKinds...cf. PprAbsC
     amodeZeroVoid item
       | getAmodeRep item == VoidRep = StInt 0
       | otherwise = a2stix item
+    -}
 
 \end{code}
 
@@ -238,10 +243,10 @@ addresses, etc.)
 
  gencode (CInitHdr cl_info reg_rel _)
   = let
-       lhs = a2stix (CVal reg_rel PtrRep)
+       lhs = a2stix reg_rel
        lbl = infoTableLabelFromCI cl_info
     in
-       returnUs (\xs -> StAssign PtrRep lhs (StCLbl lbl) : xs)
+       returnUs (\xs -> StAssign PtrRep (StInd PtrRep lhs) (StCLbl lbl) : xs)
 
 \end{code}