[project @ 2004-08-13 13:04:50 by simonmar]
[ghc-hetmet.git] / ghc / rts / Updates.cmm
similarity index 55%
rename from ghc/rts/Updates.hc
rename to ghc/rts/Updates.cmm
index 5965ea9..02d1827 100644 (file)
@@ -1,20 +1,18 @@
 /* -----------------------------------------------------------------------------
 /* -----------------------------------------------------------------------------
- * $Id: Updates.hc,v 1.41 2003/07/28 15:57:40 simonmar Exp $
  *
  *
- * (c) The GHC Team, 1998-2002
+ * (c) The GHC Team, 1998-2004
  *
  * Code to perform updates.
  *
  *
  * Code to perform updates.
  *
+ * This file is written in a subset of C--, extended with various
+ * features specific to GHC.  It is compiled by GHC directly.  For the
+ * syntax of .cmm files, see the parser in ghc/compiler/cmm/CmmParse.y.
+ *
  * ---------------------------------------------------------------------------*/
 
  * ---------------------------------------------------------------------------*/
 
-#include "Stg.h"
-#include "Rts.h"
-#include "RtsUtils.h"
-#include "RtsFlags.h"
-#include "Storage.h"
-#if defined(GRAN) || defined(PAR)
-# include "FetchMe.h"
-#endif
+#include "Cmm.h"
+#include "Updates.h"
+#include "StgLdvProf.h"
 
 /*
   The update frame return address must be *polymorphic*, that means
 
 /*
   The update frame return address must be *polymorphic*, that means
@@ -33,9 +31,9 @@
 /* on entry to the update code
    (1) R1 points to the closure being returned
    (2) Sp points to the update frame
 /* on entry to the update code
    (1) R1 points to the closure being returned
    (2) Sp points to the update frame
-   */
+*/
 
 
-/* The update fragment has been tuned so as to generate reasonable
+/* The update fragment has been tuned so as to generate good
    code with gcc, which accounts for some of the strangeness in the
    way it is written.  
 
    code with gcc, which accounts for some of the strangeness in the
    way it is written.  
 
 */
 
 #define UPD_FRAME_ENTRY_TEMPLATE(label,ind_info,ret)                   \
 */
 
 #define UPD_FRAME_ENTRY_TEMPLATE(label,ind_info,ret)                   \
-        STGFUN(label);                                                 \
-       STGFUN(label)                                                   \
+        label                                                          \
        {                                                               \
        {                                                               \
-          StgClosure *updatee;                                         \
-         FB_                                                           \
+          W_ updatee;                                                  \
                                                                        \
                                                                        \
-          updatee = ((StgUpdateFrame *)Sp)->updatee;                   \
+          updatee = StgUpdateFrame_updatee(Sp);                                \
                                                                        \
          /* remove the update frame from the stack */                  \
                                                                        \
          /* remove the update frame from the stack */                  \
-         Sp += sizeofW(StgUpdateFrame);                                \
+         Sp = Sp + SIZEOF_StgUpdateFrame;                              \
                                                                        \
          /* ToDo: it might be a PAP, so we should check... */          \
                                                                        \
          /* ToDo: it might be a PAP, so we should check... */          \
-         TICK_UPD_CON_IN_NEW(sizeW_fromITBL(get_itbl(updatee)));       \
+         TICK_UPD_CON_IN_NEW(sizeW_fromITBL(%GET_STD_INFO(updatee)));  \
                                                                        \
                                                                        \
-         UPD_SPEC_IND(updatee, ind_info, R1.cl, JMP_(ret));            \
-         FE_                                                           \
+         UPD_SPEC_IND(updatee, ind_info, R1, jump (ret));              \
        }
 
        }
 
-UPD_FRAME_ENTRY_TEMPLATE(stg_upd_frame_ret,&stg_IND_direct_info,ENTRY_CODE(Sp[0]));
-UPD_FRAME_ENTRY_TEMPLATE(stg_upd_frame_0_ret,&stg_IND_0_info,RET_VEC(Sp[0],0));
-UPD_FRAME_ENTRY_TEMPLATE(stg_upd_frame_1_ret,&stg_IND_1_info,RET_VEC(Sp[0],1));
-UPD_FRAME_ENTRY_TEMPLATE(stg_upd_frame_2_ret,&stg_IND_2_info,RET_VEC(Sp[0],2));
-UPD_FRAME_ENTRY_TEMPLATE(stg_upd_frame_3_ret,&stg_IND_3_info,RET_VEC(Sp[0],3));
-UPD_FRAME_ENTRY_TEMPLATE(stg_upd_frame_4_ret,&stg_IND_4_info,RET_VEC(Sp[0],4));
-UPD_FRAME_ENTRY_TEMPLATE(stg_upd_frame_5_ret,&stg_IND_5_info,RET_VEC(Sp[0],5));
-UPD_FRAME_ENTRY_TEMPLATE(stg_upd_frame_6_ret,&stg_IND_6_info,RET_VEC(Sp[0],6));
-UPD_FRAME_ENTRY_TEMPLATE(stg_upd_frame_7_ret,&stg_IND_7_info,RET_VEC(Sp[0],7));
+UPD_FRAME_ENTRY_TEMPLATE(stg_upd_frame_0_ret,stg_IND_0_info,%RET_VEC(Sp(0),0))
+UPD_FRAME_ENTRY_TEMPLATE(stg_upd_frame_1_ret,stg_IND_1_info,%RET_VEC(Sp(0),1))
+UPD_FRAME_ENTRY_TEMPLATE(stg_upd_frame_2_ret,stg_IND_2_info,%RET_VEC(Sp(0),2))
+UPD_FRAME_ENTRY_TEMPLATE(stg_upd_frame_3_ret,stg_IND_3_info,%RET_VEC(Sp(0),3))
+UPD_FRAME_ENTRY_TEMPLATE(stg_upd_frame_4_ret,stg_IND_4_info,%RET_VEC(Sp(0),4))
+UPD_FRAME_ENTRY_TEMPLATE(stg_upd_frame_5_ret,stg_IND_5_info,%RET_VEC(Sp(0),5))
+UPD_FRAME_ENTRY_TEMPLATE(stg_upd_frame_6_ret,stg_IND_6_info,%RET_VEC(Sp(0),6))
+UPD_FRAME_ENTRY_TEMPLATE(stg_upd_frame_7_ret,stg_IND_7_info,%RET_VEC(Sp(0),7))
+
+#if MAX_VECTORED_RTN > 8
+#error MAX_VECTORED_RTN has changed: please modify stg_upd_frame too.
+#endif
 
 /*
   Make sure this table is big enough to handle the maximum vectored
 
 /*
   Make sure this table is big enough to handle the maximum vectored
@@ -91,10 +89,18 @@ UPD_FRAME_ENTRY_TEMPLATE(stg_upd_frame_7_ret,&stg_IND_7_info,RET_VEC(Sp[0],7));
  * there's a cost-centre-stack in there too).
  */
 
  * there's a cost-centre-stack in there too).
  */
 
-VEC_POLY_INFO_TABLE( stg_upd_frame, 
-                    MK_SMALL_BITMAP(UPD_FRAME_WORDS, UPD_FRAME_BITMAP),
-                    0/*srt*/, 0/*srt_off*/, 0/*srt_bitmap*/,
-                    UPDATE_FRAME,, EF_);
+INFO_TABLE_RET( stg_upd_frame, 
+           UPD_FRAME_WORDS, UPD_FRAME_BITMAP, UPDATE_FRAME,
+           stg_upd_frame_0_ret,
+           stg_upd_frame_1_ret,
+           stg_upd_frame_2_ret,
+           stg_upd_frame_3_ret,
+           stg_upd_frame_4_ret,
+           stg_upd_frame_5_ret,
+           stg_upd_frame_6_ret,
+           stg_upd_frame_7_ret
+           )
+UPD_FRAME_ENTRY_TEMPLATE(,stg_IND_direct_info,%ENTRY_CODE(Sp(0)))
 
 /*-----------------------------------------------------------------------------
   Seq frames 
 
 /*-----------------------------------------------------------------------------
   Seq frames 
@@ -113,26 +119,21 @@ VEC_POLY_INFO_TABLE( stg_upd_frame,
   into a direct one.
   -------------------------------------------------------------------------- */
 
   into a direct one.
   -------------------------------------------------------------------------- */
 
-IF_(stg_seq_frame_ret);
-
-#define stg_seq_frame_0_ret stg_seq_frame_ret
-#define stg_seq_frame_1_ret stg_seq_frame_ret
-#define stg_seq_frame_2_ret stg_seq_frame_ret
-#define stg_seq_frame_3_ret stg_seq_frame_ret
-#define stg_seq_frame_4_ret stg_seq_frame_ret
-#define stg_seq_frame_5_ret stg_seq_frame_ret
-#define stg_seq_frame_6_ret stg_seq_frame_ret
-#define stg_seq_frame_7_ret stg_seq_frame_ret
-
-VEC_POLY_INFO_TABLE( stg_seq_frame,
-                    MK_SMALL_BITMAP(0, 0),
-                    0/*srt*/, 0/*srt_off*/, 0/*srt_bitmap*/,
-                    RET_SMALL,, EF_);
+#if MAX_VECTORED_RTN > 8
+#error MAX_VECTORED_RTN has changed: please modify stg_seq_frame too.
+#endif
 
 
-IF_(stg_seq_frame_ret)
+INFO_TABLE_RET( stg_seq_frame, 0/* words */, 0/* bitmap */, RET_SMALL,
+       RET_LBL(stg_seq_frame), /* 0 */
+       RET_LBL(stg_seq_frame), /* 1 */
+       RET_LBL(stg_seq_frame), /* 2 */
+       RET_LBL(stg_seq_frame), /* 3 */
+       RET_LBL(stg_seq_frame), /* 4 */
+       RET_LBL(stg_seq_frame), /* 5 */
+       RET_LBL(stg_seq_frame), /* 6 */
+       RET_LBL(stg_seq_frame)  /* 7 */
+       )
 {
 {
-   FB_
-   Sp ++;
-   JMP_(ENTRY_CODE(Sp[0]));
-   FE_
+   Sp_adj(1);
+   jump %ENTRY_CODE(Sp(0));
 }
 }