Vectorise.Generic.Description

ghc-8.2.2: The GHC API

Safe Haskell | None
Language | Haskell2010

Vectorise.Generic.Description

Description

Compute a description of the generic representation that we use for a user defined data type.

During vectorisation, we generate a PRepr and PA instance for each user defined data type. The PA dictionary contains methods to convert the user type to and from our generic representation. This module computes a description of what that generic representation is.

Synopsis

- data CompRepr
  - = Keep Type CoreExpr
  - | Wrap Type
- data ProdRepr
  - = EmptyProd
  - | UnaryProd CompRepr
  - | Prod {
    - repr_tup_tc :: TyCon
    - repr_ptup_tc :: TyCon
    - repr_ptups_tc :: TyCon
    - repr_comp_tys :: [Type]
    - repr_comps :: [CompRepr]
    }
- data ConRepr = ConRepr {
  - repr_dc :: DataCon
  - repr_prod :: ProdRepr
  }
- data SumRepr
  - = EmptySum
  - | UnarySum ConRepr
  - | Sum {
    - repr_sum_tc :: TyCon
    - repr_psum_tc :: TyCon
    - repr_psums_tc :: TyCon
    - repr_sel_ty :: Type
    - repr_sels_ty :: Type
    - repr_selsLength_v :: CoreExpr
    - repr_con_tys :: [Type]
    - repr_cons :: [ConRepr]
    }
- tyConRepr :: TyCon -> VM SumRepr
- sumReprType :: SumRepr -> VM Type
- compOrigType :: CompRepr -> Type

# Documentation

data CompRepr Source #

Describes the representation type of a data constructor field.

Constructors

Keep Type CoreExpr |
Wrap Type |

Instances

Outputable CompRepr # |
Methods ppr :: CompRepr -> SDoc Source # pprPrec :: Rational -> CompRepr -> SDoc Source #

data ProdRepr Source #

Describes the representation type of the fields / components of a constructor. If the data constructor has multiple fields then we bundle them together into a generic product type.

Constructors

EmptyProd | Data constructor has no fields.
UnaryProd CompRepr | Data constructor has a single field.
Prod | Data constructor has several fields.
Fields repr_tup_tc :: TyCon Representation tycon for the product (eg Tuple2) repr_ptup_tc :: TyCon PData version of the product tycon (eg PDataTuple2) repr_ptups_tc :: TyCon PDatas version of the product tycon (eg PDatasTuple2s) Not all lifted backends use `PDatas`. repr_comp_tys :: [Type] Types of each field. repr_comps :: [CompRepr] Generic representation types for each field.

Instances

Outputable ProdRepr # |
Methods ppr :: ProdRepr -> SDoc Source # pprPrec :: Rational -> ProdRepr -> SDoc Source #

data ConRepr Source #

Describes the representation type of a data constructor.

Constructors

ConRepr |
Fields repr_dc :: DataCon repr_prod :: ProdRepr

Instances

Outputable ConRepr # |
Methods ppr :: ConRepr -> SDoc Source # pprPrec :: Rational -> ConRepr -> SDoc Source #

data SumRepr Source #

Describes the generic representation of a data type. If the data type has multiple constructors then we bundle them together into a generic sum type.

Constructors

EmptySum | Data type has no data constructors.
UnarySum ConRepr | Data type has a single constructor.
Sum | Data type has multiple constructors.
Fields repr_sum_tc :: TyCon Representation tycon for the sum (eg Sum2) repr_psum_tc :: TyCon PData version of the sum tycon (eg PDataSum2) This TyCon doesn't appear explicitly in the source program. See Note [PData TyCons]. repr_psums_tc :: TyCon PDatas version of the sum tycon (eg PDatasSum2) repr_sel_ty :: Type Type of the selector (eg Sel2) repr_sels_ty :: Type Type of multi-selector (eg Sel2s) repr_selsLength_v :: CoreExpr Function to get the length of a Sels of this type. repr_con_tys :: [Type] Type of each data constructor. repr_cons :: [ConRepr] Generic representation types of each data constructor.

Instances

Outputable SumRepr # |
Methods ppr :: SumRepr -> SDoc Source # pprPrec :: Rational -> SumRepr -> SDoc Source #

tyConRepr :: TyCon -> VM SumRepr Source #

Determine the generic representation of a data type, given its tycon.

sumReprType :: SumRepr -> VM Type Source #

Yield the type of this sum representation.

compOrigType :: CompRepr -> Type Source #

Yield the original component type of a data constructor component representation.