[project @ 2002-10-24 14:17:46 by simonpj]
[ghc-hetmet.git] / ghc / compiler / nativeGen / AbsCStixGen.lhs
index b3ac35b..426ae3c 100644 (file)
@@ -33,7 +33,7 @@ import Maybes         ( maybeToBool )
 import StgSyn          ( StgOp(..) )
 import MachOp          ( MachOp(..), resultRepOfMachOp )
 import PrimRep         ( isFloatingRep, is64BitRep, 
-                         PrimRep(..), getPrimRepArrayElemSize )
+                         PrimRep(..), getPrimRepSizeInBytes )
 import StixInfo                ( genCodeInfoTable, genBitmapInfoTable,
                          livenessIsSmall, bitmapToIntegers )
 import StixMacro       ( macroCode, checkCode )
@@ -49,7 +49,7 @@ import CmdLineOpts    ( opt_Static, opt_EnsureSplittableC )
 import Outputable      ( assertPanic )
 
 -- DEBUGGING ONLY
---import IOExts                ( trace )
+--import TRACE         ( trace )
 --import Outputable    ( showSDoc )
 --import MachOp                ( pprMachOp )
 
@@ -181,7 +181,7 @@ Here we handle top-level things, like @CCodeBlock@s and
                                       (tyConDataCons tycon) )
              ]
 
- gentopcode stmt@(CModuleInitBlock lbl absC)
+ gentopcode stmt@(CModuleInitBlock plain_lbl lbl absC)
   = gencode absC                       `thenUs` \ code ->
     getUniqLabelNCG                    `thenUs` \ tmp_lbl ->
     getUniqLabelNCG                    `thenUs` \ flag_lbl ->
@@ -189,6 +189,8 @@ Here we handle top-level things, like @CCodeBlock@s and
             : StLabel flag_lbl
             : StData IntRep [StInt 0]
             : StSegment TextSegment
+            : StLabel plain_lbl
+            : StJump NoDestInfo (StCLbl lbl)
             : StLabel lbl
             : StCondJump tmp_lbl (StMachOp MO_Nat_Ne
                                     [StInd IntRep (StCLbl flag_lbl),
@@ -231,15 +233,18 @@ Here we handle top-level things, like @CCodeBlock@s and
   = returnUs (\xs -> table ++ xs)
   where
     table = StData PtrRep [StCLbl (infoTableLabelFromCI cl_info)] : 
-           map do_one_amode amodes
+           foldr do_one_amode [] amodes
 
-    do_one_amode amode 
-       = StData (promote_to_word (getAmodeRep amode)) [a2stix amode]
+    do_one_amode amode rest
+       | rep == VoidRep = rest
+       | otherwise      = StData (promote_to_word rep) [a2stix amode] : rest
+       where 
+         rep = getAmodeRep amode
 
     -- We need to promote any item smaller than a word to a word
     promote_to_word pk 
-       | getPrimRepArrayElemSize pk >= getPrimRepArrayElemSize IntRep  = pk
-       | otherwise                                                     = IntRep
+       | getPrimRepSizeInBytes pk >= getPrimRepSizeInBytes IntRep  = pk
+       | otherwise                                                 = IntRep
 \end{code}
 
 Now the individual AbstractC statements.