[project @ 1998-10-21 11:28:00 by sof]
[ghc-hetmet.git] / ghc / compiler / absCSyn / AbsCSyn.lhs
index 61d17ac..05972fa 100644 (file)
@@ -12,8 +12,6 @@ From @AbstractC@, one may convert to real C (for portability) or to
 raw assembler/machine code.
 
 \begin{code}
-#include "HsVersions.h"
-
 module AbsCSyn {- (
        -- export everything
        AbstractC(..),
@@ -35,18 +33,29 @@ module AbsCSyn {- (
        CostRes(Cost)
     )-} where
 
-IMP_Ubiq(){-uitous-}
+#include "HsVersions.h"
+
+import {-# SOURCE #-} ClosureInfo ( ClosureInfo )
+import {-# SOURCE #-} CLabel     ( CLabel )
+
+#if  ! OMIT_NATIVE_CODEGEN
+import {-# SOURCE #-} MachMisc
+#endif
 
-import CgCompInfo      ( mAX_Vanilla_REG, mAX_Float_REG,
+import Constants       ( mAX_Vanilla_REG, mAX_Float_REG,
                          mAX_Double_REG, lIVENESS_R1, lIVENESS_R2,
                          lIVENESS_R3, lIVENESS_R4, lIVENESS_R5,
                          lIVENESS_R6, lIVENESS_R7, lIVENESS_R8
                        )
-import HeapOffs                ( SYN_IE(VirtualSpAOffset), SYN_IE(VirtualSpBOffset),
-                         SYN_IE(VirtualHeapOffset)
+import HeapOffs                ( VirtualSpAOffset, VirtualSpBOffset,
+                         VirtualHeapOffset, HeapOffset
                        )
-import Literal         ( mkMachInt )
+import CostCentre       ( CostCentre )
+import Literal         ( mkMachInt, Literal )
 import PrimRep         ( isFollowableRep, PrimRep(..) )
+import PrimOp           ( PrimOp )
+import Unique           ( Unique )
+
 \end{code}
 
 @AbstractC@ is a list of Abstract~C statements, but the data structure
@@ -141,6 +150,17 @@ stored in a mixed type location.)
   | CCallProfCtrMacro  FAST_STRING     [CAddrMode]
   | CCallProfCCMacro   FAST_STRING     [CAddrMode]
 
+    {- The presence of this constructor is a makeshift solution;
+       it being used to work around a gcc-related problem of
+       handling typedefs within statement blocks (or, rather,
+       the inability to do so.)
+       
+       The AbstractC flattener takes care of lifting out these
+       typedefs if needs be (i.e., when generating .hc code and
+       compiling 'foreign import dynamic's)
+    -}
+  | CCallTypedef        PrimOp{-CCallOp-} [CAddrMode] [CAddrMode]
+
   -- *** the next three [or so...] are DATA (those above are CODE) ***
 
   | CStaticClosure
@@ -433,7 +453,7 @@ data MagicId
 
   -- Argument and return registers
   | VanillaReg         -- pointers, unboxed ints and chars
-       PrimRep -- PtrRep, IntRep, CharRep, StablePtrRep or ForeignObjRep
+       PrimRep         -- PtrRep, IntRep, CharRep, StablePtrRep or ForeignObjRep
                        --      (in case we need to distinguish)
        FAST_INT        -- its number (1 .. mAX_Vanilla_REG)
 
@@ -443,6 +463,10 @@ data MagicId
   | DoubleReg  -- double-precision floating-point registers
        FAST_INT        -- its number (1 .. mAX_Double_REG)
 
+  | LongReg            -- long int registers (64-bit, really)
+       PrimRep         -- Int64Rep or Word64Rep
+       FAST_INT        -- its number (1 .. mAX_Long_REG)
+
   | TagReg     -- to return constructor tags; as almost all returns are vectored,
                -- this is rarely used.
 
@@ -518,16 +542,18 @@ instance Eq MagicId where
        tag CurCostCentre    = ILIT(14)
        tag VoidReg          = ILIT(15)
 
-       tag (VanillaReg _ i) = ILIT(15) _ADD_ i
-
-       tag (FloatReg i) = ILIT(15) _ADD_ maxv _ADD_ i
-         where
-           maxv = case mAX_Vanilla_REG of { IBOX(x) -> x }
-
-       tag (DoubleReg i) = ILIT(15) _ADD_ maxv _ADD_ maxf _ADD_ i
+       tag reg =
+          ILIT(15) _ADD_ (
+         case reg of
+           VanillaReg _ i -> i
+           FloatReg i     -> maxv _ADD_ i
+           DoubleReg i    -> maxv _ADD_ maxf _ADD_ i
+           LongReg _ i    -> maxv _ADD_ maxf _ADD_ maxd _ADD_ i
+         )
          where
            maxv = case mAX_Vanilla_REG of { IBOX(x) -> x }
            maxf = case mAX_Float_REG   of { IBOX(x) -> x }
+           maxd = case mAX_Double_REG of { IBOX(x) -> x }
 \end{code}
 
 Returns True for any register that {\em potentially} dies across