Fix segfault in array copy primops on 32-bit
[ghc-hetmet.git] / compiler / prelude / primops.txt.pp
index 6e0a13d..4dfe019 100644 (file)
@@ -1,8 +1,12 @@
 -----------------------------------------------------------------------
 -----------------------------------------------------------------------
--- $Id: primops.txt.pp,v 1.37 2005/11/25 09:46:19 simonmar Exp $
+-- 
+-- (c) 2010 The University of Glasgow
 --
 -- Primitive Operations and Types
 --
 --
 -- Primitive Operations and Types
 --
+-- For more information on PrimOps, see
+--   http://hackage.haskell.org/trac/ghc/wiki/Commentary/PrimOps
+--
 -----------------------------------------------------------------------
 
 -- This file is processed by the utility program genprimopcode to produce
 -----------------------------------------------------------------------
 
 -- This file is processed by the utility program genprimopcode to produce
 --
 -- It should first be preprocessed.
 --
 --
 -- It should first be preprocessed.
 --
--- To add a new primop, you currently need to update the following files:
---
---     - this file (ghc/compiler/prelude/primops.txt.pp), which includes
---       the type of the primop, and various other properties (its
---       strictness attributes, whether it is defined as a macro
---       or as out-of-line code, etc.)
---
---     - if the primop is inline (i.e. a macro), then:
---             ghc/compiler/AbsCUtils.lhs (dscCOpStmt)
---               defines the translation of the primop into simpler
---               abstract C operations.
---             
---     - or, for an out-of-line primop:
---             ghc/includes/StgMiscClosures.h (just add the declaration)
---             ghc/rts/PrimOps.cmm     (define it here)
---             ghc/rts/Linker.c       (declare the symbol for GHCi)
---
---     - the User's Guide 
+-- Information on how PrimOps are implemented and the steps necessary to
+-- add a new one can be found in the Commentary:
 --
 --
+--  http://hackage.haskell.org/trac/ghc/wiki/Commentary/PrimOps
 
 -- This file is divided into named sections, each containing or more
 -- primop entries. Section headers have the format:
 
 -- This file is divided into named sections, each containing or more
 -- primop entries. Section headers have the format:
 -- text between curly brackets.  This is a kludge to enable 
 -- processors of this file to easily get hold of simple info
 -- (eg, out_of_line), whilst avoiding parsing complex expressions
 -- text between curly brackets.  This is a kludge to enable 
 -- processors of this file to easily get hold of simple info
 -- (eg, out_of_line), whilst avoiding parsing complex expressions
--- needed for strictness and usage info.
+-- needed for strictness info.
 
 defaults
    has_side_effects = False
    out_of_line      = False
    commutable       = False
 
 defaults
    has_side_effects = False
    out_of_line      = False
    commutable       = False
-   needs_wrapper    = False
+   code_size        = { primOpCodeSizeDefault }
    can_fail         = False
    strictness       = { \ arity -> mkStrictSig (mkTopDmdType (replicate arity lazyDmd) TopRes) }
    can_fail         = False
    strictness       = { \ arity -> mkStrictSig (mkTopDmdType (replicate arity lazyDmd) TopRes) }
-   usage            = { nomangle other }
 
 -- Currently, documentation is produced using latex, so contents of
 -- description fields should be legal latex. Descriptions can contain
 
 -- Currently, documentation is produced using latex, so contents of
 -- description fields should be legal latex. Descriptions can contain
@@ -114,8 +102,8 @@ section "The word size story."
         primops are fixed, but their {\it types} vary according to
         the value of {\tt WORD\_SIZE\_IN\_BITS}. For example, if word
         size is at least 32 bits then an operator like
         primops are fixed, but their {\it types} vary according to
         the value of {\tt WORD\_SIZE\_IN\_BITS}. For example, if word
         size is at least 32 bits then an operator like
-        \texttt{indexInt32Array\#} has type {\tt ByteArr\# -> Int\#
-        -> Int\#}; otherwise it has type {\tt ByteArr\# -> Int\# ->
+        \texttt{indexInt32Array\#} has type {\tt ByteArray\# -> Int\#
+        -> Int\#}; otherwise it has type {\tt ByteArray\# -> Int\# ->
         Int32\#}.  This approach confines the necessary {\tt
         \#if}-defs to this file; no conditional compilation is needed
         in the files that expose these primops.
         Int32\#}.  This approach confines the necessary {\tt
         \#if}-defs to this file; no conditional compilation is needed
         in the files that expose these primops.
@@ -167,6 +155,7 @@ primop   CharLtOp  "ltChar#"   Compare   Char# -> Char# -> Bool
 primop   CharLeOp  "leChar#"   Compare   Char# -> Char# -> Bool
 
 primop   OrdOp   "ord#"  GenPrimOp   Char# -> Int#
 primop   CharLeOp  "leChar#"   Compare   Char# -> Char# -> Bool
 
 primop   OrdOp   "ord#"  GenPrimOp   Char# -> Int#
+   with code_size = 0
 
 ------------------------------------------------------------------------
 section "Int#"
 
 ------------------------------------------------------------------------
 section "Int#"
@@ -220,16 +209,16 @@ primop   IntRemOp    "remInt#"    Dyadic
    {Satisfies \texttt{(quotInt\# x y) *\# y +\# (remInt\# x y) == x}.}
    with can_fail = True
 
    {Satisfies \texttt{(quotInt\# x y) *\# y +\# (remInt\# x y) == x}.}
    with can_fail = True
 
-primop   IntGcdOp    "gcdInt#"    Dyadic   Int# -> Int# -> Int#
-   with out_of_line = True
-
 primop   IntNegOp    "negateInt#"    Monadic   Int# -> Int#
 primop   IntAddCOp   "addIntC#"    GenPrimOp   Int# -> Int# -> (# Int#, Int# #)
         {Add with carry.  First member of result is (wrapped) sum; 
           second member is 0 iff no overflow occured.}
 primop   IntNegOp    "negateInt#"    Monadic   Int# -> Int#
 primop   IntAddCOp   "addIntC#"    GenPrimOp   Int# -> Int# -> (# Int#, Int# #)
         {Add with carry.  First member of result is (wrapped) sum; 
           second member is 0 iff no overflow occured.}
+   with code_size = 2
+
 primop   IntSubCOp   "subIntC#"    GenPrimOp   Int# -> Int# -> (# Int#, Int# #)
         {Subtract with carry.  First member of result is (wrapped) difference; 
           second member is 0 iff no overflow occured.}
 primop   IntSubCOp   "subIntC#"    GenPrimOp   Int# -> Int# -> (# Int#, Int# #)
         {Subtract with carry.  First member of result is (wrapped) difference; 
           second member is 0 iff no overflow occured.}
+   with code_size = 2
 
 primop   IntGtOp  ">#"   Compare   Int# -> Int# -> Bool
 primop   IntGeOp  ">=#"   Compare   Int# -> Int# -> Bool
 
 primop   IntGtOp  ">#"   Compare   Int# -> Int# -> Bool
 primop   IntGeOp  ">=#"   Compare   Int# -> Int# -> Bool
@@ -246,15 +235,14 @@ primop   IntLtOp  "<#"   Compare   Int# -> Int# -> Bool
 primop   IntLeOp  "<=#"   Compare   Int# -> Int# -> Bool
 
 primop   ChrOp   "chr#"   GenPrimOp   Int# -> Char#
 primop   IntLeOp  "<=#"   Compare   Int# -> Int# -> Bool
 
 primop   ChrOp   "chr#"   GenPrimOp   Int# -> Char#
+   with code_size = 0
 
 primop   Int2WordOp "int2Word#" GenPrimOp Int# -> Word#
 
 primop   Int2WordOp "int2Word#" GenPrimOp Int# -> Word#
+   with code_size = 0
+
 primop   Int2FloatOp   "int2Float#"      GenPrimOp  Int# -> Float#
 primop   Int2DoubleOp   "int2Double#"          GenPrimOp  Int# -> Double#
 
 primop   Int2FloatOp   "int2Float#"      GenPrimOp  Int# -> Float#
 primop   Int2DoubleOp   "int2Double#"          GenPrimOp  Int# -> Double#
 
-primop   Int2IntegerOp    "int2Integer#"
-   GenPrimOp Int# -> (# Int#, ByteArr# #)
-   with out_of_line = True
-
 primop   ISllOp   "uncheckedIShiftL#" GenPrimOp  Int# -> Int# -> Int#
         {Shift left.  Result undefined if shift amount is not
           in the range 0 to word size - 1 inclusive.}
 primop   ISllOp   "uncheckedIShiftL#" GenPrimOp  Int# -> Int# -> Int#
         {Shift left.  Result undefined if shift amount is not
           in the range 0 to word size - 1 inclusive.}
@@ -305,10 +293,7 @@ primop   SrlOp   "uncheckedShiftRL#"   GenPrimOp   Word# -> Int# -> Word#
           in the range 0 to word size - 1 inclusive.}
 
 primop   Word2IntOp   "word2Int#"   GenPrimOp   Word# -> Int#
           in the range 0 to word size - 1 inclusive.}
 
 primop   Word2IntOp   "word2Int#"   GenPrimOp   Word# -> Int#
-
-primop   Word2IntegerOp   "word2Integer#"   GenPrimOp 
-   Word# -> (# Int#, ByteArr# #)
-   with out_of_line = True
+   with code_size = 0
 
 primop   WordGtOp   "gtWord#"   Compare   Word# -> Word# -> Bool
 primop   WordGeOp   "geWord#"   Compare   Word# -> Word# -> Bool
 
 primop   WordGtOp   "gtWord#"   Compare   Word# -> Word# -> Bool
 primop   WordGeOp   "geWord#"   Compare   Word# -> Word# -> Bool
@@ -340,11 +325,6 @@ section "Int32#"
 
 primtype Int32#
 
 
 primtype Int32#
 
-primop   Int32ToIntegerOp   "int32ToInteger#" GenPrimOp 
-   Int32# -> (# Int#, ByteArr# #)
-   with out_of_line = True
-
-
 ------------------------------------------------------------------------
 section "Word32#"
        {Operations on 32-bit unsigned words. This type is only used 
 ------------------------------------------------------------------------
 section "Word32#"
        {Operations on 32-bit unsigned words. This type is only used 
@@ -354,11 +334,6 @@ section "Word32#"
 
 primtype Word32#
 
 
 primtype Word32#
 
-primop   Word32ToIntegerOp   "word32ToInteger#" GenPrimOp
-   Word32# -> (# Int#, ByteArr# #)
-   with out_of_line = True
-
-
 #endif 
 
 
 #endif 
 
 
@@ -372,10 +347,6 @@ section "Int64#"
 
 primtype Int64#
 
 
 primtype Int64#
 
-primop   Int64ToIntegerOp   "int64ToInteger#" GenPrimOp 
-   Int64# -> (# Int#, ByteArr# #)
-   with out_of_line = True
-
 ------------------------------------------------------------------------
 section "Word64#"
        {Operations on 64-bit unsigned words. This type is only used 
 ------------------------------------------------------------------------
 section "Word64#"
        {Operations on 64-bit unsigned words. This type is only used 
@@ -385,130 +356,9 @@ section "Word64#"
 
 primtype Word64#
 
 
 primtype Word64#
 
-primop   Word64ToIntegerOp   "word64ToInteger#" GenPrimOp
-   Word64# -> (# Int#, ByteArr# #)
-   with out_of_line = True
-
 #endif
 
 ------------------------------------------------------------------------
 #endif
 
 ------------------------------------------------------------------------
-section "Integer#"
-       {Operations on arbitrary-precision integers. These operations are 
-implemented via the GMP package. An integer is represented as a pair
-consisting of an {\tt Int\#} representing the number of 'limbs' in use and
-the sign, and a {\tt ByteArr\#} containing the 'limbs' themselves.  Such pairs
-are returned as unboxed pairs, but must be passed as separate
-components.
-
-For .NET these operations are implemented by foreign imports, so the
-primops are omitted.}
-------------------------------------------------------------------------
-
-#ifndef ILX
-
-primop   IntegerAddOp   "plusInteger#" GenPrimOp   
-   Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
-   with commutable = True
-        out_of_line = True
-
-primop   IntegerSubOp   "minusInteger#" GenPrimOp  
-   Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
-   with out_of_line = True
-
-primop   IntegerMulOp   "timesInteger#" GenPrimOp   
-   Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
-   with commutable = True
-        out_of_line = True
-
-primop   IntegerGcdOp   "gcdInteger#" GenPrimOp    
-   Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
-   {Greatest common divisor.}
-   with commutable = True
-        out_of_line = True
-
-primop   IntegerIntGcdOp   "gcdIntegerInt#" GenPrimOp
-   Int# -> ByteArr# -> Int# -> Int#
-   {Greatest common divisor, where second argument is an ordinary {\tt Int\#}.}
-   with out_of_line = True
-
-primop   IntegerDivExactOp   "divExactInteger#" GenPrimOp
-   Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
-   {Divisor is guaranteed to be a factor of dividend.}
-   with out_of_line = True
-
-primop   IntegerQuotOp   "quotInteger#" GenPrimOp
-   Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
-   {Rounds towards zero.}
-   with out_of_line = True
-
-primop   IntegerRemOp   "remInteger#" GenPrimOp
-   Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
-   {Satisfies \texttt{plusInteger\# (timesInteger\# (quotInteger\# x y) y) (remInteger\# x y) == x}.}
-   with out_of_line = True
-
-primop   IntegerCmpOp   "cmpInteger#"   GenPrimOp  
-   Int# -> ByteArr# -> Int# -> ByteArr# -> Int#
-   {Returns -1,0,1 according as first argument is less than, equal to, or greater than second argument.}
-   with needs_wrapper = True
-        out_of_line = True
-
-primop   IntegerCmpIntOp   "cmpIntegerInt#" GenPrimOp
-   Int# -> ByteArr# -> Int# -> Int#
-   {Returns -1,0,1 according as first argument is less than, equal to, or greater than second argument, which
-   is an ordinary Int\#.}
-   with needs_wrapper = True
-        out_of_line = True
-
-primop   IntegerQuotRemOp   "quotRemInteger#" GenPrimOp
-   Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr#, Int#, ByteArr# #)
-   {Compute quot and rem simulaneously.}
-   with can_fail = True
-        out_of_line = True
-
-primop   IntegerDivModOp    "divModInteger#"  GenPrimOp
-   Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr#, Int#, ByteArr# #)
-   {Compute div and mod simultaneously, where div rounds towards negative infinity
-    and\texttt{(q,r) = divModInteger\#(x,y)} implies \texttt{plusInteger\# (timesInteger\# q y) r = x}.}
-   with can_fail = True
-        out_of_line = True
-
-primop   Integer2IntOp   "integer2Int#"    GenPrimOp
-   Int# -> ByteArr# -> Int#
-   with needs_wrapper = True
-        out_of_line = True
-
-primop   Integer2WordOp   "integer2Word#"   GenPrimOp
-   Int# -> ByteArr# -> Word#
-   with needs_wrapper = True
-        out_of_line = True
-
-#if WORD_SIZE_IN_BITS < 32
-primop   IntegerToInt32Op   "integerToInt32#" GenPrimOp
-   Int# -> ByteArr# -> Int32#
-
-primop   IntegerToWord32Op   "integerToWord32#" GenPrimOp
-   Int# -> ByteArr# -> Word32#
-#endif
-
-primop   IntegerAndOp  "andInteger#" GenPrimOp
-   Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
-   with out_of_line = True
-
-primop   IntegerOrOp  "orInteger#" GenPrimOp
-   Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
-   with out_of_line = True
-
-primop   IntegerXorOp  "xorInteger#" GenPrimOp
-   Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
-   with out_of_line = True
-
-primop   IntegerComplementOp  "complementInteger#" GenPrimOp
-   Int# -> ByteArr# -> (# Int#, ByteArr# #)
-   with out_of_line = True
-
-#endif /* ndef ILX */
-
-------------------------------------------------------------------------
 section "Double#"
        {Operations on double-precision (64 bit) floating-point numbers.}
 ------------------------------------------------------------------------
 section "Double#"
        {Operations on double-precision (64 bit) floating-point numbers.}
 ------------------------------------------------------------------------
@@ -546,73 +396,87 @@ primop   DoubleDivOp   "/##"   Dyadic
 primop   DoubleNegOp   "negateDouble#"  Monadic   Double# -> Double#
 
 primop   Double2IntOp   "double2Int#"          GenPrimOp  Double# -> Int#
 primop   DoubleNegOp   "negateDouble#"  Monadic   Double# -> Double#
 
 primop   Double2IntOp   "double2Int#"          GenPrimOp  Double# -> Int#
+   {Truncates a {\tt Double#} value to the nearest {\tt Int#}.
+    Results are undefined if the truncation if truncation yields
+    a value outside the range of {\tt Int#}.}
+
 primop   Double2FloatOp   "double2Float#" GenPrimOp Double# -> Float#
 
 primop   DoubleExpOp   "expDouble#"      Monadic
    Double# -> Double#
 primop   Double2FloatOp   "double2Float#" GenPrimOp Double# -> Float#
 
 primop   DoubleExpOp   "expDouble#"      Monadic
    Double# -> Double#
-   with needs_wrapper = True
+   with
+   code_size = { primOpCodeSizeForeignCall }
 
 primop   DoubleLogOp   "logDouble#"      Monadic         
    Double# -> Double#
    with
 
 primop   DoubleLogOp   "logDouble#"      Monadic         
    Double# -> Double#
    with
-   needs_wrapper = True
+   code_size = { primOpCodeSizeForeignCall }
    can_fail = True
 
 primop   DoubleSqrtOp   "sqrtDouble#"      Monadic  
    Double# -> Double#
    can_fail = True
 
 primop   DoubleSqrtOp   "sqrtDouble#"      Monadic  
    Double# -> Double#
-   with needs_wrapper = True
+   with
+   code_size = { primOpCodeSizeForeignCall }
 
 primop   DoubleSinOp   "sinDouble#"      Monadic          
    Double# -> Double#
 
 primop   DoubleSinOp   "sinDouble#"      Monadic          
    Double# -> Double#
-   with needs_wrapper = True
+   with
+   code_size = { primOpCodeSizeForeignCall }
 
 primop   DoubleCosOp   "cosDouble#"      Monadic          
    Double# -> Double#
 
 primop   DoubleCosOp   "cosDouble#"      Monadic          
    Double# -> Double#
-   with needs_wrapper = True
+   with
+   code_size = { primOpCodeSizeForeignCall }
 
 primop   DoubleTanOp   "tanDouble#"      Monadic          
    Double# -> Double#
 
 primop   DoubleTanOp   "tanDouble#"      Monadic          
    Double# -> Double#
-   with needs_wrapper = True
+   with
+   code_size = { primOpCodeSizeForeignCall }
 
 primop   DoubleAsinOp   "asinDouble#"      Monadic 
    Double# -> Double#
    with
 
 primop   DoubleAsinOp   "asinDouble#"      Monadic 
    Double# -> Double#
    with
-   needs_wrapper = True
+   code_size = { primOpCodeSizeForeignCall }
    can_fail = True
 
 primop   DoubleAcosOp   "acosDouble#"      Monadic  
    Double# -> Double#
    with
    can_fail = True
 
 primop   DoubleAcosOp   "acosDouble#"      Monadic  
    Double# -> Double#
    with
-   needs_wrapper = True
+   code_size = { primOpCodeSizeForeignCall }
    can_fail = True
 
 primop   DoubleAtanOp   "atanDouble#"      Monadic  
    Double# -> Double#
    with
    can_fail = True
 
 primop   DoubleAtanOp   "atanDouble#"      Monadic  
    Double# -> Double#
    with
-   needs_wrapper = True
+   code_size = { primOpCodeSizeForeignCall }
 
 primop   DoubleSinhOp   "sinhDouble#"      Monadic  
    Double# -> Double#
 
 primop   DoubleSinhOp   "sinhDouble#"      Monadic  
    Double# -> Double#
-   with needs_wrapper = True
+   with
+   code_size = { primOpCodeSizeForeignCall }
 
 primop   DoubleCoshOp   "coshDouble#"      Monadic  
    Double# -> Double#
 
 primop   DoubleCoshOp   "coshDouble#"      Monadic  
    Double# -> Double#
-   with needs_wrapper = True
+   with
+   code_size = { primOpCodeSizeForeignCall }
 
 primop   DoubleTanhOp   "tanhDouble#"      Monadic  
    Double# -> Double#
 
 primop   DoubleTanhOp   "tanhDouble#"      Monadic  
    Double# -> Double#
-   with needs_wrapper = True
+   with
+   code_size = { primOpCodeSizeForeignCall }
 
 primop   DoublePowerOp   "**##" Dyadic  
    Double# -> Double# -> Double#
    {Exponentiation.}
 
 primop   DoublePowerOp   "**##" Dyadic  
    Double# -> Double# -> Double#
    {Exponentiation.}
-   with needs_wrapper = True
+   with
+   code_size = { primOpCodeSizeForeignCall }
 
 
-primop   DoubleDecodeOp   "decodeDouble#" GenPrimOp    
-   Double# -> (# Int#, Int#, ByteArr# #)
-   {Convert to arbitrary-precision integer.
-    First {\tt Int\#} in result is the exponent; second {\tt Int\#} and {\tt ByteArr\#}
-    represent an {\tt Integer\#} holding the mantissa.}
+primop   DoubleDecode_2IntOp   "decodeDouble_2Int#" GenPrimOp    
+   Double# -> (# Int#, Word#, Word#, Int# #)
+   {Convert to integer.
+    First component of the result is -1 or 1, indicating the sign of the
+    mantissa. The next two are the high and low 32 bits of the mantissa
+    respectively, and the last is the exponent.}
    with out_of_line = True
 
 ------------------------------------------------------------------------
    with out_of_line = True
 
 ------------------------------------------------------------------------
@@ -653,69 +517,84 @@ primop   FloatDivOp   "divideFloat#"      Dyadic
 primop   FloatNegOp   "negateFloat#"      Monadic    Float# -> Float#
 
 primop   Float2IntOp   "float2Int#"      GenPrimOp  Float# -> Int#
 primop   FloatNegOp   "negateFloat#"      Monadic    Float# -> Float#
 
 primop   Float2IntOp   "float2Int#"      GenPrimOp  Float# -> Int#
+   {Truncates a {\tt Float#} value to the nearest {\tt Int#}.
+    Results are undefined if the truncation if truncation yields
+    a value outside the range of {\tt Int#}.}
 
 primop   FloatExpOp   "expFloat#"      Monadic          
    Float# -> Float#
 
 primop   FloatExpOp   "expFloat#"      Monadic          
    Float# -> Float#
-   with needs_wrapper = True
+   with
+   code_size = { primOpCodeSizeForeignCall }
 
 primop   FloatLogOp   "logFloat#"      Monadic          
    Float# -> Float#
 
 primop   FloatLogOp   "logFloat#"      Monadic          
    Float# -> Float#
-   with needs_wrapper = True
-        can_fail = True
+   with
+   code_size = { primOpCodeSizeForeignCall }
+   can_fail = True
 
 primop   FloatSqrtOp   "sqrtFloat#"      Monadic          
    Float# -> Float#
 
 primop   FloatSqrtOp   "sqrtFloat#"      Monadic          
    Float# -> Float#
-   with needs_wrapper = True
+   with
+   code_size = { primOpCodeSizeForeignCall }
 
 primop   FloatSinOp   "sinFloat#"      Monadic          
    Float# -> Float#
 
 primop   FloatSinOp   "sinFloat#"      Monadic          
    Float# -> Float#
-   with needs_wrapper = True
+   with
+   code_size = { primOpCodeSizeForeignCall }
 
 primop   FloatCosOp   "cosFloat#"      Monadic          
    Float# -> Float#
 
 primop   FloatCosOp   "cosFloat#"      Monadic          
    Float# -> Float#
-   with needs_wrapper = True
+   with
+   code_size = { primOpCodeSizeForeignCall }
 
 primop   FloatTanOp   "tanFloat#"      Monadic          
    Float# -> Float#
 
 primop   FloatTanOp   "tanFloat#"      Monadic          
    Float# -> Float#
-   with needs_wrapper = True
+   with
+   code_size = { primOpCodeSizeForeignCall }
 
 primop   FloatAsinOp   "asinFloat#"      Monadic          
    Float# -> Float#
 
 primop   FloatAsinOp   "asinFloat#"      Monadic          
    Float# -> Float#
-   with needs_wrapper = True
-        can_fail = True
+   with
+   code_size = { primOpCodeSizeForeignCall }
+   can_fail = True
 
 primop   FloatAcosOp   "acosFloat#"      Monadic          
    Float# -> Float#
 
 primop   FloatAcosOp   "acosFloat#"      Monadic          
    Float# -> Float#
-   with needs_wrapper = True
-        can_fail = True
+   with
+   code_size = { primOpCodeSizeForeignCall }
+   can_fail = True
 
 primop   FloatAtanOp   "atanFloat#"      Monadic          
    Float# -> Float#
 
 primop   FloatAtanOp   "atanFloat#"      Monadic          
    Float# -> Float#
-   with needs_wrapper = True
+   with
+   code_size = { primOpCodeSizeForeignCall }
 
 primop   FloatSinhOp   "sinhFloat#"      Monadic          
    Float# -> Float#
 
 primop   FloatSinhOp   "sinhFloat#"      Monadic          
    Float# -> Float#
-   with needs_wrapper = True
+   with
+   code_size = { primOpCodeSizeForeignCall }
 
 primop   FloatCoshOp   "coshFloat#"      Monadic          
    Float# -> Float#
 
 primop   FloatCoshOp   "coshFloat#"      Monadic          
    Float# -> Float#
-   with needs_wrapper = True
+   with
+   code_size = { primOpCodeSizeForeignCall }
 
 primop   FloatTanhOp   "tanhFloat#"      Monadic          
    Float# -> Float#
 
 primop   FloatTanhOp   "tanhFloat#"      Monadic          
    Float# -> Float#
-   with needs_wrapper = True
+   with
+   code_size = { primOpCodeSizeForeignCall }
 
 primop   FloatPowerOp   "powerFloat#"      Dyadic   
    Float# -> Float# -> Float#
 
 primop   FloatPowerOp   "powerFloat#"      Dyadic   
    Float# -> Float# -> Float#
-   with needs_wrapper = True
+   with
+   code_size = { primOpCodeSizeForeignCall }
 
 primop   Float2DoubleOp   "float2Double#" GenPrimOp  Float# -> Double#
 
 
 primop   Float2DoubleOp   "float2Double#" GenPrimOp  Float# -> Double#
 
-primop   FloatDecodeOp   "decodeFloat#" GenPrimOp
-   Float# -> (# Int#, Int#, ByteArr# #)
-   {Convert to arbitrary-precision integer.
-    First {\tt Int\#} in result is the exponent; second {\tt Int\#} and {\tt ByteArr\#}
-    represent an {\tt Integer\#} holding the mantissa.}
+primop   FloatDecode_IntOp   "decodeFloat_Int#" GenPrimOp
+   Float# -> (# Int#, Int# #)
+   {Convert to integers.
+    First {\tt Int\#} in result is the mantissa; second is the exponent.}
    with out_of_line = True
 
 ------------------------------------------------------------------------
    with out_of_line = True
 
 ------------------------------------------------------------------------
@@ -725,269 +604,347 @@ section "Arrays"
 
 primtype Array# a
 
 
 primtype Array# a
 
-primtype MutArr# s a
+primtype MutableArray# s a
 
 primop  NewArrayOp "newArray#" GenPrimOp
 
 primop  NewArrayOp "newArray#" GenPrimOp
-   Int# -> a -> State# s -> (# State# s, MutArr# s a #)
-   {Create a new mutable array of specified size (in bytes),
+   Int# -> a -> State# s -> (# State# s, MutableArray# s a #)
+   {Create a new mutable array with the specified number of elements,
     in the specified state thread,
     with each element containing the specified initial value.}
    with
     in the specified state thread,
     with each element containing the specified initial value.}
    with
-   usage       = { mangle NewArrayOp [mkP, mkM, mkP] mkM }
    out_of_line = True
    out_of_line = True
+   has_side_effects = True
 
 primop  SameMutableArrayOp "sameMutableArray#" GenPrimOp
 
 primop  SameMutableArrayOp "sameMutableArray#" GenPrimOp
-   MutArr# s a -> MutArr# s a -> Bool
-   with
-   usage = { mangle SameMutableArrayOp [mkP, mkP] mkM }
+   MutableArray# s a -> MutableArray# s a -> Bool
 
 primop  ReadArrayOp "readArray#" GenPrimOp
 
 primop  ReadArrayOp "readArray#" GenPrimOp
-   MutArr# s a -> Int# -> State# s -> (# State# s, a #)
+   MutableArray# s a -> Int# -> State# s -> (# State# s, a #)
    {Read from specified index of mutable array. Result is not yet evaluated.}
    with
    {Read from specified index of mutable array. Result is not yet evaluated.}
    with
-   usage = { mangle ReadArrayOp [mkM, mkP, mkP] mkM }
+   has_side_effects = True
 
 primop  WriteArrayOp "writeArray#" GenPrimOp
 
 primop  WriteArrayOp "writeArray#" GenPrimOp
-   MutArr# s a -> Int# -> a -> State# s -> State# s
+   MutableArray# s a -> Int# -> a -> State# s -> State# s
    {Write to specified index of mutable array.}
    with
    {Write to specified index of mutable array.}
    with
-   usage            = { mangle WriteArrayOp [mkM, mkP, mkM, mkP] mkR }
    has_side_effects = True
    has_side_effects = True
+   code_size = 2 -- card update too
+
+primop  SizeofArrayOp "sizeofArray#" GenPrimOp
+   Array# a -> Int#
+   {Return the number of elements in the array.}
+
+primop  SizeofMutableArrayOp "sizeofMutableArray#" GenPrimOp
+   MutableArray# s a -> Int#
+   {Return the number of elements in the array.}
 
 primop  IndexArrayOp "indexArray#" GenPrimOp
    Array# a -> Int# -> (# a #)
    {Read from specified index of immutable array. Result is packaged into
     an unboxed singleton; the result itself is not yet evaluated.}
 
 primop  IndexArrayOp "indexArray#" GenPrimOp
    Array# a -> Int# -> (# a #)
    {Read from specified index of immutable array. Result is packaged into
     an unboxed singleton; the result itself is not yet evaluated.}
-   with
-   usage = { mangle  IndexArrayOp [mkM, mkP] mkM }
 
 primop  UnsafeFreezeArrayOp "unsafeFreezeArray#" GenPrimOp
 
 primop  UnsafeFreezeArrayOp "unsafeFreezeArray#" GenPrimOp
-   MutArr# s a -> State# s -> (# State# s, Array# a #)
+   MutableArray# s a -> State# s -> (# State# s, Array# a #)
    {Make a mutable array immutable, without copying.}
    with
    {Make a mutable array immutable, without copying.}
    with
-   usage            = { mangle UnsafeFreezeArrayOp [mkM, mkP] mkM }
    has_side_effects = True
 
 primop  UnsafeThawArrayOp  "unsafeThawArray#" GenPrimOp
    has_side_effects = True
 
 primop  UnsafeThawArrayOp  "unsafeThawArray#" GenPrimOp
-   Array# a -> State# s -> (# State# s, MutArr# s a #)
+   Array# a -> State# s -> (# State# s, MutableArray# s a #)
    {Make an immutable array mutable, without copying.}
    with
    {Make an immutable array mutable, without copying.}
    with
-   usage       = { mangle UnsafeThawArrayOp [mkM, mkP] mkM }
    out_of_line = True
    out_of_line = True
+   has_side_effects = True
+
+primop  CopyArrayOp "copyArray#" GenPrimOp
+  Array# a -> Int# -> MutableArray# s a -> Int# -> Int# -> State# s -> State# s
+  {Copy a range of the Array# to the specified region in the MutableArray#.
+   Both arrays must fully contain the specified ranges, but this is not checked.
+   The two arrays must not be the same array in different states, but this is not checked either.}
+  with
+  has_side_effects = True
+  code_size = { primOpCodeSizeForeignCall + 4 }
+
+primop  CopyMutableArrayOp "copyMutableArray#" GenPrimOp
+  MutableArray# s a -> Int# -> MutableArray# s a -> Int# -> Int# -> State# s -> State# s
+  {Copy a range of the first MutableArray# to the specified region in the second MutableArray#.
+   Both arrays must fully contain the specified ranges, but this is not checked.}
+  with
+  has_side_effects = True
+  code_size = { primOpCodeSizeForeignCall + 4 }
+
+primop  CloneArrayOp "cloneArray#" GenPrimOp
+  Array# a -> Int# -> Int# -> Array# a
+  {Return a newly allocated Array# with the specified subrange of the provided Array#. 
+   The provided Array# should contain the full subrange specified by the two Int#s, but this is not checked.}
+  with
+  has_side_effects = True
+  code_size = { primOpCodeSizeForeignCall + 4 }
+
+primop  CloneMutableArrayOp "cloneMutableArray#" GenPrimOp
+  MutableArray# s a -> Int# -> Int# -> State# s -> (# State# s, MutableArray# s a #)
+  {Return a newly allocated Array# with the specified subrange of the provided Array#.
+   The provided MutableArray# should contain the full subrange specified by the two Int#s, but this is not checked.}
+  with
+  has_side_effects = True
+  code_size = { primOpCodeSizeForeignCall + 4 }
+
+primop  FreezeArrayOp "freezeArray#" GenPrimOp
+  MutableArray# s a -> Int# -> Int# -> State# s -> (# State# s, Array# a #)
+  {Return a newly allocated Array# with the specified subrange of the provided MutableArray#.
+   The provided MutableArray# should contain the full subrange specified by the two Int#s, but this is not checked.}
+  with
+  has_side_effects = True
+  code_size = { primOpCodeSizeForeignCall + 4 }
+
+primop  ThawArrayOp "thawArray#" GenPrimOp
+  Array# a -> Int# -> Int# -> State# s -> (# State# s, MutableArray# s a #)
+  {Return a newly allocated Array# with the specified subrange of the provided MutableArray#.
+   The provided Array# should contain the full subrange specified by the two Int#s, but this is not checked.}
+  with
+  has_side_effects = True
+  code_size = { primOpCodeSizeForeignCall + 4 }
 
 ------------------------------------------------------------------------
 section "Byte Arrays"
        {Operations on {\tt ByteArray\#}. A {\tt ByteArray\#} is a just a region of
 
 ------------------------------------------------------------------------
 section "Byte Arrays"
        {Operations on {\tt ByteArray\#}. A {\tt ByteArray\#} is a just a region of
-         raw memory in the garbage-collected heap, which is not scanned
-         for pointers. It carries its own size (in bytes). There are
-        three sets of operations for accessing byte array contents:
-        index for reading from immutable byte arrays, and read/write
-        for mutable byte arrays.  Each set contains operations for 
-        a range of useful primitive data types.  Each operation takes  
-        an offset measured in terms of the size fo the primitive type
-        being read or written.}
+         raw memory in the garbage-collected heap, which is not
+         scanned for pointers. It carries its own size (in bytes).
+         There are
+         three sets of operations for accessing byte array contents:
+         index for reading from immutable byte arrays, and read/write
+         for mutable byte arrays.  Each set contains operations for a
+         range of useful primitive data types.  Each operation takes
+         an offset measured in terms of the size fo the primitive type
+         being read or written.}
 
 ------------------------------------------------------------------------
 
 
 ------------------------------------------------------------------------
 
-primtype ByteArr#
+primtype ByteArray#
 
 
-primtype MutByteArr# s
+primtype MutableByteArray# s
 
 primop  NewByteArrayOp_Char "newByteArray#" GenPrimOp
 
 primop  NewByteArrayOp_Char "newByteArray#" GenPrimOp
-   Int# -> State# s -> (# State# s, MutByteArr# s #)
+   Int# -> State# s -> (# State# s, MutableByteArray# s #)
    {Create a new mutable byte array of specified size (in bytes), in
     the specified state thread.}
    with out_of_line = True
    {Create a new mutable byte array of specified size (in bytes), in
     the specified state thread.}
    with out_of_line = True
+        has_side_effects = True
 
 primop  NewPinnedByteArrayOp_Char "newPinnedByteArray#" GenPrimOp
 
 primop  NewPinnedByteArrayOp_Char "newPinnedByteArray#" GenPrimOp
-   Int# -> State# s -> (# State# s, MutByteArr# s #)
+   Int# -> State# s -> (# State# s, MutableByteArray# s #)
    {Create a mutable byte array that the GC guarantees not to move.}
    with out_of_line = True
    {Create a mutable byte array that the GC guarantees not to move.}
    with out_of_line = True
+        has_side_effects = True
+
+primop  NewAlignedPinnedByteArrayOp_Char "newAlignedPinnedByteArray#" GenPrimOp
+   Int# -> Int# -> State# s -> (# State# s, MutableByteArray# s #)
+   {Create a mutable byte array, aligned by the specified amount, that the GC guarantees not to move.}
+   with out_of_line = True
+        has_side_effects = True
 
 primop  ByteArrayContents_Char "byteArrayContents#" GenPrimOp
 
 primop  ByteArrayContents_Char "byteArrayContents#" GenPrimOp
-   ByteArr# -> Addr#
+   ByteArray# -> Addr#
    {Intended for use with pinned arrays; otherwise very unsafe!}
 
 primop  SameMutableByteArrayOp "sameMutableByteArray#" GenPrimOp
    {Intended for use with pinned arrays; otherwise very unsafe!}
 
 primop  SameMutableByteArrayOp "sameMutableByteArray#" GenPrimOp
-   MutByteArr# s -> MutByteArr# s -> Bool
+   MutableByteArray# s -> MutableByteArray# s -> Bool
 
 primop  UnsafeFreezeByteArrayOp "unsafeFreezeByteArray#" GenPrimOp
 
 primop  UnsafeFreezeByteArrayOp "unsafeFreezeByteArray#" GenPrimOp
-   MutByteArr# s -> State# s -> (# State# s, ByteArr# #)
+   MutableByteArray# s -> State# s -> (# State# s, ByteArray# #)
    {Make a mutable byte array immutable, without copying.}
    with
    has_side_effects = True
 
 primop  SizeofByteArrayOp "sizeofByteArray#" GenPrimOp  
    {Make a mutable byte array immutable, without copying.}
    with
    has_side_effects = True
 
 primop  SizeofByteArrayOp "sizeofByteArray#" GenPrimOp  
-   ByteArr# -> Int#
+   ByteArray# -> Int#
+   {Return the size of the array in bytes.}
 
 primop  SizeofMutableByteArrayOp "sizeofMutableByteArray#" GenPrimOp
 
 primop  SizeofMutableByteArrayOp "sizeofMutableByteArray#" GenPrimOp
-   MutByteArr# s -> Int#
-
+   MutableByteArray# s -> Int#
+   {Return the size of the array in bytes.}
 
 primop IndexByteArrayOp_Char "indexCharArray#" GenPrimOp
 
 primop IndexByteArrayOp_Char "indexCharArray#" GenPrimOp
-   ByteArr# -> Int# -> Char#
+   ByteArray# -> Int# -> Char#
    {Read 8-bit character; offset in bytes.}
 
 primop IndexByteArrayOp_WideChar "indexWideCharArray#" GenPrimOp
    {Read 8-bit character; offset in bytes.}
 
 primop IndexByteArrayOp_WideChar "indexWideCharArray#" GenPrimOp
-   ByteArr# -> Int# -> Char#
+   ByteArray# -> Int# -> Char#
    {Read 31-bit character; offset in 4-byte words.}
 
 primop IndexByteArrayOp_Int "indexIntArray#" GenPrimOp
    {Read 31-bit character; offset in 4-byte words.}
 
 primop IndexByteArrayOp_Int "indexIntArray#" GenPrimOp
-   ByteArr# -> Int# -> Int#
+   ByteArray# -> Int# -> Int#
 
 primop IndexByteArrayOp_Word "indexWordArray#" GenPrimOp
 
 primop IndexByteArrayOp_Word "indexWordArray#" GenPrimOp
-   ByteArr# -> Int# -> Word#
+   ByteArray# -> Int# -> Word#
 
 primop IndexByteArrayOp_Addr "indexAddrArray#" GenPrimOp
 
 primop IndexByteArrayOp_Addr "indexAddrArray#" GenPrimOp
-   ByteArr# -> Int# -> Addr#
+   ByteArray# -> Int# -> Addr#
 
 primop IndexByteArrayOp_Float "indexFloatArray#" GenPrimOp
 
 primop IndexByteArrayOp_Float "indexFloatArray#" GenPrimOp
-   ByteArr# -> Int# -> Float#
+   ByteArray# -> Int# -> Float#
 
 primop IndexByteArrayOp_Double "indexDoubleArray#" GenPrimOp
 
 primop IndexByteArrayOp_Double "indexDoubleArray#" GenPrimOp
-   ByteArr# -> Int# -> Double#
+   ByteArray# -> Int# -> Double#
 
 primop IndexByteArrayOp_StablePtr "indexStablePtrArray#" GenPrimOp
 
 primop IndexByteArrayOp_StablePtr "indexStablePtrArray#" GenPrimOp
-   ByteArr# -> Int# -> StablePtr# a
+   ByteArray# -> Int# -> StablePtr# a
 
 primop IndexByteArrayOp_Int8 "indexInt8Array#" GenPrimOp
 
 primop IndexByteArrayOp_Int8 "indexInt8Array#" GenPrimOp
-   ByteArr# -> Int# -> Int#
+   ByteArray# -> Int# -> Int#
 
 primop IndexByteArrayOp_Int16 "indexInt16Array#" GenPrimOp
 
 primop IndexByteArrayOp_Int16 "indexInt16Array#" GenPrimOp
-   ByteArr# -> Int# -> Int#
+   ByteArray# -> Int# -> Int#
 
 primop IndexByteArrayOp_Int32 "indexInt32Array#" GenPrimOp
 
 primop IndexByteArrayOp_Int32 "indexInt32Array#" GenPrimOp
-   ByteArr# -> Int# -> INT32
+   ByteArray# -> Int# -> INT32
 
 primop IndexByteArrayOp_Int64 "indexInt64Array#" GenPrimOp
 
 primop IndexByteArrayOp_Int64 "indexInt64Array#" GenPrimOp
-   ByteArr# -> Int# -> INT64
+   ByteArray# -> Int# -> INT64
 
 primop IndexByteArrayOp_Word8 "indexWord8Array#" GenPrimOp
 
 primop IndexByteArrayOp_Word8 "indexWord8Array#" GenPrimOp
-   ByteArr# -> Int# -> Word#
+   ByteArray# -> Int# -> Word#
 
 primop IndexByteArrayOp_Word16 "indexWord16Array#" GenPrimOp
 
 primop IndexByteArrayOp_Word16 "indexWord16Array#" GenPrimOp
-   ByteArr# -> Int# -> Word#
+   ByteArray# -> Int# -> Word#
 
 primop IndexByteArrayOp_Word32 "indexWord32Array#" GenPrimOp
 
 primop IndexByteArrayOp_Word32 "indexWord32Array#" GenPrimOp
-   ByteArr# -> Int# -> WORD32
+   ByteArray# -> Int# -> WORD32
 
 primop IndexByteArrayOp_Word64 "indexWord64Array#" GenPrimOp
 
 primop IndexByteArrayOp_Word64 "indexWord64Array#" GenPrimOp
-   ByteArr# -> Int# -> WORD64
+   ByteArray# -> Int# -> WORD64
 
 primop  ReadByteArrayOp_Char "readCharArray#" GenPrimOp
 
 primop  ReadByteArrayOp_Char "readCharArray#" GenPrimOp
-   MutByteArr# s -> Int# -> State# s -> (# State# s, Char# #)
+   MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #)
    {Read 8-bit character; offset in bytes.}
    {Read 8-bit character; offset in bytes.}
+   with has_side_effects = True
 
 primop  ReadByteArrayOp_WideChar "readWideCharArray#" GenPrimOp
 
 primop  ReadByteArrayOp_WideChar "readWideCharArray#" GenPrimOp
-   MutByteArr# s -> Int# -> State# s -> (# State# s, Char# #)
+   MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #)
    {Read 31-bit character; offset in 4-byte words.}
    {Read 31-bit character; offset in 4-byte words.}
+   with has_side_effects = True
 
 primop  ReadByteArrayOp_Int "readIntArray#" GenPrimOp
 
 primop  ReadByteArrayOp_Int "readIntArray#" GenPrimOp
-   MutByteArr# s -> Int# -> State# s -> (# State# s, Int# #)
+   MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)
+   with has_side_effects = True
 
 primop  ReadByteArrayOp_Word "readWordArray#" GenPrimOp
 
 primop  ReadByteArrayOp_Word "readWordArray#" GenPrimOp
-   MutByteArr# s -> Int# -> State# s -> (# State# s, Word# #)
+   MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)
+   with has_side_effects = True
 
 primop  ReadByteArrayOp_Addr "readAddrArray#" GenPrimOp
 
 primop  ReadByteArrayOp_Addr "readAddrArray#" GenPrimOp
-   MutByteArr# s -> Int# -> State# s -> (# State# s, Addr# #)
+   MutableByteArray# s -> Int# -> State# s -> (# State# s, Addr# #)
+   with has_side_effects = True
 
 primop  ReadByteArrayOp_Float "readFloatArray#" GenPrimOp
 
 primop  ReadByteArrayOp_Float "readFloatArray#" GenPrimOp
-   MutByteArr# s -> Int# -> State# s -> (# State# s, Float# #)
+   MutableByteArray# s -> Int# -> State# s -> (# State# s, Float# #)
+   with has_side_effects = True
 
 primop  ReadByteArrayOp_Double "readDoubleArray#" GenPrimOp
 
 primop  ReadByteArrayOp_Double "readDoubleArray#" GenPrimOp
-   MutByteArr# s -> Int# -> State# s -> (# State# s, Double# #)
+   MutableByteArray# s -> Int# -> State# s -> (# State# s, Double# #)
+   with has_side_effects = True
 
 primop  ReadByteArrayOp_StablePtr "readStablePtrArray#" GenPrimOp
 
 primop  ReadByteArrayOp_StablePtr "readStablePtrArray#" GenPrimOp
-   MutByteArr# s -> Int# -> State# s -> (# State# s, StablePtr# a #)
+   MutableByteArray# s -> Int# -> State# s -> (# State# s, StablePtr# a #)
+   with has_side_effects = True
 
 primop  ReadByteArrayOp_Int8 "readInt8Array#" GenPrimOp
 
 primop  ReadByteArrayOp_Int8 "readInt8Array#" GenPrimOp
-   MutByteArr# s -> Int# -> State# s -> (# State# s, Int# #)
+   MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)
+   with has_side_effects = True
 
 primop  ReadByteArrayOp_Int16 "readInt16Array#" GenPrimOp
 
 primop  ReadByteArrayOp_Int16 "readInt16Array#" GenPrimOp
-   MutByteArr# s -> Int# -> State# s -> (# State# s, Int# #)
+   MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)
+   with has_side_effects = True
 
 primop  ReadByteArrayOp_Int32 "readInt32Array#" GenPrimOp
 
 primop  ReadByteArrayOp_Int32 "readInt32Array#" GenPrimOp
-   MutByteArr# s -> Int# -> State# s -> (# State# s, INT32 #)
+   MutableByteArray# s -> Int# -> State# s -> (# State# s, INT32 #)
+   with has_side_effects = True
 
 primop  ReadByteArrayOp_Int64 "readInt64Array#" GenPrimOp
 
 primop  ReadByteArrayOp_Int64 "readInt64Array#" GenPrimOp
-   MutByteArr# s -> Int# -> State# s -> (# State# s, INT64 #)
+   MutableByteArray# s -> Int# -> State# s -> (# State# s, INT64 #)
+   with has_side_effects = True
 
 primop  ReadByteArrayOp_Word8 "readWord8Array#" GenPrimOp
 
 primop  ReadByteArrayOp_Word8 "readWord8Array#" GenPrimOp
-   MutByteArr# s -> Int# -> State# s -> (# State# s, Word# #)
+   MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)
+   with has_side_effects = True
 
 primop  ReadByteArrayOp_Word16 "readWord16Array#" GenPrimOp
 
 primop  ReadByteArrayOp_Word16 "readWord16Array#" GenPrimOp
-   MutByteArr# s -> Int# -> State# s -> (# State# s, Word# #)
+   MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)
+   with has_side_effects = True
 
 primop  ReadByteArrayOp_Word32 "readWord32Array#" GenPrimOp
 
 primop  ReadByteArrayOp_Word32 "readWord32Array#" GenPrimOp
-   MutByteArr# s -> Int# -> State# s -> (# State# s, WORD32 #)
+   MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD32 #)
+   with has_side_effects = True
 
 primop  ReadByteArrayOp_Word64 "readWord64Array#" GenPrimOp
 
 primop  ReadByteArrayOp_Word64 "readWord64Array#" GenPrimOp
-   MutByteArr# s -> Int# -> State# s -> (# State# s, WORD64 #)
+   MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD64 #)
+   with has_side_effects = True
 
 primop  WriteByteArrayOp_Char "writeCharArray#" GenPrimOp
 
 primop  WriteByteArrayOp_Char "writeCharArray#" GenPrimOp
-   MutByteArr# s -> Int# -> Char# -> State# s -> State# s
+   MutableByteArray# s -> Int# -> Char# -> State# s -> State# s
    {Write 8-bit character; offset in bytes.}
    with has_side_effects = True
 
 primop  WriteByteArrayOp_WideChar "writeWideCharArray#" GenPrimOp
    {Write 8-bit character; offset in bytes.}
    with has_side_effects = True
 
 primop  WriteByteArrayOp_WideChar "writeWideCharArray#" GenPrimOp
-   MutByteArr# s -> Int# -> Char# -> State# s -> State# s
+   MutableByteArray# s -> Int# -> Char# -> State# s -> State# s
    {Write 31-bit character; offset in 4-byte words.}
    with has_side_effects = True
 
 primop  WriteByteArrayOp_Int "writeIntArray#" GenPrimOp
    {Write 31-bit character; offset in 4-byte words.}
    with has_side_effects = True
 
 primop  WriteByteArrayOp_Int "writeIntArray#" GenPrimOp
-   MutByteArr# s -> Int# -> Int# -> State# s -> State# s
+   MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
    with has_side_effects = True
 
 primop  WriteByteArrayOp_Word "writeWordArray#" GenPrimOp
    with has_side_effects = True
 
 primop  WriteByteArrayOp_Word "writeWordArray#" GenPrimOp
-   MutByteArr# s -> Int# -> Word# -> State# s -> State# s
+   MutableByteArray# s -> Int# -> Word# -> State# s -> State# s
    with has_side_effects = True
 
 primop  WriteByteArrayOp_Addr "writeAddrArray#" GenPrimOp
    with has_side_effects = True
 
 primop  WriteByteArrayOp_Addr "writeAddrArray#" GenPrimOp
-   MutByteArr# s -> Int# -> Addr# -> State# s -> State# s
+   MutableByteArray# s -> Int# -> Addr# -> State# s -> State# s
    with has_side_effects = True
 
 primop  WriteByteArrayOp_Float "writeFloatArray#" GenPrimOp
    with has_side_effects = True
 
 primop  WriteByteArrayOp_Float "writeFloatArray#" GenPrimOp
-   MutByteArr# s -> Int# -> Float# -> State# s -> State# s
+   MutableByteArray# s -> Int# -> Float# -> State# s -> State# s
    with has_side_effects = True
 
 primop  WriteByteArrayOp_Double "writeDoubleArray#" GenPrimOp
    with has_side_effects = True
 
 primop  WriteByteArrayOp_Double "writeDoubleArray#" GenPrimOp
-   MutByteArr# s -> Int# -> Double# -> State# s -> State# s
+   MutableByteArray# s -> Int# -> Double# -> State# s -> State# s
    with has_side_effects = True
 
 primop  WriteByteArrayOp_StablePtr "writeStablePtrArray#" GenPrimOp
    with has_side_effects = True
 
 primop  WriteByteArrayOp_StablePtr "writeStablePtrArray#" GenPrimOp
-   MutByteArr# s -> Int# -> StablePtr# a -> State# s -> State# s
+   MutableByteArray# s -> Int# -> StablePtr# a -> State# s -> State# s
    with has_side_effects = True
 
 primop  WriteByteArrayOp_Int8 "writeInt8Array#" GenPrimOp
    with has_side_effects = True
 
 primop  WriteByteArrayOp_Int8 "writeInt8Array#" GenPrimOp
-   MutByteArr# s -> Int# -> Int# -> State# s -> State# s
+   MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
    with has_side_effects = True
 
 primop  WriteByteArrayOp_Int16 "writeInt16Array#" GenPrimOp
    with has_side_effects = True
 
 primop  WriteByteArrayOp_Int16 "writeInt16Array#" GenPrimOp
-   MutByteArr# s -> Int# -> Int# -> State# s -> State# s
+   MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
    with has_side_effects = True
 
 primop  WriteByteArrayOp_Int32 "writeInt32Array#" GenPrimOp
    with has_side_effects = True
 
 primop  WriteByteArrayOp_Int32 "writeInt32Array#" GenPrimOp
-   MutByteArr# s -> Int# -> INT32 -> State# s -> State# s
+   MutableByteArray# s -> Int# -> INT32 -> State# s -> State# s
    with has_side_effects = True
 
 primop  WriteByteArrayOp_Int64 "writeInt64Array#" GenPrimOp
    with has_side_effects = True
 
 primop  WriteByteArrayOp_Int64 "writeInt64Array#" GenPrimOp
-   MutByteArr# s -> Int# -> INT64 -> State# s -> State# s
+   MutableByteArray# s -> Int# -> INT64 -> State# s -> State# s
    with has_side_effects = True
 
 primop  WriteByteArrayOp_Word8 "writeWord8Array#" GenPrimOp
    with has_side_effects = True
 
 primop  WriteByteArrayOp_Word8 "writeWord8Array#" GenPrimOp
-   MutByteArr# s -> Int# -> Word# -> State# s -> State# s
+   MutableByteArray# s -> Int# -> Word# -> State# s -> State# s
    with has_side_effects = True
 
 primop  WriteByteArrayOp_Word16 "writeWord16Array#" GenPrimOp
    with has_side_effects = True
 
 primop  WriteByteArrayOp_Word16 "writeWord16Array#" GenPrimOp
-   MutByteArr# s -> Int# -> Word# -> State# s -> State# s
+   MutableByteArray# s -> Int# -> Word# -> State# s -> State# s
    with has_side_effects = True
 
 primop  WriteByteArrayOp_Word32 "writeWord32Array#" GenPrimOp
    with has_side_effects = True
 
 primop  WriteByteArrayOp_Word32 "writeWord32Array#" GenPrimOp
-   MutByteArr# s -> Int# -> WORD32 -> State# s -> State# s
+   MutableByteArray# s -> Int# -> WORD32 -> State# s -> State# s
    with has_side_effects = True
 
 primop  WriteByteArrayOp_Word64 "writeWord64Array#" GenPrimOp
    with has_side_effects = True
 
 primop  WriteByteArrayOp_Word64 "writeWord64Array#" GenPrimOp
-   MutByteArr# s -> Int# -> WORD64 -> State# s -> State# s
+   MutableByteArray# s -> Int# -> WORD64 -> State# s -> State# s
    with has_side_effects = True
 
 ------------------------------------------------------------------------
    with has_side_effects = True
 
 ------------------------------------------------------------------------
@@ -1011,8 +968,10 @@ primop     AddrRemOp "remAddr#" GenPrimOp Addr# -> Int# -> Int#
 #if (WORD_SIZE_IN_BITS == 32 || WORD_SIZE_IN_BITS == 64)
 primop   Addr2IntOp  "addr2Int#"     GenPrimOp   Addr# -> Int#
        {Coerce directly from address to int. Strongly deprecated.}
 #if (WORD_SIZE_IN_BITS == 32 || WORD_SIZE_IN_BITS == 64)
 primop   Addr2IntOp  "addr2Int#"     GenPrimOp   Addr# -> Int#
        {Coerce directly from address to int. Strongly deprecated.}
+   with code_size = 0
 primop   Int2AddrOp   "int2Addr#"    GenPrimOp  Int# -> Addr#
        {Coerce directly from int to address. Strongly deprecated.}
 primop   Int2AddrOp   "int2Addr#"    GenPrimOp  Int# -> Addr#
        {Coerce directly from int to address. Strongly deprecated.}
+   with code_size = 0
 #endif
 
 primop   AddrGtOp  "gtAddr#"   Compare   Addr# -> Addr# -> Bool
 #endif
 
 primop   AddrGtOp  "gtAddr#"   Compare   Addr# -> Addr# -> Bool
@@ -1075,52 +1034,68 @@ primop IndexOffAddrOp_Word64 "indexWord64OffAddr#" GenPrimOp
 primop ReadOffAddrOp_Char "readCharOffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, Char# #)
    {Reads 8-bit character; offset in bytes.}
 primop ReadOffAddrOp_Char "readCharOffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, Char# #)
    {Reads 8-bit character; offset in bytes.}
+   with has_side_effects = True
 
 primop ReadOffAddrOp_WideChar "readWideCharOffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, Char# #)
    {Reads 31-bit character; offset in 4-byte words.}
 
 primop ReadOffAddrOp_WideChar "readWideCharOffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, Char# #)
    {Reads 31-bit character; offset in 4-byte words.}
+   with has_side_effects = True
 
 primop ReadOffAddrOp_Int "readIntOffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, Int# #)
 
 primop ReadOffAddrOp_Int "readIntOffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, Int# #)
+   with has_side_effects = True
 
 primop ReadOffAddrOp_Word "readWordOffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, Word# #)
 
 primop ReadOffAddrOp_Word "readWordOffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, Word# #)
+   with has_side_effects = True
 
 primop ReadOffAddrOp_Addr "readAddrOffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, Addr# #)
 
 primop ReadOffAddrOp_Addr "readAddrOffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, Addr# #)
+   with has_side_effects = True
 
 primop ReadOffAddrOp_Float "readFloatOffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, Float# #)
 
 primop ReadOffAddrOp_Float "readFloatOffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, Float# #)
+   with has_side_effects = True
 
 primop ReadOffAddrOp_Double "readDoubleOffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, Double# #)
 
 primop ReadOffAddrOp_Double "readDoubleOffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, Double# #)
+   with has_side_effects = True
 
 primop ReadOffAddrOp_StablePtr "readStablePtrOffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, StablePtr# a #)
 
 primop ReadOffAddrOp_StablePtr "readStablePtrOffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, StablePtr# a #)
+   with has_side_effects = True
 
 primop ReadOffAddrOp_Int8 "readInt8OffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, Int# #)
 
 primop ReadOffAddrOp_Int8 "readInt8OffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, Int# #)
+   with has_side_effects = True
 
 primop ReadOffAddrOp_Int16 "readInt16OffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, Int# #)
 
 primop ReadOffAddrOp_Int16 "readInt16OffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, Int# #)
+   with has_side_effects = True
 
 primop ReadOffAddrOp_Int32 "readInt32OffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, INT32 #)
 
 primop ReadOffAddrOp_Int32 "readInt32OffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, INT32 #)
+   with has_side_effects = True
 
 primop ReadOffAddrOp_Int64 "readInt64OffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, INT64 #)
 
 primop ReadOffAddrOp_Int64 "readInt64OffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, INT64 #)
+   with has_side_effects = True
 
 primop ReadOffAddrOp_Word8 "readWord8OffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, Word# #)
 
 primop ReadOffAddrOp_Word8 "readWord8OffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, Word# #)
+   with has_side_effects = True
 
 primop ReadOffAddrOp_Word16 "readWord16OffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, Word# #)
 
 primop ReadOffAddrOp_Word16 "readWord16OffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, Word# #)
+   with has_side_effects = True
 
 primop ReadOffAddrOp_Word32 "readWord32OffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, WORD32 #)
 
 primop ReadOffAddrOp_Word32 "readWord32OffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, WORD32 #)
+   with has_side_effects = True
 
 primop ReadOffAddrOp_Word64 "readWord64OffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, WORD64 #)
 
 primop ReadOffAddrOp_Word64 "readWord64OffAddr#" GenPrimOp
    Addr# -> Int# -> State# s -> (# State# s, WORD64 #)
+   with has_side_effects = True
 
 
 primop  WriteOffAddrOp_Char "writeCharOffAddr#" GenPrimOp
 
 
 primop  WriteOffAddrOp_Char "writeCharOffAddr#" GenPrimOp
@@ -1199,26 +1174,24 @@ primop  NewMutVarOp "newMutVar#" GenPrimOp
    a -> State# s -> (# State# s, MutVar# s a #)
    {Create {\tt MutVar\#} with specified initial value in specified state thread.}
    with
    a -> State# s -> (# State# s, MutVar# s a #)
    {Create {\tt MutVar\#} with specified initial value in specified state thread.}
    with
-   usage       = { mangle NewMutVarOp [mkM, mkP] mkM }
    out_of_line = True
    out_of_line = True
+   has_side_effects = True
 
 primop  ReadMutVarOp "readMutVar#" GenPrimOp
    MutVar# s a -> State# s -> (# State# s, a #)
    {Read contents of {\tt MutVar\#}. Result is not yet evaluated.}
    with
 
 primop  ReadMutVarOp "readMutVar#" GenPrimOp
    MutVar# s a -> State# s -> (# State# s, a #)
    {Read contents of {\tt MutVar\#}. Result is not yet evaluated.}
    with
-   usage = { mangle ReadMutVarOp [mkM, mkP] mkM }
+   has_side_effects = True
 
 primop  WriteMutVarOp "writeMutVar#"  GenPrimOp
    MutVar# s a -> a -> State# s -> State# s
    {Write contents of {\tt MutVar\#}.}
    with
 
 primop  WriteMutVarOp "writeMutVar#"  GenPrimOp
    MutVar# s a -> a -> State# s -> State# s
    {Write contents of {\tt MutVar\#}.}
    with
-   usage            = { mangle WriteMutVarOp [mkM, mkM, mkP] mkR }
    has_side_effects = True
    has_side_effects = True
+   code_size = { primOpCodeSizeForeignCall } -- for the write barrier
 
 primop  SameMutVarOp "sameMutVar#" GenPrimOp
    MutVar# s a -> MutVar# s a -> Bool
 
 primop  SameMutVarOp "sameMutVar#" GenPrimOp
    MutVar# s a -> MutVar# s a -> Bool
-   with
-   usage = { mangle SameMutVarOp [mkP, mkP] mkM }
 
 -- not really the right type, but we don't know about pairs here.  The
 -- correct type is
 
 -- not really the right type, but we don't know about pairs here.  The
 -- correct type is
@@ -1228,9 +1201,14 @@ primop  SameMutVarOp "sameMutVar#" GenPrimOp
 primop  AtomicModifyMutVarOp "atomicModifyMutVar#" GenPrimOp
    MutVar# s a -> (a -> b) -> State# s -> (# State# s, c #)
    with
 primop  AtomicModifyMutVarOp "atomicModifyMutVar#" GenPrimOp
    MutVar# s a -> (a -> b) -> State# s -> (# State# s, c #)
    with
-   usage = { mangle AtomicModifyMutVarOp [mkP, mkM, mkP] mkM }
+   out_of_line = True
    has_side_effects = True
    has_side_effects = True
+
+primop  CasMutVarOp "casMutVar#" GenPrimOp
+  MutVar# s a -> a -> a -> State# s -> (# State# s, Int#, a #)
+   with
    out_of_line = True
    out_of_line = True
+   has_side_effects = True
 
 ------------------------------------------------------------------------
 section "Exceptions"
 
 ------------------------------------------------------------------------
 section "Exceptions"
@@ -1245,39 +1223,57 @@ primop  CatchOp "catch#" GenPrimOp
        -- Catch is actually strict in its first argument
        -- but we don't want to tell the strictness
        -- analyser about that!
        -- Catch is actually strict in its first argument
        -- but we don't want to tell the strictness
        -- analyser about that!
-   usage = { mangle CatchOp [mkM, mkM . (inFun CatchOp mkM mkM), mkP] mkM }
-        --     [mkO, mkO . (inFun mkM mkO)] mkO
         -- might use caught action multiply
    out_of_line = True
         -- might use caught action multiply
    out_of_line = True
+   has_side_effects = True
 
 primop  RaiseOp "raise#" GenPrimOp
    a -> b
    with
 
 primop  RaiseOp "raise#" GenPrimOp
    a -> b
    with
-   strictness  = { \ arity -> mkStrictSig (mkTopDmdType [lazyDmd] BotRes) }
+   strictness  = { \ _arity -> mkStrictSig (mkTopDmdType [lazyDmd] BotRes) }
       -- NB: result is bottom
       -- NB: result is bottom
-   usage       = { mangle RaiseOp [mkM] mkM }
    out_of_line = True
 
 -- raiseIO# needs to be a primop, because exceptions in the IO monad
 -- must be *precise* - we don't want the strictness analyser turning
 -- one kind of bottom into another, as it is allowed to do in pure code.
    out_of_line = True
 
 -- raiseIO# needs to be a primop, because exceptions in the IO monad
 -- must be *precise* - we don't want the strictness analyser turning
 -- one kind of bottom into another, as it is allowed to do in pure code.
+--
+-- But we *do* want to know that it returns bottom after 
+-- being applied to two arguments
 
 primop  RaiseIOOp "raiseIO#" GenPrimOp
    a -> State# RealWorld -> (# State# RealWorld, b #)
    with
 
 primop  RaiseIOOp "raiseIO#" GenPrimOp
    a -> State# RealWorld -> (# State# RealWorld, b #)
    with
+   strictness  = { \ _arity -> mkStrictSig (mkTopDmdType [lazyDmd,lazyDmd] BotRes) }
+   out_of_line = True
+   has_side_effects = True
+
+primop  MaskAsyncExceptionsOp "maskAsyncExceptions#" GenPrimOp
+        (State# RealWorld -> (# State# RealWorld, a #))
+     -> (State# RealWorld -> (# State# RealWorld, a #))
+   with
    out_of_line = True
    out_of_line = True
+   has_side_effects = True
 
 
-primop  BlockAsyncExceptionsOp "blockAsyncExceptions#" GenPrimOp
+primop  MaskUninterruptibleOp "maskUninterruptible#" GenPrimOp
         (State# RealWorld -> (# State# RealWorld, a #))
      -> (State# RealWorld -> (# State# RealWorld, a #))
    with
    out_of_line = True
         (State# RealWorld -> (# State# RealWorld, a #))
      -> (State# RealWorld -> (# State# RealWorld, a #))
    with
    out_of_line = True
+   has_side_effects = True
 
 
-primop  UnblockAsyncExceptionsOp "unblockAsyncExceptions#" GenPrimOp
+primop  UnmaskAsyncExceptionsOp "unmaskAsyncExceptions#" GenPrimOp
         (State# RealWorld -> (# State# RealWorld, a #))
      -> (State# RealWorld -> (# State# RealWorld, a #))
    with
    out_of_line = True
         (State# RealWorld -> (# State# RealWorld, a #))
      -> (State# RealWorld -> (# State# RealWorld, a #))
    with
    out_of_line = True
+   has_side_effects = True
+
+primop  MaskStatus "getMaskingState#" GenPrimOp
+        State# RealWorld -> (# State# RealWorld, Int# #)
+   with
+   out_of_line = True
+   has_side_effects = True
 
 ------------------------------------------------------------------------
 section "STM-accessible Mutable Variables"
 
 ------------------------------------------------------------------------
 section "STM-accessible Mutable Variables"
@@ -1327,6 +1323,7 @@ primop    NewTVarOp "newTVar#" GenPrimOp
    {Create a new {\tt TVar\#} holding a specified initial value.}
    with
    out_of_line  = True
    {Create a new {\tt TVar\#} holding a specified initial value.}
    with
    out_of_line  = True
+   has_side_effects = True
 
 primop ReadTVarOp "readTVar#" GenPrimOp
        TVar# s a
 
 primop ReadTVarOp "readTVar#" GenPrimOp
        TVar# s a
@@ -1334,6 +1331,15 @@ primop   ReadTVarOp "readTVar#" GenPrimOp
    {Read contents of {\tt TVar\#}.  Result is not yet evaluated.}
    with
    out_of_line = True
    {Read contents of {\tt TVar\#}.  Result is not yet evaluated.}
    with
    out_of_line = True
+   has_side_effects = True
+
+primop ReadTVarIOOp "readTVarIO#" GenPrimOp
+       TVar# s a
+    -> State# s -> (# State# s, a #)
+   {Read contents of {\tt TVar\#} outside an STM transaction}
+   with
+   out_of_line = True
+   has_side_effects = True
 
 primop WriteTVarOp "writeTVar#" GenPrimOp
        TVar# s a
 
 primop WriteTVarOp "writeTVar#" GenPrimOp
        TVar# s a
@@ -1362,56 +1368,50 @@ primop  NewMVarOp "newMVar#"  GenPrimOp
    State# s -> (# State# s, MVar# s a #)
    {Create new {\tt MVar\#}; initially empty.}
    with
    State# s -> (# State# s, MVar# s a #)
    {Create new {\tt MVar\#}; initially empty.}
    with
-   usage       = { mangle NewMVarOp [mkP] mkR }
    out_of_line = True
    out_of_line = True
+   has_side_effects = True
 
 primop  TakeMVarOp "takeMVar#" GenPrimOp
    MVar# s a -> State# s -> (# State# s, a #)
    {If {\tt MVar\#} is empty, block until it becomes full.
    Then remove and return its contents, and set it empty.}
    with
 
 primop  TakeMVarOp "takeMVar#" GenPrimOp
    MVar# s a -> State# s -> (# State# s, a #)
    {If {\tt MVar\#} is empty, block until it becomes full.
    Then remove and return its contents, and set it empty.}
    with
-   usage            = { mangle TakeMVarOp [mkM, mkP] mkM }
-   has_side_effects = True
    out_of_line      = True
    out_of_line      = True
+   has_side_effects = True
 
 primop  TryTakeMVarOp "tryTakeMVar#" GenPrimOp
    MVar# s a -> State# s -> (# State# s, Int#, a #)
    {If {\tt MVar\#} is empty, immediately return with integer 0 and value undefined.
    Otherwise, return with integer 1 and contents of {\tt MVar\#}, and set {\tt MVar\#} empty.}
    with
 
 primop  TryTakeMVarOp "tryTakeMVar#" GenPrimOp
    MVar# s a -> State# s -> (# State# s, Int#, a #)
    {If {\tt MVar\#} is empty, immediately return with integer 0 and value undefined.
    Otherwise, return with integer 1 and contents of {\tt MVar\#}, and set {\tt MVar\#} empty.}
    with
-   usage            = { mangle TryTakeMVarOp [mkM, mkP] mkM }
-   has_side_effects = True
    out_of_line      = True
    out_of_line      = True
+   has_side_effects = True
 
 primop  PutMVarOp "putMVar#" GenPrimOp
    MVar# s a -> a -> State# s -> State# s
    {If {\tt MVar\#} is full, block until it becomes empty.
    Then store value arg as its new contents.}
    with
 
 primop  PutMVarOp "putMVar#" GenPrimOp
    MVar# s a -> a -> State# s -> State# s
    {If {\tt MVar\#} is full, block until it becomes empty.
    Then store value arg as its new contents.}
    with
-   usage            = { mangle PutMVarOp [mkM, mkM, mkP] mkR }
-   has_side_effects = True
    out_of_line      = True
    out_of_line      = True
+   has_side_effects = True
 
 primop  TryPutMVarOp "tryPutMVar#" GenPrimOp
    MVar# s a -> a -> State# s -> (# State# s, Int# #)
    {If {\tt MVar\#} is full, immediately return with integer 0.
     Otherwise, store value arg as {\tt MVar\#}'s new contents, and return with integer 1.}
    with
 
 primop  TryPutMVarOp "tryPutMVar#" GenPrimOp
    MVar# s a -> a -> State# s -> (# State# s, Int# #)
    {If {\tt MVar\#} is full, immediately return with integer 0.
     Otherwise, store value arg as {\tt MVar\#}'s new contents, and return with integer 1.}
    with
-   usage            = { mangle TryPutMVarOp [mkM, mkM, mkP] mkR }
-   has_side_effects = True
    out_of_line      = True
    out_of_line      = True
+   has_side_effects = True
 
 primop  SameMVarOp "sameMVar#" GenPrimOp
    MVar# s a -> MVar# s a -> Bool
 
 primop  SameMVarOp "sameMVar#" GenPrimOp
    MVar# s a -> MVar# s a -> Bool
-   with
-   usage = { mangle SameMVarOp [mkP, mkP] mkM }
 
 primop  IsEmptyMVarOp "isEmptyMVar#" GenPrimOp
    MVar# s a -> State# s -> (# State# s, Int# #)
    {Return 1 if {\tt MVar\#} is empty; 0 otherwise.}
    with
 
 primop  IsEmptyMVarOp "isEmptyMVar#" GenPrimOp
    MVar# s a -> State# s -> (# State# s, Int# #)
    {Return 1 if {\tt MVar\#} is empty; 0 otherwise.}
    with
-   usage = { mangle IsEmptyMVarOp [mkP, mkP] mkM }
    out_of_line = True
    out_of_line = True
+   has_side_effects = True
 
 ------------------------------------------------------------------------
 section "Delay/wait operations"
 
 ------------------------------------------------------------------------
 section "Delay/wait operations"
@@ -1421,7 +1421,6 @@ primop  DelayOp "delay#" GenPrimOp
    Int# -> State# s -> State# s
    {Sleep specified number of microseconds.}
    with
    Int# -> State# s -> State# s
    {Sleep specified number of microseconds.}
    with
-   needs_wrapper    = True
    has_side_effects = True
    out_of_line      = True
 
    has_side_effects = True
    out_of_line      = True
 
@@ -1429,7 +1428,6 @@ primop  WaitReadOp "waitRead#" GenPrimOp
    Int# -> State# s -> State# s
    {Block until input is available on specified file descriptor.}
    with
    Int# -> State# s -> State# s
    {Block until input is available on specified file descriptor.}
    with
-   needs_wrapper    = True
    has_side_effects = True
    out_of_line      = True
 
    has_side_effects = True
    out_of_line      = True
 
@@ -1437,7 +1435,6 @@ primop  WaitWriteOp "waitWrite#" GenPrimOp
    Int# -> State# s -> State# s
    {Block until output is possible on specified file descriptor.}
    with
    Int# -> State# s -> State# s
    {Block until output is possible on specified file descriptor.}
    with
-   needs_wrapper    = True
    has_side_effects = True
    out_of_line      = True
 
    has_side_effects = True
    out_of_line      = True
 
@@ -1446,7 +1443,6 @@ primop  AsyncReadOp "asyncRead#" GenPrimOp
    Int# -> Int# -> Int# -> Addr# -> State# RealWorld-> (# State# RealWorld, Int#, Int# #)
    {Asynchronously read bytes from specified file descriptor.}
    with
    Int# -> Int# -> Int# -> Addr# -> State# RealWorld-> (# State# RealWorld, Int#, Int# #)
    {Asynchronously read bytes from specified file descriptor.}
    with
-   needs_wrapper    = True
    has_side_effects = True
    out_of_line      = True
 
    has_side_effects = True
    out_of_line      = True
 
@@ -1454,7 +1450,6 @@ primop  AsyncWriteOp "asyncWrite#" GenPrimOp
    Int# -> Int# -> Int# -> Addr# -> State# RealWorld-> (# State# RealWorld, Int#, Int# #)
    {Asynchronously write bytes from specified file descriptor.}
    with
    Int# -> Int# -> Int# -> Addr# -> State# RealWorld-> (# State# RealWorld, Int#, Int# #)
    {Asynchronously write bytes from specified file descriptor.}
    with
-   needs_wrapper    = True
    has_side_effects = True
    out_of_line      = True
 
    has_side_effects = True
    out_of_line      = True
 
@@ -1462,7 +1457,6 @@ primop  AsyncDoProcOp "asyncDoProc#" GenPrimOp
    Addr# -> Addr# -> State# RealWorld-> (# State# RealWorld, Int#, Int# #)
    {Asynchronously perform procedure (first arg), passing it 2nd arg.}
    with
    Addr# -> Addr# -> State# RealWorld-> (# State# RealWorld, Int#, Int# #)
    {Asynchronously perform procedure (first arg), passing it 2nd arg.}
    with
-   needs_wrapper    = True
    has_side_effects = True
    out_of_line      = True
 
    has_side_effects = True
    out_of_line      = True
 
@@ -1473,7 +1467,7 @@ section "Concurrency primitives"
 ------------------------------------------------------------------------
 
 primtype State# s
 ------------------------------------------------------------------------
 
 primtype State# s
-       { {\tt State#} is the primitive, unlifted type of states.  It has
+       { {\tt State\#} is the primitive, unlifted type of states.  It has
        one type parameter, thus {\tt State\# RealWorld}, or {\tt State\# s},
        where s is a type variable. The only purpose of the type parameter
        is to keep different state threads separate.  It is represented by
        one type parameter, thus {\tt State\# RealWorld}, or {\tt State\# s},
        where s is a type variable. The only purpose of the type parameter
        is to keep different state threads separate.  It is represented by
@@ -1482,7 +1476,7 @@ primtype State# s
 primtype RealWorld
        { {\tt RealWorld} is deeply magical.  It is {\it primitive}, but it is not
        {\it unlifted} (hence {\tt ptrArg}).  We never manipulate values of type
 primtype RealWorld
        { {\tt RealWorld} is deeply magical.  It is {\it primitive}, but it is not
        {\it unlifted} (hence {\tt ptrArg}).  We never manipulate values of type
-       {\tt RealWorld}; it's only used in the type system, to parameterise {\tt State#}. }
+       {\tt RealWorld}; it's only used in the type system, to parameterise {\tt State\#}. }
 
 primtype ThreadId#
        {(In a non-concurrent implementation, this can be a singleton
 
 primtype ThreadId#
        {(In a non-concurrent implementation, this can be a singleton
@@ -1492,21 +1486,18 @@ primtype ThreadId#
 primop  ForkOp "fork#" GenPrimOp
    a -> State# RealWorld -> (# State# RealWorld, ThreadId# #)
    with
 primop  ForkOp "fork#" GenPrimOp
    a -> State# RealWorld -> (# State# RealWorld, ThreadId# #)
    with
-   usage            = { mangle ForkOp [mkO, mkP] mkR }
    has_side_effects = True
    out_of_line      = True
 
 primop  ForkOnOp "forkOn#" GenPrimOp
    Int# -> a -> State# RealWorld -> (# State# RealWorld, ThreadId# #)
    with
    has_side_effects = True
    out_of_line      = True
 
 primop  ForkOnOp "forkOn#" GenPrimOp
    Int# -> a -> State# RealWorld -> (# State# RealWorld, ThreadId# #)
    with
-   usage            = { mangle ForkOnOp [mkO, mkP] mkR }
    has_side_effects = True
    out_of_line      = True
 
 primop  KillThreadOp "killThread#"  GenPrimOp
    ThreadId# -> a -> State# RealWorld -> State# RealWorld
    with
    has_side_effects = True
    out_of_line      = True
 
 primop  KillThreadOp "killThread#"  GenPrimOp
    ThreadId# -> a -> State# RealWorld -> State# RealWorld
    with
-   usage            = { mangle KillThreadOp [mkP, mkM, mkP] mkR }
    has_side_effects = True
    out_of_line      = True
 
    has_side_effects = True
    out_of_line      = True
 
@@ -1520,6 +1511,7 @@ primop  MyThreadIdOp "myThreadId#" GenPrimOp
    State# RealWorld -> (# State# RealWorld, ThreadId# #)
    with
    out_of_line = True
    State# RealWorld -> (# State# RealWorld, ThreadId# #)
    with
    out_of_line = True
+   has_side_effects = True
 
 primop LabelThreadOp "labelThread#" GenPrimOp
    ThreadId# -> Addr# -> State# RealWorld -> State# RealWorld
 
 primop LabelThreadOp "labelThread#" GenPrimOp
    ThreadId# -> Addr# -> State# RealWorld -> State# RealWorld
@@ -1531,6 +1523,19 @@ primop  IsCurrentThreadBoundOp "isCurrentThreadBound#" GenPrimOp
    State# RealWorld -> (# State# RealWorld, Int# #)
    with
    out_of_line = True
    State# RealWorld -> (# State# RealWorld, Int# #)
    with
    out_of_line = True
+   has_side_effects = True
+
+primop  NoDuplicateOp "noDuplicate#" GenPrimOp
+   State# RealWorld -> State# RealWorld
+   with
+   out_of_line = True
+   has_side_effects = True
+
+primop  ThreadStatusOp "threadStatus#" GenPrimOp
+   ThreadId# -> State# RealWorld -> (# State# RealWorld, Int#, Int#, Int# #)
+   with
+   out_of_line = True
+   has_side_effects = True
 
 ------------------------------------------------------------------------
 section "Weak pointers"
 
 ------------------------------------------------------------------------
 section "Weak pointers"
@@ -1543,14 +1548,18 @@ primtype Weak# b
 primop  MkWeakOp "mkWeak#" GenPrimOp
    o -> b -> c -> State# RealWorld -> (# State# RealWorld, Weak# b #)
    with
 primop  MkWeakOp "mkWeak#" GenPrimOp
    o -> b -> c -> State# RealWorld -> (# State# RealWorld, Weak# b #)
    with
-   usage            = { mangle MkWeakOp [mkZ, mkM, mkM, mkP] mkM }
+   has_side_effects = True
+   out_of_line      = True
+
+primop  MkWeakForeignEnvOp "mkWeakForeignEnv#" GenPrimOp
+   o -> b -> Addr# -> Addr# -> Int# -> Addr# -> State# RealWorld -> (# State# RealWorld, Weak# b #)
+   with
    has_side_effects = True
    out_of_line      = True
 
 primop  DeRefWeakOp "deRefWeak#" GenPrimOp
    Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #)
    with
    has_side_effects = True
    out_of_line      = True
 
 primop  DeRefWeakOp "deRefWeak#" GenPrimOp
    Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #)
    with
-   usage            = { mangle DeRefWeakOp [mkM, mkP] mkM }
    has_side_effects = True
    out_of_line      = True
 
    has_side_effects = True
    out_of_line      = True
 
@@ -1558,15 +1567,13 @@ primop  FinalizeWeakOp "finalizeWeak#" GenPrimOp
    Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, 
               (State# RealWorld -> (# State# RealWorld, () #)) #)
    with
    Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, 
               (State# RealWorld -> (# State# RealWorld, () #)) #)
    with
-   usage            = { mangle FinalizeWeakOp [mkM, mkP] 
-                               (mkR . (inUB FinalizeWeakOp 
-                                            [id,id,inFun FinalizeWeakOp mkR mkM])) }
    has_side_effects = True
    out_of_line      = True
 
 primop TouchOp "touch#" GenPrimOp
    o -> State# RealWorld -> State# RealWorld
    with
    has_side_effects = True
    out_of_line      = True
 
 primop TouchOp "touch#" GenPrimOp
    o -> State# RealWorld -> State# RealWorld
    with
+   code_size = { 0 }
    has_side_effects = True
 
 ------------------------------------------------------------------------
    has_side_effects = True
 
 ------------------------------------------------------------------------
@@ -1580,41 +1587,31 @@ primtype StableName# a
 primop  MakeStablePtrOp "makeStablePtr#" GenPrimOp
    a -> State# RealWorld -> (# State# RealWorld, StablePtr# a #)
    with
 primop  MakeStablePtrOp "makeStablePtr#" GenPrimOp
    a -> State# RealWorld -> (# State# RealWorld, StablePtr# a #)
    with
-   usage            = { mangle MakeStablePtrOp [mkM, mkP] mkM }
    has_side_effects = True
    out_of_line      = True
 
 primop  DeRefStablePtrOp "deRefStablePtr#" GenPrimOp
    StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #)
    with
    has_side_effects = True
    out_of_line      = True
 
 primop  DeRefStablePtrOp "deRefStablePtr#" GenPrimOp
    StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #)
    with
-   usage            = { mangle DeRefStablePtrOp [mkM, mkP] mkM }
-   needs_wrapper    = True
    has_side_effects = True
    out_of_line      = True
 
 primop  EqStablePtrOp "eqStablePtr#" GenPrimOp
    StablePtr# a -> StablePtr# a -> Int#
    with
    has_side_effects = True
    out_of_line      = True
 
 primop  EqStablePtrOp "eqStablePtr#" GenPrimOp
    StablePtr# a -> StablePtr# a -> Int#
    with
-   usage            = { mangle EqStablePtrOp [mkP, mkP] mkR }
    has_side_effects = True
 
 primop  MakeStableNameOp "makeStableName#" GenPrimOp
    a -> State# RealWorld -> (# State# RealWorld, StableName# a #)
    with
    has_side_effects = True
 
 primop  MakeStableNameOp "makeStableName#" GenPrimOp
    a -> State# RealWorld -> (# State# RealWorld, StableName# a #)
    with
-   usage            = { mangle MakeStableNameOp [mkZ, mkP] mkR }
-   needs_wrapper    = True
    has_side_effects = True
    out_of_line      = True
 
 primop  EqStableNameOp "eqStableName#" GenPrimOp
    StableName# a -> StableName# a -> Int#
    has_side_effects = True
    out_of_line      = True
 
 primop  EqStableNameOp "eqStableName#" GenPrimOp
    StableName# a -> StableName# a -> Int#
-   with
-   usage = { mangle EqStableNameOp [mkP, mkP] mkR }
 
 primop  StableNameToIntOp "stableNameToInt#" GenPrimOp
    StableName# a -> Int#
 
 primop  StableNameToIntOp "stableNameToInt#" GenPrimOp
    StableName# a -> Int#
-   with
-   usage = { mangle StableNameToIntOp [mkP] mkR }
 
 ------------------------------------------------------------------------
 section "Unsafe pointer equality"
 
 ------------------------------------------------------------------------
 section "Unsafe pointer equality"
@@ -1623,8 +1620,6 @@ section "Unsafe pointer equality"
 
 primop  ReallyUnsafePtrEqualityOp "reallyUnsafePtrEquality#" GenPrimOp
    a -> a -> Int#
 
 primop  ReallyUnsafePtrEqualityOp "reallyUnsafePtrEquality#" GenPrimOp
    a -> a -> Int#
-   with
-   usage = { mangle ReallyUnsafePtrEqualityOp [mkZ, mkZ] mkR }
 
 ------------------------------------------------------------------------
 section "Parallelism"
 
 ------------------------------------------------------------------------
 section "Parallelism"
@@ -1633,10 +1628,23 @@ section "Parallelism"
 primop  ParOp "par#" GenPrimOp
    a -> Int#
    with
 primop  ParOp "par#" GenPrimOp
    a -> Int#
    with
-   usage            = { mangle ParOp [mkO] mkR }
       -- Note that Par is lazy to avoid that the sparked thing
       -- gets evaluted strictly, which it should *not* be
    has_side_effects = True
       -- Note that Par is lazy to avoid that the sparked thing
       -- gets evaluted strictly, which it should *not* be
    has_side_effects = True
+   code_size = { primOpCodeSizeForeignCall }
+
+primop GetSparkOp "getSpark#" GenPrimOp
+   State# s -> (# State# s, Int#, a #)
+   with
+   has_side_effects = True
+   out_of_line = True
+
+primop NumSparks "numSparks#" GenPrimOp
+   State# s -> (# State# s, Int# #)
+   { Returns the number of sparks in the local spark pool. }
+   with
+   has_side_effects = True
+   out_of_line = True
 
 -- HWL: The first 4 Int# in all par... annotations denote:
 --   name, granularity info, size of result, degree of parallelism
 
 -- HWL: The first 4 Int# in all par... annotations denote:
 --   name, granularity info, size of result, degree of parallelism
@@ -1647,37 +1655,31 @@ primop  ParOp "par#" GenPrimOp
 primop  ParGlobalOp  "parGlobal#"  GenPrimOp
    a -> Int# -> Int# -> Int# -> Int# -> b -> Int#
    with
 primop  ParGlobalOp  "parGlobal#"  GenPrimOp
    a -> Int# -> Int# -> Int# -> Int# -> b -> Int#
    with
-   usage            = { mangle ParGlobalOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
    has_side_effects = True
 
 primop  ParLocalOp  "parLocal#"  GenPrimOp
    a -> Int# -> Int# -> Int# -> Int# -> b -> Int#
    with
    has_side_effects = True
 
 primop  ParLocalOp  "parLocal#"  GenPrimOp
    a -> Int# -> Int# -> Int# -> Int# -> b -> Int#
    with
-   usage            = { mangle ParLocalOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
    has_side_effects = True
 
 primop  ParAtOp  "parAt#"  GenPrimOp
    b -> a -> Int# -> Int# -> Int# -> Int# -> c -> Int#
    with
    has_side_effects = True
 
 primop  ParAtOp  "parAt#"  GenPrimOp
    b -> a -> Int# -> Int# -> Int# -> Int# -> c -> Int#
    with
-   usage            = { mangle ParAtOp [mkO, mkZ, mkP, mkP, mkP, mkP, mkM] mkM }
    has_side_effects = True
 
 primop  ParAtAbsOp  "parAtAbs#"  GenPrimOp
    a -> Int# -> Int# -> Int# -> Int# -> Int# -> b -> Int#
    with
    has_side_effects = True
 
 primop  ParAtAbsOp  "parAtAbs#"  GenPrimOp
    a -> Int# -> Int# -> Int# -> Int# -> Int# -> b -> Int#
    with
-   usage            = { mangle ParAtAbsOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
    has_side_effects = True
 
 primop  ParAtRelOp  "parAtRel#" GenPrimOp
    a -> Int# -> Int# -> Int# -> Int# -> Int# -> b -> Int#
    with
    has_side_effects = True
 
 primop  ParAtRelOp  "parAtRel#" GenPrimOp
    a -> Int# -> Int# -> Int# -> Int# -> Int# -> b -> Int#
    with
-   usage            = { mangle ParAtRelOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
    has_side_effects = True
 
 primop  ParAtForNowOp  "parAtForNow#" GenPrimOp
    b -> a -> Int# -> Int# -> Int# -> Int# -> c -> Int#
    with
    has_side_effects = True
 
 primop  ParAtForNowOp  "parAtForNow#" GenPrimOp
    b -> a -> Int# -> Int# -> Int# -> Int# -> c -> Int#
    with
-   usage            = { mangle ParAtForNowOp [mkO, mkZ, mkP, mkP, mkP, mkP, mkM] mkM }
    has_side_effects = True
 
 -- copyable# and noFollow# are yet to be implemented (for GpH)
    has_side_effects = True
 
 -- copyable# and noFollow# are yet to be implemented (for GpH)
@@ -1685,13 +1687,11 @@ primop  ParAtForNowOp  "parAtForNow#" GenPrimOp
 --primop  CopyableOp  "copyable#" GenPrimOp
 --   a -> Int#
 --   with
 --primop  CopyableOp  "copyable#" GenPrimOp
 --   a -> Int#
 --   with
---   usage            = { mangle CopyableOp [mkZ] mkR }
 --   has_side_effects = True
 --
 --primop  NoFollowOp "noFollow#" GenPrimOp
 --   a -> Int#
 --   with
 --   has_side_effects = True
 --
 --primop  NoFollowOp "noFollow#" GenPrimOp
 --   a -> Int#
 --   with
---   usage            = { mangle NoFollowOp [mkZ] mkR }
 --   has_side_effects = True
 
 
 --   has_side_effects = True
 
 
@@ -1704,7 +1704,7 @@ section "Tag to enum stuff"
 primop  DataToTagOp "dataToTag#" GenPrimOp
    a -> Int#
    with
 primop  DataToTagOp "dataToTag#" GenPrimOp
    a -> Int#
    with
-   strictness  = { \ arity -> mkStrictSig (mkTopDmdType [seqDmd] TopRes) }
+   strictness  = { \ _arity -> mkStrictSig (mkTopDmdType [seqDmd] TopRes) }
        -- dataToTag# must have an evaluated argument
 
 primop  TagToEnumOp "tagToEnum#" GenPrimOp     
        -- dataToTag# must have an evaluated argument
 
 primop  TagToEnumOp "tagToEnum#" GenPrimOp     
@@ -1721,6 +1721,8 @@ primtype BCO#
 primop   AddrToHValueOp "addrToHValue#" GenPrimOp
    Addr# -> (# a #)
    {Convert an {\tt Addr\#} to a followable type.}
 primop   AddrToHValueOp "addrToHValue#" GenPrimOp
    Addr# -> (# a #)
    {Convert an {\tt Addr\#} to a followable type.}
+   with
+   code_size = 0
 
 primop   MkApUpd0_Op "mkApUpd0#" GenPrimOp
    BCO# -> (# a #)
 
 primop   MkApUpd0_Op "mkApUpd0#" GenPrimOp
    BCO# -> (# a #)
@@ -1728,21 +1730,31 @@ primop   MkApUpd0_Op "mkApUpd0#" GenPrimOp
    out_of_line = True
 
 primop  NewBCOOp "newBCO#" GenPrimOp
    out_of_line = True
 
 primop  NewBCOOp "newBCO#" GenPrimOp
-   ByteArr# -> ByteArr# -> Array# a -> Int# -> ByteArr# -> State# s -> (# State# s, BCO# #)
+   ByteArray# -> ByteArray# -> Array# a -> Int# -> ByteArray# -> State# s -> (# State# s, BCO# #)
    with
    has_side_effects = True
    out_of_line      = True
 
    with
    has_side_effects = True
    out_of_line      = True
 
-primop  InfoPtrOp "infoPtr#" GenPrimOp
-   a -> Addr#
+primop  UnpackClosureOp "unpackClosure#" GenPrimOp
+   a -> (# Addr#, Array# b, ByteArray# #)
    with
    out_of_line = True
 
    with
    out_of_line = True
 
-primop  ClosurePayloadOp "closurePayload#" GenPrimOp
-   a -> (# Array# b, ByteArr# #)
+primop  GetApStackValOp "getApStackVal#" GenPrimOp
+   a -> Int# -> (# Int#, b #)
    with
    out_of_line = True
 
    with
    out_of_line = True
 
+------------------------------------------------------------------------
+section "Misc"
+        {These aren't nearly as wired in as Etc...}
+------------------------------------------------------------------------
+
+primop  TraceCcsOp "traceCcs#" GenPrimOp
+   a -> b -> b
+   with
+   has_side_effects = True
+   out_of_line = True
 
 ------------------------------------------------------------------------
 section "Etc" 
 
 ------------------------------------------------------------------------
 section "Etc" 
@@ -1756,11 +1768,11 @@ pseudoop   "seq"
 
 pseudoop   "inline"
    a -> a
 
 pseudoop   "inline"
    a -> a
-   { The call {\tt(inline f)} arranges that f is inlined, regardless of its size.
-       More precisely, the call {\tt(inline f)} rewrites to the right-hand side of
+   { The call {\tt (inline f)} arranges that f is inlined, regardless of its size.
+       More precisely, the call {\tt (inline f)} rewrites to the right-hand side of
        {\tt f}'s definition. This allows the programmer to control inlining from a
        particular call site rather than the definition site of the function (c.f.
        {\tt f}'s definition. This allows the programmer to control inlining from a
        particular call site rather than the definition site of the function (c.f.
-       {\ttINLINE} pragmas in User's Guide, Section 7.10.3, "INLINE and NOINLINE
+       {\tt INLINE} pragmas in User's Guide, Section 7.10.3, "INLINE and NOINLINE
        pragmas").
 
        This inlining occurs regardless of the argument to the call or the size of
        pragmas").
 
        This inlining occurs regardless of the argument to the call or the size of
@@ -1770,11 +1782,9 @@ pseudoop   "inline"
        {\tt inline} function expands to the identity function in Phase zero; so its
        use imposes no overhead.
 
        {\tt inline} function expands to the identity function in Phase zero; so its
        use imposes no overhead.
 
-       If the function is defined in another module, GHC only exposes its inlining
-       in the interface file if the function is sufficiently small that it might be
-       inlined by the automatic mechanism. There is currently no way to tell GHC to
-       expose arbitrarily-large functions in the interface file. (This shortcoming
-       is something that could be fixed, with some kind of pragma.) }
+       It is good practice to mark the function with an INLINABLE pragma at
+        its definition, (a) so that GHC guarantees to expose its unfolding regardless
+        of size, and (b) so that you have control over exactly what is inlined. }
 
 pseudoop   "lazy"
    a -> a
 
 pseudoop   "lazy"
    a -> a
@@ -1787,8 +1797,9 @@ pseudoop   "lazy"
        This behaviour is occasionally useful when controlling evaluation order.
        Notably, {\tt lazy} is used in the library definition of {\tt Control.Parallel.par}:
 
        This behaviour is occasionally useful when controlling evaluation order.
        Notably, {\tt lazy} is used in the library definition of {\tt Control.Parallel.par}:
 
-       >    par :: a -> b -> b
-       >    par x y = case (par# x) of { _ -> lazy y }
+       {\tt par :: a -> b -> b}
+
+       {\tt par x y = case (par\# x) of \_ -> lazy y}
 
        If {\tt lazy} were not lazy, {\tt par} would look strict in {\tt y} which
        would defeat the whole purpose of {\tt par}.
 
        If {\tt lazy} were not lazy, {\tt par} would look strict in {\tt y} which
        would defeat the whole purpose of {\tt par}.
@@ -1806,9 +1817,19 @@ primtype Any a
            but never enters a function value.  
 
        It's also used to instantiate un-constrained type variables after type
            but never enters a function value.  
 
        It's also used to instantiate un-constrained type variables after type
-       checking.  For example
+       checking.  For example, {\tt length} has type
+
+       {\tt length :: forall a. [a] -> Int}
+
+       and the list datacon for the empty list has type
+
+       {\tt [] :: forall a. [a]}
 
 
-       >       length Any []
+       In order to compose these two terms as {\tt length []} a type
+       application is required, but there is no constraint on the
+       choice.  In this situation GHC uses {\tt Any}:
+
+       {\tt length Any ([] Any)}
 
        Annoyingly, we sometimes need {\tt Any}s of other kinds, such as {\tt (* -> *)} etc.
        This is a bit like tuples.   We define a couple of useful ones here,
 
        Annoyingly, we sometimes need {\tt Any}s of other kinds, such as {\tt (* -> *)} etc.
        This is a bit like tuples.   We define a couple of useful ones here,
@@ -1824,9 +1845,49 @@ pseudoop   "unsafeCoerce#"
        used when you want to write a program that you know is well-typed, but where Haskell's
        type system is not expressive enough to prove that it is well typed.
 
        used when you want to write a program that you know is well-typed, but where Haskell's
        type system is not expressive enough to prove that it is well typed.
 
-       The argument to {\tt unsafeCoerce\#} can have unboxed types, although extremely bad
-       things will happen if you coerce a boxed type to an unboxed type.  }
+        The following uses of {\tt unsafeCoerce\#} are supposed to work (i.e. not lead to
+        spurious compile-time or run-time crashes):
+
+         * Casting any lifted type to {\tt Any}
+
+         * Casting {\tt Any} back to the real type
 
 
+         * Casting an unboxed type to another unboxed type of the same size
+           (but not coercions between floating-point and integral types)
+
+         * Casting between two types that have the same runtime representation.  One case is when
+           the two types differ only in "phantom" type parameters, for example
+           {\tt Ptr Int} to {\tt Ptr Float}, or {\tt [Int]} to {\tt [Float]} when the list is 
+           known to be empty.  Also, a {\tt newtype} of a type {\tt T} has the same representation
+           at runtime as {\tt T}.
+
+        Other uses of {\tt unsafeCoerce\#} are undefined.  In particular, you should not use
+       {\tt unsafeCoerce\#} to cast a T to an algebraic data type D, unless T is also
+       an algebraic data type.  For example, do not cast {\tt Int->Int} to {\tt Bool}, even if
+        you later cast that {\tt Bool} back to {\tt Int->Int} before applying it.  The reasons
+        have to do with GHC's internal representation details (for the congnoscenti, data values
+       can be entered but function closures cannot).  If you want a safe type to cast things
+       to, use {\tt Any}, which is not an algebraic data type.
+       
+        }
+
+-- NB. It is tempting to think that casting a value to a type that it doesn't have is safe
+-- as long as you don't "do anything" with the value in its cast form, such as seq on it.  This
+-- isn't the case: the compiler can insert seqs itself, and if these happen at the wrong type,
+-- Bad Things Might Happen.  See bug #1616: in this case we cast a function of type (a,b) -> (a,b)
+-- to () -> () and back again.  The strictness analyser saw that the function was strict, but
+-- the wrapper had type () -> (), and hence the wrapper de-constructed the (), the worker re-constructed
+-- a new (), with the result that the code ended up with "case () of (a,b) -> ...".
+
+primop  TraceEventOp "traceEvent#" GenPrimOp
+   Addr# -> State# s -> State# s
+   { Emits an event via the RTS tracing framework.  The contents
+     of the event is the zero-terminated byte string passed as the first
+     argument.  The event will be emitted either to the .eventlog file,
+     or to stderr, depending on the runtime RTS flags. }
+   with
+   has_side_effects = True
+   out_of_line      = True
 
 ------------------------------------------------------------------------
 ---                                                                  ---
 
 ------------------------------------------------------------------------
 ---                                                                  ---