[project @ 2000-10-12 11:47:25 by sewardj]
[ghc-hetmet.git] / ghc / compiler / absCSyn / AbsCSyn.lhs
index dfaf400..5cf12fc 100644 (file)
@@ -1,7 +1,7 @@
 %
 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
 %
-% $Id: AbsCSyn.lhs,v 1.21 1999/03/11 11:32:22 simonm Exp $
+% $Id: AbsCSyn.lhs,v 1.33 2000/08/07 23:37:19 qrczak Exp $
 %
 \section[AbstractC]{Abstract C: the last stop before machine code}
 
@@ -39,19 +39,16 @@ module AbsCSyn {- (
 
 import {-# SOURCE #-} ClosureInfo ( ClosureInfo )
 
-#if  ! OMIT_NATIVE_CODEGEN
-import {-# SOURCE #-} MachMisc
-#endif
-
 import CLabel
 import Constants       ( mAX_Vanilla_REG, mAX_Float_REG,
                          mAX_Double_REG, spRelToInt )
 import CostCentre       ( CostCentre, CostCentreStack )
-import Const           ( mkMachInt, Literal )
+import Literal         ( mkMachInt, Literal(..) )
 import PrimRep         ( PrimRep(..) )
-import PrimOp           ( PrimOp )
+import PrimOp           ( PrimOp, CCall )
 import Unique           ( Unique )
 import StgSyn          ( SRT(..) )
+import TyCon           ( TyCon )
 import BitSet                          -- for liveness masks
 
 \end{code}
@@ -91,9 +88,9 @@ stored in a mixed type location.)
                        -- (for the benefit of the native code generators)
                        -- Equivalent to CJump in C land
 
-  | CReturn            -- This used to be RetVecRegRel
-       CAddrMode       -- Any base address mode
-       ReturnInfo      -- How to get the return address from the base address
+  | CReturn            -- Perform a return
+       CAddrMode       -- Address of a RET_<blah> info table
+       ReturnInfo      -- Whether it's a direct or vectored return
 
   | CSwitch !CAddrMode
        [(Literal, AbstractC)]  -- alternatives
@@ -113,7 +110,7 @@ stored in a mixed type location.)
 
   | CInitHdr           -- to initialise the header of a closure (both fixed/var parts)
        ClosureInfo
-       RegRelative     -- address of the info ptr
+       CAddrMode       -- address of the info ptr
        CAddrMode       -- cost centre to place in closure
                        --   CReg CurCostCentre or CC_HDR(R1.p{-Node-})
 
@@ -165,7 +162,8 @@ stored in a mixed type location.)
        typedefs if needs be (i.e., when generating .hc code and
        compiling 'foreign import dynamic's)
     -}
-  | CCallTypedef        PrimOp{-CCallOp-} [CAddrMode] [CAddrMode]
+  | CCallTypedef Bool {- True => use "typedef"; False => use "extern"-}
+                CCall [CAddrMode] [CAddrMode]
 
   -- *** the next three [or so...] are DATA (those above are CODE) ***
 
@@ -196,6 +194,13 @@ stored in a mixed type location.)
        (CLabel,SRT)            -- SRT info
        Liveness                -- stack liveness at the return point
 
+  | CClosureTbl                -- table of constructors for enumerated types
+       TyCon                   -- which TyCon this table is for
+
+  | CModuleInitBlock           -- module initialisation block
+       CLabel                  -- label for init block
+       AbstractC               -- initialisation code
+
   | CCostCentreDecl            -- A cost centre *declaration*
        Bool                    -- True  <=> local => full declaration
                                -- False <=> extern; just say so
@@ -228,13 +233,19 @@ data CStmtMacro
   | UPD_BH_SINGLE_ENTRY                        -- more eager blackholing
   | PUSH_UPD_FRAME                     -- push update frame
   | 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
+
+  | REGISTER_FOREIGN_EXPORT            -- register a foreign exported fun
+  | REGISTER_IMPORT                    -- register an imported module
+  | REGISTER_DIMPORT                    -- register an imported module from
+                                        -- another DLL
+
   | GRAN_FETCH                 -- for GrAnSim only  -- HWL
   | GRAN_RESCHEDULE            -- for GrAnSim only  -- HWL
   | GRAN_FETCH_AND_RESCHEDULE  -- for GrAnSim only  -- HWL
   | THREAD_CONTEXT_SWITCH      -- for GrAnSim only  -- HWL
   | GRAN_YIELD                 -- for GrAnSim only  -- HWL 
-  deriving Text
 \end{code}
 
 Heap/Stack checks.  There are far too many of these.
@@ -261,7 +272,6 @@ data CCheckMacro
   | HP_CHK_UT_ALT                      --   unboxed tuple return.
 
   | HP_CHK_GEN                         -- generic heap check
-  deriving Text
 \end{code}
 
 \item[@CCallProfCtrMacro@:]
@@ -296,11 +306,6 @@ data CAddrMode
 
   | CReg MagicId       -- To replace (CAddr MagicId 0)
 
-  | CTableEntry            -- CVal should be generalized to allow this
-               CAddrMode   -- Base
-               CAddrMode   -- Offset
-               PrimRep    -- For casting
-
   | CTemp !Unique !PrimRep     -- Temporary locations
        -- ``Temporaries'' correspond to local variables in C, and registers in
        -- native code.
@@ -310,17 +315,13 @@ data CAddrMode
 
   | CCharLike CAddrMode        -- The address of a static char-like closure for
                        -- the specified character.  It is guaranteed to be in
-                       -- the range 0..255.
+                       -- the range mIN_CHARLIKE..mAX_CHARLIKE
 
   | CIntLike CAddrMode -- The address of a static int-like closure for the
                        -- specified small integer.  It is guaranteed to be in
                        -- the range mIN_INTLIKE..mAX_INTLIKE
 
-  | CString FAST_STRING        -- The address of the null-terminated string
   | CLit    Literal
-  | CLitLit FAST_STRING        -- completely literal literal: just spit this String
-                       -- into the C output
-           PrimRep
 
   | CJoinPoint         -- This is used as the amode of a let-no-escape-bound
                        -- variable.
@@ -344,7 +345,8 @@ data CExprMacro
   = ENTRY_CODE
   | ARG_TAG                            -- stack argument tagging
   | GET_TAG                            -- get current constructor tag
-  deriving(Text)
+  | UPD_FRAME_UPDATEE
+  | CCS_HDR
 
 \end{code}
 
@@ -354,6 +356,9 @@ Convenience functions:
 mkIntCLit :: Int -> CAddrMode
 mkIntCLit i = CLit (mkMachInt (toInteger i))
 
+mkCString :: FAST_STRING -> CAddrMode
+mkCString s = CLit (MachStr s)
+
 mkCCostCentre :: CostCentre -> CAddrMode
 mkCCostCentre cc = CLbl (mkCC_Label cc) DataPtrRep
 
@@ -372,6 +377,8 @@ data RegRelative
   = HpRel      FAST_INT        -- }
   | SpRel      FAST_INT        -- }- offsets in StgWords
   | NodeRel    FAST_INT        -- }
+  | CIndex     CAddrMode CAddrMode PrimRep     -- pointer arithmetic :-)
+                                               -- CIndex a b k === (k*)a[b]
 
 data ReturnInfo
   = DirectReturn                       -- Jump directly, if possible
@@ -396,7 +403,7 @@ nodeRel IBOX(off) = NodeRel off
 
 %************************************************************************
 %*                                                                     *
-\subsection[RegRelative]{@RegRelatives@: ???}
+\subsection[Liveness]{Liveness Masks}
 %*                                                                     *
 %************************************************************************
 
@@ -465,10 +472,14 @@ data MagicId
        PrimRep         -- Int64Rep or Word64Rep
        FAST_INT        -- its number (1 .. mAX_Long_REG)
 
+  | CurrentTSO         -- pointer to current thread's TSO
+  | CurrentNursery     -- pointer to allocation area
+
 
 node   = VanillaReg PtrRep     ILIT(1) -- A convenient alias for Node
 tagreg  = VanillaReg WordRep    ILIT(2) -- A convenient alias for TagReg
 
+nodeReg = CReg node
 \end{code}
 
 We need magical @Eq@ because @VanillaReg@s come in multiple flavors.