Vectorise.hs 14.8 KB
Newer Older
1
{-# OPTIONS -w #-}
2
3
4
-- The above warning supression flag is a temporary kludge.
-- While working on this module you are encouraged to remove it and fix
-- any warnings in the module. See
Ian Lynagh's avatar
Ian Lynagh committed
5
--     http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
6
7
-- for details

8
9
10
module Vectorise( vectorise )
where

11
import VectMonad
12
import VectUtils
13
import VectType
14
import VectCore
15

16
17
18
import DynFlags
import HscTypes

rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
19
import CoreLint             ( showPass, endPass )
20
import CoreSyn
21
22
import CoreUtils
import CoreFVs
23
24
import SimplMonad           ( SimplCount, zeroSimplCount )
import Rules                ( RuleBase )
25
import DataCon
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
26
import TyCon
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
27
import Type
28
29
import FamInstEnv           ( extendFamInstEnvList )
import InstEnv              ( extendInstEnvList )
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
30
31
import Var
import VarEnv
32
import VarSet
33
import Name                 ( Name, mkSysTvName, getName )
34
import NameEnv
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
35
import Id
36
import MkId                 ( unwrapFamInstScrut )
37
import OccName
38
import Module               ( Module )
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
39

rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
40
import DsMonad hiding (mapAndUnzipM)
41
import DsUtils              ( mkCoreTup, mkCoreTupTy )
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
42

43
import Literal              ( Literal, mkMachInt )
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
44
import PrelNames
45
import TysWiredIn
46
import TysPrim              ( intPrimTy )
47
import BasicTypes           ( Boxity(..) )
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
48

49
import Outputable
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
50
import FastString
51
import Control.Monad        ( liftM, liftM2, zipWithM, mapAndUnzipM )
52
import Data.List            ( sortBy, unzip4 )
53

54
55
56
vectorise :: HscEnv -> UniqSupply -> RuleBase -> ModGuts
          -> IO (SimplCount, ModGuts)
vectorise hsc_env _ _ guts
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
57
58
59
60
  = do
      showPass dflags "Vectorisation"
      eps <- hscEPS hsc_env
      let info = hptVectInfo hsc_env `plusVectInfo` eps_vect_info eps
61
      Just (info', guts') <- initV hsc_env guts info (vectModule guts)
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
62
      endPass dflags "Vectorisation" Opt_D_dump_vect (mg_binds guts')
63
      return (zeroSimplCount dflags, guts' { mg_vect_info = info' })
64
65
66
  where
    dflags = hsc_dflags hsc_env

rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
67
vectModule :: ModGuts -> VM ModGuts
68
69
vectModule guts
  = do
70
      (types', fam_insts, tc_binds) <- vectTypeEnv (mg_types guts)
Ian Lynagh's avatar
Ian Lynagh committed
71

72
73
      let fam_inst_env' = extendFamInstEnvList (mg_fam_inst_env guts) fam_insts
      updGEnv (setFamInstEnv fam_inst_env')
Ian Lynagh's avatar
Ian Lynagh committed
74

75
76
      -- dicts   <- mapM buildPADict pa_insts
      -- workers <- mapM vectDataConWorkers pa_insts
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
77
      binds'  <- mapM vectTopBind (mg_binds guts)
78
      return $ guts { mg_types        = types'
79
                    , mg_binds        = Rec tc_binds : binds'
80
81
82
                    , mg_fam_inst_env = fam_inst_env'
                    , mg_fam_insts    = mg_fam_insts guts ++ fam_insts
                    }
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
83

84
vectTopBind :: CoreBind -> VM CoreBind
85
86
87
vectTopBind b@(NonRec var expr)
  = do
      var'  <- vectTopBinder var
88
      expr' <- vectTopRhs var expr
89
      hs    <- takeHoisted
90
91
      cexpr <- tryConvert var var' expr
      return . Rec $ (var, cexpr) : (var', expr') : hs
92
93
94
95
96
97
  `orElseV`
    return b

vectTopBind b@(Rec bs)
  = do
      vars'  <- mapM vectTopBinder vars
98
      exprs' <- zipWithM vectTopRhs vars exprs
99
      hs     <- takeHoisted
100
101
      cexprs <- sequence $ zipWith3 tryConvert vars vars' exprs
      return . Rec $ zip vars cexprs ++ zip vars' exprs' ++ hs
102
103
104
105
106
107
108
109
  `orElseV`
    return b
  where
    (vars, exprs) = unzip bs

vectTopBinder :: Var -> VM Var
vectTopBinder var
  = do
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
110
111
      vty  <- vectType (idType var)
      var' <- cloneId mkVectOcc var vty
112
113
      defGlobalVar var var'
      return var'
Ian Lynagh's avatar
Ian Lynagh committed
114

115
116
vectTopRhs :: Var -> CoreExpr -> VM CoreExpr
vectTopRhs var expr
117
118
  = do
      closedV . liftM vectorised
119
              . inBind var
120
              $ vectPolyExpr (freeVars expr)
121

122
123
124
125
tryConvert :: Var -> Var -> CoreExpr -> VM CoreExpr
tryConvert var vect_var rhs
  = fromVect (idType var) (Var vect_var) `orElseV` return rhs

126
127
-- ----------------------------------------------------------------------------
-- Bindings
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
128

129
vectBndr :: Var -> VM VVar
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
130
131
132
vectBndr v
  = do
      vty <- vectType (idType v)
133
      lty <- mkPArrayType vty
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
134
135
136
137
138
      let vv = v `Id.setIdType` vty
          lv = v `Id.setIdType` lty
      updLEnv (mapTo vv lv)
      return (vv, lv)
  where
139
    mapTo vv lv env = env { local_vars = extendVarEnv (local_vars env) v (vv, lv) }
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
140

141
142
143
144
145
146
147
148
149
150
vectBndrNew :: Var -> FastString -> VM VVar
vectBndrNew v fs
  = do
      vty <- vectType (idType v)
      vv  <- newLocalVVar fs vty
      updLEnv (upd vv)
      return vv
  where
    upd vv env = env { local_vars = extendVarEnv (local_vars env) v vv }

151
vectBndrIn :: Var -> VM a -> VM (VVar, a)
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
152
153
154
vectBndrIn v p
  = localV
  $ do
155
      vv <- vectBndr v
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
156
      x <- p
157
      return (vv, x)
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
158

159
160
161
162
163
164
165
166
vectBndrNewIn :: Var -> FastString -> VM a -> VM (VVar, a)
vectBndrNewIn v fs p
  = localV
  $ do
      vv <- vectBndrNew v fs
      x  <- p
      return (vv, x)

167
168
169
170
171
172
173
174
vectBndrIn' :: Var -> (VVar -> VM a) -> VM (VVar, a)
vectBndrIn' v p
  = localV
  $ do
      vv <- vectBndr v
      x  <- p vv
      return (vv, x)

175
vectBndrsIn :: [Var] -> VM a -> VM ([VVar], a)
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
176
177
178
vectBndrsIn vs p
  = localV
  $ do
179
      vvs <- mapM vectBndr vs
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
180
      x <- p
181
      return (vvs, x)
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
182

rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
183
-- ----------------------------------------------------------------------------
184
185
-- Expressions

186
187
vectVar :: Var -> VM VExpr
vectVar v
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
188
189
190
  = do
      r <- lookupVar v
      case r of
191
192
193
        Local (vv,lv) -> return (Var vv, Var lv)
        Global vv     -> do
                           let vexpr = Var vv
194
                           lexpr <- liftPA vexpr
195
                           return (vexpr, lexpr)
196

197
198
vectPolyVar :: Var -> [Type] -> VM VExpr
vectPolyVar v tys
199
  = do
200
      vtys <- mapM vectType tys
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
201
      r <- lookupVar v
202
      case r of
203
204
205
206
        Local (vv, lv) -> liftM2 (,) (polyApply (Var vv) vtys)
                                     (polyApply (Var lv) vtys)
        Global poly    -> do
                            vexpr <- polyApply (Var poly) vtys
207
                            lexpr <- liftPA vexpr
208
                            return (vexpr, lexpr)
209

210
211
vectLiteral :: Literal -> VM VExpr
vectLiteral lit
212
  = do
213
      lexpr <- liftPA (Lit lit)
214
215
      return (Lit lit, lexpr)

216
vectPolyExpr :: CoreExprWithFVs -> VM VExpr
217
218
vectPolyExpr (_, AnnNote note expr)
  = liftM (vNote note) $ vectPolyExpr expr
219
vectPolyExpr expr
220
  = polyAbstract tvs $ \abstract ->
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
221
    do
222
      mono' <- vectExpr mono
223
      return $ mapVect abstract mono'
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
224
  where
Ian Lynagh's avatar
Ian Lynagh committed
225
226
    (tvs, mono) = collectAnnTypeBinders expr

227
228
vectExpr :: CoreExprWithFVs -> VM VExpr
vectExpr (_, AnnType ty)
229
  = liftM vType (vectType ty)
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
230

231
vectExpr (_, AnnVar v) = vectVar v
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
232

233
vectExpr (_, AnnLit lit) = vectLiteral lit
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
234

235
236
vectExpr (_, AnnNote note expr)
  = liftM (vNote note) (vectExpr expr)
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
237

238
vectExpr e@(_, AnnApp _ arg)
239
  | isAnnTypeArg arg
240
  = vectTyAppExpr fn tys
241
242
  where
    (fn, tys) = collectAnnTypeArgs e
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
243

244
245
246
247
248
249
250
251
252
vectExpr (_, AnnApp (_, AnnVar v) (_, AnnLit lit))
  | Just con <- isDataConId_maybe v
  , is_special_con con
  = do
      let vexpr = App (Var v) (Lit lit)
      lexpr <- liftPA vexpr
      return (vexpr, lexpr)
  where
    is_special_con con = con `elem` [intDataCon, floatDataCon, doubleDataCon]
Ian Lynagh's avatar
Ian Lynagh committed
253

254

255
vectExpr (_, AnnApp fn arg)
256
  = do
257
258
259
260
261
262
263
      arg_ty' <- vectType arg_ty
      res_ty' <- vectType res_ty
      fn'     <- vectExpr fn
      arg'    <- vectExpr arg
      mkClosureApp arg_ty' res_ty' fn' arg'
  where
    (arg_ty, res_ty) = splitFunTy . exprType $ deAnnotate fn
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
264

265
vectExpr (_, AnnCase scrut bndr ty alts)
266
267
268
  | Just (tycon, ty_args) <- splitTyConApp_maybe scrut_ty
  , isAlgTyCon tycon
  = vectAlgCase tycon ty_args scrut bndr ty alts
269
270
271
  where
    scrut_ty = exprType (deAnnotate scrut)

272
vectExpr (_, AnnCase expr bndr ty alts)
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
273
  = panic "vectExpr: case"
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
274

275
vectExpr (_, AnnLet (AnnNonRec bndr rhs) body)
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
276
  = do
277
278
      vrhs <- localV . inBind bndr $ vectPolyExpr rhs
      (vbndr, vbody) <- vectBndrIn bndr (vectExpr body)
279
      return $ vLet (vNonRec vbndr vrhs) vbody
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
280

281
vectExpr (_, AnnLet (AnnRec bs) body)
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
282
  = do
283
284
      (vbndrs, (vrhss, vbody)) <- vectBndrsIn bndrs
                                $ liftM2 (,)
285
                                  (zipWithM vect_rhs bndrs rhss)
286
                                  (vectPolyExpr body)
287
      return $ vLet (vRec vbndrs vrhss) vbody
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
288
  where
289
    (bndrs, rhss) = unzip bs
rl@cse.unsw.edu.au's avatar
rl@cse.unsw.edu.au committed
290

291
292
    vect_rhs bndr rhs = localV
                      . inBind bndr
293
                      $ vectExpr rhs
294

295
vectExpr e@(fvs, AnnLam bndr _)
296
  | not (isId bndr) = pprPanic "vectExpr" (ppr $ deAnnotate e)
297
  | otherwise = vectLam fvs bs body
298
299
  where
    (bs,body) = collectAnnValBinders e
300

301
302
vectExpr e = pprPanic "vectExpr" (ppr $ deAnnotate e)

303
304
vectLam :: VarSet -> [Var] -> CoreExprWithFVs -> VM VExpr
vectLam fvs bs body
305
  = do
306
      tyvars <- localTyVars
307
308
309
      (vs, vvs) <- readLEnv $ \env ->
                   unzip [(var, vv) | var <- varSetElems fvs
                                    , Just vv <- [lookupVarEnv (local_vars env) var]]
310

311
312
313
      arg_tys <- mapM (vectType . idType) bs
      res_ty  <- vectType (exprType $ deAnnotate body)

314
      buildClosures tyvars vvs arg_tys res_ty
315
        . hoistPolyVExpr tyvars
316
        $ do
317
            lc <- builtin liftingContext
318
            (vbndrs, vbody) <- vectBndrsIn (vs ++ bs)
319
                                           (vectExpr body)
320
            return $ vLams lc vbndrs vbody
Ian Lynagh's avatar
Ian Lynagh committed
321

322
323
324
vectTyAppExpr :: CoreExprWithFVs -> [Type] -> VM VExpr
vectTyAppExpr (_, AnnVar v) tys = vectPolyVar v tys
vectTyAppExpr e tys = pprPanic "vectTyAppExpr" (ppr $ deAnnotate e)
325

326
327
328
329
330
331
332
333
type CoreAltWithFVs = AnnAlt Id VarSet

-- We convert
--
--   case e :: t of v { ... }
--
-- to
--
334
335
--   V:    let v' = e in case v' of _ { ... }
--   L:    let v' = e in case v' `cast` ... of _ { ... }
336
337
--
-- When lifting, we have to do it this way because v must have the type
338
339
-- [:V(T):] but the scrutinee must be cast to the representation type. We also
-- have to handle the case where v is a wild var correctly.
Ian Lynagh's avatar
Ian Lynagh committed
340
--
341
342

-- FIXME: this is too lazy
343
vectAlgCase tycon ty_args scrut bndr ty [(DEFAULT, [], body)]
344
345
346
347
348
349
350
  = do
      vscrut <- vectExpr scrut
      vty    <- vectType ty
      lty    <- mkPArrayType vty
      (vbndr, vbody) <- vectBndrIn bndr (vectExpr body)
      return $ vCaseDEFAULT vscrut vbndr vty lty vbody

351
352
353
354
355
356
357
358
vectAlgCase tycon ty_args scrut bndr ty [(DataAlt dc, [], body)]
  = do
      vscrut <- vectExpr scrut
      vty    <- vectType ty
      lty    <- mkPArrayType vty
      (vbndr, vbody) <- vectBndrIn bndr (vectExpr body)
      return $ vCaseDEFAULT vscrut vbndr vty lty vbody

359
vectAlgCase tycon ty_args scrut bndr ty [(DataAlt dc, bndrs, body)]
360
  = do
361
      vect_tc <- maybeV (lookupTyCon tycon)
362
363
364
      vty <- vectType ty
      lty <- mkPArrayType vty
      vexpr <- vectExpr scrut
365
      (vbndr, (vbndrs, vbody)) <- vect_scrut_bndr
366
367
368
369
370
371
                                . vectBndrsIn bndrs
                                $ vectExpr body

      (vscrut, arr_tc, arg_tys) <- mkVScrut (vVar vbndr)
      vect_dc <- maybeV (lookupDataCon dc)
      let [arr_dc] = tyConDataCons arr_tc
372
373
      repr <- mkRepr vect_tc
      shape_bndrs <- arrShapeVars repr
374
375
      return . vLet (vNonRec vbndr vexpr)
             $ vCaseProd vscrut vty lty vect_dc arr_dc shape_bndrs vbndrs vbody
376
  where
Ian Lynagh's avatar
Ian Lynagh committed
377
    vect_scrut_bndr | isDeadBinder bndr = vectBndrNewIn bndr (fsLit "scrut")
378
379
                    | otherwise         = vectBndrIn bndr

380
381
382
383
384
385
386
387
388
389
vectAlgCase tycon ty_args scrut bndr ty alts
  = do
      vect_tc <- maybeV (lookupTyCon tycon)
      vty               <- vectType ty
      lty               <- mkPArrayType vty

      repr        <- mkRepr vect_tc
      shape_bndrs <- arrShapeVars repr
      (len, sel, indices) <- arrSelector repr (map Var shape_bndrs)

390
      (vbndr, valts) <- vect_scrut_bndr $ mapM (proc_alt sel vty lty) alts'
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
      let (vect_dcs, vect_bndrss, lift_bndrss, vbodies) = unzip4 valts

      vexpr <- vectExpr scrut
      (vscrut, arr_tc, arg_tys) <- mkVScrut (vVar vbndr)
      let [arr_dc] = tyConDataCons arr_tc

      let (vect_scrut,  lift_scrut)  = vscrut
          (vect_bodies, lift_bodies) = unzip vbodies

      let vect_case = Case vect_scrut (mkWildId (exprType vect_scrut)) vty
                           (zipWith3 mk_vect_alt vect_dcs vect_bndrss vect_bodies)

      lbody <- combinePA vty len sel indices lift_bodies
      let lift_case = Case lift_scrut (mkWildId (exprType lift_scrut)) lty
                           [(DataAlt arr_dc, shape_bndrs ++ concat lift_bndrss,
                             lbody)]

      return . vLet (vNonRec vbndr vexpr)
             $ (vect_case, lift_case)
  where
Ian Lynagh's avatar
Ian Lynagh committed
411
    vect_scrut_bndr | isDeadBinder bndr = vectBndrNewIn bndr (fsLit "scrut")
412
413
414
415
416
417
418
419
420
                    | otherwise         = vectBndrIn bndr

    alts' = sortBy (\(alt1, _, _) (alt2, _, _) -> cmp alt1 alt2) alts

    cmp (DataAlt dc1) (DataAlt dc2) = dataConTag dc1 `compare` dataConTag dc2
    cmp DEFAULT       DEFAULT       = EQ
    cmp DEFAULT       _             = LT
    cmp _             DEFAULT       = GT

421
    proc_alt sel vty lty (DataAlt dc, bndrs, body)
422
423
424
425
426
427
      = do
          vect_dc <- maybeV (lookupDataCon dc)
          let tag = mkDataConTag vect_dc
              fvs = freeVarsOf body `delVarSetList` bndrs
          (vect_bndrs, lift_bndrs, vbody)
            <- vect_alt_bndrs bndrs
428
             $ \len -> packLiftingContext len sel tag fvs vty lty
429
430
431
432
433
434
435
436
437
             $ vectExpr body

          return (vect_dc, vect_bndrs, lift_bndrs, vbody)

    vect_alt_bndrs [] p
      = do
          void_tc <- builtin voidTyCon
          let void_ty = mkTyConApp void_tc []
          arr_ty <- mkPArrayType void_ty
Ian Lynagh's avatar
Ian Lynagh committed
438
          bndr   <- newLocalVar (fsLit "voids") arr_ty
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
          len    <- lengthPA void_ty (Var bndr)
          e      <- p len
          return ([], [bndr], e)

    vect_alt_bndrs bndrs p
       = localV
       $ do
           vbndrs <- mapM vectBndr bndrs
           let (vect_bndrs, lift_bndrs) = unzip vbndrs
               vv : _ = vect_bndrs
               lv : _ = lift_bndrs
           len <- lengthPA (idType vv) (Var lv)
           e   <- p len
           return (vect_bndrs, lift_bndrs, e)

    mk_vect_alt vect_dc bndrs body = (DataAlt vect_dc, bndrs, body)

456
457
458
packLiftingContext :: CoreExpr -> CoreExpr -> CoreExpr -> VarSet
                   -> Type -> Type -> VM VExpr -> VM VExpr
packLiftingContext len shape tag fvs vty lty p
459
460
461
  = do
      select <- builtin selectPAIntPrimVar
      let sel_expr = mkApps (Var select) [shape, tag]
Ian Lynagh's avatar
Ian Lynagh committed
462
      sel_var <- newLocalVar (fsLit "sel#") (exprType sel_expr)
463
464
465
      lc_var <- builtin liftingContext
      localV $
        do
466
467
468
          bnds <- mapM (packFreeVar (Var lc_var) (Var sel_var))
                . filter isLocalId
                $ varSetElems fvs
469
          (vexpr, lexpr) <- p
470
          empty <- emptyPA vty
471
          return (vexpr, Let (NonRec sel_var sel_expr)
472
                         $ Case len lc_var lty
473
                             [(DEFAULT, [], mkLets (concat bnds) lexpr),
474
                              (LitAlt (mkMachInt 0), [], empty)])
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491

packFreeVar :: CoreExpr -> CoreExpr -> Var -> VM [CoreBind]
packFreeVar len sel v
  = do
      r <- lookupVar v
      case r of
        Local (vv,lv) ->
          do
            lv' <- cloneVar lv
            expr <- packPA (idType vv) (Var lv) len sel
            updLEnv (upd vv lv')
            return [(NonRec lv' expr)]

        _  -> return []
  where
    upd vv lv' env = env { local_vars = extendVarEnv (local_vars env) v (vv, lv') }