Changes between Version 2 and Version 3 of DataParallel/ClosureConversion/Indexed


Ignore:
Timestamp:
Apr 17, 2007 12:17:06 PM (7 years ago)
Author:
guest
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DataParallel/ClosureConversion/Indexed

    v2 v3  
    7070inc :: Num (CConv a) => CConv (a -> a) 
    7171}}} 
    72 As closure conversion happens on Core code, we need to be careful, as the context is not visible as such in the ''core view'' of types. 
     72As closure conversion happens on Core code, we need to be careful, as the context is not visible as such in the ''core view'' of types.  (An alternative view point is that as closure conversion happens on Core, we don't want to treat dictionaries specially.  However, interface files contain the ''source view''  of a signature, so we need to deal with closure conversion of contexts in some way, independent of whether we use associated types...unless we manage to keep closure conversion entirely out of interface files.) 
     73 
     74=== Contexts: 2. implicit `CC` contexts === 
     75 
     76Our main problem right now is the following.  If we have  
     77{{{ 
     78foo :: tau 
     79foo = e 
     80}}} 
     81we want to generate 
     82{{{ 
     83foo = fr fooCC 
     84 
     85fooCC :: CConv tau 
     86fooCC = <convert> [[e]] 
     87}}} 
     88 
     89Unfortunately, this is not type correct if `tau` contains type variables; e.g., 
     90{{{ 
     91id :: a -> a 
     92id = \x -> x 
     93}}} 
     94generates 
     95{{{ 
     96id = fr idCC 
     97 
     98idCC :: CConv (a -> a) 
     99idCC = ... 
     100}}} 
     101as we now have `id :: CC a => a -> a`. 
     102 
     103=== Additional notes === 
     104 
     105When we closure convert a module `B`, importing functions from a module `A`, we may be able to completely ignore whether `B` was closure converted itself (that would simplify matters enormously!)  The idea is that if `B` wants to use a function `A.foo` in closure converted code, it simply uses `(to A.foo)`.  If `A` is closure converted, we will have `A.foo = fr A.fooCC`.  Now a simple rewrite rule can eliminate the back and forth conversion (after inlining): 
     106{{{ 
     107{-# RULES 
     108"to/fr" forall f. to (fr f) = f 
     109 #-} 
     110}}} 
     111 
     112We still have to now whether a client module was closure converted to optimise the treatment of data constructors.  Otherwise, we would have to apply `fr` to every scrutinee of a case expression (and `to` to all variables bound in a case branch).