ghc-7.4.2: The GHC API

Safe Haskell | None

Vectorise.Env

Contents

- Local Environments
- Global Environments

Synopsis

- data Scope a b
  - = Global a
  - | Local b
- data LocalEnv = LocalEnv {
  - local_vars :: VarEnv (Var, Var)
  - local_tyvars :: [TyVar]
  - local_tyvar_pa :: VarEnv CoreExpr
  - local_bind_name :: FastString
  }
- emptyLocalEnv :: LocalEnv
- data GlobalEnv = GlobalEnv {
  - global_vars :: VarEnv Var
  - global_vect_decls :: VarEnv (Type, CoreExpr)
  - global_scalar_vars :: VarSet
  - global_scalar_tycons :: NameSet
  - global_novect_vars :: VarSet
  - global_tycons :: NameEnv TyCon
  - global_datacons :: NameEnv DataCon
  - global_pa_funs :: NameEnv Var
  - global_pr_funs :: NameEnv Var
  - global_inst_env :: (InstEnv, InstEnv)
  - global_fam_inst_env :: FamInstEnvs
  - global_bindings :: [(Var, CoreExpr)]
  }
- initGlobalEnv :: VectInfo -> [CoreVect] -> (InstEnv, InstEnv) -> FamInstEnvs -> GlobalEnv
- extendImportedVarsEnv :: [(Var, Var)] -> GlobalEnv -> GlobalEnv
- extendFamEnv :: [FamInst] -> GlobalEnv -> GlobalEnv
- setPAFunsEnv :: [(Name, Var)] -> GlobalEnv -> GlobalEnv
- setPRFunsEnv :: [(Name, Var)] -> GlobalEnv -> GlobalEnv
- modVectInfo :: GlobalEnv -> [Id] -> [TyCon] -> [CoreVect] -> VectInfo -> VectInfo

# Documentation

data Scope a b

Indicates what scope something (a variable) is in.

Constructors

Global a |
Local b |

# Local Environments

data LocalEnv

The local environment.

Constructors

LocalEnv |

Fields

local_vars :: VarEnv (Var, Var)
local_tyvars :: [TyVar]
local_tyvar_pa :: VarEnv CoreExpr
local_bind_name :: FastString

emptyLocalEnv :: LocalEnv

Create an empty local environment.

# Global Environments

data GlobalEnv

The global environment: entities that exist at top-level.

Constructors

GlobalEnv |

Fields

global_vars :: VarEnv Var

  Mapping from global variables to their vectorised versions — aka the /vectorisation map/.

global_vect_decls :: VarEnv (Type, CoreExpr)

  Mapping from global variables that have a vectorisation declaration to the right-hand side of that declaration and its type. This mapping only applies to non-scalar vectorisation declarations. All variables with a scalar vectorisation declaration are mentioned in `global_scalars_vars`.

global_scalar_vars :: VarSet

  Purely scalar variables. Code which mentions only these variables doesn't have to be lifted. This includes variables from the current module that have a scalar vectorisation declaration and those that the vectoriser determines to be scalar.

global_scalar_tycons :: NameSet

  Type constructors whose values can only contain scalar data. This includes type constructors that appear in a 'VECTORISE SCALAR type' pragma or 'VECTORISE type' pragma *without* a right-hand side in the current or an imported module as well as type constructors that are automatically identified as scalar by the vectoriser (in `Env`). Scalar code may only operate on such data.

  NB: Not all type constructors in that set are members of the `Scalar` type class (which can be trivially marshalled across scalar code boundaries).

global_novect_vars :: VarSet

  Variables that are not vectorised. (They may be referenced in the right-hand sides of vectorisation declarations, though.)

global_tycons :: NameEnv TyCon

  Mapping from TyCons to their vectorised versions. TyCons which do not have to be vectorised are mapped to themselves.

global_datacons :: NameEnv DataCon

  Mapping from DataCons to their vectorised versions.

global_pa_funs :: NameEnv Var

  Mapping from TyCons to their PA dfuns.

global_pr_funs :: NameEnv Var

  Mapping from TyCons to their PR dfuns.

global_inst_env :: (InstEnv, InstEnv)

  External package inst-env & home-package inst-env for class instances.

global_fam_inst_env :: FamInstEnvs

  External package inst-env & home-package inst-env for family instances.

global_bindings :: [(Var, CoreExpr)]

  Hoisted bindings.

initGlobalEnv :: VectInfo -> [CoreVect] -> (InstEnv, InstEnv) -> FamInstEnvs -> GlobalEnv

Create an initial global environment.

We add scalar variables and type constructors identified by vectorisation pragmas already here to the global table, so that we can query scalarness during vectorisation, and especially, when vectorising the scalar entities' definitions themselves.

extendImportedVarsEnv :: [(Var, Var)] -> GlobalEnv -> GlobalEnv

Extend the list of global variables in an environment.

extendFamEnv :: [FamInst] -> GlobalEnv -> GlobalEnv

Extend the list of type family instances.

setPAFunsEnv :: [(Name, Var)] -> GlobalEnv -> GlobalEnv

Set the list of PA functions in an environment.

setPRFunsEnv :: [(Name, Var)] -> GlobalEnv -> GlobalEnv

Set the list of PR functions in an environment.

modVectInfo :: GlobalEnv -> [Id] -> [TyCon] -> [CoreVect] -> VectInfo -> VectInfo

Compute vectorisation information that goes into `ModGuts` (and is stored in interface files). The incoming `vectInfo` is that from the `HscEnv` and `EPS`. The outgoing one contains only the declarations for the currently compiled module; this includes variables, type constructors, and data constructors referenced in VECTORISE pragmas, even if they are defined in an imported module.

The variables explicitly include class selectors and dfuns.