[project @ 2000-03-20 15:32:10 by panne]
[ghc-hetmet.git] / ghc / includes / Assembler.h
index f318000..1d5c7db 100644 (file)
@@ -1,12 +1,10 @@
-/* -*- mode: hugs-c; -*- */
+
 /* -----------------------------------------------------------------------------
- * Bytecode assembler
+ * $Id: Assembler.h,v 1.12 1999/11/29 18:59:23 sewardj Exp $
  *
- * Copyright (c) 1994-1998.
+ * (c) The GHC Team 1994-1998.
  *
- * $RCSfile: Assembler.h,v $
- * $Revision: 1.2 $
- * $Date: 1998/12/02 13:20:52 $
+ * Bytecode assembler
  *
  * NB This is one of the few files shared between Hugs and the runtime system,
  * so it is very important that it not conflict with either and that it not
@@ -86,51 +84,36 @@ typedef enum {
   /* The following can be passed to C */
   CHAR_REP    = 'C',     
   INT_REP     = 'I',      
-#ifdef PROVIDE_INT64
-  INT64_REP   = 'z', 
-#endif
-#ifdef PROVIDE_INTEGER
   INTEGER_REP = 'Z',  
-#endif
-#ifdef PROVIDE_WORD
   WORD_REP    = 'W',     
-#endif
-#ifdef PROVIDE_ADDR
   ADDR_REP    = 'A',     
-#endif
   FLOAT_REP   = 'F',    
   DOUBLE_REP  = 'D',   
-#ifdef PROVIDE_STABLE
   STABLE_REP  = 's',   /* StablePtr a */
-#endif
 #ifdef PROVIDE_FOREIGN
   FOREIGN_REP = 'f',   /* ForeignObj  */
 #endif
 #ifdef PROVIDE_WEAK
   WEAK_REP    = 'w',   /* Weak a      */
 #endif
-#ifdef PROVIDE_ARRAY
   BARR_REP     = 'x',  /* PrimByteArray          a */
   MUTBARR_REP  = 'm',  /* PrimMutableByteArray s a */
-#endif
 
   /* The following can't be passed to C */
   PTR_REP      = 'P',      
   ALPHA_REP    = 'a',  /* a                        */
   BETA_REP     = 'b',  /* b                       */
+  GAMMA_REP    = 'c',  /* c                        */
+  DELTA_REP    = 'd',  /* d                        */
   BOOL_REP     = 'B',  /* Bool                    */
   IO_REP       = 'i',  /* IO a                    */
   HANDLER_REP  = 'H',  /* Exception -> IO a       */
   ERROR_REP    = 'E',  /* Exception               */
-#ifdef PROVIDE_ARRAY           
   ARR_REP      = 'X',  /* PrimArray              a */
   REF_REP      = 'R',  /* Ref                  s a */
   MUTARR_REP   = 'M',  /* PrimMutableArray     s a */
-#endif
-#ifdef PROVIDE_CONCURRENT
   THREADID_REP = 'T',  /* ThreadId                 */
   MVAR_REP     = 'r',  /* MVar a                   */
-#endif
 
   /* Allegedly used in the IO monad */
   VOID_REP     = 'v'      
@@ -140,10 +123,10 @@ typedef enum {
  * Allocating (top level) heap objects
  * ------------------------------------------------------------------------*/
 
-extern AsmBCO     asmBeginBCO        ( void );
+extern AsmBCO     asmBeginBCO        ( int /*StgExpr*/ e );
 extern void       asmEndBCO          ( AsmBCO bco );
 
-extern AsmBCO     asmBeginContinuation ( AsmSp sp );
+extern AsmBCO     asmBeginContinuation ( AsmSp sp, int /*List*/ alts );
 extern void       asmEndContinuation   ( AsmBCO bco );
 
 extern AsmObject  asmMkObject        ( AsmClosure c );
@@ -165,6 +148,8 @@ extern int        asmObjectHasClosure( AsmObject obj );
 extern AsmClosure asmClosureOfObject ( AsmObject obj );
 extern void       asmMarkObject      ( AsmObject obj );
 
+extern int        asmRepSizeW        ( AsmRep rep );
+
 /* --------------------------------------------------------------------------
  * Generating instruction streams
  * ------------------------------------------------------------------------*/
@@ -181,7 +166,7 @@ extern void   asmVar           ( AsmBCO bco, AsmVar v, AsmRep rep );
 extern AsmSp  asmBeginCase     ( AsmBCO bco );
 extern void   asmEndCase       ( AsmBCO bco );
 extern AsmSp  asmContinuation  ( AsmBCO bco, AsmBCO ret_addr );
-                               
+
 extern AsmSp  asmBeginAlt      ( AsmBCO bco );
 extern void   asmEndAlt        ( AsmBCO bco, AsmSp  sp );
 extern AsmPc  asmTest          ( AsmBCO bco, AsmWord tag );
@@ -195,21 +180,12 @@ extern void   asmReturnUnboxed ( AsmBCO bco, AsmRep rep );
 
 /* push unboxed Ints, Floats, etc */
 extern void   asmConstInt      ( AsmBCO bco, AsmInt     x );
-#ifdef PROVIDE_ADDR
 extern void   asmConstAddr     ( AsmBCO bco, AsmAddr    x );
-#endif
-#ifdef PROVIDE_WORD
 extern void   asmConstWord     ( AsmBCO bco, AsmWord    x );
-#endif
 extern void   asmConstChar     ( AsmBCO bco, AsmChar    x );
 extern void   asmConstFloat    ( AsmBCO bco, AsmFloat   x );
 extern void   asmConstDouble   ( AsmBCO bco, AsmDouble  x );
-#ifdef PROVIDE_INT64
-extern void   asmConstInt64    ( AsmBCO bco, AsmInt64   x );
-#endif
-#ifdef PROVIDE_INTEGER
 extern void   asmConstInteger  ( AsmBCO bco, AsmString  x );
-#endif
              
 /* Which monad (if any) does the primop live in? */
 typedef enum {
@@ -227,18 +203,27 @@ typedef struct {
     AsmNat8  opcode; /* should be Primop1 or Primop2 */
 } AsmPrim;
 
-extern const AsmPrim asmPrimOps[]; /* null terminated list */
+extern AsmPrim asmPrimOps[]; /* null terminated list */
+
+extern AsmPrim* asmFindPrim      ( char* s );
+extern AsmPrim* asmFindPrimop    ( AsmInstr prefix, AsmInstr op );
+extern AsmSp    asmBeginPrim     ( AsmBCO bco );
+extern void     asmEndPrim       ( AsmBCO bco, const AsmPrim* prim, 
+                                               AsmSp base );
+extern char*    asmGetPrimopName ( AsmPrim* p );
+
+extern AsmBCO asm_BCO_catch    ( void );
+extern AsmBCO asm_BCO_raise    ( void );
+extern AsmBCO asm_BCO_seq      ( void );
+extern AsmBCO asm_BCO_takeMVar ( void );
 
-extern const AsmPrim* asmFindPrim    ( char* s );
-extern const AsmPrim* asmFindPrimop  ( AsmInstr prefix, AsmInstr op );
-extern AsmSp          asmBeginPrim   ( AsmBCO bco );
-extern void           asmEndPrim     ( AsmBCO bco, const AsmPrim* prim, AsmSp base );
 
 /* --------------------------------------------------------------------------
  * Heap manipulation
  * ------------------------------------------------------------------------*/
 
 extern AsmVar asmClosure       ( AsmBCO bco, AsmObject p );
+extern AsmVar asmGHCClosure    ( AsmBCO bco, AsmObject p );
 
 extern AsmVar asmAllocCONSTR   ( AsmBCO bco, AsmInfo info );
 
@@ -260,21 +245,18 @@ extern void   asmEndMkPAP      ( AsmBCO bco, AsmVar v, AsmSp start );
  * C-call and H-call
  * ------------------------------------------------------------------------*/
 
-extern const AsmPrim ccall_Id;
-extern const AsmPrim ccall_IO;
+extern AsmPrim ccall_ccall_Id;
+extern AsmPrim ccall_ccall_IO;
+extern AsmPrim ccall_stdcall_Id;
+extern AsmPrim ccall_stdcall_IO;
 
 typedef struct {
-  char *        arg_tys;
-  int           arg_size;
-  char *        result_tys;
-  int           result_size;
+  unsigned int  num_args;
+  char*         arg_tys;
+  unsigned int  num_results;
+  char*         result_tys;
 } CFunDescriptor;
 
-typedef struct {
-  char *        arg_tys;
-  char *        result_tys;
-} HFunDescriptor;
-
 CFunDescriptor* mkDescriptor( char* as, char* rs );
 
 /*-------------------------------------------------------------------------*/