ghc-8.2.2: The GHC API

Safe Haskell | None
Language | Haskell2010

RepType

Contents

- Code generator views onto Types
- Predicates on types
- Type representation for the code generator
- Unboxed sum representation type

Synopsis

- type UnaryType = Type
- type NvUnaryType = Type
- isNvUnaryType :: Type -> Bool
- unwrapType :: Type -> Type
- isVoidTy :: Type -> Bool
- typePrimRep :: HasDebugCallStack => Type -> [PrimRep]
- typePrimRep1 :: HasDebugCallStack => UnaryType -> PrimRep
- runtimeRepPrimRep :: HasDebugCallStack => SDoc -> Type -> [PrimRep]
- typePrimRepArgs :: Type -> [PrimRep]
- data PrimRep
  - = VoidRep
  - | LiftedRep
  - | UnliftedRep
  - | IntRep
  - | WordRep
  - | Int64Rep
  - | Word64Rep
  - | AddrRep
  - | FloatRep
  - | DoubleRep
  - | VecRep Int PrimElemRep
- primRepToType :: PrimRep -> Type
- countFunRepArgs :: Arity -> Type -> RepArity
- countConRepArgs :: DataCon -> RepArity
- tyConPrimRep :: HasDebugCallStack => TyCon -> [PrimRep]
- tyConPrimRep1 :: HasDebugCallStack => TyCon -> PrimRep
- ubxSumRepType :: [[PrimRep]] -> [SlotTy]
- layoutUbxSum :: SortedSlotTys -> [SlotTy] -> [Int]
- typeSlotTy :: UnaryType -> Maybe SlotTy
- data SlotTy
  - = PtrSlot
  - | WordSlot
  - | Word64Slot
  - | FloatSlot
  - | DoubleSlot
- slotPrimRep :: SlotTy -> PrimRep
- primRepSlot :: PrimRep -> SlotTy

# Code generator views onto Types

type UnaryType = Type #

type NvUnaryType = Type #

isNvUnaryType :: Type -> Bool #

unwrapType :: Type -> Type #

Gets rid of the stuff that prevents us from understanding the runtime representation of a type. Including: 1. Casts 2. Newtypes 3. Foralls 4. Synonyms But not type/data families, because we don't have the envs to hand.

# Predicates on types

isVoidTy :: Type -> Bool #

True if the type has zero width.

# Type representation for the code generator

typePrimRep :: HasDebugCallStack => Type -> [PrimRep] #

Discovers the primitive representation of a `Type`. Returns a list of `PrimRep`: it's a list because of the possibility of no runtime representation (void) or multiple (unboxed tuple/sum)

typePrimRep1 :: HasDebugCallStack => UnaryType -> PrimRep #

Like `typePrimRep`, but assumes that there is precisely one `PrimRep` output; an empty list of PrimReps becomes a VoidRep

runtimeRepPrimRep :: HasDebugCallStack => SDoc -> Type -> [PrimRep] #

Take a type of kind RuntimeRep and extract the list of `PrimRep` that it encodes.

typePrimRepArgs :: Type -> [PrimRep] #

data PrimRep #

A `PrimRep` is an abstraction of a type. It contains information that the code generator needs in order to pass arguments, return results, and store values of this type.

Constructors

VoidRep |
LiftedRep |
UnliftedRep | Unlifted pointer
IntRep | Signed, word-sized value
WordRep | Unsigned, word-sized value
Int64Rep | Signed, 64 bit value (with 32-bit words only)
Word64Rep | Unsigned, 64 bit value (with 32-bit words only)
AddrRep | A pointer, but not to a Haskell value (use '(Un)liftedRep')
FloatRep |
DoubleRep |
VecRep Int PrimElemRep | A vector

Instances

Eq PrimRep # |
Methods (==) :: PrimRep -> PrimRep -> Bool # (/=) :: PrimRep -> PrimRep -> Bool #
Show PrimRep # |
Methods showsPrec :: Int -> PrimRep -> ShowS Source # show :: PrimRep -> String Source # showList :: [PrimRep] -> ShowS Source #
Outputable PrimRep # |
Methods ppr :: PrimRep -> SDoc # pprPrec :: Rational -> PrimRep -> SDoc #

primRepToType :: PrimRep -> Type #

Convert a PrimRep back to a Type. Used only in the unariser to give types to fresh Ids. Really, only the type's representation matters.

countFunRepArgs :: Arity -> Type -> RepArity #

countConRepArgs :: DataCon -> RepArity #

tyConPrimRep :: HasDebugCallStack => TyCon -> [PrimRep] #

Find the runtime representation of a `TyCon`. Defined here to avoid module loops. Returns a list of the register shapes necessary.

tyConPrimRep1 :: HasDebugCallStack => TyCon -> PrimRep #

Like `tyConPrimRep`, but assumed that there is precisely zero or one `PrimRep` output

# Unboxed sum representation type

ubxSumRepType :: [[PrimRep]] -> [SlotTy] #

Given the arguments of a sum type constructor application, return the unboxed sum rep type.

E.g.

( | Maybe Int | (, Float) #)

We call `ubxSumRepType [ [IntRep], [LiftedRep], [IntRep, FloatRep] ]`, which returns [WordSlot, PtrSlot, WordSlot, FloatSlot]

INVARIANT: Result slots are sorted (via Ord SlotTy), except that at the head of the list we have the slot for the tag.

layoutUbxSum :: SortedSlotTys -> [SlotTy] -> [Int] #

typeSlotTy :: UnaryType -> Maybe SlotTy #

data SlotTy #

Constructors

PtrSlot |
WordSlot |
Word64Slot |
FloatSlot |
DoubleSlot |

Instances

Eq SlotTy # |
Methods (==) :: SlotTy -> SlotTy -> Bool # (/=) :: SlotTy -> SlotTy -> Bool #
Ord SlotTy # |
Methods compare :: SlotTy -> SlotTy -> Ordering # (<) :: SlotTy -> SlotTy -> Bool # (<=) :: SlotTy -> SlotTy -> Bool # (>) :: SlotTy -> SlotTy -> Bool # (>=) :: SlotTy -> SlotTy -> Bool # max :: SlotTy -> SlotTy -> SlotTy # min :: SlotTy -> SlotTy -> SlotTy #
Outputable SlotTy # |
Methods ppr :: SlotTy -> SDoc # pprPrec :: Rational -> SlotTy -> SDoc #

slotPrimRep :: SlotTy -> PrimRep #

primRepSlot :: PrimRep -> SlotTy #