[project @ 2002-03-02 18:02:30 by sof]
authorsof <unknown>
Sat, 2 Mar 2002 18:02:31 +0000 (18:02 +0000)
committersof <unknown>
Sat, 2 Mar 2002 18:02:31 +0000 (18:02 +0000)
Urk, code generator assumed reversed info tables
in its implementation of dataToTag# - broke a
compiler built unregisterised rather weirdly
(and only, none of the code in testsuite/ nor
nofib/ showed up this bug.)

This commit assumes that unregisterised==
info_tables_not_next_to_code & calls upon
a trusty old PrimOps.h macro to locate the tag
in the info table (the reasons for doing it
this way is explained in AbsCUtils.lhs
comments).

To help the poor sod who has to debug a break
like this sometime in the future, I'm trying to
come up with a repro case smaller than
ghc/compiler/ -- not yet successful.

Anyway, this concludes the fixes to the
unregisterised bits; I hereby claim that it
is now working again.

ghc/compiler/absCSyn/AbsCSyn.lhs
ghc/compiler/absCSyn/AbsCUtils.lhs
ghc/compiler/absCSyn/PprAbsC.lhs

index edc2bc0..36d3db7 100644 (file)
@@ -1,7 +1,7 @@
 %
 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
 %
-% $Id: AbsCSyn.lhs,v 1.45 2002/02/06 11:13:47 sewardj Exp $
+% $Id: AbsCSyn.lhs,v 1.46 2002/03/02 18:02:30 sof Exp $
 %
 \section[AbstractC]{Abstract C: the last stop before machine code}
 
@@ -269,6 +269,9 @@ data CStmtMacro
   | PUSH_SEQ_FRAME                     -- push seq frame
   | UPDATE_SU_FROM_UPD_FRAME           -- pull Su out of the update frame
   | SET_TAG                            -- set TagReg if it exists
+      -- dataToTag# primop -- *only* used in unregisterised builds.
+      -- (see AbsCUtils.dsCOpStmt)
+  | DATA_TO_TAGZH
 
   | REGISTER_FOREIGN_EXPORT            -- register a foreign exported fun
   | REGISTER_IMPORT                    -- register an imported module
index c3a63f9..c6f5fc8 100644 (file)
@@ -29,7 +29,7 @@ import MachOp         ( MachOp(..), isDefinitelyInlineMachOp )
 import Unique          ( Unique{-instance Eq-} )
 import UniqSupply      ( uniqFromSupply, uniqsFromSupply, splitUniqSupply, 
                          UniqSupply )
-import CmdLineOpts      ( opt_EmitCExternDecls )
+import CmdLineOpts      ( opt_EmitCExternDecls, opt_Unregisterised )
 import ForeignCall     ( ForeignCall(..), CCallSpec(..), CCallTarget(..), Safety(..),
                          isDynamicTarget, isCasmTarget, defaultCCallConv )
 import StgSyn          ( StgOp(..) )
@@ -901,12 +901,45 @@ dscCOpStmt [res] AddrToHValueOp [arg] vols
         (CAssign res arg)
 
 -- #define dataToTagzh(r,a)  r=(GET_TAG(((StgClosure *)a)->header.info))
+-- 
+--   In the unregisterised case, we don't attempt to compute the location
+--   of the tag halfword, just a macro. For this build, fixing on layout
+--   info has only got drawbacks. [NOTE: We're faking it slightly here,
+--   info table layout is a separate issue from having an unregistered
+--   impl of the STG machine, but currently only the unregisterised build
+--   doesn't have TABLES_NEXT_TO_CODE]
+--
+--   Should this arrangement deeply offend you for some reason, code which
+--   computes the offset can be found below also.
+--      -- sof 3/02
+-- 
 dscCOpStmt [res] DataToTagOp [arg] vols
+   | opt_Unregisterised
+   = returnFlt (CMacroStmt DATA_TO_TAGZH [res,arg])
+   | otherwise
    = mkTemps [PtrRep, WordRep]         `thenFlt` \ [t_infoptr, t_theword] ->
      mkHalfWord_HIADDR res t_theword   `thenFlt` \ select_ops ->
      (returnFlt . CSequential) [
         CAssign t_infoptr (mkDerefOff PtrRep arg 0),
+        {-
+          Get at the tag within the info table; two cases to consider:
+          
+             - reversed info tables next to the entry point code;
+               one word above the end of the info table (which is
+               what t_infoptr is really pointing to).
+             - info tables with their entry points stored somewhere else,
+               which is how the unregisterised (nee TABLES_NEXT_TO_CODE)
+               world operates.
+               
+               The t_infoptr points to the start of the info table, so add
+               the length of the info table & subtract one word.
+        -}
         CAssign t_theword (mkDerefOff WordRep t_infoptr (-1)),
+{- UNUSED - see above comment.
+                                    (if opt_Unregisterised then 
+                                        (fixedItblSize - 1)
+                                     else (-1))),
+-}
         select_ops
      ]
 
index 0c8688a..dc072cc 100644 (file)
@@ -1312,6 +1312,7 @@ cStmtMacroText PUSH_UPD_FRAME             = SLIT("PUSH_UPD_FRAME")
 cStmtMacroText PUSH_SEQ_FRAME          = SLIT("PUSH_SEQ_FRAME")
 cStmtMacroText UPDATE_SU_FROM_UPD_FRAME        = SLIT("UPDATE_SU_FROM_UPD_FRAME")
 cStmtMacroText SET_TAG                 = SLIT("SET_TAG")
+cStmtMacroText DATA_TO_TAGZH            = SLIT("dataToTagzh")
 cStmtMacroText REGISTER_FOREIGN_EXPORT = SLIT("REGISTER_FOREIGN_EXPORT")
 cStmtMacroText REGISTER_IMPORT         = SLIT("REGISTER_IMPORT")
 cStmtMacroText REGISTER_DIMPORT                = SLIT("REGISTER_DIMPORT")