futhark-0.20.3: An optimising compiler for a functional, array-oriented language.
Safe HaskellTrustworthy
LanguageHaskell2010

Futhark.CodeGen.Backends.SimpleRep

Description

Simple C runtime representation.

Most types use the same memory and scalar variable representation. For those that do not (as of this writing, only Float16), we use primStorageType for the array element representation, and primTypeToCType for their scalar representation. Use toStorage and fromStorage to convert back and forth.

Synopsis

Documentation

tupleField :: Int -> String Source #

tupleField i is the name of field number i in a tuple.

funName :: Name -> String Source #

funName f is the name of the C function corresponding to the Futhark function f.

defaultMemBlockType :: Type Source #

The type of memory blocks in the default memory space.

intTypeToCType :: IntType -> Type Source #

The C type corresponding to a signed integer type.

primTypeToCType :: PrimType -> Type Source #

The C type corresponding to a primitive type. Integers are assumed to be unsigned.

primStorageType :: PrimType -> Type Source #

The C storage type for arrays of this primitive type.

primAPIType :: Signedness -> PrimType -> Type Source #

The C API corresponding to a primitive type. Integers are assumed to have the specified sign.

arrayName :: PrimType -> Signedness -> Int -> String Source #

The name of exposed array type structs.

opaqueName :: String -> [ValueDesc] -> String Source #

The name of exposed opaque types.

toStorage :: PrimType -> Exp -> Exp Source #

Convert from scalar to storage representation for the given type.

fromStorage :: PrimType -> Exp -> Exp Source #

Convert from storage to scalar representation for the given type.

cproduct :: [Exp] -> Exp Source #

Return an expression multiplying together the given expressions. If an empty list is given, the expression 1 is returned.

csum :: [Exp] -> Exp Source #

Return an expression summing the given expressions. If an empty list is given, the expression 0 is returned.

scalarToPrim :: Text -> (Signedness, PrimType) Source #

The PrimType (and sign) correspond to a human-readable scalar type name (e.g. f64). Beware: partial!

Primitive value operations

cScalarDefs :: Text Source #

Implementations of scalar operations.

Storing/restoring values in byte sequences

Orphan instances

ToIdent Text Source # 
Instance details

Methods

toIdent :: Text -> SrcLoc -> Id #

ToIdent VName Source # 
Instance details

Methods

toIdent :: VName -> SrcLoc -> Id #

ToIdent Name Source # 
Instance details

Methods

toIdent :: Name -> SrcLoc -> Id #

ToExp PrimValue Source # 
Instance details

Methods

toExp :: PrimValue -> SrcLoc -> Exp #

ToExp FloatValue Source # 
Instance details

Methods

toExp :: FloatValue -> SrcLoc -> Exp #

ToExp IntValue Source # 
Instance details

Methods

toExp :: IntValue -> SrcLoc -> Exp #

ToExp VName Source # 
Instance details

Methods

toExp :: VName -> SrcLoc -> Exp #

ToExp SubExp Source # 
Instance details

Methods

toExp :: SubExp -> SrcLoc -> Exp #