Skip to content
  • Simon Peyton Jones's avatar
    [project @ 2005-10-27 14:35:20 by simonpj] · 958924a2
    Simon Peyton Jones authored
    Add a new pragma: SPECIALISE INLINE
    
    This amounts to adding an INLINE pragma to the specialised version
    of the function.  You can add phase stuff too (SPECIALISE INLINE [2]),
    and NOINLINE instead of INLINE.
    
    The reason for doing this is to support inlining of type-directed
    recursive functions.  The main example is this:
    
      -- non-uniform array type
      data Arr e where
        ArrInt  :: !Int -> ByteArray#       -> Arr Int
        ArrPair :: !Int -> Arr e1 -> Arr e2 -> Arr (e1, e2)
    
      (!:) :: Arr e -> Int -> e
      {-# SPECIALISE INLINE (!:) :: Arr Int -> Int -> Int #-}
      {-# SPECIALISE INLINE (!:) :: Arr (a, b) -> Int -> (a, b) #-}
      ArrInt  _ ba    !: (I# i) = I# (indexIntArray# ba i)
      ArrPair _ a1 a2 !: i      = (a1 !: i, a2 !: i)
    
    If we use (!:) at a particular array type, we want to inline (:!),
    which is recursive, until all the type specialisation is done.
    
    
    On the way I did a bit of renaming and tidying of the way that
    pragmas are carried, so quite a lot of files are touched in a
    fairly trivial way.
    958924a2